Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ), |
74 | 74 | array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 7 ), |
75 | 75 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 26 ), |
76 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 92 ), |
| 76 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 93 ), |
77 | 77 | array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 29 ), |
78 | 78 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 46 ), |
79 | 79 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 11 ), |
— | — | @@ -82,10 +82,10 @@ |
83 | 83 | array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 2 ), |
84 | 84 | ), |
85 | 85 | 'combined' => array( |
86 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 209 ), |
| 86 | + array( 'src' => 'js/plugins.combined.js', 'version' => 210 ), |
87 | 87 | ), |
88 | 88 | 'minified' => array( |
89 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 209 ), |
| 89 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 210 ), |
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -89,7 +89,7 @@ |
90 | 90 | } |
91 | 91 | // Check over each browser condition to determine if we are running in a compatible client |
92 | 92 | var browser = $.wikiEditor.browsers[$( 'body' ).is( '.rtl' ) ? 'rtl' : 'ltr'][$.browser.name]; |
93 | | - for ( condition in browser ) { |
| 93 | + for ( var condition in browser ) { |
94 | 94 | var op = browser[condition][0]; |
95 | 95 | var val = browser[condition][1]; |
96 | 96 | if ( typeof val == 'string' ) { |
— | — | @@ -118,7 +118,7 @@ |
119 | 119 | 'autoMsg': function( object, property ) { |
120 | 120 | // Accept array of possible properties, of which the first one found will be used |
121 | 121 | if ( typeof property == 'object' ) { |
122 | | - for ( i in property ) { |
| 122 | + for ( var i in property ) { |
123 | 123 | if ( property[i] in object || property[i] + 'Msg' in object ) { |
124 | 124 | property = property[i]; |
125 | 125 | break; |
— | — | @@ -229,12 +229,12 @@ |
230 | 230 | } else if ( typeof data == 'object' ) { |
231 | 231 | modules = data; |
232 | 232 | } |
233 | | - for ( module in modules ) { |
| 233 | + for ( var module in modules ) { |
234 | 234 | // Check for the existance of an available module with a matching name and a create function |
235 | 235 | if ( typeof module == 'string' && module in $.wikiEditor.modules ) { |
236 | 236 | // Extend the context's core API with this module's own API calls |
237 | 237 | if ( 'api' in $.wikiEditor.modules[module] ) { |
238 | | - for ( call in $.wikiEditor.modules[module].api ) { |
| 238 | + for ( var call in $.wikiEditor.modules[module].api ) { |
239 | 239 | // Modules may not overwrite existing API functions - first come, first serve |
240 | 240 | if ( !( call in context.api ) ) { |
241 | 241 | context.api[call] = $.wikiEditor.modules[module].api[call]; |
— | — | @@ -310,7 +310,7 @@ |
311 | 311 | } |
312 | 312 | } |
313 | 313 | // Pass the event around to all modules activated on this context |
314 | | - for ( module in context.modules ) { |
| 314 | + for ( var module in context.modules ) { |
315 | 315 | if ( |
316 | 316 | module in $.wikiEditor.modules && |
317 | 317 | 'evt' in $.wikiEditor.modules[module] && |
— | — | @@ -400,7 +400,7 @@ |
401 | 401 | var $pre = $( '<pre>' + html + '</pre>' ); |
402 | 402 | $pre.find( '.wikiEditor-noinclude' ).each( function() { $( this ).remove(); } ); |
403 | 403 | // Convert tabs, <p>s and <br>s back |
404 | | - $pre.find( '.wikiEditor-tab' ).each( function() { $( this ).text( "\t" ) } ); |
| 404 | + $pre.find( '.wikiEditor-tab' ).each( function() { $( this ).text( "\t" ); } ); |
405 | 405 | $pre.find( 'br' ).each( function() { $( this ).replaceWith( "\n" ); } ); |
406 | 406 | // Converting <p>s is wrong if there's nothing before them, so check that. |
407 | 407 | // .find( '* + p' ) isn't good enough because textnodes aren't considered |
— | — | @@ -545,9 +545,11 @@ |
546 | 546 | } |
547 | 547 | var insertText = ""; |
548 | 548 | if ( options.splitlines ) { |
549 | | - for( var i = 0; i < selTextArr.length; i++ ) { |
550 | | - insertText = insertText + pre + selTextArr[i] + post; |
551 | | - if( i != selTextArr.length - 1 ) insertText += "\n"; |
| 549 | + for( var j = 0; j < selTextArr.length; j++ ) { |
| 550 | + insertText = insertText + pre + selTextArr[j] + post; |
| 551 | + if( j != selTextArr.length - 1 ) { |
| 552 | + insertText += "\n"; |
| 553 | + } |
552 | 554 | } |
553 | 555 | } else { |
554 | 556 | insertText = pre + selText + post; |
— | — | @@ -593,9 +595,9 @@ |
594 | 596 | // TODO: Clean this up. Duplicate code due to the pre-existing browser specific structure of this function |
595 | 597 | var insertText = ""; |
596 | 598 | if ( options.splitlines ) { |
597 | | - for( var i = 0; i < selTextArr.length; i++ ) { |
598 | | - insertText = insertText + pre + selTextArr[i] + post; |
599 | | - if( i != selTextArr.length - 1 ) { |
| 599 | + for( var j = 0; j < selTextArr.length; j++ ) { |
| 600 | + insertText = insertText + pre + selTextArr[j] + post; |
| 601 | + if( j != selTextArr.length - 1 ) { |
600 | 602 | insertText += "\n"; |
601 | 603 | } |
602 | 604 | } |
— | — | @@ -721,13 +723,13 @@ |
722 | 724 | |
723 | 725 | /** |
724 | 726 | * Get the first element before the selection that's in a certain class |
725 | | - * @param class Class to match. Defaults to '', meaning any class |
| 727 | + * @param classname Class to match. Defaults to '', meaning any class |
726 | 728 | * @param strict If true, the element the selection starts in cannot match (default: false) |
727 | 729 | * @return jQuery object |
728 | 730 | */ |
729 | | - 'beforeSelection': function( class, strict ) { |
730 | | - if ( typeof class == 'undefined' ) { |
731 | | - class = ''; |
| 731 | + 'beforeSelection': function( classname, strict ) { |
| 732 | + if ( typeof classname == 'undefined' ) { |
| 733 | + classname = ''; |
732 | 734 | } |
733 | 735 | var e, offset; |
734 | 736 | if ( context.$iframe[0].contentWindow.getSelection ) { |
— | — | @@ -753,7 +755,7 @@ |
754 | 756 | // not in the iframe |
755 | 757 | try { |
756 | 758 | range2.setEndPoint( 'EndToStart', range ); |
757 | | - } catch ( e ) { |
| 759 | + } catch ( ex ) { |
758 | 760 | return $( [] ); |
759 | 761 | } |
760 | 762 | var seekPos = context.fn.htmlToText( range2.htmlText ).length; |
— | — | @@ -780,9 +782,9 @@ |
781 | 783 | |
782 | 784 | // We'd normally use if( $( e ).hasClass( class ) in the while loop, but running the jQuery |
783 | 785 | // constructor thousands of times is very inefficient |
784 | | - var classStr = ' ' + class + ' '; |
| 786 | + var classStr = ' ' + classname + ' '; |
785 | 787 | while ( e ) { |
786 | | - if ( !strict && ( !class || ( ' ' + e.className + ' ' ).indexOf( classStr ) != -1 ) ) { |
| 788 | + if ( !strict && ( !classname || ( ' ' + e.className + ' ' ).indexOf( classStr ) != -1 ) ) { |
787 | 789 | return $( e ); |
788 | 790 | } |
789 | 791 | var next = e.previousSibling; |
— | — | @@ -1020,7 +1022,7 @@ |
1021 | 1023 | // Setup the intial view |
1022 | 1024 | context.view = 'wikitext'; |
1023 | 1025 | // Trigger the "resize" event anytime the window is resized |
1024 | | - $( window ).resize( function( event ) { context.fn.trigger( 'resize', event ) } ); |
| 1026 | + $( window ).resize( function( event ) { context.fn.trigger( 'resize', event ); } ); |
1025 | 1027 | // Create an iframe in place of the text area |
1026 | 1028 | context.$iframe = $( '<iframe></iframe>' ) |
1027 | 1029 | .attr( { |
— | — | @@ -1124,19 +1126,19 @@ |
1125 | 1127 | window.onbeforeunload = function() { |
1126 | 1128 | context.$textarea.val( context.$textarea.textSelection( 'getContents' ) ); |
1127 | 1129 | return context.fallbackWindowOnBeforeUnload ? context.fallbackWindowOnBeforeUnload() : null; |
1128 | | - } |
| 1130 | + }; |
1129 | 1131 | } |
1130 | 1132 | |
1131 | 1133 | /* API Execution */ |
1132 | 1134 | |
1133 | 1135 | // Since javascript gives arguments as an object, we need to convert them so they can be used more easily |
1134 | | -arguments = $.makeArray( arguments ); |
| 1136 | +var args = $.makeArray( arguments ); |
1135 | 1137 | // There would need to be some arguments if the API is being called |
1136 | | -if ( arguments.length > 0 ) { |
| 1138 | +if ( args.length > 0 ) { |
1137 | 1139 | // Handle API calls |
1138 | | - var call = arguments.shift(); |
| 1140 | + var call = args.shift(); |
1139 | 1141 | if ( call in context.api ) { |
1140 | | - context.api[call]( context, typeof arguments[0] == 'undefined' ? {} : arguments[0] ); |
| 1142 | + context.api[call]( context, typeof args[0] == 'undefined' ? {} : args[0] ); |
1141 | 1143 | } |
1142 | 1144 | } |
1143 | 1145 | |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -6513,7 +6513,7 @@ |
6514 | 6514 | } |
6515 | 6515 | // Check over each browser condition to determine if we are running in a compatible client |
6516 | 6516 | var browser = $.wikiEditor.browsers[$( 'body' ).is( '.rtl' ) ? 'rtl' : 'ltr'][$.browser.name]; |
6517 | | - for ( condition in browser ) { |
| 6517 | + for ( var condition in browser ) { |
6518 | 6518 | var op = browser[condition][0]; |
6519 | 6519 | var val = browser[condition][1]; |
6520 | 6520 | if ( typeof val == 'string' ) { |
— | — | @@ -6542,7 +6542,7 @@ |
6543 | 6543 | 'autoMsg': function( object, property ) { |
6544 | 6544 | // Accept array of possible properties, of which the first one found will be used |
6545 | 6545 | if ( typeof property == 'object' ) { |
6546 | | - for ( i in property ) { |
| 6546 | + for ( var i in property ) { |
6547 | 6547 | if ( property[i] in object || property[i] + 'Msg' in object ) { |
6548 | 6548 | property = property[i]; |
6549 | 6549 | break; |
— | — | @@ -6653,12 +6653,12 @@ |
6654 | 6654 | } else if ( typeof data == 'object' ) { |
6655 | 6655 | modules = data; |
6656 | 6656 | } |
6657 | | - for ( module in modules ) { |
| 6657 | + for ( var module in modules ) { |
6658 | 6658 | // Check for the existance of an available module with a matching name and a create function |
6659 | 6659 | if ( typeof module == 'string' && module in $.wikiEditor.modules ) { |
6660 | 6660 | // Extend the context's core API with this module's own API calls |
6661 | 6661 | if ( 'api' in $.wikiEditor.modules[module] ) { |
6662 | | - for ( call in $.wikiEditor.modules[module].api ) { |
| 6662 | + for ( var call in $.wikiEditor.modules[module].api ) { |
6663 | 6663 | // Modules may not overwrite existing API functions - first come, first serve |
6664 | 6664 | if ( !( call in context.api ) ) { |
6665 | 6665 | context.api[call] = $.wikiEditor.modules[module].api[call]; |
— | — | @@ -6734,7 +6734,7 @@ |
6735 | 6735 | } |
6736 | 6736 | } |
6737 | 6737 | // Pass the event around to all modules activated on this context |
6738 | | - for ( module in context.modules ) { |
| 6738 | + for ( var module in context.modules ) { |
6739 | 6739 | if ( |
6740 | 6740 | module in $.wikiEditor.modules && |
6741 | 6741 | 'evt' in $.wikiEditor.modules[module] && |
— | — | @@ -6824,7 +6824,7 @@ |
6825 | 6825 | var $pre = $( '<pre>' + html + '</pre>' ); |
6826 | 6826 | $pre.find( '.wikiEditor-noinclude' ).each( function() { $( this ).remove(); } ); |
6827 | 6827 | // Convert tabs, <p>s and <br>s back |
6828 | | - $pre.find( '.wikiEditor-tab' ).each( function() { $( this ).text( "\t" ) } ); |
| 6828 | + $pre.find( '.wikiEditor-tab' ).each( function() { $( this ).text( "\t" ); } ); |
6829 | 6829 | $pre.find( 'br' ).each( function() { $( this ).replaceWith( "\n" ); } ); |
6830 | 6830 | // Converting <p>s is wrong if there's nothing before them, so check that. |
6831 | 6831 | // .find( '* + p' ) isn't good enough because textnodes aren't considered |
— | — | @@ -6969,9 +6969,11 @@ |
6970 | 6970 | } |
6971 | 6971 | var insertText = ""; |
6972 | 6972 | if ( options.splitlines ) { |
6973 | | - for( var i = 0; i < selTextArr.length; i++ ) { |
6974 | | - insertText = insertText + pre + selTextArr[i] + post; |
6975 | | - if( i != selTextArr.length - 1 ) insertText += "\n"; |
| 6973 | + for( var j = 0; j < selTextArr.length; j++ ) { |
| 6974 | + insertText = insertText + pre + selTextArr[j] + post; |
| 6975 | + if( j != selTextArr.length - 1 ) { |
| 6976 | + insertText += "\n"; |
| 6977 | + } |
6976 | 6978 | } |
6977 | 6979 | } else { |
6978 | 6980 | insertText = pre + selText + post; |
— | — | @@ -7017,9 +7019,9 @@ |
7018 | 7020 | // TODO: Clean this up. Duplicate code due to the pre-existing browser specific structure of this function |
7019 | 7021 | var insertText = ""; |
7020 | 7022 | if ( options.splitlines ) { |
7021 | | - for( var i = 0; i < selTextArr.length; i++ ) { |
7022 | | - insertText = insertText + pre + selTextArr[i] + post; |
7023 | | - if( i != selTextArr.length - 1 ) { |
| 7023 | + for( var j = 0; j < selTextArr.length; j++ ) { |
| 7024 | + insertText = insertText + pre + selTextArr[j] + post; |
| 7025 | + if( j != selTextArr.length - 1 ) { |
7024 | 7026 | insertText += "\n"; |
7025 | 7027 | } |
7026 | 7028 | } |
— | — | @@ -7145,13 +7147,13 @@ |
7146 | 7148 | |
7147 | 7149 | /** |
7148 | 7150 | * Get the first element before the selection that's in a certain class |
7149 | | - * @param class Class to match. Defaults to '', meaning any class |
| 7151 | + * @param classname Class to match. Defaults to '', meaning any class |
7150 | 7152 | * @param strict If true, the element the selection starts in cannot match (default: false) |
7151 | 7153 | * @return jQuery object |
7152 | 7154 | */ |
7153 | | - 'beforeSelection': function( class, strict ) { |
7154 | | - if ( typeof class == 'undefined' ) { |
7155 | | - class = ''; |
| 7155 | + 'beforeSelection': function( classname, strict ) { |
| 7156 | + if ( typeof classname == 'undefined' ) { |
| 7157 | + classname = ''; |
7156 | 7158 | } |
7157 | 7159 | var e, offset; |
7158 | 7160 | if ( context.$iframe[0].contentWindow.getSelection ) { |
— | — | @@ -7177,7 +7179,7 @@ |
7178 | 7180 | // not in the iframe |
7179 | 7181 | try { |
7180 | 7182 | range2.setEndPoint( 'EndToStart', range ); |
7181 | | - } catch ( e ) { |
| 7183 | + } catch ( ex ) { |
7182 | 7184 | return $( [] ); |
7183 | 7185 | } |
7184 | 7186 | var seekPos = context.fn.htmlToText( range2.htmlText ).length; |
— | — | @@ -7204,9 +7206,9 @@ |
7205 | 7207 | |
7206 | 7208 | // We'd normally use if( $( e ).hasClass( class ) in the while loop, but running the jQuery |
7207 | 7209 | // constructor thousands of times is very inefficient |
7208 | | - var classStr = ' ' + class + ' '; |
| 7210 | + var classStr = ' ' + classname + ' '; |
7209 | 7211 | while ( e ) { |
7210 | | - if ( !strict && ( !class || ( ' ' + e.className + ' ' ).indexOf( classStr ) != -1 ) ) { |
| 7212 | + if ( !strict && ( !classname || ( ' ' + e.className + ' ' ).indexOf( classStr ) != -1 ) ) { |
7211 | 7213 | return $( e ); |
7212 | 7214 | } |
7213 | 7215 | var next = e.previousSibling; |
— | — | @@ -7444,7 +7446,7 @@ |
7445 | 7447 | // Setup the intial view |
7446 | 7448 | context.view = 'wikitext'; |
7447 | 7449 | // Trigger the "resize" event anytime the window is resized |
7448 | | - $( window ).resize( function( event ) { context.fn.trigger( 'resize', event ) } ); |
| 7450 | + $( window ).resize( function( event ) { context.fn.trigger( 'resize', event ); } ); |
7449 | 7451 | // Create an iframe in place of the text area |
7450 | 7452 | context.$iframe = $( '<iframe></iframe>' ) |
7451 | 7453 | .attr( { |
— | — | @@ -7548,19 +7550,19 @@ |
7549 | 7551 | window.onbeforeunload = function() { |
7550 | 7552 | context.$textarea.val( context.$textarea.textSelection( 'getContents' ) ); |
7551 | 7553 | return context.fallbackWindowOnBeforeUnload ? context.fallbackWindowOnBeforeUnload() : null; |
7552 | | - } |
| 7554 | + }; |
7553 | 7555 | } |
7554 | 7556 | |
7555 | 7557 | /* API Execution */ |
7556 | 7558 | |
7557 | 7559 | // Since javascript gives arguments as an object, we need to convert them so they can be used more easily |
7558 | | -arguments = $.makeArray( arguments ); |
| 7560 | +var args = $.makeArray( arguments ); |
7559 | 7561 | // There would need to be some arguments if the API is being called |
7560 | | -if ( arguments.length > 0 ) { |
| 7562 | +if ( args.length > 0 ) { |
7561 | 7563 | // Handle API calls |
7562 | | - var call = arguments.shift(); |
| 7564 | + var call = args.shift(); |
7563 | 7565 | if ( call in context.api ) { |
7564 | | - context.api[call]( context, typeof arguments[0] == 'undefined' ? {} : arguments[0] ); |
| 7566 | + context.api[call]( context, typeof args[0] == 'undefined' ? {} : args[0] ); |
7565 | 7567 | } |
7566 | 7568 | } |
7567 | 7569 | |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -436,22 +436,22 @@ |
437 | 437 | options.endContainer=options.startContainer;break;case'scrollToCaretPosition':options=$.extend({'force':false},options);break;} |
438 | 438 | var context=$(this).data('wikiEditor-context');var hasIframe=context!==undefined&&context.$iframe!==undefined;return(hasIframe?context.fn:fn)[command].call(this,options);};})(jQuery);(function($){$.wikiEditor={'modules':{},'instances':[],'browsers':{'ltr':{'msie':[['>=',7]],'firefox':[['>=',2],['!=','2.0'],['!=','2.0.0.1'],['!=','2.0.0.2'],['!=','2.0.0.3'],['!=','2.0.0.4']],'opera':[['>=',9.6]],'safari':[['>=',3.1]]},'rtl':{'msie':[['>=',8]],'firefox':[['>=',2],['!=','2.0'],['!=','2.0.0.1'],['!=','2.0.0.2'],['!=','2.0.0.3'],['!=','2.0.0.4']],'opera':[['>=',9.6]],'safari':[['>=',3.1]]}},'imgPath':wgScriptPath+'/extensions/UsabilityInitiative/images/wikiEditor/','isSupported':function(){if(typeof $.wikiEditor.supported!='undefined'){return $.wikiEditor.supported;} |
439 | 439 | if(!($.browser.name in $.wikiEditor.browsers[$('body').is('.rtl')?'rtl':'ltr'])){return $.wikiEditor.supported=true;} |
440 | | -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 $.wikiEditor.supported=false;}}else if(typeof val=='number'){if(!(eval('$.browser.versionNumber'+op+val))){return $.wikiEditor.supported=false;}}} |
441 | | -return $.wikiEditor.supported=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;}}} |
| 440 | +var browser=$.wikiEditor.browsers[$('body').is('.rtl')?'rtl':'ltr'][$.browser.name];for(var condition in browser){var op=browser[condition][0];var val=browser[condition][1];if(typeof val=='string'){if(!(eval('$.browser.version'+op+'"'+val+'"'))){return $.wikiEditor.supported=false;}}else if(typeof val=='number'){if(!(eval('$.browser.versionNumber'+op+val))){return $.wikiEditor.supported=false;}}} |
| 441 | +return $.wikiEditor.supported=true;},'autoMsg':function(object,property){if(typeof property=='object'){for(var i in property){if(property[i]in object||property[i]+'Msg'in object){property=property[i];break;}}} |
442 | 442 | if(property in object){return object[property];}else if(property+'Msg'in object){if(typeof object[property+'Msg']=='object'){return mw.usability.getMsg.apply(mw.usability,object[property+'Msg']);}else{return mw.usability.getMsg(object[property+'Msg']);}}else{return'';}},'autoLang':function(object,lang){return object[lang||wgUserLanguage]||object['default']||object;},'autoIcon':function(icon,path,lang){var src=$.wikiEditor.autoLang(icon,lang);path=path||$.wikiEditor.imgPath;if(src.substr(0,7)!='http://'&&src.substr(0,8)!='https://'&&src[0]!='/'){src=path+src;} |
443 | 443 | return src+'?'+wgWikiEditorIconVersion;}};$.fn.wikiEditor=function(){if(!$j.wikiEditor.isSupported()){return $(this);} |
444 | 444 | var context=$(this).data('wikiEditor-context');if(typeof context=='undefined'){context={'$textarea':$(this),'views':{},'modules':{},'data':{},'instance':$.wikiEditor.instances.push($(this))-1,'offsets':null,'htmlToTextMap':{},'oldHTML':null,'oldDelayedHTML':null};context.api={'addModule':function(context,data){var modules={};if(typeof data=='string'){modules[data]={};}else if(typeof data=='object'){modules=data;} |
445 | | -for(module in modules){if(typeof module=='string'&&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];}}} |
| 445 | +for(var module in modules){if(typeof module=='string'&&module in $.wikiEditor.modules){if('api'in $.wikiEditor.modules[module]){for(var call in $.wikiEditor.modules[module].api){if(!(call in context.api)){context.api[call]=$.wikiEditor.modules[module].api[call];}}} |
446 | 446 | if('fn'in $.wikiEditor.modules[module]&&'create'in $.wikiEditor.modules[module].fn){context.modules[module]={};$.wikiEditor.modules[module].fn.create(context,modules[module]);}}}}};context.evt={'change':function(event){event.data.scope='division';var newHTML=context.$content.html();if(context.oldHTML!=newHTML){context.fn.purgeOffsets();context.oldHTML=newHTML;event.data.scope='realchange';} |
447 | 447 | return true;},'delayedChange':function(event){event.data.scope='division';var newHTML=context.$content.html();if(context.oldDelayedHTML!=newHTML){context.fn.purgeOffsets();context.oldDelayedHTML=newHTML;event.data.scope='realchange';} |
448 | 448 | return true;}};context.fn={'trigger':function(name,event){if(typeof event=='undefined'){event={'type':'custom'};} |
449 | 449 | if(typeof event.data=='undefined'){event.data={};} |
450 | 450 | if(name in context.evt){if(!context.evt[name](event)){return false;}} |
451 | | -for(module in context.modules){if(module in $.wikiEditor.modules&&'evt'in $.wikiEditor.modules[module]&&name in $.wikiEditor.modules[module].evt){$.wikiEditor.modules[module].evt[name](context,event);}}},'addButton':function(options){context.$controls.show();context.$buttons.show();return $('<button />').text($.wikiEditor.autoMsg(options,'caption')).click(options.action).appendTo(context.$buttons);},'addView':function(options){function addTab(options){context.$controls.show();context.$tabs.show();return $('<div></div>').attr('rel','wikiEditor-ui-view-'+options.name).addClass(context.view==options.name?'current':null).append($('<a></a>').attr('href','#').click(function(event){context.$ui.find('.wikiEditor-ui-view').hide();context.$ui.find('.'+$(this).parent().attr('rel')).show();context.$tabs.find('div').removeClass('current');$(this).parent().addClass('current');$(this).blur();if('init'in options&&typeof options.init=='function'){options.init(context);} |
| 451 | +for(var module in context.modules){if(module in $.wikiEditor.modules&&'evt'in $.wikiEditor.modules[module]&&name in $.wikiEditor.modules[module].evt){$.wikiEditor.modules[module].evt[name](context,event);}}},'addButton':function(options){context.$controls.show();context.$buttons.show();return $('<button />').text($.wikiEditor.autoMsg(options,'caption')).click(options.action).appendTo(context.$buttons);},'addView':function(options){function addTab(options){context.$controls.show();context.$tabs.show();return $('<div></div>').attr('rel','wikiEditor-ui-view-'+options.name).addClass(context.view==options.name?'current':null).append($('<a></a>').attr('href','#').click(function(event){context.$ui.find('.wikiEditor-ui-view').hide();context.$ui.find('.'+$(this).parent().attr('rel')).show();context.$tabs.find('div').removeClass('current');$(this).parent().addClass('current');$(this).blur();if('init'in options&&typeof options.init=='function'){options.init(context);} |
452 | 452 | event.preventDefault();return false;}).text($.wikiEditor.autoMsg(options,'title'))).appendTo(context.$tabs);} |
453 | 453 | if(!context.$tabs.children().size()){addTab({'name':'wikitext','titleMsg':'wikieditor-wikitext-tab'});} |
454 | 454 | addTab(options);return $('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-'+options.name).hide().appendTo(context.$ui);},'htmlToText':function(html){if(html in context.htmlToTextMap){return context.htmlToTextMap[html];} |
455 | | -var origHTML=html;html=html.replace(/\r?\n/g,"").replace(/ /g," ").replace(/\<br[^\>]*\>/gi,"\n").replace(/\<\/p\>\<p\>/gi,"\n").replace(/\<\/p\>(\n*)\<p\>/gi,"$1\n");var leading=html.match(/^\s*/)[0];var trailing=html.match(/\s*$/)[0];html=html.substr(leading.length,html.length-leading.length-trailing.length);var $pre=$('<pre>'+html+'</pre>');$pre.find('.wikiEditor-noinclude').each(function(){$(this).remove();});$pre.find('.wikiEditor-tab').each(function(){$(this).text("\t")});$pre.find('br').each(function(){$(this).replaceWith("\n");});$pre.find('p').each(function(){if(this.previousSibling||this.parentNode!=$pre.get(0)){var text=$(this).text();var t=new context.fn.rawTraverser(this.firstChild,-10,this).prev();while(t&&t.node.nodeName!='#text'&&t.node.nodeName!='BR'&&t.node.nodeName!='P'){t=t.prev();} |
| 455 | +var origHTML=html;html=html.replace(/\r?\n/g,"").replace(/ /g," ").replace(/\<br[^\>]*\>/gi,"\n").replace(/\<\/p\>\<p\>/gi,"\n").replace(/\<\/p\>(\n*)\<p\>/gi,"$1\n");var leading=html.match(/^\s*/)[0];var trailing=html.match(/\s*$/)[0];html=html.substr(leading.length,html.length-leading.length-trailing.length);var $pre=$('<pre>'+html+'</pre>');$pre.find('.wikiEditor-noinclude').each(function(){$(this).remove();});$pre.find('.wikiEditor-tab').each(function(){$(this).text("\t");});$pre.find('br').each(function(){$(this).replaceWith("\n");});$pre.find('p').each(function(){if(this.previousSibling||this.parentNode!=$pre.get(0)){var text=$(this).text();var t=new context.fn.rawTraverser(this.firstChild,-10,this).prev();while(t&&t.node.nodeName!='#text'&&t.node.nodeName!='BR'&&t.node.nodeName!='P'){t=t.prev();} |
456 | 456 | if(t){text="\n"+text;} |
457 | 457 | t=new context.fn.rawTraverser(this.lastChild,-10,this).next();while(t&&t.node.nodeName!='#text'&&t.node.nodeName!='BR'&&t.node.nodeName!='P'){t=t.next();} |
458 | 458 | if(t&&!t.inP&&t.node.nodeName=='#text'&&t.node.nodeValue.charAt(0)!='\n'&&t.node.nodeValue.charAt(0)!='\r'){text+="\n";} |
— | — | @@ -464,11 +464,11 @@ |
465 | 465 | if(n&&n.nodeName=='BR'){atStart=true;}else{atEnd=true;}}else if(range.startContainer.nodeName=='#text'&&range.startOffset==range.startContainer.nodeValue.length){atEnd=true;} |
466 | 466 | if(!atStart){pre="\n"+options.pre;} |
467 | 467 | if(!atEnd){post+="\n";}} |
468 | | -var insertText="";if(options.splitlines){for(var i=0;i<selTextArr.length;i++){insertText=insertText+pre+selTextArr[i]+post;if(i!=selTextArr.length-1)insertText+="\n";}}else{insertText=pre+selText+post;} |
| 468 | +var insertText="";if(options.splitlines){for(var j=0;j<selTextArr.length;j++){insertText=insertText+pre+selTextArr[j]+post;if(j!=selTextArr.length-1){insertText+="\n";}}}else{insertText=pre+selText+post;} |
469 | 469 | var insertLines=insertText.split("\n");range.extractContents();var lastNode;for(var i=insertLines.length-1;i>=0;i--){range.insertNode(context.$iframe[0].contentWindow.document.createTextNode(insertLines[i]));if(i>0){lastNode=range.insertNode(context.$iframe[0].contentWindow.document.createElement('br'));}} |
470 | 470 | if(lastNode){context.fn.scrollToTop(lastNode);}}else if(context.$iframe[0].contentWindow.document.selection){context.$iframe[0].contentWindow.focus();var range=context.$iframe[0].contentWindow.document.selection.createRange();if(options.ownline&&range.moveStart){var range2=context.$iframe[0].contentWindow.document.selection.createRange();range2.collapse();range2.moveStart('character',-1);if(range2.text!="\r"&&range2.text!="\n"&&range2.text!=""){pre="\n"+pre;} |
471 | 471 | var range3=context.$iframe[0].contentWindow.document.selection.createRange();range3.collapse(false);range3.moveEnd('character',1);if(range3.text!="\r"&&range3.text!="\n"&&range3.text!=""){post+="\n";}} |
472 | | -var insertText="";if(options.splitlines){for(var i=0;i<selTextArr.length;i++){insertText=insertText+pre+selTextArr[i]+post;if(i!=selTextArr.length-1){insertText+="\n";}}}else{insertText=pre+selText+post;} |
| 472 | +var insertText="";if(options.splitlines){for(var j=0;j<selTextArr.length;j++){insertText=insertText+pre+selTextArr[j]+post;if(j!=selTextArr.length-1){insertText+="\n";}}}else{insertText=pre+selText+post;} |
473 | 473 | range.pasteHTML(insertText.replace(/\</g,'<').replace(/>/g,'>').replace(/\r?\n/g,'<br />'));} |
474 | 474 | $(context.$iframe[0].contentWindow.document).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&&sc.jquery?sc[0]:sc;ec=ec&&ec.jquery?ec[0]:ec;if(context.$iframe[0].contentWindow.getSelection){var start=options.start,end=options.end;if(!sc||!ec){var s=context.fn.getOffset(start);var e=context.fn.getOffset(end);sc=s?s.node:null;ec=e?e.node:null;start=s?s.offset:null;end=e?e.offset:null;} |
475 | 475 | if(!sc||!ec){return context.$textarea;} |
— | — | @@ -479,13 +479,13 @@ |
480 | 480 | range2.collapse();range2.moveEnd('character',options.end);range.setEndPoint('EndToEnd',range2);range.select();} |
481 | 481 | return context.$textarea;},'scrollToCaretPosition':function(options){},'scrollToTop':function($element,force){var html=context.$content.closest('html'),body=context.$content.closest('body'),parentHtml=$('html'),parentBody=$('body');var y=$element.offset().top;if(!$.browser.msie&&!$element.is('body')){y=parentHtml.scrollTop()>0?y+html.scrollTop()-parentHtml.scrollTop():y;y=parentBody.scrollTop()>0?y+body.scrollTop()-parentBody.scrollTop():y;} |
482 | 482 | var topBound=html.scrollTop()>body.scrollTop()?html.scrollTop():body.scrollTop(),bottomBound=topBound+context.$iframe.height();if(force||y<topBound||y>bottomBound){html.scrollTop(y);body.scrollTop(y);} |
483 | | -$element.trigger('scrollToTop');},'beforeSelection':function(class,strict){if(typeof class=='undefined'){class='';} |
484 | | -var e,offset;if(context.$iframe[0].contentWindow.getSelection){var selection=context.$iframe[0].contentWindow.getSelection();if(selection.baseNode!==null){e=selection.getRangeAt(0).startContainer;offset=selection.getRangeAt(0).startOffset;}else{return $([]);}}else if(context.$iframe[0].contentWindow.document.selection){var range=context.$iframe[0].contentWindow.document.selection.createRange();var range2=context.$iframe[0].contentWindow.document.body.createTextRange();try{range2.setEndPoint('EndToStart',range);}catch(e){return $([]);} |
| 483 | +$element.trigger('scrollToTop');},'beforeSelection':function(classname,strict){if(typeof classname=='undefined'){classname='';} |
| 484 | +var e,offset;if(context.$iframe[0].contentWindow.getSelection){var selection=context.$iframe[0].contentWindow.getSelection();if(selection.baseNode!==null){e=selection.getRangeAt(0).startContainer;offset=selection.getRangeAt(0).startOffset;}else{return $([]);}}else if(context.$iframe[0].contentWindow.document.selection){var range=context.$iframe[0].contentWindow.document.selection.createRange();var range2=context.$iframe[0].contentWindow.document.body.createTextRange();try{range2.setEndPoint('EndToStart',range);}catch(ex){return $([]);} |
485 | 485 | var seekPos=context.fn.htmlToText(range2.htmlText).length;var offset=context.fn.getOffset(seekPos);e=offset?offset.node:null;offset=offset?offset.offset:null;if(!e){return $([]);}} |
486 | 486 | if(e.nodeName!='#text'){var newE=e.firstChild;for(var i=0;i<offset-1&&newE;i++){newE=newE.nextSibling;} |
487 | 487 | while(newE&&newE.lastChild){newE=newE.lastChild;} |
488 | 488 | e=newE||e;} |
489 | | -var classStr=' '+class+' ';while(e){if(!strict&&(!class||(' '+e.className+' ').indexOf(classStr)!=-1)){return $(e);} |
| 489 | +var classStr=' '+classname+' ';while(e){if(!strict&&(!classname||(' '+e.className+' ').indexOf(classStr)!=-1)){return $(e);} |
490 | 490 | var next=e.previousSibling;while(next&&next.lastChild){next=next.lastChild;} |
491 | 491 | e=next||e.parentNode;strict=false;} |
492 | 492 | return $([]);},'rawTraverser':function(node,depth,inP){this.node=node;this.depth=depth;this.inP=inP;this.next=function(){var p=this.node;var nextDepth=this.depth;var nextInP=this.inP;while(p&&!p.nextSibling){p=p.parentNode;nextDepth--;if(nextDepth==0){p=null;} |
— | — | @@ -505,12 +505,12 @@ |
506 | 506 | var base=context.offsets[lowerBound];return context.offsets[offset]={'node':base.node,'offset':base.offset+offset-lowerBound,'length':base.length,'depth':base.depth,'lastTextNode':base.lastTextNode,'lastTextNodeDepth':base.lastTextNodeDepth};},'purgeOffsets':function(){context.offsets=null;},'refreshOffsets':function(){context.offsets=[];var t=context.fn.traverser(context.$content);var pos=0,lastTextNode=null,lastTextNodeDepth=null;while(t){if(t.node.nodeName!='#text'&&t.node.nodeName!='BR'&&t.node.nodeName!='P'){t=t.next();continue;} |
507 | 507 | var nextPos=t.node.nodeName=='#text'?pos+t.node.nodeValue.length:pos+1;var nextT=t.next();var leavingP=t.node.nodeName!='P'&&t.inP&&nextT&&(!nextT.inP||nextT.inP!=t.inP);context.offsets[pos]={'node':t.node,'offset':0,'length':nextPos-pos+(leavingP?1:0),'depth':t.depth,'lastTextNode':lastTextNode,'lastTextNodeDepth':lastTextNodeDepth};if(leavingP){context.offsets[nextPos]={'node':t.node,'offset':nextPos-pos,'length':nextPos-pos+1,'depth':t.depth,'lastTextNode':lastTextNode,'lastTextNodeDepth':lastTextNodeDepth};} |
508 | 508 | pos=nextPos+(leavingP?1:0);if(t.node.nodeName=='#text'){lastTextNode=t.node;lastTextNodeDepth=t.depth;} |
509 | | -t=nextT;}}};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;}} |
| 509 | +t=nextT;}}};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;}} |
510 | 510 | context.$content=$(context.$iframe[0].contentWindow.document.body);var html=context.$textarea.val().replace(/ /g,'&nbsp;').replace(/\<br\>/g,'<br>').replace(/\<span class="wikiEditor-tab"\>\<\/span\>/g,'<span class="wikiEditor-tab"></span>');if($.browser.msie){if($.browser.versionNumber<=7){html=html.replace(/ /g," ");}else{html=html.replace(/(^|\n) /g,"$1 ");} |
511 | 511 | html=html.replace(/\t/g,'<span class="wikiEditor-tab"></span>');} |
512 | 512 | html=$('<div />').text('<p>'+html.replace(/\r?\n/g,'</p><p>')+'</p>').html().replace(/&nbsp;/g,' ').replace(/<p>/g,'<p>').replace(/<\/p>/g,'</p>').replace(/<p><\/p>/g,'<br>').replace(/<span class="wikiEditor-tab"><\/span>/g,'<span class="wikiEditor-tab"></span>').replace(/&amp;nbsp;/g,'&nbsp;').replace(/&lt;br&gt;/g,'<br>').replace(/&lt;span class=&quot;wikiEditor-tab&quot;&gt;&lt;\/span&gt;/g,'<span class="wikiEditor-tab"></span>');context.$content.html(html);context.oldHTML=html;if($('body').is('.rtl')){context.$content.addClass('rtl').attr('dir','rtl');} |
513 | | -context.$textarea.attr('disabled',true);context.$textarea.hide();context.$iframe.show();context.fn.trigger('ready');$(context.$iframe[0].contentWindow.document).bind('keyup mouseup paste cut encapsulateSelection',function(event){context.fn.trigger('change',event);}).delayedBind(250,'keyup mouseup paste cut encapsulateSelection',function(event){context.fn.trigger('delayedChange',event);});});context.$textarea.closest('form').submit(function(){context.$textarea.attr('disabled',false);context.$textarea.val(context.$textarea.textSelection('getContents'));});context.fallbackWindowOnBeforeUnload=window.onbeforeunload;window.onbeforeunload=function(){context.$textarea.val(context.$textarea.textSelection('getContents'));return context.fallbackWindowOnBeforeUnload?context.fallbackWindowOnBeforeUnload():null;}} |
514 | | -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]);}} |
| 513 | +context.$textarea.attr('disabled',true);context.$textarea.hide();context.$iframe.show();context.fn.trigger('ready');$(context.$iframe[0].contentWindow.document).bind('keyup mouseup paste cut encapsulateSelection',function(event){context.fn.trigger('change',event);}).delayedBind(250,'keyup mouseup paste cut encapsulateSelection',function(event){context.fn.trigger('delayedChange',event);});});context.$textarea.closest('form').submit(function(){context.$textarea.attr('disabled',false);context.$textarea.val(context.$textarea.textSelection('getContents'));});context.fallbackWindowOnBeforeUnload=window.onbeforeunload;window.onbeforeunload=function(){context.$textarea.val(context.$textarea.textSelection('getContents'));return context.fallbackWindowOnBeforeUnload?context.fallbackWindowOnBeforeUnload():null;};} |
| 514 | +var args=$.makeArray(arguments);if(args.length>0){var call=args.shift();if(call in context.api){context.api[call](context,typeof args[0]=='undefined'?{}:args[0]);}} |
515 | 515 | 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];} |
516 | 516 | mw.usability.load(['$j.ui','$j.ui.dialog','$j.ui.draggable','$j.ui.resizable'],function(){for(module in $.wikiEditor.modules.dialogs.modules){var module=$.wikiEditor.modules.dialogs.modules[module];if($('#'+module.id).size()==0){var configuration=module.dialog;configuration.bgiframe=true;configuration.autoOpen=false;configuration.modal=true;configuration.title=$.wikiEditor.autoMsg(module,'title');configuration.newButtons={};for(msg in configuration.buttons) |
517 | 517 | configuration.newButtons[mw.usability.getMsg(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);});} |