@base-framework/base 2.6.1 → 2.6.3
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.
- package/README.md +1 -0
- package/dist/base.js +1 -0
- package/package.json +30 -26
- package/.jshintrc +0 -3
- package/base.js +0 -41
- package/base.min.js +0 -1
- package/core.js +0 -1
- package/data-tracker.js +0 -351
- package/es5/base.js +0 -2968
- package/es5/modules/ajax.js +0 -663
- package/es5/modules/animation.js +0 -188
- package/es5/modules/animations.js +0 -1080
- package/es5/modules/atom.js +0 -65
- package/es5/modules/component.js +0 -1310
- package/es5/modules/data-binder.js +0 -1131
- package/es5/modules/data.js +0 -1808
- package/es5/modules/date.js +0 -525
- package/es5/modules/form-validator.js +0 -324
- package/es5/modules/history.js +0 -126
- package/es5/modules/html-builder.js +0 -461
- package/es5/modules/layout.js +0 -1679
- package/es5/modules/mouse.js +0 -124
- package/es5/modules/nav-link.js +0 -123
- package/es5/modules/olderversions/animations-ease.js +0 -1095
- package/es5/modules/olderversions/animations-update.js +0 -1048
- package/es5/modules/olderversions/base-animations.js +0 -636
- package/es5/modules/olderversions/base-component-class.js +0 -100
- package/es5/modules/olderversions/base-data-binder-1.js +0 -407
- package/es5/modules/olderversions/base-data-binder-class.js +0 -358
- package/es5/modules/olderversions/base-layout-parser-class.js +0 -172
- package/es5/modules/olderversions/base-mode-1.js +0 -777
- package/es5/modules/olderversions/base-model-class.js +0 -585
- package/es5/modules/olderversions/data-binder/element-binding/base-data-binder-class.js +0 -358
- package/es5/modules/olderversions/data-binder/element-binding/base-model-class.js +0 -585
- package/es5/modules/olderversions/data-binder/model-binding/base-data-binder-class.js +0 -353
- package/es5/modules/olderversions/data-binder/model-binding/base-model-class.js +0 -604
- package/es5/modules/olderversions/data-binder-update-watcher.js +0 -640
- package/es5/modules/olderversions/data-tracker.js +0 -187
- package/es5/modules/olderversions/event-update.js +0 -666
- package/es5/modules/olderversions/nav-link.js +0 -119
- package/es5/modules/olderversions/router-with-templates-1.js +0 -785
- package/es5/modules/olderversions/router-with-templates.js +0 -701
- package/es5/modules/prototypes/ajax.js +0 -657
- package/es5/modules/prototypes/atom.js +0 -65
- package/es5/modules/prototypes/component.js +0 -972
- package/es5/modules/prototypes/data-binder.js +0 -1089
- package/es5/modules/prototypes/data.js +0 -1290
- package/es5/modules/prototypes/html-builder.js +0 -414
- package/es5/modules/prototypes/layout.js +0 -879
- package/es5/modules/router.js +0 -1680
- package/es5/modules/state.js +0 -274
- package/es6/.jshintrc +0 -3
- package/es6/base.js +0 -41
- package/es6/core.js +0 -1
- package/es6/data-tracker.js +0 -351
- package/es6/events.js +0 -602
- package/es6/legacy/es5/base.js +0 -2968
- package/es6/legacy/es5/modules/ajax.js +0 -663
- package/es6/legacy/es5/modules/animation.js +0 -188
- package/es6/legacy/es5/modules/animations.js +0 -1080
- package/es6/legacy/es5/modules/atom.js +0 -65
- package/es6/legacy/es5/modules/component.js +0 -1310
- package/es6/legacy/es5/modules/data-binder.js +0 -1131
- package/es6/legacy/es5/modules/data.js +0 -1808
- package/es6/legacy/es5/modules/date.js +0 -525
- package/es6/legacy/es5/modules/form-validator.js +0 -324
- package/es6/legacy/es5/modules/history.js +0 -126
- package/es6/legacy/es5/modules/html-builder.js +0 -461
- package/es6/legacy/es5/modules/layout.js +0 -1679
- package/es6/legacy/es5/modules/mouse.js +0 -124
- package/es6/legacy/es5/modules/nav-link.js +0 -123
- package/es6/legacy/es5/modules/olderversions/animations-ease.js +0 -1095
- package/es6/legacy/es5/modules/olderversions/animations-update.js +0 -1048
- package/es6/legacy/es5/modules/olderversions/base-animations.js +0 -636
- package/es6/legacy/es5/modules/olderversions/base-component-class.js +0 -100
- package/es6/legacy/es5/modules/olderversions/base-data-binder-1.js +0 -407
- package/es6/legacy/es5/modules/olderversions/base-data-binder-class.js +0 -358
- package/es6/legacy/es5/modules/olderversions/base-layout-parser-class.js +0 -172
- package/es6/legacy/es5/modules/olderversions/base-mode-1.js +0 -777
- package/es6/legacy/es5/modules/olderversions/base-model-class.js +0 -585
- package/es6/legacy/es5/modules/olderversions/data-binder/element-binding/base-data-binder-class.js +0 -358
- package/es6/legacy/es5/modules/olderversions/data-binder/element-binding/base-model-class.js +0 -585
- package/es6/legacy/es5/modules/olderversions/data-binder/model-binding/base-data-binder-class.js +0 -353
- package/es6/legacy/es5/modules/olderversions/data-binder/model-binding/base-model-class.js +0 -604
- package/es6/legacy/es5/modules/olderversions/data-binder-update-watcher.js +0 -640
- package/es6/legacy/es5/modules/olderversions/data-tracker.js +0 -187
- package/es6/legacy/es5/modules/olderversions/event-update.js +0 -666
- package/es6/legacy/es5/modules/olderversions/nav-link.js +0 -119
- package/es6/legacy/es5/modules/olderversions/router-with-templates-1.js +0 -785
- package/es6/legacy/es5/modules/olderversions/router-with-templates.js +0 -701
- package/es6/legacy/es5/modules/prototypes/ajax.js +0 -657
- package/es6/legacy/es5/modules/prototypes/atom.js +0 -65
- package/es6/legacy/es5/modules/prototypes/component.js +0 -972
- package/es6/legacy/es5/modules/prototypes/data-binder.js +0 -1089
- package/es6/legacy/es5/modules/prototypes/data.js +0 -1290
- package/es6/legacy/es5/modules/prototypes/html-builder.js +0 -414
- package/es6/legacy/es5/modules/prototypes/layout.js +0 -879
- package/es6/legacy/es5/modules/router.js +0 -1680
- package/es6/legacy/es5/modules/state.js +0 -274
- package/es6/main.js +0 -1331
- package/es6/modules/ajax/ajax.js +0 -514
- package/es6/modules/animation/animation.js +0 -236
- package/es6/modules/animations/animation-controller.js +0 -231
- package/es6/modules/animations/animation.js +0 -64
- package/es6/modules/animations/attr-movement.js +0 -66
- package/es6/modules/animations/css-movement.js +0 -170
- package/es6/modules/animations/movement.js +0 -131
- package/es6/modules/animations/value.js +0 -187
- package/es6/modules/atom/atom.js +0 -54
- package/es6/modules/component/component.js +0 -230
- package/es6/modules/component/event-helper.js +0 -119
- package/es6/modules/component/jot.js +0 -144
- package/es6/modules/component/state-helper.js +0 -262
- package/es6/modules/component/unit.js +0 -551
- package/es6/modules/data/attrs.js +0 -40
- package/es6/modules/data/basic-data.js +0 -500
- package/es6/modules/data/data-utils.js +0 -29
- package/es6/modules/data/data.js +0 -3
- package/es6/modules/data/deep-data.js +0 -541
- package/es6/modules/data/model-service.js +0 -528
- package/es6/modules/data/model.js +0 -133
- package/es6/modules/data/simple-data.js +0 -33
- package/es6/modules/data-binder/connection-tracker.js +0 -113
- package/es6/modules/data-binder/connection.js +0 -16
- package/es6/modules/data-binder/data-binder.js +0 -352
- package/es6/modules/data-binder/data-pub-sub.js +0 -141
- package/es6/modules/data-binder/data-source.js +0 -56
- package/es6/modules/data-binder/element-source.js +0 -219
- package/es6/modules/data-binder/one-way-connection.js +0 -46
- package/es6/modules/data-binder/one-way-source.js +0 -43
- package/es6/modules/data-binder/source.js +0 -36
- package/es6/modules/data-binder/two-way-connection.js +0 -75
- package/es6/modules/data-binder/two-way-source.js +0 -41
- package/es6/modules/date/date.js +0 -544
- package/es6/modules/history/history.js +0 -89
- package/es6/modules/html-builder/html-builder.js +0 -434
- package/es6/modules/import/import.js +0 -390
- package/es6/modules/layout/layout-builder.js +0 -1269
- package/es6/modules/layout/layout-parser.js +0 -134
- package/es6/modules/layout/watcher-helper.js +0 -282
- package/es6/modules/mouse/mouse.js +0 -114
- package/es6/modules/router/component-helper.js +0 -163
- package/es6/modules/router/history-controller.js +0 -216
- package/es6/modules/router/nav-link.js +0 -124
- package/es6/modules/router/route.js +0 -401
- package/es6/modules/router/router.js +0 -789
- package/es6/modules/router/utils.js +0 -31
- package/es6/modules/state/state-target.js +0 -91
- package/es6/modules/state/state.js +0 -171
- package/es6/package-lock.json +0 -13
- package/es6/package.json +0 -28
- package/es6/shared/objects.js +0 -99
- package/events.js +0 -602
- package/legacy/es5/base.js +0 -2968
- package/legacy/es5/modules/ajax.js +0 -663
- package/legacy/es5/modules/animation.js +0 -188
- package/legacy/es5/modules/animations.js +0 -1080
- package/legacy/es5/modules/atom.js +0 -65
- package/legacy/es5/modules/component.js +0 -1310
- package/legacy/es5/modules/data-binder.js +0 -1131
- package/legacy/es5/modules/data.js +0 -1808
- package/legacy/es5/modules/date.js +0 -525
- package/legacy/es5/modules/form-validator.js +0 -324
- package/legacy/es5/modules/history.js +0 -126
- package/legacy/es5/modules/html-builder.js +0 -461
- package/legacy/es5/modules/layout.js +0 -1679
- package/legacy/es5/modules/mouse.js +0 -124
- package/legacy/es5/modules/nav-link.js +0 -123
- package/legacy/es5/modules/olderversions/animations-ease.js +0 -1095
- package/legacy/es5/modules/olderversions/animations-update.js +0 -1048
- package/legacy/es5/modules/olderversions/base-animations.js +0 -636
- package/legacy/es5/modules/olderversions/base-component-class.js +0 -100
- package/legacy/es5/modules/olderversions/base-data-binder-1.js +0 -407
- package/legacy/es5/modules/olderversions/base-data-binder-class.js +0 -358
- package/legacy/es5/modules/olderversions/base-layout-parser-class.js +0 -172
- package/legacy/es5/modules/olderversions/base-mode-1.js +0 -777
- package/legacy/es5/modules/olderversions/base-model-class.js +0 -585
- package/legacy/es5/modules/olderversions/data-binder/element-binding/base-data-binder-class.js +0 -358
- package/legacy/es5/modules/olderversions/data-binder/element-binding/base-model-class.js +0 -585
- package/legacy/es5/modules/olderversions/data-binder/model-binding/base-data-binder-class.js +0 -353
- package/legacy/es5/modules/olderversions/data-binder/model-binding/base-model-class.js +0 -604
- package/legacy/es5/modules/olderversions/data-binder-update-watcher.js +0 -640
- package/legacy/es5/modules/olderversions/data-tracker.js +0 -187
- package/legacy/es5/modules/olderversions/event-update.js +0 -666
- package/legacy/es5/modules/olderversions/nav-link.js +0 -119
- package/legacy/es5/modules/olderversions/router-with-templates-1.js +0 -785
- package/legacy/es5/modules/olderversions/router-with-templates.js +0 -701
- package/legacy/es5/modules/prototypes/ajax.js +0 -657
- package/legacy/es5/modules/prototypes/atom.js +0 -65
- package/legacy/es5/modules/prototypes/component.js +0 -972
- package/legacy/es5/modules/prototypes/data-binder.js +0 -1089
- package/legacy/es5/modules/prototypes/data.js +0 -1290
- package/legacy/es5/modules/prototypes/html-builder.js +0 -414
- package/legacy/es5/modules/prototypes/layout.js +0 -879
- package/legacy/es5/modules/router.js +0 -1680
- package/legacy/es5/modules/state.js +0 -274
- package/main.js +0 -1331
- package/modules/ajax/ajax.js +0 -514
- package/modules/animation/animation.js +0 -236
- package/modules/animations/animation-controller.js +0 -231
- package/modules/animations/animation.js +0 -64
- package/modules/animations/attr-movement.js +0 -66
- package/modules/animations/css-movement.js +0 -170
- package/modules/animations/movement.js +0 -131
- package/modules/animations/value.js +0 -187
- package/modules/atom/atom.js +0 -54
- package/modules/component/component.js +0 -230
- package/modules/component/event-helper.js +0 -119
- package/modules/component/jot.js +0 -144
- package/modules/component/state-helper.js +0 -262
- package/modules/component/unit.js +0 -551
- package/modules/data/attrs.js +0 -40
- package/modules/data/basic-data.js +0 -500
- package/modules/data/data-utils.js +0 -29
- package/modules/data/data.js +0 -3
- package/modules/data/deep-data.js +0 -541
- package/modules/data/model-service.js +0 -528
- package/modules/data/model.js +0 -133
- package/modules/data/simple-data.js +0 -33
- package/modules/data-binder/connection-tracker.js +0 -113
- package/modules/data-binder/connection.js +0 -16
- package/modules/data-binder/data-binder.js +0 -352
- package/modules/data-binder/data-pub-sub.js +0 -141
- package/modules/data-binder/data-source.js +0 -56
- package/modules/data-binder/element-source.js +0 -219
- package/modules/data-binder/one-way-connection.js +0 -46
- package/modules/data-binder/one-way-source.js +0 -43
- package/modules/data-binder/source.js +0 -36
- package/modules/data-binder/two-way-connection.js +0 -75
- package/modules/data-binder/two-way-source.js +0 -41
- package/modules/date/date.js +0 -544
- package/modules/history/history.js +0 -89
- package/modules/html-builder/html-builder.js +0 -434
- package/modules/import/import.js +0 -390
- package/modules/layout/layout-builder.js +0 -1269
- package/modules/layout/layout-parser.js +0 -134
- package/modules/layout/watcher-helper.js +0 -282
- package/modules/mouse/mouse.js +0 -114
- package/modules/router/component-helper.js +0 -163
- package/modules/router/history-controller.js +0 -216
- package/modules/router/nav-link.js +0 -124
- package/modules/router/route.js +0 -401
- package/modules/router/router.js +0 -789
- package/modules/router/utils.js +0 -31
- package/modules/state/state-target.js +0 -91
- package/modules/state/state.js +0 -171
- package/shared/objects.js +0 -99
- package/update +0 -16
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
/* base framework module */
|
|
2
|
-
/*
|
|
3
|
-
this will create dynamic html to be
|
|
4
|
-
added and modified
|
|
5
|
-
*/
|
|
6
|
-
(function()
|
|
7
|
-
{
|
|
8
|
-
"use strict";
|
|
9
|
-
|
|
10
|
-
base.extend.formValidator =
|
|
11
|
-
{
|
|
12
|
-
/* these are the classes that will display on
|
|
13
|
-
the field when validated */
|
|
14
|
-
errorClass: 'error-val',
|
|
15
|
-
acceptedClass: 'success-val',
|
|
16
|
-
|
|
17
|
-
/* this will return true or false if an
|
|
18
|
-
email has valid email syntax.
|
|
19
|
-
@param (string) email = the email address
|
|
20
|
-
to validate */
|
|
21
|
-
isValidEmail: function(email)
|
|
22
|
-
{
|
|
23
|
-
var regExp = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
24
|
-
return regExp.test(email);
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
/* this will return true or false if a
|
|
28
|
-
phone is the filled out.
|
|
29
|
-
@param (mixed) phone = the phone number
|
|
30
|
-
to validate */
|
|
31
|
-
isValidPhone: function(phone)
|
|
32
|
-
{
|
|
33
|
-
var pattern = /[^0-9]/g;
|
|
34
|
-
/* we want to convert to string and remove any marks */
|
|
35
|
-
phone = phone.toString().replace(pattern, '');
|
|
36
|
-
|
|
37
|
-
/* we want to check if the phone is a
|
|
38
|
-
number */
|
|
39
|
-
if(isNaN(phone))
|
|
40
|
-
{
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/* we want to check to remove the leading 1 */
|
|
45
|
-
if(phone.substring(0, 1) === '1')
|
|
46
|
-
{
|
|
47
|
-
phone = phone.substring(1);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/* we want check the length and block any 555
|
|
51
|
-
area code numbers */
|
|
52
|
-
return (phone.length === 10 && phone.substring(0, 3) !== '555');
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
/* this will return true or false if a
|
|
56
|
-
date is the filled out.
|
|
57
|
-
@param (string) date = the date
|
|
58
|
-
to validate */
|
|
59
|
-
isValidDate: function(date)
|
|
60
|
-
{
|
|
61
|
-
if(typeof date === 'undefined')
|
|
62
|
-
{
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
var result = new Date(date).toDateString();
|
|
67
|
-
return (result !== 'Invalid Date');
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
/* this will return true or false if an
|
|
71
|
-
radio group is checked.
|
|
72
|
-
@param (string) groupName = the radio
|
|
73
|
-
group name */
|
|
74
|
-
isRadioChecked: function(groupName)
|
|
75
|
-
{
|
|
76
|
-
if(typeof groupName === 'undefined')
|
|
77
|
-
{
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
var radios = document.getElementsByName(groupName);
|
|
82
|
-
if(radios && radios.length)
|
|
83
|
-
{
|
|
84
|
-
for(var i = 0, maxLength = radios.length; i < maxLength; i++)
|
|
85
|
-
{
|
|
86
|
-
var radio = radios[i];
|
|
87
|
-
if(radio.type === 'radio' && radio.checked)
|
|
88
|
-
{
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return false;
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
/* this will return true or false if a field
|
|
97
|
-
has a value.
|
|
98
|
-
@param (mixed) val = the value to validate */
|
|
99
|
-
isValidField: function(val)
|
|
100
|
-
{
|
|
101
|
-
if(typeof val !== 'undefined' && val != '')
|
|
102
|
-
{
|
|
103
|
-
return true;
|
|
104
|
-
}
|
|
105
|
-
return false;
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
/* this will validate a form and return an error object
|
|
109
|
-
with the number of errors and an error message.
|
|
110
|
-
@param (object) form = the form to validate
|
|
111
|
-
@param [(string)] uniqueFormId = specify any unique prefix that
|
|
112
|
-
should be remove from the error message
|
|
113
|
-
@return (object) a response object with the error
|
|
114
|
-
number and message */
|
|
115
|
-
validateForm: function(form, uniqueFormId)
|
|
116
|
-
{
|
|
117
|
-
uniqueFormId = uniqueFormId || '';
|
|
118
|
-
/* we want to save a reference of our object
|
|
119
|
-
to use with any call backs */
|
|
120
|
-
var self = this;
|
|
121
|
-
|
|
122
|
-
/* this will save the errors and the error message */
|
|
123
|
-
var errors =
|
|
124
|
-
{
|
|
125
|
-
number: 0,
|
|
126
|
-
message: ''
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
/* this will update add a field to the error object
|
|
130
|
-
@param (object) node = the node element object */
|
|
131
|
-
var updateError = function(node)
|
|
132
|
-
{
|
|
133
|
-
/* this will uppercase each word */
|
|
134
|
-
var upperCaseWords = function(str)
|
|
135
|
-
{
|
|
136
|
-
var pattern = /\w\S*/g;
|
|
137
|
-
return str.replace(pattern, function(txt){return txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase();});
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
/* we want to get something to identify the field */
|
|
141
|
-
var fieldName = base.attr(node, 'placeholder') || base.attr(node, 'name') || base.attr(node, 'id');
|
|
142
|
-
if(fieldName)
|
|
143
|
-
{
|
|
144
|
-
if(uniqueFormId !== '')
|
|
145
|
-
{
|
|
146
|
-
fieldName = fieldName.replace(uniqueFormId, '');
|
|
147
|
-
}
|
|
148
|
-
var pattern = /[^a-zA-Z1-9]/g;
|
|
149
|
-
fieldName = fieldName.replace(pattern, ' ');
|
|
150
|
-
fieldName = upperCaseWords(fieldName);
|
|
151
|
-
}
|
|
152
|
-
/* we want to increase the error count
|
|
153
|
-
and save an error message for the field */
|
|
154
|
-
errors.number++;
|
|
155
|
-
errors.message += "<br>" + fieldName + " is empty or invaid.";
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
if(typeof form === 'object')
|
|
159
|
-
{
|
|
160
|
-
/* we want to track a radio so we do keep tracking
|
|
161
|
-
the same group after the first check */
|
|
162
|
-
var previousRadios = [];
|
|
163
|
-
|
|
164
|
-
var nodes = base.find(form, 'input.val, select.val, textarea.val');
|
|
165
|
-
if(nodes)
|
|
166
|
-
{
|
|
167
|
-
for(var i = 0, maxLength = nodes.length; i < maxLength; i++)
|
|
168
|
-
{
|
|
169
|
-
/* we want to cache the object and settings */
|
|
170
|
-
var node = nodes[i],
|
|
171
|
-
nodeName = node.nodeName.toLowerCase();
|
|
172
|
-
|
|
173
|
-
/* we want to check if the input is a radio */
|
|
174
|
-
if(nodeName === 'input' && base.attr(node, 'type') === 'radio')
|
|
175
|
-
{
|
|
176
|
-
var groupName = node.name;
|
|
177
|
-
|
|
178
|
-
/* we want to check if the radio has already
|
|
179
|
-
been checked */
|
|
180
|
-
if(base.inArray(previousRadios, groupName) == '-1')
|
|
181
|
-
{
|
|
182
|
-
/* we want to add this group to the previous
|
|
183
|
-
radio array to stop future checks */
|
|
184
|
-
previousRadios.push(groupName);
|
|
185
|
-
|
|
186
|
-
/* we want to validate the field and check
|
|
187
|
-
the status */
|
|
188
|
-
var validField = self.isRadioChecked(groupName);
|
|
189
|
-
if(validField == false)
|
|
190
|
-
{
|
|
191
|
-
updateError(node);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
else
|
|
196
|
-
{
|
|
197
|
-
/* we want to validate the field and check
|
|
198
|
-
the status */
|
|
199
|
-
var validField = self.validateField(node);
|
|
200
|
-
if(validField == false)
|
|
201
|
-
{
|
|
202
|
-
updateError(node);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
return errors;
|
|
210
|
-
},
|
|
211
|
-
|
|
212
|
-
/* this will set a field to show a validated style
|
|
213
|
-
after the field is validated.
|
|
214
|
-
@param (object) field = the field object
|
|
215
|
-
@param (bool) isValid = set true if the field is valid */
|
|
216
|
-
showValidateStyle: function(field, isValid)
|
|
217
|
-
{
|
|
218
|
-
/* we want to check if the field was valid */
|
|
219
|
-
if(isValid == true)
|
|
220
|
-
{
|
|
221
|
-
/* we want to update the class to reflect the
|
|
222
|
-
valid status */
|
|
223
|
-
base.removeClass(field, this.errorClass);
|
|
224
|
-
base.addClass(field, this.acceptedClass);
|
|
225
|
-
return true;
|
|
226
|
-
}
|
|
227
|
-
else
|
|
228
|
-
{
|
|
229
|
-
/* we want to show the field is invalid
|
|
230
|
-
and save */
|
|
231
|
-
base.addClass(field, this.errorClass);
|
|
232
|
-
base.removeClass(field, this.acceptedClass);
|
|
233
|
-
|
|
234
|
-
return false;
|
|
235
|
-
}
|
|
236
|
-
},
|
|
237
|
-
|
|
238
|
-
/* this will validate a field and return true or false.
|
|
239
|
-
@param (object) field = the field element */
|
|
240
|
-
validateField: function(field)
|
|
241
|
-
{
|
|
242
|
-
var returnValue = false;
|
|
243
|
-
|
|
244
|
-
if(!field)
|
|
245
|
-
{
|
|
246
|
-
return returnValue;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
var val = field.value,
|
|
250
|
-
type = base.attr(field, 'type'),
|
|
251
|
-
placeholder = base.attr(field, 'placeholder') || base.attr(field, 'alt');
|
|
252
|
-
|
|
253
|
-
if(type === 'checkbox')
|
|
254
|
-
{
|
|
255
|
-
var validField = field.checked;
|
|
256
|
-
returnValue = this.showValidateStyle(field, validField);
|
|
257
|
-
}
|
|
258
|
-
else if(!this.isValidField(val) || val === placeholder)
|
|
259
|
-
{
|
|
260
|
-
/* if the field is empty or has same value as the
|
|
261
|
-
placeholder text we can set the style to error */
|
|
262
|
-
returnValue = this.showValidateStyle(field, false);
|
|
263
|
-
}
|
|
264
|
-
else if(type === 'email')
|
|
265
|
-
{
|
|
266
|
-
/* we need to validate the email */
|
|
267
|
-
var validField = this.isValidEmail(val);
|
|
268
|
-
returnValue = this.showValidateStyle(field, validField);
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
else if(type === 'tel')
|
|
272
|
-
{
|
|
273
|
-
/* we need to validate the phone */
|
|
274
|
-
var validField = this.isValidPhone(val);
|
|
275
|
-
returnValue = this.showValidateStyle(field, validField);
|
|
276
|
-
}
|
|
277
|
-
else if(type === 'date')
|
|
278
|
-
{
|
|
279
|
-
/* we need to validate the phone */
|
|
280
|
-
var validField = this.isValidDate(val);
|
|
281
|
-
returnValue = this.showValidateStyle(field, validField);
|
|
282
|
-
}
|
|
283
|
-
else
|
|
284
|
-
{
|
|
285
|
-
returnValue = this.showValidateStyle(field, true);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
return returnValue;
|
|
289
|
-
},
|
|
290
|
-
|
|
291
|
-
/* this will remove all the validation styles from a form
|
|
292
|
-
@param (object) form = the form element */
|
|
293
|
-
resetForm: function(form)
|
|
294
|
-
{
|
|
295
|
-
if(!form || typeof form === 'object')
|
|
296
|
-
{
|
|
297
|
-
return false;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
var elements = form.elements;
|
|
301
|
-
if(elements)
|
|
302
|
-
{
|
|
303
|
-
for(var i = 0, maxLength = elements.length; i < maxLength; i++)
|
|
304
|
-
{
|
|
305
|
-
var element = elements[i];
|
|
306
|
-
this.removeStyles(element);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
},
|
|
310
|
-
|
|
311
|
-
/* this will remove the styles from a field
|
|
312
|
-
@param (object) field = the element object */
|
|
313
|
-
removeStyles: function(field)
|
|
314
|
-
{
|
|
315
|
-
if(field)
|
|
316
|
-
{
|
|
317
|
-
base.removeClass(field, this.errorClass);
|
|
318
|
-
base.removeClass(field, this.acceptedClass);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
};
|
|
323
|
-
|
|
324
|
-
})();
|
package/es5/modules/history.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/* base framework module */
|
|
2
|
-
(function()
|
|
3
|
-
{
|
|
4
|
-
"use strict";
|
|
5
|
-
|
|
6
|
-
/* this will update the page title */
|
|
7
|
-
var updateTitle = function(title)
|
|
8
|
-
{
|
|
9
|
-
if(typeof title === 'string')
|
|
10
|
-
{
|
|
11
|
-
document.title = title;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/* this will check if the user is sending the title
|
|
16
|
-
by the state object because most browsers dont use
|
|
17
|
-
the current title param.
|
|
18
|
-
@param (string) title = the new title
|
|
19
|
-
@param (object) stateObj = the new state object */
|
|
20
|
-
var getStateTitle = function(title, stateObj)
|
|
21
|
-
{
|
|
22
|
-
return (title === null && (stateObj && stateObj.title))? stateObj.title : title;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/* this will add and remove states from window history */
|
|
26
|
-
base.extend.history =
|
|
27
|
-
{
|
|
28
|
-
/* this will check if history api is supported and if so
|
|
29
|
-
return true else return false */
|
|
30
|
-
isSupported: function()
|
|
31
|
-
{
|
|
32
|
-
if('history' in window && 'pushState' in window.history)
|
|
33
|
-
{
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
else
|
|
37
|
-
{
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
/* this will add and event listener for window popstate.
|
|
43
|
-
@param (function) fn = the function to use as callback
|
|
44
|
-
@param [(bool)] capture = event capture */
|
|
45
|
-
addEvent: function(fn, capture)
|
|
46
|
-
{
|
|
47
|
-
/* this will check if the current state has a
|
|
48
|
-
title property to update thepage title */
|
|
49
|
-
var popEvent = function(e)
|
|
50
|
-
{
|
|
51
|
-
var state = e.state;
|
|
52
|
-
if(state && state.title)
|
|
53
|
-
{
|
|
54
|
-
updateTitle(state.title);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
fn(e);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
base.events.add('popstate', window, popEvent, capture, true, fn);
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
/* this will remove and event listener for window popstate.
|
|
64
|
-
@param (function) fn = the function to use as callback
|
|
65
|
-
@param [(bool)] capture = event capture */
|
|
66
|
-
removeEvent: function(fn, capture)
|
|
67
|
-
{
|
|
68
|
-
base.off('popstate', window, fn, capture);
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
/* this will add a state to the window history
|
|
72
|
-
@param (object) object = the state object
|
|
73
|
-
@param (string) title = the state page title
|
|
74
|
-
@param (string) url = the state url */
|
|
75
|
-
|
|
76
|
-
pushState: function(object, title, url)
|
|
77
|
-
{
|
|
78
|
-
var history = window.history,
|
|
79
|
-
lastState = history.state;
|
|
80
|
-
|
|
81
|
-
/* we want to check if the object is not already
|
|
82
|
-
the last saved state */
|
|
83
|
-
if(!lastState || base.equals(lastState, object) === false)
|
|
84
|
-
{
|
|
85
|
-
title = getStateTitle(title, object);
|
|
86
|
-
updateTitle(title);
|
|
87
|
-
|
|
88
|
-
/* we want to add the new state to the window history*/
|
|
89
|
-
history.pushState(object, title, url);
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
/* this will add a state to the window history
|
|
94
|
-
@param (object) object = the state object
|
|
95
|
-
@param (string) title = the state page title
|
|
96
|
-
@param (string) url = the state url */
|
|
97
|
-
replaceState: function(object, title, url)
|
|
98
|
-
{
|
|
99
|
-
title = getStateTitle(title, object);
|
|
100
|
-
updateTitle(title);
|
|
101
|
-
|
|
102
|
-
/* we want to add the new state to the window history*/
|
|
103
|
-
window.history.replaceState(object, title, url);
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
/* this will go to the next state in the window history */
|
|
107
|
-
nextState: function()
|
|
108
|
-
{
|
|
109
|
-
window.history.forward();
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
/* this will go to the previous state in the window history */
|
|
113
|
-
prevState: function()
|
|
114
|
-
{
|
|
115
|
-
window.history.back();
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
/* this will take you to a specified number in the history
|
|
119
|
-
index.
|
|
120
|
-
@param (int) indexNumber= the number to go to */
|
|
121
|
-
goTo: function(indexNumber)
|
|
122
|
-
{
|
|
123
|
-
window.history.go(indexNumber);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
})();
|