All files / dgrid/extensions DijitRegistry.js

0% Statements 0/23
0% Branches 0/8
0% Functions 0/12
0% Lines 0/23

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99                                                                                                                                                                                                     
define([
	'dojo/_base/declare',
	'dojo/dom-geometry',
	'dijit/_WidgetBase',
	'dijit/registry'
], function (declare, domGeometry, _WidgetBase, registry) {
	var wbPrototype = _WidgetBase.prototype;
 
	return declare(null, {
		// summary:
		//		A dgrid extension which will add the grid to the dijit registry,
		//		so that startup() will be successfully called by dijit layout widgets
		//		with dgrid children.
 
		// Defaults normally imposed on _WidgetBase by container widget modules:
		minSize: 0, // BorderContainer
		maxSize: Infinity, // BorderContainer
		layoutPriority: 0, // BorderContainer
		showTitle: true, // StackContainer
 
		buildRendering: function () {
			registry.add(this);
			this.inherited(arguments);
			// Note: for dojo 2.0 may rename widgetId to dojo._scopeName + "_widgetId"
			this.domNode.setAttribute('widgetId', this.id);
		},
 
		startup: function () {
			if (this._started) {
				return;
			}
			this.inherited(arguments);
 
			var widget = this.getParent();
			// If we have a parent layout container widget, it will handle resize,
			// so remove the window resize listener added by List.
			if (widget && widget.isLayoutContainer) {
				this._resizeHandle.remove();
			}
		},
 
		destroyRecursive: function () {
			this.destroy();
		},
 
		destroy: function () {
			this.inherited(arguments);
			registry.remove(this.id);
		},
 
		getChildren: function () {
			// provide hollow implementation for logic which assumes its existence
			// (e.g. dijit/form/_FormMixin)
			return [];
		},
 
		getParent: function () {
			// summary:
			//		Analogous to _WidgetBase#getParent, for compatibility with e.g. dijit._KeyNavContainer.
			return registry.getEnclosingWidget(this.domNode.parentNode);
		},
 
		isLeftToRight: function () {
			// Implement method expected by Dijit layout widgets
			return !this.isRTL;
		},
 
		placeAt: function (/*String|DomNode|DocumentFragment|dijit/_WidgetBase*/ reference, /*String|Int?*/ position) {
			// summary:
			//		Analogous to dijit/_WidgetBase#placeAt;
			//		places this widget in the DOM based on domConstruct.place() conventions.
 
			return wbPrototype.placeAt.call(this, reference, position);
		},
 
		resize: function (changeSize) {
			// Honor changeSize parameter used by layout widgets, and resize grid
			if (changeSize) {
				domGeometry.setMarginBox(this.domNode, changeSize);
			}
 
			this.inherited(arguments);
		},
 
		_set: function (prop, value) {
			// summary:
			//		Simple analogue of _WidgetBase#_set for compatibility with some
			//		Dijit layout widgets which assume its existence.
			this[prop] = value;
		},
 
		watch: function () {
			// summary:
			//		dgrid doesn't support watch; this is a no-op for compatibility with
			//		some Dijit layout widgets which assume its existence.
		}
	});
});