Index: trunk/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php |
— | — | @@ -53,18 +53,7 @@ |
54 | 54 | implode( "\t", $digitTransTable ), |
55 | 55 | ); |
56 | 56 | $mainPage = Title::newMainPage(); |
57 | | - |
58 | | - #$localDateFormats = $wgContLang->getDateFormats(); |
59 | | - #$localPreferedFormat = $localDateFormats[$wgContLang->getDefaultDateFormat().' date']; |
60 | | - |
61 | | - $monthNames = array(''); |
62 | | - $monthNamesShort = array(''); |
63 | | - for ($i=1; $i < 13; $i++) { |
64 | | - $monthNames[]=$wgContLang->getMonthName($i); |
65 | | - $monthNamesShort[]=$wgContLang->getMonthAbbreviation($i); |
66 | | - } |
67 | | - |
68 | | - #$localPreferedFormat = $localDateFormats['dmy date']; |
| 57 | + |
69 | 58 | // Build list of variables |
70 | 59 | $vars = array( |
71 | 60 | 'wgLoadScript' => $wgLoadScript, |
— | — | @@ -85,8 +74,8 @@ |
86 | 75 | 'wgEnableAPI' => $wgEnableAPI, |
87 | 76 | 'wgEnableWriteAPI' => $wgEnableWriteAPI, |
88 | 77 | 'wgDefaultDateFormat' => $wgContLang->getDefaultDateFormat(), |
89 | | - 'wgMonthNames' => $monthNames, |
90 | | - 'wgMonthNamesShort' => $monthNamesShort, |
| 78 | + 'wgMonthNames' => $wgContLang->getMonthNamesArray(), |
| 79 | + 'wgMonthNamesShort' => $wgContLang->getMonthAbbreviationsArray(), |
91 | 80 | 'wgSeparatorTransformTable' => $compactSeparatorTransTable, |
92 | 81 | 'wgDigitTransformTable' => $compactDigitTransTable, |
93 | 82 | 'wgMainPageTitle' => $mainPage ? $mainPage->getPrefixedText() : null, |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -603,7 +603,15 @@ |
604 | 604 | function getMonthName( $key ) { |
605 | 605 | return $this->getMessageFromDB( self::$mMonthMsgs[$key - 1] ); |
606 | 606 | } |
607 | | - |
| 607 | + |
| 608 | + function getMonthNamesArray() { |
| 609 | + $monthNames = array( '' ); |
| 610 | + for ( $i=1; $i < 13; $i++ ) { |
| 611 | + $monthNames[] = $this->getMonthName( $i ); |
| 612 | + } |
| 613 | + return $monthNames; |
| 614 | + } |
| 615 | + |
608 | 616 | function getMonthNameGen( $key ) { |
609 | 617 | return $this->getMessageFromDB( self::$mMonthGenMsgs[$key - 1] ); |
610 | 618 | } |
— | — | @@ -611,7 +619,15 @@ |
612 | 620 | function getMonthAbbreviation( $key ) { |
613 | 621 | return $this->getMessageFromDB( self::$mMonthAbbrevMsgs[$key - 1] ); |
614 | 622 | } |
615 | | - |
| 623 | + |
| 624 | + function getMonthAbbreviationsArray() { |
| 625 | + $monthNames = array(''); |
| 626 | + for ( $i=1; $i < 13; $i++ ) { |
| 627 | + $monthNames[] = $this->getMonthAbbreviation( $i ); |
| 628 | + } |
| 629 | + return $monthNames; |
| 630 | + } |
| 631 | + |
616 | 632 | function getWeekdayName( $key ) { |
617 | 633 | return $this->getMessageFromDB( self::$mWeekdayMsgs[$key - 1] ); |
618 | 634 | } |
Index: trunk/phase3/resources/jquery/jquery.tablesorter.js |
— | — | @@ -83,7 +83,7 @@ |
84 | 84 | /* debuging utils */ |
85 | 85 | // |
86 | 86 | // function benchmark( s, d ) { |
87 | | - // alert( s + "," + ( new Date().getTime() - d.getTime() ) + "ms" ); |
| 87 | + // console.log( s + " " + ( new Date().getTime() - d.getTime() ) + "ms" ); |
88 | 88 | // } |
89 | 89 | // |
90 | 90 | // this.benchmark = benchmark; |
— | — | @@ -250,14 +250,24 @@ |
251 | 251 | } |
252 | 252 | |
253 | 253 | function buildHeaders( table ) { |
254 | | - |
| 254 | + var maxSeen = 0; |
| 255 | + var longest; |
255 | 256 | // if ( table.config.debug ) { |
256 | 257 | // var time = new Date(); |
257 | 258 | // } |
258 | 259 | //var header_index = computeTableHeaderCellIndexes( table ); |
259 | 260 | var realCellIndex = 0; |
260 | | - |
261 | | - $tableHeaders = $( table.config.selectorHeaders, table ).each( function ( index ) { |
| 261 | + $tableHeaders = $( "thead:eq(0) tr", table ); |
| 262 | + if ( $tableHeaders.length > 1 ) { |
| 263 | + $tableHeaders.each(function() { |
| 264 | + if (this.cells.length > maxSeen) { |
| 265 | + maxSeen = this.cells.length; |
| 266 | + longest = this; |
| 267 | + } |
| 268 | + }); |
| 269 | + $tableHeaders = $( longest ); |
| 270 | + } |
| 271 | + $tableHeaders = $tableHeaders.find('th').each( function ( index ) { |
262 | 272 | //var normalIndex = allCells.index( this ); |
263 | 273 | //var realCellIndex = 0; |
264 | 274 | this.column = realCellIndex; |
— | — | @@ -290,84 +300,6 @@ |
291 | 301 | |
292 | 302 | } |
293 | 303 | |
294 | | - // // from: |
295 | | - // // http://www.javascripttoolbox.com/lib/table/examples.php |
296 | | - // // http://www.javascripttoolbox.com/temp/table_cellindex.html |
297 | | - // |
298 | | - // function computeTableHeaderCellIndexes(t) { |
299 | | - // var matrix = []; |
300 | | - // var lookup = {}; |
301 | | - // var thead = t.getElementsByTagName( 'THEAD' )[0]; |
302 | | - // var trs = thead.getElementsByTagName( 'TR' ); |
303 | | - // |
304 | | - // for ( var i = 0; i < trs.length; i++ ) { |
305 | | - // var cells = trs[i].cells; |
306 | | - // for ( var j = 0; j < cells.length; j++ ) { |
307 | | - // var c = cells[j]; |
308 | | - // |
309 | | - // var rowIndex = c.parentNode.rowIndex; |
310 | | - // var cellId = rowIndex + "-" + c.cellIndex; |
311 | | - // var rowSpan = c.rowSpan || 1; |
312 | | - // var colSpan = c.colSpan || 1; |
313 | | - // var firstAvailCol; |
314 | | - // if ( typeof( matrix[rowIndex] ) == "undefined" ) { |
315 | | - // matrix[rowIndex] = []; |
316 | | - // } |
317 | | - // // Find first available column in the first row |
318 | | - // for ( var k = 0; k < matrix[rowIndex].length + 1; k++ ) { |
319 | | - // if ( typeof( matrix[rowIndex][k] ) == "undefined" ) { |
320 | | - // firstAvailCol = k; |
321 | | - // break; |
322 | | - // } |
323 | | - // } |
324 | | - // lookup[cellId] = firstAvailCol; |
325 | | - // for ( var k = rowIndex; k < rowIndex + rowSpan; k++ ) { |
326 | | - // if ( typeof( matrix[k] ) == "undefined" ) { |
327 | | - // matrix[k] = []; |
328 | | - // } |
329 | | - // var matrixrow = matrix[k]; |
330 | | - // for ( var l = firstAvailCol; l < firstAvailCol + colSpan; l++ ) { |
331 | | - // matrixrow[l] = "x"; |
332 | | - // } |
333 | | - // } |
334 | | - // } |
335 | | - // } |
336 | | - // return lookup; |
337 | | - // } |
338 | | - // function checkCellColSpan( table, rows, row ) { |
339 | | - // var arr = [], |
340 | | - // r = table.tHead.rows, |
341 | | - // c = r[row].cells; |
342 | | - // |
343 | | - // for ( var i = 0; i < c.length; i++ ) { |
344 | | - // var cell = c[i]; |
345 | | - // |
346 | | - // if ( cell.colSpan > 1 ) { |
347 | | - // arr = arr.concat( checkCellColSpan( table, headerArr, row++ ) ); |
348 | | - // } else { |
349 | | - // if ( table.tHead.length == 1 || ( cell.rowSpan > 1 || !r[row + 1] ) ) { |
350 | | - // arr.push( cell ); |
351 | | - // } |
352 | | - // // headerArr[row] = ( i+row ); |
353 | | - // } |
354 | | - // } |
355 | | - // return arr; |
356 | | - // } |
357 | | - // |
358 | | - // function checkHeaderOptions( table, i ) { |
359 | | - // if ( ( table.config.headers[i] ) && ( table.config.headers[i].sorter === false ) ) { |
360 | | - // return true; |
361 | | - // } |
362 | | - // return false; |
363 | | - // } |
364 | | - // function formatSortingOrder(v) { |
365 | | - // if ( typeof(v) != "Number" ) { |
366 | | - // return ( v.toLowerCase() == "desc" ) ? 1 : 0; |
367 | | - // } else { |
368 | | - // return ( v == 1 ) ? 1 : 0; |
369 | | - // } |
370 | | - // } |
371 | | - |
372 | 304 | function isValueInArray( v, a ) { |
373 | 305 | var l = a.length; |
374 | 306 | for ( var i = 0; i < l; i++ ) { |
— | — | @@ -397,7 +329,7 @@ |
398 | 330 | |
399 | 331 | function multisort( table, sortList, cache ) { |
400 | 332 | // if ( table.config.debug ) { |
401 | | - // var sortTime = new Date(); |
| 333 | + // var sortTime = new Date(); |
402 | 334 | // } |
403 | 335 | var dynamicExp = "var sortWrapper = function(a,b) {", |
404 | 336 | l = sortList.length; |
— | — | @@ -410,15 +342,15 @@ |
411 | 343 | var s = ""; |
412 | 344 | if ( table.config.parsers[c].type == "text" ) { |
413 | 345 | if ( order == 0 ) { |
414 | | - s = makeSortFunction( "text", "asc", c ); |
| 346 | + s = makeSortText( c ); |
415 | 347 | } else { |
416 | | - s = makeSortFunction( "text", "desc", c ); |
| 348 | + s = makeSortTextDesc( c ); |
417 | 349 | } |
418 | 350 | } else { |
419 | 351 | if ( order == 0 ) { |
420 | | - s = makeSortFunction( "numeric", "asc", c ); |
| 352 | + s = makeSortNumeric( c ); |
421 | 353 | } else { |
422 | | - s = makeSortFunction( "numeric", "desc", c ); |
| 354 | + s = makeSortNumericDesc( c ); |
423 | 355 | } |
424 | 356 | } |
425 | 357 | var e = "e" + i; |
— | — | @@ -446,25 +378,11 @@ |
447 | 379 | cache.normalized.sort( sortWrapper ); |
448 | 380 | |
449 | 381 | // if ( table.config.debug ) { |
450 | | - // benchmark( "Sorting on " + sortList.toString() + " and dir " + order + " time:", sortTime ); |
| 382 | + // benchmark( "Sorting in dir " + order + " time:", sortTime ); |
451 | 383 | // } |
452 | 384 | return cache; |
453 | 385 | } |
454 | 386 | |
455 | | - function makeSortFunction( type, direction, index ) { |
456 | | - var a = "a[" + index + "]", |
457 | | - b = "b[" + index + "]"; |
458 | | - if (type == 'text' && direction == 'asc') { |
459 | | - return "(" + a + " == " + b + " ? 0 : (" + a + " === null ? Number.POSITIVE_INFINITY : (" + b + " === null ? Number.NEGATIVE_INFINITY : (" + a + " < " + b + ") ? -1 : 1 )));"; |
460 | | - } else if (type == 'text' && direction == 'desc') { |
461 | | - return "(" + a + " == " + b + " ? 0 : (" + a + " === null ? Number.POSITIVE_INFINITY : (" + b + " === null ? Number.NEGATIVE_INFINITY : (" + b + " < " + a + ") ? -1 : 1 )));"; |
462 | | - } else if (type == 'numeric' && direction == 'asc') { |
463 | | - return "(" + a + " === null && " + b + " === null) ? 0 :(" + a + " === null ? Number.POSITIVE_INFINITY : (" + b + " === null ? Number.NEGATIVE_INFINITY : " + a + " - " + b + "));"; |
464 | | - } else if (type == 'numeric' && direction == 'desc') { |
465 | | - return "(" + a + " === null && " + b + " === null) ? 0 :(" + a + " === null ? Number.POSITIVE_INFINITY : (" + b + " === null ? Number.NEGATIVE_INFINITY : " + b + " - " + a + "));"; |
466 | | - } |
467 | | - } |
468 | | - |
469 | 387 | function makeSortText(i) { |
470 | 388 | return "((a[" + i + "] < b[" + i + "]) ? -1 : ((a[" + i + "] > b[" + i + "]) ? 1 : 0));"; |
471 | 389 | } |
— | — | @@ -482,12 +400,12 @@ |
483 | 401 | } |
484 | 402 | |
485 | 403 | function sortText( a, b ) { |
486 | | - if ( table.config.sortLocaleCompare ) return a.localeCompare(b); |
| 404 | + //if ( table.config.sortLocaleCompare ) return a.localeCompare(b); |
487 | 405 | return ((a < b) ? -1 : ((a > b) ? 1 : 0)); |
488 | 406 | } |
489 | 407 | |
490 | 408 | function sortTextDesc( a, b ) { |
491 | | - if ( table.config.sortLocaleCompare ) return b.localeCompare(a); |
| 409 | + //if ( table.config.sortLocaleCompare ) return b.localeCompare(a); |
492 | 410 | return ((b < a) ? -1 : ((b > a) ? 1 : 0)); |
493 | 411 | } |
494 | 412 | |
— | — | @@ -556,13 +474,27 @@ |
557 | 475 | |
558 | 476 | } |
559 | 477 | |
| 478 | + function explodeRowspans( $table ) { |
| 479 | + // Split multi row cells into multiple cells with the same content |
| 480 | + $table.find( '[rowspan]' ).each(function() { |
| 481 | + var rowSpan = this.rowSpan; |
| 482 | + this.rowSpan = 1; |
| 483 | + var cell = $( this ); |
| 484 | + var next = cell.parent().nextAll(); |
| 485 | + for ( var i = 0; i < rowSpan - 1; i++ ) { |
| 486 | + next.eq(0).find( 'td' ).eq( this.cellIndex ).before( cell.clone() ); |
| 487 | + }; |
| 488 | + }); |
| 489 | + }; |
| 490 | + |
560 | 491 | function buildCollationTable() { |
561 | | - if ( typeof tableSorterCollation == "object" ) { |
| 492 | + ts.collationTable = mw.config.get('tableSorterCollation'); |
| 493 | + if ( typeof ts.collationTable === "object" ) { |
562 | 494 | ts.collationRegex = []; |
563 | 495 | |
564 | 496 | //Build array of key names |
565 | | - for ( var key in tableSorterCollation ) { |
566 | | - if ( tableSorterCollation.hasOwnProperty(key) ) { //to be safe |
| 497 | + for ( var key in ts.collationTable ) { |
| 498 | + if ( ts.collationTable.hasOwnProperty(key) ) { //to be safe |
567 | 499 | ts.collationRegex.push(key); |
568 | 500 | } |
569 | 501 | } |
— | — | @@ -626,6 +558,7 @@ |
627 | 559 | // enabled. |
628 | 560 | //$this.trigger( "sortStart" ); |
629 | 561 | // store exp, for speed |
| 562 | + explodeRowspans( $this ); |
630 | 563 | var $cell = $( this ); |
631 | 564 | // get current column index |
632 | 565 | var i = this.column; |
— | — | @@ -782,7 +715,7 @@ |
783 | 716 | format: function (s) { |
784 | 717 | s = $.trim( s.toLowerCase() ); |
785 | 718 | if ( ts.collationRegex ) { |
786 | | - var tsc = tableSorterCollation; |
| 719 | + var tsc = ts.collationTable; |
787 | 720 | s = s.replace( ts.collationRegex, function ( match ) { |
788 | 721 | var r = tsc[match] ? tsc[match] : tsc[match.toUpperCase()]; |
789 | 722 | return r.toLowerCase(); |
— | — | @@ -877,7 +810,7 @@ |
878 | 811 | return ( ts.dateRegex[0].test(s) || ts.dateRegex[1].test(s) || ts.dateRegex[2].test(s )); |
879 | 812 | }, |
880 | 813 | format: function ( s, table ) { |
881 | | - s = s.toLowerCase(); |
| 814 | + s = $.trim( s.toLowerCase() ); |
882 | 815 | |
883 | 816 | for ( i = 1, j = 0; i < 13 && j < 2; i++ ) { |
884 | 817 | s = s.replace( ts.monthNames[j][i], i ); |