define([ 'dojo/_base/declare', 'dojo/_base/lang', 'dijit/_WidgetBase', 'dijit/_TemplatedMixin', 'dijit/_WidgetsInTemplateMixin', './LineWithActionsWidget', 'dojo/text!./templates/ObjectBox.html' ], function(declare, lang, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, LineWithActionsWidget, template){ return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], { baseClass: "rftObjectBox", templateString: template, value: null, actions: null, startup: function() { if ( this._started ){ return; } this.inherited(arguments); this.line1 = new LineWithActionsWidget({ actions: { "inspectIcon": { callback: lang.hitch(this, this._showInfoBox), properties: { blockButton: false, icon: "Inspect" } } } }).placeAt(this.line1Node); this.line2 = new LineWithActionsWidget({ }).placeAt(this.line2Node); var line3Actions = this._createLine3Actions(); this.line3 = new LineWithActionsWidget({ actions: line3Actions }).placeAt(this.line3Node); this.line1.startup(); this.line2.startup(); this.line3.startup(); this.inherited(arguments); }, _createLine3Actions: function() { var line3Actions = {}; for (var action in this.actions) { line3Actions[action] = { callback: lang.hitch(this, function(callback){ if ( this.value ) { callback(this.value); } }, this.actions[action]), properties: { blockButton: true, label: action, icon: action.charAt(0).toUpperCase()+action.slice(1) } }; } return line3Actions; }, _showInfoBox: function() {}, _setValueAttr: function(value) { this.value = value; this._refresh(); }, _getValueAttr: function(value) { this.value = value; }, _refresh: function() { if ( this.value !== null ) { this.iconNode.className = "rftIcon typeIcon rftIcon"+(this.value.type || ''); this.line1.set('title', this.value.title || ''); this.line2.set('title', this.value.subTitle || ''); this.line3.set('title', this.value.lowerTitle || ''); } } }); });