Skip to content

Commit

Permalink
Allow for merging of options within the containers
Browse files Browse the repository at this point in the history
This means I can push common config into all the containers without the
individual container implementations requiring knowledge of these
specific config options!
  • Loading branch information
ciaranj committed Oct 2, 2009
1 parent 75dd72f commit 2640da7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 49 deletions.
37 changes: 14 additions & 23 deletions js/Container.js
Expand Up @@ -97,6 +97,7 @@ WireIt.Container = function(options, layer) {

};


WireIt.Container.prototype = {

/**
Expand Down Expand Up @@ -127,29 +128,19 @@ WireIt.Container.prototype = {
* @property options
* @type {Object}
*/
this.options = {};
this.options.terminals = options.terminals || [];
this.options.draggable = (typeof options.draggable == "undefined") ? true : options.draggable ;
this.options.position = options.position || [100,100];
this.options.className = options.className || CSS_PREFIX+'Container';

this.options.ddHandle = (typeof options.ddHandle == "undefined") ? true : options.ddHandle;
this.options.ddHandleClassName = options.ddHandleClassName || CSS_PREFIX+"Container-ddhandle";

this.options.resizable = (typeof options.resizable == "undefined") ? true : options.resizable;
this.options.resizeHandleClassName = options.resizeHandleClassName || CSS_PREFIX+"Container-resizehandle";

this.options.width = options.width; // no default
this.options.height = options.height;

this.options.close = (typeof options.close == "undefined") ? true : options.close;
this.options.closeButtonClassName = options.closeButtonClassName || CSS_PREFIX+"Container-closebutton";

this.options.title = options.title; // no default

this.options.icon = options.icon;

this.options.preventSelfWiring = (typeof options.preventSelfWiring == "undefined") ? true : options.preventSelfWiring;
this.options= YAHOO.lang.merge({
terminals: [],
draggable: true,
position: [100,100],
className: CSS_PREFIX+"Container",
ddHandle: true,
ddHandleClassName: CSS_PREFIX+"Container-ddhandle",
resizable: true,
resizeHandleClassName: CSS_PREFIX+"Container-resizehandle",
close: true,
closeButtonClassName: CSS_PREFIX+"Container-closebutton",
preventSelfWiring:true
}, options);
},

/**
Expand Down
18 changes: 7 additions & 11 deletions js/ImageContainer.js
Expand Up @@ -11,22 +11,18 @@ WireIt.ImageContainer = function(options, layer) {
};

YAHOO.lang.extend(WireIt.ImageContainer, WireIt.Container, {

/**
* @method setOptions
* @param {Object} options the options object
*/
setOptions: function(options) {
WireIt.ImageContainer.superclass.setOptions.call(this, options);

this.options.image = options.image;
this.options.xtype = "WireIt.ImageContainer";

this.options.className = options.className || "WireIt-Container WireIt-ImageContainer";

// Overwrite default value for options:
this.options.resizable = (typeof options.resizable == "undefined") ? false : options.resizable;
this.options.ddHandle = (typeof options.ddHandle == "undefined") ? false : options.ddHandle;

WireIt.ImageContainer.superclass.setOptions.call(this, YAHOO.lang.merge( {
resizable: false,
ddHandle: false,
className: "WireIt-Container WireIt-ImageContainer"
}, options));
this.options.xtype = "WireIt.ImageContainer"; //don't allow overriding.
},

/**
Expand Down
16 changes: 6 additions & 10 deletions js/InOutContainer.js
Expand Up @@ -17,18 +17,14 @@ YAHOO.lang.extend(WireIt.InOutContainer, WireIt.Container, {
* @param {Object} options the options object
*/
setOptions: function(options) {
WireIt.InOutContainer.superclass.setOptions.call(this, options);
WireIt.InOutContainer.superclass.setOptions.call(this, YAHOO.lang.merge( {
resizable: false,
className: "WireIt-Container WireIt-InOutContainer",
inputs: [],
outputs: []
}, options));

this.options.xtype = "WireIt.InOutContainer";

this.options.className = options.className || "WireIt-Container WireIt-InOutContainer";

// Overwrite default value for options:
this.options.resizable = (typeof options.resizable == "undefined") ? false : options.resizable;

this.options.inputs = options.inputs || [];
this.options.outputs = options.outputs || [];

},

render: function() {
Expand Down
6 changes: 1 addition & 5 deletions js/util/inputex/FormContainer-beta.js
Expand Up @@ -12,16 +12,12 @@ WireIt.FormContainer = function(options, layer) {
};

YAHOO.lang.extend(WireIt.FormContainer, WireIt.Container, {

/**
* @method setOptions
*/
setOptions: function(options) {
WireIt.FormContainer.superclass.setOptions.call(this, options);

this.options.legend = options.legend;
this.options.collapsible = options.collapsible;
this.options.fields = options.fields;
},

/**
Expand Down

0 comments on commit 2640da7

Please sign in to comment.