-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathABComponentCore.js
More file actions
94 lines (77 loc) · 2.19 KB
/
ABComponentCore.js
File metadata and controls
94 lines (77 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// // Import our Custom Components here:
// import CustomComponentManager from '../webix_custom_components/customComponentManager'
var EventEmitter = require("events").EventEmitter;
// just keep a running counter for ABComponents
var _countUID = 0;
function uid() {
return _countUID++;
}
module.exports = class ABComponentCore extends EventEmitter {
/**
* @param {object} App
* ?what is this?
* @param {string} idBase
* Identifier for this component
*/
constructor(App, idBase, AB) {
super();
if (AB) this.AB = AB;
var L = this.Label();
if (!App) {
App = {
uuid: uid(),
/*
* actions:
* a hash of exposed application methods that are shared among our
* components, so one component can invoke an action that updates
* another component.
*/
actions: {},
/*
* config
* webix configuration settings for our current browser
*/
config: {},
/*
* custom
* a collection of custom components for this App Instance.
*/
custom: {},
Label: L,
/*
* labels
* a collection of labels that are common for the Application.
*/
labels: {},
/*
* unique()
* A function that returns a globally unique Key.
* @param {string} key The key to modify and return.
* @return {string}
*/
unique: function (key) {
return key + this.uuid;
},
};
}
// var componentManager = new CustomComponentManager();
// componentManager.initComponents(App);
this.App = App;
this.idBase = idBase || "?idbase?";
}
actions(_actions) {
if (_actions) {
for (var a in _actions) {
this.App.actions[a] = _actions[a];
}
}
}
Label() {
return (key, altText, values) => {
return altText;
};
}
unique(key) {
return this.App.unique(this.idBase + "_" + key);
}
};