Index: branches/usability/acaifix/UsabilityInitiative.hooks.php |
— | — | @@ -65,17 +65,17 @@ |
66 | 66 | array( 'src' => 'js/plugins/jquery.delayedBind.js', 'version' => 1 ), |
67 | 67 | array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ), |
68 | 68 | array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 6 ), |
69 | | - array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 17 ), |
70 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 12 ), |
| 69 | + array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 18 ), |
| 70 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 13 ), |
71 | 71 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 22 ), |
72 | 72 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 8 ), |
73 | 73 | array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 27 ), |
74 | 74 | ), |
75 | 75 | 'combined' => array( |
76 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 64 ), |
| 76 | + array( 'src' => 'js/plugins.combined.js', 'version' => 65 ), |
77 | 77 | ), |
78 | 78 | 'minified' => array( |
79 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 64 ), |
| 79 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 65 ), |
80 | 80 | ), |
81 | 81 | ), |
82 | 82 | ); |
Index: branches/usability/acaifix/EditToolbar/EditToolbar.js |
— | — | @@ -1043,11 +1043,11 @@ |
1044 | 1044 | } |
1045 | 1045 | }, |
1046 | 1046 | open: function() { |
| 1047 | + // Pre-fill the text fields based on the current selection |
| 1048 | + var selection = $j(this).data( 'context' ).$textarea.focus().getSelection(); |
1047 | 1049 | $j( '#edittoolbar-link-int-target, #edittoolbar-link-ext-target' ) |
1048 | 1050 | .filter( ':visible' ) |
1049 | 1051 | .focus(); |
1050 | | - // Pre-fill the text fields based on the current selection |
1051 | | - var selection = $j(this).data( 'context' ).$textarea.getSelection(); |
1052 | 1052 | $j( '#edittoolbar-link-dialog-tab-int' ).data( 'whitespace', [ '', '' ] ); |
1053 | 1053 | $j( '#edittoolbar-link-dialog-tab-ext' ).data( 'whitespace', [ '', '' ] ); |
1054 | 1054 | if ( selection != '' ) { |
Index: branches/usability/acaifix/EditToolbar/EditToolbar.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | /* Configuration */ |
21 | 21 | |
22 | 22 | // Bump the version number every time you change any of the .css/.js files |
23 | | -$wgEditToolbarStyleVersion = 75; |
| 23 | +$wgEditToolbarStyleVersion = 76; |
24 | 24 | |
25 | 25 | // Set this to true to simply override the stock toolbar for everyone |
26 | 26 | $wgEditToolbarGlobalEnable = false; |
Index: branches/usability/acaifix/js/plugins/jquery.textSelection.js |
— | — | @@ -51,13 +51,12 @@ |
52 | 52 | post += ' '; |
53 | 53 | } |
54 | 54 | } |
55 | | - var selText = $(this).getSelection(); |
| 55 | + var selText = $(this).focus().getSelection(); |
56 | 56 | var isSample = false; |
57 | 57 | if ( this.style.display == 'none' ) { |
58 | 58 | // Do nothing |
59 | 59 | } else if ( this.selectionStart || this.selectionStart == '0' ) { |
60 | 60 | // Mozilla/Opera |
61 | | - $(this).focus(); |
62 | 61 | var startPos = this.selectionStart; |
63 | 62 | var endPos = this.selectionEnd; |
64 | 63 | checkSelectedText(); |
— | — | @@ -82,9 +81,10 @@ |
83 | 82 | this.selectionStart = startPos + pre.length + selText.length + post.length; |
84 | 83 | this.selectionEnd = this.selectionStart; |
85 | 84 | } |
| 85 | + // Scroll the textarea to the inserted text |
| 86 | + $(this).scrollToCaretPosition(); |
86 | 87 | } else if ( document.selection && document.selection.createRange ) { |
87 | 88 | // IE |
88 | | - $(this).focus(); |
89 | 89 | var range = document.selection.createRange(); |
90 | 90 | if ( ownline && range.moveStart ) { |
91 | 91 | var range2 = document.selection.createRange(); |
— | — | @@ -109,8 +109,6 @@ |
110 | 110 | } |
111 | 111 | range.select(); |
112 | 112 | } |
113 | | - // Scroll the textarea to the inserted text |
114 | | - $(this).scrollToCaretPosition(); |
115 | 113 | $(this).trigger( 'encapsulateSelection', [ pre, peri, post, ownline, replace ] ); |
116 | 114 | }); |
117 | 115 | }, |
— | — | @@ -123,11 +121,18 @@ |
124 | 122 | * Get the position (in resolution of bytes not nessecarily characters) |
125 | 123 | * in a textarea |
126 | 124 | */ |
127 | | - getCaretPosition: function( startAndEnd ) { |
| 125 | + getCaretPosition: function( startAndEnd, restoreFocus ) { |
128 | 126 | function getCaret( e ) { |
129 | 127 | var caretPos = 0, endPos = 0; |
130 | 128 | if ( $.browser.msie ) { |
131 | 129 | // IE Support |
| 130 | + // Focus the textarea for this |
| 131 | + // If another element currently has focus, restore it |
| 132 | + var oldFocus = false; |
| 133 | + if ( restoreFocus ) |
| 134 | + oldFocus = document.selection.createRange().parentElement; |
| 135 | + e.focus(); |
| 136 | + |
132 | 137 | var postFinished = false; |
133 | 138 | var periFinished = false; |
134 | 139 | var postFinished = false; |
— | — | @@ -196,6 +201,9 @@ |
197 | 202 | } while ( ( !postFinished || !periFinished || !postFinished ) ); |
198 | 203 | caretPos = rawPreText.replace( /\r\n/g, "\n" ).length; |
199 | 204 | endPos = caretPos + rawPeriText.replace( /\r\n/g, "\n" ).length; |
| 205 | + // Restore focus |
| 206 | + if ( oldFocus && oldFocus.focus ) |
| 207 | + oldFocus.focus(); |
200 | 208 | } else if ( e.selectionStart || e.selectionStart == '0' ) { |
201 | 209 | // Firefox support |
202 | 210 | caretPos = e.selectionStart; |
— | — | @@ -224,8 +232,12 @@ |
225 | 233 | var selection = document.body.createTextRange(); |
226 | 234 | selection.moveToElementText( this ); |
227 | 235 | var length = selection.text.length; |
| 236 | + if ( start > length || end > length ) |
| 237 | + // Faulty data, ignore |
| 238 | + return; |
| 239 | + selection.collapse(); |
| 240 | + selection.moveEnd( 'character', end ); |
228 | 241 | selection.moveStart( 'character', start ); |
229 | | - selection.moveEnd( 'character', -length + end ); |
230 | 242 | selection.select(); |
231 | 243 | } |
232 | 244 | }); |
— | — | @@ -321,4 +333,4 @@ |
322 | 334 | } ); |
323 | 335 | } |
324 | 336 | |
325 | | -} ); } )( jQuery ); |
\ No newline at end of file |
| 337 | +} ); } )( jQuery ); |
Index: branches/usability/acaifix/js/plugins/jquery.wikiEditor.js |
— | — | @@ -171,7 +171,9 @@ |
172 | 172 | $(this).data( 'wikiEditor-cursor', false ); |
173 | 173 | }) |
174 | 174 | .blur( function() { |
175 | | - $(this).data( 'wikiEditor-cursor', $(this).getCaretPosition( true ) ); |
| 175 | + var pos = $(this).data( 'wikiEditor-cursor' ); |
| 176 | + if ( !$(this).data( 'wikiEditor-cursor' ) ) |
| 177 | + $(this).data( 'wikiEditor-cursor', $(this).getCaretPosition( true, true ) ); |
176 | 178 | }); |
177 | 179 | |
178 | 180 | // Create a set of standard methods for internal and external use |
— | — | @@ -237,4 +239,4 @@ |
238 | 240 | // Store the context for next time, and support chaining |
239 | 241 | return $(this).data( 'wikiEditor-context', context ); |
240 | 242 | |
241 | | -};})(jQuery); |
\ No newline at end of file |
| 243 | +};})(jQuery); |
Index: branches/usability/acaifix/js/plugins.combined.js |
— | — | @@ -879,13 +879,12 @@ |
880 | 880 | post += ' '; |
881 | 881 | } |
882 | 882 | } |
883 | | - var selText = $(this).getSelection(); |
| 883 | + var selText = $(this).focus().getSelection(); |
884 | 884 | var isSample = false; |
885 | 885 | if ( this.style.display == 'none' ) { |
886 | 886 | // Do nothing |
887 | 887 | } else if ( this.selectionStart || this.selectionStart == '0' ) { |
888 | 888 | // Mozilla/Opera |
889 | | - $(this).focus(); |
890 | 889 | var startPos = this.selectionStart; |
891 | 890 | var endPos = this.selectionEnd; |
892 | 891 | checkSelectedText(); |
— | — | @@ -910,9 +909,10 @@ |
911 | 910 | this.selectionStart = startPos + pre.length + selText.length + post.length; |
912 | 911 | this.selectionEnd = this.selectionStart; |
913 | 912 | } |
| 913 | + // Scroll the textarea to the inserted text |
| 914 | + $(this).scrollToCaretPosition(); |
914 | 915 | } else if ( document.selection && document.selection.createRange ) { |
915 | 916 | // IE |
916 | | - $(this).focus(); |
917 | 917 | var range = document.selection.createRange(); |
918 | 918 | if ( ownline && range.moveStart ) { |
919 | 919 | var range2 = document.selection.createRange(); |
— | — | @@ -937,8 +937,6 @@ |
938 | 938 | } |
939 | 939 | range.select(); |
940 | 940 | } |
941 | | - // Scroll the textarea to the inserted text |
942 | | - $(this).scrollToCaretPosition(); |
943 | 941 | $(this).trigger( 'encapsulateSelection', [ pre, peri, post, ownline, replace ] ); |
944 | 942 | }); |
945 | 943 | }, |
— | — | @@ -951,11 +949,18 @@ |
952 | 950 | * Get the position (in resolution of bytes not nessecarily characters) |
953 | 951 | * in a textarea |
954 | 952 | */ |
955 | | - getCaretPosition: function( startAndEnd ) { |
| 953 | + getCaretPosition: function( startAndEnd, restoreFocus ) { |
956 | 954 | function getCaret( e ) { |
957 | 955 | var caretPos = 0, endPos = 0; |
958 | 956 | if ( $.browser.msie ) { |
959 | 957 | // IE Support |
| 958 | + // Focus the textarea for this |
| 959 | + // If another element currently has focus, restore it |
| 960 | + var oldFocus = false; |
| 961 | + if ( restoreFocus ) |
| 962 | + oldFocus = document.selection.createRange().parentElement; |
| 963 | + e.focus(); |
| 964 | + |
960 | 965 | var postFinished = false; |
961 | 966 | var periFinished = false; |
962 | 967 | var postFinished = false; |
— | — | @@ -1024,6 +1029,9 @@ |
1025 | 1030 | } while ( ( !postFinished || !periFinished || !postFinished ) ); |
1026 | 1031 | caretPos = rawPreText.replace( /\r\n/g, "\n" ).length; |
1027 | 1032 | endPos = caretPos + rawPeriText.replace( /\r\n/g, "\n" ).length; |
| 1033 | + // Restore focus |
| 1034 | + if ( oldFocus && oldFocus.focus ) |
| 1035 | + oldFocus.focus(); |
1028 | 1036 | } else if ( e.selectionStart || e.selectionStart == '0' ) { |
1029 | 1037 | // Firefox support |
1030 | 1038 | caretPos = e.selectionStart; |
— | — | @@ -1052,8 +1060,12 @@ |
1053 | 1061 | var selection = document.body.createTextRange(); |
1054 | 1062 | selection.moveToElementText( this ); |
1055 | 1063 | var length = selection.text.length; |
| 1064 | + if ( start > length || end > length ) |
| 1065 | + // Faulty data, ignore |
| 1066 | + return; |
| 1067 | + selection.collapse(); |
| 1068 | + selection.moveEnd( 'character', end ); |
1056 | 1069 | selection.moveStart( 'character', start ); |
1057 | | - selection.moveEnd( 'character', -length + end ); |
1058 | 1070 | selection.select(); |
1059 | 1071 | } |
1060 | 1072 | }); |
— | — | @@ -1149,7 +1161,8 @@ |
1150 | 1162 | } ); |
1151 | 1163 | } |
1152 | 1164 | |
1153 | | -} ); } )( jQuery );/** |
| 1165 | +} ); } )( jQuery ); |
| 1166 | +/** |
1154 | 1167 | * This plugin provides a way to build a user interface around a textarea. You |
1155 | 1168 | * can build the UI from a confguration.. |
1156 | 1169 | * $j( 'div#edittoolbar' ).wikiEditor( |
— | — | @@ -1322,7 +1335,9 @@ |
1323 | 1336 | $(this).data( 'wikiEditor-cursor', false ); |
1324 | 1337 | }) |
1325 | 1338 | .blur( function() { |
1326 | | - $(this).data( 'wikiEditor-cursor', $(this).getCaretPosition( true ) ); |
| 1339 | + var pos = $(this).data( 'wikiEditor-cursor' ); |
| 1340 | + if ( !$(this).data( 'wikiEditor-cursor' ) ) |
| 1341 | + $(this).data( 'wikiEditor-cursor', $(this).getCaretPosition( true, true ) ); |
1327 | 1342 | }); |
1328 | 1343 | |
1329 | 1344 | // Create a set of standard methods for internal and external use |
— | — | @@ -1388,7 +1403,8 @@ |
1389 | 1404 | // Store the context for next time, and support chaining |
1390 | 1405 | return $(this).data( 'wikiEditor-context', context ); |
1391 | 1406 | |
1392 | | -};})(jQuery);/** |
| 1407 | +};})(jQuery); |
| 1408 | +/** |
1393 | 1409 | * Extend the RegExp object with an escaping function |
1394 | 1410 | * From http://simonwillison.net/2006/Jan/20/escape/ |
1395 | 1411 | */ |
Index: branches/usability/acaifix/js/plugins.combined.min.js |
— | — | @@ -52,22 +52,26 @@ |
53 | 53 | context.data.$container.hide();$.suggestions.cancel(context);});} |
54 | 54 | $(this).data('suggestions-context',context);});return returnValue!==null?returnValue:$(this);};})(jQuery);(function($){$.fn.extend({getSelection:function(){var e=this.jquery?this[0]:this;var retval='';if(e.style.display=='none'){}else if(document.selection&&document.selection.createRange){e.focus();var range=document.selection.createRange();retval=range.text;}else if(e.selectionStart||e.selectionStart=='0'){retval=e.value.substring(e.selectionStart,e.selectionEnd);} |
55 | 55 | return retval;},encapsulateSelection:function(pre,peri,post,ownline,replace){return this.each(function(){function checkSelectedText(){if(!selText){selText=peri;isSample=true;}else if(replace){selText=peri;}else if(selText.charAt(selText.length-1)==' '){selText=selText.substring(0,selText.length-1);post+=' ';}} |
56 | | -var selText=$(this).getSelection();var isSample=false;if(this.style.display=='none'){}else if(this.selectionStart||this.selectionStart=='0'){$(this).focus();var startPos=this.selectionStart;var endPos=this.selectionEnd;checkSelectedText();if(ownline){if(startPos!=0&&this.value.charAt(startPos-1)!="\n"){pre="\n"+pre;} |
| 56 | +var selText=$(this).focus().getSelection();var isSample=false;if(this.style.display=='none'){}else if(this.selectionStart||this.selectionStart=='0'){var startPos=this.selectionStart;var endPos=this.selectionEnd;checkSelectedText();if(ownline){if(startPos!=0&&this.value.charAt(startPos-1)!="\n"){pre="\n"+pre;} |
57 | 57 | if(this.value.charAt(endPos)!="\n"){post+="\n";}} |
58 | 58 | this.value=this.value.substring(0,startPos)+pre+selText+post+this.value.substring(endPos,this.value.length);if(window.opera){pre=pre.replace(/\r?\n/g,"\r\n");selText=selText.replace(/\r?\n/g,"\r\n");post=post.replace(/\r?\n/g,"\r\n");} |
59 | | -if(isSample){this.selectionStart=startPos+pre.length;this.selectionEnd=startPos+pre.length+selText.length;}else{this.selectionStart=startPos+pre.length+selText.length+post.length;this.selectionEnd=this.selectionStart;}}else if(document.selection&&document.selection.createRange){$(this).focus();var range=document.selection.createRange();if(ownline&&range.moveStart){var range2=document.selection.createRange();range2.collapse();range2.moveStart('character',-1);if(range2.text!="\r"&&range2.text!="\n"&&range2.text!=""){pre="\n"+pre;} |
| 59 | +if(isSample){this.selectionStart=startPos+pre.length;this.selectionEnd=startPos+pre.length+selText.length;}else{this.selectionStart=startPos+pre.length+selText.length+post.length;this.selectionEnd=this.selectionStart;} |
| 60 | +$(this).scrollToCaretPosition();}else if(document.selection&&document.selection.createRange){var range=document.selection.createRange();if(ownline&&range.moveStart){var range2=document.selection.createRange();range2.collapse();range2.moveStart('character',-1);if(range2.text!="\r"&&range2.text!="\n"&&range2.text!=""){pre="\n"+pre;} |
60 | 61 | var range3=document.selection.createRange();range3.collapse(false);range3.moveEnd('character',1);if(range3.text!="\r"&&range3.text!="\n"&&range3.text!=""){post+="\n";}} |
61 | 62 | checkSelectedText();range.text=pre+selText+post;if(isSample&&range.moveStart){range.moveStart('character',-post.length-selText.length);range.moveEnd('character',-post.length);} |
62 | 63 | range.select();} |
63 | | -$(this).scrollToCaretPosition();$(this).trigger('encapsulateSelection',[pre,peri,post,ownline,replace]);});},getCaretPosition:function(startAndEnd){function getCaret(e){var caretPos=0,endPos=0;if($.browser.msie){var postFinished=false;var periFinished=false;var postFinished=false;var preText,rawPreText,periText;var rawPeriText,postText,rawPostText;var periRange=document.selection.createRange().duplicate();var preRange=document.body.createTextRange();preRange.moveToElementText(e);preRange.setEndPoint("EndToStart",periRange);var postRange=document.body.createTextRange();postRange.moveToElementText(e);postRange.setEndPoint("StartToEnd",periRange);preText=rawPreText=preRange.text;periText=rawPeriText=periRange.text;postText=rawPostText=postRange.text;do{if(!postFinished){if(preRange.compareEndPoints("StartToEnd",preRange)==0){postFinished=true;}else{preRange.moveEnd("character",-1) |
| 64 | +$(this).trigger('encapsulateSelection',[pre,peri,post,ownline,replace]);});},getCaretPosition:function(startAndEnd,restoreFocus){function getCaret(e){var caretPos=0,endPos=0;if($.browser.msie){var oldFocus=false;if(restoreFocus) |
| 65 | +oldFocus=document.selection.createRange().parentElement;e.focus();var postFinished=false;var periFinished=false;var postFinished=false;var preText,rawPreText,periText;var rawPeriText,postText,rawPostText;var periRange=document.selection.createRange().duplicate();var preRange=document.body.createTextRange();preRange.moveToElementText(e);preRange.setEndPoint("EndToStart",periRange);var postRange=document.body.createTextRange();postRange.moveToElementText(e);postRange.setEndPoint("StartToEnd",periRange);preText=rawPreText=preRange.text;periText=rawPeriText=periRange.text;postText=rawPostText=postRange.text;do{if(!postFinished){if(preRange.compareEndPoints("StartToEnd",preRange)==0){postFinished=true;}else{preRange.moveEnd("character",-1) |
64 | 66 | if(preRange.text==preText){rawPreText+="\r\n";}else{postFinished=true;}}} |
65 | 67 | if(!periFinished){if(periRange.compareEndPoints("StartToEnd",periRange)==0){periFinished=true;}else{periRange.moveEnd("character",-1) |
66 | 68 | if(periRange.text==periText){rawPeriText+="\r\n";}else{periFinished=true;}}} |
67 | 69 | if(!postFinished){if(postRange.compareEndPoints("StartToEnd",postRange)==0){postFinished=true;}else{postRange.moveEnd("character",-1) |
68 | | -if(postRange.text==postText){rawPostText+="\r\n";}else{postFinished=true;}}}}while((!postFinished||!periFinished||!postFinished));caretPos=rawPreText.replace(/\r\n/g,"\n").length;endPos=caretPos+rawPeriText.replace(/\r\n/g,"\n").length;}else if(e.selectionStart||e.selectionStart=='0'){caretPos=e.selectionStart;endPos=e.selectionEnd;} |
| 70 | +if(postRange.text==postText){rawPostText+="\r\n";}else{postFinished=true;}}}}while((!postFinished||!periFinished||!postFinished));caretPos=rawPreText.replace(/\r\n/g,"\n").length;endPos=caretPos+rawPeriText.replace(/\r\n/g,"\n").length;if(oldFocus&&oldFocus.focus) |
| 71 | +oldFocus.focus();}else if(e.selectionStart||e.selectionStart=='0'){caretPos=e.selectionStart;endPos=e.selectionEnd;} |
69 | 72 | return startAndEnd?[caretPos,endPos]:caretPos;} |
70 | 73 | return getCaret(this.get(0));},setSelection:function(start,end){if(typeof end=='undefined') |
71 | | -end=start;return this.each(function(){if(this.selectionStart||this.selectionStart=='0'){if(start>this.selectionEnd){this.selectionEnd=end;this.selectionStart=start;}else{this.selectionStart=start;this.selectionEnd=end;}}else if(document.body.createTextRange){var selection=document.body.createTextRange();selection.moveToElementText(this);var length=selection.text.length;selection.moveStart('character',start);selection.moveEnd('character',-length+end);selection.select();}});},scrollToCaretPosition:function(force){function getLineLength(e){return Math.floor(e.scrollWidth/($.os.name=='linux'?7:8));} |
| 74 | +end=start;return this.each(function(){if(this.selectionStart||this.selectionStart=='0'){if(start>this.selectionEnd){this.selectionEnd=end;this.selectionStart=start;}else{this.selectionStart=start;this.selectionEnd=end;}}else if(document.body.createTextRange){var selection=document.body.createTextRange();selection.moveToElementText(this);var length=selection.text.length;if(start>length||end>length) |
| 75 | +return;selection.collapse();selection.moveEnd('character',end);selection.moveStart('character',start);selection.select();}});},scrollToCaretPosition:function(force){function getLineLength(e){return Math.floor(e.scrollWidth/($.os.name=='linux'?7:8));} |
72 | 76 | function getCaretScrollPosition(e){var text=e.value.replace(/\r/g,"");var caret=$(e).getCaretPosition();var lineLength=getLineLength(e);var row=0;var charInLine=0;var lastSpaceInLine=0;for(i=0;i<caret;i++){charInLine++;if(text.charAt(i)==" "){lastSpaceInLine=charInLine;}else if(text.charAt(i)=="\n"){lastSpaceInLine=0;charInLine=0;row++;} |
73 | 77 | if(charInLine>lineLength){if(lastSpaceInLine>0){charInLine=charInLine-lastSpaceInLine;lastSpaceInLine=0;row++;}}} |
74 | 78 | var nextSpace=0;for(j=caret;j<caret+lineLength;j++){if(text.charAt(j)==" "||text.charAt(j)=="\n"||caret==text.length){nextSpace=j;break;}} |
— | — | @@ -84,7 +88,8 @@ |
85 | 89 | $.isOperaBroken=true;div.remove();} |
86 | 90 | if($.isOperaBroken) |
87 | 91 | s=s.replace(/\n/g,"\r\n");return s;};$.fn.wikiEditor=function(){var context=$(this).data('wikiEditor-context');if(typeof context=='undefined'){var instance=$.wikiEditor.instances.length;context={'$textarea':$(this),'modules':{},'data':{},'instance':instance};$.wikiEditor.instances[instance]=$(this);$(this).wrap($('<div></div>').addClass('wikiEditor-ui').attr('id','wikiEditor-ui')).wrap($('<div></div>').addClass('wikiEditor-ui-bottom').attr('id','wikiEditor-ui-bottom')).wrap($('<div></div>').addClass('wikiEditor-ui-text').attr('id','wikiEditor-ui-text'));context.$ui=$(this).parent().parent().parent();context.$ui.after($('<div style="clear:both;"></div>'));context.$ui.prepend($('<div></div>').addClass('wikiEditor-ui-top').attr('id','wikiEditor-ui-top'));$(this).focus(function(){var pos=$(this).data('wikiEditor-cursor');if(pos) |
88 | | -$(this).setSelection(pos[0],pos[1]);$(this).data('wikiEditor-cursor',false);}).blur(function(){$(this).data('wikiEditor-cursor',$(this).getCaretPosition(true));});context.api={addModule:function(context,data){function callModuleApi(module,call,data){if(module in $.wikiEditor.modules&&'fn'in $.wikiEditor.modules[module]&&call in $.wikiEditor.modules[module].fn){$.wikiEditor.modules[module].fn[call](context,data);}} |
| 92 | +$(this).setSelection(pos[0],pos[1]);$(this).data('wikiEditor-cursor',false);}).blur(function(){var pos=$(this).data('wikiEditor-cursor');if(!$(this).data('wikiEditor-cursor')) |
| 93 | +$(this).data('wikiEditor-cursor',$(this).getCaretPosition(true,true));});context.api={addModule:function(context,data){function callModuleApi(module,call,data){if(module in $.wikiEditor.modules&&'fn'in $.wikiEditor.modules[module]&&call in $.wikiEditor.modules[module].fn){$.wikiEditor.modules[module].fn[call](context,data);}} |
89 | 94 | if(typeof data=='string'){callModuleApi(data,'create',{});}else if(typeof data=='object'){for(module in data){if(typeof module=='string'){callModuleApi(module,'create',data[module]);}}}}};for(module in $.wikiEditor.modules){if('api'in $.wikiEditor.modules[module]){for(call in $.wikiEditor.modules[module].api){if(!(call in context.api)){context.api[call]=$.wikiEditor.modules[module].api[call];}}}}} |
90 | 95 | if(arguments.length>0&&typeof arguments[0]=='object'){context.api.addModule(context,arguments[0]);}else{arguments=$.makeArray(arguments);if(arguments.length>0){var call=arguments.shift();if(call in context.api){context.api[call](context,arguments[0]==undefined?{}:arguments[0]);}}} |
91 | 96 | return $(this).data('wikiEditor-context',context);};})(jQuery);RegExp.escape=function(s){return s.replace(/([.*+?^${}()|\/\\[\]])/g,'\\$1');};(function($){$.wikiEditor.modules.dialogs={api:{addDialog:function(context,data){$.wikiEditor.modules.dialogs.fn.create(context,{'modules':data})},openDialog:function(context,data){if(data.dialog in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[data.dialog].id).dialog('open');}},closeDialog:function(context,data){if(data.dialog in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[data.dialog].id).dialog('close');}}},fn:{create:function(context,config){for(module in config){$.wikiEditor.modules.dialogs.modules[module]=config[module];} |