diff --git a/js/bootstrap-fileupload.js b/js/bootstrap-fileupload.js index d25f9153..abb9fc69 100644 --- a/js/bootstrap-fileupload.js +++ b/js/bootstrap-fileupload.js @@ -59,7 +59,12 @@ change: function(e, invoked) { var file = e.target.files !== undefined ? e.target.files[0] : (e.target.value ? { name: e.target.value.replace(/^.+\\/, '') } : null) - if (!file || invoked === 'clear') return + if (invoked === 'clear') return + + if (!file) { + this.clear() + return + } this.$hidden.val('') this.$hidden.attr('name', '') @@ -91,9 +96,10 @@ this.$preview.html('') this.$element.addClass('fileupload-new').removeClass('fileupload-exists') - this.$input.trigger('change', [ 'clear' ]) - - e.preventDefault() + if (e) { + this.$input.trigger('change', [ 'clear' ]) + e.preventDefault() + } }, trigger: function(e) { diff --git a/less/jasny/fileupload.less b/less/jasny/fileupload.less index e9e60453..9e41ad81 100644 --- a/less/jasny/fileupload.less +++ b/less/jasny/fileupload.less @@ -64,7 +64,43 @@ .border-radius(0); .box-shadow(none); } - .fileupload-new.thumbnail-borderless .thumbnail { border: 1px solid #ddd; } + +.control-group.warning .fileupload { + .uneditable-input { + color: #a47e3c; + border-color: #a47e3c; + } + .fileupload-preview { + color: #a47e3c; + } + .thumbnail { + border-color: #a47e3c; + } +} +.control-group.error .fileupload { + .uneditable-input { + color: #b94a48; + border-color: #b94a48; + } + .fileupload-preview { + color: #b94a48; + } + .thumbnail { + border-color: #b94a48; + } +} +.control-group.success .fileupload { + .uneditable-input { + color: #468847; + border-color: #468847; + } + .fileupload-preview { + color: #468847; + } + .thumbnail { + border-color: #468847; + } +} \ No newline at end of file