aboutsummaryrefslogtreecommitdiffstats
path: root/themes/elegant/scripts_pp.js
blob: 92e8cfc06dad47d0d19e2a5c7246a750ab77ff0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/**
 * Cookie plugin
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 */
jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options=jQuery.extend({},options);options.expires=-1;}
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;}
expires='; expires='+date.toUTCString();}
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;}}}
return cookieValue;}};

if (jQuery.cookie('picture-menu') == 'visible') {
	jQuery("head").append("<style type=\"text/css\">#content.contentWithMenu, #the_page > .content {margin-left:240px;}</style>");
} else {
	jQuery("head").append("<style type=\"text/css\">#the_page #menubar {display:none;} #content.contentWithMenu, #the_page > .content {margin-left:35px;}</style>");
}

function hideMenu(delay) {
	var menubar=jQuery("#menubar");
	var menuswitcher=jQuery("#menuSwitcher");
	var content=jQuery("#the_page > .content");
	var pcontent=jQuery("#content");
	
	menubar.hide(delay);
	menuswitcher.addClass("menuhidden").removeClass("menushown");
	content.addClass("menuhidden").removeClass("menushown");
	pcontent.addClass("menuhidden").removeClass("menushown");
	jQuery.cookie('picture-menu', 'hidden', {path: "/"});
	
}

function showMenu(delay) {

	var menubar=jQuery("#menubar");
	var menuswitcher=jQuery("#menuSwitcher");
	var content=jQuery("#the_page > .content");
	var pcontent=jQuery("#content");

	menubar.show(delay);
	menuswitcher.addClass("menushown").removeClass("menuhidden");
	content.addClass("menushown").removeClass("menuhidden");
	pcontent.addClass("menushown").removeClass("menuhidden");
	jQuery.cookie('picture-menu', 'visible', {path: "/"});
	
}

function hideInfo(delay) {

	var imageInfos=jQuery("#imageInfos");
	var infoswitcher=jQuery("#infoSwitcher");
	var theImage=jQuery("#theImage");
	
	imageInfos.hide(delay);
	infoswitcher.addClass("infohidden").removeClass("infoshown");
	theImage.addClass("infohidden").removeClass("infoshown");
	jQuery.cookie('side-info', 'hidden', {path: "/"});

}

function showInfo(delay) {

	var imageInfos=jQuery("#imageInfos");
	var infoswitcher=jQuery("#infoSwitcher");
	var theImage=jQuery("#theImage");
	
	imageInfos.show(delay);
	infoswitcher.addClass("infoshown").removeClass("infohidden");
	theImage.addClass("infoshown").removeClass("infohidden");
	jQuery.cookie('side-info', 'visible', {path: "/"});

}

jQuery("document").ready(function(jQuery){
	
	// side-menu show/hide

	var sidemenu = jQuery.cookie('picture-menu');
	var menubar=jQuery("#menubar");

	if (menubar.length == 1) {

		jQuery("#menuSwitcher").html("<div class=\"switchArrow\">&nbsp;</div>");

		// if cookie says the menu is hiding, keep it hidden!
		if (sidemenu == 'visible') {
			showMenu(0);
		} else {
			hideMenu(0);
		}
	
		jQuery("#menuSwitcher").click(function(){
			if (jQuery("#menubar").is(":hidden")) {
				showMenu(0);
				return false;
			} else {
				hideMenu(0);
				return false;
			}
		});
	
	}

	// info show/hide
	
	var sideinfo = jQuery.cookie('side-info');
	var imageInfos=jQuery("#imageInfos");

	if (imageInfos.length == 1) {

		jQuery("#infoSwitcher").html("<div class=\"switchArrow\">&nbsp;</div>");

		// if cookie says the menu is hiding, keep it hidden!
		if (sideinfo == 'hidden') {
			hideInfo(0);
		} else {
			showInfo(0);
		}
	
		jQuery("#infoSwitcher").click(function(){
			if (jQuery("#imageInfos").is(":hidden")) {
				showInfo(0);
				return false;
			} else {
				hideInfo(0);
				return false;
			}
		});
	
	}

	// comments show/hide

	var commentsswicther=jQuery("#commentsSwitcher");
	var comments=jQuery("#thePicturePage #comments");
	
	commentsswicther.html("<div class=\"switchArrow\">&nbsp;</div>");
	
	if (comments.length == 1) {
		var comments_button=jQuery("#comments h3");

		if (comments_button.length == 0) {
			jQuery("#addComment").before("<h3>Comments</h3>");
			comments_button=jQuery("#comments h3");
		}
	
		if (jQuery.cookie('comments') == 'visible') {
			comments.addClass("commentsshown");
			comments_button.addClass("comments_toggle").addClass("comments_toggle_off");
		} else {
			comments.addClass("commentshidden");
			comments_button.addClass("comments_toggle").addClass("comments_toggle_on");
		}
		
		comments_button.click(function() { commentsToggle() });
		commentsswicther.click(function() { commentsToggle() });
	
	}
	
	
});

function commentsToggle() {
	var comments=jQuery("#thePicturePage #comments");
	var comments_button=jQuery("#comments h3");

	if (comments.hasClass("commentshidden")) {
			comments.removeClass("commentshidden").addClass("commentsshown");
			comments_button.addClass("comments_toggle_off").removeClass("comments_toggle_on");;
			jQuery.cookie('comments', 'visible', {path: "/"});
		} else {
			comments.addClass("commentshidden").removeClass("commentsshown");
			comments_button.addClass("comments_toggle_on").removeClass("comments_toggle_off");;
			jQuery.cookie('comments', 'hidden', {path: "/"});
		}

}