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

Last change on this file since 305 was 292, checked in by hendrikvanantwerpen, 13 years ago

[Client] Added surveys list and survey details skeleton pages.
[Client] Changed method of passing parameters to pages. This still feels clumsy, because we're working against Dojo a bit with this.
[Server] Integrated REST resources for collections and objects, since they shared more than they differed.

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