r59801 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59800‎ | r59801 | r59802 >
Date:21:09, 7 December 2009
Author:catrope
Status:deferred
Tags:
Comment:
UsabilityInitiative: Some IE fixes, recombine for r59799
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/Vector/Vector.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/Vector/Vector.combined.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/Vector/Vector.combined.js
@@ -77,7 +77,7 @@
7878 } );
7979 } );/* JavaScript for EditWarning extension */
8080
81 -js2AddOnloadHook( function() {
 81+mw.addOnloadHook( function() {
8282 // Check preferences for editwarning
8383 if ( !wgVectorPreferences || !( wgVectorPreferences.editwarning && wgVectorPreferences.editwarning.enable ) ) {
8484 return true;
@@ -127,7 +127,7 @@
128128 os_autoload_forms = [];
129129 }
130130
131 -js2AddOnloadHook( function() {
 131+mw.addOnloadHook( function() {
132132 // Only use this function in conjuction with the Vector skin
133133 if( skin != 'vector' ) {
134134 return;
Index: trunk/extensions/UsabilityInitiative/Vector/Vector.combined.min.js
@@ -1,10 +1,10 @@
22
33 mw.addOnloadHook(function(){var rtl=$j('body').is('.rtl')?true:false;$j.collapsibleTabs.moveToCollapsed=function(ele){var $moving=$j(ele);$j($moving.data('collapsibleTabsSettings').expandedContainer).data('collapsibleTabsSettings').shifting=true;var data=$moving.data('collapsibleTabsSettings');var target=$moving.data('collapsibleTabsSettings').collapsedContainer;$moving.css("position","relative").css((rtl?'left':'right'),0).animate({width:'1px'},"normal",function(){$j(this).hide();$j('<span class="placeholder" style="display:none;"></span>').insertAfter(this);$j(this).remove().prependTo(target).data('collapsibleTabsSettings',data);$j(this).attr('style','display:list-item;');$j($j(ele).data('collapsibleTabsSettings').expandedContainer).data('collapsibleTabsSettings').shifting=false;$j.collapsibleTabs.handleResize();});};$j.collapsibleTabs.moveToExpanded=function(ele){var $moving=$j(ele);$j($moving.data('collapsibleTabsSettings').expandedContainer).data('collapsibleTabsSettings').shifting=true;var data=$moving.data('collapsibleTabsSettings');var $target=$j($moving.data('collapsibleTabsSettings').expandedContainer).find('span.placeholder:first');var expandedWidth=$moving.data('collapsibleTabsSettings').expandedWidth;$moving.css("position","relative").css((rtl?'right':'left'),0).css('width','1px');$target.replaceWith($moving.remove().css('width','1px').data('collapsibleTabsSettings',data).animate({width:expandedWidth+"px"},"normal",function(){$j(this).attr('style','display:block;');$j($moving.data('collapsibleTabsSettings').expandedContainer).data('collapsibleTabsSettings').shifting=false;$j.collapsibleTabs.handleResize();}));};$j('#p-views ul').bind("beforeTabCollapse",function(){if($j('#p-cactions').css('display')=='none')
44 $j("#p-cactions").addClass("filledPortlet").removeClass("emptyPortlet").find('h5').css('width','1px').animate({'width':'26px'},390);}).bind("beforeTabExpand",function(){if($j('#p-cactions li').length==1)
5 -$j("#p-cactions h5").animate({'width':'1px'},370,function(){$j(this).attr('style','').parent().addClass("emptyPortlet").removeClass("filledPortlet");});}).collapsibleTabs({expandCondition:function(eleWidth){if(rtl){return($j('#right-navigation').position().left+$j('#right-navigation').width()+1)<($j('#left-navigation').position().left-eleWidth);}else{return($j('#left-navigation').position().left+$j('#left-navigation').width()+1)<($j('#right-navigation').position().left-eleWidth);}},collapseCondition:function(){if(rtl){return($j('#right-navigation').position().left+$j('#right-navigation').width())>$j('#left-navigation').position().left;}else{return($j('#left-navigation').position().left+$j('#left-navigation').width())>$j('#right-navigation').position().left;}}});});js2AddOnloadHook(function(){if(!wgVectorPreferences||!(wgVectorPreferences.editwarning&&wgVectorPreferences.editwarning.enable)){return true;}
 5+$j("#p-cactions h5").animate({'width':'1px'},370,function(){$j(this).attr('style','').parent().addClass("emptyPortlet").removeClass("filledPortlet");});}).collapsibleTabs({expandCondition:function(eleWidth){if(rtl){return($j('#right-navigation').position().left+$j('#right-navigation').width()+1)<($j('#left-navigation').position().left-eleWidth);}else{return($j('#left-navigation').position().left+$j('#left-navigation').width()+1)<($j('#right-navigation').position().left-eleWidth);}},collapseCondition:function(){if(rtl){return($j('#right-navigation').position().left+$j('#right-navigation').width())>$j('#left-navigation').position().left;}else{return($j('#left-navigation').position().left+$j('#left-navigation').width())>$j('#right-navigation').position().left;}}});});mw.addOnloadHook(function(){if(!wgVectorPreferences||!(wgVectorPreferences.editwarning&&wgVectorPreferences.editwarning.enable)){return true;}
66 $j('#wpTextbox1, #wpSummary').each(function(){$j(this).data('origtext',$j(this).val());});fallbackWindowOnBeforeUnload=window.onbeforeunload;window.onbeforeunload=function(){var fallbackResult=null;if(fallbackWindowOnBeforeUnload){fallbackResult=fallbackWindowOnBeforeUnload();}
77 if(fallbackResult!==null){return fallbackResult;}
88 if(wgAction=='submit'||$j('#wpTextbox1').data('origtext')!=$j('#wpTextbox1').val()||$j('#wpSummary').data('origtext')!=$j('#wpSummary').val()){return gM('vector-editwarning-warning');}}
99 $j('form').submit(function(){window.onbeforeunload=fallbackWindowOnBeforeUnload;});});var fallbackWindowOnBeforeUnload=null;if(typeof os_autoload_inputs!=='undefined'&&os_autoload_forms!=='undefined'){os_autoload_inputs=[];os_autoload_forms=[];}
10 -js2AddOnloadHook(function(){if(skin!='vector'){return;}
 10+mw.addOnloadHook(function(){if(skin!='vector'){return;}
1111 $j('div#simpleSearch > input#searchInput').each(function(){$j('<label></label>').text(gM('vector-simplesearch-search')).css({'display':'none','position':'absolute','bottom':0,'padding':'0.25em','color':'#999999','cursor':'text'}).css(($j('body').is('.rtl')?'right':'left'),0).click(function(){$j(this).parent().find('input#searchInput').focus();}).appendTo($j(this).parent());if($j(this).val()==''){$j(this).parent().find('label').show();}}).focus(function(){$j(this).parent().find('label').hide();}).blur(function(){if($j(this).val()==''){$j(this).parent().find('label').show();}});$j('#searchInput, #searchInput2, #powerSearchText, #searchText').suggestions({fetch:function(query){var $this=$j(this);var request=$j.ajax({url:wgScriptPath+'/api.php',data:{'action':'opensearch','search':query,'namespace':0,'suggest':''},dataType:'json',success:function(data){$this.suggestions('suggestions',data[1]);}});$j(this).data('request',request);},cancel:function(){var request=$j(this).data('request');if(request&&typeof request.abort=='function'){request.abort();$j(this).removeData('request');}},result:{select:function($textbox){$textbox.closest('form').submit();}},delay:120});$j('#searchInput').suggestions({result:{select:function($textbox){$textbox.closest('form').submit();}},special:{render:function(query){var perfectMatch=false;$j(this).closest('.suggestions').find('.suggestions-results div').each(function(){if($j(this).data('text')==query){perfectMatch=true;}});if(perfectMatch){if($j(this).children().size()==0){$j(this).show();$label=$j('<div />').addClass('special-label').text(gM('vector-simplesearch-containing')).appendTo($j(this));$query=$j('<div />').addClass('special-query').text(query).appendTo($j(this));$query.autoEllipse();}else{$j(this).find('.special-query').empty().text(query).autoEllipse();}}else{$j(this).hide();$j(this).empty();}},select:function($textbox){$textbox.closest('form').append($j('<input />').attr({'type':'hidden','name':'fulltext','value':1}));$textbox.closest('form').submit();}},$region:$j('#simpleSearch')});});
\ No newline at end of file
Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -70,19 +70,19 @@
7171 array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ),
7272 array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 6 ),
7373 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 21 ),
74 - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 26 ),
 74+ array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 27 ),
7575 array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 1 ),
7676 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 34 ),
7777 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 9 ),
78 - array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 45 ),
 78+ array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 46 ),
