1 | /* ----------------------------------------------------------------------------- |
---|
2 | GALLY |
---|
3 | Template for Piwigo |
---|
4 | ------------------------------------------------------------------------------ |
---|
5 | file: gally/gallyjs-tcp.js |
---|
6 | file release: 1.1.0 |
---|
7 | ------------------------------------------------------------------------------ |
---|
8 | author: grum at grum.dnsalias.com |
---|
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 menuState; |
---|
19 | |
---|
20 | $("document").ready( function() |
---|
21 | { |
---|
22 | initMenu(); |
---|
23 | initContentDesc(); |
---|
24 | } |
---|
25 | ); |
---|
26 | |
---|
27 | |
---|
28 | function initContentDesc() |
---|
29 | { |
---|
30 | if(($("#additional_infoTOP").length + $("#additional_infoBOTTOM").length)<2) |
---|
31 | { |
---|
32 | // if div TOP & BOTTOM don't exists, it's not necessary to process this the |
---|
33 | // initialisation |
---|
34 | return(false); |
---|
35 | } |
---|
36 | /* |
---|
37 | this code permit to manage 3 informations panels with one text area (or 2 if |
---|
38 | extended description plugin is used) |
---|
39 | |
---|
40 | this function don't use a regExp object (due to some freeze with this method |
---|
41 | during test) |
---|
42 | |
---|
43 | known tags : |
---|
44 | <!--up-down--> |
---|
45 | <!--right-left--> |
---|
46 | |
---|
47 | if the plugin "ExtendedDescription" is installed, the "<!--up-down-->" tag is |
---|
48 | already managed by the plugin : |
---|
49 | - top text is in a <div class="additional_info"> |
---|
50 | => text is moved to the to the '#additional_infoTOP' div and |
---|
51 | the '.additional_info' div added by the plugin is deleted |
---|
52 | - bottom text is in <div id="additional_infoLEFT"> |
---|
53 | => if tag "<!--right-left-->" is present |
---|
54 | text on right is moved to the to the '#additional_infoBOTTOM' div and |
---|
55 | removed from the '#additional_infoLEFT' div |
---|
56 | |
---|
57 | if the plugin "ExtendedDescription" is not installed, all the text is in |
---|
58 | the <div id="additional_infoLEFT"> |
---|
59 | => if tag "<!--up-down-->" is present |
---|
60 | text on right is moved to the to the '#additional_infoTOP' div and |
---|
61 | removed from the '#additional_infoLEFT' div |
---|
62 | => if tag "<!--right-left-->" is present on the '#additional_infoLEFT' div |
---|
63 | text on right is moved to the to the '#additional_infoBOTTOM' div and |
---|
64 | removed from the '#additional_infoLEFT' div |
---|
65 | */ |
---|
66 | |
---|
67 | // <!--up-down--> tag |
---|
68 | txt = $("#additional_infoLEFT").attr("innerHTML"); |
---|
69 | if(txt==null) { txt=""; } |
---|
70 | tmp = txt.indexOf("<!--up-down-->"); |
---|
71 | |
---|
72 | if(tmp>-1) |
---|
73 | { // tag is not managed by the ExtendedDescription plugin |
---|
74 | $("#additional_infoTOP").attr("innerHTML", txt.slice(0,tmp)); |
---|
75 | txt=txt.substr(tmp+14); //remove the tag |
---|
76 | } |
---|
77 | else |
---|
78 | { // perhaps tag is managed by the ExtendedDescription plugin |
---|
79 | $(".additional_info").each( function (i) |
---|
80 | { |
---|
81 | if(this.id=="") |
---|
82 | { |
---|
83 | $("#additional_infoTOP").attr("innerHTML", $("#additional_infoTOP").attr("innerHTML")+this.innerHTML); |
---|
84 | this.parentNode.removeChild(this); |
---|
85 | } |
---|
86 | } |
---|
87 | ); |
---|
88 | } |
---|
89 | |
---|
90 | // <!--right-left--> tag |
---|
91 | tmp = txt.indexOf("<!--right-left-->"); |
---|
92 | |
---|
93 | if(tmp>-1) |
---|
94 | { // tag is present, cut the right text to the |
---|
95 | $("#additional_infoBOTTOM").attr("innerHTML", txt.slice(0,tmp)); |
---|
96 | txt=txt.substr(tmp+17); |
---|
97 | } |
---|
98 | |
---|
99 | $("#additional_infoLEFT").attr("innerHTML", txt); |
---|
100 | |
---|
101 | if((txt.replace(/\s*/im, "")=="")&&($("#additional_infoID").length>0)) |
---|
102 | { |
---|
103 | // remove the left area if empty |
---|
104 | $("#additional_infoID").get(0).parentNode.removeChild($("#additional_infoID").get(0)); |
---|
105 | } |
---|
106 | $(".additional_info").css("visibility", "visible"); |
---|
107 | |
---|
108 | if($("#additional_infoBOTTOM").attr("innerHTML").replace(/\s*/im, "")=="") |
---|
109 | { |
---|
110 | // remove the bottom area if empty |
---|
111 | $("#additional_infoBOTTOM").get(0).parentNode.removeChild($("#additional_infoBOTTOM").get(0)); |
---|
112 | } |
---|
113 | else |
---|
114 | { |
---|
115 | $("#additional_infoBOTTOM").css("visibility", "visible"); |
---|
116 | } |
---|
117 | |
---|
118 | if($("#additional_infoTOP").attr("innerHTML").replace(/\s*/im, "")=="") |
---|
119 | { |
---|
120 | // remove the top area if empty |
---|
121 | $("#additional_infoTOP").get(0).parentNode.removeChild($("#additional_infoTOP").get(0)); |
---|
122 | } |
---|
123 | else |
---|
124 | { |
---|
125 | $("#additional_infoTOP").css("visibility", "visible"); |
---|
126 | } |
---|
127 | } |
---|
128 | |
---|
129 | |
---|
130 | function initMenu() |
---|
131 | { |
---|
132 | if(options.menuAnimated != "noswitch") |
---|
133 | { |
---|
134 | $("#menubar").css( |
---|
135 | { |
---|
136 | visibility:"hidden", |
---|
137 | top: $("#titrePageID").attr("offsetTop")+$("#titrePageID").attr("offsetHeight")-2+'px' |
---|
138 | } |
---|
139 | ); |
---|
140 | switchmenu('n'); |
---|
141 | switch(options.menuWidth) |
---|
142 | { |
---|
143 | case "auto": |
---|
144 | $("#menubar").css("width", "auto"); |
---|
145 | maxwidth=options.menuMaxWidth; |
---|
146 | |
---|
147 | regexp = /[1234567]\./i; |
---|
148 | if(jQuery.browser.msie && jQuery.browser.version.match(regexp)) |
---|
149 | { |
---|
150 | maxwidth=options.menuMSIEMaxWidth; |
---|
151 | } |
---|
152 | if(maxwidth>0) { $("#menubar").css("max-width", maxwidth+"px"); } |
---|
153 | break; |
---|
154 | case "info": |
---|
155 | $("#menubar").css("width", $(".additionnal_info").css("width")); |
---|
156 | break; |
---|
157 | default: |
---|
158 | $("#menubar").css("width", options.menuWidth+"px"); |
---|
159 | } |
---|
160 | } |
---|
161 | else |
---|
162 | { |
---|
163 | $("#menubar dl dd").each( |
---|
164 | function (index, elem) |
---|
165 | { |
---|
166 | //alert($(this.parentNode).attr('offsetWidth')+"---"+$(this.parentNode).attr('id')); |
---|
167 | $(this).css("min-width", $(this.parentNode).attr('offsetWidth')); |
---|
168 | if(jQuery.browser.msie) |
---|
169 | { |
---|
170 | $(this).css("max-width", options.menuMSIEMaxWidth+"px"); |
---|
171 | } |
---|
172 | } |
---|
173 | ); |
---|
174 | } |
---|
175 | } |
---|
176 | |
---|
177 | |
---|
178 | function switchmenu(force, iconpath) |
---|
179 | { |
---|
180 | if(force=='') |
---|
181 | { |
---|
182 | (!menuState)?force='y':force='n'; |
---|
183 | } |
---|
184 | |
---|
185 | if(options.menuAnimated == "fade") |
---|
186 | { |
---|
187 | switch(force) |
---|
188 | { |
---|
189 | case 'y': |
---|
190 | $("#menubar").css({ |
---|
191 | visibility:"visible", |
---|
192 | height:"auto" |
---|
193 | }).fadeTo(options.animateDelay,1); |
---|
194 | $("#icon_menu").attr("className", "button2"); |
---|
195 | menuState=true; |
---|
196 | break; |
---|
197 | default: |
---|
198 | $("#menubar").fadeTo(options.animateDelay, 0, function () { |
---|
199 | $("#menubar").css({ |
---|
200 | visibility:"hidden", |
---|
201 | height:"0px" |
---|
202 | }); |
---|
203 | }); |
---|
204 | $("#icon_menu").attr("className", "button"); |
---|
205 | menuState=false; |
---|
206 | } |
---|
207 | } |
---|
208 | else |
---|
209 | { |
---|
210 | switch(force) |
---|
211 | { |
---|
212 | case 'y': |
---|
213 | $("#menubar").css({ |
---|
214 | visibility:"visible", |
---|
215 | height:"auto" |
---|
216 | }); |
---|
217 | $("#icon_menu").attr("className", "button2"); |
---|
218 | menuState=true; |
---|
219 | break; |
---|
220 | default: |
---|
221 | $("#menubar").css({ |
---|
222 | visibility:"hidden", |
---|
223 | height:"0px" |
---|
224 | }); |
---|
225 | $("#icon_menu").attr("className", "button"); |
---|
226 | menuState=false; |
---|
227 | } |
---|
228 | } |
---|
229 | } |
---|