1 | define([ |
---|
2 | 'dojo/_base/declare', |
---|
3 | 'dojo/_base/lang', |
---|
4 | 'dojo/on', |
---|
5 | 'dojo/dom', |
---|
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( |
---|
14 | declare, |
---|
15 | lang, |
---|
16 | on, |
---|
17 | dom, |
---|
18 | domClass, |
---|
19 | Button, |
---|
20 | _WidgetBase, |
---|
21 | _TemplatedMixin, |
---|
22 | _WidgetsInTemplateMixin, |
---|
23 | templateString) { |
---|
24 | return declare('rft.ui.LineWithActionsWidgetThijs',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{ |
---|
25 | |
---|
26 | templateString: templateString, |
---|
27 | baseClass: 'rftLineWithButtons', |
---|
28 | title: '', |
---|
29 | modifiers: "", |
---|
30 | userObject: null, |
---|
31 | actions: {}, |
---|
32 | |
---|
33 | postCreate: function() { |
---|
34 | dom.setSelectable(this.domNode, false); |
---|
35 | on(this.titleNode,'click',lang.hitch(this,'_onClick')); |
---|
36 | }, |
---|
37 | startup: function() { |
---|
38 | this.inherited(arguments); |
---|
39 | this._setupActions(); |
---|
40 | domClass.add(this.domNode, this.modifiers); |
---|
41 | this.refresh(); |
---|
42 | }, |
---|
43 | _setupActions: function() { |
---|
44 | for (var action in this.actions) { |
---|
45 | |
---|
46 | if (this.actions[action].properties.blockButton == true) { // BlockButton |
---|
47 | var properties = lang.mixin({ |
---|
48 | baseClass: 'rftBlockButton', |
---|
49 | modifiers: this.modifiers, |
---|
50 | label: "Default", |
---|
51 | iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon, |
---|
52 | title: action, |
---|
53 | onClick: lang.hitch(this, this.actions[action].callback) |
---|
54 | }, this.actions[action].properties); |
---|
55 | properties["class"] = properties.modifiers; |
---|
56 | new Button(properties).placeAt(this.buttonsNode); |
---|
57 | } else { //InlineButton |
---|
58 | var properties = lang.mixin({ |
---|
59 | baseClass: 'rftInlineButton', |
---|
60 | modifiers: 'black', |
---|
61 | label: "Default", |
---|
62 | showLabel: false, |
---|
63 | iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon, |
---|
64 | title: action, |
---|
65 | onClick: lang.hitch(this, this.actions[action].callback) |
---|
66 | }, this.actions[action].properties); |
---|
67 | properties["class"] = properties.modifiers; |
---|
68 | new Button(properties).placeAt(this.buttonsNode); |
---|
69 | } |
---|
70 | } |
---|
71 | }, |
---|
72 | refresh: function() { |
---|
73 | |
---|
74 | this.titleNode.innerHTML = this.title; |
---|
75 | }, |
---|
76 | _onClick: function(e){ |
---|
77 | var preventDefault = this.onClick(e) === false; |
---|
78 | if(preventDefault){ |
---|
79 | e.preventDefault(); |
---|
80 | } |
---|
81 | return !preventDefault; |
---|
82 | }, |
---|
83 | onClick: function(e) {}, |
---|
84 | _setTitleAttr: function(value){ |
---|
85 | this.title = value; |
---|
86 | this.refresh(); |
---|
87 | } |
---|
88 | }); |
---|
89 | }); |
---|