r59367 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59366‎ | r59367 | r59368 >
Date:20:02, 23 November 2009
Author:adam
Status:deferred (Comments)
Tags:
Comment:
temporary fix for the calls to context.modules. in jquery.wikiEditor.toolbar.js introduced in r59152, minimal spacing fixes in jquery.wikiEditor.toc.js
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (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.toc.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -72,16 +72,16 @@
7373 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 20 ),
7474 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 19 ),
7575 array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 1 ),
76 - array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 32 ),
 76+ array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 33 ),
7777 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 9 ),
78 - array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 40 ),
 78+ array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 41 ),
7979 array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 3 ),
8080 ),
8181 'combined' => array(
82 - array( 'src' => 'js/plugins.combined.js', 'version' => 86 ),
 82+ array( 'src' => 'js/plugins.combined.js', 'version' => 87 ),
8383 ),
8484 'minified' => array(
85 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 86 ),
 85+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 87 ),
8686 ),
8787 ),
8888 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js
@@ -354,7 +354,7 @@
355355 .data( 'resizableDone', true )
356356 .find( '.wikiEditor-ui-right' )
357357 .data( 'wikiEditor-ui-left', context.$ui.find( '.wikiEditor-ui-left' ))
358 - .resizable( {handles: 'w,e', dontScrewWithLeft: true, minWidth: 50,
 358+ .resizable( {handles: 'w,e', preventPositionLeftChange: true, minWidth: 50,
359359 start: function( e, ui ) {
360360 $this = $( this );
361361 // Toss a transparent cover over our iframe
@@ -399,10 +399,10 @@
400400 /*
401401 * Extending resizable to allow west resizing without altering the left position attribute
402402 */
403 -$.ui.plugin.add("resizable", "dontScrewWithLeft", {
404 - resize: function(event, ui){
405 - $(this).data("resizable").position.left=0;
 403+$.ui.plugin.add( "resizable", "preventPositionLeftChange", {
 404+ resize: function( event, ui ) {
 405+ $( this ).data( "resizable" ).position.left = 0;
406406 }
407 -});
 407+} );
408408
409409 } ) ( jQuery );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js
@@ -479,7 +479,9 @@
480480 if ( show ) {
481481 $section.fadeIn( 'fast' );
482482 dH = $section.outerHeight() - dH;
483 - context.modules.$toc.animate({'height': "+="+dH}, $section.outerHeight() * 2);
 483+ if ( context.modules.$toc ) {
 484+ context.modules.$toc.animate({'height': "+="+dH}, $section.outerHeight() * 2);
 485+ }
484486 $sections.animate( { 'height': $section.outerHeight() }, $section.outerHeight() * 2, function() {
485487 $(this).css('overflow', 'visible').css('height', 'auto');
486488 } );
@@ -489,7 +491,9 @@
490492 .animate( { 'height': 0 }, $section.outerHeight() * 2, function() {
491493 $(this).css('overflow', 'visible');
492494 } );
493 - context.modules.$toc.animate({'height': "-="+$section.outerHeight()}, $section.outerHeight() * 2);
 495+ if ( context.modules.$toc ) {
 496+ context.modules.$toc.animate({'height': "-="+$section.outerHeight()}, $section.outerHeight() * 2);
 497+ }
494498 }
495499 // Click tracking
496500 if($.trackAction != undefined){
@@ -590,10 +594,12 @@
591595 var $section = s.$sections.find( '.section:visible' );
592596 if ( $section.size() ) {
593597 $sections.animate( { 'height': $section.outerHeight() }, $section.outerHeight() * 2, function( ) {
594 - context.modules.$toc.height(
595 - context.$ui.find( '.wikiEditor-ui-left' )
596 - .outerHeight() - context.$ui.find( '.tab-toc' ).outerHeight()
597 - );
 598+ if ( context.modules.$toc ) {
 599+ context.modules.$toc.height(
 600+ context.$ui.find( '.wikiEditor-ui-left' )
 601+ .outerHeight() - context.$ui.find( '.tab-toc' ).outerHeight()
 602+ )
 603+ }
598604 } );
599605 }
600606 }
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -1444,75 +1444,15 @@
14451445 // gets called again we can pick up where we left off
14461446 var context = $(this).data( 'wikiEditor-context' );
14471447
 1448+// This only gets run on the first call
14481449 if ( typeof context == 'undefined' ) {
14491450
1450 - /* Base UI Construction */
1451 -
14521451 var instance = $.wikiEditor.instances.length;
14531452 context = { '$textarea': $(this), 'modules': {}, 'data': {}, 'instance': instance };
14541453 $.wikiEditor.instances[instance] = $(this);
1455 - // Encapsulate the textarea with some containers for layout
1456 - $(this)
1457 - .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui' ) )
1458 - .wrap( $( '<div></div>' ).addClass( 'wikiEditor-wikitext' ) )
1459 - .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui-left' ) )
1460 - .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui-bottom' ) )
1461 - .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui-text' ) );
1462 - // Get a reference to the outer container
1463 - context.$ui = $(this).parent().parent().parent().parent();
1464 - context.$ui.after( $( '<div style="clear:both;"></div>' ) );
1465 - // Attach a right container
1466 - context.$ui.append( $( '<div></div>' ).addClass( 'wikiEditor-ui-right' ) );
1467 - // Attach a top container to the left pane
1468 - context.$ui.find( '.wikiEditor-ui-left' ).prepend( $( '<div></div>' ).addClass( 'wikiEditor-ui-top' ) );
14691454
1470 - /* Magic IFRAME Construction */
 1455+ /* Externally Accessible API */
14711456
1472 - // Create an iframe in place of the text area
1473 - context.$iframe = $( '<iframe></iframe>' )
1474 - .attr( 'frameborder', 0 )
1475 - .css( {
1476 - 'backgroundColor': 'white',
1477 - 'width': '100%',
1478 - 'height': context.$textarea.height(),
1479 - 'display': 'none',
1480 - 'overflow-y': 'scroll',
1481 - 'overflow-x': 'hidden',
1482 - })
1483 - .insertAfter( context.$textarea );
1484 -
1485 - /*
1486 - * For whatever strange reason, this code needs to be within a timeout or it doesn't work - it seems to be that
1487 - * the DOM manipulation to add the iframe happens asynchronously and this code that depends on it actually being
1488 - * finished doesn't function on the right reference.
1489 - * FIXME: The fact that this calls a function that's defined below is ugly
1490 - */
1491 - setTimeout( function() { context.fn.setup(); }, 1 );
1492 -
1493 - // Attach a submit handler to the form so that when the form is submitted the content of the iframe gets decoded and
1494 - // copied over to the textarea
1495 - context.$textarea.closest( 'form' ).submit( function() {
1496 - context.$textarea.attr( 'disabled', false );
1497 - context.$textarea.val( context.$textarea.textSelection( 'getContents' ) );
1498 - } );
1499 -
1500 - /* This is probably only a textarea issue, thus no longer needed
1501 - *
1502 - // Some browsers don't restore the cursor position on refocus properly
1503 - // Do it for them
1504 - $(this)
1505 - .focus( function() {
1506 - var pos = $(this).data( 'wikiEditor-cursor' );
1507 - if ( pos )
1508 - $(this).setSelection( pos[0], pos[1] );
1509 - $(this).data( 'wikiEditor-cursor', false );
1510 - })
1511 - .blur( function() {
1512 - $(this).data( 'wikiEditor-cursor', $(this).getCaretPosition( true ) );
1513 - });
1514 - */
1515 -
1516 - // Create a set of standard methods for internal and external use
15171457 context.api = {
15181458 /**
15191459 * Accepts either a string of the name of a module to add without any
@@ -1553,9 +1493,7 @@
15541494 }
15551495 }
15561496 }
1557 - /*
1558 - * Create a set of event handlers for the iframe to hook into
1559 - */
 1497+ /* Event Handlers */
15601498 context.evt = {
15611499 'change': function( event ) {
15621500 // BTW: context is in event.data.context
@@ -1598,11 +1536,11 @@
15991537 context.$iframe[0].contentWindow.document.close();
16001538 // Turn the document's design mode on
16011539 context.$iframe[0].contentWindow.document.designMode = 'on';
1602 -
16031540 // Get a reference to the content area of the iframe
16041541 context.$content = $( context.$iframe[0].contentWindow.document.body );
1605 - if ( $( 'body' ).is( '.rtl' ) )
 1542+ if ( $( 'body' ).is( '.rtl' ) ) {
16061543 context.$content.addClass( 'rtl' ).attr( 'dir', 'rtl' );
 1544+ }
16071545
16081546 /* Magic IFRAME Activation */
16091547
@@ -1672,7 +1610,6 @@
16731611 selText = selText.substring( 0, selText.length - 1 );
16741612 post += ' ';
16751613 }
1676 -
16771614 var range = context.$iframe[0].contentWindow.getSelection().getRangeAt( 0 );
16781615 if ( options.ownline ) {
16791616 // TODO: This'll probably break with syntax highlighting
@@ -1682,10 +1619,8 @@
16831620 if ( range.endContainer == range.commonAncestorContainer )
16841621 post += "\n";
16851622 }
1686 -
16871623 var insertText = pre + selText + post;
16881624 var insertLines = insertText.split( "\n" );
1689 -
16901625 range.extractContents();
16911626 // Insert the contents one line at a time
16921627 // insertNode() inserts at the beginning, so this has
@@ -1693,12 +1628,13 @@
16941629 var lastNode;
16951630 for ( var i = insertLines.length - 1; i >= 0; i-- ) {
16961631 range.insertNode( document.createTextNode( insertLines[i] ) );
1697 - if ( i > 0 )
 1632+ if ( i > 0 ) {
16981633 lastNode = range.insertNode( document.createElement( 'br' ) );
 1634+ }
16991635 }
1700 - if ( lastNode )
 1636+ if ( lastNode ) {
17011637 context.fn.scrollToTop( lastNode );
1702 -
 1638+ }
17031639 // Trigger the encapsulateSelection event (this might need to get named something else/done differently)
17041640 context.$content.trigger( 'encapsulateSelection', [ pre, peri, post, ownline, replace ] );
17051641 return context.$textarea;
@@ -1741,10 +1677,56 @@
17421678 $element.trigger( 'scrollToTop' );
17431679 }
17441680 };
 1681+
 1682+ /* Base UI Construction */
 1683+
 1684+ // Encapsulate the textarea with some containers for layout
 1685+ $(this)
 1686+ .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui' ) )
 1687+ .wrap( $( '<div></div>' ).addClass( 'wikiEditor-wikitext' ) )
 1688+ .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui-left' ) )
 1689+ .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui-bottom' ) )
 1690+ .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui-text' ) );
 1691+ // Get a reference to the outer container
 1692+ context.$ui = $(this).parent().parent().parent().parent();
 1693+ context.$ui.after( $( '<div style="clear:both;"></div>' ) );
 1694+ // Attach a right container
 1695+ context.$ui.append( $( '<div></div>' ).addClass( 'wikiEditor-ui-right' ) );
 1696+ // Attach a top container to the left pane
 1697+ context.$ui.find( '.wikiEditor-ui-left' ).prepend( $( '<div></div>' ).addClass( 'wikiEditor-ui-top' ) );
 1698+
 1699+ /* Magic IFRAME Construction */
 1700+
 1701+ // Create an iframe in place of the text area
 1702+ context.$iframe = $( '<iframe></iframe>' )
 1703+ .attr( 'frameborder', 0 )
 1704+ .css( {
 1705+ 'backgroundColor': 'white',
 1706+ 'width': '100%',
 1707+ 'height': context.$textarea.height(),
 1708+ 'display': 'none',
 1709+ 'overflow-y': 'scroll',
 1710+ 'overflow-x': 'hidden',
 1711+ })
 1712+ .insertAfter( context.$textarea );
 1713+
 1714+ /*
 1715+ * For whatever strange reason, this code needs to be within a timeout or it doesn't work - it seems to be that
 1716+ * the DOM manipulation to add the iframe happens asynchronously and this code that depends on it actually being
 1717+ * finished doesn't function on the right reference.
 1718+ * FIXME: The fact that this calls a function that's defined below is ugly
 1719+ */
 1720+ setTimeout( function() { context.fn.setup(); }, 1 );
 1721+
 1722+ // Attach a submit handler to the form so that when the form is submitted the content of the iframe gets decoded and
 1723+ // copied over to the textarea
 1724+ context.$textarea.closest( 'form' ).submit( function() {
 1725+ context.$textarea.attr( 'disabled', false );
 1726+ context.$textarea.val( context.$textarea.textSelection( 'getContents' ) );
 1727+ } );
17451728 }
17461729
1747 -// If there was a configuration passed, it's assumed to be for the addModule
1748 -// API call
 1730+// If there was a configuration passed, it's assumed to be for the addModule API call
17491731 if ( arguments.length > 0 && typeof arguments[0] == 'object' ) {
17501732 // If the iframe construction isn't ready yet, defer the call
17511733 if ( context.fn.isSetup() )
@@ -1756,8 +1738,7 @@
17571739 }, 2 );
17581740 }
17591741 } else {
1760 - // Since javascript gives arguments as an object, we need to convert them
1761 - // so they can be used more easily
 1742+ // Since javascript gives arguments as an object, we need to convert them so they can be used more easily
17621743 arguments = $.makeArray( arguments );
17631744 if ( arguments.length > 0 ) {
17641745 // Handle API calls
@@ -2424,7 +2405,9 @@
24252406 if ( show ) {
24262407 $section.fadeIn( 'fast' );
24272408 dH = $section.outerHeight() - dH;
2428 - context.modules.$toc.animate({'height': "+="+dH}, $section.outerHeight() * 2);
 2409+ if ( context.modules.$toc ) {
 2410+ context.modules.$toc.animate({'height': "+="+dH}, $section.outerHeight() * 2);
 2411+ }
24292412 $sections.animate( { 'height': $section.outerHeight() }, $section.outerHeight() * 2, function() {
24302413 $(this).css('overflow', 'visible').css('height', 'auto');
24312414 } );
@@ -2434,7 +2417,9 @@
24352418 .animate( { 'height': 0 }, $section.outerHeight() * 2, function() {
24362419 $(this).css('overflow', 'visible');
24372420 } );
2438 - context.modules.$toc.animate({'height': "-="+$section.outerHeight()}, $section.outerHeight() * 2);
 2421+ if ( context.modules.$toc ) {
 2422+ context.modules.$toc.animate({'height': "-="+$section.outerHeight()}, $section.outerHeight() * 2);
 2423+ }
24392424 }
24402425 // Click tracking
24412426 if($.trackAction != undefined){
@@ -2535,10 +2520,12 @@
25362521 var $section = s.$sections.find( '.section:visible' );
25372522 if ( $section.size() ) {
25382523 $sections.animate( { 'height': $section.outerHeight() }, $section.outerHeight() * 2, function( ) {
2539 - context.modules.$toc.height(
2540 - context.$ui.find( '.wikiEditor-ui-left' )
2541 - .outerHeight() - context.$ui.find( '.tab-toc' ).outerHeight()
2542 - );
 2524+ if ( context.modules.$toc ) {
 2525+ context.modules.$toc.height(
 2526+ context.$ui.find( '.wikiEditor-ui-left' )
 2527+ .outerHeight() - context.$ui.find( '.tab-toc' ).outerHeight()
 2528+ )
 2529+ }
25432530 } );
25442531 }
25452532 }
@@ -2903,7 +2890,7 @@
29042891 .data( 'resizableDone', true )
29052892 .find( '.wikiEditor-ui-right' )
29062893 .data( 'wikiEditor-ui-left', context.$ui.find( '.wikiEditor-ui-left' ))
2907 - .resizable( {handles: 'w,e', dontScrewWithLeft: true, minWidth: 50,
 2894+ .resizable( {handles: 'w,e', preventPositionLeftChange: true, minWidth: 50,
29082895 start: function( e, ui ) {
29092896 $this = $( this );
29102897 // Toss a transparent cover over our iframe
@@ -2948,11 +2935,11 @@
29492936 /*
29502937 * Extending resizable to allow west resizing without altering the left position attribute
29512938 */
2952 -$.ui.plugin.add("resizable", "dontScrewWithLeft", {
2953 - resize: function(event, ui){
2954 - $(this).data("resizable").position.left=0;
 2939+$.ui.plugin.add( "resizable", "preventPositionLeftChange", {
 2940+ resize: function( event, ui ) {
 2941+ $( this ).data( "resizable" ).position.left = 0;
29552942 }
2956 -});
 2943+} );
29572944
29582945 } ) ( jQuery );
29592946 /* Preview module for wikiEditor */
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -84,22 +84,21 @@
8585 var browser=$.wikiEditor.browsers[$('body').is('.rtl')?'rtl':'ltr'][$.browser.name];for(condition in browser){var op=browser[condition][0];var val=browser[condition][1];if(typeof val=='string'){if(!(eval('$.browser.version'+op+'"'+val+'"'))){return false;}}else if(typeof val=='number'){if(!(eval('$.browser.versionNumber'+op+val))){return false;}}}
8686 return true;},'autoMsg':function(object,property){if(typeof property=='object'){for(i in property){if(property[i]in object||property[i]+'Msg'in object){property=property[i];break;}}}
8787 if(property in object){return object[property];}else if(property+'Msg'in object){return gM(object[property+'Msg']);}else{return'';}},'fixOperaBrokenness':function(s){return s;}};$.fn.wikiEditor=function(){if($j.wikiEditor.isSupportKnown()&&!$j.wikiEditor.isSupported()){return $(this);}
88 -var context=$(this).data('wikiEditor-context');if(typeof context=='undefined'){var instance=$.wikiEditor.instances.length;context={'$textarea':$(this),'modules':{},'data':{},'instance':instance};$.wikiEditor.instances[instance]=$(this);$(this).wrap($('<div></div>').addClass('wikiEditor-ui')).wrap($('<div></div>').addClass('wikiEditor-wikitext')).wrap($('<div></div>').addClass('wikiEditor-ui-left')).wrap($('<div></div>').addClass('wikiEditor-ui-bottom')).wrap($('<div></div>').addClass('wikiEditor-ui-text'));context.$ui=$(this).parent().parent().parent().parent();context.$ui.after($('<div style="clear:both;"></div>'));context.$ui.append($('<div></div>').addClass('wikiEditor-ui-right'));context.$ui.find('.wikiEditor-ui-left').prepend($('<div></div>').addClass('wikiEditor-ui-top'));context.$iframe=$('<iframe></iframe>').attr('frameborder',0).css({'backgroundColor':'white','width':'100%','height':context.$textarea.height(),'display':'none','overflow-y':'scroll','overflow-x':'hidden',}).insertAfter(context.$textarea);setTimeout(function(){context.fn.setup();},1);context.$textarea.closest('form').submit(function(){context.$textarea.attr('disabled',false);context.$textarea.val(context.$textarea.textSelection('getContents'));});context.api={'addModule':function(context,data){function callModuleApi(module,call,data){if(module in $.wikiEditor.modules&&'fn'in $.wikiEditor.modules[module]&&call in $.wikiEditor.modules[module].fn){$.wikiEditor.modules[module].fn[call](context,data);}}
 88+var context=$(this).data('wikiEditor-context');if(typeof context=='undefined'){var instance=$.wikiEditor.instances.length;context={'$textarea':$(this),'modules':{},'data':{},'instance':instance};$.wikiEditor.instances[instance]=$(this);context.api={'addModule':function(context,data){function callModuleApi(module,call,data){if(module in $.wikiEditor.modules&&'fn'in $.wikiEditor.modules[module]&&call in $.wikiEditor.modules[module].fn){$.wikiEditor.modules[module].fn[call](context,data);}}
8989 if(typeof data=='string'){callModuleApi(data,'create',{});}else if(typeof data=='object'){for(module in data){if(typeof module=='string'){callModuleApi(module,'create',data[module]);}}}}};for(module in $.wikiEditor.modules){if('api'in $.wikiEditor.modules[module]){for(call in $.wikiEditor.modules[module].api){if(!(call in context.api)){context.api[call]=$.wikiEditor.modules[module].api[call];}}}}
9090 context.evt={'change':function(event){switch(event.type){case'keypress':if(false){}else{}
9191 break;case'mousedown':if(false){}else{}
92 -break;default:break;}}};context.fn={'setup':function(){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"></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'))
93 -context.$content.addClass('rtl').attr('dir','rtl');context.$textarea.attr('disabled',true);context.$content.text(context.$textarea.val());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;},'getSelection':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();}
 92+break;default:break;}}};context.fn={'setup':function(){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"></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');}
 93+context.$textarea.attr('disabled',true);context.$content.text(context.$textarea.val());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;},'getSelection':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();}
9494 if(retval.text){retval=retval.text;}else if(retval.toString){retval=retval.toString();}
9595 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+=' ';}
9696 var range=context.$iframe[0].contentWindow.getSelection().getRangeAt(0);if(options.ownline){if(range.startOffset!=0)
9797 pre="\n"+options.pre;if(range.endContainer==range.commonAncestorContainer)
9898 post+="\n";}
99 -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)
100 -lastNode=range.insertNode(document.createElement('br'));}
101 -if(lastNode)
102 -context.fn.scrollToTop(lastNode);context.$content.trigger('encapsulateSelection',[pre,peri,post,ownline,replace]);return context.$textarea;},'getCaretPosition':function(options){},'setSelection':function(options){},'scrollToCaretPosition':function(options){},'scrollToTop':function($element,force){var body=context.$content.closest('body');var y=$element.offset().top-context.$content.offset().top;if(force||y<body.scrollTop()||y>body.scrollTop()+body.height())
103 -body.scrollTop(y);$element.trigger('scrollToTop');}};}
 99+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'));}}
 100+if(lastNode){context.fn.scrollToTop(lastNode);}
 101+context.$content.trigger('encapsulateSelection',[pre,peri,post,ownline,replace]);return context.$textarea;},'getCaretPosition':function(options){},'setSelection':function(options){},'scrollToCaretPosition':function(options){},'scrollToTop':function($element,force){var body=context.$content.closest('body');var y=$element.offset().top-context.$content.offset().top;if(force||y<body.scrollTop()||y>body.scrollTop()+body.height())
 102+body.scrollTop(y);$element.trigger('scrollToTop');}};$(this).wrap($('<div></div>').addClass('wikiEditor-ui')).wrap($('<div></div>').addClass('wikiEditor-wikitext')).wrap($('<div></div>').addClass('wikiEditor-ui-left')).wrap($('<div></div>').addClass('wikiEditor-ui-bottom')).wrap($('<div></div>').addClass('wikiEditor-ui-text'));context.$ui=$(this).parent().parent().parent().parent();context.$ui.after($('<div style="clear:both;"></div>'));context.$ui.append($('<div></div>').addClass('wikiEditor-ui-right'));context.$ui.find('.wikiEditor-ui-left').prepend($('<div></div>').addClass('wikiEditor-ui-top'));context.$iframe=$('<iframe></iframe>').attr('frameborder',0).css({'backgroundColor':'white','width':'100%','height':context.$textarea.height(),'display':'none','overflow-y':'scroll','overflow-x':'hidden',}).insertAfter(context.$textarea);setTimeout(function(){context.fn.setup();},1);context.$textarea.closest('form').submit(function(){context.$textarea.attr('disabled',false);context.$textarea.val(context.$textarea.textSelection('getContents'));});}
