1 | define(['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 | ], |
---|
5 | function(declare,lang,on,dom,Button,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString){ |
---|
6 | return declare('rft.ui.LineWithActionsWidgetThijs',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{ |
---|
7 | templateString: templateString, |
---|
8 | baseClass: 'rftLineWithButtons', |
---|
9 | title: '', |
---|
10 | color: "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 | this.refresh(); |
---|
21 | }, |
---|
22 | _setupActions: function() { |
---|
23 | for (var action in this.actions) { |
---|
24 | |
---|
25 | if (this.actions[action].properties.blockButton == true) { // BlockButton |
---|
26 | new Button( |
---|
27 | lang.mixin({ |
---|
28 | baseClass: 'rftBlockButton', |
---|
29 | "class": this.color, |
---|
30 | label: action, |
---|
31 | iconClass: 'rftIcon rftIcon'+action, |
---|
32 | title: action, |
---|
33 | onClick: lang.hitch(this, function(){ |
---|
34 | this.actions[action].callback(this.userObject); |
---|
35 | }) |
---|
36 | }, this.actions[action].properties)).placeAt(this.buttonsNode); |
---|
37 | } else { //InlineButton |
---|
38 | new Button( |
---|
39 | lang.mixin({ |
---|
40 | baseClass: 'rftInlineButton', |
---|
41 | "class": "black", |
---|
42 | showLabel: false, |
---|
43 | iconClass: 'rftIcon rftIcon'+action, |
---|
44 | title: action, |
---|
45 | onClick: lang.hitch(this, function(){ |
---|
46 | this.actions[action].callback(this.userObject); |
---|
47 | }) |
---|
48 | }, this.actions[action].properties)).placeAt(this.buttonsNode); |
---|
49 | } |
---|
50 | |
---|
51 | |
---|
52 | |
---|
53 | /* THIS USES DEPRECATED CLASSES!!! |
---|
54 | if (this.actions[action].blockButton == true) { // BlockButton! |
---|
55 | new BlockButton({ |
---|
56 | label: action, |
---|
57 | iconType: action, |
---|
58 | highlightColor: this.actions[action].color || "green", |
---|
59 | onClick: lang.hitch(this, function(){ |
---|
60 | this.actions[action].callback(this.userObject); |
---|
61 | }) |
---|
62 | }).placeAt(this.buttonsNode); |
---|
63 | |
---|
64 | } else { // InlineButton! |
---|
65 | new InlineButton({ |
---|
66 | label: action, |
---|
67 | iconType: action, |
---|
68 | highlightColor: "Black", |
---|
69 | onClick: lang.hitch(this, function(){ |
---|
70 | this.actions[action].callback(this.userObject); |
---|
71 | }) |
---|
72 | }).placeAt(this.buttonsNode); |
---|
73 | } |
---|
74 | */ |
---|
75 | } |
---|
76 | }, |
---|
77 | refresh: function() { |
---|
78 | this.titleNode.innerHTML = this.title; |
---|
79 | }, |
---|
80 | _onClick: function(e){ |
---|
81 | var preventDefault = this.onClick(e) === false; |
---|
82 | if(preventDefault){ |
---|
83 | e.preventDefault(); |
---|
84 | } |
---|
85 | return !preventDefault; |
---|
86 | }, |
---|
87 | onClick: function(e) {} |
---|
88 | }); |
---|
89 | }); |
---|