Skip to content

Instantly share code, notes, and snippets.

@ghinch
Created October 9, 2010 19:20
Show Gist options
  • Save ghinch/618508 to your computer and use it in GitHub Desktop.
Save ghinch/618508 to your computer and use it in GitHub Desktop.
function WidgetParentStdMod () {
Y.before(this._initParentStdMod, this, 'renderUI');
Y.before(function () {
console.log('halt?');
return new Y.Do.Halt('ParentStdMod halted this');
}, this, '_renderChildren');
Y.after(this._renderChildrenAfterSync, this, 'syncUI');
}
WidgetParentStdMod.ATTRS = {
childrenContainer : {
value : Y.WidgetStdMod.BODY
}
};
WidgetParentStdMod.prototype = {
_initParentStdMod : function () {
var c = this.get('childrenContainer'),
renderTo;
if (c == Y.WidgetStdMod.BODY) {
renderTo = this.bodyNode;
} else if (c == Y.WidgetStdMod.HEADER) {
renderTo = this.headerNode;
} else if (c == Y.WidgetStdMod.FOOTER) {
renderTo = this.footerNode;
}
this._childrenContainer = renderTo || this.get('contentBox');
},
_renderChildrenAfterSync : function () {
this.each(Y.bind(function (child) {
child.render(this._childrenContainer);
}, this));
}
};
var Container = Y.Base.create('container', Y.Widget, [Y.WidgetStdMod, Y.WidgetParent, WidgetParentStdMod]);
var ChildContainer = Y.Base.create('child-container', Y.Widget, [Y.WidgetStdMod, Y.WidgetChild]);
var myContainer = new Container({
defaultChildType : ChildContainer,
children : [
{width: 400, height: 400, headerContent : "foo", bodyContent : 'bar', footerContent : 'baz', fillHeight : Y.WidgetStdMod.BODY},
],
width: 800,
height : 600,
boundingBox : '#contents',
headerContent : 'header',
bodyContent : 'foo',
footerContent: 'footer',
fillHeight : Y.WidgetStdMod.BODY,
render : true
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment