Skip to content

Commit 729af46

Browse files
committed
Simplify click event handler selectors.
2 parents cea1278 + 0c415e8 commit 729af46

File tree

5 files changed

+38
-34
lines changed

5 files changed

+38
-34
lines changed

css/jquery.fileupload-ui.css

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@charset "UTF-8";
22
/*
3-
* jQuery File Upload UI Plugin CSS 6.10
3+
* jQuery File Upload UI Plugin CSS 7.4
44
* https://github.com/blueimp/jQuery-File-Upload
55
*
66
* Copyright 2010, Sebastian Tschan
@@ -82,6 +82,11 @@
8282
}
8383

8484
@media (max-width: 767px) {
85+
.fileupload-buttonbar .toggle,
86+
.files .toggle,
87+
.files .btn span {
88+
display: none;
89+
}
8590
.files .preview * {
8691
width: 40px;
8792
}
@@ -93,9 +98,6 @@
9398
.files .progress {
9499
width: 20px;
95100
}
96-
.files .delete {
97-
width: 60px;
98-
}
99101
}
100102

101103
/* Fix for Webkit (Safari, Chrome) */

index.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE HTML>
22
<!--
33
/*
4-
* jQuery File Upload Plugin Demo 6.14
4+
* jQuery File Upload Plugin Demo 7.4
55
* https://github.com/blueimp/jQuery-File-Upload
66
*
77
* Copyright 2010, Sebastian Tschan
@@ -160,17 +160,17 @@ <h3>Demo Notes</h3>
160160
<td>
161161
<div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="bar" style="width:0%;"></div></div>
162162
</td>
163-
<td class="start">{% if (!o.options.autoUpload) { %}
164-
<button class="btn btn-primary">
163+
<td>{% if (!o.options.autoUpload) { %}
164+
<button class="btn btn-primary start">
165165
<i class="icon-upload icon-white"></i>
166166
<span>Start</span>
167167
</button>
168168
{% } %}</td>
169169
{% } else { %}
170170
<td colspan="2"></td>
171171
{% } %}
172-
<td class="cancel">{% if (!i) { %}
173-
<button class="btn btn-warning">
172+
<td>{% if (!i) { %}
173+
<button class="btn btn-warning cancel">
174174
<i class="icon-ban-circle icon-white"></i>
175175
<span>Cancel</span>
176176
</button>
@@ -197,12 +197,12 @@ <h3>Demo Notes</h3>
197197
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
198198
<td colspan="2"></td>
199199
{% } %}
200-
<td class="delete">
201-
<button class="btn btn-danger" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}"{% if (file.delete_with_credentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}>
200+
<td>
201+
<button class="btn btn-danger delete" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}"{% if (file.delete_with_credentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}>
202202
<i class="icon-trash icon-white"></i>
203203
<span>Delete</span>
204204
</button>
205-
<input type="checkbox" name="delete" value="1">
205+
<input type="checkbox" name="delete" value="1" class="toggle">
206206
</td>
207207
</tr>
208208
{% } %}

js/jquery.fileupload-jui.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jQuery File Upload jQuery UI Plugin 1.4
2+
* jQuery File Upload jQuery UI Plugin 7.4
33
* https://github.com/blueimp/jQuery-File-Upload
44
*
55
* Copyright 2012, Sebastian Tschan
@@ -69,11 +69,11 @@
6969
var node = this._super(func, files),
7070
showIconText = $(window).width() > 480;
7171
node.find('.progress').empty().progressbar();
72-
node.find('.start button').button({
72+
node.find('.start').button({
7373
icons: {primary: 'ui-icon-circle-arrow-e'},
7474
text: showIconText
7575
});
76-
node.find('.cancel button').button({
76+
node.find('.cancel').button({
7777
icons: {primary: 'ui-icon-cancel'},
7878
text: showIconText
7979
});
@@ -82,7 +82,7 @@
8282
_renderDownload: function (func, files) {
8383
var node = this._super(func, files),
8484
showIconText = $(window).width() > 480;
85-
node.find('.delete button').button({
85+
node.find('.delete').button({
8686
icons: {primary: 'ui-icon-trash'},
8787
text: showIconText
8888
});

js/jquery.fileupload-ui.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jQuery File Upload User Interface Plugin 7.3.2
2+
* jQuery File Upload User Interface Plugin 7.4
33
* https://github.com/blueimp/jQuery-File-Upload
44
*
55
* Copyright 2010, Sebastian Tschan
@@ -638,27 +638,28 @@
638638
this._on(fileUploadButtonBar.find('.start'), {
639639
click: function (e) {
640640
e.preventDefault();
641-
filesList.find('.start button').click();
641+
filesList.find('.start').click();
642642
}
643643
});
644644
this._on(fileUploadButtonBar.find('.cancel'), {
645645
click: function (e) {
646646
e.preventDefault();
647-
filesList.find('.cancel button').click();
647+
filesList.find('.cancel').click();
648648
}
649649
});
650650
this._on(fileUploadButtonBar.find('.delete'), {
651651
click: function (e) {
652652
e.preventDefault();
653-
filesList.find('.delete input:checked')
654-
.siblings('button').click();
653+
filesList.find('.toggle:checked')
654+
.closest('.template-download')
655+
.find('.delete').click();
655656
fileUploadButtonBar.find('.toggle')
656657
.prop('checked', false);
657658
}
658659
});
659660
this._on(fileUploadButtonBar.find('.toggle'), {
660661
change: function (e) {
661-
filesList.find('.delete input').prop(
662+
filesList.find('.toggle').prop(
662663
'checked',
663664
$(e.currentTarget).is(':checked')
664665
);
@@ -668,7 +669,8 @@
668669

669670
_destroyButtonBarEventHandlers: function () {
670671
this._off(
671-
this.element.find('.fileupload-buttonbar button'),
672+
this.element.find('.fileupload-buttonbar')
673+
.find('.start, .cancel, .delete'),
672674
'click'
673675
);
674676
this._off(
@@ -680,9 +682,9 @@
680682
_initEventHandlers: function () {
681683
this._super();
682684
this._on(this.options.filesContainer, {
683-
'click .start button': this._startHandler,
684-
'click .cancel button': this._cancelHandler,
685-
'click .delete button': this._deleteHandler
685+
'click .start': this._startHandler,
686+
'click .cancel': this._cancelHandler,
687+
'click .delete': this._deleteHandler
686688
});
687689
this._initButtonBarEventHandlers();
688690
},

test/index.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE HTML>
22
<!--
33
/*
4-
* jQuery File Upload Plugin Test 6.14
4+
* jQuery File Upload Plugin Test 7.4
55
* https://github.com/blueimp/jQuery-File-Upload
66
*
77
* Copyright 2010, Sebastian Tschan
@@ -82,17 +82,17 @@ <h2 id="qunit-userAgent"></h2>
8282
<td>
8383
<div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="bar" style="width:0%;"></div></div>
8484
</td>
85-
<td class="start">{% if (!o.options.autoUpload) { %}
86-
<button class="btn btn-primary">
85+
<td>{% if (!o.options.autoUpload) { %}
86+
<button class="btn btn-primary start">
8787
<i class="icon-upload icon-white"></i>
8888
<span>Start</span>
8989
</button>
9090
{% } %}</td>
9191
{% } else { %}
9292
<td colspan="2"></td>
9393
{% } %}
94-
<td class="cancel">{% if (!i) { %}
95-
<button class="btn btn-warning">
94+
<td>{% if (!i) { %}
95+
<button class="btn btn-warning cancel">
9696
<i class="icon-ban-circle icon-white"></i>
9797
<span>Cancel</span>
9898
</button>
@@ -119,12 +119,12 @@ <h2 id="qunit-userAgent"></h2>
119119
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
120120
<td colspan="2"></td>
121121
{% } %}
122-
<td class="delete">
123-
<button class="btn btn-danger" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}"{% if (file.delete_with_credentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}>
122+
<td>
123+
<button class="btn btn-danger delete" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}"{% if (file.delete_with_credentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}>
124124
<i class="icon-trash icon-white"></i>
125125
<span>Delete</span>
126126
</button>
127-
<input type="checkbox" name="delete" value="1">
127+
<input type="checkbox" name="delete" value="1" class="toggle">
128128
</td>
129129
</tr>
130130
{% } %}

0 commit comments

Comments
 (0)