Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -22,15 +22,15 @@ |
23 | 23 | array( 'src' => 'css/wikiEditor.css', 'version' => 4 ), |
24 | 24 | array( 'src' => 'css/wikiEditor.toolbar.css', 'version' => 5 ), |
25 | 25 | array( 'src' => 'css/wikiEditor.dialogs.css', 'version' => 2 ), |
26 | | - array( 'src' => 'css/wikiEditor.toc.css', 'version' => 5 ), |
| 26 | + array( 'src' => 'css/wikiEditor.toc.css', 'version' => 6 ), |
27 | 27 | array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2' ), |
28 | 28 | ), |
29 | 29 | 'combined' => array( |
30 | | - array( 'src' => 'css/combined.css', 'version' => 9 ), |
| 30 | + array( 'src' => 'css/combined.css', 'version' => 10 ), |
31 | 31 | array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2' ), |
32 | 32 | ), |
33 | 33 | 'minified' => array( |
34 | | - array( 'src' => 'css/combined.min.css', 'version' => 9 ), |
| 34 | + array( 'src' => 'css/combined.min.css', 'version' => 10 ), |
35 | 35 | array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2' ), |
36 | 36 | ), |
37 | 37 | ) |
— | — | @@ -63,20 +63,20 @@ |
64 | 64 | array( 'src' => 'js/plugins/jquery.delayedBind.js', 'version' => 1 ), |
65 | 65 | array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ), |
66 | 66 | array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 4 ), |
67 | | - array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 15 ), |
68 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 9 ), |
| 67 | + array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 16 ), |
| 68 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 10 ), |
69 | 69 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 11 ), |
70 | 70 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 4 ), |
71 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 17 ), |
| 71 | + array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 18 ), |
72 | 72 | // FIXME: jQuery UI doesn't belong here, should move to no_js2 |
73 | 73 | // once we figure out how to do jQuery UI properly in JS2 |
74 | 74 | array( 'src' => 'js/js2/jquery-ui-1.7.2.js', 'version' => '1.7.2y' ), |
75 | 75 | ), |
76 | 76 | 'combined' => array( |
77 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 39 ), |
| 77 | + array( 'src' => 'js/plugins.combined.js', 'version' => 40 ), |
78 | 78 | ), |
79 | 79 | 'minified' => array( |
80 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 39 ), |
| 80 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 40 ), |
81 | 81 | ), |
82 | 82 | ), |
83 | 83 | ); |
Index: trunk/extensions/UsabilityInitiative/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 = 50; |
| 23 | +$wgEditToolbarStyleVersion = 51; |
24 | 24 | |
25 | 25 | // Set this to true to simply override the stock toolbar for everyone |
26 | 26 | $wgEditToolbarGlobalEnable = false; |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js |
— | — | @@ -1144,7 +1144,7 @@ |
1145 | 1145 | $j.wikiEditor.modules.toolbar.fn.doAction( |
1146 | 1146 | $j(this).data( 'context' ), |
1147 | 1147 | { |
1148 | | - type: 'encapsulate', |
| 1148 | + type: 'replace', |
1149 | 1149 | options: { |
1150 | 1150 | pre: "{|\n", |
1151 | 1151 | peri: table, |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.textSelection.js |
— | — | @@ -118,9 +118,9 @@ |
119 | 119 | * Get the position (in resolution of bytes not nessecarily characters) |
120 | 120 | * in a textarea |
121 | 121 | */ |
122 | | - getCaretPosition: function() { |
| 122 | + getCaretPosition: function( startAndEnd ) { |
123 | 123 | function getCaret( e ) { |
124 | | - var caretPos = 0; |
| 124 | + var caretPos = 0, endPos = 0; |
125 | 125 | if ( $.browser.msie ) { |
126 | 126 | // IE Support |
127 | 127 | var postFinished = false; |
— | — | @@ -190,11 +190,13 @@ |
191 | 191 | } |
192 | 192 | } while ( ( !postFinished || !periFinished || !postFinished ) ); |
193 | 193 | caretPos = rawPreText.replace( /\r\n/g, "\n" ).length; |
| 194 | + endPos = caretPos + rawPeriText.replace( /\r\n/g, "\n" ).length; |
194 | 195 | } else if ( e.selectionStart || e.selectionStart == '0' ) { |
195 | 196 | // Firefox support |
196 | 197 | caretPos = e.selectionStart; |
| 198 | + endPos = e.selectionEnd; |
197 | 199 | } |
198 | | - return caretPos; |
| 200 | + return startAndEnd ? [ caretPos, endPos ] : caretPos; |
199 | 201 | } |
200 | 202 | return getCaret( this.get( 0 ) ); |
201 | 203 | }, |
— | — | @@ -280,7 +282,6 @@ |
281 | 283 | return ( $.os.name == 'mac' ? 13 : ( $.os.name == 'linux' ? 15 : 16 ) ) * row; |
282 | 284 | } |
283 | 285 | return this.each(function() { |
284 | | - $(this).focus(); |
285 | 286 | if ( this.selectionStart || this.selectionStart == '0' ) { |
286 | 287 | // Mozilla |
287 | 288 | var scroll = getCaretScrollPosition( this ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -118,6 +118,18 @@ |
119 | 119 | // Attach a container in the top |
120 | 120 | context.$ui.prepend( $( '<div></div>' ).addClass( 'wikiEditor-ui-top' ).attr( 'id', 'wikiEditor-ui-top' ) ); |
121 | 121 | |
| 122 | + // Some browsers don't restore the cursor position on refocus properly |
| 123 | + // Do it for them |
| 124 | + $(this) |
| 125 | + .focus( function() { |
| 126 | + var pos = $(this).data( 'wikiEditor-cursor' ); |
| 127 | + if ( typeof pos != 'undefined' ) |
| 128 | + $(this).setSelection( pos[0], pos[1] ); |
| 129 | + }) |
| 130 | + .blur( function() { |
| 131 | + $(this).data( 'wikiEditor-cursor', $(this).getCaretPosition( true ) ); |
| 132 | + }); |
| 133 | + |
122 | 134 | // Create a set of standard methods for internal and external use |
123 | 135 | context.api = { |
124 | 136 | /** |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js |
— | — | @@ -156,6 +156,7 @@ |
157 | 157 | .data( 'position', structure[i].position ) |
158 | 158 | .click( function( event ) { |
159 | 159 | $(this).data( 'textbox' ) |
| 160 | + .focus() |
160 | 161 | .setSelection( $(this).data( 'position' ) ) |
161 | 162 | .scrollToCaretPosition( true ); |
162 | 163 | event.preventDefault(); |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -942,9 +942,9 @@ |
943 | 943 | * Get the position (in resolution of bytes not nessecarily characters) |
944 | 944 | * in a textarea |
945 | 945 | */ |
946 | | - getCaretPosition: function() { |
| 946 | + getCaretPosition: function( startAndEnd ) { |
947 | 947 | function getCaret( e ) { |
948 | | - var caretPos = 0; |
| 948 | + var caretPos = 0, endPos = 0; |
949 | 949 | if ( $.browser.msie ) { |
950 | 950 | // IE Support |
951 | 951 | var postFinished = false; |
— | — | @@ -1014,11 +1014,13 @@ |
1015 | 1015 | } |
1016 | 1016 | } while ( ( !postFinished || !periFinished || !postFinished ) ); |
1017 | 1017 | caretPos = rawPreText.replace( /\r\n/g, "\n" ).length; |
| 1018 | + endPos = caretPos + rawPeriText.replace( /\r\n/g, "\n" ).length; |
1018 | 1019 | } else if ( e.selectionStart || e.selectionStart == '0' ) { |
1019 | 1020 | // Firefox support |
1020 | 1021 | caretPos = e.selectionStart; |
| 1022 | + endPos = e.selectionEnd; |
1021 | 1023 | } |
1022 | | - return caretPos; |
| 1024 | + return startAndEnd ? [ caretPos, endPos ] : caretPos; |
1023 | 1025 | } |
1024 | 1026 | return getCaret( this.get( 0 ) ); |
1025 | 1027 | }, |
— | — | @@ -1104,7 +1106,6 @@ |
1105 | 1107 | return ( $.os.name == 'mac' ? 13 : ( $.os.name == 'linux' ? 15 : 16 ) ) * row; |
1106 | 1108 | } |
1107 | 1109 | return this.each(function() { |
1108 | | - $(this).focus(); |
1109 | 1110 | if ( this.selectionStart || this.selectionStart == '0' ) { |
1110 | 1111 | // Mozilla |
1111 | 1112 | var scroll = getCaretScrollPosition( this ); |
— | — | @@ -1259,6 +1260,18 @@ |
1260 | 1261 | // Attach a container in the top |
1261 | 1262 | context.$ui.prepend( $( '<div></div>' ).addClass( 'wikiEditor-ui-top' ).attr( 'id', 'wikiEditor-ui-top' ) ); |
1262 | 1263 | |
| 1264 | + // Some browsers don't restore the cursor position on refocus properly |
| 1265 | + // Do it for them |
| 1266 | + $(this) |
| 1267 | + .focus( function() { |
| 1268 | + var pos = $(this).data( 'wikiEditor-cursor' ); |
| 1269 | + if ( typeof pos != 'undefined' ) |
| 1270 | + $(this).setSelection( pos[0], pos[1] ); |
| 1271 | + }) |
| 1272 | + .blur( function() { |
| 1273 | + $(this).data( 'wikiEditor-cursor', $(this).getCaretPosition( true ) ); |
| 1274 | + }); |
| 1275 | + |
1263 | 1276 | // Create a set of standard methods for internal and external use |
1264 | 1277 | context.api = { |
1265 | 1278 | /** |
— | — | @@ -2055,6 +2068,8 @@ |
2056 | 2069 | context.modules.$toc = $( '<div />' ) |
2057 | 2070 | .addClass( 'wikiEditor-ui-toc' ) |
2058 | 2071 | .attr( 'id', 'wikiEditor-ui-toc' ); |
| 2072 | + // If we ask for this later (after we insert the TOC) then in IE this measurement will be incorrect |
| 2073 | + var height = context.$ui.find( '.wikiEditor-ui-bottom' ).height() |
2059 | 2074 | context.$ui.find( '.wikiEditor-ui-bottom' ) |
2060 | 2075 | .append( context.modules.$toc ); |
2061 | 2076 | context.modules.$toc.height( |
— | — | @@ -2062,10 +2077,7 @@ |
2063 | 2078 | ); |
2064 | 2079 | // Make some css modifications to make room for the toc on the right... |
2065 | 2080 | // Perhaps this could be configurable? |
2066 | | - context.modules.$toc |
2067 | | - .css( { 'width': '12em', |
2068 | | - 'marginTop': -( context.$ui.find( '.wikiEditor-ui-bottom' ).height() ) |
2069 | | - } ); |
| 2081 | + context.modules.$toc.css( { 'width': '12em', 'marginTop': -( height ) } ); |
2070 | 2082 | context.$ui.find( '.wikiEditor-ui-text' ) |
2071 | 2083 | .css( ( $( 'body.rtl' ).size() ? 'marginLeft' : 'marginRight' ), '12em' ); |
2072 | 2084 | // Add the TOC to the document |
— | — | @@ -2186,6 +2198,7 @@ |
2187 | 2199 | .data( 'position', structure[i].position ) |
2188 | 2200 | .click( function( event ) { |
2189 | 2201 | $(this).data( 'textbox' ) |
| 2202 | + .focus() |
2190 | 2203 | .setSelection( $(this).data( 'position' ) ) |
2191 | 2204 | .scrollToCaretPosition( true ); |
2192 | 2205 | event.preventDefault(); |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -61,13 +61,13 @@ |
62 | 62 | var range3=document.selection.createRange();range3.collapse(false);range3.moveEnd('character',1);if(range3.text!="\r"&&range3.text!="\n"&&range3.text!=""){post+="\n";}} |
63 | 63 | checkSelectedText();range.text=pre+selText+post;if(isSample&&range.moveStart){range.moveStart('character',-post.length-selText.length);range.moveEnd('character',-post.length);} |
64 | 64 | range.select();} |
65 | | -$(this).scrollToCaretPosition();$(this).trigger('encapsulateSelection',[pre,peri,post,ownline,replace]);});},getCaretPosition:function(){function getCaret(e){var caretPos=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) |
| 65 | +$(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) |
66 | 66 | if(preRange.text==preText){rawPreText+="\r\n";}else{postFinished=true;}}} |
67 | 67 | if(!periFinished){if(periRange.compareEndPoints("StartToEnd",periRange)==0){periFinished=true;}else{periRange.moveEnd("character",-1) |
68 | 68 | if(periRange.text==periText){rawPeriText+="\r\n";}else{periFinished=true;}}} |
69 | 69 | if(!postFinished){if(postRange.compareEndPoints("StartToEnd",postRange)==0){postFinished=true;}else{postRange.moveEnd("character",-1) |
70 | | -if(postRange.text==postText){rawPostText+="\r\n";}else{postFinished=true;}}}}while((!postFinished||!periFinished||!postFinished));caretPos=rawPreText.replace(/\r\n/g,"\n").length;}else if(e.selectionStart||e.selectionStart=='0'){caretPos=e.selectionStart;} |
71 | | -return caretPos;} |
| 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;}else if(e.selectionStart||e.selectionStart=='0'){caretPos=e.selectionStart;endPos=e.selectionEnd;} |
| 71 | +return startAndEnd?[caretPos,endPos]:caretPos;} |
72 | 72 | return getCaret(this.get(0));},setSelection:function(start,end){if(typeof end=='undefined') |
73 | 73 | 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 | 74 | 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++;} |
— | — | @@ -75,7 +75,7 @@ |
76 | 76 | var nextSpace=0;for(j=caret;j<caret+lineLength;j++){if(text.charAt(j)==" "||text.charAt(j)=="\n"||caret==text.length){nextSpace=j;break;}} |
77 | 77 | if(nextSpace>lineLength&&caret<=lineLength){charInLine=caret-lastSpaceInLine;row++;} |
78 | 78 | return($.os.name=='mac'?13:($.os.name=='linux'?15:16))*row;} |
79 | | -return this.each(function(){$(this).focus();if(this.selectionStart||this.selectionStart=='0'){var scroll=getCaretScrollPosition(this);if(force||scroll<$(this).scrollTop()||scroll>$(this).scrollTop()+$(this).height()) |
| 79 | +return this.each(function(){if(this.selectionStart||this.selectionStart=='0'){var scroll=getCaretScrollPosition(this);if(force||scroll<$(this).scrollTop()||scroll>$(this).scrollTop()+$(this).height()) |
80 | 80 | $(this).scrollTop(scroll);}else if(document.selection&&document.selection.createRange){var range=document.selection.createRange();var pos=$(this).getCaretPosition();var oldScrollTop=this.scrollTop;range.moveToElementText(this);range.collapse();range.move('character',pos+1);range.select();if(this.scrollTop!=oldScrollTop) |
81 | 81 | this.scrollTop+=range.offsetTop;else if(force){range.move('character',-1);range.select();}} |
82 | 82 | $(this).trigger('scrollToPosition');});}});})(jQuery);(function($){$.wikiEditor={'modules':{},'instances':[],'supportedBrowsers':{'ltr':{'msie':7,'firefox':2,'opera':9,'safari':3,'chrome':1,'camino':1},'rtl':{'msie':8,'firefox':2,'opera':9,'safari':3,'chrome':1,'camino':1}},imgPath:wgScriptPath+'/extensions/UsabilityInitiative/images/wikiEditor/'};$.wikiEditor.isSupportKnown=function(){return(function(supportedBrowsers){return $.browser.name in supportedBrowsers;})($.wikiEditor.supportedBrowsers[$('body.rtl').size()?'rtl':'ltr']);};$.wikiEditor.isSupported=function(){return(function(supportedBrowsers){return $.browser.name in supportedBrowsers&&$.browser.versionNumber>=supportedBrowsers[$.browser.name];})($.wikiEditor.supportedBrowsers[$('body.rtl').size()?'rtl':'ltr']);};$.wikiEditor.autoMsg=function(object,property){if(typeof property=='object'){for(i in property){if(property[i]in object||property[i]+'Msg'in object){property=property[i];break;}}} |
— | — | @@ -83,7 +83,8 @@ |
84 | 84 | $.isOperaBroken=false;else |
85 | 85 | $.isOperaBroken=true;div.remove();} |
86 | 86 | if($.isOperaBroken) |
87 | | -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'));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);}} |
| 87 | +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(typeof pos!='undefined') |
| 88 | +$(this).setSelection(pos[0],pos[1]);}).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);}} |
88 | 89 | 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];}}}}} |
89 | 90 | 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]);}}} |
90 | 91 | 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];} |
— | — | @@ -138,14 +139,15 @@ |
139 | 140 | return $section;},updateBookletSelection:function(context,id,$pages,$index){var cookie='wikiEditor-'+context.instance+'-booklet-'+id+'-page';var selected=$.cookie(cookie);var $selectedIndex=$index.find('*[rel='+selected+']');if($selectedIndex.size()==0){selected=$index.children().eq(0).attr('rel');$.cookie(cookie,selected);} |
140 | 141 | $pages.children().hide();$pages.find('*[rel='+selected+']').show();$index.children().removeClass('current');$selectedIndex.addClass('current');},build:function(context,config){var $tabs=$('<div />').addClass('tabs').appendTo(context.modules.$toolbar);var $sections=$('<div />').addClass('sections').appendTo(context.modules.$toolbar);context.modules.$toolbar.append($('<div />').css('clear','both'));var sectionQueue=[];for(section in config){if(section=='main'){context.modules.$toolbar.prepend($.wikiEditor.modules.toolbar.fn.buildSection(context,section,config[section]));}else{sectionQueue.push({'$sections':$sections,'context':context,'id':section,'config':config[section]});$tabs.append($.wikiEditor.modules.toolbar.fn.buildTab(context,section,config[section]));}} |
141 | 142 | $.eachAsync(sectionQueue,{'bulk':0,'end':function(){$('body').css('position','static');$('body').css('position','relative');},'loop':function(i,s){s.$sections.append($.wikiEditor.modules.toolbar.fn.buildSection(s.context,s.id,s.config));}});}}};})(jQuery);(function($){$.wikiEditor.modules.toc={api:{},fn:{create:function(context,config){if('$toc'in context.modules){return;} |
142 | | -context.modules.$toc=$('<div />').addClass('wikiEditor-ui-toc').attr('id','wikiEditor-ui-toc');context.$ui.find('.wikiEditor-ui-bottom').append(context.modules.$toc);context.modules.$toc.height(context.$ui.find('.wikiEditor-ui-bottom').height());context.modules.$toc.css({'width':'12em','marginTop':-(context.$ui.find('.wikiEditor-ui-bottom').height())});context.$ui.find('.wikiEditor-ui-text').css(($('body.rtl').size()?'marginLeft':'marginRight'),'12em');$.wikiEditor.modules.toc.fn.build(context,config);context.$textarea.delayedBind(1000,'keyup encapsulateSelection change',function(event){var context=$(this).data('wikiEditor-context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).bind('mouseup scrollToPosition focus keyup encapsulateSelection change',function(event){var context=$(this).data('wikiEditor-context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.update(context);}});}).blur(function(){var context=$(this).data('wikiEditor-context');$.wikiEditor.modules.toc.fn.unhighlight(context);});},unhighlight:function(context){context.modules.$toc.find('a').removeClass('currentSelection');},update:function(context){$.wikiEditor.modules.toc.fn.unhighlight(context);var position=context.$textarea.getCaretPosition();var section=0;if(context.data.outline.length>0){if(!(position<context.data.outline[0].position-1)){while(section<context.data.outline.length&&context.data.outline[section].position-1<position){section++;} |
| 143 | +context.modules.$toc=$('<div />').addClass('wikiEditor-ui-toc').attr('id','wikiEditor-ui-toc');var height=context.$ui.find('.wikiEditor-ui-bottom').height() |
| 144 | +context.$ui.find('.wikiEditor-ui-bottom').append(context.modules.$toc);context.modules.$toc.height(context.$ui.find('.wikiEditor-ui-bottom').height());context.modules.$toc.css({'width':'12em','marginTop':-(height)});context.$ui.find('.wikiEditor-ui-text').css(($('body.rtl').size()?'marginLeft':'marginRight'),'12em');$.wikiEditor.modules.toc.fn.build(context,config);context.$textarea.delayedBind(1000,'keyup encapsulateSelection change',function(event){var context=$(this).data('wikiEditor-context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).bind('mouseup scrollToPosition focus keyup encapsulateSelection change',function(event){var context=$(this).data('wikiEditor-context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.update(context);}});}).blur(function(){var context=$(this).data('wikiEditor-context');$.wikiEditor.modules.toc.fn.unhighlight(context);});},unhighlight:function(context){context.modules.$toc.find('a').removeClass('currentSelection');},update:function(context){$.wikiEditor.modules.toc.fn.unhighlight(context);var position=context.$textarea.getCaretPosition();var section=0;if(context.data.outline.length>0){if(!(position<context.data.outline[0].position-1)){while(section<context.data.outline.length&&context.data.outline[section].position-1<position){section++;} |
143 | 145 | section=Math.max(0,section);} |
144 | 146 | var sectionLink=context.modules.$toc.find('a.section-'+section);sectionLink.addClass('currentSelection');var relTop=sectionLink.offset().top-context.modules.$toc.offset().top;var scrollTop=context.modules.$toc.scrollTop();var divHeight=context.modules.$toc.height();var sectionHeight=sectionLink.height();if(relTop<0) |
145 | 147 | context.modules.$toc.scrollTop(scrollTop+relTop);else if(relTop+sectionHeight>divHeight) |
146 | 148 | context.modules.$toc.scrollTop(scrollTop+relTop+sectionHeight-divHeight);}},build:function(context){function buildStructure(outline,offset,level){if(offset==undefined)offset=0;if(level==undefined)level=1;var sections=[];for(var i=offset;i<outline.length;i++){if(outline[i].nLevel==level){var sub=buildStructure(outline,i+1,level+1);if(sub.length){outline[i].sections=sub;} |
147 | 149 | sections[sections.length]=outline[i];}else if(outline[i].nLevel<level){break;}} |
148 | 150 | return sections;} |
149 | | -function buildList(structure){var list=$('<ul />');for(i in structure){var item=$('<li />').append($('<a />').attr('href','#').addClass('section-'+structure[i].index).data('textbox',context.$textarea).data('position',structure[i].position).click(function(event){$(this).data('textbox').setSelection($(this).data('position')).scrollToCaretPosition(true);event.preventDefault();}).text(structure[i].text));if(structure[i].sections!==undefined){item.append(buildList(structure[i].sections));} |
| 151 | +function buildList(structure){var list=$('<ul />');for(i in structure){var item=$('<li />').append($('<a />').attr('href','#').addClass('section-'+structure[i].index).data('textbox',context.$textarea).data('position',structure[i].position).click(function(event){$(this).data('textbox').focus().setSelection($(this).data('position')).scrollToCaretPosition(true);event.preventDefault();}).text(structure[i].text));if(structure[i].sections!==undefined){item.append(buildList(structure[i].sections));} |
150 | 152 | list.append(item);} |
151 | 153 | return list;} |
152 | 154 | var outline=[];var wikitext=$.wikiEditor.fixOperaBrokenness(context.$textarea.val());var headings=wikitext.match(/^={1,6}.+={1,6}\s*$/gm);var offset=0;headings=$.makeArray(headings);for(var h=0;h<headings.length;h++){text=$.trim(headings[h]);var position=wikitext.indexOf(text,offset);if(position>=offset){offset=position+1;}else if(position==-1){continue;} |
Index: trunk/extensions/UsabilityInitiative/css/combined.css |
— | — | @@ -127,6 +127,10 @@ |
128 | 128 | padding: 0; |
129 | 129 | margin: 0.5em 1em; |
130 | 130 | list-style: none; |
| 131 | + /* IE needs to be told in great detail how to act, or it misbehaves */ |
| 132 | + list-style-image: none; |
| 133 | + list-style-position: outside; |
| 134 | + list-style-type: none; |
131 | 135 | } |
132 | 136 | .wikiEditor-ui-toc ul ul { |
133 | 137 | padding: 0; |
Index: trunk/extensions/UsabilityInitiative/css/combined.min.css |
— | — | @@ -115,6 +115,9 @@ |
116 | 116 | padding:0; |
117 | 117 | margin:0.5em 1em; |
118 | 118 | list-style:none; |
| 119 | +list-style-image:none; |
| 120 | +list-style-position:outside; |
| 121 | +list-style-type:none; |
119 | 122 | } |
120 | 123 | .wikiEditor-ui-toc ul ul{ |
121 | 124 | padding:0; |