rails-fort 0.1.5 → 0.1.6

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: 08b7b0c97e01bf4cbec192e7a1af23030317ccb0
4
- data.tar.gz: c02deb8fe42a71bbf114af126027c8907ac9a68b
3
+ metadata.gz: 9924c8ff5baded75fe1dabe106d84dbfd64069dc
4
+ data.tar.gz: cf9b5c601665bd00972247bb6fd5746cf0b56790
5
5
  SHA512:
6
- metadata.gz: ae70e99e7537819869c0bff39d097ef2fa500dd0ec2dacc1c7a01c06ae1ee054ee87dbdcf110afbede9e2f2989c9bd2f33270ebec333aadb58dcf2801baa523d
7
- data.tar.gz: e225f341e2f4d99089a6d01f57f01907c74111e3f1dab6e4c7c5f8f178f55b963c1b9c367c5a0f798668c7a35d6ad3fa5539a64fdad9ab860e5c392d6f3de9db
6
+ metadata.gz: 84438ba3ea9a63dcde8e88787e3f974a9110b8c78a6bfeb9a9ae82ec0e1df57adc71e48a5ce81d430a61d195efbcfd5bd62c2ccc61c9eca4efe7cdb167f9e7d8
7
+ data.tar.gz: 12c353eb6780bf32befea2127f336f971c861ddabc6f9b01b1c23ea8211e963af79fd754a89480b1c582014b9ad8f5f1c0e0374d1edf1ea6f52f0cef1faa7ed5
data/README.md CHANGED
@@ -25,12 +25,7 @@ Or install it yourself as:
25
25
 
26
26
  To use this gem add this require statement to your application.js file:
27
27
 
28
- //= require fort
29
-
30
- and in application.css file
31
-
32
- *= require fort
33
-
28
+ //= require rails_fort
34
29
 
35
30
  ## Usage
36
31
 
@@ -0,0 +1,20 @@
1
+ $(document).ready(function(){
2
+ $("form").wrap( "<div class='form'></div>" );
3
+ <% path_to_file = "#{Rails.root}/config/fort.yml" %>
4
+ <% if File.exist?(path_to_file) %>
5
+ fortconfig = <%= JSON.dump(YAML.load_file(path_to_file)) %>;
6
+ if (fortconfig.type == null)
7
+ fortconfig.type = "solid"
8
+ if(fortconfig.value instanceof Array)
9
+ Fort[fortconfig.type].apply(this,fortconfig.value)
10
+ else
11
+ Fort[fortconfig.type](fortconfig.value)
12
+ Fort.config({
13
+ height: fortconfig.height,
14
+ duration: fortconfig.duration,
15
+ alignment: fortconfig.alignment
16
+ });
17
+ <% else %>
18
+ Fort.solid("#009DFF");
19
+ <% end %>
20
+ });
@@ -1,5 +1,5 @@
1
1
  module Rails
