[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 | |
---|
[23251] | 80 | if (menubar.length == 1 && p_main_menu!="disabled") { |
---|
[13730] | 81 | |
---|
| 82 | jQuery("#menuSwitcher").html("<div class=\"switchArrow\"> </div>"); |
---|
| 83 | |
---|
| 84 | // if cookie says the menu is hiding, keep it hidden! |
---|
[23251] | 85 | if (sidemenu == 'hidden') { |
---|
| 86 | hideMenu(0); |
---|
| 87 | } else if (sidemenu == 'visible') { |
---|
[13730] | 88 | showMenu(0); |
---|
[23251] | 89 | } else if (p_main_menu == 'off') { |
---|
[13730] | 90 | hideMenu(0); |
---|
[23251] | 91 | } else { |
---|
| 92 | showMenu(0); |
---|
[13730] | 93 | } |
---|
| 94 | |
---|
| 95 | jQuery("#menuSwitcher").click(function(){ |
---|
| 96 | if (jQuery("#menubar").is(":hidden")) { |
---|
| 97 | showMenu(0); |
---|
| 98 | return false; |
---|
| 99 | } else { |
---|
| 100 | hideMenu(0); |
---|
| 101 | return false; |
---|
| 102 | } |
---|
| 103 | }); |
---|
| 104 | |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | // info show/hide |
---|
| 108 | |
---|
| 109 | var sideinfo = jQuery.cookie('side-info'); |
---|
| 110 | var imageInfos=jQuery("#imageInfos"); |
---|
| 111 | |
---|
[23251] | 112 | if (imageInfos.length == 1 && p_pict_descr!="disabled") { |
---|
[13730] | 113 | |
---|
| 114 | jQuery("#infoSwitcher").html("<div class=\"switchArrow\"> </div>"); |
---|
| 115 | |
---|
| 116 | // if cookie says the menu is hiding, keep it hidden! |
---|
| 117 | if (sideinfo == 'hidden') { |
---|
| 118 | hideInfo(0); |
---|
[23251] | 119 | } else if (sideinfo == 'visible') { |
---|
| 120 | showInfo(0); |
---|
| 121 | } else if (p_pict_descr == 'off') { |
---|
| 122 | hideInfo(0); |
---|
[13730] | 123 | } else { |
---|
| 124 | showInfo(0); |
---|
| 125 | } |
---|
| 126 | |
---|
| 127 | jQuery("#infoSwitcher").click(function(){ |
---|
| 128 | if (jQuery("#imageInfos").is(":hidden")) { |
---|
| 129 | showInfo(0); |
---|
| 130 | return false; |
---|
| 131 | } else { |
---|
| 132 | hideInfo(0); |
---|
| 133 | return false; |
---|
| 134 | } |
---|
| 135 | }); |
---|
| 136 | |
---|
| 137 | } |
---|
| 138 | |
---|
| 139 | // comments show/hide |
---|
| 140 | |
---|
| 141 | var commentsswicther=jQuery("#commentsSwitcher"); |
---|
| 142 | var comments=jQuery("#thePicturePage #comments"); |
---|
| 143 | |
---|
| 144 | commentsswicther.html("<div class=\"switchArrow\"> </div>"); |
---|
| 145 | |
---|
[23251] | 146 | if (comments.length == 1 && p_pict_comment!="disabled") { |
---|
[13730] | 147 | var comments_button=jQuery("#comments h3"); |
---|
| 148 | |
---|
| 149 | if (comments_button.length == 0) { |
---|
| 150 | jQuery("#addComment").before("<h3>Comments</h3>"); |
---|
| 151 | comments_button=jQuery("#comments h3"); |
---|
| 152 | } |
---|
| 153 | |
---|
[23251] | 154 | if (jQuery.cookie('comments') == 'hidden') { |
---|
| 155 | comments.addClass("commentshidden"); |
---|
| 156 | comments_button.addClass("comments_toggle").addClass("comments_toggle_on"); |
---|
| 157 | } else if (jQuery.cookie('comments') == 'visible') { |
---|
[13730] | 158 | comments.addClass("commentsshown"); |
---|
| 159 | comments_button.addClass("comments_toggle").addClass("comments_toggle_off"); |
---|
[23251] | 160 | } else if (p_pict_comment == 'off') { |
---|
[13730] | 161 | comments.addClass("commentshidden"); |
---|
| 162 | comments_button.addClass("comments_toggle").addClass("comments_toggle_on"); |
---|
[23251] | 163 | } else { |
---|
| 164 | comments.addClass("commentsshown"); |
---|
| 165 | comments_button.addClass("comments_toggle").addClass("comments_toggle_off"); |
---|
[13730] | 166 | } |
---|
| 167 | |
---|
| 168 | comments_button.click(function() { commentsToggle() }); |
---|
| 169 | commentsswicther.click(function() { commentsToggle() }); |
---|
[23269] | 170 | |
---|
| 171 | if (jQuery('#commentAdd').is(":visible")) { |
---|
| 172 | var top = jQuery('#commentAdd').offset().top - parseFloat(jQuery('#commentAdd').css('marginTop').replace(/auto/, 0)); |
---|
| 173 | jQuery(window).scroll(function (event) { |
---|
| 174 | // what the y position of the scroll is |
---|
| 175 | var y = jQuery(this).scrollTop(); |
---|
| 176 | |
---|
| 177 | // whether that's below the form |
---|
| 178 | if (y >= top) { |
---|
| 179 | // if so, ad the fixed class |
---|
| 180 | jQuery('#commentAdd').addClass('fixed'); |
---|
| 181 | } else { |
---|
| 182 | // otherwise remove it |
---|
| 183 | jQuery('#commentAdd').removeClass('fixed'); |
---|
| 184 | } |
---|
| 185 | }); |
---|
| 186 | } |
---|
[13730] | 187 | } |
---|
[23233] | 188 | |
---|
| 189 | |
---|
[13730] | 190 | |
---|
| 191 | }); |
---|
| 192 | |
---|
| 193 | function commentsToggle() { |
---|
| 194 | var comments=jQuery("#thePicturePage #comments"); |
---|
| 195 | var comments_button=jQuery("#comments h3"); |
---|
| 196 | |
---|
| 197 | if (comments.hasClass("commentshidden")) { |
---|
| 198 | comments.removeClass("commentshidden").addClass("commentsshown"); |
---|
| 199 | comments_button.addClass("comments_toggle_off").removeClass("comments_toggle_on");; |
---|
| 200 | jQuery.cookie('comments', 'visible', {path: "/"}); |
---|
[23269] | 201 | var top = jQuery('#commentAdd').offset().top - parseFloat(jQuery('#commentAdd').css('marginTop').replace(/auto/, 0)); |
---|
| 202 | jQuery(window).scroll(function (event) { |
---|
| 203 | // what the y position of the scroll is |
---|
| 204 | var y = jQuery(this).scrollTop(); |
---|
| 205 | |
---|
| 206 | // whether that's below the form |
---|
| 207 | if (y >= top) { |
---|
| 208 | // if so, ad the fixed class |
---|
| 209 | jQuery('#commentAdd').addClass('fixed'); |
---|
| 210 | } else { |
---|
| 211 | // otherwise remove it |
---|
| 212 | jQuery('#commentAdd').removeClass('fixed'); |
---|
| 213 | } |
---|
| 214 | }); |
---|
| 215 | |
---|
[13730] | 216 | } else { |
---|
| 217 | comments.addClass("commentshidden").removeClass("commentsshown"); |
---|
| 218 | comments_button.addClass("comments_toggle_on").removeClass("comments_toggle_off");; |
---|
| 219 | jQuery.cookie('comments', 'hidden', {path: "/"}); |
---|
| 220 | } |
---|
| 221 | |
---|
| 222 | } |
---|