Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js |
— | — | @@ -195,8 +195,30 @@ |
196 | 196 | * |
197 | 197 | * @param {Object} context |
198 | 198 | * @param {Object} action |
| 199 | + * @param {Object} source |
199 | 200 | */ |
200 | | - doAction : function( context, action ) { |
| 201 | + doAction : function( context, action, source ) { |
| 202 | + // Verify that this has been called from a source that's within the toolbar |
| 203 | + if ( source.closest( '.wikiEditor-ui-toolbar' ).size() ) { |
| 204 | + // Build a unique id for this action by tracking the parent rel attributes up to the toolbar level |
| 205 | + var rels = []; |
| 206 | + var step = source; |
| 207 | + var i = 0; |
| 208 | + while ( !step.hasClass( 'wikiEditor-ui-toolbar' ) ) { |
| 209 | + if ( i > 25 ) { |
| 210 | + break; |
| 211 | + } |
| 212 | + i++; |
| 213 | + var rel = step.attr( 'rel' ); |
| 214 | + if ( rel ) { |
| 215 | + rels.push( step.attr( 'rel' ) ); |
| 216 | + } |
| 217 | + step = step.parent(); |
| 218 | + } |
| 219 | + rels.reverse(); |
| 220 | + var id = rels.join( '.' ); |
| 221 | + // PERFORM CLICK TRACKING HERE! |
| 222 | + } |
201 | 223 | switch ( action.type ) { |
202 | 224 | case 'replace': |
203 | 225 | case 'encapsulate': |
— | — | @@ -285,7 +307,7 @@ |
286 | 308 | .data( 'context', context ) |
287 | 309 | .click( function() { |
288 | 310 | $.wikiEditor.modules.toolbar.fn.doAction( |
289 | | - $(this).data( 'context' ), $(this).data( 'action' ) |
| 311 | + $(this).data( 'context' ), $(this).data( 'action' ), $(this) |
290 | 312 | ); |
291 | 313 | return false; |
292 | 314 | } ); |
— | — | @@ -308,7 +330,7 @@ |
309 | 331 | .data( 'context', context ) |
310 | 332 | .click( function() { |
311 | 333 | $.wikiEditor.modules.toolbar.fn.doAction( |
312 | | - $(this).data( 'context' ), $(this).data( 'action' ) |
| 334 | + $(this).data( 'context' ), $(this).data( 'action' ), $(this) |
313 | 335 | ); |
314 | 336 | } ) |
315 | 337 | .text( optionLabel ) |
— | — | @@ -385,7 +407,8 @@ |
386 | 408 | .click( function() { |
387 | 409 | $.wikiEditor.modules.toolbar.fn.doAction( |
388 | 410 | $(this).parent().data( 'context' ), |
389 | | - $(this).parent().data( 'actions' )[$(this).attr( 'rel' )] |
| 411 | + $(this).parent().data( 'actions' )[$(this).attr( 'rel' )], |
| 412 | + $(this) |
390 | 413 | ); |
391 | 414 | return false; |
392 | 415 | } ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -625,24 +625,10 @@ |
626 | 626 | conf._data.keypressed_count = 0; |
627 | 627 | }) |
628 | 628 | .keypress( function() { |
629 | | - // When arrow up/down keys are held down, |
630 | | - // keypress events fire rapidly. Slow this down |
631 | | - // to one in every 120 ms |
632 | | - if ( conf._data.keypressed == 38 || conf._data.keypressed == 40 ) { |
633 | | - var now = new Date().getTime(); |
634 | | - if ( now - conf._data.last_keypress < 120 ) { |
635 | | - return; |
636 | | - } |
637 | | - } |
638 | | - conf._data.last_keypress = now; |
639 | 629 | conf._data.keypressed_count++; |
640 | 630 | processKey( conf._data.keypressed ); |
641 | 631 | }) |
642 | 632 | .keyup( function() { |
643 | | - // Reset last_keypress here instead of in |
644 | | - // keydown because at least in Firefox, all |
645 | | - // keypresses are preceded by a keydown |
646 | | - conf._data.last_keypress = 0; |
647 | 633 | // Some browsers won't throw keypress() for |
648 | 634 | // arrow keys. If we got a keydown and a keyup |
649 | 635 | // without a keypress in between, solve that |
— | — | @@ -1568,8 +1554,30 @@ |
1569 | 1555 | * |
1570 | 1556 | * @param {Object} context |
1571 | 1557 | * @param {Object} action |
| 1558 | + * @param {Object} source |
1572 | 1559 | */ |
1573 | | - doAction : function( context, action ) { |
| 1560 | + doAction : function( context, action, source ) { |
| 1561 | + // Verify that this has been called from a source that's within the toolbar |
| 1562 | + if ( source.closest( '.wikiEditor-ui-toolbar' ).size() ) { |
| 1563 | + // Build a unique id for this action by tracking the parent rel attributes up to the toolbar level |
| 1564 | + var rels = []; |
| 1565 | + var step = source; |
| 1566 | + var i = 0; |
| 1567 | + while ( !step.hasClass( 'wikiEditor-ui-toolbar' ) ) { |
| 1568 | + if ( i > 25 ) { |
| 1569 | + break; |
| 1570 | + } |
| 1571 | + i++; |
| 1572 | + var rel = step.attr( 'rel' ); |
| 1573 | + if ( rel ) { |
| 1574 | + rels.push( step.attr( 'rel' ) ); |
| 1575 | + } |
| 1576 | + step = step.parent(); |
| 1577 | + } |
| 1578 | + rels.reverse(); |
| 1579 | + var id = rels.join( '.' ); |
| 1580 | + // PERFORM CLICK TRACKING HERE! |
| 1581 | + } |
1574 | 1582 | switch ( action.type ) { |
1575 | 1583 | case 'replace': |
1576 | 1584 | case 'encapsulate': |
— | — | @@ -1658,7 +1666,7 @@ |
1659 | 1667 | .data( 'context', context ) |
1660 | 1668 | .click( function() { |
1661 | 1669 | $.wikiEditor.modules.toolbar.fn.doAction( |
1662 | | - $(this).data( 'context' ), $(this).data( 'action' ) |
| 1670 | + $(this).data( 'context' ), $(this).data( 'action' ), $(this) |
1663 | 1671 | ); |
1664 | 1672 | return false; |
1665 | 1673 | } ); |
— | — | @@ -1681,7 +1689,7 @@ |
1682 | 1690 | .data( 'context', context ) |
1683 | 1691 | .click( function() { |
1684 | 1692 | $.wikiEditor.modules.toolbar.fn.doAction( |
1685 | | - $(this).data( 'context' ), $(this).data( 'action' ) |
| 1693 | + $(this).data( 'context' ), $(this).data( 'action' ), $(this) |
1686 | 1694 | ); |
1687 | 1695 | } ) |
1688 | 1696 | .text( optionLabel ) |
— | — | @@ -1758,7 +1766,8 @@ |
1759 | 1767 | .click( function() { |
1760 | 1768 | $.wikiEditor.modules.toolbar.fn.doAction( |
1761 | 1769 | $(this).parent().data( 'context' ), |
1762 | | - $(this).parent().data( 'actions' )[$(this).attr( 'rel' )] |
| 1770 | + $(this).parent().data( 'actions' )[$(this).attr( 'rel' )], |
| 1771 | + $(this) |
1763 | 1772 | ); |
1764 | 1773 | return false; |
1765 | 1774 | } ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -67,8 +67,7 @@ |
68 | 68 | conf.maxGrowFactor=2;if(typeof conf.maxRows=='undefined') |
69 | 69 | conf.maxRows=7;if(typeof conf.submitOnClick=='undefined') |
70 | 70 | conf.submitOnClick=false;if(typeof conf.suggestions!='object') |
71 | | -conf.suggestions=[];conf._data={};conf._data.textbox=$(this);conf._data.timerID=null;conf._data.prevText=null;conf._data.visibleResults=0;conf._data.mouseDownOn=$([]);conf._data.div=$('<div />').addClass('os-suggest').css({top:Math.round($(this).offset().top)+this.offsetHeight,left:Math.round($(this).offset().left),width:$(this).outerWidth()}).hide().appendTo($('body'));$('<table />').addClass('os-suggest-results').width($(this).outerWidth()).appendTo(conf._data.div);$(this).attr('autocomplete','off').keydown(function(e){conf._data.keypressed=(e.keyCode==undefined)?e.which:e.keyCode;conf._data.keypressed_count=0;}).keypress(function(){if(conf._data.keypressed==38||conf._data.keypressed==40){var now=new Date().getTime();if(now-conf._data.last_keypress<120){return;}} |
72 | | -conf._data.last_keypress=now;conf._data.keypressed_count++;processKey(conf._data.keypressed);}).keyup(function(){conf._data.last_keypress=0;if(conf._data.keypressed_count==0) |
| 71 | +conf.suggestions=[];conf._data={};conf._data.textbox=$(this);conf._data.timerID=null;conf._data.prevText=null;conf._data.visibleResults=0;conf._data.mouseDownOn=$([]);conf._data.div=$('<div />').addClass('os-suggest').css({top:Math.round($(this).offset().top)+this.offsetHeight,left:Math.round($(this).offset().left),width:$(this).outerWidth()}).hide().appendTo($('body'));$('<table />').addClass('os-suggest-results').width($(this).outerWidth()).appendTo(conf._data.div);$(this).attr('autocomplete','off').keydown(function(e){conf._data.keypressed=(e.keyCode==undefined)?e.which:e.keyCode;conf._data.keypressed_count=0;}).keypress(function(){conf._data.keypressed_count++;processKey(conf._data.keypressed);}).keyup(function(){if(conf._data.keypressed_count==0) |
73 | 72 | processKey(conf._data.keypressed);}).blur(function(){if(conf._data.mouseDownOn.size()>0) |
74 | 73 | return;conf._data.div.hide();cancelPendingSuggestions();});conf._data.div.mouseover(function(e){var tr=$(e.target).closest('.os-suggest tr');highlightResult(tr,false);}).mousedown(function(e){var tr=$(e.target).closest('.os-suggest tr');conf._data.mouseDownOn=tr;}).mouseup(function(e){var tr=$(e.target).closest('.os-suggest tr');var other=conf._data.mouseDownOn;conf._data.mouseDownOn=$([]);if(tr.get(0)!=other.get(0)) |
75 | 74 | return;highlightResult(tr,true);conf._data.div.hide();conf._data.textbox.focus();if(conf.submitOnClick) |
— | — | @@ -146,21 +145,25 @@ |
147 | 146 | $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;}));} |
148 | 147 | 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();} |
149 | 148 | 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;} |
150 | | -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){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]||'')}} |
| 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;} |
| 150 | +i++;var rel=step.attr('rel');if(rel){rels.push(step.attr('rel'));} |
| 151 | +step=step.parent();} |
| 152 | +rels.reverse();var id=rels.join('.');} |
| 153 | +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]||'')}} |
151 | 154 | 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];} |
152 | 155 | $j('<div /> ').attr('id',action.id).html(action.html).data('context',context).appendTo($j('body')).each(action.init).dialog(dialogConf);} |
153 | 156 | $j('#'+action.id).dialog('open');break;default:break;}},buildGroup:function(context,id,group){var $group=$('<div />').attr({'class':'group group-'+id,'rel':id});var label=$.wikiEditor.modules.toolbar.fn.autoMsg(group,'label');if(label){$group.append('<div class="label">'+label+'</div>')} |
154 | 157 | if('tools'in group){for(tool in group.tools){$group.append($.wikiEditor.modules.toolbar.fn.buildTool(context,tool,group.tools[tool]));}} |
155 | 158 | return $group;},buildTool:function(context,id,tool){if('filters'in tool){for(filter in tool.filters){if($(tool.filters[filter]).size()==0){return null;}}} |
156 | 159 | var label=$.wikiEditor.modules.toolbar.fn.autoMsg(tool,'label');switch(tool.type){case'button':var src=tool.icon;if(src.indexOf('http://')!==0&&src.indexOf('https://')!==0){src=$.wikiEditor.modules.toolbar.imgPath+src;} |
157 | | -$button=$('<img />').attr({'src':src,'width':22,'height':22,'alt':label,'title':label,'rel':id,'class':'tool tool-button'});if('action'in tool){$button.data('action',tool.action).data('context',context).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).data('context'),$(this).data('action'));return false;});} |
158 | | -return $button;case'select':var $select=$('<div />').attr({'rel':id,'class':'tool tool-select'}).click(function(){var $options=$(this).find('.options');$options.animate({'opacity':'toggle'},'fast');});$options=$('<div />').addClass('options');if('list'in tool){for(option in tool.list){var optionLabel=$.wikiEditor.modules.toolbar.fn.autoMsg(tool.list[option],'label');$options.append($('<a />').data('action',tool.list[option].action).data('context',context).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).data('context'),$(this).data('action'));}).text(optionLabel).addClass('option').attr('rel',option));}} |
| 160 | +$button=$('<img />').attr({'src':src,'width':22,'height':22,'alt':label,'title':label,'rel':id,'class':'tool tool-button'});if('action'in tool){$button.data('action',tool.action).data('context',context).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).data('context'),$(this).data('action'),$(this));return false;});} |
| 161 | +return $button;case'select':var $select=$('<div />').attr({'rel':id,'class':'tool tool-select'}).click(function(){var $options=$(this).find('.options');$options.animate({'opacity':'toggle'},'fast');});$options=$('<div />').addClass('options');if('list'in tool){for(option in tool.list){var optionLabel=$.wikiEditor.modules.toolbar.fn.autoMsg(tool.list[option],'label');$options.append($('<a />').data('action',tool.list[option].action).data('context',context).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).data('context'),$(this).data('action'),$(this));}).text(optionLabel).addClass('option').attr('rel',option));}} |
159 | 162 | $select.append($('<div />').addClass('menu').append($options));$select.append($('<div />').addClass('label').text(label));return $select;default:return null;}},buildBookmark:function(context,id,page){var label=$.wikiEditor.modules.toolbar.fn.autoMsg(page,'label');return $('<div />').text(label).attr('rel',id).data('context',context).click(function(){$(this).parent().parent().find('.page').hide();$(this).parent().parent().find('.page-'+$(this).attr('rel')).show();$(this).siblings().removeClass('current');$(this).addClass('current');var section=$(this).parent().parent().attr('rel');$.cookie('wikiEditor-'+$(this).data('context').instance+'-booklet-'+section+'-page',$(this).attr('rel'));});},buildPage:function(context,id,page){var $page=$('<div />').attr({'class':'page page-'+id,'rel':id});switch(page.layout){case'table':$page.addClass('page-table');var html='<table cellpadding=0 cellspacing=0 '+'border=0 width="100%" class="table table-"'+id+'">';if('headings'in page){html+=$.wikiEditor.modules.toolbar.fn.buildHeading(context,page.headings)} |
160 | 163 | if('rows'in page){for(row in page.rows){html+=$.wikiEditor.modules.toolbar.fn.buildRow(context,page.rows[row])}} |
161 | 164 | $page.html(html);break;case'characters':$page.addClass('page-characters');$characters=$('<div />').data('context',context).data('actions',{});var actions=$characters.data('actions');if('language'in page){$characters.attr('lang',page.language);} |
162 | 165 | if('direction'in page){$characters.attr('dir',page.direction);} |
163 | 166 | if('characters'in page){var html='';for(character in page.characters){html+=$.wikiEditor.modules.toolbar.fn.buildCharacter(page.characters[character],actions);} |
164 | | -$characters.html(html).children().click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).parent().data('context'),$(this).parent().data('actions')[$(this).attr('rel')]);return false;});} |
| 167 | +$characters.html(html).children().click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).parent().data('context'),$(this).parent().data('actions')[$(this).attr('rel')],$(this));return false;});} |
165 | 168 | $page.append($characters);break;} |
166 | 169 | return $page;},buildHeading:function(context,headings){var html='<tr>';for(heading in headings){html+='<th>'+$.wikiEditor.modules.toolbar.fn.autoMsg(headings[heading],'content')+'</th>';} |
167 | 170 | return html;},buildRow:function(context,row){var html='<tr>';for(cell in row){html+='<td class="cell cell-'+cell+'" valign="top"><span>'+ |