2
2
  module Fort
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
@@ -0,0 +1 @@
1
+ var Fort={clean:function(){for(var e=document.querySelectorAll(".form"),t=e.length;t--;){var o=e[t].querySelectorAll("input, textarea, select");Array.prototype.forEach.call(o,function(e){0!=e.value.length&&(e.classList?e.classList.add("ignore"):e.className+=" ignore")});var n=e[t].querySelectorAll("input[type=hidden]");Array.prototype.forEach.call(n,function(e){e.classList?e.classList.add("ignore"):e.className+=" ignore"})}},solid:function(e){function t(t){for(var o=[],r=n.length;r--;)n[r].value.length||o.push(n[r]);for(var l=o.length,s=n.length,a=document.querySelectorAll(".top-one"),i=a.length;i--;)a[i].style.width=100-l/s*100+"%";document.getElementById("top1").style.background=e}Fort.clean(),document.body.innerHTML='<div class="top-one" id="top1"><div class="colors"></div></div>'+document.body.innerHTML;for(var o=document.querySelectorAll(".form"),n=[],r=o.length;r--;)for(var l=o[r].querySelectorAll("input, textarea, select"),s=l.length;s--;){classes=l[s].className.replace(/\s+/g," ").split(" "),ignore=!1;for(var a=classes.length;a--;)if("ignore"==classes[a]){ignore=!0;break}"button"==l[s].type||"submit"==l[s].type||ignore||(n.push(l[s]),l[s].addEventListener("input",t,!1))}},gradient:function(e,t){function o(o){for(var n=[],l=r.length;l--;)r[l].value.length||n.push(r[l]);for(var s=n.length,a=r.length,i=document.querySelectorAll(".top-one"),c=i.length;c--;)i[c].style.width=100-s/a*100+"%";orientation="to right";var u="linear-gradient("+orientation+", "+e+", "+t+")";document.getElementById("top1").style.background=u}Fort.clean(),document.body.innerHTML='<div class="top-one" id="top1"><div class="colors"></div></div>'+document.body.innerHTML;for(var n=document.querySelectorAll(".form"),r=[],l=n.length;l--;)for(var s=n[l].querySelectorAll("input, textarea, select"),a=s.length;a--;){classes=s[a].className.replace(/\s+/g," ").split(" "),ignore=!1;for(var i=classes.length;i--;)if("ignore"==classes[i]){ignore=!0;break}"button"==s[a].type||"submit"==s[a].type||ignore||(r.push(s[a]),s[a].addEventListener("input",o,!1))}},sections:function(){function e(e){for(var t=[],o=s.length;o--;)s[o].value.length||t.push(s[o]);for(var n=t.length,r=s.length,l=document.querySelectorAll(".top-one"),a=l.length;a--;)l[a].style.width=100-n/r*100+"%"}function t(e){var t=[],o=0;for(n=0;n<2*e.length;n++){n%2&&o++;var r=Math.floor(1e3*o/e.length)/10;t.push([e[n-o],r+"%"])}return t}function o(e){var t,o=e.length;for(t=0;o>t;t++)e[t]=e[t].join(" ");return"linear-gradient( to right, "+e.join(", ")+")"}Fort.clean();for(var n=0;n<arguments.length;++n)var r=Array.prototype.slice.call(arguments);document.body.innerHTML='<div class="top-one" id="top1"><div class="colors"></div></div>'+document.body.innerHTML;for(var l=document.querySelectorAll(".form"),s=[],n=l.length;n--;)for(var a=l[n].querySelectorAll("input, textarea, select"),i=a.length;i--;){classes=a[i].className.replace(/\s+/g," ").split(" "),ignore=!1;for(var c=classes.length;c--;)if("ignore"==classes[c]){ignore=!0;break}"button"==a[i].type||"submit"==a[i].type||ignore||(s.push(a[i]),a[i].addEventListener("input",e,!1))}document.getElementsByClassName("top-one").innerHTML='<div class="colors"></div>',document.querySelector(".colors").style.background=o(t(r.sort()));var u=window.innerWidth+"px";document.querySelector(".colors").style.width=u},flash:function(){function e(e){for(var t=[],o=l.length;o--;)l[o].value.length||t.push(l[o]);for(var r=t.length,s=l.length,a=document.querySelectorAll(".top-one"),i=a.length;i--;)a[i].style.width=100-r/s*100+"%",a[i].style.background=n[s-r-1]}Fort.clean();for(var t=0;t<arguments.length;++t){arguments.length,arguments[t]}var o=Array.prototype.slice.call(arguments),n=o.sort();document.body.innerHTML='<div class="top-one" id="top1"><div class="colors"></div></div>'+document.body.innerHTML;for(var r=document.querySelectorAll(".form"),l=[],t=r.length;t--;)for(var s=r[t].querySelectorAll("input, textarea, select"),a=s.length;a--;){classes=s[a].className.replace(/\s+/g," ").split(" "),ignore=!1;for(var i=classes.length;i--;)if("ignore"==classes[i]){ignore=!0;break}"button"==s[a].type||"submit"==s[a].type||ignore||(l.push(s[a]),s[a].addEventListener("input",e,!1))}},merge:function(e){function t(t){for(var o=[],r=n.length;r--;)n[r].value.length||o.push(n[r]);for(var l=o.length,s=n.length,a=document.querySelectorAll("#top1"),i=a.length;i--;){precalct=100-l/s*100;var c=precalct/2;a[i].style.width=c+"%"}for(var l=o.length,s=n.length,a=document.querySelectorAll("#top2"),i=a.length;i--;){precalct=100-l/s*100;var c=precalct/2;a[i].style.width=c+"%"}document.getElementById("top1").style.background=e,document.getElementById("top2").style.background=e}Fort.clean(),document.body.innerHTML='<div class="top-one" id="top1"><div class="colors"></div></div>'+document.body.innerHTML,document.body.innerHTML='<div class="top-two" id="top2"><div class="colors"></div></div>'+document.body.innerHTML;for(var o=document.querySelectorAll(".form"),n=[],r=o.length;r--;)for(var l=o[r].querySelectorAll("input, textarea, select"),s=l.length;s--;){classes=l[s].className.replace(/\s+/g," ").split(" "),ignore=!1;for(var a=classes.length;a--;)if("ignore"==classes[a]){ignore=!0;break}"button"==l[s].type||"submit"==l[s].type||ignore||(n.push(l[s]),l[s].addEventListener("input",t,!1))}},config:function(e){var t=document.querySelector("#top1"),o=document.querySelector("#top2")||{style:{}};e.height&&(t.style.height=e.height,o.style.height=e.height),e.alignment&&("top"===e.alignment?(t.style.top=0,t.style.bottom="auto",o.style.top=0,o.style.bottom="auto"):(t.style.top="auto",t.style.bottom=0,o.style.top="auto",o.style.bottom=0)),e.duration&&(t.style.transitionDuration=e.duration,o.style.transitionDuration=e.duration)}};
@@ -0,0 +1 @@
1
+ .top-one{background:#009dff;position:fixed;z-index:1031;top:0;left:0;height:4px;transition:all 1s;width:0;overflow:hidden}.top-two{background:#009dff;position:fixed;z-index:1031;top:0;right:0;transform:rotate(180deg);height:4px;transition:all 1s;width:0;overflow:hidden}.colors{width:100%;height:4px}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-fort
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - ethiraj
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-23 00:00:00.000000000 Z
11
+ date: 2016-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,15 +66,15 @@ files:
66
66
  - LICENSE.txt
67
67
  - README.md
68
68
  - Rakefile
69
- - app/assets/javascripts/fort.js.erb
70
- - app/assets/stylesheets/fort.css
69
+ - app/assets/javascripts/rails_fort.js.erb
71
70
  - bin/console
72
71
  - bin/setup
73
72
  - lib/rails/fort.rb
74
73
  - lib/rails/fort/version.rb
75
74
  - npm-debug.log
76
75
  - rails-fort.gemspec
77
- - vendor/assets/javascripts/rails.fort.js
76
+ - vendor/assets/javascripts/fort.min.js
77
+ - vendor/assets/stylesheets/fort.min.css
78
78
  homepage: https://github.com/ethirajsrinivasan/rails-fort
79
79
  licenses:
80
80
  - MIT
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  version: '0'
97
97
  requirements: []
98
98
  rubyforge_project:
99
- rubygems_version: 2.4.8
99
+ rubygems_version: 2.5.1
100
100
  signing_key:
101
101
  specification_version: 4
102
102
  summary: Modern progress bar for form completion
@@ -1,27 +0,0 @@
1
- //= require rails.fort
2
-
3
- $(document).ready(function(){
4
- $("form").wrap( "<div class='form'></div>" );
5
- $("input[type='hidden']").addClass('ignore');
6
- $('input, textarea, select').each(function() {
7
- if ($(this).val().length != 0 )
8
- $(this).addClass( "ignore" );
9
- });
10
- <% path_to_file = "#{Rails.root}/config/fort.yml" %>
11
- <% if File.exist?(path_to_file) %>
12
- fortconfig = <%= JSON.dump(YAML.load_file(path_to_file)) %>;
13
- if (fortconfig.type == null)
14
- fortconfig.type = "solid"
15
- if(fortconfig.value instanceof Array)
16
- Fort[fortconfig.type].apply(this,fortconfig.value)
17
- else
18
- Fort[fortconfig.type](fortconfig.value)
19
- Fort.config({
20
- height: fortconfig.height,
21
- duration: fortconfig.duration,
22
- alignment: fortconfig.alignment
23
- });
24
- <% else %>
25
- Fort.solid("#009DFF");
26
- <% end %>
27
- });
@@ -1,31 +0,0 @@
1
- .top-one {
2
- background: #009dff;
3
- /*background: linear-gradient(to right, #009dff 0, #00c8ff 100%);*/
4
- position: fixed;
5
- z-index: 1031;
6
- top: 0;
7
- left: 0;
8
- height: 4px;
9
- transition: all 1s;
10
- width: 0;
11
- overflow: hidden;
12
- }
13
- /*.top-two is for merge() only*/
14
- .top-two {
15
- background: #009dff;
16
- /*background: linear-gradient(to right, #009dff 0, #00c8ff 100%);*/
17
- position: fixed;
18
- z-index: 1031;
19
- top: 0;
20
- right: 0;
21
- transform: rotate(180deg);
22
- height: 4px;
23
- transition: all 1s;
24
- width: 0;
25
- overflow: hidden;
26
- }
27
-
28
- .colors {
29
- width: 100%;
30
- height: 4px;
31
- }
@@ -1,270 +0,0 @@
1
- var Fort = {
2
- solid: function solid(hex) {
3
- document.body.innerHTML = '<div class="top-one" id="top1"><div class="colors"></div></div>' + document.body.innerHTML;
4
-
5
- function cback(e) {
6
- var t = [];
7
- for (var n = inputs.length; n--;) {
8
- if (!inputs[n].value.length) t.push(inputs[n]);
9
- }
10
- var r = t.length;
11
- var i = inputs.length;
12
- var s = document.querySelectorAll(".top-one");
13
- for (var o = s.length; o--;) {
14
- s[o].style.width = 100 - r / i * 100 + "%";
15
- }
16
-
17
- //Set color of bar as solid
18
- document.getElementById("top1").style.background = hex;
19
- }
20
- var forms = document.querySelectorAll(".form"),
21
- inputs = [];
22
- for (var i = forms.length; i--;) {
23
- var els = forms[i].querySelectorAll("input, textarea, select");
24
- for (var j = els.length; j--;) {
25
- classes = els[j].className.replace(/\s+/g, ' ').split(' ');
26
- ignore = false;
27
- for (var k = classes.length; k--;) {
28
- if (classes[k] == "ignore") {
29
- ignore = true;
30
- break;
31
- }
32
- }
33
- if (els[j].type != "button" && els[j].type != "submit" && !ignore) {
34
- inputs.push(els[j]);
35
- els[j].addEventListener("input", cback, false);
36
- }
37
- }
38
- }
39
- },
40
-
41
- gradient: function(firstColor, secondColor) {
42
- document.body.innerHTML = '<div class="top-one" id="top1"><div class="colors"></div></div>' + document.body.innerHTML;
43
-
44
- function cback(e) {
45
- var t = [];
46
- for (var n = inputs.length; n--;) {
47
- if (!inputs[n].value.length) t.push(inputs[n]);
48
- }
49
- var r = t.length;
50
- var i = inputs.length;
51
- var s = document.querySelectorAll(".top-one");
52
- for (var o = s.length; o--;) {
53
- s[o].style.width = 100 - r / i * 100 + "%";
54
- }
55
- orientation = 'to right';
56
- var string = 'linear-gradient(' + orientation + ', ' + firstColor + ', ' + secondColor + ')';
57
- document.getElementById("top1").style.background = string;
58
- }
59
- var forms = document.querySelectorAll(".form"),
60
- inputs = [];
61
- for (var i = forms.length; i--;) {
62
- var els = forms[i].querySelectorAll("input, textarea, select");
63
- for (var j = els.length; j--;) {
64
- classes = els[j].className.replace(/\s+/g, ' ').split(' ');
65
- ignore = false;
66
- for (var k = classes.length; k--;) {
67
- if (classes[k] == "ignore") {
68
- ignore = true;
69
- break;
70
- }
71
- }
72
- if (els[j].type != "button" && els[j].type != "submit" && !ignore) {
73
- inputs.push(els[j]);
74
- els[j].addEventListener("input", cback, false);
75
- }
76
- }
77
- }
78
- },
79
-
80
- sections: function() {
81
- for (var i = 0; i < arguments.length; ++i) {
82
- var args = Array.prototype.slice.call(arguments);
83
- }
84
-
85
- document.body.innerHTML = '<div class="top-one" id="top1"><div class="colors"></div></div>' + document.body.innerHTML;
86
-
87
- function cback(e) {
88
- var t = [];
89
- for (var n = inputs.length; n--;) {
90
- if (!inputs[n].value.length) t.push(inputs[n]);
91
- }
92
- var r = t.length;
93
- var i = inputs.length;
94
- var s = document.querySelectorAll(".top-one");
95
- for (var o = s.length; o--;) {
96
- s[o].style.width = 100 - r / i * 100 + "%";
97
- }
98
- }
99
- var forms = document.querySelectorAll(".form"),
100
- inputs = [];
101
- for (var i = forms.length; i--;) {
102
- var els = forms[i].querySelectorAll("input, textarea, select");
103
- for (var j = els.length; j--;) {
104
- classes = els[j].className.replace(/\s+/g, ' ').split(' ');
105
- ignore = false;
106
- for (var k = classes.length; k--;) {
107
- if (classes[k] == "ignore") {
108
- ignore = true;
109
- break;
110
- }
111
- }
112
- if (els[j].type != "button" && els[j].type != "submit" && !ignore) {
113
- inputs.push(els[j]);
114
- els[j].addEventListener("input", cback, false);
115
- }
116
- }
117
- }
118
-
119
-
120
- function colDistr(input) {
121
- var result = [],
122
- step = 0;
123
- for (i = 0; i < input.length * 2; i++) {
124
- if (i % 2) step++;
125
- var perc = Math.floor(step * 1000 / input.length) / 10;
126
- result.push([input[i - step], perc + "%"]);
127
- }
128
- return result;
129
- }
130
-
131
-
132
- function generateCSSGradient(colours) {
133
- var l = colours.length,
134
- i;
135
- for (i = 0; i < l; i++) colours[i] = colours[i].join(" ");
136
- return "linear-gradient( to right, " + colours.join(", ") + ")";
137
- }
138
-
139
- document.getElementsByClassName('top-one').innerHTML = '<div class="colors"></div>';
140
- document.querySelector(".colors").style.background = generateCSSGradient(colDistr(args.sort()));
141
-
142
- var window_width = window.innerWidth + "px";
143
- document.querySelector(".colors").style.width = window_width;
144
- },
145
-
146
-
147
- flash: function() {
148
- for (var i = 0; i < arguments.length; ++i) {
149
- var totalSections = arguments.length;
150
- var totalColors = arguments[i];
151
- }
152
- var args = Array.prototype.slice.call(arguments);
153
- var cols = args.sort();
154
-
155
- document.body.innerHTML = '<div class="top-one" id="top1"><div class="colors"></div></div>' + document.body.innerHTML;
156
-
157
- function cback(e) {
158
- var t = [];
159
- for (var n = inputs.length; n--;) {
160
- if (!inputs[n].value.length) t.push(inputs[n]);
161
- }
162
- var r = t.length;
163
- var i = inputs.length;
164
- var s = document.querySelectorAll(".top-one");
165
- for (var o = s.length; o--;) {
166
- s[o].style.width = 100 - r / i * 100 + "%";
167
- s[o].style.background = cols[i - r - 1];
168
- }
169
- }
170
- var forms = document.querySelectorAll(".form"),
171
- inputs = [];
172
- for (var i = forms.length; i--;) {
173
- var els = forms[i].querySelectorAll("input, textarea, select");
174
- for (var j = els.length; j--;) {
175
- classes = els[j].className.replace(/\s+/g, ' ').split(' ');
176
- ignore = false;
177
- for (var k = classes.length; k--;) {
178
- if (classes[k] == "ignore") {
179
- ignore = true;
180
- break;
181
- }
182
- }
183
- if (els[j].type != "button" && els[j].type != "submit" && !ignore) {
184
- inputs.push(els[j]);
185
- els[j].addEventListener("input", cback, false);
186
- }
187
-
188
- }
189
- }
190
- },
191
-
192
- merge: function(hex) {
193
- document.body.innerHTML = '<div class="top-one" id="top1"><div class="colors"></div></div>' + document.body.innerHTML;
194
- document.body.innerHTML = '<div class="top-two" id="top2"><div class="colors"></div></div>' + document.body.innerHTML;
195
-
196
- function cback(e) {
197
- var t = [];
198
- for (var n = inputs.length; n--;) {
199
- if (!inputs[n].value.length) t.push(inputs[n]);
200
- }
201
- var r = t.length;
202
- var i = inputs.length;
203
- var s = document.querySelectorAll("#top1");
204
-
205
- for (var o = s.length; o--;) {
206
- precalct = 100 - r / i * 100;
207
- var precalct2 = precalct / 2;
208
- s[o].style.width = precalct2 + "%";
209
- }
210
-
211
- var r = t.length;
212
- var i = inputs.length;
213
- var s = document.querySelectorAll("#top2");
214
-
215
- for (var o = s.length; o--;) {
216
- precalct = 100 - r / i * 100;
217
- var precalct2 = precalct / 2;
218
- s[o].style.width = precalct2 + "%";
219
- }
220
-
221
- document.getElementById("top1").style.background = hex;
222
- document.getElementById("top2").style.background = hex;
223
-
224
- }
225
- var forms = document.querySelectorAll(".form"),
226
- inputs = [];
227
- for (var i = forms.length; i--;) {
228
- var els = forms[i].querySelectorAll("input, textarea, select");
229
- for (var j = els.length; j--;) {
230
- classes = els[j].className.replace(/\s+/g, ' ').split(' ');
231
- ignore = false;
232
- for (var k = classes.length; k--;) {
233
- if (classes[k] == "ignore") {
234
- ignore = true;
235
- break;
236
- }
237
- }
238
- if (els[j].type != "button" && els[j].type != "submit" && !ignore) {
239
- inputs.push(els[j]);
240
- els[j].addEventListener("input", cback, false);
241
- }
242
- }
243
- }
244
- },
245
- config: function(settings) {
246
- var t1 = document.querySelector('#top1');
247
- var t2 = document.querySelector('#top2') || {style:{}};
248
- if (settings.height) {
249
- t1.style.height = settings.height;
250
- t2.style.height = settings.height;
251
- }
252
- if (settings.alignment) {
253
- if (settings.alignment === 'top') {
254
- t1.style.top = 0;
255
- t1.style.bottom = 'auto';
256
- t2.style.top = 0;
257
- t2.style.bottom = 'auto';
258
- } else {
259
- t1.style.top = 'auto';
260
- t1.style.bottom = 0;
261
- t2.style.top = 'auto';
262
- t2.style.bottom = 0;
263
- }
264
- }
265
- if (settings.duration) {
266
- t1.style.transitionDuration = settings.duration;
267
- t2.style.transitionDuration = settings.duration;
268
- }
269
- }
270
- };