codelation_ui 1.0.1 → 1.0.57

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/codelation_ui/_base_resources/app.js +54 -5
  3. data/app/assets/javascripts/codelation_ui/base.js +1 -0
  4. data/app/assets/javascripts/codelation_ui/extended/checkmark.js +31 -0
  5. data/app/assets/javascripts/codelation_ui/extended/code.js +64 -0
  6. data/app/assets/javascripts/codelation_ui/extended/fail.js +31 -0
  7. data/app/assets/javascripts/codelation_ui/extended/radial_progress_bar.js +267 -0
  8. data/app/assets/javascripts/codelation_ui/extended/slider.js +636 -639
  9. data/app/assets/javascripts/codelation_ui/extended/spinner.js +103 -0
  10. data/app/assets/javascripts/codelation_ui/forms/components/input.js +417 -388
  11. data/app/assets/javascripts/codelation_ui/forms/interfaces/form.js +35 -30
  12. data/app/assets/javascripts/codelation_ui/std.js +3 -1
  13. data/app/assets/javascripts/codelation_ui/std/components/info.js +22 -0
  14. data/app/assets/javascripts/codelation_ui/std/components/transition.js +26 -0
  15. data/app/assets/javascripts/codelation_ui/std/computed_interfaces/mockAPI.js +17 -0
  16. data/app/assets/javascripts/codelation_ui/std/interfaces/array.js +28 -0
  17. data/app/assets/javascripts/codelation_ui/std/interfaces/content_formatters.js +37 -10
  18. data/app/assets/javascripts/codelation_ui/std/interfaces/date.js +8 -0
  19. data/app/assets/javascripts/codelation_ui/std/interfaces/number.js +20 -0
  20. data/app/assets/javascripts/codelation_ui/std/interfaces/rest_api.js +104 -0
  21. data/app/assets/javascripts/codelation_ui/std/interfaces/string.js +29 -0
  22. data/app/assets/javascripts/codelation_ui/vue.js +25 -8
  23. data/app/assets/javascripts/codelation_ui/vue_pages.js +35 -10
  24. data/app/assets/stylesheets/codelation_ui.scss +1 -3
  25. data/app/assets/stylesheets/codelation_ui/_base_resources/_turbolinks.scss +11 -0
  26. data/app/assets/stylesheets/codelation_ui/_base_resources/mixins/button.scss +185 -33
  27. data/app/assets/stylesheets/codelation_ui/base.scss +3 -0
  28. data/app/assets/stylesheets/codelation_ui/colors.scss +2 -0
  29. data/app/assets/stylesheets/codelation_ui/extended/checkmark.scss +53 -0
  30. data/app/assets/stylesheets/codelation_ui/extended/code.scss +153 -0
  31. data/app/assets/stylesheets/codelation_ui/extended/fail.scss +50 -0
  32. data/app/assets/stylesheets/codelation_ui/extended/radial_progress_bar.scss +70 -0
  33. data/app/assets/stylesheets/codelation_ui/extended/slider.scss +2 -2
  34. data/app/assets/stylesheets/codelation_ui/extended/spinner.scss +100 -0
  35. data/app/assets/stylesheets/codelation_ui/std.scss +1 -1
  36. data/app/assets/stylesheets/codelation_ui/std/info.scss +51 -0
  37. data/app/assets/stylesheets/codelation_ui/vue_transitions.scss +94 -0
  38. data/app/helpers/action_view/helpers/url_helper.rb +22 -0
  39. data/lib/generators/ui/component/USAGE +22 -0
  40. data/lib/generators/ui/component/component_generator.rb +41 -0
  41. data/lib/generators/ui/component/templates/javascript.js.erb +20 -0
  42. data/lib/generators/ui/component/templates/page_javascript.js.erb +20 -0
  43. data/lib/generators/ui/component/templates/page_stylesheet.scss.erb +3 -0
  44. data/lib/generators/ui/component/templates/stylesheet.scss.erb +3 -0
  45. data/lib/generators/ui/component/templates/template.html.erb +5 -0
  46. data/lib/generators/ui/mixin/USAGE +8 -0
  47. data/lib/generators/ui/mixin/mixin_generator.rb +11 -0
  48. data/lib/generators/ui/mixin/templates/javascript.js.erb +8 -0
  49. data/lib/generators/ui/pages/USAGE +23 -0
  50. data/lib/generators/ui/pages/pages_generator.rb +48 -0
  51. data/lib/generators/ui/pages/templates/controller.rb +2 -0
  52. data/lib/generators/ui/pages/templates/javascript.js.erb +22 -0
  53. data/lib/generators/ui/pages/templates/stylesheet.scss.erb +3 -0
  54. data/lib/generators/ui/pages/templates/template.html.erb +3 -0
  55. data/vendor/assets/javascripts/highlight.pack.js +2 -0
  56. data/vendor/assets/javascripts/pluralize.js +1 -0
  57. data/vendor/assets/javascripts/vue.js +4 -10232
  58. metadata +107 -11
  59. data/app/assets/javascripts/codelation_ui/std/index.js +0 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a98b2212a1e28f925270f4e234717bdf9f3f415
4
- data.tar.gz: 4e61ca901af94887763d19ff8594c2c997a2fdf0
3
+ metadata.gz: f5509d439e28984c350955f88462af5b9cc5a6b7
4
+ data.tar.gz: 97c05ad5a4b99aa4df39847535eeeebe663ed9ba
5
5
  SHA512:
6
- metadata.gz: 27c23d7701ab559fa3e0f5b143b19a67eccd68ffae4358a5ed7de51f698e4fe792526f57ccbf0e93598fa5abe7de2b2506c2a724d1d606ab01e14bf81ff32738
7
- data.tar.gz: fbd2d3fae242de14167833c8b69c02a61948596add8dbaefebb6a15466201c984e84b8b819f68c2c2ec1a766ec9d695987f72b4ba3502c9e3e7938f5f2797436
6
+ metadata.gz: 9ec45bec284dc5b73e9d8196b6472dc1d4113fc95c1be73057c2083be89862aac92442389858a77983e7b5080a0baa696e14c6d0007078dd5f53a50dbe1bef09
7
+ data.tar.gz: 838960e2773a581d024d335df4cdc30d0de1d4f4f2f5c91f988cc5bd4b974e23f5cc6a17472f1c53f42174d658bc3a5679157b81350baafbebac073c39f121b7
@@ -2,14 +2,19 @@
2
2
  "use strict";
3
3
 
4
4
  var app = window.App;
5
- var bodyClass, bodyElement;
5
+ var bodyClass,
6
+ bodyElement;
6
7
 
7
8
  if (app === undefined) {
8
9
  app = window.App = {};
9
10
  }
10
11
 
11
- app.enterFunctions = { component: [] };
12
- app.exitFunctions = { component: [] };
12
+ app.enterFunctions = {
13
+ component: []
14
+ };
15
+ app.exitFunctions = {
16
+ component: []
17
+ };
13
18
 
14
19
  // Register functions to run when any page or specific pages are loaded.
15
20
  //
@@ -61,21 +66,49 @@
61
66
  bodyElement = $('body');
62
67
 
63
68
  // Determine which functions should be fired
69
+ var fireConfigFunctions = [];
70
+ var fireFirstFunctions = [];
64
71
  var fireFunctions = [];
72
+ var fireLastFunctions = [];
65
73
  $.each(app.enterFunctions, function(key, functions) {
66
74
  bodyClass = key.split('.').join(' ');
67
75
  if (bodyClass === 'component' || bodyElement.hasClass(bodyClass)) {
68
76
  fireFunctions = fireFunctions.concat(functions);
69
77
  }
78
+
79
+ if (bodyClass === 'last') {
80
+ fireLastFunctions = fireLastFunctions.concat(functions);
81
+ }
82
+
83
+ if (bodyClass === 'first') {
84
+ fireFirstFunctions = fireFirstFunctions.concat(functions);
85
+ }
86
+
87
+ if (bodyClass === 'config') {
88
+ fireConfigFunctions = fireConfigFunctions.concat(functions);
89
+ }
70
90
  });
