Index: trunk/extensions/UsabilityInitiative/Vector/Vector.combined.js |
— | — | @@ -120,8 +120,8 @@ |
121 | 121 | /* JavaScript for EditWarning extension */ |
122 | 122 | |
123 | 123 | mw.ready( function() { |
124 | | - // Check if EditWarning is enabled |
125 | | - if ( !wgVectorEnabledModules.editwarning ) { |
| 124 | + // Check if EditWarning is enabled and if we need it |
| 125 | + if ( !wgVectorEnabledModules.editwarning || $j( '#wpTextbox1' ).size() == 0 ) { |
126 | 126 | return true; |
127 | 127 | } |
128 | 128 | // Get the original values of some form elements |
Index: trunk/extensions/UsabilityInitiative/Vector/Vector.combined.min.js |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | $j('#panel').addClass('collapsible-nav');$j('#panel > div.portal:first').addClass('expanded').find('div.body').show();$j('#panel > div.portal:not(:first)').each(function(){if($j.cookie('vector-nav-'+$j(this).attr('id'))=='true'){$j(this).addClass('expanded').find('div.body').show();}else{$j(this).addClass('collapsed');}});$j('#panel > div.portal > h5').click(function(){$j.cookie('vector-nav-'+$j(this).parent().attr('id'),$j(this).parent().is('.collapsed'));$j(this).parent().toggleClass('expanded').toggleClass('collapsed').find('div.body').slideToggle('fast');return false;});});mw.ready(function(){if(!wgVectorEnabledModules.collapsibletabs){return true;} |
5 | 5 | var rtl=$j('body').is('.rtl');$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') |
6 | 6 | $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) |
7 | | -$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.ready(function(){if(!wgVectorEnabledModules.editwarning){return true;} |
| 7 | +$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.ready(function(){if(!wgVectorEnabledModules.editwarning||$j('#wpTextbox1').size()==0){return true;} |
8 | 8 | $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();} |
9 | 9 | if(fallbackResult!==null){return fallbackResult;} |
10 | 10 | if(wgAction=='submit'||$j('#wpTextbox1').data('origtext')!=$j('#wpTextbox1').val()||$j('#wpSummary').data('origtext')!=$j('#wpSummary').val()){return gM('vector-editwarning-warning');}} |
Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -84,7 +84,7 @@ |
85 | 85 | array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ), |
86 | 86 | array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 7 ), |
87 | 87 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 22 ), |
88 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 44 ), |
| 88 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 45 ), |
89 | 89 | array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 12 ), |
90 | 90 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 41 ), |
91 | 91 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 10 ), |
— | — | @@ -94,10 +94,10 @@ |
95 | 95 | array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 1 ), |
96 | 96 | ), |
97 | 97 | 'combined' => array( |
98 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 142 ), |
| 98 | + array( 'src' => 'js/plugins.combined.js', 'version' => 143 ), |
99 | 99 | ), |
100 | 100 | 'minified' => array( |
101 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 142 ), |
| 101 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 143 ), |
102 | 102 | ), |
103 | 103 | ), |
104 | 104 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.html |
— | — | @@ -10,9 +10,14 @@ |
11 | 11 | width: 100%; |
12 | 12 | height: 100%; |
13 | 13 | font-family: monospace; |
14 | | - white-space: pre-wrap; |
15 | 14 | font-size: 9.5pt; |
16 | | - line-height:16px; |
| 15 | + line-height: 1.5em; |
| 16 | + overflow-x: auto; /* Use horizontal scroller if needed; for Firefox 2, not needed in Firefox 3 */ |
| 17 | + white-space: pre-wrap; /* css-3 */ |
| 18 | + white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */ |
| 19 | + white-space: -pre-wrap; /* Opera 4-6 */ |
| 20 | + white-space: -o-pre-wrap; /* Opera 7 */ |
| 21 | + word-wrap: break-word; /* Internet Explorer 5.5+ */ |
17 | 22 | } |
18 | 23 | /* Wikitext that's folded away and shouldn't be displayed */ |
19 | 24 | .wikiEditor-nodisplay { |
— | — | @@ -73,7 +78,6 @@ |
74 | 79 | } |
75 | 80 | </style> |
76 | 81 | <script type="text/javascript"> |
77 | | - |
78 | 82 | parent.inherit( window )( function() { |
79 | 83 | function get( name ) { |
80 | 84 | // Extracts the value of a given URL parameter from the current window location |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -388,9 +388,10 @@ |
389 | 389 | if ( $.browser.name == 'msie' ) { |
390 | 390 | return context.$content.text(); |
391 | 391 | } |
392 | | - // Get rid of the noincludes when getting text - we use .html() instead of .text() so HTML entities are |
393 | | - // handled right - setting the HTML of the textarea doesn't work on all browsers, use a dummy <div> instead |
394 | | - var $dummyDiv = $( '<div />' ).html( context.$content.html().replace( /\<br\>/g, "\n" ) ); |
| 392 | + // We use .html() instead of .text() so HTML entities are handled right - setting the HTML of the textarea |
| 393 | + // doesn't work on all browsers, use a dummy <div> instead |
| 394 | + var $dummyDiv = $( '<div />' ).html( context.$content.html().replace( /\<br[^\>]*\>/g, "\n" ) ); |
| 395 | + // Get rid of the noincludes when getting text |
395 | 396 | $dummyDiv.find( ".wikiEditor-noinclude" ).each( function() { $( this ).remove(); } ); |
396 | 397 | return $dummyDiv.text(); |
397 | 398 | |
— | — | @@ -684,6 +685,8 @@ |
685 | 686 | context.$content.append( |
686 | 687 | context.$textarea.val().replace( /\</g, '<' ).replace( /\>/g, '>' ).replace( /\n/g, '<br />' ) |
687 | 688 | ); |
| 689 | + //context.$content[0].innerText = context.$textarea.val().replace( /\n/g, '\n\n' ); |
| 690 | + //context.$content.text( context.$textarea.val() ); |
688 | 691 | // Reflect direction of parent frame into child |
689 | 692 | if ( $( 'body' ).is( '.rtl' ) ) { |
690 | 693 | context.$content.addClass( 'rtl' ).attr( 'dir', 'rtl' ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -5850,7 +5850,7 @@ |
5851 | 5851 | if ( args.length > 0 ) { |
5852 | 5852 | if ( typeof args[0] == 'object' ) { |
5853 | 5853 | // Apply set of properties |
5854 | | - for ( key in args[0] ) { |
| 5854 | + for ( var key in args[0] ) { |
5855 | 5855 | $.suggestions.configure( context, key, args[0][key] ); |
5856 | 5856 | } |
5857 | 5857 | } else if ( typeof args[0] == 'string' ) { |
— | — | @@ -6551,7 +6551,6 @@ |
6552 | 6552 | // The wikiEditor context is stored in the element's data, so when this function gets called again we can pick up right |
6553 | 6553 | // where we left off |
6554 | 6554 | var context = $(this).data( 'wikiEditor-context' ); |
6555 | | - |
6556 | 6555 | // On first call, we need to set things up, but on all following calls we can skip right to the API handling |
6557 | 6556 | if ( typeof context == 'undefined' ) { |
6558 | 6557 | |
— | — | @@ -6741,11 +6740,11 @@ |
6742 | 6741 | .appendTo( context.$ui ); |
6743 | 6742 | }, |
6744 | 6743 | |
6745 | | - /** |
6746 | | - * FIXME: This section is a bit of a "wonky" section given it's supposed to keep compatibility with the |
6747 | | - * textSelection plugin, which works on character-based manipulations as opposed to the node-based manipulations |
6748 | | - * we use for the iframe. It's debatable whether compatibility with this plugin is even being done well, or for |
6749 | | - * that matter should be done at all. |
| 6744 | + /* |
| 6745 | + * FIXME: This section needs attention! It doesn't really make sense given it's supposed to keep compatibility |
| 6746 | + * with the textSelection plugin, which works on character-based manipulations as opposed to the node-based |
| 6747 | + * manipulations we use for the iframe. It's debatable whether compatibility with this plugin is even being done |
| 6748 | + * well, or for that matter should be done at all. |
6750 | 6749 | */ |
6751 | 6750 | |
6752 | 6751 | /** |
— | — | @@ -6756,12 +6755,10 @@ |
6757 | 6756 | if ( $.browser.name == 'msie' ) { |
6758 | 6757 | return context.$content.text(); |
6759 | 6758 | } |
6760 | | - // We use .html() instead of .text() so HTML entities are handled right |
6761 | | - // Setting the HTML of the textarea doesn't work on all browsers, use a dummy <div> instead |
6762 | | - |
6763 | | - |
6764 | | - //get rid of the noincludes when getting text |
6765 | | - var $dummyDiv = $( '<div />' ).html( context.$content.html().replace( /\<br\>/g, "\n" ) ); |
| 6759 | + // We use .html() instead of .text() so HTML entities are handled right - setting the HTML of the textarea |
| 6760 | + // doesn't work on all browsers, use a dummy <div> instead |
| 6761 | + var $dummyDiv = $( '<div />' ).html( context.$content.html().replace( /\<br[^\>]*\>/g, "\n" ) ); |
| 6762 | + // Get rid of the noincludes when getting text |
6766 | 6763 | $dummyDiv.find( ".wikiEditor-noinclude" ).each( function() { $( this ).remove(); } ); |
6767 | 6764 | return $dummyDiv.text(); |
6768 | 6765 | |
— | — | @@ -6831,9 +6828,8 @@ |
6832 | 6829 | var insertText = pre + selText + post; |
6833 | 6830 | var insertLines = insertText.split( "\n" ); |
6834 | 6831 | range.extractContents(); |
6835 | | - // Insert the contents one line at a time |
6836 | | - // insertNode() inserts at the beginning, so this has |
6837 | | - // to happen in reverse order |
| 6832 | + // Insert the contents one line at a time - insertNode() inserts at the beginning, so this has to happen |
| 6833 | + // in reverse order |
6838 | 6834 | var lastNode; |
6839 | 6835 | for ( var i = insertLines.length - 1; i >= 0; i-- ) { |
6840 | 6836 | range.insertNode( document.createTextNode( insertLines[i] ) ); |
— | — | @@ -6845,8 +6841,7 @@ |
6846 | 6842 | context.fn.scrollToTop( lastNode ); |
6847 | 6843 | } |
6848 | 6844 | } else if ( context.$iframe[0].contentWindow.document.selection ) { |
6849 | | - // IE |
6850 | | - // TODO |
| 6845 | + // TODO: IE |
6851 | 6846 | } |
6852 | 6847 | // Trigger the encapsulateSelection event (this might need to get named something else/done differently) |
6853 | 6848 | context.$content.trigger( |
— | — | @@ -6859,9 +6854,7 @@ |
6860 | 6855 | * DO NOT CALL THESE DIRECTLY, use .textSelection( 'functionname', options ) instead |
6861 | 6856 | */ |
6862 | 6857 | 'getCaretPosition': function( options ) { |
6863 | | - // FIXME: Character-based functions aren't useful for the magic iframe |
6864 | | - // ... |
6865 | | - //reurn character position |
| 6858 | + // FIXME: Character-based functions aren't useful for the magic iframe - return character position? |
6866 | 6859 | }, |
6867 | 6860 | /** |
6868 | 6861 | * Sets the selection of the content |
— | — | @@ -6885,7 +6878,6 @@ |
6886 | 6879 | while ( ec.firstChild && ec.nodeName != '#text' ) { |
6887 | 6880 | ec = ec.firstChild; |
6888 | 6881 | } |
6889 | | - |
6890 | 6882 | var range = document.createRange(); |
6891 | 6883 | range.setStart( sc, options.start ); |
6892 | 6884 | range.setEnd( ec, options.end ); |
— | — | @@ -6893,8 +6885,7 @@ |
6894 | 6886 | sel.addRange( range ); |
6895 | 6887 | context.$iframe[0].contentWindow.focus(); |
6896 | 6888 | } else if ( context.$iframe[0].contentWindow.document.selection ) { |
6897 | | - // IE |
6898 | | - // FIXME still broken for when sc or ec is the <body>, needs more tweaking |
| 6889 | + // FIXME: IE is still broken for when sc or ec is the <body>, needs more tweaking |
6899 | 6890 | var range = document.selection.createRange(); |
6900 | 6891 | range.moveToElementText( sc ); |
6901 | 6892 | range.moveStart( 'character', options.start ); |
— | — | @@ -6910,8 +6901,7 @@ |
6911 | 6902 | * DO NOT CALL THESE DIRECTLY, use .textSelection( 'functionname', options ) instead |
6912 | 6903 | */ |
6913 | 6904 | 'scrollToCaretPosition': function( options ) { |
6914 | | - // ... |
6915 | | - //context.$textarea.trigger( 'scrollToPosition' ); |
| 6905 | + // FIXME: context.$textarea.trigger( 'scrollToPosition' ) ? |
6916 | 6906 | }, |
6917 | 6907 | /** |
6918 | 6908 | * Scroll an element to the top of the iframe |
— | — | @@ -6938,8 +6928,9 @@ |
6939 | 6929 | * @return jQuery object |
6940 | 6930 | */ |
6941 | 6931 | 'beforeSelection': function( selector, strict ) { |
6942 | | - if ( typeof selector == 'undefined' ) |
| 6932 | + if ( typeof selector == 'undefined' ) { |
6943 | 6933 | selector = '*'; |
| 6934 | + } |
6944 | 6935 | var e; |
6945 | 6936 | if ( context.$iframe[0].contentWindow.getSelection ) { |
6946 | 6937 | // Firefox and Opera |
— | — | @@ -6979,10 +6970,9 @@ |
6980 | 6971 | return $( [] ); |
6981 | 6972 | } |
6982 | 6973 | |
6983 | | - /** |
6984 | | - * End of "wonky" textSelection "compatible" section that needs attention. |
| 6974 | + /* |
| 6975 | + * End of wonky textSelection "compatible" section that needs attention. |
6985 | 6976 | */ |
6986 | | - |
6987 | 6977 | }; |
6988 | 6978 | |
6989 | 6979 | /* |
— | — | @@ -7028,7 +7018,8 @@ |
7029 | 7019 | // Create an iframe in place of the text area |
7030 | 7020 | context.$iframe = $( '<iframe></iframe>' ) |
7031 | 7021 | .attr( { |
7032 | | - 'frameborder': 0, |
| 7022 | + 'frameBorder': 0, |
| 7023 | + 'border': 0, |
7033 | 7024 | 'src': wgScriptPath + '/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.html?' + |
7034 | 7025 | 'instance=' + context.instance + '&ts=' + ( new Date() ).getTime(), |
7035 | 7026 | 'id': 'wikiEditor-iframe-' + context.instance |
— | — | @@ -7043,18 +7034,26 @@ |
7044 | 7035 | } ) |
7045 | 7036 | .insertAfter( context.$textarea ) |
7046 | 7037 | .load( function() { |
7047 | | - if ( !context.$iframe[0].contentWindow.document.body ) { |
7048 | | - return; |
| 7038 | + // Internet Explorer will reload the iframe once we turn on design mode, so we need to only turn it on |
| 7039 | + // during the first run, and then bail |
| 7040 | + if ( !this.isSecondRun ) { |
| 7041 | + // Turn the document's design mode on |
| 7042 | + context.$iframe[0].contentWindow.document.designMode = 'on'; |
| 7043 | + // Let the rest of this function happen next time around |
| 7044 | + if ( $.browser.msie ) { |
| 7045 | + this.isSecondRun = true; |
| 7046 | + return; |
| 7047 | + } |
7049 | 7048 | } |
7050 | | - // Turn the document's design mode on |
7051 | | - context.$iframe[0].contentWindow.document.designMode = 'on'; |
7052 | 7049 | // Get a reference to the content area of the iframe |
7053 | 7050 | context.$content = $( context.$iframe[0].contentWindow.document.body ); |
7054 | | - // We need to properly escape any HTML entities like &, < and > so they end up as visible |
7055 | | - // characters rather than actual HTML tags in the code editor container. |
| 7051 | + // If we just do "context.$content.text( context.$textarea.val() )", Internet Explorer will strip out the |
| 7052 | + // whitespace charcters, specifically "\n" - so we must manually encode the text and append it |
7056 | 7053 | context.$content.append( |
7057 | | - context.$textarea.val().replace( /</g, '<' ).replace( />/g, '>' ) |
| 7054 | + context.$textarea.val().replace( /\</g, '<' ).replace( /\>/g, '>' ).replace( /\n/g, '<br />' ) |
7058 | 7055 | ); |
| 7056 | + //context.$content[0].innerText = context.$textarea.val().replace( /\n/g, '\n\n' ); |
| 7057 | + //context.$content.text( context.$textarea.val() ); |
7059 | 7058 | // Reflect direction of parent frame into child |
7060 | 7059 | if ( $( 'body' ).is( '.rtl' ) ) { |
7061 | 7060 | context.$content.addClass( 'rtl' ).attr( 'dir', 'rtl' ); |
— | — | @@ -7295,15 +7294,8 @@ |
7296 | 7295 | } ) ); |
7297 | 7296 | */ |
7298 | 7297 | // Highlight stuff for the first time |
| 7298 | + |
7299 | 7299 | |
7300 | | - //IE8 runs this twice, the second time is valid |
7301 | | - if( $.browser.msie && $.browser.version >= 8 ) { |
7302 | | - if(!this.isSecondRun){ |
7303 | | - this.isSecondRun = true; |
7304 | | - return; |
7305 | | - } |
7306 | | - } |
7307 | | - |
7308 | 7300 | $.wikiEditor.modules.highlight.fn.scan( context, "" ); |
7309 | 7301 | $.wikiEditor.modules.highlight.fn.mark( context, "", "" ); |
7310 | 7302 | } |
— | — | @@ -7934,6 +7926,7 @@ |
7935 | 7927 | return; |
7936 | 7928 | } |
7937 | 7929 | // Build a model for this |
| 7930 | + |
7938 | 7931 | var model = new $.wikiEditor.modules.templateEditor.fn.model( $( this ).text() ); |
7939 | 7932 | var $template = $( this ) |
7940 | 7933 | .wrap( '<div class="wikiEditor-template"></div>' ) |
— | — | @@ -7941,8 +7934,8 @@ |
7942 | 7935 | .html( |
7943 | 7936 | // Wrap the start and end of the wikitext in spans so we can bind events to them |
7944 | 7937 | $( this ).html() |
7945 | | - .replace( /\{\{/, '<span class="wikiEditor-template-start">{{</span>' ) |
7946 | | - .replace( /\}\}/, '<span class="wikiEditor-template-end">}}</span>' ) ) |
| 7938 | + .replace( /\{\{/, '<span class="wikiEditor-template-start">{{</span><span class="wikiEditor-template-inner-text">' ) |
| 7939 | + .replace( /\}\}$/, '</span><span class="wikiEditor-template-end">}}</span>' ) ) //grab the *last* {{ |
7947 | 7940 | .parent() |
7948 | 7941 | .addClass( 'wikiEditor-template-collapsed' ) |
7949 | 7942 | .data( 'model', model ); |
— | — | @@ -7952,7 +7945,7 @@ |
7953 | 7946 | .mousedown( noEdit ) |
7954 | 7947 | .prependTo( $template ); |
7955 | 7948 | $template.find( '.wikiEditor-template-end, .wikiEditor-template-start' ).mousedown( toggleWikiText ); |
7956 | | - $( '<ul />' ) |
| 7949 | + var $options = $( '<ul />' ) |
7957 | 7950 | .addClass( 'wikiEditor-template-modes wikiEditor-noinclude' ) |
7958 | 7951 | .append( $( '<li />' ) |
7959 | 7952 | .addClass( 'wikiEditor-template-action-wikiText' ) |
— | — | @@ -7960,6 +7953,14 @@ |
7961 | 7954 | $.wikiEditor.imgPath + 'templateEditor/' + 'wiki-text.png' ) ) |
7962 | 7955 | .mousedown( toggleWikiText ) ) |
7963 | 7956 | .insertAfter( $template.find( '.wikiEditor-template-name' ) ); |
| 7957 | + $options.append( |
| 7958 | + $( '<li />' ) |
| 7959 | + .addClass( 'wikiEditor-template-action-form' ) |
| 7960 | + .append( $( '<span>F</span>' ) ) |
| 7961 | + .mousedown( function(){createDialog($template); return false;} )); |
| 7962 | + |
| 7963 | + |
| 7964 | + |
7964 | 7965 | // Expand |
7965 | 7966 | function expandTemplate( $displayDiv ) { |
7966 | 7967 | // Housekeeping |
— | — | @@ -7995,6 +7996,45 @@ |
7996 | 7997 | $displayDiv.removeClass( 'wikiEditor-template-expanded' ); |
7997 | 7998 | $displayDiv.text( model.getName() ); |
7998 | 7999 | }; |
| 8000 | + |
| 8001 | + |
| 8002 | + function createDialog( $templateDiv ){ |
| 8003 | + var templateModel = $templateDiv.data('model'); |
| 8004 | + var $dialog = $("<div></div>"); |
| 8005 | + var $title = $("<div>" + templateModel.getName() + "</div>").addClass('wikiEditor-template-dialog-title'); |
| 8006 | + var $table = $("<table></table>") |
| 8007 | + .addClass('wikiEditor-template-dialog-table') |
| 8008 | + .appendTo($dialog); |
| 8009 | + var allInitialParams = templateModel.getAllInitialParams(); |
| 8010 | + for( var paramIndex in allInitialParams ){ |
| 8011 | + var param = allInitialParams[paramIndex]; |
| 8012 | + if(typeof param.name == 'undefined'){continue;} //param 0 is the name |
| 8013 | + var $paramRow = $("<tr></tr>") |
| 8014 | + .addClass('wikiEditor-template-dialog-row'); |
| 8015 | + var $paramName = $("<td></td>") |
| 8016 | + .addClass('wikiEditor-template-dialog-name') |
| 8017 | + .text( param.name ); |
| 8018 | + var $paramVal = $("<td></td>") |
| 8019 | + .addClass('wikiEditor-template-dialog-value'); |
| 8020 | + var $paramInput =$("<input></input>") |
| 8021 | + .data('name', param.name) |
| 8022 | + .val( templateModel.getValue(param.name) ); |
| 8023 | + $paramVal.append($paramInput); |
| 8024 | + $paramRow.append($paramName).append($paramVal); |
| 8025 | + $table.append($paramRow); |
| 8026 | + } |
| 8027 | + //click handler for values |
| 8028 | + $("<button></button>").click(function(){ |
| 8029 | + $('.wikiEditor-template-dialog-value input').each( function(){ |
| 8030 | + templateModel.setValue( $(this).data('name'), $(this).val() ); |
| 8031 | + }); |
| 8032 | + $dialog.dialog('close'); |
| 8033 | + |
| 8034 | + }).text("OK").appendTo($dialog); |
| 8035 | + $dialog.dialog(); //opens dialog |
| 8036 | + }; |
| 8037 | + |
| 8038 | + |
7999 | 8039 | function toggleWikiText( ) { |
8000 | 8040 | var $template = $( this ).closest( '.wikiEditor-template' ); |
8001 | 8041 | $template |
— | — | @@ -8002,6 +8042,22 @@ |
8003 | 8043 | .toggleClass( 'wikiEditor-template-expanded' ) |
8004 | 8044 | .children( '.wikiEditor-template-text, .wikiEditor-template-name, .wikiEditor-template-modes' ) |
8005 | 8045 | .toggleClass( 'wikiEditor-nodisplay' ); |
| 8046 | + |
| 8047 | + //if we just collapsed this |
| 8048 | + if( $template.hasClass('wikiEditor-template-collapsed') ) { |
| 8049 | + var model = new $.wikiEditor.modules.templateEditor.fn.model( $template.children( '.wikiEditor-template-text' ).text() ); |
| 8050 | + $template.data( 'model' , model ); |
| 8051 | + $template.children( '.wikiEditor-template-name' ).text( model.getName() ); |
| 8052 | + } |
| 8053 | + else{ //else we just expanded this |
| 8054 | + $template.children( '.wikiEditor-template-text' ).children('.wikiEditor-template-inner-text').text( |
| 8055 | + $template.data('model') |
| 8056 | + .getText() |
| 8057 | + .replace(/\{\{/, '') |
| 8058 | + .replace(/\}\}$/, '') |
| 8059 | + ); |
| 8060 | + |
| 8061 | + } |
8006 | 8062 | return false; |
8007 | 8063 | } |
8008 | 8064 | function noEdit() { |
— | — | @@ -8009,9 +8065,6 @@ |
8010 | 8066 | } |
8011 | 8067 | }); |
8012 | 8068 | |
8013 | | - function toggleWikiText ( context, template ) { |
8014 | | - |
8015 | | - } |
8016 | 8069 | }, |
8017 | 8070 | |
8018 | 8071 | |
— | — | @@ -8180,6 +8233,23 @@ |
8181 | 8234 | return newText; |
8182 | 8235 | }; |
8183 | 8236 | |
| 8237 | + /** |
| 8238 | + * Update ranges if there's been a change |
| 8239 | + */ |
| 8240 | + this.updateRanges = function() { |
| 8241 | + var adjustment = 0; |
| 8242 | + for ( i = 0 ; i < ranges.length; i++ ) { |
| 8243 | + ranges[i].begin += adjustment; |
| 8244 | + if( typeof ranges[i].adjust != 'undefined' ) { |
| 8245 | + adjustment += ranges[i].adjust(); |
| 8246 | + //note, adjust should be a function that has the information necessary to calculate the length of this 'segment' |
| 8247 | + delete ranges[i].adjust; |
| 8248 | + } |
| 8249 | + ranges[i].end += adjustment; |
| 8250 | + } |
| 8251 | + }; |
| 8252 | + |
| 8253 | + |
8184 | 8254 | // Whitespace* {{ whitespace* nonwhitespace: |
8185 | 8255 | if ( wikitext.match( /\s*{{\s*\S*:/ ) ) { |
8186 | 8256 | // We have a parser function! |
— | — | @@ -8201,7 +8271,7 @@ |
8202 | 8272 | startIndex = sanatizedStr.indexOf( '{{' ) + 1; |
8203 | 8273 | openBraces = 2; |
8204 | 8274 | endIndex = startIndex; |
8205 | | - while ( openBraces > 0 ) { |
| 8275 | + while ( (openBraces > 0) && (endIndex < sanatizedStr.length) ) { |
8206 | 8276 | var brace = sanatizedStr[++endIndex]; |
8207 | 8277 | openBraces += brace == '}' ? -1 : brace == '{' ? 1 : 0; |
8208 | 8278 | } |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -389,7 +389,7 @@ |
390 | 390 | context.data.$textbox.trigger('change');preventDefault=wasVisible;break;case 27:context.data.$container.hide();$.suggestions.restore(context);$.suggestions.cancel(context);context.data.$textbox.trigger('change');preventDefault=wasVisible;break;case 13:context.data.$container.hide();preventDefault=wasVisible;if(typeof context.config.result.select=='function'){context.config.result.select.call(context.data.$container.find('.suggestions-result-current'),context.data.$textbox);} |
391 | 391 | break;default:$.suggestions.update(context,true);break;} |
392 | 392 | if(preventDefault){e.preventDefault();e.stopImmediatePropagation();}}};$.fn.suggestions=function(){var returnValue=null;var args=arguments;$(this).each(function(){var context=$(this).data('suggestions-context');if(typeof context=='undefined'){context={config:{'fetch':function(){},'cancel':function(){},'special':{},'result':{},'$region':$(this),'suggestions':[],'maxRows':7,'delay':120,'submitOnClick':false}};} |
393 | | -if(args.length>0){if(typeof args[0]=='object'){for(key in args[0]){$.suggestions.configure(context,key,args[0][key]);}}else if(typeof args[0]=='string'){if(args.length>1){$.suggestions.configure(context,args[0],args[1]);}else if(returnValue==null){returnValue=(args[0]in context.config?undefined:context.config[args[0]]);}}} |
| 393 | +if(args.length>0){if(typeof args[0]=='object'){for(var key in args[0]){$.suggestions.configure(context,key,args[0][key]);}}else if(typeof args[0]=='string'){if(args.length>1){$.suggestions.configure(context,args[0],args[1]);}else if(returnValue==null){returnValue=(args[0]in context.config?undefined:context.config[args[0]]);}}} |
394 | 394 | if(typeof context.data=='undefined'){context.data={'timerID':null,'prevText':null,'visibleResults':0,'mouseDownOn':$([]),'$textbox':$(this)};context.data.$container=$('<div />').css({'top':Math.round(context.data.$textbox.offset().top+context.data.$textbox.outerHeight()),'left':Math.round(context.data.$textbox.offset().left),'width':context.data.$textbox.outerWidth(),'display':'none'}).mouseover(function(e){$.suggestions.highlight(context,$(e.target).closest('.suggestions-results div'),false);}).addClass('suggestions').append($('<div />').addClass('suggestions-results').mousedown(function(e){context.data.mouseDownOn=$(e.target).closest('.suggestions-results div');}).mouseup(function(e){var $result=$(e.target).closest('.suggestions-results div');var $other=context.data.mouseDownOn;context.data.mouseDownOn=$([]);if($result.get(0)!=$other.get(0)){return;} |
395 | 395 | $.suggestions.highlight(context,$result,true);context.data.$container.hide();if(typeof context.config.result.select=='function'){context.config.result.select.call($result,context.data.$textbox);} |
396 | 396 | context.data.$textbox.focus();})).append($('<div />').addClass('suggestions-special').mousedown(function(e){context.data.mouseDownOn=$(e.target).closest('.suggestions-special');}).mouseup(function(e){var $special=$(e.target).closest('.suggestions-special');var $other=context.data.mouseDownOn;context.data.mouseDownOn=$([]);if($special.get(0)!=$other.get(0)){return;} |
— | — | @@ -444,7 +444,7 @@ |
445 | 445 | event.preventDefault();return false;}).text($.wikiEditor.autoMsg(options,'title'))).appendTo(context.$tabs);} |
446 | 446 | if(!context.$tabs.children().size()){addTab({'name':'wikitext','titleMsg':'wikieditor-wikitext-tab'});} |
447 | 447 | addTab(options);return $('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-'+options.name).hide().appendTo(context.$ui);},'getContents':function(){if($.browser.name=='msie'){return context.$content.text();} |
448 | | -var $dummyDiv=$('<div />').html(context.$content.html().replace(/\<br\>/g,"\n"));$dummyDiv.find(".wikiEditor-noinclude").each(function(){$(this).remove();});return $dummyDiv.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.document.selection){retval=context.$iframe[0].contentWindow.document.selection.createRange();} |
| 448 | +var $dummyDiv=$('<div />').html(context.$content.html().replace(/\<br[^\>]*\>/g,"\n"));$dummyDiv.find(".wikiEditor-noinclude").each(function(){$(this).remove();});return $dummyDiv.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.document.selection){retval=context.$iframe[0].contentWindow.document.selection.createRange();} |
449 | 449 | if(retval.text){retval=retval.text;}else if(retval.toString){retval=retval.toString();} |
450 | 450 | 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+=' ';} |
451 | 451 | if(context.$iframe[0].contentWindow.getSelection){var range=context.$iframe[0].contentWindow.getSelection().getRangeAt(0);if(options.ownline){if(range.startOffset!=0){pre="\n"+options.pre;} |
— | — | @@ -454,16 +454,16 @@ |
455 | 455 | context.$content.trigger('encapsulateSelection',[pre,options.peri,post,options.ownline,options.replace]);return context.$textarea;},'getCaretPosition':function(options){},'setSelection':function(options){var sc=options.startContainer,ec=options.endContainer;sc=sc.jquery?sc[0]:sc;ec=ec.jquery?ec[0]:ec;if(context.$iframe[0].contentWindow.getSelection){var sel=context.$iframe[0].contentWindow.getSelection();while(sc.firstChild&&sc.nodeName!='#text'){sc=sc.firstChild;} |
456 | 456 | while(ec.firstChild&&ec.nodeName!='#text'){ec=ec.firstChild;} |
457 | 457 | var range=document.createRange();range.setStart(sc,options.start);range.setEnd(ec,options.end);sel.removeAllRanges();sel.addRange(range);context.$iframe[0].contentWindow.focus();}else if(context.$iframe[0].contentWindow.document.selection){var range=document.selection.createRange();range.moveToElementText(sc);range.moveStart('character',options.start);var range2=document.selection.createRange();range2.moveToElementText(ec);range2.moveEnd('character',options.end);range.setEndPoint(EndToEnd,range2);range.select();}},'scrollToCaretPosition':function(options){},'scrollToTop':function($element,force){var html=context.$content.closest('html'),body=context.$content.closest('body'),parent=$('html');var y=$element.offset().top-context.$content.offset().top;y=parent.scrollTop()>0?y+html.scrollTop()-parent.scrollTop():y;if(force||y<html.scrollTop()||y>html.scrollTop()+context.$iframe.height()){html.scrollTop(y);} |
458 | | -$element.trigger('scrollToTop');},'beforeSelection':function(selector,strict){if(typeof selector=='undefined') |
459 | | -selector='*';var e;if(context.$iframe[0].contentWindow.getSelection){var range=context.$iframe[0].contentWindow.getSelection().getRangeAt(0);e=range.startContainer;}else if(context.$iframe[0].contentWindow.document.selection){return $([]);} |
| 458 | +$element.trigger('scrollToTop');},'beforeSelection':function(selector,strict){if(typeof selector=='undefined'){selector='*';} |
| 459 | +var e;if(context.$iframe[0].contentWindow.getSelection){var range=context.$iframe[0].contentWindow.getSelection().getRangeAt(0);e=range.startContainer;}else if(context.$iframe[0].contentWindow.document.selection){return $([]);} |
460 | 460 | if(e.nodeName!='#text'){var newE=e.firstChild;for(var i=0;i<range.startOffset-1&&newE;i++){newE=newE.nextSibling;} |
461 | 461 | while(newE&&newE.lastChild){newE=newE.lastChild;} |
462 | 462 | e=newE;} |
463 | 463 | while(e){if($(e).is(selector)&&!strict) |
464 | 464 | return $(e);var next=e.previousSibling;while(next&&next.lastChild){next=next.lastChild;} |
465 | 465 | e=next||e.parentNode;strict=false;} |
466 | | -return $([]);}};context.$textarea.wrap($('<div></div>').addClass('wikiEditor-ui')).wrap($('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-wikitext')).wrap($('<div></div>').addClass('wikiEditor-ui-left')).wrap($('<div></div>').addClass('wikiEditor-ui-bottom')).wrap($('<div></div>').addClass('wikiEditor-ui-text'));context.$ui=context.$textarea.parent().parent().parent().parent().parent();context.$wikitext=context.$textarea.parent().parent().parent().parent();context.$wikitext.before($('<div></div>').addClass('wikiEditor-ui-controls').append($('<div></div>').addClass('wikiEditor-ui-tabs').hide()).append($('<div></div>').addClass('wikiEditor-ui-buttons'))).before($('<div style="clear:both;"></div>'));context.$controls=context.$ui.find('.wikiEditor-ui-buttons').hide();context.$buttons=context.$ui.find('.wikiEditor-ui-buttons');context.$tabs=context.$ui.find('.wikiEditor-ui-tabs');context.$ui.after($('<div style="clear:both;"></div>'));context.$wikitext.append($('<div></div>').addClass('wikiEditor-ui-right'));context.$wikitext.find('.wikiEditor-ui-left').prepend($('<div></div>').addClass('wikiEditor-ui-top'));context.view='wikitext';$(window).resize(function(event){context.fn.trigger('resize',event)});context.$iframe=$('<iframe></iframe>').attr({'frameborder':0,'src':wgScriptPath+'/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.html?'+'instance='+context.instance+'&ts='+(new Date()).getTime(),'id':'wikiEditor-iframe-'+context.instance}).css({'backgroundColor':'white','width':'100%','height':context.$textarea.height(),'display':'none','overflow-y':'scroll','overflow-x':'hidden'}).insertAfter(context.$textarea).load(function(){if(!context.$iframe[0].contentWindow.document.body){return;} |
467 | | -context.$iframe[0].contentWindow.document.designMode='on';context.$content=$(context.$iframe[0].contentWindow.document.body);context.$content.append(context.$textarea.val().replace(/</g,'<').replace(/>/g,'>'));if($('body').is('.rtl')){context.$content.addClass('rtl').attr('dir','rtl');} |
| 466 | +return $([]);}};context.$textarea.wrap($('<div></div>').addClass('wikiEditor-ui')).wrap($('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-wikitext')).wrap($('<div></div>').addClass('wikiEditor-ui-left')).wrap($('<div></div>').addClass('wikiEditor-ui-bottom')).wrap($('<div></div>').addClass('wikiEditor-ui-text'));context.$ui=context.$textarea.parent().parent().parent().parent().parent();context.$wikitext=context.$textarea.parent().parent().parent().parent();context.$wikitext.before($('<div></div>').addClass('wikiEditor-ui-controls').append($('<div></div>').addClass('wikiEditor-ui-tabs').hide()).append($('<div></div>').addClass('wikiEditor-ui-buttons'))).before($('<div style="clear:both;"></div>'));context.$controls=context.$ui.find('.wikiEditor-ui-buttons').hide();context.$buttons=context.$ui.find('.wikiEditor-ui-buttons');context.$tabs=context.$ui.find('.wikiEditor-ui-tabs');context.$ui.after($('<div style="clear:both;"></div>'));context.$wikitext.append($('<div></div>').addClass('wikiEditor-ui-right'));context.$wikitext.find('.wikiEditor-ui-left').prepend($('<div></div>').addClass('wikiEditor-ui-top'));context.view='wikitext';$(window).resize(function(event){context.fn.trigger('resize',event)});context.$iframe=$('<iframe></iframe>').attr({'frameBorder':0,'border':0,'src':wgScriptPath+'/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.html?'+'instance='+context.instance+'&ts='+(new Date()).getTime(),'id':'wikiEditor-iframe-'+context.instance}).css({'backgroundColor':'white','width':'100%','height':context.$textarea.height(),'display':'none','overflow-y':'scroll','overflow-x':'hidden'}).insertAfter(context.$textarea).load(function(){if(!this.isSecondRun){context.$iframe[0].contentWindow.document.designMode='on';if($.browser.msie){this.isSecondRun=true;return;}} |
| 467 | +context.$content=$(context.$iframe[0].contentWindow.document.body);context.$content.append(context.$textarea.val().replace(/\</g,'<').replace(/\>/g,'>').replace(/\n/g,'<br />'));if($('body').is('.rtl')){context.$content.addClass('rtl').attr('dir','rtl');} |
468 | 468 | context.$textarea.attr('disabled',true);context.$textarea.hide();context.$iframe.show();context.fn.trigger('ready');});context.$textarea.closest('form').submit(function(){context.$textarea.attr('disabled',false);context.$textarea.val(context.$textarea.textSelection('getContents'));});} |
469 | 469 | arguments=$.makeArray(arguments);if(arguments.length>0){var call=arguments.shift();if(call in context.api){context.api[call](context,typeof arguments[0]=='undefined'?{}:arguments[0]);}} |
470 | 470 | return $(this).data('wikiEditor-context',context);};})(jQuery);RegExp.escape=function(s){return s.replace(/([.*+?^${}()|\/\\[\]])/g,'\\$1');};(function($){$.wikiEditor.modules.dialogs={api:{addDialog:function(context,data){$.wikiEditor.modules.dialogs.fn.create(context,data)},openDialog:function(context,module){if(module in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[module].id).dialog('open');}},closeDialog:function(context,data){if(module in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[module].id).dialog('close');}}},fn:{create:function(context,config){for(module in config){$.wikiEditor.modules.dialogs.modules[module]=config[module];} |
— | — | @@ -471,8 +471,7 @@ |
472 | 472 | configuration.newButtons[gM(msg)]=configuration.buttons[msg];configuration.buttons=configuration.newButtons;var dialogDiv=$('<div /> ').attr('id',module.id).html(module.html).data('context',context).appendTo($('body')).each(module.init).dialog(configuration);if(!('resizeme'in module)||module.resizeme){dialogDiv.bind('dialogopen',$.wikiEditor.modules.dialogs.fn.resize).find('.ui-tabs').bind('tabsshow',function(){$(this).closest('.ui-dialog-content').each($.wikiEditor.modules.dialogs.fn.resize);});} |
473 | 473 | var maxTI=0;$j('[tabindex]').each(function(){var ti=parseInt($j(this).attr('tabindex'));if(ti>maxTI) |
474 | 474 | maxTI=ti;});var tabIndex=maxTI+1;$j('.ui-dialog input, .ui-dialog button').not('[tabindex]').each(function(){$j(this).attr('tabindex',tabIndex++);});}}});},resize:function(){var wrapper=$(this).closest('.ui-dialog');var oldWidth=wrapper.width();var oldHidden=$(this).find('*').not(':visible');oldHidden.each(function(){$(this).data('oldstyle',$(this).attr('style'));});oldHidden.show();var oldWS=$(this).css('white-space');$(this).css('white-space','nowrap');if(wrapper.width()<=$(this).get(0).scrollWidth){var thisWidth=$(this).data('thisWidth')?$(this).data('thisWidth'):0;thisWidth=Math.max($(this).get(0).scrollWidth,thisWidth);$(this).width(thisWidth);$(this).data('thisWidth',thisWidth);var wrapperWidth=$(this).data('wrapperWidth')?$(this).data('wrapperWidth'):0;wrapperWidth=Math.max(wrapper.get(0).scrollWidth,wrapperWidth);wrapper.width(wrapperWidth);$(this).data('wrapperWidth',wrapperWidth);$(this).dialog({'width':wrapper.width()});wrapper.css('left',parseInt(wrapper.css('left'))-(wrapper.width()-oldWidth)/2);} |
475 | | -$(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});}},modules:{},quickDialog:function(body,settings){$('<div />').text(body).appendTo($('body')).dialog($.extend({bgiframe:true,modal:true},settings)).dialog('open');}};})(jQuery);(function($){$.wikiEditor.modules.highlight={cfg:{'styleVersion':3},evt:{delayedChange:function(context,event){if(event.data.scope=='none'){$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},ready:function(context,event){if($.browser.msie&&$.browser.version>=8){if(!this.isSecondRun){this.isSecondRun=true;return;}} |
476 | | -$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},fn:{create:function(context,config){},divide:function(context){},isolate:function(context){return[];},strip:function(context,division){return $('<div />').html(division.html().replace(/\<br[^\>]*\>/g,"\n")).text();},scan:function(context,division){function Token(offset,label,tokenStart,match){this.offset=offset;this.label=label;this.tokenStart=tokenStart;this.match=match;} |
| 475 | +$(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});}},modules:{},quickDialog:function(body,settings){$('<div />').text(body).appendTo($('body')).dialog($.extend({bgiframe:true,modal:true},settings)).dialog('open');}};})(jQuery);(function($){$.wikiEditor.modules.highlight={cfg:{'styleVersion':3},evt:{delayedChange:function(context,event){if(event.data.scope=='none'){$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},ready:function(context,event){$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},fn:{create:function(context,config){},divide:function(context){},isolate:function(context){return[];},strip:function(context,division){return $('<div />').html(division.html().replace(/\<br[^\>]*\>/g,"\n")).text();},scan:function(context,division){function Token(offset,label,tokenStart,match){this.offset=offset;this.label=label;this.tokenStart=tokenStart;this.match=match;} |
477 | 476 | var tokenArray=context.modules.highlight.tokenArray=[];var text=context.fn.getContents();for(module in $.wikiEditor.modules){if('exp'in $.wikiEditor.modules[module]){for(var i=0;i<$.wikiEditor.modules[module].exp.length;i++){var regex=$.wikiEditor.modules[module].exp[i].regex;var label=$.wikiEditor.modules[module].exp[i].label;var markAfter=false;if(typeof $.wikiEditor.modules[module].exp[i].markAfter!='undefined'){markAfter=true;} |
478 | 477 | match=text.match(regex);var oldOffset=0;while(match!=null){var markOffset=0;var tokenStart=match.index+oldOffset+markOffset;if(markAfter){markOffset+=match[0].length;} |
479 | 478 | tokenArray.push(new Token(match.index+oldOffset+markOffset,label,tokenStart,match));oldOffset+=match.index+match[0].length;newSubstring=text.substring(oldOffset);match=newSubstring.match(regex);}}}} |
— | — | @@ -529,8 +528,12 @@ |
530 | 529 | $('#wikiEditor-'+context.instance+'-dialog-watch').attr('checked','checked');$(this).find('form').submit(function(e){$(this).closest('.ui-dialog').find('button:first').click();e.preventDefault();});},dialog:{buttons:{'wikieditor-publish-dialog-publish':function(){var minorChecked=$('#wikiEditor-'+context.instance+'-dialog-minor').is(':checked')?'checked':'';var watchChecked=$('#wikiEditor-'+context.instance+'-dialog-watch').is(':checked')?'checked':'';$('#wpMinoredit').attr('checked',minorChecked);$('#wpWatchthis').attr('checked',watchChecked);$('#wpSummary').val($j('#wikiEditor-'+context.instance+'-dialog-summary').val());$('#editform').submit();},'wikieditor-publish-dialog-goback':function(){$(this).dialog('close');}},open:function(){$('#wikiEditor-'+context.instance+'-dialog-summary').focus();},width:500},resizeme:false}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-publish','action':function(){$('#'+dialogID).dialog('open');return false;}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-cancel','action':function(){}});}}};})(jQuery);(function($){$.wikiEditor.modules.templateEditor={evt:{mark:function(context,event){var markers=context.modules.highlight.markers;var tokenArray=context.modules.highlight.tokenArray;var level=0;var tokenIndex=0;while(tokenIndex<tokenArray.length){while(tokenIndex<tokenArray.length&&tokenArray[tokenIndex].label!='TEMPLATE_BEGIN'){tokenIndex++;} |
531 | 530 | if(tokenIndex<tokenArray.length){var beginIndex=tokenIndex;var endIndex=-1;var openTemplates=1;var templatesMatched=false;while(tokenIndex<tokenArray.length-1&&endIndex==-1){tokenIndex++;if(tokenArray[tokenIndex].label=='TEMPLATE_BEGIN'){openTemplates++;}else if(tokenArray[tokenIndex].label=='TEMPLATE_END'){openTemplates--;if(openTemplates==0){endIndex=tokenIndex;}}} |
532 | 531 | if(endIndex!=-1){markers.push({start:tokenArray[beginIndex].offset,end:tokenArray[endIndex].offset,afterWrap:$.wikiEditor.modules.templateEditor.fn.stylize,beforeUnwrap:function(node){$(node).data('display').remove();},getWrapper:function(ca1,ca2){return $(ca1.parentNode).is('div.wikiEditor-template')&&ca1.previousSibling==null&&ca1.nextSibling==null?ca1.parentNode:null;}});}else{tokenArray[beginIndex].label='TEMPLATE_FALSE_BEGIN';tokenIndex=beginIndex;}}}}},exp:[{'regex':/{{/,'label':"TEMPLATE_BEGIN"},{'regex':/}}/,'label':"TEMPLATE_END",'markAfter':true}],cfg:{},fn:{create:function(context,config){context.modules.templateEditor={};},stylize:function(wrappedTemplate){$(wrappedTemplate).each(function(){if(typeof $(this).data('model')!='undefined'){return;} |
533 | | -var model=new $.wikiEditor.modules.templateEditor.fn.model($(this).text());var $template=$(this).wrap('<div class="wikiEditor-template"></div>').addClass('wikiEditor-template-text wikiEditor-nodisplay').html($(this).html().replace(/\{\{/,'<span class="wikiEditor-template-start">{{</span>').replace(/\}\}/,'<span class="wikiEditor-template-end">}}</span>')).parent().addClass('wikiEditor-template-collapsed').data('model',model);$('<span />').addClass('wikiEditor-template-name wikiEditor-noinclude').text(model.getName()).mousedown(noEdit).prependTo($template);$template.find('.wikiEditor-template-end, .wikiEditor-template-start').mousedown(toggleWikiText);$('<ul />').addClass('wikiEditor-template-modes wikiEditor-noinclude').append($('<li />').addClass('wikiEditor-template-action-wikiText').append($('<img />').attr('src',$.wikiEditor.imgPath+'templateEditor/'+'wiki-text.png')).mousedown(toggleWikiText)).insertAfter($template.find('.wikiEditor-template-name'));function expandTemplate($displayDiv){$displayDiv.removeClass('wikiEditor-template-collapsed');$displayDiv.addClass('wikiEditor-template-expanded');$displayDiv.unbind('mousedown');$keyValueTable=$('<table />').appendTo($displayDiv);$header_row=$('<tr />').appendTo($keyValueTable);$('<th />').attr('colspan','2').text(model.getName()).appendTo($header_row);for(param in model.getAllParamNames()){$keyVal_row=$('<tr />').appendTo($keyValueTable);$('<td />').text(param).appendTo($keyVal_row);$('<td />').text(model.getValue(param)).appendTo($keyVal_row);}};function collapseTemplate($displayDiv){$displayDiv.addClass('wikiEditor-template-collapsed');$displayDiv.removeClass('wikiEditor-template-expanded');$displayDiv.text(model.getName());};function toggleWikiText(){var $template=$(this).closest('.wikiEditor-template');$template.toggleClass('wikiEditor-template-collapsed').toggleClass('wikiEditor-template-expanded').children('.wikiEditor-template-text, .wikiEditor-template-name, .wikiEditor-template-modes').toggleClass('wikiEditor-nodisplay');return false;} |
534 | | -function noEdit(){return false;}});function toggleWikiText(context,template){}},getTemplateInfo:function(templateName){var templateInfo='';return $(templateInfo);},model:function(wikitext){function Param(name,value,number,nameIndex,equalsIndex,valueIndex){this.name=name;this.value=value;this.number=number;this.nameIndex=nameIndex;this.equalsIndex=equalsIndex;this.valueIndex=valueIndex;} |
| 532 | +var model=new $.wikiEditor.modules.templateEditor.fn.model($(this).text());var $template=$(this).wrap('<div class="wikiEditor-template"></div>').addClass('wikiEditor-template-text wikiEditor-nodisplay').html($(this).html().replace(/\{\{/,'<span class="wikiEditor-template-start">{{</span><span class="wikiEditor-template-inner-text">').replace(/\}\}$/,'</span><span class="wikiEditor-template-end">}}</span>')).parent().addClass('wikiEditor-template-collapsed').data('model',model);$('<span />').addClass('wikiEditor-template-name wikiEditor-noinclude').text(model.getName()).mousedown(noEdit).prependTo($template);$template.find('.wikiEditor-template-end, .wikiEditor-template-start').mousedown(toggleWikiText);var $options=$('<ul />').addClass('wikiEditor-template-modes wikiEditor-noinclude').append($('<li />').addClass('wikiEditor-template-action-wikiText').append($('<img />').attr('src',$.wikiEditor.imgPath+'templateEditor/'+'wiki-text.png')).mousedown(toggleWikiText)).insertAfter($template.find('.wikiEditor-template-name'));$options.append($('<li />').addClass('wikiEditor-template-action-form').append($('<span>F</span>')).mousedown(function(){createDialog($template);return false;}));function expandTemplate($displayDiv){$displayDiv.removeClass('wikiEditor-template-collapsed');$displayDiv.addClass('wikiEditor-template-expanded');$displayDiv.unbind('mousedown');$keyValueTable=$('<table />').appendTo($displayDiv);$header_row=$('<tr />').appendTo($keyValueTable);$('<th />').attr('colspan','2').text(model.getName()).appendTo($header_row);for(param in model.getAllParamNames()){$keyVal_row=$('<tr />').appendTo($keyValueTable);$('<td />').text(param).appendTo($keyVal_row);$('<td />').text(model.getValue(param)).appendTo($keyVal_row);}};function collapseTemplate($displayDiv){$displayDiv.addClass('wikiEditor-template-collapsed');$displayDiv.removeClass('wikiEditor-template-expanded');$displayDiv.text(model.getName());};function createDialog($templateDiv){var templateModel=$templateDiv.data('model');var $dialog=$("<div></div>");var $title=$("<div>"+templateModel.getName()+"</div>").addClass('wikiEditor-template-dialog-title');var $table=$("<table></table>").addClass('wikiEditor-template-dialog-table').appendTo($dialog);var allInitialParams=templateModel.getAllInitialParams();for(var paramIndex in allInitialParams){var param=allInitialParams[paramIndex];if(typeof param.name=='undefined'){continue;} |
| 533 | +var $paramRow=$("<tr></tr>").addClass('wikiEditor-template-dialog-row');var $paramName=$("<td></td>").addClass('wikiEditor-template-dialog-name').text(param.name);var $paramVal=$("<td></td>").addClass('wikiEditor-template-dialog-value');var $paramInput=$("<input></input>").data('name',param.name).val(templateModel.getValue(param.name));$paramVal.append($paramInput);$paramRow.append($paramName).append($paramVal);$table.append($paramRow);} |
| 534 | +$("<button></button>").click(function(){$('.wikiEditor-template-dialog-value input').each(function(){templateModel.setValue($(this).data('name'),$(this).val());});$dialog.dialog('close');}).text("OK").appendTo($dialog);$dialog.dialog();};function toggleWikiText(){var $template=$(this).closest('.wikiEditor-template');$template.toggleClass('wikiEditor-template-collapsed').toggleClass('wikiEditor-template-expanded').children('.wikiEditor-template-text, .wikiEditor-template-name, .wikiEditor-template-modes').toggleClass('wikiEditor-nodisplay');if($template.hasClass('wikiEditor-template-collapsed')){var model=new $.wikiEditor.modules.templateEditor.fn.model($template.children('.wikiEditor-template-text').text());$template.data('model',model);$template.children('.wikiEditor-template-name').text(model.getName());} |
| 535 | +else{$template.children('.wikiEditor-template-text').children('.wikiEditor-template-inner-text').text($template.data('model').getText().replace(/\{\{/,'').replace(/\}\}$/,''));} |
| 536 | +return false;} |
| 537 | +function noEdit(){return false;}});},getTemplateInfo:function(templateName){var templateInfo='';return $(templateInfo);},model:function(wikitext){function Param(name,value,number,nameIndex,equalsIndex,valueIndex){this.name=name;this.value=value;this.number=number;this.nameIndex=nameIndex;this.equalsIndex=equalsIndex;this.valueIndex=valueIndex;} |
535 | 538 | function Range(begin,end){this.begin=begin;this.end=end;} |
536 | 539 | function getSetValue(name,value,original){var valueRange;var rangeIndex;var retVal;if(isNaN(name)){if(typeof paramsByName[name]=='undefined'){return"";} |
537 | 540 | rangeIndex=paramsByName[name];}else{rangeIndex=parseInt(name);} |
— | — | @@ -539,10 +542,11 @@ |
540 | 543 | if(value!=null){ranges[params[rangeIndex].valueIndex].newVal=value;} |
541 | 544 | return retVal;};this.getName=function(){if(typeof ranges[templateNameIndex].newVal=='undefined'){return wikitext.substring(ranges[templateNameIndex].begin,ranges[templateNameIndex].end);}else{return ranges[templateNameIndex].newVal;}};this.setName=function(name){ranges[templateNameIndex].newVal=name;};this.setValue=function(name,value){return getSetValue(name,value,false);};this.getValue=function(name){return getSetValue(name,null,false);};this.getOriginalValue=function(name){return getSetValue(name,null,true);};this.getAllParamNames=function(){return paramsByName;};this.getAllInitialParams=function(){return params;} |
542 | 545 | this.getOriginalText=function(){return wikitext;};this.getText=function(){newText="";for(i=0;i<ranges.length;i++){if(typeof ranges[i].newVal=='undefined'){newText+=wikitext.substring(ranges[i].begin,ranges[i].end);}else{newText+=ranges[i].newVal;}} |
543 | | -return newText;};if(wikitext.match(/\s*{{\s*\S*:/)){} |
| 546 | +return newText;};this.updateRanges=function(){var adjustment=0;for(i=0;i<ranges.length;i++){ranges[i].begin+=adjustment;if(typeof ranges[i].adjust!='undefined'){adjustment+=ranges[i].adjust();delete ranges[i].adjust;} |
| 547 | +ranges[i].end+=adjustment;}};if(wikitext.match(/\s*{{\s*\S*:/)){} |
544 | 548 | var sanatizedStr=wikitext.replace(/{{/," ");endBraces=sanatizedStr.match(/}}\s*$/);if(endBraces){sanatizedStr=sanatizedStr.substring(0,endBraces.index)+" "+ |
545 | 549 | sanatizedStr.substring(endBraces.index+2);} |
546 | | -while(sanatizedStr.indexOf('{{')!=-1){startIndex=sanatizedStr.indexOf('{{')+1;openBraces=2;endIndex=startIndex;while(openBraces>0){var brace=sanatizedStr[++endIndex];openBraces+=brace=='}'?-1:brace=='{'?1:0;} |
| 550 | +while(sanatizedStr.indexOf('{{')!=-1){startIndex=sanatizedStr.indexOf('{{')+1;openBraces=2;endIndex=startIndex;while((openBraces>0)&&(endIndex<sanatizedStr.length)){var brace=sanatizedStr[++endIndex];openBraces+=brace=='}'?-1:brace=='{'?1:0;} |
547 | 551 | sanatizedSegment=sanatizedStr.substring(startIndex,endIndex).replace(/[{}|=]/g,'X');sanatizedStr=sanatizedStr.substring(0,startIndex)+sanatizedSegment+sanatizedStr.substring(endIndex);} |
548 | 552 | var ranges=[];var params=[];var templateNameIndex=0;var doneParsing=false;oldDivider=0;divider=sanatizedStr.indexOf('|',oldDivider);if(divider==-1){divider=sanatizedStr.length;doneParsing=true;} |
549 | 553 | nameMatch=wikitext.substring(0,divider).match(/[^{\s]+/);if(nameMatch!=undefined){ranges.push(new Range(0,nameMatch.index));nameEndMatch=sanatizedStr.substring(0,divider).match(/[^\s]\s*$/);templateNameIndex=ranges.push(new Range(nameMatch.index,nameEndMatch.index+1));templateNameIndex--;ranges[templateNameIndex].old=wikitext.substring(ranges[templateNameIndex].begin,ranges[templateNameIndex].end);} |