bootstrap-filestyle-rails 1.0.4 → 1.0.5
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/lib/bootstrap-filestyle-rails/version.rb +1 -1
- data/vendor/assets/javascripts/bootstrap-filestyle.js +136 -41
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7deb2e392fe88fb72770777d196ea992176e89ef
|
4
|
+
data.tar.gz: b06f07c017e17360236d3e37bc29e484aa1adce0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2d9559f22ad91a0b7a267b462ee21f67120b4d724dc2f30aa60c7f1b0359967250cbcad351b81e2119f9d2316752420726ce3a95274079f8086ab1bf8605db2
|
7
|
+
data.tar.gz: 0c5ee89516713146d799519e3c48648a68b2cec3f6fd2d3f71ef6f720277bd904c6678b2f30c443618df425c5d84ea831f8630b8c519b3264666d80349511882
|
@@ -2,8 +2,8 @@
|
|
2
2
|
* bootstrap-filestyle
|
3
3
|
* http://dev.tudosobreweb.com.br/bootstrap-filestyle/
|
4
4
|
*
|
5
|
-
* Copyright (c)
|
6
|
-
* Version 1.0.
|
5
|
+
* Copyright (c) 2014 Markus Vinicius da Silva Lima
|
6
|
+
* Version 1.0.5
|
7
7
|
* Licensed under the MIT license.
|
8
8
|
*/
|
9
9
|
(function ($) {
|
@@ -29,6 +29,50 @@
|
|
29
29
|
this.$elementFilestyle.remove();
|
30
30
|
},
|
31
31
|
|
32
|
+
disabled: function (value) {
|
33
|
+
if (value === true) {
|
34
|
+
if (!this.options.disabled) {
|
35
|
+
this.$element
|
36
|
+
.attr('disabled', 'true');
|
37
|
+
this.$elementFilestyle.find('label').attr('disabled', 'true');
|
38
|
+
this.options.disabled = true;
|
39
|
+
}
|
40
|
+
} else if (value === false) {
|
41
|
+
if (this.options.disabled) {
|
42
|
+
this.$element
|
43
|
+
.removeAttr('disabled');
|
44
|
+
this.$elementFilestyle.find('label').removeAttr('disabled');
|
45
|
+
this.options.disabled = false;
|
46
|
+
}
|
47
|
+
} else {
|
48
|
+
return this.options.disabled;
|
49
|
+
}
|
50
|
+
},
|
51
|
+
|
52
|
+
buttonBefore: function (value) {
|
53
|
+
if (value === true) {
|
54
|
+
if (!this.options.buttonBefore) {
|
55
|
+
this.options.buttonBefore = true;
|
56
|
+
if (this.options.input) {
|
57
|
+
this.$elementFilestyle.remove();
|
58
|
+
this.constructor();
|
59
|
+
this.pushNameFiles();
|
60
|
+
}
|
61
|
+
}
|
62
|
+
} else if (value === false) {
|
63
|
+
if (this.options.buttonBefore) {
|
64
|
+
this.options.buttonBefore = false;
|
65
|
+
if (this.options.input) {
|
66
|
+
this.$elementFilestyle.remove();
|
67
|
+
this.constructor();
|
68
|
+
this.pushNameFiles();
|
69
|
+
}
|
70
|
+
}
|
71
|
+
} else {
|
72
|
+
return this.options.buttonBefore;
|
73
|
+
}
|
74
|
+
},
|
75
|
+
|
32
76
|
icon: function (value) {
|
33
77
|
if (value === true) {
|
34
78
|
if (!this.options.icon) {
|
@@ -49,7 +93,14 @@
|
|
49
93
|
if (value === true) {
|
50
94
|
if (!this.options.input) {
|
51
95
|
this.options.input = true;
|
52
|
-
|
96
|
+
|
97
|
+
if (this.options.buttonBefore) {
|
98
|
+
this.$elementFilestyle.append(this.htmlInput());
|
99
|
+
} else {
|
100
|
+
this.$elementFilestyle.prepend(this.htmlInput());
|
101
|
+
}
|
102
|
+
|
103
|
+
this.$elementFilestyle.find('.quant-files-filestyle').remove();
|
53
104
|
|
54
105
|
var content = '',
|
55
106
|
files = [];
|
@@ -70,6 +121,21 @@
|
|
70
121
|
if (this.options.input) {
|
71
122
|
this.options.input = false;
|
72
123
|
this.$elementFilestyle.find(':text').remove();
|
124
|
+
var files = [];
|
125
|
+
if (this.$element[0].files === undefined) {
|
126
|
+
files[0] = {'name': this.$element[0].value};
|
127
|
+
} else {
|
128
|
+
files = this.$element[0].files;
|
129
|
+
}
|
130
|
+
if (files.length > 0) {
|
131
|
+
var style;
|
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>');
|
138
|
+
}
|
73
139
|
}
|
74
140
|
} else {
|
75
141
|
return this.options.input;
|
@@ -142,6 +208,27 @@
|
|
142
208
|
}
|
143
209
|
},
|
144
210
|
|
211
|
+
// puts the name of the input files
|
212
|
+
pushNameFiles: function () {
|
213
|
+
var content = '',
|
214
|
+
files = [];
|
215
|
+
if (this.$element[0].files === undefined) {
|
216
|
+
files[0] = {'name': this.$element.value};
|
217
|
+
} else {
|
218
|
+
files = this.$element[0].files;
|
219
|
+
}
|
220
|
+
|
221
|
+
for (var i = 0; i < files.length; i++) {
|
222
|
+
content += files[i].name.split("\\").pop() + ', ';
|
223
|
+
}
|
224
|
+
|
225
|
+
if (content !== '') {
|
226
|
+
this.$elementFilestyle.find(':text').val(content.replace(/\, $/g, ''));
|
227
|
+
} else {
|
228
|
+
this.$elementFilestyle.find(':text').val('');
|
229
|
+
}
|
230
|
+
},
|
231
|
+
|
145
232
|
constructor: function () {
|
146
233
|
var _self = this,
|
147
234
|
html = '',
|
@@ -153,38 +240,21 @@
|
|
153
240
|
this.$element.attr({'id': id});
|
154
241
|
}
|
155
242
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
if(this.options.buttonBefore)
|
163
|
-
{
|
164
|
-
html =
|
165
|
-
buttonContainerOpen+
|
166
|
-
'<label for="'+id+'" class="'+this.options.classButton+'">'+
|
167
|
-
this.htmlIcon()+
|
168
|
-
'<span>'+this.options.buttonText+'</span>'+
|
169
|
-
'</label>'+
|
170
|
-
buttonContainerClose+
|
171
|
-
inputContainerOpen+
|
172
|
-
this.htmlInput()+
|
173
|
-
inputContainerClose;
|
243
|
+
if(this.options.buttonBefore) {
|
244
|
+
html = '<label for="'+id+'" style="margin-right: 4px;" class="'+this.options.classButton+'" '+(this.options.disabled?'disabled="true"':'')+'>'+
|
245
|
+
this.htmlIcon()+
|
246
|
+
'<span>'+this.options.buttonText+'</span>'+
|
247
|
+
'</label>'+
|
248
|
+
this.htmlInput();
|
174
249
|
} else {
|
175
|
-
html =
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
'<label for="'+id+'" class="'+this.options.classButton+'">'+
|
181
|
-
this.htmlIcon()+
|
182
|
-
'<span>'+this.options.buttonText+'</span>'+
|
183
|
-
'</label>'+
|
184
|
-
buttonContainerClose;
|
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>';
|
185
255
|
}
|
186
256
|
|
187
|
-
this.$elementFilestyle = $('<div class="
|
257
|
+
this.$elementFilestyle = $('<div class="bootstrap-filestyle" style="display: inline-block;">'+html+'</div>');
|
188
258
|
|
189
259
|
var $label = this.$elementFilestyle.find('label');
|
190
260
|
var $labelFocusableContainer = $label.parent();
|
@@ -203,6 +273,10 @@
|
|
203
273
|
.attr('tabindex', "-1")
|
204
274
|
.after(this.$elementFilestyle);
|
205
275
|
|
276
|
+
if (this.options.disabled) {
|
277
|
+
this.$element.attr('disabled', 'true');
|
278
|
+
}
|
279
|
+
|
206
280
|
// Getting input file value
|
207
281
|
this.$element.change(function () {
|
208
282
|
var content = '';
|
@@ -219,7 +293,25 @@
|
|
219
293
|
if (content !== '') {
|
220
294
|
_self.$elementFilestyle.find(':text').val(content.replace(/\, $/g, ''));
|
221
295
|
} else {
|
222
|
-
|
296
|
+
_self.$elementFilestyle.find(':text').val('');
|
297
|
+
}
|
298
|
+
|
299
|
+
if (_self.options.input == false) {
|
300
|
+
var style;
|
301
|
+
if (_self.options.classButton.search(/btn-inverse|btn-primary|btn-danger|btn-warning|btn-success/i) !== -1) {
|
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>');
|
308
|
+
} else if (files.length == 0) {
|
309
|
+
_self.$elementFilestyle.find('.quant-files-filestyle').remove();
|
310
|
+
} else {
|
311
|
+
_self.$elementFilestyle.find('.quant-files-filestyle').html(files.length);
|
312
|
+
}
|
313
|
+
} else {
|
314
|
+
_self.$elementFilestyle.find('.quant-files-filestyle').remove();
|
223
315
|
}
|
224
316
|
});
|
225
317
|
|
@@ -267,13 +359,11 @@
|
|
267
359
|
'input': true,
|
268
360
|
'icon': true,
|
269
361
|
'buttonBefore': false,
|
362
|
+
'disabled': false,
|
270
363
|
|
271
|
-
'containerClass': 'form-group', // bootstrap-filestyle
|
272
|
-
'classButtonContainerClass': '',
|
273
364
|
'classButton': 'btn btn-default',
|
274
|
-
'
|
275
|
-
'
|
276
|
-
'classIcon': 'glyphicon glyphicon-folder-open'
|
365
|
+
'classInput': 'input-large',
|
366
|
+
'classIcon': 'icon-folder-open'
|
277
367
|
};
|
278
368
|
|
279
369
|
$.fn.filestyle.noConflict = function () {
|
@@ -286,14 +376,19 @@
|
|
286
376
|
$('.filestyle').each(function () {
|
287
377
|
var $this = $(this),
|
288
378
|
options = {
|
289
|
-
|
379
|
+
|
290
380
|
'input': $this.attr('data-input') === 'false' ? false : true,
|
291
381
|
'icon': $this.attr('data-icon') === 'false' ? false : true,
|
382
|
+
'buttonBefore': $this.attr('data-buttonBefore') === 'true' ? true : false,
|
383
|
+
'disabled': $this.attr('data-disabled') === 'true' ? true : false,
|
384
|
+
|
385
|
+
'buttonText': $this.attr('data-buttonText'),
|
292
386
|
'classButton': $this.attr('data-classButton'),
|
293
387
|
'classInput': $this.attr('data-classInput'),
|
294
|
-
'classIcon': $this.attr('data-classIcon')
|
388
|
+
'classIcon': $this.attr('data-classIcon'),
|
389
|
+
'disabled': $this.attr('data-disabled') === 'true' ? true : false,
|
295
390
|
};
|
296
|
-
|
391
|
+
|
297
392
|
$this.filestyle(options);
|
298
393
|
});
|
299
394
|
});
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap-filestyle-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mauricio Pasquier Juan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|