[13730] | 1 | /** |
---|
| 2 | * Cookie plugin |
---|
| 3 | * Copyright (c) 2006 Klaus Hartl (stilbuero.de) |
---|
| 4 | * Dual licensed under the MIT and GPL licenses: |
---|
| 5 | */ |
---|
| 6 | jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options=jQuery.extend({},options);options.expires=-1;} |
---|
| 7 | var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;} |
---|
| 8 | expires='; expires='+date.toUTCString();} |
---|
| 9 | var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}} |
---|
| 10 | return cookieValue;}}; |
---|
| 11 | |
---|
| 12 | if (jQuery.cookie('picture-menu') == 'visible') { |
---|
| 13 | jQuery("head").append("<style type=\"text/css\">#content.contentWithMenu, #the_page > .content {margin-left:240px;}</style>"); |
---|
| 14 | } else { |
---|
| 15 | jQuery("head").append("<style type=\"text/css\">#the_page #menubar {display:none;} #content.contentWithMenu, #the_page > .content {margin-left:35px;}</style>"); |
---|
| 16 | } |
---|
| 17 | |
---|
| 18 | function hideMenu(delay) { |
---|
| 19 | var menubar=jQuery("#menubar"); |
---|
| 20 | var menuswitcher=jQuery("#menuSwitcher"); |
---|
| 21 | var content=jQuery("#the_page > .content"); |
---|
| 22 | var pcontent=jQuery("#content"); |
---|
| 23 | |
---|
| 24 | menubar.hide(delay); |
---|
| 25 | menuswitcher.addClass("menuhidden").removeClass("menushown"); |
---|
| 26 | content.addClass("menuhidden").removeClass("menushown"); |
---|
| 27 | pcontent.addClass("menuhidden").removeClass("menushown"); |
---|
| 28 | jQuery.cookie('picture-menu', 'hidden', {path: "/"}); |
---|
| 29 | |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | function showMenu(delay) { |
---|
| 33 | |
---|
| 34 | var menubar=jQuery("#menubar"); |
---|
| 35 | var menuswitcher=jQuery("#menuSwitcher"); |
---|
| 36 | var content=jQuery("#the_page > .content"); |
---|
| 37 | var pcontent=jQuery("#content"); |
---|
| 38 | |
---|
| 39 | menubar.show(delay); |
---|
| 40 | menuswitcher.addClass("menushown").removeClass("menuhidden"); |
---|
| 41 | content.addClass("menushown").removeClass("menuhidden"); |
---|
| 42 | pcontent.addClass("menushown").removeClass("menuhidden"); |
---|
| 43 | jQuery.cookie('picture-menu', 'visible', {path: "/"}); |
---|
| 44 | |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | function hideInfo(delay) { |
---|
| 48 | |
---|
| 49 | var imageInfos=jQuery("#imageInfos"); |
---|
| 50 | var infoswitcher=jQuery("#infoSwitcher"); |
---|
| 51 | var theImage=jQuery("#theImage"); |
---|
| 52 | |
---|
| 53 | imageInfos.hide(delay); |
---|
| 54 | infoswitcher.addClass("infohidden").removeClass("infoshown"); |
---|
| 55 | theImage.addClass("infohidden").removeClass("infoshown"); |
---|
| 56 | jQuery.cookie('side-info', 'hidden', {path: "/"}); |
---|
| 57 | |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | function showInfo(delay) { |
---|
| 61 | |
---|
| 62 | var imageInfos=jQuery("#imageInfos"); |
---|
| 63 | var infoswitcher=jQuery("#infoSwitcher"); |
---|
| 64 | var theImage=jQuery("#theImage"); |
---|
| 65 | |
---|
| 66 | imageInfos.show(delay); |
---|
| 67 | infoswitcher.addClass("infoshown").removeClass("infohidden"); |
---|
| 68 | theImage.addClass("infoshown").removeClass("infohidden"); |
---|
| 69 | jQuery.cookie('side-info', 'visible', {path: "/"}); |
---|
| 70 | |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | jQuery("document").ready(function(jQuery){ |
---|
| 74 | |
---|
| 75 | // side-menu show/hide |
---|
| 76 | |
---|
| 77 | var sidemenu = jQuery.cookie('picture-menu'); |
---|
| 78 | var menubar=jQuery("#menubar"); |
---|
| 79 | |
---|
| 80 | if (menubar.length == 1) { |
---|
| 81 | |
---|
| 82 | jQuery("#menuSwitcher").html("<div class=\"switchArrow\"> </div>"); |
---|
| 83 | |
---|
| 84 | // if cookie says the menu is hiding, keep it hidden! |
---|
| 85 | if (sidemenu == 'visible') { |
---|
| 86 | showMenu(0); |
---|
| 87 | } else { |
---|
| 88 | hideMenu(0); |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | jQuery("#menuSwitcher").click(function(){ |
---|
| 92 | if (jQuery("#menubar").is(":hidden")) { |
---|
| 93 | showMenu(0); |
---|
| 94 | return false; |
---|
| 95 | } else { |
---|
| 96 | hideMenu(0); |
---|
| 97 | return false; |
---|
| 98 | } |
---|
| 99 | }); |
---|
| 100 | |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | // info show/hide |
---|
| 104 | |
---|
| 105 | var sideinfo = jQuery.cookie('side-info'); |
---|
| 106 | var imageInfos=jQuery("#imageInfos"); |
---|
| 107 | |
---|
| 108 | if (imageInfos.length == 1) { |
---|
| 109 | |
---|
| 110 | jQuery("#infoSwitcher").html("<div class=\"switchArrow\"> </div>"); |
---|
| 111 | |
---|
| 112 | // if cookie says the menu is hiding, keep it hidden! |
---|
| 113 | if (sideinfo == 'hidden') { |
---|
| 114 | hideInfo(0); |
---|
| 115 | } else { |
---|
| 116 | showInfo(0); |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | jQuery("#infoSwitcher").click(function(){ |
---|
| 120 | if (jQuery("#imageInfos").is(":hidden")) { |
---|
| 121 | showInfo(0); |
---|
| 122 | return false; |
---|
| 123 | } else { |
---|
| 124 | hideInfo(0); |
---|
| 125 | return false; |
---|
| 126 | } |
---|
| 127 | }); |
---|
| 128 | |
---|
| 129 | } |
---|
| 130 | |
---|
| 131 | // comments show/hide |
---|
| 132 | |
---|
| 133 | var commentsswicther=jQuery("#commentsSwitcher"); |
---|
| 134 | var comments=jQuery("#thePicturePage #comments"); |
---|
| 135 | |
---|
| 136 | commentsswicther.html("<div class=\"switchArrow\"> </div>"); |
---|
| 137 | |
---|
| 138 | if (comments.length == 1) { |
---|
| 139 | var comments_button=jQuery("#comments h3"); |
---|
| 140 | |
---|
| 141 | if (comments_button.length == 0) { |
---|
| 142 | jQuery("#addComment").before("<h3>Comments</h3>"); |
---|
| 143 | comments_button=jQuery("#comments h3"); |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | if (jQuery.cookie('comments') == 'visible') { |
---|
| 147 | comments.addClass("commentsshown"); |
---|
| 148 | comments_button.addClass("comments_toggle").addClass("comments_toggle_off"); |
---|
| 149 | } else { |
---|
| 150 | comments.addClass("commentshidden"); |
---|
| 151 | comments_button.addClass("comments_toggle").addClass("comments_toggle_on"); |
---|
| 152 | } |
---|
| 153 | |
---|
| 154 | comments_button.click(function() { commentsToggle() }); |
---|
| 155 | commentsswicther.click(function() { commentsToggle() }); |
---|
| 156 | |
---|
| 157 | } |
---|
| 158 | |
---|
| 159 | |
---|
| 160 | }); |
---|
| 161 | |
---|
| 162 | function commentsToggle() { |
---|
| 163 | var comments=jQuery("#thePicturePage #comments"); |
---|
| 164 | var comments_button=jQuery("#comments h3"); |
---|
| 165 | |
---|
| 166 | if (comments.hasClass("commentshidden")) { |
---|
| 167 | comments.removeClass("commentshidden").addClass("commentsshown"); |
---|
| 168 | comments_button.addClass("comments_toggle_off").removeClass("comments_toggle_on");; |
---|
| 169 | jQuery.cookie('comments', 'visible', {path: "/"}); |
---|
| 170 | } else { |
---|
| 171 | comments.addClass("commentshidden").removeClass("commentsshown"); |
---|
| 172 | comments_button.addClass("comments_toggle_on").removeClass("comments_toggle_off");; |
---|
| 173 | jQuery.cookie('comments', 'hidden', {path: "/"}); |
---|
| 174 | } |
---|
| 175 | |
---|
| 176 | } |
---|