PluginProbe
Contact Forms by Cimatti / 1.9.2
Contact Forms by Cimatti v1.9.2
2.3.6 2.3.5 2.3.0 2.2.32 2.2.4 2.2.0 2.1.2 2.1.1 trunk 1.0 1.1 1.2 1.2.1 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 All 62 releases
← All changes | form-fields.js +299 -299 1.3.81.9.2 View file →
@@ -1,299 +1,299 @@
1 -var accuaWidgets = {};
2 -(function($) {
3 -
4 -accuaWidgets = {
5 -
6 - init : function() {
7 - var rem, sidebars = $('div.widgets-sortables'), isRTL = !! ( 'undefined' != typeof isRtl && isRtl ),
8 - margin = ( isRtl ? 'marginRight' : 'marginLeft' ), the_id;
9 -
10 - //Evento per widget-action (aggiunto in modalità "live")
11 - // $('a.widget-action').live('click', function(){
12 - $(document).on('click', 'a.widget-action', function(){
13 - var css = {}, widget = $(this).closest('div.widget'), inside = widget.children('.widget-inside'), w = parseInt( widget.find('input.widget-width').val(), 10 );
14 -
15 - if ( inside.is(':hidden') ) {
16 - if ( w > 250 && inside.closest('div.widgets-sortables').length ) {
17 - css['width'] = w + 30 + 'px';
18 - if ( inside.closest('div.widget-liquid-right').length )
19 - css[margin] = 235 - w + 'px';
20 - widget.css(css);
21 - }
22 - accuaWidgets.fixLabels(widget);
23 - inside.slideDown('fast');
24 - } else {
25 - inside.slideUp('fast', function() {
26 - widget.css({'width':'', margin:''});
27 - });
28 - }
29 - return false;
30 - });
31 -
32 - //Click sul bottone di salvataggio
33 - // $('input.widget-control-save').live('click', function(){
34 - $(document).on('click', 'input.widget-control-save', function(){
35 - accuaWidgets.save( $(this).closest('div.widget'), 0, 1, 0 );
36 - return false;
37 - });
38 -
39 - //Click sul bottone di rimozione
40 - //$('a.widget-control-remove').live('click', function(){
41 - $(document).on('click', 'a.widget-control-remove', function(){
42 - accuaWidgets.save( $(this).closest('div.widget'), 1, 1, 0 );
43 - return false;
44 - });
45 -
46 - //Click sul bottone di chiusura
47 - //$('a.widget-control-close').live('click', function(){
48 - $(document).on('click', 'a.widget-control-close', function(){
49 - accuaWidgets.close( $(this).closest('div.widget') );
50 - return false;
51 - });
52 -
53 - //Impostazione titolo e apertura widget se c'è un errore
54 - sidebars.children('.widget').each(function() {
55 - accuaWidgets.appendTitle(this);
56 - if ( $('p.widget-error', this).length )
57 - $('a.widget-action', this).click();
58 - });
59 -
60 - //Trascinabilità dei widget nella lista
61 - $('#widget-list').children('.widget').draggable({
62 - connectToSortable: 'div.widgets-sortables',
63 - handle: '> .widget-top > .widget-title',
64 - distance: 2,
65 - helper: 'clone',
66 - zIndex: 5,
67 - containment: 'document',
68 - start: function(e,ui) {
69 - accuaWidgets.fixWebkit(1);
70 - ui.helper.find('div.widget-description').hide();
71 - the_id = this.id;
72 - },
73 - stop: function(e,ui) {
74 - if ( rem )
75 - $(rem).hide();
76 - rem = '';
77 - accuaWidgets.fixWebkit();
78 - }
79 - });
80 -
81 - //Ordinabilità dei widget
82 - sidebars.sortable({
83 - placeholder: 'widget-placeholder',
84 - items: '> .widget',
85 - handle: '> .widget-top > .widget-title',
86 - cursor: 'move',
87 - distance: 2,
88 - containment: 'document',
89 - start: function(e,ui) {
90 - accuaWidgets.fixWebkit(1);
91 - ui.item.children('.widget-inside').hide();
92 - ui.item.css({margin:'', 'width':''});
93 - },
94 - stop: function(e,ui) {
95 - if ( ui.item.hasClass('ui-draggable') && ui.item.data('draggable') )
96 - ui.item.draggable('destroy');
97 -
98 - if ( ui.item.hasClass('deleting') ) {
99 - accuaWidgets.save( ui.item, 1, 0, 1 ); // delete widget
100 - ui.item.remove();
101 - return;
102 - }
103 -
104 - var add = ui.item.find('input.add_new').val(),
105 - n = ui.item.find('input.multi_number').val(),
106 - id = the_id,
107 - sb = $(this).attr('id');
108 -
109 - ui.item.css({margin:'', 'width':''});
110 - the_id = '';
111 -
112 - accuaWidgets.fixWebkit();
113 - if ( add ) {
114 - if ( 'multi' == add ) {
115 - ui.item.html( ui.item.html().replace(/<[^<>]+>/g, function(m){ return m.replace(/__i__|%i%/g, n); }) );
116 - ui.item.attr( 'id', id.replace(/__i__|%i%/g, n) );
117 - n++;
118 - $('div#' + id).find('input.multi_number').val(n);
119 - } else if ( 'single' == add ) {
120 - ui.item.attr( 'id', 'new-' + id );
121 - rem = 'div#' + id;
122 - }
123 - accuaWidgets.save( ui.item, 0, 0, 1 );
124 - ui.item.find('input.add_new').val('');
125 - ui.item.find('a.widget-action').click();
126 - return;
127 - }
128 - accuaWidgets.saveOrder(sb);
129 - },
130 - receive: function(e,ui) {
131 - var t = $(this);
132 - if ( !t.is(':visible') ) {
133 - t.sortable('cancel');
134 - }
135 - }
136 - }).sortable('option', 'connectWith', 'div.widgets-sortables').parent().filter('.closed').children('.widgets-sortables').sortable('disable');
137 -
138 - //Droppabilità dei widget disponibili
139 - $('#available-widgets').droppable({
140 - tolerance: 'pointer',
141 - accept: function(o){
142 - return $(o).parent().attr('id') != 'widget-list';
143 - },
144 - drop: function(e,ui) {
145 - ui.draggable.addClass('deleting');
146 - $('#removing-widget').hide().children('span').html('');
147 - },
148 - over: function(e,ui) {
149 - ui.draggable.addClass('deleting');
150 - $('div.widget-placeholder').hide();
151 -
152 - if ( ui.draggable.hasClass('ui-sortable-helper') )
153 - $('#removing-widget').show().children('span')
154 - .html( ui.draggable.find('div.widget-title').children('h4').html() );
155 - },
156 - out: function(e,ui) {
157 - ui.draggable.removeClass('deleting');
158 - $('div.widget-placeholder').show();
159 - $('#removing-widget').hide().children('span').html('');
160 - }
161 - });
162 -
163 - var holders = $('#widgets-left .widget-holder, #widgets-right .widgets-sortables');
164 - holders.wrap('<div class="accua-form-widget-scroll-wrapper"></div>');
165 -
166 - $('.accua-form-widget-scroll-wrapper').each(function(){
167 - var t = $(this);
168 - t.css({'height': t.height()});
169 - t.resizable({handles: 's'});
170 - });
171 - },
172 -
173 - //Salvataggio ordine
174 - saveOrder : function(sb) {
175 - if ( sb )
176 - $('#' + sb).closest('div.widgets-holder-wrap').find('img.ajax-feedback').css('visibility', 'visible');
177 -
178 - var a = {
179 - action: 'accua-form-fields-order',
180 - savewidgets: $('#_wpnonce_widgets').val(),
181 - sidebars: []
182 - };
183 -
184 - $('div.widgets-sortables').each( function() {
185 - var t = $(this);
186 - if ( t.sortable ) {
187 - a['sidebars[' + t.attr('id') + ']'] = t.sortable('toArray').join(',');
188 - }
189 - });
190 -
191 - $.post( ajaxurl, a, function() {
192 - $('img.ajax-feedback').css('visibility', 'hidden');
193 - });
194 -
195 - this.resize();
196 - },
197 -
198 - //Salvataggio stato widget
199 - save : function(widget, del, animate, order) {
200 - var sb = widget.closest('div.widgets-sortables').attr('id'), data = widget.find('form').serialize(), a;
201 - widget = $(widget);
202 - $('.ajax-feedback', widget).css('visibility', 'visible');
203 -
204 - a = {
205 - action: 'accua-save-form-field',
206 - savewidgets: $('#_wpnonce_widgets').val(),
207 - sidebar: sb
208 - };
209 -
210 - if ( del )
211 - a['delete_widget'] = 1;
212 -
213 - data += '&' + $.param(a);
214 -
215 - $.post( ajaxurl, data, function(r){
216 - var id;
217 -
218 - if ( del ) {
219 - if ( !$('input.widget_number', widget).val() ) {
220 - id = $('input.widget-id', widget).val();
221 - $('#available-widgets').find('input.widget-id').each(function(){
222 - if ( $(this).val() == id )
223 - $(this).closest('div.widget').show();
224 - });
225 - }
226 -
227 - if ( animate ) {
228 - order = 0;
229 - widget.slideUp('fast', function(){
230 - $(this).remove();
231 - accuaWidgets.saveOrder();
232 - });
233 - } else {
234 - widget.remove();
235 - accuaWidgets.resize();
236 - }
237 - } else {
238 - $('.ajax-feedback').css('visibility', 'hidden');
239 - if ( r && r.length > 2 ) {
240 - $('div.widget-content', widget).html(r);
241 - accuaWidgets.appendTitle(widget);
242 - accuaWidgets.fixLabels(widget);
243 - }
244 - }
245 - if ( order )
246 - accuaWidgets.saveOrder();
247 - });
248 - },
249 -
250 - //Aggiunta titolo
251 - appendTitle : function(widget) {
252 - var title = $('input[id*="-title"]', widget);
253 - if ( title = title.val() ) {
254 - title = title.replace(/<[^<>]+>/g, '').replace(/</g, '&lt;').replace(/>/g, '&gt;');
255 - $(widget).children('.widget-top').children('.widget-title').children()
256 - .children('.in-widget-title').html(': ' + title);
257 - }
258 - },
259 -
260 - resize : function() {
261 - /*
262 - $('div.widgets-sortables').not('#wp_inactive_widgets').each(function(){
263 - var t = $(this);
264 - var h = 50, H = t.children('.widget').length;
265 - h = h + parseInt(H * 48, 10);
266 - t.css( 'minHeight', h + 'px' );
267 - });
268 - */
269 - },
270 -
271 - fixWebkit : function(n) {
272 - n = n ? 'none' : '';
273 - $('body').css({
274 - WebkitUserSelect: n,
275 - KhtmlUserSelect: n
276 - });
277 - },
278 -
279 - fixLabels : function(widget) {
280 - widget.children('.widget-inside').find('label').each(function(){
281 - var t = $(this);
282 - var f = t.attr('for');
283 - if ( f && f == $('input', this).attr('id') ) {
284 - t.removeAttr('for');
285 - }
286 - });
287 - },
288 -
289 - //Chiusura widget
290 - close : function(widget) {
291 - widget.children('.widget-inside').slideUp('fast', function(){
292 - widget.css({'width':'', margin:''});
293 - });
294 - }
295 -};
296 -
297 -$(document).ready(function($){ accuaWidgets.init(); });
298 -
299 -})(jQuery);
1 +var accuaWidgets = {};
2 +(function($) {
3 +
4 +accuaWidgets = {
5 +
6 + init : function() {
7 + var rem, sidebars = $('div.widgets-sortables'), isRTL = !! ( 'undefined' != typeof isRtl && isRtl ),
8 + margin = ( isRtl ? 'marginRight' : 'marginLeft' ), the_id;
9 +
10 + //Evento per widget-action (aggiunto in modalità "live")
11 + // $('a.widget-action').live('click', function(){
12 + $(document).on('click', 'a.widget-action', function(){
13 + var css = {}, widget = $(this).closest('div.widget'), inside = widget.children('.widget-inside'), w = parseInt( widget.find('input.widget-width').val(), 10 );
14 +
15 + if ( inside.is(':hidden') ) {
16 + if ( w > 250 && inside.closest('div.widgets-sortables').length ) {
17 + css['width'] = w + 30 + 'px';
18 + if ( inside.closest('div.widget-liquid-right').length )
19 + css[margin] = 235 - w + 'px';
20 + widget.css(css);
21 + }
22 + accuaWidgets.fixLabels(widget);
23 + inside.slideDown('fast');
24 + } else {
25 + inside.slideUp('fast', function() {
26 + widget.css({'width':'', margin:''});
27 + });
28 + }
29 + return false;
30 + });
31 +
32 + //Click sul bottone di salvataggio
33 + // $('input.widget-control-save').live('click', function(){
34 + $(document).on('click', 'input.widget-control-save', function(){
35 + accuaWidgets.save( $(this).closest('div.widget'), 0, 1, 0 );
36 + return false;
37 + });
38 +
39 + //Click sul bottone di rimozione
40 + //$('a.widget-control-remove').live('click', function(){
41 + $(document).on('click', 'a.widget-control-remove', function(){
42 + accuaWidgets.save( $(this).closest('div.widget'), 1, 1, 0 );
43 + return false;
44 + });
45 +
46 + //Click sul bottone di chiusura
47 + //$('a.widget-control-close').live('click', function(){
48 + $(document).on('click', 'a.widget-control-close', function(){
49 + accuaWidgets.close( $(this).closest('div.widget') );
50 + return false;
51 + });
52 +
53 + //Impostazione titolo e apertura widget se c'è un errore
54 + sidebars.children('.widget').each(function() {
55 + accuaWidgets.appendTitle(this);
56 + if ( $('p.widget-error', this).length )
57 + $('a.widget-action', this).click();
58 + });
59 +
60 + //Trascinabilità dei widget nella lista
61 + $('#widget-list').children('.widget').draggable({
62 + connectToSortable: 'div.widgets-sortables',
63 + handle: '> .widget-top > .widget-title',
64 + distance: 2,
65 + helper: 'clone',
66 + zIndex: 5,
67 + containment: 'document',
68 + start: function(e,ui) {
69 + accuaWidgets.fixWebkit(1);
70 + ui.helper.find('div.widget-description').hide();
71 + the_id = this.id;
72 + },
73 + stop: function(e,ui) {
74 + if ( rem )
75 + $(rem).hide();
76 + rem = '';
77 + accuaWidgets.fixWebkit();
78 + }
79 + });
80 +
81 + //Ordinabilità dei widget
82 + sidebars.sortable({
83 + placeholder: 'widget-placeholder',
84 + items: '> .widget',
85 + handle: '> .widget-top > .widget-title',
86 + cursor: 'move',
87 + distance: 2,
88 + containment: 'document',
89 + start: function(e,ui) {
90 + accuaWidgets.fixWebkit(1);
91 + ui.item.children('.widget-inside').hide();
92 + ui.item.css({margin:'', 'width':''});
93 + },
94 + stop: function(e,ui) {
95 + if ( ui.item.hasClass('ui-draggable') && ui.item.data('draggable') )
96 + ui.item.draggable('destroy');
97 +
98 + if ( ui.item.hasClass('deleting') ) {
99 + accuaWidgets.save( ui.item, 1, 0, 1 ); // delete widget
100 + ui.item.remove();
101 + return;
102 + }
103 +
104 + var add = ui.item.find('input.add_new').val(),
105 + n = ui.item.find('input.multi_number').val(),
106 + id = the_id,
107 + sb = $(this).attr('id');
108 +
109 + ui.item.css({margin:'', 'width':''});
110 + the_id = '';
111 +
112 + accuaWidgets.fixWebkit();
113 + if ( add ) {
114 + if ( 'multi' == add ) {
115 + ui.item.html( ui.item.html().replace(/<[^<>]+>/g, function(m){ return m.replace(/__i__|%i%/g, n); }) );
116 + ui.item.attr( 'id', id.replace(/__i__|%i%/g, n) );
117 + n++;
118 + $('div#' + id).find('input.multi_number').val(n);
119 + } else if ( 'single' == add ) {
120 + ui.item.attr( 'id', 'new-' + id );
121 + rem = 'div#' + id;
122 + }
123 + accuaWidgets.save( ui.item, 0, 0, 1 );
124 + ui.item.find('input.add_new').val('');
125 + ui.item.find('a.widget-action').click();
126 + return;
127 + }
128 + accuaWidgets.saveOrder(sb);
129 + },
130 + receive: function(e,ui) {
131 + var t = $(this);
132 + if ( !t.is(':visible') ) {
133 + t.sortable('cancel');
134 + }
135 + }
136 + }).sortable('option', 'connectWith', 'div.widgets-sortables').parent().filter('.closed').children('.widgets-sortables').sortable('disable');
137 +
138 + //Droppabilità dei widget disponibili
139 + $('#available-widgets').droppable({
140 + tolerance: 'pointer',
141 + accept: function(o){
142 + return $(o).parent().attr('id') != 'widget-list';
143 + },
144 + drop: function(e,ui) {
145 + ui.draggable.addClass('deleting');
146 + $('#removing-widget').hide().children('span').html('');
147 + },
148 + over: function(e,ui) {
149 + ui.draggable.addClass('deleting');
150 + $('div.widget-placeholder').hide();
151 +
152 + if ( ui.draggable.hasClass('ui-sortable-helper') )
153 + $('#removing-widget').show().children('span')
154 + .html( ui.draggable.find('div.widget-title').children('h4').html() );
155 + },
156 + out: function(e,ui) {
157 + ui.draggable.removeClass('deleting');
158 + $('div.widget-placeholder').show();
159 + $('#removing-widget').hide().children('span').html('');
160 + }
161 + });
162 +
163 + var holders = $('#widgets-left .widget-holder, #widgets-right .widgets-sortables');
164 + holders.wrap('<div class="accua-form-widget-scroll-wrapper"></div>');
165 + /*
166 + $('.accua-form-widget-scroll-wrapper').each(function(){
167 + var t = $(this);
168 + //t.css({'height': t.height()});
169 + t.resizable({handles: 's'});
170 + });*/
171 + },
172 +
173 + //Salvataggio ordine
174 + saveOrder : function(sb) {
175 + if ( sb )
176 + $('#' + sb).closest('div.widgets-holder-wrap').find('img.ajax-feedback').css('visibility', 'visible');
177 +
178 + var a = {
179 + action: 'accua-form-fields-order',
180 + _nonce_edit_form: $('#_nonce_edit_form').val(),
181 + sidebars: []
182 + };
183 +
184 + $('div.widgets-sortables').each( function() {
185 + var t = $(this);
186 + if ( t.sortable ) {
187 + a['sidebars[' + t.attr('id') + ']'] = t.sortable('toArray').join(',');
188 + }
189 + });
190 +
191 + $.post( ajaxurl, a, function() {
192 + $('img.ajax-feedback').css('visibility', 'hidden');
193 + });
194 +
195 + this.resize();
196 + },
197 +
198 + //Salvataggio stato widget
199 + save : function(widget, del, animate, order) {
200 + var sb = widget.closest('div.widgets-sortables').attr('id'), data = widget.find('form').serialize(), a;
201 + widget = $(widget);
202 + $('.ajax-feedback', widget).css('visibility', 'visible');
203 +
204 + a = {
205 + action: 'accua-save-form-field',
206 + _nonce_edit_form: $('#_nonce_edit_form').val(),
207 + sidebar: sb
208 + };
209 +
210 + if ( del )
211 + a['delete_widget'] = 1;
212 +
213 + data += '&' + $.param(a);
214 +
215 + $.post( ajaxurl, data, function(r){
216 + var id;
217 +
218 + if ( del ) {
219 + if ( !$('input.widget_number', widget).val() ) {
220 + id = $('input.widget-id', widget).val();
221 + $('#available-widgets').find('input.widget-id').each(function(){
222 + if ( $(this).val() == id )
223 + $(this).closest('div.widget').show();
224 + });
225 + }
226 +
227 + if ( animate ) {
228 + order = 0;
229 + widget.slideUp('fast', function(){
230 + $(this).remove();
231 + accuaWidgets.saveOrder();
232 + });
233 + } else {
234 + widget.remove();
235 + accuaWidgets.resize();
236 + }
237 + } else {
238 + $('.ajax-feedback').css('visibility', 'hidden');
239 + if ( r && r.length > 2 ) {
240 + $('div.widget-content', widget).html(r);
241 + accuaWidgets.appendTitle(widget);
242 + accuaWidgets.fixLabels(widget);
243 + }
244 + }
245 + if ( order )
246 + accuaWidgets.saveOrder();
247 + });
248 + },
249 +
250 + //Aggiunta titolo
251 + appendTitle : function(widget) {
252 + var title = $('input[id*="-title"]', widget);
253 + if ( title = title.val() ) {
254 + title = title.replace(/<[^<>]+>/g, '').replace(/</g, '&lt;').replace(/>/g, '&gt;');
255 + $(widget).children('.widget-top').children('.widget-title').children()
256 + .children('.in-widget-title').html(': ' + title);
257 + }
258 + },
259 +
260 + resize : function() {
261 + /*
262 + $('div.widgets-sortables').not('#wp_inactive_widgets').each(function(){
263 + var t = $(this);
264 + var h = 50, H = t.children('.widget').length;
265 + h = h + parseInt(H * 48, 10);
266 + t.css( 'minHeight', h + 'px' );
267 + });
268 + */
269 + },
270 +
271 + fixWebkit : function(n) {
272 + n = n ? 'none' : '';
273 + $('body').css({
274 + WebkitUserSelect: n,
275 + KhtmlUserSelect: n
276 + });
277 + },
278 +
279 + fixLabels : function(widget) {
280 + widget.children('.widget-inside').find('label').each(function(){
281 + var t = $(this);
282 + var f = t.attr('for');
283 + if ( f && f == $('input', this).attr('id') ) {
284 + t.removeAttr('for');
285 + }
286 + });
287 + },
288 +
289 + //Chiusura widget
290 + close : function(widget) {
291 + widget.children('.widget-inside').slideUp('fast', function(){
292 + widget.css({'width':'', margin:''});
293 + });
294 + }
295 +};
296 +
297 +$(document).ready(function($){ accuaWidgets.init(); });
298 +
299 +})(jQuery);