@@ -1,78 +1,78 | |||||
1 | plugins { |
|
1 | plugins { | |
2 | id "org.implab.gradle-typescript" version "1.3.3" |
|
2 | id "org.implab.gradle-typescript" version "1.3.3" | |
3 | id "ivy-publish" |
|
3 | id "ivy-publish" | |
4 | } |
|
4 | } | |
5 |
|
5 | |||
6 | typescript { |
|
6 | typescript { | |
7 | compilerOptions { |
|
7 | compilerOptions { | |
8 | lib = ["es5", "dom", "scripthost", "es2015.promise", "es2015.symbol", "es2015.iterable"] |
|
8 | lib = ["es5", "dom", "scripthost", "es2015.promise", "es2015.symbol", "es2015.iterable"] | |
9 | //listFiles = true |
|
9 | //listFiles = true | |
10 | declaration = true |
|
10 | declaration = true | |
11 | strict = true |
|
11 | strict = true | |
12 | types = [] |
|
12 | types = [] | |
13 | module = "amd" |
|
13 | module = "amd" | |
14 | it.target = "es5" |
|
14 | it.target = "es5" | |
15 | experimentalDecorators = true |
|
15 | experimentalDecorators = true | |
16 | jsx = "react" |
|
16 | jsx = "react" | |
17 | jsxFactory = "createElement" |
|
17 | jsxFactory = "createElement" | |
18 | moduleResolution = "node" |
|
18 | moduleResolution = "node" | |
19 | // dojo-typings are sick |
|
19 | // dojo-typings are sick | |
20 | skipLibCheck = true |
|
20 | skipLibCheck = true | |
21 | // traceResolution = true |
|
21 | // traceResolution = true | |
22 | // baseUrl = "./" |
|
22 | // baseUrl = "./" | |
23 | // paths = [ "*": [ "$projectDir/src/typings/*" ] ] |
|
23 | // paths = [ "*": [ "$projectDir/src/typings/*" ] ] | |
24 | // baseUrl = "$projectDir/src/typings" |
|
24 | // baseUrl = "$projectDir/src/typings" | |
25 | // typeRoots = ["$projectDir/src/typings"] |
|
25 | // typeRoots = ["$projectDir/src/typings"] | |
26 | } |
|
26 | } | |
27 |
|
27 | |||
28 | tscCmd = "$projectDir/node_modules/.bin/tsc" |
|
28 | tscCmd = "$projectDir/node_modules/.bin/tsc" | |
29 | tsLintCmd = "$projectDir/node_modules/.bin/tslint" |
|
29 | tsLintCmd = "$projectDir/node_modules/.bin/tslint" | |
30 | esLintCmd = "$projectDir/node_modules/.bin/eslint" |
|
30 | esLintCmd = "$projectDir/node_modules/.bin/eslint" | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
33 | configureTsMain { |
|
33 | configureTsMain { | |
34 | compilerOptions { |
|
34 | compilerOptions { | |
35 | baseUrl = "$projectDir/src" |
|
35 | /*baseUrl = "$projectDir/src" | |
36 | paths = [ |
|
36 | paths = [ | |
37 | "dojo/*" : [ "typings/dojo/*" ], |
|
37 | "dojo/*" : [ "typings/dojo/*" ], | |
38 | "dijit/*" : [ "typings/dijit/*" ] |
|
38 | "dijit/*" : [ "typings/dijit/*" ] | |
39 |
|
|
39 | ]*/ | |
40 |
types = ["requirejs", |
|
40 | types = ["requirejs", "dojo-typings"] | |
41 | } |
|
41 | } | |
42 | } |
|
42 | } | |
43 |
|
43 | |||
44 | configureTsTest { |
|
44 | configureTsTest { | |
45 | compilerOptions { |
|
45 | compilerOptions { | |
46 | baseUrl = "." |
|
46 | baseUrl = "." | |
47 | paths = [ |
|
47 | paths = [ | |
48 | "@implab/djx" : [ sources.main.output.typingsDir.get().toString() ], |
|
48 | "@implab/djx" : [ sources.main.output.typingsDir.get().toString() ], | |
49 | "@implab/djx/*" : [ "${sources.main.output.typingsDir.get().toString()}/*" ] |
|
49 | "@implab/djx/*" : [ "${sources.main.output.typingsDir.get().toString()}/*" ] | |
50 | ] |
|
50 | ] | |
51 | types = ["requirejs", sources.main.output.typingsDir.get().toString()] |
|
51 | types = ["requirejs", sources.main.output.typingsDir.get().toString()] | |
52 | } |
|
52 | } | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | npmPackMeta { |
|
55 | npmPackMeta { | |
56 | meta { |
|
56 | meta { | |
57 | name = "@$npmScope/$project.name" |
|
57 | name = "@$npmScope/$project.name" | |
58 | } |
|
58 | } | |
59 | } |
|
59 | } | |
60 |
|
60 | |||
61 | task npmPackTypings(type: Copy) { |
|
61 | task npmPackTypings(type: Copy) { | |
62 | dependsOn typings |
|
62 | dependsOn typings | |
63 |
|
63 | |||
64 | npmPackContents.dependsOn it |
|
64 | npmPackContents.dependsOn it | |
65 |
|
65 | |||
66 | from typescript.typingsDir |
|
66 | from typescript.typingsDir | |
67 | into npm.packageDir |
|
67 | into npm.packageDir | |
68 | } |
|
68 | } | |
69 |
|
69 | |||
70 | task printVersion { |
|
70 | task printVersion { | |
71 | doLast { |
|
71 | doLast { | |
72 | println "packageName: ${npmPackMeta.metadata.get().name}"; |
|
72 | println "packageName: ${npmPackMeta.metadata.get().name}"; | |
73 | println "version: $version"; |
|
73 | println "version: $version"; | |
74 | println "target: $typescript.compilerOptions.target"; |
|
74 | println "target: $typescript.compilerOptions.target"; | |
75 | println "module: $typescript.compilerOptions.module"; |
|
75 | println "module: $typescript.compilerOptions.module"; | |
76 | println "symbols: $symbols"; |
|
76 | println "symbols: $symbols"; | |
77 | } |
|
77 | } | |
78 | } No newline at end of file |
|
78 | } |
@@ -1,76 +1,76 | |||||
1 | import { isNull, mixin } from "@implab/core-amd/safe"; |
|
1 | import { isNull, mixin } from "@implab/core-amd/safe"; | |
2 | import { isPlainObject, isNode, isBuildContext, DojoNodePosition, BuildContext } from "./traits"; |
|
2 | import { isPlainObject, isNode, isBuildContext, DojoNodePosition, BuildContext } from "./traits"; | |
3 |
|
3 | |||
4 | import dom = require("dojo/dom-construct"); |
|
4 | import dom = require("dojo/dom-construct"); | |
5 |
|
5 | |||
6 | export abstract class BuildContextBase implements BuildContext { |
|
6 | export abstract class BuildContextBase<TNode extends Node> implements BuildContext<TNode> { | |
7 | _attrs = {}; |
|
7 | _attrs = {}; | |
8 |
|
8 | |||
9 | _children = new Array(); |
|
9 | _children = new Array(); | |
10 |
|
10 | |||
11 | _created: boolean = false; |
|
11 | _created: boolean = false; | |
12 |
|
12 | |||
13 | visitNext(v: any) { |
|
13 | visitNext(v: any) { | |
14 | if (isNull(v)) |
|
14 | if (isNull(v)) | |
15 | return; |
|
15 | return; | |
16 |
|
16 | |||
17 | if (isPlainObject(v)) { |
|
17 | if (isPlainObject(v)) { | |
18 |
|
18 | |||
19 | if (this._created) |
|
19 | if (this._created) | |
20 | this._setAttrs(v); |
|
20 | this._setAttrs(v); | |
21 | else |
|
21 | else | |
22 | mixin(this._attrs, v); |
|
22 | mixin(this._attrs, v); | |
23 | } else if (v instanceof Array) { |
|
23 | } else if (v instanceof Array) { | |
24 | v.forEach(x => this._addChild(x)); |
|
24 | v.forEach(x => this._addChild(x)); | |
25 | } else { |
|
25 | } else { | |
26 | if (this._created) |
|
26 | if (this._created) | |
27 | this._addChild(v); |
|
27 | this._addChild(v); | |
28 | else |
|
28 | else | |
29 | this._children.push(v); |
|
29 | this._children.push(v); | |
30 | } |
|
30 | } | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
33 | getChildDom(v: any) { |
|
33 | getChildDom(v: any) { | |
34 | const tv = typeof v; |
|
34 | const tv = typeof v; | |
35 | if (tv === "string" || tv === "number" || tv === "boolean" || v instanceof RegExp || v instanceof Date) { |
|
35 | if (tv === "string" || tv === "number" || tv === "boolean" || v instanceof RegExp || v instanceof Date) { | |
36 | return document.createTextNode(v.toString()); |
|
36 | return document.createTextNode(v.toString()); | |
37 | } else if (isNode(v)) { |
|
37 | } else if (isNode(v)) { | |
38 | return v; |
|
38 | return v; | |
39 | } else if (isBuildContext(v)) { |
|
39 | } else if (isBuildContext(v)) { | |
40 | return v.getDomNode(); |
|
40 | return v.getDomNode(); | |
41 | } else { |
|
41 | } else { | |
42 | throw new Error("Invalid parameter"); |
|
42 | throw new Error("Invalid parameter"); | |
43 | } |
|
43 | } | |
44 | } |
|
44 | } | |
45 |
|
45 | |||
46 | abstract _getDomNode(): Node; |
|
46 | abstract _getDomNode(): TNode; | |
47 |
|
47 | |||
48 | ensureCreated() { |
|
48 | ensureCreated() { | |
49 | if (!this._created) { |
|
49 | if (!this._created) { | |
50 | this._create(this._attrs, this._children); |
|
50 | this._create(this._attrs, this._children); | |
51 | this._children = []; |
|
51 | this._children = []; | |
52 | this._attrs = {}; |
|
52 | this._attrs = {}; | |
53 | this._created = true; |
|
53 | this._created = true; | |
54 | } |
|
54 | } | |
55 | } |
|
55 | } | |
56 |
|
56 | |||
57 | /** @deprecated use getDomNode() */ |
|
57 | /** @deprecated use getDomNode() */ | |
58 | getDomElement() { |
|
58 | getDomElement() { | |
59 | return this.getDomNode(); |
|
59 | return this.getDomNode(); | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 | getDomNode() { |
|
62 | getDomNode() { | |
63 | this.ensureCreated(); |
|
63 | this.ensureCreated(); | |
64 | return this._getDomNode(); |
|
64 | return this._getDomNode(); | |
65 | } |
|
65 | } | |
66 |
|
66 | |||
67 | placeAt(refNode: string | Node, position?: DojoNodePosition) { |
|
67 | placeAt(refNode: string | Node, position?: DojoNodePosition) { | |
68 | dom.place(this.getDomNode(), refNode, position); |
|
68 | dom.place(this.getDomNode(), refNode, position); | |
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 | abstract _addChild(child: any): void; |
|
71 | abstract _addChild(child: any): void; | |
72 |
|
72 | |||
73 | abstract _setAttrs(attrs: object): void; |
|
73 | abstract _setAttrs(attrs: object): void; | |
74 |
|
74 | |||
75 | abstract _create(attrs: object, children: any[]): void; |
|
75 | abstract _create(attrs: object, children: any[]): void; | |
76 | } |
|
76 | } |
@@ -1,52 +1,51 | |||||
1 | import { djbase, djclass } from "../declare"; |
|
1 | import { djbase, djclass } from "../declare"; | |
2 | import _WidgetBase = require("dijit/_WidgetBase"); |
|
2 | import _WidgetBase = require("dijit/_WidgetBase"); | |
3 | import _AttachMixin = require("dijit/_AttachMixin"); |
|
3 | import _AttachMixin = require("dijit/_AttachMixin"); | |
4 | import { BuildContext, isNode } from "./traits"; |
|
4 | import { BuildContext, isNode } from "./traits"; | |
5 | import registry = require("dijit/registry"); |
|
5 | import registry = require("dijit/registry"); | |
6 | import { Handle } from "dojo/interfaces"; |
|
|||
7 |
|
6 | |||
8 | // type Handle = dojo.Handle; |
|
7 | // type Handle = dojo.Handle; | |
9 |
|
8 | |||
10 | @djclass |
|
9 | @djclass | |
11 | export abstract class DjxWidgetBase extends djbase(_WidgetBase, _AttachMixin) { |
|
10 | export abstract class DjxWidgetBase extends djbase(_WidgetBase, _AttachMixin) { | |
12 |
|
11 | |||
13 | buildRendering() { |
|
12 | buildRendering() { | |
14 | this.domNode = this.render().getDomNode(); |
|
13 | this.domNode = this.render().getDomNode(); | |
15 | super.buildRendering(); |
|
14 | super.buildRendering(); | |
16 | } |
|
15 | } | |
17 |
|
16 | |||
18 | abstract render(): BuildContext; |
|
17 | abstract render(): BuildContext<HTMLElement>; | |
19 |
|
18 | |||
20 | _processTemplateNode<T extends (Element | Node | _WidgetBase)>( |
|
19 | _processTemplateNode<T extends (Element | Node | _WidgetBase)>( | |
21 | baseNode: T, |
|
20 | baseNode: T, | |
22 | getAttrFunc: (baseNode: T, attr: string) => string, |
|
21 | getAttrFunc: (baseNode: T, attr: string) => string, | |
23 | // tslint:disable-next-line: ban-types |
|
22 | // tslint:disable-next-line: ban-types | |
24 | attachFunc: (node: T, type: string, func?: Function) => Handle |
|
23 | attachFunc: (node: T, type: string, func?: Function) => dojo.Handle | |
25 | ): boolean { |
|
24 | ): boolean { | |
26 | if (isNode(baseNode)) { |
|
25 | if (isNode(baseNode)) { | |
27 | const w = registry.byNode(baseNode); |
|
26 | const w = registry.byNode(baseNode); | |
28 | if (w) { |
|
27 | if (w) { | |
29 | // from dijit/_WidgetsInTemplateMixin |
|
28 | // from dijit/_WidgetsInTemplateMixin | |
30 | this._processTemplateNode(w, |
|
29 | this._processTemplateNode(w, | |
31 | (n, p) => n.get(p), // callback to get a property of a widget |
|
30 | (n, p) => n.get(p), // callback to get a property of a widget | |
32 | (widget, type, callback) => { |
|
31 | (widget, type, callback) => { | |
33 | if (!callback) |
|
32 | if (!callback) | |
34 | throw new Error("The callback must be specified"); |
|
33 | throw new Error("The callback must be specified"); | |
35 |
|
34 | |||
36 | // callback to do data-dojo-attach-event to a widget |
|
35 | // callback to do data-dojo-attach-event to a widget | |
37 | if (type in widget) { |
|
36 | if (type in widget) { | |
38 | // back-compat, remove for 2.0 |
|
37 | // back-compat, remove for 2.0 | |
39 | return widget.connect(widget, type, callback as EventListener); |
|
38 | return widget.connect(widget, type, callback as EventListener); | |
40 | } else { |
|
39 | } else { | |
41 | // 1.x may never hit this branch, but it's the default for 2.0 |
|
40 | // 1.x may never hit this branch, but it's the default for 2.0 | |
42 | return widget.on(type, callback); |
|
41 | return widget.on(type, callback); | |
43 | } |
|
42 | } | |
44 |
|
43 | |||
45 | }); |
|
44 | }); | |
46 | // don't process widgets internals |
|
45 | // don't process widgets internals | |
47 | return false; |
|
46 | return false; | |
48 | } |
|
47 | } | |
49 | } |
|
48 | } | |
50 | return super._processTemplateNode(baseNode, getAttrFunc, attachFunc); |
|
49 | return super._processTemplateNode(baseNode, getAttrFunc, attachFunc); | |
51 | } |
|
50 | } | |
52 | } |
|
51 | } |
@@ -1,45 +1,45 | |||||
1 | import dom = require("dojo/dom-construct"); |
|
1 | import dom = require("dojo/dom-construct"); | |
2 | import attr = require("dojo/dom-attr"); |
|
2 | import attr = require("dojo/dom-attr"); | |
3 | import { argumentNotEmptyString } from "@implab/core-amd/safe"; |
|
3 | import { argumentNotEmptyString } from "@implab/core-amd/safe"; | |
4 | import { BuildContextBase } from "./BuildContextBase"; |
|
4 | import { BuildContextBase } from "./BuildContextBase"; | |
5 |
|
5 | |||
6 | export class HtmlElementContext extends BuildContextBase { |
|
6 | export class HtmlElementContext extends BuildContextBase<HTMLElement> { | |
7 | elementType: string; |
|
7 | elementType: string; | |
8 |
|
8 | |||
9 | _element: HTMLElement | undefined; |
|
9 | _element: HTMLElement | undefined; | |
10 |
|
10 | |||
11 | constructor(elementType: string) { |
|
11 | constructor(elementType: string) { | |
12 | argumentNotEmptyString(elementType, "elementType"); |
|
12 | argumentNotEmptyString(elementType, "elementType"); | |
13 | super(); |
|
13 | super(); | |
14 |
|
14 | |||
15 | this.elementType = elementType; |
|
15 | this.elementType = elementType; | |
16 | } |
|
16 | } | |
17 |
|
17 | |||
18 | _addChild(child: any): void { |
|
18 | _addChild(child: any): void { | |
19 | if (!this._element) |
|
19 | if (!this._element) | |
20 | throw new Error("The HTML element isn't created"); |
|
20 | throw new Error("The HTML element isn't created"); | |
21 | dom.place(this.getChildDom(child), this._element); |
|
21 | dom.place(this.getChildDom(child), this._element); | |
22 | } |
|
22 | } | |
23 |
|
23 | |||
24 | _setAttrs(attrs: object): void { |
|
24 | _setAttrs(attrs: object): void { | |
25 | if (!this._element) |
|
25 | if (!this._element) | |
26 | throw new Error("The HTML element isn't created"); |
|
26 | throw new Error("The HTML element isn't created"); | |
27 |
|
27 | |||
28 | attr.set(this._element, attrs); |
|
28 | attr.set(this._element, attrs); | |
29 | } |
|
29 | } | |
30 |
|
30 | |||
31 | _create(attrs: object, children: any[]) { |
|
31 | _create(attrs: object, children: any[]) { | |
32 | this._element = dom.create(this.elementType, attrs); |
|
32 | this._element = dom.create(this.elementType, attrs); | |
33 |
|
33 | |||
34 | if (children) |
|
34 | if (children) | |
35 | children.forEach(v => this._addChild(v)); |
|
35 | children.forEach(v => this._addChild(v)); | |
36 | } |
|
36 | } | |
37 |
|
37 | |||
38 | _getDomNode() { |
|
38 | _getDomNode() { | |
39 | if (!this._element) |
|
39 | if (!this._element) | |
40 | throw new Error("The HTML element isn't created"); |
|
40 | throw new Error("The HTML element isn't created"); | |
41 |
|
41 | |||
42 | return this._element; |
|
42 | return this._element; | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | } |
|
45 | } |
@@ -1,55 +1,55 | |||||
1 | import dom = require("dojo/dom-construct"); |
|
1 | import dom = require("dojo/dom-construct"); | |
2 | import { argumentNotNull } from "@implab/core-amd/safe"; |
|
2 | import { argumentNotNull } from "@implab/core-amd/safe"; | |
3 | import { BuildContextBase } from "./BuildContextBase"; |
|
3 | import { BuildContextBase } from "./BuildContextBase"; | |
4 | import { MapOf } from "@implab/core-amd/interfaces"; |
|
4 | import { MapOf } from "@implab/core-amd/interfaces"; | |
5 |
|
5 | |||
6 | // tslint:disable-next-line: class-name |
|
6 | // tslint:disable-next-line: class-name | |
7 | export interface _Widget { |
|
7 | export interface _Widget { | |
8 | domNode: Node; |
|
8 | domNode: Node; | |
9 |
|
9 | |||
10 | get(attr: string): any; |
|
10 | get(attr: string): any; | |
11 |
|
11 | |||
12 | set(attr: string, value: any): void; |
|
12 | set(attr: string, value: any): void; | |
13 | set(attrs: MapOf<any>): void; |
|
13 | set(attrs: MapOf<any>): void; | |
14 |
|
14 | |||
15 | containerNode?: Node |
|
15 | containerNode?: Node | |
16 | } |
|
16 | } | |
17 |
|
17 | |||
18 | export type _WidgetCtor = new (attrs: any, srcNode?: string | Node) => _Widget; |
|
18 | export type _WidgetCtor = new (attrs: any, srcNode?: string | Node) => _Widget; | |
19 |
|
19 | |||
20 | export class WidgetContext extends BuildContextBase { |
|
20 | export class WidgetContext extends BuildContextBase<Node> { | |
21 | widgetClass: _WidgetCtor; |
|
21 | widgetClass: _WidgetCtor; | |
22 |
|
22 | |||
23 | _instance: _Widget | undefined; |
|
23 | _instance: _Widget | undefined; | |
24 |
|
24 | |||
25 | constructor(widgetClass: _WidgetCtor) { |
|
25 | constructor(widgetClass: _WidgetCtor) { | |
26 | super(); |
|
26 | super(); | |
27 | argumentNotNull(widgetClass, "widgetClass"); |
|
27 | argumentNotNull(widgetClass, "widgetClass"); | |
28 |
|
28 | |||
29 | this.widgetClass = widgetClass; |
|
29 | this.widgetClass = widgetClass; | |
30 | } |
|
30 | } | |
31 |
|
31 | |||
32 | _addChild(child: any): void { |
|
32 | _addChild(child: any): void { | |
33 | if (!this._instance || !this._instance.containerNode) |
|
33 | if (!this._instance || !this._instance.containerNode) | |
34 | throw new Error("Widget doesn't support adding children"); |
|
34 | throw new Error("Widget doesn't support adding children"); | |
35 |
|
35 | |||
36 | dom.place(this.getChildDom(child), this._instance.containerNode); |
|
36 | dom.place(this.getChildDom(child), this._instance.containerNode); | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | _setAttrs(attrs: object): void { |
|
39 | _setAttrs(attrs: object): void { | |
40 | this._instance?.set(attrs); |
|
40 | this._instance?.set(attrs); | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | _create(attrs: object, children: any[]) { |
|
43 | _create(attrs: object, children: any[]) { | |
44 | this._instance = new this.widgetClass(this._attrs); |
|
44 | this._instance = new this.widgetClass(this._attrs); | |
45 | if (children) |
|
45 | if (children) | |
46 | children.forEach(x => this._addChild(x)); |
|
46 | children.forEach(x => this._addChild(x)); | |
47 | } |
|
47 | } | |
48 |
|
48 | |||
49 | _getDomNode() { |
|
49 | _getDomNode() { | |
50 | if (!this._instance) |
|
50 | if (!this._instance) | |
51 | throw new Error("The instance of the widget isn't created"); |
|
51 | throw new Error("The instance of the widget isn't created"); | |
52 | return this._instance.domNode; |
|
52 | return this._instance.domNode; | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | } |
|
55 | } |
@@ -1,63 +1,63 | |||||
1 | import _WidgetBase = require("dijit/_WidgetBase"); |
|
1 | import _WidgetBase = require("dijit/_WidgetBase"); | |
2 |
|
2 | |||
3 | type _WidgetBaseConstructor = typeof _WidgetBase; |
|
3 | type _WidgetBaseConstructor = typeof _WidgetBase; | |
4 |
|
4 | |||
5 | export type DojoNodePosition = "first" | "after" | "before" | "last" | "replace" | "only" | number; |
|
5 | export type DojoNodePosition = "first" | "after" | "before" | "last" | "replace" | "only" | number; | |
6 |
|
6 | |||
7 | export interface BuildContext { |
|
7 | export interface BuildContext<TNode extends Node = Node> { | |
8 | getDomNode(): Node; |
|
8 | getDomNode(): TNode; | |
9 |
|
9 | |||
10 | placeAt(refNode: string | Node, position?: DojoNodePosition): void; |
|
10 | placeAt(refNode: string | Node, position?: DojoNodePosition): void; | |
11 | } |
|
11 | } | |
12 |
|
12 | |||
13 | export function isNode(el: any): el is Node { |
|
13 | export function isNode(el: any): el is Node { | |
14 | return el && el.nodeName && el.nodeType; |
|
14 | return el && el.nodeName && el.nodeType; | |
15 | } |
|
15 | } | |
16 |
|
16 | |||
17 | export function isElementNode(el: any): el is Element { |
|
17 | export function isElementNode(el: any): el is Element { | |
18 | return isNode(el) && el.nodeType === 1; |
|
18 | return isNode(el) && el.nodeType === 1; | |
19 | } |
|
19 | } | |
20 |
|
20 | |||
21 | export function isTextNode(el: any): el is Text { |
|
21 | export function isTextNode(el: any): el is Text { | |
22 | return isNode(el) && el.nodeType === 3; |
|
22 | return isNode(el) && el.nodeType === 3; | |
23 | } |
|
23 | } | |
24 |
|
24 | |||
25 | export function isProcessingInstructionNode(el: any): el is ProcessingInstruction { |
|
25 | export function isProcessingInstructionNode(el: any): el is ProcessingInstruction { | |
26 | return isNode(el) && el.nodeType === 7; |
|
26 | return isNode(el) && el.nodeType === 7; | |
27 | } |
|
27 | } | |
28 |
|
28 | |||
29 | export function isCommentNode(el: any): el is Comment { |
|
29 | export function isCommentNode(el: any): el is Comment { | |
30 | return isNode(el) && el.nodeType === 8; |
|
30 | return isNode(el) && el.nodeType === 8; | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
33 | export function isDocumentNode(el: any): el is Document { |
|
33 | export function isDocumentNode(el: any): el is Document { | |
34 | return isNode(el) && el.nodeType === 9; |
|
34 | return isNode(el) && el.nodeType === 9; | |
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | export function isDocumentTypeNode(el: any): el is DocumentType { |
|
37 | export function isDocumentTypeNode(el: any): el is DocumentType { | |
38 | return isNode(el) && el.nodeType === 10; |
|
38 | return isNode(el) && el.nodeType === 10; | |
39 | } |
|
39 | } | |
40 |
|
40 | |||
41 | export function isDocumentFragmentNode(el: any): el is DocumentFragment { |
|
41 | export function isDocumentFragmentNode(el: any): el is DocumentFragment { | |
42 | return isNode(el) && el.nodeType === 11; |
|
42 | return isNode(el) && el.nodeType === 11; | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | export function isWidget(v: any): v is _WidgetBase { |
|
45 | export function isWidget(v: any): v is _WidgetBase { | |
46 | return v && "domNode" in v; |
|
46 | return v && "domNode" in v; | |
47 | } |
|
47 | } | |
48 |
|
48 | |||
49 | export function isBuildContext(v: any): v is BuildContext { |
|
49 | export function isBuildContext(v: any): v is BuildContext { | |
50 | return typeof v === "object" && typeof v.getDomElement === "function"; |
|
50 | return typeof v === "object" && typeof v.getDomElement === "function"; | |
51 | } |
|
51 | } | |
52 |
|
52 | |||
53 | export function isPlainObject(v: object) { |
|
53 | export function isPlainObject(v: object) { | |
54 | if (typeof v !== "object") |
|
54 | if (typeof v !== "object") | |
55 | return false; |
|
55 | return false; | |
56 |
|
56 | |||
57 | const vp = Object.getPrototypeOf(v); |
|
57 | const vp = Object.getPrototypeOf(v); | |
58 | return !vp || vp === Object.prototype; |
|
58 | return !vp || vp === Object.prototype; | |
59 | } |
|
59 | } | |
60 |
|
60 | |||
61 | export function isWidgetConstructor(v: any): v is _WidgetBaseConstructor { |
|
61 | export function isWidgetConstructor(v: any): v is _WidgetBaseConstructor { | |
62 | return typeof v === "function" && v.prototype && "domNode" in v.prototype; |
|
62 | return typeof v === "function" && v.prototype && "domNode" in v.prototype; | |
63 | } |
|
63 | } |
@@ -1,18 +1,13 | |||||
1 | { |
|
1 | { | |
2 | "extends": "../tsconfig", |
|
2 | "extends": "../tsconfig", | |
3 | "compilerOptions": { |
|
3 | "compilerOptions": { | |
4 | "baseUrl": "../", |
|
|||
5 | "rootDir": "ts", |
|
4 | "rootDir": "ts", | |
6 | "rootDirs": [ |
|
5 | "rootDirs": [ | |
7 | "ts", |
|
6 | "ts", | |
8 | "typings" |
|
7 | "typings" | |
9 | ], |
|
8 | ], | |
10 | "paths" : { |
|
|||
11 | "dojo/*" : [ "typings/dojo/*" ], |
|
|||
12 | "dijit/*" : [ "typings/dijit/*" ] |
|
|||
13 | }, |
|
|||
14 | "types": [ |
|
9 | "types": [ | |
15 |
"requirejs", "./typings/index", " |
|
10 | "requirejs", "./typings/index", "dojo-typings" | |
16 | ] |
|
11 | ] | |
17 | } |
|
12 | } | |
18 | } No newline at end of file |
|
13 | } |
@@ -1,88 +1,87 | |||||
1 | import { Handle } from "dojo/interfaces"; |
|
1 | import { Handle } from "dojo/interfaces"; | |
2 | import _WidgetBase = require("./_WidgetBase"); |
|
2 | import _WidgetBase = require("./_WidgetBase"); | |
3 |
import d |
|
3 | import dojo = require("dojo/_base/kernel"); | |
4 | import dojo = require("dojo/_base/html"); |
|
|||
5 |
|
4 | |||
6 | declare module "./_WidgetBase" { |
|
5 | declare module "./_WidgetBase" { | |
7 | interface _WidgetBase { |
|
6 | interface _WidgetBase { | |
8 | dojoAttachEvent: string; |
|
7 | dojoAttachEvent: string; | |
9 | dojoAttachPoint: string; |
|
8 | dojoAttachPoint: string; | |
10 | } |
|
9 | } | |
11 | } |
|
10 | } | |
12 |
|
11 | |||
13 | declare module "dojo/_base/kernel" { |
|
12 | declare module "dojo/_base/kernel" { | |
14 | interface Dijit { |
|
13 | interface Dijit { | |
15 | _AttachMixin: _AttachMixinConstructor; |
|
14 | _AttachMixin: _AttachMixinConstructor; | |
16 | } |
|
15 | } | |
17 | } |
|
16 | } | |
18 |
|
17 | |||
19 | interface _AttachMixin { |
|
18 | interface _AttachMixin { | |
20 | /** |
|
19 | /** | |
21 | * List of widget attribute names associated with data-dojo-attach-point=... in the template, ex: ["containerNode", "labelNode"] |
|
20 | * List of widget attribute names associated with data-dojo-attach-point=... in the template, ex: ["containerNode", "labelNode"] | |
22 | */ |
|
21 | */ | |
23 | _attachPoints: string[]; |
|
22 | _attachPoints: string[]; | |
24 |
|
23 | |||
25 | /** |
|
24 | /** | |
26 | * List of connections associated with data-dojo-attach-event=... in the template |
|
25 | * List of connections associated with data-dojo-attach-event=... in the template | |
27 | */ |
|
26 | */ | |
28 | _attachEvents: Handle[]; |
|
27 | _attachEvents: Handle[]; | |
29 |
|
28 | |||
30 | /** |
|
29 | /** | |
31 | * Object to which attach points and events will be scoped. Defaults to 'this'. |
|
30 | * Object to which attach points and events will be scoped. Defaults to 'this'. | |
32 | */ |
|
31 | */ | |
33 | attachScope: any; |
|
32 | attachScope: any; | |
34 |
|
33 | |||
35 | /** |
|
34 | /** | |
36 | * Search descendants of this.containerNode for data-dojo-attach-point and data-dojo-attach-event. |
|
35 | * Search descendants of this.containerNode for data-dojo-attach-point and data-dojo-attach-event. | |
37 | * |
|
36 | * | |
38 | * Should generally be left false (the default value) both for performance and to avoid failures when this.containerNode holds other _AttachMixin instances with their own attach points and events. |
|
37 | * Should generally be left false (the default value) both for performance and to avoid failures when this.containerNode holds other _AttachMixin instances with their own attach points and events. | |
39 | */ |
|
38 | */ | |
40 | searchContainerNode: boolean; |
|
39 | searchContainerNode: boolean; | |
41 |
|
40 | |||
42 | /** |
|
41 | /** | |
43 | * Attach to DOM nodes marked with special attributes. |
|
42 | * Attach to DOM nodes marked with special attributes. | |
44 | */ |
|
43 | */ | |
45 | buildRendering(): void; |
|
44 | buildRendering(): void; | |
46 |
|
45 | |||
47 | /** |
|
46 | /** | |
48 | * hook for _WidgetsInTemplateMixin |
|
47 | * hook for _WidgetsInTemplateMixin | |
49 | */ |
|
48 | */ | |
50 | _beforeFillContent(): void; |
|
49 | _beforeFillContent(): void; | |
51 |
|
50 | |||
52 | /** |
|
51 | /** | |
53 | * Iterate through the dom nodes and attach functions and nodes accordingly. |
|
52 | * Iterate through the dom nodes and attach functions and nodes accordingly. | |
54 | * |
|
53 | * | |
55 | * Map widget properties and functions to the handlers specified in the dom node and it's descendants. This function iterates over all nodes and looks for these properties: |
|
54 | * Map widget properties and functions to the handlers specified in the dom node and it's descendants. This function iterates over all nodes and looks for these properties: | |
56 | * - dojoAttachPoint/data-dojo-attach-point |
|
55 | * - dojoAttachPoint/data-dojo-attach-point | |
57 | * - dojoAttachEvent/data-dojo-attach-event |
|
56 | * - dojoAttachEvent/data-dojo-attach-event | |
58 | */ |
|
57 | */ | |
59 | _attachTemplateNodes(rootNode: Element | Node): void; |
|
58 | _attachTemplateNodes(rootNode: Element | Node): void; | |
60 |
|
59 | |||
61 | /** |
|
60 | /** | |
62 | * Process data-dojo-attach-point and data-dojo-attach-event for given node or widget. |
|
61 | * Process data-dojo-attach-point and data-dojo-attach-event for given node or widget. | |
63 | * |
|
62 | * | |
64 | * Returns true if caller should process baseNode's children too. |
|
63 | * Returns true if caller should process baseNode's children too. | |
65 | */ |
|
64 | */ | |
66 | _processTemplateNode<T extends (Element | Node | _WidgetBase)>( |
|
65 | _processTemplateNode<T extends (Element | Node | _WidgetBase)>( | |
67 | baseNode: T, |
|
66 | baseNode: T, | |
68 | getAttrFunc: (baseNode: T, attr: string) => string, |
|
67 | getAttrFunc: (baseNode: T, attr: string) => string, | |
69 | attachFunc: (node: T, type: string, func?: Function) => Handle |
|
68 | attachFunc: (node: T, type: string, func?: Function) => Handle | |
70 | ): boolean; |
|
69 | ): boolean; | |
71 |
|
70 | |||
72 | /** |
|
71 | /** | |
73 | * Roughly corresponding to dojo/on, this is the default function for processing a data-dojo-attach-event. Meant to attach to DOMNodes, not to widgets. |
|
72 | * Roughly corresponding to dojo/on, this is the default function for processing a data-dojo-attach-event. Meant to attach to DOMNodes, not to widgets. | |
74 | */ |
|
73 | */ | |
75 | _attach(node: Element | Node, type: string, func?: Function): Handle; |
|
74 | _attach(node: Element | Node, type: string, func?: Function): Handle; | |
76 |
|
75 | |||
77 | /** |
|
76 | /** | |
78 | * Detach and clean up the attachments made in _attachtempalteNodes. |
|
77 | * Detach and clean up the attachments made in _attachtempalteNodes. | |
79 | */ |
|
78 | */ | |
80 | _detachTemplateNodes(): void; |
|
79 | _detachTemplateNodes(): void; | |
81 |
|
80 | |||
82 | destroyRendering(preserveDom?: boolean): void; |
|
81 | destroyRendering(preserveDom?: boolean): void; | |
83 | } |
|
82 | } | |
84 |
|
83 | |||
85 | interface _AttachMixinConstructor extends dojo._base.DeclareConstructor<_AttachMixin> { } |
|
84 | interface _AttachMixinConstructor extends dojo._base.DeclareConstructor<_AttachMixin> { } | |
86 |
|
85 | |||
87 | declare const _AttachMixin: _AttachMixinConstructor; |
|
86 | declare const _AttachMixin: _AttachMixinConstructor; | |
88 | export = _AttachMixin; |
|
87 | export = _AttachMixin; |
@@ -1,240 +1,241 | |||||
1 | import Stateful = require("dojo/Stateful"); |
|
1 | import Stateful = require("dojo/Stateful"); | |
2 | import Destroyable = require("./Destroyable"); |
|
2 | import Destroyable = require("./Destroyable"); | |
3 | import { ExtensionEvent } from "dojo/on"; |
|
3 | import { ExtensionEvent } from "dojo/on"; | |
4 | import { NodeFragmentOrString, Handle, NodeOrString, WatchHandle } from "dojo/interfaces"; |
|
4 | import { NodeFragmentOrString, Handle, NodeOrString, WatchHandle } from "dojo/interfaces"; | |
|
5 | import dojo = require("dojo/_base/kernel"); | |||
5 |
|
6 | |||
6 | declare namespace _WidgetBase { |
|
7 | declare namespace _WidgetBase { | |
7 | interface _WidgetBase extends Stateful, Destroyable { |
|
8 | interface _WidgetBase extends Stateful, Destroyable { | |
8 |
|
9 | |||
9 | /** |
|
10 | /** | |
10 | * A unique, opaque ID string that can be assigned by users or by the |
|
11 | * A unique, opaque ID string that can be assigned by users or by the | |
11 | * system. If the developer passes an ID which is known not to be |
|
12 | * system. If the developer passes an ID which is known not to be | |
12 | * unique, the specified ID is ignored and the system-generated ID is |
|
13 | * unique, the specified ID is ignored and the system-generated ID is | |
13 | * used instead. |
|
14 | * used instead. | |
14 | */ |
|
15 | */ | |
15 | id: string; |
|
16 | id: string; | |
16 |
|
17 | |||
17 | /** |
|
18 | /** | |
18 | * Rarely used. Overrides the default Dojo locale used to render this widget, |
|
19 | * Rarely used. Overrides the default Dojo locale used to render this widget, | |
19 | * as defined by the [HTML LANG](http://www.w3.org/TR/html401/struct/dirlang.html#adef-lang) attribute. |
|
20 | * as defined by the [HTML LANG](http://www.w3.org/TR/html401/struct/dirlang.html#adef-lang) attribute. | |
20 | * Value must be among the list of locales specified during by the Dojo bootstrap, |
|
21 | * Value must be among the list of locales specified during by the Dojo bootstrap, | |
21 | * formatted according to [RFC 3066](http://www.ietf.org/rfc/rfc3066.txt) (like en-us). |
|
22 | * formatted according to [RFC 3066](http://www.ietf.org/rfc/rfc3066.txt) (like en-us). | |
22 | */ |
|
23 | */ | |
23 | lang: string; |
|
24 | lang: string; | |
24 |
|
25 | |||
25 | /** |
|
26 | /** | |
26 | * Bi-directional support, as defined by the [HTML DIR](http://www.w3.org/TR/html401/struct/dirlang.html#adef-dir) |
|
27 | * Bi-directional support, as defined by the [HTML DIR](http://www.w3.org/TR/html401/struct/dirlang.html#adef-dir) | |
27 | * attribute. Either left-to-right "ltr" or right-to-left "rtl". If undefined, widgets renders in page's |
|
28 | * attribute. Either left-to-right "ltr" or right-to-left "rtl". If undefined, widgets renders in page's | |
28 | * default direction. |
|
29 | * default direction. | |
29 | */ |
|
30 | */ | |
30 | dir: string; |
|
31 | dir: string; | |
31 |
|
32 | |||
32 | /** |
|
33 | /** | |
33 | * HTML class attribute |
|
34 | * HTML class attribute | |
34 | */ |
|
35 | */ | |
35 | class: string; |
|
36 | class: string; | |
36 |
|
37 | |||
37 | /** |
|
38 | /** | |
38 | * HTML style attributes as cssText string or name/value hash |
|
39 | * HTML style attributes as cssText string or name/value hash | |
39 | */ |
|
40 | */ | |
40 | style: string; |
|
41 | style: string; | |
41 |
|
42 | |||
42 | /** |
|
43 | /** | |
43 | * HTML title attribute. |
|
44 | * HTML title attribute. | |
44 | * |
|
45 | * | |
45 | * For form widgets this specifies a tooltip to display when hovering over |
|
46 | * For form widgets this specifies a tooltip to display when hovering over | |
46 | * the widget (just like the native HTML title attribute). |
|
47 | * the widget (just like the native HTML title attribute). | |
47 | * |
|
48 | * | |
48 | * For TitlePane or for when this widget is a child of a TabContainer, AccordionContainer, |
|
49 | * For TitlePane or for when this widget is a child of a TabContainer, AccordionContainer, | |
49 | * etc., it's used to specify the tab label, accordion pane title, etc. In this case it's |
|
50 | * etc., it's used to specify the tab label, accordion pane title, etc. In this case it's | |
50 | * interpreted as HTML. |
|
51 | * interpreted as HTML. | |
51 | */ |
|
52 | */ | |
52 | title: string; |
|
53 | title: string; | |
53 |
|
54 | |||
54 | /** |
|
55 | /** | |
55 | * When this widget's title attribute is used to for a tab label, accordion pane title, etc., |
|
56 | * When this widget's title attribute is used to for a tab label, accordion pane title, etc., | |
56 | * this specifies the tooltip to appear when the mouse is hovered over that text. |
|
57 | * this specifies the tooltip to appear when the mouse is hovered over that text. | |
57 | */ |
|
58 | */ | |
58 | tooltip: string; |
|
59 | tooltip: string; | |
59 |
|
60 | |||
60 | /** |
|
61 | /** | |
61 | * Root CSS class of the widget (ex: dijitTextBox), used to construct CSS classes to indicate |
|
62 | * Root CSS class of the widget (ex: dijitTextBox), used to construct CSS classes to indicate | |
62 | * widget state. |
|
63 | * widget state. | |
63 | */ |
|
64 | */ | |
64 | baseClass: string; |
|
65 | baseClass: string; | |
65 |
|
66 | |||
66 | /** |
|
67 | /** | |
67 | * pointer to original DOM node |
|
68 | * pointer to original DOM node | |
68 | */ |
|
69 | */ | |
69 | srcNodeRef: HTMLElement; |
|
70 | srcNodeRef: HTMLElement; | |
70 |
|
71 | |||
71 | /** |
|
72 | /** | |
72 | * This is our visible representation of the widget! Other DOM |
|
73 | * This is our visible representation of the widget! Other DOM | |
73 | * Nodes may by assigned to other properties, usually through the |
|
74 | * Nodes may by assigned to other properties, usually through the | |
74 | * template system's data-dojo-attach-point syntax, but the domNode |
|
75 | * template system's data-dojo-attach-point syntax, but the domNode | |
75 | * property is the canonical "top level" node in widget UI. |
|
76 | * property is the canonical "top level" node in widget UI. | |
76 | */ |
|
77 | */ | |
77 | domNode: HTMLElement; |
|
78 | domNode: HTMLElement; | |
78 |
|
79 | |||
79 | /** |
|
80 | /** | |
80 | * Designates where children of the source DOM node will be placed. |
|
81 | * Designates where children of the source DOM node will be placed. | |
81 | * "Children" in this case refers to both DOM nodes and widgets. |
|
82 | * "Children" in this case refers to both DOM nodes and widgets. | |
82 | */ |
|
83 | */ | |
83 | containerNode: HTMLElement; |
|
84 | containerNode: HTMLElement; | |
84 |
|
85 | |||
85 | /** |
|
86 | /** | |
86 | * The document this widget belongs to. If not specified to constructor, will default to |
|
87 | * The document this widget belongs to. If not specified to constructor, will default to | |
87 | * srcNodeRef.ownerDocument, or if no sourceRef specified, then to the document global |
|
88 | * srcNodeRef.ownerDocument, or if no sourceRef specified, then to the document global | |
88 | */ |
|
89 | */ | |
89 | ownerDocument: HTMLElement; |
|
90 | ownerDocument: HTMLElement; | |
90 |
|
91 | |||
91 | /** |
|
92 | /** | |
92 | * Deprecated. Instead of attributeMap, widget should have a _setXXXAttr attribute |
|
93 | * Deprecated. Instead of attributeMap, widget should have a _setXXXAttr attribute | |
93 | * for each XXX attribute to be mapped to the DOM. |
|
94 | * for each XXX attribute to be mapped to the DOM. | |
94 | */ |
|
95 | */ | |
95 | attributeMap: { [attribute: string]: any }; |
|
96 | attributeMap: { [attribute: string]: any }; | |
96 |
|
97 | |||
97 | /** |
|
98 | /** | |
98 | * Bi-directional support, the main variable which is responsible for the direction of the text. |
|
99 | * Bi-directional support, the main variable which is responsible for the direction of the text. | |
99 | * The text direction can be different than the GUI direction by using this parameter in creation |
|
100 | * The text direction can be different than the GUI direction by using this parameter in creation | |
100 | * of a widget. |
|
101 | * of a widget. | |
101 | */ |
|
102 | */ | |
102 | textDir: string; |
|
103 | textDir: string; | |
103 |
|
104 | |||
104 | /** |
|
105 | /** | |
105 | * Kicks off widget instantiation. See create() for details. |
|
106 | * Kicks off widget instantiation. See create() for details. | |
106 | */ |
|
107 | */ | |
107 | postscript(params?: any, srcNodeRef?: HTMLElement): void; |
|
108 | postscript(params?: any, srcNodeRef?: HTMLElement): void; | |
108 |
|
109 | |||
109 | /** |
|
110 | /** | |
110 | * Kick off the life-cycle of a widget |
|
111 | * Kick off the life-cycle of a widget | |
111 | */ |
|
112 | */ | |
112 | create(params?: any, srcNodeRef?: HTMLElement): void; |
|
113 | create(params?: any, srcNodeRef?: HTMLElement): void; | |
113 |
|
114 | |||
114 | /** |
|
115 | /** | |
115 | * Called after the parameters to the widget have been read-in, |
|
116 | * Called after the parameters to the widget have been read-in, | |
116 | * but before the widget template is instantiated. Especially |
|
117 | * but before the widget template is instantiated. Especially | |
117 | * useful to set properties that are referenced in the widget |
|
118 | * useful to set properties that are referenced in the widget | |
118 | * template. |
|
119 | * template. | |
119 | */ |
|
120 | */ | |
120 | postMixInProperties(): void; |
|
121 | postMixInProperties(): void; | |
121 |
|
122 | |||
122 | /** |
|
123 | /** | |
123 | * Construct the UI for this widget, setting this.domNode. |
|
124 | * Construct the UI for this widget, setting this.domNode. | |
124 | * Most widgets will mixin `dijit._TemplatedMixin`, which implements this method. |
|
125 | * Most widgets will mixin `dijit._TemplatedMixin`, which implements this method. | |
125 | */ |
|
126 | */ | |
126 | buildRendering(): void; |
|
127 | buildRendering(): void; | |
127 |
|
128 | |||
128 | /** |
|
129 | /** | |
129 | * Processing after the DOM fragment is created |
|
130 | * Processing after the DOM fragment is created | |
130 | */ |
|
131 | */ | |
131 | postCreate(): void; |
|
132 | postCreate(): void; | |
132 |
|
133 | |||
133 | /** |
|
134 | /** | |
134 | * Processing after the DOM fragment is added to the document |
|
135 | * Processing after the DOM fragment is added to the document | |
135 | */ |
|
136 | */ | |
136 | startup(): void; |
|
137 | startup(): void; | |
137 |
|
138 | |||
138 | /** |
|
139 | /** | |
139 | * Destroy this widget and its descendants |
|
140 | * Destroy this widget and its descendants | |
140 | */ |
|
141 | */ | |
141 | destroyRecursive(preserveDom?: boolean): void; |
|
142 | destroyRecursive(preserveDom?: boolean): void; | |
142 |
|
143 | |||
143 | /** |
|
144 | /** | |
144 | * Destroys the DOM nodes associated with this widget. |
|
145 | * Destroys the DOM nodes associated with this widget. | |
145 | */ |
|
146 | */ | |
146 | destroyRendering(preserveDom?: boolean): void; |
|
147 | destroyRendering(preserveDom?: boolean): void; | |
147 |
|
148 | |||
148 | /** |
|
149 | /** | |
149 | * Recursively destroy the children of this widget and their |
|
150 | * Recursively destroy the children of this widget and their | |
150 | * descendants. |
|
151 | * descendants. | |
151 | */ |
|
152 | */ | |
152 | destroyDescendants(preserveDom?: boolean): void; |
|
153 | destroyDescendants(preserveDom?: boolean): void; | |
153 |
|
154 | |||
154 | /** |
|
155 | /** | |
155 | * Deprecated. Override destroy() instead to implement custom widget tear-down |
|
156 | * Deprecated. Override destroy() instead to implement custom widget tear-down | |
156 | * behavior. |
|
157 | * behavior. | |
157 | */ |
|
158 | */ | |
158 | uninitialize(): boolean; |
|
159 | uninitialize(): boolean; | |
159 |
|
160 | |||
160 | /** |
|
161 | /** | |
161 | * Used by widgets to signal that a synthetic event occurred, ex: |
|
162 | * Used by widgets to signal that a synthetic event occurred, ex: | |
162 | * | myWidget.emit("attrmodified-selectedChildWidget", {}). |
|
163 | * | myWidget.emit("attrmodified-selectedChildWidget", {}). | |
163 | */ |
|
164 | */ | |
164 | emit(type: string, eventObj?: any, callbackArgs?: any[]): any; |
|
165 | emit(type: string, eventObj?: any, callbackArgs?: any[]): any; | |
165 |
|
166 | |||
166 | /** |
|
167 | /** | |
167 | * Call specified function when event occurs, ex: myWidget.on("click", function(){ ... }). |
|
168 | * Call specified function when event occurs, ex: myWidget.on("click", function(){ ... }). | |
168 | */ |
|
169 | */ | |
169 | on(type: string | ExtensionEvent, func: EventListener | Function): WatchHandle; |
|
170 | on(type: string | ExtensionEvent, func: EventListener | Function): WatchHandle; | |
170 |
|
171 | |||
171 | /** |
|
172 | /** | |
172 | * Returns a string that represents the widget. |
|
173 | * Returns a string that represents the widget. | |
173 | */ |
|
174 | */ | |
174 | toString(): string; |
|
175 | toString(): string; | |
175 |
|
176 | |||
176 | /** |
|
177 | /** | |
177 | * Returns all direct children of this widget, i.e. all widgets underneath this.containerNode whose parent |
|
178 | * Returns all direct children of this widget, i.e. all widgets underneath this.containerNode whose parent | |
178 | * is this widget. Note that it does not return all descendants, but rather just direct children. |
|
179 | * is this widget. Note that it does not return all descendants, but rather just direct children. | |
179 | */ |
|
180 | */ | |
180 | getChildren<T extends _WidgetBase>(): T[]; |
|
181 | getChildren<T extends _WidgetBase>(): T[]; | |
181 |
|
182 | |||
182 | /** |
|
183 | /** | |
183 | * Returns the parent widget of this widget. |
|
184 | * Returns the parent widget of this widget. | |
184 | */ |
|
185 | */ | |
185 | getParent<T extends _WidgetBase>(): T; |
|
186 | getParent<T extends _WidgetBase>(): T; | |
186 |
|
187 | |||
187 | /** |
|
188 | /** | |
188 | * Deprecated, will be removed in 2.0, use this.own(on(...)) or this.own(aspect.after(...)) instead. |
|
189 | * Deprecated, will be removed in 2.0, use this.own(on(...)) or this.own(aspect.after(...)) instead. | |
189 | */ |
|
190 | */ | |
190 | connect(obj: any, event: string | ExtensionEvent, method: string | EventListener): WatchHandle; |
|
191 | connect(obj: any, event: string | ExtensionEvent, method: string | EventListener): WatchHandle; | |
191 |
|
192 | |||
192 | /** |
|
193 | /** | |
193 | * Deprecated, will be removed in 2.0, use handle.remove() instead. |
|
194 | * Deprecated, will be removed in 2.0, use handle.remove() instead. | |
194 | */ |
|
195 | */ | |
195 | disconnect(handle: WatchHandle): void; |
|
196 | disconnect(handle: WatchHandle): void; | |
196 |
|
197 | |||
197 | /** |
|
198 | /** | |
198 | * Deprecated, will be removed in 2.0, use this.own(topic.subscribe()) instead. |
|
199 | * Deprecated, will be removed in 2.0, use this.own(topic.subscribe()) instead. | |
199 | */ |
|
200 | */ | |
200 | subscribe(t: string, method: EventListener): WatchHandle; |
|
201 | subscribe(t: string, method: EventListener): WatchHandle; | |
201 |
|
202 | |||
202 | /** |
|
203 | /** | |
203 | * Deprecated, will be removed in 2.0, use handle.remove() instead. |
|
204 | * Deprecated, will be removed in 2.0, use handle.remove() instead. | |
204 | */ |
|
205 | */ | |
205 | unsubscribe(handle: WatchHandle): void; |
|
206 | unsubscribe(handle: WatchHandle): void; | |
206 |
|
207 | |||
207 | /** |
|
208 | /** | |
208 | * Return this widget's explicit or implicit orientation (true for LTR, false for RTL) |
|
209 | * Return this widget's explicit or implicit orientation (true for LTR, false for RTL) | |
209 | */ |
|
210 | */ | |
210 | isLeftToRight(): boolean; |
|
211 | isLeftToRight(): boolean; | |
211 |
|
212 | |||
212 | /** |
|
213 | /** | |
213 | * Return true if this widget can currently be focused |
|
214 | * Return true if this widget can currently be focused | |
214 | * and false if not |
|
215 | * and false if not | |
215 | */ |
|
216 | */ | |
216 | isFocusable(): boolean; |
|
217 | isFocusable(): boolean; | |
217 |
|
218 | |||
218 | /** |
|
219 | /** | |
219 | * Place this widget somewhere in the DOM based |
|
220 | * Place this widget somewhere in the DOM based | |
220 | * on standard domConstruct.place() conventions. |
|
221 | * on standard domConstruct.place() conventions. | |
221 | */ |
|
222 | */ | |
222 | placeAt<T extends _WidgetBase>(reference: NodeFragmentOrString | T, position?: string | number): this; |
|
223 | placeAt<T extends _WidgetBase>(reference: NodeFragmentOrString | T, position?: string | number): this; | |
223 |
|
224 | |||
224 | /** |
|
225 | /** | |
225 | * Wrapper to setTimeout to avoid deferred functions executing |
|
226 | * Wrapper to setTimeout to avoid deferred functions executing | |
226 | * after the originating widget has been destroyed. |
|
227 | * after the originating widget has been destroyed. | |
227 | * Returns an object handle with a remove method (that returns null) (replaces clearTimeout). |
|
228 | * Returns an object handle with a remove method (that returns null) (replaces clearTimeout). | |
228 | */ |
|
229 | */ | |
229 | defer(fcn: Function, delay?: number): Handle; |
|
230 | defer(fcn: Function, delay?: number): Handle; | |
230 | } |
|
231 | } | |
231 |
|
232 | |||
232 | interface _WidgetBaseConstructor<W = _WidgetBase> extends DeclareConstructor<W> { |
|
233 | interface _WidgetBaseConstructor<W = _WidgetBase> extends dojo._base.DeclareConstructor<W> { | |
233 | new(params: Object, srcNodeRef?: NodeOrString): W; |
|
234 | new(params: Object, srcNodeRef?: NodeOrString): W; | |
234 | } |
|
235 | } | |
235 |
|
236 | |||
236 | } |
|
237 | } | |
237 |
|
238 | |||
238 | type _WidgetBase = _WidgetBase._WidgetBase; |
|
239 | type _WidgetBase = _WidgetBase._WidgetBase; | |
239 | declare const _WidgetBase: _WidgetBase._WidgetBaseConstructor; |
|
240 | declare const _WidgetBase: _WidgetBase._WidgetBaseConstructor; | |
240 | export = _WidgetBase; |
|
241 | export = _WidgetBase; |
General Comments 0
You need to be logged in to leave comments.
Login now