7979 array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 4 ),
8080 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 0 ),
8181 ),
8282 'combined' => array(
83 - array( 'src' => 'js/plugins.combined.js', 'version' => 95 ),
 83+ array( 'src' => 'js/plugins.combined.js', 'version' => 96 ),
8484 ),
8585 'minified' => array(
86 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 95 ),
 86+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 96 ),
8787 ),
8888 ),
8989 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js
@@ -325,12 +325,12 @@
326326 var p = this;
327327 while( !p.previousSibling )
328328 p = p.parentNode;
329 - var prev = p.previousSibling;
 329+ var prev = p ? p.previousSibling : null;
330330
331331 p = this;
332332 while ( p && !p.nextSibling )
333333 p = p.parentNode;
334 - var next = p.nextSibling;
 334+ var next = p ? p.nextSibling : null;
335335
336336 // Edge case: there are more equals signs,
337337 // but they're not all in the <div>. Eat them.
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
@@ -275,6 +275,7 @@
276276 options.init( context );
277277 }
278278 event.preventDefault();
 279+ return false;
279280 } )
280281 .text( $.wikiEditor.autoMsg( options, 'title' ) )
281282 )
@@ -334,6 +335,7 @@
335336 'getContents': function() {
336337 // We use .html() instead of .text() so HTML entities are handled right
337338 // Setting the HTML of the textarea doesn't work on all browsers, use a dummy <div> instead
 339+
338340 return $( '<div />' )
339341 .html( context.$content.html().replace( /\<br\>/g, "\n" ) )
340342 .text();
@@ -350,8 +352,8 @@
351353 var retval;
352354 if ( context.$iframe[0].contentWindow.getSelection ) {
353355 retval = context.$iframe[0].contentWindow.getSelection();
354 - } else if ( context.$iframe[0].contentWindow.selection ) { // should come last; Opera!
355 - retval = context.$iframe[0].contentWindow.selection.createRange();
 356+ } else if ( context.$iframe[0].contentWindow.document.selection ) { // should come last; Opera!
 357+ retval = context.$iframe[0].contentWindow.document.selection.createRange();
356358 }
357359 if ( retval.text ) {
358360 retval = retval.text;
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -1585,6 +1585,7 @@
15861586 options.init( context );
15871587 }
15881588 event.preventDefault();
 1589+ return false;
15891590 } )
15901591 .text( $.wikiEditor.autoMsg( options, 'title' ) )
15911592 )
@@ -1644,6 +1645,7 @@
16451646 'getContents': function() {
16461647 // We use .html() instead of .text() so HTML entities are handled right
16471648 // Setting the HTML of the textarea doesn't work on all browsers, use a dummy <div> instead
 1649+
16481650 return $( '<div />' )
16491651 .html( context.$content.html().replace( /\<br\>/g, "\n" ) )
16501652 .text();
@@ -1660,8 +1662,8 @@
16611663 var retval;
16621664 if ( context.$iframe[0].contentWindow.getSelection ) {
16631665 retval = context.$iframe[0].contentWindow.getSelection();
1664 - } else if ( context.$iframe[0].contentWindow.selection ) { // should come last; Opera!
1665 - retval = context.$iframe[0].contentWindow.selection.createRange();
 1666+ } else if ( context.$iframe[0].contentWindow.document.selection ) { // should come last; Opera!
 1667+ retval = context.$iframe[0].contentWindow.document.selection.createRange();
16661668 }
16671669 if ( retval.text ) {
16681670 retval = retval.text;
@@ -2661,12 +2663,12 @@
26622664 var p = this;
26632665 while( !p.previousSibling )
26642666 p = p.parentNode;
2665 - var prev = p.previousSibling;
 2667+ var prev = p ? p.previousSibling : null;
26662668
26672669 p = this;
26682670 while ( p && !p.nextSibling )
26692671 p = p.parentNode;
2670 - var next = p.nextSibling;
 2672+ var next = p ? p.nextSibling : null;
26712673
26722674 // Edge case: there are more equals signs,
26732675 // but they're not all in the <div>. Eat them.
@@ -2940,7 +2942,7 @@
29412943 fn : {
29422944 /**
29432945 * Creates a toolbar module within a wikiEditor
2944 - *
 2946+ *
29452947 * @param {Object} context Context object of editor to create module in
29462948 * @param {Object} config Configuration object to create module from
29472949 */
@@ -2956,7 +2958,7 @@
29572959 },
29582960 /**
29592961 * Performs an operation based on parameters
2960 - *
 2962+ *
29612963 * @param {Object} context
29622964 * @param {Object} action
29632965 * @param {Object} source
@@ -2995,15 +2997,12 @@
29962998 parts[part] = ( action.options[part] || '' )
29972999 }
29983000 }
2999 - if ( 'periRegex' in action.options && 'periRegexReplace' in action.options ) {
3000 -<<<<<<< .mine
3001 - var selection = context.$textarea.textSelection();
3002 -=======
 3001+ if ( 'regex' in action.options && 'regexReplace' in action.options ) {
30033002 var selection = context.$textarea.textSelection( 'getSelection' );
3004 ->>>>>>> .r58906
3005 - if ( selection != '' ) {
3006 - parts.peri = selection.replace( action.options.periRegex,
3007 - action.options.periRegexReplace );
 3003+ if ( selection != '' && selection.match( action.options.regex ) ) {
 3004+ parts.peri = selection.replace( action.options.regex,
 3005+ action.options.regexReplace );
 3006+ parts.pre = parts.post = '';
30083007 }
30093008 }
30103009 context.$textarea.textSelection( 'encapsulateSelection', $.extend( action.options,
@@ -3026,12 +3025,18 @@
30273026 if ( label ) {
30283027 $group.append( '<div class="label">' + label + '</div>' )
30293028 }
 3029+
 3030+ var empty = true;
30303031 if ( 'tools' in group ) {
30313032 for ( tool in group.tools ) {
3032 - $group.append( $.wikiEditor.modules.toolbar.fn.buildTool( context, tool, group.tools[tool] ) );
 3033+ var tool = $.wikiEditor.modules.toolbar.fn.buildTool( context, tool, group.tools[tool] );
 3034+ if ( tool ) {
 3035+ empty = false;
 3036+ $group.append( tool );
 3037+ }
30333038 }
30343039 }
3035 - return $group;
 3040+ return empty ? null : $group;
30363041 },
30373042 buildTool : function( context, id, tool ) {
30383043 if ( 'filters' in tool ) {
@@ -3044,10 +3049,7 @@
30453050 var label = $.wikiEditor.autoMsg( tool, 'label' );
30463051 switch ( tool.type ) {
30473052 case 'button':
3048 - var src = tool.icon;
3049 - if ( src.indexOf( 'http://' ) !== 0 && src.indexOf( 'https://' ) !== 0 ) {
3050 - src = $.wikiEditor.imgPath + 'toolbar/' + src;
3051 - }
 3053+ var src = $.wikiEditor.getIcon( tool.icon, $.wikiEditor.imgPath + 'toolbar/' );
30523054 $button = $( '<img />' ).attr( {
30533055 'src' : src,
30543056 'width' : 22,
@@ -3235,31 +3237,35 @@
32363238 .bind( 'mouseup', function( e ) {
32373239 $(this).blur();
32383240 } )
3239 - .bind( 'mousedown', function( e ) {
3240 - // Only act when the primary mouse button was pressed
3241 - if ( e.button !== 0 ) {
3242 - return true;
3243 - }
 3241+ .bind( 'click', function( e ) {
32443242 var $sections = $(this).data( 'context' ).$ui.find( '.sections' );
32453243 var $section =
32463244 $(this).data( 'context' ).$ui.find( '.section-' + $(this).parent().attr( 'rel' ) );
32473245 var show = $section.css( 'display' ) == 'none';
32483246 $previousSections = $section.parent().find( '.section:visible' );
 3247+ var dH = $previousSections.outerHeight();
32493248 $previousSections.css( 'position', 'absolute' );
32503249 $previousSections.fadeOut( 'fast', function() { $(this).css( 'position', 'relative' ); } );
32513250 $(this).parent().parent().find( 'a' ).removeClass( 'current' );
32523251 $sections.css('overflow', 'hidden');
32533252 if ( show ) {
32543253 $section.fadeIn( 'fast' );
3255 - $sections.animate( { 'height': $section.outerHeight() }, $section.outerHeight() * 2, function() {
3256 - $(this).css('overflow', 'visible').css('height', 'auto');
 3254+ dH = $section.outerHeight() - dH;
 3255+ if ( context.modules.$toc ) {
 3256+ context.modules.$toc.animate({'height': "+="+dH}, $section.outerHeight() * 2);
 3257+ }
 3258+ $sections.animate( { 'height': $section.outerHeight() }, $section.outerHeight() * 2, function() {
 3259+ $(this).css('overflow', 'visible').css('height', 'auto');
32573260 } );
32583261 $(this).addClass( 'current' );
32593262 } else {
32603263 $sections.css('height', $section.outerHeight() )
3261 - .animate( { 'height': 0 }, $section.outerHeight() * 2, function() {
3262 - $(this).css('overflow', 'visible');
 3264+ .animate( { 'height': 0 }, $section.outerHeight() * 2, function() {
 3265+ $(this).css('overflow', 'visible');
32633266 } );
 3267+ if ( context.modules.$toc ) {
 3268+ context.modules.$toc.animate({'height': "-="+$section.outerHeight()}, $section.outerHeight() * 2);
 3269+ }
32643270 }
32653271 // Click tracking
32663272 if($.trackAction != undefined){
@@ -3270,8 +3276,8 @@
32713277 'wikiEditor-' + $(this).data( 'context' ).instance + '-toolbar-section',
32723278 show ? $section.attr( 'rel' ) : null
32733279 );
 3280+ return false;
32743281 } )
3275 - .click( function() { return false; } )
32763282 );
32773283 },
32783284 buildSection : function( context, id, section ) {
@@ -3329,29 +3335,6 @@
33303336 },
33313337 build : function( context, config ) {
33323338 var $tabs = $( '<div />' ).addClass( 'tabs' ).appendTo( context.modules.$toolbar );
3333 - if( wgNavigableTOCCollapseEnable ) {
3334 - // placeholder for drag control creation code
3335 - $dragControl = $( '<div />' ).addClass( 'tab' ).attr( 'id', 'wikiEditor-ui-toc-resize-grip' )
3336 - .append( '<a href="#" title="Drag to resize"></a>' )
3337 - .bind( 'mousedown', function() {
3338 - $( '#wikiEditor-ui-toc' )
3339 - .data( 'openWidth', $( '#wikiEditor-ui-toc' ).width() );
3340 - $()
3341 - .bind( 'mousemove', {'context': context}, $.wikiEditor.modules.toc.fn.drag )
3342 - .bind( 'mouseup', {'context': context}, $.wikiEditor.modules.toc.fn.stopDrag );
3343 - $(context.$iframe[0].contentWindow.document)
3344 - .bind( 'mousemove', {'context': context}, function( e ){
3345 - parent.top.$j().trigger("mousemove", e.pageX);
3346 - return false;
3347 - } )
3348 - .bind( 'mouseup', {'context': context}, function( e ){
3349 - parent.top.$j().trigger("mouseup");
3350 - return false;
3351 - });
3352 - return false;
3353 - });
3354 - context.modules.$toolbar.append( $dragControl );
3355 - }
33563339 var $sections = $( '<div />' ).addClass( 'sections' ).appendTo( context.modules.$toolbar );
33573340 context.modules.$toolbar.append( $( '<div />' ).css( 'clear', 'both' ) );
33583341 var sectionQueue = [];
@@ -3373,8 +3356,7 @@
33743357 $.eachAsync( sectionQueue, {
33753358 'bulk' : 0,
33763359 'end' : function() {
3377 - // HACK: Opera doesn't seem to want to redraw after
3378 - // these bits
 3360+ // HACK: Opera doesn't seem to want to redraw after these bits
33793361 // are added to the DOM, so we can just FORCE it!
33803362 $( 'body' ).css( 'position', 'static' );
33813363 $( 'body' ).css( 'position', 'relative' );
@@ -3383,7 +3365,14 @@
33843366 s.$sections.append( $.wikiEditor.modules.toolbar.fn.buildSection( s.context, s.id, s.config ) );
33853367 var $section = s.$sections.find( '.section:visible' );
33863368 if ( $section.size() ) {
3387 - $sections.animate( { 'height': $section.outerHeight() }, $section.outerHeight() * 2 );
 3369+ $sections.animate( { 'height': $section.outerHeight() }, $section.outerHeight() * 2, function( ) {
 3370+ if ( context.modules.$toc ) {
 3371+ context.modules.$toc.height(
 3372+ context.$ui.find( '.wikiEditor-ui-left' )
 3373+ .outerHeight() - context.$ui.find( '.tab-toc' ).outerHeight()
 3374+ )
 3375+ }
 3376+ } );
33883377 }
33893378 }
33903379 } );
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -93,10 +93,10 @@
9494 context.evt={'change':function(event){switch(event.type){case'keypress':if(false){}else{}
9595 break;case'mousedown':if(false){}else{}
9696 break;default:break;}}};context.fn={'addButton':function(options){context.$controls.show();context.$buttons.show();return $('<button />').text($.wikiEditor.autoMsg(options,'caption')).click(options.action).appendTo(context.$buttons);},'addView':function(options){function addTab(options){context.$controls.show();context.$tabs.show();return $('<div></div>').attr('rel','wikiEditor-ui-view-'+options.name).addClass(context.view==options.name?'current':null).append($('<a></a>').attr('href','#').click(function(event){context.$ui.find('.wikiEditor-ui-view').hide();context.$ui.find('.'+$(this).parent().attr('rel')).show();context.$tabs.find('div').removeClass('current');$(this).parent().addClass('current');$(this).blur();if('init'in options&&typeof options.init=='function'){options.init(context);}
97 -event.preventDefault();}).text($.wikiEditor.autoMsg(options,'title'))).appendTo(context.$tabs);}
 97+event.preventDefault();return false;}).text($.wikiEditor.autoMsg(options,'title'))).appendTo(context.$tabs);}
9898 if(!context.$tabs.children().size()){addTab({'name':'wikitext','titleMsg':'wikieditor-wikitext-tab'});}
9999 addTab(options);return $('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-'+options.name).hide().appendTo(context.$ui);},'setup':function(){var contentHTML=$('<div />').text(context.$textarea.val()).html();context.$iframe[0].contentWindow.document.open();context.$iframe[0].contentWindow.document.write('<html><head><title>wikiEditor</title><script>var context = window.parent.jQuery.wikiEditor.instances['+context.instance+'].data( "wikiEditor-context" ); window.parent.jQuery( document ).bind( "keydown keypress keyup mousedown mouseup cut paste", { "context": context }, context.evt.change );</script></head><body style="margin:0;padding:0;width:100%;height:100%;white-space:pre-wrap;font-family:monospace">'+contentHTML+'</body></html>');context.$iframe[0].contentWindow.document.close();context.$iframe[0].contentWindow.document.designMode='on';context.$content=$(context.$iframe[0].contentWindow.document.body);if($('body').is('.rtl')){context.$content.addClass('rtl').attr('dir','rtl');}
100 -context.$textarea.attr('disabled',true);context.$textarea.hide();context.$iframe.show();},'isSetup':function(){return context.$content!=undefined&&context.$content[0].innerHTML!=undefined;},'getContents':function(){return $('<div />').html(context.$content.html().replace(/\<br\>/g,"\n")).text();},'setContents':function(options){context.$content.text(options.contents);return context.$textarea;},'textSelection':function(){var retval;if(context.$iframe[0].contentWindow.getSelection){retval=context.$iframe[0].contentWindow.getSelection();}else if(context.$iframe[0].contentWindow.selection){retval=context.$iframe[0].contentWindow.selection.createRange();}
 100+context.$textarea.attr('disabled',true);context.$textarea.hide();context.$iframe.show();},'isSetup':function(){return context.$content!=undefined&&context.$content[0].innerHTML!=undefined;},'getContents':function(){return $('<div />').html(context.$content.html().replace(/\<br\>/g,"\n")).text();},'setContents':function(options){context.$content.text(options.contents);return context.$textarea;},'textSelection':function(){var retval;if(context.$iframe[0].contentWindow.getSelection){retval=context.$iframe[0].contentWindow.getSelection();}else if(context.$iframe[0].contentWindow.document.selection){retval=context.$iframe[0].contentWindow.document.selection.createRange();}
101101 if(retval.text){retval=retval.text;}else if(retval.toString){retval=retval.toString();}
102102 return retval;},'encapsulateSelection':function(options){var selText=$(this).textSelection('getSelection');var selectAfter=false;var pre=options.pre,post=options.post;if(!selText){selText=options.peri;selectAfter=true;}else if(options.replace){selText=options.peri;}else if(selText.charAt(selText.length-1)==' '){selText=selText.substring(0,selText.length-1);post+=' ';}
103103 var range=context.$iframe[0].contentWindow.getSelection().getRangeAt(0);if(options.ownline){if(range.startOffset!=0)
@@ -164,8 +164,8 @@
165165 initialWidth=parseFloat($.wikiEditor.modules.toc.minimumWidth)+1;context.modules.$toc.data('openWidth',initialWidth+'px');context.$ui.find('.wikiEditor-ui-right').css('width',initialWidth+'px');context.$ui.find('.wikiEditor-ui-left').css('marginRight',(parseFloat(initialWidth)*-1)+'px').children().css('marginRight',initialWidth+'px');}}
166166 var outline=[],h=0;function traverseTextNodes(){if(this.nodeName!='#text'){$(this.childNodes).each(traverseTextNodes);return;}
167167 var text=this.nodeValue;var p=this;while(!p.previousSibling)
168 -p=p.parentNode;var prev=p.previousSibling;p=this;while(p&&!p.nextSibling)
169 -p=p.parentNode;var next=p.nextSibling;if(prev&&prev.nodeName=='#text'){var prevText=prev.nodeValue;while(prevText.substr(-1)=='='){prevText=prevText.substr(0,prevText.length-1);text='='+text;}
 168+p=p.parentNode;var prev=p?p.previousSibling:null;p=this;while(p&&!p.nextSibling)
 169+p=p.parentNode;var next=p?p.nextSibling:null;if(prev&&prev.nodeName=='#text'){var prevText=prev.nodeValue;while(prevText.substr(-1)=='='){prevText=prevText.substr(0,prevText.length-1);text='='+text;}
170170 prev.nodeValue=prevText;}
171171 var next=this.nextSibling;if(next&&next.nodeName=='#text'){var nextText=next.nodeValue;while(nextText.substr(0,1)=='='){nextText=nextText.substr(1);text=text+'=';}
172172 next.nodeValue=nextText;}
@@ -201,15 +201,12 @@
202202 step=step.parent();}
203203 rels.reverse();var id=rels.join('.');$.trackAction(id);}
204204 switch(action.type){case'replace':case'encapsulate':var parts={'pre':'','peri':'','post':''};for(part in parts){if(part+'Msg'in action.options){parts[part]=gM(action.options[part+'Msg'],(action.options[part]||null));}else{parts[part]=(action.options[part]||'')}}
205 -if('periRegex'in action.options&&'periRegexReplace'in action.options){<<<<<<<.mine
206 -var selection=context.$textarea.textSelection();=======var selection=context.$textarea.textSelection('getSelection');>>>>>>>.r58906
207 -if(selection!=''){parts.peri=selection.replace(action.options.periRegex,action.options.periRegexReplace);}}
 205+if('regex'in action.options&&'regexReplace'in action.options){var selection=context.$textarea.textSelection('getSelection');if(selection!=''&&selection.match(action.options.regex)){parts.peri=selection.replace(action.options.regex,action.options.regexReplace);parts.pre=parts.post='';}}
208206 context.$textarea.textSelection('encapsulateSelection',$.extend(action.options,parts,{'replace':action.type=='replace'}));break;case'callback':if(typeof action.execute=='function'){action.execute(context);}
209207 break;case'dialog':context.$textarea.wikiEditor('openDialog',action.module);break;default:break;}},buildGroup:function(context,id,group){var $group=$('<div />').attr({'class':'group group-'+id,'rel':id});var label=$.wikiEditor.autoMsg(group,'label');if(label){$group.append('<div class="label">'+label+'</div>')}
210 -if('tools'in group){for(tool in group.tools){$group.append($.wikiEditor.modules.toolbar.fn.buildTool(context,tool,group.tools[tool]));}}
211 -return $group;},buildTool:function(context,id,tool){if('filters'in tool){for(filter in tool.filters){if($(tool.filters[filter]).size()==0){return null;}}}
212 -var label=$.wikiEditor.autoMsg(tool,'label');switch(tool.type){case'button':var src=tool.icon;if(src.indexOf('http://')!==0&&src.indexOf('https://')!==0){src=$.wikiEditor.imgPath+'toolbar/'+src;}
213 -$button=$('<img />').attr({'src':src,'width':22,'height':22,'alt':label,'title':label,'rel':id,'class':'tool tool-button'});if('action'in tool){$button.data('action',tool.action).data('context',context).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).data('context'),$(this).data('action'),$(this));return false;});}
 208+var empty=true;if('tools'in group){for(tool in group.tools){var tool=$.wikiEditor.modules.toolbar.fn.buildTool(context,tool,group.tools[tool]);if(tool){empty=false;$group.append(tool);}}}
 209+return empty?null:$group;},buildTool:function(context,id,tool){if('filters'in tool){for(filter in tool.filters){if($(tool.filters[filter]).size()==0){return null;}}}
 210+var label=$.wikiEditor.autoMsg(tool,'label');switch(tool.type){case'button':var src=$.wikiEditor.getIcon(tool.icon,$.wikiEditor.imgPath+'toolbar/');$button=$('<img />').attr({'src':src,'width':22,'height':22,'alt':label,'title':label,'rel':id,'class':'tool tool-button'});if('action'in tool){$button.data('action',tool.action).data('context',context).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).data('context'),$(this).data('action'),$(this));return false;});}
214211 return $button;case'select':var $select=$('<div />').attr({'rel':id,'class':'tool tool-select'}).click(function(){var $options=$(this).find('.options');$options.animate({'opacity':'toggle'},'fast');});$options=$('<div />').addClass('options');if('list'in tool){for(option in tool.list){var optionLabel=$.wikiEditor.autoMsg(tool.list[option],'label');$options.append($('<a />').data('action',tool.list[option].action).data('context',context).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).data('context'),$(this).data('action'),$(this));}).text(optionLabel).addClass('option').attr('rel',option));}}
215212 $select.append($('<div />').addClass('menu').append($options));$select.append($('<div />').addClass('label').text(label));return $select;default:return null;}},buildBookmark:function(context,id,page){var label=$.wikiEditor.autoMsg(page,'label');return $('<div />').text(label).attr('rel',id).data('context',context).bind('mousedown',function(){$(this).parent().parent().find('.page').hide();$(this).parent().parent().find('.page-'+$(this).attr('rel')).show();$(this).siblings().removeClass('current');$(this).addClass('current');var section=$(this).parent().parent().attr('rel');if($.trackAction!=undefined){$.trackAction(section+'.'+$(this).attr('rel'));}
216213 $.cookie('wikiEditor-'+$(this).data('context').instance+'-booklet-'+section+'-page',$(this).attr('rel'));});},buildPage:function(context,id,page){var $page=$('<div />').attr({'class':'page page-'+id,'rel':id});switch(page.layout){case'table':$page.addClass('page-table');var html='<table cellpadding=0 cellspacing=0 '+'border=0 width="100%" class="table table-"'+id+'">';if('headings'in page){html+=$.wikiEditor.modules.toolbar.fn.buildHeading(context,page.headings)}
@@ -223,14 +220,13 @@
224221 return html;},buildRow:function(context,row){var html='<tr>';for(cell in row){html+='<td class="cell cell-'+cell+'" valign="top"><span>'+
225222 $.wikiEditor.autoMsg(row[cell],['html','text'])+'</span></td>';}
226223 html+='</tr>';return html;},buildCharacter:function(character,actions){if(typeof character=='string'){character={'label':character,'action':{'type':'encapsulate','options':{'pre':character}}};}else if(0 in character&&1 in character){character={'label':character[0],'action':{'type':'encapsulate','options':{'pre':character[1]}}};}
227 -if('action'in character&&'label'in character){actions[character.label]=character.action;return'<a rel="'+character.label+'" href="#">'+character.label+'</a>';}},buildTab:function(context,id,section){var selected=$.cookie('wikiEditor-'+context.instance+'-toolbar-section');return $('<span />').attr({'class':'tab tab-'+id,'rel':id}).append($('<a />').addClass(selected==id?'current':null).attr('href','#').text($.wikiEditor.autoMsg(section,'label')).data('context',context).bind('mouseup',function(e){$(this).blur();}).bind('mousedown',function(e){if(e.button!==0){return true;}
228 -var $sections=$(this).data('context').$ui.find('.sections');var $section=$(this).data('context').$ui.find('.section-'+$(this).parent().attr('rel'));var show=$section.css('display')=='none';$previousSections=$section.parent().find('.section:visible');$previousSections.css('position','absolute');$previousSections.fadeOut('fast',function(){$(this).css('position','relative');});$(this).parent().parent().find('a').removeClass('current');$sections.css('overflow','hidden');if(show){$section.fadeIn('fast');$sections.animate({'height':$section.outerHeight()},$section.outerHeight()*2,function(){$(this).css('overflow','visible').css('height','auto');});$(this).addClass('current');}else{$sections.css('height',$section.outerHeight()).animate({'height':0},$section.outerHeight()*2,function(){$(this).css('overflow','visible');});}
 224+if('action'in character&&'label'in character){actions[character.label]=character.action;return'<a rel="'+character.label+'" href="#">'+character.label+'</a>';}},buildTab:function(context,id,section){var selected=$.cookie('wikiEditor-'+context.instance+'-toolbar-section');return $('<span />').attr({'class':'tab tab-'+id,'rel':id}).append($('<a />').addClass(selected==id?'current':null).attr('href','#').text($.wikiEditor.autoMsg(section,'label')).data('context',context).bind('mouseup',function(e){$(this).blur();}).bind('click',function(e){var $sections=$(this).data('context').$ui.find('.sections');var $section=$(this).data('context').$ui.find('.section-'+$(this).parent().attr('rel'));var show=$section.css('display')=='none';$previousSections=$section.parent().find('.section:visible');var dH=$previousSections.outerHeight();$previousSections.css('position','absolute');$previousSections.fadeOut('fast',function(){$(this).css('position','relative');});$(this).parent().parent().find('a').removeClass('current');$sections.css('overflow','hidden');if(show){$section.fadeIn('fast');dH=$section.outerHeight()-dH;if(context.modules.$toc){context.modules.$toc.animate({'height':"+="+dH},$section.outerHeight()*2);}
 225+$sections.animate({'height':$section.outerHeight()},$section.outerHeight()*2,function(){$(this).css('overflow','visible').css('height','auto');});$(this).addClass('current');}else{$sections.css('height',$section.outerHeight()).animate({'height':0},$section.outerHeight()*2,function(){$(this).css('overflow','visible');});if(context.modules.$toc){context.modules.$toc.animate({'height':"-="+$section.outerHeight()},$section.outerHeight()*2);}}
229226 if($.trackAction!=undefined){$.trackAction($section.attr('rel')+'.'+(show?'show':'hide'));}
230 -$.cookie('wikiEditor-'+$(this).data('context').instance+'-toolbar-section',show?$section.attr('rel'):null);}).click(function(){return false;}));},buildSection:function(context,id,section){context.$textarea.trigger('wikiEditor-toolbar-buildSection-'+id,[section]);var selected=$.cookie('wikiEditor-'+context.instance+'-toolbar-section');var $section;switch(section.type){case'toolbar':var $section=$('<div />').attr({'class':'toolbar section section-'+id,'rel':id});if('groups'in section){for(group in section.groups){$section.append($.wikiEditor.modules.toolbar.fn.buildGroup(context,group,section.groups[group]));}}
 227+$.cookie('wikiEditor-'+$(this).data('context').instance+'-toolbar-section',show?$section.attr('rel'):null);return false;}));},buildSection:function(context,id,section){context.$textarea.trigger('wikiEditor-toolbar-buildSection-'+id,[section]);var selected=$.cookie('wikiEditor-'+context.instance+'-toolbar-section');var $section;switch(section.type){case'toolbar':var $section=$('<div />').attr({'class':'toolbar section section-'+id,'rel':id});if('groups'in section){for(group in section.groups){$section.append($.wikiEditor.modules.toolbar.fn.buildGroup(context,group,section.groups[group]));}}
231228 break;case'booklet':var $pages=$('<div />').addClass('pages');var $index=$('<div />').addClass('index');if('pages'in section){for(page in section.pages){$pages.append($.wikiEditor.modules.toolbar.fn.buildPage(context,page,section.pages[page]));$index.append($.wikiEditor.modules.toolbar.fn.buildBookmark(context,page,section.pages[page]));}}
232229 $section=$('<div />').attr({'class':'booklet section section-'+id,'rel':id}).append($index).append($pages);$.wikiEditor.modules.toolbar.fn.updateBookletSelection(context,page,$pages,$index);break;}
233230 if($section!==null&&id!=='main'){var show=selected==id;$section.css('display',show?'block':'none');}
234231 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);}
235 -$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);if(wgNavigableTOCCollapseEnable){$dragControl=$('<div />').addClass('tab').attr('id','wikiEditor-ui-toc-resize-grip').append('<a href="#" title="Drag to resize"></a>').bind('mousedown',function(){$('#wikiEditor-ui-toc').data('openWidth',$('#wikiEditor-ui-toc').width());$().bind('mousemove',{'context':context},$.wikiEditor.modules.toc.fn.drag).bind('mouseup',{'context':context},$.wikiEditor.modules.toc.fn.stopDrag);$(context.$iframe[0].contentWindow.document).bind('mousemove',{'context':context},function(e){parent.top.$j().trigger("mousemove",e.pageX);return false;}).bind('mouseup',{'context':context},function(e){parent.top.$j().trigger("mouseup");return false;});return false;});context.modules.$toolbar.append($dragControl);}
236 -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]));}}
237 -$.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));var $section=s.$sections.find('.section:visible');if($section.size()){$sections.animate({'height':$section.outerHeight()},$section.outerHeight()*2);}}});}}};})(jQuery);
\ No newline at end of file
 232+$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]));}}
 233+$.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));var $section=s.$sections.find('.section:visible');if($section.size()){$sections.animate({'height':$section.outerHeight()},$section.outerHeight()*2,function(){if(context.modules.$toc){context.modules.$toc.height(context.$ui.find('.wikiEditor-ui-left').outerHeight()-context.$ui.find('.tab-toc').outerHeight())}});}}});}}};})(jQuery);
\ No newline at end of file

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r59799* updated js2 stopgap stubs to reflect new function name...dale19:56, 7 December 2009

Status & tagging log