Debian Codegraph @

dojox/layout/Dock.js

raw symbols SCIP
1 define([
2 "dojo/_base/lang", "dojo/_base/window", "dojo/_base/declare",
3 "dojo/_base/fx", "dojo/on", "dojo/_base/array", "dojo/_base/sniff",
4 "dojo/window", "dojo/dom", "dojo/dom-class", "dojo/dom-geometry", "dojo/dom-construct",
5 "dijit/_TemplatedMixin", "dijit/_WidgetBase"
6 ], function(
7 lang, winUtil, declare, fx, on, arrayUtil,
8 has, windowLib, dom, domClass, domGeom, domConstruct, _TemplatedMixin, _WidgetBase
9 ){
10
11 //TODO: don't want to rely on kernel just to make something as experimental
12 //kernel.experimental("dojox.layout.Dock");
13
14 var Dock = declare("dojox.layout.Dock",[_WidgetBase, _TemplatedMixin],{
15 // summary:
16 // A widget that attaches to a node and keeps track of incoming / outgoing FloatingPanes
17 // and handles layout
18
19 templateString: '<div class="dojoxDock"><ul data-dojo-attach-point="containerNode" class="dojoxDockList"></ul></div>',
20
21 // _docked: [private] Array
22 // array of panes currently in our dock
23 _docked: [],
24
25 _inPositioning: false,
26
27 autoPosition: false,
28
29 addNode: function(refNode){
30 // summary:
31 // Insert a dockNode reference into the dock
32
33 var div = domConstruct.create('li', null, this.containerNode),
34 node = new DockNode({
35 title: refNode.title,
36 paneRef: refNode
37 }, div)
38 ;
39 node.startup();
40 return node;
41 },
42
43 startup: function(){
44
45 if (this.id == "dojoxGlobalFloatingDock" || this.isFixedDock) {
46 // attach window.onScroll, and a position like in presentation/dialog
47 this.own(
48 on(window, "resize", lang.hitch(this, "_positionDock")),
49 on(window, "scroll", lang.hitch(this, "_positionDock"))
50 );
51 if(has("ie")){ // TODO: All versions of IE, or pre-IE9, or some feature to test?
52 this.own(
53 on(this.domNode, "resize", lang.hitch(this, "_positionDock"))
54 );
55 }
56 }
57 this._positionDock(null);
58 this.inherited(arguments);
59
60 },
61
62 _positionDock: function(/* Event? */e){
63 if(!this._inPositioning){
64 if(this.autoPosition == "south"){
65 // Give some time for scrollbars to appear/disappear
66 this.defer(function() {
67 this._inPositiononing = true;
68 var viewport = windowLib.getBox();
69 var s = this.domNode.style;
70 s.left = viewport.l + "px";
71 s.width = (viewport.w-2) + "px";
72 s.top = (viewport.h + viewport.t) - this.domNode.offsetHeight + "px";
73 this._inPositioning = false;
74 }, 125);
75 }
76 }
77 }
78
79
80 });
81
82 var DockNode = declare("dojox.layout._DockNode",[_WidgetBase, _TemplatedMixin],{
83 // summary:
84 // dojox.layout._DockNode is a private widget used to keep track of
85 // which pane is docked.
86
87 // title: String
88 // Shown in dock icon. should read parent iconSrc?
89 title: "",
90
91 // paneRef: Widget
92 // reference to the FloatingPane we reprasent in any given dock
93 paneRef: null,
94
95 templateString:
96 '<li data-dojo-attach-event="onclick: restore" class="dojoxDockNode">'+
97 '<span data-dojo-attach-point="restoreNode" class="dojoxDockRestoreButton" data-dojo-attach-event="onclick: restore"></span>'+
98 '<span class="dojoxDockTitleNode" data-dojo-attach-point="titleNode">${title}</span>'+
99 '</li>',
100
101 restore: function(){
102 // summary:
103 // remove this dock item from parent dock, and call show() on reffed floatingpane
104 this.paneRef.show();
105 this.paneRef.bringToTop();
106 this.destroy();
107 }
108 });
109
110 return Dock;
111 });
112