Choleriker
30 Dec 2006, 9:05 AM
Hi,
i wanted to support the user with a help button like this:
http://tecbehind.de/useruploads/choleriker/LayoutRegionHack.jpg
So i have started to look jacks code how to do. Its very simple, so i have extended the LayoutRegion class:
YAHOO.ext.LayoutRegion.prototype.createToolButton = function(cls, fn, scope) {
var _btn = this.createTool(this.tools.dom, cls);
_btn.enableDisplayMode();
_btn.on('click', fn, scope, true);
return _btn;
};
Its based on a private method of the LayoutRegion createTool. If you want to try it, simple add a css class to your code:
.ylayout-help{
background-image:url('images/help.gif');
}
Save this image to your project: http://tecbehind.de/useruploads/choleriker/help.gif
And try this code, which, for simplicity, only alerts 'Jo!' after clicking the button.
var _region = LAY.getRegion('west');
_region.helpButton = _region.createToolButton('ylayout-help', function() {alert('Jo!');}, window);
Keep in mind that my layout-object is named LAY and i added the button to the west region, take another one if you dont have a west region.
The createToolButton returns the newly created button. If you switch between panels in the related region, the newly created button is always visible. If you dont want this, simply bind activate and deactivate events on the panels and call show() or hide() on the newly created button!
i wanted to support the user with a help button like this:
http://tecbehind.de/useruploads/choleriker/LayoutRegionHack.jpg
So i have started to look jacks code how to do. Its very simple, so i have extended the LayoutRegion class:
YAHOO.ext.LayoutRegion.prototype.createToolButton = function(cls, fn, scope) {
var _btn = this.createTool(this.tools.dom, cls);
_btn.enableDisplayMode();
_btn.on('click', fn, scope, true);
return _btn;
};
Its based on a private method of the LayoutRegion createTool. If you want to try it, simple add a css class to your code:
.ylayout-help{
background-image:url('images/help.gif');
}
Save this image to your project: http://tecbehind.de/useruploads/choleriker/help.gif
And try this code, which, for simplicity, only alerts 'Jo!' after clicking the button.
var _region = LAY.getRegion('west');
_region.helpButton = _region.createToolButton('ylayout-help', function() {alert('Jo!');}, window);
Keep in mind that my layout-object is named LAY and i added the button to the west region, take another one if you dont have a west region.
The createToolButton returns the newly created button. If you switch between panels in the related region, the newly created button is always visible. If you dont want this, simply bind activate and deactivate events on the panels and call show() or hide() on the newly created button!