Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -68,24 +68,24 @@ |
69 | 69 | array( 'src' => 'js/plugins/jquery.collapsibleTabs.js', 'version' => 5 ), |
70 | 70 | array( 'src' => 'js/plugins/jquery.cookie.js', 'version' => 3 ), |
71 | 71 | array( 'src' => 'js/plugins/jquery.delayedBind.js', 'version' => 1 ), |
72 | | - array( 'src' => 'js/plugins/jquery.inherit.js', 'version' => 1 ), |
| 72 | + array( 'src' => 'js/plugins/jquery.inherit.js', 'version' => 2 ), |
73 | 73 | array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ), |
74 | 74 | array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 7 ), |
75 | | - array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 21 ), |
76 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 42 ), |
| 75 | + array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 22 ), |
| 76 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 43 ), |
77 | 77 | array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 12 ), |
78 | 78 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 40 ), |
79 | 79 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 10 ), |
80 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 56 ), |
| 80 | + array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 57 ), |
81 | 81 | array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 9 ), |
82 | 82 | array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 14 ), |
83 | 83 | array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 1 ), |
84 | 84 | ), |
85 | 85 | 'combined' => array( |
86 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 134 ), |
| 86 | + array( 'src' => 'js/plugins.combined.js', 'version' => 135 ), |
87 | 87 | ), |
88 | 88 | 'minified' => array( |
89 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 134 ), |
| 89 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 135 ), |
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.textSelection.js |
— | — | @@ -348,7 +348,7 @@ |
349 | 349 | break; |
350 | 350 | case 'getCaretPosition': |
351 | 351 | options = $.extend( { |
352 | | - 'startAndEnd': false, // Return [start, end] instead of just start |
| 352 | + 'startAndEnd': false // Return [start, end] instead of just start |
353 | 353 | }, options ); |
354 | 354 | // FIXME: We may not need character position-based functions if we insert markers in the right places |
355 | 355 | break; |
— | — | @@ -357,7 +357,7 @@ |
358 | 358 | 'start': undefined, // Position to start selection at |
359 | 359 | 'end': undefined, // Position to end selection at. Defaults to start |
360 | 360 | 'startContainer': undefined, // Element to start selection in (iframe only) |
361 | | - 'endContainer': undefined, // Element to end selection in (iframe only). Defaults to startContainer |
| 361 | + 'endContainer': undefined // Element to end selection in (iframe only). Defaults to startContainer |
362 | 362 | }, options ); |
363 | 363 | if ( options.end === undefined ) |
364 | 364 | options.end = options.start; |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | // Minimum width to allow resizing to before collapsing the table of contents - used when resizing and collapsing |
12 | 12 | minimumWidth: '70px', |
13 | 13 | // Boolean var indicating text direction |
14 | | - rtl: false, |
| 14 | + rtl: false |
15 | 15 | }, |
16 | 16 | /** |
17 | 17 | * API accessible functions |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.inherit.js |
— | — | @@ -105,7 +105,8 @@ |
106 | 106 | // Test and see if we're handling a shortcut bind for the document.ready function. This occurs when the selector |
107 | 107 | // is a function. Because firefox throws xpconnect objects around in iFrames, the standard |
108 | 108 | // jQuery.isFunction test returns false negatives. |
109 | | - if ( selector.constructor.toString().match( /Function/ ) != null ) { |
| 109 | + // PATCHED: Disable this check because it breaks subtly on IE7 and we don't use $j( function() { ... } ) anyway |
| 110 | + if ( false && selector.constructor.toString().match( /Function/ ) != null ) { |
110 | 111 | return child.jQueryInherit.fn.ready( selector ); |
111 | 112 | } |
112 | 113 | // Otherwise, just let the jQuery init function handle the rest. Be sure we pass in proper context of the |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -506,12 +506,12 @@ |
507 | 507 | * @param endContainer Element in iframe to end selection in |
508 | 508 | */ |
509 | 509 | 'setSelection': function( options ) { |
| 510 | + var sc = options.startContainer, ec = options.endContainer; |
| 511 | + sc = sc.jquery ? sc[0] : sc; |
| 512 | + ec = ec.jquery ? ec[0] : ec; |
510 | 513 | if ( context.$iframe[0].contentWindow.getSelection ) { |
511 | 514 | // Firefox and Opera |
512 | 515 | var sel = context.$iframe[0].contentWindow.getSelection(); |
513 | | - var sc = options.startContainer, ec = options.endContainer; |
514 | | - sc = sc.jquery ? sc[0] : sc; |
515 | | - ec = ec.jquery ? ec[0] : ec; |
516 | 516 | while ( sc.firstChild && sc.nodeName != '#text' ) { |
517 | 517 | sc = sc.firstChild; |
518 | 518 | } |
— | — | @@ -527,7 +527,15 @@ |
528 | 528 | context.$iframe[0].contentWindow.focus(); |
529 | 529 | } else if ( context.$iframe[0].contentWindow.document.selection ) { |
530 | 530 | // IE |
531 | | - // TODO |
| 531 | + // FIXME still broken for when sc or ec is the <body>, needs more tweaking |
| 532 | + var range = document.selection.createRange(); |
| 533 | + range.moveToElementText( sc ); |
| 534 | + range.moveStart( 'character', options.start ); |
| 535 | + var range2 = document.selection.createRange(); |
| 536 | + range2.moveToElementText( ec ); |
| 537 | + range2.moveEnd( 'character', options.end ); |
| 538 | + range.setEndPoint( EndToEnd, range2 ); |
| 539 | + range.select(); |
532 | 540 | } |
533 | 541 | }, |
534 | 542 | /** |
— | — | @@ -669,7 +677,7 @@ |
670 | 678 | } ) |
671 | 679 | .insertAfter( context.$textarea ) |
672 | 680 | .load( function() { |
673 | | - if(!$( context.$iframe[0].contentWindow.document.body )){ |
| 681 | + if ( !context.$iframe[0].contentWindow.document.body ) { |
674 | 682 | return; |
675 | 683 | } |
676 | 684 | // Turn the document's design mode on |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -1278,7 +1278,7 @@ |
1279 | 1279 | break; |
1280 | 1280 | case 'getCaretPosition': |
1281 | 1281 | options = $.extend( { |
1282 | | - 'startAndEnd': false, // Return [start, end] instead of just start |
| 1282 | + 'startAndEnd': false // Return [start, end] instead of just start |
1283 | 1283 | }, options ); |
1284 | 1284 | // FIXME: We may not need character position-based functions if we insert markers in the right places |
1285 | 1285 | break; |
— | — | @@ -1287,7 +1287,7 @@ |
1288 | 1288 | 'start': undefined, // Position to start selection at |
1289 | 1289 | 'end': undefined, // Position to end selection at. Defaults to start |
1290 | 1290 | 'startContainer': undefined, // Element to start selection in (iframe only) |
1291 | | - 'endContainer': undefined, // Element to end selection in (iframe only). Defaults to startContainer |
| 1291 | + 'endContainer': undefined // Element to end selection in (iframe only). Defaults to startContainer |
1292 | 1292 | }, options ); |
1293 | 1293 | if ( options.end === undefined ) |
1294 | 1294 | options.end = options.start; |
— | — | @@ -1816,12 +1816,12 @@ |
1817 | 1817 | * @param endContainer Element in iframe to end selection in |
1818 | 1818 | */ |
1819 | 1819 | 'setSelection': function( options ) { |
| 1820 | + var sc = options.startContainer, ec = options.endContainer; |
| 1821 | + sc = sc.jquery ? sc[0] : sc; |
| 1822 | + ec = ec.jquery ? ec[0] : ec; |
1820 | 1823 | if ( context.$iframe[0].contentWindow.getSelection ) { |
1821 | 1824 | // Firefox and Opera |
1822 | 1825 | var sel = context.$iframe[0].contentWindow.getSelection(); |
1823 | | - var sc = options.startContainer, ec = options.endContainer; |
1824 | | - sc = sc.jquery ? sc[0] : sc; |
1825 | | - ec = ec.jquery ? ec[0] : ec; |
1826 | 1826 | while ( sc.firstChild && sc.nodeName != '#text' ) { |
1827 | 1827 | sc = sc.firstChild; |
1828 | 1828 | } |
— | — | @@ -1837,7 +1837,15 @@ |
1838 | 1838 | context.$iframe[0].contentWindow.focus(); |
1839 | 1839 | } else if ( context.$iframe[0].contentWindow.document.selection ) { |
1840 | 1840 | // IE |
1841 | | - // TODO |
| 1841 | + // FIXME still broken for when sc or ec is the <body>, needs more tweaking |
| 1842 | + var range = document.selection.createRange(); |
| 1843 | + range.moveToElementText( sc ); |
| 1844 | + range.moveStart( 'character', options.start ); |
| 1845 | + var range2 = document.selection.createRange(); |
| 1846 | + range2.moveToElementText( ec ); |
| 1847 | + range2.moveEnd( 'character', options.end ); |
| 1848 | + range.setEndPoint( EndToEnd, range2 ); |
| 1849 | + range.select(); |
1842 | 1850 | } |
1843 | 1851 | }, |
1844 | 1852 | /** |
— | — | @@ -1979,6 +1987,9 @@ |
1980 | 1988 | } ) |
1981 | 1989 | .insertAfter( context.$textarea ) |
1982 | 1990 | .load( function() { |
| 1991 | + if ( !context.$iframe[0].contentWindow.document.body ) { |
| 1992 | + return; |
| 1993 | + } |
1983 | 1994 | // Turn the document's design mode on |
1984 | 1995 | context.$iframe[0].contentWindow.document.designMode = 'on'; |
1985 | 1996 | // Get a reference to the content area of the iframe |
— | — | @@ -3147,8 +3158,14 @@ |
3148 | 3159 | if ( currentField.indexOf( '=' ) == -1 ) { |
3149 | 3160 | // anonymous field, gets a number |
3150 | 3161 | valueBegin = currentField.match( /\S+/ ); //first nonwhitespace character |
| 3162 | + if( valueBegin == null ){ //ie |
| 3163 | + continue; |
| 3164 | + } |
3151 | 3165 | valueBeginIndex = valueBegin.index + oldDivider+1; |
3152 | 3166 | valueEnd = currentField.match( /[^\s]\s*$/ ); //last nonwhitespace character |
| 3167 | + if( valueEnd == null ){ //ie |
| 3168 | + continue; |
| 3169 | + } |
3153 | 3170 | valueEndIndex = valueEnd.index + oldDivider + 2; |
3154 | 3171 | ranges.push( new Range( ranges[ranges.length-1].end, |
3155 | 3172 | valueBeginIndex ) ); //all the chars upto now |
— | — | @@ -3177,6 +3194,9 @@ |
3178 | 3195 | nameBeginIndex = nameBegin.index + oldDivider + 1; |
3179 | 3196 | // Last nonwhitespace and non } character |
3180 | 3197 | nameEnd = currentName.match( /[^\s]\s*$/ ); |
| 3198 | + if( nameEnd == null ){ //ie |
| 3199 | + continue; |
| 3200 | + } |
3181 | 3201 | nameEndIndex = nameEnd.index + oldDivider + 2; |
3182 | 3202 | // All the chars upto now |
3183 | 3203 | ranges.push( new Range( ranges[ranges.length-1].end, nameBeginIndex ) ); |
— | — | @@ -3185,9 +3205,15 @@ |
3186 | 3206 | oldDivider += currentField.indexOf( '=' ) + 1; |
3187 | 3207 | // First nonwhitespace character |
3188 | 3208 | valueBegin = currentValue.match( /\S+/ ); |
| 3209 | + if( valueBegin == null ){ //ie |
| 3210 | + continue; |
| 3211 | + } |
3189 | 3212 | valueBeginIndex = valueBegin.index + oldDivider + 1; |
3190 | 3213 | // Last nonwhitespace and non } character |
3191 | 3214 | valueEnd = currentValue.match( /[^\s]\s*$/ ); |
| 3215 | + if( valueEnd == null ){ //ie |
| 3216 | + continue; |
| 3217 | + } |
3192 | 3218 | valueEndIndex = valueEnd.index + oldDivider + 2; |
3193 | 3219 | // All the chars upto now |
3194 | 3220 | equalsIndex = ranges.push( new Range( ranges[ranges.length-1].end, valueBeginIndex) ) - 1; |
— | — | @@ -3228,7 +3254,7 @@ |
3229 | 3255 | // Minimum width to allow resizing to before collapsing the table of contents - used when resizing and collapsing |
3230 | 3256 | minimumWidth: '70px', |
3231 | 3257 | // Boolean var indicating text direction |
3232 | | - rtl: false, |
| 3258 | + rtl: false |
3233 | 3259 | }, |
3234 | 3260 | /** |
3235 | 3261 | * API accessible functions |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -79,7 +79,7 @@ |
80 | 80 | return this.each(function(){if($(this).is(':hidden')){}else if(this.selectionStart||this.selectionStart=='0'){var scroll=getCaretScrollPosition(this);if(options.force||scroll<$(this).scrollTop()||scroll>$(this).scrollTop()+$(this).height()) |
81 | 81 | $(this).scrollTop(scroll);}else if(document.selection&&document.selection.createRange){var range=document.selection.createRange();var pos=$(this).textSelection('getCaretPosition');var oldScrollTop=this.scrollTop;range.moveToElementText(this);range.collapse();range.move('character',pos+1);range.select();if(this.scrollTop!=oldScrollTop) |
82 | 82 | this.scrollTop+=range.offsetTop;else if(options.force){range.move('character',-1);range.select();}} |
83 | | -$(this).trigger('scrollToPosition');});}};switch(command){case'encapsulateSelection':options=$.extend({'pre':'','peri':'','post':'','ownline':false,'replace':false},options);break;case'getCaretPosition':options=$.extend({'startAndEnd':false,},options);break;case'setSelection':options=$.extend({'start':undefined,'end':undefined,'startContainer':undefined,'endContainer':undefined,},options);if(options.end===undefined) |
| 83 | +$(this).trigger('scrollToPosition');});}};switch(command){case'encapsulateSelection':options=$.extend({'pre':'','peri':'','post':'','ownline':false,'replace':false},options);break;case'getCaretPosition':options=$.extend({'startAndEnd':false},options);break;case'setSelection':options=$.extend({'start':undefined,'end':undefined,'startContainer':undefined,'endContainer':undefined},options);if(options.end===undefined) |
84 | 84 | options.end=options.start;if(options.endContainer==undefined) |
85 | 85 | options.endContainer=options.startContainer;break;case'scrollToCaretPosition':options=$.extend({'force':false},options);break;} |
86 | 86 | var context=$(this).data('wikiEditor-context');var hasIframe=context!==undefined&&context.$iframe!==undefined;return(hasIframe?context.fn:fn)[command].call(this,options);};})(jQuery);(function($){$.wikiEditor={'modules':{},'instances':[],'browsers':{'ltr':{'msie':[['>=',7]],'firefox':[['>=',2],['!=','2.0'],['!=','2.0.0.1'],['!=','2.0.0.2'],['!=','2.0.0.3'],['!=','2.0.0.4']],'opera':[['>=',9.6]],'safari':[['>=',3.1]]},'rtl':{'msie':[['>=',8]],'firefox':[['>=',2],['!=','2.0'],['!=','2.0.0.1'],['!=','2.0.0.2'],['!=','2.0.0.3'],['!=','2.0.0.4']],'opera':[['>=',9.6]],'safari':[['>=',3.1]]}},'imgPath':wgScriptPath+'/extensions/UsabilityInitiative/images/wikiEditor/','isSupported':function(){if(typeof $.wikiEditor.supported!='undefined'){return $.wikiEditor.supported;} |
— | — | @@ -107,9 +107,9 @@ |
108 | 108 | if(range.endContainer==range.commonAncestorContainer){post+="\n";}} |
109 | 109 | var insertText=pre+selText+post;var insertLines=insertText.split("\n");range.extractContents();var lastNode;for(var i=insertLines.length-1;i>=0;i--){range.insertNode(document.createTextNode(insertLines[i]));if(i>0){lastNode=range.insertNode(document.createElement('br'));}} |
110 | 110 | if(lastNode){context.fn.scrollToTop(lastNode);}}else if(context.$iframe[0].contentWindow.document.selection){} |
111 | | -context.$content.trigger('encapsulateSelection',[pre,options.peri,post,options.ownline,options.replace]);return context.$textarea;},'getCaretPosition':function(options){},'setSelection':function(options){if(context.$iframe[0].contentWindow.getSelection){var sel=context.$iframe[0].contentWindow.getSelection();var sc=options.startContainer,ec=options.endContainer;sc=sc.jquery?sc[0]:sc;ec=ec.jquery?ec[0]:ec;while(sc.firstChild&&sc.nodeName!='#text'){sc=sc.firstChild;} |
| 111 | +context.$content.trigger('encapsulateSelection',[pre,options.peri,post,options.ownline,options.replace]);return context.$textarea;},'getCaretPosition':function(options){},'setSelection':function(options){var sc=options.startContainer,ec=options.endContainer;sc=sc.jquery?sc[0]:sc;ec=ec.jquery?ec[0]:ec;if(context.$iframe[0].contentWindow.getSelection){var sel=context.$iframe[0].contentWindow.getSelection();while(sc.firstChild&&sc.nodeName!='#text'){sc=sc.firstChild;} |
112 | 112 | while(ec.firstChild&&ec.nodeName!='#text'){ec=ec.firstChild;} |
113 | | -var range=document.createRange();range.setStart(sc,options.start);range.setEnd(ec,options.end);sel.removeAllRanges();sel.addRange(range);context.$iframe[0].contentWindow.focus();}else if(context.$iframe[0].contentWindow.document.selection){}},'scrollToCaretPosition':function(options){},'scrollToTop':function($element,force){var html=context.$content.closest('html'),body=context.$content.closest('body');var y=$element.offset().top-context.$content.offset().top;if(force||y<html.scrollTop()||y<body.scrollTop()||y>html.scrollTop()+context.$iframe.height()||y>body.scrollTop()+context.$iframe.height()){html.scrollTop(y);body.scrollTop(y);} |
| 113 | +var range=document.createRange();range.setStart(sc,options.start);range.setEnd(ec,options.end);sel.removeAllRanges();sel.addRange(range);context.$iframe[0].contentWindow.focus();}else if(context.$iframe[0].contentWindow.document.selection){var range=document.selection.createRange();range.moveToElementText(sc);range.moveStart('character',options.start);var range2=document.selection.createRange();range2.moveToElementText(ec);range2.moveEnd('character',options.end);range.setEndPoint(EndToEnd,range2);range.select();}},'scrollToCaretPosition':function(options){},'scrollToTop':function($element,force){var html=context.$content.closest('html'),body=context.$content.closest('body');var y=$element.offset().top-context.$content.offset().top;if(force||y<html.scrollTop()||y<body.scrollTop()||y>html.scrollTop()+context.$iframe.height()||y>body.scrollTop()+context.$iframe.height()){html.scrollTop(y);body.scrollTop(y);} |
114 | 114 | $element.trigger('scrollToTop');},'beforeSelection':function(selector,strict){if(typeof selector=='undefined') |
115 | 115 | selector='*';var e;if(context.$iframe[0].contentWindow.getSelection){var range=context.$iframe[0].contentWindow.getSelection().getRangeAt(0);e=range.startContainer;}else if(context.$iframe[0].contentWindow.document.selection){return $([]);} |
116 | 116 | if(e.nodeName!='#text'){var newE=e.firstChild;for(var i=0;i<range.startOffset-1&&newE;i++){newE=newE.nextSibling;} |
— | — | @@ -118,7 +118,8 @@ |
119 | 119 | while(e){if($(e).is(selector)&&!strict) |
120 | 120 | return $(e);var next=e.previousSibling;while(next&&next.lastChild){next=next.lastChild;} |
121 | 121 | e=next||e.parentNode;strict=false;} |
122 | | -return $([]);}};context.$textarea.wrap($('<div></div>').addClass('wikiEditor-ui')).wrap($('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-wikitext')).wrap($('<div></div>').addClass('wikiEditor-ui-left')).wrap($('<div></div>').addClass('wikiEditor-ui-bottom')).wrap($('<div></div>').addClass('wikiEditor-ui-text'));context.$ui=context.$textarea.parent().parent().parent().parent().parent();context.$wikitext=context.$textarea.parent().parent().parent().parent();context.$wikitext.before($('<div></div>').addClass('wikiEditor-ui-controls').append($('<div></div>').addClass('wikiEditor-ui-tabs').hide()).append($('<div></div>').addClass('wikiEditor-ui-buttons'))).before($('<div style="clear:both;"></div>'));context.$controls=context.$ui.find('.wikiEditor-ui-buttons').hide();context.$buttons=context.$ui.find('.wikiEditor-ui-buttons');context.$tabs=context.$ui.find('.wikiEditor-ui-tabs');context.$ui.after($('<div style="clear:both;"></div>'));context.$wikitext.append($('<div></div>').addClass('wikiEditor-ui-right'));context.$wikitext.find('.wikiEditor-ui-left').prepend($('<div></div>').addClass('wikiEditor-ui-top'));context.view='wikitext';$(window).resize(function(event){context.fn.trigger('resize',event)});context.$iframe=$('<iframe></iframe>').attr({'frameborder':0,'src':wgScriptPath+'/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.html?'+'instance='+context.instance+'&ts='+(new Date()).getTime(),'id':'wikiEditor-iframe-'+context.instance}).css({'backgroundColor':'white','width':'100%','height':context.$textarea.height(),'display':'none','overflow-y':'scroll','overflow-x':'hidden'}).insertAfter(context.$textarea).load(function(){context.$iframe[0].contentWindow.document.designMode='on';context.$content=$(context.$iframe[0].contentWindow.document.body);context.$content.append(context.$textarea.val().replace(/</g,'<').replace(/>/g,'>'));if($('body').is('.rtl')){context.$content.addClass('rtl').attr('dir','rtl');} |
| 122 | +return $([]);}};context.$textarea.wrap($('<div></div>').addClass('wikiEditor-ui')).wrap($('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-wikitext')).wrap($('<div></div>').addClass('wikiEditor-ui-left')).wrap($('<div></div>').addClass('wikiEditor-ui-bottom')).wrap($('<div></div>').addClass('wikiEditor-ui-text'));context.$ui=context.$textarea.parent().parent().parent().parent().parent();context.$wikitext=context.$textarea.parent().parent().parent().parent();context.$wikitext.before($('<div></div>').addClass('wikiEditor-ui-controls').append($('<div></div>').addClass('wikiEditor-ui-tabs').hide()).append($('<div></div>').addClass('wikiEditor-ui-buttons'))).before($('<div style="clear:both;"></div>'));context.$controls=context.$ui.find('.wikiEditor-ui-buttons').hide();context.$buttons=context.$ui.find('.wikiEditor-ui-buttons');context.$tabs=context.$ui.find('.wikiEditor-ui-tabs');context.$ui.after($('<div style="clear:both;"></div>'));context.$wikitext.append($('<div></div>').addClass('wikiEditor-ui-right'));context.$wikitext.find('.wikiEditor-ui-left').prepend($('<div></div>').addClass('wikiEditor-ui-top'));context.view='wikitext';$(window).resize(function(event){context.fn.trigger('resize',event)});context.$iframe=$('<iframe></iframe>').attr({'frameborder':0,'src':wgScriptPath+'/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.html?'+'instance='+context.instance+'&ts='+(new Date()).getTime(),'id':'wikiEditor-iframe-'+context.instance}).css({'backgroundColor':'white','width':'100%','height':context.$textarea.height(),'display':'none','overflow-y':'scroll','overflow-x':'hidden'}).insertAfter(context.$textarea).load(function(){if(!context.$iframe[0].contentWindow.document.body){return;} |
| 123 | +context.$iframe[0].contentWindow.document.designMode='on';context.$content=$(context.$iframe[0].contentWindow.document.body);context.$content.append(context.$textarea.val().replace(/</g,'<').replace(/>/g,'>'));if($('body').is('.rtl')){context.$content.addClass('rtl').attr('dir','rtl');} |
123 | 124 | context.$textarea.attr('disabled',true);context.$textarea.hide();context.$iframe.show();context.fn.trigger('ready');});context.$textarea.closest('form').submit(function(){context.$textarea.attr('disabled',false);context.$textarea.val(context.$textarea.textSelection('getContents'));});} |
124 | 125 | arguments=$.makeArray(arguments);if(arguments.length>0){var call=arguments.shift();if(call in context.api){context.api[call](context,typeof arguments[0]=='undefined'?{}:arguments[0]);}} |
125 | 126 | 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,data)},openDialog:function(context,module){if(module in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[module].id).dialog('open');}},closeDialog:function(context,data){if(module in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[module].id).dialog('close');}}},fn:{create:function(context,config){for(module in config){$.wikiEditor.modules.dialogs.modules[module]=config[module];} |
— | — | @@ -200,9 +201,14 @@ |
201 | 202 | var ranges=[];var params=[];var templateNameIndex=0;var doneParsing=false;oldDivider=0;divider=sanatizedStr.indexOf('|',oldDivider);if(divider==-1){divider=sanatizedStr.length;doneParsing=true;} |
202 | 203 | nameMatch=wikitext.substring(0,divider).match(/[^{\s]+/);if(nameMatch!=undefined){ranges.push(new Range(0,nameMatch.index));nameEndMatch=sanatizedStr.substring(0,divider).match(/[^\s]\s*$/);templateNameIndex=ranges.push(new Range(nameMatch.index,nameEndMatch.index+1));templateNameIndex--;ranges[templateNameIndex].old=wikitext.substring(ranges[templateNameIndex].begin,ranges[templateNameIndex].end);} |
203 | 204 | params.push(ranges[templateNameIndex].old);var currentParamNumber=0;var valueEndIndex;var paramsByName=[];while(!doneParsing){currentParamNumber++;oldDivider=divider;divider=sanatizedStr.indexOf('|',oldDivider+1);if(divider==-1){divider=sanatizedStr.length;doneParsing=true;} |
204 | | -currentField=sanatizedStr.substring(oldDivider+1,divider);if(currentField.indexOf('=')==-1){valueBegin=currentField.match(/\S+/);valueBeginIndex=valueBegin.index+oldDivider+1;valueEnd=currentField.match(/[^\s]\s*$/);valueEndIndex=valueEnd.index+oldDivider+2;ranges.push(new Range(ranges[ranges.length-1].end,valueBeginIndex));nameIndex=ranges.push(new Range(valueBeginIndex,valueBeginIndex))-1;equalsIndex=ranges.push(new Range(valueBeginIndex,valueBeginIndex))-1;valueIndex=ranges.push(new Range(valueBeginIndex,valueEndIndex))-1;params.push(new Param(currentParamNumber,wikitext.substring(ranges[valueIndex].begin,ranges[valueIndex].end),currentParamNumber,nameIndex,equalsIndex,valueIndex));paramsByName[currentParamNumber]=currentParamNumber;}else{currentName=currentField.substring(0,currentField.indexOf('='));nameBegin=currentName.match(/\S+/);if(nameBegin==null){currentParamNumber--;continue;} |
205 | | -nameBeginIndex=nameBegin.index+oldDivider+1;nameEnd=currentName.match(/[^\s]\s*$/);nameEndIndex=nameEnd.index+oldDivider+2;ranges.push(new Range(ranges[ranges.length-1].end,nameBeginIndex));nameIndex=ranges.push(new Range(nameBeginIndex,nameEndIndex))-1;currentValue=currentField.substring(currentField.indexOf('=')+1);oldDivider+=currentField.indexOf('=')+1;valueBegin=currentValue.match(/\S+/);valueBeginIndex=valueBegin.index+oldDivider+1;valueEnd=currentValue.match(/[^\s]\s*$/);valueEndIndex=valueEnd.index+oldDivider+2;equalsIndex=ranges.push(new Range(ranges[ranges.length-1].end,valueBeginIndex))-1;valueIndex=ranges.push(new Range(valueBeginIndex,valueEndIndex))-1;params.push(new Param(wikitext.substring(nameBeginIndex,nameEndIndex),wikitext.substring(valueBeginIndex,valueEndIndex),currentParamNumber,nameIndex,equalsIndex,valueIndex));paramsByName[wikitext.substring(nameBeginIndex,nameEndIndex)]=currentParamNumber;}} |
206 | | -ranges.push(new Range(valueEndIndex,wikitext.length));this.ranges=ranges;this.wikitext=wikitext;this.params=params;this.paramsByName=paramsByName;this.templateNameIndex=templateNameIndex;}}};})(jQuery);(function($){$.wikiEditor.modules.toc={cfg:{defaultWidth:'166px',minimumWidth:'70px',rtl:false,},api:{},evt:{ready:function(context,event){$.wikiEditor.modules.toc.fn.build(context);context.$content.parent().blur(function(event){var context=event.data.context;$.wikiEditor.modules.toc.fn.unhighlight(context);});},resize:function(context,event){context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').height()- |
| 205 | +currentField=sanatizedStr.substring(oldDivider+1,divider);if(currentField.indexOf('=')==-1){valueBegin=currentField.match(/\S+/);if(valueBegin==null){continue;} |
| 206 | +valueBeginIndex=valueBegin.index+oldDivider+1;valueEnd=currentField.match(/[^\s]\s*$/);if(valueEnd==null){continue;} |
| 207 | +valueEndIndex=valueEnd.index+oldDivider+2;ranges.push(new Range(ranges[ranges.length-1].end,valueBeginIndex));nameIndex=ranges.push(new Range(valueBeginIndex,valueBeginIndex))-1;equalsIndex=ranges.push(new Range(valueBeginIndex,valueBeginIndex))-1;valueIndex=ranges.push(new Range(valueBeginIndex,valueEndIndex))-1;params.push(new Param(currentParamNumber,wikitext.substring(ranges[valueIndex].begin,ranges[valueIndex].end),currentParamNumber,nameIndex,equalsIndex,valueIndex));paramsByName[currentParamNumber]=currentParamNumber;}else{currentName=currentField.substring(0,currentField.indexOf('='));nameBegin=currentName.match(/\S+/);if(nameBegin==null){currentParamNumber--;continue;} |
| 208 | +nameBeginIndex=nameBegin.index+oldDivider+1;nameEnd=currentName.match(/[^\s]\s*$/);if(nameEnd==null){continue;} |
| 209 | +nameEndIndex=nameEnd.index+oldDivider+2;ranges.push(new Range(ranges[ranges.length-1].end,nameBeginIndex));nameIndex=ranges.push(new Range(nameBeginIndex,nameEndIndex))-1;currentValue=currentField.substring(currentField.indexOf('=')+1);oldDivider+=currentField.indexOf('=')+1;valueBegin=currentValue.match(/\S+/);if(valueBegin==null){continue;} |
| 210 | +valueBeginIndex=valueBegin.index+oldDivider+1;valueEnd=currentValue.match(/[^\s]\s*$/);if(valueEnd==null){continue;} |
| 211 | +valueEndIndex=valueEnd.index+oldDivider+2;equalsIndex=ranges.push(new Range(ranges[ranges.length-1].end,valueBeginIndex))-1;valueIndex=ranges.push(new Range(valueBeginIndex,valueEndIndex))-1;params.push(new Param(wikitext.substring(nameBeginIndex,nameEndIndex),wikitext.substring(valueBeginIndex,valueEndIndex),currentParamNumber,nameIndex,equalsIndex,valueIndex));paramsByName[wikitext.substring(nameBeginIndex,nameEndIndex)]=currentParamNumber;}} |
| 212 | +ranges.push(new Range(valueEndIndex,wikitext.length));this.ranges=ranges;this.wikitext=wikitext;this.params=params;this.paramsByName=paramsByName;this.templateNameIndex=templateNameIndex;}}};})(jQuery);(function($){$.wikiEditor.modules.toc={cfg:{defaultWidth:'166px',minimumWidth:'70px',rtl:false},api:{},evt:{ready:function(context,event){$.wikiEditor.modules.toc.fn.build(context);context.$content.parent().blur(function(event){var context=event.data.context;$.wikiEditor.modules.toc.fn.unhighlight(context);});},resize:function(context,event){context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').height()- |
207 | 213 | context.$ui.find('.tab-toc').outerHeight());},mark:function(context,event){var markers=context.modules.highlight.markers;var tokenArray=context.modules.highlight.tokenArray;var outline=context.data.outline=[];var h=0;for(var i=0;i<tokenArray.length;i++){if(tokenArray[i].label!='TOC_HEADER'){continue;} |
208 | 214 | h++;markers.push({index:h,start:tokenArray[i].tokenStart,end:tokenArray[i].offset,afterWrap:function(node){var marker=$(node).data('marker');$(node).addClass('wikiEditor-toc-header').addClass('wikiEditor-toc-section-'+marker.index).data('section',marker.index);},getWrapper:function(ca1,ca2){return $(ca1.parentNode).is('div.wikiEditor-toc-header')&&ca1.previousSibling==null&&ca1.nextSibling==null?ca1.parentNode:null;}});outline.push({'text':tokenArray[i].match[2],'level':tokenArray[i].match[1].length,'index':h});} |
209 | 215 | $.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}},exp:[{'regex':/^(={1,6})(.+?)\1\s*$/m,'label':'TOC_HEADER','markAfter':true}],fn:{create:function(context,config){if('$toc'in context.modules.toc){return;} |