[16589] | 1 | jQuery.cookie = function(name, value, options) { |
---|
[8981] | 2 | if (typeof value != 'undefined') { // name and value given, set cookie |
---|
| 3 | options = options || {}; |
---|
| 4 | if (value === null) { |
---|
| 5 | value = ''; |
---|
| 6 | options.expires = -1; |
---|
| 7 | } |
---|
| 8 | var expires = ''; |
---|
| 9 | if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { |
---|
| 10 | var date; |
---|
| 11 | if (typeof options.expires == 'number') { |
---|
| 12 | date = new Date(); |
---|
| 13 | date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); |
---|
| 14 | } else { |
---|
| 15 | date = options.expires; |
---|
| 16 | } |
---|
| 17 | expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE |
---|
| 18 | } |
---|
| 19 | // CAUTION: Needed to parenthesize options.path and options.domain |
---|
| 20 | // in the following expressions, otherwise they evaluate to undefined |
---|
| 21 | // in the packed version for some reason... |
---|
| 22 | var path = options.path ? '; path=' + (options.path) : ''; |
---|
| 23 | var domain = options.domain ? '; domain=' + (options.domain) : ''; |
---|
| 24 | var secure = options.secure ? '; secure' : ''; |
---|
| 25 | document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); |
---|
| 26 | } else { // only name given, get cookie |
---|
| 27 | var cookieValue = null; |
---|
| 28 | if (document.cookie && document.cookie != '') { |
---|
| 29 | var cookies = document.cookie.split(';'); |
---|
| 30 | for (var i = 0; i < cookies.length; i++) { |
---|
| 31 | var cookie = jQuery.trim(cookies[i]); |
---|
| 32 | // Does this cookie string begin with the name we want? |
---|
| 33 | if (cookie.substring(0, name.length + 1) == (name + '=')) { |
---|
| 34 | cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); |
---|
| 35 | break; |
---|
| 36 | } |
---|
| 37 | } |
---|
| 38 | } |
---|
| 39 | return cookieValue; |
---|
[16579] | 40 | } |
---|
| 41 | }; |
---|
[16931] | 42 | |
---|
[16579] | 43 | |
---|
[16931] | 44 | function hideMenu(delay) { |
---|
| 45 | var menubar = jQuery("#menubar"); |
---|
| 46 | var menuswitcher = jQuery("#menuSwitcher"); |
---|
| 47 | var content = jQuery("#the_page > .content"); |
---|
| 48 | var pcontent = jQuery("#content"); |
---|
| 49 | |
---|
| 50 | menubar.hide(delay); |
---|
| 51 | menuswitcher.addClass("menuhidden").removeClass("menushown"); |
---|
| 52 | content.addClass("menuhidden").removeClass("menushown"); |
---|
| 53 | pcontent.addClass("menuhidden").removeClass("menushown"); |
---|
| 54 | jQuery.cookie('picture-menu', 'hidden', { path: "/" }); |
---|
| 55 | |
---|
[16589] | 56 | } |
---|
[16931] | 57 | |
---|
| 58 | function showMenu(delay) { |
---|
| 59 | |
---|
| 60 | var menubar = jQuery("#menubar"); |
---|
| 61 | var menuswitcher = jQuery("#menuSwitcher"); |
---|
| 62 | var content = jQuery("#the_page > .content"); |
---|
| 63 | var pcontent = jQuery("#content"); |
---|
| 64 | |
---|
| 65 | menubar.show(delay); |
---|
| 66 | menuswitcher.addClass("menushown").removeClass("menuhidden"); |
---|
| 67 | content.addClass("menushown").removeClass("menuhidden"); |
---|
| 68 | pcontent.addClass("menushown").removeClass("menuhidden"); |
---|
| 69 | jQuery.cookie('picture-menu', 'visible', { path: "/" }); |
---|
| 70 | |
---|
[16589] | 71 | } |
---|
[16931] | 72 | |
---|
| 73 | function hideInfo(delay) { |
---|
| 74 | |
---|
| 75 | var imageInfos = jQuery("#imageInfos"); |
---|
| 76 | var infoswitcher = jQuery("#infoSwitcher"); |
---|
| 77 | var theImage = jQuery("#theImage"); |
---|
| 78 | |
---|
| 79 | imageInfos.hide(delay); |
---|
| 80 | infoswitcher.addClass("infohidden").removeClass("infoshown"); |
---|
| 81 | theImage.addClass("infohidden").removeClass("infoshown"); |
---|
| 82 | jQuery.cookie('side-info', 'hidden', { path: "/" }); |
---|
| 83 | |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | function showInfo(delay) { |
---|
| 87 | |
---|
| 88 | var imageInfos = jQuery("#imageInfos"); |
---|
| 89 | var infoswitcher = jQuery("#infoSwitcher"); |
---|
| 90 | var theImage = jQuery("#theImage"); |
---|
| 91 | |
---|
| 92 | imageInfos.show(delay); |
---|
| 93 | infoswitcher.addClass("infoshown").removeClass("infohidden"); |
---|
| 94 | theImage.addClass("infoshown").removeClass("infohidden"); |
---|
| 95 | jQuery.cookie('side-info', 'visible', { path: "/" }); |
---|
| 96 | |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | jQuery("document").ready(function (jQuery) { |
---|
| 100 | |
---|
[17308] | 101 | return; |
---|
| 102 | |
---|
[16931] | 103 | // side-menu show/hide |
---|
| 104 | |
---|
[17308] | 105 | |
---|
| 106 | var sidemenu = jQuery.cookie('picture-menu') || jQuery.cookie('side-menu'); |
---|
[16931] | 107 | var menubar = jQuery("#menubar"); |
---|
[17308] | 108 | // return; |
---|
[16931] | 109 | if (menubar.length == 1) { |
---|
| 110 | |
---|
| 111 | jQuery("#menuSwitcher").html("<div class=\"switchArrow\"> </div>"); |
---|
| 112 | |
---|
| 113 | // if cookie says the menu is hiding, keep it hidden! |
---|
[17308] | 114 | if (sidemenu == 'visible' || sidemenu == 'showing') { |
---|
[16931] | 115 | showMenu(0); |
---|
| 116 | } else { |
---|
| 117 | hideMenu(0); |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | jQuery("#menuSwitcher").click(function () { |
---|
| 121 | if (jQuery("#menubar").is(":hidden")) { |
---|
| 122 | showMenu(0); |
---|
| 123 | return false; |
---|
| 124 | } else { |
---|
| 125 | hideMenu(0); |
---|
| 126 | return false; |
---|
| 127 | } |
---|
| 128 | }); |
---|
| 129 | |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | // info show/hide |
---|
| 133 | |
---|
| 134 | var sideinfo = jQuery.cookie('side-info'); |
---|
| 135 | var imageInfos = jQuery("#imageInfos"); |
---|
| 136 | |
---|
| 137 | if (imageInfos.length == 1) { |
---|
| 138 | |
---|
| 139 | jQuery("#infoSwitcher").html("<div class=\"switchArrow\"> </div>"); |
---|
| 140 | |
---|
| 141 | // if cookie says the menu is hiding, keep it hidden! |
---|
| 142 | if (sideinfo == 'hidden') { |
---|
| 143 | hideInfo(0); |
---|
| 144 | } else { |
---|
| 145 | showInfo(0); |
---|
| 146 | } |
---|
| 147 | |
---|
| 148 | jQuery("#infoSwitcher").click(function () { |
---|
| 149 | if (jQuery("#imageInfos").is(":hidden")) { |
---|
| 150 | showInfo(0); |
---|
| 151 | return false; |
---|
| 152 | } else { |
---|
| 153 | hideInfo(0); |
---|
| 154 | return false; |
---|
| 155 | } |
---|
| 156 | }); |
---|
| 157 | |
---|
| 158 | } |
---|
| 159 | |
---|
| 160 | // comments show/hide |
---|
| 161 | |
---|
| 162 | var commentsswicther = jQuery("#commentsSwitcher"); |
---|
| 163 | var comments = jQuery("#thePicturePage #comments"); |
---|
| 164 | |
---|
| 165 | commentsswicther.html("<div class=\"switchArrow\"> </div>"); |
---|
| 166 | |
---|
| 167 | if (comments.length == 1) { |
---|
| 168 | var comments_button = jQuery("#comments h3"); |
---|
| 169 | |
---|
| 170 | if (comments_button.length == 0) { |
---|
| 171 | jQuery("#addComment").before("<h3>Comments</h3>"); |
---|
| 172 | comments_button = jQuery("#comments h3"); |
---|
| 173 | } |
---|
| 174 | |
---|
| 175 | if (jQuery.cookie('comments') == 'visible') { |
---|
| 176 | comments.addClass("commentsshown"); |
---|
| 177 | comments_button.addClass("comments_toggle").addClass("comments_toggle_off"); |
---|
| 178 | } else { |
---|
| 179 | comments.addClass("commentshidden"); |
---|
| 180 | comments_button.addClass("comments_toggle").addClass("comments_toggle_on"); |
---|
| 181 | } |
---|
| 182 | |
---|
| 183 | comments_button.click(function () { commentsToggle() }); |
---|
| 184 | commentsswicther.click(function () { commentsToggle() }); |
---|
| 185 | |
---|
| 186 | } |
---|
| 187 | |
---|
| 188 | |
---|
| 189 | }); |
---|
| 190 | |
---|
| 191 | function commentsToggle() { |
---|
| 192 | var comments = jQuery("#thePicturePage #comments"); |
---|
| 193 | var comments_button = jQuery("#comments h3"); |
---|
| 194 | |
---|
| 195 | if (comments.hasClass("commentshidden")) { |
---|
| 196 | comments.removeClass("commentshidden").addClass("commentsshown"); |
---|
| 197 | comments_button.addClass("comments_toggle_off").removeClass("comments_toggle_on"); ; |
---|
| 198 | jQuery.cookie('comments', 'visible', { path: "/" }); |
---|
| 199 | } else { |
---|
| 200 | comments.addClass("commentshidden").removeClass("commentsshown"); |
---|
| 201 | comments_button.addClass("comments_toggle_on").removeClass("comments_toggle_off"); ; |
---|
| 202 | jQuery.cookie('comments', 'hidden', { path: "/" }); |
---|
| 203 | } |
---|
| 204 | |
---|
| 205 | } |
---|