Skip to content

Commit

Permalink
Sorttable: avoid registering init multiple times
Browse files Browse the repository at this point in the history
The script pre-dates jQuery usage so it's understandable the amount of
workarounds and boilerplate that were needed back then to run code at startup.
They are not necessary anymore and this commit removes them which also avoids to
register extra listeners to run the init callback.
  • Loading branch information
julen committed Jul 22, 2016
1 parent 9b617ff commit 05dd800
Showing 1 changed file with 1 addition and 36 deletions.
37 changes: 1 addition & 36 deletions pootle/static/js/vendor/sorttable.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@

sorttable = {
init: function() {
// quit if this function has already been called
if (arguments.callee.done) return;
// flag this function so we don't do the same thing twice
arguments.callee.done = true;
// kill the timer
if (_timer) clearInterval(_timer);

if (!document.createElement || !document.getElementsByTagName) return;

sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/;
Expand Down Expand Up @@ -401,35 +394,7 @@ sorttable = {

// Dean Edwards/Matthias Miller/John Resig

/* for Mozilla/Opera9 */
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", sorttable.init, false);
}

/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
var dummy = (location.protocol == "https:") ? "//:" : "javascript:void(0)";
document.write('<script id=__ie_onload defer src="' + dummy + '"><\/script>');
var script = document.getElementById("__ie_onload");
script.onreadystatechange = function() {
if (this.readyState == "complete") {
sorttable.init(); // call the onload handler
}
};
/*@end @*/

/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff
var _timer = setInterval(function() {
if (/loaded|complete/.test(document.readyState)) {
sorttable.init(); // call the onload handler
}
}, 10);
}

/* for other browsers */
window.onload = sorttable.init;
document.addEventListener("DOMContentLoaded", sorttable.init, false);

// written by Dean Edwards, 2005
// with input from Tino Zijdel, Matthias Miller, Diego Perini
Expand Down

0 comments on commit 05dd800

Please sign in to comment.