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' => 171 ), |
| 76 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 172 ), |
77 | 77 | array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 43 ), |
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' => 57 ), |
| 82 | + array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 58 ), |
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' => 337 ), |
| 86 | + array( 'src' => 'js/plugins.combined.js', 'version' => 338 ), |
87 | 87 | ), |
88 | 88 | 'minified' => array( |
89 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 337 ), |
| 89 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 338 ), |
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js |
— | — | @@ -33,7 +33,6 @@ |
34 | 34 | var tokenArray = context.modules.highlight.tokenArray; |
35 | 35 | // Collect matching level 0 template call boundaries from the tokenArray |
36 | 36 | var level = 0; |
37 | | - |
38 | 37 | var tokenIndex = 0; |
39 | 38 | while ( tokenIndex < tokenArray.length ){ |
40 | 39 | while ( tokenIndex < tokenArray.length && tokenArray[tokenIndex].label != 'TEMPLATE_BEGIN' ) { |
— | — | @@ -139,6 +138,8 @@ |
140 | 139 | } else if ( $evtElem.hasClass( 'wikiEditor-template-text' ) ) { |
141 | 140 | switch ( event.which ) { |
142 | 141 | case 13: //enter |
| 142 | + // Ensure that the user can't break this by holding in the enter key |
| 143 | + context.$iframe.data( 'ignoreKeypress', true ); |
143 | 144 | //FIXME: may be a more elegant way to do this, but this works too |
144 | 145 | context.fn.encapsulateSelection( { 'pre':'\n', 'peri':'', 'post':'' } ); |
145 | 146 | return false; |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -1174,7 +1174,8 @@ |
1175 | 1175 | return $( [] ); |
1176 | 1176 | } |
1177 | 1177 | var sc = selection.getRangeAt( 0 ).startContainer; |
1178 | | - return $( sc.parentNode ); |
| 1178 | + if ( sc.nodeName == "#text" ) sc = sc.parentNode; |
| 1179 | + return $( sc ); |
1179 | 1180 | } else { |
1180 | 1181 | return $( [] ); |
1181 | 1182 | } |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -7717,7 +7717,8 @@ |
7718 | 7718 | return $( [] ); |
7719 | 7719 | } |
7720 | 7720 | var sc = selection.getRangeAt( 0 ).startContainer; |
7721 | | - return $( sc.parentNode ); |
| 7721 | + if ( sc.nodeName == "#text" ) sc = sc.parentNode; |
| 7722 | + return $( sc ); |
7722 | 7723 | } else { |
7723 | 7724 | return $( [] ); |
7724 | 7725 | } |
— | — | @@ -9277,7 +9278,6 @@ |
9278 | 9279 | var tokenArray = context.modules.highlight.tokenArray; |
9279 | 9280 | // Collect matching level 0 template call boundaries from the tokenArray |
9280 | 9281 | var level = 0; |
9281 | | - |
9282 | 9282 | var tokenIndex = 0; |
9283 | 9283 | while ( tokenIndex < tokenArray.length ){ |
9284 | 9284 | while ( tokenIndex < tokenArray.length && tokenArray[tokenIndex].label != 'TEMPLATE_BEGIN' ) { |
— | — | @@ -9383,6 +9383,8 @@ |
9384 | 9384 | } else if ( $evtElem.hasClass( 'wikiEditor-template-text' ) ) { |
9385 | 9385 | switch ( event.which ) { |
9386 | 9386 | case 13: //enter |
| 9387 | + // Ensure that the user can't break this by holding in the enter key |
| 9388 | + context.$iframe.data( 'ignoreKeypress', true ); |
9387 | 9389 | //FIXME: may be a more elegant way to do this, but this works too |
9388 | 9390 | context.fn.encapsulateSelection( { 'pre':'\n', 'peri':'', 'post':'' } ); |
9389 | 9391 | return false; |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -521,7 +521,7 @@ |
522 | 522 | 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 ");}} |
523 | 523 | 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');} |
524 | 524 | 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){event.jQueryNode=context.fn.getElementAtCursor();return context.fn.trigger('keydown',event);}).bind('keyup',function(event){event.jQueryNode=context.fn.getElementAtCursor();return context.fn.trigger('keyup',event);}).bind('keypress',function(event){event.jQueryNode=context.fn.getElementAtCursor();return context.fn.trigger('keypress',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 $([]);} |
525 | | -var sc=selection.getRangeAt(0).startContainer;return $(sc.parentNode);}else{return $([]);}},'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();} |
| 525 | +var sc=selection.getRangeAt(0).startContainer;if(sc.nodeName=="#text")sc=sc.parentNode;return $(sc);}else{return $([]);}},'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();} |
526 | 526 | 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();} |
527 | 527 | if(typeof retval.text!='undefined'){retval=context.fn.htmlToText(retval.htmlText);}else if(typeof retval.toString!='undefined'){retval=retval.toString();} |
528 | 528 | 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+=' ';} |
— | — | @@ -646,7 +646,7 @@ |
647 | 647 | 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;}}} |
648 | 648 | 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;} |
649 | 649 | var model=$.wikiEditor.modules.templateEditor.fn.updateModel($(node));if($(node).parent().hasClass('wikiEditor-template')){var $label=$(node).parent().find('.wikiEditor-template-label');if($label.text()!=model.getName()){$label.text(model.getName());}} |
650 | | -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){if(context.$iframe.data('ignoreKeypress'))context.$iframe.data('ignoreKeypress',false);var $evtElem=event.jQueryNode;if($evtElem.hasClass('wikiEditor-template-name')){if(event.ctrlKey||event.metaKey)return true;switch(event.which){case 37:case 38:case 39:case 40:return true;default:context.$iframe.data('ignoreKeypress',true);return false;}}else if($evtElem.hasClass('wikiEditor-template-text')){switch(event.which){case 13:context.fn.encapsulateSelection({'pre':'\n','peri':'','post':''});return false;default:return true;}}},keyup:function(context,event){if(context.$iframe.data('ignoreKeypress'))context.$iframe.data('ignoreKeypress',false);return true;},keypress:function(context,event){return(context.$iframe.data('ignoreKeypress')?false:true);}},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').prepend($('<span class="wikiEditor-template-expand wikiEditor-noinclude"></span>'+'<span class="wikiEditor-template-name wikiEditor-noinclude">'+'<span class="wikiEditor-template-label wikiEditor-noinclude">'+model.getName()+'</span>'+'<span class="wikiEditor-template-dialog wikiEditor-noinclude"></span>'+'</span>'));},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;});},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':'\ |
| 650 | +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){if(context.$iframe.data('ignoreKeypress'))context.$iframe.data('ignoreKeypress',false);var $evtElem=event.jQueryNode;if($evtElem.hasClass('wikiEditor-template-name')){if(event.ctrlKey||event.metaKey)return true;switch(event.which){case 37:case 38:case 39:case 40:return true;default:context.$iframe.data('ignoreKeypress',true);return false;}}else if($evtElem.hasClass('wikiEditor-template-text')){switch(event.which){case 13:context.$iframe.data('ignoreKeypress',true);context.fn.encapsulateSelection({'pre':'\n','peri':'','post':''});return false;default:return true;}}},keyup:function(context,event){if(context.$iframe.data('ignoreKeypress'))context.$iframe.data('ignoreKeypress',false);return true;},keypress:function(context,event){return(context.$iframe.data('ignoreKeypress')?false:true);}},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').prepend($('<span class="wikiEditor-template-expand wikiEditor-noinclude"></span>'+'<span class="wikiEditor-template-name wikiEditor-noinclude">'+'<span class="wikiEditor-template-label wikiEditor-noinclude">'+model.getName()+'</span>'+'<span class="wikiEditor-template-dialog wikiEditor-noinclude"></span>'+'</span>'));},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;});},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':'\ |
651 | 651 | <fieldset>\ |
652 | 652 | <div class="wikiEditor-template-dialog-title" />\ |
653 | 653 | <div class="wikiEditor-template-dialog-fields" />\ |