Skip to content

Instantly share code, notes, and snippets.

@mattapperson
Created February 23, 2013 22:50
Show Gist options
  • Save mattapperson/5021707 to your computer and use it in GitHub Desktop.
Save mattapperson/5021707 to your computer and use it in GitHub Desktop.
// Here we have 2 examples of perposed TiKit syntax
// Example 1 (a basic window):
var TiKit = require('com.tikit');
var win = new TiKit.Window({
backgroundColor: 'red'
});
win.open();
//---------------------------
// Example 2 (a custom window):
var TiKit = require('com.tikit');
var CustomWin = TiKit.Window.extend(function(parentPrototype) { //parentPrototype var would be the TiKit.Window default prototype
return {
init: function(_args) {
// _args are what get passed into the constructure
this.backgroundColor = 'red';
// maybe add some views or something...
var testView = new TiKit.View();
this.add(testView);
parentPrototype.init.call(this, _args); // do whatever the parent init would have done
},
open: function() {
alert('fire an alert any time the custom window opens');
parentPrototype.open.call(this, _args); // do whatever the parent open would have done
}
}
});
var win = new CustomWin();
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment