r60089 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60088‎ | r60089 | r60090 >
Date:19:30, 15 December 2009
Author:tparscal
Status:deferred
Tags:
Comment:
Moved some things around in modules, mostly focusing on encapsulating data into a data field rather than just placing them at the root level. Took first pass at cleaning up wikieditor.templateEditor.js. Also added bits of comments and removed empty api fields in modules.
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.dialogs.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.preview.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.publish.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -72,19 +72,19 @@
7373 array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 6 ),
7474 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 21 ),
7575 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 35 ),
76 - array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 1 ),
 76+ array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 2 ),
7777 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 39 ),
78 - array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 9 ),
79 - array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 50 ),
80 - array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 7 ),
81 - array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 1 ),
82 - array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 0 ),
 78+ array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 10 ),
 79+ array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 51 ),
 80+ array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 8 ),
 81+ array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 2 ),
 82+ array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 1 ),
8383 ),
8484 'combined' => array(
85 - array( 'src' => 'js/plugins.combined.js', 'version' => 109 ),
 85+ array( 'src' => 'js/plugins.combined.js', 'version' => 110 ),
8686 ),
8787 'minified' => array(
88 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 109 ),
 88+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 110 ),
8989 ),
9090 ),
9191 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.preview.js
@@ -2,12 +2,6 @@
33 ( function( $ ) { $.wikiEditor.modules.preview = {
44
55 /**
6 - * API accessible functions
7 - */
8 -api: {
9 - //
10 -},
11 -/**
126 * Internally used functions
137 */
148 fn: {
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js
@@ -1,77 +1,77 @@
2 -/* template forms module for wikiEditor */
 2+/* TemplateEditor module for wikiEditor */
33 ( function( $ ) { $.wikiEditor.modules.templateEditor = {
44
55 /**
6 - * API accessible functions
 6+ * Event handlers
77 */
8 -api: {
9 - //
10 -},
11 -
128 evt: {
13 - mark: function() {
14 - function findOutermostTemplates( tokenStack ) {
15 - templateBeginFound = false;
16 - for ( ;i< tokenStack.length; i++ ) {
17 - if ( tokenStack[i].label == "TEMPLATE_BEGIN" ) {
18 - templateBeginFound = true;
19 - break;
20 - }
 9+ mark: function( context, event ) {
 10+ // This is shared by both the closure findOutermostTemplates and the calling code - is this a good idea?
 11+ var i = 0;
 12+ /**
 13+ * Finds the left and right character positions of the outer-most template declaration, playing nicely with
 14+ * nested template calls of any depth. This function acts as an iterator, which is why the i var is shared - but
 15+ * this seems a bit scary seeing as 'i' is so often used in loops.
 16+ *
 17+ * @param tokenStack Array of tokens to find boundries within
 18+ */
 19+ function findOutermostTemplates( tokenStack ) {
 20+ var templateBeginFound = false;
 21+ for ( ; i < tokenStack.length; i++ ) {
 22+ if ( tokenStack[i].label == 'TEMPLATE_BEGIN' ) {
 23+ templateBeginFound = true;
 24+ break;
2125 }
22 - var j = i;
23 - i++;
24 - if ( !templateBeginFound ) {
 26+ }
 27+ var j = i++;
 28+ if ( !templateBeginFound ) {
 29+ return false;
 30+ } else {
 31+ // This is only designed to find the outermost template boundaries, the model handles nested template
 32+ // and template-like objects better
 33+ var nestedBegins = 1;
 34+ while ( nestedBegins > 0 && j < tokenStack.length ) {
 35+ var label = tokenStack[++j].label;
 36+ nestedBegins += label == 'TEMPLATE_END' ? -1 : label == 'TEMPLATE_BEGIN' ? 1 : 0;
 37+ }
 38+ if ( nestedBegins == 0 ) {
 39+ // Outer template begins at tokenStack[i].offset and ends at tokenStack[j].offset + 2
 40+ var leftMarker = i -1;
 41+ var rightMarker = j;
 42+ i = j;
 43+ return [leftMarker, rightMarker];
 44+ } else {
2545 return false;
26 - } else {
27 - // This is only designed to find the outermost template boundaries, the model handles nested template
28 - // and template-like objects better
29 - var nestedBegins = 1;
30 - while ( nestedBegins > 0 && j < tokenStack.length ) {
31 - j++;
32 - if ( tokenStack[j].label == "TEMPLATE_END" ) {
33 - nestedBegins--;
34 - }
35 - if ( tokenStack[j].label == "TEMPLATE_BEGIN" ) {
36 - nestedBegins++;
37 - }
38 - }
39 - if ( nestedBegins == 0 ) {
40 - // outer template begins at tokenStack[i].offset
41 - // and ends at tokenStack[j].offset + 2
42 - var leftMarker = i -1;
43 - var rightMarker = j;
44 - i = j;
45 - return [ leftMarker, rightMarker ];
46 - } else {
47 - return false;
48 - }
4946 }
50 - }; //find outermost templates
51 -
52 - markers = $.wikiEditor.modules.highlight.fn.markers;
53 - var tokenStack = $.wikiEditor.modules.highlight.fn.tokenArray;
54 - i = 0;
55 - var templateBoundaries;
56 - templateBeginFound = false;
57 -
58 - while ( templateBoundaries = findOutermostTemplates( tokenStack ) ) {
59 - if ( typeof markers[tokenStack[templateBoundaries[0]].offset] == 'undefined' ) {
60 - markers[tokenStack[templateBoundaries[0]].offset] = [];
61 - }
62 - if ( typeof markers[tokenStack[templateBoundaries[1]].offset] == 'undefined' ) {
63 - markers[tokenStack[templateBoundaries[1]].offset] = [];
64 - }
65 - markers[tokenStack[templateBoundaries[0]].offset].push( "<div class='wiki-template'>" );
66 - markers[tokenStack[templateBoundaries[1]].offset].push( "</div>" );
6747 }
 48+ };
 49+ // Get the markers and tokens from the current context
 50+ var markers = context.modules.highlight.data.markers;
 51+ var tokenStack = context.modules.highlight.data.tokenArray;
 52+ // Scan through and detect the boundries of template calls
 53+ var templateBeginFound = false;
 54+ var templateBoundaries;
 55+ while ( templateBoundaries = findOutermostTemplates( tokenStack ) ) {
 56+ // Ensure indexes exist for left and right boundry markers
 57+ if ( typeof markers[tokenStack[templateBoundaries[0]].offset] == 'undefined' ) {
 58+ markers[tokenStack[templateBoundaries[0]].offset] = [];
 59+ }
 60+ if ( typeof markers[tokenStack[templateBoundaries[1]].offset] == 'undefined' ) {
 61+ markers[tokenStack[templateBoundaries[1]].offset] = [];
 62+ }
 63+ // Append boundry markers
 64+ markers[tokenStack[templateBoundaries[0]].offset].push( "<div class='wiki-template'>" );
 65+ markers[tokenStack[templateBoundaries[1]].offset].push( "</div>" );
6866 }
 67+ }
6968 },
70 -
 69+/**
 70+ * Regular expressions that produce tokens
 71+ */
7172 exp: [
72 - { regex: /{{/, label: "TEMPLATE_BEGIN" },
73 - { regex: /}}/, label: "TEMPLATE_END", markAfter: true }
 73+ { 'regex': /{{/, 'label': "TEMPLATE_BEGIN" },
 74+ { 'regex': /}}/, 'label': "TEMPLATE_END", 'markAfter': true }
7475 ],
75 -
7676 /**
7777 * Internally used functions
7878 */
@@ -82,14 +82,28 @@
8383 * @param config Configuration object to create module from
8484 */
8585 create: function( context, config ) {
 86+ // Initialize module within the context
 87+ },
 88+ /**
 89+ * Builds a template model from given wikitext representation, allowing object-oriented manipulation of the contents
 90+ * of the template while preserving whitespace and formatting.
 91+ *
 92+ * @param wikitext String of wikitext content
 93+ */
 94+ model: function( wikitext ) {
8695
87 - //initializations
 96+ /* Private Functions */
8897
89 - },
90 -
91 - //template Model
92 - model: function( wikitext ) {
93 - // Param object
 98+ /**
 99+ * Builds a Param object.
 100+ *
 101+ * @param name
 102+ * @param value
 103+ * @param number
 104+ * @param nameIndex
 105+ * @param equalsIndex
 106+ * @param valueIndex
 107+ */
94108 function Param( name, value, number, nameIndex, equalsIndex, valueIndex ) {
95109 this.name = name;
96110 this.value = value;
@@ -98,56 +112,167 @@
99113 this.equalsIndex = equalsIndex;
100114 this.valueIndex = valueIndex;
101115 }
102 -
103 - // Range object
 116+ /**
 117+ * Builds a Range object.
 118+ *
 119+ * @param begin
 120+ * @param end
 121+ */
104122 function Range( begin, end ) {
105123 this.begin = begin;
106124 this.end = end;
107125 }
 126+ /**
 127+ * Set 'original' to true if you want the original value irrespective of whether the model's been changed
 128+ *
 129+ * @param name
 130+ * @param value
 131+ * @param original
 132+ */
 133+ function getSetValue( name, value, original ) {
 134+ var valueRange;
 135+ var rangeIndex;
 136+ var retVal;
 137+ if ( isNaN( name ) ) {
 138+ // It's a string!
 139+ if ( typeof paramsByName[name] == 'undefined' ) {
 140+ // Does not exist
 141+ return "";
 142+ }
 143+ rangeIndex = paramsByName[name];
 144+ } else {
 145+ // It's a number!
 146+ rangeIndex = parseInt( name );
 147+ }
 148+ if ( typeof params[rangeIndex] == 'undefined' ) {
 149+ // Does not exist
 150+ return "";
 151+ }
 152+ valueRange = ranges[params[rangeIndex].valueIndex];
 153+ if ( typeof valueRange.newVal == 'undefined' || original ) {
 154+ // Value unchanged, return original wikitext
 155+ retVal = wikitext.substring( valueRange.begin, valueRange.end );
 156+ } else {
 157+ // New value exists, return new value
 158+ retVal = valueRange.newVal;
 159+ }
 160+ if ( value != null ) {
 161+ ranges[params[rangeIndex].valueIndex].newVal = value;
 162+ }
 163+ return retVal;
 164+ };
108165
109 - var ranges = [];
110 - var sanatizedStr = "";
111 - var params = [];
112 - var paramsByName = [];
113 - var templateNameIndex = 0;
 166+ /* Public Functions */
114167
115 - //takes all template-specific characters, namely {|=} away if they're not particular to the
116 - //template we're looking at
117 - function markOffTemplates() {
118 - sanatizedStr = wikitext.replace( /{{/, " " ); //get rid of first {{ with whitespace
119 - endBraces = sanatizedStr.match( /}}\s*$/ ); //replace end
120 - sanatizedStr = sanatizedStr.substring( 0, endBraces.index ) + " " +
121 - sanatizedStr.substring( endBraces.index + 2 );
122 -
123 - //match the open braces we just found with equivalent closing braces
124 - //note, works for any level of braces
125 - while ( sanatizedStr.indexOf( '{{' ) != -1 ) {
126 - startIndex = sanatizedStr.indexOf('{{') + 1;
127 - openBraces = 2;
128 - endIndex = startIndex;
129 - while ( openBraces > 0 ) {
130 - endIndex++;
131 - switch ( sanatizedStr[endIndex] ) {
132 - case '}': openBraces--; break;
133 - case '{': openBraces++; break;
134 - }
 168+ /**
 169+ * Get template name
 170+ */
 171+ this.getName = function() {
 172+ if( typeof ranges[templateNameIndex].newVal == 'undefined' ) {
 173+ return wikitext.substring( ranges[templateNameIndex].begin, ranges[templateNameIndex].end );
 174+ } else {
 175+ return ranges[templateNameIndex].newVal;
 176+ }
 177+ };
 178+ /**
 179+ * Set template name (if we want to support this)
 180+ *
 181+ * @param name
 182+ */
 183+ this.setName = function( name ) {
 184+ ranges[templateNameIndex].newVal = name;
 185+ };
 186+ /**
 187+ * Set value for a given param name / number
 188+ *
 189+ * @param name
 190+ * @param value
 191+ */
 192+ this.setValue = function( name, value ) {
 193+ return getSetValue( name, value, false );
 194+ };
 195+ /**
 196+ * Get value for a given param name / number
 197+ *
 198+ * @param name
 199+ */
 200+ this.getValue = function( name ) {
 201+ return getSetValue( name, null, false );
 202+ };
 203+ /**
 204+ * Get original value of a param
 205+ *
 206+ * @param name
 207+ */
 208+ this.getOriginalValue = function( name ) {
 209+ return getSetValue( name, null, true );
 210+ };
 211+ /**
 212+ * Get a list of all param names (numbers for the anonymous ones)
 213+ */
 214+ this.getAllParamNames = function() {
 215+ return paramsByName;
 216+ };
 217+ /**
 218+ * Get the initial params
 219+ */
 220+ this.getAllInitialParams = function(){
 221+ return params;
 222+ }
 223+ /**
 224+ * Get original template text
 225+ */
 226+ this.getOriginalText = function() {
 227+ return wikitext;
 228+ };
 229+ /**
 230+ * Get modified template text
 231+ */
 232+ this.getText = function() {
 233+ newText = "";
 234+ for ( i = 0 ; i < ranges.length; i++ ) {
 235+ if( typeof ranges[i].newVal == 'undefined' ) {
 236+ wikitext.substring( ranges[i].begin, ranges[i].end );
 237+ } else {
 238+ newText += ranges[i].newVal;
135239 }
136 - sanatizedSegment = sanatizedStr.substring( startIndex,endIndex )
137 - .replace( /[{}|=]/g , 'X' );
138 - sanatizedStr = sanatizedStr.substring( 0, startIndex ) +
139 - sanatizedSegment + sanatizedStr.substring( endIndex );
140 - }//while
141 - return sanatizedStr;
 240+ }
 241+ return newText;
142242 };
143 -
 243+
144244 // Whitespace* {{ whitespace* nonwhitespace:
145245 if ( wikitext.match( /\s*{{\s*\S*:/ ) ) {
146 - // we have a parser function!
 246+ // We have a parser function!
147247 }
148 -
149 - markOffTemplates();
150 -
151 - //parse 1 param at a time
 248+ /*
 249+ * Take all template-specific characters that are not particular to the template we're looking at, namely {|=},
 250+ * and convert them into something harmless, in this case 'X'
 251+ */
 252+ // Get rid of first {{ with whitespace
 253+ var sanatizedStr = wikitext.replace( /{{/, " " );
 254+ // Replace end
 255+ endBraces = sanatizedStr.match( /}}\s*$/ );
 256+ sanatizedStr =
 257+ sanatizedStr.substring( 0, endBraces.index ) + " " + sanatizedStr.substring( endBraces.index + 2 );
 258+ // Match the open braces we just found with equivalent closing braces note, works for any level of braces
 259+ while ( sanatizedStr.indexOf( '{{' ) != -1 ) {
 260+ startIndex = sanatizedStr.indexOf('{{') + 1;
 261+ openBraces = 2;
 262+ endIndex = startIndex;
 263+ while ( openBraces > 0 ) {
 264+ var brace = sanatizedStr[++endIndex];
 265+ openBraces += brace == '}' ? -1 : brace == '{' ? 1 : 0;
 266+ }
 267+ sanatizedSegment = sanatizedStr.substring( startIndex,endIndex ).replace( /[{}|=]/g , 'X' );
 268+ sanatizedStr =
 269+ sanatizedStr.substring( 0, startIndex ) + sanatizedSegment + sanatizedStr.substring( endIndex );
 270+ }
 271+ /*
 272+ * Parse 1 param at a time
 273+ */
 274+ var ranges = [];
 275+ var params = [];
 276+ var templateNameIndex = 0;
152277 var doneParsing = false;
153278 oldDivider = 0;
154279 divider = sanatizedStr.indexOf( '|', oldDivider );
@@ -165,11 +290,12 @@
166291 ranges[templateNameIndex].end );
167292 }
168293 params.push( ranges[templateNameIndex].old ); //put something in params (0)
169 -
170 - currentParamNumber = 0;
 294+ /*
 295+ * Start looping over params
 296+ */
 297+ var currentParamNumber = 0;
171298 var valueEndIndex;
172 -
173 - //start looping over params
 299+ var paramsByName = [];
174300 while ( !doneParsing ) {
175301 currentParamNumber++;
176302 oldDivider = divider;
@@ -198,147 +324,48 @@
199325 currentParamNumber, nameIndex, equalsIndex, valueIndex ) );
200326 paramsByName[currentParamNumber] = currentParamNumber;
201327 } else {
202 - // there's an equals, could be comment or a value pair
 328+ // There's an equals, could be comment or a value pair
203329 currentName = currentField.substring( 0, currentField.indexOf( '=' ) );
204 - // (still offset by oldDivider)
205 - nameBegin = currentName.match( /\S+/ ); //first nonwhitespace character
 330+ // Still offset by oldDivider - first nonwhitespace character
 331+ nameBegin = currentName.match( /\S+/ );
206332 if ( nameBegin == null ) {
207 - // this is a comment inside a template call/parser abuse. let's not encourage it
 333+ // This is a comment inside a template call / parser abuse. let's not encourage it
208334 divider++;
209335 currentParamNumber--;
210336 continue;
211337 }
212338 nameBeginIndex = nameBegin.index + oldDivider + 1;
213 - nameEnd = currentName.match( /[^\s]\s*$/ ); //last nonwhitespace and non } character
 339+ // Last nonwhitespace and non } character
 340+ nameEnd = currentName.match( /[^\s]\s*$/ );
214341 nameEndIndex = nameEnd.index + oldDivider + 2;
215 -
216 - ranges.push( new Range( ranges[ranges.length-1].end,
217 - nameBeginIndex ) ); //all the chars upto now
218 - nameIndex = ranges.push( new Range( nameBeginIndex, nameEndIndex ) );
219 - nameIndex--;
 342+ // All the chars upto now
 343+ ranges.push( new Range( ranges[ranges.length-1].end, nameBeginIndex ) );
 344+ nameIndex = ranges.push( new Range( nameBeginIndex, nameEndIndex ) ) - 1;
220345 currentValue = currentField.substring( currentField.indexOf( '=' ) + 1);
221346 oldDivider += currentField.indexOf( '=' ) + 1;
222 - valueBegin = currentValue.match( /\S+/ ); //first nonwhitespace character
 347+ // First nonwhitespace character
 348+ valueBegin = currentValue.match( /\S+/ );
223349 valueBeginIndex = valueBegin.index + oldDivider + 1;
224 - valueEnd = currentValue.match( /[^\s]\s*$/ ); //last nonwhitespace and non } character
 350+ // Last nonwhitespace and non } character
 351+ valueEnd = currentValue.match( /[^\s]\s*$/ );
225352 valueEndIndex = valueEnd.index + oldDivider + 2;
226 - equalsIndex = ranges.push( new Range( ranges[ranges.length-1].end,
227 - valueBeginIndex) ); //all the chars upto now
228 - equalsIndex--;
229 - valueIndex = ranges.push( new Range( valueBeginIndex, valueEndIndex ) );
230 - valueIndex--;
231 - params.push( new Param( wikitext.substring( nameBeginIndex, nameEndIndex ),
 353+ // All the chars upto now
 354+ equalsIndex = ranges.push( new Range( ranges[ranges.length-1].end, valueBeginIndex) ) - 1;
 355+ valueIndex = ranges.push( new Range( valueBeginIndex, valueEndIndex ) ) - 1;
 356+ params.push( new Param(
 357+ wikitext.substring( nameBeginIndex, nameEndIndex ),
232358 wikitext.substring( valueBeginIndex, valueEndIndex ),
233 - currentParamNumber, nameIndex, equalsIndex, valueIndex ) );
 359+ currentParamNumber,
 360+ nameIndex,
 361+ equalsIndex,
 362+ valueIndex
 363+ ) );
234364 paramsByName[wikitext.substring( nameBeginIndex, nameEndIndex )] = currentParamNumber;
235365 }
236366 }
237 - //the rest of the string
 367+ // The rest of the string
238368 ranges.push( new Range( valueEndIndex, wikitext.length ) );
239 -
240 - //FUNCTIONS
241 - //set 'original' to true if you want the original value irrespective of whether the model's been changed
242 - function getSetValue( name, value, original ) {
243 - var valueRange;
244 - var rangeIndex;
245 - var retVal;
246 - if ( isNaN( name ) ) {
247 - // it's a string!
248 - if ( typeof paramsByName[name] == 'undefined' ) {
249 - //does not exist
250 - return "";
251 - }
252 - rangeIndex = paramsByName[name];
253 - } else {
254 - //it's a number!
255 - rangeIndex = parseInt( name );
256 - }
257 -
258 - if ( typeof params[rangeIndex] == 'undefined' ) {
259 - //does not exist
260 - return "";
261 - }
262 - valueRange = ranges[params[rangeIndex].valueIndex];
263 -
264 - if ( typeof valueRange.newVal == 'undefined' || original ) {
265 - //value unchanged, return original wikitext
266 - retVal = wikitext.substring( valueRange.begin, valueRange.end );
267 - } else {
268 - //new value exists, return new value
269 - retVal = valueRange.newVal;
270 - }
271 -
272 - if ( value != null ) {
273 - ranges[params[rangeIndex].valueIndex].newVal = value;
274 - }
275 -
276 - return retVal;
277 - };
278 -
279 - //'public' functions
280 -
281 - //get template name
282 - this.getName = function() {
283 - if( typeof ranges[templateNameIndex].newVal == 'undefined' ) {
284 - return wikitext.substring( ranges[templateNameIndex].begin,
285 - ranges[templateNameIndex].end );
286 -
287 - } else {
288 - return ranges[templateNameIndex].newVal;
289 - }
290 - };
291 -
292 - //set template name (if we want to support this)
293 - this.setName = function( name ) {
294 - ranges[templateNameIndex].newVal = name;
295 - };
296 -
297 - //set value for a given param name/number
298 - this.setValue = function( name, value ) {
299 - return getSetValue( name, value, false );
300 - };
 369+ } // model
 370+}
301371
302 - //get value for a given param name/number
303 - this.getValue = function( name ) {
304 - return getSetValue( name, null, false );
305 - };
306 -
307 - //get original value of a param
308 - this.getOriginalValue = function( name ) {
309 - return getSetValue( name, null, true );
310 - };
311 -
312 - //get a list of all param names (numbers for the anonymous ones)
313 - this.getAllParamNames = function() {
314 - return paramsByName;
315 - };
316 -
317 - //get the initial params
318 - this.getAllInitialParams = function(){
319 - return params;
320 - }
321 -
322 - //get original template text
323 - this.getOriginalText = function() {
324 - return wikitext;
325 - };
326 -
327 - //get modified template text
328 - this.getText = function() {
329 - newText = "";
330 - for ( i = 0 ; i < ranges.length; i++ ) {
331 - if( typeof ranges[i].newVal == 'undefined' ) {
332 - wikitext.substring( ranges[i].begin, ranges[i].end );
333 - } else {
334 - newText += ranges[i].newVal;
335 - }
336 - }
337 - return newText;
338 - };
339 - }//template model
340 -
341 -}//fn
342 -
343372 }; } )( jQuery );
344 -
345 -
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.dialogs.js
@@ -69,14 +69,14 @@
7070 .appendTo( $( 'body' ) )
7171 .each( module.init )
7272 .dialog( configuration );
73 - if ( !( 'resizeme' in module ) || module.resizeme )
 73+ if ( !( 'resizeme' in module ) || module.resizeme ) {
7474 dialogDiv
7575 .bind( 'dialogopen', $.wikiEditor.modules.dialogs.fn.resize )
7676 .find( '.ui-tabs' ).bind( 'tabsshow', function() {
7777 $(this).closest( '.ui-dialog-content' ).each(
7878 $.wikiEditor.modules.dialogs.fn.resize );
7979 });
80 -
 80+ }
8181 // Add tabindexes to dialog form elements
8282 // Find the highest tabindex in use
8383 var maxTI = 0;
@@ -96,7 +96,6 @@
9797 }
9898 });
9999 },
100 -
101100 /**
102101 * Resize a dialog so its contents fit
103102 *
@@ -106,48 +105,37 @@
107106 resize: function() {
108107 var wrapper = $(this).closest( '.ui-dialog' );
109108 var oldWidth = wrapper.width();
110 - // Make sure elements don't wrapped so we get an accurate idea
111 - // of whether they really fit. Also temporarily show hidden
112 - // elements.
113 -
114 - // Work around jQuery bug where <div style="display:inline;" />
115 - // inside a dialog is both :visible and :hidden
 109+ // Make sure elements don't wrapped so we get an accurate idea of whether they really fit. Also temporarily show
 110+ // hidden elements. Work around jQuery bug where <div style="display:inline;" /> inside a dialog is both
 111+ // :visible and :hidden
116112 var oldHidden = $(this).find( '*' ).not( ':visible' );
117 -
118 - // Save the style attributes of the hidden elements to restore
119 - // them later. Calling hide() after show() messes up for
120 - // elements hidden with a class
 113+ // Save the style attributes of the hidden elements to restore them later. Calling hide() after show() messes up
 114+ // for elements hidden with a class
121115 oldHidden.each( function() {
122116 $(this).data( 'oldstyle', $(this).attr( 'style' ) );
123117 });
124118 oldHidden.show();
125119 var oldWS = $(this).css( 'white-space' );
126120 $(this).css( 'white-space', 'nowrap' );
127 -
128121 if ( wrapper.width() <= $(this).get(0).scrollWidth ) {
129122 var thisWidth = $(this).data( 'thisWidth' ) ? $(this).data( 'thisWidth' ) : 0;
130123 thisWidth = Math.max( $(this).get(0).scrollWidth, thisWidth );
131124 $(this).width( thisWidth );
132125 $(this).data( 'thisWidth', thisWidth );
133 -
134126 var wrapperWidth = $(this).data( 'wrapperWidth' ) ? $(this).data( 'wrapperWidth' ) : 0;
135127 wrapperWidth = Math.max( wrapper.get(0).scrollWidth, wrapperWidth );
136128 wrapper.width( wrapperWidth );
137129 $(this).data( 'wrapperWidth', wrapperWidth );
138 -
139130 $(this).dialog( { 'width': wrapper.width() } );
140 - wrapper.css( 'left',
141 - parseInt( wrapper.css( 'left' ) ) -
142 - ( wrapper.width() - oldWidth ) / 2 );
 131+ wrapper.css( 'left', parseInt( wrapper.css( 'left' ) ) - ( wrapper.width() - oldWidth ) / 2 );
143132 }
144 -
145133 $(this).css( 'white-space', oldWS );
146134 oldHidden.each( function() {
147135 $(this).attr( 'style', $(this).data( 'oldstyle' ) );
148 - });
149 -
 136+ });
150137 }
151138 },
 139+// This stuff is just hanging here, perhaps we could come up with a better home for this stuff
152140 modules: {},
153141 quickDialog: function( body, settings ) {
154142 $( '<div />' )
@@ -160,4 +148,4 @@
161149 .dialog( 'open' );
162150 }
163151
164 -}; } ) ( jQuery );
 152+}; } ) ( jQuery );
\ No newline at end of file
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js
@@ -1,16 +1,16 @@
22 /* TOC Module for wikiEditor */
33 ( function( $ ) { $.wikiEditor.modules.toc = {
4 -
 4+
55 /**
6 - * Default width of table of contents
 6+ * Configuration
77 */
8 -defaultWidth: '166px',
 8+cfg: {
 9+ // Default width of table of contents
 10+ defaultWidth: '166px',
 11+ // Minimum width to allow resizing to before collapsing the table of contents - used when resizing and collapsing
 12+ minimumWidth: '70px',
 13+},
914 /**
10 - * Minimum width to allow resizing to before collapsing the table of contents
11 - * Only used if resizing and collapsing is enabled
12 - */
13 -minimumWidth: '70px',
14 -/**
1515 * API accessible functions
1616 */
1717 api: {
@@ -68,15 +68,15 @@
6969 .addClass( 'wikiEditor-ui-toc' )
7070 .data( 'context', context );
7171 context.$ui.find( '.wikiEditor-ui-right' )
72 - .css( 'width', $.wikiEditor.modules.toc.defaultWidth )
 72+ .css( 'width', $.wikiEditor.modules.toc.cfg.defaultWidth )
7373 .append( context.modules.toc.$toc );
7474 context.modules.toc.$toc.height(
7575 context.$ui.find( '.wikiEditor-ui-left' ).height()
7676 );
7777 context.$ui.find( '.wikiEditor-ui-left' )
78 - .css( 'marginRight', "-" + $.wikiEditor.modules.toc.defaultWidth )
 78+ .css( 'marginRight', "-" + $.wikiEditor.modules.toc.cfg.defaultWidth )
7979 .children()
80 - .css( 'marginRight', $.wikiEditor.modules.toc.defaultWidth );
 80+ .css( 'marginRight', $.wikiEditor.modules.toc.cfg.defaultWidth );
8181 },
8282
8383 unhighlight: function( context ) {
@@ -280,7 +280,14 @@
281281 // Toss a transparent cover over our iframe
282282 $( '<div />' )
283283 .addClass( 'wikiEditor-ui-resize-mask' )
284 - .css( { 'position': 'absolute', 'z-index': 2, 'left': 0, 'top': 0, 'bottom': 0, 'right': 0 } )
 284+ .css( {
 285+ 'position': 'absolute',
 286+ 'z-index': 2,
 287+ 'left': 0,
 288+ 'top': 0,
 289+ 'bottom': 0,
 290+ 'right': 0
 291+ } )
285292 .appendTo( context.$ui.find( '.wikiEditor-ui-left' ) );
286293 $this.resizable( 'option', 'maxWidth', $this.parent().width() - 450 );
287294 },
@@ -296,7 +303,7 @@
297304 stop: function ( e, ui ) {
298305 context.$ui.find( '.wikiEditor-ui-resize-mask' ).remove();
299306 context.$content.trigger( 'mouseup' );
300 - if( ui.size.width < parseFloat( $.wikiEditor.modules.toc.minimumWidth ) ) {
 307+ if( ui.size.width < parseFloat( $.wikiEditor.modules.toc.cfg.minimumWidth ) ) {
301308 context.modules.toc.$toc.trigger( 'collapse' );
302309 } else {
303310 context.modules.toc.$toc.data( 'openWidth', ui.size.width );
@@ -316,14 +323,14 @@
317324 context.modules.toc.$toc
318325 .bind( 'collapse.wikiEditor-toc', $.wikiEditor.modules.toc.fn.collapse )
319326 .bind( 'expand.wikiEditor-toc', $.wikiEditor.modules.toc.fn.expand );
320 - context.modules.toc.$toc.data( 'openWidth', $.wikiEditor.modules.toc.defaultWidth );
 327+ context.modules.toc.$toc.data( 'openWidth', $.wikiEditor.modules.toc.cfg.defaultWidth );
321328 // If the toc-width cookie is set, reset the widths based upon that
322329 if ( $.cookie( 'wikiEditor-' + context.instance + '-toc-width' ) == 0 ) {
323330 context.modules.toc.$toc.trigger( 'collapse.wikiEditor-toc', { data: context } );
324331 } else if ( $.cookie( 'wikiEditor-' + context.instance + '-toc-width' ) > 0 ) {
325332 var initialWidth = $.cookie( 'wikiEditor-' + context.instance + '-toc-width' );
326 - if( initialWidth < parseFloat( $.wikiEditor.modules.toc.minimumWidth ) )
327 - initialWidth = parseFloat( $.wikiEditor.modules.toc.minimumWidth ) + 1;
 333+ if( initialWidth < parseFloat( $.wikiEditor.modules.toc.cfg.minimumWidth ) )
 334+ initialWidth = parseFloat( $.wikiEditor.modules.toc.cfg.minimumWidth ) + 1;
328335 context.modules.toc.$toc.data( 'openWidth', initialWidth + 'px' );
329336 context.$ui.find( '.wikiEditor-ui-right' )
330337 .css( 'width', initialWidth + 'px' );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.publish.js
@@ -2,12 +2,6 @@
33 ( function( $ ) { $.wikiEditor.modules.publish = {
44
55 /**
6 - * API accessible functions
7 - */
8 -api: {
9 - //
10 -},
11 -/**
126 * Internally used functions
137 */
148 fn: {
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js
@@ -2,12 +2,6 @@
33 ( function( $ ) { $.wikiEditor.modules.highlight = {
44
55 /**
6 - * API accessible functions
7 - */
8 -api: {
9 - //
10 -},
11 -/**
126 * Internally used event handlers
137 */
148 evt: {
@@ -40,43 +34,61 @@
4135 }
4236 }
4337 },
44 -
4538 /**
4639 * Internally used functions
4740 */
4841 fn: {
4942 /**
5043 * Creates a highlight module within a wikiEditor
51 - * @param context Context object of editor to create module in
 44+ *
5245 * @param config Configuration object to create module from
5346 */
5447 create: function( context, config ) {
5548 // hook $.wikiEditor.modules.highlight.evt.change to context.evt.change
5649 },
 50+ /**
 51+ * Divides text into divisions
 52+ */
5753 divide: function( context ) {
5854 /*
5955 * We need to add some markup to the iframe content to encapsulate divisions
6056 */
6157 },
 58+ /**
 59+ * Isolates division which was affected by most recent change
 60+ */
6261 isolate: function( context ) {
6362 /*
6463 * A change just occured, and we need to know which sections were affected
6564 */
6665 return []; // array of sections?
6766 },
 67+ /**
 68+ * Strips division of HTML
 69+ *
 70+ * @param division
 71+ */
6872 strip: function( context, division ) {
6973 return $( '<div />' ).html( division.html().replace( /\<br[^\>]*\>/g, "\n" ) ).text();
7074 },
71 - tokenArray: [],
 75+ /**
 76+ * Scans text division for tokens
 77+ *
 78+ * @param division
 79+ */
7280 scan: function( context, division ) {
73 - // We need to look over some text and find interesting areas, then return the
74 - // positions of those areas as tokens
 81+ /**
 82+ * Builds a Token object
 83+ *
 84+ * @param offset
 85+ * @param label
 86+ */
7587 function Token( offset, label ) {
7688 this.offset = offset;
7789 this.label = label;
7890 }
79 -
80 - this.tokenArray = [];
 91+ // We need to look over some text and find interesting areas, then return the positions of those areas as tokens
 92+ context.modules.highlight.tokenArray = [];
8193 var text = context.fn.getContents();
8294 for ( module in $.wikiEditor.modules ) {
8395 if ( 'exp' in $.wikiEditor.modules[module] ) {
@@ -94,8 +106,9 @@
95107 if ( markAfter ) {
96108 markOffset += match[0].length;
97109 }
98 - this.tokenArray.push( new Token(
99 - match.index + oldOffset + markOffset, label ) );
 110+ context.modules.highlight.tokenArray.push(
 111+ new Token( match.index + oldOffset + markOffset, label )
 112+ );
100113 oldOffset += match.index + match[0].length;
101114 newSubstring = text.substring( oldOffset );
102115 match = newSubstring.match( regex );
@@ -104,9 +117,14 @@
105118 }
106119 }
107120
108 - return this.tokenArray; // array of tokens
 121+ return context.modules.highlight.tokenArray; // array of tokens
109122 },
110 - markers: [],
 123+ /**
 124+ * Marks up text with HTML
 125+ *
 126+ * @param division
 127+ * @param tokens
 128+ */
111129 mark: function( context, division, tokens ) {
112130 // We need to markup some text based on some tokens
113131 var rawText = context.fn.getContents();
@@ -117,20 +135,20 @@
118136 $.wikiEditor.modules[module].evt.mark();
119137 }
120138 }
121 - markedText = "";
 139+ markedText = '';
122140 var previousIndex = 0;
123 - for(var currentIndex in this.markers){
124 - markedText+= rawText.substring(previousIndex, currentIndex);
125 - for(var i = 0 ; i < this.markers[currentIndex].length; i++){
126 - markedText += this.markers[currentIndex][i];
 141+ for ( var currentIndex in context.modules.highlight.markers ){
 142+ markedText += rawText.substring( previousIndex, currentIndex );
 143+ for( var i = 0 ; i < context.modules.highlight.markers[currentIndex].length; i++ ){
 144+ markedText += context.modules.highlight.markers[currentIndex][i];
127145 }
128146 previousIndex = currentIndex;
129147 }
130 - if(markedText != ""){
131 - markedText.replace(/\n/g, '<br\>');
 148+ if ( markedText != '' ){
 149+ markedText.replace( /\n/g, '<br\>' );
132150 context.fn.setContents( { contents:markedText } );
133151 }
134 - }//mark
 152+ }
135153 }
136154
137155 }; })( jQuery );
\ No newline at end of file
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -2042,14 +2042,14 @@
20432043 .appendTo( $( 'body' ) )
20442044 .each( module.init )
20452045 .dialog( configuration );
2046 - if ( !( 'resizeme' in module ) || module.resizeme )
 2046+ if ( !( 'resizeme' in module ) || module.resizeme ) {
20472047 dialogDiv
20482048 .bind( 'dialogopen', $.wikiEditor.modules.dialogs.fn.resize )
20492049 .find( '.ui-tabs' ).bind( 'tabsshow', function() {
20502050 $(this).closest( '.ui-dialog-content' ).each(
20512051 $.wikiEditor.modules.dialogs.fn.resize );
20522052 });
2053 -
 2053+ }
20542054 // Add tabindexes to dialog form elements
20552055 // Find the highest tabindex in use
20562056 var maxTI = 0;
@@ -2069,7 +2069,6 @@
20702070 }
20712071 });
20722072 },
2073 -
20742073 /**
20752074 * Resize a dialog so its contents fit
20762075 *
@@ -2079,48 +2078,37 @@
20802079 resize: function() {
20812080 var wrapper = $(this).closest( '.ui-dialog' );
20822081 var oldWidth = wrapper.width();
2083 - // Make sure elements don't wrapped so we get an accurate idea
2084 - // of whether they really fit. Also temporarily show hidden
2085 - // elements.
2086 -
2087 - // Work around jQuery bug where <div style="display:inline;" />
2088 - // inside a dialog is both :visible and :hidden
 2082+ // Make sure elements don't wrapped so we get an accurate idea of whether they really fit. Also temporarily show
 2083+ // hidden elements. Work around jQuery bug where <div style="display:inline;" /> inside a dialog is both
 2084+ // :visible and :hidden
20892085 var oldHidden = $(this).find( '*' ).not( ':visible' );
2090 -
2091 - // Save the style attributes of the hidden elements to restore
2092 - // them later. Calling hide() after show() messes up for
2093 - // elements hidden with a class
 2086+ // Save the style attributes of the hidden elements to restore them later. Calling hide() after show() messes up
 2087+ // for elements hidden with a class
20942088 oldHidden.each( function() {
20952089 $(this).data( 'oldstyle', $(this).attr( 'style' ) );
20962090 });
20972091 oldHidden.show();
20982092 var oldWS = $(this).css( 'white-space' );
20992093 $(this).css( 'white-space', 'nowrap' );
2100 -
21012094 if ( wrapper.width() <= $(this).get(0).scrollWidth ) {
21022095 var thisWidth = $(this).data( 'thisWidth' ) ? $(this).data( 'thisWidth' ) : 0;
21032096 thisWidth = Math.max( $(this).get(0).scrollWidth, thisWidth );
21042097 $(this).width( thisWidth );
21052098 $(this).data( 'thisWidth', thisWidth );
2106 -
21072099 var wrapperWidth = $(this).data( 'wrapperWidth' ) ? $(this).data( 'wrapperWidth' ) : 0;
21082100 wrapperWidth = Math.max( wrapper.get(0).scrollWidth, wrapperWidth );
21092101 wrapper.width( wrapperWidth );
21102102 $(this).data( 'wrapperWidth', wrapperWidth );
2111 -
21122103 $(this).dialog( { 'width': wrapper.width() } );
2113 - wrapper.css( 'left',
2114 - parseInt( wrapper.css( 'left' ) ) -
2115 - ( wrapper.width() - oldWidth ) / 2 );
 2104+ wrapper.css( 'left', parseInt( wrapper.css( 'left' ) ) - ( wrapper.width() - oldWidth ) / 2 );
21162105 }
2117 -
21182106 $(this).css( 'white-space', oldWS );
21192107 oldHidden.each( function() {
21202108 $(this).attr( 'style', $(this).data( 'oldstyle' ) );
2121 - });
2122 -
 2109+ });
21232110 }
21242111 },
 2112+// This stuff is just hanging here, perhaps we could come up with a better home for this stuff
21252113 modules: {},
21262114 quickDialog: function( body, settings ) {
21272115 $( '<div />' )
@@ -2133,17 +2121,10 @@
21342122 .dialog( 'open' );
21352123 }
21362124
2137 -}; } ) ( jQuery );
2138 -/* Highlight module for wikiEditor */
 2125+}; } ) ( jQuery );/* Highlight module for wikiEditor */
21392126 ( function( $ ) { $.wikiEditor.modules.highlight = {
21402127
21412128 /**
2142 - * API accessible functions
2143 - */
2144 -api: {
2145 - //
2146 -},
2147 -/**
21482129 * Internally used event handlers
21492130 */
21502131 evt: {
@@ -2176,43 +2157,61 @@
21772158 }
21782159 }
21792160 },
2180 -
21812161 /**
21822162 * Internally used functions
21832163 */
21842164 fn: {
21852165 /**
21862166 * Creates a highlight module within a wikiEditor
2187 - * @param context Context object of editor to create module in
 2167+ *
21882168 * @param config Configuration object to create module from
21892169 */
21902170 create: function( context, config ) {
21912171 // hook $.wikiEditor.modules.highlight.evt.change to context.evt.change
21922172 },
 2173+ /**
 2174+ * Divides text into divisions
 2175+ */
21932176 divide: function( context ) {
21942177 /*
21952178 * We need to add some markup to the iframe content to encapsulate divisions
21962179 */
21972180 },
 2181+ /**
 2182+ * Isolates division which was affected by most recent change
 2183+ */
21982184 isolate: function( context ) {
21992185 /*
22002186 * A change just occured, and we need to know which sections were affected
22012187 */
22022188 return []; // array of sections?
22032189 },
 2190+ /**
 2191+ * Strips division of HTML
 2192+ *
 2193+ * @param division
 2194+ */
22042195 strip: function( context, division ) {
22052196 return $( '<div />' ).html( division.html().replace( /\<br[^\>]*\>/g, "\n" ) ).text();
22062197 },
2207 - tokenArray: [],
 2198+ /**
 2199+ * Scans text division for tokens
 2200+ *
 2201+ * @param division
 2202+ */
22082203 scan: function( context, division ) {
2209 - // We need to look over some text and find interesting areas, then return the
2210 - // positions of those areas as tokens
 2204+ /**
 2205+ * Builds a Token object
 2206+ *
 2207+ * @param offset
 2208+ * @param label
 2209+ */
22112210 function Token( offset, label ) {
22122211 this.offset = offset;
22132212 this.label = label;
22142213 }
2215 -
2216 - this.tokenArray = [];
 2214+ // We need to look over some text and find interesting areas, then return the positions of those areas as tokens
 2215+ context.modules.highlight.tokenArray = [];
22172216 var text = context.fn.getContents();
22182217 for ( module in $.wikiEditor.modules ) {
22192218 if ( 'exp' in $.wikiEditor.modules[module] ) {
@@ -2230,8 +2229,9 @@
22312230 if ( markAfter ) {
22322231 markOffset += match[0].length;
22332232 }
2234 - this.tokenArray.push( new Token(
2235 - match.index + oldOffset + markOffset, label ) );
 2233+ context.modules.highlight.tokenArray.push(
 2234+ new Token( match.index + oldOffset + markOffset, label )
 2235+ );
22362236 oldOffset += match.index + match[0].length;
22372237 newSubstring = text.substring( oldOffset );
22382238 match = newSubstring.match( regex );
@@ -2240,9 +2240,14 @@
22412241 }
22422242 }
22432243
2244 - return this.tokenArray; // array of tokens
 2244+ return context.modules.highlight.tokenArray; // array of tokens
22452245 },
2246 - markers: [],
 2246+ /**
 2247+ * Marks up text with HTML
 2248+ *
 2249+ * @param division
 2250+ * @param tokens
 2251+ */
22472252 mark: function( context, division, tokens ) {
22482253 // We need to markup some text based on some tokens
22492254 var rawText = context.fn.getContents();
@@ -2253,32 +2258,26 @@
22542259 $.wikiEditor.modules[module].evt.mark();
22552260 }
22562261 }
2257 - markedText = "";
 2262+ markedText = '';
22582263 var previousIndex = 0;
2259 - for(var currentIndex in this.markers){
2260 - markedText+= rawText.substring(previousIndex, currentIndex);
2261 - for(var i = 0 ; i < this.markers[currentIndex].length; i++){
2262 - markedText += this.markers[currentIndex][i];
 2264+ for ( var currentIndex in context.modules.highlight.markers ){
 2265+ markedText += rawText.substring( previousIndex, currentIndex );
 2266+ for( var i = 0 ; i < context.modules.highlight.markers[currentIndex].length; i++ ){
 2267+ markedText += context.modules.highlight.markers[currentIndex][i];
22632268 }
22642269 previousIndex = currentIndex;
22652270 }
2266 - if(markedText != ""){
2267 - markedText.replace(/\n/g, '<br\>');
 2271+ if ( markedText != '' ){
 2272+ markedText.replace( /\n/g, '<br\>' );
22682273 context.fn.setContents( { contents:markedText } );
22692274 }
2270 - }//mark
 2275+ }
22712276 }
22722277
22732278 }; })( jQuery );/* Preview module for wikiEditor */
22742279 ( function( $ ) { $.wikiEditor.modules.preview = {
22752280
22762281 /**
2277 - * API accessible functions
2278 - */
2279 -api: {
2280 - //
2281 -},
2282 -/**
22832282 * Internally used functions
22842283 */
22852284 fn: {
@@ -2417,12 +2416,6 @@
24182417 ( function( $ ) { $.wikiEditor.modules.publish = {
24192418
24202419 /**
2421 - * API accessible functions
2422 - */
2423 -api: {
2424 - //
2425 -},
2426 -/**
24272420 * Internally used functions
24282421 */
24292422 fn: {
@@ -2526,80 +2519,80 @@
25272520 }
25282521 }
25292522
2530 -}; } )( jQuery );/* template forms module for wikiEditor */
 2523+}; } )( jQuery );/* TemplateEditor module for wikiEditor */
