Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | /* JavaScript for EditToolbar extension */ |
3 | 3 | |
4 | 4 | js2AddOnloadHook( function() { |
5 | | - if ( $j.wikiEditor.isSupported() ) { |
| 5 | + if ( $j.wikiEditor != undefined && $j.wikiEditor.isSupported() || !$j.wikiEditor.isSupportKnown() ) { |
6 | 6 | // Remove the old toolbar |
7 | 7 | $j( '#toolbar' ).remove(); |
8 | 8 | // Build a wikiEditor around the textarea |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -15,17 +15,21 @@ |
16 | 16 | $.wikiEditor = { |
17 | 17 | 'modules': {}, |
18 | 18 | 'instances': [], |
19 | | - 'isSupported': function() { |
20 | | - function isSupported( supportedBrowsers ) { |
21 | | - return $.browser.name in supportedBrowsers && $.browser.versionNumber >= supportedBrowsers[$.browser.name]; |
22 | | - } |
23 | | - var supportedBrowsers = { |
24 | | - 'ltr': { 'msie': 7, 'firefox': 2, 'opera': 9, 'safari': 3, 'chrome': 1, 'camino': 1 }, |
25 | | - 'rtl': { 'msie': 8, 'firefox': 2, 'opera': 9, 'safari': 3, 'chrome': 1, 'camino': 1 } |
26 | | - }; |
27 | | - return isSupported( supportedBrowsers[$( 'body.rtl' ).size() ? 'rtl' : 'ltr'] ); |
| 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 } |
28 | 22 | } |
29 | 23 | }; |
| 24 | +$.wikiEditor.isSupportKnown = function() { |
| 25 | + return ( function( supportedBrowsers ) { |
| 26 | + return $.browser.name in supportedBrowsers; |
| 27 | + } )( $.wikiEditor.supportedBrowsers[$( 'body.rtl' ).size() ? 'rtl' : 'ltr'] ); |
| 28 | +}; |
| 29 | +$.wikiEditor.isSupported = function() { |
| 30 | + return ( function( supportedBrowsers ) { |
| 31 | + return $.browser.name in supportedBrowsers && $.browser.versionNumber >= supportedBrowsers[$.browser.name]; |
| 32 | + } )( $.wikiEditor.supportedBrowsers[$( 'body.rtl' ).size() ? 'rtl' : 'ltr'] ); |
| 33 | +}; |
30 | 34 | $.fn.wikiEditor = function() { |
31 | 35 | |
32 | 36 | /* Initialization */ |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -1026,17 +1026,21 @@ |
1027 | 1027 | $.wikiEditor = { |
1028 | 1028 | 'modules': {}, |
1029 | 1029 | 'instances': [], |
1030 | | - 'isSupported': function() { |
1031 | | - function isSupported( supportedBrowsers ) { |
1032 | | - return $.browser.name in supportedBrowsers && $.browser.versionNumber >= supportedBrowsers[$.browser.name]; |
1033 | | - } |
1034 | | - var supportedBrowsers = { |
1035 | | - 'ltr': { 'msie': 7, 'firefox': 2, 'opera': 9, 'safari': 3, 'chrome': 1, 'camino': 1 }, |
1036 | | - 'rtl': { 'msie': 8, 'firefox': 2, 'opera': 9, 'safari': 3, 'chrome': 1, 'camino': 1 } |
1037 | | - }; |
1038 | | - return isSupported( supportedBrowsers[$( 'body.rtl' ).size() ? 'rtl' : 'ltr'] ); |
| 1030 | + 'supportedBrowsers': { |
| 1031 | + 'ltr': { 'msie': 7, 'firefox': 2, 'opera': 9, 'safari': 3, 'chrome': 1, 'camino': 1 }, |
| 1032 | + 'rtl': { 'msie': 8, 'firefox': 2, 'opera': 9, 'safari': 3, 'chrome': 1, 'camino': 1 } |
1039 | 1033 | } |
1040 | 1034 | }; |
| 1035 | +$.wikiEditor.isSupportKnown = function() { |
| 1036 | + return ( function( supportedBrowsers ) { |
| 1037 | + return $.browser.name in supportedBrowsers; |
| 1038 | + } )( $.wikiEditor.supportedBrowsers[$( 'body.rtl' ).size() ? 'rtl' : 'ltr'] ); |
| 1039 | +}; |
| 1040 | +$.wikiEditor.isSupported = function() { |
| 1041 | + return ( function( supportedBrowsers ) { |
| 1042 | + return $.browser.name in supportedBrowsers && $.browser.versionNumber >= supportedBrowsers[$.browser.name]; |
| 1043 | + } )( $.wikiEditor.supportedBrowsers[$( 'body.rtl' ).size() ? 'rtl' : 'ltr'] ); |
| 1044 | +}; |
1041 | 1045 | $.fn.wikiEditor = function() { |
1042 | 1046 | |
1043 | 1047 | /* Initialization */ |
— | — | @@ -1558,7 +1562,8 @@ |
1559 | 1563 | */ |
1560 | 1564 | doAction : function( context, action, source ) { |
1561 | 1565 | // Verify that this has been called from a source that's within the toolbar |
1562 | | - if ( source.closest( '.wikiEditor-ui-toolbar' ).size() ) { |
| 1566 | + // 'trackAction' defined in click tracking |
| 1567 | + if ($.trackAction != undefined && source.closest( '.wikiEditor-ui-toolbar' ).size() ) { |
1563 | 1568 | // Build a unique id for this action by tracking the parent rel attributes up to the toolbar level |
1564 | 1569 | var rels = []; |
1565 | 1570 | var step = source; |
— | — | @@ -1576,7 +1581,7 @@ |
1577 | 1582 | } |
1578 | 1583 | rels.reverse(); |
1579 | 1584 | var id = rels.join( '.' ); |
1580 | | - // PERFORM CLICK TRACKING HERE! |
| 1585 | + $.trackAction(id); |
1581 | 1586 | } |
1582 | 1587 | switch ( action.type ) { |
1583 | 1588 | case 'replace': |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -107,8 +107,7 @@ |
108 | 108 | return($.os.name=='mac'?13:($.os.name=='linux'?15:16))*row;} |
109 | 109 | return this.each(function(){$(this).focus();if(this.selectionStart||this.selectionStart=='0'){this.selectionStart=pos;this.selectionEnd=pos;$(this).scrollTop(getCaretScrollPosition(this));}else if(document.selection&&document.selection.createRange){var range=document.selection.createRange();var oldPos=$(this).getCaretPosition();var goBack=false;if(oldPos==pos){pos++;goBack=true;} |
110 | 110 | range.moveToElementText(this);range.collapse();range.move('character',pos);range.select();this.scrollTop+=range.offsetTop;if(goBack){range.move('character',-1);range.select();}} |
111 | | -$(this).trigger('scrollToPosition');});}});})(jQuery);(function($){$.wikiEditor={'modules':{},'instances':[],'isSupported':function(){function isSupported(supportedBrowsers){return $.browser.name in supportedBrowsers&&$.browser.versionNumber>=supportedBrowsers[$.browser.name];} |
112 | | -var 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}};return isSupported(supportedBrowsers[$('body.rtl').size()?'rtl':'ltr']);}};$.fn.wikiEditor=function(){var context=$(this).data('context');if(typeof context!=='undefined'){arguments=$.makeArray(arguments);if(arguments.length>0){var call=arguments.shift();if(call in context.api){context.api[call](context,arguments[0]==undefined?{}:arguments[0]);} |
| 111 | +$(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}}};$.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']);};$.fn.wikiEditor=function(){var context=$(this).data('context');if(typeof context!=='undefined'){arguments=$.makeArray(arguments);if(arguments.length>0){var call=arguments.shift();if(call in context.api){context.api[call](context,arguments[0]==undefined?{}:arguments[0]);} |
113 | 112 | return $(this).data('context',context);} |
114 | 113 | return $(this);} |
115 | 114 | var instance=$.wikiEditor.instances.length;context={'$textarea':$(this),'modules':{},'data':{},'instance':instance};$.wikiEditor.instances[instance]=$(this);$(this).wrap($('<div></div>').addClass('wikiEditor-ui').attr('id','wikiEditor-ui')).wrap($('<div></div>').addClass('wikiEditor-ui-bottom').attr('id','wikiEditor-ui-bottom')).wrap($('<div></div>').addClass('wikiEditor-ui-text').attr('id','wikiEditor-ui-text'));context.$ui=$(this).parent().parent().parent();context.$ui.after($('<div style="clear:both;"></div>'));context.$ui.prepend($('<div></div>').addClass('wikiEditor-ui-top').attr('id','wikiEditor-ui-top'));context.api={addModule:function(context,data){function callModuleApi(module,call,data){if(module in $.wikiEditor.modules&&'fn'in $.wikiEditor.modules[module]&&call in $.wikiEditor.modules[module].fn){$.wikiEditor.modules[module].fn[call](context,data);}} |
— | — | @@ -145,10 +144,10 @@ |
146 | 145 | $characters=context.modules.$toolbar.find('div[rel='+data.section+'].section '+'div[rel='+data.page+'].page div');var actions=$characters.data('actions');for(character in data[type]){$characters.append($($.wikiEditor.modules.toolbar.fn.buildCharacter(data[type][character],actions)).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).parent().data('context'),$(this).parent().data('actions')[$(this).attr('rel')]);return false;}));} |
147 | 146 | break;default:break;}}},removeFromToolbar:function(context,data){if(typeof data.section=='string'){var tab='div.tabs span[rel='+data.section+'].tab';var target='div[rel='+data.section+'].section';if(typeof data.group=='string'){target+=' div[rel='+data.group+'].group';if(typeof data.tool=='string'){target+=' div[rel='+data.tool+'].tool';}}else if(typeof data.page=='string'){var index=target+' div.index div[rel='+data.page+']';target+=' div.pages div[rel='+data.page+'].page';if(typeof data.character=='string'){target+=' a[rel='+data.character+']';}else if(typeof data.row=='number'){target+=' table tr:not(:has(th)):eq('+data.row+')';}else{context.modules.$toolbar.find(index).remove();$.wikiEditor.modules.toolbar.fn.updateBookletSelection(context,null,context.modules.$toolbar.find(target),context.modules.$toolbar.find(index));}}else{context.modules.$toolbar.find(tab).remove();} |
148 | 147 | context.modules.$toolbar.find(target).remove();}}},fn:{autoMsg:function(object,property){if(property in object){return object[property];}else if(property+'Msg'in object){return gM(object[property+'Msg']);}else{return'';}},create:function(context,config){if('$toolbar'in context.modules){return;} |
149 | | -context.modules.$toolbar=$('<div />').addClass('wikiEditor-ui-toolbar').attr('id','wikiEditor-ui-toolbar');$.wikiEditor.modules.toolbar.fn.build(context,config);context.$ui.find('.wikiEditor-ui-top').append(context.modules.$toolbar);},doAction:function(context,action,source){if(source.closest('.wikiEditor-ui-toolbar').size()){var rels=[];var step=source;var i=0;while(!step.hasClass('wikiEditor-ui-toolbar')){if(i>25){break;} |
| 148 | +context.modules.$toolbar=$('<div />').addClass('wikiEditor-ui-toolbar').attr('id','wikiEditor-ui-toolbar');$.wikiEditor.modules.toolbar.fn.build(context,config);context.$ui.find('.wikiEditor-ui-top').append(context.modules.$toolbar);},doAction:function(context,action,source){if($.trackAction!=undefined&&source.closest('.wikiEditor-ui-toolbar').size()){var rels=[];var step=source;var i=0;while(!step.hasClass('wikiEditor-ui-toolbar')){if(i>25){break;} |
150 | 149 | i++;var rel=step.attr('rel');if(rel){rels.push(step.attr('rel'));} |
151 | 150 | step=step.parent();} |
152 | | -rels.reverse();var id=rels.join('.');} |
| 151 | +rels.reverse();var id=rels.join('.');$.trackAction(id);} |
153 | 152 | switch(action.type){case'replace':case'encapsulate':var parts={'pre':'','peri':'','post':''};for(part in parts){if(part+'Msg'in action.options){parts[part]=gM(action.options[part+'Msg'],(action.options[part]||null));}else{parts[part]=(action.options[part]||'')}} |
154 | 153 | context.$textarea.encapsulateSelection(parts.pre,parts.peri,parts.post,action.options.ownline,action.type=='replace');break;case'dialog':if($j('#'+action.id).size()==0){var dialogConf=action.dialog;dialogConf.bgiframe=true;dialogConf.autoOpen=false;dialogConf.modal=true;dialogConf.title=gM(action.titleMsg);for(msg in dialogConf.buttons){dialogConf.buttons[gM(msg)]=dialogConf.buttons[msg];delete dialogConf.buttons[msg];} |
155 | 154 | $j('<div /> ').attr('id',action.id).html(action.html).data('context',context).appendTo($j('body')).each(action.init).dialog(dialogConf);} |