Last active
August 29, 2015 14:01
-
-
Save cmilfont/ab77c54945c4b8eedb63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App = { fields: {}, field: {} }; | |
App.field.Field = function(){ | |
this.callSuper = function(args){ | |
var name = arguments.callee.caller.$name; | |
var parent = new this.parent; | |
parent[name].apply(this, args); | |
}; | |
this.render = function(json){ | |
console.log("Field", json); | |
}; | |
this.$constructor = function() { | |
var instance = this; | |
for(var name in instance) { | |
var fn = instance[name]; | |
if( typeof fn === 'function') { | |
fn.$name = name; | |
} | |
} | |
} | |
} | |
App.field.Text = (function(){ | |
var klass = function() { | |
this.$type = "textfield"; | |
this.parent = App.field.Field; | |
this.parent(); | |
this.render = function(json){ | |
console.log("Before", json.name); | |
this.callSuper(arguments); | |
console.log("After", json.name); | |
}; | |
this.$constructor(); | |
}; | |
App.fields["textfield"] = klass; | |
return klass; | |
})(); | |
field = new App.fields["textfield"](); | |
field.render({ name: "Adalto" }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment