diff --git a/lib/shimmie.js b/lib/shimmie.js index 727e1b26..8f19cd7c 100644 --- a/lib/shimmie.js +++ b/lib/shimmie.js @@ -41,17 +41,6 @@ $(document).ready(function() { $("TABLE.sortable").tablesorter(); - var sections=get_sections(); - for(var i=0;i 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; + } }); diff --git a/themes/danbooru/layout.class.php b/themes/danbooru/layout.class.php index 39259544..beaca2f6 100644 --- a/themes/danbooru/layout.class.php +++ b/themes/danbooru/layout.class.php @@ -13,7 +13,7 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Danbooru Theme - Notes (Bzchan) -Files: default.php, sidebar.js, style.css +Files: default.php, style.css How to use a theme - Copy the danbooru folder with all its contained files into the "themes" @@ -197,7 +197,6 @@ class Layout { {$page->title} $header_html - @@ -241,13 +240,13 @@ EOD; $html = ""; if($hidable) { $i = str_replace(' ', '_', $h.$s); - if(!is_null($h)) $html .= "\n

$h

\n"; + if(!is_null($h)) $html .= "\n

$h

\n"; if(!is_null($b)) $html .= "
$b
\n"; } else { $i = str_replace(' ', '_', $h.$s); if(!is_null($h)) $html .= "\n

$h

\n"; - if(!is_null($b)) $html .= "
$b
\n"; + if(!is_null($b)) $html .= "
$b
\n"; } return $html; } diff --git a/themes/danbooru/sidebar.js b/themes/danbooru/sidebar.js deleted file mode 100644 index ce0a7d8b..00000000 --- a/themes/danbooru/sidebar.js +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This script shamelessly stolen from wakachan.org d(^_^)b - */ - -var cookie_name="shimmie_sidebar"; -var default_sections=[]; - -function toggle(id) -{ - var e=document.getElementById(id); - if(!e) return; - if(e.style.display) - { - remove_section(id); - e.style.display=""; - - var e2 = document.getElementById(id+"-toggle"); - if(e2) { - e2.style.color = "#000"; - } - } - else - { - add_section(id); - e.style.display="none"; - - var e2 = document.getElementById(id+"-toggle"); - if(e2) { - e2.style.color = "#AAA"; - } - } -} - -function add_section(id) -{ - var sections=get_sections(); - for(var i=0;i {$page->title} - $header_html @@ -89,27 +88,8 @@ EOD; $b = $block->body; $html = ""; $i = str_replace(' ', '_', $h) . $salt; - if($hidable) $html .= " - - "; if(!is_null($h)) $html .= " -

$h

+

$h

"; if(!is_null($b)) { if(strpos($b, "") === FALSE) { diff --git a/themes/default/sidebar.js b/themes/default/sidebar.js deleted file mode 100644 index 585f8ca8..00000000 --- a/themes/default/sidebar.js +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This script shamelessly stolen from wakachan.org d(^_^)b - */ - -var cookie_name="shimmie_sidebar"; -var default_sections=["upload", "edit_tags"]; - -function toggle(id) -{ - var e=document.getElementById(id); - if(!e) return; - if(e.style.display) - { - remove_section(id); - e.style.display=""; - - var e2 = document.getElementById(id+"-toggle"); - if(e2) { - e2.style.color = "#000"; - } - } - else - { - add_section(id); - e.style.display="none"; - - var e2 = document.getElementById(id+"-toggle"); - if(e2) { - e2.style.color = "#AAA"; - } - } -} - -function add_section(id) -{ - var sections=get_sections(); - for(var i=0;ibody; $html = ""; $i = str_replace(' ', '_', $h) . $salt; - if($hidable) $html .= " - - "; if(!is_null($h)) $html .= " -
+

$h

diff --git a/themes/futaba/layout.class.php b/themes/futaba/layout.class.php index c945c3bb..c6447668 100644 --- a/themes/futaba/layout.class.php +++ b/themes/futaba/layout.class.php @@ -61,7 +61,6 @@ class Layout { {$page->title} $header_html - @@ -95,13 +94,7 @@ EOD; $b = $block->body; $html = ""; $i = str_replace(' ', '_', $h) . $salt; - if($hidable) { - $toggle = " onclick=\"toggle('$i')\""; - } - else { - $toggle = ""; - } - if(!is_null($h)) $html .= "\n

$h

\n"; + if(!is_null($h)) $html .= "\n

$h

\n"; if(!is_null($b)) $html .= "
$b
\n"; return $html; } diff --git a/themes/futaba/sidebar.js b/themes/futaba/sidebar.js deleted file mode 100644 index 585f8ca8..00000000 --- a/themes/futaba/sidebar.js +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This script shamelessly stolen from wakachan.org d(^_^)b - */ - -var cookie_name="shimmie_sidebar"; -var default_sections=["upload", "edit_tags"]; - -function toggle(id) -{ - var e=document.getElementById(id); - if(!e) return; - if(e.style.display) - { - remove_section(id); - e.style.display=""; - - var e2 = document.getElementById(id+"-toggle"); - if(e2) { - e2.style.color = "#000"; - } - } - else - { - add_section(id); - e.style.display="none"; - - var e2 = document.getElementById(id+"-toggle"); - if(e2) { - e2.style.color = "#AAA"; - } - } -} - -function add_section(id) -{ - var sections=get_sections(); - for(var i=0;ibody; $html = ""; $i = str_replace(' ', '_', $h) . $salt; - if($hidable) $html .= " - - "; if(!is_null($h)) { if($salt == "main") { - $html .= ""; + $html .= ""; } else { - $html .= ""; + $html .= ""; } } if(!is_null($b)) { diff --git a/themes/old_default/layout.class.php b/themes/old_default/layout.class.php index ec8e4514..6c70d649 100644 --- a/themes/old_default/layout.class.php +++ b/themes/old_default/layout.class.php @@ -51,7 +51,6 @@ class Layout { {$page->title} $header_html - @@ -84,13 +83,7 @@ EOD; $b = $block->body; $html = ""; $i = str_replace(' ', '_', $h) . $salt; - if($hidable) { - $toggle = " onclick=\"toggle('$i')\""; - } - else { - $toggle = ""; - } - if(!is_null($h)) $html .= "\n

$h

\n"; + if(!is_null($h)) $html .= "\n

$h

\n"; if(!is_null($b)) $html .= "
$b
\n"; return $html; } diff --git a/themes/old_default/sidebar.js b/themes/old_default/sidebar.js deleted file mode 100644 index 585f8ca8..00000000 --- a/themes/old_default/sidebar.js +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This script shamelessly stolen from wakachan.org d(^_^)b - */ - -var cookie_name="shimmie_sidebar"; -var default_sections=["upload", "edit_tags"]; - -function toggle(id) -{ - var e=document.getElementById(id); - if(!e) return; - if(e.style.display) - { - remove_section(id); - e.style.display=""; - - var e2 = document.getElementById(id+"-toggle"); - if(e2) { - e2.style.color = "#000"; - } - } - else - { - add_section(id); - e.style.display="none"; - - var e2 = document.getElementById(id+"-toggle"); - if(e2) { - e2.style.color = "#AAA"; - } - } -} - -function add_section(id) -{ - var sections=get_sections(); - for(var i=0;ibody; $html = ""; $i = str_replace(' ', '_', $h) . $salt; - if($hidable) $html .= " - - "; if(!is_null($h)) $html .= " -
+

$h