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 | '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 | }); |
---|