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' => 27 ), |
76 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 122 ), |
| 76 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 123 ), |
77 | 77 | array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 29 ), |
78 | 78 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 48 ), |
79 | 79 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 12 ), |
— | — | @@ -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' => 242 ), |
| 86 | + array( 'src' => 'js/plugins.combined.js', 'version' => 243 ), |
87 | 87 | ), |
88 | 88 | 'minified' => array( |
89 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 242 ), |
| 89 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 243 ), |
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -78,17 +78,32 @@ |
79 | 79 | * "open-web" way to go. |
80 | 80 | */ |
81 | 81 | 'isSupported': function( module ) { |
82 | | - var map = module && typeof $.wikiEditor.modules[module].browsers !== 'undefined' ? |
83 | | - $.wikiEditor.modules[module].browsers : |
84 | | - $.wikiEditor.browsers; |
85 | | - // Check for and make use of a cached return value |
86 | | - if ( typeof $.wikiEditor.supported != 'undefined' ) { |
87 | | - return $.wikiEditor.supported; |
| 82 | + // Check for and make use of cached value and early opportunities to bail |
| 83 | + if ( module ) { |
| 84 | + // If the module doesn't exist, it's clearly not supported |
| 85 | + if ( !( module in $.wikiEditor.modules ) ) { |
| 86 | + return false; |
| 87 | + } else if ( typeof $.wikiEditor.modules[module].supported !== 'undefined' ) { |
| 88 | + // Cache hit |
| 89 | + return $.wikiEditor.modules[module].supported; |
| 90 | + } |
| 91 | + } else if ( typeof $.wikiEditor.modules[module] !== 'undefined' ) { |
| 92 | + if ( typeof $.wikiEditor.supported !== 'undefined' ) { |
| 93 | + // Cache hit |
| 94 | + return $.wikiEditor.supported; |
| 95 | + } |
88 | 96 | } |
| 97 | + // Provide quick way to cache support |
| 98 | + function cacheSupport( value ) { |
| 99 | + return module ? $.wikiEditor.modules[module].supported = value : $.wikiEditor.supported = value; |
| 100 | + } |
| 101 | + // Fallback to the wikiEditor browser map if no special map is provided in the module |
| 102 | + var map = module && 'browsers' in $.wikiEditor.modules[module] ? |
| 103 | + $.wikiEditor.modules[module].browsers : $.wikiEditor.browsers; |
89 | 104 | // Check if we have any compatiblity information on-hand for the current browser |
90 | 105 | if ( !( $.browser.name in map[$( 'body' ).is( '.rtl' ) ? 'rtl' : 'ltr'] ) ) { |
91 | 106 | // Assume good faith :) |
92 | | - return $.wikiEditor.supported = true; |
| 107 | + return cacheSupport( true ); |
93 | 108 | } |
94 | 109 | // Check over each browser condition to determine if we are running in a compatible client |
95 | 110 | var browser = map[$( 'body' ).is( '.rtl' ) ? 'rtl' : 'ltr'][$.browser.name]; |
— | — | @@ -97,16 +112,16 @@ |
98 | 113 | var val = browser[condition][1]; |
99 | 114 | if ( typeof val == 'string' ) { |
100 | 115 | if ( !( eval( '$.browser.version' + op + '"' + val + '"' ) ) ) { |
101 | | - return $.wikiEditor.supported = false; |
| 116 | + return cacheSupport( false ); |
102 | 117 | } |
103 | 118 | } else if ( typeof val == 'number' ) { |
104 | 119 | if ( !( eval( '$.browser.versionNumber' + op + val ) ) ) { |
105 | | - return $.wikiEditor.supported = false; |
| 120 | + return cacheSupport( false ); |
106 | 121 | } |
107 | 122 | } |
108 | 123 | } |
109 | 124 | // Return and also cache the return value - this will be checked somewhat often |
110 | | - return $.wikiEditor.supported = true; |
| 125 | + return cacheSupport( true ); |
111 | 126 | }, |
112 | 127 | /** |
113 | 128 | * Provides a way to extract messages from objects. Wraps the mw.usability.getMsg() function, which |
— | — | @@ -239,8 +254,8 @@ |
240 | 255 | modules = data; |
241 | 256 | } |
242 | 257 | for ( var module in modules ) { |
243 | | - // Check for the existance of an available module with a matching name and a create function |
244 | | - if ( typeof module == 'string' && module in $.wikiEditor.modules ) { |
| 258 | + // Check for the existance of an available / supported module with a matching name and a create function |
| 259 | + if ( typeof module == 'string' && $.wikiEditor.isSupported( module ) ) { |
245 | 260 | // Extend the context's core API with this module's own API calls |
246 | 261 | if ( 'api' in $.wikiEditor.modules[module] ) { |
247 | 262 | for ( var call in $.wikiEditor.modules[module].api ) { |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -6511,17 +6511,32 @@ |
6512 | 6512 | * "open-web" way to go. |
6513 | 6513 | */ |
6514 | 6514 | 'isSupported': function( module ) { |
6515 | | - var map = module && typeof $.wikiEditor.modules[module].browsers !== 'undefined' ? |
6516 | | - $.wikiEditor.modules[module].browsers : |
6517 | | - $.wikiEditor.browsers; |
6518 | | - // Check for and make use of a cached return value |
6519 | | - if ( typeof $.wikiEditor.supported != 'undefined' ) { |
6520 | | - return $.wikiEditor.supported; |
| 6515 | + // Check for and make use of cached value and early opportunities to bail |
| 6516 | + if ( module ) { |
| 6517 | + // If the module doesn't exist, it's clearly not supported |
| 6518 | + if ( !( module in $.wikiEditor.modules ) ) { |
| 6519 | + return false; |
| 6520 | + } else if ( typeof $.wikiEditor.modules[module].supported !== 'undefined' ) { |
| 6521 | + // Cache hit |
| 6522 | + return $.wikiEditor.modules[module].supported; |
| 6523 | + } |
| 6524 | + } else if ( typeof $.wikiEditor.modules[module] !== 'undefined' ) { |
| 6525 | + if ( typeof $.wikiEditor.supported !== 'undefined' ) { |
| 6526 | + // Cache hit |
| 6527 | + return $.wikiEditor.supported; |
| 6528 | + } |
6521 | 6529 | } |
| 6530 | + // Provide quick way to cache support |
| 6531 | + function cacheSupport( value ) { |
| 6532 | + return module ? $.wikiEditor.modules[module].supported = value : $.wikiEditor.supported = value; |
| 6533 | + } |
| 6534 | + // Fallback to the wikiEditor browser map if no special map is provided in the module |
| 6535 | + var map = module && 'browsers' in $.wikiEditor.modules[module] ? |
| 6536 | + $.wikiEditor.modules[module].browsers : $.wikiEditor.browsers; |
6522 | 6537 | // Check if we have any compatiblity information on-hand for the current browser |
6523 | 6538 | if ( !( $.browser.name in map[$( 'body' ).is( '.rtl' ) ? 'rtl' : 'ltr'] ) ) { |
6524 | 6539 | // Assume good faith :) |
6525 | | - return $.wikiEditor.supported = true; |
| 6540 | + return cacheSupport( true ); |
6526 | 6541 | } |
6527 | 6542 | // Check over each browser condition to determine if we are running in a compatible client |
6528 | 6543 | var browser = map[$( 'body' ).is( '.rtl' ) ? 'rtl' : 'ltr'][$.browser.name]; |
— | — | @@ -6530,16 +6545,16 @@ |
6531 | 6546 | var val = browser[condition][1]; |
6532 | 6547 | if ( typeof val == 'string' ) { |
6533 | 6548 | if ( !( eval( '$.browser.version' + op + '"' + val + '"' ) ) ) { |
6534 | | - return $.wikiEditor.supported = false; |
| 6549 | + return cacheSupport( false ); |
6535 | 6550 | } |
6536 | 6551 | } else if ( typeof val == 'number' ) { |
6537 | 6552 | if ( !( eval( '$.browser.versionNumber' + op + val ) ) ) { |
6538 | | - return $.wikiEditor.supported = false; |
| 6553 | + return cacheSupport( false ); |
6539 | 6554 | } |
6540 | 6555 | } |
6541 | 6556 | } |
6542 | 6557 | // Return and also cache the return value - this will be checked somewhat often |
6543 | | - return $.wikiEditor.supported = true; |
| 6558 | + return cacheSupport( true ); |
6544 | 6559 | }, |
6545 | 6560 | /** |
6546 | 6561 | * Provides a way to extract messages from objects. Wraps the mw.usability.getMsg() function, which |
— | — | @@ -6672,8 +6687,8 @@ |
6673 | 6688 | modules = data; |
6674 | 6689 | } |
6675 | 6690 | for ( var module in modules ) { |
6676 | | - // Check for the existance of an available module with a matching name and a create function |
6677 | | - if ( typeof module == 'string' && module in $.wikiEditor.modules ) { |
| 6691 | + // Check for the existance of an available / supported module with a matching name and a create function |
| 6692 | + if ( typeof module == 'string' && $.wikiEditor.isSupported( module ) ) { |
6678 | 6693 | // Extend the context's core API with this module's own API calls |
6679 | 6694 | if ( 'api' in $.wikiEditor.modules[module] ) { |
6680 | 6695 | for ( var call in $.wikiEditor.modules[module].api ) { |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -436,14 +436,15 @@ |
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;var needSave=false;if(hasIframe&&context.savedSelection!==null){context.fn.restoreSelection();needSave=true;} |
439 | 439 | retval=(hasIframe?context.fn:fn)[command].call(this,options);if(hasIframe&&needSave){context.fn.saveSelection();} |
440 | | -return retval;};})(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':[['>=',4]]},'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':[['>=',4]]}},'imgPath':wgScriptPath+'/extensions/UsabilityInitiative/images/wikiEditor/','isSupported':function(module){var map=module&&typeof $.wikiEditor.modules[module].browsers!=='undefined'?$.wikiEditor.modules[module].browsers:$.wikiEditor.browsers;if(typeof $.wikiEditor.supported!='undefined'){return $.wikiEditor.supported;} |
441 | | -if(!($.browser.name in map[$('body').is('.rtl')?'rtl':'ltr'])){return $.wikiEditor.supported=true;} |
442 | | -var browser=map[$('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;}}} |
443 | | -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;}}} |
| 440 | +return retval;};})(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':[['>=',4]]},'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':[['>=',4]]}},'imgPath':wgScriptPath+'/extensions/UsabilityInitiative/images/wikiEditor/','isSupported':function(module){if(module){if(!(module in $.wikiEditor.modules)){return false;}else if(typeof $.wikiEditor.modules[module].supported!=='undefined'){return $.wikiEditor.modules[module].supported;}}else if(typeof $.wikiEditor.modules[module]!=='undefined'){if(typeof $.wikiEditor.supported!=='undefined'){return $.wikiEditor.supported;}} |
| 441 | +function cacheSupport(value){return module?$.wikiEditor.modules[module].supported=value:$.wikiEditor.supported=value;} |
| 442 | +var map=module&&'browsers'in $.wikiEditor.modules[module]?$.wikiEditor.modules[module].browsers:$.wikiEditor.browsers;if(!($.browser.name in map[$('body').is('.rtl')?'rtl':'ltr'])){return cacheSupport(true);} |
| 443 | +var browser=map[$('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 cacheSupport(false);}}else if(typeof val=='number'){if(!(eval('$.browser.versionNumber'+op+val))){return cacheSupport(false);}}} |
| 444 | +return cacheSupport(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;}}} |
444 | 445 | 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;} |
445 | 446 | return src+'?'+wgWikiEditorIconVersion;}};$.fn.wikiEditor=function(){if(!$j.wikiEditor.isSupported()){return $(this);} |
446 | 447 | 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,'savedSelection':null,'history':[],'historyPosition':-1};context.api={'addModule':function(context,data){var modules={};if(typeof data=='string'){modules[data]={};}else if(typeof data=='object'){modules=data;} |
447 | | -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];}}} |
| 448 | +for(var module in modules){if(typeof module=='string'&&$.wikiEditor.isSupported(module)){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];}}} |
448 | 449 | 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={'keydown':function(event){switch(event.which){case 90:if((event.ctrlKey||event.metaKey)&&context.history.length){if(event.shiftKey){context.historyPosition++;}else{context.historyPosition--;} |
449 | 450 | if(context.history.length+context.historyPosition>=0&&context.historyPosition<0){context.$content.html(context.history[context.history.length+context.historyPosition].html);}else{context.historyPosition=Math.max(-context.history.length,Math.min(context.historyPosition,-1));} |
450 | 451 | return false;} |