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

Last change on this file since 404 was 386, checked in by hendrikvanantwerpen, 13 years ago
  • Changed questions view to return null for empty topic/categorie and leave presentation of null to TabbedQuestionWidget?.
File size: 2.2 KB
Line 
1define([
2    'dojo/_base/declare',
3    'dojo/_base/lang',
4    'dojo/dom-attr',
5    'dojo/parser',
6    'dojo/query',
7    'dijit/layout/ContentPane',
8    'dijit/registry'
9    ],function(declare,lang,attr,parser,query,ContentPane,registry){
10        return declare('rft.ui._Page',[ContentPane],{
11            startup: function() {
12                this.inherited(arguments);
13                this._attachPointsAndEvents();
14                this.onVisit();
15            },
16            _attachPointsAndEvents: function() {
17                query('*[data-rft-attach-point]'/*, this.domNode*/).forEach(lang.hitch(this,function(node){
18                    var point = attr.get(node,'data-rft-attach-point');
19                    var widget = registry.byId(attr.get(node,'id'));
20                    this[point] = widget || node;
21                }));
22                query('*[data-rft-attach-event]'/*, this.domNode*/).forEach(lang.hitch(this,function(node){
23                    var event = attr.get(node,'data-rft-attach-event').split(':');
24                    var eventName = event[0];
25                    var eventHandler = event[1];
26                    var widget = registry.byId(attr.get(node,'id'));
27                    if ( widget ) {
28                        this.connect(widget,eventName,lang.hitch(this,eventHandler));
29                    } else {
30                        this.connect(node,eventName,lang.hitch(this,eventHandler));
31                    }
32                }));
33                query('> script[type^="rft/method"]',this.domNode)
34                .orphan().forEach(lang.hitch(this,function(s){
35                    var methodName = s.getAttribute("data-rft-method");
36                    var func = parser._functionFromScript(s);
37                    this[methodName] = func;
38                }));
39            },
40            /** Event fired after startup of all widgets is complete */
41            onVisit: function(){},
42            /** Event fired before leaving the page. Return false to prevent */
43            onLeave: function(){
44                registry.findWidgets(this.domNode).forEach(function(w){
45                    w.destroyRecursive(false);
46                });
47                return true;
48            }
49        });
50});
Note: See TracBrowser for help on using the repository browser.