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

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

feature:2499 - compatibility with Piwigo 2.3

  • Property svn:executable set to *
File size: 7.1 KB
Line 
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
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    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
140  initMenu = function ()
141  {
142    if(options.menuAnimated != "noswitch")
143    {
144      $("#menubar").css(
145        {
146          visibility:"hidden",
147          top: $("#titrePageID").prop("offsetTop")+$("#titrePageID").prop("offsetHeight")-2+'px'
148        }
149      );
150      switchmenu('n');
151      switch(options.menuWidth)
152      {
153        case "auto":
154          $("#menubar").css("width", "auto");
155          maxwidth=options.menuMaxWidth;
156
157          regexp = /[1234567]\./i;
158          if(jQuery.browser.msie && jQuery.browser.version.match(regexp))
159          {
160            maxwidth=options.menuMSIEMaxWidth;
161          }
162          if(maxwidth>0) { $("#menubar").css("max-width", maxwidth+"px"); }
163          break;
164        case "info":
165          $("#menubar").css("width", $(".additionnal_info").css("width"));
166          break;
167        default:
168          $("#menubar").css("width", options.menuWidth+"px");
169      }
170    }
171    else
172    {
173      $("#menubar dl dd").each(
174        function (index, elem)
175        {
176          //alert($(this.parentNode).prop('offsetWidth')+"---"+$(this.parentNode).prop('id'));
177          $(this).css("min-width", $(this.parentNode).prop('offsetWidth'));
178          if(jQuery.browser.msie)
179          {
180            $(this).css("max-width", options.menuMSIEMaxWidth+"px");
181          }
182        }
183      );
184    }
185  },
186
187  switchmenu = function(force, iconpath)
188  {
189    if(force=='')
190    {
191      (!menuState)?force='y':force='n';
192    }
193
194    if(options.menuAnimated == "fade")
195    {
196      switch(force)
197      {
198        case 'y':
199          $("#menubar").css({
200            visibility:"visible",
201            height:"auto"
202          }).fadeTo(options.animateDelay,1);
203          $("#icon_menu").toggleClass("button button2");
204          menuState=true;
205          break;
206        default:
207          $("#menubar").fadeTo(options.animateDelay, 0, function () {
208            $("#menubar").css({
209              visibility:"hidden",
210              height:"0px"
211            });
212          });
213          $("#icon_menu").toggleClass("button button2");
214          menuState=false;
215      }
216    }
217    else
218    {
219      switch(force)
220      {
221        case 'y':
222          $("#menubar").css({
223            visibility:"visible",
224            height:"auto"
225          });
226          $("#icon_menu").toggleClass("button button2");
227          menuState=true;
228          break;
229        default:
230          $("#menubar").css({
231            visibility:"hidden",
232            height:"0px"
233          });
234          $("#icon_menu").toggleClass("button button2");
235          menuState=false;
236      }
237    }
238  };
239
240  this.switchmenu = function(force, iconpath) { switchmenu(force, iconpath); };
241
242  initMenu();
243  initContentDesc();
244}
245
246
Note: See TracBrowser for help on using the repository browser.