@web-atoms/core 2.2.194 → 2.3.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/dist/core/AtomComponent.d.ts +19 -28
- package/dist/core/AtomComponent.d.ts.map +1 -1
- package/dist/core/AtomComponent.js +9 -19
- package/dist/core/AtomComponent.js.map +1 -1
- package/dist/core/Hacks.d.ts +7 -0
- package/dist/core/Hacks.d.ts.map +1 -0
- package/dist/core/Hacks.js +66 -0
- package/dist/core/Hacks.js.map +1 -0
- package/dist/core/InjectProperty.d.ts +1 -1
- package/dist/core/InjectProperty.d.ts.map +1 -1
- package/dist/core/InjectProperty.js.map +1 -1
- package/dist/core/WatchProperty.d.ts +1 -1
- package/dist/core/WatchProperty.d.ts.map +1 -1
- package/dist/core/WatchProperty.js.map +1 -1
- package/dist/services/http/RestService.d.ts.map +1 -1
- package/dist/services/http/RestService.js +2 -13
- package/dist/services/http/RestService.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/web/controls/AtomControl.d.ts +1 -1
- package/dist/web/controls/AtomControl.d.ts.map +1 -1
- package/dist/web/controls/AtomControl.js +7 -8
- package/dist/web/controls/AtomControl.js.map +1 -1
- package/dist/web/controls/AtomGridView.js +5 -5
- package/dist/web/controls/AtomGridView.js.map +1 -1
- package/package.json +1 -1
- package/src/core/AtomComponent.ts +33 -61
- package/src/core/Hacks.ts +62 -0
- package/src/core/InjectProperty.ts +1 -1
- package/src/core/WatchProperty.ts +1 -1
- package/src/services/http/RestService.ts +9 -10
- package/src/web/controls/AtomControl.ts +4 -8
- package/src/web/controls/AtomGridView.ts +2 -2
- package/dist/core/AtomBridge.d.ts +0 -60
- package/dist/core/AtomBridge.d.ts.map +0 -1
- package/dist/core/AtomBridge.js +0 -308
- package/dist/core/AtomBridge.js.map +0 -1
- package/dist/xf/XFApp.d.ts +0 -11
- package/dist/xf/XFApp.d.ts.map +0 -1
- package/dist/xf/XFApp.js +0 -65
- package/dist/xf/XFApp.js.map +0 -1
- package/dist/xf/controls/AtomXFControl.d.ts +0 -27
- package/dist/xf/controls/AtomXFControl.d.ts.map +0 -1
- package/dist/xf/controls/AtomXFControl.js +0 -246
- package/dist/xf/controls/AtomXFControl.js.map +0 -1
- package/dist/xf/services/XFBusyIndicatorService.d.ts +0 -6
- package/dist/xf/services/XFBusyIndicatorService.d.ts.map +0 -1
- package/dist/xf/services/XFBusyIndicatorService.js +0 -31
- package/dist/xf/services/XFBusyIndicatorService.js.map +0 -1
- package/dist/xf/services/XFNavigationService.d.ts +0 -21
- package/dist/xf/services/XFNavigationService.d.ts.map +0 -1
- package/dist/xf/services/XFNavigationService.js +0 -139
- package/dist/xf/services/XFNavigationService.js.map +0 -1
- package/src/core/AtomBridge.ts +0 -430
- package/src/xf/XFApp.ts +0 -58
- package/src/xf/controls/AtomXFControl.ts +0 -297
- package/src/xf/services/XFBusyIndicatorService.ts +0 -18
- package/src/xf/services/XFNavigationService.ts +0 -162
package/src/core/AtomBridge.ts
DELETED
|
@@ -1,430 +0,0 @@
|
|
|
1
|
-
import { AjaxOptions } from "../services/http/AjaxOptions";
|
|
2
|
-
import { AtomUI, ChildEnumerator } from "../web/core/AtomUI";
|
|
3
|
-
import { AtomBinder } from "./AtomBinder";
|
|
4
|
-
import { IAtomElement, IDisposable, INameValuePairs, INativeComponent, IUIAtomControl } from "./types";
|
|
5
|
-
import XNode from "./XNode";
|
|
6
|
-
|
|
7
|
-
export abstract class BaseElementBridge<T extends IAtomElement> {
|
|
8
|
-
|
|
9
|
-
public controlFactory: any;
|
|
10
|
-
|
|
11
|
-
public createBusyIndicator: () => IDisposable;
|
|
12
|
-
|
|
13
|
-
public ajax: (
|
|
14
|
-
url: string,
|
|
15
|
-
options: AjaxOptions,
|
|
16
|
-
success: (r) => void,
|
|
17
|
-
failed: (r) => void,
|
|
18
|
-
progress: (p) => void) => void;
|
|
19
|
-
|
|
20
|
-
public reset: () => void;
|
|
21
|
-
|
|
22
|
-
public abstract create(
|
|
23
|
-
type: string
|
|
24
|
-
| ((n: any, ... nodes: XNode[]) => XNode)
|
|
25
|
-
| (new (... a: any[]) => any),
|
|
26
|
-
node?: any,
|
|
27
|
-
app?: any): T;
|
|
28
|
-
|
|
29
|
-
public abstract attachControl(element: T, control: IUIAtomControl): void;
|
|
30
|
-
|
|
31
|
-
public abstract addEventHandler(
|
|
32
|
-
element: T,
|
|
33
|
-
name: string,
|
|
34
|
-
handler: EventListenerOrEventListenerObject,
|
|
35
|
-
capture?: boolean): IDisposable;
|
|
36
|
-
|
|
37
|
-
public abstract atomParent(element: T, climbUp?: boolean): IUIAtomControl;
|
|
38
|
-
|
|
39
|
-
public abstract elementParent(element: T): T;
|
|
40
|
-
|
|
41
|
-
public abstract templateParent(element: T): IUIAtomControl;
|
|
42
|
-
|
|
43
|
-
public abstract visitDescendents(element: T, action: (e: T, ac: IUIAtomControl) => boolean): void;
|
|
44
|
-
|
|
45
|
-
public abstract dispose(element: T): void;
|
|
46
|
-
|
|
47
|
-
public abstract appendChild(parent: T, child: T): void;
|
|
48
|
-
|
|
49
|
-
public abstract getValue(element: HTMLElement, name: string): any;
|
|
50
|
-
|
|
51
|
-
public abstract setValue(element: T, name: string, value: any): void;
|
|
52
|
-
|
|
53
|
-
public abstract watchProperty(element: T, name: string, events: string[], f: (v: any) => void): IDisposable;
|
|
54
|
-
|
|
55
|
-
public abstract loadContent(element: T, text: string): void;
|
|
56
|
-
|
|
57
|
-
public abstract findChild(element: T, name: string): T;
|
|
58
|
-
|
|
59
|
-
public abstract close(element: T, success: () => void, error: (e) => void): void;
|
|
60
|
-
|
|
61
|
-
public refreshInherited(target: { element: T }, name: string, fieldName?: string): void {
|
|
62
|
-
AtomBinder.refreshValue(target, name);
|
|
63
|
-
if (!fieldName) {
|
|
64
|
-
fieldName = "m" + name[0].toUpperCase() + name.substr(1);
|
|
65
|
-
}
|
|
66
|
-
if (!target.element) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
this.visitDescendents(target.element, (e, ac) => {
|
|
70
|
-
if (ac) {
|
|
71
|
-
if (ac[fieldName] === undefined) {
|
|
72
|
-
this.refreshInherited(ac as any, name, fieldName);
|
|
73
|
-
}
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
return true;
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
public createNode(
|
|
82
|
-
target: any,
|
|
83
|
-
node: XNode,
|
|
84
|
-
// tslint:disable-next-line: ban-types
|
|
85
|
-
binder: Function,
|
|
86
|
-
// tslint:disable-next-line: ban-types
|
|
87
|
-
xNodeClass: Function,
|
|
88
|
-
// tslint:disable-next-line: ban-types
|
|
89
|
-
creator: Function): any {
|
|
90
|
-
throw new Error("Method not implemented.");
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export class AtomElementBridge extends BaseElementBridge<HTMLElement> {
|
|
96
|
-
|
|
97
|
-
public addEventHandler(
|
|
98
|
-
element: HTMLElement,
|
|
99
|
-
name: string,
|
|
100
|
-
handler: EventListenerOrEventListenerObject,
|
|
101
|
-
capture?: boolean): IDisposable {
|
|
102
|
-
element.addEventListener(name, handler, capture);
|
|
103
|
-
return {
|
|
104
|
-
dispose: () => {
|
|
105
|
-
element.removeEventListener(name, handler, capture);
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
public atomParent(element: HTMLElement, climbUp: boolean = true): IUIAtomControl {
|
|
111
|
-
const eAny: INameValuePairs = element as INameValuePairs;
|
|
112
|
-
if (eAny.atomControl) {
|
|
113
|
-
return eAny.atomControl;
|
|
114
|
-
}
|
|
115
|
-
if (!climbUp) {
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
if (!element.parentNode) {
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
return this.atomParent(this.elementParent(element));
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
public elementParent(element: HTMLElement): HTMLElement {
|
|
125
|
-
const eAny = element as any;
|
|
126
|
-
const lp = eAny._logicalParent;
|
|
127
|
-
if (lp) {
|
|
128
|
-
return lp;
|
|
129
|
-
}
|
|
130
|
-
return element.parentElement;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
public templateParent(element: HTMLElement): IUIAtomControl {
|
|
134
|
-
if (!element) {
|
|
135
|
-
return null;
|
|
136
|
-
}
|
|
137
|
-
const eAny = element as any;
|
|
138
|
-
if (eAny._templateParent) {
|
|
139
|
-
return this.atomParent(element);
|
|
140
|
-
}
|
|
141
|
-
const parent = this.elementParent(element);
|
|
142
|
-
if (!parent) {
|
|
143
|
-
return null;
|
|
144
|
-
}
|
|
145
|
-
return this.templateParent(parent);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
public visitDescendents(element: HTMLElement, action: (e: HTMLElement, ac: IUIAtomControl) => boolean): void {
|
|
149
|
-
|
|
150
|
-
for (const iterator of ChildEnumerator.enumerate(element)) {
|
|
151
|
-
const eAny = iterator as any;
|
|
152
|
-
const ac = eAny ? eAny.atomControl : undefined;
|
|
153
|
-
if (!action(iterator, ac)) {
|
|
154
|
-
continue;
|
|
155
|
-
}
|
|
156
|
-
this.visitDescendents(iterator, action);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
public dispose(element: HTMLElement): void {
|
|
161
|
-
const eAny = element as any;
|
|
162
|
-
eAny.atomControl = undefined;
|
|
163
|
-
eAny.innerHTML = "";
|
|
164
|
-
delete eAny.atomControl;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
public appendChild(parent: HTMLElement, child: HTMLElement): void {
|
|
168
|
-
parent.appendChild(child);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
public setValue(element: HTMLElement, name: string, value: any): void {
|
|
172
|
-
element[name] = value;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
public getValue(element: HTMLElement, name: string): any {
|
|
176
|
-
return element[name];
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
public watchProperty(element: HTMLElement, name: string, events: string[], f: (v: any) => void): IDisposable {
|
|
180
|
-
|
|
181
|
-
if (events.indexOf("change") === -1) {
|
|
182
|
-
events.push("change");
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const l = (e) => {
|
|
186
|
-
const e1 = element as HTMLInputElement;
|
|
187
|
-
const v = e1.type === "checkbox" ? e1.checked : e1.value;
|
|
188
|
-
f(v);
|
|
189
|
-
};
|
|
190
|
-
for (const iterator of events) {
|
|
191
|
-
element.addEventListener(iterator, l , false);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return {
|
|
195
|
-
dispose: () => {
|
|
196
|
-
for (const iterator of events) {
|
|
197
|
-
element.removeEventListener(iterator, l, false);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
public attachControl(element: HTMLElement, control: IUIAtomControl): void {
|
|
204
|
-
(element as any).atomControl = control;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
public create(type: string): HTMLElement {
|
|
208
|
-
return document.createElement(type);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
public loadContent(element: HTMLElement, text: string): void {
|
|
212
|
-
throw new Error("Not supported");
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
public findChild(element: HTMLElement, name: string): HTMLElement {
|
|
216
|
-
throw new Error("Not supported");
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
public close(element: HTMLElement, success: () => void, error: (e) => void): void {
|
|
220
|
-
throw new Error("Not supported");
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
public toTemplate(element, creator) {
|
|
224
|
-
const templateNode = element as any;
|
|
225
|
-
const name = templateNode.name;
|
|
226
|
-
if (typeof name === "string") {
|
|
227
|
-
element = ((bx, n) => class extends bx {
|
|
228
|
-
|
|
229
|
-
public create(): void {
|
|
230
|
-
this.render(n);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
})(creator as any, templateNode.children[0]);
|
|
234
|
-
|
|
235
|
-
} else {
|
|
236
|
-
element = ((base, n) => class extends base {
|
|
237
|
-
|
|
238
|
-
public create(): void {
|
|
239
|
-
this.render(n);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
})(name, templateNode.children[0]);
|
|
243
|
-
}
|
|
244
|
-
return element;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
public createNode(
|
|
248
|
-
target: any,
|
|
249
|
-
node: XNode,
|
|
250
|
-
// tslint:disable-next-line: ban-types
|
|
251
|
-
binder: Function,
|
|
252
|
-
// tslint:disable-next-line: ban-types
|
|
253
|
-
xNodeClass: Function,
|
|
254
|
-
// tslint:disable-next-line: ban-types
|
|
255
|
-
creator: Function): any {
|
|
256
|
-
|
|
257
|
-
let parent = null;
|
|
258
|
-
|
|
259
|
-
const app = target.app;
|
|
260
|
-
let e: HTMLElement = null;
|
|
261
|
-
const nn = node.attributes ? node.attributes.for : undefined;
|
|
262
|
-
if (typeof node.name === "string") {
|
|
263
|
-
// it is simple node..
|
|
264
|
-
e = document.createElement(node.name);
|
|
265
|
-
parent = e;
|
|
266
|
-
if (nn) {
|
|
267
|
-
delete node.attributes.for;
|
|
268
|
-
}
|
|
269
|
-
} else {
|
|
270
|
-
if (nn) {
|
|
271
|
-
target = new (node.name as any)(app, document.createElement(nn));
|
|
272
|
-
delete node.attributes.for;
|
|
273
|
-
}
|
|
274
|
-
target = new (node.name as any)(app);
|
|
275
|
-
e = target.element;
|
|
276
|
-
parent = target;
|
|
277
|
-
// target.append(child);
|
|
278
|
-
// const firstChild = node.children ? node.children[0] : null;
|
|
279
|
-
// if (firstChild) {
|
|
280
|
-
// const n = this.createNode(child, firstChild, binder, xNodeClass, creator);
|
|
281
|
-
// child.append(n.atomControl || n);
|
|
282
|
-
// }
|
|
283
|
-
// return child.element;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
const a = node.attributes;
|
|
287
|
-
if (a) {
|
|
288
|
-
for (const key in a) {
|
|
289
|
-
if (a.hasOwnProperty(key)) {
|
|
290
|
-
let element = a[key] as any;
|
|
291
|
-
if (element instanceof binder) {
|
|
292
|
-
if (/^event/.test(key)) {
|
|
293
|
-
let ev = key.substr(5);
|
|
294
|
-
if (ev.startsWith("-")) {
|
|
295
|
-
ev = ev.split("-").map((s) => s[0].toLowerCase() + s.substr(1)).join("");
|
|
296
|
-
} else {
|
|
297
|
-
ev = ev[0].toLowerCase() + ev.substr(1);
|
|
298
|
-
}
|
|
299
|
-
(element as any).setupFunction(ev, element, target, e);
|
|
300
|
-
} else {
|
|
301
|
-
(element as any).setupFunction(key, element, target, e);
|
|
302
|
-
}
|
|
303
|
-
} else {
|
|
304
|
-
|
|
305
|
-
// this is template...
|
|
306
|
-
if (element instanceof xNodeClass) {
|
|
307
|
-
element = this.toTemplate(element, creator);
|
|
308
|
-
}
|
|
309
|
-
target.setLocalValue(e, key, element);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
const children = node.children;
|
|
316
|
-
if (children) {
|
|
317
|
-
for (const iterator of children) {
|
|
318
|
-
if (typeof iterator === "string") {
|
|
319
|
-
e.appendChild(document.createTextNode(iterator));
|
|
320
|
-
continue;
|
|
321
|
-
}
|
|
322
|
-
const t = iterator.attributes ? iterator.attributes.template : null;
|
|
323
|
-
if (t) {
|
|
324
|
-
const tx = this.toTemplate(iterator, creator);
|
|
325
|
-
target[t] = tx;
|
|
326
|
-
continue;
|
|
327
|
-
}
|
|
328
|
-
if (typeof iterator.name === "string") {
|
|
329
|
-
e.appendChild(this.createNode(target, iterator, binder, xNodeClass, creator));
|
|
330
|
-
continue;
|
|
331
|
-
}
|
|
332
|
-
const child = this.createNode(target, iterator, binder, xNodeClass, creator);
|
|
333
|
-
if (parent.element && parent.element.atomControl === parent) {
|
|
334
|
-
parent.append(child.atomControl || child);
|
|
335
|
-
} else {
|
|
336
|
-
parent.appendChild(child);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
return e;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
export class AtomBridge {
|
|
345
|
-
|
|
346
|
-
public static platform: "web" | "xf";
|
|
347
|
-
|
|
348
|
-
public static instance: BaseElementBridge<IAtomElement>;
|
|
349
|
-
|
|
350
|
-
public static createNode(iterator: XNode, app: any): { element?: any, control?: any } {
|
|
351
|
-
if (typeof iterator.name === "string" || (iterator.name as any).factory) {
|
|
352
|
-
|
|
353
|
-
return { element: AtomBridge.instance.create(iterator.name as any, iterator, app) };
|
|
354
|
-
}
|
|
355
|
-
const fx = iterator.attributes ? iterator.attributes.for : undefined;
|
|
356
|
-
const c = new (iterator.name as any)(app,
|
|
357
|
-
fx ? AtomBridge.instance.create(fx, iterator, app) : undefined) as any;
|
|
358
|
-
return { element: c.element, control: c };
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
public static toTemplate(app: any, n: XNode, creator: any) {
|
|
362
|
-
|
|
363
|
-
if (n.isTemplate) {
|
|
364
|
-
const t = AtomBridge.toTemplate(app, n.children[0], creator);
|
|
365
|
-
return AtomBridge.instance.create(n.name.toString(), t, app);
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
const bridge = AtomBridge.instance;
|
|
369
|
-
let fx;
|
|
370
|
-
let en;
|
|
371
|
-
if (typeof n.name === "function") {
|
|
372
|
-
fx = n.name;
|
|
373
|
-
en = (n.attributes && n.attributes.for) ? n.attributes.for : undefined;
|
|
374
|
-
} else {
|
|
375
|
-
fx = bridge.controlFactory;
|
|
376
|
-
en = n.name;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
return class Template extends (fx as any) {
|
|
380
|
-
|
|
381
|
-
// tslint:disable-next-line: variable-name
|
|
382
|
-
public _creator = fx;
|
|
383
|
-
|
|
384
|
-
constructor(a, e1) {
|
|
385
|
-
super(a || app, e1 || (en ? bridge.create(en, null, app) : undefined));
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
public create() {
|
|
389
|
-
super.create();
|
|
390
|
-
this.render(n, null, creator);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
};
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
public static refreshInherited(target: { element: any }, name: string, fieldName?: string): void {
|
|
397
|
-
if (AtomBridge.instance.refreshInherited) {
|
|
398
|
-
AtomBridge.instance.refreshInherited(target, name, fieldName);
|
|
399
|
-
return;
|
|
400
|
-
}
|
|
401
|
-
AtomBinder.refreshValue(target, name);
|
|
402
|
-
if (!fieldName) {
|
|
403
|
-
fieldName = "m" + name[0].toUpperCase() + name.substr(1);
|
|
404
|
-
}
|
|
405
|
-
if (!target.element) {
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
408
|
-
AtomBridge.instance.visitDescendents(target.element, (e, ac) => {
|
|
409
|
-
if (ac) {
|
|
410
|
-
if (ac[fieldName] === undefined) {
|
|
411
|
-
AtomBridge.refreshInherited(ac as any, name, fieldName);
|
|
412
|
-
}
|
|
413
|
-
return false;
|
|
414
|
-
}
|
|
415
|
-
return true;
|
|
416
|
-
});
|
|
417
|
-
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
// tslint:disable-next-line: one-variable-per-declaration
|
|
423
|
-
declare var window, global;
|
|
424
|
-
const globalNS = (typeof window !== "undefined" ? window : (global as any)) as any;
|
|
425
|
-
globalNS.AtomBridge = AtomBridge;
|
|
426
|
-
|
|
427
|
-
if (typeof window !== "undefined") {
|
|
428
|
-
AtomBridge.instance = new AtomElementBridge();
|
|
429
|
-
AtomBridge.platform = "web";
|
|
430
|
-
}
|
package/src/xf/XFApp.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import * as A from "../App";
|
|
2
|
-
import { AtomBridge } from "../core/AtomBridge";
|
|
3
|
-
import { BusyIndicatorService } from "../services/BusyIndicatorService";
|
|
4
|
-
import { NavigationService } from "../services/NavigationService";
|
|
5
|
-
import { AtomStyleSheet } from "../web/styles/AtomStyleSheet";
|
|
6
|
-
import XFBusyIndicatorService from "./services/XFBusyIndicatorService";
|
|
7
|
-
import XFNavigationService from "./services/XFNavigationService";
|
|
8
|
-
|
|
9
|
-
declare var bridge: any;
|
|
10
|
-
|
|
11
|
-
export default class XFApp extends A.App {
|
|
12
|
-
|
|
13
|
-
private mLastStyle: string = null;
|
|
14
|
-
|
|
15
|
-
private mRoot: any;
|
|
16
|
-
public get root(): any {
|
|
17
|
-
return this.mRoot;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
public set root(v: any) {
|
|
21
|
-
this.mRoot = v;
|
|
22
|
-
bridge.setRoot(v.element);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
constructor() {
|
|
26
|
-
super();
|
|
27
|
-
AtomBridge.instance = bridge;
|
|
28
|
-
this.put(NavigationService, this.resolve(XFNavigationService));
|
|
29
|
-
this.put(BusyIndicatorService, this.resolve(XFBusyIndicatorService));
|
|
30
|
-
this.put(AtomStyleSheet, new AtomStyleSheet(this, "WA_"));
|
|
31
|
-
|
|
32
|
-
const s = bridge.subscribe((channel, data) => {
|
|
33
|
-
this.broadcast(channel, data);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
// register for messaging...
|
|
37
|
-
const oldDispose = this.dispose;
|
|
38
|
-
this.dispose = () => {
|
|
39
|
-
s.dispose();
|
|
40
|
-
oldDispose.call(this);
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public updateDefaultStyle(textContent: string) {
|
|
45
|
-
if (!textContent) { return; }
|
|
46
|
-
if (this.mLastStyle && this.mLastStyle === textContent) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
this.mLastStyle = textContent;
|
|
50
|
-
bridge.updateDefaultStyle(textContent);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
public broadcast(channel: string, data: any) {
|
|
54
|
-
super.broadcast(channel, data);
|
|
55
|
-
bridge.broadcast(channel, data);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
}
|