71
91
 
72
92
  // Fire off each function
73
- $.each(fireFunctions, function() { this.call(); });
93
+ $.each(fireConfigFunctions, function() {
94
+ this.call();
95
+ });
96
+ $.each(fireFirstFunctions, function() {
97
+ this.call();
98
+ });
99
+ $.each(fireFunctions, function() {
100
+ this.call();
101
+ });
102
+ $.each(fireLastFunctions, function() {
103
+ this.call();
104
+ });
74
105
  });
75
106
 
76
107
  // Fires off any callbacks registered for exit, ONLY if using Turbolinks.
77
108
  $(document).on('page:before-unload', function() {
109
+ var fireFirstFunctions = [];
78
110
  var fireFunctions = [];
111
+ var fireLastFunctions = [];
79
112
 
80
113
  // Determine which functions should be fired
81
114
  $.each(app.exitFunctions, function(key, functions) {
@@ -83,9 +116,25 @@
83
116
  if (bodyClass === 'component' || bodyElement.hasClass(bodyClass)) {
84
117
  fireFunctions = fireFunctions.concat(functions);
85
118
  }
119
+
120
+ if (bodyClass === 'last') {
121
+ fireLastFunctions = fireLastFunctions.concat(functions);
122
+ }
123
+
124
+ if (bodyClass === 'first') {
125
+ fireFirstFunctions = fireFirstFunctions.concat(functions);
126
+ }
86
127
  });
87
128
 
88
129
  // Fire off each function
89
- $.each(fireFunctions, function() { this.call(); });
130
+ $.each(fireFirstFunctions, function() {
131
+ this.call();
132
+ });
133
+ $.each(fireFunctions, function() {
134
+ this.call();
135
+ });
136
+ $.each(fireLastFunctions, function() {
137
+ this.call();
138
+ });
90
139
  });
91
140
  })();
@@ -3,6 +3,7 @@
3
3
  //= require turbolinks
4
4
  //= require moment
5
5
  //= require numeral
6
+ //= require pluralize
6
7
  //= require ./_base_resources/app
7
8
  //= require ./_base_resources/progress_bar
8
9
  //= require_tree ./_base_resources/components
