source: Dev/branches/rest-dojo-ui/client/rft/ui/LineWithActionsWidget.js @ 402

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

Created widgets for several input types.
Work on multiplechoice widget, see if we can make OrderedList? work with
form items? Maybe make the item the widget iso a data item.

File size: 3.3 KB
Line 
1define(['dojo/_base/declare',
2        'dojo/_base/lang',
3        'dojo/on',
4        'dojo/dom',
5        'dojo/_base/event',
6        'dojo/dom-class',
7        'dijit/form/Button',
8        'dijit/_WidgetBase',
9        'dijit/_TemplatedMixin',
10        'dijit/_WidgetsInTemplateMixin',
11        'dojo/text!./templates/LineWithActionsWidget.html'
12        ],
13        function(declare,lang,on,dom,event,domClass,Button,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString){
14                return declare('rft.ui.LineWithActionsWidget',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{
15                        templateString: templateString,
16                        baseClass: 'rftLineWithButtons',
17                        title: '',
18                        selectable: false,
19                        userObject: null,
20
21                        actions: null,
22                        postCreate: function() {
23                                dom.setSelectable(this.domNode, false); // Text selection, has nothing to do with object selection!
24                                on(this.domNode,'click',lang.hitch(this,'_onClick'));
25                        },
26                        startup: function() {
27                                this.inherited(arguments);
28                                this._setupActions();
29                                domClass.add(this.domNode, "inheritBgColor bg");
30                                this.refresh();
31                        },
32                        _setupActions: function() {
33                if ( this.actions === null ) {
34                    return;
35                }
36                                for (var action in this.actions) {
37                                        var properties;
38                                        if (this.actions[action].properties.blockButton == true) {
39                                                properties = lang.mixin({
40                                                        baseClass: 'rftBlockButton',
41                            "class": "inheritBgColor light",
42                                                        label: "Default",
43                                                        iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon,
44                                                        title: this.actions[action].properties.tooltip,
45                            onClick: lang.hitch(this, function(action, e){
46                                action.callback && action.callback(e);
47                                event.stop(e);
48                                return false;
49                            }, this.actions[action])
50                                                }, this.actions[action].properties);
51                        new Button(properties).placeAt(this.buttonsNode);
52                    } else {
53                        properties = lang.mixin({
54                            baseClass: 'rftInlineButton',
55                            label: "Default",
56                            showLabel: false,
57                            iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon,
58                            title: this.actions[action].properties.tooltip,
59                            onClick: lang.hitch(this, function(action, e){
60                                action.callback && action.callback(e);
61                                event.stop(e);
62                                return false;
63                            }, this.actions[action])
64                        }, this.actions[action].properties);
65                        new Button(properties).placeAt(this.buttonsNode);
66                    }
67                }
68            },
69            refresh: function() {
70                this.titleNode.innerHTML = this.title;
71            },
72            _onClick: function(e){
73                var preventDefault = this.onClick(e) === false;
74                if (preventDefault) {
75                    event.stop(e);
76                }
77                return !preventDefault;
78            },
79            onClick: function(e) {
80            },
81            _setTitleAttr: function(value){
82                this.title = value;
83                this.refresh();
84            }
85        });
86    });
Note: See TracBrowser for help on using the repository browser.