+/*
+
+This file is part of Ext JS 4
+
+Copyright (c) 2011 Sencha Inc
+
+Contact: http://www.sencha.com/contact
+
+GNU General Public License Usage
+This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
+
+If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
+
+*/
/**
* @class Ext.resizer.SplitterTracker
* @extends Ext.dd.DragTracker
extend: 'Ext.dd.DragTracker',
requires: ['Ext.util.Region'],
enabled: true,
+
+ overlayCls: Ext.baseCSSPrefix + 'resizable-overlay',
getPrevCmp: function() {
var splitter = this.getSplitter();
// ensure the tracker is enabled, store boxes of previous and next
// components and calculate the constrain region
onBeforeStart: function(e) {
- var prevCmp = this.getPrevCmp(),
- nextCmp = this.getNextCmp();
+ var me = this,
+ prevCmp = me.getPrevCmp(),
+ nextCmp = me.getNextCmp(),
+ collapseEl = me.getSplitter().collapseEl,
+ overlay;
+
+ if (collapseEl && (e.getTarget() === me.getSplitter().collapseEl.dom)) {
+ return false;
+ }
// SplitterTracker is disabled if any of its adjacents are collapsed.
if (nextCmp.collapsed || prevCmp.collapsed) {
return false;
}
+
+ overlay = me.overlay = Ext.getBody().createChild({
+ cls: me.overlayCls,
+ html: ' '
+ });
+ overlay.unselectable();
+ overlay.setSize(Ext.Element.getViewWidth(true), Ext.Element.getViewHeight(true));
+ overlay.show();
+
// store boxes of previous and next
- this.prevBox = prevCmp.getEl().getBox();
- this.nextBox = nextCmp.getEl().getBox();
- this.constrainTo = this.calculateConstrainRegion();
+ me.prevBox = prevCmp.getEl().getBox();
+ me.nextBox = nextCmp.getEl().getBox();
+ me.constrainTo = me.calculateConstrainRegion();
},
// We move the splitter el. Add the proxy class.
// calculate the constrain Region in which the splitter el may be moved.
calculateConstrainRegion: function() {
- var splitter = this.getSplitter(),
- topPad = 0,
- bottomPad = 0,
+ var me = this,
+ splitter = me.getSplitter(),
splitWidth = splitter.getWidth(),
defaultMin = splitter.defaultSplitMin,
orient = splitter.orientation,
- prevBox = this.prevBox,
- prevCmp = this.getPrevCmp(),
- nextBox = this.nextBox,
- nextCmp = this.getNextCmp(),
+ prevBox = me.prevBox,
+ prevCmp = me.getPrevCmp(),
+ nextBox = me.nextBox,
+ nextCmp = me.getNextCmp(),
// prev and nextConstrainRegions are the maximumBoxes minus the
// minimumBoxes. The result is always the intersection
// of these two boxes.
}
// intersection of the two regions to provide region draggable
- return prevConstrainRegion.intersect(nextConstrainRegion);
+ return prevConstrainRegion.intersect(nextConstrainRegion);
},
// Performs the actual resizing of the previous and next components
performResize: function(e) {
- var offset = this.getOffset('dragTarget'),
- splitter = this.getSplitter(),
+ var me = this,
+ offset = me.getOffset('dragTarget'),
+ splitter = me.getSplitter(),
orient = splitter.orientation,
- prevCmp = this.getPrevCmp(),
- nextCmp = this.getNextCmp(),
+ prevCmp = me.getPrevCmp(),
+ nextCmp = me.getNextCmp(),
owner = splitter.ownerCt,
layout = owner.getLayout();
if (prevCmp) {
if (!prevCmp.maintainFlex) {
delete prevCmp.flex;
- prevCmp.setSize(this.prevBox.width + offset[0], prevCmp.getHeight());
+ prevCmp.setSize(me.prevBox.width + offset[0], prevCmp.getHeight());
}
}
if (nextCmp) {
if (!nextCmp.maintainFlex) {
delete nextCmp.flex;
- nextCmp.setSize(this.nextBox.width - offset[0], nextCmp.getHeight());
+ nextCmp.setSize(me.nextBox.width - offset[0], nextCmp.getHeight());
}
}
// verticals
if (prevCmp) {
if (!prevCmp.maintainFlex) {
delete prevCmp.flex;
- prevCmp.setSize(prevCmp.getWidth(), this.prevBox.height + offset[1]);
+ prevCmp.setSize(prevCmp.getWidth(), me.prevBox.height + offset[1]);
}
}
if (nextCmp) {
if (!nextCmp.maintainFlex) {
delete nextCmp.flex;
- nextCmp.setSize(prevCmp.getWidth(), this.nextBox.height - offset[1]);
+ nextCmp.setSize(prevCmp.getWidth(), me.nextBox.height - offset[1]);
}
}
}
layout.onLayout();
},
+ // Cleans up the overlay (if we have one) and calls the base. This cannot be done in
+ // onEnd, because onEnd is only called if a drag is detected but the overlay is created
+ // regardless (by onBeforeStart).
+ endDrag: function () {
+ var me = this;
+
+ if (me.overlay) {
+ me.overlay.remove();
+ delete me.overlay;
+ }
+
+ me.callParent(arguments); // this calls onEnd
+ },
+
// perform the resize and remove the proxy class from the splitter el
onEnd: function(e) {
- var splitter = this.getSplitter();
+ var me = this,
+ splitter = me.getSplitter();
+
splitter.removeCls(splitter.baseCls + '-active');
- this.performResize();
+ me.performResize();
},
// Track the proxy and set the proper XY coordinates
// while constraining the drag
onDrag: function(e) {
- var offset = this.getOffset('dragTarget'),
- splitter = this.getSplitter(),
+ var me = this,
+ offset = me.getOffset('dragTarget'),
+ splitter = me.getSplitter(),
splitEl = splitter.getEl(),
orient = splitter.orientation;
if (orient === "vertical") {
- splitEl.setX(this.startRegion.left + offset[0]);
+ splitEl.setX(me.startRegion.left + offset[0]);
} else {
- splitEl.setY(this.startRegion.top + offset[1]);
+ splitEl.setY(me.startRegion.top + offset[1]);
}
},
getSplitter: function() {
return Ext.getCmp(this.getDragCt().id);
}
-});
\ No newline at end of file
+});