" + hightlighted_text + "";
- else
- new_Obj.innerHTML= ""+ hightlighted_text +"";
-
- t.content_highlight.parentNode.replaceChild(new_Obj, t.content_highlight);
-
- t.content_highlight= new_Obj;
- }
-
- t.last_text_to_highlight= infos["full_text"];
- t.last_hightlighted_text= hightlighted_text;
-
- tps3=new Date().getTime();
-
- if(t.settings["debug"]){
- //lineNumber=tab_text.length;
- //t.debug.value+=" \nNB char: "+_$("src").value.length+" Nb line: "+ lineNumber;
-
- t.debug.value= "Tps optimisation "+(tps_end_opti-tps_start)
- +" | tps reg exp: "+ (tpsAfterReg-tps_end_opti)
- +" | tps opti HTML : "+ (tpsAfterOpti2-tpsAfterReg) + ' '+ ( doHtmlOpti ? 'yes' : 'no' )
- +" | tps update highlight content: "+ (tps3-tpsAfterOpti2)
- +" | tpsTotal: "+ (tps3-tps_start)
- + "("+tps3+")\n"+ debug_opti;
- // t.debug.value+= "highlight\n"+hightlighted_text;*/
- }
-
- };
-
- EditArea.prototype.resync_highlight= function(reload_now){
- this.reload_highlight=true;
- this.last_text_to_highlight="";
- this.focus();
- if(reload_now)
- this.check_line_selection(false);
- };
+ // change_to: "on" or "off"
+ EditArea.prototype.change_highlight= function(change_to){
+ if(this.settings["syntax"].length==0 && change_to==false){
+ this.switchClassSticky(_$("highlight"), 'editAreaButtonDisabled', true);
+ this.switchClassSticky(_$("reset_highlight"), 'editAreaButtonDisabled', true);
+ return false;
+ }
+
+ if(this.do_highlight==change_to)
+ return false;
+
+
+ this.getIESelection();
+ var pos_start= this.textarea.selectionStart;
+ var pos_end= this.textarea.selectionEnd;
+
+ if(this.do_highlight===true || change_to==false)
+ this.disable_highlight();
+ else
+ this.enable_highlight();
+ this.textarea.focus();
+ this.textarea.selectionStart = pos_start;
+ this.textarea.selectionEnd = pos_end;
+ this.setIESelection();
+
+ };
+
+ EditArea.prototype.disable_highlight= function(displayOnly){
+ var t= this, a=t.textarea, new_Obj, old_class, new_class;
+
+ t.selection_field.innerHTML="";
+ t.selection_field_text.innerHTML="";
+ t.content_highlight.style.visibility="hidden";
+ // replacing the node is far more faster than deleting it's content in firefox
+ new_Obj= t.content_highlight.cloneNode(false);
+ new_Obj.innerHTML= "";
+ t.content_highlight.parentNode.insertBefore(new_Obj, t.content_highlight);
+ t.content_highlight.parentNode.removeChild(t.content_highlight);
+ t.content_highlight= new_Obj;
+ old_class= parent.getAttribute( a,"class" );
+ if(old_class){
+ new_class= old_class.replace( "hidden","" );
+ parent.setAttribute( a, "class", new_class );
+ }
+
+ a.style.backgroundColor="transparent"; // needed in order to see the bracket finders
+
+ //var icon= document.getElementById("highlight");
+ //setAttribute(icon, "class", getAttribute(icon, "class").replace(/ selected/g, "") );
+ //t.restoreClass(icon);
+ //t.switchClass(icon,'editAreaButtonNormal');
+ t.switchClassSticky(_$("highlight"), 'editAreaButtonNormal', true);
+ t.switchClassSticky(_$("reset_highlight"), 'editAreaButtonDisabled', true);
+
+ t.do_highlight=false;
+
+ t.switchClassSticky(_$("change_smooth_selection"), 'editAreaButtonSelected', true);
+ if(typeof(t.smooth_selection_before_highlight)!="undefined" && t.smooth_selection_before_highlight===false){
+ t.change_smooth_selection_mode(false);
+ }
+
+ // this.textarea.style.backgroundColor="#FFFFFF";
+ };
+
+ EditArea.prototype.enable_highlight= function(){
+ var t=this, a=t.textarea, new_class;
+ t.show_waiting_screen();
+
+ t.content_highlight.style.visibility="visible";
+ new_class =parent.getAttribute(a,"class")+" hidden";
+ parent.setAttribute( a, "class", new_class );
+
+ // IE can't manage mouse click outside text range without this
+ if( t.isIE )
+ a.style.backgroundColor="#FFFFFF";
+
+ t.switchClassSticky(_$("highlight"), 'editAreaButtonSelected', false);
+ t.switchClassSticky(_$("reset_highlight"), 'editAreaButtonNormal', false);
+
+ t.smooth_selection_before_highlight=t.smooth_selection;
+ if(!t.smooth_selection)
+ t.change_smooth_selection_mode(true);
+ t.switchClassSticky(_$("change_smooth_selection"), 'editAreaButtonDisabled', true);
+
+
+ t.do_highlight=true;
+ t.resync_highlight();
+
+ t.hide_waiting_screen();
+ };
+
+ /**
+ * Ask to update highlighted text
+ * @param Array infos - Array of datas returned by EditArea.get_selection_infos()
+ */
+ EditArea.prototype.maj_highlight= function(infos){
+ // for speed mesure
+ var debug_opti="",tps_start= new Date().getTime(), tps_middle_opti=new Date().getTime();
+ var t=this, hightlighted_text, updated_highlight;
+ var textToHighlight=infos["full_text"], doSyntaxOpti = false, doHtmlOpti = false, stay_begin="", stay_end="", trace_new , trace_last;
+
+ if(t.last_text_to_highlight==infos["full_text"] && t.resync_highlight!==true)
+ return;
+
+ // OPTIMISATION: will search to update only changed lines
+ if(t.reload_highlight===true){
+ t.reload_highlight=false;
+ }else if(textToHighlight.length==0){
+ textToHighlight="\n ";
+ }else{
+ // get text change datas
+ changes = t.checkTextEvolution(t.last_text_to_highlight,textToHighlight);
+
+ // check if it can only reparse the changed text
+ trace_new = t.get_syntax_trace(changes.newTextLine).replace(/\r/g, '');
+ trace_last = t.get_syntax_trace(changes.lastTextLine).replace(/\r/g, '');
+ doSyntaxOpti = ( trace_new == trace_last );
+
+ // check if the difference comes only from a new line created
+ // => we have to remember that the editor can automaticaly add tabulation or space after the new line)
+ if( !doSyntaxOpti && trace_new == "\n"+trace_last && /^[ \t\s]*\n[ \t\s]*$/.test( changes.newText.replace(/\r/g, '') ) && changes.lastText =="" )
+ {
+ doSyntaxOpti = true;
+ }
+
+ // we do the syntax optimisation
+ if( doSyntaxOpti ){
+
+ tps_middle_opti=new Date().getTime();
+
+ stay_begin= t.last_hightlighted_text.split("\n").slice(0, changes.lineStart).join("\n");
+ if(changes.lineStart>0)
+ stay_begin+= "\n";
+ stay_end= t.last_hightlighted_text.split("\n").slice(changes.lineLastEnd+1).join("\n");
+ if(stay_end.length>0)
+ stay_end= "\n"+stay_end;
+
+ // Final check to see that we're not in the middle of span tags
+ if( stay_begin.split(' trace: "+trace_new
+ +"\nchanged_last_text: "+ch.lastText+" => trace: "+trace_last
+ //debug_opti+= "\nchanged: "+ infos["full_text"].substring(ch.posStart, ch.posNewEnd);
+ + "\nchanged_line: "+ch.newTextLine
+ + "\nlast_changed_line: "+ch.lastTextLine
+ +"\nstay_begin: "+ stay_begin.slice(-100)
+ +"\nstay_end: "+ stay_end.substr( 0, 100 );
+ //debug_opti="start: "+stay_begin_len+ "("+nb_line_start_unchanged+") end: "+ (stay_end_len)+ "("+(splited.length-nb_line_end_unchanged)+") ";
+ //debug_opti+="changed: "+ textToHighlight.substring(stay_begin_len, textToHighlight.length-stay_end_len)+" \n";
+
+ //debug_opti+="changed: "+ stay_begin.substr(stay_begin.length-200)+ "----------"+ textToHighlight+"------------------"+ stay_end.substr(0,200) +"\n";
+ +"\n";
+ }
+
+
+ // END OPTIMISATION
+ }
+
+ tps_end_opti = new Date().getTime();
+
+ // apply highlight
+ updated_highlight = t.colorize_text(textToHighlight);
+ tpsAfterReg = new Date().getTime();
+
+ /***
+ * see if we can optimize for updating only the required part of the HTML code
+ *
+ * The goal here will be to find the text node concerned by the modification and to update it
+ */
+ //-------------------------------------------
+
+ // disable latest optimization tricks (introduced in 0.8.1 and removed in 0.8.2), TODO: check for another try later
+ doSyntaxOpti = doHtmlOpti = false;
+ if( doSyntaxOpti )
+ {
+ try
+ {
+ var replacedBloc, i, nbStart = '', nbEnd = '', newHtml, lengthOld, lengthNew;
+ replacedBloc = t.last_hightlighted_text.substring( stay_begin.length, t.last_hightlighted_text.length - stay_end.length );
+
+ lengthOld = replacedBloc.length;
+ lengthNew = updated_highlight.length;
+
+ // find the identical caracters at the beginning
+ for( i=0; i < lengthOld && i < lengthNew && replacedBloc.charAt(i) == updated_highlight.charAt(i) ; i++ )
+ {
+ }
+ nbStart = i;
+ // find the identical caracters at the end
+ for( i=0; i + nbStart < lengthOld && i + nbStart < lengthNew && replacedBloc.charAt(lengthOld-i-1) == updated_highlight.charAt(lengthNew-i-1) ; i++ )
+ {
+ }
+ nbEnd = i;
+ //console.log( nbStart, nbEnd, replacedBloc, updated_highlight );
+ // get the changes
+ lastHtml = replacedBloc.substring( nbStart, lengthOld - nbEnd );
+ newHtml = updated_highlight.substring( nbStart, lengthNew - nbEnd );
+
+ // We can do the optimisation only if we havn't touch to span elements
+ if( newHtml.indexOf('').replace( /&/g, '&');
+
+ nbOpendedSpan = beginStr.split(' 0 )
+ {
+ nbClosed--;
+ parentSpan = parentSpan.parentNode;
+ }
+
+ // find the position of the last opended tag
+ while( parentSpan.parentNode != t.content_highlight && parentSpan.parentNode.tagName != 'PRE' && ( tmpMaxStartOffset = Math.max( 0, beginStr.lastIndexOf( '', maxStartOffset ) );
+
+ // count the number of sub spans
+ nbSubSpanBefore = beginStr.substr( lastEndPos ).split('' ) ) == -1 ? beginStr.length : beginStr.length - ( lastIndex + 1 );
+ //nbUnchangedChars = ? beginStr.length : beginStr.substr( lastIndex + 1 ).replace( /</g, '<').replace( />/g, '>').replace( /&/g, '&').length;
+
+ if( ( lastIndex = beginStr.lastIndexOf( '>' ) ) == -1 )
+ {
+ nbUnchangedChars = beginStr.length;
+ }
+ else
+ {
+ nbUnchangedChars = beginStr.substr( lastIndex + 1 ).replace( /</g, '<').replace( />/g, '>').replace( /&/g, '&').length;
+ //nbUnchangedChars += beginStr.substr( ).replace( /&/g, '&').replace( //g, '>').length - beginStr.length;
+ }
+ //alert( nbUnchangedChars );
+ // console.log( span, textNode, nbOpendedSpan,nbClosedSpan, span.nextSibling, textNode.length, nbUnchangedChars, lastHtml, lastHtml.length, newHtml, newHtml.length );
+ // alert( textNode.parentNode.className +'-'+ textNode.parentNode.tagName+"\n"+ textNode.data +"\n"+ nbUnchangedChars +"\n"+ lastHtml.length +"\n"+ newHtml +"\n"+ newHtml.length );
+ // console.log( nbUnchangedChars, lastIndex, beginStr.length, beginStr.replace(/&/g, '&'), lastHtml.length, '|', newHtml.replace( /\t/g, 't').replace( /\n/g, 'n').replace( /\r/g, 'r'), lastHtml.replace( /\t/g, 't').replace( /\n/g, 'n').replace( /\r/, 'r') );
+ // console.log( textNode.data.replace(/&/g, '&') );
+ // IE only manage \r for cariage return in textNode and not \n or \r\n
+ if( t.isIE )
+ {
+ nbUnchangedChars -= ( beginStr.substr( beginStr.length - nbUnchangedChars ).split("\n").length - 1 );
+ //alert( textNode.data.replace(/\r/g, '_r').replace(/\n/g, '_n'));
+ textNode.replaceData( nbUnchangedChars, lastHtml.replace(/\n/g, '').length, newHtml.replace(/\n/g, '') );
+ }
+ else
+ {
+ textNode.replaceData( nbUnchangedChars, lastHtml.length, newHtml );
+ }
+ //--------]
+ }
+ }
+ // an exception shouldn't occured but if replaceData failed at least it won't break everything
+ catch( e )
+ {
+ // throw e;
+ // console.log( e );
+ doHtmlOpti = false;
+ }
+
+ }
+
+ /*** END HTML update's optimisation ***/
+ // end test
+
+ // console.log( (TPS6-TPS5), (TPS5-TPS4), (TPS4-TPS3), (TPS3-TPS2), (TPS2-TPS1), _CPT );
+ // get the new highlight content
+ tpsAfterOpti2 = new Date().getTime();
+ hightlighted_text = stay_begin + updated_highlight + stay_end;
+ if( !doHtmlOpti )
+ {
+ // update the content of the highlight div by first updating a clone node (as there is no display in the same time for t node it's quite faster (5*))
+ var new_Obj= t.content_highlight.cloneNode(false);
+ if( ( t.isIE && t.isIE < 8 ) || ( t.isOpera && t.isOpera < 9.6 ) )
+ new_Obj.innerHTML= "" + hightlighted_text + "";
+ else
+ new_Obj.innerHTML= ""+ hightlighted_text +"";
+
+ t.content_highlight.parentNode.replaceChild(new_Obj, t.content_highlight);
+
+ t.content_highlight= new_Obj;
+ }
+
+ t.last_text_to_highlight= infos["full_text"];
+ t.last_hightlighted_text= hightlighted_text;
+
+ tps3=new Date().getTime();
+
+ if(t.settings["debug"]){
+ //lineNumber=tab_text.length;
+ //t.debug.value+=" \nNB char: "+_$("src").value.length+" Nb line: "+ lineNumber;
+
+ t.debug.value= "Tps optimisation "+(tps_end_opti-tps_start)
+ +" | tps reg exp: "+ (tpsAfterReg-tps_end_opti)
+ +" | tps opti HTML : "+ (tpsAfterOpti2-tpsAfterReg) + ' '+ ( doHtmlOpti ? 'yes' : 'no' )
+ +" | tps update highlight content: "+ (tps3-tpsAfterOpti2)
+ +" | tpsTotal: "+ (tps3-tps_start)
+ + "("+tps3+")\n"+ debug_opti;
+ // t.debug.value+= "highlight\n"+hightlighted_text;*/
+ }
+
+ };
+
+ EditArea.prototype.resync_highlight= function(reload_now){
+ this.reload_highlight=true;
+ this.last_text_to_highlight="";
+ this.focus();
+ if(reload_now)
+ this.check_line_selection(false);
+ };
+
diff --git a/applications/admin/static/edit_area/keyboard.js b/applications/admin/static/edit_area/keyboard.js
index 798a7524..b2c154a1 100755
--- a/applications/admin/static/edit_area/keyboard.js
+++ b/applications/admin/static/edit_area/keyboard.js
@@ -1,145 +1,146 @@
-var EA_keys = {8:"Retour arriere",9:"Tabulation",12:"Milieu (pave numerique)",13:"Entrer",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"Verr Maj",27:"Esc",32:"Space",33:"Page up",34:"Page down",35:"End",36:"Begin",37:"Left",38:"Up",39:"Right",40:"Down",44:"Impr ecran",45:"Inser",46:"Suppr",91:"Menu Demarrer Windows / touche pomme Mac",92:"Menu Demarrer Windows",93:"Menu contextuel Windows",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"Verr Num",145:"Arret defil"};
-
-
-
-function keyDown(e){
- if(!e){ // if IE
- e=event;
- }
-
- // send the event to the plugins
- for(var i in editArea.plugins){
- if(typeof(editArea.plugins[i].onkeydown)=="function"){
- if(editArea.plugins[i].onkeydown(e)===false){ // stop propaging
- if(editArea.isIE)
- e.keyCode=0;
- return false;
- }
- }
- }
-
- var target_id=(e.target || e.srcElement).id;
- var use=false;
- if (EA_keys[e.keyCode])
- letter=EA_keys[e.keyCode];
- else
- letter=String.fromCharCode(e.keyCode);
-
- var low_letter= letter.toLowerCase();
-
- if(letter=="Page up" && !AltPressed(e) && !editArea.isOpera){
- editArea.execCommand("scroll_page", {"dir": "up", "shift": ShiftPressed(e)});
- use=true;
- }else if(letter=="Page down" && !AltPressed(e) && !editArea.isOpera){
- editArea.execCommand("scroll_page", {"dir": "down", "shift": ShiftPressed(e)});
- use=true;
- }else if(editArea.is_editable==false){
- // do nothing but also do nothing else (allow to navigate with page up and page down)
- return true;
- }else if(letter=="Tabulation" && target_id=="textarea" && !CtrlPressed(e) && !AltPressed(e)){
- if(ShiftPressed(e))
- editArea.execCommand("invert_tab_selection");
- else
- editArea.execCommand("tab_selection");
-
- use=true;
- if(editArea.isOpera || (editArea.isFirefox && editArea.isMac) ) // opera && firefox mac can't cancel tabulation events...
- setTimeout("editArea.execCommand('focus');", 1);
- }else if(letter=="Entrer" && target_id=="textarea"){
- if(editArea.press_enter())
- use=true;
- }else if(letter=="Entrer" && target_id=="area_search"){
- editArea.execCommand("area_search");
- use=true;
- }else if(letter=="Esc"){
- editArea.execCommand("close_all_inline_popup", e);
- use=true;
- }else if(CtrlPressed(e) && !AltPressed(e) && !ShiftPressed(e)){
- switch(low_letter){
- case "f":
- editArea.execCommand("area_search");
- use=true;
- break;
- case "r":
- editArea.execCommand("area_replace");
- use=true;
- break;
- case "q":
- editArea.execCommand("close_all_inline_popup", e);
- use=true;
- break;
- case "h":
- editArea.execCommand("change_highlight");
- use=true;
- break;
- case "g":
- setTimeout("editArea.execCommand('go_to_line');", 5); // the prompt stop the return false otherwise
- use=true;
- break;
- case "e":
- editArea.execCommand("show_help");
- use=true;
- break;
- case "z":
- use=true;
- editArea.execCommand("undo");
- break;
- case "y":
- use=true;
- editArea.execCommand("redo");
- break;
- default:
- break;
- }
- }
-
- // check to disable the redo possibility if the textarea content change
- if(editArea.next.length > 0){
- setTimeout("editArea.check_redo();", 10);
- }
-
- setTimeout("editArea.check_file_changes();", 10);
-
-
- if(use){
- // in case of a control that sould'nt be used by IE but that is used => THROW a javascript error that will stop key action
- if(editArea.isIE)
- e.keyCode=0;
- return false;
- }
- //alert("Test: "+ letter + " ("+e.keyCode+") ALT: "+ AltPressed(e) + " CTRL "+ CtrlPressed(e) + " SHIFT "+ ShiftPressed(e));
-
- return true;
-
-};
-
-
-// return true if Alt key is pressed
-function AltPressed(e) {
- if (window.event) {
- return (window.event.altKey);
- } else {
- if(e.modifiers)
- return (e.altKey || (e.modifiers % 2));
- else
- return e.altKey;
- }
-};
-
-// return true if Ctrl key is pressed
-function CtrlPressed(e) {
- if (window.event) {
- return (window.event.ctrlKey);
- } else {
- return (e.ctrlKey || (e.modifiers==2) || (e.modifiers==3) || (e.modifiers>5));
- }
-};
-
-// return true if Shift key is pressed
-function ShiftPressed(e) {
- if (window.event) {
- return (window.event.shiftKey);
- } else {
- return (e.shiftKey || (e.modifiers>3));
- }
-};
+var EA_keys = {8:"Retour arriere",9:"Tabulation",12:"Milieu (pave numerique)",13:"Entrer",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"Verr Maj",27:"Esc",32:"Space",33:"Page up",34:"Page down",35:"End",36:"Begin",37:"Left",38:"Up",39:"Right",40:"Down",44:"Impr ecran",45:"Inser",46:"Suppr",91:"Menu Demarrer Windows / touche pomme Mac",92:"Menu Demarrer Windows",93:"Menu contextuel Windows",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"Verr Num",145:"Arret defil"};
+
+
+
+function keyDown(e){
+ if(!e){ // if IE
+ e=event;
+ }
+
+ // send the event to the plugins
+ for(var i in editArea.plugins){
+ if(typeof(editArea.plugins[i].onkeydown)=="function"){
+ if(editArea.plugins[i].onkeydown(e)===false){ // stop propaging
+ if(editArea.isIE)
+ e.keyCode=0;
+ return false;
+ }
+ }
+ }
+
+ var target_id=(e.target || e.srcElement).id;
+ var use=false;
+ if (EA_keys[e.keyCode])
+ letter=EA_keys[e.keyCode];
+ else
+ letter=String.fromCharCode(e.keyCode);
+
+ var low_letter= letter.toLowerCase();
+
+ if(letter=="Page up" && !AltPressed(e) && !editArea.isOpera){
+ editArea.execCommand("scroll_page", {"dir": "up", "shift": ShiftPressed(e)});
+ use=true;
+ }else if(letter=="Page down" && !AltPressed(e) && !editArea.isOpera){
+ editArea.execCommand("scroll_page", {"dir": "down", "shift": ShiftPressed(e)});
+ use=true;
+ }else if(editArea.is_editable==false){
+ // do nothing but also do nothing else (allow to navigate with page up and page down)
+ return true;
+ }else if(letter=="Tabulation" && target_id=="textarea" && !CtrlPressed(e) && !AltPressed(e)){
+ if(ShiftPressed(e))
+ editArea.execCommand("invert_tab_selection");
+ else
+ editArea.execCommand("tab_selection");
+
+ use=true;
+ if(editArea.isOpera || (editArea.isFirefox && editArea.isMac) ) // opera && firefox mac can't cancel tabulation events...
+ setTimeout("editArea.execCommand('focus');", 1);
+ }else if(letter=="Entrer" && target_id=="textarea"){
+ if(editArea.press_enter())
+ use=true;
+ }else if(letter=="Entrer" && target_id=="area_search"){
+ editArea.execCommand("area_search");
+ use=true;
+ }else if(letter=="Esc"){
+ editArea.execCommand("close_all_inline_popup", e);
+ use=true;
+ }else if(CtrlPressed(e) && !AltPressed(e) && !ShiftPressed(e)){
+ switch(low_letter){
+ case "f":
+ editArea.execCommand("area_search");
+ use=true;
+ break;
+ case "r":
+ editArea.execCommand("area_replace");
+ use=true;
+ break;
+ case "q":
+ editArea.execCommand("close_all_inline_popup", e);
+ use=true;
+ break;
+ case "h":
+ editArea.execCommand("change_highlight");
+ use=true;
+ break;
+ case "g":
+ setTimeout("editArea.execCommand('go_to_line');", 5); // the prompt stop the return false otherwise
+ use=true;
+ break;
+ case "e":
+ editArea.execCommand("show_help");
+ use=true;
+ break;
+ case "z":
+ use=true;
+ editArea.execCommand("undo");
+ break;
+ case "y":
+ use=true;
+ editArea.execCommand("redo");
+ break;
+ default:
+ break;
+ }
+ }
+
+ // check to disable the redo possibility if the textarea content change
+ if(editArea.next.length > 0){
+ setTimeout("editArea.check_redo();", 10);
+ }
+
+ setTimeout("editArea.check_file_changes();", 10);
+
+
+ if(use){
+ // in case of a control that sould'nt be used by IE but that is used => THROW a javascript error that will stop key action
+ if(editArea.isIE)
+ e.keyCode=0;
+ return false;
+ }
+ //alert("Test: "+ letter + " ("+e.keyCode+") ALT: "+ AltPressed(e) + " CTRL "+ CtrlPressed(e) + " SHIFT "+ ShiftPressed(e));
+
+ return true;
+
+};
+
+
+// return true if Alt key is pressed
+function AltPressed(e) {
+ if (window.event) {
+ return (window.event.altKey);
+ } else {
+ if(e.modifiers)
+ return (e.altKey || (e.modifiers % 2));
+ else
+ return e.altKey;
+ }
+};
+
+// return true if Ctrl key is pressed
+function CtrlPressed(e) {
+ if (window.event) {
+ return (window.event.ctrlKey);
+ } else {
+ return (e.ctrlKey || (e.modifiers==2) || (e.modifiers==3) || (e.modifiers>5));
+ }
+};
+
+// return true if Shift key is pressed
+function ShiftPressed(e) {
+ if (window.event) {
+ return (window.event.shiftKey);
+ } else {
+ return (e.shiftKey || (e.modifiers>3));
+ }
+};
+
diff --git a/applications/admin/static/edit_area/manage_area.js b/applications/admin/static/edit_area/manage_area.js
index e10c5e94..f4134e3a 100755
--- a/applications/admin/static/edit_area/manage_area.js
+++ b/applications/admin/static/edit_area/manage_area.js
@@ -1,623 +1,623 @@
- EditArea.prototype.focus = function() {
- this.textarea.focus();
- this.textareaFocused=true;
- };
-
-
- EditArea.prototype.check_line_selection= function(timer_checkup){
- var changes, infos, new_top, new_width,i;
-
- var t1=t2=t2_1=t3=tLines=tend= new Date().getTime();
- // l'editeur n'existe plus => on quitte
- if(!editAreas[this.id])
- return false;
-
- if(!this.smooth_selection && !this.do_highlight)
- {
- //do nothing
- }
- else if(this.textareaFocused && editAreas[this.id]["displayed"]==true && this.isResizing==false)
- {
- infos = this.get_selection_infos();
- changes = this.checkTextEvolution( typeof( this.last_selection['full_text'] ) == 'undefined' ? '' : this.last_selection['full_text'], infos['full_text'] );
-
- t2= new Date().getTime();
-
- // if selection change
- if(this.last_selection["line_start"] != infos["line_start"] || this.last_selection["line_nb"] != infos["line_nb"] || infos["full_text"] != this.last_selection["full_text"] || this.reload_highlight || this.last_selection["selectionStart"] != infos["selectionStart"] || this.last_selection["selectionEnd"] != infos["selectionEnd"] || !timer_checkup )
- {
- // move and adjust text selection elements
- new_top = this.getLinePosTop( infos["line_start"] );
- new_width = Math.max(this.textarea.scrollWidth, this.container.clientWidth -50);
- this.selection_field.style.top=this.selection_field_text.style.top=new_top+"px";
- if(!this.settings['word_wrap']){
- this.selection_field.style.width=this.selection_field_text.style.width=this.test_font_size.style.width=new_width+"px";
- }
-
- // usefull? => _$("cursor_pos").style.top=new_top+"px";
-
- if(this.do_highlight==true)
- {
- // fill selection elements
- var curr_text = infos["full_text"].split("\n");
- var content = "";
- //alert("length: "+curr_text.length+ " i: "+ Math.max(0,infos["line_start"]-1)+ " end: "+Math.min(curr_text.length, infos["line_start"]+infos["line_nb"]-1)+ " line: "+infos["line_start"]+" [0]: "+curr_text[0]+" [1]: "+curr_text[1]);
- var start = Math.max(0,infos["line_start"]-1);
- var end = Math.min(curr_text.length, infos["line_start"]+infos["line_nb"]-1);
-
- //curr_text[start]= curr_text[start].substr(0,infos["curr_pos"]-1) +"¤_overline_¤"+ curr_text[start].substr(infos["curr_pos"]-1);
- for(i=start; i< end; i++){
- content+= curr_text[i]+"\n";
- }
-
- // add special chars arround selected characters
- selLength = infos['selectionEnd'] - infos['selectionStart'];
- content = content.substr( 0, infos["curr_pos"] - 1 ) + "\r\r" + content.substr( infos["curr_pos"] - 1, selLength ) + "\r\r" + content.substr( infos["curr_pos"] - 1 + selLength );
- content = ''+ content.replace(/&/g,"&").replace(//g,">").replace("\r\r", '').replace("\r\r", '') +'';
-
- if( this.isIE || ( this.isOpera && this.isOpera < 9.6 ) ) {
- this.selection_field.innerHTML= "" + content.replace(/^\r?\n/, ""; - } else { - this.selection_field.innerHTML= content; - } - this.selection_field_text.innerHTML = this.selection_field.innerHTML; - t2_1 = new Date().getTime(); - // check if we need to update the highlighted background - if(this.reload_highlight || (infos["full_text"] != this.last_text_to_highlight && (this.last_selection["line_start"]!=infos["line_start"] || this.show_line_colors || this.settings['word_wrap'] || this.last_selection["line_nb"]!=infos["line_nb"] || this.last_selection["nb_line"]!=infos["nb_line"]) ) ) - { - this.maj_highlight(infos); - } - } - } - t3= new Date().getTime(); - - // manage line heights - if( this.settings['word_wrap'] && infos["full_text"] != this.last_selection["full_text"]) - { - // refresh only 1 line if text change concern only one line and that the total line number has not changed - if( changes.newText.split("\n").length == 1 && this.last_selection['nb_line'] && infos['nb_line'] == this.last_selection['nb_line'] ) - { - this.fixLinesHeight( infos['full_text'], changes.lineStart, changes.lineStart ); - } - else - { - this.fixLinesHeight( infos['full_text'], changes.lineStart, -1 ); - } - } - - tLines= new Date().getTime(); - // manage bracket finding - if( infos["line_start"] != this.last_selection["line_start"] || infos["curr_pos"] != this.last_selection["curr_pos"] || infos["full_text"].length!=this.last_selection["full_text"].length || this.reload_highlight || !timer_checkup ) - { - // move _cursor_pos - var selec_char= infos["curr_line"].charAt(infos["curr_pos"]-1); - var no_real_move=true; - if(infos["line_nb"]==1 && (this.assocBracket[selec_char] || this.revertAssocBracket[selec_char]) ){ - - no_real_move=false; - //findEndBracket(infos["line_start"], infos["curr_pos"], selec_char); - if(this.findEndBracket(infos, selec_char) === true){ - _$("end_bracket").style.visibility ="visible"; - _$("cursor_pos").style.visibility ="visible"; - _$("cursor_pos").innerHTML = selec_char; - _$("end_bracket").innerHTML = (this.assocBracket[selec_char] || this.revertAssocBracket[selec_char]); - }else{ - _$("end_bracket").style.visibility ="hidden"; - _$("cursor_pos").style.visibility ="hidden"; - } - }else{ - _$("cursor_pos").style.visibility ="hidden"; - _$("end_bracket").style.visibility ="hidden"; - } - //alert("move cursor"); - this.displayToCursorPosition("cursor_pos", infos["line_start"], infos["curr_pos"]-1, infos["curr_line"], no_real_move); - if(infos["line_nb"]==1 && infos["line_start"]!=this.last_selection["line_start"]) - this.scroll_to_view(); - } - this.last_selection=infos; - } - - tend= new Date().getTime(); - //if( (tend-t1) > 7 ) - // console.log( "tps total: "+ (tend-t1) + " tps get_infos: "+ (t2-t1)+ " tps selec: "+ (t2_1-t2)+ " tps highlight: "+ (t3-t2_1) +" tps lines: "+ (tLines-t3) +" tps cursor+lines: "+ (tend-tLines)+" \n" ); - - - if(timer_checkup){ - setTimeout("editArea.check_line_selection(true)", this.check_line_selection_timer); - } - }; - - - EditArea.prototype.get_selection_infos= function(){ - var sel={}, start, end, len, str; - - this.getIESelection(); - start = this.textarea.selectionStart; - end = this.textarea.selectionEnd; - - if( this.last_selection["selectionStart"] == start && this.last_selection["selectionEnd"] == end && this.last_selection["full_text"] == this.textarea.value ) - { - return this.last_selection; - } - - if(this.tabulation!="\t" && this.textarea.value.indexOf("\t")!=-1) - { // can append only after copy/paste - len = this.textarea.value.length; - this.textarea.value = this.replace_tab(this.textarea.value); - start = end = start+(this.textarea.value.length-len); - this.area_select( start, 0 ); - } - - sel["selectionStart"] = start; - sel["selectionEnd"] = end; - sel["full_text"] = this.textarea.value; - sel["line_start"] = 1; - sel["line_nb"] = 1; - sel["curr_pos"] = 0; - sel["curr_line"] = ""; - sel["indexOfCursor"] = 0; - sel["selec_direction"] = this.last_selection["selec_direction"]; - - //return sel; - var splitTab= sel["full_text"].split("\n"); - var nbLine = Math.max(0, splitTab.length); - var nbChar = Math.max(0, sel["full_text"].length - (nbLine - 1)); // (remove \n caracters from the count) - if( sel["full_text"].indexOf("\r") != -1 ) - nbChar = nbChar - ( nbLine - 1 ); // (remove \r caracters from the count) - sel["nb_line"] = nbLine; - sel["nb_char"] = nbChar; - - if(start>0){ - str = sel["full_text"].substr(0,start); - sel["curr_pos"] = start - str.lastIndexOf("\n"); - sel["line_start"] = Math.max(1, str.split("\n").length); - }else{ - sel["curr_pos"]=1; - } - if(end>start){ - sel["line_nb"]=sel["full_text"].substring(start,end).split("\n").length; - } - sel["indexOfCursor"]=start; - sel["curr_line"]=splitTab[Math.max(0,sel["line_start"]-1)]; - - // determine in which direction the selection grow - if(sel["selectionStart"] == this.last_selection["selectionStart"]){ - if(sel["selectionEnd"]>this.last_selection["selectionEnd"]) - sel["selec_direction"]= "down"; - else if(sel["selectionEnd"] == this.last_selection["selectionStart"]) - sel["selec_direction"]= this.last_selection["selec_direction"]; - }else if(sel["selectionStart"] == this.last_selection["selectionEnd"] && sel["selectionEnd"]>this.last_selection["selectionEnd"]){ - sel["selec_direction"]= "down"; - }else{ - sel["selec_direction"]= "up"; - } - - _$("nbLine").innerHTML = nbLine; - _$("nbChar").innerHTML = nbChar; - _$("linePos").innerHTML = sel["line_start"]; - _$("currPos").innerHTML = sel["curr_pos"]; - - return sel; - }; - - // set IE position in Firefox mode (textarea.selectionStart and textarea.selectionEnd) - EditArea.prototype.getIESelection= function(){ - var selectionStart, selectionEnd, range, stored_range; - - if( !this.isIE ) - return false; - - // make it work as nowrap mode (easier for range manipulation with lineHeight) - if( this.settings['word_wrap'] ) - this.textarea.wrap='off'; - - try{ - range = document.selection.createRange(); - stored_range = range.duplicate(); - stored_range.moveToElementText( this.textarea ); - stored_range.setEndPoint( 'EndToEnd', range ); - if( stored_range.parentElement() != this.textarea ) - throw "invalid focus"; - - // the range don't take care of empty lines in the end of the selection - var scrollTop = this.result.scrollTop + document.body.scrollTop; - var relative_top= range.offsetTop - parent.calculeOffsetTop(this.textarea) + scrollTop; - var line_start = Math.round((relative_top / this.lineHeight) +1); - var line_nb = Math.round( range.boundingHeight / this.lineHeight ); - - selectionStart = stored_range.text.length - range.text.length; - selectionStart += ( line_start - this.textarea.value.substr(0, selectionStart).split("\n").length)*2; // count missing empty \r to the selection - selectionStart -= ( line_start - this.textarea.value.substr(0, selectionStart).split("\n").length ) * 2; - - selectionEnd = selectionStart + range.text.length; - selectionEnd += (line_start + line_nb - 1 - this.textarea.value.substr(0, selectionEnd ).split("\n").length)*2; - - this.textarea.selectionStart = selectionStart; - this.textarea.selectionEnd = selectionEnd; - } - catch(e){} - - // restore wrap mode - if( this.settings['word_wrap'] ) - this.textarea.wrap='soft'; - }; - - // select the text for IE (and take care of \r caracters) - EditArea.prototype.setIESelection= function(){ - var a = this.textarea, nbLineStart, nbLineEnd, range; - - if( !this.isIE ) - return false; - - nbLineStart = a.value.substr(0, a.selectionStart).split("\n").length - 1; - nbLineEnd = a.value.substr(0, a.selectionEnd).split("\n").length - 1; - range = document.selection.createRange(); - range.moveToElementText( a ); - range.setEndPoint( 'EndToStart', range ); - - range.moveStart('character', a.selectionStart - nbLineStart); - range.moveEnd('character', a.selectionEnd - nbLineEnd - (a.selectionStart - nbLineStart) ); - range.select(); - }; - - - - EditArea.prototype.checkTextEvolution=function(lastText,newText){ - // ch will contain changes datas - var ch={},baseStep=200, cpt=0, end, step,tStart=new Date().getTime(); - - end = Math.min(newText.length, lastText.length); - step = baseStep; - // find how many chars are similar at the begin of the text - while( cpt
") + "
" + content.replace(/^\r?\n/, ""; - } else { - elem.innerHTML= content; - } - - - endElem = _$('endTestFont'); - topOffset = endElem.offsetTop; - fixPadding = parseInt( this.content_highlight.style.paddingLeft.replace("px", "") ); - posLeft = 45 + endElem.offsetLeft + ( !isNaN( fixPadding ) && topOffset > 0 ? fixPadding : 0 ); - posTop = this.getLinePosTop( start_line ) + topOffset;// + Math.floor( ( endElem.offsetHeight - 1 ) / this.lineHeight ) * this.lineHeight; - - // detect the case where the span start on a line but has no display on it - if( this.isIE && cur_pos > 0 && endElem.offsetLeft == 0 ) - { - posTop += this.lineHeight; - } - if(no_real_move!=true){ // when the cursor is hidden no need to move him - dest.style.top=posTop+"px"; - dest.style.left=posLeft+"px"; - } - // usefull for smarter scroll - dest.cursor_top=posTop; - dest.cursor_left=posLeft; - // _$(id).style.marginLeft=posLeft+"px"; - }; - - EditArea.prototype.getLinePosTop= function(start_line){ - var elem= _$('line_'+ start_line), posTop=0; - if( elem ) - posTop = elem.offsetTop; - else - posTop = this.lineHeight * (start_line-1); - return posTop; - }; - - - // return the dislpayed height of a text (take word-wrap into account) - EditArea.prototype.getTextHeight= function(text){ - var t=this,elem,height; - elem = t.test_font_size; - content = text.replace(/&/g,"&").replace(/" + content.replace(/^\r?\n/, "
") + "
" + content.replace(/^\r?\n/, ""; + } else { + this.selection_field.innerHTML= content; + } + this.selection_field_text.innerHTML = this.selection_field.innerHTML; + t2_1 = new Date().getTime(); + // check if we need to update the highlighted background + if(this.reload_highlight || (infos["full_text"] != this.last_text_to_highlight && (this.last_selection["line_start"]!=infos["line_start"] || this.show_line_colors || this.settings['word_wrap'] || this.last_selection["line_nb"]!=infos["line_nb"] || this.last_selection["nb_line"]!=infos["nb_line"]) ) ) + { + this.maj_highlight(infos); + } + } + } + t3= new Date().getTime(); + + // manage line heights + if( this.settings['word_wrap'] && infos["full_text"] != this.last_selection["full_text"]) + { + // refresh only 1 line if text change concern only one line and that the total line number has not changed + if( changes.newText.split("\n").length == 1 && this.last_selection['nb_line'] && infos['nb_line'] == this.last_selection['nb_line'] ) + { + this.fixLinesHeight( infos['full_text'], changes.lineStart, changes.lineStart ); + } + else + { + this.fixLinesHeight( infos['full_text'], changes.lineStart, -1 ); + } + } + + tLines= new Date().getTime(); + // manage bracket finding + if( infos["line_start"] != this.last_selection["line_start"] || infos["curr_pos"] != this.last_selection["curr_pos"] || infos["full_text"].length!=this.last_selection["full_text"].length || this.reload_highlight || !timer_checkup ) + { + // move _cursor_pos + var selec_char= infos["curr_line"].charAt(infos["curr_pos"]-1); + var no_real_move=true; + if(infos["line_nb"]==1 && (this.assocBracket[selec_char] || this.revertAssocBracket[selec_char]) ){ + + no_real_move=false; + //findEndBracket(infos["line_start"], infos["curr_pos"], selec_char); + if(this.findEndBracket(infos, selec_char) === true){ + _$("end_bracket").style.visibility ="visible"; + _$("cursor_pos").style.visibility ="visible"; + _$("cursor_pos").innerHTML = selec_char; + _$("end_bracket").innerHTML = (this.assocBracket[selec_char] || this.revertAssocBracket[selec_char]); + }else{ + _$("end_bracket").style.visibility ="hidden"; + _$("cursor_pos").style.visibility ="hidden"; + } + }else{ + _$("cursor_pos").style.visibility ="hidden"; + _$("end_bracket").style.visibility ="hidden"; + } + //alert("move cursor"); + this.displayToCursorPosition("cursor_pos", infos["line_start"], infos["curr_pos"]-1, infos["curr_line"], no_real_move); + if(infos["line_nb"]==1 && infos["line_start"]!=this.last_selection["line_start"]) + this.scroll_to_view(); + } + this.last_selection=infos; + } + + tend= new Date().getTime(); + //if( (tend-t1) > 7 ) + // console.log( "tps total: "+ (tend-t1) + " tps get_infos: "+ (t2-t1)+ " tps selec: "+ (t2_1-t2)+ " tps highlight: "+ (t3-t2_1) +" tps lines: "+ (tLines-t3) +" tps cursor+lines: "+ (tend-tLines)+" \n" ); + + + if(timer_checkup){ + setTimeout("editArea.check_line_selection(true)", this.check_line_selection_timer); + } + }; + + + EditArea.prototype.get_selection_infos= function(){ + var sel={}, start, end, len, str; + + this.getIESelection(); + start = this.textarea.selectionStart; + end = this.textarea.selectionEnd; + + if( this.last_selection["selectionStart"] == start && this.last_selection["selectionEnd"] == end && this.last_selection["full_text"] == this.textarea.value ) + { + return this.last_selection; + } + + if(this.tabulation!="\t" && this.textarea.value.indexOf("\t")!=-1) + { // can append only after copy/paste + len = this.textarea.value.length; + this.textarea.value = this.replace_tab(this.textarea.value); + start = end = start+(this.textarea.value.length-len); + this.area_select( start, 0 ); + } + + sel["selectionStart"] = start; + sel["selectionEnd"] = end; + sel["full_text"] = this.textarea.value; + sel["line_start"] = 1; + sel["line_nb"] = 1; + sel["curr_pos"] = 0; + sel["curr_line"] = ""; + sel["indexOfCursor"] = 0; + sel["selec_direction"] = this.last_selection["selec_direction"]; + + //return sel; + var splitTab= sel["full_text"].split("\n"); + var nbLine = Math.max(0, splitTab.length); + var nbChar = Math.max(0, sel["full_text"].length - (nbLine - 1)); // (remove \n caracters from the count) + if( sel["full_text"].indexOf("\r") != -1 ) + nbChar = nbChar - ( nbLine - 1 ); // (remove \r caracters from the count) + sel["nb_line"] = nbLine; + sel["nb_char"] = nbChar; + + if(start>0){ + str = sel["full_text"].substr(0,start); + sel["curr_pos"] = start - str.lastIndexOf("\n"); + sel["line_start"] = Math.max(1, str.split("\n").length); + }else{ + sel["curr_pos"]=1; + } + if(end>start){ + sel["line_nb"]=sel["full_text"].substring(start,end).split("\n").length; + } + sel["indexOfCursor"]=start; + sel["curr_line"]=splitTab[Math.max(0,sel["line_start"]-1)]; + + // determine in which direction the selection grow + if(sel["selectionStart"] == this.last_selection["selectionStart"]){ + if(sel["selectionEnd"]>this.last_selection["selectionEnd"]) + sel["selec_direction"]= "down"; + else if(sel["selectionEnd"] == this.last_selection["selectionStart"]) + sel["selec_direction"]= this.last_selection["selec_direction"]; + }else if(sel["selectionStart"] == this.last_selection["selectionEnd"] && sel["selectionEnd"]>this.last_selection["selectionEnd"]){ + sel["selec_direction"]= "down"; + }else{ + sel["selec_direction"]= "up"; + } + + _$("nbLine").innerHTML = nbLine; + _$("nbChar").innerHTML = nbChar; + _$("linePos").innerHTML = sel["line_start"]; + _$("currPos").innerHTML = sel["curr_pos"]; + + return sel; + }; + + // set IE position in Firefox mode (textarea.selectionStart and textarea.selectionEnd) + EditArea.prototype.getIESelection= function(){ + var selectionStart, selectionEnd, range, stored_range; + + if( !this.isIE ) + return false; + + // make it work as nowrap mode (easier for range manipulation with lineHeight) + if( this.settings['word_wrap'] ) + this.textarea.wrap='off'; + + try{ + range = document.selection.createRange(); + stored_range = range.duplicate(); + stored_range.moveToElementText( this.textarea ); + stored_range.setEndPoint( 'EndToEnd', range ); + if( stored_range.parentElement() != this.textarea ) + throw "invalid focus"; + + // the range don't take care of empty lines in the end of the selection + var scrollTop = this.result.scrollTop + document.body.scrollTop; + var relative_top= range.offsetTop - parent.calculeOffsetTop(this.textarea) + scrollTop; + var line_start = Math.round((relative_top / this.lineHeight) +1); + var line_nb = Math.round( range.boundingHeight / this.lineHeight ); + + selectionStart = stored_range.text.length - range.text.length; + selectionStart += ( line_start - this.textarea.value.substr(0, selectionStart).split("\n").length)*2; // count missing empty \r to the selection + selectionStart -= ( line_start - this.textarea.value.substr(0, selectionStart).split("\n").length ) * 2; + + selectionEnd = selectionStart + range.text.length; + selectionEnd += (line_start + line_nb - 1 - this.textarea.value.substr(0, selectionEnd ).split("\n").length)*2; + + this.textarea.selectionStart = selectionStart; + this.textarea.selectionEnd = selectionEnd; + } + catch(e){} + + // restore wrap mode + if( this.settings['word_wrap'] ) + this.textarea.wrap='soft'; + }; + + // select the text for IE (and take care of \r caracters) + EditArea.prototype.setIESelection= function(){ + var a = this.textarea, nbLineStart, nbLineEnd, range; + + if( !this.isIE ) + return false; + + nbLineStart = a.value.substr(0, a.selectionStart).split("\n").length - 1; + nbLineEnd = a.value.substr(0, a.selectionEnd).split("\n").length - 1; + range = document.selection.createRange(); + range.moveToElementText( a ); + range.setEndPoint( 'EndToStart', range ); + + range.moveStart('character', a.selectionStart - nbLineStart); + range.moveEnd('character', a.selectionEnd - nbLineEnd - (a.selectionStart - nbLineStart) ); + range.select(); + }; + + + + EditArea.prototype.checkTextEvolution=function(lastText,newText){ + // ch will contain changes datas + var ch={},baseStep=200, cpt=0, end, step,tStart=new Date().getTime(); + + end = Math.min(newText.length, lastText.length); + step = baseStep; + // find how many chars are similar at the begin of the text + while( cpt
") + "
" + content.replace(/^\r?\n/, ""; + } else { + elem.innerHTML= content; + } + + + endElem = _$('endTestFont'); + topOffset = endElem.offsetTop; + fixPadding = parseInt( this.content_highlight.style.paddingLeft.replace("px", "") ); + posLeft = 45 + endElem.offsetLeft + ( !isNaN( fixPadding ) && topOffset > 0 ? fixPadding : 0 ); + posTop = this.getLinePosTop( start_line ) + topOffset;// + Math.floor( ( endElem.offsetHeight - 1 ) / this.lineHeight ) * this.lineHeight; + + // detect the case where the span start on a line but has no display on it + if( this.isIE && cur_pos > 0 && endElem.offsetLeft == 0 ) + { + posTop += this.lineHeight; + } + if(no_real_move!=true){ // when the cursor is hidden no need to move him + dest.style.top=posTop+"px"; + dest.style.left=posLeft+"px"; + } + // usefull for smarter scroll + dest.cursor_top=posTop; + dest.cursor_left=posLeft; + // _$(id).style.marginLeft=posLeft+"px"; + }; + + EditArea.prototype.getLinePosTop= function(start_line){ + var elem= _$('line_'+ start_line), posTop=0; + if( elem ) + posTop = elem.offsetTop; + else + posTop = this.lineHeight * (start_line-1); + return posTop; + }; + + + // return the dislpayed height of a text (take word-wrap into account) + EditArea.prototype.getTextHeight= function(text){ + var t=this,elem,height; + elem = t.test_font_size; + content = text.replace(/&/g,"&").replace(/" + content.replace(/^\r?\n/, "
") + "
| t |
created by {{="%(first_name)s %(last_name)s" % db.auth_user[db.app(name=a).owner]}}
{{pass}} @@ -18,7 +18,7 @@ {{=LI(A(T('Goto'),_rel="external",_href=URL(a,'default','index')))}} {{if not os.path.exists('applications/%s/compiled' % a):}} {{=LI(A(T('Edit'),_href=URL('design',args=a)))}} - {{else:}} + {{else:}} {{=LI(A(T('appadmin'),_rel="external",_href=URL(a,'appadmin','index')))}} {{pass}} {{=LI(A(T('About'),_href=URL('about',args=a)))}} @@ -41,3 +41,4 @@{{=T('Functions with no doctests will result in [passed] tests.')}}
{{=T('ATTENTION: TESTING IS NOT THREAD SAFE SO DO NOT PERFORM MULTIPLE TESTS CONCURRENTLY.')}}
+ diff --git a/applications/admin/views/default.mobile/ticket.html b/applications/admin/views/default.mobile/ticket.html index f8fb11c3..026b00bd 100644 --- a/applications/admin/views/default.mobile/ticket.html +++ b/applications/admin/views/default.mobile/ticket.html @@ -28,14 +28,14 @@ {{try:}} - +@@ -60,7 +60,7 @@
File {{="%s in %s at line %s" % (frame['file'], frame['func'], frame['lnum'])}} - {{=T("code")}} - {{=T("arguments")}} + {{=T("code")}} + {{=T("arguments")}} {{=T("variables")}} -
-{{=frame['call']}}
{{=CODE('\n'.join([x[1] for x in sorted(frame['lines'].items(),key=lambda x: x[0])]),
+ {{=CODE('\n'.join([x[1] for x in sorted(frame['lines'].items(),key=lambda x: x[0])]),
language='python', link=None, counter=min(frame['lines'].keys()), highlight_line=frame['lnum'])}}
{{pass}}
{{=button(URL('edit/%s/LICENSE' % (app)), T('Edit'))}}
{{=FORM(INPUT(_type='submit',_name='nodelete',_value=T('Abort')),INPUT(_type='hidden',_name='sender',_value=sender), _class="inline")}}{{=FORM(INPUT(_type='submit',_name='delete',_value=T('Delete')),INPUT(_type='hidden',_name='sender',_value=sender), _class="inline")}}
{{=FORM(INPUT(_type='submit',_name='nodelete',_value=T('NO')))}}
{{=FORM(INPUT(_type='submit',_name='delete',_value=T('YES')))}}
{{else:}} -
{{if not os.path.exists('applications/%s/compiled' % a):}} @@ -58,7 +58,7 @@ {{if is_manager():}}
{{=T('Checking for upgrades...')}} @@ -85,8 +85,8 @@
{{=T('Functions with no doctests will result in [passed] tests.')}}
{{=T('ATTENTION: TESTING IS NOT THREAD SAFE SO DO NOT PERFORM MULTIPLE TESTS CONCURRENTLY.')}}
+ diff --git a/applications/admin/views/default/ticket.html b/applications/admin/views/default/ticket.html index f8fb11c3..026b00bd 100644 --- a/applications/admin/views/default/ticket.html +++ b/applications/admin/views/default/ticket.html @@ -28,14 +28,14 @@ {{try:}} - +@@ -60,7 +60,7 @@
File {{="%s in %s at line %s" % (frame['file'], frame['func'], frame['lnum'])}} - {{=T("code")}} - {{=T("arguments")}} + {{=T("code")}} + {{=T("arguments")}} {{=T("variables")}} -
-{{=frame['call']}}
{{=CODE('\n'.join([x[1] for x in sorted(frame['lines'].items(),key=lambda x: x[0])]),
+ {{=CODE('\n'.join([x[1] for x in sorted(frame['lines'].items(),key=lambda x: x[0])]),
language='python', link=None, counter=min(frame['lines'].keys()), highlight_line=frame['lnum'])}}
{{pass}}
Try click on a button on the left, it is a demo!
-profiler info
App Name: {{=session.app['name']}}
{{=button(URL('step1'), T('Edit'))}}
| t |
{{for i in range(1000):}}bla {{pass}}
\ No newline at end of file +{{for i in range(1000):}}bla {{pass}}
diff --git a/applications/examples/views/layout_examples/layout_civilized.html b/applications/examples/views/layout_examples/layout_civilized.html index e9d925cc..7d0c017b 100644 --- a/applications/examples/views/layout_examples/layout_civilized.html +++ b/applications/examples/views/layout_examples/layout_civilized.html @@ -288,3 +288,4 @@ body