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' => 160 ), |
| 76 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 161 ), |
77 | 77 | array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 37 ), |
78 | 78 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 52 ), |
79 | 79 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 19 ), |
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' => 40 ), |
| 82 | + array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 41 ), |
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' => 309 ), |
| 86 | + array( 'src' => 'js/plugins.combined.js', 'version' => 310 ), |
87 | 87 | ), |
88 | 88 | 'minified' => array( |
89 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 309 ), |
| 89 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 310 ), |
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js |
— | — | @@ -231,7 +231,7 @@ |
232 | 232 | // Build the table |
233 | 233 | // TODO: Be smart and recycle existing table |
234 | 234 | var params = templateModel.getAllInitialParams(); |
235 | | - var $fields = $( this ).find( '.wikiEditor-template-dialog-fields' ).empty(); |
| 235 | + var $fields = $( this ).find( '.wikiEditor-template-dialog-fields' ); |
236 | 236 | // Do some bookkeeping so we can recycle existing rows |
237 | 237 | var $rows = $fields.find( '.wikiEditor-template-dialog-field-wrapper' ); |
238 | 238 | for ( var paramIndex in params ) { |
— | — | @@ -248,7 +248,10 @@ |
249 | 249 | // We have another row to recycle |
250 | 250 | var $row = $rows.eq( 0 ); |
251 | 251 | $row.children( 'label' ).text( paramText ); |
252 | | - $row.children( 'input' ).val( paramVal ); |
| 252 | + $row.children( 'textarea' ) |
| 253 | + .data( 'name', param.name ) |
| 254 | + .val( paramVal ) |
| 255 | + .change(); |
253 | 256 | $rows = $rows.not( $row ); |
254 | 257 | } else { |
255 | 258 | // Create a new row |
— | — | @@ -260,8 +263,9 @@ |
261 | 264 | $( '<textarea />' ) |
262 | 265 | .data( 'name', param.name ) |
263 | 266 | .val( paramVal ) |
264 | | - .bind( 'cut paste keypress click', function() { |
265 | | - $this = $(this); |
| 267 | + .data( 'expanded', false ) |
| 268 | + .bind( 'cut paste keypress click change', function() { |
| 269 | + var $this = $(this); |
266 | 270 | setTimeout( function() { |
267 | 271 | var expanded = $this.data( 'expanded' ); |
268 | 272 | if ( $this.val().length > 24 ) { |
— | — | @@ -278,14 +282,15 @@ |
279 | 283 | }, 0 ); |
280 | 284 | } ) |
281 | 285 | .appendTo( $paramRow ); |
282 | | - $( '<div style="clear:both"></div>' ) |
283 | | - .appendTo( $paramRow ); |
284 | | - $fields.append( $paramRow ); |
| 286 | + $paramRow |
| 287 | + .append( '<div style="clear:both"></div>' ) |
| 288 | + .appendTo( $fields ); |
285 | 289 | } |
286 | | - // Remove any leftover rows |
287 | | - $rows.remove(); |
288 | | - $fields.find( 'label' ).autoEllipsis(); |
289 | 290 | } |
| 291 | + |
| 292 | + // Remove any leftover rows |
| 293 | + $rows.remove(); |
| 294 | + $fields.find( 'label' ).autoEllipsis(); |
290 | 295 | // Ensure our close button doesn't recieve the ui-state-focus class |
291 | 296 | $( this ).parent( '.ui-dialog' ).find( '.ui-dialog-titlebar-close' ) |
292 | 297 | .removeClass( 'ui-state-focus' ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -443,7 +443,7 @@ |
444 | 444 | } |
445 | 445 | t = t.next(); |
446 | 446 | } |
447 | | - // MS Word + webkit |
| 447 | + // MS Word + webkit |
448 | 448 | context.$content.find( 'p:not(.wikiEditor) p:not(.wikiEditor)' ) |
449 | 449 | .each( function(){ |
450 | 450 | var outerParent = $(this).parent(); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js |
— | — | @@ -272,6 +272,8 @@ |
273 | 273 | } |
274 | 274 | lastP = t.inP; |
275 | 275 | } |
| 276 | + // Moving nodes around like this invalidates offset objects |
| 277 | + context.fn.purgeOffsets(); |
276 | 278 | } |
277 | 279 | |
278 | 280 | // Now wrap everything between startNode and endNode (may be equal). |
— | — | @@ -342,6 +344,10 @@ |
343 | 345 | $(this).replaceWith( this.childNodes ); |
344 | 346 | } |
345 | 347 | }); |
| 348 | + |
| 349 | + // Purge offsets after we're done |
| 350 | + // TODO: Ideally this is not needed |
| 351 | + context.fn.purgeOffsets(); |
346 | 352 | } |
347 | 353 | } |
348 | 354 | |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -6913,12 +6913,7 @@ |
6914 | 6914 | context.oldHTML = newHTML; |
6915 | 6915 | event.data.scope = 'realchange'; |
6916 | 6916 | } |
6917 | | - // Are we deleting a <p> with one keystroke? if so, either remove preceding <br> or merge <p>s |
6918 | | - switch ( event.which ) { |
6919 | | - case 8: // backspace |
6920 | | - // do something here... |
6921 | | - break; |
6922 | | - } |
| 6917 | + |
6923 | 6918 | return true; |
6924 | 6919 | }, |
6925 | 6920 | 'delayedChange': function( event ) { |
— | — | @@ -6928,6 +6923,17 @@ |
6929 | 6924 | context.oldDelayedHTML = newHTML; |
6930 | 6925 | event.data.scope = 'realchange'; |
6931 | 6926 | } |
| 6927 | + |
| 6928 | + //surround by <p> if it does not already have it |
| 6929 | + var t = context.fn.getOffset(); |
| 6930 | + if ( t.node.parentNode.nodeName.toLowerCase() == 'body' ) { |
| 6931 | + var cursorPos = context.fn.getCaretPosition()[0]; |
| 6932 | + $( t.node ).wrap( "<p></p>" ); |
| 6933 | + context.fn.refreshOffsets(); |
| 6934 | + context.fn.setSelection( { start: cursorPos, end: cursorPos } ); |
| 6935 | + } |
| 6936 | + |
| 6937 | + |
6932 | 6938 | context.fn.updateHistory( event.data.scope == 'realchange' ); |
6933 | 6939 | return true; |
6934 | 6940 | }, |
— | — | @@ -8107,10 +8113,10 @@ |
8108 | 8114 | end = e ? e.offset : null; |
8109 | 8115 | // Don't try to set the selection past the end of a node, causes errors |
8110 | 8116 | // Just put the selection at the end of the node in this case |
8111 | | - if ( sc.nodeName == '#text' && start >= sc.nodeValue.length ) { |
| 8117 | + if ( sc.nodeName == '#text' && start > sc.nodeValue.length ) { |
8112 | 8118 | start = sc.nodeValue.length - 1; |
8113 | 8119 | } |
8114 | | - if ( ec.nodeName == '#text' && end >= ec.nodeValue.length ) { |
| 8120 | + if ( ec.nodeName == '#text' && end > ec.nodeValue.length ) { |
8115 | 8121 | end = ec.nodeValue.length - 1; |
8116 | 8122 | } |
8117 | 8123 | } |
— | — | @@ -8728,6 +8734,8 @@ |
8729 | 8735 | } |
8730 | 8736 | lastP = t.inP; |
8731 | 8737 | } |
| 8738 | + // Moving nodes around like this invalidates offset objects |
| 8739 | + context.fn.purgeOffsets(); |
8732 | 8740 | } |
8733 | 8741 | |
8734 | 8742 | // Now wrap everything between startNode and endNode (may be equal). |
— | — | @@ -8798,6 +8806,10 @@ |
8799 | 8807 | $(this).replaceWith( this.childNodes ); |
8800 | 8808 | } |
8801 | 8809 | }); |
| 8810 | + |
| 8811 | + // Purge offsets after we're done |
| 8812 | + // TODO: Ideally this is not needed |
| 8813 | + context.fn.purgeOffsets(); |
8802 | 8814 | } |
8803 | 8815 | } |
8804 | 8816 | |
— | — | @@ -9333,7 +9345,7 @@ |
9334 | 9346 | // Build the table |
9335 | 9347 | // TODO: Be smart and recycle existing table |
9336 | 9348 | var params = templateModel.getAllInitialParams(); |
9337 | | - var $fields = $( this ).find( '.wikiEditor-template-dialog-fields' ).empty(); |
| 9349 | + var $fields = $( this ).find( '.wikiEditor-template-dialog-fields' ); |
9338 | 9350 | // Do some bookkeeping so we can recycle existing rows |
9339 | 9351 | var $rows = $fields.find( '.wikiEditor-template-dialog-field-wrapper' ); |
9340 | 9352 | for ( var paramIndex in params ) { |
— | — | @@ -9350,7 +9362,10 @@ |
9351 | 9363 | // We have another row to recycle |
9352 | 9364 | var $row = $rows.eq( 0 ); |
9353 | 9365 | $row.children( 'label' ).text( paramText ); |
9354 | | - $row.children( 'input' ).val( paramVal ); |
| 9366 | + $row.children( 'textarea' ) |
| 9367 | + .data( 'name', param.name ) |
| 9368 | + .val( paramVal ) |
| 9369 | + .change(); |
9355 | 9370 | $rows = $rows.not( $row ); |
9356 | 9371 | } else { |
9357 | 9372 | // Create a new row |
— | — | @@ -9362,8 +9377,9 @@ |
9363 | 9378 | $( '<textarea />' ) |
9364 | 9379 | .data( 'name', param.name ) |
9365 | 9380 | .val( paramVal ) |
9366 | | - .bind( 'cut paste keypress click', function() { |
9367 | | - $this = $(this); |
| 9381 | + .data( 'expanded', false ) |
| 9382 | + .bind( 'cut paste keypress click change', function() { |
| 9383 | + var $this = $(this); |
9368 | 9384 | setTimeout( function() { |
9369 | 9385 | var expanded = $this.data( 'expanded' ); |
9370 | 9386 | if ( $this.val().length > 24 ) { |
— | — | @@ -9380,14 +9396,15 @@ |
9381 | 9397 | }, 0 ); |
9382 | 9398 | } ) |
9383 | 9399 | .appendTo( $paramRow ); |
9384 | | - $( '<div style="clear:both"></div>' ) |
9385 | | - .appendTo( $paramRow ); |
9386 | | - $fields.append( $paramRow ); |
| 9400 | + $paramRow |
| 9401 | + .append( '<div style="clear:both"></div>' ) |
| 9402 | + .appendTo( $fields ); |
9387 | 9403 | } |
9388 | | - // Remove any leftover rows |
9389 | | - $rows.remove(); |
9390 | | - $fields.find( 'label' ).autoEllipsis(); |
9391 | 9404 | } |
| 9405 | + |
| 9406 | + // Remove any leftover rows |
| 9407 | + $rows.remove(); |
| 9408 | + $fields.find( 'label' ).autoEllipsis(); |
9392 | 9409 | // Ensure our close button doesn't recieve the ui-state-focus class |
9393 | 9410 | $( this ).parent( '.ui-dialog' ).find( '.ui-dialog-titlebar-close' ) |
9394 | 9411 | .removeClass( 'ui-state-focus' ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -460,8 +460,8 @@ |
461 | 461 | break;case 86:if(event.ctrlKey){context.evt.paste(event);} |
462 | 462 | break;} |
463 | 463 | 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';} |
464 | | -switch(event.which){case 8:break;} |
465 | 464 | return true;},'delayedChange':function(event){event.data.scope='division';var newHTML=context.$content.html();if(context.oldDelayedHTML!=newHTML){context.oldDelayedHTML=newHTML;event.data.scope='realchange';} |
| 465 | +var t=context.fn.getOffset();if(t.node.parentNode.nodeName.toLowerCase()=='body'){var cursorPos=context.fn.getCaretPosition()[0];$(t.node).wrap("<p></p>");context.fn.refreshOffsets();context.fn.setSelection({start:cursorPos,end:cursorPos});} |
466 | 466 | context.fn.updateHistory(event.data.scope=='realchange');return true;},'cut':function(event){setTimeout(function(){context.$content.find('br').each(function(){if($(this).parent().is('body')){$(this).wrap($('<p></p>'));}});},100);return true;},'paste':function(event){var cursorPos=context.fn.getCaretPosition();var oldLength=context.fn.getContents().length;context.$content.find(':not(.wikiEditor)').addClass('wikiEditor');if($.layout.name!=='webkit'){context.$content.addClass('pasting');} |
467 | 467 | setTimeout(function(){context.$content.find('script,style,img,input,select,textarea,hr,button,link,meta').remove();context.$content.find('*').each(function(){if($(this).children().length==0&&this.childNodes.length>0){$(this).text($(this).text());}});var t=context.fn.traverser(context.$content);while(t){if(t.node.nodeName=='#text'){if(t.node.nodeValue==='\n'){$('<p><br></p>').insertAfter($(t.node));var oldNode=t.node;t=t.next();$(oldNode).remove();continue;} |
468 | 468 | else if((t.node.nodeValue.indexOf('\n')!=1||t.node.nodeValue.indexOf('\r')!=-1)){t.node.nodeValue=t.node.nodeValue.replace(/\r|\n/g,' ');}} |
— | — | @@ -559,8 +559,8 @@ |
560 | 560 | if(periRange.text==periText){rawPeriText+="\r\n";}else{periFinished=true;}}} |
561 | 561 | if(!postFinished){if(postRange.compareEndPoints("StartToEnd",postRange)==0){postFinished=true;}else{postRange.moveEnd("character",-1) |
562 | 562 | if(postRange.text==postText){rawPostText+="\r\n";}else{postFinished=true;}}}}while((!postFinished||!periFinished||!postFinished));startPos=rawPreText.replace(/\r\n/g,"\n").length;endPos=startPos+rawPeriText.replace(/\r\n/g,"\n").length;}catch(e){startPos=endPos=0;}} |
563 | | -return[startPos,endPos];},'setSelection':function(options){var sc=options.startContainer,ec=options.endContainer;sc=sc&&sc.jquery?sc[0]:sc;ec=ec&&ec.jquery?ec[0]:ec;if(context.$iframe[0].contentWindow.getSelection){var start=options.start,end=options.end;if(!sc||!ec){var s=context.fn.getOffset(start);var e=context.fn.getOffset(end);sc=s?s.node:null;ec=e?e.node:null;start=s?s.offset:null;end=e?e.offset:null;if(sc.nodeName=='#text'&&start>=sc.nodeValue.length){start=sc.nodeValue.length-1;} |
564 | | -if(ec.nodeName=='#text'&&end>=ec.nodeValue.length){end=ec.nodeValue.length-1;}} |
| 563 | +return[startPos,endPos];},'setSelection':function(options){var sc=options.startContainer,ec=options.endContainer;sc=sc&&sc.jquery?sc[0]:sc;ec=ec&&ec.jquery?ec[0]:ec;if(context.$iframe[0].contentWindow.getSelection){var start=options.start,end=options.end;if(!sc||!ec){var s=context.fn.getOffset(start);var e=context.fn.getOffset(end);sc=s?s.node:null;ec=e?e.node:null;start=s?s.offset:null;end=e?e.offset:null;if(sc.nodeName=='#text'&&start>sc.nodeValue.length){start=sc.nodeValue.length-1;} |
| 564 | +if(ec.nodeName=='#text'&&end>ec.nodeValue.length){end=ec.nodeValue.length-1;}} |
565 | 565 | if(!sc||!ec){return context.$textarea;} |
566 | 566 | var sel=context.$iframe[0].contentWindow.getSelection();while(sc.firstChild&&sc.nodeName!='#text'){sc=sc.firstChild;} |
567 | 567 | while(ec.firstChild&&ec.nodeName!='#text'){ec=ec.firstChild;} |
— | — | @@ -598,7 +598,8 @@ |
599 | 599 | while(oldParent.firstChild){startNode.parentNode.insertBefore(oldParent.firstChild,afterStart);}}else{if(lastP!=t.inP){startNode.parentNode.appendChild(startNode.ownerDocument.createElement('br'));} |
600 | 600 | while(oldParent.firstChild){startNode.parentNode.appendChild(oldParent.firstChild);}} |
601 | 601 | oldParent.parentNode.removeChild(oldParent);} |
602 | | -lastP=t.inP;}} |
| 602 | +lastP=t.inP;} |
| 603 | +context.fn.purgeOffsets();} |
603 | 604 | var ca1=startNode,ca2=endNode;if(ca1&&ca2&&ca1.parentNode){var anchor=markers[i].getAnchor(ca1,ca2);if(!anchor){var commonAncestor=ca1.parentNode;if(markers[i].anchor=='wrap'){var newNode=ca1.ownerDocument.createElement('span');var nextNode=ca2.nextSibling;var n=ca1;while(n!=nextNode){var ns=n.nextSibling;newNode.appendChild(n);n=ns;} |
604 | 605 | if(nextNode){commonAncestor.insertBefore(newNode,nextNode);}else{commonAncestor.appendChild(newNode);} |
605 | 606 | anchor=newNode;}else if(markers[i].anchor=='tag'){anchor=commonAncestor;} |
— | — | @@ -606,7 +607,7 @@ |
607 | 608 | visited[v++]=anchor;}} |
608 | 609 | var j=0;context.$content.find('.wikiEditor-highlight').each(function(){if(visited[j]==this){j++;return true;} |
609 | 610 | var marker=$(this).data('marker');if(marker&&typeof marker.beforeUnwrap=='function') |
610 | | -marker.beforeUnwrap(this);if((marker&&marker.anchor=='tag')||$(this).is('p')){$(this).removeAttr('class');}else{$(this).replaceWith(this.childNodes);}});}}};})(jQuery);(function($){$.wikiEditor.modules.preview={'browsers':{'ltr':{'msie':[['>=',7]],'firefox':[['>=',3]],'opera':[['>=',9.6]],'safari':[['>=',4]]},'rtl':{'msie':[['>=',8]],'firefox':[['>=',3]],'opera':[['>=',9.6]],'safari':[['>=',4]]}},fn:{create:function(context,config){if('initialized'in context.modules.preview){return;} |
| 611 | +marker.beforeUnwrap(this);if((marker&&marker.anchor=='tag')||$(this).is('p')){$(this).removeAttr('class');}else{$(this).replaceWith(this.childNodes);}});context.fn.purgeOffsets();}}};})(jQuery);(function($){$.wikiEditor.modules.preview={'browsers':{'ltr':{'msie':[['>=',7]],'firefox':[['>=',3]],'opera':[['>=',9.6]],'safari':[['>=',4]]},'rtl':{'msie':[['>=',8]],'firefox':[['>=',3]],'opera':[['>=',9.6]],'safari':[['>=',4]]}},fn:{create:function(context,config){if('initialized'in context.modules.preview){return;} |
611 | 612 | context.modules.preview={'initialized':true,'previewText':null,'changesText':null};context.modules.preview.$preview=context.fn.addView({'name':'preview','titleMsg':'wikieditor-preview-tab','init':function(context){var wikitext=context.fn.getContents();if(context.modules.preview.previewText==wikitext){return;} |
612 | 613 | context.modules.preview.$preview.find('.wikiEditor-preview-contents').empty();context.modules.preview.$preview.find('.wikiEditor-preview-loading').show();$.post(wgScriptPath+'/api.php',{'action':'parse','title':wgPageName,'text':wikitext,'prop':'text','pst':'','format':'json'},function(data){if(typeof data.parse=='undefined'||typeof data.parse.text=='undefined'||typeof data.parse.text['*']=='undefined'){return;} |
613 | 614 | context.modules.preview.previewText=wikitext;context.modules.preview.$preview.find('.wikiEditor-preview-loading').hide();context.modules.preview.$preview.find('.wikiEditor-preview-contents').html(data.parse.text['*']).find('a:not([href^=#])').click(function(){return false;});},'json');}});context.$changesTab=context.fn.addView({'name':'changes','titleMsg':'wikieditor-preview-changes-tab','init':function(context){var wikitext=context.fn.getContents();if(context.modules.preview.changesText==wikitext){return;} |
— | — | @@ -645,10 +646,9 @@ |
646 | 647 | <div class="wikiEditor-template-dialog-title" />\ |
647 | 648 | <div class="wikiEditor-template-dialog-fields" />\ |
648 | 649 | </fieldset>',init:function(){$(this).find('[rel]').each(function(){$(this).text(mw.usability.getMsg($(this).attr('rel')));});},dialog:{width:600,height:400,dialogClass:'wikiEditor-toolbar-dialog',buttons:{'wikieditor-template-editor-dialog-submit':function(){var $templateDiv=$(this).data('templateDiv');context.fn.highlightLine($templateDiv);var $templateText=$templateDiv.children('.wikiEditor-template-text');var templateModel=$templateText.data('model');$(this).find('.wikiEditor-template-dialog-field-wrapper textarea').each(function(){templateModel.setValue($(this).data('name'),$(this).val());});$.wikiEditor.modules.templateEditor.fn.updateModel($templateText,templateModel);$(this).dialog('close');}},open:function(){var $templateDiv=$(this).data('templateDiv');var $templateText=$templateDiv.children('.wikiEditor-template-text');var templateModel=$templateText.data('model');if($templateText.html()!=$templateText.data('oldHTML')){templateModel=$.wikiEditor.modules.templateEditor.fn.updateModel($templateText);} |
649 | | -var params=templateModel.getAllInitialParams();var $fields=$(this).find('.wikiEditor-template-dialog-fields').empty();var $rows=$fields.find('.wikiEditor-template-dialog-field-wrapper');for(var paramIndex in params){var param=params[paramIndex];if(typeof param.name=='undefined'){continue;} |
650 | | -var paramText=typeof param=='string'?param.name.replace(/[\_\-]/g,' '):param.name;var paramVal=templateModel.getValue(param.name);if($rows.length>0){var $row=$rows.eq(0);$row.children('label').text(paramText);$row.children('input').val(paramVal);$rows=$rows.not($row);}else{var $paramRow=$('<div />').addClass('wikiEditor-template-dialog-field-wrapper');$('<label />').text(paramText).appendTo($paramRow);$('<textarea />').data('name',param.name).val(paramVal).bind('cut paste keypress click',function(){$this=$(this);setTimeout(function(){var expanded=$this.data('expanded');if($this.val().length>24){if(!expanded){$this.animate({'height':'4.5em'},'fast');$this.data('expanded',true);}}else{if(expanded){$this.animate({'height':'1.5em'},'fast');$this.data('expanded',false);}}},0);}).appendTo($paramRow);$('<div style="clear:both"></div>').appendTo($paramRow);$fields.append($paramRow);} |
651 | | -$rows.remove();$fields.find('label').autoEllipsis();} |
652 | | -$(this).parent('.ui-dialog').find('.ui-dialog-titlebar-close').removeClass('ui-state-focus');}}};function createDialog($templateDiv){context.$textarea.wikiEditor('addDialog',{'templateEditor':dialog});$('#'+dialog.id).data('templateDiv',$templateDiv).dialog('open');}},unwrapTemplate:function($wrapper){$wrapper.parent().replaceWith($wrapper);},updateModel:function($templateText,model){var context=$templateText.data('marker').context;var text;if(typeof model=='undefined'){text=context.fn.htmlToText($templateText.html());}else{text=model.getText();} |
| 650 | +var params=templateModel.getAllInitialParams();var $fields=$(this).find('.wikiEditor-template-dialog-fields');var $rows=$fields.find('.wikiEditor-template-dialog-field-wrapper');for(var paramIndex in params){var param=params[paramIndex];if(typeof param.name=='undefined'){continue;} |
| 651 | +var paramText=typeof param=='string'?param.name.replace(/[\_\-]/g,' '):param.name;var paramVal=templateModel.getValue(param.name);if($rows.length>0){var $row=$rows.eq(0);$row.children('label').text(paramText);$row.children('textarea').data('name',param.name).val(paramVal).change();$rows=$rows.not($row);}else{var $paramRow=$('<div />').addClass('wikiEditor-template-dialog-field-wrapper');$('<label />').text(paramText).appendTo($paramRow);$('<textarea />').data('name',param.name).val(paramVal).data('expanded',false).bind('cut paste keypress click change',function(){var $this=$(this);setTimeout(function(){var expanded=$this.data('expanded');if($this.val().length>24){if(!expanded){$this.animate({'height':'4.5em'},'fast');$this.data('expanded',true);}}else{if(expanded){$this.animate({'height':'1.5em'},'fast');$this.data('expanded',false);}}},0);}).appendTo($paramRow);$paramRow.append('<div style="clear:both"></div>').appendTo($fields);}} |
| 652 | +$rows.remove();$fields.find('label').autoEllipsis();$(this).parent('.ui-dialog').find('.ui-dialog-titlebar-close').removeClass('ui-state-focus');}}};function createDialog($templateDiv){context.$textarea.wikiEditor('addDialog',{'templateEditor':dialog});$('#'+dialog.id).data('templateDiv',$templateDiv).dialog('open');}},unwrapTemplate:function($wrapper){$wrapper.parent().replaceWith($wrapper);},updateModel:function($templateText,model){var context=$templateText.data('marker').context;var text;if(typeof model=='undefined'){text=context.fn.htmlToText($templateText.html());}else{text=model.getText();} |
653 | 653 | $templateText.text(text);$templateText.html($templateText.html().replace(/\n/g,'<br />'));$templateText.data('oldHTML',$templateText.html());if(typeof model=='undefined'){model=new $.wikiEditor.modules.templateEditor.fn.model(text);$templateText.data('model',model);} |
654 | 654 | return model;},getTemplateInfo:function(templateName){var templateInfo='';return $(templateInfo);},model:function(wikitext){var collapsible=true;function Param(name,value,number,nameIndex,equalsIndex,valueIndex){this.name=name;this.value=value;this.number=number;this.nameIndex=nameIndex;this.equalsIndex=equalsIndex;this.valueIndex=valueIndex;} |
655 | 655 | function Range(begin,end){this.begin=begin;this.end=end;} |