From c24a1ccd085b2ac48ef0d6d332ba170d66b0cdd3 Mon Sep 17 00:00:00 2001 From: urs_hunkler Date: Sat, 5 Feb 2005 21:37:53 +0000 Subject: [PATCH] I added all code to handle the cookies and the sideblock content, the icon and the patches for hiding/showing the content of the sideblocks. How it works: _ within the "sideblockheading" a DIV with class="hide-show" holds a link calling the JS containerDisplaySwitching(). To the user it's represented by the icon "switch.gif" (a plus in a square) at the right end side of the header. _ all content of the sideblock is surounded by a new
" _ a call of the JS containerDisplaySwitching() changes the state of the appropriate DIV with the content to "display:none/inline" and writes this state into a cookie. _ at the end of every block I added a call to the JS "containerDisplaySet()". This reads the block's state and hides the content or leaves it visible with every page load. _ in the stylesheet I added the positioning of the icon: .sideblockheading .hide-show { float:right; } .sideblockheading a img.hide-show-image { padding-top:0.25em; } --- lib/container.js | 37 ++++++++++++ lib/cookies.js | 84 ++++++++++++++++++++++++++++ lib/javascript.php | 3 + lib/weblib.php | 26 +++++++-- pix/t/switch.gif | Bin 0 -> 124 bytes theme/orangewhite/styles_layout.css | 8 +++ theme/standard/styles_layout.css | 8 +++ 7 files changed, 161 insertions(+), 5 deletions(-) create mode 100644 lib/container.js create mode 100644 lib/cookies.js create mode 100644 pix/t/switch.gif diff --git a/lib/container.js b/lib/container.js new file mode 100644 index 0000000000..436c1a3876 --- /dev/null +++ b/lib/container.js @@ -0,0 +1,37 @@ +function containerDisplaySwitching(id) +{ + var id_cont = id + "_cont"; + var x = new getObj(id_cont); + var what = (x.style.display == 'inline' || x.style.display == '') ? 'none' : 'inline'; + x.style.display = what; + new cookie(id, what, 356, '/').set(); +} + +function containerDisplaySet(id) +{ + var id_cont = id + "_cont"; + var x = new getObj(id_cont); + var what = new cookie(id).read(); + if (what != null) { + x.style.display = what; + } +} + +function getObj(id) +{ + if (document.getElementById) + { + this.obj = document.getElementById(id); + this.style = document.getElementById(id).style; + } + else if (document.all) + { + this.obj = document.all[id]; + this.style = document.all[id].style; + } + else if (document.layers) + { + this.obj = document.layers[id]; + this.style = document.layers[id]; + } +} diff --git a/lib/cookies.js b/lib/cookies.js new file mode 100644 index 0000000000..966b7c2ceb --- /dev/null +++ b/lib/cookies.js @@ -0,0 +1,84 @@ +/******************************************************* +COOKIE FUNCTIONALITY +Based on "Night of the Living Cookie" by Bill Dortch +(c) 2003, Ryan Parman +http://www.skyzyx.com +Distributed according to SkyGPL 2.1, http://www.skyzyx.com/license/ +*******************************************************/ +function cookie(name, value, expires, path, domain, secure) +{ + // Passed Values + this.name=name; + this.value=value; + this.expires=expires; + this.path=path; + this.domain=domain; + this.secure=secure; + + // Read cookie + this.read=function() + { + // To allow for faster parsing + var ck=document.cookie; + + var arg = this.name + "="; + var alen = arg.length; + var clen = ck.length; + var i = 0; + + while (i < clen) + { + var j = i + alen; + if (ck.substring(i, j) == arg) + { + var endstr = ck.indexOf (";", j); + if (endstr == -1) endstr = ck.length; + return unescape(ck.substring(j, endstr)); + } + i = ck.indexOf(" ", i) + 1; + if (i == 0) break; + } + return null; + } + + // Set cookie + this.set=function() + { + // Store initial value of "this.expires" for re-initialization. + expStore=this.expires; + + // Set time to absolute zero. + exp = new Date(); + base = new Date(0); + skew = base.getTime(); + if (skew > 0) exp.setTime (exp.getTime() - skew); + exp.setTime(exp.getTime() + (this.expires*24*60*60*1000)); + this.expires=exp; + + document.cookie = this.name + "=" + escape (this.value) + + ((this.expires) ? "; expires=" + this.expires.toGMTString() : "") + + ((this.path) ? "; path=" + this.path : "") + + ((this.domain) ? "; domain=" + this.domain : "") + + ((this.secure) ? "; secure" : ""); + + // Re-initialize + this.expires=expStore; + } + + // Kill cookie + this.kill=function() + { + document.cookie = this.name + "=" + + ((this.path) ? "; path=" + this.path : "") + + ((this.domain) ? "; domain=" + this.domain : "") + + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; + } + + // Change cookie settings. + this.changeName=function(chName) { this.kill(); this.name=chName; this.set(); } + this.changeVal=function(chVal) { this.kill(); this.value=chVal; this.set(); } + this.changeExp=function(chExp) { this.kill(); this.expires=chExp; this.set(); } + this.changePath=function(chPath) { this.kill(); this.path=chPath; this.set(); } + this.changeDomain=function(chDom) { this.kill(); this.domain=chDom; this.set(); } + this.changeSecurity=function(chSec) { this.kill(); this.secure=chSec; this.set(); } +} diff --git a/lib/javascript.php b/lib/javascript.php index d4dd36c6fc..d871c780b8 100644 --- a/lib/javascript.php +++ b/lib/javascript.php @@ -11,6 +11,9 @@ ?> + "; echo "\n"; } diff --git a/pix/t/switch.gif b/pix/t/switch.gif new file mode 100644 index 0000000000000000000000000000000000000000..84ac3532459419c05bf4d53206d14f3864524fde GIT binary patch literal 124 zcmV-?0E7QWNk%w1VG95Y0J9DNva+)O|NmiOVX3L9u&}VPv9YMAsI#-Po}QkZoSc-D zl&7bst*x!Eudo0A{{R30A^8LW000gEEC2ui01E&M000Cj5P=B}ZELvAIWb*GXq?a$ epecd{z?}>+K*bxazWynxO0029>=rm;j literal 0 HcmV?d00001 diff --git a/theme/orangewhite/styles_layout.css b/theme/orangewhite/styles_layout.css index 2c6d3e5835..48ede844c3 100644 --- a/theme/orangewhite/styles_layout.css +++ b/theme/orangewhite/styles_layout.css @@ -676,6 +676,14 @@ TD.cal_event_description { padding-top:0.5em; } +.sideblockheading .hide-show { + float:right; +} + +.sideblockheading a img.hide-show-image { + padding-top:0.35em; +} + .sideblockmain HR { height:1px; border:none; diff --git a/theme/standard/styles_layout.css b/theme/standard/styles_layout.css index 8b96433e1c..4fcaaa7995 100644 --- a/theme/standard/styles_layout.css +++ b/theme/standard/styles_layout.css @@ -436,6 +436,14 @@ td.cal_event_description { background-repeat:repeat-x; } +.sideblockheading .hide-show { + float:right; +} + +.sideblockheading a img.hide-show-image { + padding-top:0.25em; +} + .sideblockmain hr { height:1px; margin-top:4px; -- 2.39.5