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