gfse: more readable layout for not so simple grammars + bug fix

To make definitions that span multiple lines more readable in guided mode,
preserve line breaks and indentation when lin and oper definitions are
displayed and edited in guided mode.

Bug fix: moving the cursor by clicking and selecting text by dragging did
not work in textareas and input fields, because those mouse event were
intercepted by the sort-by-drag-and-drop handler.
This commit is contained in:
hallgren
2012-11-26 14:11:12 +00:00
parent 18c8ff3579
commit 818faee27e
2 changed files with 17 additions and 5 deletions

View File

@@ -77,6 +77,9 @@ div.template:hover
tr.deletable:hover .delete
{ visibility: visible; }
.editable { white-space: pre; }
div.lin span.editable { display: inline-block; vertical-align: top; }
.more { color: green; }
.edit { color: orange; }
.delete { color: red; }
@@ -110,7 +113,8 @@ table.tabs input[type=button], table.matrixview th input[type=button] {
/*text-decoration: underline;*/
}
input.string_edit { font-family: inherit; font-size: inherit; }
.string_edit { font-family: inherit; font-size: inherit; }
textarea.string_edit { vertical-align: top; }
ul.languages { -moz-column-width: 20em; }

View File

@@ -1798,9 +1798,16 @@ function string_editor(el,init,ok,async) {
e.it.focus();
}
var m=empty_class("span","error_message");
var i=node("input",{"class":"string_edit",name:"it",value:init},[]);
if(init.length>10) i.size=init.length+5;
// var i=node("textarea",{name:"it",rows:"2",cols:"60"},[text(init)]);
if(init.indexOf("\n")>=0) {
var rows=init.split("\n").length+1
var i=node("textarea",{"class":"string_edit",name:"it",
rows:rows,cols:"80"},
[text(init)]);
}
else {
var i=node("input",{"class":"string_edit",name:"it",value:init},[]);
if(init.length>10) i.size=init.length+5;
}
var e=node("form",{},
[i,
text(" "),
@@ -1996,7 +2003,8 @@ if(editor) {
initial_view();
touch_edit();
dir_bugfix();
initialize_sorting(["DIV"],["fun","lin","lincat","oper"]);
initialize_sorting(["DIV","INPUT","TEXTAREA"],
["fun","lin","lincat","oper"]);
}
else
editor.innerHTML="<p>This browser does not appear to support localStorage, and the grammar editor does not work without it. Sorry!"