|
1 | 1 | /*
|
2 |
| - * jQuery Form Styler v1.7.2 |
| 2 | + * jQuery Form Styler v1.7.3 |
3 | 3 | * https://github.com/Dimox/jQueryFormStyler
|
4 | 4 | *
|
5 | 5 | * Copyright 2012-2015 Dimox (http://dimox.name/)
|
6 | 6 | * Released under the MIT license.
|
7 | 7 | *
|
8 |
| - * Date: 2015.07.15 |
| 8 | + * Date: 2015.09.05 |
9 | 9 | *
|
10 | 10 | */
|
11 | 11 |
|
|
29 | 29 | idSuffix: '-styler',
|
30 | 30 | filePlaceholder: 'Файл не выбран',
|
31 | 31 | fileBrowse: 'Обзор...',
|
| 32 | + fileNumber: 'Выбрано файлов: %s', |
32 | 33 | selectPlaceholder: 'Выберите...',
|
33 | 34 | selectSearch: false,
|
34 | 35 | selectSearchLimit: 10,
|
|
109 | 110 | if (el.is(':disabled')) checkbox.addClass('disabled');
|
110 | 111 |
|
111 | 112 | // клик на псевдочекбокс
|
112 |
| - checkbox.on('click.styler', function() { |
| 113 | + checkbox.click(function(e) { |
| 114 | + e.preventDefault(); |
113 | 115 | if (!checkbox.is('.disabled')) {
|
114 | 116 | if (el.is(':checked')) {
|
115 | 117 | el.prop('checked', false);
|
|
118 | 120 | el.prop('checked', true);
|
119 | 121 | checkbox.addClass('checked');
|
120 | 122 | }
|
121 |
| - el.change(); |
122 |
| - return false; |
123 |
| - } else { |
124 |
| - return false; |
| 123 | + el.focus().change(); |
125 | 124 | }
|
126 | 125 | });
|
127 | 126 | // клик на label
|
128 | 127 | el.closest('label').add('label[for="' + el.attr('id') + '"]').on('click.styler', function(e) {
|
129 |
| - if (!$(e.target).is('a')) { |
130 |
| - checkbox.click(); |
| 128 | + if (!$(e.target).is('a') && !$(e.target).closest(checkbox).length) { |
| 129 | + checkbox.triggerHandler('click'); |
131 | 130 | e.preventDefault();
|
132 | 131 | }
|
133 | 132 | });
|
|
190 | 189 | if (el.is(':disabled')) radio.addClass('disabled');
|
191 | 190 |
|
192 | 191 | // клик на псевдорадиокнопке
|
193 |
| - radio.on('click.styler', function() { |
| 192 | + radio.click(function(e) { |
| 193 | + e.preventDefault(); |
194 | 194 | if (!radio.is('.disabled')) {
|
195 | 195 | radio.closest(opt.wrapper).find('input[name="' + el.attr('name') + '"]').prop('checked', false).parent().removeClass('checked');
|
196 | 196 | el.prop('checked', true).parent().addClass('checked');
|
197 |
| - el.change(); |
198 |
| - return false; |
199 |
| - } else { |
200 |
| - return false; |
| 197 | + el.focus().change(); |
201 | 198 | }
|
202 | 199 | });
|
203 | 200 | // клик на label
|
204 | 201 | el.closest('label').add('label[for="' + el.attr('id') + '"]').on('click.styler', function(e) {
|
205 |
| - if (!$(e.target).is('a')) { |
206 |
| - radio.click(); |
| 202 | + if (!$(e.target).is('a') && !$(e.target).closest(radio).length) { |
| 203 | + radio.triggerHandler('click'); |
207 | 204 | e.preventDefault();
|
208 | 205 | }
|
209 | 206 | });
|
|
263 | 260 | var value = el.val();
|
264 | 261 | if (el.is('[multiple]')) {
|
265 | 262 | value = '';
|
266 |
| - var files = el[0].files; |
267 |
| - for (var i = 0; i < files.length; i++) { |
268 |
| - value += ( (i > 0) ? ', ' : '' ) + files[i].name; |
| 263 | + var files = el[0].files.length; |
| 264 | + if (files > 0) { |
| 265 | + var number = el.data('number'); |
| 266 | + if (number === undefined) number = opt.fileNumber; |
| 267 | + number = number.replace('%s', files); |
| 268 | + value = number; |
269 | 269 | }
|
270 | 270 | }
|
271 | 271 | name.text(value.replace(/.+[\\\/]/, ''));
|
|
345 | 345 | };
|
346 | 346 |
|
347 | 347 | if (!number.is('.disabled')) {
|
348 |
| - number.on('mousedown.styler', 'div.jq-number__spin', function() { |
| 348 | + number.on('mousedown', 'div.jq-number__spin', function() { |
349 | 349 | var spin = $(this);
|
350 | 350 | changeValue(spin);
|
351 | 351 | timeout = setTimeout(function(){
|
352 | 352 | interval = setInterval(function(){ changeValue(spin); }, 40);
|
353 | 353 | }, 350);
|
354 |
| - }).on('mouseup.styler mouseout.styler', 'div.jq-number__spin', function() { |
| 354 | + }).on('mouseup mouseout', 'div.jq-number__spin', function() { |
355 | 355 | clearTimeout(timeout);
|
356 | 356 | clearInterval(interval);
|
357 | 357 | });
|
|
711 | 711 | }
|
712 | 712 |
|
713 | 713 | preventScrolling(ul);
|
714 |
| - return false; |
715 | 714 |
|
716 | 715 | }); // end divSelect.click()
|
717 | 716 |
|
|
998 | 997 | var el = $(this.element);
|
999 | 998 |
|
1000 | 999 | if (el.is(':checkbox') || el.is(':radio')) {
|
1001 |
| - el.removeData().off('.styler').removeAttr('style').parent().before(el).remove(); |
| 1000 | + el.removeData('_' + pluginName).off('.styler refresh').removeAttr('style').parent().before(el).remove(); |
1002 | 1001 | el.closest('label').add('label[for="' + el.attr('id') + '"]').off('.styler');
|
1003 | 1002 | } else if (el.is('input[type="number"]')) {
|
1004 |
| - el.removeData().off('.styler').closest('.jq-number').before(el).remove(); |
| 1003 | + el.removeData('_' + pluginName).off('.styler refresh').closest('.jq-number').before(el).remove(); |
1005 | 1004 | } else if (el.is(':file') || el.is('select')) {
|
1006 |
| - el.removeData().off('.styler').removeAttr('style').parent().before(el).remove(); |
| 1005 | + el.removeData('_' + pluginName).off('.styler refresh').removeAttr('style').parent().before(el).remove(); |
1007 | 1006 | }
|
1008 | 1007 |
|
1009 | 1008 | } // destroy: function()
|
|
0 commit comments