@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,134 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LayoutParser
|
|
3
|
-
*
|
|
4
|
-
* This will parse JSON layouts.
|
|
5
|
-
* @class
|
|
6
|
-
*/
|
|
7
|
-
export class LayoutParser
|
|
8
|
-
{
|
|
9
|
-
constructor()
|
|
10
|
-
{
|
|
11
|
-
/**
|
|
12
|
-
* @member {array} _reserved
|
|
13
|
-
* @protected
|
|
14
|
-
*/
|
|
15
|
-
this._reserved = [
|
|
16
|
-
'tag',
|
|
17
|
-
'bind',
|
|
18
|
-
'onCreated',
|
|
19
|
-
'route',
|
|
20
|
-
'switch',
|
|
21
|
-
'useParent',
|
|
22
|
-
'useState',
|
|
23
|
-
'useData',
|
|
24
|
-
'addState',
|
|
25
|
-
'map',
|
|
26
|
-
'for',
|
|
27
|
-
'html',
|
|
28
|
-
'onSet',
|
|
29
|
-
'onState',
|
|
30
|
-
'watch',
|
|
31
|
-
'context',
|
|
32
|
-
'useContext',
|
|
33
|
-
'addContext',
|
|
34
|
-
'role',
|
|
35
|
-
'aria',
|
|
36
|
-
'cache'
|
|
37
|
-
];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* This will get the tag name of an element.
|
|
42
|
-
*
|
|
43
|
-
* @param {object} obj
|
|
44
|
-
* @return {string}
|
|
45
|
-
*/
|
|
46
|
-
getElementTag(obj)
|
|
47
|
-
{
|
|
48
|
-
let type = 'div',
|
|
49
|
-
node = obj.tag || obj.t;
|
|
50
|
-
if (typeof node !== 'undefined')
|
|
51
|
-
{
|
|
52
|
-
type = obj.tag = node;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return type;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* This will setup the element children.
|
|
60
|
-
*
|
|
61
|
-
* @param {object} obj
|
|
62
|
-
*/
|
|
63
|
-
setupChildren(obj)
|
|
64
|
-
{
|
|
65
|
-
if(obj.nest)
|
|
66
|
-
{
|
|
67
|
-
obj.children = obj.nest;
|
|
68
|
-
obj.nest = null;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* This will parse a layout element.
|
|
74
|
-
*
|
|
75
|
-
* @param {object} obj
|
|
76
|
-
* @return {object}
|
|
77
|
-
*/
|
|
78
|
-
parseElement(obj)
|
|
79
|
-
{
|
|
80
|
-
let attr = {},
|
|
81
|
-
children = [];
|
|
82
|
-
|
|
83
|
-
let tag = this.getElementTag(obj);
|
|
84
|
-
if(tag === 'button')
|
|
85
|
-
{
|
|
86
|
-
attr.type = attr.type || 'button';
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
this.setupChildren(obj);
|
|
90
|
-
const reserved = this._reserved;
|
|
91
|
-
|
|
92
|
-
for (var key in obj)
|
|
93
|
-
{
|
|
94
|
-
if (obj.hasOwnProperty(key))
|
|
95
|
-
{
|
|
96
|
-
var value = obj[key];
|
|
97
|
-
if (value === undefined || value === null)
|
|
98
|
-
{
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (reserved.indexOf(key) !== -1)
|
|
103
|
-
{
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/* we need to filter the children from the attr
|
|
108
|
-
settings. the children need to keep their order. */
|
|
109
|
-
if (typeof value !== 'object')
|
|
110
|
-
{
|
|
111
|
-
attr[key] = value;
|
|
112
|
-
}
|
|
113
|
-
else
|
|
114
|
-
{
|
|
115
|
-
if (key === 'children')
|
|
116
|
-
{
|
|
117
|
-
//Array.prototype.push.apply(children, value);
|
|
118
|
-
children = children.concat(value);
|
|
119
|
-
}
|
|
120
|
-
else
|
|
121
|
-
{
|
|
122
|
-
children.push(value);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return {
|
|
129
|
-
tag,
|
|
130
|
-
attr,
|
|
131
|
-
children
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
}
|
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
import {base} from '../../core.js';
|
|
2
|
-
import {dataBinder} from '../data-binder/data-binder.js';
|
|
3
|
-
|
|
4
|
-
const WATCHER_PATTERN = /(\[\[(.*?)\]\])/g;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WatcherHelper
|
|
8
|
-
*
|
|
9
|
-
* This helper creates watcher callBacks, parses watcher strings
|
|
10
|
-
* and sets up watchers.
|
|
11
|
-
*/
|
|
12
|
-
export const WatcherHelper =
|
|
13
|
-
{
|
|
14
|
-
/**
|
|
15
|
-
* This will get the property names to be watched.
|
|
16
|
-
*
|
|
17
|
-
* @protected
|
|
18
|
-
* @param {string} string
|
|
19
|
-
* @return {(array|null)}
|
|
20
|
-
*/
|
|
21
|
-
_getWatcherProps(string)
|
|
22
|
-
{
|
|
23
|
-
let pattern = /\[\[(.*?)\]\]/g,
|
|
24
|
-
matches = string.match(pattern);
|
|
25
|
-
if(matches)
|
|
26
|
-
{
|
|
27
|
-
pattern = /(\[\[|\]\])/g;
|
|
28
|
-
for(var i = 0, length = matches.length; i < length; i++)
|
|
29
|
-
{
|
|
30
|
-
matches[i] = matches[i].replace(pattern, '');
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return matches;
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* This will update an element attribute.
|
|
38
|
-
*
|
|
39
|
-
* @protected
|
|
40
|
-
* @param {object} ele
|
|
41
|
-
* @param {string} attr
|
|
42
|
-
* @param {string} value
|
|
43
|
-
*/
|
|
44
|
-
updateAttr(ele, attr, value)
|
|
45
|
-
{
|
|
46
|
-
if(attr === 'text' || attr === 'textContent')
|
|
47
|
-
{
|
|
48
|
-
ele.textContent = value;
|
|
49
|
-
}
|
|
50
|
-
else if(attr === 'innerHTML')
|
|
51
|
-
{
|
|
52
|
-
ele.innerHTML = value;
|
|
53
|
-
}
|
|
54
|
-
else
|
|
55
|
-
{
|
|
56
|
-
if(attr.substring(4, 1) === '-')
|
|
57
|
-
{
|
|
58
|
-
base.setAttr(ele, attr, value);
|
|
59
|
-
}
|
|
60
|
-
else
|
|
61
|
-
{
|
|
62
|
-
ele[attr] = value;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* This will get a watcher callBack.
|
|
69
|
-
*
|
|
70
|
-
* @protected
|
|
71
|
-
* @param {object} ele
|
|
72
|
-
* @param {(string|array)} data
|
|
73
|
-
* @param {string} string
|
|
74
|
-
* @param {string} attr
|
|
75
|
-
* @param {boolean} isArray
|
|
76
|
-
* @return {function}
|
|
77
|
-
*/
|
|
78
|
-
_getWatcherCallBack(ele, data, string, attr, isArray)
|
|
79
|
-
{
|
|
80
|
-
return () =>
|
|
81
|
-
{
|
|
82
|
-
let count = 0,
|
|
83
|
-
value = string.replace(WATCHER_PATTERN, function()
|
|
84
|
-
{
|
|
85
|
-
let watcherData = (isArray)? data[count] : data;
|
|
86
|
-
count++;
|
|
87
|
-
|
|
88
|
-
let result = watcherData.get(arguments[2]);
|
|
89
|
-
return (typeof result !== 'undefined'? result : '');
|
|
90
|
-
});
|
|
91
|
-
this.updateAttr(ele, attr, value);
|
|
92
|
-
};
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* This will get the parent data.
|
|
97
|
-
*
|
|
98
|
-
* @param {object} parent
|
|
99
|
-
* @returns {object|null}
|
|
100
|
-
*/
|
|
101
|
-
getParentData(parent)
|
|
102
|
-
{
|
|
103
|
-
if(parent.data)
|
|
104
|
-
{
|
|
105
|
-
return parent.data;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if(parent.context && parent.context.data)
|
|
109
|
-
{
|
|
110
|
-
return parent.context.data;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if(parent.state)
|
|
114
|
-
{
|
|
115
|
-
return parent.state;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return null;
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* This will get a watcher value.
|
|
123
|
-
*
|
|
124
|
-
* @private
|
|
125
|
-
* @param {(string|object)} settings
|
|
126
|
-
* @param {object} parent
|
|
127
|
-
* @return {array}
|
|
128
|
-
*/
|
|
129
|
-
getValue(settings, parent)
|
|
130
|
-
{
|
|
131
|
-
if(typeof settings === 'string')
|
|
132
|
-
{
|
|
133
|
-
settings =
|
|
134
|
-
{
|
|
135
|
-
value: settings
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
let value = settings.value;
|
|
140
|
-
if(Array.isArray(value) === false)
|
|
141
|
-
{
|
|
142
|
-
/**
|
|
143
|
-
* This will setup an array watcher based on a string.
|
|
144
|
-
*/
|
|
145
|
-
value = [value, this.getParentData(parent)];
|
|
146
|
-
}
|
|
147
|
-
else
|
|
148
|
-
{
|
|
149
|
-
/**
|
|
150
|
-
* This will check to add the default data.
|
|
151
|
-
*/
|
|
152
|
-
if(value.length < 2)
|
|
153
|
-
{
|
|
154
|
-
value.push(this.getParentData(parent));
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return value;
|
|
158
|
-
},
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* This will get the prop values.
|
|
162
|
-
*
|
|
163
|
-
* @param {object} data
|
|
164
|
-
* @param {string} string
|
|
165
|
-
* @param {bool} isArray
|
|
166
|
-
* @return {array}
|
|
167
|
-
*/
|
|
168
|
-
getPropValues(data, props, isArray)
|
|
169
|
-
{
|
|
170
|
-
let values = [];
|
|
171
|
-
|
|
172
|
-
for(var i = 0, length = props.length; i < length; i++)
|
|
173
|
-
{
|
|
174
|
-
var watcherData = (isArray)? data[i] : data;
|
|
175
|
-
var value = watcherData.get(props[i]);
|
|
176
|
-
value = (typeof value !== 'undefined'? value : '');
|
|
177
|
-
values.push(value);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
return values;
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* This will get the watcher callBack.
|
|
185
|
-
*
|
|
186
|
-
* @param {object} settings
|
|
187
|
-
* @param {object} ele
|
|
188
|
-
* @param {object} data
|
|
189
|
-
* @param {string} string
|
|
190
|
-
* @param {bool} isDataArray
|
|
191
|
-
* @return {function}
|
|
192
|
-
*/
|
|
193
|
-
getCallBack(settings, ele, data, string, isDataArray)
|
|
194
|
-
{
|
|
195
|
-
let callBack,
|
|
196
|
-
overrideCallBack = settings.callBack;
|
|
197
|
-
if(typeof overrideCallBack === 'function')
|
|
198
|
-
{
|
|
199
|
-
let props = string.match(WATCHER_PATTERN);
|
|
200
|
-
let isMultiProp = (props && props.length > 1);
|
|
201
|
-
callBack = (value, committer) =>
|
|
202
|
-
{
|
|
203
|
-
value = (isMultiProp !== true)? value : this.getPropValues(data, props, isDataArray);
|
|
204
|
-
overrideCallBack(ele, value, committer);
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
else
|
|
208
|
-
{
|
|
209
|
-
let attr = settings.attr || 'textContent';
|
|
210
|
-
callBack = this._getWatcherCallBack(ele, data, string, attr, isDataArray);
|
|
211
|
-
}
|
|
212
|
-
return callBack;
|
|
213
|
-
},
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* This will add a data watcher.
|
|
217
|
-
*
|
|
218
|
-
* @private
|
|
219
|
-
* @param {object} ele
|
|
220
|
-
* @param {(string|object)} settings
|
|
221
|
-
* @param {object} parent
|
|
222
|
-
*/
|
|
223
|
-
addDataWatcher(ele, settings, parent)
|
|
224
|
-
{
|
|
225
|
-
let value = this.getValue(settings, parent),
|
|
226
|
-
data = value[1];
|
|
227
|
-
if(!data)
|
|
228
|
-
{
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
let string = value[0],
|
|
233
|
-
isDataArray = Array.isArray(data);
|
|
234
|
-
|
|
235
|
-
let callBack = this.getCallBack(settings, ele, data, string, isDataArray),
|
|
236
|
-
props = this._getWatcherProps(string);
|
|
237
|
-
for(var i = 0, length = props.length; i < length; i++)
|
|
238
|
-
{
|
|
239
|
-
var watcherData = (isDataArray)? data[i] : data;
|
|
240
|
-
this.addWatcher(ele, watcherData, props[i], callBack);
|
|
241
|
-
}
|
|
242
|
-
},
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* This will setup a data watcher.
|
|
246
|
-
*
|
|
247
|
-
* @param {object} ele
|
|
248
|
-
* @param {(string|object)} settings
|
|
249
|
-
* @param {object} parent
|
|
250
|
-
*/
|
|
251
|
-
setup(ele, settings, parent)
|
|
252
|
-
{
|
|
253
|
-
if(!settings)
|
|
254
|
-
{
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
if(Array.isArray(settings))
|
|
259
|
-
{
|
|
260
|
-
settings = {
|
|
261
|
-
attr: settings[2],
|
|
262
|
-
value: [settings[0], settings[1]]
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
this.addDataWatcher(ele, settings, parent);
|
|
267
|
-
},
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* This will add a watcher.
|
|
271
|
-
*
|
|
272
|
-
* @private
|
|
273
|
-
* @param {object} ele
|
|
274
|
-
* @param {object} data
|
|
275
|
-
* @param {string} prop
|
|
276
|
-
* @param {function} callBack
|
|
277
|
-
*/
|
|
278
|
-
addWatcher(ele, data, prop, callBack)
|
|
279
|
-
{
|
|
280
|
-
dataBinder.watch(ele, data, prop, callBack);
|
|
281
|
-
}
|
|
282
|
-
};
|
package/modules/mouse/mouse.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import {base} from '../../core.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Mouse
|
|
5
|
-
*
|
|
6
|
-
* This will create a mouse event object.
|
|
7
|
-
* @class
|
|
8
|
-
*/
|
|
9
|
-
export class Mouse
|
|
10
|
-
{
|
|
11
|
-
/**
|
|
12
|
-
* @contrustor
|
|
13
|
-
* @param {string} [mode]
|
|
14
|
-
* @param {function} [callBackFn]
|
|
15
|
-
* @param {object} [obj]
|
|
16
|
-
* @param {boolean} [capture]
|
|
17
|
-
*/
|
|
18
|
-
constructor(mode, callBackFn, obj, capture)
|
|
19
|
-
{
|
|
20
|
-
/* this will store the mouse position */
|
|
21
|
-
this.position = { x: null, y: null };
|
|
22
|
-
this.callBackFn = callBackFn;
|
|
23
|
-
this.obj = obj || window;
|
|
24
|
-
this.capture = capture || false;
|
|
25
|
-
|
|
26
|
-
/* the mouse can be tracked by different modes
|
|
27
|
-
and this will control the tracking position mode */
|
|
28
|
-
this.mode = mode || 'page';
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* This will update the mode.
|
|
33
|
-
*
|
|
34
|
-
* @param {string} mode
|
|
35
|
-
*/
|
|
36
|
-
updateMode(mode)
|
|
37
|
-
{
|
|
38
|
-
let selectedMode = 'page';
|
|
39
|
-
|
|
40
|
-
switch(mode)
|
|
41
|
-
{
|
|
42
|
-
case 'client':
|
|
43
|
-
case 'screen':
|
|
44
|
-
selectedMode = mode;
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
this.mode = selectedMode;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* This will update the position.
|
|
53
|
-
*
|
|
54
|
-
* @param {object} e
|
|
55
|
-
* @return {object}
|
|
56
|
-
*/
|
|
57
|
-
updatePosition(e)
|
|
58
|
-
{
|
|
59
|
-
let x, y;
|
|
60
|
-
|
|
61
|
-
if(e)
|
|
62
|
-
{
|
|
63
|
-
/* we need to check if the mode is set to
|
|
64
|
-
client or return page position */
|
|
65
|
-
switch(this.mode)
|
|
66
|
-
{
|
|
67
|
-
case 'client':
|
|
68
|
-
case 'screen':
|
|
69
|
-
x = e.clientX || e.pageX;
|
|
70
|
-
y = e.clientY || e.pageY;
|
|
71
|
-
break;
|
|
72
|
-
default:
|
|
73
|
-
x = e.pageX;
|
|
74
|
-
y = e.pageY;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return {
|
|
79
|
-
y,
|
|
80
|
-
x
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* This will start tracking.
|
|
86
|
-
*/
|
|
87
|
-
start()
|
|
88
|
-
{
|
|
89
|
-
let callBackFn = this.callBackFn;
|
|
90
|
-
/* we want to update mouse position and
|
|
91
|
-
standardize the return */
|
|
92
|
-
const mouseResults = (e) =>
|
|
93
|
-
{
|
|
94
|
-
let position = this.position = this.updatePosition(e);
|
|
95
|
-
|
|
96
|
-
/* we can now send the mouse wheel results to
|
|
97
|
-
the call back function */
|
|
98
|
-
if(typeof callBackFn === 'function')
|
|
99
|
-
{
|
|
100
|
-
callBackFn.call(position, e);
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
base.events.add('mousemove', this.obj, mouseResults, this.capture, true, callBackFn);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* This will stop tracking.
|
|
109
|
-
*/
|
|
110
|
-
stop()
|
|
111
|
-
{
|
|
112
|
-
base.off('mousemove', this.obj, this.callBackFn, this.capture);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { builder } from "../layout/layout-builder.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ComponentHelper
|
|
5
|
-
*
|
|
6
|
-
* This will create a helper to create and destroy components
|
|
7
|
-
* that are added to a route.
|
|
8
|
-
* @class
|
|
9
|
-
*/
|
|
10
|
-
export class ComponentHelper
|
|
11
|
-
{
|
|
12
|
-
/**
|
|
13
|
-
* @constructor
|
|
14
|
-
* @param {object} route
|
|
15
|
-
* @param {object} settings
|
|
16
|
-
*/
|
|
17
|
-
constructor(route, settings)
|
|
18
|
-
{
|
|
19
|
-
this.route = route;
|
|
20
|
-
|
|
21
|
-
this.template = settings.component;
|
|
22
|
-
this.component = null;
|
|
23
|
-
this.hasTemplate = false;
|
|
24
|
-
|
|
25
|
-
this.setup = false;
|
|
26
|
-
this.container = settings.container;
|
|
27
|
-
this.persist = settings.persist;
|
|
28
|
-
this.parent = settings.parent;
|
|
29
|
-
|
|
30
|
-
this.setupTemplate();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* This will create the component.
|
|
35
|
-
*
|
|
36
|
-
* @param {object} params
|
|
37
|
-
*/
|
|
38
|
-
focus(params)
|
|
39
|
-
{
|
|
40
|
-
if(this.setup === false)
|
|
41
|
-
{
|
|
42
|
-
this.create();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
this.update(params);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* This will setup the template.
|
|
50
|
-
* @protected
|
|
51
|
-
*/
|
|
52
|
-
setupTemplate()
|
|
53
|
-
{
|
|
54
|
-
let template = this.template;
|
|
55
|
-
if(typeof template === 'string')
|
|
56
|
-
{
|
|
57
|
-
template = this.template = window[template];
|
|
58
|
-
if(!template)
|
|
59
|
-
{
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
let type = typeof template;
|
|
65
|
-
if(type === 'function')
|
|
66
|
-
{
|
|
67
|
-
this.component = new this.template({
|
|
68
|
-
route: this.route,
|
|
69
|
-
persist: this.persist,
|
|
70
|
-
parent: this.parent
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
else if(type === 'object')
|
|
74
|
-
{
|
|
75
|
-
if(!this.template.isUnit)
|
|
76
|
-
{
|
|
77
|
-
this.template = Jot(this.template);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
let comp = this.component = this.template;
|
|
81
|
-
let persist = (comp.persist !== false);
|
|
82
|
-
|
|
83
|
-
comp.route = this.route;
|
|
84
|
-
comp.persist = persist;
|
|
85
|
-
comp.parent = this.parent;
|
|
86
|
-
this.persist = persist;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
this.hasTemplate = true;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* This will create the route component.
|
|
94
|
-
* @protected
|
|
95
|
-
*/
|
|
96
|
-
create()
|
|
97
|
-
{
|
|
98
|
-
if(!this.hasTemplate)
|
|
99
|
-
{
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
this.setup = true;
|
|
104
|
-
|
|
105
|
-
let comp = this.component;
|
|
106
|
-
if(!this.persist || !comp)
|
|
107
|
-
{
|
|
108
|
-
comp = this.component = this.template;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
builder.render(comp, this.container, this.parent);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* This will remove the component.
|
|
116
|
-
*/
|
|
117
|
-
remove()
|
|
118
|
-
{
|
|
119
|
-
if(this.setup !== true)
|
|
120
|
-
{
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
this.setup = false;
|
|
125
|
-
|
|
126
|
-
let component = this.component;
|
|
127
|
-
if(!component)
|
|
128
|
-
{
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if(typeof component.destroy === 'function')
|
|
133
|
-
{
|
|
134
|
-
component.destroy();
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// this will remove the reference to the component if persit is false
|
|
138
|
-
if(this.persist === false)
|
|
139
|
-
{
|
|
140
|
-
this.component = null;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* This will call the component update method and pass the params.
|
|
146
|
-
*
|
|
147
|
-
* @protected
|
|
148
|
-
* @param {object} params
|
|
149
|
-
*/
|
|
150
|
-
update(params)
|
|
151
|
-
{
|
|
152
|
-
let component = this.component;
|
|
153
|
-
if(!component)
|
|
154
|
-
{
|
|
155
|
-
return false;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if(typeof component.update === 'function')
|
|
159
|
-
{
|
|
160
|
-
component.update(params);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|