You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
2.5 KiB
89 lines
2.5 KiB
2 years ago
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>declare Test</title>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
|
||
|
<style type="text/css">
|
||
|
body {
|
||
|
font-family: Tahoma, Arial, Helvetica, sans-serif;
|
||
|
font-size: 11px;
|
||
|
}
|
||
|
</style>
|
||
|
<script>djConfig = { isDebug: true }</script>
|
||
|
<script language="JavaScript" type="text/javascript" src="../../dojo.js"></script>
|
||
|
<script language="JavaScript" type="text/javascript">
|
||
|
dojo.require("dojo.lang.declare");
|
||
|
|
||
|
dojo.addOnLoad(function(){
|
||
|
dojo.debug("> dojo.declare('my.classes.foo'...");
|
||
|
dojo.declare('my.classes.foo', null, {
|
||
|
initializer: function(arg) {
|
||
|
dojo.debug('foo: initializing instance' + (arg ? ' [' + arg + ']' : ''));
|
||
|
this.id = 'foo';
|
||
|
},
|
||
|
getInstanceId: function(extra) {
|
||
|
var ancestorId = my.classes.foo.superclass.getInstanceId.apply(this, arguments);
|
||
|
return "a " + this.id + (ancestorId ? " is " + ancestorId : '');
|
||
|
},
|
||
|
getId: function() {
|
||
|
return "I am a foo";
|
||
|
},
|
||
|
method: function() {
|
||
|
return "A method in foo";
|
||
|
}
|
||
|
});
|
||
|
|
||
|
dojo.debug("> dojo.declare('my.classes.bar', my.classes.foo, ...");
|
||
|
dojo.declare('my.classes.bar', my.classes.foo, {
|
||
|
initializer: function(arg) {
|
||
|
dojo.debug('bar: initializing instance' + (arg ? ' [' + arg + ']' : ''));
|
||
|
this.id = 'bar';
|
||
|
},
|
||
|
getId: function(extra) {
|
||
|
return "I am a bar and " + my.classes.bar.superclass.getId.apply(this, arguments);
|
||
|
}
|
||
|
});
|
||
|
dojo.debug('');
|
||
|
|
||
|
dojo.debug('> b = new my.classes.bar()');
|
||
|
b = new my.classes.bar();
|
||
|
dojo.debug('');
|
||
|
|
||
|
dojo.debug("> dojo.declare('my.classes.zot', my.classes.bar, ...");
|
||
|
dojo.declare('my.classes.zot', my.classes.bar, {
|
||
|
initializer: function(arg) {
|
||
|
dojo.debug('zot: initializing instance' + (arg ? ' [' + arg + ']' : ''));
|
||
|
this.id = 'zot';
|
||
|
},
|
||
|
getId: function(extra) {
|
||
|
return "I am a zot and " + my.classes.zot.superclass.getId.apply(this, arguments);
|
||
|
}
|
||
|
});
|
||
|
dojo.debug('');
|
||
|
|
||
|
dojo.debug('> f = new my.classes.foo()');
|
||
|
f = new my.classes.foo();
|
||
|
dojo.debug('');
|
||
|
|
||
|
dojo.debug('> z = new my.classes.zot("with an argument")');
|
||
|
z = new my.classes.zot("with an argument");
|
||
|
dojo.debug('');
|
||
|
|
||
|
dojo.debug('> f.getId()');
|
||
|
dojo.debug(f.getId());
|
||
|
dojo.debug('');
|
||
|
|
||
|
dojo.debug('> b.getId()');
|
||
|
dojo.debug(b.getId());
|
||
|
dojo.debug('');
|
||
|
|
||
|
dojo.debug('> z.getId()');
|
||
|
dojo.debug(z.getId());
|
||
|
dojo.debug('');
|
||
|
});
|
||
|
</script>
|
||
|
</head>
|
||
|
<body>
|
||
|
</body>
|
||
|
</html>
|