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

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

[extensions] set_plugins fix bugs

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