Skip to content
This repository was archived by the owner on Dec 27, 2021. It is now read-only.

Commit 572d18d

Browse files
committed
1.7.3
1 parent a7696c3 commit 572d18d

File tree

5 files changed

+69
-63
lines changed

5 files changed

+69
-63
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# История изменений
22

3+
## 1.7.3 <sup>05.09.2015</sup>
4+
- Добавлено: новая опция `fileNumber` для текста "Выбрано файлов: N".
5+
- Изменено: при выборе файлов в файловом поле с множественным выбором теперь вместо перечисления списка файлов отображается текст "Выбрано файлов: N".
6+
- Исправлено: [#82](https://github.com/Dimox/jQueryFormStyler/pull/82).
7+
38
## 1.7.2 <sup>15.07.2015</sup>
49
- Добавлено: поддержка стилизации тега `<input type="number">`.
510

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# jQuery Form Styler <sup>[1.7.2](https://github.com/Dimox/jQueryFormStyler/blob/master/CHANGELOG.md)</sup>
1+
# jQuery Form Styler <sup>[1.7.3](https://github.com/Dimox/jQueryFormStyler/blob/master/CHANGELOG.md)</sup>
22

33
jQuery-плагин для стилизации элементов HTML-форм:
44

@@ -12,6 +12,7 @@ jQuery-плагин для стилизации элементов HTML-форм
1212

1313
- [Страница с примерами](http://dimox.github.io/jQueryFormStyler/demo/)
1414
- [Домашняя страница плагина](http://dimox.name/jquery-form-styler/)
15+
- [Плагин в CDN jsDelivr](http://www.jsdelivr.com/#!jquery.formstyler)
1516

1617
## Лицензия
1718

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jquery-form-styler",
3-
"version": "1.7.2",
3+
"version": "1.7.3",
44
"main": [
55
"jquery.formstyler.min.js",
66
"jquery.formstyler.css"

jquery.formstyler.js

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* jQuery Form Styler v1.7.2
2+
* jQuery Form Styler v1.7.3
33
* https://github.com/Dimox/jQueryFormStyler
44
*
55
* Copyright 2012-2015 Dimox (http://dimox.name/)
66
* Released under the MIT license.
77
*
8-
* Date: 2015.07.15
8+
* Date: 2015.09.05
99
*
1010
*/
1111

@@ -29,6 +29,7 @@
2929
idSuffix: '-styler',
3030
filePlaceholder: 'Файл не выбран',
3131
fileBrowse: 'Обзор...',
32+
fileNumber: 'Выбрано файлов: %s',
3233
selectPlaceholder: 'Выберите...',
3334
selectSearch: false,
3435
selectSearchLimit: 10,
@@ -109,7 +110,8 @@
109110
if (el.is(':disabled')) checkbox.addClass('disabled');
110111

111112
// клик на псевдочекбокс
112-
checkbox.on('click.styler', function() {
113+
checkbox.click(function(e) {
114+
e.preventDefault();
113115
if (!checkbox.is('.disabled')) {
114116
if (el.is(':checked')) {
115117
el.prop('checked', false);
@@ -118,16 +120,13 @@
118120
el.prop('checked', true);
119121
checkbox.addClass('checked');
120122
}
121-
el.change();
122-
return false;
123-
} else {
124-
return false;
123+
el.focus().change();
125124
}
126125
});
127126
// клик на label
128127
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');
131130
e.preventDefault();
132131
}
133132
});
@@ -190,20 +189,18 @@
190189
if (el.is(':disabled')) radio.addClass('disabled');
191190

192191
// клик на псевдорадиокнопке
193-
radio.on('click.styler', function() {
192+
radio.click(function(e) {
193+
e.preventDefault();
194194
if (!radio.is('.disabled')) {
195195
radio.closest(opt.wrapper).find('input[name="' + el.attr('name') + '"]').prop('checked', false).parent().removeClass('checked');
196196
el.prop('checked', true).parent().addClass('checked');
197-
el.change();
198-
return false;
199-
} else {
200-
return false;
197+
el.focus().change();
201198
}
202199
});
203200
// клик на label
204201
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');
207204
e.preventDefault();
208205
}
209206
});
@@ -263,9 +260,12 @@
263260
var value = el.val();
264261
if (el.is('[multiple]')) {
265262
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;
269269
}
270270
}
271271
name.text(value.replace(/.+[\\\/]/, ''));
@@ -345,13 +345,13 @@
345345
};
346346

347347
if (!number.is('.disabled')) {
348-
number.on('mousedown.styler', 'div.jq-number__spin', function() {
348+
number.on('mousedown', 'div.jq-number__spin', function() {
349349
var spin = $(this);
350350
changeValue(spin);
351351
timeout = setTimeout(function(){
352352
interval = setInterval(function(){ changeValue(spin); }, 40);
353353
}, 350);
354-
}).on('mouseup.styler mouseout.styler', 'div.jq-number__spin', function() {
354+
}).on('mouseup mouseout', 'div.jq-number__spin', function() {
355355
clearTimeout(timeout);
356356
clearInterval(interval);
357357
});
@@ -711,7 +711,6 @@
711711
}
712712

713713
preventScrolling(ul);
714-
return false;
715714

716715
}); // end divSelect.click()
717716

@@ -998,12 +997,12 @@
998997
var el = $(this.element);
999998

1000999
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();
10021001
el.closest('label').add('label[for="' + el.attr('id') + '"]').off('.styler');
10031002
} 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();
10051004
} 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();
10071006
}
10081007

10091008
} // destroy: function()

0 commit comments

Comments
 (0)