@@ -0,0 +1,31 @@
1
+ (function() {
2
+ "use strict";
3
+
4
+ App.vue.components.vueCheckmark = Vue.extend({
5
+ template: '<div :style="styles">\
6
+ <svg class="vue-checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">\
7
+ <circle class="vue-checkmark-circle" cx="26" cy="26" r="25" fill="none" :stroke-width="stroke"/>\
8
+ <path class="vue-checkmark-check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8" :stroke-width="stroke"/>\
9
+ </svg></div>\
10
+ ',
11
+ props: {
12
+ size: {
13
+ type: Number,
14
+ default: 50
15
+ },
16
+ stroke: {
17
+ type: Number,
18
+ default: 3.5
19
+ }
20
+ },
21
+ computed: {
22
+ styles: function() {
23
+ var newSize = this.size + 'px';
24
+ return {
25
+ width: newSize,
26
+ height: newSize
27
+ };
28
+ }
29
+ }
30
+ });
31
+ })();
@@ -0,0 +1,64 @@
1
+ //= require highlight.pack
2
+
3
+ // NORMAL
4
+ // <vue-code lang="javascript">
5
+ // function name(){
6
+ // return 'jake';
7
+ // }
8
+ //
9
+ // //comment
10
+ // var test = '12' + ' days';
11
+ // </vue-code>
12
+
13
+ // DARK UI
14
+ // <vue-code lang="javascript" dark>
15
+ // function name(){
16
+ // return 'jake';
17
+ // }
18
+ //
19
+ // //comment
20
+ // var test = '12' + ' days';
21
+ // </vue-code>
22
+
23
+ // INLINE
24
+ // <vue-code lang="javascript" inline>
25
+ // function name(){
26
+ // return 'jake';
27
+ // }
28
+ //
29
+ // //comment
30
+ // var test = '12' + ' days';
31
+ // </vue-code>
32
+
33
+ (function() {
34
+ "use strict";
35
+
36
+ App.vue.config.code = {
37
+ 'dark': false
38
+ }
39
+
40
+
41
+ var template = '<div class="vue-code" :class="[inline ? \'vue-code-inline\' : \'vue-code-block\', dark ? \'vue-code-dark\' : \'\']">\
42
+ <pre v-if="!inline"><code v-el:code :class="lang"><slot></slot></code></pre>\
43
+ <span v-else><code v-el:code :class="lang"><slot></slot></code></span>\
44
+ </div>';
45
+
46
+ App.vue.components.vueCode = Vue.extend({
47
+ template: template,
48
+ props: {
49
+ lang: String,
50
+ inline: {
51
+ type: Boolean,
52
+ default: false
53
+ },
54
+ dark: {
55
+ type: Boolean,
56
+ default: App.vue.config.code.dark
57
+ }
58
+ },
59
+ ready: function() {
60
+ var code = this.$els.code;
61
+ hljs.highlightBlock(code);
62
+ }
63
+ });
64
+ })();
@@ -0,0 +1,31 @@
1
+ (function() {
2
+ "use strict";
3
+
4
+ App.vue.components.vueFail = Vue.extend({
5
+ template: '<div :style="styles">\
6
+ <svg class="vue-fail" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">\
7
+ <circle class="vue-fail-circle" cx="26" cy="26" r="25" fill="none" :stroke-width="stroke"/>\
8
+ <path class="vue-fail-check" fill="none" d="M16 16 36 36 M36 16 16 36" :stroke-width="stroke"/>\
9
+ </svg></div>\
10
+ ',
11
+ props: {
12
+ size: {
13
+ type: Number,
14
+ default: 50
15
+ },
16
+ stroke: {
17
+ type: Number,
18
+ default: 3.5
19
+ }
20
+ },
21
+ computed: {
22
+ styles: function() {
23
+ var newSize = this.size + 'px';
24
+ return {
25
+ width: newSize,
26
+ height: newSize
27
+ };
28
+ }
29
+ }
30
+ });
31
+ })();
@@ -0,0 +1,267 @@
1
+ // # Use
2
+
3
+ // <vue-radial-progress-bar :total-steps="10" :completed-steps="5"><h4>Inner content</h4></vue-radial-progress-bar>
4
+
5
+ // # Props
6
+
7
+ // Name | Default value | Description
8
+ // ---|:---:|---
9
+ // `diameter` | `200` | Diameter of the progress bar circle in pixels.
10
+ // `totalSteps` | `10` | Total number of steps to complete progress bar.
11
+ // `completedSteps` | `0` | Number of completed steps in the progress bar.
12
+ // `startColor` | `#bbff42` | The color of the leading edge of the progress bar gradient.
13
+ // `stopColor` | `#429321` | The secondary color of the progress bar gradient.
14
+ // `innerStrokeColor` | `#323232` | Background color of the progress bar.
15
+ // `strokeWidth` | `10` | The width of the progress bar.
16
+ // `animateSpeed` | `1000` | The amount of time in milliseconds to animate one step.
17
+ // `fps` | `60` | The frames per second that the animation should run.
18
+ // `timingFunc` | `linear` | The transition timing function to use for the CSS transition. See [transition-timing-function](https://developer.mozilla.org/en-US/docs/Web/CSS/transition-timing-function).
19
+
20
+
21
+ (function(){
22
+ "use strict"
23
+
24
+ var template = '<div class="vue-radial-progress-bar-container" :class="[over ? \'vue-radial-progress-bar-over\' : \'\', complete ? \'vue-radial-progress-bar-complete\' : \'\']" :style="containerStyle">\
25
+ <div class="vue-radial-progress-bar-inner" :style="innerCircleStyle">\
26
+ <slot></slot>\
27
+ </div>\
28
+ <svg class="vue-radial-progress-bar-bar"\
29
+ :width="diameter"\
30
+ :height="diameter"\
31
+ version="1.1"\
32
+ xmlns="http://www.w3.org/2000/svg">\
33
+ <defs>\
34
+ <radialGradient :id="\'radial-gradient\' + _uid"\
35
+ :fx="gradient.fx"\
36
+ :fy="gradient.fy"\
37
+ :cx="gradient.cx"\
38
+ :cy="gradient.cy"\
39
+ :r="gradient.r">\
40
+ <stop class="vue-radial-progress-bar-start-color" offset="30%"/>\
41
+ <stop class="vue-radial-progress-bar-stop-color" offset="100%"/>\
42
+ </radialGradient>\
43
+ </defs>\
44
+ <circle class="vue-radial-progress-bar-circle" :r="innerCircleRadius"\
45
+ :cx="radius"\
46
+ :cy="radius"\
47
+ fill="transparent"\
48
+ :stroke-dasharray="circumference"\
49
+ stroke-dashoffset="0"\
50
+ stroke-linecap="round"\
51
+ :style="strokeStyle"></circle>\
52
+ <circle :transform="\'rotate(270, \' + radius + \',\' + radius + \')\'"\
53
+ :r="innerCircleRadius"\
54
+ :cx="radius"\
55
+ :cy="radius"\
56
+ fill="transparent"\
57
+ :stroke="\'url(#radial-gradient\' + _uid + \')\'"\
58
+ :stroke-dasharray="circumference"\
59
+ :stroke-dashoffset="circumference"\
60
+ stroke-linecap="round"\
61
+ :style="progressStyle"></circle>\
62
+ </svg>\
63
+ </div>';
64
+
65
+ App.vue.components.vueRadialProgressBar = Vue.extend({
66
+ template: template,
67
+ props: {
68
+ diameter: {
69
+ type: Number,
70
+ required: false,
71
+ default: 200
72
+ },
73
+ totalSteps: {
74
+ type: Number,
75
+ required: true,
76
+ default: 10
77
+ },
78
+ completedSteps: {
79
+ type: Number,
80
+ required: true,
81
+ default: 0
82
+ },
83
+ strokeWidth: {
84
+ type: Number,
85
+ required: false,
86
+ default: 10
87
+ },
88
+ animateSpeed: {
89
+ type: Number,
90
+ required: false,
91
+ default: 1000
92
+ },
93
+ fps: {
94
+ type: Number,
95
+ required: false,
96
+ default: 60
97
+ },
98
+ timingFunc: {
99
+ type: String,
100
+ required: false,
101
+ default: 'linear'
102
+ }
103
+ },
104
+ data: function() {
105
+ return {
106
+ gradient: {
107
+ fx: 0.99,
108
+ fy: 0.5,
109
+ cx: 0.5,
110
+ cy: 0.5,
111
+ r: 0.65
112
+ },
113
+ gradientAnimation: null,
114
+ currentAngle: 0,
115
+ strokeDashoffset: 0
116
+ }
117
+ },
118
+ computed: {
119
+ over: function() {
120
+ if (this.completedSteps > this.totalSteps) {
121
+ return true;
122
+ }
123
+
124
+ return false;
125
+ },
126
+ complete: function() {
127
+ if (this.completedSteps === this.totalSteps) {
128
+ return true;
129
+ }
130
+
131
+ return false;
132
+ },
133
+ radius: function() {
134
+ return this.diameter / 2
135
+ },
136
+ circumference: function() {
137
+ return Math.PI * this.innerCircleDiameter
138
+ },
139
+ stepSize: function() {
140
+ if (this.totalSteps === 0) {
141
+ return 0
142
+ }
143
+ return 100 / this.totalSteps
144
+ },
145
+ finishedPercentage: function() {
146
+ return this.stepSize * this.completedSteps
147
+ },
148
+ circleSlice: function() {
149
+ return 2 * Math.PI / this.totalSteps
150
+ },
151
+ animateSlice: function() {
152
+ return this.circleSlice / this.totalPoints
153
+ },
154
+ innerCircleDiameter: function() {
155
+ return this.diameter - (this.strokeWidth * 2)
156
+ },
157
+ innerCircleRadius: function() {
158
+ return this.innerCircleDiameter / 2
159
+ },
160
+ totalPoints: function() {
161
+ return this.animateSpeed / this.animationIncrements
162
+ },
163
+ animationIncrements: function() {
164
+ return 1000 / this.fps
165
+ },
166
+ hasGradient: function() {
167
+ return true;
168
+ },
169
+ containerStyle: function() {
170
+ return {
171
+ height: this.diameter + 'px',
172
+ width: this.diameter + 'px'
173
+ }
174
+ },
175
+ progressStyle: function() {
176
+ return {
177
+ height: this.diameter + 'px',
178
+ width: this.diameter + 'px',
179
+ strokeWidth: this.strokeWidth + 'px',
180
+ strokeDashoffset: this.strokeDashoffset,
181
+ transition: 'stroke-dashoffset ' + this.animateSpeed + 'ms ' + this.timingFunc
182
+ }
183
+ },
184
+ strokeStyle: function() {
185
+ return {
186
+ height: this.diameter + 'px',
187
+ width: this.diameter + 'px',
188
+ strokeWidth: this.strokeWidth + 'px'
189
+ }
190
+ },
191
+ innerCircleStyle: function() {
192
+ return {
193
+ width: this.innerCircleDiameter + 'px'
194
+ }
195
+ }
196
+ },
197
+ methods: {
198
+ getStopPointsOfCircle: function(steps) {
199
+ var points = []
200
+ for (var i = 0; i < steps; i++) {
201
+ var angle = this.circleSlice * i
202
+ points.push(this.getPointOfCircle(angle))
203
+ }
204
+ return points
205
+ },
206
+ getPointOfCircle: function(angle) {
207
+ var radius = 0.5
208
+ var x = radius + (radius * Math.cos(angle))
209
+ var y = radius + (radius * Math.sin(angle))
210
+ return { x: x, y: y }
211
+ },
212
+ gotoPoint: function() {
213
+ var point = this.getPointOfCircle(this.currentAngle)
214
+ this.gradient.fx = point.x
215
+ this.gradient.fy = point.y
216
+ },
217
+ changeProgress: function(args) {
218
+ var ops = args || {};
219
+ var isAnimate = ops.isAnimate;
220
+ this.strokeDashoffset = ((100 - this.finishedPercentage) / 100) * this.circumference
221
+ if (this.gradientAnimation) {
222
+ clearInterval(this.gradientAnimation)
223
+ }
224
+ if (!isAnimate) {
225
+ this.gotoNextStep()
226
+ return
227
+ }
228
+ var angleOffset = (this.completedSteps - 1) * this.circleSlice
229
+ var i = (this.currentAngle - angleOffset) / this.animateSlice
230
+ var incrementer = Math.abs(i - this.totalPoints) / this.totalPoints
231
+ var isMoveForward = i < this.totalPoints
232
+ var self = this;
233
+ this.gradientAnimation = setInterval(function() {
234
+ if (isMoveForward && i >= self.totalPoints ||
235
+ !isMoveForward && i < self.totalPoints) {
236
+ clearInterval(self.gradientAnimation);
237
+ return;
238
+ }
239
+ self.currentAngle = angleOffset + (self.animateSlice * i);
240
+ self.gotoPoint();
241
+ i += isMoveForward ? incrementer : -incrementer;
242
+ }, self.animationIncrements)
243
+ },
244
+ gotoNextStep: function() {
245
+ this.currentAngle = this.completedSteps * this.circleSlice
246
+ this.gotoPoint();
247
+ }
248
+ },
249
+ watch: {
250
+ totalSteps: function() {
251
+ this.changeProgress({ isAnimate: true })
252
+ },
253
+ completedSteps: function() {
254
+ this.changeProgress({ isAnimate: true })
255
+ },
256
+ diameter: function() {
257
+ this.changeProgress({ isAnimate: true })
258
+ },
259
+ strokeWidth: function() {
260
+ this.changeProgress({ isAnimate: true })
261
+ }
262
+ },
263
+ created: function() {
264
+ this.changeProgress({ isAnimate: false })
265
+ }
266
+ });
267
+ })()