@base-framework/base 2.6.0 → 2.6.1
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/base.min.js +1 -0
- package/es5/base.js +2968 -0
- package/es5/modules/ajax.js +663 -0
- package/es5/modules/animation.js +188 -0
- package/es5/modules/animations.js +1080 -0
- package/es5/modules/atom.js +65 -0
- package/es5/modules/component.js +1310 -0
- package/es5/modules/data-binder.js +1131 -0
- package/es5/modules/data.js +1808 -0
- package/es5/modules/date.js +525 -0
- package/es5/modules/form-validator.js +324 -0
- package/es5/modules/history.js +126 -0
- package/es5/modules/html-builder.js +461 -0
- package/es5/modules/layout.js +1679 -0
- package/es5/modules/mouse.js +124 -0
- package/es5/modules/nav-link.js +123 -0
- package/es5/modules/olderversions/animations-ease.js +1095 -0
- package/es5/modules/olderversions/animations-update.js +1048 -0
- package/es5/modules/olderversions/base-animations.js +636 -0
- package/es5/modules/olderversions/base-component-class.js +100 -0
- package/es5/modules/olderversions/base-data-binder-1.js +407 -0
- package/es5/modules/olderversions/base-data-binder-class.js +358 -0
- package/es5/modules/olderversions/base-layout-parser-class.js +172 -0
- package/es5/modules/olderversions/base-mode-1.js +777 -0
- package/es5/modules/olderversions/base-model-class.js +585 -0
- package/es5/modules/olderversions/data-binder/element-binding/base-data-binder-class.js +358 -0
- package/es5/modules/olderversions/data-binder/element-binding/base-model-class.js +585 -0
- package/es5/modules/olderversions/data-binder/model-binding/base-data-binder-class.js +353 -0
- package/es5/modules/olderversions/data-binder/model-binding/base-model-class.js +604 -0
- package/es5/modules/olderversions/data-binder-update-watcher.js +640 -0
- package/es5/modules/olderversions/data-tracker.js +187 -0
- package/es5/modules/olderversions/event-update.js +666 -0
- package/es5/modules/olderversions/nav-link.js +119 -0
- package/es5/modules/olderversions/router-with-templates-1.js +785 -0
- package/es5/modules/olderversions/router-with-templates.js +701 -0
- package/es5/modules/prototypes/ajax.js +657 -0
- package/es5/modules/prototypes/atom.js +65 -0
- package/es5/modules/prototypes/component.js +972 -0
- package/es5/modules/prototypes/data-binder.js +1089 -0
- package/es5/modules/prototypes/data.js +1290 -0
- package/es5/modules/prototypes/html-builder.js +414 -0
- package/es5/modules/prototypes/layout.js +879 -0
- package/es5/modules/router.js +1680 -0
- package/es5/modules/state.js +274 -0
- package/es6/.jshintrc +3 -0
- package/es6/base.js +41 -0
- package/es6/core.js +1 -0
- package/es6/data-tracker.js +351 -0
- package/es6/events.js +602 -0
- package/es6/legacy/es5/base.js +2968 -0
- package/es6/legacy/es5/modules/ajax.js +663 -0
- package/es6/legacy/es5/modules/animation.js +188 -0
- package/es6/legacy/es5/modules/animations.js +1080 -0
- package/es6/legacy/es5/modules/atom.js +65 -0
- package/es6/legacy/es5/modules/component.js +1310 -0
- package/es6/legacy/es5/modules/data-binder.js +1131 -0
- package/es6/legacy/es5/modules/data.js +1808 -0
- package/es6/legacy/es5/modules/date.js +525 -0
- package/es6/legacy/es5/modules/form-validator.js +324 -0
- package/es6/legacy/es5/modules/history.js +126 -0
- package/es6/legacy/es5/modules/html-builder.js +461 -0
- package/es6/legacy/es5/modules/layout.js +1679 -0
- package/es6/legacy/es5/modules/mouse.js +124 -0
- package/es6/legacy/es5/modules/nav-link.js +123 -0
- package/es6/legacy/es5/modules/olderversions/animations-ease.js +1095 -0
- package/es6/legacy/es5/modules/olderversions/animations-update.js +1048 -0
- package/es6/legacy/es5/modules/olderversions/base-animations.js +636 -0
- package/es6/legacy/es5/modules/olderversions/base-component-class.js +100 -0
- package/es6/legacy/es5/modules/olderversions/base-data-binder-1.js +407 -0
- package/es6/legacy/es5/modules/olderversions/base-data-binder-class.js +358 -0
- package/es6/legacy/es5/modules/olderversions/base-layout-parser-class.js +172 -0
- package/es6/legacy/es5/modules/olderversions/base-mode-1.js +777 -0
- package/es6/legacy/es5/modules/olderversions/base-model-class.js +585 -0
- package/es6/legacy/es5/modules/olderversions/data-binder/element-binding/base-data-binder-class.js +358 -0
- package/es6/legacy/es5/modules/olderversions/data-binder/element-binding/base-model-class.js +585 -0
- package/es6/legacy/es5/modules/olderversions/data-binder/model-binding/base-data-binder-class.js +353 -0
- package/es6/legacy/es5/modules/olderversions/data-binder/model-binding/base-model-class.js +604 -0
- package/es6/legacy/es5/modules/olderversions/data-binder-update-watcher.js +640 -0
- package/es6/legacy/es5/modules/olderversions/data-tracker.js +187 -0
- package/es6/legacy/es5/modules/olderversions/event-update.js +666 -0
- package/es6/legacy/es5/modules/olderversions/nav-link.js +119 -0
- package/es6/legacy/es5/modules/olderversions/router-with-templates-1.js +785 -0
- package/es6/legacy/es5/modules/olderversions/router-with-templates.js +701 -0
- package/es6/legacy/es5/modules/prototypes/ajax.js +657 -0
- package/es6/legacy/es5/modules/prototypes/atom.js +65 -0
- package/es6/legacy/es5/modules/prototypes/component.js +972 -0
- package/es6/legacy/es5/modules/prototypes/data-binder.js +1089 -0
- package/es6/legacy/es5/modules/prototypes/data.js +1290 -0
- package/es6/legacy/es5/modules/prototypes/html-builder.js +414 -0
- package/es6/legacy/es5/modules/prototypes/layout.js +879 -0
- package/es6/legacy/es5/modules/router.js +1680 -0
- package/es6/legacy/es5/modules/state.js +274 -0
- package/es6/main.js +1331 -0
- package/es6/modules/ajax/ajax.js +514 -0
- package/es6/modules/animation/animation.js +236 -0
- package/es6/modules/animations/animation-controller.js +231 -0
- package/es6/modules/animations/animation.js +64 -0
- package/es6/modules/animations/attr-movement.js +66 -0
- package/es6/modules/animations/css-movement.js +170 -0
- package/es6/modules/animations/movement.js +131 -0
- package/es6/modules/animations/value.js +187 -0
- package/es6/modules/atom/atom.js +54 -0
- package/es6/modules/component/component.js +230 -0
- package/es6/modules/component/event-helper.js +119 -0
- package/es6/modules/component/jot.js +144 -0
- package/es6/modules/component/state-helper.js +262 -0
- package/es6/modules/component/unit.js +551 -0
- package/es6/modules/data/attrs.js +40 -0
- package/es6/modules/data/basic-data.js +500 -0
- package/es6/modules/data/data-utils.js +29 -0
- package/es6/modules/data/data.js +3 -0
- package/es6/modules/data/deep-data.js +541 -0
- package/es6/modules/data/model-service.js +528 -0
- package/es6/modules/data/model.js +133 -0
- package/es6/modules/data/simple-data.js +33 -0
- package/es6/modules/data-binder/connection-tracker.js +113 -0
- package/es6/modules/data-binder/connection.js +16 -0
- package/es6/modules/data-binder/data-binder.js +352 -0
- package/es6/modules/data-binder/data-pub-sub.js +141 -0
- package/es6/modules/data-binder/data-source.js +56 -0
- package/es6/modules/data-binder/element-source.js +219 -0
- package/es6/modules/data-binder/one-way-connection.js +46 -0
- package/es6/modules/data-binder/one-way-source.js +43 -0
- package/es6/modules/data-binder/source.js +36 -0
- package/es6/modules/data-binder/two-way-connection.js +75 -0
- package/es6/modules/data-binder/two-way-source.js +41 -0
- package/es6/modules/date/date.js +544 -0
- package/es6/modules/history/history.js +89 -0
- package/es6/modules/html-builder/html-builder.js +434 -0
- package/es6/modules/import/import.js +390 -0
- package/es6/modules/layout/layout-builder.js +1269 -0
- package/es6/modules/layout/layout-parser.js +134 -0
- package/es6/modules/layout/watcher-helper.js +282 -0
- package/es6/modules/mouse/mouse.js +114 -0
- package/es6/modules/router/component-helper.js +163 -0
- package/es6/modules/router/history-controller.js +216 -0
- package/es6/modules/router/nav-link.js +124 -0
- package/es6/modules/router/route.js +401 -0
- package/es6/modules/router/router.js +789 -0
- package/es6/modules/router/utils.js +31 -0
- package/es6/modules/state/state-target.js +91 -0
- package/es6/modules/state/state.js +171 -0
- package/es6/package-lock.json +13 -0
- package/es6/package.json +28 -0
- package/es6/shared/objects.js +99 -0
- package/legacy/es5/base.js +2968 -0
- package/legacy/es5/modules/ajax.js +663 -0
- package/legacy/es5/modules/animation.js +188 -0
- package/legacy/es5/modules/animations.js +1080 -0
- package/legacy/es5/modules/atom.js +65 -0
- package/legacy/es5/modules/component.js +1310 -0
- package/legacy/es5/modules/data-binder.js +1131 -0
- package/legacy/es5/modules/data.js +1808 -0
- package/legacy/es5/modules/date.js +525 -0
- package/legacy/es5/modules/form-validator.js +324 -0
- package/legacy/es5/modules/history.js +126 -0
- package/legacy/es5/modules/html-builder.js +461 -0
- package/legacy/es5/modules/layout.js +1679 -0
- package/legacy/es5/modules/mouse.js +124 -0
- package/legacy/es5/modules/nav-link.js +123 -0
- package/legacy/es5/modules/olderversions/animations-ease.js +1095 -0
- package/legacy/es5/modules/olderversions/animations-update.js +1048 -0
- package/legacy/es5/modules/olderversions/base-animations.js +636 -0
- package/legacy/es5/modules/olderversions/base-component-class.js +100 -0
- package/legacy/es5/modules/olderversions/base-data-binder-1.js +407 -0
- package/legacy/es5/modules/olderversions/base-data-binder-class.js +358 -0
- package/legacy/es5/modules/olderversions/base-layout-parser-class.js +172 -0
- package/legacy/es5/modules/olderversions/base-mode-1.js +777 -0
- package/legacy/es5/modules/olderversions/base-model-class.js +585 -0
- package/legacy/es5/modules/olderversions/data-binder/element-binding/base-data-binder-class.js +358 -0
- package/legacy/es5/modules/olderversions/data-binder/element-binding/base-model-class.js +585 -0
- package/legacy/es5/modules/olderversions/data-binder/model-binding/base-data-binder-class.js +353 -0
- package/legacy/es5/modules/olderversions/data-binder/model-binding/base-model-class.js +604 -0
- package/legacy/es5/modules/olderversions/data-binder-update-watcher.js +640 -0
- package/legacy/es5/modules/olderversions/data-tracker.js +187 -0
- package/legacy/es5/modules/olderversions/event-update.js +666 -0
- package/legacy/es5/modules/olderversions/nav-link.js +119 -0
- package/legacy/es5/modules/olderversions/router-with-templates-1.js +785 -0
- package/legacy/es5/modules/olderversions/router-with-templates.js +701 -0
- package/legacy/es5/modules/prototypes/ajax.js +657 -0
- package/legacy/es5/modules/prototypes/atom.js +65 -0
- package/legacy/es5/modules/prototypes/component.js +972 -0
- package/legacy/es5/modules/prototypes/data-binder.js +1089 -0
- package/legacy/es5/modules/prototypes/data.js +1290 -0
- package/legacy/es5/modules/prototypes/html-builder.js +414 -0
- package/legacy/es5/modules/prototypes/layout.js +879 -0
- package/legacy/es5/modules/router.js +1680 -0
- package/legacy/es5/modules/state.js +274 -0
- package/package.json +8 -3
- package/update +16 -0
|
@@ -0,0 +1,414 @@
|
|
|
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
|
+
var DataTracker = base.DataTracker,
|
|
11
|
+
DataBinder = base.DataBinder;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* htmlBuilder
|
|
15
|
+
*
|
|
16
|
+
* This will create an html builder object that can create
|
|
17
|
+
* and remove dom elements.
|
|
18
|
+
* @class
|
|
19
|
+
*/
|
|
20
|
+
var htmlBuilder = base.Class.extend(
|
|
21
|
+
{
|
|
22
|
+
/**
|
|
23
|
+
* @constructor
|
|
24
|
+
*/
|
|
25
|
+
constructor: function()
|
|
26
|
+
{
|
|
27
|
+
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* This will create a new element.
|
|
32
|
+
*
|
|
33
|
+
* @param {string} nodeName The node name.
|
|
34
|
+
* @param {object} attrObject The node attributes.
|
|
35
|
+
* @param {object} container The node container.
|
|
36
|
+
* @param {boolean} [prepend=false] Add to the begining of the container.
|
|
37
|
+
* @return {object} The new element.
|
|
38
|
+
*/
|
|
39
|
+
create: function(nodeName, attrObject, container, prepend)
|
|
40
|
+
{
|
|
41
|
+
var obj = document.createElement(nodeName);
|
|
42
|
+
this._addElementAttrs(obj, attrObject);
|
|
43
|
+
|
|
44
|
+
/* we want to check if the new element should be
|
|
45
|
+
added to the begining or end */
|
|
46
|
+
if(prepend === true)
|
|
47
|
+
{
|
|
48
|
+
this.prepend(container, obj);
|
|
49
|
+
}
|
|
50
|
+
else
|
|
51
|
+
{
|
|
52
|
+
this.append(container, obj);
|
|
53
|
+
}
|
|
54
|
+
return obj;
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* This will add the element attributes.
|
|
59
|
+
*
|
|
60
|
+
* @protected
|
|
61
|
+
* @param {object} obj
|
|
62
|
+
* @param {object} attrObject
|
|
63
|
+
*/
|
|
64
|
+
_addElementAttrs: function(obj, attrObject)
|
|
65
|
+
{
|
|
66
|
+
/* we want to check if we have attrributes to add */
|
|
67
|
+
if(!attrObject || typeof attrObject !== 'object')
|
|
68
|
+
{
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* we need to add the type if set to stop ie
|
|
73
|
+
from removing the value if set after the value is
|
|
74
|
+
added */
|
|
75
|
+
var type = attrObject.type;
|
|
76
|
+
if(typeof type !== 'undefined')
|
|
77
|
+
{
|
|
78
|
+
base.setAttr(obj, 'type', type);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* we want to add each attr to the obj */
|
|
82
|
+
for(var prop in attrObject)
|
|
83
|
+
{
|
|
84
|
+
/* we have already added the type so we need to
|
|
85
|
+
skip if the prop is type */
|
|
86
|
+
if(attrObject.hasOwnProperty(prop) === false || prop === 'type')
|
|
87
|
+
{
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
var attrPropValue = attrObject[prop];
|
|
92
|
+
|
|
93
|
+
/* we want to check to add the attr settings
|
|
94
|
+
by property name */
|
|
95
|
+
if(prop === 'innerHTML')
|
|
96
|
+
{
|
|
97
|
+
obj.innerHTML = attrPropValue;
|
|
98
|
+
}
|
|
99
|
+
else if(prop.substring(4, 1) === '-')
|
|
100
|
+
{
|
|
101
|
+
// this will handle data and aria attributes
|
|
102
|
+
base.setAttr(obj, prop, attrPropValue);
|
|
103
|
+
}
|
|
104
|
+
else
|
|
105
|
+
{
|
|
106
|
+
this.addAttr(obj, prop, attrPropValue);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* This will add html to an element.
|
|
113
|
+
*
|
|
114
|
+
* @param {object} obj
|
|
115
|
+
* @param {string} content
|
|
116
|
+
*/
|
|
117
|
+
addHtml: function(obj, content)
|
|
118
|
+
{
|
|
119
|
+
if(typeof content !== 'undefined' && content !== '')
|
|
120
|
+
{
|
|
121
|
+
/* we need to check if we are adding inner
|
|
122
|
+
html content or just a string */
|
|
123
|
+
var pattern = /(?:<[a-z][\s\S]*>)/i;
|
|
124
|
+
if(pattern.test(content))
|
|
125
|
+
{
|
|
126
|
+
/* html */
|
|
127
|
+
obj.innerHTML = content;
|
|
128
|
+
}
|
|
129
|
+
else
|
|
130
|
+
{
|
|
131
|
+
/* string */
|
|
132
|
+
obj.textContent = content;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* This will add an element attribute.
|
|
139
|
+
*
|
|
140
|
+
* @param {object} obj
|
|
141
|
+
* @param {object} attr
|
|
142
|
+
* @param {string} value
|
|
143
|
+
*/
|
|
144
|
+
addAttr: function(obj, attr, value)
|
|
145
|
+
{
|
|
146
|
+
if(value === '' || !attr)
|
|
147
|
+
{
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/* we want to check to add a value or an event listener */
|
|
152
|
+
var type = typeof value;
|
|
153
|
+
if(type === 'function')
|
|
154
|
+
{
|
|
155
|
+
/* this will add the event using the base events
|
|
156
|
+
so the event is tracked */
|
|
157
|
+
base.addListener(attr, obj, value);
|
|
158
|
+
}
|
|
159
|
+
else
|
|
160
|
+
{
|
|
161
|
+
obj[attr] = value;
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* This will create a doc fragment.
|
|
167
|
+
*
|
|
168
|
+
* @return {object}
|
|
169
|
+
*/
|
|
170
|
+
createDocFragment: function()
|
|
171
|
+
{
|
|
172
|
+
return document.createDocumentFragment();
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* This will create a text node.
|
|
177
|
+
*
|
|
178
|
+
* @param {string} text
|
|
179
|
+
* @param {object} container
|
|
180
|
+
* @return {object}
|
|
181
|
+
*/
|
|
182
|
+
createTextNode: function(text, container)
|
|
183
|
+
{
|
|
184
|
+
var obj = document.createTextNode(text);
|
|
185
|
+
|
|
186
|
+
if(container)
|
|
187
|
+
{
|
|
188
|
+
this.append(container, obj);
|
|
189
|
+
}
|
|
190
|
+
return obj;
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* This will create the options on a select.
|
|
195
|
+
*
|
|
196
|
+
* @param {object} selectElem
|
|
197
|
+
* @param {array} optionArray
|
|
198
|
+
* @param {string} [defaultValue]
|
|
199
|
+
*/
|
|
200
|
+
setupSelectOptions: function(selectElem, optionArray, defaultValue)
|
|
201
|
+
{
|
|
202
|
+
if(!selectElem || typeof selectElem !== 'object')
|
|
203
|
+
{
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if(!optionArray || !optionArray.length)
|
|
208
|
+
{
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/* create each option then add it to the select */
|
|
213
|
+
for(var n = 0, maxLength = optionArray.length; n < maxLength; n++)
|
|
214
|
+
{
|
|
215
|
+
var settings = optionArray[n];
|
|
216
|
+
var option = selectElem.options[n] = new Option(settings.label, settings.value);
|
|
217
|
+
|
|
218
|
+
/* we can select an option if a default value
|
|
219
|
+
has been sumbitted */
|
|
220
|
+
if(defaultValue !== null && option.value == defaultValue)
|
|
221
|
+
{
|
|
222
|
+
option.selected = true;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* This will remove an elements data.
|
|
229
|
+
*
|
|
230
|
+
* @param {object} ele
|
|
231
|
+
*/
|
|
232
|
+
removeElementData: function(ele)
|
|
233
|
+
{
|
|
234
|
+
/* we want to do a recursive remove child
|
|
235
|
+
removal */
|
|
236
|
+
var children = ele.childNodes;
|
|
237
|
+
if(children)
|
|
238
|
+
{
|
|
239
|
+
var length = children.length - 1;
|
|
240
|
+
for(var i = length; i >= 0; i--)
|
|
241
|
+
{
|
|
242
|
+
var child = children[i];
|
|
243
|
+
if(child)
|
|
244
|
+
{
|
|
245
|
+
/* this will remove the child element data
|
|
246
|
+
before the parent is removed */
|
|
247
|
+
this.removeElementData(child);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
DataTracker.remove(ele);
|
|
253
|
+
|
|
254
|
+
var bound = ele.dataBindId;
|
|
255
|
+
if(bound)
|
|
256
|
+
{
|
|
257
|
+
/* this will check to remove any data bindings
|
|
258
|
+
to the element */
|
|
259
|
+
DataBinder.unbind(ele);
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* This will remove an element and its data.
|
|
265
|
+
*
|
|
266
|
+
* @param {object} obj
|
|
267
|
+
*/
|
|
268
|
+
removeElement: function(obj)
|
|
269
|
+
{
|
|
270
|
+
var container;
|
|
271
|
+
|
|
272
|
+
if(!obj || !(container = obj.parentNode))
|
|
273
|
+
{
|
|
274
|
+
return this;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/* this will remove all element data and binding
|
|
278
|
+
and remove from the parent container */
|
|
279
|
+
this.removeElementData(obj);
|
|
280
|
+
container.removeChild(obj);
|
|
281
|
+
|
|
282
|
+
return this;
|
|
283
|
+
},
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* This will remove an element.
|
|
287
|
+
*
|
|
288
|
+
* @param {object} child
|
|
289
|
+
*/
|
|
290
|
+
removeChild: function(child)
|
|
291
|
+
{
|
|
292
|
+
this.removeElement(child);
|
|
293
|
+
},
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* This will remove all elements from the container.
|
|
297
|
+
*
|
|
298
|
+
* @param {object} container
|
|
299
|
+
*/
|
|
300
|
+
removeAll: function(container)
|
|
301
|
+
{
|
|
302
|
+
if(typeof container === 'object')
|
|
303
|
+
{
|
|
304
|
+
var children = container.childNodes;
|
|
305
|
+
for(var child in children)
|
|
306
|
+
{
|
|
307
|
+
if(children.hasOwnProperty(child))
|
|
308
|
+
{
|
|
309
|
+
this.removeElementData(children[child]);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
container.innerHTML = '';
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* This change the parent of an element.
|
|
318
|
+
*
|
|
319
|
+
* @param {object} child
|
|
320
|
+
* @param {object} newParent
|
|
321
|
+
*/
|
|
322
|
+
changeParent: function(child, newParent)
|
|
323
|
+
{
|
|
324
|
+
if(typeof child === 'string')
|
|
325
|
+
{
|
|
326
|
+
child = document.getElementById(child);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
var container = (typeof newParent === 'string')? document.getElementById(newParent) : newParent;
|
|
330
|
+
container.appendChild(child);
|
|
331
|
+
},
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* This will append a child element.
|
|
335
|
+
*
|
|
336
|
+
* @param {object} parent
|
|
337
|
+
* @param {object} child
|
|
338
|
+
*/
|
|
339
|
+
append: function(parent, child)
|
|
340
|
+
{
|
|
341
|
+
switch(typeof parent)
|
|
342
|
+
{
|
|
343
|
+
case "object":
|
|
344
|
+
break;
|
|
345
|
+
case "string":
|
|
346
|
+
parent = document.getElementById(parent);
|
|
347
|
+
break;
|
|
348
|
+
case "undefined":
|
|
349
|
+
parent = document.body;
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
parent.appendChild(child);
|
|
354
|
+
},
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* This will prepend a child element.
|
|
358
|
+
*
|
|
359
|
+
* @param {object} parent
|
|
360
|
+
* @param {object} child
|
|
361
|
+
*/
|
|
362
|
+
prepend: function(parent, child)
|
|
363
|
+
{
|
|
364
|
+
switch(typeof parent)
|
|
365
|
+
{
|
|
366
|
+
case "object":
|
|
367
|
+
break;
|
|
368
|
+
case "string":
|
|
369
|
+
parent = document.getElementById(parent);
|
|
370
|
+
break;
|
|
371
|
+
case "undefined":
|
|
372
|
+
parent = document.body;
|
|
373
|
+
break;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
parent.insertBefore(child, parent.firstChild);
|
|
377
|
+
},
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* This will clone an element.
|
|
381
|
+
*
|
|
382
|
+
* @param {object} node
|
|
383
|
+
* @param {boolean} deepCopy
|
|
384
|
+
* @return {object}
|
|
385
|
+
*/
|
|
386
|
+
clone: function(node, deepCopy)
|
|
387
|
+
{
|
|
388
|
+
if(!node || typeof node !== 'object')
|
|
389
|
+
{
|
|
390
|
+
return false;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
deepCopy = deepCopy || false;
|
|
394
|
+
return node.cloneNode(deepCopy);
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
/* we want to use a few private functions to add input selection
|
|
399
|
+
to an element and reduce any closures */
|
|
400
|
+
/**
|
|
401
|
+
* This will focus an element.
|
|
402
|
+
*
|
|
403
|
+
* @param {object} e
|
|
404
|
+
*/
|
|
405
|
+
var focusElement = function(e)
|
|
406
|
+
{
|
|
407
|
+
e = e || window.event;
|
|
408
|
+
var src = e.srcElement || e.target;
|
|
409
|
+
src.select();
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
base.extend.htmlBuilder = htmlBuilder;
|
|
413
|
+
|
|
414
|
+
})();
|