ink_ui_rails 2.1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.md +21 -0
- data/README.md +39 -0
- data/lib/ink_ui_rails.rb +8 -0
- data/lib/ink_ui_rails/version.rb +3 -0
- data/vendor/assets/fonts/font/FontAwesome.otf +0 -0
- data/vendor/assets/fonts/font/fontawesome-webfont.eot +0 -0
- data/vendor/assets/fonts/font/fontawesome-webfont.svg +399 -0
- data/vendor/assets/fonts/font/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/fontawesome-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntu-b-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntu-b-webfont.svg +245 -0
- data/vendor/assets/fonts/font/ubuntu-b-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntu-b-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntu-bi-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntu-bi-webfont.svg +245 -0
- data/vendor/assets/fonts/font/ubuntu-bi-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntu-bi-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntu-c-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntu-c-webfont.svg +245 -0
- data/vendor/assets/fonts/font/ubuntu-c-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntu-c-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntu-l-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntu-l-webfont.svg +245 -0
- data/vendor/assets/fonts/font/ubuntu-l-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntu-l-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntu-li-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntu-li-webfont.svg +245 -0
- data/vendor/assets/fonts/font/ubuntu-li-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntu-li-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntu-m-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntu-m-webfont.svg +245 -0
- data/vendor/assets/fonts/font/ubuntu-m-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntu-m-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntu-mi-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntu-mi-webfont.svg +245 -0
- data/vendor/assets/fonts/font/ubuntu-mi-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntu-mi-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntu-r-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntu-r-webfont.svg +245 -0
- data/vendor/assets/fonts/font/ubuntu-r-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntu-r-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntu-ri-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntu-ri-webfont.svg +245 -0
- data/vendor/assets/fonts/font/ubuntu-ri-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntu-ri-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntumono-b-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntumono-b-webfont.svg +242 -0
- data/vendor/assets/fonts/font/ubuntumono-b-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntumono-b-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntumono-bi-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntumono-bi-webfont.svg +242 -0
- data/vendor/assets/fonts/font/ubuntumono-bi-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntumono-bi-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntumono-r-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntumono-r-webfont.svg +242 -0
- data/vendor/assets/fonts/font/ubuntumono-r-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntumono-r-webfont.woff +0 -0
- data/vendor/assets/fonts/font/ubuntumono-ri-webfont.eot +0 -0
- data/vendor/assets/fonts/font/ubuntumono-ri-webfont.svg +242 -0
- data/vendor/assets/fonts/font/ubuntumono-ri-webfont.ttf +0 -0
- data/vendor/assets/fonts/font/ubuntumono-ri-webfont.woff +0 -0
- data/vendor/assets/images/img/SAPOlogo.png +0 -0
- data/vendor/assets/images/img/favicon.ico +0 -0
- data/vendor/assets/images/img/home_bkg.png +0 -0
- data/vendor/assets/images/img/home_logo_IE.jpg +0 -0
- data/vendor/assets/images/img/icon_Sprite.png +0 -0
- data/vendor/assets/images/img/ink-favicon.ico +0 -0
- data/vendor/assets/images/img/logo_home.png +0 -0
- data/vendor/assets/images/img/shot_ink.png +0 -0
- data/vendor/assets/images/img/shot_intra.png +0 -0
- data/vendor/assets/images/img/shot_livebots.png +0 -0
- data/vendor/assets/images/img/shot_meo.png +0 -0
- data/vendor/assets/images/img/shot_musicbox.png +0 -0
- data/vendor/assets/images/img/shot_pessoa.png +0 -0
- data/vendor/assets/images/img/splash.1024x748.png +0 -0
- data/vendor/assets/images/img/splash.320x460.png +0 -0
- data/vendor/assets/images/img/splash.768x1004.png +0 -0
- data/vendor/assets/images/img/touch-icon.114.png +0 -0
- data/vendor/assets/images/img/touch-icon.16.png +0 -0
- data/vendor/assets/images/img/touch-icon.256.png +0 -0
- data/vendor/assets/images/img/touch-icon.57.png +0 -0
- data/vendor/assets/images/img/touch-icon.72.png +0 -0
- data/vendor/assets/javascripts/autoload.js +85 -0
- data/vendor/assets/javascripts/example.json +1174 -0
- data/vendor/assets/javascripts/holder.js +440 -0
- data/vendor/assets/javascripts/html5shiv-printshiv.js +496 -0
- data/vendor/assets/javascripts/html5shiv.js +298 -0
- data/vendor/assets/javascripts/ink-all.js +18015 -0
- data/vendor/assets/javascripts/ink-ui.js +7737 -0
- data/vendor/assets/javascripts/ink.aux.js +506 -0
- data/vendor/assets/javascripts/ink.close.js +54 -0
- data/vendor/assets/javascripts/ink.datepicker.js +1194 -0
- data/vendor/assets/javascripts/ink.datepicker.pt.js +32 -0
- data/vendor/assets/javascripts/ink.draggable.js +437 -0
- data/vendor/assets/javascripts/ink.droppable.js +193 -0
- data/vendor/assets/javascripts/ink.formvalidator.js +712 -0
- data/vendor/assets/javascripts/ink.gallery.js +757 -0
- data/vendor/assets/javascripts/ink.imagequery.js +259 -0
- data/vendor/assets/javascripts/ink.js +10278 -0
- data/vendor/assets/javascripts/ink.modal.js +628 -0
- data/vendor/assets/javascripts/ink.pagination.js +473 -0
- data/vendor/assets/javascripts/ink.progressbar.js +110 -0
- data/vendor/assets/javascripts/ink.smoothscroller.js +234 -0
- data/vendor/assets/javascripts/ink.sortablelist.js +338 -0
- data/vendor/assets/javascripts/ink.spy.js +123 -0
- data/vendor/assets/javascripts/ink.sticky.js +254 -0
- data/vendor/assets/javascripts/ink.table.js +621 -0
- data/vendor/assets/javascripts/ink.tabs.js +426 -0
- data/vendor/assets/javascripts/ink.toggle.js +218 -0
- data/vendor/assets/javascripts/ink.treeview.js +179 -0
- data/vendor/assets/javascripts/ink_ui.js +1 -0
- data/vendor/assets/javascripts/modernizr.js +815 -0
- data/vendor/assets/javascripts/prettify.js +28 -0
- data/vendor/assets/stylesheets/ink/_ink-ie7.css +1662 -0
- data/vendor/assets/stylesheets/ink/_ink.css +7496 -0
- data/vendor/assets/stylesheets/ink/ink_ui.scss.css +2 -0
- data/vendor/assets/stylesheets/ink_ui.scss.css +1 -0
- metadata +203 -0
@@ -0,0 +1,193 @@
|
|
1
|
+
/**
|
2
|
+
* @module Ink.UI.Droppable_1
|
3
|
+
* @author inkdev AT sapo.pt
|
4
|
+
* @version 1
|
5
|
+
*/
|
6
|
+
Ink.createModule("Ink.UI.Droppable","1",["Ink.Dom.Element_1", "Ink.Dom.Event_1", "Ink.Dom.Css_1"], function( Element, Event, Css) {
|
7
|
+
|
8
|
+
/**
|
9
|
+
* @class Ink.UI.Droppable
|
10
|
+
* @version 1
|
11
|
+
* @static
|
12
|
+
*/
|
13
|
+
var Droppable = {
|
14
|
+
/**
|
15
|
+
* Flag that determines if it's in debug mode or not
|
16
|
+
*
|
17
|
+
* @property debug
|
18
|
+
* @type {Boolean}
|
19
|
+
* @private
|
20
|
+
*/
|
21
|
+
debug: false,
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Associative array with the elements that are droppable
|
25
|
+
*
|
26
|
+
* @property _elements
|
27
|
+
* @type {Object}
|
28
|
+
* @private
|
29
|
+
*/
|
30
|
+
_elements: {}, // indexed by id
|
31
|
+
|
32
|
+
/**
|
33
|
+
* Makes an element droppable and adds it to the stack of droppable elements.
|
34
|
+
* Can consider it a constructor of droppable elements, but where no Droppable object is returned.
|
35
|
+
*
|
36
|
+
* @method add
|
37
|
+
* @param {String|DOMElement} element - target element
|
38
|
+
* @param {optional Object} options - options object
|
39
|
+
* @param {String} [options.hoverclass] - Classname applied when an acceptable draggable element is hovering the element
|
40
|
+
* @param {Array|String} [options.accept] - Array or comma separated string of classnames for elements that can be accepted by this droppable
|
41
|
+
* @param {Function} [options.onHover] - callback called when an acceptable draggable element is hovering the droppable. Gets the draggable and the droppable element as parameters.
|
42
|
+
* @param {Function} [options.onDrop] - callback called when an acceptable draggable element is dropped. Gets the draggable, the droppable and the event as parameterse.
|
43
|
+
* @public
|
44
|
+
*/
|
45
|
+
add: function(element, options) {
|
46
|
+
var opt = Ink.extendObj( {
|
47
|
+
hoverclass: false,
|
48
|
+
accept: false,
|
49
|
+
onHover: false,
|
50
|
+
onDrop: false,
|
51
|
+
onDropOut: false
|
52
|
+
}, options || {});
|
53
|
+
|
54
|
+
element = Ink.i(element);
|
55
|
+
|
56
|
+
if (opt.accept && opt.accept.constructor === Array) {
|
57
|
+
opt.accept = opt.accept.join();
|
58
|
+
}
|
59
|
+
|
60
|
+
this._elements[element.id] = {options: opt};
|
61
|
+
this.update(element.id);
|
62
|
+
},
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Invoke every time a drag starts
|
66
|
+
*
|
67
|
+
* @method updateAll
|
68
|
+
* @public
|
69
|
+
*/
|
70
|
+
/**
|
71
|
+
*/
|
72
|
+
updateAll: function() {
|
73
|
+
for (var id in this._elements) {
|
74
|
+
if (!this._elements.hasOwnProperty(id)) { continue; }
|
75
|
+
this.update(Ink.i(id));
|
76
|
+
}
|
77
|
+
},
|
78
|
+
|
79
|
+
/**
|
80
|
+
* Updates location and size of droppable element
|
81
|
+
*
|
82
|
+
* @method update
|
83
|
+
* @param {String|DOMElement} element - target element
|
84
|
+
* @public
|
85
|
+
*/
|
86
|
+
update: function(element) {
|
87
|
+
element = Ink.i(element);
|
88
|
+
var data = this._elements[element.id];
|
89
|
+
if (!data) {
|
90
|
+
return; /*throw 'Data about element with id="' + element.id + '" was not found!';*/
|
91
|
+
}
|
92
|
+
|
93
|
+
data.left = Element.offsetLeft(element);
|
94
|
+
data.top = Element.offsetTop( element);
|
95
|
+
data.right = data.left + Element.elementWidth( element);
|
96
|
+
data.bottom = data.top + Element.elementHeight(element);
|
97
|
+
|
98
|
+
// if (this.debug) {
|
99
|
+
// // for debugging purposes
|
100
|
+
// if (!data.rt) { data.rt = SAPO.Utility.Debug.addRect(document.body, [data.left, data.top], [data.right-data.left+1, data.bottom-data.top+1]); }
|
101
|
+
// else { SAPO.Utility.Debug.updateRect(data.rt, [data.left, data.top], [data.right-data.left+1, data.bottom-data.top+1]); }
|
102
|
+
// }
|
103
|
+
},
|
104
|
+
|
105
|
+
/**
|
106
|
+
* Removes an element from the droppable stack and removes the droppable behavior
|
107
|
+
*
|
108
|
+
* @method remove
|
109
|
+
* @param {String|DOMElement} el - target element
|
110
|
+
* @public
|
111
|
+
*/
|
112
|
+
remove: function(el) {
|
113
|
+
el = Ink.i(el);
|
114
|
+
delete this._elements[el.id];
|
115
|
+
},
|
116
|
+
|
117
|
+
/**
|
118
|
+
* Method called by a draggable to execute an action on a droppable
|
119
|
+
*
|
120
|
+
* @method action
|
121
|
+
* @param {Object} coords - coordinates where the action happened
|
122
|
+
* @param {String} type - type of action. drag or drop.
|
123
|
+
* @param {Object} ev - Event object
|
124
|
+
* @param {Object} draggable - draggable element
|
125
|
+
* @public
|
126
|
+
*/
|
127
|
+
action: function(coords, type, ev, draggable) {
|
128
|
+
var opt, classnames, accept, el, element;
|
129
|
+
|
130
|
+
// check all droppable elements
|
131
|
+
for (var elId in this._elements) {
|
132
|
+
if (!this._elements.hasOwnProperty(elId)) { continue; }
|
133
|
+
el = this._elements[elId];
|
134
|
+
opt = el.options;
|
135
|
+
accept = false;
|
136
|
+
element = Ink.i(elId);
|
137
|
+
|
138
|
+
// check if our draggable is over our droppable
|
139
|
+
if (coords.x >= el.left && coords.x <= el.right && coords.y >= el.top && coords.y <= el.bottom) {
|
140
|
+
|
141
|
+
// INSIDE
|
142
|
+
|
143
|
+
// check if the droppable accepts the draggable
|
144
|
+
if (opt.accept) {
|
145
|
+
classnames = draggable.className.split(' ');
|
146
|
+
for ( var j = 0, lj = classnames.length; j < lj; j++) {
|
147
|
+
if (opt.accept.search(classnames[j]) >= 0 && draggable !== element) {
|
148
|
+
accept = true;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
}
|
152
|
+
else {
|
153
|
+
accept = true;
|
154
|
+
}
|
155
|
+
|
156
|
+
if (accept) {
|
157
|
+
if (type === 'drag') {
|
158
|
+
if (opt.hoverclass) {
|
159
|
+
Css.addClassName(element, opt.hoverclass);
|
160
|
+
}
|
161
|
+
if (opt.onHover) {
|
162
|
+
opt.onHover(draggable, element);
|
163
|
+
}
|
164
|
+
}
|
165
|
+
else {
|
166
|
+
if (type === 'drop' && opt.onDrop) {
|
167
|
+
if (opt.hoverclass) {
|
168
|
+
Css.removeClassName(element, opt.hoverclass);
|
169
|
+
}
|
170
|
+
if (opt.onDrop) {
|
171
|
+
opt.onDrop(draggable, element, ev);
|
172
|
+
}
|
173
|
+
}
|
174
|
+
}
|
175
|
+
}
|
176
|
+
}
|
177
|
+
else {
|
178
|
+
// OUTSIDE
|
179
|
+
if (type === 'drag' && opt.hoverclass) {
|
180
|
+
Css.removeClassName(element, opt.hoverclass);
|
181
|
+
}
|
182
|
+
if(type === 'drop'){
|
183
|
+
if(opt.onDropOut){
|
184
|
+
opt.onDropOut(draggable, element, ev);
|
185
|
+
}
|
186
|
+
}
|
187
|
+
}
|
188
|
+
}
|
189
|
+
}
|
190
|
+
};
|
191
|
+
|
192
|
+
return Droppable;
|
193
|
+
});
|
@@ -0,0 +1,712 @@
|
|
1
|
+
/**
|
2
|
+
* @module Ink.UI.FormValidator_1
|
3
|
+
* @author inkdev AT sapo.pt
|
4
|
+
* @version 1
|
5
|
+
*/
|
6
|
+
Ink.createModule('Ink.UI.FormValidator', '1', ['Ink.Dom.Css_1','Ink.Util.Validator_1'], function( Css, InkValidator ) {
|
7
|
+
'use strict';
|
8
|
+
|
9
|
+
/**
|
10
|
+
* @class Ink.UI.FormValidator
|
11
|
+
* @version 1
|
12
|
+
* @uses Ink.Dom.Css
|
13
|
+
* @uses Ink.Util.Validator
|
14
|
+
*/
|
15
|
+
var FormValidator = {
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Specifies the version of the component
|
19
|
+
*
|
20
|
+
* @property version
|
21
|
+
* @type {String}
|
22
|
+
* @readOnly
|
23
|
+
* @public
|
24
|
+
*/
|
25
|
+
version: '1',
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Available flags to use in the validation process.
|
29
|
+
* The keys are the 'rules', and their values are objects with the key 'msg', determining
|
30
|
+
* what is the error message.
|
31
|
+
*
|
32
|
+
* @property _flagMap
|
33
|
+
* @type {Object}
|
34
|
+
* @readOnly
|
35
|
+
* @private
|
36
|
+
*/
|
37
|
+
_flagMap: {
|
38
|
+
//'ink-fv-required': {msg: 'Campo obrigatório'},
|
39
|
+
'ink-fv-required': {msg: 'Required field'},
|
40
|
+
//'ink-fv-email': {msg: 'E-mail inválido'},
|
41
|
+
'ink-fv-email': {msg: 'Invalid e-mail address'},
|
42
|
+
//'ink-fv-url': {msg: 'URL inválido'},
|
43
|
+
'ink-fv-url': {msg: 'Invalid URL'},
|
44
|
+
//'ink-fv-number': {msg: 'Número inválido'},
|
45
|
+
'ink-fv-number': {msg: 'Invalid number'},
|
46
|
+
//'ink-fv-phone_pt': {msg: 'Número de telefone inválido'},
|
47
|
+
'ink-fv-phone_pt': {msg: 'Invalid phone number'},
|
48
|
+
//'ink-fv-phone_cv': {msg: 'Número de telefone inválido'},
|
49
|
+
'ink-fv-phone_cv': {msg: 'Invalid phone number'},
|
50
|
+
//'ink-fv-phone_mz': {msg: 'Número de telefone inválido'},
|
51
|
+
'ink-fv-phone_mz': {msg: 'Invalid phone number'},
|
52
|
+
//'ink-fv-phone_ao': {msg: 'Número de telefone inválido'},
|
53
|
+
'ink-fv-phone_ao': {msg: 'Invalid phone number'},
|
54
|
+
//'ink-fv-date': {msg: 'Data inválida'},
|
55
|
+
'ink-fv-date': {msg: 'Invalid date'},
|
56
|
+
//'ink-fv-confirm': {msg: 'Confirmação inválida'},
|
57
|
+
'ink-fv-confirm': {msg: 'Confirmation does not match'},
|
58
|
+
'ink-fv-custom': {msg: ''}
|
59
|
+
},
|
60
|
+
|
61
|
+
/**
|
62
|
+
* This property holds all form elements for later validation
|
63
|
+
*
|
64
|
+
* @property elements
|
65
|
+
* @type {Object}
|
66
|
+
* @public
|
67
|
+
*/
|
68
|
+
elements: {},
|
69
|
+
|
70
|
+
/**
|
71
|
+
* This property holds the objects needed to cross-check for the 'confirm' rule
|
72
|
+
*
|
73
|
+
* @property confirmElms
|
74
|
+
* @type {Object}
|
75
|
+
* @public
|
76
|
+
*/
|
77
|
+
confirmElms: {},
|
78
|
+
|
79
|
+
/**
|
80
|
+
* This property holds the previous elements in the confirmElms property, but with a
|
81
|
+
* true/false specifying if it has the class ink-fv-confirm.
|
82
|
+
*
|
83
|
+
* @property hasConfirm
|
84
|
+
* @type {Object}
|
85
|
+
*/
|
86
|
+
hasConfirm: {},
|
87
|
+
|
88
|
+
/**
|
89
|
+
* Defined class name to use in error messages label
|
90
|
+
*
|
91
|
+
* @property _errorClassName
|
92
|
+
* @type {String}
|
93
|
+
* @readOnly
|
94
|
+
* @private
|
95
|
+
*/
|
96
|
+
_errorClassName: 'tip',
|
97
|
+
|
98
|
+
/**
|
99
|
+
* @property _errorValidationClassName
|
100
|
+
* @type {String}
|
101
|
+
* @readOnly
|
102
|
+
* @private
|
103
|
+
*/
|
104
|
+
_errorValidationClassName: 'validaton',
|
105
|
+
|
106
|
+
/**
|
107
|
+
* @property _errorTypeWarningClassName
|
108
|
+
* @type {String}
|
109
|
+
* @readOnly
|
110
|
+
* @private
|
111
|
+
*/
|
112
|
+
_errorTypeWarningClassName: 'warning',
|
113
|
+
|
114
|
+
/**
|
115
|
+
* @property _errorTypeErrorClassName
|
116
|
+
* @type {String}
|
117
|
+
* @readOnly
|
118
|
+
* @private
|
119
|
+
*/
|
120
|
+
_errorTypeErrorClassName: 'error',
|
121
|
+
|
122
|
+
/**
|
123
|
+
* Check if a form is valid or not
|
124
|
+
*
|
125
|
+
* @method validate
|
126
|
+
* @param {DOMElement|String} elm DOM form element or form id
|
127
|
+
* @param {Object} options Options for
|
128
|
+
* @param {Function} [options.onSuccess] function to run when form is valid
|
129
|
+
* @param {Function} [options.onError] function to run when form is not valid
|
130
|
+
* @param {Array} [options.customFlag] custom flags to use to validate form fields
|
131
|
+
* @public
|
132
|
+
* @return {Boolean}
|
133
|
+
*/
|
134
|
+
validate: function(elm, options)
|
135
|
+
{
|
136
|
+
this._free();
|
137
|
+
|
138
|
+
options = Ink.extendObj({
|
139
|
+
onSuccess: false,
|
140
|
+
onError: false,
|
141
|
+
customFlag: false,
|
142
|
+
confirmGroup: []
|
143
|
+
}, options || {});
|
144
|
+
|
145
|
+
if(typeof(elm) === 'string') {
|
146
|
+
elm = document.getElementById(elm);
|
147
|
+
}
|
148
|
+
if(elm === null){
|
149
|
+
return false;
|
150
|
+
}
|
151
|
+
this.element = elm;
|
152
|
+
|
153
|
+
if(typeof(this.element.id) === 'undefined' || this.element.id === null || this.element.id === '') {
|
154
|
+
// generate a random ID
|
155
|
+
this.element.id = 'ink-fv_randomid_'+(Math.round(Math.random() * 99999));
|
156
|
+
}
|
157
|
+
|
158
|
+
this.custom = options.customFlag;
|
159
|
+
|
160
|
+
this.confirmGroup = options.confirmGroup;
|
161
|
+
|
162
|
+
var fail = this._validateElements();
|
163
|
+
|
164
|
+
if(fail.length > 0) {
|
165
|
+
if(options.onError) {
|
166
|
+
options.onError(fail);
|
167
|
+
} else {
|
168
|
+
this._showError(elm, fail);
|
169
|
+
}
|
170
|
+
return false;
|
171
|
+
} else {
|
172
|
+
if(!options.onError) {
|
173
|
+
this._clearError(elm);
|
174
|
+
}
|
175
|
+
this._clearCache();
|
176
|
+
if(options.onSuccess) {
|
177
|
+
options.onSuccess();
|
178
|
+
}
|
179
|
+
return true;
|
180
|
+
}
|
181
|
+
|
182
|
+
},
|
183
|
+
|
184
|
+
/**
|
185
|
+
* Reset previously generated validation errors
|
186
|
+
*
|
187
|
+
* @method reset
|
188
|
+
* @public
|
189
|
+
*/
|
190
|
+
reset: function()
|
191
|
+
{
|
192
|
+
this._clearError();
|
193
|
+
this._clearCache();
|
194
|
+
},
|
195
|
+
|
196
|
+
/**
|
197
|
+
* Cleans the object
|
198
|
+
*
|
199
|
+
* @method _free
|
200
|
+
* @private
|
201
|
+
*/
|
202
|
+
_free: function()
|
203
|
+
{
|
204
|
+
this.element = null;
|
205
|
+
//this.elements = [];
|
206
|
+
this.custom = false;
|
207
|
+
this.confirmGroup = false;
|
208
|
+
},
|
209
|
+
|
210
|
+
/**
|
211
|
+
* Cleans the properties responsible for caching
|
212
|
+
*
|
213
|
+
* @method _clearCache
|
214
|
+
* @private
|
215
|
+
*/
|
216
|
+
_clearCache: function()
|
217
|
+
{
|
218
|
+
this.element = null;
|
219
|
+
this.elements = [];
|
220
|
+
this.custom = false;
|
221
|
+
this.confirmGroup = false;
|
222
|
+
},
|
223
|
+
|
224
|
+
/**
|
225
|
+
* Gets the form elements and stores them in the caching properties
|
226
|
+
*
|
227
|
+
* @method _getElements
|
228
|
+
* @private
|
229
|
+
*/
|
230
|
+
_getElements: function()
|
231
|
+
{
|
232
|
+
//this.elements = [];
|
233
|
+
// if(typeof(this.elements[this.element.id]) !== 'undefined') {
|
234
|
+
// return;
|
235
|
+
// }
|
236
|
+
|
237
|
+
this.elements[this.element.id] = [];
|
238
|
+
this.confirmElms[this.element.id] = [];
|
239
|
+
console.log(this.element);
|
240
|
+
console.log(this.element.elements);
|
241
|
+
var formElms = this.element.elements;
|
242
|
+
var curElm = false;
|
243
|
+
for(var i=0, totalElm = formElms.length; i < totalElm; i++) {
|
244
|
+
curElm = formElms[i];
|
245
|
+
|
246
|
+
if(curElm.getAttribute('type') !== null && curElm.getAttribute('type').toLowerCase() === 'radio') {
|
247
|
+
if(this.elements[this.element.id].length === 0 ||
|
248
|
+
(
|
249
|
+
curElm.getAttribute('type') !== this.elements[this.element.id][(this.elements[this.element.id].length - 1)].getAttribute('type') &&
|
250
|
+
curElm.getAttribute('name') !== this.elements[this.element.id][(this.elements[this.element.id].length - 1)].getAttribute('name')
|
251
|
+
)) {
|
252
|
+
for(var flag in this._flagMap) {
|
253
|
+
if(Css.hasClassName(curElm, flag)) {
|
254
|
+
this.elements[this.element.id].push(curElm);
|
255
|
+
break;
|
256
|
+
}
|
257
|
+
}
|
258
|
+
}
|
259
|
+
} else {
|
260
|
+
for(var flag2 in this._flagMap) {
|
261
|
+
if(Css.hasClassName(curElm, flag2) && flag2 !== 'ink-fv-confirm') {
|
262
|
+
/*if(flag2 == 'ink-fv-confirm') {
|
263
|
+
this.confirmElms[this.element.id].push(curElm);
|
264
|
+
this.hasConfirm[this.element.id] = true;
|
265
|
+
}*/
|
266
|
+
this.elements[this.element.id].push(curElm);
|
267
|
+
break;
|
268
|
+
}
|
269
|
+
}
|
270
|
+
|
271
|
+
if(Css.hasClassName(curElm, 'ink-fv-confirm')) {
|
272
|
+
this.confirmElms[this.element.id].push(curElm);
|
273
|
+
this.hasConfirm[this.element.id] = true;
|
274
|
+
}
|
275
|
+
|
276
|
+
}
|
277
|
+
}
|
278
|
+
debugger;
|
279
|
+
},
|
280
|
+
|
281
|
+
/**
|
282
|
+
* Runs the validation for each element
|
283
|
+
*
|
284
|
+
* @method _validateElements
|
285
|
+
* @private
|
286
|
+
*/
|
287
|
+
_validateElements: function()
|
288
|
+
{
|
289
|
+
var oGroups;
|
290
|
+
this._getElements();
|
291
|
+
//console.log('HAS CONFIRM', this.hasConfirm);
|
292
|
+
if(typeof(this.hasConfirm[this.element.id]) !== 'undefined' && this.hasConfirm[this.element.id] === true) {
|
293
|
+
oGroups = this._makeConfirmGroups();
|
294
|
+
}
|
295
|
+
|
296
|
+
var errors = [];
|
297
|
+
|
298
|
+
var curElm = false;
|
299
|
+
var customErrors = false;
|
300
|
+
var inArray;
|
301
|
+
for(var i=0, totalElm = this.elements[this.element.id].length; i < totalElm; i++) {
|
302
|
+
inArray = false;
|
303
|
+
curElm = this.elements[this.element.id][i];
|
304
|
+
|
305
|
+
if(!curElm.disabled) {
|
306
|
+
for(var flag in this._flagMap) {
|
307
|
+
if(Css.hasClassName(curElm, flag)) {
|
308
|
+
|
309
|
+
if(flag !== 'ink-fv-custom' && flag !== 'ink-fv-confirm') {
|
310
|
+
if(!this._isValid(curElm, flag)) {
|
311
|
+
|
312
|
+
if(!inArray) {
|
313
|
+
errors.push({elm: curElm, errors:[flag]});
|
314
|
+
inArray = true;
|
315
|
+
} else {
|
316
|
+
errors[(errors.length - 1)].errors.push(flag);
|
317
|
+
}
|
318
|
+
}
|
319
|
+
} else if(flag !== 'ink-fv-confirm'){
|
320
|
+
customErrors = this._isCustomValid(curElm);
|
321
|
+
if(customErrors.length > 0) {
|
322
|
+
errors.push({elm: curElm, errors:[flag], custom: customErrors});
|
323
|
+
}
|
324
|
+
} else if(flag === 'ink-fv-confirm'){
|
325
|
+
}
|
326
|
+
}
|
327
|
+
}
|
328
|
+
}
|
329
|
+
}
|
330
|
+
errors = this._validateConfirmGroups(oGroups, errors);
|
331
|
+
//console.log(InkDumper.returnDump(errors));
|
332
|
+
return errors;
|
333
|
+
},
|
334
|
+
|
335
|
+
/**
|
336
|
+
* Runs the 'confirm' validation for each group of elements
|
337
|
+
*
|
338
|
+
* @method _validateConfirmGroups
|
339
|
+
* @param {Array} oGroups Array/Object that contains the group of confirm objects
|
340
|
+
* @param {Array} errors Array that will store the errors
|
341
|
+
* @private
|
342
|
+
* @return {Array} Array of errors that was passed as 2nd parameter (either changed, or not, depending if errors were found).
|
343
|
+
*/
|
344
|
+
_validateConfirmGroups: function(oGroups, errors)
|
345
|
+
{
|
346
|
+
//console.log(oGroups);
|
347
|
+
var curGroup = false;
|
348
|
+
for(var i in oGroups) {
|
349
|
+
curGroup = oGroups[i];
|
350
|
+
if(curGroup.length === 2) {
|
351
|
+
if(curGroup[0].value !== curGroup[1].value) {
|
352
|
+
errors.push({elm:curGroup[1], errors:['ink-fv-confirm']});
|
353
|
+
}
|
354
|
+
}
|
355
|
+
}
|
356
|
+
return errors;
|
357
|
+
},
|
358
|
+
|
359
|
+
/**
|
360
|
+
* Creates the groups of 'confirm' objects
|
361
|
+
*
|
362
|
+
* @method _makeConfirmGroups
|
363
|
+
* @private
|
364
|
+
* @return {Array|Boolean} Returns the array of confirm elements or false on error.
|
365
|
+
*/
|
366
|
+
_makeConfirmGroups: function()
|
367
|
+
{
|
368
|
+
var oGroups;
|
369
|
+
if(this.confirmGroup && this.confirmGroup.length > 0) {
|
370
|
+
oGroups = {};
|
371
|
+
var curElm = false;
|
372
|
+
var curGroup = false;
|
373
|
+
//this.confirmElms[this.element.id];
|
374
|
+
for(var i=0, total=this.confirmElms[this.element.id].length; i < total; i++) {
|
375
|
+
curElm = this.confirmElms[this.element.id][i];
|
376
|
+
for(var j=0, totalG=this.confirmGroup.length; j < totalG; j++) {
|
377
|
+
curGroup = this.confirmGroup[j];
|
378
|
+
if(Css.hasClassName(curElm, curGroup)) {
|
379
|
+
if(typeof(oGroups[curGroup]) === 'undefined') {
|
380
|
+
oGroups[curGroup] = [curElm];
|
381
|
+
} else {
|
382
|
+
oGroups[curGroup].push(curElm);
|
383
|
+
}
|
384
|
+
}
|
385
|
+
}
|
386
|
+
}
|
387
|
+
return oGroups;
|
388
|
+
} else {
|
389
|
+
if(this.confirmElms[this.element.id].length === 2) {
|
390
|
+
oGroups = {
|
391
|
+
"ink-fv-confirm": [
|
392
|
+
this.confirmElms[this.element.id][0],
|
393
|
+
this.confirmElms[this.element.id][1]
|
394
|
+
]
|
395
|
+
};
|
396
|
+
}
|
397
|
+
return oGroups;
|
398
|
+
}
|
399
|
+
return false;
|
400
|
+
},
|
401
|
+
|
402
|
+
/**
|
403
|
+
* Validates an element with a custom validation
|
404
|
+
*
|
405
|
+
* @method _isCustomValid
|
406
|
+
* @param {DOMElemenmt} elm Element to be validated
|
407
|
+
* @private
|
408
|
+
* @return {Array} Array of errors. If no errors are found, results in an empty array.
|
409
|
+
*/
|
410
|
+
_isCustomValid: function(elm)
|
411
|
+
{
|
412
|
+
var customErrors = [];
|
413
|
+
var curFlag = false;
|
414
|
+
for(var i=0, tCustom = this.custom.length; i < tCustom; i++) {
|
415
|
+
curFlag = this.custom[i];
|
416
|
+
if(Css.hasClassName(elm, curFlag.flag)) {
|
417
|
+
if(!curFlag.callback(elm, curFlag.msg)) {
|
418
|
+
customErrors.push({flag: curFlag.flag, msg: curFlag.msg});
|
419
|
+
}
|
420
|
+
}
|
421
|
+
}
|
422
|
+
return customErrors;
|
423
|
+
},
|
424
|
+
|
425
|
+
/**
|
426
|
+
* Runs the normal validation functions for a specific element
|
427
|
+
*
|
428
|
+
* @method :_isValid
|
429
|
+
* @param {DOMElement} elm DOMElement that will be validated
|
430
|
+
* @param {String} fieldType Rule to be validated. This must be one of the keys present in the _flagMap property.
|
431
|
+
* @private
|
432
|
+
* @return {Boolean} The result of the validation.
|
433
|
+
*/
|
434
|
+
_isValid: function(elm, fieldType)
|
435
|
+
{
|
436
|
+
/*jshint maxstatements:50, maxcomplexity:50 */
|
437
|
+
switch(fieldType) {
|
438
|
+
case 'ink-fv-required':
|
439
|
+
if(elm.nodeName.toLowerCase() === 'select') {
|
440
|
+
if(elm.selectedIndex > 0) {
|
441
|
+
return true;
|
442
|
+
} else {
|
443
|
+
return false;
|
444
|
+
}
|
445
|
+
}
|
446
|
+
if(elm.getAttribute('type') !== 'checkbox' && elm.getAttribute('type') !== 'radio') {
|
447
|
+
if(this._trim(elm.value) !== '') {
|
448
|
+
return true;
|
449
|
+
}
|
450
|
+
} else if(elm.getAttribute('type') === 'checkbox') {
|
451
|
+
if(elm.checked === true) {
|
452
|
+
return true;
|
453
|
+
}
|
454
|
+
} else if(elm.getAttribute('type') === 'radio') { // get top radio
|
455
|
+
var aFormRadios = elm.form[elm.name];
|
456
|
+
if(typeof(aFormRadios.length) === 'undefined') {
|
457
|
+
aFormRadios = [aFormRadios];
|
458
|
+
}
|
459
|
+
var isChecked = false;
|
460
|
+
for(var i=0, totalRadio = aFormRadios.length; i < totalRadio; i++) {
|
461
|
+
if(aFormRadios[i].checked === true) {
|
462
|
+
isChecked = true;
|
463
|
+
}
|
464
|
+
}
|
465
|
+
return isChecked;
|
466
|
+
}
|
467
|
+
break;
|
468
|
+
|
469
|
+
case 'ink-fv-email':
|
470
|
+
if(this._trim(elm.value) === '') {
|
471
|
+
if(Css.hasClassName(elm, 'ink-fv-required')) {
|
472
|
+
return false;
|
473
|
+
} else {
|
474
|
+
return true;
|
475
|
+
}
|
476
|
+
} else {
|
477
|
+
if(InkValidator.mail(elm.value)) {
|
478
|
+
return true;
|
479
|
+
}
|
480
|
+
}
|
481
|
+
break;
|
482
|
+
case 'ink-fv-url':
|
483
|
+
if(this._trim(elm.value) === '') {
|
484
|
+
if(Css.hasClassName(elm, 'ink-fv-required')) {
|
485
|
+
return false;
|
486
|
+
} else {
|
487
|
+
return true;
|
488
|
+
}
|
489
|
+
} else {
|
490
|
+
if(InkValidator.url(elm.value)) {
|
491
|
+
return true;
|
492
|
+
}
|
493
|
+
}
|
494
|
+
break;
|
495
|
+
case 'ink-fv-number':
|
496
|
+
if(this._trim(elm.value) === '') {
|
497
|
+
if(Css.hasClassName(elm, 'ink-fv-required')) {
|
498
|
+
return false;
|
499
|
+
} else {
|
500
|
+
return true;
|
501
|
+
}
|
502
|
+
} else {
|
503
|
+
if(!isNaN(Number(elm.value))) {
|
504
|
+
return true;
|
505
|
+
}
|
506
|
+
}
|
507
|
+
break;
|
508
|
+
case 'ink-fv-phone_pt':
|
509
|
+
if(this._trim(elm.value) === '') {
|
510
|
+
if(Css.hasClassName(elm, 'ink-fv-required')) {
|
511
|
+
return false;
|
512
|
+
} else {
|
513
|
+
return true;
|
514
|
+
}
|
515
|
+
} else {
|
516
|
+
if(InkValidator.isPTPhone(elm.value)) {
|
517
|
+
return true;
|
518
|
+
}
|
519
|
+
}
|
520
|
+
break;
|
521
|
+
case 'ink-fv-phone_cv':
|
522
|
+
if(this._trim(elm.value) === '') {
|
523
|
+
if(Css.hasClassName(elm, 'ink-fv-required')) {
|
524
|
+
return false;
|
525
|
+
} else {
|
526
|
+
return true;
|
527
|
+
}
|
528
|
+
} else {
|
529
|
+
if(InkValidator.isCVPhone(elm.value)) {
|
530
|
+
return true;
|
531
|
+
}
|
532
|
+
}
|
533
|
+
break;
|
534
|
+
case 'ink-fv-phone_ao':
|
535
|
+
if(this._trim(elm.value) === '') {
|
536
|
+
if(Css.hasClassName(elm, 'ink-fv-required')) {
|
537
|
+
return false;
|
538
|
+
} else {
|
539
|
+
return true;
|
540
|
+
}
|
541
|
+
} else {
|
542
|
+
if(InkValidator.isAOPhone(elm.value)) {
|
543
|
+
return true;
|
544
|
+
}
|
545
|
+
}
|
546
|
+
break;
|
547
|
+
case 'ink-fv-phone_mz':
|
548
|
+
if(this._trim(elm.value) === '') {
|
549
|
+
if(Css.hasClassName(elm, 'ink-fv-required')) {
|
550
|
+
return false;
|
551
|
+
} else {
|
552
|
+
return true;
|
553
|
+
}
|
554
|
+
} else {
|
555
|
+
if(InkValidator.isMZPhone(elm.value)) {
|
556
|
+
return true;
|
557
|
+
}
|
558
|
+
}
|
559
|
+
break;
|
560
|
+
case 'ink-fv-date':
|
561
|
+
if(this._trim(elm.value) === '') {
|
562
|
+
if(Css.hasClassName(elm, 'ink-fv-required')) {
|
563
|
+
return false;
|
564
|
+
} else {
|
565
|
+
return true;
|
566
|
+
}
|
567
|
+
} else {
|
568
|
+
var Element = Ink.getModule('Ink.Dom.Element',1);
|
569
|
+
var dataset = Element.data( elm );
|
570
|
+
var validFormat = 'yyyy-mm-dd';
|
571
|
+
|
572
|
+
if( Css.hasClassName(elm, 'ink-datepicker') && ("format" in dataset) ){
|
573
|
+
validFormat = dataset.format;
|
574
|
+
} else if( ("validFormat" in dataset) ){
|
575
|
+
validFormat = dataset.validFormat;
|
576
|
+
}
|
577
|
+
|
578
|
+
if( !(validFormat in InkValidator._dateParsers ) ){
|
579
|
+
var validValues = [];
|
580
|
+
for( val in InkValidator._dateParsers ){
|
581
|
+
validValues.push(val);
|
582
|
+
}
|
583
|
+
throw "The attribute data-valid-format must be one of the following values: " + validValues.join(',');
|
584
|
+
}
|
585
|
+
|
586
|
+
return InkValidator.isDate( validFormat, elm.value );
|
587
|
+
}
|
588
|
+
break;
|
589
|
+
case 'ink-fv-custom':
|
590
|
+
break;
|
591
|
+
}
|
592
|
+
|
593
|
+
return false;
|
594
|
+
},
|
595
|
+
|
596
|
+
/**
|
597
|
+
* Makes the necessary changes to the markup to show the errors of a given element
|
598
|
+
*
|
599
|
+
* @method _showError
|
600
|
+
* @param {DOMElement} formElm The form element to be changed to show the errors
|
601
|
+
* @param {Array} aFail An array with the errors found.
|
602
|
+
* @private
|
603
|
+
*/
|
604
|
+
_showError: function(formElm, aFail)
|
605
|
+
{
|
606
|
+
this._clearError(formElm);
|
607
|
+
|
608
|
+
//ink-warning-field
|
609
|
+
|
610
|
+
//console.log(aFail);
|
611
|
+
var curElm = false;
|
612
|
+
for(var i=0, tFail = aFail.length; i < tFail; i++) {
|
613
|
+
curElm = aFail[i].elm;
|
614
|
+
|
615
|
+
if(curElm.getAttribute('type') !== 'radio') {
|
616
|
+
|
617
|
+
var newLabel = document.createElement('p');
|
618
|
+
//newLabel.setAttribute('for',curElm.id);
|
619
|
+
newLabel.className = this._errorClassName;
|
620
|
+
newLabel.className += ' ' . this._errorTypeErrorClassName;
|
621
|
+
if(aFail[i].errors[0] !== 'ink-fv-custom') {
|
622
|
+
newLabel.innerHTML = this._flagMap[aFail[i].errors[0]].msg;
|
623
|
+
} else {
|
624
|
+
newLabel.innerHTML = aFail[i].custom[0].msg;
|
625
|
+
}
|
626
|
+
|
627
|
+
if(curElm.getAttribute('type') !== 'checkbox') {
|
628
|
+
curElm.nextSibling.parentNode.insertBefore(newLabel, curElm.nextSibling);
|
629
|
+
if(Css.hasClassName(curElm.parentNode, 'control')) {
|
630
|
+
Css.addClassName(curElm.parentNode.parentNode, 'validation');
|
631
|
+
if(aFail[i].errors[0] === 'ink-fv-required') {
|
632
|
+
Css.addClassName(curElm.parentNode.parentNode, 'error');
|
633
|
+
} else {
|
634
|
+
Css.addClassName(curElm.parentNode.parentNode, 'warning');
|
635
|
+
}
|
636
|
+
}
|
637
|
+
} else {
|
638
|
+
/* // TODO checkbox... does not work with this CSS
|
639
|
+
curElm.parentNode.appendChild(newLabel);
|
640
|
+
if(Css.hasClassName(curElm.parentNode.parentNode, 'control-group')) {
|
641
|
+
Css.addClassName(curElm.parentNode.parentNode, 'control');
|
642
|
+
Css.addClassName(curElm.parentNode.parentNode, 'validation');
|
643
|
+
Css.addClassName(curElm.parentNode.parentNode, 'error');
|
644
|
+
}*/
|
645
|
+
}
|
646
|
+
} else {
|
647
|
+
if(Css.hasClassName(curElm.parentNode.parentNode, 'control-group')) {
|
648
|
+
Css.addClassName(curElm.parentNode.parentNode, 'validation');
|
649
|
+
Css.addClassName(curElm.parentNode.parentNode, 'error');
|
650
|
+
}
|
651
|
+
}
|
652
|
+
}
|
653
|
+
},
|
654
|
+
|
655
|
+
/**
|
656
|
+
* Clears the error of a given element. Normally executed before any validation, for all elements, as a reset.
|
657
|
+
*
|
658
|
+
* @method _clearErrors
|
659
|
+
* @param {DOMElement} formElm Form element to be cleared.
|
660
|
+
* @private
|
661
|
+
*/
|
662
|
+
_clearError: function(formElm)
|
663
|
+
{
|
664
|
+
//return;
|
665
|
+
var aErrorLabel = formElm.getElementsByTagName('p');
|
666
|
+
|
667
|
+
var curElm = false;
|
668
|
+
for(var i = (aErrorLabel.length - 1); i >= 0; i--) {
|
669
|
+
curElm = aErrorLabel[i];
|
670
|
+
if(Css.hasClassName(curElm, this._errorClassName)) {
|
671
|
+
if(Css.hasClassName(curElm.parentNode, 'control')) {
|
672
|
+
Css.removeClassName(curElm.parentNode.parentNode, 'validation');
|
673
|
+
Css.removeClassName(curElm.parentNode.parentNode, 'error');
|
674
|
+
Css.removeClassName(curElm.parentNode.parentNode, 'warning');
|
675
|
+
}
|
676
|
+
|
677
|
+
if(Css.hasClassName(curElm,'tip') && Css.hasClassName(curElm,'error')){
|
678
|
+
curElm.parentNode.removeChild(curElm);
|
679
|
+
}
|
680
|
+
}
|
681
|
+
}
|
682
|
+
|
683
|
+
var aErrorLabel2 = formElm.getElementsByTagName('ul');
|
684
|
+
for(i = (aErrorLabel2.length - 1); i >= 0; i--) {
|
685
|
+
curElm = aErrorLabel2[i];
|
686
|
+
if(Css.hasClassName(curElm, 'control-group')) {
|
687
|
+
Css.removeClassName(curElm, 'validation');
|
688
|
+
Css.removeClassName(curElm, 'error');
|
689
|
+
}
|
690
|
+
}
|
691
|
+
},
|
692
|
+
|
693
|
+
/**
|
694
|
+
* Removes unnecessary spaces to the left or right of a string
|
695
|
+
*
|
696
|
+
* @method _trim
|
697
|
+
* @param {String} stri String to be trimmed
|
698
|
+
* @private
|
699
|
+
* @return {String|undefined} String trimmed.
|
700
|
+
*/
|
701
|
+
_trim: function(str)
|
702
|
+
{
|
703
|
+
if(typeof(str) === 'string')
|
704
|
+
{
|
705
|
+
return str.replace(/^\s+|\s+$|\n+$/g, '');
|
706
|
+
}
|
707
|
+
}
|
708
|
+
};
|
709
|
+
|
710
|
+
return FormValidator;
|
711
|
+
|
712
|
+
});
|