Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -15,9 +15,38 @@ |
16 | 16 | $.wikiEditor = { |
17 | 17 | 'modules': {}, |
18 | 18 | 'instances': [], |
19 | | - 'supportedBrowsers': { |
20 | | - 'ltr': { 'msie': 7, 'firefox': 2, 'opera': 9, 'safari': 3, 'chrome': 1, 'camino': 1 }, |
21 | | - 'rtl': { 'msie': 8, 'firefox': 2, 'opera': 9, 'safari': 3, 'chrome': 1, 'camino': 1 } |
| 19 | + /** |
| 20 | + * For each browser name, an array of conditions that must be met are supplied in [operaton, value] form where |
| 21 | + * operation is a string containing a JavaScript compatible binary operator and value is either a number to be |
| 22 | + * compared with $.browser.versionNumber or a string to be compared with $.browser.version |
| 23 | + */ |
| 24 | + 'browsers': { |
| 25 | + 'ltr': { |
| 26 | + 'msie': [['>=', 7]], |
| 27 | + 'firefox': [ |
| 28 | + ['>=', 2], |
| 29 | + ['!=', '2.0'], |
| 30 | + ['!=', '2.0.0.1'], |
| 31 | + ['!=', '2.0.0.2'], |
| 32 | + ['!=', '2.0.0.3'], |
| 33 | + ['!=', '2.0.0.4'] |
| 34 | + ], |
| 35 | + 'opera': [['>=', 9.6]], |
| 36 | + 'safari': [['>=', 3.1]] |
| 37 | + }, |
| 38 | + 'rtl': { |
| 39 | + 'msie': [['>=', 8]], |
| 40 | + 'firefox': [ |
| 41 | + ['>=', 2], |
| 42 | + ['!=', '2.0'], |
| 43 | + ['!=', '2.0.0.1'], |
| 44 | + ['!=', '2.0.0.2'], |
| 45 | + ['!=', '2.0.0.3'], |
| 46 | + ['!=', '2.0.0.4'] |
| 47 | + ], |
| 48 | + 'opera': [['>=', 9.6]], |
| 49 | + 'safari': [['>=', 3.1]] |
| 50 | + } |
22 | 51 | }, |
23 | 52 | /** |
24 | 53 | * Path to images - this is a bit messy, and it would need to change if |
— | — | @@ -28,14 +57,28 @@ |
29 | 58 | }; |
30 | 59 | |
31 | 60 | $.wikiEditor.isSupportKnown = function() { |
32 | | - return ( function( supportedBrowsers ) { |
33 | | - return $.browser.name in supportedBrowsers; |
34 | | - } )( $.wikiEditor.supportedBrowsers[$( 'body.rtl' ).size() ? 'rtl' : 'ltr'] ); |
| 61 | + return $.browser.name in $.wikiEditor.browsers[$( 'body.rtl' ).size() ? 'rtl' : 'ltr']; |
35 | 62 | }; |
36 | 63 | $.wikiEditor.isSupported = function() { |
37 | | - return ( function( supportedBrowsers ) { |
38 | | - return $.browser.name in supportedBrowsers && $.browser.versionNumber >= supportedBrowsers[$.browser.name]; |
39 | | - } )( $.wikiEditor.supportedBrowsers[$( 'body.rtl' ).size() ? 'rtl' : 'ltr'] ); |
| 64 | + if ( !$.wikiEditor.isSupportKnown ) { |
| 65 | + // Assume good faith :) |
| 66 | + return true; |
| 67 | + } |
| 68 | + var browser = $.wikiEditor.browsers[$( 'body.rtl' ).size() ? 'rtl' : 'ltr'][$.browser.name]; |
| 69 | + for ( condition in browser ) { |
| 70 | + var op = browser[condition][0]; |
| 71 | + var val = browser[condition][1]; |
| 72 | + if ( typeof val == 'string' ) { |
| 73 | + if ( !( eval( '$.browser.version' + op + '"' + val + '"' ) ) ) { |
| 74 | + return false; |
| 75 | + } |
| 76 | + } else if ( typeof val == 'number' ) { |
| 77 | + if ( !( eval( '$.browser.versionNumber' + op + val ) ) ) { |
| 78 | + return false; |
| 79 | + } |
| 80 | + } |
| 81 | + } |
| 82 | + return true; |
40 | 83 | }; |
41 | 84 | // Wraps gM from js2, but allows raw text to supercede |
42 | 85 | $.wikiEditor.autoMsg = function( object, property ) { |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -1157,9 +1157,38 @@ |
1158 | 1158 | $.wikiEditor = { |
1159 | 1159 | 'modules': {}, |
1160 | 1160 | 'instances': [], |
1161 | | - 'supportedBrowsers': { |
1162 | | - 'ltr': { 'msie': 7, 'firefox': 2, 'opera': 9, 'safari': 3, 'chrome': 1, 'camino': 1 }, |
1163 | | - 'rtl': { 'msie': 8, 'firefox': 2, 'opera': 9, 'safari': 3, 'chrome': 1, 'camino': 1 } |
| 1161 | + /** |
| 1162 | + * For each browser name, an array of conditions that must be met are supplied in [operaton, value] form where |
| 1163 | + * operation is a string containing a JavaScript compatible binary operator and value is either a number to be |
| 1164 | + * compared with $.browser.versionNumber or a string to be compared with $.browser.version |
| 1165 | + */ |
| 1166 | + 'browsers': { |
| 1167 | + 'ltr': { |
| 1168 | + 'msie': [['>=', 7]], |
| 1169 | + 'firefox': [ |
| 1170 | + ['>=', 2], |
| 1171 | + ['!=', '2.0'], |
| 1172 | + ['!=', '2.0.0.1'], |
| 1173 | + ['!=', '2.0.0.2'], |
| 1174 | + ['!=', '2.0.0.3'], |
| 1175 | + ['!=', '2.0.0.4'] |
| 1176 | + ], |
| 1177 | + 'opera': [['>=', 9.6]], |
| 1178 | + 'safari': [['>=', 3.1]] |
| 1179 | + }, |
| 1180 | + 'rtl': { |
| 1181 | + 'msie': [['>=', 8]], |
| 1182 | + 'firefox': [ |
| 1183 | + ['>=', 2], |
| 1184 | + ['!=', '2.0'], |
| 1185 | + ['!=', '2.0.0.1'], |
| 1186 | + ['!=', '2.0.0.2'], |
| 1187 | + ['!=', '2.0.0.3'], |
| 1188 | + ['!=', '2.0.0.4'] |
| 1189 | + ], |
| 1190 | + 'opera': [['>=', 9.6]], |
| 1191 | + 'safari': [['>=', 3.1]] |
| 1192 | + } |
1164 | 1193 | }, |
1165 | 1194 | /** |
1166 | 1195 | * Path to images - this is a bit messy, and it would need to change if |
— | — | @@ -1170,14 +1199,28 @@ |
1171 | 1200 | }; |
1172 | 1201 | |
1173 | 1202 | $.wikiEditor.isSupportKnown = function() { |
1174 | | - return ( function( supportedBrowsers ) { |
1175 | | - return $.browser.name in supportedBrowsers; |
1176 | | - } )( $.wikiEditor.supportedBrowsers[$( 'body.rtl' ).size() ? 'rtl' : 'ltr'] ); |
| 1203 | + return $.browser.name in $.wikiEditor.browsers[$( 'body.rtl' ).size() ? 'rtl' : 'ltr']; |
1177 | 1204 | }; |
1178 | 1205 | $.wikiEditor.isSupported = function() { |
1179 | | - return ( function( supportedBrowsers ) { |
1180 | | - return $.browser.name in supportedBrowsers && $.browser.versionNumber >= supportedBrowsers[$.browser.name]; |
1181 | | - } )( $.wikiEditor.supportedBrowsers[$( 'body.rtl' ).size() ? 'rtl' : 'ltr'] ); |
| 1206 | + if ( !$.wikiEditor.isSupportKnown ) { |
| 1207 | + // Assume good faith :) |
| 1208 | + return true; |
| 1209 | + } |
| 1210 | + var browser = $.wikiEditor.browsers[$( 'body.rtl' ).size() ? 'rtl' : 'ltr'][$.browser.name]; |
| 1211 | + for ( condition in browser ) { |
| 1212 | + var op = browser[condition][0]; |
| 1213 | + var val = browser[condition][1]; |
| 1214 | + if ( typeof val == 'string' ) { |
| 1215 | + if ( !( eval( '$.browser.version' + op + '"' + val + '"' ) ) ) { |
| 1216 | + return false; |
| 1217 | + } |
| 1218 | + } else if ( typeof val == 'number' ) { |
| 1219 | + if ( !( eval( '$.browser.versionNumber' + op + val ) ) ) { |
| 1220 | + return false; |
| 1221 | + } |
| 1222 | + } |
| 1223 | + } |
| 1224 | + return true; |
1182 | 1225 | }; |
1183 | 1226 | // Wraps gM from js2, but allows raw text to supercede |
1184 | 1227 | $.wikiEditor.autoMsg = function( object, property ) { |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -78,7 +78,9 @@ |
79 | 79 | return this.each(function(){if(this.selectionStart||this.selectionStart=='0'){var scroll=getCaretScrollPosition(this);if(force||scroll<$(this).scrollTop()||scroll>$(this).scrollTop()+$(this).height()) |
80 | 80 | $(this).scrollTop(scroll);}else if(document.selection&&document.selection.createRange){var range=document.selection.createRange();var pos=$(this).getCaretPosition();var oldScrollTop=this.scrollTop;range.moveToElementText(this);range.collapse();range.move('character',pos+1);range.select();if(this.scrollTop!=oldScrollTop) |
81 | 81 | this.scrollTop+=range.offsetTop;else if(force){range.move('character',-1);range.select();}} |
82 | | -$(this).trigger('scrollToPosition');});}});})(jQuery);(function($){$.wikiEditor={'modules':{},'instances':[],'supportedBrowsers':{'ltr':{'msie':7,'firefox':2,'opera':9,'safari':3,'chrome':1,'camino':1},'rtl':{'msie':8,'firefox':2,'opera':9,'safari':3,'chrome':1,'camino':1}},imgPath:wgScriptPath+'/extensions/UsabilityInitiative/images/wikiEditor/'};$.wikiEditor.isSupportKnown=function(){return(function(supportedBrowsers){return $.browser.name in supportedBrowsers;})($.wikiEditor.supportedBrowsers[$('body.rtl').size()?'rtl':'ltr']);};$.wikiEditor.isSupported=function(){return(function(supportedBrowsers){return $.browser.name in supportedBrowsers&&$.browser.versionNumber>=supportedBrowsers[$.browser.name];})($.wikiEditor.supportedBrowsers[$('body.rtl').size()?'rtl':'ltr']);};$.wikiEditor.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;}}} |
| 82 | +$(this).trigger('scrollToPosition');});}});})(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/'};$.wikiEditor.isSupportKnown=function(){return $.browser.name in $.wikiEditor.browsers[$('body.rtl').size()?'rtl':'ltr'];};$.wikiEditor.isSupported=function(){if(!$.wikiEditor.isSupportKnown){return true;} |
| 83 | +var browser=$.wikiEditor.browsers[$('body.rtl').size()?'rtl':'ltr'][$.browser.name];for(condition in browser){var op=browser[condition][0];var val=browser[condition][1];if(typeof val=='string'){if(!(eval('$.browser.version'+op+'"'+val+'"'))){return false;}}else if(typeof val=='number'){if(!(eval('$.browser.versionNumber'+op+val))){return false;}}} |
| 84 | +return true;};$.wikiEditor.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;}}} |
83 | 85 | if(property in object){return object[property];}else if(property+'Msg'in object){return gM(object[property+'Msg']);}else{return'';}};$.wikiEditor.fixOperaBrokenness=function(s){if(typeof $.isOperaBroken=='undefined'&&$.wikiEditor.instances.length>0){var div=$('<div />').height(0).width(0).insertBefore($.wikiEditor.instances[0]);var textarea=$('<textarea />').height(0).appendTo(div).val("foo\r\nbar");var index=textarea.val().indexOf('bar');textarea.select();textarea.setSelection(index,index+3);textarea.encapsulateSelection('','BAR','',false,true);if(textarea.val().substr(-1)=='R') |
84 | 86 | $.isOperaBroken=false;else |
85 | 87 | $.isOperaBroken=true;div.remove();} |