source: extensions/gally/gally-default/js/gallyjs-tcp.js @ 8528

Last change on this file since 8528 was 8528, checked in by grum, 13 years ago

Release 1.4.0
Rewrite some JS
fix bug bug:1983

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