source: extensions/set_plugins/js/field_set.js @ 12058

Last change on this file since 12058 was 12058, checked in by cljosse, 13 years ago

[extensions] set_plugins compatibility width piwigo 2.3

File size: 6.7 KB
Line 
1function raffraichir() {
2  n = 1;
3 // jQuery("#form_set_plugins").submit();
4}
5
6//===============================================================================
7function send_val(datas) {
8  jQuery.ajax({
9    method: 'GET',
10    // url: get_post,
11    data: datas,
12    async: true,
13    dataType: 'json',
14    success: function (data) {
15      if (jQuery("#progressbar").length > 0) {
16
17      } else
18        jQuery("#titrePage").before(
19                '<img id="progressbar" alt = "" width="300px" title = ""' +
20                'src = "./plugins/set_plugins/js/icon/ajax-loader-bar.gif"' + '>'
21              );
22      //    location.reload();
23      if (!data) return;
24
25      if (data['liste_plugins'] != undefined)
26        liste_des_plugins_activés = data['liste_plugins'];
27      if (data['config']['liste_visible'])
28        jQuery("#liste_visible").val(data['config']['liste_visible']);
29
30    }
31  });
32} //send val
33//===================================================================================
34
35jQuery().ready(function () {
36  jQuery('.cluetip').tipTip({  maxWidth:'600px' ,'delay': 0, 'fadeIn': 200, 'fadeOut': 200 }); 
37 
38});  var post = {};
39jQuery("fieldset").hide();
40jQuery(document).ready(function () {
41  jQuery(window).unload(function () {
42
43  });
44  if (typeof plus_path == "undefined") {
45    var plus_path = './plugins/set_plugins/js/icon/plus.png';
46    var minus_path = './plugins/set_plugins/js/icon/minus.png';
47  }
48  var h_min = 0;
49  var liste_des_plugins_activés = new Array();
50
51  jQuery(window).load(function (event) {
52    n = post;
53    var link = event.target.location.href;
54    if (link.indexOf("?") != -1) {
55      link = link.replace(/\"/ig, "");
56      var query = link.split("?")[1];
57      eval("query = {" + query.replace(/&/ig, "\",").replace(/=/ig, ":\"") + "\"};");
58    }
59
60    if (query.plugin)
61      jQuery('#add_plugins').val(query.plugin);
62
63    if (jQuery(".titrePage").length >= 1) {
64      if (jQuery("span.sort").length >= 1)
65        jQuery("#titrePage").before(jQuery("span.sort"));
66      jQuery(".titrePage ").hide();
67    }
68
69    if (jQuery("fieldset").length >= 1) {
70      var reg = new RegExp("[,]", "g");
71      liste_visible = jQuery("input[name=list_visible]").val();
72      if (typeof liste_visible == "undefined") {
73        liste_visible = "on,on,on,on";
74        jQuery("input[name=list_visible]").val(liste_visible);
75      }
76      liste_visible = liste_visible.split(reg);
77      reg = new RegExp("['off']", "g");
78      h_min = jQuery("fieldset legend").height();
79      h_min = 0;
80      jQuery("fieldset").each(function (i) {
81          id0 = jQuery(this).attr("id");
82          if (id0 == "" or id0=="undefined" ) jQuery(this).attr("id", "fieldset_" + i);
83          jQuery(this).attr("rel", i);
84
85          if (!jQuery(this).hasClass("field_set"))
86            jQuery(this).addClass("field_set");
87        if (liste_visible[i] == "off") {
88          liste_visible[i] = "off";
89            jQuery(this).height(h_min + 0);
90
91            jQuery("#" + this.id + ' legend').prepend(
92            '<img alt = "" title = ""' + 'src = "' + plus_path + '"' + '>&nbsp;'
93        );
94          } else {
95          liste_visible[i] = "on";
96            jQuery(this).addClass("visible");
97            jQuery("#" + this.id + ' legend').prepend(
98          '<img alt = "" title = ""' +
99          'src = "' + minus_path + '"' + '>&nbsp;'
100        );
101          }
102
103          jQuery("#" + this.id + ' legend').css('cursor', 'pointer');
104        id0 = jQuery(this).attr("id");
105
106
107          jQuery("#" + id0 + ' legend').click(function (event) {
108
109            n = jQuery(this).parent().hasClass("visible");
110          i = jQuery(jQuery(this).parent()).attr("rel");
111
112            if (typeof liste_visible == "undefined") {
113              liste_visible = "on,on,on,on";
114              jQuery("input[name=list_visible]").val(liste_visible);
115            }
116          liste_visible = jQuery("input[name=list_visible]").val().split(",");
117            // src = jQuery(this).find("img").attr("src");
118            if (n) {
119              jQuery(this).parent().height(h_min + 0);
120              jQuery(this).parent().removeClass("visible");
121            liste_visible[i] = "off";
122              jQuery(this).find("img").attr({
123                src: plus_path
124
125              });
126          } else {
127              jQuery(this).parent().css("height", "auto");
128              jQuery(this).parent().addClass("visible");
129            liste_visible[i] = "on";
130              jQuery(this).find("img").attr({
131                src: minus_path
132
133              });
134            }
135          val = liste_visible.join(",");
136            jQuery("input[name=list_visible]").val(val);
137            jQuery('#set').val("true");
138          jQuery("#set").click();
139
140
141        }); // click
142        }); //each fieldset
143      //==========================================================
144
145      var liste_action = { active: "", deactive: "" };
146      jQuery("input[name=list_visible]").val(liste_visible.join(","));
147      jQuery("fieldset").show();
148    } // fielset
149    //====================================================================
150    jQuery(".plugin_list").each(function (i) {
151      liste_des_plugins_activés.push(jQuery(this).attr('id'));
152    });
153
154    //==============================================================
155    jQuery("input").each(
156        function (i) {
157          jQuery(this).click(function (event) {
158            jQuery(this).css("color", "red");
159            jQuery('#set').val("true");
160            jQuery("#titrePage").before(
161                '<img id="progressbar" alt = "" width="300px" title = ""' +
162                'src = "./plugins/set_plugins/js/icon/ajax-loader-bar.gif"' + '>'
163              );
164            send_val({liste_visible:liste_visible,
165              set: "true"
166
167            });
168
169          }); // click
170
171        }); //each
172
173    jQuery(".pluginBox a").click(function (event) {
174      var link = event.target.href;
175      if (link.indexOf("?") != -1) {
176        var query = link.split("?")[1];
177        eval("query = {" + query.replace(/&/ig, "\",").replace(/=/ig, ":\"") + "\"};");
178        jQuery('#add_plugins').val(query.plugin);
179        jQuery('#set').val("true");
180        n = query.pwg_token;
181        action = query.action;
182        val = liste_visible.join(",");
183        val2 = liste_des_plugins_activés.join(",");
184        send_val({ 
185          liste_des_plugins_activés: liste_des_plugins_activés,
186            add_plugins: query.plugin,
187            set: "true",
188            action: query.action
189        });
190
191
192        /* */
193
194      }
195
196    });
197  }); // load
198});                                                                                  //ready           
199           
Note: See TracBrowser for help on using the repository browser.