Skip to content

Commit 2989a8b

Browse files
author
Samuel Piquet
committed
Added preventDefault on click
1 parent eb7a9a1 commit 2989a8b

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

js/bootstrap-uploader.js

+16-15
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
(function( $ ){
2-
2+
33
"use strict";
4-
4+
55
var Uploader = function(el, options) {
66
this.$el = $(el);
77
this.options = $.extend({}, $.fn.uploader.defaults, options);
88
};
9-
9+
1010
Uploader.prototype = {
11-
11+
1212
constructor: Uploader,
13-
13+
1414
applyTheme: function() {
1515
if (!this.$overlay) {
1616
this.$el.width(0).height(0).css({
@@ -19,7 +19,7 @@
1919
'margin': 0,
2020
'padding': 0
2121
});
22-
22+
2323
this.$overlay = $('<div class="input-prepend"/>').insertAfter(this.$el);
2424

2525
this.$button = $('<button class="btn"></button>').appendTo(this.$overlay);
@@ -30,26 +30,27 @@
3030
//this.$overlay.append('<button class="btn"><i class="icon-upload"></i></button>');
3131
this.$input = $('<input type="text"/>').appendTo(this.$overlay);
3232
this.$input.val(this.options.inputText);
33-
33+
3434
this.$overlay.on('click', $.proxy(this._on_click, this));
3535
this.$el.on('change', $.proxy(this._on_change, this));
36-
36+
3737
this.$el.trigger('themed');
3838
}
3939
this.$overlay.offset(this.$el.offset());
4040
},
41-
41+
4242
_on_click: function(e) {
43+
e.preventDefault();
4344
this.$el.click();
4445
},
45-
46+
4647
_on_change: function(e) {
4748
var filename = this.$el.val().replace(/^(.*)(\\|\/)/g, '');
4849
this.$overlay.find('input').val(filename);
4950
}
50-
51+
5152
};
52-
53+
5354
$.fn.uploader = function(option) {
5455
return this.each(function(){
5556
var $this = $(this)
@@ -59,15 +60,15 @@
5960
data.applyTheme();
6061
});
6162
};
62-
63+
6364
$.fn.uploader.defaults = {
6465
inputText: 'Choose a file...',
6566
buttonText: '',
6667
icon: 'file'
6768
};
68-
69+
6970
$.fn.uploader.Constructor = Uploader;
70-
71+
7172
$(function() {
7273
$(':file').each(function(i, el) {
7374
var $this = $(this), options = {};

0 commit comments

Comments
 (0)