PDA

View Full Version : universal cookie function for splitter's move



kuzynpiy
22 Oct 2006, 11:49 AM
Hello
I use sth like this:

layout.getRegion('north').split.onMoved.subscribe(setSplitterCookie);
where setSplitterCookieSouth is function writing the position of splitter into cookie. And the setSplitterCookie function takes two arguments:

function setSplitterCookie(pSplitbar, pNewSize){
Cookies.set('north', pNewSize);
}
I'd like to write universal setSplitterCookie function but do not know how to get information about pSplitbar. Has anybody an idea of getting parameters from pSplitbar - the layout and the region ?

Peter

jack.slocum
22 Oct 2006, 12:20 PM
There's an event on BorderLayout: regionresized. This way you don't have to subscribe to the splitter directly.



var layout = .... // make your BorderLayout

function setSplitterCookie(region, pNewSize){
Cookies.set(region.position, pNewSize);
}

layout.on('regionresized', setSplitterCookie);

kuzynpiy
23 Oct 2006, 12:03 AM
Hello,
Thank You once again for Your help. Can I find somewhere all this functions and events (like regionresized for example), cause http://www.jackslocum.com/docs/ doesn't mention about it ?

And I would be gratefult to You for telling me if it's possible to get layout variable declare inside 'Example' function from outside this function:

function myFun() {
// how to get layout variable from Example ? Is't possible ?
};

Example = function(){
var layout;

return {
init : function(){
....
Peter

jack.slocum
23 Oct 2006, 1:40 PM
The code is not officially part of the release yet and is undocumented. Before it's released it will be fully documented.

In the return {} block of Example, define a function getLayout() and return the variable.



function myFun() {
var layout = Example.getLayout();
};

Example = function(){
var layout;

return {
init : function(){...},
getLayout : function(){
return layout;
}
}
}

kuzynpiy
28 Oct 2006, 12:02 PM
Hey,

The function You have written works great. Thank You.

function setSplitterCookie(region, pNewSize){
Cookies.set(region.position, pNewSize);
}
layout.on('regionresized', setSplitterCookie);
But how to recognize to which layout the region belong if I have many layouts (and BorderLayout)with 'west' region (for example) ?

Peter

jack.slocum
28 Oct 2006, 2:22 PM
Have you looked at the latest BorderLayout post? It will handle all this for you automatically.