1 | /* ----------------------------------------------------------------------------- |
---|
2 | GALLY |
---|
3 | Template for Piwigo |
---|
4 | ------------------------------------------------------------------------------ |
---|
5 | file: gally/gallyjs-tcp.js |
---|
6 | file release: 1.4.4 |
---|
7 | ------------------------------------------------------------------------------ |
---|
8 | author: grum at piwigo.org |
---|
9 | << May the Little SpaceFrog be with you >> |
---|
10 | ------------------------------------------------------------------------------ |
---|
11 | JS for the categories pages |
---|
12 | |
---|
13 | need jQuery 1.2.6 |
---|
14 | |
---|
15 | see the release_notes.txt file for more informations |
---|
16 | ----------------------------------------------------------------------------- */ |
---|
17 | |
---|
18 | var gallyCP=null; |
---|
19 | |
---|
20 | $(document).ready( |
---|
21 | function() |
---|
22 | { |
---|
23 | gallyCP=new GallyCP(); |
---|
24 | } |
---|
25 | ); |
---|
26 | |
---|
27 | |
---|
28 | function GallyCP () |
---|
29 | { |
---|
30 | var menuState, |
---|
31 | |
---|
32 | initContentDesc = function() |
---|
33 | { |
---|
34 | var tmpInfo=''; |
---|
35 | |
---|
36 | if(($("#additional_infoTOP").length + $("#additional_infoBOTTOM").length)<2) |
---|
37 | { |
---|
38 | // if div TOP & BOTTOM don't exists, it's not necessary to process this the |
---|
39 | // initialisation |
---|
40 | return(false); |
---|
41 | } |
---|
42 | /* |
---|
43 | this code permit to manage 3 informations panels with one text area (or 2 if |
---|
44 | extended description plugin is used) |
---|
45 | |
---|
46 | this function don't use a regExp object (due to some freeze with this method |
---|
47 | during test) |
---|
48 | |
---|
49 | known tags : |
---|
50 | <!--up-down--> |
---|
51 | <!--right-left--> |
---|
52 | |
---|
53 | if the plugin "ExtendedDescription" is installed, the "<!--up-down-->" tag is |
---|
54 | already managed by the plugin : |
---|
55 | - top text is in a <div class="additional_info"> |
---|
56 | => text is moved to the to the '#additional_infoTOP' div and |
---|
57 | the '.additional_info' div added by the plugin is deleted |
---|
58 | - bottom text is in <div id="additional_infoLEFT"> |
---|
59 | => if tag "<!--right-left-->" is present |
---|
60 | text on right is moved to the to the '#additional_infoBOTTOM' div and |
---|
61 | removed from the '#additional_infoLEFT' div |
---|
62 | |
---|
63 | if the plugin "ExtendedDescription" is not installed, all the text is in |
---|
64 | the <div id="additional_infoLEFT"> |
---|
65 | => if tag "<!--up-down-->" is present |
---|
66 | text on right is moved to the to the '#additional_infoTOP' div and |
---|
67 | removed from the '#additional_infoLEFT' div |
---|
68 | => if tag "<!--right-left-->" is present on the '#additional_infoLEFT' div |
---|
69 | text on right is moved to the to the '#additional_infoBOTTOM' div and |
---|
70 | removed from the '#additional_infoLEFT' div |
---|
71 | */ |
---|
72 | |
---|
73 | // <!--up-down--> tag |
---|
74 | txt = $("#additional_infoLEFT").prop("innerHTML"); |
---|
75 | if(txt==null) { txt=""; } |
---|
76 | tmp = txt.indexOf("<!--up-down-->"); |
---|
77 | |
---|
78 | if(tmp>-1) |
---|
79 | { // tag is not managed by the ExtendedDescription plugin |
---|
80 | $("#additional_infoTOP").prop("innerHTML", txt.slice(0,tmp)); |
---|
81 | txt=txt.substr(tmp+14); //remove the tag |
---|
82 | } |
---|
83 | else |
---|
84 | { // perhaps tag is managed by the ExtendedDescription plugin |
---|
85 | $(".additional_info").each( function (i) |
---|
86 | { |
---|
87 | if(this.id=="") |
---|
88 | { |
---|
89 | $("#additional_infoTOP").prop("innerHTML", $("#additional_infoTOP").prop("innerHTML")+this.innerHTML); |
---|
90 | this.parentNode.removeChild(this); |
---|
91 | } |
---|
92 | } |
---|
93 | ); |
---|
94 | } |
---|
95 | |
---|
96 | // <!--right-left--> tag |
---|
97 | tmp = txt.indexOf("<!--right-left-->"); |
---|
98 | |
---|
99 | if(tmp>-1) |
---|
100 | { // tag is present, cut the right text to the |
---|
101 | $("#additional_infoBOTTOM").prop("innerHTML", txt.slice(0,tmp)); |
---|
102 | txt=txt.substr(tmp+17); |
---|
103 | } |
---|
104 | |
---|
105 | $("#additional_infoLEFT").prop("innerHTML", txt); |
---|
106 | |
---|
107 | if((txt.replace(/\s*/im, "")=="")&&($("#additional_infoID").length>0)) |
---|
108 | { |
---|
109 | // remove the left area if empty |
---|
110 | $("#additional_infoID").get(0).parentNode.removeChild($("#additional_infoID").get(0)); |
---|
111 | } |
---|
112 | $(".additional_info").css("visibility", "visible"); |
---|
113 | |
---|
114 | tmpInfo=$("#additional_infoBOTTOM").prop("innerHTML"); |
---|
115 | if(tmpInfo==null) tmpInfo=''; |
---|
116 | |
---|
117 | if(tmpInfo.replace(/\s*/im, "")=="") |
---|
118 | { |
---|
119 | // remove the bottom area if empty |
---|
120 | $("#additional_infoBOTTOM").get(0).parentNode.removeChild($("#additional_infoBOTTOM").get(0)); |
---|
121 | } |
---|
122 | else |
---|
123 | { |
---|
124 | $("#additional_infoBOTTOM").css("visibility", "visible"); |
---|
125 | } |
---|
126 | |
---|
127 | tmpInfo=$("#additional_infoTOP").prop("innerHTML"); |
---|
128 | if(tmpInfo==null) tmpInfo=''; |
---|
129 | if(tmpInfo.replace(/\s*/im, "")=="") |
---|
130 | { |
---|
131 | // remove the top area if empty |
---|
132 | $("#additional_infoTOP").get(0).parentNode.removeChild($("#additional_infoTOP").get(0)); |
---|
133 | } |
---|
134 | else |
---|
135 | { |
---|
136 | $("#additional_infoTOP").css("visibility", "visible"); |
---|
137 | } |
---|
138 | |
---|
139 | $("#icon_derivatives").click(function() |
---|
140 | { |
---|
141 | var elt = $("#derivativeSwitchBox"); |
---|
142 | elt.css("left", 0); |
---|
143 | |
---|
144 | $("#sortOrderBox").hide(); |
---|
145 | elt.css("left", Math.min( $(this).position().left + $('#tabRandomButtons').outerWidth(true) - 5, $('#the_page').width() - elt.outerWidth(true) - 5)) |
---|
146 | .css("top", $(this).position().top) |
---|
147 | .toggle(); |
---|
148 | $('#iSimpleTip').css('display', 'none'); // if tip activated, hide it.. |
---|
149 | } |
---|
150 | ); |
---|
151 | $("#derivativeSwitchBox").on("mouseleave click", function() |
---|
152 | { |
---|
153 | $(this).hide(); |
---|
154 | } |
---|
155 | ); |
---|
156 | |
---|
157 | $("#icon_sort").click(function() |
---|
158 | { |
---|
159 | var elt = $("#sortOrderBox"); |
---|
160 | elt.css("left", 0); |
---|
161 | |
---|
162 | $("#derivativeSwitchBox").hide(); |
---|
163 | elt.css("left", Math.min( $(this).position().left + $('#tabRandomButtons').outerWidth(true) - 5, $('#the_page').width() - elt.outerWidth(true) - 5)) |
---|
164 | .css("top", $(this).position().top) |
---|
165 | .toggle(); |
---|
166 | $('#iSimpleTip').css('display', 'none'); // if tip activated, hide it.. |
---|
167 | } |
---|
168 | ); |
---|
169 | $("#sortOrderBox").on("mouseleave click", function() |
---|
170 | { |
---|
171 | $(this).hide(); |
---|
172 | } |
---|
173 | ); |
---|
174 | |
---|
175 | liWidth=$('ul.thumbnails li').outerWidth(); |
---|
176 | thumbListWidth=$('#thumbnails').width(); |
---|
177 | $('div ul.thumbnails').css('padding-left', (thumbListWidth-liWidth*Math.floor(thumbListWidth/liWidth))/2-1); |
---|
178 | }, |
---|
179 | |
---|
180 | initMenu = function () |
---|
181 | { |
---|
182 | if(options.menuAnimated != "noswitch") |
---|
183 | { |
---|
184 | $("#menubar").css( |
---|
185 | { |
---|
186 | visibility:"hidden", |
---|
187 | top: $("#titrePageID").prop("offsetTop")+$("#titrePageID").prop("offsetHeight")-2+'px' |
---|
188 | } |
---|
189 | ); |
---|
190 | switchmenu('n'); |
---|
191 | switch(options.menuWidth) |
---|
192 | { |
---|
193 | case "auto": |
---|
194 | $("#menubar").css("width", "auto"); |
---|
195 | maxwidth=options.menuMaxWidth; |
---|
196 | |
---|
197 | regexp = /[1234567]\./i; |
---|
198 | if(jQuery.browser.msie && jQuery.browser.version.match(regexp)) |
---|
199 | { |
---|
200 | maxwidth=options.menuMSIEMaxWidth; |
---|
201 | } |
---|
202 | if(maxwidth>0) { $("#menubar").css("max-width", maxwidth+"px"); } |
---|
203 | break; |
---|
204 | case "info": |
---|
205 | $("#menubar").css("width", $(".additionnal_info").css("width")); |
---|
206 | break; |
---|
207 | default: |
---|
208 | $("#menubar").css("width", options.menuWidth+"px"); |
---|
209 | } |
---|
210 | } |
---|
211 | else |
---|
212 | { |
---|
213 | $("#menubar dl dd").each( |
---|
214 | function (index, elem) |
---|
215 | { |
---|
216 | //alert($(this.parentNode).prop('offsetWidth')+"---"+$(this.parentNode).prop('id')); |
---|
217 | $(this).css("min-width", $(this.parentNode).prop('offsetWidth')); |
---|
218 | if(jQuery.browser.msie) |
---|
219 | { |
---|
220 | $(this).css("max-width", options.menuMSIEMaxWidth+"px"); |
---|
221 | } |
---|
222 | } |
---|
223 | ); |
---|
224 | } |
---|
225 | }, |
---|
226 | |
---|
227 | switchmenu = function(force, iconpath) |
---|
228 | { |
---|
229 | if(force=='') |
---|
230 | { |
---|
231 | (!menuState)?force='y':force='n'; |
---|
232 | } |
---|
233 | |
---|
234 | if(options.menuAnimated == "fade") |
---|
235 | { |
---|
236 | switch(force) |
---|
237 | { |
---|
238 | case 'y': |
---|
239 | $("#menubar").css({ |
---|
240 | visibility:"visible", |
---|
241 | height:"auto" |
---|
242 | }).fadeTo(options.animateDelay,1); |
---|
243 | $("#icon_menu").toggleClass("button button2"); |
---|
244 | menuState=true; |
---|
245 | break; |
---|
246 | default: |
---|
247 | $("#menubar").fadeTo(options.animateDelay, 0, function () { |
---|
248 | $("#menubar").css({ |
---|
249 | visibility:"hidden", |
---|
250 | height:"0px" |
---|
251 | }); |
---|
252 | }); |
---|
253 | $("#icon_menu").toggleClass("button button2"); |
---|
254 | menuState=false; |
---|
255 | } |
---|
256 | } |
---|
257 | else |
---|
258 | { |
---|
259 | switch(force) |
---|
260 | { |
---|
261 | case 'y': |
---|
262 | $("#menubar").css({ |
---|
263 | visibility:"visible", |
---|
264 | height:"auto" |
---|
265 | }); |
---|
266 | $("#icon_menu").toggleClass("button button2"); |
---|
267 | menuState=true; |
---|
268 | break; |
---|
269 | default: |
---|
270 | $("#menubar").css({ |
---|
271 | visibility:"hidden", |
---|
272 | height:"0px" |
---|
273 | }); |
---|
274 | $("#icon_menu").toggleClass("button button2"); |
---|
275 | menuState=false; |
---|
276 | } |
---|
277 | } |
---|
278 | }; |
---|
279 | |
---|
280 | this.switchmenu = function(force, iconpath) { switchmenu(force, iconpath); }; |
---|
281 | |
---|
282 | initMenu(); |
---|
283 | initContentDesc(); |
---|
284 | } |
---|
285 | |
---|
286 | |
---|