mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-05 05:29:13 +01:00
Save splitter preferd size base on percentage instead of pixel, because user may switch between different screen with different resolution
This commit is contained in:
parent
9c23cb33f4
commit
7d7430c0a6
@ -183,12 +183,48 @@ var et2_split = et2_DOMWidget.extend([et2_IResizeable,et2_IPrint],
|
|||||||
sizeLeft: this.dynheight.outerNode.width() / 2
|
sizeLeft: this.dynheight.outerNode.width() / 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var widget = this;
|
||||||
|
//Convert percent size to pixel
|
||||||
|
var per2pix = function(_size)
|
||||||
|
{
|
||||||
|
var size = _size.replace("%",'');
|
||||||
|
if (widget.orientation == "v")
|
||||||
|
{
|
||||||
|
return size * widget.dynheight.outerNode.width() / 100;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return size * widget.dynheight.outerNode.height() / 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Convert pixel size to percent
|
||||||
|
var pix2per = function (_size)
|
||||||
|
{
|
||||||
|
if (widget.orientation == "v")
|
||||||
|
{
|
||||||
|
return _size * 100 / widget.dynheight.outerNode.width() + '%';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return _size * 100 / widget.dynheight.outerNode.height() + '%';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check for position preference, load it in
|
// Check for position preference, load it in
|
||||||
if(this.id)
|
if(this.id)
|
||||||
{
|
{
|
||||||
var pref = this.egw().preference('splitter-size-' + this.id, this.egw().getAppName());
|
var pref = this.egw().preference('splitter-size-' + this.id, this.egw().getAppName());
|
||||||
if(pref)
|
if(pref)
|
||||||
{
|
{
|
||||||
|
// TODO:This condition can be removed for the next release
|
||||||
|
// because this is a correction data and supposely all new prefs size
|
||||||
|
// are all in percent
|
||||||
|
if (pref[Object.keys(pref)].toString().match(/%/g))
|
||||||
|
{
|
||||||
|
pref [Object.keys(pref)] = per2pix(pref [Object.keys(pref)]);
|
||||||
|
}
|
||||||
|
|
||||||
if(this.orientation == "v" && pref['sizeLeft'] < this.dynheight.outerNode.width() ||
|
if(this.orientation == "v" && pref['sizeLeft'] < this.dynheight.outerNode.width() ||
|
||||||
this.orientation == "h" && pref['sizeTop'] < this.dynheight.outerNode.height())
|
this.orientation == "h" && pref['sizeTop'] < this.dynheight.outerNode.height())
|
||||||
{
|
{
|
||||||
@ -256,7 +292,8 @@ var et2_split = et2_DOMWidget.extend([et2_IResizeable,et2_IPrint],
|
|||||||
// Store current position in preferences
|
// Store current position in preferences
|
||||||
var size = self.orientation == "v" ? {sizeLeft: self.left.width()} : {sizeTop: self.left.height()};
|
var size = self.orientation == "v" ? {sizeLeft: self.left.width()} : {sizeTop: self.left.height()};
|
||||||
self.prefSize = size[this.orientation == "v" ?'sizeLeft' : 'sizeTop'];
|
self.prefSize = size[this.orientation == "v" ?'sizeLeft' : 'sizeTop'];
|
||||||
self.egw().set_preference(self.egw().getAppName(), 'splitter-size-' + self.id, size);
|
var prefInPercent = self.orientation == "v" ?{sizeLeft:pix2per(size.sizeLeft)}:{sizeTop:pix2per(size.sizeTop)};
|
||||||
|
self.egw().set_preference(self.egw().getAppName(), 'splitter-size-' + self.id, prefInPercent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ok, update children
|
// Ok, update children
|
||||||
|
Loading…
Reference in New Issue
Block a user