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

Last change on this file since 338 was 338, checked in by tjcschipper, 13 years ago
  • Changed linewithactions and selector -options- property to -modifiers-: more general approach. These extra classes are applied to the root domNode of the widget during the postCreate phase instead.
  • Changed rftSelector.css stuff to match this change, and allow for separate colouring of a selector and its contents.
File size: 3.1 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: "red",
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                        {
29                            baseClass: 'rftBlockButton',
30                            modifiers: this.modifiers,
31                            label: action,
32                            iconClass: 'rftIcon rftIcon'+action,
33                            title: action,
34                            onClick: lang.hitch(this, function(){
35                                this.actions[action].callback(this.userObject);
36                            })
37                        },
38                        this.actions[action].properties);
39                        properties["class"] = properties.modifiers;
40                       
41                        new Button(properties).placeAt(this.buttonsNode);
42                    } else {    //InlineButton
43                        new Button(
44                            lang.mixin({
45                                baseClass: 'rftInlineButton',
46                                "class": "black",
47                                showLabel: false,
48                                iconClass: 'rftIcon rftIcon'+action,
49                                title: action,
50                                onClick: lang.hitch(this, function(){
51                                    this.actions[action].callback(this.userObject);
52                                })
53                            }, this.actions[action].properties)).placeAt(this.buttonsNode);
54                    }
55                }
56            },
57            refresh: function() {
58                this.titleNode.innerHTML = this.title;
59            },
60            _onClick: function(e){
61                var preventDefault = this.onClick(e) === false;
62                if(preventDefault){
63                    e.preventDefault();
64                }
65                return !preventDefault;
66            },
67            onClick: function(e) {}
68        });
69    });
Note: See TracBrowser for help on using the repository browser.