define(['dojo/_base/declare', 'dojo/_base/lang', 'dojo/on', 'dojo/dom', 'dojo/_base/event', 'dojo/dom-class', 'dijit/form/Button', 'dijit/_WidgetBase', 'dijit/_TemplatedMixin', 'dijit/_WidgetsInTemplateMixin', 'dojo/text!./templates/LineWithActionsWidget.html' ],function(declare,lang,on,dom,event,domClass,Button,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString){ return declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{ templateString: templateString, baseClass: 'rftLineWithActions', title: '', selectable: false, userObject: null, actions: null, postCreate: function() { dom.setSelectable(this.domNode, false); // Text selection, has nothing to do with object selection! on(this.domNode,'click',lang.hitch(this,'_onClick')); }, startup: function() { if ( this._started ){ return; } this.inherited(arguments); this._setupActions(); this.refresh(); }, _setupActions: function() { if ( this.actions === null ) { return; } for (var action in this.actions) { var properties; if (this.actions[action].properties.blockButton === true) { properties = lang.mixin({ baseClass: 'rftBlockButton', label: "Default", iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon, title: this.actions[action].properties.tooltip, onClick: lang.hitch(this, function(action, e){ if ( action.callback ) { action.callback(e); } event.stop(e); return false; }, this.actions[action]) }, this.actions[action].properties); new Button(properties).placeAt(this.buttonsNode); } else { properties = lang.mixin({ baseClass: 'rftInlineButton', label: "Default", showLabel: false, iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon, title: this.actions[action].properties.tooltip, onClick: lang.hitch(this, function(action, e){ if ( action.callback ) { action.callback(e); } event.stop(e); return false; }, this.actions[action]) }, this.actions[action].properties); new Button(properties).placeAt(this.buttonsNode); } } }, refresh: function() { this.titleNode.innerHTML = this.title; }, _onClick: function(e){ var preventDefault = this.onClick(e) === false; if (preventDefault) { event.stop(e); } return !preventDefault; }, onClick: function(/*e*/) { }, _setTitleAttr: function(value){ this.title = value; this.refresh(); } }); });