Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | array( 'src' => 'js/plugins/jquery.namespaceSelect.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' => 101 ), |
| 76 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 102 ), |
77 | 77 | array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 29 ), |
78 | 78 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 47 ), |
79 | 79 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 12 ), |
— | — | @@ -82,10 +82,10 @@ |
83 | 83 | array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 2 ), |
84 | 84 | ), |
85 | 85 | 'combined' => array( |
86 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 218 ), |
| 86 | + array( 'src' => 'js/plugins.combined.js', 'version' => 219 ), |
87 | 87 | ), |
88 | 88 | 'minified' => array( |
89 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 218 ), |
| 89 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 219 ), |
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -311,7 +311,6 @@ |
312 | 312 | context.fn.purgeOffsets(); |
313 | 313 | context.oldHTML = newHTML; |
314 | 314 | event.data.scope = 'realchange'; |
315 | | - context.historyPosition = -1; |
316 | 315 | } |
317 | 316 | // Are we deleting a <p> with one keystroke? if so, either remove preceding <br> or merge <p>s |
318 | 317 | switch ( event.which ) { |
— | — | @@ -330,6 +329,10 @@ |
331 | 330 | event.data.scope = 'realchange'; |
332 | 331 | // Save in the history |
333 | 332 | //console.log( 'save-state' ); |
| 333 | + // Only reset the historyPosition and begin moving forward if this change is not the result of undo |
| 334 | + if ( newHTML !== context.history[context.history.length + context.historyPosition].html ) { |
| 335 | + context.historyPosition = -1; |
| 336 | + } |
334 | 337 | context.history.push( { 'html': newHTML } ); |
335 | 338 | // Keep the history under control |
336 | 339 | while ( context.history.length > 10 ) { |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -6744,7 +6744,6 @@ |
6745 | 6745 | context.fn.purgeOffsets(); |
6746 | 6746 | context.oldHTML = newHTML; |
6747 | 6747 | event.data.scope = 'realchange'; |
6748 | | - context.historyPosition = -1; |
6749 | 6748 | } |
6750 | 6749 | // Are we deleting a <p> with one keystroke? if so, either remove preceding <br> or merge <p>s |
6751 | 6750 | switch ( event.which ) { |
— | — | @@ -6763,6 +6762,10 @@ |
6764 | 6763 | event.data.scope = 'realchange'; |
6765 | 6764 | // Save in the history |
6766 | 6765 | //console.log( 'save-state' ); |
| 6766 | + // Only reset the historyPosition and begin moving forward if this change is not the result of undo |
| 6767 | + if ( newHTML !== context.history[context.history.length + context.historyPosition].html ) { |
| 6768 | + context.historyPosition = -1; |
| 6769 | + } |
6767 | 6770 | context.history.push( { 'html': newHTML } ); |
6768 | 6771 | // Keep the history under control |
6769 | 6772 | while ( context.history.length > 10 ) { |
— | — | @@ -6875,9 +6878,11 @@ |
6876 | 6879 | html = html |
6877 | 6880 | .replace( /\r?\n/g, "" ) // IE7 inserts newlines before block elements |
6878 | 6881 | .replace( / /g, " " ) // We inserted these to prevent IE from collapsing spaces |
| 6882 | + .replace( /\<br[^\>]*\>\s*\<\/p\>/gi, '</p>' ) // Remove trailing <br> from <p> |
| 6883 | + .replace( /\<p[^\>]*\>\s*\<\/p\>/gi, '' ) // Collapse empty <p> |
| 6884 | + .replace( /\<\/p\>\s*\<p[^\>]*\>/gi, "\n" ) // Easy case for <p> conversion |
6879 | 6885 | .replace( /\<br[^\>]*\>/gi, "\n" ) // <br> conversion |
6880 | | - .replace( /\<\/p\>\<p\>/gi, "\n" ) // Easy case for <p> conversion |
6881 | | - .replace( /\<\/p\>(\n*)\<p\>/gi, "$1\n" ); |
| 6886 | + .replace( /\<\/p\>(\n*)\<p[^\>]*\>/gi, "$1\n" ); |
6882 | 6887 | // Save leading and trailing whitespace now and restore it later. IE eats it all, and even Firefox |
6883 | 6888 | // won't leave everything alone |
6884 | 6889 | var leading = html.match( /^\s*/ )[0]; |
— | — | @@ -8589,6 +8594,9 @@ |
8590 | 8595 | $template.data( 'model' , model ); |
8591 | 8596 | $template.children( '.wikiEditor-template-name' ).text( model.getName() ); |
8592 | 8597 | } |
| 8598 | + else{ //we just expanded this |
| 8599 | + $wikitext.text($template.data('model').getText()); |
| 8600 | + } |
8593 | 8601 | |
8594 | 8602 | return false; |
8595 | 8603 | }; |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -448,9 +448,10 @@ |
449 | 449 | if(context.history.length+context.historyPosition>=0&&context.historyPosition<0){context.$content.html(context.history[context.history.length+context.historyPosition].html);}else{context.historyPosition=Math.max(-context.history.length,Math.min(context.historyPosition,-1));} |
450 | 450 | return false;} |
451 | 451 | break;} |
452 | | -return true;},'change':function(event){event.data.scope='division';var newHTML=context.$content.html();if(context.oldHTML!=newHTML){context.fn.purgeOffsets();context.oldHTML=newHTML;event.data.scope='realchange';context.historyPosition=-1;} |
| 452 | +return true;},'change':function(event){event.data.scope='division';var newHTML=context.$content.html();if(context.oldHTML!=newHTML){context.fn.purgeOffsets();context.oldHTML=newHTML;event.data.scope='realchange';} |
453 | 453 | switch(event.which){case 8:break;} |
454 | | -return true;},'delayedChange':function(event){event.data.scope='division';var newHTML=context.$content.html();if(context.oldDelayedHTML!=newHTML){context.fn.purgeOffsets();context.oldDelayedHTML=newHTML;event.data.scope='realchange';context.history.push({'html':newHTML});while(context.history.length>10){context.history.shift();}} |
| 454 | +return true;},'delayedChange':function(event){event.data.scope='division';var newHTML=context.$content.html();if(context.oldDelayedHTML!=newHTML){context.fn.purgeOffsets();context.oldDelayedHTML=newHTML;event.data.scope='realchange';if(newHTML!==context.history[context.history.length+context.historyPosition].html){context.historyPosition=-1;} |
| 455 | +context.history.push({'html':newHTML});while(context.history.length>10){context.history.shift();}} |
455 | 456 | return true;}};context.fn={'trigger':function(name,event){if(typeof event=='undefined'){event={'type':'custom'};} |
456 | 457 | if(typeof event.data=='undefined'){event.data={};} |
457 | 458 | if(name in context.evt){if(!context.evt[name](event)){return false;}} |
— | — | @@ -459,7 +460,7 @@ |
460 | 461 | event.preventDefault();return false;}).text($.wikiEditor.autoMsg(options,'title'))).appendTo(context.$tabs);} |
461 | 462 | if(!context.$tabs.children().size()){addTab({'name':'wikitext','titleMsg':'wikieditor-wikitext-tab'});} |
462 | 463 | addTab(options);return $('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-'+options.name).hide().appendTo(context.$ui);},'htmlToText':function(html){if(html in context.htmlToTextMap){return context.htmlToTextMap[html];} |
463 | | -var origHTML=html;html=html.replace(/\r?\n/g,"").replace(/ /g," ").replace(/\<br[^\>]*\>/gi,"\n").replace(/\<\/p\>\<p\>/gi,"\n").replace(/\<\/p\>(\n*)\<p\>/gi,"$1\n");var leading=html.match(/^\s*/)[0];var trailing=html.match(/\s*$/)[0];html=html.substr(leading.length,html.length-leading.length-trailing.length);var $pre=$('<pre>'+html+'</pre>');$pre.find('.wikiEditor-noinclude').each(function(){$(this).remove();});$pre.find('.wikiEditor-tab').each(function(){$(this).text("\t");});$pre.find('br').each(function(){$(this).replaceWith("\n");});$pre.find('p').each(function(){var text=$(this).text();var t=new context.fn.rawTraverser(this.firstChild,0,this,$pre.get(0)).prev();while(t&&t.node.nodeName!='#text'&&t.node.nodeName!='BR'&&t.node.nodeName!='P'){t=t.prev();} |
| 464 | +var origHTML=html;html=html.replace(/\r?\n/g,"").replace(/ /g," ").replace(/\<br[^\>]*\>\s*\<\/p\>/gi,'</p>').replace(/\<p[^\>]*\>\s*\<\/p\>/gi,'').replace(/\<\/p\>\s*\<p[^\>]*\>/gi,"\n").replace(/\<br[^\>]*\>/gi,"\n").replace(/\<\/p\>(\n*)\<p[^\>]*\>/gi,"$1\n");var leading=html.match(/^\s*/)[0];var trailing=html.match(/\s*$/)[0];html=html.substr(leading.length,html.length-leading.length-trailing.length);var $pre=$('<pre>'+html+'</pre>');$pre.find('.wikiEditor-noinclude').each(function(){$(this).remove();});$pre.find('.wikiEditor-tab').each(function(){$(this).text("\t");});$pre.find('br').each(function(){$(this).replaceWith("\n");});$pre.find('p').each(function(){var text=$(this).text();var t=new context.fn.rawTraverser(this.firstChild,0,this,$pre.get(0)).prev();while(t&&t.node.nodeName!='#text'&&t.node.nodeName!='BR'&&t.node.nodeName!='P'){t=t.prev();} |
464 | 465 | if(t){text="\n"+text;} |
465 | 466 | t=new context.fn.rawTraverser(this.lastChild,0,this,$pre.get(0)).next();while(t&&t.node.nodeName!='#text'&&t.node.nodeName!='BR'&&t.node.nodeName!='P'){t=t.next();} |
466 | 467 | if(t&&!t.inP&&t.node.nodeName=='#text'&&t.node.nodeValue.charAt(0)!='\n'&&t.node.nodeValue.charAt(0)!='\r'){text+="\n";} |
— | — | @@ -587,6 +588,7 @@ |
588 | 589 | if(endIndex!=-1){markers.push({start:tokenArray[beginIndex].offset,end:tokenArray[endIndex].offset,type:'template',anchor:'wrap',afterWrap:$.wikiEditor.modules.templateEditor.fn.stylize,beforeUnwrap:function(node){$(node).data('display').remove();},onSkip:function(){},getAnchor:function(ca1,ca2){return $(ca1.parentNode).is('div.wikiEditor-template-text')&&$(ca1.parentNode.previousSibling).is('ul.wikiEditor-template-modes')&&ca1.parentNode.nextSibling==null?ca1.parentNode:null;}});}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={};},stylize:function(wrappedTemplate){$(wrappedTemplate).each(function(){if(typeof $(this).data('model')!='undefined'){return;} |
589 | 590 | var model=new $.wikiEditor.modules.templateEditor.fn.model($(this).text());if(!model.isCollapsible()){return;} |
590 | 591 | var $template=$(this).wrap('<div class="wikiEditor-template"></div>').addClass('wikiEditor-template-text wikiEditor-nodisplay').parent().addClass('wikiEditor-template-collapsed').data('model',model);$('<span />').addClass('wikiEditor-template-name wikiEditor-noinclude').text(model.getName()).mousedown(function(){createDialog($template);}).prependTo($template);var $options=$('<ul />').addClass('wikiEditor-template-modes wikiEditor-noinclude').append($('<li />').addClass('wikiEditor-template-action-wikiText').append($('<img />').attr('src',$.wikiEditor.imgPath+'templateEditor/'+'wiki-text.png')).mousedown(toggleWikiTextEditor)).insertAfter($template.find('.wikiEditor-template-name'));function toggleWikiTextEditor(){var $template=$(this).closest('.wikiEditor-template');$template.toggleClass('wikiEditor-template-expanded').toggleClass('wikiEditor-template-collapsed');var $wikitext=$template.children('.wikiEditor-template-text');$wikitext.toggleClass('wikiEditor-nodisplay');if($template.hasClass('wikiEditor-template-collapsed')){var model=new $.wikiEditor.modules.templateEditor.fn.model($template.children('.wikiEditor-template-text').text());$template.data('model',model);$template.children('.wikiEditor-template-name').text(model.getName());} |
| 592 | +else{$wikitext.text($template.data('model').getText());} |
591 | 593 | return false;};function expandTemplate($displayDiv){$displayDiv.removeClass('wikiEditor-template-collapsed');$displayDiv.addClass('wikiEditor-template-expanded');$displayDiv.unbind('mousedown');$keyValueTable=$('<table />').appendTo($displayDiv);$header_row=$('<tr />').appendTo($keyValueTable);$('<th />').attr('colspan','2').text(model.getName()).appendTo($header_row);for(param in model.getAllParamNames()){$keyVal_row=$('<tr />').appendTo($keyValueTable);$('<td />').text(param).appendTo($keyVal_row);$('<td />').text(model.getValue(param)).appendTo($keyVal_row);}};function collapseTemplate($displayDiv){$displayDiv.addClass('wikiEditor-template-collapsed');$displayDiv.removeClass('wikiEditor-template-expanded');$displayDiv.text(model.getName());};function createDialog($templateDiv){var templateModel=$templateDiv.data('model');console.log(templateModel.getText());var $dialog=$("<div></div>");var $title=$("<div>"+templateModel.getName()+"</div>").addClass('wikiEditor-template-dialog-title');var $table=$("<table></table>").addClass('wikiEditor-template-dialog-table').appendTo($dialog);var allInitialParams=templateModel.getAllInitialParams();for(var paramIndex in allInitialParams){var param=allInitialParams[paramIndex];if(typeof param.name=='undefined'){continue;} |
592 | 594 | var $paramRow=$("<tr></tr>").addClass('wikiEditor-template-dialog-row');var $paramName=$("<td></td>").addClass('wikiEditor-template-dialog-name').text(param.name);var $paramVal=$("<td></td>").addClass('wikiEditor-template-dialog-value');var $paramInput=$("<input></input>").data('name',param.name).val(templateModel.getValue(param.name));$paramVal.append($paramInput);$paramRow.append($paramName).append($paramVal);$table.append($paramRow);} |
593 | 595 | $("<button></button>").click(function(){$('.wikiEditor-template-dialog-value input').each(function(){templateModel.setValue($(this).data('name'),$(this).val());});$dialog.dialog('close');}).text("OK").appendTo($dialog);$dialog.dialog();return false;};function toggleWikiText(){var $template=$(this).closest('.wikiEditor-template');$template.toggleClass('wikiEditor-template-collapsed').toggleClass('wikiEditor-template-expanded').children('.wikiEditor-template-text, .wikiEditor-template-name, .wikiEditor-template-modes').toggleClass('wikiEditor-nodisplay');if($template.hasClass('wikiEditor-template-collapsed')){var model=new $.wikiEditor.modules.templateEditor.fn.model($template.children('.wikiEditor-template-text').text());$template.data('model',model);$template.children('.wikiEditor-template-name').text(model.getName());} |