bootstrap-filestyle-rails 1.0.6 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/bootstrap-filestyle-rails/version.rb +1 -1
- data/vendor/assets/javascripts/bootstrap-filestyle.js +60 -81
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7825381a68052a8127594da8d788f6598d01012
|
4
|
+
data.tar.gz: 14eba8aacd89565768ee247b27f8e8124fa99ae8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1299e95b30064d68ca3a30f741a2690b45fcdd0fec55fa8316f4c8ec9d3b4c54d8c0fbc6c92da42cd5de17d938086c2bb5bea72aeaf904b36ff8ea993281bdc9
|
7
|
+
data.tar.gz: fe1d1ba8b7c0f518f456f85b3298aaefd2721c847c8490878c629890715ac4ed8ab9c70b58d38a2cad99dbb4967a22bc99f5bd078531ffa2574eed7d17ac84d5
|
data/README.md
CHANGED
@@ -26,9 +26,9 @@ Just require it in your `application.js`:
|
|
26
26
|
|
27
27
|
And initialize your file input somehow:
|
28
28
|
|
29
|
-
$(":file").filestyle(
|
29
|
+
$(":file").filestyle({
|
30
30
|
input: false
|
31
|
-
)
|
31
|
+
})
|
32
32
|
|
33
33
|
You can check more configuration options in the [bootstrap-filestyle][] site.
|
34
34
|
|
@@ -1,9 +1,10 @@
|
|
1
1
|
/*
|
2
2
|
* bootstrap-filestyle
|
3
|
-
* http://dev.tudosobreweb.com.br/bootstrap-filestyle/
|
3
|
+
* doc: http://dev.tudosobreweb.com.br/bootstrap-filestyle/
|
4
|
+
* github: https://github.com/markusslima/bootstrap-filestyle
|
4
5
|
*
|
5
6
|
* Copyright (c) 2014 Markus Vinicius da Silva Lima
|
6
|
-
* Version 1.0
|
7
|
+
* Version 1.1.0
|
7
8
|
* Licensed under the MIT license.
|
8
9
|
*/
|
9
10
|
(function ($) {
|
@@ -82,7 +83,7 @@
|
|
82
83
|
} else if (value === false) {
|
83
84
|
if (this.options.icon) {
|
84
85
|
this.options.icon = false;
|
85
|
-
this.$elementFilestyle.find('
|
86
|
+
this.$elementFilestyle.find('.glyphicon').remove();
|
86
87
|
}
|
87
88
|
} else {
|
88
89
|
return this.options.icon;
|
@@ -100,7 +101,7 @@
|
|
100
101
|
this.$elementFilestyle.prepend(this.htmlInput());
|
101
102
|
}
|
102
103
|
|
103
|
-
this.$elementFilestyle.find('.
|
104
|
+
this.$elementFilestyle.find('.badge').remove();
|
104
105
|
|
105
106
|
var content = '',
|
106
107
|
files = [];
|
@@ -116,6 +117,8 @@
|
|
116
117
|
if (content !== '') {
|
117
118
|
this.$elementFilestyle.find(':text').val(content.replace(/\, $/g, ''));
|
118
119
|
}
|
120
|
+
|
121
|
+
this.$elementFilestyle.find('.group-span-filestyle').addClass('input-group-btn');
|
119
122
|
}
|
120
123
|
} else if (value === false) {
|
121
124
|
if (this.options.input) {
|
@@ -128,73 +131,60 @@
|
|
128
131
|
files = this.$element[0].files;
|
129
132
|
}
|
130
133
|
if (files.length > 0) {
|
131
|
-
|
132
|
-
if (this.options.classButton.search(/btn-inverse|btn-primary|btn-danger|btn-warning|btn-success/i) !== -1) {
|
133
|
-
style = 'style="background-color: #fff !important; color: 000;"';
|
134
|
-
} else {
|
135
|
-
style = 'style="background-color: #000 !important; color: fff;"';
|
136
|
-
}
|
137
|
-
this.$elementFilestyle.find('label').append(' <span '+style+' class="quant-files-filestyle badge">'+files.length+'</span>');
|
134
|
+
this.$elementFilestyle.find('label').append(' <span class="badge">'+files.length+'</span>');
|
138
135
|
}
|
136
|
+
this.$elementFilestyle.find('.group-span-filestyle').removeClass('input-group-btn');
|
139
137
|
}
|
140
138
|
} else {
|
141
139
|
return this.options.input;
|
142
140
|
}
|
143
141
|
},
|
144
142
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
143
|
+
size: function (value) {
|
144
|
+
if (value !== undefined) {
|
145
|
+
var btn = this.$elementFilestyle.find('label'),
|
146
|
+
input = this.$elementFilestyle.find('input');
|
147
|
+
|
148
|
+
btn.removeClass('btn-lg btn-sm');
|
149
|
+
input.removeClass('input-lg input-sm');
|
150
|
+
if (value != 'nr') {
|
151
|
+
btn.addClass('btn-'+value);
|
152
|
+
input.addClass('input-'+value);
|
153
|
+
}
|
149
154
|
} else {
|
150
|
-
return this.options.
|
155
|
+
return this.options.size;
|
151
156
|
}
|
152
157
|
},
|
153
158
|
|
154
|
-
|
159
|
+
buttonText: function (value) {
|
155
160
|
if (value !== undefined) {
|
156
|
-
this.options.
|
157
|
-
this.$elementFilestyle.find('label').
|
158
|
-
if (this.options.classButton.search(/btn-inverse|btn-primary|btn-danger|btn-warning|btn-success/i) !== -1) {
|
159
|
-
this.$elementFilestyle.find('label i').addClass('icon-white');
|
160
|
-
} else {
|
161
|
-
this.$elementFilestyle.find('label i').removeClass('icon-white');
|
162
|
-
}
|
161
|
+
this.options.buttonText = value;
|
162
|
+
this.$elementFilestyle.find('label span').html(this.options.buttonText);
|
163
163
|
} else {
|
164
|
-
return this.options.
|
164
|
+
return this.options.buttonText;
|
165
165
|
}
|
166
166
|
},
|
167
167
|
|
168
|
-
|
168
|
+
buttonName: function (value) {
|
169
169
|
if (value !== undefined) {
|
170
|
-
this.options.
|
171
|
-
|
172
|
-
this.$elementFilestyle.find('label').find('i').attr({'class': 'icon-white '+this.options.classIcon});
|
173
|
-
} else {
|
174
|
-
this.$elementFilestyle.find('label').find('i').attr({'class': this.options.classIcon});
|
175
|
-
}
|
170
|
+
this.options.buttonName = value;
|
171
|
+
this.$elementFilestyle.find('label').attr({'class': 'btn '+this.options.buttonName});
|
176
172
|
} else {
|
177
|
-
return this.options.
|
173
|
+
return this.options.buttonName;
|
178
174
|
}
|
179
175
|
},
|
180
176
|
|
181
|
-
|
177
|
+
iconName: function (value) {
|
182
178
|
if (value !== undefined) {
|
183
|
-
this.
|
184
|
-
this.$elementFilestyle.find(':text').addClass(this.options.classInput);
|
179
|
+
this.$elementFilestyle.find('.glyphicon').attr({'class': '.glyphicon ' + this.options.iconName});
|
185
180
|
} else {
|
186
|
-
return this.options.
|
181
|
+
return this.options.iconName;
|
187
182
|
}
|
188
183
|
},
|
189
184
|
|
190
185
|
htmlIcon: function () {
|
191
186
|
if (this.options.icon) {
|
192
|
-
|
193
|
-
if (this.options.classButton.search(/btn-inverse|btn-primary|btn-danger|btn-warning|btn-success/i) !== -1) {
|
194
|
-
colorIcon = ' icon-white ';
|
195
|
-
}
|
196
|
-
|
197
|
-
return '<i class="'+colorIcon+this.options.classIcon+'"></i> ';
|
187
|
+
return '<span class="glyphicon '+this.options.iconName+'"></span> ';
|
198
188
|
} else {
|
199
189
|
return '';
|
200
190
|
}
|
@@ -202,7 +192,7 @@
|
|
202
192
|
|
203
193
|
htmlInput: function () {
|
204
194
|
if (this.options.input) {
|
205
|
-
return '<input type="text" class="'+this.options.
|
195
|
+
return '<input type="text" class="form-control '+(this.options.size=='nr'?'':'input-'+this.options.size)+'" disabled> ';
|
206
196
|
} else {
|
207
197
|
return '';
|
208
198
|
}
|
@@ -233,31 +223,28 @@
|
|
233
223
|
var _self = this,
|
234
224
|
html = '',
|
235
225
|
id = this.$element.attr('id'),
|
236
|
-
files = []
|
226
|
+
files = [],
|
227
|
+
btn = '',
|
228
|
+
$label,
|
229
|
+
$labelFocusableContainer;
|
237
230
|
|
238
231
|
if (id === '' || !id) {
|
239
232
|
id = 'filestyle-'+$('.bootstrap-filestyle').length;
|
240
233
|
this.$element.attr({'id': id});
|
241
234
|
}
|
242
235
|
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
html = this.htmlInput()+
|
251
|
-
'<label for="'+id+'" class="'+this.options.classButton+'" '+(this.options.disabled?'disabled="true"':'')+'> '+
|
252
|
-
this.htmlIcon()+
|
253
|
-
'<span>'+this.options.buttonText+'</span>'+
|
254
|
-
'</label>';
|
255
|
-
}
|
236
|
+
btn = '<span class="group-span-filestyle '+(this.options.input ? 'input-group-btn' : '') +'">'+
|
237
|
+
'<label for="'+id+'" class="btn '+this.options.buttonName+' '+(this.options.size=='nr'?'':'btn-'+this.options.size)+'" '+(this.options.disabled?'disabled="true"':'')+'>'+
|
238
|
+
this.htmlIcon()+this.options.buttonText+
|
239
|
+
'</label>'+
|
240
|
+
'</span>';
|
241
|
+
|
242
|
+
html = this.options.buttonBefore ? btn+this.htmlInput() : this.htmlInput()+btn;
|
256
243
|
|
257
|
-
this.$elementFilestyle = $('<div class="bootstrap-filestyle
|
244
|
+
this.$elementFilestyle = $('<div class="bootstrap-filestyle input-group">'+html+'</div>');
|
258
245
|
|
259
|
-
|
260
|
-
|
246
|
+
$label = this.$elementFilestyle.find('label');
|
247
|
+
$labelFocusableContainer = $label.parent();
|
261
248
|
|
262
249
|
$labelFocusableContainer
|
263
250
|
.attr('tabindex', "0")
|
@@ -297,21 +284,15 @@
|
|
297
284
|
}
|
298
285
|
|
299
286
|
if (_self.options.input == false) {
|
300
|
-
|
301
|
-
|
302
|
-
style = 'style="background-color: #fff !important; color: #000;"';
|
303
|
-
} else {
|
304
|
-
style = 'style="background-color: #000 !important; color: #fff;"';
|
305
|
-
}
|
306
|
-
if (_self.$elementFilestyle.find('.quant-files-filestyle').length == 0) {
|
307
|
-
_self.$elementFilestyle.find('label').append(' <span '+style+' class="quant-files-filestyle badge">'+files.length+'</span>');
|
287
|
+
if (_self.$elementFilestyle.find('.badge').length == 0) {
|
288
|
+
_self.$elementFilestyle.find('label').append(' <span class="badge">'+files.length+'</span>');
|
308
289
|
} else if (files.length == 0) {
|
309
|
-
_self.$elementFilestyle.find('.
|
290
|
+
_self.$elementFilestyle.find('.badge').remove();
|
310
291
|
} else {
|
311
|
-
_self.$elementFilestyle.find('.
|
292
|
+
_self.$elementFilestyle.find('.badge').html(files.length);
|
312
293
|
}
|
313
294
|
} else {
|
314
|
-
_self.$elementFilestyle.find('.
|
295
|
+
_self.$elementFilestyle.find('.badge').remove();
|
315
296
|
}
|
316
297
|
});
|
317
298
|
|
@@ -356,14 +337,13 @@
|
|
356
337
|
|
357
338
|
$.fn.filestyle.defaults = {
|
358
339
|
'buttonText': 'Choose file',
|
340
|
+
'iconName': 'glyphicon-folder-open',
|
341
|
+
'buttonName': 'btn-default',
|
342
|
+
'size': 'nr',
|
359
343
|
'input': true,
|
360
344
|
'icon': true,
|
361
345
|
'buttonBefore': false,
|
362
|
-
'disabled': false
|
363
|
-
|
364
|
-
'classButton': 'btn btn-default',
|
365
|
-
'classInput': 'input-large',
|
366
|
-
'classIcon': 'icon-folder-open'
|
346
|
+
'disabled': false
|
367
347
|
};
|
368
348
|
|
369
349
|
$.fn.filestyle.noConflict = function () {
|
@@ -381,11 +361,10 @@
|
|
381
361
|
'icon': $this.attr('data-icon') === 'false' ? false : true,
|
382
362
|
'buttonBefore': $this.attr('data-buttonBefore') === 'true' ? true : false,
|
383
363
|
'disabled': $this.attr('data-disabled') === 'true' ? true : false,
|
384
|
-
|
364
|
+
'size': $this.attr('data-size'),
|
385
365
|
'buttonText': $this.attr('data-buttonText'),
|
386
|
-
'
|
387
|
-
'
|
388
|
-
'classIcon': $this.attr('data-classIcon')
|
366
|
+
'buttonName': $this.attr('data-buttonName'),
|
367
|
+
'iconName': $this.attr('data-iconName')
|
389
368
|
};
|
390
369
|
|
391
370
|
$this.filestyle(options);
|