source: Dev/branches/rest-dojo-ui/client/rft/ui/_Page.js @ 291

Last change on this file since 291 was 288, checked in by hendrikvanantwerpen, 13 years ago

[Client] MultipleChoiceWidget? for editing multiple choice questions
[Client] Move templates to separate directories.
[Client] Created QuestionWidget? to edit complete questions.
[Client] Fixed startup race condition where parsing was started before all classes were loaded.

File size: 2.1 KB
Line 
1define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/array','dojo/parser',
2    'dojo/query','dojo/dom-attr','dojo/_base/connect','dijit','dijit/_WidgetBase',
3    'dijit/_Container','dijit/_Contained'],
4    function(declare,lang,array,parser,query,attr,connect,dijit,_WidgetBase,_Container,_Contained){
5        return declare('rft.ui._Page',[_WidgetBase],{
6            startup: function() {
7                this.inherited(arguments);
8                this._attachPointsAndEvents();
9                this.onVisit();
10            },
11            _attachPointsAndEvents: function() {
12                query('*[data-rft-attach-point]'/*, this.domNode*/).forEach(lang.hitch(this,function(node){
13                    var point = attr.get(node,'data-rft-attach-point');
14                    var widget = dijit.byId(attr.get(node,'id'));
15                    this[point] = widget || node;
16                }));
17                query('*[data-rft-attach-event]'/*, this.domNode*/).forEach(lang.hitch(this,function(node){
18                    var event = attr.get(node,'data-rft-attach-event').split(':');
19                    var eventName = event[0];
20                    var eventHandler = event[1];
21                    var widget = dijit.byId(attr.get(node,'id'));
22                    if ( widget ) {
23                        this.connect(widget,eventName,lang.hitch(this,eventHandler));
24                    } else {
25                        this.connect(node,eventName,lang.hitch(this,eventHandler));
26                    }
27                }));
28                query('> script[type^="rft/method"]',this.domNode)
29                .orphan().forEach(lang.hitch(this,function(s){
30                    var methodName = s.getAttribute("data-rft-method");
31                    var func = parser._functionFromScript(s);
32                    this[methodName] = func;
33                }));
34            },
35            /** Event fired after startup of all widgets is complete */
36            onVisit: function(){},
37            /** Event fired before leaving the page. Return false to prevent */
38            onLeave: function(){}
39        });
40    });
Note: See TracBrowser for help on using the repository browser.