25312524 ( function( $ ) { $.wikiEditor.modules.templateEditor = {
25322525
25332526 /**
2534 - * API accessible functions
 2527+ * Event handlers
25352528 */
2536 -api: {
2537 - //
2538 -},
2539 -
25402529 evt: {
2541 - mark: function() {
2542 - function findOutermostTemplates( tokenStack ) {
2543 - templateBeginFound = false;
2544 - for ( ;i< tokenStack.length; i++ ) {
2545 - if ( tokenStack[i].label == "TEMPLATE_BEGIN" ) {
2546 - templateBeginFound = true;
2547 - break;
2548 - }
 2530+ mark: function( context, event ) {
 2531+ // This is shared by both the closure findOutermostTemplates and the calling code - is this a good idea?
 2532+ var i = 0;
 2533+ /**
 2534+ * Finds the left and right character positions of the outer-most template declaration, playing nicely with
 2535+ * nested template calls of any depth. This function acts as an iterator, which is why the i var is shared - but
 2536+ * this seems a bit scary seeing as 'i' is so often used in loops.
 2537+ *
 2538+ * @param tokenStack Array of tokens to find boundries within
 2539+ */
 2540+ function findOutermostTemplates( tokenStack ) {
 2541+ var templateBeginFound = false;
 2542+ for ( ; i < tokenStack.length; i++ ) {
 2543+ if ( tokenStack[i].label == 'TEMPLATE_BEGIN' ) {
 2544+ templateBeginFound = true;
 2545+ break;
25492546 }
2550 - var j = i;
2551 - i++;
2552 - if ( !templateBeginFound ) {
 2547+ }
 2548+ var j = i++;
 2549+ if ( !templateBeginFound ) {
 2550+ return false;
 2551+ } else {
 2552+ // This is only designed to find the outermost template boundaries, the model handles nested template
 2553+ // and template-like objects better
 2554+ var nestedBegins = 1;
 2555+ while ( nestedBegins > 0 && j < tokenStack.length ) {
 2556+ var label = tokenStack[++j].label;
 2557+ nestedBegins += label == 'TEMPLATE_END' ? -1 : label == 'TEMPLATE_BEGIN' ? 1 : 0;
 2558+ }
 2559+ if ( nestedBegins == 0 ) {
 2560+ // Outer template begins at tokenStack[i].offset and ends at tokenStack[j].offset + 2
 2561+ var leftMarker = i -1;
 2562+ var rightMarker = j;
 2563+ i = j;
 2564+ return [leftMarker, rightMarker];
 2565+ } else {
25532566 return false;
2554 - } else {
2555 - // This is only designed to find the outermost template boundaries, the model handles nested template
2556 - // and template-like objects better
2557 - var nestedBegins = 1;
2558 - while ( nestedBegins > 0 && j < tokenStack.length ) {
2559 - j++;
2560 - if ( tokenStack[j].label == "TEMPLATE_END" ) {
2561 - nestedBegins--;
2562 - }
2563 - if ( tokenStack[j].label == "TEMPLATE_BEGIN" ) {
2564 - nestedBegins++;
2565 - }
2566 - }
2567 - if ( nestedBegins == 0 ) {
2568 - // outer template begins at tokenStack[i].offset
2569 - // and ends at tokenStack[j].offset + 2
2570 - var leftMarker = i -1;
2571 - var rightMarker = j;
2572 - i = j;
2573 - return [ leftMarker, rightMarker ];
2574 - } else {
2575 - return false;
2576 - }
25772567 }
2578 - }; //find outermost templates
2579 -
2580 - markers = $.wikiEditor.modules.highlight.fn.markers;
2581 - var tokenStack = $.wikiEditor.modules.highlight.fn.tokenArray;
2582 - i = 0;
2583 - var templateBoundaries;
2584 - templateBeginFound = false;
2585 -
2586 - while ( templateBoundaries = findOutermostTemplates( tokenStack ) ) {
2587 - if ( typeof markers[tokenStack[templateBoundaries[0]].offset] == 'undefined' ) {
2588 - markers[tokenStack[templateBoundaries[0]].offset] = [];
2589 - }
2590 - if ( typeof markers[tokenStack[templateBoundaries[1]].offset] == 'undefined' ) {
2591 - markers[tokenStack[templateBoundaries[1]].offset] = [];
2592 - }
2593 - markers[tokenStack[templateBoundaries[0]].offset].push( "<div class='wiki-template'>" );
2594 - markers[tokenStack[templateBoundaries[1]].offset].push( "</div>" );
25952568 }
 2569+ };
 2570+ // Get the markers and tokens from the current context
 2571+ var markers = context.modules.highlight.data.markers;
 2572+ var tokenStack = context.modules.highlight.data.tokenArray;
 2573+ // Scan through and detect the boundries of template calls
 2574+ var templateBeginFound = false;
 2575+ var templateBoundaries;
 2576+ while ( templateBoundaries = findOutermostTemplates( tokenStack ) ) {
 2577+ // Ensure indexes exist for left and right boundry markers
 2578+ if ( typeof markers[tokenStack[templateBoundaries[0]].offset] == 'undefined' ) {
 2579+ markers[tokenStack[templateBoundaries[0]].offset] = [];
 2580+ }
 2581+ if ( typeof markers[tokenStack[templateBoundaries[1]].offset] == 'undefined' ) {
 2582+ markers[tokenStack[templateBoundaries[1]].offset] = [];
 2583+ }
 2584+ // Append boundry markers
 2585+ markers[tokenStack[templateBoundaries[0]].offset].push( "<div class='wiki-template'>" );
 2586+ markers[tokenStack[templateBoundaries[1]].offset].push( "</div>" );
25962587 }
 2588+ }
25972589 },
2598 -
 2590+/**
 2591+ * Regular expressions that produce tokens
 2592+ */
25992593 exp: [
2600 - { regex: /{{/, label: "TEMPLATE_BEGIN" },
2601 - { regex: /}}/, label: "TEMPLATE_END", markAfter: true }
 2594+ { 'regex': /{{/, 'label': "TEMPLATE_BEGIN" },
 2595+ { 'regex': /}}/, 'label': "TEMPLATE_END", 'markAfter': true }
26022596 ],
2603 -
26042597 /**
26052598 * Internally used functions
26062599 */
@@ -2610,14 +2603,28 @@
26112604 * @param config Configuration object to create module from
26122605 */
26132606 create: function( context, config ) {
 2607+ // Initialize module within the context
 2608+ },
 2609+ /**
 2610+ * Builds a template model from given wikitext representation, allowing object-oriented manipulation of the contents
 2611+ * of the template while preserving whitespace and formatting.
 2612+ *
 2613+ * @param wikitext String of wikitext content
 2614+ */
 2615+ model: function( wikitext ) {
26142616
2615 - //initializations
 2617+ /* Private Functions */
26162618
2617 - },
2618 -
2619 - //template Model
2620 - model: function( wikitext ) {
2621 - // Param object
 2619+ /**
 2620+ * Builds a Param object.
 2621+ *
 2622+ * @param name
 2623+ * @param value
 2624+ * @param number
 2625+ * @param nameIndex
 2626+ * @param equalsIndex
 2627+ * @param valueIndex
 2628+ */
26222629 function Param( name, value, number, nameIndex, equalsIndex, valueIndex ) {
26232630 this.name = name;
26242631 this.value = value;
@@ -2626,56 +2633,167 @@
26272634 this.equalsIndex = equalsIndex;
26282635 this.valueIndex = valueIndex;
26292636 }
2630 -
2631 - // Range object
 2637+ /**
 2638+ * Builds a Range object.
 2639+ *
 2640+ * @param begin
 2641+ * @param end
 2642+ */
26322643 function Range( begin, end ) {
26332644 this.begin = begin;
26342645 this.end = end;
26352646 }
 2647+ /**
 2648+ * Set 'original' to true if you want the original value irrespective of whether the model's been changed
 2649+ *
 2650+ * @param name
 2651+ * @param value
 2652+ * @param original
 2653+ */
 2654+ function getSetValue( name, value, original ) {
 2655+ var valueRange;
 2656+ var rangeIndex;
 2657+ var retVal;
 2658+ if ( isNaN( name ) ) {
 2659+ // It's a string!
 2660+ if ( typeof paramsByName[name] == 'undefined' ) {
 2661+ // Does not exist
 2662+ return "";
 2663+ }
 2664+ rangeIndex = paramsByName[name];
 2665+ } else {
 2666+ // It's a number!
 2667+ rangeIndex = parseInt( name );
 2668+ }
 2669+ if ( typeof params[rangeIndex] == 'undefined' ) {
 2670+ // Does not exist
 2671+ return "";
 2672+ }
 2673+ valueRange = ranges[params[rangeIndex].valueIndex];
 2674+ if ( typeof valueRange.newVal == 'undefined' || original ) {
 2675+ // Value unchanged, return original wikitext
 2676+ retVal = wikitext.substring( valueRange.begin, valueRange.end );
 2677+ } else {
 2678+ // New value exists, return new value
 2679+ retVal = valueRange.newVal;
 2680+ }
 2681+ if ( value != null ) {
 2682+ ranges[params[rangeIndex].valueIndex].newVal = value;
 2683+ }
 2684+ return retVal;
 2685+ };
26362686
2637 - var ranges = [];
2638 - var sanatizedStr = "";
2639 - var params = [];
2640 - var paramsByName = [];
2641 - var templateNameIndex = 0;
 2687+ /* Public Functions */
26422688
2643 - //takes all template-specific characters, namely {|=} away if they're not particular to the
2644 - //template we're looking at
2645 - function markOffTemplates() {
2646 - sanatizedStr = wikitext.replace( /{{/, " " ); //get rid of first {{ with whitespace
2647 - endBraces = sanatizedStr.match( /}}\s*$/ ); //replace end
2648 - sanatizedStr = sanatizedStr.substring( 0, endBraces.index ) + " " +
2649 - sanatizedStr.substring( endBraces.index + 2 );
2650 -
2651 - //match the open braces we just found with equivalent closing braces
2652 - //note, works for any level of braces
2653 - while ( sanatizedStr.indexOf( '{{' ) != -1 ) {
2654 - startIndex = sanatizedStr.indexOf('{{') + 1;
2655 - openBraces = 2;
2656 - endIndex = startIndex;
2657 - while ( openBraces > 0 ) {
2658 - endIndex++;
2659 - switch ( sanatizedStr[endIndex] ) {
2660 - case '}': openBraces--; break;
2661 - case '{': openBraces++; break;
2662 - }
 2689+ /**
 2690+ * Get template name
 2691+ */
 2692+ this.getName = function() {
 2693+ if( typeof ranges[templateNameIndex].newVal == 'undefined' ) {
 2694+ return wikitext.substring( ranges[templateNameIndex].begin, ranges[templateNameIndex].end );
 2695+ } else {
 2696+ return ranges[templateNameIndex].newVal;
 2697+ }
 2698+ };
 2699+ /**
 2700+ * Set template name (if we want to support this)
 2701+ *
 2702+ * @param name
 2703+ */
 2704+ this.setName = function( name ) {
 2705+ ranges[templateNameIndex].newVal = name;
 2706+ };
 2707+ /**
 2708+ * Set value for a given param name / number
 2709+ *
 2710+ * @param name
 2711+ * @param value
 2712+ */
 2713+ this.setValue = function( name, value ) {
 2714+ return getSetValue( name, value, false );
 2715+ };
 2716+ /**
 2717+ * Get value for a given param name / number
 2718+ *
 2719+ * @param name
 2720+ */
 2721+ this.getValue = function( name ) {
 2722+ return getSetValue( name, null, false );
 2723+ };
 2724+ /**
 2725+ * Get original value of a param
 2726+ *
 2727+ * @param name
 2728+ */
 2729+ this.getOriginalValue = function( name ) {
 2730+ return getSetValue( name, null, true );
 2731+ };
 2732+ /**
 2733+ * Get a list of all param names (numbers for the anonymous ones)
 2734+ */
 2735+ this.getAllParamNames = function() {
 2736+ return paramsByName;
 2737+ };
 2738+ /**
 2739+ * Get the initial params
 2740+ */
 2741+ this.getAllInitialParams = function(){
 2742+ return params;
 2743+ }
 2744+ /**
 2745+ * Get original template text
 2746+ */
 2747+ this.getOriginalText = function() {
 2748+ return wikitext;
 2749+ };
 2750+ /**
 2751+ * Get modified template text
 2752+ */
 2753+ this.getText = function() {
 2754+ newText = "";
 2755+ for ( i = 0 ; i < ranges.length; i++ ) {
 2756+ if( typeof ranges[i].newVal == 'undefined' ) {
 2757+ wikitext.substring( ranges[i].begin, ranges[i].end );
 2758+ } else {
 2759+ newText += ranges[i].newVal;
26632760 }
2664 - sanatizedSegment = sanatizedStr.substring( startIndex,endIndex )
2665 - .replace( /[{}|=]/g , 'X' );
2666 - sanatizedStr = sanatizedStr.substring( 0, startIndex ) +
2667 - sanatizedSegment + sanatizedStr.substring( endIndex );
2668 - }//while
2669 - return sanatizedStr;
 2761+ }
 2762+ return newText;
26702763 };
2671 -
 2764+
26722765 // Whitespace* {{ whitespace* nonwhitespace:
26732766 if ( wikitext.match( /\s*{{\s*\S*:/ ) ) {
2674 - // we have a parser function!
 2767+ // We have a parser function!
26752768 }
2676 -
2677 - markOffTemplates();
2678 -
2679 - //parse 1 param at a time
 2769+ /*
 2770+ * Take all template-specific characters that are not particular to the template we're looking at, namely {|=},
 2771+ * and convert them into something harmless, in this case 'X'
 2772+ */
 2773+ // Get rid of first {{ with whitespace
 2774+ var sanatizedStr = wikitext.replace( /{{/, " " );
 2775+ // Replace end
 2776+ endBraces = sanatizedStr.match( /}}\s*$/ );
 2777+ sanatizedStr =
 2778+ sanatizedStr.substring( 0, endBraces.index ) + " " + sanatizedStr.substring( endBraces.index + 2 );
 2779+ // Match the open braces we just found with equivalent closing braces note, works for any level of braces
 2780+ while ( sanatizedStr.indexOf( '{{' ) != -1 ) {
 2781+ startIndex = sanatizedStr.indexOf('{{') + 1;
 2782+ openBraces = 2;
 2783+ endIndex = startIndex;
 2784+ while ( openBraces > 0 ) {
 2785+ var brace = sanatizedStr[++endIndex];
 2786+ openBraces += brace == '}' ? -1 : brace == '{' ? 1 : 0;
 2787+ }
 2788+ sanatizedSegment = sanatizedStr.substring( startIndex,endIndex ).replace( /[{}|=]/g , 'X' );
 2789+ sanatizedStr =
 2790+ sanatizedStr.substring( 0, startIndex ) + sanatizedSegment + sanatizedStr.substring( endIndex );
 2791+ }
 2792+ /*
 2793+ * Parse 1 param at a time
 2794+ */
 2795+ var ranges = [];
 2796+ var params = [];
 2797+ var templateNameIndex = 0;
26802798 var doneParsing = false;
26812799 oldDivider = 0;
26822800 divider = sanatizedStr.indexOf( '|', oldDivider );
@@ -2693,11 +2811,12 @@
26942812 ranges[templateNameIndex].end );
26952813 }
26962814 params.push( ranges[templateNameIndex].old ); //put something in params (0)
2697 -
2698 - currentParamNumber = 0;
 2815+ /*
 2816+ * Start looping over params
 2817+ */
 2818+ var currentParamNumber = 0;
26992819 var valueEndIndex;
2700 -
2701 - //start looping over params
 2820+ var paramsByName = [];
27022821 while ( !doneParsing ) {
27032822 currentParamNumber++;
27042823 oldDivider = divider;
@@ -2726,163 +2845,64 @@
27272846 currentParamNumber, nameIndex, equalsIndex, valueIndex ) );
27282847 paramsByName[currentParamNumber] = currentParamNumber;
27292848 } else {
2730 - // there's an equals, could be comment or a value pair
 2849+ // There's an equals, could be comment or a value pair
27312850 currentName = currentField.substring( 0, currentField.indexOf( '=' ) );
2732 - // (still offset by oldDivider)
2733 - nameBegin = currentName.match( /\S+/ ); //first nonwhitespace character
 2851+ // Still offset by oldDivider - first nonwhitespace character
 2852+ nameBegin = currentName.match( /\S+/ );
27342853 if ( nameBegin == null ) {
2735 - // this is a comment inside a template call/parser abuse. let's not encourage it
 2854+ // This is a comment inside a template call / parser abuse. let's not encourage it
27362855 divider++;
27372856 currentParamNumber--;
27382857 continue;
27392858 }
27402859 nameBeginIndex = nameBegin.index + oldDivider + 1;
2741 - nameEnd = currentName.match( /[^\s]\s*$/ ); //last nonwhitespace and non } character
 2860+ // Last nonwhitespace and non } character
 2861+ nameEnd = currentName.match( /[^\s]\s*$/ );
27422862 nameEndIndex = nameEnd.index + oldDivider + 2;
2743 -
2744 - ranges.push( new Range( ranges[ranges.length-1].end,
2745 - nameBeginIndex ) ); //all the chars upto now
2746 - nameIndex = ranges.push( new Range( nameBeginIndex, nameEndIndex ) );
2747 - nameIndex--;
 2863+ // All the chars upto now
 2864+ ranges.push( new Range( ranges[ranges.length-1].end, nameBeginIndex ) );
 2865+ nameIndex = ranges.push( new Range( nameBeginIndex, nameEndIndex ) ) - 1;
27482866 currentValue = currentField.substring( currentField.indexOf( '=' ) + 1);
27492867 oldDivider += currentField.indexOf( '=' ) + 1;
2750 - valueBegin = currentValue.match( /\S+/ ); //first nonwhitespace character
 2868+ // First nonwhitespace character
 2869+ valueBegin = currentValue.match( /\S+/ );
27512870 valueBeginIndex = valueBegin.index + oldDivider + 1;
2752 - valueEnd = currentValue.match( /[^\s]\s*$/ ); //last nonwhitespace and non } character
 2871+ // Last nonwhitespace and non } character
 2872+ valueEnd = currentValue.match( /[^\s]\s*$/ );
27532873 valueEndIndex = valueEnd.index + oldDivider + 2;
2754 - equalsIndex = ranges.push( new Range( ranges[ranges.length-1].end,
2755 - valueBeginIndex) ); //all the chars upto now
2756 - equalsIndex--;
2757 - valueIndex = ranges.push( new Range( valueBeginIndex, valueEndIndex ) );
2758 - valueIndex--;
2759 - params.push( new Param( wikitext.substring( nameBeginIndex, nameEndIndex ),
 2874+ // All the chars upto now
 2875+ equalsIndex = ranges.push( new Range( ranges[ranges.length-1].end, valueBeginIndex) ) - 1;
 2876+ valueIndex = ranges.push( new Range( valueBeginIndex, valueEndIndex ) ) - 1;
 2877+ params.push( new Param(
 2878+ wikitext.substring( nameBeginIndex, nameEndIndex ),
27602879 wikitext.substring( valueBeginIndex, valueEndIndex ),
2761 - currentParamNumber, nameIndex, equalsIndex, valueIndex ) );
 2880+ currentParamNumber,
 2881+ nameIndex,
 2882+ equalsIndex,
 2883+ valueIndex
 2884+ ) );
27622885 paramsByName[wikitext.substring( nameBeginIndex, nameEndIndex )] = currentParamNumber;
27632886 }
27642887 }
2765 - //the rest of the string
 2888+ // The rest of the string
27662889 ranges.push( new Range( valueEndIndex, wikitext.length ) );
2767 -
2768 - //FUNCTIONS
2769 - //set 'original' to true if you want the original value irrespective of whether the model's been changed
2770 - function getSetValue( name, value, original ) {
2771 - var valueRange;
2772 - var rangeIndex;
2773 - var retVal;
2774 - if ( isNaN( name ) ) {
2775 - // it's a string!
2776 - if ( typeof paramsByName[name] == 'undefined' ) {
2777 - //does not exist
2778 - return "";
2779 - }
2780 - rangeIndex = paramsByName[name];
2781 - } else {
2782 - //it's a number!
2783 - rangeIndex = parseInt( name );
2784 - }
2785 -
2786 - if ( typeof params[rangeIndex] == 'undefined' ) {
2787 - //does not exist
2788 - return "";
2789 - }
2790 - valueRange = ranges[params[rangeIndex].valueIndex];
2791 -
2792 - if ( typeof valueRange.newVal == 'undefined' || original ) {
2793 - //value unchanged, return original wikitext
2794 - retVal = wikitext.substring( valueRange.begin, valueRange.end );
2795 - } else {
2796 - //new value exists, return new value
2797 - retVal = valueRange.newVal;
2798 - }
2799 -
2800 - if ( value != null ) {
2801 - ranges[params[rangeIndex].valueIndex].newVal = value;
2802 - }
2803 -
2804 - return retVal;
2805 - };
2806 -
2807 - //'public' functions
2808 -
2809 - //get template name
2810 - this.getName = function() {
2811 - if( typeof ranges[templateNameIndex].newVal == 'undefined' ) {
2812 - return wikitext.substring( ranges[templateNameIndex].begin,
2813 - ranges[templateNameIndex].end );
2814 -
2815 - } else {
2816 - return ranges[templateNameIndex].newVal;
2817 - }
2818 - };
2819 -
2820 - //set template name (if we want to support this)
2821 - this.setName = function( name ) {
2822 - ranges[templateNameIndex].newVal = name;
2823 - };
2824 -
2825 - //set value for a given param name/number
2826 - this.setValue = function( name, value ) {
2827 - return getSetValue( name, value, false );
2828 - };
 2890+ } // model
 2891+}
28292892
2830 - //get value for a given param name/number
2831 - this.getValue = function( name ) {
2832 - return getSetValue( name, null, false );
2833 - };
2834 -
2835 - //get original value of a param
2836 - this.getOriginalValue = function( name ) {
2837 - return getSetValue( name, null, true );
2838 - };
2839 -
2840 - //get a list of all param names (numbers for the anonymous ones)
2841 - this.getAllParamNames = function() {
2842 - return paramsByName;
2843 - };
2844 -
2845 - //get the initial params
2846 - this.getAllInitialParams = function(){
2847 - return params;
2848 - }
2849 -
2850 - //get original template text
2851 - this.getOriginalText = function() {
2852 - return wikitext;
2853 - };
2854 -
2855 - //get modified template text
2856 - this.getText = function() {
2857 - newText = "";
2858 - for ( i = 0 ; i < ranges.length; i++ ) {
2859 - if( typeof ranges[i].newVal == 'undefined' ) {
2860 - wikitext.substring( ranges[i].begin, ranges[i].end );
2861 - } else {
2862 - newText += ranges[i].newVal;
2863 - }
2864 - }
2865 - return newText;
2866 - };
2867 - }//template model
2868 -
2869 -}//fn
2870 -
28712893 }; } )( jQuery );
2872 -
2873 -
28742894 /* TOC Module for wikiEditor */
28752895 ( function( $ ) { $.wikiEditor.modules.toc = {
2876 -
 2896+
28772897 /**
2878 - * Default width of table of contents
 2898+ * Configuration
28792899 */
2880 -defaultWidth: '166px',
 2900+cfg: {
 2901+ // Default width of table of contents
 2902+ defaultWidth: '166px',
 2903+ // Minimum width to allow resizing to before collapsing the table of contents - used when resizing and collapsing
 2904+ minimumWidth: '70px',
 2905+},
28812906 /**
2882 - * Minimum width to allow resizing to before collapsing the table of contents
2883 - * Only used if resizing and collapsing is enabled
2884 - */
2885 -minimumWidth: '70px',
2886 -/**
28872907 * API accessible functions
28882908 */
28892909 api: {
@@ -2940,15 +2960,15 @@
29412961 .addClass( 'wikiEditor-ui-toc' )
29422962 .data( 'context', context );
29432963 context.$ui.find( '.wikiEditor-ui-right' )
2944 - .css( 'width', $.wikiEditor.modules.toc.defaultWidth )
 2964+ .css( 'width', $.wikiEditor.modules.toc.cfg.defaultWidth )
29452965 .append( context.modules.toc.$toc );
29462966 context.modules.toc.$toc.height(
29472967 context.$ui.find( '.wikiEditor-ui-left' ).height()
29482968 );
29492969 context.$ui.find( '.wikiEditor-ui-left' )
2950 - .css( 'marginRight', "-" + $.wikiEditor.modules.toc.defaultWidth )
 2970+ .css( 'marginRight', "-" + $.wikiEditor.modules.toc.cfg.defaultWidth )
29512971 .children()
2952 - .css( 'marginRight', $.wikiEditor.modules.toc.defaultWidth );
 2972+ .css( 'marginRight', $.wikiEditor.modules.toc.cfg.defaultWidth );
29532973 },
29542974
29552975 unhighlight: function( context ) {
@@ -3152,7 +3172,14 @@
31533173 // Toss a transparent cover over our iframe
31543174 $( '<div />' )
31553175 .addClass( 'wikiEditor-ui-resize-mask' )
3156 - .css( { 'position': 'absolute', 'z-index': 2, 'left': 0, 'top': 0, 'bottom': 0, 'right': 0 } )
 3176+ .css( {
 3177+ 'position': 'absolute',
 3178+ 'z-index': 2,
 3179+ 'left': 0,
 3180+ 'top': 0,
 3181+ 'bottom': 0,
 3182+ 'right': 0
 3183+ } )
31573184 .appendTo( context.$ui.find( '.wikiEditor-ui-left' ) );
31583185 $this.resizable( 'option', 'maxWidth', $this.parent().width() - 450 );
31593186 },
@@ -3168,7 +3195,7 @@
31693196 stop: function ( e, ui ) {
31703197 context.$ui.find( '.wikiEditor-ui-resize-mask' ).remove();
31713198 context.$content.trigger( 'mouseup' );
3172 - if( ui.size.width < parseFloat( $.wikiEditor.modules.toc.minimumWidth ) ) {
 3199+ if( ui.size.width < parseFloat( $.wikiEditor.modules.toc.cfg.minimumWidth ) ) {
31733200 context.modules.toc.$toc.trigger( 'collapse' );
31743201 } else {
31753202 context.modules.toc.$toc.data( 'openWidth', ui.size.width );
@@ -3188,14 +3215,14 @@
31893216 context.modules.toc.$toc
31903217 .bind( 'collapse.wikiEditor-toc', $.wikiEditor.modules.toc.fn.collapse )
31913218 .bind( 'expand.wikiEditor-toc', $.wikiEditor.modules.toc.fn.expand );
3192 - context.modules.toc.$toc.data( 'openWidth', $.wikiEditor.modules.toc.defaultWidth );
 3219+ context.modules.toc.$toc.data( 'openWidth', $.wikiEditor.modules.toc.cfg.defaultWidth );
31933220 // If the toc-width cookie is set, reset the widths based upon that
31943221 if ( $.cookie( 'wikiEditor-' + context.instance + '-toc-width' ) == 0 ) {
31953222 context.modules.toc.$toc.trigger( 'collapse.wikiEditor-toc', { data: context } );
31963223 } else if ( $.cookie( 'wikiEditor-' + context.instance + '-toc-width' ) > 0 ) {
31973224 var initialWidth = $.cookie( 'wikiEditor-' + context.instance + '-toc-width' );
3198 - if( initialWidth < parseFloat( $.wikiEditor.modules.toc.minimumWidth ) )
3199 - initialWidth = parseFloat( $.wikiEditor.modules.toc.minimumWidth ) + 1;
 3225+ if( initialWidth < parseFloat( $.wikiEditor.modules.toc.cfg.minimumWidth ) )
 3226+ initialWidth = parseFloat( $.wikiEditor.modules.toc.cfg.minimumWidth ) + 1;
32003227 context.modules.toc.$toc.data( 'openWidth', initialWidth + 'px' );
32013228 context.$ui.find( '.wikiEditor-ui-right' )
32023229 .css( 'width', initialWidth + 'px' );
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -116,24 +116,23 @@
117117 arguments=$.makeArray(arguments);if(arguments.length>0){var call=arguments.shift();if(call in context.api){context.api[call](context,typeof arguments[0]=='undefined'?{}:arguments[0]);}}
118118 return $(this).data('wikiEditor-context',context);};})(jQuery);RegExp.escape=function(s){return s.replace(/([.*+?^${}()|\/\\[\]])/g,'\\$1');};(function($){$.wikiEditor.modules.dialogs={api:{addDialog:function(context,data){$.wikiEditor.modules.dialogs.fn.create(context,data)},openDialog:function(context,module){if(module in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[module].id).dialog('open');}},closeDialog:function(context,data){if(module in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[module].id).dialog('close');}}},fn:{create:function(context,config){for(module in config){$.wikiEditor.modules.dialogs.modules[module]=config[module];}
119119 mw.load(['$j.ui','$j.ui.dialog','$j.ui.draggable','$j.ui.resizable'],function(){for(module in $.wikiEditor.modules.dialogs.modules){var module=$.wikiEditor.modules.dialogs.modules[module];if($('#'+module.id).size()==0){var configuration=module.dialog;configuration.bgiframe=true;configuration.autoOpen=false;configuration.modal=true;configuration.title=$.wikiEditor.autoMsg(module,'title');configuration.newButtons={};for(msg in configuration.buttons)
120 -configuration.newButtons[gM(msg)]=configuration.buttons[msg];configuration.buttons=configuration.newButtons;var dialogDiv=$('<div /> ').attr('id',module.id).html(module.html).data('context',context).appendTo($('body')).each(module.init).dialog(configuration);if(!('resizeme'in module)||module.resizeme)
121 -dialogDiv.bind('dialogopen',$.wikiEditor.modules.dialogs.fn.resize).find('.ui-tabs').bind('tabsshow',function(){$(this).closest('.ui-dialog-content').each($.wikiEditor.modules.dialogs.fn.resize);});var maxTI=0;$j('[tabindex]').each(function(){var ti=parseInt($j(this).attr('tabindex'));if(ti>maxTI)
122 -maxTI=ti;});var tabIndex=maxTI+1;$j('.ui-dialog input, .ui-dialog button').not('[tabindex]').each(function(){$j(this).attr('tabindex',tabIndex++);});}}});},resize:function(){var wrapper=$(this).closest('.ui-dialog');var oldWidth=wrapper.width();var oldHidden=$(this).find('*').not(':visible');oldHidden.each(function(){$(this).data('oldstyle',$(this).attr('style'));});oldHidden.show();var oldWS=$(this).css('white-space');$(this).css('white-space','nowrap');if(wrapper.width()<=$(this).get(0).scrollWidth){var thisWidth=$(this).data('thisWidth')?$(this).data('thisWidth'):0;thisWidth=Math.max($(this).get(0).scrollWidth,thisWidth);$(this).width(thisWidth);$(this).data('thisWidth',thisWidth);var wrapperWidth=$(this).data('wrapperWidth')?$(this).data('wrapperWidth'):0;wrapperWidth=Math.max(wrapper.get(0).scrollWidth,wrapperWidth);wrapper.width(wrapperWidth);$(this).data('wrapperWidth',wrapperWidth);$(this).dialog({'width':wrapper.width()});wrapper.css('left',parseInt(wrapper.css('left'))-
123 -(wrapper.width()-oldWidth)/2);}
124 -$(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});}},modules:{},quickDialog:function(body,settings){$('<div />').text(body).appendTo($('body')).dialog($.extend({bgiframe:true,modal:true},settings)).dialog('open');}};})(jQuery);(function($){$.wikiEditor.modules.highlight={api:{},evt:{change:function(context,event){if(event.data.scope=='do_not_trigger'){$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}}},fn:{create:function(context,config){},divide:function(context){},isolate:function(context){return[];},strip:function(context,division){return $('<div />').html(division.html().replace(/\<br[^\>]*\>/g,"\n")).text();},tokenArray:[],scan:function(context,division){function Token(offset,label){this.offset=offset;this.label=label;}
125 -this.tokenArray=[];var text=context.fn.getContents();for(module in $.wikiEditor.modules){if('exp'in $.wikiEditor.modules[module]){for(var i=0;i<$.wikiEditor.modules[module].exp.length;i++){var regex=$.wikiEditor.modules[module].exp[i].regex;var label=$.wikiEditor.modules[module].exp[i].label;var markAfter=false;if(typeof $.wikiEditor.modules[module].exp[i].markAfter!='undefined'){markAfter=true;}
 120+configuration.newButtons[gM(msg)]=configuration.buttons[msg];configuration.buttons=configuration.newButtons;var dialogDiv=$('<div /> ').attr('id',module.id).html(module.html).data('context',context).appendTo($('body')).each(module.init).dialog(configuration);if(!('resizeme'in module)||module.resizeme){dialogDiv.bind('dialogopen',$.wikiEditor.modules.dialogs.fn.resize).find('.ui-tabs').bind('tabsshow',function(){$(this).closest('.ui-dialog-content').each($.wikiEditor.modules.dialogs.fn.resize);});}
 121+var maxTI=0;$j('[tabindex]').each(function(){var ti=parseInt($j(this).attr('tabindex'));if(ti>maxTI)
 122+maxTI=ti;});var tabIndex=maxTI+1;$j('.ui-dialog input, .ui-dialog button').not('[tabindex]').each(function(){$j(this).attr('tabindex',tabIndex++);});}}});},resize:function(){var wrapper=$(this).closest('.ui-dialog');var oldWidth=wrapper.width();var oldHidden=$(this).find('*').not(':visible');oldHidden.each(function(){$(this).data('oldstyle',$(this).attr('style'));});oldHidden.show();var oldWS=$(this).css('white-space');$(this).css('white-space','nowrap');if(wrapper.width()<=$(this).get(0).scrollWidth){var thisWidth=$(this).data('thisWidth')?$(this).data('thisWidth'):0;thisWidth=Math.max($(this).get(0).scrollWidth,thisWidth);$(this).width(thisWidth);$(this).data('thisWidth',thisWidth);var wrapperWidth=$(this).data('wrapperWidth')?$(this).data('wrapperWidth'):0;wrapperWidth=Math.max(wrapper.get(0).scrollWidth,wrapperWidth);wrapper.width(wrapperWidth);$(this).data('wrapperWidth',wrapperWidth);$(this).dialog({'width':wrapper.width()});wrapper.css('left',parseInt(wrapper.css('left'))-(wrapper.width()-oldWidth)/2);}
 123+$(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});}},modules:{},quickDialog:function(body,settings){$('<div />').text(body).appendTo($('body')).dialog($.extend({bgiframe:true,modal:true},settings)).dialog('open');}};})(jQuery);(function($){$.wikiEditor.modules.highlight={evt:{change:function(context,event){if(event.data.scope=='do_not_trigger'){$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}}},fn:{create:function(context,config){},divide:function(context){},isolate:function(context){return[];},strip:function(context,division){return $('<div />').html(division.html().replace(/\<br[^\>]*\>/g,"\n")).text();},scan:function(context,division){function Token(offset,label){this.offset=offset;this.label=label;}
 124+context.modules.highlight.tokenArray=[];var text=context.fn.getContents();for(module in $.wikiEditor.modules){if('exp'in $.wikiEditor.modules[module]){for(var i=0;i<$.wikiEditor.modules[module].exp.length;i++){var regex=$.wikiEditor.modules[module].exp[i].regex;var label=$.wikiEditor.modules[module].exp[i].label;var markAfter=false;if(typeof $.wikiEditor.modules[module].exp[i].markAfter!='undefined'){markAfter=true;}
126125 match=text.match(regex);var oldOffset=0;while(match!=null){var markOffset=0;if(markAfter){markOffset+=match[0].length;}
127 -this.tokenArray.push(new Token(match.index+oldOffset+markOffset,label));oldOffset+=match.index+match[0].length;newSubstring=text.substring(oldOffset);match=newSubstring.match(regex);}}}}
128 -return this.tokenArray;},markers:[],mark:function(context,division,tokens){var rawText=context.fn.getContents();for(module in $.wikiEditor.modules){if('evt'in $.wikiEditor.modules[module]&&'mark'in $.wikiEditor.modules[module].evt){$.wikiEditor.modules[module].evt.mark();}}
129 -markedText="";var previousIndex=0;for(var currentIndex in this.markers){markedText+=rawText.substring(previousIndex,currentIndex);for(var i=0;i<this.markers[currentIndex].length;i++){markedText+=this.markers[currentIndex][i];}
 126+context.modules.highlight.tokenArray.push(new Token(match.index+oldOffset+markOffset,label));oldOffset+=match.index+match[0].length;newSubstring=text.substring(oldOffset);match=newSubstring.match(regex);}}}}
 127+return context.modules.highlight.tokenArray;},mark:function(context,division,tokens){var rawText=context.fn.getContents();for(module in $.wikiEditor.modules){if('evt'in $.wikiEditor.modules[module]&&'mark'in $.wikiEditor.modules[module].evt){$.wikiEditor.modules[module].evt.mark();}}
 128+markedText='';var previousIndex=0;for(var currentIndex in context.modules.highlight.markers){markedText+=rawText.substring(previousIndex,currentIndex);for(var i=0;i<context.modules.highlight.markers[currentIndex].length;i++){markedText+=context.modules.highlight.markers[currentIndex][i];}
130129 previousIndex=currentIndex;}
131 -if(markedText!=""){markedText.replace(/\n/g,'<br\>');context.fn.setContents({contents:markedText});}}}};})(jQuery);(function($){$.wikiEditor.modules.preview={api:{},fn:{create:function(context,config){if('initialized'in context.modules.preview){return;}
 130+if(markedText!=''){markedText.replace(/\n/g,'<br\>');context.fn.setContents({contents:markedText});}}}};})(jQuery);(function($){$.wikiEditor.modules.preview={fn:{create:function(context,config){if('initialized'in context.modules.preview){return;}
132131 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;}
133132 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;}
134133 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;}
135134 context.$changesTab.find('table.diff tbody').empty();context.$changesTab.find('.wikiEditor-preview-loading').show();var postdata={'action':'query','indexpageids':'','prop':'revisions','titles':wgPageName,'rvdifftotext':wikitext,'rvprop':'','format':'json'};var section=$('[name=wpSection]').val();if(section!='')
136135 postdata['rvsection']=section;$.post(wgScriptPath+'/api.php',postdata,function(data){if($('link[href='+stylepath+'/common/diff.css]').size()==0){$('head').append($('<link />').attr({'rel':'stylesheet','type':'text/css','href':stylepath+'/common/diff.css'}));}
137 -try{var diff=data.query.pages[data.query.pageids[0]].revisions[0].diff['*'];context.$changesTab.find('table.diff tbody').html(diff);context.$changesTab.find('.wikiEditor-preview-loading').hide();context.modules.preview.changesText=wikitext;}catch(e){}},'json');}});var loadingMsg=gM('wikieditor-preview-loading');context.modules.preview.$preview.add(context.$changesTab).append($('<div />').addClass('wikiEditor-preview-loading').append($('<img />').addClass('wikiEditor-preview-spinner').attr({'src':$.wikiEditor.imgPath+'dialogs/loading.gif','valign':'absmiddle','alt':loadingMsg,'title':loadingMsg})).append($('<span></span>').text(loadingMsg))).append($('<div />').addClass('wikiEditor-preview-contents'));context.$changesTab.find('.wikiEditor-preview-contents').html('<table class="diff"><col class="diff-marker" /><col class="diff-content" />'+'<col class="diff-marker" /><col class="diff-content" /><tbody /></table>');}}};})(jQuery);(function($){$.wikiEditor.modules.publish={api:{},fn:{create:function(context,config){var dialogID='wikiEditor-'+context.instance+'-dialog';$.wikiEditor.modules.dialogs.fn.create(context,{previewsave:{id:dialogID,titleMsg:'wikieditor-publish-dialog-title',html:'\
 136+try{var diff=data.query.pages[data.query.pageids[0]].revisions[0].diff['*'];context.$changesTab.find('table.diff tbody').html(diff);context.$changesTab.find('.wikiEditor-preview-loading').hide();context.modules.preview.changesText=wikitext;}catch(e){}},'json');}});var loadingMsg=gM('wikieditor-preview-loading');context.modules.preview.$preview.add(context.$changesTab).append($('<div />').addClass('wikiEditor-preview-loading').append($('<img />').addClass('wikiEditor-preview-spinner').attr({'src':$.wikiEditor.imgPath+'dialogs/loading.gif','valign':'absmiddle','alt':loadingMsg,'title':loadingMsg})).append($('<span></span>').text(loadingMsg))).append($('<div />').addClass('wikiEditor-preview-contents'));context.$changesTab.find('.wikiEditor-preview-contents').html('<table class="diff"><col class="diff-marker" /><col class="diff-content" />'+'<col class="diff-marker" /><col class="diff-content" /><tbody /></table>');}}};})(jQuery);(function($){$.wikiEditor.modules.publish={fn:{create:function(context,config){var dialogID='wikiEditor-'+context.instance+'-dialog';$.wikiEditor.modules.dialogs.fn.create(context,{previewsave:{id:dialogID,titleMsg:'wikieditor-publish-dialog-title',html:'\
138137 <div class="wikiEditor-dialog-copywarn"></div>\
139138 <div class="wikiEditor-dialog-editoptions">\
140139 <form>\
@@ -157,33 +156,30 @@
158157 $('#wikiEditor-'+context.instance+'-dialog-minor').hide();else if($('#wpMinoredit').is(':checked'))
159158 $('#wikiEditor-'+context.instance+'-dialog-minor').attr('checked','checked');if($('#wpWatchthis').size()==0)
160159 $('#wikiEditor-'+context.instance+'-dialog-watch').hide();else if($('#wpWatchthis').is(':checked'))
161 -$('#wikiEditor-'+context.instance+'-dialog-watch').attr('checked','checked');$(this).find('form').submit(function(e){$(this).closest('.ui-dialog').find('button:first').click();e.preventDefault();});},dialog:{buttons:{'wikieditor-publish-dialog-publish':function(){var minorChecked=$('#wikiEditor-'+context.instance+'-dialog-minor').is(':checked')?'checked':'';var watchChecked=$('#wikiEditor-'+context.instance+'-dialog-watch').is(':checked')?'checked':'';$('#wpMinoredit').attr('checked',minorChecked);$('#wpWatchthis').attr('checked',watchChecked);$('#wpSummary').val($j('#wikiEditor-'+context.instance+'-dialog-summary').val());$('#editform').submit();},'wikieditor-publish-dialog-goback':function(){$(this).dialog('close');}},open:function(){$('#wikiEditor-'+context.instance+'-dialog-summary').focus();},width:500},resizeme:false}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-publish','action':function(){$('#'+dialogID).dialog('open');return false;}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-cancel','action':function(){}});}}};})(jQuery);(function($){$.wikiEditor.modules.templateEditor={api:{},evt:{mark:function(){function findOutermostTemplates(tokenStack){templateBeginFound=false;for(;i<tokenStack.length;i++){if(tokenStack[i].label=="TEMPLATE_BEGIN"){templateBeginFound=true;break;}}
162 -var j=i;i++;if(!templateBeginFound){return false;}else{var nestedBegins=1;while(nestedBegins>0&&j<tokenStack.length){j++;if(tokenStack[j].label=="TEMPLATE_END"){nestedBegins--;}
163 -if(tokenStack[j].label=="TEMPLATE_BEGIN"){nestedBegins++;}}
164 -if(nestedBegins==0){var leftMarker=i-1;var rightMarker=j;i=j;return[leftMarker,rightMarker];}else{return false;}}};markers=$.wikiEditor.modules.highlight.fn.markers;var tokenStack=$.wikiEditor.modules.highlight.fn.tokenArray;i=0;var templateBoundaries;templateBeginFound=false;while(templateBoundaries=findOutermostTemplates(tokenStack)){if(typeof markers[tokenStack[templateBoundaries[0]].offset]=='undefined'){markers[tokenStack[templateBoundaries[0]].offset]=[];}
 160+$('#wikiEditor-'+context.instance+'-dialog-watch').attr('checked','checked');$(this).find('form').submit(function(e){$(this).closest('.ui-dialog').find('button:first').click();e.preventDefault();});},dialog:{buttons:{'wikieditor-publish-dialog-publish':function(){var minorChecked=$('#wikiEditor-'+context.instance+'-dialog-minor').is(':checked')?'checked':'';var watchChecked=$('#wikiEditor-'+context.instance+'-dialog-watch').is(':checked')?'checked':'';$('#wpMinoredit').attr('checked',minorChecked);$('#wpWatchthis').attr('checked',watchChecked);$('#wpSummary').val($j('#wikiEditor-'+context.instance+'-dialog-summary').val());$('#editform').submit();},'wikieditor-publish-dialog-goback':function(){$(this).dialog('close');}},open:function(){$('#wikiEditor-'+context.instance+'-dialog-summary').focus();},width:500},resizeme:false}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-publish','action':function(){$('#'+dialogID).dialog('open');return false;}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-cancel','action':function(){}});}}};})(jQuery);(function($){$.wikiEditor.modules.templateEditor={evt:{mark:function(context,event){var i=0;function findOutermostTemplates(tokenStack){var templateBeginFound=false;for(;i<tokenStack.length;i++){if(tokenStack[i].label=='TEMPLATE_BEGIN'){templateBeginFound=true;break;}}
 161+var j=i++;if(!templateBeginFound){return false;}else{var nestedBegins=1;while(nestedBegins>0&&j<tokenStack.length){var label=tokenStack[++j].label;nestedBegins+=label=='TEMPLATE_END'?-1:label=='TEMPLATE_BEGIN'?1:0;}
 162+if(nestedBegins==0){var leftMarker=i-1;var rightMarker=j;i=j;return[leftMarker,rightMarker];}else{return false;}}};var markers=context.modules.highlight.data.markers;var tokenStack=context.modules.highlight.data.tokenArray;var templateBeginFound=false;var templateBoundaries;while(templateBoundaries=findOutermostTemplates(tokenStack)){if(typeof markers[tokenStack[templateBoundaries[0]].offset]=='undefined'){markers[tokenStack[templateBoundaries[0]].offset]=[];}
165163 if(typeof markers[tokenStack[templateBoundaries[1]].offset]=='undefined'){markers[tokenStack[templateBoundaries[1]].offset]=[];}
166 -markers[tokenStack[templateBoundaries[0]].offset].push("<div class='wiki-template'>");markers[tokenStack[templateBoundaries[1]].offset].push("</div>");}}},exp:[{regex:/{{/,label:"TEMPLATE_BEGIN"},{regex:/}}/,label:"TEMPLATE_END",markAfter:true}],fn:{create:function(context,config){},model:function(wikitext){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;}
 164+markers[tokenStack[templateBoundaries[0]].offset].push("<div class='wiki-template'>");markers[tokenStack[templateBoundaries[1]].offset].push("</div>");}}},exp:[{'regex':/{{/,'label':"TEMPLATE_BEGIN"},{'regex':/}}/,'label':"TEMPLATE_END",'markAfter':true}],fn:{create:function(context,config){},model:function(wikitext){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;}
167165 function Range(begin,end){this.begin=begin;this.end=end;}
168 -var ranges=[];var sanatizedStr="";var params=[];var paramsByName=[];var templateNameIndex=0;function markOffTemplates(){sanatizedStr=wikitext.replace(/{{/," ");endBraces=sanatizedStr.match(/}}\s*$/);sanatizedStr=sanatizedStr.substring(0,endBraces.index)+" "+
169 -sanatizedStr.substring(endBraces.index+2);while(sanatizedStr.indexOf('{{')!=-1){startIndex=sanatizedStr.indexOf('{{')+1;openBraces=2;endIndex=startIndex;while(openBraces>0){endIndex++;switch(sanatizedStr[endIndex]){case'}':openBraces--;break;case'{':openBraces++;break;}}
170 -sanatizedSegment=sanatizedStr.substring(startIndex,endIndex).replace(/[{}|=]/g,'X');sanatizedStr=sanatizedStr.substring(0,startIndex)+
171 -sanatizedSegment+sanatizedStr.substring(endIndex);}
172 -return sanatizedStr;};if(wikitext.match(/\s*{{\s*\S*:/)){}
173 -markOffTemplates();var doneParsing=false;oldDivider=0;divider=sanatizedStr.indexOf('|',oldDivider);if(divider==-1){divider=sanatizedStr.length;doneParsing=true;}
174 -nameMatch=wikitext.substring(oldDivider,divider).match(/[^{\s]+/);if(nameMatch!=undefined){ranges.push(new Range(oldDivider,nameMatch.index));templateNameIndex=ranges.push(new Range(nameMatch.index,nameMatch.index+nameMatch[0].length));templateNameIndex--;ranges[templateNameIndex].old=wikitext.substring(ranges[templateNameIndex].begin,ranges[templateNameIndex].end);}
175 -params.push(ranges[templateNameIndex].old);currentParamNumber=0;var valueEndIndex;while(!doneParsing){currentParamNumber++;oldDivider=divider;divider=sanatizedStr.indexOf('|',oldDivider+1);if(divider==-1){divider=sanatizedStr.length;doneParsing=true;}
176 -currentField=sanatizedStr.substring(oldDivider+1,divider);if(currentField.indexOf('=')==-1){valueBegin=currentField.match(/\S+/);valueBeginIndex=valueBegin.index+oldDivider+1;valueEnd=currentField.match(/[^\s]\s*$/);valueEndIndex=valueEnd.index+oldDivider+2;ranges.push(new Range(ranges[ranges.length-1].end,valueBeginIndex));nameIndex=ranges.push(new Range(valueBeginIndex,valueBeginIndex));nameIndex--;equalsIndex=ranges.push(new Range(valueBeginIndex,valueBeginIndex));equalsIndex--;valueIndex=ranges.push(new Range(valueBeginIndex,valueEndIndex));valueIndex--;params.push(new Param(currentParamNumber,wikitext.substring(ranges[valueIndex].begin,ranges[valueIndex].end),currentParamNumber,nameIndex,equalsIndex,valueIndex));paramsByName[currentParamNumber]=currentParamNumber;}else{currentName=currentField.substring(0,currentField.indexOf('='));nameBegin=currentName.match(/\S+/);if(nameBegin==null){divider++;currentParamNumber--;continue;}
177 -nameBeginIndex=nameBegin.index+oldDivider+1;nameEnd=currentName.match(/[^\s]\s*$/);nameEndIndex=nameEnd.index+oldDivider+2;ranges.push(new Range(ranges[ranges.length-1].end,nameBeginIndex));nameIndex=ranges.push(new Range(nameBeginIndex,nameEndIndex));nameIndex--;currentValue=currentField.substring(currentField.indexOf('=')+1);oldDivider+=currentField.indexOf('=')+1;valueBegin=currentValue.match(/\S+/);valueBeginIndex=valueBegin.index+oldDivider+1;valueEnd=currentValue.match(/[^\s]\s*$/);valueEndIndex=valueEnd.index+oldDivider+2;equalsIndex=ranges.push(new Range(ranges[ranges.length-1].end,valueBeginIndex));equalsIndex--;valueIndex=ranges.push(new Range(valueBeginIndex,valueEndIndex));valueIndex--;params.push(new Param(wikitext.substring(nameBeginIndex,nameEndIndex),wikitext.substring(valueBeginIndex,valueEndIndex),currentParamNumber,nameIndex,equalsIndex,valueIndex));paramsByName[wikitext.substring(nameBeginIndex,nameEndIndex)]=currentParamNumber;}}
178 -ranges.push(new Range(valueEndIndex,wikitext.length));function getSetValue(name,value,original){var valueRange;var rangeIndex;var retVal;if(isNaN(name)){if(typeof paramsByName[name]=='undefined'){return"";}
 166+function getSetValue(name,value,original){var valueRange;var rangeIndex;var retVal;if(isNaN(name)){if(typeof paramsByName[name]=='undefined'){return"";}
179167 rangeIndex=paramsByName[name];}else{rangeIndex=parseInt(name);}
180168 if(typeof params[rangeIndex]=='undefined'){return"";}
181169 valueRange=ranges[params[rangeIndex].valueIndex];if(typeof valueRange.newVal=='undefined'||original){retVal=wikitext.substring(valueRange.begin,valueRange.end);}else{retVal=valueRange.newVal;}
182170 if(value!=null){ranges[params[rangeIndex].valueIndex].newVal=value;}
183171 return retVal;};this.getName=function(){if(typeof ranges[templateNameIndex].newVal=='undefined'){return wikitext.substring(ranges[templateNameIndex].begin,ranges[templateNameIndex].end);}else{return ranges[templateNameIndex].newVal;}};this.setName=function(name){ranges[templateNameIndex].newVal=name;};this.setValue=function(name,value){return getSetValue(name,value,false);};this.getValue=function(name){return getSetValue(name,null,false);};this.getOriginalValue=function(name){return getSetValue(name,null,true);};this.getAllParamNames=function(){return paramsByName;};this.getAllInitialParams=function(){return params;}
184172 this.getOriginalText=function(){return wikitext;};this.getText=function(){newText="";for(i=0;i<ranges.length;i++){if(typeof ranges[i].newVal=='undefined'){wikitext.substring(ranges[i].begin,ranges[i].end);}else{newText+=ranges[i].newVal;}}
185 -return newText;};}}};})(jQuery);(function($){$.wikiEditor.modules.toc={defaultWidth:'166px',minimumWidth:'70px',api:{},evt:{ready:function(context,event){$.wikiEditor.modules.toc.fn.build(context);context.$content.parent().delayedBind(250,'mouseup scrollToTop keyup change',function(){$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).blur(function(event){var context=event.data.context;context.$textarea.delayedBindCancel(250,'mouseup scrollToTop keyup change');$.wikiEditor.modules.toc.fn.unhighlight(context);});},resize:function(context,event){context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').height()-
 173+return newText;};if(wikitext.match(/\s*{{\s*\S*:/)){}
 174+var sanatizedStr=wikitext.replace(/{{/," ");endBraces=sanatizedStr.match(/}}\s*$/);sanatizedStr=sanatizedStr.substring(0,endBraces.index)+" "+sanatizedStr.substring(endBraces.index+2);while(sanatizedStr.indexOf('{{')!=-1){startIndex=sanatizedStr.indexOf('{{')+1;openBraces=2;endIndex=startIndex;while(openBraces>0){var brace=sanatizedStr[++endIndex];openBraces+=brace=='}'?-1:brace=='{'?1:0;}
 175+sanatizedSegment=sanatizedStr.substring(startIndex,endIndex).replace(/[{}|=]/g,'X');sanatizedStr=sanatizedStr.substring(0,startIndex)+sanatizedSegment+sanatizedStr.substring(endIndex);}
 176+var ranges=[];var params=[];var templateNameIndex=0;var doneParsing=false;oldDivider=0;divider=sanatizedStr.indexOf('|',oldDivider);if(divider==-1){divider=sanatizedStr.length;doneParsing=true;}
 177+nameMatch=wikitext.substring(oldDivider,divider).match(/[^{\s]+/);if(nameMatch!=undefined){ranges.push(new Range(oldDivider,nameMatch.index));templateNameIndex=ranges.push(new Range(nameMatch.index,nameMatch.index+nameMatch[0].length));templateNameIndex--;ranges[templateNameIndex].old=wikitext.substring(ranges[templateNameIndex].begin,ranges[templateNameIndex].end);}
 178+params.push(ranges[templateNameIndex].old);var currentParamNumber=0;var valueEndIndex;var paramsByName=[];while(!doneParsing){currentParamNumber++;oldDivider=divider;divider=sanatizedStr.indexOf('|',oldDivider+1);if(divider==-1){divider=sanatizedStr.length;doneParsing=true;}
 179+currentField=sanatizedStr.substring(oldDivider+1,divider);if(currentField.indexOf('=')==-1){valueBegin=currentField.match(/\S+/);valueBeginIndex=valueBegin.index+oldDivider+1;valueEnd=currentField.match(/[^\s]\s*$/);valueEndIndex=valueEnd.index+oldDivider+2;ranges.push(new Range(ranges[ranges.length-1].end,valueBeginIndex));nameIndex=ranges.push(new Range(valueBeginIndex,valueBeginIndex));nameIndex--;equalsIndex=ranges.push(new Range(valueBeginIndex,valueBeginIndex));equalsIndex--;valueIndex=ranges.push(new Range(valueBeginIndex,valueEndIndex));valueIndex--;params.push(new Param(currentParamNumber,wikitext.substring(ranges[valueIndex].begin,ranges[valueIndex].end),currentParamNumber,nameIndex,equalsIndex,valueIndex));paramsByName[currentParamNumber]=currentParamNumber;}else{currentName=currentField.substring(0,currentField.indexOf('='));nameBegin=currentName.match(/\S+/);if(nameBegin==null){divider++;currentParamNumber--;continue;}
 180+nameBeginIndex=nameBegin.index+oldDivider+1;nameEnd=currentName.match(/[^\s]\s*$/);nameEndIndex=nameEnd.index+oldDivider+2;ranges.push(new Range(ranges[ranges.length-1].end,nameBeginIndex));nameIndex=ranges.push(new Range(nameBeginIndex,nameEndIndex))-1;currentValue=currentField.substring(currentField.indexOf('=')+1);oldDivider+=currentField.indexOf('=')+1;valueBegin=currentValue.match(/\S+/);valueBeginIndex=valueBegin.index+oldDivider+1;valueEnd=currentValue.match(/[^\s]\s*$/);valueEndIndex=valueEnd.index+oldDivider+2;equalsIndex=ranges.push(new Range(ranges[ranges.length-1].end,valueBeginIndex))-1;valueIndex=ranges.push(new Range(valueBeginIndex,valueEndIndex))-1;params.push(new Param(wikitext.substring(nameBeginIndex,nameEndIndex),wikitext.substring(valueBeginIndex,valueEndIndex),currentParamNumber,nameIndex,equalsIndex,valueIndex));paramsByName[wikitext.substring(nameBeginIndex,nameEndIndex)]=currentParamNumber;}}
 181+ranges.push(new Range(valueEndIndex,wikitext.length));}}};})(jQuery);(function($){$.wikiEditor.modules.toc={cfg:{defaultWidth:'166px',minimumWidth:'70px',},api:{},evt:{ready:function(context,event){$.wikiEditor.modules.toc.fn.build(context);context.$content.parent().delayedBind(250,'mouseup scrollToTop keyup change',function(){$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).blur(function(event){var context=event.data.context;context.$textarea.delayedBindCancel(250,'mouseup scrollToTop keyup change');$.wikiEditor.modules.toc.fn.unhighlight(context);});},resize:function(context,event){context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').height()-
186182 context.$ui.find('.tab-toc').outerHeight());}},fn:{create:function(context,config){if('$toc'in context.modules.toc){return;}
187 -var height=context.$ui.find('.wikiEditor-ui-left').height();context.modules.toc.$toc=$('<div />').addClass('wikiEditor-ui-toc').data('context',context);context.$ui.find('.wikiEditor-ui-right').css('width',$.wikiEditor.modules.toc.defaultWidth).append(context.modules.toc.$toc);context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').height());context.$ui.find('.wikiEditor-ui-left').css('marginRight',"-"+$.wikiEditor.modules.toc.defaultWidth).children().css('marginRight',$.wikiEditor.modules.toc.defaultWidth);},unhighlight:function(context){context.modules.toc.$toc.find('div').removeClass('current');},update:function(context){$.wikiEditor.modules.toc.fn.unhighlight(context);var position=context.$textarea.textSelection('getCaretPosition');var section=0;if(context.data.outline.length>0){if(!(position<context.data.outline[0].position-1)){while(section<context.data.outline.length&&context.data.outline[section].position-1<position){section++;}
 183+var height=context.$ui.find('.wikiEditor-ui-left').height();context.modules.toc.$toc=$('<div />').addClass('wikiEditor-ui-toc').data('context',context);context.$ui.find('.wikiEditor-ui-right').css('width',$.wikiEditor.modules.toc.cfg.defaultWidth).append(context.modules.toc.$toc);context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').height());context.$ui.find('.wikiEditor-ui-left').css('marginRight',"-"+$.wikiEditor.modules.toc.cfg.defaultWidth).children().css('marginRight',$.wikiEditor.modules.toc.cfg.defaultWidth);},unhighlight:function(context){context.modules.toc.$toc.find('div').removeClass('current');},update:function(context){$.wikiEditor.modules.toc.fn.unhighlight(context);var position=context.$textarea.textSelection('getCaretPosition');var section=0;if(context.data.outline.length>0){if(!(position<context.data.outline[0].position-1)){while(section<context.data.outline.length&&context.data.outline[section].position-1<position){section++;}
188184 section=Math.max(0,section);}
189185 var sectionLink=context.modules.toc.$toc.find('div.section-'+section);sectionLink.addClass('current');var relTop=sectionLink.offset().top-context.modules.toc.$toc.offset().top;var scrollTop=context.modules.toc.$toc.scrollTop();var divHeight=context.modules.toc.$toc.height();var sectionHeight=sectionLink.height();if(relTop<0)
190186 context.modules.toc.$toc.scrollTop(scrollTop+relTop);else if(relTop+sectionHeight>divHeight)
@@ -196,10 +192,10 @@
197193 list.append(item);}
198194 return list;}
199195 function buildCollapseControls(){var $collapseControl=$('<div />'),$expandControl=$('<div />');$collapseControl.addClass('tab').addClass('tab-toc').append('<a href="#" />').bind('click.wikiEditor-toc',function(){context.modules.toc.$toc.trigger('collapse.wikiEditor-toc');return false;}).find('a').text(gM('wikieditor-toc-hide'));$expandControl.addClass('wikiEditor-ui-toc-expandControl').append('<a href="#" />').bind('click.wikiEditor-toc',function(){context.modules.toc.$toc.trigger('expand.wikiEditor-toc');return false;}).hide().find('a').text(gM('wikieditor-toc-show'));$collapseControl.insertBefore(context.modules.toc.$toc);context.$ui.find('.wikiEditor-ui-left .wikiEditor-ui-top').append($expandControl);context.fn.trigger('resize');}
200 -function buildResizeControls(){context.$ui.data('resizableDone',true).find('.wikiEditor-ui-right').data('wikiEditor-ui-left',context.$ui.find('.wikiEditor-ui-left')).resizable({handles:'w,e',preventPositionLeftChange:true,minWidth:50,start:function(e,ui){var $this=$(this);$('<div />').addClass('wikiEditor-ui-resize-mask').css({'position':'absolute','z-index':2,'left':0,'top':0,'bottom':0,'right':0}).appendTo(context.$ui.find('.wikiEditor-ui-left'));$this.resizable('option','maxWidth',$this.parent().width()-450);},resize:function(e,ui){$(this).css({'width':ui.size.width,'top':'auto','height':'auto'}).data('wikiEditor-ui-left').css('marginRight',(-1*ui.size.width)).children().css('marginRight',ui.size.width);context.fn.trigger('resize');},stop:function(e,ui){context.$ui.find('.wikiEditor-ui-resize-mask').remove();context.$content.trigger('mouseup');if(ui.size.width<parseFloat($.wikiEditor.modules.toc.minimumWidth)){context.modules.toc.$toc.trigger('collapse');}else{context.modules.toc.$toc.data('openWidth',ui.size.width);$.cookie('wikiEditor-'+context.instance+'-toc-width',ui.size.width);}
 196+function buildResizeControls(){context.$ui.data('resizableDone',true).find('.wikiEditor-ui-right').data('wikiEditor-ui-left',context.$ui.find('.wikiEditor-ui-left')).resizable({handles:'w,e',preventPositionLeftChange:true,minWidth:50,start:function(e,ui){var $this=$(this);$('<div />').addClass('wikiEditor-ui-resize-mask').css({'position':'absolute','z-index':2,'left':0,'top':0,'bottom':0,'right':0}).appendTo(context.$ui.find('.wikiEditor-ui-left'));$this.resizable('option','maxWidth',$this.parent().width()-450);},resize:function(e,ui){$(this).css({'width':ui.size.width,'top':'auto','height':'auto'}).data('wikiEditor-ui-left').css('marginRight',(-1*ui.size.width)).children().css('marginRight',ui.size.width);context.fn.trigger('resize');},stop:function(e,ui){context.$ui.find('.wikiEditor-ui-resize-mask').remove();context.$content.trigger('mouseup');if(ui.size.width<parseFloat($.wikiEditor.modules.toc.cfg.minimumWidth)){context.modules.toc.$toc.trigger('collapse');}else{context.modules.toc.$toc.data('openWidth',ui.size.width);$.cookie('wikiEditor-'+context.instance+'-toc-width',ui.size.width);}
201197 context.fn.trigger('resize');}});var handle=$j('body').is('.rtl')?'w':'e'
202 -context.$ui.find('.ui-resizable-'+handle).removeClass('ui-resizable-'+handle).addClass('ui-resizable-'+(handle=='w'?'e':'w')).addClass('wikiEditor-ui-toc-resize-grip');context.modules.toc.$toc.bind('collapse.wikiEditor-toc',$.wikiEditor.modules.toc.fn.collapse).bind('expand.wikiEditor-toc',$.wikiEditor.modules.toc.fn.expand);context.modules.toc.$toc.data('openWidth',$.wikiEditor.modules.toc.defaultWidth);if($.cookie('wikiEditor-'+context.instance+'-toc-width')==0){context.modules.toc.$toc.trigger('collapse.wikiEditor-toc',{data:context});}else if($.cookie('wikiEditor-'+context.instance+'-toc-width')>0){var initialWidth=$.cookie('wikiEditor-'+context.instance+'-toc-width');if(initialWidth<parseFloat($.wikiEditor.modules.toc.minimumWidth))
203 -initialWidth=parseFloat($.wikiEditor.modules.toc.minimumWidth)+1;context.modules.toc.$toc.data('openWidth',initialWidth+'px');context.$ui.find('.wikiEditor-ui-right').css('width',initialWidth+'px');context.$ui.find('.wikiEditor-ui-left').css('marginRight',(parseFloat(initialWidth)*-1)+'px').children().css('marginRight',initialWidth+'px');}}
 198+context.$ui.find('.ui-resizable-'+handle).removeClass('ui-resizable-'+handle).addClass('ui-resizable-'+(handle=='w'?'e':'w')).addClass('wikiEditor-ui-toc-resize-grip');context.modules.toc.$toc.bind('collapse.wikiEditor-toc',$.wikiEditor.modules.toc.fn.collapse).bind('expand.wikiEditor-toc',$.wikiEditor.modules.toc.fn.expand);context.modules.toc.$toc.data('openWidth',$.wikiEditor.modules.toc.cfg.defaultWidth);if($.cookie('wikiEditor-'+context.instance+'-toc-width')==0){context.modules.toc.$toc.trigger('collapse.wikiEditor-toc',{data:context});}else if($.cookie('wikiEditor-'+context.instance+'-toc-width')>0){var initialWidth=$.cookie('wikiEditor-'+context.instance+'-toc-width');if(initialWidth<parseFloat($.wikiEditor.modules.toc.cfg.minimumWidth))
 199+initialWidth=parseFloat($.wikiEditor.modules.toc.cfg.minimumWidth)+1;context.modules.toc.$toc.data('openWidth',initialWidth+'px');context.$ui.find('.wikiEditor-ui-right').css('width',initialWidth+'px');context.$ui.find('.wikiEditor-ui-left').css('marginRight',(parseFloat(initialWidth)*-1)+'px').children().css('marginRight',initialWidth+'px');}}
204200 var outline=[],h=0;function traverseTextNodes(){if(this.nodeName!='#text'){$(this.childNodes).each(traverseTextNodes);return;}
205201 var text=this.nodeValue;var p=this;while(!p.previousSibling)
206202 p=p.parentNode;var prev=p?p.previousSibling:null;p=this;while(p&&!p.nextSibling)

Status & tagging log