replace lots of javascript with a little jquery

This commit is contained in:
Shish
2012-03-02 23:57:27 +00:00
parent 74f0d38c04
commit 15fdd2e0b7
12 changed files with 42 additions and 445 deletions

View File

@ -41,17 +41,6 @@ $(document).ready(function() {
$("TABLE.sortable").tablesorter();
var sections=get_sections();
for(var i=0;i<sections.length;i++) toggle(sections[i]);
if(document.location.hash.length > 3) {
query = document.location.hash.substring(1);
a = document.getElementById("prevlink");
a.href = a.href + '?' + query;
a = document.getElementById("nextlink");
a.href = a.href + '?' + query;
}
$(".comment_link").each(function(idx, elm) {
var target_id = $(elm).text().match(/#c?(\d+)/);
if(target_id && $("#c"+target_id[1])) {
@ -62,6 +51,38 @@ $(document).ready(function() {
}
}
});
var sidebar_hidden = ($.cookie("sidebar-hidden") || "").split("|");
for(var i in sidebar_hidden) {
$("#"+sidebar_hidden[i]).hide();
};
$(".shm-toggler").each(function(idx, elm) {
var tid = $(elm).data("toggle-id");
var tob = $("#"+tid);
$(elm).click(function(e) {
tob.slideToggle("slow");
if(sidebar_hidden.indexOf(tid) == -1) {
sidebar_hidden.push(tid);
}
else {
console.log("unhiding", tid);
for (var i in sidebar_hidden) {
if (sidebar_hidden[i] === tid) {
sidebar_hidden.splice(i, 1);
}
}
}
$.cookie("sidebar-hidden", sidebar_hidden.join("|"), {path: '/'});
})
});
if(document.location.hash.length > 3) {
query = document.location.hash.substring(1);
a = document.getElementById("prevlink");
a.href = a.href + '?' + query;
a = document.getElementById("nextlink");
a.href = a.href + '?' + query;
}
});