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