MediaWiki:Gadget-highlightTable-core.js: Difference between revisions
Created page with " * highlightTable.js * * Description: * Adds highlighting to tables * * History: * - 1.0: Row highlighting - Quarenon * - 1.1: Update from pengLo..." |
mNo edit summary |
||
| (5 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
/** <pre> | |||
* highlightTable.js | * highlightTable.js | ||
* | * | ||
| Line 4: | Line 5: | ||
* Adds highlighting to tables | * Adds highlighting to tables | ||
* | * | ||
*/ | */ | ||
| Line 86: | Line 76: | ||
*/ | */ | ||
(function($, mw, OO, | (function($, mw, OO, gs) { | ||
'use strict'; | 'use strict'; | ||
// constants | // constants | ||
var STORAGE_KEY = ' | var STORAGE_KEY = 'gs:lightTable', | ||
TABLE_CLASS = 'lighttable', | TABLE_CLASS = 'lighttable', | ||
LIGHT_ON_CLASS = 'highlight-on', | LIGHT_ON_CLASS = 'highlight-on', | ||
| Line 109: | Line 99: | ||
* Perform initial checks on the page and browser. | * Perform initial checks on the page and browser. | ||
*/ | */ | ||
init: function() { | init: function(sorted) { | ||
var $tables = $('table.' + TABLE_CLASS), | var $tables = $('table.' + TABLE_CLASS), | ||
hashedPageName = self.hashString(mw.config.get('wgPageName')); | hashedPageName = self.hashString(mw.config.get('wgPageName')); | ||
| Line 118: | Line 108: | ||
} | } | ||
// check the browser supports local storage | // check the browser supports local storage | ||
if (! | if (!gs.hasLocalStorage()) { | ||
return; | return; | ||
} | |||
// check if any of the tables are autosort tables | |||
// and, if so, ensure the autosort gadget runs first | |||
if (!sorted && $tables.filter('[class*="autosort="]').length) { | |||
mw.hook('gadget.autosort.sorted').add(function delayInit() { | |||
self.init(true); | |||
// only run once | |||
mw.hook('gadget.autosort.sorted').remove(delayInit); | |||
}); | |||
return; | |||
} | } | ||
| Line 501: | Line 503: | ||
*/ | */ | ||
}(this.jQuery, this.mediaWiki, this.OO, this. | }(this.jQuery, this.mediaWiki, this.OO, this.gswiki)); | ||
// </pre> | // </pre> | ||