One way to do it would be like this:
SGP.panel.ModalRounded = function(title,oConfig) {
SGP.panel.ModalRounded.superclass.constructor.call(
this,
'sgp_panel_modal',
{
width:oConfig.width || "600px",
fixedcenter: oConfig.fixedcenter !== false,
And so on for the rest. You set the panel with the option coming from
the extra argument oConfig and if there is none (undefined hence false)
it will take your default. With fixedcenter you have to do it in
another way since false is a valid setting so you set it to true if
fixedcenter is anything but exactly false.
Satyam
stuplum wrote:
> Hi All,
>
> I'm trying to build my own versions of Panels, that I can re-use (as
> much for practice than actual pratical reasons at the moment).
>
> I've got this code so far:
>
> In a Global JS file:
>
> var Dom = YAHOO.util.Dom, Event = YAHOO.util.Event, Panel =
> YAHOO.widget.Panel;
> var BASE_IMG_MEDIA_URL = 'Content/Images';
>
> /*
> Set up some global SGP panels
> */
> // create SGP.panel namespace
> .namespace(["pa nel"]);
>
> // Modal Panel with title.
> SGP.panel.ModalRounded = function(title) {
>
> SGP.panel.ModalRounded.superclass.constructor.call(
> this,
> 'sgp_panel_modal',
> {
> width: "600px",
> fixedcenter: true,
> constraintoviewport: false,
> underlay: "none",
> modal: true,
> close: true,
> visible: false,
> draggable: true
> }
> ; );
>
> this.setHeader('<div class="tl"></div><span>' + title +
> '</span><div class="tr"></div>');
> this.setBody('<img class="panel-waiting" src="' +
> BASE_IMG_MEDIA_URL + '/trans.gif" alt="waiting..." />');
> this.setFooter('<div class="bl"></div><span
> class="button-group"><a id="sgp_panel_modal_cancel" href="javascript:
> void(0)">cancel</a> | <button
> id="sgp_panel_modal_save">Save</button></span><div class="br"></div>');
> this.render(document.body);
> };
> if(Panel) {
> YAHOO.lang.extend(SGP.panel.ModalRounded, Panel);
> };
>
> In a Page specific JS file:
>
> ...
>
> open_preview: function(ev) {
> var _onlinePreviewPanel;
> if (!_onlinePreviewPanel) {
> _onlinePreviewPanel = new
> LOOT.panel.ModalRounded(this.config.modal_box_title,
> {
> width: '900px'
> }
> );
> };
> // set body to what html were after
> _onlinePreviewPanel.setBody(this.html);
> _onlinePreviewPanel.cfg.setProperty("width", "900px", true);
> // show th e modal box
> _onlinePreviewPanel.show();
> }
>
> ...
>
>
> As you can see, I extend the YAHOO panel to my own setting default
> properties, however I want to be able to overide these properties. The
> 'open_preview' function tries to overide the width property, in 2
> ways, both don't work, what am I missing.
>
> Regards
>
> Stuart
>
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - http://www.avg.com
> Version: 8.0.173 / Virus Database: 270.7.6/1709 - Release Date: 05/10/2008
9:20
>
>