Skip to content

Instantly share code, notes, and snippets.

@ericf
Created February 2, 2011 20:58
Show Gist options
  • Select an option

  • Save ericf/808422 to your computer and use it in GitHub Desktop.

Select an option

Save ericf/808422 to your computer and use it in GitHub Desktop.
showView : function (newViewClass, prevViewClass) {
var content = Y.one('#content'),
newViewName = newViewClass.NS,
prevViewName = prevViewClass ? prevViewClass.NS : null,
tmp, viewContent;
this.plug(newViewClass, { after: {
contentChange : function(e){
tmp = Y.Markout('body').div().node().hide().append(e.newVal);
}
}});
viewContent = tmp ? tmp.get('children') : this[newViewName].get('content');
function transToNewView () {
content.get('children').remove().destroy(true);
content.removeClass(prevViewName).addClass(newViewName);
content.setContent(viewContent).transition('viewIn');
if (tmp) {
tmp.remove().destroy(true);
}
}
if (prevViewClass) {
content.transition('viewOut', Y.bind(function(){
this.unplug(prevViewClass);
transToNewView();
}, this));
} else {
transToNewView();
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment