add (but do not enable) reset-size-on-doubleclick for split panel elements
This commit is contained in:
parent
43495de239
commit
771b15c25a
2 changed files with 38 additions and 4 deletions
|
@ -36,6 +36,8 @@ Ox.Resizebar = function(options, self) {
|
||||||
.options(options || {}) // fixme: options function should be able to handle undefined, no need for || {}
|
.options(options || {}) // fixme: options function should be able to handle undefined, no need for || {}
|
||||||
.addClass('OxResizebar Ox' + Ox.toTitleCase(self.options.orientation))
|
.addClass('OxResizebar Ox' + Ox.toTitleCase(self.options.orientation))
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
|
// singleclick: toggle,
|
||||||
|
// doubleclick: reset,
|
||||||
anyclick: toggle,
|
anyclick: toggle,
|
||||||
dragstart: dragstart,
|
dragstart: dragstart,
|
||||||
drag: drag,
|
drag: drag,
|
||||||
|
@ -149,9 +151,19 @@ Ox.Resizebar = function(options, self) {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reset() {
|
||||||
|
if (self.options.resizable && !self.options.collapsed) {
|
||||||
|
// fixme: silly, pass an option
|
||||||
|
self.options.parent.reset(
|
||||||
|
self.isLeftOrTop ? 0
|
||||||
|
: self.options.parent.options('elements').length - 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function toggle() {
|
function toggle() {
|
||||||
if (self.options.collapsible) {
|
if (self.options.collapsible) {
|
||||||
// fixme: silly, pass a parameter
|
// fixme: silly, pass an option
|
||||||
self.options.parent.toggle(
|
self.options.parent.toggle(
|
||||||
self.isLeftOrTop ? 0
|
self.isLeftOrTop ? 0
|
||||||
: self.options.parent.options('elements').length - 1
|
: self.options.parent.options('elements').length - 1
|
||||||
|
|
|
@ -40,6 +40,10 @@ Ox.SplitPanel = function(options, self) {
|
||||||
Ox.extend(self, {
|
Ox.extend(self, {
|
||||||
dimensions: Ox.UI.DIMENSIONS[self.options.orientation],
|
dimensions: Ox.UI.DIMENSIONS[self.options.orientation],
|
||||||
edges: Ox.UI.EDGES[self.options.orientation],
|
edges: Ox.UI.EDGES[self.options.orientation],
|
||||||
|
defaultSize: self.options.elements.map(function(element) {
|
||||||
|
return !Ox.isUndefined(element.defaultSize)
|
||||||
|
? element.defaultSize : element.size;
|
||||||
|
}),
|
||||||
length: self.options.elements.length,
|
length: self.options.elements.length,
|
||||||
resizebarElements: [],
|
resizebarElements: [],
|
||||||
$resizebars: []
|
$resizebars: []
|
||||||
|
@ -58,12 +62,10 @@ Ox.SplitPanel = function(options, self) {
|
||||||
that.$elements[i] = element.element
|
that.$elements[i] = element.element
|
||||||
.css(self.edges[2], (parseInt(element.element.css(self.edges[2])) || 0) + 'px')
|
.css(self.edges[2], (parseInt(element.element.css(self.edges[2])) || 0) + 'px')
|
||||||
.css(self.edges[3], (parseInt(element.element.css(self.edges[3])) || 0) + 'px');
|
.css(self.edges[3], (parseInt(element.element.css(self.edges[3])) || 0) + 'px');
|
||||||
//alert(v.element.css(self.edges[3]))
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// create resizebars
|
// create resizebars
|
||||||
self.options.elements.forEach(function(element, i) {
|
self.options.elements.forEach(function(element, i) {
|
||||||
//that.append(element)
|
|
||||||
var index = i == 0 ? 0 : 1;
|
var index = i == 0 ? 0 : 1;
|
||||||
that.$elements[i].appendTo(that.$element); // fixme: that.$content
|
that.$elements[i].appendTo(that.$element); // fixme: that.$content
|
||||||
if (element.collapsible || element.resizable) {
|
if (element.collapsible || element.resizable) {
|
||||||
|
@ -117,6 +119,7 @@ Ox.SplitPanel = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setSizes(init, animate) {
|
function setSizes(init, animate) {
|
||||||
|
// will animate if animate is truthy, and call animate if its a function
|
||||||
self.options.elements.forEach(function(element, i) {
|
self.options.elements.forEach(function(element, i) {
|
||||||
// fixme: maybe we can add a conditional here, since init
|
// fixme: maybe we can add a conditional here, since init
|
||||||
// is about elements that are collapsed splitpanels
|
// is about elements that are collapsed splitpanels
|
||||||
|
@ -255,6 +258,25 @@ Ox.SplitPanel = function(options, self) {
|
||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*@
|
||||||
|
reset <f> Reset an outer element to its initial size
|
||||||
|
@*/
|
||||||
|
that.reset = function(id) {
|
||||||
|
// one can pass pos instead of id
|
||||||
|
var pos = Ox.isNumber(id) ? id : getPositionById(id),
|
||||||
|
element = self.options.elements[pos];
|
||||||
|
element.size = self.defaultSize[pos];
|
||||||
|
setSizes(false, function() {
|
||||||
|
element.element.triggerEvent('resize', {
|
||||||
|
size: element.size
|
||||||
|
});
|
||||||
|
element = self.options.elements[pos == 0 ? 1 : pos - 1];
|
||||||
|
element.element.triggerEvent('resize', {
|
||||||
|
size: element.element[self.dimensions[0]]()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
/*@
|
/*@
|
||||||
size <f> Get or set size of an element
|
size <f> Get or set size of an element
|
||||||
(id) -> <i> Returns size
|
(id) -> <i> Returns size
|
||||||
|
@ -295,7 +317,7 @@ Ox.SplitPanel = function(options, self) {
|
||||||
that.animate(animate, 250, function() {
|
that.animate(animate, 250, function() {
|
||||||
element.collapsed = !element.collapsed;
|
element.collapsed = !element.collapsed;
|
||||||
element.element.triggerEvent('toggle', {
|
element.element.triggerEvent('toggle', {
|
||||||
'collapsed': element.collapsed
|
collapsed: element.collapsed
|
||||||
});
|
});
|
||||||
self.$resizebars[pos == 0 ? 0 : 1].options({collapsed: element.collapsed});
|
self.$resizebars[pos == 0 ? 0 : 1].options({collapsed: element.collapsed});
|
||||||
element = self.options.elements[pos == 0 ? 1 : pos - 1];
|
element = self.options.elements[pos == 0 ? 1 : pos - 1];
|
||||||
|
|
Loading…
Reference in a new issue