frameworks/uki/src/uki-view/view/splitPane.js in uki-1.0.1 vs frameworks/uki/src/uki-view/view/splitPane.js in uki-1.0.2
- old
+ new
@@ -1,9 +1,7 @@
uki.view.declare('uki.view.HSplitPane', uki.view.Container, function(Base) {
- var proto = this;
-
- proto._setup = function() {
+ this._setup = function() {
Base._setup.call(this);
this._originalRect = this._rect;
uki.extend(this, {
_vertical: false,
_handlePosition: 200,
@@ -18,17 +16,17 @@
};
/**
* @fires event:handleMove
*/
- proto.handlePosition = uki.newProp('_handlePosition', function(val) {
+ this.handlePosition = uki.newProp('_handlePosition', function(val) {
this._handlePosition = this._normalizePosition(val);
this.trigger('handleMove', {source: this, handlePosition: this._handlePosition, dragValue: val });
this._resizeChildViews();
});
- proto.handleWidth = uki.newProp('_handleWidth', function(val) {
+ this.handleWidth = uki.newProp('_handleWidth', function(val) {
if (this._handleWidth != val) {
this._handleWidth = val;
var handle = this._createHandle();
this._dom.insertBefore(handle, this._handle);
this._removeHandle();
@@ -36,30 +34,30 @@
this._resizeChildViews();
}
});
- proto._normalizePosition = function(val) {
+ this._normalizePosition = function(val) {
var prop = this._vertical ? 'height' : 'width';
return MAX(
this._leftMin,
MIN(
this._rect[prop] - this._rightMin - this._handleWidth,
MAX(0, MIN(this._rect ? this._rect[prop] : 1000, val * 1))
));
};
- uki.addProps(proto, ['leftMin', 'rightMin', 'autogrowLeft', 'autogrowRight']);
- proto.topMin = proto.leftMin;
- proto.bottomMin = proto.rightMin;
+ uki.addProps(this, ['leftMin', 'rightMin', 'autogrowLeft', 'autogrowRight']);
+ this.topMin = this.leftMin;
+ this.bottomMin = this.rightMin;
- proto._removeHandle = function() {
+ this._removeHandle = function() {
this._dom.removeChild(this._handle);
};
- proto._createHandle = function() {
+ this._createHandle = function() {
var handle;
if (this._vertical) {
handle = uki.theme.dom('splitPane-vertical', {handleWidth: this._handleWidth});
handle.style.top = this._handlePosition + PX;
} else {
@@ -72,11 +70,11 @@
}, this);
return handle;
};
- proto._createDom = function() {
+ this._createDom = function() {
this._dom = uki.createElement('div', Base.defaultCss);
for (var i=0, paneML; i < 2; i++) {
paneML = { view: 'Container' };
paneML.anchors = i == 1 ? 'left top bottom right' :
this._vertical ? 'left top right' :
@@ -86,22 +84,22 @@
this.appendChild(this._panes[i]);
};
this._dom.appendChild(this._handle = this._createHandle());
};
- proto._normalizeRect = function(rect) {
+ this._normalizeRect = function(rect) {
rect = Base._normalizeRect.call(this, rect);
var newRect = rect.clone();
if (this._vertical) {
newRect.height = MAX(newRect.height, this._leftMin + this._rightMin); // force min width
} else {
newRect.width = MAX(newRect.width, this._leftMin + this._rightMin); // force min width
}
return newRect;
};
- proto._resizeSelf = function(newRect) {
+ this._resizeSelf = function(newRect) {
var oldRect = this._rect,
dx, prop = this._vertical ? 'height' : 'width';
if (!Base._resizeSelf.call(this, newRect)) return false;
if (this._autogrowLeft) {
dx = newRect[prop] - oldRect[prop];
@@ -117,63 +115,62 @@
}
}
return true;
};
- proto._draggesturestart = function(e) {
+ this._draggesturestart = function(e) {
var offset = uki.dom.offset(this.dom());
this._posWithinHandle = (e[this._vertical ? 'pageY' : 'pageX'] - offset[this._vertical ? 'y' : 'x']) - this._handlePosition;
return true;
};
- proto._draggesture = function(e) {
+ this._draggesture = function(e) {
var offset = uki.dom.offset(this.dom());
this.handlePosition(e[this._vertical ? 'pageY' : 'pageX'] - offset[this._vertical ? 'y' : 'x'] - this._posWithinHandle);
- e.preventDefault();
this.layout();
};
- proto._draggestureend = function(e, offset) {
+ this._draggestureend = function(e, offset) {
};
- proto.topPane = proto.leftPane = function(pane) {
+ this.topPane = this.leftPane = function(pane) {
return this._paneAt(0, pane);
};
- proto.bottomPane = proto.rightPane = function(pane) {
+ this.bottomPane = this.rightPane = function(pane) {
return this._paneAt(1, pane);
};
- proto.topChildViews = proto.leftChildViews = function(views) {
+ this.topChildViews = this.leftChildViews = function(views) {
return this._childViewsAt(0, views);
};
- proto.bottomChildViews = proto.rightChildViews = function(views) {
+ this.bottomChildViews = this.rightChildViews = function(views) {
return this._childViewsAt(1, views);
};
- proto._childViewsAt = function(i, views) {
+ this._childViewsAt = function(i, views) {
if (views === undefined) return this._panes[i].childViews();
this._panes[i].childViews(views);
return this;
};
- proto._paneAt = function(i, pane) {
+ this._paneAt = function(i, pane) {
if (pane === undefined) return this._panes[i];
uki.build.copyAttrs(this._panes[i], pane);
return this;
};
- proto._leftRect = function() {
+ this._leftRect = function() {
if (this._vertical) {
return new Rect(this._rect.width, this._handlePosition);
} else {
return new Rect(this._handlePosition, this._rect.height);
}
};
- proto._rightRect = function() {
+ this._rightRect = function() {
if (this._vertical) {
return new Rect(
0, this._handlePosition + this._handleWidth,
this._rect.width, this._rect.height - this._handleWidth - this._handlePosition
);
@@ -183,20 +180,20 @@
this._rect.width - this._handleWidth - this._handlePosition, this._rect.height
);
}
};
- proto._resizeChildViews = function() {
+ this._resizeChildViews = function() {
this._panes[0].rect(this._leftRect());
this._panes[1].rect(this._rightRect());
};
- proto._layoutDom = function(rect) {
+ this._layoutDom = function(rect) {
Base._layoutDom.call(this, rect);
this._handle.style[this._vertical ? 'top' : 'left'] = this._handlePosition + 'px';
};
- proto._bindToDom = function(name) {
+ this._bindToDom = function(name) {
if (name == 'handleMove') return true;
return Base._bindToDom.call(this, name);
};
});