root / trunk / tests / lang / test_declare.html

Revision 7351, 2.5 kB (checked in by jburke, 23 months ago)

(merge from 0.4 branch) References #2366. Converting more tests to use dojo.addOnLoad()

Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<head>
4        <title>declare Test</title>
5        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
6        <style type="text/css">
7                body {
8                        font-family: Tahoma, Arial, Helvetica, sans-serif;
9                        font-size: 11px;
10                }
11        </style>
12        <script>djConfig = { isDebug: true }</script>
13        <script language="JavaScript" type="text/javascript" src="../../dojo.js"></script>
14        <script language="JavaScript" type="text/javascript">
15                dojo.require("dojo.lang.declare");
16
17                dojo.addOnLoad(function(){
18                        dojo.debug("> dojo.declare('my.classes.foo'...");
19                        dojo.declare('my.classes.foo', null,
20                                function(arg) {
21                                        dojo.debug('foo: initializing instance' + (arg ? ' [' + arg + ']' : ''));
22                                        this.id = 'foo';
23                                },
24                                {
25                                        getInstanceId: function(extra) {
26                                                var ancestorId = my.classes.foo.superclass.getInstanceId.apply(this, arguments);
27                                                return "a " + this.id + (ancestorId ? " is " + ancestorId : '');
28                                        },
29                                        getId: function() {
30                                                return "I am a foo";
31                                        },
32                                        method: function() {
33                                                return "A method in foo";
34                                        }
35                                });
36                       
37                        dojo.debug("> dojo.declare('my.classes.bar', my.classes.foo, ...");
38                        dojo.declare('my.classes.bar', my.classes.foo,
39                                function(arg) {
40                                        dojo.debug('bar: initializing instance' + (arg ? ' [' + arg + ']' : ''));
41                                        this.id = 'bar';
42                                },
43                                {
44                                        getId: function(extra) {
45                                                return "I am a bar and " + my.classes.bar.superclass.getId.apply(this, arguments);
46                                        }
47                                });
48                        dojo.debug('');
49                       
50                        dojo.debug('> b = new my.classes.bar()');
51                        b = new my.classes.bar();
52                        dojo.debug('');
53                       
54                        dojo.debug("> dojo.declare('my.classes.zot', my.classes.bar, ...");
55                        dojo.declare('my.classes.zot', my.classes.bar,
56                                function(arg) {
57                                        dojo.debug('zot: initializing instance' + (arg ? ' [' + arg + ']' : ''));
58                                        this.id = 'zot';
59                                },
60                                {
61                                        getId: function(extra) {
62                                                return "I am a zot and " + my.classes.zot.superclass.getId.apply(this, arguments);
63                                        }
64                                });
65                        dojo.debug('');
66                       
67                        dojo.debug('> f = new my.classes.foo()');
68                        f = new my.classes.foo();
69                        dojo.debug('');
70                       
71                        dojo.debug('> z = new my.classes.zot("with an argument")');
72                        z = new my.classes.zot("with an argument");
73                        dojo.debug('');
74                       
75                        dojo.debug('> f.getId()');
76                        dojo.debug(f.getId());
77                        dojo.debug('');
78                       
79                        dojo.debug('> b.getId()');
80                        dojo.debug(b.getId());
81                        dojo.debug('');
82                       
83                        dojo.debug('> z.getId()');
84                        dojo.debug(z.getId());
85                        dojo.debug('');
86                });
87        </script>
88</head>
89<body> 
90</body>
91</html>
Note: See TracBrowser for help on using the browser.