Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Simplify click event handler selectors. Closes #2122.

  • Loading branch information...
commit 0c415e8bc6a8d8666be1c9eda5f99285aa483bba 1 parent 160cd0e
@blueimp authored
View
7 css/jquery.fileupload-ui.css
@@ -1,6 +1,6 @@
@charset "UTF-8";
/*
- * jQuery File Upload UI Plugin CSS 6.10
+ * jQuery File Upload UI Plugin CSS 7.4
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
@@ -64,6 +64,8 @@
}
@media (max-width: 767px) {
+ .fileupload-buttonbar .toggle,
+ .files .toggle,
.files .btn span {
display: none;
}
@@ -78,7 +80,4 @@
.files .progress {
width: 20px;
}
- .files .delete {
- width: 60px;
- }
}
View
16 index.html
@@ -1,7 +1,7 @@
<!DOCTYPE HTML>
<!--
/*
- * jQuery File Upload Plugin Demo 6.14
+ * jQuery File Upload Plugin Demo 7.4
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
@@ -164,8 +164,8 @@ <h3 class="modal-title"></h3>
<td>
<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>
</td>
- <td class="start">{% if (!o.options.autoUpload) { %}
- <button class="btn btn-primary">
+ <td>{% if (!o.options.autoUpload) { %}
+ <button class="btn btn-primary start">
<i class="icon-upload icon-white"></i>
<span>Start</span>
</button>
@@ -173,8 +173,8 @@ <h3 class="modal-title"></h3>
{% } else { %}
<td colspan="2"></td>
{% } %}
- <td class="cancel">{% if (!i) { %}
- <button class="btn btn-warning">
+ <td>{% if (!i) { %}
+ <button class="btn btn-warning cancel">
<i class="icon-ban-circle icon-white"></i>
<span>Cancel</span>
</button>
@@ -201,12 +201,12 @@ <h3 class="modal-title"></h3>
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
<td colspan="2"></td>
{% } %}
- <td class="delete">
- <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}'{% } %}>
+ <td>
+ <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}'{% } %}>
<i class="icon-trash icon-white"></i>
<span>Delete</span>
</button>
- <input type="checkbox" name="delete" value="1">
+ <input type="checkbox" name="delete" value="1" class="toggle">
</td>
</tr>
{% } %}
View
22 js/jquery.fileupload-ui.js
@@ -1,5 +1,5 @@
/*
- * jQuery File Upload User Interface Plugin 7.3.2
+ * jQuery File Upload User Interface Plugin 7.4
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
@@ -638,27 +638,28 @@
this._on(fileUploadButtonBar.find('.start'), {
click: function (e) {
e.preventDefault();
- filesList.find('.start button').click();
+ filesList.find('.start').click();
}
});
this._on(fileUploadButtonBar.find('.cancel'), {
click: function (e) {
e.preventDefault();
- filesList.find('.cancel button').click();
+ filesList.find('.cancel').click();
}
});
this._on(fileUploadButtonBar.find('.delete'), {
click: function (e) {
e.preventDefault();
- filesList.find('.delete input:checked')
- .siblings('button').click();
+ filesList.find('.toggle:checked')
+ .closest('.template-download')
+ .find('.delete').click();
fileUploadButtonBar.find('.toggle')
.prop('checked', false);
}
});
this._on(fileUploadButtonBar.find('.toggle'), {
change: function (e) {
- filesList.find('.delete input').prop(
+ filesList.find('.toggle').prop(
'checked',
$(e.currentTarget).is(':checked')
);
@@ -668,7 +669,8 @@
_destroyButtonBarEventHandlers: function () {
this._off(
- this.element.find('.fileupload-buttonbar button'),
+ this.element.find('.fileupload-buttonbar')
+ .find('.start, .cancel, .delete'),
'click'
);
this._off(
@@ -680,9 +682,9 @@
_initEventHandlers: function () {
this._super();
this._on(this.options.filesContainer, {
- 'click .start button': this._startHandler,
- 'click .cancel button': this._cancelHandler,
- 'click .delete button': this._deleteHandler
+ 'click .start': this._startHandler,
+ 'click .cancel': this._cancelHandler,
+ 'click .delete': this._deleteHandler
@batter
batter added a note

If I'm not mistaken, these 3 lines mean that the implementation for the _startHandler, and _deleteHandler functions should be changed so that the variable being set in the 2nd line of these functions is not var button = $(e.currentTarget), since they no longer point to the buttons themselves. Just took me a while of debugging to figure out why this changed.

@blueimp Owner
blueimp added a note

The .start, .cancel and .delete handlers still point to buttons, since the templates changed as well.

@batter
batter added a note

My apologies. You are correct, I didn't examine the templates closely enough to notice they had changed as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
});
this._initButtonBarEventHandlers();
},
View
16 test/index.html
@@ -1,7 +1,7 @@
<!DOCTYPE HTML>
<!--
/*
- * jQuery File Upload Plugin Test 6.14
+ * jQuery File Upload Plugin Test 7.4
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
@@ -82,8 +82,8 @@ <h2 id="qunit-userAgent"></h2>
<td>
<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>
</td>
- <td class="start">{% if (!o.options.autoUpload) { %}
- <button class="btn btn-primary">
+ <td>{% if (!o.options.autoUpload) { %}
+ <button class="btn btn-primary start">
<i class="icon-upload icon-white"></i>
<span>Start</span>
</button>
@@ -91,8 +91,8 @@ <h2 id="qunit-userAgent"></h2>
{% } else { %}
<td colspan="2"></td>
{% } %}
- <td class="cancel">{% if (!i) { %}
- <button class="btn btn-warning">
+ <td>{% if (!i) { %}
+ <button class="btn btn-warning cancel">
<i class="icon-ban-circle icon-white"></i>
<span>Cancel</span>
</button>
@@ -119,12 +119,12 @@ <h2 id="qunit-userAgent"></h2>
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
<td colspan="2"></td>
{% } %}
- <td class="delete">
- <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}'{% } %}>
+ <td>
+ <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}'{% } %}>
<i class="icon-trash icon-white"></i>
<span>Delete</span>
</button>
- <input type="checkbox" name="delete" value="1">
+ <input type="checkbox" name="delete" value="1" class="toggle">
</td>
</tr>
{% } %}
Please sign in to comment.
Something went wrong with that request. Please try again.