bootstrap-filestyle-rails 1.1.2 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad66b3f52a0655168b4fb62cd1546e31da11cd1e
4
- data.tar.gz: 86346109edf0e55dbde44f2248c96ee6cbd7d881
3
+ metadata.gz: e04d6a4ded58685c039181d1704f42cfc9cbd29c
4
+ data.tar.gz: edb35b4dcd6c9c4bcae792868a2179ee9c04076c
5
5
  SHA512:
6
- metadata.gz: 07c311a3bf040958a696432e8c7e80673ea373170baac3f6b659d2bdcaf84df9cc14e2c94828201ad7e9042aec6d78401b4656162f5ba7c7ad1e80abe8607a08
7
- data.tar.gz: 82c04c170ceb9a1436a0251f50d68a7f7adb6b2a9a685db3b2fd2c00970d88f08ee95f18edf2a42730d952d7053705b74f98b18c770381dc2d4acb58bc4d3ef9
6
+ metadata.gz: 5f018b50874c6e64dae2fa4208e764c3acb1099ab93300aa2dc08da8ed861aeb565d74b40ee4160f7c085ddff987a7e657ddd6bea7ea4ba717ca1a61410815cf
7
+ data.tar.gz: 3a0f455768bb08f571d440ad95c424a3c3e9be6526ca0eacfaba79a5b88bf1565b9d248f7be2c7ba6f7bd56b16d0ba76782882c6815979e31ba6674aa69b44f9
@@ -1,4 +1,4 @@
1
1
  module BootstrapFilestyleRails
2
2
  # Public: String gem version number, which reflects the asset version number.
3
- VERSION = '1.1.2'
3
+ VERSION = '1.2.1'
4
4
  end
@@ -4,11 +4,13 @@
4
4
  * github: https://github.com/markusslima/bootstrap-filestyle
5
5
  *
6
6
  * Copyright (c) 2014 Markus Vinicius da Silva Lima
7
- * Version 1.1.2
7
+ * Version 1.2.1
8
8
  * Licensed under the MIT license.
9
9
  */
10
10
  (function($) {"use strict";
11
11
 
12
+ var nextId = 0;
13
+
12
14
  var Filestyle = function(element, options) {
13
15
  this.options = options;
14
16
  this.$elementFilestyle = [];
@@ -23,7 +25,7 @@
23
25
  },
24
26
 
25
27
  destroy : function() {
26
- this.$element.removeAttr('style').removeData('filestyle').val('');
28
+ this.$element.removeAttr('style').removeData('filestyle');
27
29
  this.$elementFilestyle.remove();
28
30
  },
29
31
 
@@ -78,7 +80,7 @@
78
80
  } else if (value === false) {
79
81
  if (this.options.icon) {
80
82
  this.options.icon = false;
81
- this.$elementFilestyle.find('.glyphicon').remove();
83
+ this.$elementFilestyle.find('.icon-span-filestyle').remove();
82
84
  }
83
85
  } else {
84
86
  return this.options.icon;
@@ -132,10 +134,19 @@
132
134
  }
133
135
  },
134
136
 
