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

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

[extensions] set_plugins update

File size: 4.9 KB
Line 
1function raffraichir() {
2  n = 1;
3 // jQuery("#form_set_plugins").submit();
4}
5
6
7
8jQuery("fieldset").hide();
9jQuery(document).ready(function () {
10  jQuery(window).unload(function () {
11    // jQuery("#form_set_plugins").submit();
12  });
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 = {};
20  jQuery(window).load(function () {
21    if (jQuery(".titrePage").length >= 1) {
22      if (jQuery("span.sort").length >= 1)
23        jQuery("#titrePage").before(jQuery("span.sort"));
24      jQuery(".titrePage ").hide();
25    }
26
27    if (jQuery("fieldset").length >= 1) {
28      var reg = new RegExp("[,]", "g");
29      liste_visible = jQuery("input[name=list_visible]").val();
30      if (typeof liste_visible == "undefined") {
31        liste_visible = "on,on,on,on";
32        jQuery("input[name=list_visible]").val(liste_visible);
33      }
34      liste = liste_visible.split(reg);
35      reg = new RegExp("['off']", "g");
36      jQuery("fieldset").each(
37        function (i) {
38
39          id0 = jQuery(this).attr("id");
40          if (id0 == "") jQuery(this).attr("id", "fieldset_" + i);
41          jQuery(this).attr("rel", i);
42
43          if (!jQuery(this).hasClass("field_set"))
44            jQuery(this).addClass("field_set");
45
46
47          if (liste[i] == "off") {
48            liste[i] = "off";
49
50            h_min = jQuery("#" + this.id + ' legend').height();
51            jQuery(this).height(h_min + 0);
52
53            jQuery("#" + this.id + ' legend').prepend(
54          '<img alt = "" title = ""' +
55          'src = "' + plus_path + '"' + '>&nbsp;'
56        );
57          } else {
58            liste[i] = "on";
59            jQuery(this).addClass("visible");
60            jQuery("#" + this.id + ' legend').prepend(
61          '<img alt = "" title = ""' +
62          'src = "' + minus_path + '"' + '>&nbsp;'
63        );
64          }
65
66          jQuery("#" + this.id + ' legend').css('cursor', 'pointer');
67
68
69          id0 = jQuery(this).attr("id");
70          jQuery("#" + id0 + ' legend').click(function (event) {
71
72            n = jQuery(this).parent().hasClass("visible");
73            //   jQuery(this).css("color", "red");
74
75            i = jQuery(jQuery(this).parent()).attr("rel");
76            liste_visible = jQuery("input[name=list_visible]").val();
77            if (typeof liste_visible == "undefined") {
78              liste_visible = "on,on,on,on";
79              jQuery("input[name=list_visible]").val(liste_visible);
80            }
81            // src = jQuery(this).find("img").attr("src");
82            if (n) {
83              jQuery(this).parent().height(h_min + 0);
84              jQuery(this).parent().removeClass("visible");
85              liste[i] = "off";
86              jQuery(this).find("img").attr({
87                src: plus_path
88
89              });
90            }
91            else {
92              jQuery(this).parent().css("height", "auto");
93              jQuery(this).parent().addClass("visible");
94              liste[i] = "on";
95              jQuery(this).find("img").attr({
96                src: minus_path
97
98              });
99            }
100            val = liste.join(",");
101            jQuery("input[name=list_visible]").val(val);
102            jQuery('#set').val("true");
103
104            jQuery.ajax({
105              type: "POST",
106              async: true,
107              data: { list_visible: val, set: "true" },
108              success: function (msg) {
109                // jQuery("#form_set_plugins").submit();
110              }
111            });
112
113          }); // click
114
115
116        }); //each
117      var liste_action = { active: "", deactive: "" };
118
119      jQuery(".pluginBox a").each(
120        function (i) {
121          jQuery(this).click(function (event) {
122            jQuery(this).css("color", "red");
123            jQuery('#set').val("true");
124          }); // click
125
126        }); //each
127      jQuery("input[name=list_visible]").val(liste.join(","));
128      jQuery("fieldset").show();
129    } // fielset
130    //====================================================================
131    jQuery(".pluginBox a").click(function (event) {
132      var link = event.target.href;
133      if (link.indexOf("?") != -1) {
134        var query = link.split("?")[1];
135        eval("query = {" + query.replace(/&/ig, "\",").replace(/=/ig, ":\"") + "\"};");
136        jQuery('#add_plugins').val(query.plugin);
137        jQuery('#set').val("true");
138        val = liste.join(",");
139
140        jQuery.ajax({
141          type: "POST",
142          async: true,
143          data: { add_plugins: query.plugin,
144           set: "true",
145           list_visible: val
146            }
147           ,
148          success: function (data) {
149          //  jQuery("#form_set_plugins").submit();
150
151          }
152        });
153
154      }
155
156    })
157
158  }); // load
159});                                                               //ready           
160           
Note: See TracBrowser for help on using the repository browser.