source: Dev/branches/rest-dojo-ui/client/rft/ui/LineWithActionsWidgetThijs.js @ 342

Last change on this file since 342 was 342, checked in by tjcschipper, 13 years ago
  • Fixed callbacks/actions in LineWithActionsWidgetThijs?.js. Previously an onClick event would not fire the correct callback. They were also incorrectly bound to the context of the widget, so the this keyword referred to the properties object instead of the LineWithActions?.
  • Changed a bunch of stuff in CSS files, general layout.
  • Added another mockup page to show the Session selection page.
File size: 3.2 KB
Line 
1define(['dojo/_base/declare','dojo/_base/lang','dojo/on','dojo/dom', 'dojo/dom-class', 'dijit/form/Button',
2    'dijit/_WidgetBase','dijit/_TemplatedMixin','dijit/_WidgetsInTemplateMixin',
3    'dojo/text!./templates/LineWithActionsWidget.html'
4    ],
5    function(declare,lang,on,dom,domClass,Button,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString){
6        return declare('rft.ui.LineWithActionsWidgetThijs',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{
7            templateString: templateString,
8            baseClass: 'rftLineWithButtons',
9            title: '',
10            modifiers: "blue",
11            userObject: null,
12            actions: {},
13            postCreate: function() {
14                dom.setSelectable(this.domNode, false);
15                on(this.titleNode,'click',lang.hitch(this,'_onClick'));
16            },
17            startup: function() {
18                this.inherited(arguments);
19                this._setupActions();
20                domClass.add(this.domNode, this.modifiers);
21                this.refresh();
22            },
23            _setupActions: function() {
24                for (var action in this.actions) {
25                   
26                    if (this.actions[action].properties.blockButton == true) {  // BlockButton
27                        var properties = lang.mixin({
28                            baseClass: 'rftBlockButton',
29                            modifiers: this.modifiers,
30                            label: "Default",
31                            iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon,
32                            title: action,
33                            onClick: lang.hitch(this, this.actions[action].callback)
34                        }, this.actions[action].properties);
35                        properties["class"] = properties.modifiers;
36                        new Button(properties).placeAt(this.buttonsNode);
37                    } else {    //InlineButton
38                        var properties = lang.mixin({
39                            baseClass: 'rftInlineButton',
40                            modifiers: 'black',
41                            label: "Default",
42                            showLabel: false,
43                            iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon,
44                            title: action,
45                            onClick: lang.hitch(this, this.actions[action].callback)
46                        }, this.actions[action].properties);
47                        properties["class"] = properties.modifiers;
48                        new Button(properties).placeAt(this.buttonsNode);
49                    }
50                }
51            },
52            refresh: function() {
53                this.titleNode.innerHTML = this.title;
54            },
55            _onClick: function(e){
56                var preventDefault = this.onClick(e) === false;
57                if(preventDefault){
58                    e.preventDefault();
59                }
60                return !preventDefault;
61            },
62            onClick: function(e) {},
63            _setTitleAttr: function(value){
64                this.title = value;
65                this.refresh();
66            }
67        });
68    });
Note: See TracBrowser for help on using the repository browser.