Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -72,20 +72,20 @@ |
73 | 73 | array( 'src' => 'js/plugins/jquery.delayedBind.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' => 163 ), |
| 76 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 164 ), |
77 | 77 | array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 40 ), |
78 | 78 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 52 ), |
79 | 79 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 21 ), |
80 | 80 | array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 97 ), |
81 | 81 | array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 11 ), |
82 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 50 ), |
| 82 | + array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 51 ), |
83 | 83 | array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 3 ), |
84 | 84 | ), |
85 | 85 | 'combined' => array( |
86 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 325 ), |
| 86 | + array( 'src' => 'js/plugins.combined.js', 'version' => 326 ), |
87 | 87 | ), |
88 | 88 | 'minified' => array( |
89 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 325 ), |
| 89 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 326 ), |
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js |
— | — | @@ -116,7 +116,22 @@ |
117 | 117 | } |
118 | 118 | }//if opentemplates |
119 | 119 | } |
120 | | - } |
| 120 | + }, //mark |
| 121 | + |
| 122 | + keydown: function( context, event ){ |
| 123 | + var $evtElem = event.jQueryNode; |
| 124 | + if ( $evtElem ) { |
| 125 | + if( $evtElem.hasClass( 'wikiEditor-template-name' ) ){ |
| 126 | + switch ( event.which ) { |
| 127 | + case 37://left |
| 128 | + case 38://up |
| 129 | + case 39://right |
| 130 | + case 40: return true;//down |
| 131 | + default: return false; //can't type in a template name |
| 132 | + } |
| 133 | + } |
| 134 | + } |
| 135 | + } //keydown |
121 | 136 | }, |
122 | 137 | /** |
123 | 138 | * Regular expressions that produce tokens |
— | — | @@ -181,7 +196,8 @@ |
182 | 197 | var $template = $wrapper.parent( '.wikiEditor-template' ); |
183 | 198 | $template.find( '.wikiEditor-template-name' ) |
184 | 199 | .click( function() { $.wikiEditor.modules.templateEditor.fn.createDialog( $wrapper ); return false; } ) |
185 | | - .mousedown( function() { return false; } ); |
| 200 | + .mousedown( function() { return false; } ) |
| 201 | + .data("keydownHandler", function(){console.log("CARLOS!");}); |
186 | 202 | $template.find( '.wikiEditor-template-expand' ) |
187 | 203 | .click( function() { $.wikiEditor.modules.templateEditor.fn.toggleWikiTextEditor( $wrapper ); return false; } ) |
188 | 204 | .mousedown( function() { return false; } ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -521,6 +521,8 @@ |
522 | 522 | return false; |
523 | 523 | } |
524 | 524 | } |
| 525 | + |
| 526 | + var returnFromModules = null; //they return null by default |
525 | 527 | // Pass the event around to all modules activated on this context |
526 | 528 | for ( var module in context.modules ) { |
527 | 529 | if ( |
— | — | @@ -528,10 +530,22 @@ |
529 | 531 | 'evt' in $.wikiEditor.modules[module] && |
530 | 532 | name in $.wikiEditor.modules[module].evt |
531 | 533 | ) { |
532 | | - $.wikiEditor.modules[module].evt[name]( context, event ); |
| 534 | + var ret = $.wikiEditor.modules[module].evt[name]( context, event ); |
| 535 | + if(ret != null){ |
| 536 | + //if 1 returns false, the end result is false |
| 537 | + if( returnFromModules == null ) { |
| 538 | + returnFromModules = ret; |
| 539 | + } else { |
| 540 | + returnFromModules = returnFromModules && ret; |
| 541 | + } |
| 542 | + } |
533 | 543 | } |
534 | 544 | } |
535 | | - return true; |
| 545 | + if(returnFromModules != null){ |
| 546 | + return returnFromModules; |
| 547 | + } else{ |
| 548 | + return true; |
| 549 | + } |
536 | 550 | }, |
537 | 551 | /** |
538 | 552 | * Adds a button to the UI |
— | — | @@ -1111,7 +1125,10 @@ |
1112 | 1126 | // Setup event handling on the iframe |
1113 | 1127 | $( context.$iframe[0].contentWindow.document ) |
1114 | 1128 | .bind( 'keydown', function( event ) { |
| 1129 | + var $cElem = context.fn.getElementAtCursor(); |
| 1130 | + event.jQueryNode = $cElem |
1115 | 1131 | return context.fn.trigger( 'keydown', event ); |
| 1132 | + |
1116 | 1133 | } ) |
1117 | 1134 | .bind( 'paste', function( event ) { |
1118 | 1135 | return context.fn.trigger( 'paste', event ); |
— | — | @@ -1148,6 +1165,20 @@ |
1149 | 1166 | * equivilant functionality to the otherwise textarea-based functionality. |
1150 | 1167 | */ |
1151 | 1168 | |
| 1169 | + 'getElementAtCursor': function(){ |
| 1170 | + //firefox only |
| 1171 | + if ( context.$iframe[0].contentWindow.getSelection ) { |
| 1172 | + var selection = context.$iframe[0].contentWindow.getSelection(); |
| 1173 | + if ( selection.rangeCount == 0 ) { |
| 1174 | + // We don't know where the cursor is |
| 1175 | + return null; |
| 1176 | + } |
| 1177 | + var sc = selection.getRangeAt( 0 ).startContainer; |
| 1178 | + return $( sc.parentNode ).eq( 0 ); |
| 1179 | + } |
| 1180 | + else return null; |
| 1181 | + }, |
| 1182 | + |
1152 | 1183 | /** |
1153 | 1184 | * Gets the complete contents of the iframe (in plain text, not HTML) |
1154 | 1185 | */ |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -7064,6 +7064,8 @@ |
7065 | 7065 | return false; |
7066 | 7066 | } |
7067 | 7067 | } |
| 7068 | + |
| 7069 | + var returnFromModules = null; //they return null by default |
7068 | 7070 | // Pass the event around to all modules activated on this context |
7069 | 7071 | for ( var module in context.modules ) { |
7070 | 7072 | if ( |
— | — | @@ -7071,10 +7073,22 @@ |
7072 | 7074 | 'evt' in $.wikiEditor.modules[module] && |
7073 | 7075 | name in $.wikiEditor.modules[module].evt |
7074 | 7076 | ) { |
7075 | | - $.wikiEditor.modules[module].evt[name]( context, event ); |
| 7077 | + var ret = $.wikiEditor.modules[module].evt[name]( context, event ); |
| 7078 | + if(ret != null){ |
| 7079 | + //if 1 returns false, the end result is false |
| 7080 | + if( returnFromModules == null ) { |
| 7081 | + returnFromModules = ret; |
| 7082 | + } else { |
| 7083 | + returnFromModules = returnFromModules && ret; |
| 7084 | + } |
| 7085 | + } |
7076 | 7086 | } |
7077 | 7087 | } |
7078 | | - return true; |
| 7088 | + if(returnFromModules != null){ |
| 7089 | + return returnFromModules; |
| 7090 | + } else{ |
| 7091 | + return true; |
| 7092 | + } |
7079 | 7093 | }, |
7080 | 7094 | /** |
7081 | 7095 | * Adds a button to the UI |
— | — | @@ -7654,7 +7668,10 @@ |
7655 | 7669 | // Setup event handling on the iframe |
7656 | 7670 | $( context.$iframe[0].contentWindow.document ) |
7657 | 7671 | .bind( 'keydown', function( event ) { |
| 7672 | + var $cElem = context.fn.getElementAtCursor(); |
| 7673 | + event.jQueryNode = $cElem |
7658 | 7674 | return context.fn.trigger( 'keydown', event ); |
| 7675 | + |
7659 | 7676 | } ) |
7660 | 7677 | .bind( 'paste', function( event ) { |
7661 | 7678 | return context.fn.trigger( 'paste', event ); |
— | — | @@ -7691,6 +7708,20 @@ |
7692 | 7709 | * equivilant functionality to the otherwise textarea-based functionality. |
7693 | 7710 | */ |
7694 | 7711 | |
| 7712 | + 'getElementAtCursor': function(){ |
| 7713 | + //firefox only |
| 7714 | + if ( context.$iframe[0].contentWindow.getSelection ) { |
| 7715 | + var selection = context.$iframe[0].contentWindow.getSelection(); |
| 7716 | + if ( selection.rangeCount == 0 ) { |
| 7717 | + // We don't know where the cursor is |
| 7718 | + return null; |
| 7719 | + } |
| 7720 | + var sc = selection.getRangeAt( 0 ).startContainer; |
| 7721 | + return $( sc.parentNode ).eq( 0 ); |
| 7722 | + } |
| 7723 | + else return null; |
| 7724 | + }, |
| 7725 | + |
7695 | 7726 | /** |
7696 | 7727 | * Gets the complete contents of the iframe (in plain text, not HTML) |
7697 | 7728 | */ |
— | — | @@ -9359,7 +9390,22 @@ |
9360 | 9391 | } |
9361 | 9392 | }//if opentemplates |
9362 | 9393 | } |
9363 | | - } |
| 9394 | + }, //mark |
| 9395 | + |
| 9396 | + keydown: function( context, event ){ |
| 9397 | + var $evtElem = event.jQueryNode; |
| 9398 | + if ( $evtElem ) { |
| 9399 | + if( $evtElem.hasClass( 'wikiEditor-template-name' ) ){ |
| 9400 | + switch ( event.which ) { |
| 9401 | + case 37://left |
| 9402 | + case 38://up |
| 9403 | + case 39://right |
| 9404 | + case 40: return true;//down |
| 9405 | + default: return false; //can't type in a template name |
| 9406 | + } |
| 9407 | + } |
| 9408 | + } |
| 9409 | + } //keydown |
9364 | 9410 | }, |
9365 | 9411 | /** |
9366 | 9412 | * Regular expressions that produce tokens |
— | — | @@ -9424,7 +9470,8 @@ |
9425 | 9471 | var $template = $wrapper.parent( '.wikiEditor-template' ); |
9426 | 9472 | $template.find( '.wikiEditor-template-name' ) |
9427 | 9473 | .click( function() { $.wikiEditor.modules.templateEditor.fn.createDialog( $wrapper ); return false; } ) |
9428 | | - .mousedown( function() { return false; } ); |
| 9474 | + .mousedown( function() { return false; } ) |
| 9475 | + .data("keydownHandler", function(){console.log("CARLOS!");}); |
9429 | 9476 | $template.find( '.wikiEditor-template-expand' ) |
9430 | 9477 | .click( function() { $.wikiEditor.modules.templateEditor.fn.toggleWikiTextEditor( $wrapper ); return false; } ) |
9431 | 9478 | .mousedown( function() { return false; } ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -473,8 +473,8 @@ |
474 | 474 | context.fn.purgeOffsets();var restoreTo=cursorPos[1]+context.fn.getContents().length-oldLength;context.fn.setSelection({start:restoreTo,end:restoreTo});},0);return true;},'ready':function(event){context.history.push({'html':context.$content.html(),'sel':context.fn.getCaretPosition()});return true;}};context.fn={'trigger':function(name,event){if(typeof event=='undefined'){event={'type':'custom'};} |
475 | 475 | if(typeof event.data=='undefined'){event.data={};} |
476 | 476 | if(name in context.evt){if(!context.evt[name](event)){return false;}} |
477 | | -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);}} |
478 | | -return true;},'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','#').mousedown(function(){return false;}).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);} |
| 477 | +var returnFromModules=null;for(var module in context.modules){if(module in $.wikiEditor.modules&&'evt'in $.wikiEditor.modules[module]&&name in $.wikiEditor.modules[module].evt){var ret=$.wikiEditor.modules[module].evt[name](context,event);if(ret!=null){if(returnFromModules==null){returnFromModules=ret;}else{returnFromModules=returnFromModules&&ret;}}}} |
| 478 | +if(returnFromModules!=null){return returnFromModules;}else{return true;}},'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','#').mousedown(function(){return false;}).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);} |
479 | 479 | event.preventDefault();return false;}).text($.wikiEditor.autoMsg(options,'title'))).appendTo(context.$tabs);} |
480 | 480 | if(!context.$tabs.children().size()){addTab({'name':'wikitext','titleMsg':'wikieditor-wikitext-tab'});} |
481 | 481 | addTab(options);return $('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-'+options.name).hide().appendTo(context.$ui);},'highlightLine':function($element,mode){if(!$element.is('p')){$element=$element.closest('p');} |
— | — | @@ -519,7 +519,10 @@ |
520 | 520 | context.oldDelayedHistoryPosition=context.historyPosition;},'setupIframe':function(){context.$iframe=$('<iframe></iframe>').attr({'frameBorder':0,'border':0,'tabindex':1,'src':wgScriptPath+'/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.html?'+'instance='+context.instance+'&ts='+(new Date()).getTime()+'&is=content','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;}} |
521 | 521 | context.$content=$(context.$iframe[0].contentWindow.document.body);var html=context.$textarea.val().replace(/&esc;/g,'&esc;esc;').replace(/\<p\>/g,'&esc;<p>').replace(/\<\/p\>/g,'&esc;</p>').replace(/\<span class="wikiEditor-tab"\>\<\/span\>/g,'&esc;<span class="wikiEditor-tab"></span>').replace(/ /g,'&esc;&nbsp;');if($.browser.msie){html=html.replace(/\t/g,'<span class="wikiEditor-tab"></span>');if($.browser.versionNumber<=7){html=html.replace(/ /g," ");}else{html=html.replace(/(^|\n) /g,"$1 ");}} |
522 | 522 | 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(/<span( | )class=("|")wikiEditor-tab("|")><\/span>/g,'<span class="wikiEditor-tab"></span>').replace(/<p><\/p>/g,'<p><br></p>').replace(/&esc;&amp;nbsp;/g,'&nbsp;').replace(/&esc;&lt;p&gt;/g,'<p>').replace(/&esc;&lt;\/p&gt;/g,'</p>').replace(/&esc;&lt;span&nbsp;class=&quot;wikiEditor-tab&quot;&gt;&lt;\/span&gt;/g,'<span class="wikiEditor-tab"><\/span>').replace(/&esc;esc;/g,'&esc;');context.$content.html(html);if($('body').is('.rtl')){context.$content.addClass('rtl').attr('dir','rtl');} |
523 | | -context.$textarea.attr('disabled',true);context.$textarea.hide();context.$iframe.show();context.fn.trigger('ready');context.oldHTML=context.oldDelayedHTML=context.$content.html();$(context.$iframe[0].contentWindow.document).bind('keydown',function(event){return context.fn.trigger('keydown',event);}).bind('paste',function(event){return context.fn.trigger('paste',event);}).bind('cut',function(event){return context.fn.trigger('cut',event);}).bind('keyup paste mouseup cut encapsulateSelection',function(event){return context.fn.trigger('change',event);}).delayedBind(250,'keyup paste mouseup 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'));if(context.fallbackWindowOnBeforeUnload){return context.fallbackWindowOnBeforeUnload();}};},'getContents':function(){var html;if($.browser.msie){var $c=$(context.$content.get(0).cloneNode(true));$c.find('p').each(function(){if($(this).html()==''){$(this).replaceWith('<p></p>');}});html=$c.html();}else{html=context.$content.html();} |
| 523 | +context.$textarea.attr('disabled',true);context.$textarea.hide();context.$iframe.show();context.fn.trigger('ready');context.oldHTML=context.oldDelayedHTML=context.$content.html();$(context.$iframe[0].contentWindow.document).bind('keydown',function(event){var $cElem=context.fn.getElementAtCursor();event.jQueryNode=$cElem |
| 524 | +return context.fn.trigger('keydown',event);}).bind('paste',function(event){return context.fn.trigger('paste',event);}).bind('cut',function(event){return context.fn.trigger('cut',event);}).bind('keyup paste mouseup cut encapsulateSelection',function(event){return context.fn.trigger('change',event);}).delayedBind(250,'keyup paste mouseup 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'));if(context.fallbackWindowOnBeforeUnload){return context.fallbackWindowOnBeforeUnload();}};},'getElementAtCursor':function(){if(context.$iframe[0].contentWindow.getSelection){var selection=context.$iframe[0].contentWindow.getSelection();if(selection.rangeCount==0){return null;} |
| 525 | +var sc=selection.getRangeAt(0).startContainer;return $(sc.parentNode).eq(0);} |
| 526 | +else return null;},'getContents':function(){var html;if($.browser.msie){var $c=$(context.$content.get(0).cloneNode(true));$c.find('p').each(function(){if($(this).html()==''){$(this).replaceWith('<p></p>');}});html=$c.html();}else{html=context.$content.html();} |
524 | 527 | return context.fn.htmlToText(html);},'getSelection':function(){var retval;if(context.$iframe[0].contentWindow.getSelection){retval=context.$iframe[0].contentWindow.getSelection();if($.browser.opera){if(retval.rangeCount>0){retval=context.fn.htmlToText($('<pre />').append(retval.getRangeAt(0).cloneContents()).html());}else{retval='';}}}else if(context.$iframe[0].contentWindow.document.selection){retval=context.$iframe[0].contentWindow.document.selection.createRange();} |
525 | 528 | if(typeof retval.text!='undefined'){retval=context.fn.htmlToText(retval.htmlText);}else if(typeof retval.toString!='undefined'){retval=retval.toString();} |
526 | 529 | return retval;},'encapsulateSelection':function(options){var selText=$(this).textSelection('getSelection');var selTextArr;var collapseToEnd=false;var selectAfter=false;var setSelectionTo=null;var pre=options.pre,post=options.post;if(!selText){selText=options.peri;selectAfter=true;}else if(options.peri==selText.replace(/\s+$/,'')){selText=selText.replace(/\s+$/,'');collapseToEnd=true;selectAfter=true;}else if(options.replace){selText=options.peri;}else if(selText.charAt(selText.length-1)==' '){selText=selText.substring(0,selText.length-1);post+=' ';} |
— | — | @@ -647,7 +650,7 @@ |
648 | 651 | if(tokenIndex<tokenArray.length){var beginIndex=tokenIndex;var endIndex=-1;var openTemplates=1;var templatesMatched=false;while(tokenIndex<tokenArray.length-1&&endIndex==-1){tokenIndex++;if(tokenArray[tokenIndex].label=='TEMPLATE_BEGIN'){openTemplates++;}else if(tokenArray[tokenIndex].label=='TEMPLATE_END'){openTemplates--;if(openTemplates==0){endIndex=tokenIndex;}}} |
649 | 652 | if(endIndex!=-1){markers.push({start:tokenArray[beginIndex].offset,end:tokenArray[endIndex].offset,type:'template',anchor:'wrap',afterWrap:function(node){var model=$.wikiEditor.modules.templateEditor.fn.updateModel($(node));if(model.isCollapsible()){$.wikiEditor.modules.templateEditor.fn.wrapTemplate($(node));$.wikiEditor.modules.templateEditor.fn.bindTemplateEvents($(node));}else{$(node).addClass('wikiEditor-template-text');}},beforeUnwrap:function(node){if($(node).parent().hasClass('wikiEditor-template')){$.wikiEditor.modules.templateEditor.fn.unwrapTemplate($(node));}},onSkip:function(node){if($(node).html()==$(node).data('oldHTML')){return;} |
650 | 653 | var model=$.wikiEditor.modules.templateEditor.fn.updateModel($(node));if($(node).parent().hasClass('wikiEditor-template')){var $name=$(node).parent().children('.wikiEditor-template-name');if($name.text()!=model.getName()){$name.text(model.getName());}} |
651 | | -if($(node).parent().hasClass('wikiEditor-template')&&!model.isCollapsible()){$.wikiEditor.modules.templateEditor.fn.unwrapTemplate($(node));}else if(!$(node).parent().hasClass('wikiEditor-template')&&model.isCollapsible()){$.wikiEditor.modules.templateEditor.fn.wrapTemplate($(node));$.wikiEditor.modules.templateEditor.fn.bindTemplateEvents($(node));}},getAnchor:function(ca1,ca2){return $(ca1.parentNode).is('span.wikiEditor-template-text')?ca1.parentNode:null;},context:context});}else{tokenArray[beginIndex].label='TEMPLATE_FALSE_BEGIN';tokenIndex=beginIndex;}}}}},exp:[{'regex':/{{/,'label':"TEMPLATE_BEGIN"},{'regex':/}}/,'label':"TEMPLATE_END",'markAfter':true}],cfg:{},fn:{create:function(context,config){context.modules.templateEditor={};},wrapTemplate:function($wrapper){var model=$wrapper.data('model');var context=$wrapper.data('marker').context;var $template=$wrapper.wrap('<span class="wikiEditor-template"></span>').addClass('wikiEditor-template-text wikiEditor-nodisplay').parent().addClass('wikiEditor-template-collapsed');var $templateName=$('<span />').addClass('wikiEditor-template-name wikiEditor-noinclude').text(model.getName()).prependTo($template);var $templateExpand=$('<span />').addClass('wikiEditor-template-expand wikiEditor-noinclude').prependTo($template);var $templateDialog=$('<span />').addClass('wikiEditor-template-dialog wikiEditor-noinclude').appendTo($templateName);},unwrapTemplate:function($wrapper){$wrapper.parent().replaceWith($wrapper);},bindTemplateEvents:function($wrapper){var $template=$wrapper.parent('.wikiEditor-template');$template.find('.wikiEditor-template-name').click(function(){$.wikiEditor.modules.templateEditor.fn.createDialog($wrapper);return false;}).mousedown(function(){return false;});$template.find('.wikiEditor-template-expand').click(function(){$.wikiEditor.modules.templateEditor.fn.toggleWikiTextEditor($wrapper);return false;}).mousedown(function(){return false;});$template.find('.wikiEditor-template-dialog').click(function(){$.wikiEditor.modules.templateEditor.fn.createDialog($wrapper);return false;}).mousedown(function(){return false;});},toggleWikiTextEditor:function($wrapper){var context=$wrapper.data('marker').context;var $template=$wrapper.parent('.wikiEditor-template');context.fn.purgeOffsets();$template.toggleClass('wikiEditor-template-expanded').toggleClass('wikiEditor-template-collapsed').find('.wikiEditor-template-text').toggleClass('wikiEditor-nodisplay');},createDialog:function($wrapper){var context=$wrapper.data('marker').context;var $template=$wrapper.parent('.wikiEditor-template');var dialog={'titleMsg':'wikieditor-template-editor-dialog-title','id':'wikiEditor-template-dialog','html':'\ |
| 654 | +if($(node).parent().hasClass('wikiEditor-template')&&!model.isCollapsible()){$.wikiEditor.modules.templateEditor.fn.unwrapTemplate($(node));}else if(!$(node).parent().hasClass('wikiEditor-template')&&model.isCollapsible()){$.wikiEditor.modules.templateEditor.fn.wrapTemplate($(node));$.wikiEditor.modules.templateEditor.fn.bindTemplateEvents($(node));}},getAnchor:function(ca1,ca2){return $(ca1.parentNode).is('span.wikiEditor-template-text')?ca1.parentNode:null;},context:context});}else{tokenArray[beginIndex].label='TEMPLATE_FALSE_BEGIN';tokenIndex=beginIndex;}}}},keydown:function(context,event){var $evtElem=event.jQueryNode;if($evtElem){if($evtElem.hasClass('wikiEditor-template-name')){switch(event.which){case 37:case 38:case 39:case 40:return true;default:return false;}}}}},exp:[{'regex':/{{/,'label':"TEMPLATE_BEGIN"},{'regex':/}}/,'label':"TEMPLATE_END",'markAfter':true}],cfg:{},fn:{create:function(context,config){context.modules.templateEditor={};},wrapTemplate:function($wrapper){var model=$wrapper.data('model');var context=$wrapper.data('marker').context;var $template=$wrapper.wrap('<span class="wikiEditor-template"></span>').addClass('wikiEditor-template-text wikiEditor-nodisplay').parent().addClass('wikiEditor-template-collapsed');var $templateName=$('<span />').addClass('wikiEditor-template-name wikiEditor-noinclude').text(model.getName()).prependTo($template);var $templateExpand=$('<span />').addClass('wikiEditor-template-expand wikiEditor-noinclude').prependTo($template);var $templateDialog=$('<span />').addClass('wikiEditor-template-dialog wikiEditor-noinclude').appendTo($templateName);},unwrapTemplate:function($wrapper){$wrapper.parent().replaceWith($wrapper);},bindTemplateEvents:function($wrapper){var $template=$wrapper.parent('.wikiEditor-template');$template.find('.wikiEditor-template-name').click(function(){$.wikiEditor.modules.templateEditor.fn.createDialog($wrapper);return false;}).mousedown(function(){return false;}).data("keydownHandler",function(){console.log("CARLOS!");});$template.find('.wikiEditor-template-expand').click(function(){$.wikiEditor.modules.templateEditor.fn.toggleWikiTextEditor($wrapper);return false;}).mousedown(function(){return false;});$template.find('.wikiEditor-template-dialog').click(function(){$.wikiEditor.modules.templateEditor.fn.createDialog($wrapper);return false;}).mousedown(function(){return false;});},toggleWikiTextEditor:function($wrapper){var context=$wrapper.data('marker').context;var $template=$wrapper.parent('.wikiEditor-template');context.fn.purgeOffsets();$template.toggleClass('wikiEditor-template-expanded').toggleClass('wikiEditor-template-collapsed').find('.wikiEditor-template-text').toggleClass('wikiEditor-nodisplay');},createDialog:function($wrapper){var context=$wrapper.data('marker').context;var $template=$wrapper.parent('.wikiEditor-template');var dialog={'titleMsg':'wikieditor-template-editor-dialog-title','id':'wikiEditor-template-dialog','html':'\ |
652 | 655 | <fieldset>\ |
653 | 656 | <div class="wikiEditor-template-dialog-title" />\ |
654 | 657 | <div class="wikiEditor-template-dialog-fields" />\ |