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

Last change on this file since 333 was 333, checked in by tjcschipper, 13 years ago
  • Added rft.ui.InlineButton?, which is another preset like LargeButton? and BlockButton?. This time icon only and no label, made to fit into rftLineWithActions widgets. highlightColor: White/Black? allows for two different versions depending on icon background.
  • Make copies of rft/ui/LineWithActionsWidget and rft/ui/Selector, with -Thijs appended to the classnames. These are an attempt at integrating the newly created buttons in their intended contexts. The original classes and templates are untouched.
  • Changed LargeButton? and BlockButton? to be less hardcoded and just better.
File size: 1.9 KB
Line 
1define(['dojo/_base/declare','dojo/_base/lang','dojo/on','dojo/dom','dijit/form/Button',
2    'dijit/_WidgetBase','dijit/_TemplatedMixin','dijit/_WidgetsInTemplateMixin',
3    'dojo/text!./templates/LineWithActionsWidget.html',
4    'rft/ui/InlineButton', 'rft/ui/BlockButton'],
5    function(declare,lang,on,dom,Button,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString, InlineButton, BlockButton){
6        return declare('rft.ui.LineWithActionsWidgetThijs',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{
7            templateString: templateString,
8            baseClass: 'rftLineWithButtons',
9            title: '',
10            userObject: null,
11            actions: {},
12            postCreate: function() {
13                dom.setSelectable(this.domNode, false);
14                on(this.titleNode,'click',lang.hitch(this,'_onClick'));
15            },
16            startup: function() {
17                this.inherited(arguments);
18                this._setupActions();
19                this.refresh();
20            },
21            _setupActions: function() {
22                for (var action in this.actions) {
23                    new InlineButton({
24                        label: action,
25                        iconType: action,
26                        highlightColor: "White",
27                        onClick: lang.hitch(this, function(){
28                            this.actions[action](this.userObject);
29                        })
30                    }).placeAt(this.buttonsNode);
31                }
32            },
33            refresh: function() {
34                this.titleNode.innerHTML = this.title;
35            },
36            _onClick: function(e){
37                var preventDefault = this.onClick(e) === false;
38                if(preventDefault){
39                    e.preventDefault();
40                }
41                return !preventDefault;
42            },
43            onClick: function(e) {}
44        });
45    });
Note: See TracBrowser for help on using the repository browser.