@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,219 +0,0 @@
|
|
|
1
|
-
import {base} from '../../core.js';
|
|
2
|
-
import {TwoWaySource} from './two-way-source.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* This will set an element attr by the setAttribute method.
|
|
6
|
-
*
|
|
7
|
-
* @param {object} element
|
|
8
|
-
* @param {string} attr
|
|
9
|
-
* @param {mixed} value
|
|
10
|
-
*/
|
|
11
|
-
const SetAttr = (element, attr, value) =>
|
|
12
|
-
{
|
|
13
|
-
base.setAttr(element, attr, value);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const UpdateRadioAttr = (element, attr, value) =>
|
|
17
|
-
{
|
|
18
|
-
element.checked = (element.value === value);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const UpdateCheckboxAttr = (element, attr, value) =>
|
|
22
|
-
{
|
|
23
|
-
value = (value == 1);
|
|
24
|
-
UpdateAttr(element, attr, value);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* This will update an element attr by the bracket notation.
|
|
29
|
-
*
|
|
30
|
-
* @param {object} element
|
|
31
|
-
* @param {string} attr
|
|
32
|
-
* @param {nixed} value
|
|
33
|
-
*/
|
|
34
|
-
const UpdateAttr = (element, attr, value) =>
|
|
35
|
-
{
|
|
36
|
-
element[attr] = value;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const GetAttr = (element, attr) =>
|
|
40
|
-
{
|
|
41
|
-
return base.getAttr(element, attr);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const GetAttribute = (element, attr) =>
|
|
45
|
-
{
|
|
46
|
-
return element[attr];
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* ElementSource
|
|
51
|
-
*
|
|
52
|
-
* This will create an element source to use with
|
|
53
|
-
* a connection.
|
|
54
|
-
* @class
|
|
55
|
-
* @augments TwoWaySource
|
|
56
|
-
*/
|
|
57
|
-
export class ElementSource extends TwoWaySource
|
|
58
|
-
{
|
|
59
|
-
/**
|
|
60
|
-
* @constructor
|
|
61
|
-
* @param {object} element
|
|
62
|
-
* @param {string} attr
|
|
63
|
-
* @param {(string|function)} [filter]
|
|
64
|
-
*/
|
|
65
|
-
constructor(element, attr, filter)
|
|
66
|
-
{
|
|
67
|
-
super();
|
|
68
|
-
this.element = element;
|
|
69
|
-
this.attr = this.getAttrBind(attr);
|
|
70
|
-
this.addSetMethod(element, this.attr);
|
|
71
|
-
|
|
72
|
-
this.filter = (typeof filter === 'string')? this.setupFilter(filter) : filter;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
addSetMethod(element, attr)
|
|
76
|
-
{
|
|
77
|
-
if(attr.substring(4, 1) === '-')
|
|
78
|
-
{
|
|
79
|
-
this.setValue = SetAttr;
|
|
80
|
-
this.getValue = GetAttr;
|
|
81
|
-
}
|
|
82
|
-
else
|
|
83
|
-
{
|
|
84
|
-
this.getValue = GetAttribute;
|
|
85
|
-
|
|
86
|
-
var type = element.type;
|
|
87
|
-
if(type)
|
|
88
|
-
{
|
|
89
|
-
switch(type)
|
|
90
|
-
{
|
|
91
|
-
case 'checkbox':
|
|
92
|
-
this.setValue = UpdateCheckboxAttr;
|
|
93
|
-
return;
|
|
94
|
-
case 'radio':
|
|
95
|
-
this.setValue = UpdateRadioAttr;
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
this.setValue = UpdateAttr;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* This will get the bind attribute.
|
|
106
|
-
*
|
|
107
|
-
* @param {string} [customAttr]
|
|
108
|
-
* @return {string}
|
|
109
|
-
*/
|
|
110
|
-
getAttrBind(customAttr)
|
|
111
|
-
{
|
|
112
|
-
/* this will setup the custom attr if the prop
|
|
113
|
-
has specified one. */
|
|
114
|
-
if(customAttr)
|
|
115
|
-
{
|
|
116
|
-
return customAttr;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
let attr = 'textContent';
|
|
120
|
-
/* if no custom attr has been requested we will get the
|
|
121
|
-
default attr of the element */
|
|
122
|
-
let element = this.element;
|
|
123
|
-
if(!(element && typeof element === 'object'))
|
|
124
|
-
{
|
|
125
|
-
return attr;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
let tagName = element.tagName.toLowerCase();
|
|
129
|
-
if (tagName === "input" || tagName === "textarea" || tagName === "select")
|
|
130
|
-
{
|
|
131
|
-
let type = element.type;
|
|
132
|
-
if(type)
|
|
133
|
-
{
|
|
134
|
-
switch(type)
|
|
135
|
-
{
|
|
136
|
-
case 'checkbox':
|
|
137
|
-
attr = 'checked';
|
|
138
|
-
break;
|
|
139
|
-
case 'file':
|
|
140
|
-
attr = 'files';
|
|
141
|
-
break;
|
|
142
|
-
default:
|
|
143
|
-
attr = 'value';
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
else
|
|
147
|
-
{
|
|
148
|
-
attr = 'value';
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return attr;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* This will setup a filter callBack.
|
|
156
|
-
*
|
|
157
|
-
* @param {string} filter
|
|
158
|
-
* @return {function}
|
|
159
|
-
*/
|
|
160
|
-
setupFilter(filter)
|
|
161
|
-
{
|
|
162
|
-
let pattern = /(\[\[[^\]]+\]\])/;
|
|
163
|
-
return (value) =>
|
|
164
|
-
{
|
|
165
|
-
return filter.replace(pattern, value);
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* This will set a value on an element.
|
|
171
|
-
*
|
|
172
|
-
* @param {*} value
|
|
173
|
-
*/
|
|
174
|
-
set(value)
|
|
175
|
-
{
|
|
176
|
-
let element = this.element;
|
|
177
|
-
if(!element || typeof element !== 'object')
|
|
178
|
-
{
|
|
179
|
-
return false;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/* this will check to apply the option filter before
|
|
183
|
-
setting the value */
|
|
184
|
-
if(this.filter)
|
|
185
|
-
{
|
|
186
|
-
value = this.filter(value);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
this.setValue(element, this.attr, value);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* This will get the value from an element.
|
|
194
|
-
*/
|
|
195
|
-
get()
|
|
196
|
-
{
|
|
197
|
-
let element = this.element;
|
|
198
|
-
if(!element || typeof element !== 'object')
|
|
199
|
-
{
|
|
200
|
-
return '';
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
return this.getValue(element, this.attr);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* The callBack when updated.
|
|
208
|
-
*
|
|
209
|
-
* @param {*} value
|
|
210
|
-
* @param {object} committer
|
|
211
|
-
*/
|
|
212
|
-
callBack(value, committer)
|
|
213
|
-
{
|
|
214
|
-
if(committer !== this.element)
|
|
215
|
-
{
|
|
216
|
-
this.set(value);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import {OneWaySource} from './one-way-source.js';
|
|
2
|
-
import {Connection} from './connection.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* OneWayConnection
|
|
6
|
-
*
|
|
7
|
-
* This will create a one way connection.
|
|
8
|
-
* @class
|
|
9
|
-
* @augments Connection
|
|
10
|
-
*/
|
|
11
|
-
export class OneWayConnection extends Connection
|
|
12
|
-
{
|
|
13
|
-
/**
|
|
14
|
-
* @constructor
|
|
15
|
-
*/
|
|
16
|
-
constructor()
|
|
17
|
-
{
|
|
18
|
-
super();
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @member {object} source
|
|
22
|
-
*/
|
|
23
|
-
this.source = null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* This will setup the connection source.
|
|
28
|
-
*
|
|
29
|
-
* @param {object} data
|
|
30
|
-
* @return {object}
|
|
31
|
-
*/
|
|
32
|
-
addSource(data)
|
|
33
|
-
{
|
|
34
|
-
return (this.source = new OneWaySource(data));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* This will be used to unsubscribe.
|
|
39
|
-
* @override
|
|
40
|
-
*/
|
|
41
|
-
unsubscribe()
|
|
42
|
-
{
|
|
43
|
-
this.source.unsubscribe();
|
|
44
|
-
this.source = null;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {Source} from './source.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* OneWaySource
|
|
5
|
-
*
|
|
6
|
-
* This will create a one way source to use with
|
|
7
|
-
* a connection.
|
|
8
|
-
* @class
|
|
9
|
-
* @augments Source
|
|
10
|
-
*/
|
|
11
|
-
export class OneWaySource extends Source
|
|
12
|
-
{
|
|
13
|
-
/**
|
|
14
|
-
* This will setup the data source.
|
|
15
|
-
*
|
|
16
|
-
* @param {object} data
|
|
17
|
-
*/
|
|
18
|
-
constructor(data)
|
|
19
|
-
{
|
|
20
|
-
super();
|
|
21
|
-
this.data = data;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* This will subscribe to a message.
|
|
26
|
-
*
|
|
27
|
-
* @param {string} msg
|
|
28
|
-
* @param {function} callBack
|
|
29
|
-
*/
|
|
30
|
-
subscribe(msg, callBack)
|
|
31
|
-
{
|
|
32
|
-
this.msg = msg;
|
|
33
|
-
this.token = this.data.on(msg, callBack);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* This will unsubscribe from the message.
|
|
38
|
-
*/
|
|
39
|
-
unsubscribe()
|
|
40
|
-
{
|
|
41
|
-
this.data.off(this.msg, this.token);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Source
|
|
3
|
-
*
|
|
4
|
-
* This will create a new source to use with
|
|
5
|
-
* a connection.
|
|
6
|
-
* @class
|
|
7
|
-
*/
|
|
8
|
-
export class Source
|
|
9
|
-
{
|
|
10
|
-
/**
|
|
11
|
-
* @constructor
|
|
12
|
-
*/
|
|
13
|
-
constructor()
|
|
14
|
-
{
|
|
15
|
-
/**
|
|
16
|
-
* @member {string} msg
|
|
17
|
-
* @protected
|
|
18
|
-
*/
|
|
19
|
-
this.msg = null;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @member {string} token
|
|
23
|
-
*/
|
|
24
|
-
this.token = null;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* This will set the token.
|
|
29
|
-
*
|
|
30
|
-
* @param {string} token
|
|
31
|
-
*/
|
|
32
|
-
setToken(token)
|
|
33
|
-
{
|
|
34
|
-
this.token = token;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import {DataSource} from './data-source.js';
|
|
2
|
-
import {ElementSource} from './element-source.js';
|
|
3
|
-
import {Connection} from './connection.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* TwoWayConnection
|
|
7
|
-
*
|
|
8
|
-
* This will setup a two way connection.
|
|
9
|
-
* @class
|
|
10
|
-
* @augments Connection
|
|
11
|
-
*/
|
|
12
|
-
export class TwoWayConnection extends Connection
|
|
13
|
-
{
|
|
14
|
-
/**
|
|
15
|
-
* @constructor
|
|
16
|
-
*/
|
|
17
|
-
constructor()
|
|
18
|
-
{
|
|
19
|
-
super();
|
|
20
|
-
|
|
21
|
-
this.element = null;
|
|
22
|
-
this.data = null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* This will add the element source.
|
|
27
|
-
*
|
|
28
|
-
* @param {object} element
|
|
29
|
-
* @param {string} attr
|
|
30
|
-
* @param {(string|function)} filter
|
|
31
|
-
* @return {object}
|
|
32
|
-
*/
|
|
33
|
-
addElement(element, attr, filter)
|
|
34
|
-
{
|
|
35
|
-
return (this.element = new ElementSource(element, attr, filter));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* This will add the data source.
|
|
40
|
-
*
|
|
41
|
-
* @param {object} data
|
|
42
|
-
* @param {string} prop
|
|
43
|
-
* @return {object}
|
|
44
|
-
*/
|
|
45
|
-
addData(data, prop)
|
|
46
|
-
{
|
|
47
|
-
return (this.data = new DataSource(data, prop));
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* This will unsubscribe from a source.
|
|
52
|
-
*
|
|
53
|
-
* @param {object} source
|
|
54
|
-
*/
|
|
55
|
-
unsubscribeSource(source)
|
|
56
|
-
{
|
|
57
|
-
if(source)
|
|
58
|
-
{
|
|
59
|
-
source.unsubscribe();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* This will be used to unsubscribe.
|
|
65
|
-
* @override
|
|
66
|
-
*/
|
|
67
|
-
unsubscribe()
|
|
68
|
-
{
|
|
69
|
-
this.unsubscribeSource(this.element);
|
|
70
|
-
this.unsubscribeSource(this.data);
|
|
71
|
-
|
|
72
|
-
this.element = null;
|
|
73
|
-
this.data = null;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import {Source} from './source.js';
|
|
2
|
-
import {pubSub} from './data-pub-sub.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* TwoWaySource
|
|
6
|
-
*
|
|
7
|
-
* This will create a two way source to use with
|
|
8
|
-
* a connection.
|
|
9
|
-
* @class
|
|
10
|
-
* @augments Source
|
|
11
|
-
*/
|
|
12
|
-
export class TwoWaySource extends Source
|
|
13
|
-
{
|
|
14
|
-
/**
|
|
15
|
-
* This will subscribe to a message.
|
|
16
|
-
*
|
|
17
|
-
* @param {string} msg
|
|
18
|
-
*/
|
|
19
|
-
subscribe(msg)
|
|
20
|
-
{
|
|
21
|
-
this.msg = msg;
|
|
22
|
-
let callBack = this.callBack.bind(this);
|
|
23
|
-
this.token = pubSub.on(msg, callBack);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* This will unsubscribe from a message.
|
|
28
|
-
*/
|
|
29
|
-
unsubscribe()
|
|
30
|
-
{
|
|
31
|
-
pubSub.off(this.msg, this.token);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Override this to setup cource callBack.
|
|
36
|
-
*/
|
|
37
|
-
callBack()
|
|
38
|
-
{
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
}
|