##// END OF EJS Templates
Added tag v1.1.0 for changeset 1a0018655d1c
Added tag v1.1.0 for changeset 1a0018655d1c

File last commit:

r63:1a0018655d1c v1.1.0 default
r64:3f27d1084ced default
Show More
DjxWidgetBase.ts
88 lines | 3.2 KiB | video/mp2t | TypeScriptLexer
/ src / main / ts / tsx / DjxWidgetBase.ts
cin
sync
r7 import { djbase, djclass } from "../declare";
import _WidgetBase = require("dijit/_WidgetBase");
import _AttachMixin = require("dijit/_AttachMixin");
cin
* tsx/{Xxx}Context renamed to tsx/{Xxx}Rendition, for old types made...
r63 import { Rendition, isNode, startupWidgets } from "./traits";
cin
sync
r7 import registry = require("dijit/registry");
cin
Working on dojo typings
r15
// type Handle = dojo.Handle;
cin
sync
r7
cin
Added 'Attrs', 'Events' type parameters to DjxWidgetBase, typed 'on' and 'emit' methods
r30 export interface EventArgs {
bubbles?: boolean;
cancelable?: boolean;
composed?: boolean;
}
export interface DjxWidgetBase<Attrs = any, Events extends { [name in keyof Events]: Event } = any> {
set<K extends keyof Attrs & string>(key: K, value: Attrs[K]): this;
set(props: Partial<Attrs>): this;
get<K extends keyof Attrs & string>(key: K): Attrs[K];
on<K extends keyof Events & string>(eventName: K, cb: (evt: Events[K]) => void): dojo.WatchHandle;
cin
DjxWidgetBase: implemented copying content from srcNode to contentNode
r57 emit<K extends keyof Events & string>(eventName: K, evt: Omit<Events[K], keyof Event> & EventArgs): void;
cin
Added 'Attrs', 'Events' type parameters to DjxWidgetBase, typed 'on' and 'emit' methods
r30 }
cin
sync
r7 @djclass
cin
Added 'Attrs', 'Events' type parameters to DjxWidgetBase, typed 'on' and 'emit' methods
r30 export abstract class DjxWidgetBase<Attrs = any, Events = any> extends djbase(_WidgetBase, _AttachMixin) {
cin
sync
r7
buildRendering() {
cin
Added DjxFragment...
r19 this.domNode = this.render().getDomNode();
cin
sync
r7 super.buildRendering();
cin
DjxWidgetBase: implemented copying content from srcNode to contentNode
r57
// now we should get assigned data-dojo-attach-points
// place the contents of the original srcNode to the containerNode
const src = this.srcNodeRef;
const dest = this.containerNode;
if (src && dest) {
while (src.firstChild)
dest.appendChild(src.firstChild);
}
cin
sync
r7 }
cin
* tsx/{Xxx}Context renamed to tsx/{Xxx}Rendition, for old types made...
r63 abstract render(): Rendition<HTMLElement>;
cin
sync
r7
_processTemplateNode<T extends (Element | Node | _WidgetBase)>(
baseNode: T,
getAttrFunc: (baseNode: T, attr: string) => string,
// tslint:disable-next-line: ban-types
cin
Switched to dojo-typings...
r22 attachFunc: (node: T, type: string, func?: Function) => dojo.Handle
cin
sync
r7 ): boolean {
if (isNode(baseNode)) {
const w = registry.byNode(baseNode);
if (w) {
// from dijit/_WidgetsInTemplateMixin
this._processTemplateNode(w,
(n, p) => n.get(p), // callback to get a property of a widget
(widget, type, callback) => {
if (!callback)
throw new Error("The callback must be specified");
// callback to do data-dojo-attach-event to a widget
if (type in widget) {
// back-compat, remove for 2.0
return widget.connect(widget, type, callback as EventListener);
} else {
// 1.x may never hit this branch, but it's the default for 2.0
return widget.on(type, callback);
}
});
// don't process widgets internals
return false;
}
}
return super._processTemplateNode(baseNode, getAttrFunc, attachFunc);
}
cin
Fixed startup of DjxWidgetBase to start inner widgets...
r52
/** Starts current widget and all its supporting widgets (placed outside
cin
DjxWidgetBase: implemented copying content from srcNode to contentNode
r57 * `containerNode`) and child widgets (placed inside `containerNode`)
*/
cin
Fixed startup of DjxWidgetBase to start inner widgets...
r52 startup() {
// startup supporting widgets
cin
* tsx/{Xxx}Context renamed to tsx/{Xxx}Rendition, for old types made...
r63 registry.findWidgets(this.domNode, this.containerNode).forEach(w => w.startup());
cin
Fixed startup of DjxWidgetBase to start inner widgets...
r52 super.startup();
}
cin
sync
r7 }