codelation_ui 1.0.1 → 1.0.57

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.
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
@@ -0,0 +1,103 @@
1
+ (function() {
2
+ "use strict";
3
+
4
+ App.vue.components.vueSpinner = Vue.extend({
5
+ template: ' <div class="vue-spinner" :class="classes" :style="styles">\
6
+ <svg class="vue-spinner-draw" viewBox="25 25 50 50" v-if="spinning">\
7
+ <circle class="vue-spinner-path" cx="50" cy="50" r="20" :stroke-width="stroke" :stroke-dasharray="dashProgress">\
8
+ </svg>\
9
+ <vue-checkmark v-if="success" :stroke="stroke" :size="size"></vue-checkmark>\
10
+ <vue-fail v-if="fail" :stroke="stroke" :size="size"></vue-fail>\
11
+ <span v-if="showMessage" class="vue-spinner-message" transition="v-fade-in-out">\
12
+ {{ message }}\
13
+ </span>\
14
+ </div>',
15
+ props: {
16
+ size: {
17
+ type: Number,
18
+ default: 50
19
+ },
20
+ stroke: {
21
+ type: Number,
22
+ default: 3.5
23
+ },
24
+ indeterminate: {
25
+ type: Boolean,
26
+ default: true
27
+ },
28
+ progress: {
29
+ type: Number,
30
+ default: null
31
+ },
32
+ success: {
33
+ type: Boolean,
34
+ default: false
35
+ },
36
+ message: {
37
+ type: String,
38
+ default: null
39
+ },
40
+ fail: {
41
+ type: Boolean,
42
+ default: false
43
+ }
44
+ },
45
+ computed: {
46
+ showMessage: function() {
47
+ if (this.message === null) {
48
+ return false;
49
+ }
50
+
51
+ if (this.success) {
52
+ return true;
53
+ }
54
+
55
+ if (this.fail) {
56
+ return true;
57
+ }
58
+
59
+ return false;
60
+ },
61
+ spinning: function() {
62
+ if (this.success) {
63
+ return false;
64
+ }
65
+
66
+ return true;
67
+ },
68
+ isIndeterminate: function() {
69
+ if (this.indeterminate) {
70
+ return true;
71
+ } else {
72
+ if (this.progress === null) {
73
+ return true;
74
+ }
75
+ }
76
+
77
+ return false;
78
+ },
79
+ classes: function() {
80
+ return {
81
+ 'vue-indeterminate': this.isIndeterminate
82
+ };
83
+ },
84
+ styles: function() {
85
+ var newSize = this.size + 'px';
86
+ return {
87
+ width: newSize,
88
+ height: newSize
89
+ };
90
+ },
91
+ dashProgress: function() {
92
+ if (this.isIndeterminate) {
93
+ return false;
94
+ }
95
+ var progress = this.progress * 125 / 100;
96
+ if (progress >= 125) {
97
+ progress = 130;
98
+ }
99
+ return progress + ', 200';
100
+ }
101
+ }
102
+ });
103
+ })();
@@ -69,429 +69,458 @@ Used to remove the icon if the field has one. Only effects Date types right now
69
69
  (function() {
70
70
  "use strict";
71
71
 
72
- App.register('component').enter(function() {
73
- var template = '<div class="vue-input" :class="[message ? \'has-message\' : \'\', disabled ? \'disabled\' : \'\']">\
74
- <i v-if="inputIcon" v-on:click="activeObject()" class="vue-input-icon fa" :class="[inputIcon]"></i>\
75
- <input :disabled="disabled" id="{{ id}}" type="text" name="{{ name }}" v-if="showInputFor(\'number\')" v-on:keyup.up="incrementValue()" v-on:keyup.down="decrementValue()" v-el:input v-model="inputValue" :placeholder="placeholder">\
76
- <input :disabled="disabled" id="{{ id}}" type="text" name="{{ name }}" v-if="showInputFor(\'string\')" v-el:input v-model="inputValue" :placeholder="placeholder">\
77
- <input :disabled="disabled" id="{{ id}}" type="text" name="{{ name }}" v-if="showInputFor(\'date\')" v-on:keyup.up="incrementValue()" v-on:keyup.down="decrementValue()" v-el:input v-model="inputValue" :placeholder="placeholder">\
78
- <input :disabled="disabled" id="{{ id}}" type="checkbox" name="{{ name }}" v-if="showInputFor(\'bool\')" v-el:input v-model="inputValue">\
79
- <input :disabled="disabled" id="{{ id}}" type="radio" name="{{ name }}" v-if="showInputFor(\'radio\')" v-el:input v-model="inputValue">\
80
- <select :disabled="disabled" id="{{ id}}" v-if="showInputFor(\'select\')" v-model="inputValue" name="{{ name }}">\
81
- <option v-for="option in optionsForSelect" :value="optionValue(option)">{{ optionLabel(option) }}</option>\
82
- </select>\
83
- <span v-if="showInputFor(\'toggle\')" class="vue-input-toggle">\
84
- <input :disabled="disabled" id="{{ id}}" name="{{ name }}" type="checkbox" v-model="inputValue">\
85
- <label for="{{ id}}"></label>\
86
- </span>\
87
- <div v-if="message" class="vue-input-message-container">\
88
- <i class="fa fa-exclamation-triangle"></i><div><h5>{{ message }}</h5><p v-if="inputFormat">Format: {{ inputFormat }}</p></div>\
89
- </div>\
90
- </div>'
91
-
92
- var inputTypeMap = {
93
- 'money':'money',
94
- 'currency':'money',
95
- 'number':'number',
96
- 'numeric':'number',
97
- 'date':'date',
98
- 'calendar':'date',
99
- 'percent':'percent',
100
- 'bool':'bool',
101
- 'check':'bool',
102
- 'boolean':'bool',
103
- 'toggle': 'toggle',
104
- 'text':'text',
105
- 'email':'text',
106
- 'phone':'text',
107
- 'option': 'radio',
108
- 'radio': 'radio',
109
- 'select':'select',
110
- 'list':'select'
72
+ var template = '<div class="vue-input" :class="[message ? \'has-message\' : \'\', disabled ? \'disabled\' : \'\', type]">\
73
+ <i v-if="inputIcon" v-on:click="activeObject()" class="vue-input-icon fa" :class="[inputIcon]"></i>\
74
+ <input :disabled="disabled" id="{{ id}}" type="text" name="{{ name }}" v-if="showInputFor(\'number\')" v-on:keyup.up="incrementValue()" v-on:keyup.down="decrementValue()" v-model="inputValue" :placeholder="placeholder" v-el:input>\
75
+ <input :disabled="disabled" id="{{ id}}" type="text" name="{{ name }}" v-if="showInputFor(\'string\')" v-model="inputValue" :placeholder="placeholder" v-el:input>\
76
+ <input :disabled="disabled" id="{{ id}}" type="text" name="{{ name }}" v-if="showInputFor(\'date\')" v-on:keyup.up="incrementValue()" v-on:keyup.down="decrementValue()" v-el:input v-model="inputValue" :placeholder="placeholder">\
77
+ <input :disabled="disabled" id="{{ id}}" type="checkbox" name="{{ name }}" v-if="showInputFor(\'bool\')" v-el:input v-model="inputValue">\
78
+ <input :disabled="disabled" id="{{ id}}" type="radio" name="{{ name }}" v-if="showInputFor(\'radio\')" v-el:input v-model="inputValue">\
79
+ <select :disabled="disabled" id="{{ id}}" v-if="showInputFor(\'select\')" v-model="inputValue" name="{{ name }}">\
80
+ <option v-for="option in optionsForSelect" :value="optionValue(option)">{{ optionLabel(option) }}</option>\
81
+ </select>\
82
+ <span v-if="showInputFor(\'toggle\')" class="vue-input-toggle">\
83
+ <input :disabled="disabled" id="{{ id}}" name="{{ name }}" type="checkbox" v-model="inputValue">\
84
+ <label for="{{ id}}"></label>\
85
+ </span>\
86
+ <div v-if="message" class="vue-input-message-container">\
87
+ <i class="fa fa-exclamation-triangle"></i><div><h5>{{ message }}</h5><p v-if="inputFormat">Format: {{ inputFormat }}</p></div>\
88
+ </div>\
89
+ </div>'
90
+
91
+ var inputTypeMap = {
92
+ 'money': 'money',
93
+ 'currency': 'money',
94
+ 'number': 'number',
95
+ 'numeric': 'number',
96
+ 'date': 'date',
97
+ 'calendar': 'date',
98
+ 'percent': 'percent',
99
+ 'bool': 'bool',
100
+ 'check': 'bool',
101
+ 'boolean': 'bool',
102
+ 'toggle': 'toggle',
103
+ 'text': 'text',
104
+ 'email': 'text',
105
+ 'phone': 'text',
106
+ 'option': 'radio',
107
+ 'radio': 'radio',
108
+ 'select': 'select',
109
+ 'list': 'select'
110
+ }
111
+
112
+ var dataTypeMap = {
113
+ 'money': 'number',
114
+ 'currency': 'number',
115
+ 'number': 'number',
116
+ 'integer': 'number',
117
+ 'float': 'number',
118
+ 'numeric': 'number',
119
+ 'date': 'date',
120
+ 'calendar': 'date',
121
+ 'percent': 'number',
122
+ 'bool': 'bool',
123
+ 'check': 'bool',
124
+ 'boolean': 'bool',
125
+ 'toggle': 'toggle',
126
+ 'text': 'string',
127
+ 'radio': 'radio',
128
+ 'select': 'select'
129
+ }
130
+
131
+ var autoNumericDefault = {
132
+ aSign: '',
133
+ pSign: 'p'
134
+ }
135
+
136
+ var numericDefaults = {
137
+ 'money': {
138
+ aSign: '$',
139
+ mDec: '2',
140
+ wEmpty: 'empty'
141
+ },
142
+ 'percent': {
143
+ aSign: '%',
144
+ mDec: '0',
145
+ wEmpty: 'empty'
146
+ },
147
+ 'number': {
148
+ wEmpty: 'empty'
149
+ },
150
+ 'integer': {
151
+ mDec: '0',
152
+ wEmpty: 'empty'
111
153
  }
112
-
113
- var dataTypeMap = {
114
- 'money':'number',
115
- 'currency':'number',
116
- 'number':'number',
117
- 'integer':'number',
118
- 'float':'number',
119
- 'numeric':'number',
120
- 'date':'date',
121
- 'calendar':'date',
122
- 'percent':'number',
123
- 'bool':'bool',
124
- 'check':'bool',
125
- 'boolean':'bool',
126
- 'toggle':'toggle',
127
- 'text':'string',
128
- 'radio':'radio',
129
- 'select':'select'
130
- }
131
-
132
- var numericDefaults = {
133
- 'money': {aSign: '$', mDec: '2', wEmpty: 'empty'},
134
- 'percent': {aSign: '%', pSign: 's', mDec: '0', wEmpty: 'empty'},
135
- 'number': {wEmpty: 'empty'},
136
- 'integer': {mDec: '0', wEmpty: 'empty'}
137
- }
138
-
139
- Vue.component('vue-input', {
140
- mixins: [App.vue.interfaces.formValidation, App.vue.interfaces.contentValidators, App.vue.interfaces.helpers],
141
- template: template,
142
- props: {
143
- 'type': {
144
- default: 'plain'
145
- },
146
- 'precision': {
147
- default: null
148
- },
149
- 'min': {
150
- default: null
151
- },
152
- 'max': {
153
- default: null
154
- },
155
- 'numberLabel': {
156
- default: null
157
- },
158
- 'numberPostLabel': {
159
- default: null
160
- },
161
- 'numberPreLabel': {
162
- default: null
163
- },
164
- 'restrictMax': {
165
- default: true
166
- },
167
- 'restrictMin': {
168
- default: true
169
- },
170
- 'placeholder': {
171
- default: null
172
- },
173
- 'required': {
174
- default: false
175
- },
176
- 'validate': {
177
- default: true
178
- },
179
- 'toString': {
180
- default: false
181
- },
182
- 'noIcon': {
183
- default: false
184
- },
185
- 'value': {
186
- twoWay: true
187
- },
188
- 'keyCodes': {
189
- default: true
190
- },
191
- 'id': {
192
- default: null
193
- },
194
- 'name': {
195
- default: null
196
- },
197
- 'optionsForSelect': {
198
- default: function() {return [];}
199
- },
200
- 'disabled': {
201
- default: false
202
- }
154
+ }
155
+
156
+ App.vue.components.vueInput = Vue.extend({
157
+ mixins: [App.vue.interfaces.formValidation, App.vue.interfaces.contentValidators, App.vue.interfaces.helpers],
158
+ template: template,
159
+ props: {
160
+ 'type': {
161
+ default: 'plain'
203
162
  },
204
- data: function() {
205
- return {
206
- inputValue: null,
207
- message: null,
208
- inputFormat: null,
209
- validating: false,
210
- formatting: true,
211
- renderHTML: false,
212
- obj: null,
213
- showInput: false,
214
- initialValue: this.value,
215
- }
163
+ 'precision': {
164
+ default: null
165
+ },
166
+ 'min': {
167
+ default: null
168
+ },
169
+ 'max': {
170
+ default: null
171
+ },
172
+ 'numberLabel': {
173
+ default: null
174
+ },
175
+ 'numberPostLabel': {
176
+ default: null
177
+ },
178
+ 'numberPreLabel': {
179
+ default: null
180
+ },
181
+ 'restrictMax': {
182
+ default: true
183
+ },
184
+ 'restrictMin': {
185
+ default: true
186
+ },
187
+ 'placeholder': {
188
+ default: null
189
+ },
190
+ 'required': {
191
+ default: false
216
192
  },
217
- ready: function() {
218
- if (this._valueIsEmpty(this.id)) {
219
- this.id = this._randomId();
193
+ 'validate': {
194
+ default: true
195
+ },
196
+ 'toString': {
197
+ default: false
198
+ },
199
+ 'noIcon': {
200
+ default: false
201
+ },
202
+ 'value': {
203
+ twoWay: true
204
+ },
205
+ 'keyCodes': {
206
+ default: true
207
+ },
208
+ 'id': {
209
+ default: null
210
+ },
211
+ 'name': {
212
+ default: null
213
+ },
214
+ 'optionsForSelect': {
215
+ default: function() {
216
+ return [];
220
217
  }
218
+ },
219
+ 'disabled': {
220
+ default: false
221
+ }
222
+ },
223
+ data: function() {
224
+ return {
225
+ inputValue: null,
226
+ message: null,
227
+ inputFormat: null,
228
+ validating: false,
229
+ formatting: true,
230
+ renderHTML: false,
231
+ obj: null,
232
+ showInput: false,
233
+ initialValue: this.value,
234
+ }
235
+ },
236
+ ready: function() {
237
+ if (this._valueIsEmpty(this.id)) {
238
+ this.id = this._randomId();
239
+ }
221
240
 
222
- // set the initial value
223
- if (this.isDate) {
224
- if (this._valueIsEmpty(this.value)) {
225
- this.inputValue = this.value;
226
- }else{
227
- this.inputValue = moment(this.value).format(this._formatForDate());
228
- }
229
- }else{
241
+ // set the initial value
242
+ if (this.isDate) {
243
+ if (this._valueIsEmpty(this.value)) {
230
244
  this.inputValue = this.value;
245
+ } else {
246
+ this.inputValue = moment(this.value).format(this._formatForDate());
231
247
  }
248
+ } else {
249
+ this.inputValue = this.value;
250
+ }
232
251
 
233
- this.renderHTML = true;
234
- var self = this;
235
- this.$nextTick(function(){
236
- self.setupNumber();
237
- self.setupDate();
238
- self.validating = true;
239
- $(self.$els.input).on('focus', self.validateContent);
240
- });
241
- },
242
- beforeDestroy: function() {
243
- try {
244
- $(self.$els.input).off('focus');
245
- $(this.$els.input).autoNumeric('destroy');
246
- this.obj.destroy();
247
- }catch(err){}
248
- },
249
- watch: {
250
- disabled: function(newValue) {
251
- if (newValue) {
252
- this.validateContent();
252
+ this.renderHTML = true;
253
+ var self = this;
254
+ this.$nextTick(function() {
255
+ self.setupNumber();
256
+ self.setupDate();
257
+ self.validating = true;
258
+ $(self.$els.input).on('focus', self.validateContent);
259
+ });
260
+ },
261
+ beforeDestroy: function() {
262
+ try {
263
+ $(self.$els.input).off('focus');
264
+ $(this.$els.input).autoNumeric('destroy');
265
+ this.obj.destroy();
266
+ } catch (err) {}
267
+ },
268
+ watch: {
269
+ disabled: function(newValue) {
270
+ if (newValue) {
271
+ this.validateContent();
272
+ }
273
+ },
274
+ inputValue: function(newValue) {
275
+ if (this.toString) {
276
+ this.value = String(newValue);
277
+ } else if (this.isDate) {
278
+ if (this._valueIsEmpty(newValue)) {
279
+ this.value = null;
280
+ } else {
281
+ this.value = new Date(newValue);
253
282
  }
254
- },
255
- inputValue: function(newValue) {
256
- if (this.toString) {
257
- this.value = String(newValue);
258
- }else if (this.isDate) {
259
- if (this._valueIsEmpty(newValue)) {
260
- this.value = null;
261
- }else{
262
- this.value = new Date(newValue);
263
- }
264
- }else if (this.isNumber){
265
- try{
266
- this.value = $(this.$els.input).autoNumeric('get');
267
- }catch(e){
268
- this.value = newValue;
269
- }
270
- }else{
283
+ } else if (this.isNumber) {
284
+ try {
285
+ this.value = $(this.$els.input).autoNumeric('get');
286
+ } catch (e) {
271
287
  this.value = newValue;
272
288
  }
273
- this.formatContent();
274
- this.validateContent();
289
+ } else {
290
+ this.value = newValue;
275
291
  }
276
- },
277
- methods: {
278
- setupDate: function() {
279
- if (this.isDate) {
280
- var options = {
281
- field: this.$els.input,
282
- format: this._formatForDate()
283
- };
292
+ this.formatContent();
293
+ this.validateContent();
294
+ }
295
+ },
296
+ methods: {
297
+ setupDate: function() {
298
+ if (this.isDate) {
299
+ var options = {
300
+ field: this.$els.input,
301
+ format: this._formatForDate()
302
+ };
284
303
 
285
- if (this.hasRestrictedMax) {
286
- options['maxDate'] = new Date(this.max);
287
- }
288
- if (this.hasRestrictedMin) {
289
- options['minDate'] = new Date(this.min);
290
- }
291
- this.obj = new Pikaday(options);
304
+ if (this.hasRestrictedMax) {
305
+ options['maxDate'] = new Date(this.max);
292
306
  }
293
- },
294
- setupNumber: function() {
295
- if (this.isNumber) {
296
- var baseOptions = numericDefaults[this.type] || numericDefaults[this.dataType] || {};
297
- if (this.precision) {
298
- baseOptions['mDec'] = this.precision;
299
- }
300
- if (this.hasRestrictedMax) {
301
- baseOptions['vMax'] = this.max;
302
- }
303
- if (this.hasRestrictedMin) {
304
- baseOptions['vMin'] = this.min;
305
- }
306
-
307
- if (this.numberPostLabel || this.numberLabel) {
308
- baseOptions['aSign'] = this.numberPostLabel || this.numberLabel;
309
- baseOptions['pSign'] = 's';
310
- }else if (this.numberPreLabel) {
311
- baseOptions['aSign'] = this.numberPreLabel;
312
- baseOptions['pSign'] = 'p';
313
- }
314
-
315
- var self = this;
316
- $(this.$els.input).autoNumeric('init', baseOptions).on('keyup', function() {
317
- self.value = $(self.$els.input).autoNumeric('get');
318
- });
319
- $(this.$els.input).autoNumeric('set', this.inputValue);
307
+ if (this.hasRestrictedMin) {
308
+ options['minDate'] = new Date(this.min);
309
+ }
310
+ this.obj = new Pikaday(options);
311
+ }
312
+ },
313
+ setupNumber: function() {
314
+ if (this.isNumber) {
315
+
316
+ // Set options
317
+ var baseOptions = JSON.parse(JSON.stringify(autoNumericDefault));
318
+ var additionals = numericDefaults[this.type] || numericDefaults[this.dataType] || {};
319
+ Object.keys(additionals).forEach(function(opt) {
320
+ baseOptions[opt] = additionals[opt];
321
+ });
322
+
323
+ if (this.precision) {
324
+ baseOptions['mDec'] = this.precision;
320
325
  }
321
- },
322
- showInputFor: function(type) {
323
- if (!this.renderHTML) {
324
- return false;
326
+ if (this.hasRestrictedMax) {
327
+ baseOptions['vMax'] = this.max;
328
+ }
329
+ if (this.hasRestrictedMin) {
330
+ baseOptions['vMin'] = this.min;
325
331
  }
326
332
 
327
- return this.dataType === type;
328
- },
329
- incrementValue: function() {
330
- if (this.keyCodes) {
331
- if (this.isDate) {
332
- this.obj.nextMonth();
333
- }
333
+ if (this.numberPostLabel || this.numberLabel) {
334
+ baseOptions['aSign'] = this.numberPostLabel || this.numberLabel;
335
+ baseOptions['pSign'] = 's';
336
+ } else if (this.numberPreLabel) {
337
+ baseOptions['aSign'] = this.numberPreLabel;
338
+ baseOptions['pSign'] = 'p';
339
+ }
334
340
 
335
- if (this.isNumber) {
336
- if (this.inputValue < this.max) {
337
- this.inputValue++;
338
- }
339
- }
341
+ var self = this;
342
+ try {
343
+ $(this.$els.input).autoNumeric('destroy');
344
+ } catch (err) {}
345
+
346
+ $(this.$els.input).autoNumeric('init', baseOptions).on('keyup', function() {
347
+ self.value = $(self.$els.input).autoNumeric('get');
348
+ });
349
+ $(this.$els.input).autoNumeric('set', this.inputValue);
350
+ }
351
+ },
352
+ showInputFor: function(type) {
353
+ if (!this.renderHTML) {
354
+ return false;
355
+ }
356
+
357
+ return this.dataType === type;
358
+ },
359
+ incrementValue: function() {
360
+ if (this.keyCodes) {
361
+ if (this.isDate) {
362
+ this.obj.nextMonth();
340
363
  }
341
- },
342
- decrementValue: function() {
343
- if (this.keyCodes) {
344
- if (this.isDate) {
345
- this.obj.prevMonth();
346
- }
347
364
 
348
- if (this.isNumber) {
349
- if (this.inputValue > this.min) {
350
- this.inputValue--;
351
- }
365
+ if (this.isNumber) {
366
+ if (this.inputValue < this.max) {
367
+ this.inputValue++;
352
368
  }
353
369
  }
354
- },
355
- activeObject: function() {
370
+ }
371
+ },
372
+ decrementValue: function() {
373
+ if (this.keyCodes) {
356
374
  if (this.isDate) {
357
- this.obj.show();
375
+ this.obj.prevMonth();
358
376
  }
359
- },
360
- formatContent: function() {
361
- if (this.formatting) {
362
- if (this.type === 'phone' && this._valueIsPhone(this.inputValue)) {
363
- this.inputValue = App.vue.interfaces.formatters.methods._formatToPhoneNumber(this.inputValue);
377
+
378
+ if (this.isNumber) {
379
+ if (this.inputValue > this.min) {
380
+ this.inputValue--;
364
381
  }
365
382
  }
366
- },
367
- validateContent: function() {
368
- this.message = null;
369
- this.inputFormat = null;
370
- if (this.validating && !this.disabled) {
371
- if (this._valueIsEmpty(this.inputValue)) {
372
- if (this.required) {
373
- this.message = "This can't be empty";
374
- this.inputFormat = this._formatForEmpty();
375
- return false;
376
- }else{
377
- // Empty but not required
378
- return true;
379
- }
383
+ }
384
+ },
385
+ activeObject: function() {
386
+ if (this.isDate) {
387
+ this.obj.show();
388
+ }
389
+ },
390
+ formatContent: function() {
391
+ if (this.formatting) {
392
+ if (this.type === 'phone' && this._valueIsPhone(this.inputValue)) {
393
+ this.inputValue = App.vue.interfaces.formatters.methods._formatToPhoneNumber(this.inputValue);
394
+ }
395
+ }
396
+ },
397
+ validateContent: function() {
398
+ this.message = null;
399
+ this.inputFormat = null;
400
+ if (this.validating && !this.disabled) {
401
+ if (this._valueIsEmpty(this.inputValue)) {
402
+ if (this.required) {
403
+ this.message = "This can't be empty";
404
+ this.inputFormat = this._formatForEmpty();
405
+ return false;
406
+ } else {
407
+ // Empty but not required
408
+ return true;
380
409
  }
410
+ }
381
411
 
382
- if (this.validate) {
383
- if (this.type === 'email') {
384
- var res = this._valueIsEmail(this.inputValue);
385
- if (!res) {
386
- this.message = "Not a valid email address.";
387
- this.inputFormat = this._formatForEmail();
388
- }
389
- return res;
390
- }else if (this.type === 'phone') {
391
- var res = this._valueIsPhone(this.inputValue);
392
- if (!res) {
393
- this.message = "Not a valid phone number.";
394
- this.inputFormat = this._formatForPhone();
395
- }
396
- return res;
397
- }else if (this.isDate) {
398
- var res = this._valueIsDate(this.inputValue);
399
- if (!res) {
400
- this.message = "Not a valid date.";
401
- this.inputFormat = this._formatForDate();
402
- }
403
- return res;
404
- }else if (this.isNumber) {
405
- if (this.hasUnrestrictedMax && numeral(this.inputValue).value() > this.max) {
406
- this.message = "Number out of range.";
407
- this.inputFormat = "less than or equal to " + this.max;
408
- }else if (this.hasUnrestrictedMin && numeral(this.inputValue).value() < this.min) {
409
- this.message = "Number out of range.";
410
- this.inputFormat = "greater than or equal to " + this.min;
411
- }
412
- }else{
413
- return true;
412
+ if (this.validate) {
413
+ if (this.type === 'email') {
414
+ var res = this._valueIsEmail(this.inputValue);
415
+ if (!res) {
416
+ this.message = "Not a valid email address.";
417
+ this.inputFormat = this._formatForEmail();
418
+ }
419
+ return res;
420
+ } else if (this.type === 'phone') {
421
+ var res = this._valueIsPhone(this.inputValue);
422
+ if (!res) {
423
+ this.message = "Not a valid phone number.";
424
+ this.inputFormat = this._formatForPhone();
425
+ }
426
+ return res;
427
+ } else if (this.isDate) {
428
+ var res = this._valueIsDate(this.inputValue);
429
+ if (!res) {
430
+ this.message = "Not a valid date.";
431
+ this.inputFormat = this._formatForDate();
432
+ }
433
+ return res;
434
+ } else if (this.isNumber) {
435
+ if (this.hasUnrestrictedMax && numeral(this.inputValue).value() > this.max) {
436
+ this.message = "Number out of range.";
437
+ this.inputFormat = "less than or equal to " + this.max;
438
+ } else if (this.hasUnrestrictedMin && numeral(this.inputValue).value() < this.min) {
439
+ this.message = "Number out of range.";
440
+ this.inputFormat = "greater than or equal to " + this.min;
414
441
  }
442
+ } else {
443
+ return true;
415
444
  }
416
445
  }
446
+ }
447
+ return true;
448
+ },
449
+ optionValue: function(option) {
450
+ return option.value || option;
451
+ },
452
+ optionLabel: function(option) {
453
+ return option.label || option;
454
+ }
455
+ },
456
+ computed: {
457
+ inputType: function() {
458
+ return inputTypeMap[this.type] || 'text';
459
+ },
460
+ dataType: function() {
461
+ return dataTypeMap[this.inputType] || 'string';
462
+ },
463
+ isNumber: function() {
464
+ if (this.dataType === 'number') {
417
465
  return true;
418
- },
419
- optionValue: function(option) {
420
- return option.value || option;
421
- },
422
- optionLabel: function(option) {
423
- return option.label || option;
466
+ } else {
467
+ return false;
424
468
  }
425
469
  },
426
- computed: {
427
- inputType: function() {
428
- return inputTypeMap[this.type] || 'text';
429
- },
430
- dataType: function() {
431
- return dataTypeMap[this.inputType] || 'string';
432
- },
433
- isNumber: function() {
434
- if (this.dataType === 'number') {
435
- return true;
436
- }else{
437
- return false;
438
- }
439
- },
440
- isDate: function() {
441
- if (this.dataType === 'date') {
442
- return true;
443
- }else{
444
- return false;
445
- }
446
- },
447
- isBool: function() {
448
- if (this.dataType === 'bool') {
449
- return true;
450
- }else{
451
- return false;
452
- }
453
- },
454
- isString: function() {
455
- if (this.dataType === 'string') {
456
- return true;
457
- }else{
458
- return false;
459
- }
460
- },
461
- hasRestrictedMax: function() {
462
- if (this.max !== null && this.restrictMax) {
463
- return true;
464
- }else{
465
- return false;
466
- }
467
- },
468
- hasRestrictedMin: function() {
469
- if (this.min !== null && this.restrictMin) {
470
- return true;
471
- }else{
472
- return false;
473
- }
474
- },
475
- hasUnrestrictedMax: function() {
476
- if (this.max !== null && !this.restrictMax) {
477
- return true;
478
- }else{
479
- return false;
480
- }
481
- },
482
- hasUnrestrictedMin: function() {
483
- if (this.min !== null && !this.restrictMin) {
484
- return true;
485
- }else{
486
- return false;
487
- }
488
- },
489
- inputIcon: function() {
490
- if (this.isDate && !this.init) {
491
- return 'fa-calendar';
492
- }
470
+ isDate: function() {
471
+ if (this.dataType === 'date') {
472
+ return true;
473
+ } else {
474
+ return false;
475
+ }
476
+ },
477
+ isBool: function() {
478
+ if (this.dataType === 'bool') {
479
+ return true;
480
+ } else {
481
+ return false;
482
+ }
483
+ },
484
+ isString: function() {
485
+ if (this.dataType === 'string') {
486
+ return true;
487
+ } else {
488
+ return false;
489
+ }
490
+ },
491
+ hasRestrictedMax: function() {
492
+ if (this.max !== null && this.restrictMax) {
493
+ return true;
494
+ } else {
495
+ return false;
496
+ }
497
+ },
498
+ hasRestrictedMin: function() {
499
+ if (this.min !== null && this.restrictMin) {
500
+ return true;
501
+ } else {
502
+ return false;
503
+ }
504
+ },
505
+ hasUnrestrictedMax: function() {
506
+ if (this.max !== null && !this.restrictMax) {
507
+ return true;
508
+ } else {
509
+ return false;
510
+ }
511
+ },
512
+ hasUnrestrictedMin: function() {
513
+ if (this.min !== null && !this.restrictMin) {
514
+ return true;
515
+ } else {
516
+ return false;
517
+ }
518
+ },
519
+ inputIcon: function() {
520
+ if (this.isDate && !this.init) {
521
+ return 'fa-calendar';
493
522
  }
494
523
  }
495
- });
524
+ }
496
525
  });
497
526
  })();