Ignore:
Timestamp:
Jun 9, 2011, 3:52:13 PM (13 years ago)
Author:
cljosse
Message:

[extensions] set_plugins Storing the state of the fields

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/set_plugins/js/field_set.js

    r11249 r11276  
     1jQuery("fieldset").hide();
     2jQuery(document).ready(function () {
     3  jQuery(window).unload(function () {
     4    // jQuery("#form_set_plugins").submit();
     5  });
     6
     7  if (typeof plus_path == "undefined") {
     8    var plus_path = './plugins/set_plugins/js/icon/plus.png';
     9    var minus_path = './plugins/set_plugins/js/icon/minus.png';
     10  }
     11  var h_min = 0;
     12
     13  jQuery(window).load(function () {
     14    if (jQuery("fieldset").length >= 1) {
     15
     16      jQuery("div.titrePage h2").parent().hide();
     17
     18      var reg = new RegExp("[,]", "g");
     19      liste_visible = jQuery("input[name=list_visible]").val();
     20      n1 = liste_visible;
     21      liste = n1.split(reg);
     22      reg = new RegExp("['off']", "g");
     23      jQuery("fieldset").each(
     24        function (i) {
     25
     26          id0 = jQuery(this).attr("id");
     27          if (id0 == "") jQuery(this).attr("id", "fieldset_" + i);
     28          jQuery(this).attr("rel", i);
     29
     30          if (!jQuery(this).hasClass("field_set"))
     31            jQuery(this).addClass("field_set");
    132
    233
     34          if (liste[i] == "off") {
     35            liste[i] = "off";
    336
    4 jQuery(document).ready(function () {
    5   if (jQuery("fieldset").length >= 1) {
    6     jQuery("div .titrePage h2").remove();
     37           h_min = jQuery("#" + this.id + ' legend').height();
     38            jQuery(this).height(h_min + 5);
    739
    8     jQuery("fieldset").each(
    9               function (i) {
    10                 id0 = jQuery(this).attr("id");
    11                 if (id0 == "") jQuery(this).attr("id", "fieldset_" + i);
    12                 if (!jQuery(this).hasClass("field_set"))
    13                   jQuery(this).addClass("field_set");
    14                 if (i > 0)
    15                   jQuery(this).height(0);
    16                 else
    17                   jQuery(this).addClass("visible");
    18                 jQuery("#" + this.id + ' legend').css('cursor', 'pointer');
    19                 id0 = jQuery(this).attr("id");
     40            jQuery("#" + this.id + ' legend').prepend(
     41          '<img alt = "" title = ""' +
     42          'src = "' + plus_path + '"' + '>&nbsp;'
     43        );
     44          } else {
     45            liste[i] = "on";
     46            jQuery(this).addClass("visible");
     47            jQuery("#" + this.id + ' legend').prepend(
     48          '<img alt = "" title = ""' +
     49          'src = "' + minus_path + '"' + '>&nbsp;'
     50        );
     51          }
    2052
    21                 jQuery("#" + this.id + ' legend').click(function (event) {
    22                   n = jQuery(this).parent().hasClass("visible");
    23 
    24                   if (n) {
    25                     jQuery(this).parent().height(0);
    26                     jQuery(this).parent().removeClass("visible");
    27                   }
    28                   else {
    29                     jQuery(this).parent().css("height", "auto");
    30                     jQuery(this).parent().addClass("visible");
    31                   }
    32                 });
    33               })
    34 
    35   }
     53          jQuery("#" + this.id + ' legend').css('cursor', 'pointer');
    3654
    3755
     56          id0 = jQuery(this).attr("id");
     57          jQuery("#" + id0 + ' legend').click(function (event) {
    3858
    39   jQuery(document).ready(function () {
    40     if (jQuery(".field_set").length >= 1)
    41       jQuery(".field_set").each(
    42                 function (i) {
     59            n = jQuery(this).parent().hasClass("visible");
     60            jQuery(this).css("color", "red");
    4361
    44                   id0 = jQuery(this).attr("id");
     62            i = jQuery(jQuery(this).parent()).attr("rel");
     63            liste_visible = jQuery("input[name=list_visible]").val();
     64            liste = liste_visible.split(",");
     65            if (n) {
     66              jQuery(this).parent().height(h_min + 5);
     67              jQuery(this).parent().removeClass("visible");
     68              liste[i] = "off";
     69            }
     70            else {
     71              jQuery(this).parent().css("height", "auto");
     72              jQuery(this).parent().addClass("visible");
     73              liste[i] = "on";
     74            }
    4575
    4676
     77            val = liste.join(",");
     78            jQuery("input[name=list_visible]").val(val);
    4779
    48                 });
     80            jQuery.ajax({
     81              type: "POST",
     82              async: true,
     83              data: "list_visible=" + val,
     84              success: function (msg) {
     85                jQuery("#form_set_plugins").submit();
     86              }
     87            });
    4988
    50   });
     89          }); // click
    5190
    5291
     92        }); //each
     93      var liste_action = { active: "", deactive: "" };
     94
     95      jQuery(".pluginBox a").each(
     96        function (i) {
     97          jQuery(this).click(function (event) {
     98            jQuery(this).css("color", "red");
     99            action = jQuery(this).attr('rel');
     100            if (action == "Deactivate")
     101              liste_plugins = jQuery(this).parent().parent().text();
     102            else if (action == "Activate")
     103              liste_plugins = jQuery(this).parent().parent().text();
     104
     105          }); // click
     106
     107        }); //each
     108
     109      jQuery("input[name=list_visible]").val(liste.join(","));
     110      jQuery("fieldset").show();
     111    } // fielset
     112    //====================================================================
     113    jQuery("td a").click(function (event) {
     114      l1 = jQuery('#liste').text();
     115      l = l1.split(new RegExp("\n", "g"));
     116
     117      list = jQuery('liste_plugins');
     118
     119      var reg = new RegExp("[?]", "g");
     120      ret_args = new Array;
     121      var args = event.target.href.split(reg)[1];
     122      reg = new RegExp("[&]", "g");
     123      var tableau = args.split(reg);
     124      for (i = 0; i < tableau.length; i++) {
     125        vals = tableau[i].split("=");
     126        ret_args[vals[0]] = vals[1];
     127      }
     128      if (ret_args['action'] == "deactivate") {
     129
     130        list = jQuery('list');
     131        n = 1;
     132      } else if (ret_args['action'] == "activate") {
     133
     134        list = jQuery('liste_plugins');
     135        n = 0;
     136      }
    53137
    54138
     139    })
    55140
    56 
    57   jQuery("td a").click(function (event) {
    58     l1 = jQuery('td[name="plugins_name"]');
    59 
    60     var reg = new RegExp("[&]", "g");
    61     var tableau = event.target.href.split(reg);
    62 
    63 
    64     if (event.target.nameProp.match(RegExp("deactivate", "g"))) {
    65       n = 1;
    66     } else if (event.target.nameProp.match(RegExp("activate", "g"))) {
    67       n = 0;
    68     }
    69 
    70 
    71 
    72   })
    73 })
    74 
    75              
     141  }); // load
     142});                     //ready           
    76143           
Note: See TracChangeset for help on using the changeset viewer.