codelation_ui 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +20 -0
- data/README.md +327 -0
- data/Rakefile +8 -0
- data/app/assets/javascripts/codelation_ui/_base_resources/app.js +91 -0
- data/app/assets/javascripts/codelation_ui/_base_resources/components/has_grid.js +24 -0
- data/app/assets/javascripts/codelation_ui/_base_resources/components/link.js +22 -0
- data/app/assets/javascripts/codelation_ui/_base_resources/progress_bar.js +5 -0
- data/app/assets/javascripts/codelation_ui/base.js +8 -0
- data/app/assets/javascripts/codelation_ui/extended/slider.js +654 -0
- data/app/assets/javascripts/codelation_ui/extended.js +1 -0
- data/app/assets/javascripts/codelation_ui/forms/components/input.js +497 -0
- data/app/assets/javascripts/codelation_ui/forms/index.js +2 -0
- data/app/assets/javascripts/codelation_ui/forms/interfaces/form.js +71 -0
- data/app/assets/javascripts/codelation_ui/forms/interfaces/form_validation.js +31 -0
- data/app/assets/javascripts/codelation_ui/forms.js +2 -0
- data/app/assets/javascripts/codelation_ui/std/index.js +2 -0
- data/app/assets/javascripts/codelation_ui/std/interfaces/content_formatters.js +27 -0
- data/app/assets/javascripts/codelation_ui/std/interfaces/content_validators.js +50 -0
- data/app/assets/javascripts/codelation_ui/std/interfaces/helpers.js +10 -0
- data/app/assets/javascripts/codelation_ui/std.js +1 -0
- data/app/assets/javascripts/codelation_ui/vue.js +12 -0
- data/app/assets/javascripts/codelation_ui/vue_pages.js +11 -0
- data/app/assets/javascripts/codelation_ui.js +6 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/_normalize.scss +427 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/_bourbon-deprecated-upcoming.scss +411 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/_bourbon.scss +87 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_border-color.scss +26 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_border-radius.scss +48 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_border-style.scss +25 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_border-width.scss +25 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_buttons.scss +64 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_clearfix.scss +25 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_ellipsis.scss +30 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_font-stacks.scss +31 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_hide-text.scss +27 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_margin.scss +26 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_padding.scss +26 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_position.scss +48 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_prefixer.scss +66 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_retina-image.scss +25 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_size.scss +51 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_text-inputs.scss +113 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_timing-functions.scss +34 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_triangle.scss +63 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_word-wrap.scss +29 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_animation.scss +43 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_appearance.scss +3 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_backface-visibility.scss +3 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_background-image.scss +42 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_background.scss +55 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_border-image.scss +59 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_calc.scss +4 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_columns.scss +47 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_filter.scss +4 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_flex-box.scss +287 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_font-face.scss +24 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_font-feature-settings.scss +4 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_hidpi-media-query.scss +10 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_hyphens.scss +4 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_image-rendering.scss +14 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_keyframes.scss +36 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_linear-gradient.scss +38 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_perspective.scss +8 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_placeholder.scss +8 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_radial-gradient.scss +39 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_selection.scss +42 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_text-decoration.scss +19 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_transform.scss +15 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_transition.scss +71 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_user-select.scss +3 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_assign-inputs.scss +11 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_contains-falsy.scss +20 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_contains.scss +26 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_is-length.scss +11 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_is-light.scss +21 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_is-number.scss +11 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_is-size.scss +13 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_modular-scale.scss +69 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_px-to-em.scss +13 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_px-to-rem.scss +15 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_shade.scss +24 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_strip-units.scss +17 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_tint.scss +24 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_transition-property-name.scss +22 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_unpack.scss +27 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_convert-units.scss +21 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_directional-values.scss +96 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_font-source-declaration.scss +43 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_gradient-positions-parser.scss +13 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_linear-angle-parser.scss +25 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_linear-gradient-parser.scss +41 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_linear-positions-parser.scss +61 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_linear-side-corner-parser.scss +31 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_radial-arg-parser.scss +69 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_radial-gradient-parser.scss +50 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_radial-positions-parser.scss +18 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_render-gradients.scss +26 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_shape-size-stripper.scss +10 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_str-to-num.scss +50 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/settings/_asset-pipeline.scss +7 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/settings/_prefixer.scss +9 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/settings/_px-to-em.scss +1 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/functions/color.scss +162 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/functions/text_color.scss +41 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/mixins/button.scss +47 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/mixins/center_children.scss +9 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/mixins/col_span.scss +16 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/mixins/has_cards.scss +43 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/mixins/has_columns.scss +66 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/mixins/has_grid.scss +80 -0
- data/app/assets/stylesheets/codelation_ui/_base_resources/mixins/outer_container.scss +10 -0
- data/app/assets/stylesheets/codelation_ui/base.scss +27 -0
- data/app/assets/stylesheets/codelation_ui/extended/slider.scss +222 -0
- data/app/assets/stylesheets/codelation_ui/extended.scss +1 -0
- data/app/assets/stylesheets/codelation_ui/forms/input.scss +72 -0
- data/app/assets/stylesheets/codelation_ui/forms.scss +1 -0
- data/app/assets/stylesheets/codelation_ui/std.scss +1 -0
- data/app/assets/stylesheets/codelation_ui.scss +4 -0
- data/lib/codelation_ui.rb +7 -0
- data/vendor/assets/javascripts/autonumeric/autoNumeric-1.9.39.js +1465 -0
- data/vendor/assets/javascripts/autonumeric/autonumeric_ujs.js +94 -0
- data/vendor/assets/javascripts/autonumeric.js +2 -0
- data/vendor/assets/javascripts/awesomplete.js +392 -0
- data/vendor/assets/javascripts/moment.js +4301 -0
- data/vendor/assets/javascripts/numeral.js +679 -0
- data/vendor/assets/javascripts/pikaday.js +1081 -0
- data/vendor/assets/javascripts/summernote.js +7300 -0
- data/vendor/assets/javascripts/vue.js +10237 -0
- metadata +242 -0
@@ -0,0 +1,497 @@
|
|
1
|
+
//= require pikaday
|
2
|
+
//= require autonumeric
|
3
|
+
|
4
|
+
/*
|
5
|
+
DOCUMENTATION
|
6
|
+
==============
|
7
|
+
Examples
|
8
|
+
-------------
|
9
|
+
|
10
|
+
Plain Text Inputs
|
11
|
+
<vue-input :value.sync="variable" placeholder="Variable Input"></vue-input>
|
12
|
+
|
13
|
+
Email Inputs
|
14
|
+
<vue-input :value.sync="email" placeholder="Your email" type="email"></vue-input>
|
15
|
+
|
16
|
+
Date Inputs
|
17
|
+
<vue-input :value.sync="when" placeholder="When" type="calendar"></vue-input>
|
18
|
+
|
19
|
+
Number Inputs
|
20
|
+
<vue-input :value.sync="number" placeholder="Enter a number" type="number"></vue-input>
|
21
|
+
<vue-input :value.sync="number" placeholder="Enter a number" type="money"></vue-input>
|
22
|
+
<vue-input :value.sync="number" placeholder="Enter a number" type="percent"></vue-input>
|
23
|
+
|
24
|
+
Required positive number with upper unrestricted bounds
|
25
|
+
<vue-input :value.sync="number" placeholder="Enter a number" type="percent" :min="0" :max="100" :unrestricted-max="true"></vue-input>
|
26
|
+
|
27
|
+
Options
|
28
|
+
-------------
|
29
|
+
type -> alias (plain text - no type)
|
30
|
+
calendar -> calendar, date
|
31
|
+
percent -> percent
|
32
|
+
number -> number, numeric
|
33
|
+
money -> money, currency
|
34
|
+
email -> email
|
35
|
+
|
36
|
+
precision (null)
|
37
|
+
Used on any number type (percent, number, money) to set the amount
|
38
|
+
of decimals used. The defaults are 2 for numbers, 0 for percent, and 3 for money
|
39
|
+
|
40
|
+
min (null)
|
41
|
+
Sets the minimum value on number types (percent, number, money).
|
42
|
+
|
43
|
+
restrictMin (true)
|
44
|
+
Used to show a message rather than restrict actual input
|
45
|
+
|
46
|
+
max (null)
|
47
|
+
Sets the maximum value on number types (percent, number, money).
|
48
|
+
|
49
|
+
restrictMax (true)
|
50
|
+
Used to show a message rather than restrict actual input
|
51
|
+
|
52
|
+
placeholder (null)
|
53
|
+
Used to set the placeholder
|
54
|
+
|
55
|
+
required (false)
|
56
|
+
Used to show a message if the field is empty
|
57
|
+
|
58
|
+
validate (true)
|
59
|
+
Validates the format of the input if available. Currently this
|
60
|
+
only supports the following types (email, date, unrestricted min and max)
|
61
|
+
|
62
|
+
toString (false)
|
63
|
+
Return the string version of the input rather than either a number or a date
|
64
|
+
|
65
|
+
noIcon (false)
|
66
|
+
Used to remove the icon if the field has one. Only effects Date types right now.
|
67
|
+
*/
|
68
|
+
|
69
|
+
(function() {
|
70
|
+
"use strict";
|
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'
|
111
|
+
}
|
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
|
+
}
|
203
|
+
},
|
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
|
+
}
|
216
|
+
},
|
217
|
+
ready: function() {
|
218
|
+
if (this._valueIsEmpty(this.id)) {
|
219
|
+
this.id = this._randomId();
|
220
|
+
}
|
221
|
+
|
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{
|
230
|
+
this.inputValue = this.value;
|
231
|
+
}
|
232
|
+
|
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();
|
253
|
+
}
|
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{
|
271
|
+
this.value = newValue;
|
272
|
+
}
|
273
|
+
this.formatContent();
|
274
|
+
this.validateContent();
|
275
|
+
}
|
276
|
+
},
|
277
|
+
methods: {
|
278
|
+
setupDate: function() {
|
279
|
+
if (this.isDate) {
|
280
|
+
var options = {
|
281
|
+
field: this.$els.input,
|
282
|
+
format: this._formatForDate()
|
283
|
+
};
|
284
|
+
|
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);
|
292
|
+
}
|
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);
|
320
|
+
}
|
321
|
+
},
|
322
|
+
showInputFor: function(type) {
|
323
|
+
if (!this.renderHTML) {
|
324
|
+
return false;
|
325
|
+
}
|
326
|
+
|
327
|
+
return this.dataType === type;
|
328
|
+
},
|
329
|
+
incrementValue: function() {
|
330
|
+
if (this.keyCodes) {
|
331
|
+
if (this.isDate) {
|
332
|
+
this.obj.nextMonth();
|
333
|
+
}
|
334
|
+
|
335
|
+
if (this.isNumber) {
|
336
|
+
if (this.inputValue < this.max) {
|
337
|
+
this.inputValue++;
|
338
|
+
}
|
339
|
+
}
|
340
|
+
}
|
341
|
+
},
|
342
|
+
decrementValue: function() {
|
343
|
+
if (this.keyCodes) {
|
344
|
+
if (this.isDate) {
|
345
|
+
this.obj.prevMonth();
|
346
|
+
}
|
347
|
+
|
348
|
+
if (this.isNumber) {
|
349
|
+
if (this.inputValue > this.min) {
|
350
|
+
this.inputValue--;
|
351
|
+
}
|
352
|
+
}
|
353
|
+
}
|
354
|
+
},
|
355
|
+
activeObject: function() {
|
356
|
+
if (this.isDate) {
|
357
|
+
this.obj.show();
|
358
|
+
}
|
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);
|
364
|
+
}
|
365
|
+
}
|
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
|
+
}
|
380
|
+
}
|
381
|
+
|
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;
|
414
|
+
}
|
415
|
+
}
|
416
|
+
}
|
417
|
+
return true;
|
418
|
+
},
|
419
|
+
optionValue: function(option) {
|
420
|
+
return option.value || option;
|
421
|
+
},
|
422
|
+
optionLabel: function(option) {
|
423
|
+
return option.label || option;
|
424
|
+
}
|
425
|
+
},
|
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
|
+
}
|
493
|
+
}
|
494
|
+
}
|
495
|
+
});
|
496
|
+
});
|
497
|
+
})();
|
@@ -0,0 +1,71 @@
|
|
1
|
+
(function() {
|
2
|
+
"use strict";
|
3
|
+
|
4
|
+
// Exposes method validateForm(success, fail)
|
5
|
+
|
6
|
+
App.vue.interfaces.form = {
|
7
|
+
data: function() {
|
8
|
+
return {
|
9
|
+
_formValidationWatch: true,
|
10
|
+
_formValidationInputs: 0,
|
11
|
+
_formValidationResponded: 0,
|
12
|
+
_formValidationValid: true,
|
13
|
+
_formValidationValidAction: null,
|
14
|
+
_formValidationInvalidAction: null,
|
15
|
+
_formValidationErrorMessage: null,
|
16
|
+
_formValidationDeveloperMode: false
|
17
|
+
}
|
18
|
+
},
|
19
|
+
ready: function() {
|
20
|
+
if (App.vue.config.disableVueFormValidations == true) {
|
21
|
+
this._formValidationDeveloperMode = true;
|
22
|
+
console.error("VUE FORMS DEVELOPER MODE: Validations will not fail the form");
|
23
|
+
}
|
24
|
+
},
|
25
|
+
methods: {
|
26
|
+
_formValidationRespondToForm: function() {
|
27
|
+
if (this._formValidationWatch && this._formValidationResponded === this._formValidationInputs) {
|
28
|
+
if (this._formValidationValid && typeof this._formValidationValidAction === 'function') {
|
29
|
+
this._formValidationValidAction();
|
30
|
+
}else if (!this._formValidationValid && typeof this._formValidationInvalidAction === 'function') {
|
31
|
+
this._formValidationInvalidAction();
|
32
|
+
}
|
33
|
+
}
|
34
|
+
},
|
35
|
+
_formValidationValidateCallback: function(valid) {
|
36
|
+
this._formValidationResponded++;
|
37
|
+
if (this._formValidationValid) {
|
38
|
+
this._formValidationValid = valid;
|
39
|
+
}
|
40
|
+
this._formValidationRespondToForm();
|
41
|
+
},
|
42
|
+
validateForm: function(successCB, failCB) {
|
43
|
+
if (this._formValidationDeveloperMode === true) {
|
44
|
+
successCB();
|
45
|
+
return;
|
46
|
+
}
|
47
|
+
this._formValidationWatch = false;
|
48
|
+
this._formValidationErrorMessage = null;
|
49
|
+
this._formValidationResponded = 0;
|
50
|
+
this._formValidationValid = true;
|
51
|
+
this._formValidationValidAction = successCB || null;
|
52
|
+
this._formValidationInvalidAction = failCB || null;
|
53
|
+
this._formValidationWatch = true;
|
54
|
+
|
55
|
+
if (this._formValidationInputs < 1) {
|
56
|
+
this._formValidationRespondToForm();
|
57
|
+
}else{
|
58
|
+
this.$broadcast('_form-validation-validate-inputs', this._formValidationValidateCallback);
|
59
|
+
}
|
60
|
+
}
|
61
|
+
},
|
62
|
+
events: {
|
63
|
+
'_form-validation-inputs-check-in': function() {
|
64
|
+
this._formValidationInputs++;
|
65
|
+
},
|
66
|
+
'_form-validation-inputs-check-out': function() {
|
67
|
+
this._formValidationInputs--;
|
68
|
+
}
|
69
|
+
}
|
70
|
+
};
|
71
|
+
})();
|
@@ -0,0 +1,31 @@
|
|
1
|
+
(function() {
|
2
|
+
"use strict";
|
3
|
+
|
4
|
+
App.vue.interfaces.formValidation = {
|
5
|
+
ready: function() {
|
6
|
+
// Check the input into the vue form
|
7
|
+
this.$dispatch('_form-validation-inputs-check-in');
|
8
|
+
},
|
9
|
+
beforeDestroy: function() {
|
10
|
+
// check out the input from the vue form
|
11
|
+
this.$dispatch('_form-validation-inputs-check-out');
|
12
|
+
},
|
13
|
+
events: {
|
14
|
+
'_form-validation-validate-inputs': function(callback){
|
15
|
+
var valid = true;
|
16
|
+
if (!this.validateContent()) {
|
17
|
+
valid = false;
|
18
|
+
}
|
19
|
+
if (typeof callback === 'function') {
|
20
|
+
callback(valid);
|
21
|
+
}
|
22
|
+
}
|
23
|
+
},
|
24
|
+
methods: {
|
25
|
+
validateContent: function(){
|
26
|
+
console.warn('Method no implemented: validateContent()');
|
27
|
+
return true;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
};
|
31
|
+
})();
|
@@ -0,0 +1,27 @@
|
|
1
|
+
(function() {
|
2
|
+
"use strict";
|
3
|
+
App.vue.interfaces.contentFormatters = {
|
4
|
+
methods: {
|
5
|
+
_formatToCurrency: function(value, custom_number_format) {
|
6
|
+
return numeral(value).format('$' + (custom_number_format || '0,0[.]00'));
|
7
|
+
},
|
8
|
+
_formatToPercent: function(value, custom_number_format) {
|
9
|
+
return numeral(value / 100).format((custom_number_format || '0,0[.]00') + '%');
|
10
|
+
},
|
11
|
+
_formatToNumber: function(value, custom_number_format) {
|
12
|
+
return numeral(value).format(custom_number_format || '0,0[.]00');
|
13
|
+
},
|
14
|
+
_formatToPhoneNumber: function(value) {
|
15
|
+
var r = /(?:(\+?(?:(\d{1,2}))\s?)?(\(?(?:(\d{3}))\)?(\s|-|\.)?)((?:(\d{3}))(\s|-|\.)?)((?:(\d{4}))))/i;
|
16
|
+
var match = r.exec(value);
|
17
|
+
if (match !== null && match.length === 11) {
|
18
|
+
var areaCode = match[2] || 1;
|
19
|
+
return '+' + areaCode + ' (' + match[4] + ') ' + match[7] + '-' + match[10];
|
20
|
+
}
|
21
|
+
},
|
22
|
+
_formatToDate: function(value) {
|
23
|
+
return moment(date).format('MM/DD/YYYY');
|
24
|
+
}
|
25
|
+
}
|
26
|
+
};
|
27
|
+
})();
|
@@ -0,0 +1,50 @@
|
|
1
|
+
(function() {
|
2
|
+
"use strict";
|
3
|
+
App.vue.interfaces.contentValidators = {
|
4
|
+
methods: {
|
5
|
+
_formatForEmpty: function() {
|
6
|
+
return null;
|
7
|
+
},
|
8
|
+
_valueIsEmpty: function(value) {
|
9
|
+
if (value === undefined || value === null || String(value).trim().length < 1) {
|
10
|
+
return true;
|
11
|
+
}else{
|
12
|
+
return false;
|
13
|
+
}
|
14
|
+
},
|
15
|
+
_formatForDate: function() {
|
16
|
+
return 'MM/DD/YYYY';
|
17
|
+
},
|
18
|
+
_valueIsDate: function(date) {
|
19
|
+
var r = /^(0?[1-9]|1[012])\/(0?[1-9]|[12][0-9]|3[01])\/(19|20)\d\d$/;
|
20
|
+
if (r.test(date)){
|
21
|
+
return true;
|
22
|
+
}else{
|
23
|
+
return false;
|
24
|
+
}
|
25
|
+
},
|
26
|
+
_formatForEmail: function() {
|
27
|
+
return 'user@domain.com';
|
28
|
+
},
|
29
|
+
_valueIsEmail: function(email) {
|
30
|
+
var r = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
|
31
|
+
if (r.test(email)){
|
32
|
+
return true;
|
33
|
+
}else{
|
34
|
+
return false;
|
35
|
+
}
|
36
|
+
},
|
37
|
+
_formatForPhone: function() {
|
38
|
+
return '+X (XXX) XXX-XXXX';
|
39
|
+
},
|
40
|
+
_valueIsPhone: function(phone) {
|
41
|
+
var r = /^(?:(\+?(?:(\d{1,2}))\s?)?(\(?(?:(\d{3}))\)?(\s|-|\.)?)((?:(\d{3}))(\s|-|\.)?)((?:(\d{4}))))$/i;
|
42
|
+
if (r.test(phone)) {
|
43
|
+
return true;
|
44
|
+
}else{
|
45
|
+
return false;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
};
|
50
|
+
})();
|