104103 if(arguments.length>0&&typeof arguments[0]=='object'){if(context.fn.isSetup())
105104 context.api.addModule(context,arguments[0]);else{var args=arguments;setTimeout(function(){context.api.addModule(context,args[0]);},2);}}else{arguments=$.makeArray(arguments);if(arguments.length>0){var call=arguments.shift();if(call in context.api){if(context.fn.isSetup())
106105 context.api[call](context,arguments[0]==undefined?{}:arguments[0]);else{var args=arguments;setTimeout(function(){context.api[call](context,args[0]==undefined?{}:args[0]);},2);}}}}
@@ -148,7 +147,8 @@
149148 return html;},buildRow:function(context,row){var html='<tr>';for(cell in row){html+='<td class="cell cell-'+cell+'" valign="top"><span>'+
150149 $.wikiEditor.autoMsg(row[cell],['html','text'])+'</span></td>';}
151150 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]}}};}
152 -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;context.modules.$toc.animate({'height':"+="+dH},$section.outerHeight()*2);$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');});context.modules.$toc.animate({'height':"-="+$section.outerHeight()},$section.outerHeight()*2);}
 151+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);}
 152+$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);}}
153153 if($.trackAction!=undefined){$.trackAction($section.attr('rel')+'.'+(show?'show':'hide'));}
154154 $.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]));}}
155155 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]));}}
@@ -156,7 +156,7 @@
157157 if($section!==null&&id!=='main'){var show=selected==id;$section.css('display',show?'block':'none');}
158158 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);}
159159 $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]));}}
160 -$.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(){context.modules.$toc.height(context.$ui.find('.wikiEditor-ui-left').outerHeight()-context.$ui.find('.tab-toc').outerHeight());});}}});}}};})(jQuery);(function($){$.wikiEditor.modules.toc={api:{},defaultWidth:'13em',fn:{create:function(context,config){if('$toc'in context.modules){return;}
 160+$.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);(function($){$.wikiEditor.modules.toc={api:{},defaultWidth:'13em',fn:{create:function(context,config){if('$toc'in context.modules){return;}
161161 context.initialWidth=$.wikiEditor.modules.toc.defaultWidth;if(wgNavigableTOCResizable){if(!$.cookie('wikiEditor-'+context.instance+'-toc-width')){$.cookie('wikiEditor-'+context.instance+'-toc-width',$.wikiEditor.modules.toc.defaultWidth);}else{context.initialWidth=$.cookie('wikiEditor-'+context.instance+'-toc-width');}}
162162 var height=context.$ui.find('.wikiEditor-ui-left').height();context.modules.$toc=$('<div />').addClass('wikiEditor-ui-toc').data('context',context);context.$ui.find('.wikiEditor-ui-right').css('width',$.wikiEditor.modules.toc.defaultWidth).append(context.modules.$toc);context.modules.$toc.height(context.$ui.find('.wikiEditor-ui-left').height());context.$ui.find('.wikiEditor-ui-left').css('marginRight',"-"+$.wikiEditor.modules.toc.defaultWidth).children().css('marginRight',$.wikiEditor.modules.toc.defaultWidth);$.wikiEditor.modules.toc.fn.build(context,config);context.$content.parent().delayedBind(250,'mouseup scrollToTop keyup change',function(){$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).blur(function(event){var context=event.data.context;context.$textarea.delayedBindCancel(250,'mouseup scrollToTop keyup change');$.wikiEditor.modules.toc.fn.unhighlight(context);});},unhighlight:function(context){context.modules.$toc.find('div').removeClass('current');},update:function(context){$.wikiEditor.modules.toc.fn.unhighlight(context);var position=context.$textarea.textSelection('getCaretPosition');var section=0;if(context.data.outline.length>0){if(!(position<context.data.outline[0].position-1)){while(section<context.data.outline.length&&context.data.outline[section].position-1<position){section++;}
163163 section=Math.max(0,section);}
@@ -186,8 +186,8 @@
187187 if(nLevel<=0){nLevel=1;}
188188 outline[i].nLevel=nLevel;lastLevel=outline[i].level;}
189189 var structure=buildStructure(outline);if($('input[name=wpSection]').val()==''){structure.unshift({'text':wgPageName.replace(/_/g,' '),'level':1,'index':0,'wrapper':context.$content});}
190 -context.modules.$toc.html(buildList(structure));if(wgNavigableTOCResizable&&!context.$ui.data('resizableDone')){context.$ui.data('resizableDone',true).find('.wikiEditor-ui-right').data('wikiEditor-ui-left',context.$ui.find('.wikiEditor-ui-left')).resizable({handles:'w,e',dontScrewWithLeft:true,minWidth:50,start:function(e,ui){$this=$(this);$('<div />').addClass('wikiEditor-ui-resize-mask').css('position','absolute').css('z-index',2).css('left',0).css('top',0).css('bottom',0).css('right',0).appendTo(context.$ui.find('.wikiEditor-ui-left'));$this.resizable('option','maxWidth',$this.parent().width()-450);},resize:function(e,ui){$(this).css({'width':ui.size.width,'top':'auto'}).data('wikiEditor-ui-left').css('marginRight',(-1*ui.size.width)).children().css('marginRight',ui.size.width);},stop:function(e,ui){context.$ui.find('.wikiEditor-ui-resize-mask').remove();if(ui.size.width<70){context.modules.$toc.trigger('collapse');}}});context.modules.$toc.append(buildResizeControls());buildCollapseControls();}
191 -context.modules.$toc.find('div').autoEllipse({'position':'right','tooltip':true});context.data.outline=outline;}}};$.ui.plugin.add("resizable","dontScrewWithLeft",{resize:function(event,ui){$(this).data("resizable").position.left=0;}});})(jQuery);(function($){$.wikiEditor.modules.preview={api:{},fn:{create:function(context,config){mvJsLoader.doLoad(['$j.ui','$j.ui.tabs'],function(){if('preview'in context.modules)
 190+context.modules.$toc.html(buildList(structure));if(wgNavigableTOCResizable&&!context.$ui.data('resizableDone')){context.$ui.data('resizableDone',true).find('.wikiEditor-ui-right').data('wikiEditor-ui-left',context.$ui.find('.wikiEditor-ui-left')).resizable({handles:'w,e',preventPositionLeftChange:true,minWidth:50,start:function(e,ui){$this=$(this);$('<div />').addClass('wikiEditor-ui-resize-mask').css('position','absolute').css('z-index',2).css('left',0).css('top',0).css('bottom',0).css('right',0).appendTo(context.$ui.find('.wikiEditor-ui-left'));$this.resizable('option','maxWidth',$this.parent().width()-450);},resize:function(e,ui){$(this).css({'width':ui.size.width,'top':'auto'}).data('wikiEditor-ui-left').css('marginRight',(-1*ui.size.width)).children().css('marginRight',ui.size.width);},stop:function(e,ui){context.$ui.find('.wikiEditor-ui-resize-mask').remove();if(ui.size.width<70){context.modules.$toc.trigger('collapse');}}});context.modules.$toc.append(buildResizeControls());buildCollapseControls();}
 191+context.modules.$toc.find('div').autoEllipse({'position':'right','tooltip':true});context.data.outline=outline;}}};$.ui.plugin.add("resizable","preventPositionLeftChange",{resize:function(event,ui){$(this).data("resizable").position.left=0;}});})(jQuery);(function($){$.wikiEditor.modules.preview={api:{},fn:{create:function(context,config){mvJsLoader.doLoad(['$j.ui','$j.ui.tabs'],function(){if('preview'in context.modules)
192192 return;var iframeHTML=context.$content.html();context.$ui.wrapInner($('<div />').addClass('wikiEditor-tab-edit').attr('id','wikiEditor-'+context.instance+'-tab-edit')).wrapInner($('<div />').addClass('wikiEditor-tabs'));var tabList=context.$ui.children();var editTab=tabList.children();var loadingMsg=gM('wikieditor-preview-loading');var previewTab=$('<div />').addClass('wikiEditor-tab-preview').attr('id','wikiEditor-'+context.instance+'-tab-preview').append($('<div />').addClass('wikiEditor-preview-spinner').append($('<img />').attr({'src':$.wikiEditor.imgPath+'dialogs/loading.gif','alt':loadingMsg,'title':loadingMsg}))).append($('<div />').addClass('wikiEditor-preview-contents')).insertAfter(editTab);var dialogID='wikiEditor-'+context.instance+'-savedialog';$.wikiEditor.modules.dialogs.fn.create(context,{previewsave:{id:dialogID,titleMsg:'wikieditor-preview-savedialog-title',html:'\
193193 <div class="wikiEditor-savedialog-copywarn"></div>\
194194 <div class="wikiEditor-savedialog-editoptions">\

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r59152migrating the toc resizing to use jquery ui resizableadam23:26, 16 November 2009

Comments

#Comment by Catrope (talk | contribs)   11:15, 24 November 2009

Note: this also recombines for r59366

Status & tagging log