@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,551 @@
|
|
|
1
|
+
import {base} from '../../core.js';
|
|
2
|
+
import {builder} from '../layout/layout-builder.js';
|
|
3
|
+
import {dataBinder} from '../data-binder/data-binder.js';
|
|
4
|
+
|
|
5
|
+
/* this will register the component system to the
|
|
6
|
+
data tracker to remove components that have been
|
|
7
|
+
nested in layouts. */
|
|
8
|
+
base.dataTracker.addType('components', (data) =>
|
|
9
|
+
{
|
|
10
|
+
if(!data)
|
|
11
|
+
{
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let component = data.component;
|
|
16
|
+
if(component && component.rendered === true)
|
|
17
|
+
{
|
|
18
|
+
component.prepareDestroy();
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
let unitNumber = 0;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Unit
|
|
26
|
+
*
|
|
27
|
+
* @class
|
|
28
|
+
*
|
|
29
|
+
* This will allow units to be extended
|
|
30
|
+
* from a single factory.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* var Alert = base.Unit.extend(
|
|
34
|
+
* {
|
|
35
|
+
* constructor: function(props)
|
|
36
|
+
* {
|
|
37
|
+
* // this will setup the component id
|
|
38
|
+
* base.Component.call(this, props);
|
|
39
|
+
* },
|
|
40
|
+
*
|
|
41
|
+
* render: function()
|
|
42
|
+
* {
|
|
43
|
+
* return {
|
|
44
|
+
*
|
|
45
|
+
* };
|
|
46
|
+
* }
|
|
47
|
+
* });
|
|
48
|
+
*/
|
|
49
|
+
export class Unit
|
|
50
|
+
{
|
|
51
|
+
/**
|
|
52
|
+
* @constructor
|
|
53
|
+
* @param {object} [props]
|
|
54
|
+
*/
|
|
55
|
+
constructor(props)
|
|
56
|
+
{
|
|
57
|
+
/**
|
|
58
|
+
* @param {bool} isUnit
|
|
59
|
+
*/
|
|
60
|
+
this.isUnit = true;
|
|
61
|
+
|
|
62
|
+
this.init();
|
|
63
|
+
this.setupProps(props);
|
|
64
|
+
this.onCreated();
|
|
65
|
+
|
|
66
|
+
this.rendered = false;
|
|
67
|
+
this.container = null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* This will setup the component number and unique
|
|
72
|
+
* instance id for the component elements.
|
|
73
|
+
* @protected
|
|
74
|
+
*/
|
|
75
|
+
init()
|
|
76
|
+
{
|
|
77
|
+
this.id = 'cp-' + (unitNumber++);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* This will setup the component props.
|
|
82
|
+
*
|
|
83
|
+
* @param {object} [props]
|
|
84
|
+
*/
|
|
85
|
+
setupProps(props)
|
|
86
|
+
{
|
|
87
|
+
if(!props || typeof props !== 'object')
|
|
88
|
+
{
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
for(var prop in props)
|
|
93
|
+
{
|
|
94
|
+
if(props.hasOwnProperty(prop))
|
|
95
|
+
{
|
|
96
|
+
this[prop] = props[prop];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* This will get the parent context.
|
|
103
|
+
*
|
|
104
|
+
* @returns {object|null}
|
|
105
|
+
*/
|
|
106
|
+
getParentContext()
|
|
107
|
+
{
|
|
108
|
+
if(!this.parent)
|
|
109
|
+
{
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return this.parent.getContext();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* This will set up the context.
|
|
118
|
+
*
|
|
119
|
+
* @returns {void}
|
|
120
|
+
*/
|
|
121
|
+
setupContext()
|
|
122
|
+
{
|
|
123
|
+
let parentContext = this.getParentContext();
|
|
124
|
+
let context = this.setContext(parentContext);
|
|
125
|
+
if(context)
|
|
126
|
+
{
|
|
127
|
+
this.context = context;
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
this.context = parentContext;
|
|
132
|
+
this.setupAddingContext();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* This will set up the adding context.
|
|
137
|
+
*
|
|
138
|
+
* @returns {void}
|
|
139
|
+
*/
|
|
140
|
+
setupAddingContext()
|
|
141
|
+
{
|
|
142
|
+
let parentContext = this.context;
|
|
143
|
+
let context = this.addContext(parentContext);
|
|
144
|
+
if(!context)
|
|
145
|
+
{
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
let branchName = context[0];
|
|
150
|
+
if(!branchName)
|
|
151
|
+
{
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
this.addingContext = true;
|
|
156
|
+
this.contextBranchName = branchName;
|
|
157
|
+
this.addContextBranch(branchName, context[1]);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* This will add a branch to the context.
|
|
162
|
+
*
|
|
163
|
+
* @param {string} branchName
|
|
164
|
+
* @param {mixed} value
|
|
165
|
+
*/
|
|
166
|
+
addContextBranch(branchName, value)
|
|
167
|
+
{
|
|
168
|
+
this.context = this.context || {};
|
|
169
|
+
this.context[branchName] = value;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* This will set the component context.
|
|
174
|
+
*
|
|
175
|
+
* @param {object|null} context
|
|
176
|
+
* @returns {object|null}
|
|
177
|
+
*/
|
|
178
|
+
setContext(context)
|
|
179
|
+
{
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* This will add context to the parent context.
|
|
185
|
+
*
|
|
186
|
+
* @param {object|null} context
|
|
187
|
+
* @return {array|null}
|
|
188
|
+
*/
|
|
189
|
+
addContext(context)
|
|
190
|
+
{
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* This will remove the added context from the parent.
|
|
196
|
+
*
|
|
197
|
+
* @returns {void}
|
|
198
|
+
*/
|
|
199
|
+
removeContext()
|
|
200
|
+
{
|
|
201
|
+
if(!this.addingContext)
|
|
202
|
+
{
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
this.removeContextBranch(this.contextBranchName);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* This will remove a context branch.
|
|
211
|
+
*
|
|
212
|
+
* @param {string} branch
|
|
213
|
+
* @returns {void}
|
|
214
|
+
*/
|
|
215
|
+
removeContextBranch(branch)
|
|
216
|
+
{
|
|
217
|
+
if(!branch)
|
|
218
|
+
{
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
delete this.context[branch];
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* This will get the context.
|
|
227
|
+
*
|
|
228
|
+
* @returns {object|null}
|
|
229
|
+
*/
|
|
230
|
+
getContext()
|
|
231
|
+
{
|
|
232
|
+
return this.context;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* override this to do something when created.
|
|
237
|
+
*/
|
|
238
|
+
onCreated()
|
|
239
|
+
{
|
|
240
|
+
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* This will render the component.
|
|
245
|
+
*
|
|
246
|
+
* @return {object}
|
|
247
|
+
*/
|
|
248
|
+
render()
|
|
249
|
+
{
|
|
250
|
+
return {
|
|
251
|
+
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* This will cache the layout panel and set the main id.
|
|
257
|
+
* @param {object} layout
|
|
258
|
+
* @return {object}
|
|
259
|
+
*/
|
|
260
|
+
_cacheRoot(layout)
|
|
261
|
+
{
|
|
262
|
+
if(!layout)
|
|
263
|
+
{
|
|
264
|
+
return layout;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if(!layout.id)
|
|
268
|
+
{
|
|
269
|
+
layout.id = this.getId();
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
layout.cache = 'panel';
|
|
273
|
+
return layout;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* This will create the component layout.
|
|
278
|
+
* @protected
|
|
279
|
+
* @return {object}
|
|
280
|
+
*/
|
|
281
|
+
_createLayout()
|
|
282
|
+
{
|
|
283
|
+
if(this.persist)
|
|
284
|
+
{
|
|
285
|
+
return this._layout || (this._layout = this.render());
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return this.render();
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* This will prepare the layout.
|
|
293
|
+
*
|
|
294
|
+
* @protected
|
|
295
|
+
* @return {object}
|
|
296
|
+
*/
|
|
297
|
+
prepareLayout()
|
|
298
|
+
{
|
|
299
|
+
let layout = this._createLayout();
|
|
300
|
+
return this._cacheRoot(layout);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* This will build the layout.
|
|
305
|
+
* @protected
|
|
306
|
+
*/
|
|
307
|
+
buildLayout()
|
|
308
|
+
{
|
|
309
|
+
let layout = this.prepareLayout();
|
|
310
|
+
this.build(layout, this.container);
|
|
311
|
+
|
|
312
|
+
base.dataTracker.add(this.panel, 'components',
|
|
313
|
+
{
|
|
314
|
+
component: this
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
this.rendered = true;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* This will build a layout.
|
|
322
|
+
*
|
|
323
|
+
* @param {object} layout
|
|
324
|
+
* @param {object} container
|
|
325
|
+
* @return {object}
|
|
326
|
+
*/
|
|
327
|
+
build(layout, container)
|
|
328
|
+
{
|
|
329
|
+
return builder.build(layout, container, this);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* This will prepend layout to a container.
|
|
334
|
+
*
|
|
335
|
+
* @param {object} layout
|
|
336
|
+
* @param {object} container
|
|
337
|
+
* @param {object} [optionalNode]
|
|
338
|
+
*/
|
|
339
|
+
prepend(layout, container, optionalNode)
|
|
340
|
+
{
|
|
341
|
+
var frag = this.build(layout, null);
|
|
342
|
+
builder.prepend(container, frag, optionalNode);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* This will rebuild a layout.
|
|
347
|
+
*
|
|
348
|
+
* @param {object} layout
|
|
349
|
+
* @param {object} container
|
|
350
|
+
* @return {object}
|
|
351
|
+
*/
|
|
352
|
+
rebuild(layout, container)
|
|
353
|
+
{
|
|
354
|
+
return builder.rebuild(container, layout, this);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* This will render the content on condition of a property.
|
|
359
|
+
*
|
|
360
|
+
* @param {mixed} prop
|
|
361
|
+
* @param {mixed} content
|
|
362
|
+
* @returns {object}
|
|
363
|
+
*/
|
|
364
|
+
if(prop, content)
|
|
365
|
+
{
|
|
366
|
+
return (!prop)? null : (content || prop);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* This will map an array to children elements.
|
|
371
|
+
*
|
|
372
|
+
* @param {array} items
|
|
373
|
+
* @param {function} callBack
|
|
374
|
+
* @returns {array}
|
|
375
|
+
*/
|
|
376
|
+
map(items, callBack)
|
|
377
|
+
{
|
|
378
|
+
let children = [];
|
|
379
|
+
if(!items || items.length < 1)
|
|
380
|
+
{
|
|
381
|
+
return children;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
for(var i = 0, length = items.length; i < length; i++)
|
|
385
|
+
{
|
|
386
|
+
var item = callBack(items[i], i);
|
|
387
|
+
children.push(item);
|
|
388
|
+
}
|
|
389
|
+
return children;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* This will remove children from an element.
|
|
394
|
+
*
|
|
395
|
+
* @param {object} layout
|
|
396
|
+
* @param {object} container
|
|
397
|
+
* @return {object}
|
|
398
|
+
*/
|
|
399
|
+
removeAll(ele)
|
|
400
|
+
{
|
|
401
|
+
return builder.removeAll(ele);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* This will cache an element when its created by
|
|
406
|
+
* saving a reference to it as a property on the
|
|
407
|
+
* component.
|
|
408
|
+
*
|
|
409
|
+
* @param {string} propName The name to use as
|
|
410
|
+
* the reference.
|
|
411
|
+
* @param {object} layout
|
|
412
|
+
* @param {function} [callBack]
|
|
413
|
+
* @return {object}
|
|
414
|
+
*/
|
|
415
|
+
cache(propName, layout, callBack)
|
|
416
|
+
{
|
|
417
|
+
if(!layout || typeof layout !== 'object')
|
|
418
|
+
{
|
|
419
|
+
return false;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
if(layout.isUnit === true)
|
|
423
|
+
{
|
|
424
|
+
layout =
|
|
425
|
+
{
|
|
426
|
+
component: layout
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
layout.onCreated = (element) =>
|
|
431
|
+
{
|
|
432
|
+
this[propName] = element;
|
|
433
|
+
|
|
434
|
+
if(typeof callBack === 'function')
|
|
435
|
+
{
|
|
436
|
+
callBack(element);
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
return layout;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* This will get an id of the component or the full
|
|
444
|
+
* id that has the component id prepended to the
|
|
445
|
+
* requested id.
|
|
446
|
+
*
|
|
447
|
+
* @param {string} [id]
|
|
448
|
+
* @return {string}
|
|
449
|
+
*/
|
|
450
|
+
getId(id)
|
|
451
|
+
{
|
|
452
|
+
let mainId = this.id;
|
|
453
|
+
if(typeof id === 'string')
|
|
454
|
+
{
|
|
455
|
+
mainId += '-' + id;
|
|
456
|
+
}
|
|
457
|
+
return mainId;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* This will initialize the component.
|
|
462
|
+
* @protected
|
|
463
|
+
*/
|
|
464
|
+
initialize()
|
|
465
|
+
{
|
|
466
|
+
this.setupContext();
|
|
467
|
+
this.beforeSetup();
|
|
468
|
+
this.buildLayout();
|
|
469
|
+
this.afterSetup();
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* override this to do something before setup.
|
|
474
|
+
*/
|
|
475
|
+
beforeSetup()
|
|
476
|
+
{
|
|
477
|
+
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* override this to do something after setup.
|
|
482
|
+
*/
|
|
483
|
+
afterSetup()
|
|
484
|
+
{
|
|
485
|
+
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* This will setup and render the component.
|
|
490
|
+
* @param {object} container
|
|
491
|
+
*/
|
|
492
|
+
setup(container)
|
|
493
|
+
{
|
|
494
|
+
this.container = container;
|
|
495
|
+
this.initialize();
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* This will remove the component.
|
|
500
|
+
* @protected
|
|
501
|
+
*/
|
|
502
|
+
remove()
|
|
503
|
+
{
|
|
504
|
+
this.prepareDestroy();
|
|
505
|
+
this.removeContext();
|
|
506
|
+
|
|
507
|
+
let panel = this.panel || this.id;
|
|
508
|
+
builder.removeElement(panel);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* This will prepare the component to be destroyed.
|
|
513
|
+
*/
|
|
514
|
+
prepareDestroy()
|
|
515
|
+
{
|
|
516
|
+
this.rendered = false;
|
|
517
|
+
this.beforeDestroy();
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Override this to do something before destroy.
|
|
522
|
+
*/
|
|
523
|
+
beforeDestroy()
|
|
524
|
+
{
|
|
525
|
+
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* This will destroy the component.
|
|
530
|
+
*/
|
|
531
|
+
destroy()
|
|
532
|
+
{
|
|
533
|
+
this.remove();
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* This will bind and element to data.
|
|
538
|
+
*
|
|
539
|
+
* @param {object} element
|
|
540
|
+
* @param {object} data
|
|
541
|
+
* @param {string} prop
|
|
542
|
+
* @param {function} filter
|
|
543
|
+
*/
|
|
544
|
+
bindElement(element, data, prop, filter)
|
|
545
|
+
{
|
|
546
|
+
if(element)
|
|
547
|
+
{
|
|
548
|
+
dataBinder.bind(element, data, prop, filter);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This will clone an object.
|
|
3
|
+
*
|
|
4
|
+
* @param {object} obj
|
|
5
|
+
*/
|
|
6
|
+
export const cloneObject = (obj) =>
|
|
7
|
+
{
|
|
8
|
+
return JSON.parse(JSON.stringify(obj));
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* This will get the data attribute settings.
|
|
13
|
+
*
|
|
14
|
+
* @param {object} settings
|
|
15
|
+
* @return {object}
|
|
16
|
+
*/
|
|
17
|
+
export const setupAttrSettings = (settings) =>
|
|
18
|
+
{
|
|
19
|
+
let attributes = {};
|
|
20
|
+
if(!settings && typeof settings !== 'object')
|
|
21
|
+
{
|
|
22
|
+
return attributes;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
settings = cloneObject(settings);
|
|
26
|
+
|
|
27
|
+
for(var prop in settings)
|
|
28
|
+
{
|
|
29
|
+
if(settings.hasOwnProperty(prop))
|
|
30
|
+
{
|
|
31
|
+
var setting = settings[prop];
|
|
32
|
+
if(typeof setting !== 'function')
|
|
33
|
+
{
|
|
34
|
+
attributes[prop] = setting;
|
|
35
|
+
delete settings[prop];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return attributes;
|
|
40
|
+
};
|