137
+ placeholder : function(value) {
138
+ if (value !== undefined) {
139
+ this.options.placeholder = value;
140
+ this.$elementFilestyle.find('input').attr('placeholder', value);
141
+ } else {
142
+ return this.options.placeholder;
143
+ }
144
+ },
145
+
135
146
  buttonText : function(value) {
136
147
  if (value !== undefined) {
137
148
  this.options.buttonText = value;
138
- this.$elementFilestyle.find('label span').html(this.options.buttonText);
149
+ this.$elementFilestyle.find('label .buttonText').html(this.options.buttonText);
139
150
  } else {
140
151
  return this.options.buttonText;
141
152
  }
@@ -154,8 +165,8 @@
154
165
 
155
166
  iconName : function(value) {
156
167
  if (value !== undefined) {
157
- this.$elementFilestyle.find('.glyphicon').attr({
158
- 'class' : '.glyphicon ' + this.options.iconName
168
+ this.$elementFilestyle.find('.icon-span-filestyle').attr({
169
+ 'class' : 'icon-span-filestyle ' + this.options.iconName
159
170
  });
160
171
  } else {
161
172
  return this.options.iconName;
@@ -164,7 +175,7 @@
164
175
 
165
176
  htmlIcon : function() {
166
177
  if (this.options.icon) {
167
- return '<span class="glyphicon ' + this.options.iconName + '"></span> ';
178
+ return '<span class="icon-span-filestyle ' + this.options.iconName + '"></span> ';
168
179
  } else {
169
180
  return '';
170
181
  }
@@ -172,7 +183,7 @@
172
183
 
173
184
  htmlInput : function() {
174
185
  if (this.options.input) {
175
- return '<input type="text" class="form-control ' + (this.options.size == 'nr' ? '' : 'input-' + this.options.size) + '" disabled> ';
186
+ return '<input type="text" class="form-control ' + (this.options.size == 'nr' ? '' : 'input-' + this.options.size) + '" placeholder="'+ this.options.placeholder +'" disabled> ';
176
187
  } else {
177
188
  return '';
178
189
  }
@@ -212,26 +223,27 @@
212
223
  $label;
213
224
 
214
225
  if (id === '' || !id) {
215
- id = 'filestyle-' + $('.bootstrap-filestyle').length;
226
+ id = 'filestyle-' + nextId;
216
227
  _self.$element.attr({
217
228
  'id' : id
218
229
  });
230
+ nextId++;
219
231
  }
220
232
 
221
233
  btn = '<span class="group-span-filestyle ' + (_self.options.input ? 'input-group-btn' : '') + '">' +
222
- '<label for="' + id + '" class="btn ' + _self.options.buttonName + ' ' +
223
- (_self.options.size == 'nr' ? '' : 'btn-' + _self.options.size) + '" ' +
224
- (_self.options.disabled ? 'disabled="true"' : '') + '>' +
225
- _self.htmlIcon() + _self.options.buttonText +
226
- '</label>' +
227
- '</span>';
234
+ '<label for="' + id + '" class="btn ' + _self.options.buttonName + ' ' +
235
+ (_self.options.size == 'nr' ? '' : 'btn-' + _self.options.size) + '" ' +
236
+ (_self.options.disabled ? 'disabled="true"' : '') + '>' +
237
+ _self.htmlIcon() + '<span class="buttonText">' + _self.options.buttonText + '</span>' +
238
+ '</label>' +
239
+ '</span>';
228
240
 
229
241
  html = _self.options.buttonBefore ? btn + _self.htmlInput() : _self.htmlInput() + btn;
230
242
 
231
243
  _self.$elementFilestyle = $('<div class="bootstrap-filestyle input-group">' + html + '</div>');
232
244
  _self.$elementFilestyle.find('.group-span-filestyle').attr('tabindex', "0").keypress(function(e) {
233
- if (e.keyCode === 13 || e.charCode === 32) {
234
- _self.$elementFilestyle.find('label').click();
245
+ if (e.keyCode === 13 || e.charCode === 32) {
246
+ _self.$elementFilestyle.find('label').click();
235
247
  return false;
236
248
  }
237
249
  });
@@ -301,14 +313,15 @@
301
313
 
302
314
  $.fn.filestyle.defaults = {
303
315
  'buttonText' : 'Choose file',
304
- 'iconName' : 'glyphicon-folder-open',
316
+ 'iconName' : 'glyphicon glyphicon-folder-open',
305
317
  'buttonName' : 'btn-default',
306
318
  'size' : 'nr',
307
319
  'input' : true,
308
320
  'badge' : true,
309
321
  'icon' : true,
310
322
  'buttonBefore' : false,
311
- 'disabled' : false
323
+ 'disabled' : false,
324
+ 'placeholder': ''
312
325
  };
313
326
 
314
327
  $.fn.filestyle.noConflict = function() {
@@ -316,7 +329,6 @@
316
329
  return this;
317
330
  };
318
331
 
319
- // Data attributes register
320
332
  $(function() {
321
333
  $('.filestyle').each(function() {
322
334
  var $this = $(this), options = {
@@ -329,7 +341,8 @@
329
341
  'buttonText' : $this.attr('data-buttonText'),
330
342
  'buttonName' : $this.attr('data-buttonName'),
331
343
  'iconName' : $this.attr('data-iconName'),
332
- 'badge' : $this.attr('data-badge') === 'false' ? false : true
344
+ 'badge' : $this.attr('data-badge') === 'false' ? false : true,
345
+ 'placeholder': $this.attr('data-placeholder')
333
346
  };
334
347
 
335
348
  $this.filestyle(options);
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.1.2
4
+ version: 1.2.1
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-10-01 00:00:00.000000000 Z
11
+ date: 2016-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  version: '0'
79
79
  requirements: []
80
80
  rubyforge_project:
81
- rubygems_version: 2.2.2
81
+ rubygems_version: 2.5.1
82
82
  signing_key:
83
83
  specification_version: 4
84
84
  summary: Bootstrap Filestyle for the asset pipeline