define([ "../lib/object", "dijit/_TemplatedMixin", "dijit/_WidgetBase", "dijit/_WidgetsInTemplateMixin", "dijit/form/Button", "dojo/_base/declare", "dojo/_base/event", "dojo/_base/lang", "dojo/dom", "dojo/dom-class", "dojo/on", "dojo/text!./templates/LineWithActionsWidget.html" ], function(objectFuns, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, Button, declare, event, lang, dom, domClass, on, 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! this.own(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; } objectFuns.forEach(this.actions, function(value,action){ var properties; if (value.properties.blockButton === true) { properties = lang.mixin({ baseClass: 'rftBlockButton', label: "Default", iconClass: 'rftIcon rftIcon'+value.properties.icon, title: value.properties.tooltip, onClick: lang.hitch(this, function(action, e){ if ( action.callback ) { action.callback(e); } if ( e ) { event.stop(e); } return false; }, value) }, value.properties); new Button(properties).placeAt(this.buttonsNode); } else { properties = lang.mixin({ baseClass: 'rftInlineButton', label: "Default", showLabel: false, iconClass: 'rftIcon rftIcon'+value.properties.icon, title: value.properties.tooltip, onClick: lang.hitch(this, function(action, e){ if ( action.callback ) { action.callback(e); } if ( e ) { event.stop(e); } return false; }, value) }, value.properties); new Button(properties).placeAt(this.buttonsNode); } },this); }, refresh: function() { this.titleNode.innerHTML = this.title; }, _onClick: function(e){ var preventDefault = this.onClick(e) === false; if (preventDefault) { if ( e ) { event.stop(e); } } return !preventDefault; }, onClick: function(/*e*/) { }, _setTitleAttr: function(value){ this.title = value; this.refresh(); } }); });