Skip to content

Instantly share code, notes, and snippets.

@zbabtkis
Created July 16, 2013 15:17
Show Gist options
  • Save zbabtkis/6009675 to your computer and use it in GitHub Desktop.
Save zbabtkis/6009675 to your computer and use it in GitHub Desktop.
Your extremely controlling mother in code.
var Bani = (function() {
var types = {
'View': {
cool: 'hi',
age: new Date()
}
};
function extend(name, type, obj) {
var extension = function() {};
for(var key in types[type]) {
extension.prototype[key] = types[type][key];
}
for(var key in obj) {
extension.prototype[key] = obj[key];
}
types[name] = extension;
}
function get(name) {
var obj = new types[name]();
if(obj.initialize) obj.initialize.apply(obj);
return obj;
}
return {
get: get,
extend: extend
};
}());
Banni.extend('SubView', 'View', {
el: '#main-view',
initialize: function() {
this.$el = $(this.el);
console.log(this)
}
});
var building = Bldr.get('SubView');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment