/* Copyright (c) 2004-2006, The Dojo Foundation All Rights Reserved. Licensed under the Academic Free License version 2.1 or above OR the modified BSD license. For more information on Dojo licensing, see: http://dojotoolkit.org/community/licensing.shtml */ dojo.provide("dojo.widget.SplitContainer"); dojo.provide("dojo.widget.SplitContainerPanel"); dojo.provide("dojo.widget.html.SplitContainer"); dojo.provide("dojo.widget.html.SplitContainerPanel"); // // TODO // make it prettier // active dragging upwards doesn't always shift other bars (direction calculation is wrong in this case) // dojo.require("dojo.widget.*"); dojo.require("dojo.widget.LayoutContainer"); dojo.require("dojo.widget.HtmlWidget"); dojo.require("dojo.html"); dojo.require("dojo.style"); dojo.require("dojo.dom"); dojo.require("dojo.io"); // workaround dojo bug. dojo.io.cookie requires dojo.io but it still doesn't get pulled in dojo.require("dojo.io.cookie"); dojo.widget.html.SplitContainer = function(){ dojo.widget.HtmlWidget.call(this); this.sizers = []; } dojo.inherits(dojo.widget.html.SplitContainer, dojo.widget.HtmlWidget); dojo.lang.extend(dojo.widget.html.SplitContainer, { widgetType: "SplitContainer", isContainer: true, virtualSizer: null, isHorizontal: 0, paneBefore: null, paneAfter: null, isSizing: false, dragOffset: null, startPoint: null, lastPoint: null, sizingSplitter: null, isActiveResize: 0, offsetX: 0, offsetY: 0, isDraggingLeft: 0, templateCssPath: dojo.uri.dojoUri("src/widget/templates/HtmlSplitContainer.css"), originPos: null, persist: true, // save splitter positions in a cookie activeSizing: '', sizerWidth: 15, orientation: 'horizontal', debugName: '', fillInTemplate: function(){ dojo.style.insertCssFile(this.templateCssPath, null, true); dojo.html.addClass(this.domNode, "dojoSplitContainer"); this.domNode.style.overflow='hidden'; // workaround firefox bug this.paneWidth = dojo.style.getContentWidth(this.domNode); this.paneHeight = dojo.style.getContentHeight(this.domNode); this.isHorizontal = (this.orientation == 'horizontal') ? 1 : 0; this.isActiveResize = (this.activeSizing == '1') ? 1 : 0; //dojo.debug("fillInTemplate for "+this.debugName); }, onResized: function(e){ this.paneWidth = dojo.style.getContentWidth(this.domNode); this.paneHeight = dojo.style.getContentHeight(this.domNode); this.layoutPanels(); }, postCreate: function(args, fragment, parentComp){ // dojo.debug("post create for "+this.debugName); // attach the children and create the draggers for(var i=0; i 0) { for(var x=0; x 1) { this._addSizer(); } this.layoutPanels(); }, layoutPanels: function(){ if (this.children.length == 0){ return; } // // calculate space // var space = this.isHorizontal ? this.paneWidth : this.paneHeight; if (this.children.length > 1){ space -= this.sizerWidth * (this.children.length - 1); } // // calculate total of SizeShare values // var out_of = 0; for(var i=0; i 0){ if (pane.sizeActual > pane.sizeMin){ if ((pane.sizeActual - pane.sizeMin) > growth){ // stick all the growth in this pane pane.sizeActual = pane.sizeActual - growth; growth = 0; }else{ // put as much growth in here as we can growth -= pane.sizeActual - pane.sizeMin; pane.sizeActual = pane.sizeMin; } } } return growth; }, checkSizes: function(){ var total_min_size = 0; var total_size = 0; for(var i=0; i 0){ if (this.isDraggingLeft){ for(var i=this.children.length-1; i>=0; i--){ growth = this.growPane(growth, this.children[i]); } }else{ for(var i=0; i 0) ? 1 : 0; if (!this.isActiveResize){ if (a < this.paneBefore.position + this.paneBefore.sizeMin){ a = this.paneBefore.position + this.paneBefore.sizeMin; } if (a > this.paneAfter.position + (this.paneAfter.sizeActual - (this.sizerWidth + this.paneAfter.sizeMin))){ a = this.paneAfter.position + (this.paneAfter.sizeActual - (this.sizerWidth + this.paneAfter.sizeMin)); } } a -= this.sizingSplitter.position; this.checkSizes(); return a; }, updateSize: function(){ var p = this.clientToScreen(this.lastPoint); var p = this.screenToClient(this.lastPoint); var pos = this.isHorizontal ? p.x - (this.dragOffset.x + this.originPos.x) : p.y - (this.dragOffset.y + this.originPos.y); var start_region = this.paneBefore.position; var end_region = this.paneAfter.position + this.paneAfter.sizeActual; this.paneBefore.sizeActual = pos - start_region; this.paneAfter.position = pos + this.sizerWidth; this.paneAfter.sizeActual = end_region - this.paneAfter.position; for(var i=0; i