appjs-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.
- data/README.md +25 -0
- data/app/assets/javascripts/app.js +53 -0
- data/lib/appjs/rails/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -82,6 +82,31 @@ Now all Array object has got functions
|
|
82
82
|
['a', 'b'].last(); // 'b'
|
83
83
|
|
84
84
|
```
|
85
|
+
|
86
|
+
### For Bootstrap 3
|
87
|
+
|
88
|
+
Adding a counter that counts how many characters left to use
|
89
|
+
Use requires the following steps:
|
90
|
+
|
91
|
+
* You must add initializer into script
|
92
|
+
|
93
|
+
```javascript
|
94
|
+
app._bootstrap.inputDownCounter();
|
95
|
+
```
|
96
|
+
|
97
|
+
* Adding class 'js-input-down-counter-x' (where x is a natural number) into an input tag.
|
98
|
+
|
99
|
+
For Example
|
100
|
+
|
101
|
+
```html
|
102
|
+
<div class="form-group">
|
103
|
+
<label class="col-lg-3 control-label">Name</label>
|
104
|
+
<div class="controls">
|
105
|
+
<input type='text' class='form-control js-input-down-counter-20" value='Example'>
|
106
|
+
</div>
|
107
|
+
</div>
|
108
|
+
```
|
109
|
+
|
85
110
|
# License
|
86
111
|
|
87
112
|
appjs-rails uses the MIT license. Please check the [LICENSE][] file for more details.
|
@@ -81,6 +81,59 @@ var app = (function() {
|
|
81
81
|
},
|
82
82
|
_uuid: function(){
|
83
83
|
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
|
84
|
+
},
|
85
|
+
_bootstrap: {
|
86
|
+
inputDownCounter: function(){
|
87
|
+
jInputs = $('[class*="js-input-down-counter-"]');
|
88
|
+
|
89
|
+
for(var i=0; i< jInputs.length; i++){
|
90
|
+
if (!$(jInputs[i]).hasClass('js-used-input-down-counter')) {
|
91
|
+
var maxNameLength = undefined;
|
92
|
+
|
93
|
+
$(jInputs[i]).attr('class').split(' ').map(function(item){
|
94
|
+
if(!item.indexOf('js-input-down-counter-')){
|
95
|
+
maxNameLength = item.split('-').last();
|
96
|
+
}
|
97
|
+
})
|
98
|
+
|
99
|
+
jInputGroup = $('<div class="input-group"></div>');
|
100
|
+
jInputGroup.insertBefore($(jInputs[i]));
|
101
|
+
jInputGroup.append($(jInputs[i]));
|
102
|
+
|
103
|
+
$('<span class="text-muted input-group-addon add-on" style="background: #fff">0</span>').insertAfter($(jInputs[i]))
|
104
|
+
var usedChar = maxNameLength - parseInt($(jInputs[i]).val().length);
|
105
|
+
$(jInputs[i]).next().text(usedChar);
|
106
|
+
$(jInputs[i]).bind('keyup', function(){
|
107
|
+
var usedChar = maxNameLength - parseInt($(this).val().length);
|
108
|
+
if (usedChar >= 0) {
|
109
|
+
$(this).next().text(usedChar);
|
110
|
+
} else {
|
111
|
+
$(this).next().text(0);
|
112
|
+
$(this).val($(this).val().substr(0, maxNameLength));
|
113
|
+
}
|
114
|
+
})
|
115
|
+
$(jInputs[i]).addClass('js-used-input-down-counter');
|
116
|
+
}
|
117
|
+
}
|
118
|
+
},
|
119
|
+
showIcons: function(){
|
120
|
+
styles = document.styleSheets;
|
121
|
+
result = []
|
122
|
+
|
123
|
+
for (i=0; i< styles.length; i++) {
|
124
|
+
style = styles[i];
|
125
|
+
for(j=0; j< style.cssRules.length; j++) {
|
126
|
+
if(style.cssRules[j].cssText.match('glyphicon-.*::')) {
|
127
|
+
result.push(style.cssRules[j].cssText.match("(glyphicon-.*)::.*")[1])
|
128
|
+
}
|
129
|
+
}
|
130
|
+
}
|
131
|
+
|
132
|
+
for(i=0; i<result.length; i++){
|
133
|
+
$('#page-wrapper').append("<div class='col-lg-3'><span style='font-size: 30px' class='glyphicon " + result[i] + "'></span> " + result[i] + "</div>")
|
134
|
+
}
|
135
|
+
}
|
84
136
|
}
|
137
|
+
|
85
138
|
}
|
86
139
|
})();
|
data/lib/appjs/rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appjs-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-03-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|