source: extensions/gally/piwigo-2.0/gallyjs-tcp.js @ 6299

Last change on this file since 6299 was 4489, checked in by grum, 14 years ago

[Template:Gally] feature 1096, feature 1097, feature 1098, feature 1099, feature 1313
And some other improvments...

  • Property svn:executable set to *
File size: 6.3 KB
Line 
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
18var menuState;
19
20$("document").ready( function()
21  {
22    initMenu();
23    initContentDesc();
24  }
25);
26
27
28function 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
130function 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        if(jQuery.browser.msie)
147        {
148          maxwidth=options.menuMSIEMaxWidth;
149        }
150        if(maxwidth>0) { $("#menubar").css("max-width", maxwidth+"px"); }
151        break;
152      case "info":
153        $("#menubar").css("width", $(".additionnal_info").css("width"));
154        break;
155      default:
156        $("#menubar").css("width", options.menuWidth+"px");
157    }
158  }
159  else
160  {
161    $("#menubar dl dd").each(
162      function (index, elem)
163      {
164        //alert($(this.parentNode).attr('offsetWidth')+"---"+$(this.parentNode).attr('id'));
165        $(this).css("min-width", $(this.parentNode).attr('offsetWidth'));
166        if(jQuery.browser.msie)
167        {
168          $(this).css("max-width", options.menuMSIEMaxWidth+"px");
169        }
170      }
171    );
172  }
173}
174
175
176function switchmenu(force, iconpath)
177{
178  if(force=='')
179  {
180    (!menuState)?force='y':force='n';
181  }
182
183  if(options.menuAnimated == "fade")
184  {
185    switch(force)
186    {
187      case 'y':
188        $("#menubar").css({
189          visibility:"visible",
190          height:"auto"
191        }).fadeTo(options.animateDelay,1);
192        $("#icon_menu").attr("className", "button2");
193        menuState=true;
194        break;
195      default:
196        $("#menubar").fadeTo(options.animateDelay, 0, function () {
197          $("#menubar").css({
198            visibility:"hidden",
199            height:"0px"
200          });
201        });
202        $("#icon_menu").attr("className", "button");
203        menuState=false;
204    }
205  }
206  else
207  {
208    switch(force)
209    {
210      case 'y':
211        $("#menubar").css({
212          visibility:"visible",
213          height:"auto"
214        });
215        $("#icon_menu").attr("className", "button2");
216        menuState=true;
217        break;
218      default:
219        $("#menubar").css({
220          visibility:"hidden",
221          height:"0px"
222        });
223        $("#icon_menu").attr("className", "button");
224        menuState=false;
225    }
226  }
227}
Note: See TracBrowser for help on using the repository browser.