Skip to content

Commit 0c415e8

Browse files
committed
Simplify click event handler selectors. Closes blueimp#2122.
1 parent 160cd0e commit 0c415e8

File tree

4 files changed

+31
-30
lines changed

4 files changed

+31
-30
lines changed

css/jquery.fileupload-ui.css

Lines changed: 3 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
@@ -64,6 +64,8 @@
6464
}
6565

6666
@media (max-width: 767px) {
67+
.fileupload-buttonbar .toggle,
68+
.files .toggle,
6769
.files .btn span {
6870
display: none;
6971
}
@@ -78,7 +80,4 @@
7880
.files .progress {
7981
width: 20px;
8082
}
81-
.files .delete {
82-
width: 60px;
83-
}
8483
}

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
@@ -164,17 +164,17 @@ <h3 class="modal-title"></h3>
164164
<td>
165165
<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>
166166
</td>
167-
<td class="start">{% if (!o.options.autoUpload) { %}
168-
<button class="btn btn-primary">
167+
<td>{% if (!o.options.autoUpload) { %}
168+
<button class="btn btn-primary start">
169169
<i class="icon-upload icon-white"></i>
170170
<span>Start</span>
171171
</button>
172172
{% } %}</td>
173173
{% } else { %}
174174
<td colspan="2"></td>
175175
{% } %}
176-
<td class="cancel">{% if (!i) { %}
177-
<button class="btn btn-warning">
176+
<td>{% if (!i) { %}
177+
<button class="btn btn-warning cancel">
178178
<i class="icon-ban-circle icon-white"></i>
179179
<span>Cancel</span>
180180
</button>
@@ -201,12 +201,12 @@ <h3 class="modal-title"></h3>
201201
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
202202
<td colspan="2"></td>
203203
{% } %}
204-
<td class="delete">
205-
<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}'{% } %}>
204+
<td>
205+
<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}'{% } %}>
206206
<i class="icon-trash icon-white"></i>
207207
<span>Delete</span>
208208
</button>
209-
<input type="checkbox" name="delete" value="1">
209+
<input type="checkbox" name="delete" value="1" class="toggle">
210210
</td>
211211
</tr>
212212
{% } %}

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)