remove theme-specific code from the globally-applied site.js file

This commit is contained in:
mappu 2016-04-18 19:42:55 +12:00
parent 12eb8a2111
commit 39789220a8

View File

@ -1,6 +1,10 @@
(function() { (function() {
"use strict"; "use strict";
//
// Tag support
//
var show_all = function() { var show_all = function() {
var tr = document.querySelectorAll(".projtable tr"); var tr = document.querySelectorAll(".projtable tr");
for (var i = 0, e = tr.length; i !== e; ++i) { for (var i = 0, e = tr.length; i !== e; ++i) {
@ -39,6 +43,18 @@
}; };
}; };
window.addEventListener('load', function() {
var taglinks = document.querySelectorAll(".tag-link");
for (var i = 0, e = taglinks.length; i !== e; ++i) {
var tag = taglinks[i].getAttribute("data-tag");
taglinks[i].addEventListener('click', get_show_tag(tag));
}
});
//
// Sort support (theme opt-in)
//
var sort_rows = function(cb) { var sort_rows = function(cb) {
var tr = document.querySelectorAll(".projtable tr"); var tr = document.querySelectorAll(".projtable tr");
var items = []; var items = [];
@ -56,42 +72,29 @@
} }
}; };
var sort_update = function() { var sort_update = function(sort_by) {
var cb; switch(sort_by) {
switch(document.getElementById('sortorder').value) {
case 'a': case 'a':
default: { default: {
cb = function(el) { sort_rows(function(el) {
return el.getAttribute('data-sort-ct'); return el.getAttribute('data-sort-ct');
}; });
} break; } break;
case 'b': { case 'b': {
cb = function(el) { sort_rows(function(el) {
return el.getAttribute('data-sort-mt'); return el.getAttribute('data-sort-mt');
} });
} break; } break;
case 'c': { case 'c': {
cb = function(el) { sort_rows(function(el) {
return el.getAttribute('data-sort-al'); return el.getAttribute('data-sort-al');
} });
} break; } break;
}; };
sort_rows(cb);
}; };
window.addEventListener('load', function() { window.sortUpdate = sort_update;
var taglinks = document.querySelectorAll(".tag-link");
for (var i = 0, e = taglinks.length; i !== e; ++i) {
var tag = taglinks[i].getAttribute("data-tag");
taglinks[i].addEventListener('click', get_show_tag(tag));
}
var so = document.getElementById('sortorder');
if (so) {
so.addEventListener('change', sort_update);
sort_update();
}
});
})(); })();