source: extensions/edit_gmaps/admin/js/fieldset.js @ 17761

Last change on this file since 17761 was 17761, checked in by cljosse, 12 years ago

[extensions] edit_gmaps compatibility 2.4

File size: 5.3 KB
Line 
1if (typeof ef_animate_fast == "undefined")
2  var ef_animate_fast = true;
3var no_affiche;
4
5// Smart Fieldsets initialization/
6if (typeof ef_plus_bullet_path == "undefined") {
7  var ef_plus_bullet_path = './plugins/edit_gmaps/admin/icon/plus.png';
8  var ef_minus_bullet_path = './plugins/edit_gmaps/admin/icon/minus.png';
9}
10
11if (typeof ef_separator == "undefined")
12  var ef_separator = ' : ';
13
14function ef_reduce(fieldset_id, fast) {
15 jQuery('#' + fieldset_id).hide();
16  return;
17  l_m = jQuery('#' + fieldset_id + ' legend');
18
19  if (ef_reduce.arguments.length < 2) fast = ef_animate_fast;
20  if (!l_m.is('.ef_command')) l_m.addClass('ef_command');
21  if (!jQuery('#' + fieldset_id).is(':hidden')) 
22    l_m.trigger('ef_reduce_private', fast.fast,this);
23  l_m.removeClass('ef_command');
24  l_m.hide();
25}
26
27function ef_maximize(fieldset_id, fast) {
28  l_r = jQuery('#' + fieldset_id + '_reduced_legend');
29  if (ef_maximize.arguments.length < 2) fast = ef_animate_fast;
30  if (!l_r.is('.ef_command')) l_r.addClass('ef_command');
31  if (jQuery('#' + fieldset_id).is(':hidden'))
32    l_r.trigger('ef_maximize_private', fast);
33  l_r.removeClass('ef_command');
34   
35}
36
37var l_m, l_r;
38function ef_init(fieldset_id, cache_id) {
39  jQuery(document).ready(function () {
40   
41    var f_m = jQuery('#' + fieldset_id);
42    l_m = jQuery('#' + fieldset_id + ' legend');
43    var l_txt = l_m.text();
44    var f_r = f_m;
45    l_r = l_m;
46
47    if (ef_minus_bullet_path != '') l_m.prepend(
48          '<img alt = "" title = ""' +
49          'src = "' + ef_minus_bullet_path + '"' + '>&nbsp;'
50        );
51    l_m.addClass('ef_legends');
52    l_m.addClass('ef_click_ok');
53
54
55    f_r = jQuery('#' + fieldset_id + " ").clone();
56    l_r = jQuery('#' + fieldset_id + " LEGEND").clone();
57    f_r.empty();
58    l_r.appendTo(f_r);
59
60    f_r.attr('id', fieldset_id + '_reduced');
61    f_r.insertAfter(f_m);
62    f_r.css({ display: 'none' });
63
64
65    l_r.attr('id', fieldset_id + '_reduced_legend');
66    l_r.addClass('ef_legends');
67    l_r.addClass('ef_click_ok');
68
69
70
71    l_r.css({
72      outlineColor: "invert",
73      opacity: 0
74    });
75
76    if (ef_plus_bullet_path == '')
77      l_r.append(
78          '<span style = "padding-left:' + l_m.css('padding-left') + ';">' +
79          l_txt + '</' + 'span>' + ef_separator
80         );
81    else {
82
83      lg = jQuery(l_r).find("img");
84      if (lg.length > 0)
85        lg.get(0).src = ef_plus_bullet_path;
86
87      l_r.append('&nbsp;' + ef_separator);
88    }
89
90    f_r.append('<span id="' + cache_id + '" > </span>');
91    jQuery('.ef_legends').css('cursor', 'pointer');
92
93    l_m.bind('ef_reduce_private', function (event, fast) { // Reduce
94
95      if (l_m.is('.ef_command, .ef_click_ok')) {
96        if (fast) {
97          f_m.hide();
98          f_r.show();
99          f_r.find('*').css({ opacity: 1 });
100        }
101        else {
102          f_m.find('*').not('.ef_legends, img').animate(
103                                 { opacity: 0 }, 200,
104                                function () {
105                                  f_m.slideUp(400);
106                                  f_r.slideDown(400, function () {
107                                    f_r.find('*').css({ opacity: 1 });
108                                  });
109                                }
110                            );
111        }
112      }
113    });
114
115    l_r.bind('ef_maximize_private', function (event, fast) { // Maximize
116      if (l_r.is('.ef_command, .ef_click_ok')) {
117        if (fast) {
118          f_r.hide();
119          f_m.show();
120        } else {
121          f_r.find('*').css({ opacity: 0 });
122          f_r.slideUp(400);
123          f_m.slideDown(400, function () {
124            f_m.find('*').not('.ef_legends, img').animate({ opacity: 1 }, 200);
125          });
126        }
127      }
128    });
129
130    l_m.click(function () { // Reduce
131      l_m.trigger('ef_reduce_private', ef_animate_fast);
132    });
133
134    l_r.click(function () { // Maximize
135      l_r.trigger('ef_maximize_private', ef_animate_fast);
136    });
137    if (no_affiche != "true") {
138      ef_reduce("geoposition", { fast: true })
139      // jQuery("#Envoie").trigger("submit");
140    } else {
141      ef_reduce("Elements", { fast: true })
142    }
143  });
144}
145
146
147jQuery(document).ready(function () {
148  if (jQuery(".fieldset").length >= 1)
149    jQuery(".fieldset").each(
150                function (i) {
151                  id0 = jQuery(this).attr("id");
152                  if (id0 == "") jQuery(this).attr("id", "Cadre_" + i);
153                  id0 = jQuery(this).attr("id");
154                  // Update of the '#cache' value when changing the selected value in the fieldset
155                  jQuery("#" + id0 + ' .inputs').click(function () {
156                    jQuery("#" + id0).text(jQuery("#" + id0 + ' .inputs:checked').next().text());
157                  });
158                });
159  // Some changes of the defaults, nothing to see with Smart Fieldsets
160  //   jQuery('input').attr('checked', 'true');
161  jQuery('code').css('font-size', 'larger');
162  jQuery('#ef_presentation label, #ef_presentation input').css('cursor', 'pointer');
163});
164
165
166
167jQuery(document).ready(function () { 
168
169  if (jQuery(".fieldset").length >= 1) {
170    jQuery(".fieldset").each(
171              function (i) {
172                id0 = jQuery(this).attr("id");
173                ef_init(id0, 'cache' + i);
174
175              })
176
177  }
178
179})
180
181             
182           
Note: See TracBrowser for help on using the repository browser.