can
Version:
MIT-licensed, client-side, JavaScript framework that makes building rich web applications easy.
52 lines (46 loc) • 1.47 kB
HTML
<html lang="en">
<head>
<title>can.Construct.proxy demo</title>
</head>
<body>
<h1>Super Demo</h1>
<p>Open the console to see the status messages.</p>
<p>This is a dummy page to show off your plugin</p>
<script type='text/javascript' src="../../node_modules/steal/steal.js" main="@empty"></script>
<script type='text/javascript'>
steal('can/construct/super', function(can) {
var Todo = can.Construct({
init : function(text) {
this.text = text;
},
toString : function() {
return 'TODO: ' + this.text;
}
});
var todo = new Todo('Take out trash');
console.log(todo.toString()); // -> TODO: Take out trash
var BetterTodo = Todo({
init : function(text, status) {
this._super(text);
this.status = status || 'Not done';
},
toString : function() {
return '[' + this.status + ']: ' + this._super();
}
});
var betterTodo = new BetterTodo('Take out trash', 'Done');
console.log(betterTodo.toString()); // -> [Done] TODO: Take out trash
var EvenBetterTodo = BetterTodo({
init : function(text, status) {
this._super.apply(this, arguments);
this.isEvenbetter = true;
}
});
var evenBetterTodo = new EvenBetterTodo('Do something else');
console.log(evenBetterTodo.toString()); // -> [Not done] TODO: Do something else
console.log(evenBetterTodo.isEvenbetter);
});
</script>
</body>
</html>