http://www.mediawiki.org/wiki/Special:Code/MediaWiki/60813

Revision: 60813
Author:   catrope
Date:     2010-01-07 22:54:53 +0000 (Thu, 07 Jan 2010)

Log Message:
-----------
* UsabilityInitiative: Add context.fn.setSelection() implementation for IE. 
Barely tested and known to be broken, but it's a start
* IE fixes
** Patched jQuery inherit plugin to disable a conditional that breaks on IE7 
and that we don't need anyway
** Fix r60812 per CR comment
** Remove trailing commas all over the place

Modified Paths:
--------------
    trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
    trunk/extensions/UsabilityInitiative/js/plugins/jquery.inherit.js
    trunk/extensions/UsabilityInitiative/js/plugins/jquery.textSelection.js
    trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
    trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js
    trunk/extensions/UsabilityInitiative/js/plugins.combined.js
    trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js

Modified: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
===================================================================
--- trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php  
2010-01-07 22:08:31 UTC (rev 60812)
+++ trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php  
2010-01-07 22:54:53 UTC (rev 60813)
@@ -68,24 +68,24 @@
                                array( 'src' => 
'js/plugins/jquery.collapsibleTabs.js', 'version' => 5 ),
                                array( 'src' => 'js/plugins/jquery.cookie.js', 
'version' => 3 ),
                                array( 'src' => 
'js/plugins/jquery.delayedBind.js', 'version' => 1 ),
-                               array( 'src' => 'js/plugins/jquery.inherit.js', 
'version' => 1 ),
+                               array( 'src' => 'js/plugins/jquery.inherit.js', 
'version' => 2 ),
                                array( 'src' => 
'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ),
                                array( 'src' => 
'js/plugins/jquery.suggestions.js', 'version' => 7 ),
-                               array( 'src' => 
'js/plugins/jquery.textSelection.js', 'version' => 21 ),
-                               array( 'src' => 
'js/plugins/jquery.wikiEditor.js', 'version' => 42 ),
+                               array( 'src' => 
'js/plugins/jquery.textSelection.js', 'version' => 22 ),
+                               array( 'src' => 
'js/plugins/jquery.wikiEditor.js', 'version' => 43 ),
                                array( 'src' => 
'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 12 ),
                                array( 'src' => 
'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 40 ),
                                array( 'src' => 
'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 10 ),
-                               array( 'src' => 
'js/plugins/jquery.wikiEditor.toc.js', 'version' => 56 ),
+                               array( 'src' => 
'js/plugins/jquery.wikiEditor.toc.js', 'version' => 57 ),
                                array( 'src' => 
'js/plugins/jquery.wikiEditor.preview.js', 'version' => 9 ),
                                array( 'src' => 
'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 14 ),
                                array( 'src' => 
'js/plugins/jquery.wikiEditor.publish.js', 'version' => 1 ),
                        ),
                        'combined' => array(
-                               array( 'src' => 'js/plugins.combined.js', 
'version' => 134 ),
+                               array( 'src' => 'js/plugins.combined.js', 
'version' => 135 ),
                        ),
                        'minified' => array(
-                               array( 'src' => 'js/plugins.combined.min.js', 
'version' => 134 ),
+                               array( 'src' => 'js/plugins.combined.min.js', 
'version' => 135 ),
                        ),
                ),
        );

Modified: trunk/extensions/UsabilityInitiative/js/plugins/jquery.inherit.js
===================================================================
--- trunk/extensions/UsabilityInitiative/js/plugins/jquery.inherit.js   
2010-01-07 22:08:31 UTC (rev 60812)
+++ trunk/extensions/UsabilityInitiative/js/plugins/jquery.inherit.js   
2010-01-07 22:54:53 UTC (rev 60813)
@@ -105,7 +105,8 @@
                // Test and see if we're handling a shortcut bind for the 
document.ready function. This occurs when the selector
                // is a function. Because firefox throws xpconnect objects 
around in iFrames, the standard
                // jQuery.isFunction test returns false negatives.
-               if ( selector.constructor.toString().match( /Function/ ) != 
null ) {
+               // PATCHED: Disable this check because it breaks subtly on IE7 
and we don't use $j( function() { ... } ) anyway
+               if ( false && selector.constructor.toString().match( /Function/ 
) != null ) {
                        return child.jQueryInherit.fn.ready( selector );
                }
                // Otherwise, just let the jQuery init function handle the 
rest. Be sure we pass in proper context of the

Modified: 
trunk/extensions/UsabilityInitiative/js/plugins/jquery.textSelection.js
===================================================================
--- trunk/extensions/UsabilityInitiative/js/plugins/jquery.textSelection.js     
2010-01-07 22:08:31 UTC (rev 60812)
+++ trunk/extensions/UsabilityInitiative/js/plugins/jquery.textSelection.js     
2010-01-07 22:54:53 UTC (rev 60813)
@@ -348,7 +348,7 @@
                        break;
                case 'getCaretPosition':
                        options = $.extend( {
-                               'startAndEnd': false, // Return [start, end] 
instead of just start
+                               'startAndEnd': false // Return [start, end] 
instead of just start
                        }, options );
                        // FIXME: We may not need character position-based 
functions if we insert markers in the right places
                        break;
@@ -357,7 +357,7 @@
                                'start': undefined, // Position to start 
selection at
                                'end': undefined, // Position to end selection 
at. Defaults to start
                                'startContainer': undefined, // Element to 
start selection in (iframe only)
-                               'endContainer': undefined, // Element to end 
selection in (iframe only). Defaults to startContainer
+                               'endContainer': undefined // Element to end 
selection in (iframe only). Defaults to startContainer
                        }, options );
                        if ( options.end === undefined )
                                options.end = options.start;

Modified: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
===================================================================
--- trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js        
2010-01-07 22:08:31 UTC (rev 60812)
+++ trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js        
2010-01-07 22:54:53 UTC (rev 60813)
@@ -506,12 +506,12 @@
                 * @param endContainer Element in iframe to end selection in
                 */
                '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 ) {
                                // Firefox and Opera
                                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;
                                }
@@ -527,7 +527,15 @@
                                context.$iframe[0].contentWindow.focus();
                        } else if ( 
context.$iframe[0].contentWindow.document.selection ) {
                                // IE
-                               // TODO
+                               // FIXME still broken for when sc or ec is the 
<body>, needs more tweaking
+                               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();
                        }
                },
                /**
@@ -669,7 +677,7 @@
                } )
                .insertAfter( context.$textarea )
                .load( function() {
-                       if(!$( context.$iframe[0].contentWindow.document.body 
)){
+                       if ( !context.$iframe[0].contentWindow.document.body ) {
                                return;
                        }
                        // Turn the document's design mode on

Modified: 
trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js
===================================================================
--- trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js    
2010-01-07 22:08:31 UTC (rev 60812)
+++ trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js    
2010-01-07 22:54:53 UTC (rev 60813)
@@ -10,7 +10,7 @@
        // Minimum width to allow resizing to before collapsing the table of 
contents - used when resizing and collapsing
        minimumWidth: '70px',
        // Boolean var indicating text direction
-       rtl: false, 
+       rtl: false
 },
 /**
  * API accessible functions

Modified: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
===================================================================
--- trunk/extensions/UsabilityInitiative/js/plugins.combined.js 2010-01-07 
22:08:31 UTC (rev 60812)
+++ trunk/extensions/UsabilityInitiative/js/plugins.combined.js 2010-01-07 
22:54:53 UTC (rev 60813)
@@ -1278,7 +1278,7 @@
                        break;
                case 'getCaretPosition':
                        options = $.extend( {
-                               'startAndEnd': false, // Return [start, end] 
instead of just start
+                               'startAndEnd': false // Return [start, end] 
instead of just start
                        }, options );
                        // FIXME: We may not need character position-based 
functions if we insert markers in the right places
                        break;
@@ -1287,7 +1287,7 @@
                                'start': undefined, // Position to start 
selection at
                                'end': undefined, // Position to end selection 
at. Defaults to start
                                'startContainer': undefined, // Element to 
start selection in (iframe only)
-                               'endContainer': undefined, // Element to end 
selection in (iframe only). Defaults to startContainer
+                               'endContainer': undefined // Element to end 
selection in (iframe only). Defaults to startContainer
                        }, options );
                        if ( options.end === undefined )
                                options.end = options.start;
@@ -1816,12 +1816,12 @@
                 * @param endContainer Element in iframe to end selection in
                 */
                '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 ) {
                                // Firefox and Opera
                                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;
                                }
@@ -1837,7 +1837,15 @@
                                context.$iframe[0].contentWindow.focus();
                        } else if ( 
context.$iframe[0].contentWindow.document.selection ) {
                                // IE
-                               // TODO
+                               // FIXME still broken for when sc or ec is the 
<body>, needs more tweaking
+                               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();
                        }
                },
                /**
@@ -1979,6 +1987,9 @@
                } )
                .insertAfter( context.$textarea )
                .load( function() {
+                       if ( !context.$iframe[0].contentWindow.document.body ) {
+                               return;
+                       }
                        // Turn the document's design mode on
                        context.$iframe[0].contentWindow.document.designMode = 
'on';
                        // Get a reference to the content area of the iframe
@@ -3147,8 +3158,14 @@
                        if ( currentField.indexOf( '=' ) == -1 ) {
                                // anonymous field, gets a number
                                valueBegin = currentField.match( /\S+/ ); 
//first nonwhitespace character
+                               if( valueBegin == null ){ //ie
+                                       continue;
+                               }
                                valueBeginIndex = valueBegin.index + 
oldDivider+1;
                                valueEnd = currentField.match( /[^\s]\s*$/ ); 
//last nonwhitespace character
+                               if( valueEnd == null ){ //ie
+                                       continue;
+                               }
                                valueEndIndex = valueEnd.index + oldDivider + 2;
                                ranges.push( new Range( 
ranges[ranges.length-1].end,
                                        valueBeginIndex ) ); //all the chars 
upto now
@@ -3177,6 +3194,9 @@
                                nameBeginIndex = nameBegin.index + oldDivider + 
1;
                                // Last nonwhitespace and non } character
                                nameEnd = currentName.match( /[^\s]\s*$/ );
+                               if( nameEnd == null ){ //ie
+                                       continue;
+                               }
                                nameEndIndex = nameEnd.index + oldDivider + 2;
                                // All the chars upto now 
                                ranges.push( new Range( 
ranges[ranges.length-1].end, nameBeginIndex ) );
@@ -3185,9 +3205,15 @@
                                oldDivider += currentField.indexOf( '=' ) + 1;
                                // First nonwhitespace character
                                valueBegin = currentValue.match( /\S+/ );
+                               if( valueBegin == null ){ //ie
+                                       continue;
+                               }
                                valueBeginIndex = valueBegin.index + oldDivider 
+ 1;
                                // Last nonwhitespace and non } character
                                valueEnd = currentValue.match( /[^\s]\s*$/ );
+                               if( valueEnd == null ){ //ie
+                                       continue;
+                               }
                                valueEndIndex = valueEnd.index + oldDivider + 2;
                                // All the chars upto now
                                equalsIndex = ranges.push( new Range( 
ranges[ranges.length-1].end, valueBeginIndex) ) - 1;
@@ -3228,7 +3254,7 @@
        // Minimum width to allow resizing to before collapsing the table of 
contents - used when resizing and collapsing
        minimumWidth: '70px',
        // Boolean var indicating text direction
-       rtl: false, 
+       rtl: false
 },
 /**
  * API accessible functions

Modified: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
===================================================================
--- trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js     
2010-01-07 22:08:31 UTC (rev 60812)
+++ trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js     
2010-01-07 22:54:53 UTC (rev 60813)
@@ -79,7 +79,7 @@
 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())
 $(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)
 this.scrollTop+=range.offsetTop;else 
if(options.force){range.move('character',-1);range.select();}}
-$(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)
+$(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)
 options.end=options.start;if(options.endContainer==undefined)
 
options.endContainer=options.startContainer;break;case'scrollToCaretPosition':options=$.extend({'force':false},options);break;}
 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 @@
 if(range.endContainer==range.commonAncestorContainer){post+="\n";}}
 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'));}}
 if(lastNode){context.fn.scrollToTop(lastNode);}}else 
if(context.$iframe[0].contentWindow.document.selection){}
-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;}
+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;}
 while(ec.firstChild&&ec.nodeName!='#text'){ec=ec.firstChild;}
-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);}
+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);}
 
$element.trigger('scrollToTop');},'beforeSelection':function(selector,strict){if(typeof
 selector=='undefined')
 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 $([]);}
 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 @@
 while(e){if($(e).is(selector)&&!strict)
 return $(e);var 
next=e.previousSibling;while(next&&next.lastChild){next=next.lastChild;}
 e=next||e.parentNode;strict=false;}
-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,'&lt;').replace(/>/g,'&gt;'));if($('body').is('.rtl')){context.$content.addClass('rtl').attr('dir','rtl');}
+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;}
+context.$iframe[0].contentWindow.document.designMode='on';context.$content=$(context.$iframe[0].contentWindow.document.body);context.$content.append(context.$textarea.val().replace(/</g,'&lt;').replace(/>/g,'&gt;'));if($('body').is('.rtl')){context.$content.addClass('rtl').attr('dir','rtl');}
 
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'));});}
 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]);}}
 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 @@
 var ranges=[];var params=[];var templateNameIndex=0;var 
doneParsing=false;oldDivider=0;divider=sanatizedStr.indexOf('|',oldDivider);if(divider==-1){divider=sanatizedStr.length;doneParsing=true;}
 
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);}
 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;}
-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;}
-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;}}
-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()-
+currentField=sanatizedStr.substring(oldDivider+1,divider);if(currentField.indexOf('=')==-1){valueBegin=currentField.match(/\S+/);if(valueBegin==null){continue;}
+valueBeginIndex=valueBegin.index+oldDivider+1;valueEnd=currentField.match(/[^\s]\s*$/);if(valueEnd==null){continue;}
+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;}
+nameBeginIndex=nameBegin.index+oldDivider+1;nameEnd=currentName.match(/[^\s]\s*$/);if(nameEnd==null){continue;}
+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;}
+valueBeginIndex=valueBegin.index+oldDivider+1;valueEnd=currentValue.match(/[^\s]\s*$/);if(valueEnd==null){continue;}
+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;}}
+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()-
 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;}
 
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});}
 
$.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;}



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to