Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -72,16 +72,16 @@ |
73 | 73 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 20 ), |
74 | 74 | array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 19 ), |
75 | 75 | 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 ), |
77 | 77 | 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 ), |
79 | 79 | array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 3 ), |
80 | 80 | ), |
81 | 81 | 'combined' => array( |
82 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 86 ), |
| 82 | + array( 'src' => 'js/plugins.combined.js', 'version' => 87 ), |
83 | 83 | ), |
84 | 84 | 'minified' => array( |
85 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 86 ), |
| 85 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 87 ), |
86 | 86 | ), |
87 | 87 | ), |
88 | 88 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js |
— | — | @@ -354,7 +354,7 @@ |
355 | 355 | .data( 'resizableDone', true ) |
356 | 356 | .find( '.wikiEditor-ui-right' ) |
357 | 357 | .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, |
359 | 359 | start: function( e, ui ) { |
360 | 360 | $this = $( this ); |
361 | 361 | // Toss a transparent cover over our iframe |
— | — | @@ -399,10 +399,10 @@ |
400 | 400 | /* |
401 | 401 | * Extending resizable to allow west resizing without altering the left position attribute |
402 | 402 | */ |
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; |
406 | 406 | } |
407 | | -}); |
| 407 | +} ); |
408 | 408 | |
409 | 409 | } ) ( jQuery ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js |
— | — | @@ -479,7 +479,9 @@ |
480 | 480 | if ( show ) { |
481 | 481 | $section.fadeIn( 'fast' ); |
482 | 482 | 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 | + } |
484 | 486 | $sections.animate( { 'height': $section.outerHeight() }, $section.outerHeight() * 2, function() { |
485 | 487 | $(this).css('overflow', 'visible').css('height', 'auto'); |
486 | 488 | } ); |
— | — | @@ -489,7 +491,9 @@ |
490 | 492 | .animate( { 'height': 0 }, $section.outerHeight() * 2, function() { |
491 | 493 | $(this).css('overflow', 'visible'); |
492 | 494 | } ); |
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 | + } |
494 | 498 | } |
495 | 499 | // Click tracking |
496 | 500 | if($.trackAction != undefined){ |
— | — | @@ -590,10 +594,12 @@ |
591 | 595 | var $section = s.$sections.find( '.section:visible' ); |
592 | 596 | if ( $section.size() ) { |
593 | 597 | $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 | + } |
598 | 604 | } ); |
599 | 605 | } |
600 | 606 | } |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -1444,75 +1444,15 @@ |
1445 | 1445 | // gets called again we can pick up where we left off |
1446 | 1446 | var context = $(this).data( 'wikiEditor-context' ); |
1447 | 1447 | |
| 1448 | +// This only gets run on the first call |
1448 | 1449 | if ( typeof context == 'undefined' ) { |
1449 | 1450 | |
1450 | | - /* Base UI Construction */ |
1451 | | - |
1452 | 1451 | var instance = $.wikiEditor.instances.length; |
1453 | 1452 | context = { '$textarea': $(this), 'modules': {}, 'data': {}, 'instance': instance }; |
1454 | 1453 | $.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' ) ); |
1469 | 1454 | |
1470 | | - /* Magic IFRAME Construction */ |
| 1455 | + /* Externally Accessible API */ |
1471 | 1456 | |
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 |
1517 | 1457 | context.api = { |
1518 | 1458 | /** |
1519 | 1459 | * Accepts either a string of the name of a module to add without any |
— | — | @@ -1553,9 +1493,7 @@ |
1554 | 1494 | } |
1555 | 1495 | } |
1556 | 1496 | } |
1557 | | - /* |
1558 | | - * Create a set of event handlers for the iframe to hook into |
1559 | | - */ |
| 1497 | + /* Event Handlers */ |
1560 | 1498 | context.evt = { |
1561 | 1499 | 'change': function( event ) { |
1562 | 1500 | // BTW: context is in event.data.context |
— | — | @@ -1598,11 +1536,11 @@ |
1599 | 1537 | context.$iframe[0].contentWindow.document.close(); |
1600 | 1538 | // Turn the document's design mode on |
1601 | 1539 | context.$iframe[0].contentWindow.document.designMode = 'on'; |
1602 | | - |
1603 | 1540 | // Get a reference to the content area of the iframe |
1604 | 1541 | context.$content = $( context.$iframe[0].contentWindow.document.body ); |
1605 | | - if ( $( 'body' ).is( '.rtl' ) ) |
| 1542 | + if ( $( 'body' ).is( '.rtl' ) ) { |
1606 | 1543 | context.$content.addClass( 'rtl' ).attr( 'dir', 'rtl' ); |
| 1544 | + } |
1607 | 1545 | |
1608 | 1546 | /* Magic IFRAME Activation */ |
1609 | 1547 | |
— | — | @@ -1672,7 +1610,6 @@ |
1673 | 1611 | selText = selText.substring( 0, selText.length - 1 ); |
1674 | 1612 | post += ' '; |
1675 | 1613 | } |
1676 | | - |
1677 | 1614 | var range = context.$iframe[0].contentWindow.getSelection().getRangeAt( 0 ); |
1678 | 1615 | if ( options.ownline ) { |
1679 | 1616 | // TODO: This'll probably break with syntax highlighting |
— | — | @@ -1682,10 +1619,8 @@ |
1683 | 1620 | if ( range.endContainer == range.commonAncestorContainer ) |
1684 | 1621 | post += "\n"; |
1685 | 1622 | } |
1686 | | - |
1687 | 1623 | var insertText = pre + selText + post; |
1688 | 1624 | var insertLines = insertText.split( "\n" ); |
1689 | | - |
1690 | 1625 | range.extractContents(); |
1691 | 1626 | // Insert the contents one line at a time |
1692 | 1627 | // insertNode() inserts at the beginning, so this has |
— | — | @@ -1693,12 +1628,13 @@ |
1694 | 1629 | var lastNode; |
1695 | 1630 | for ( var i = insertLines.length - 1; i >= 0; i-- ) { |
1696 | 1631 | range.insertNode( document.createTextNode( insertLines[i] ) ); |
1697 | | - if ( i > 0 ) |
| 1632 | + if ( i > 0 ) { |
1698 | 1633 | lastNode = range.insertNode( document.createElement( 'br' ) ); |
| 1634 | + } |
1699 | 1635 | } |
1700 | | - if ( lastNode ) |
| 1636 | + if ( lastNode ) { |
1701 | 1637 | context.fn.scrollToTop( lastNode ); |
1702 | | - |
| 1638 | + } |
1703 | 1639 | // Trigger the encapsulateSelection event (this might need to get named something else/done differently) |
1704 | 1640 | context.$content.trigger( 'encapsulateSelection', [ pre, peri, post, ownline, replace ] ); |
1705 | 1641 | return context.$textarea; |
— | — | @@ -1741,10 +1677,56 @@ |
1742 | 1678 | $element.trigger( 'scrollToTop' ); |
1743 | 1679 | } |
1744 | 1680 | }; |
| 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 | + } ); |
1745 | 1728 | } |
1746 | 1729 | |
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 |
1749 | 1731 | if ( arguments.length > 0 && typeof arguments[0] == 'object' ) { |
1750 | 1732 | // If the iframe construction isn't ready yet, defer the call |
1751 | 1733 | if ( context.fn.isSetup() ) |
— | — | @@ -1756,8 +1738,7 @@ |
1757 | 1739 | }, 2 ); |
1758 | 1740 | } |
1759 | 1741 | } 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 |
1762 | 1743 | arguments = $.makeArray( arguments ); |
1763 | 1744 | if ( arguments.length > 0 ) { |
1764 | 1745 | // Handle API calls |
— | — | @@ -2424,7 +2405,9 @@ |
2425 | 2406 | if ( show ) { |
2426 | 2407 | $section.fadeIn( 'fast' ); |
2427 | 2408 | 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 | + } |
2429 | 2412 | $sections.animate( { 'height': $section.outerHeight() }, $section.outerHeight() * 2, function() { |
2430 | 2413 | $(this).css('overflow', 'visible').css('height', 'auto'); |
2431 | 2414 | } ); |
— | — | @@ -2434,7 +2417,9 @@ |
2435 | 2418 | .animate( { 'height': 0 }, $section.outerHeight() * 2, function() { |
2436 | 2419 | $(this).css('overflow', 'visible'); |
2437 | 2420 | } ); |
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 | + } |
2439 | 2424 | } |
2440 | 2425 | // Click tracking |
2441 | 2426 | if($.trackAction != undefined){ |
— | — | @@ -2535,10 +2520,12 @@ |
2536 | 2521 | var $section = s.$sections.find( '.section:visible' ); |
2537 | 2522 | if ( $section.size() ) { |
2538 | 2523 | $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 | + } |
2543 | 2530 | } ); |
2544 | 2531 | } |
2545 | 2532 | } |
— | — | @@ -2903,7 +2890,7 @@ |
2904 | 2891 | .data( 'resizableDone', true ) |
2905 | 2892 | .find( '.wikiEditor-ui-right' ) |
2906 | 2893 | .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, |
2908 | 2895 | start: function( e, ui ) { |
2909 | 2896 | $this = $( this ); |
2910 | 2897 | // Toss a transparent cover over our iframe |
— | — | @@ -2948,11 +2935,11 @@ |
2949 | 2936 | /* |
2950 | 2937 | * Extending resizable to allow west resizing without altering the left position attribute |
2951 | 2938 | */ |
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; |
2955 | 2942 | } |
2956 | | -}); |
| 2943 | +} ); |
2957 | 2944 | |
2958 | 2945 | } ) ( jQuery ); |
2959 | 2946 | /* Preview module for wikiEditor */ |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -84,22 +84,21 @@ |
85 | 85 | 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;}}} |
86 | 86 | 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;}}} |
87 | 87 | 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);}} |
89 | 89 | if(typeof data=='string'){callModuleApi(data,'create',{});}else if(typeof data=='object'){for(module in data){if(typeof module=='string'){callModuleApi(module,'create',data[module]);}}}}};for(module in $.wikiEditor.modules){if('api'in $.wikiEditor.modules[module]){for(call in $.wikiEditor.modules[module].api){if(!(call in context.api)){context.api[call]=$.wikiEditor.modules[module].api[call];}}}} |
90 | 90 | context.evt={'change':function(event){switch(event.type){case'keypress':if(false){}else{} |
91 | 91 | 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();} |
94 | 94 | if(retval.text){retval=retval.text;}else if(retval.toString){retval=retval.toString();} |
95 | 95 | 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+=' ';} |
96 | 96 | var range=context.$iframe[0].contentWindow.getSelection().getRangeAt(0);if(options.ownline){if(range.startOffset!=0) |
97 | 97 | pre="\n"+options.pre;if(range.endContainer==range.commonAncestorContainer) |
98 | 98 | 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'));});} |
104 | 103 | if(arguments.length>0&&typeof arguments[0]=='object'){if(context.fn.isSetup()) |
105 | 104 | 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()) |
106 | 105 | 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 @@ |
149 | 148 | return html;},buildRow:function(context,row){var html='<tr>';for(cell in row){html+='<td class="cell cell-'+cell+'" valign="top"><span>'+ |
150 | 149 | $.wikiEditor.autoMsg(row[cell],['html','text'])+'</span></td>';} |
151 | 150 | 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);}} |
153 | 153 | if($.trackAction!=undefined){$.trackAction($section.attr('rel')+'.'+(show?'show':'hide'));} |
154 | 154 | $.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]));}} |
155 | 155 | 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 @@ |
157 | 157 | if($section!==null&&id!=='main'){var show=selected==id;$section.css('display',show?'block':'none');} |
158 | 158 | 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);} |
159 | 159 | $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;} |
161 | 161 | 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');}} |
162 | 162 | 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++;} |
163 | 163 | section=Math.max(0,section);} |
— | — | @@ -186,8 +186,8 @@ |
187 | 187 | if(nLevel<=0){nLevel=1;} |
188 | 188 | outline[i].nLevel=nLevel;lastLevel=outline[i].level;} |
189 | 189 | 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) |
192 | 192 | 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:'\ |
193 | 193 | <div class="wikiEditor-savedialog-copywarn"></div>\ |
194 | 194 | <div class="wikiEditor-savedialog-editoptions">\ |