- Timestamp:
- 09/03/12 18:14:37 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/rft/ui/LineWithActionsWidget.js
r405 r406 1 1 define(['dojo/_base/declare', 2 'dojo/_base/lang', 3 'dojo/on', 4 'dojo/dom', 5 'dojo/_base/event', 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(declare,lang,on,dom,event,domClass,Button,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString){ 14 return declare('rft.ui.LineWithActionsWidget',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{ 15 templateString: templateString, 16 baseClass: 'rftLineWithButtons', 17 title: '', 18 selectable: false, 19 userObject: null, 2 'dojo/_base/lang', 3 'dojo/on', 4 'dojo/dom', 5 'dojo/_base/event', 6 'dojo/dom-class', 7 'dijit/form/Button', 8 'dijit/_WidgetBase', 9 'dijit/_TemplatedMixin', 10 'dijit/_WidgetsInTemplateMixin', 11 'dojo/text!./templates/LineWithActionsWidget.html' 12 ],function(declare,lang,on,dom,event,domClass,Button,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString){ 13 return declare('rft.ui.LineWithActionsWidget',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{ 14 templateString: templateString, 15 baseClass: 'rftLineWithButtons', 16 title: '', 17 selectable: false, 18 userObject: null, 20 19 21 actions: null, 22 postCreate: function() { 23 dom.setSelectable(this.domNode, false); // Text selection, has nothing to do with object selection! 24 on(this.domNode,'click',lang.hitch(this,'_onClick')); 25 }, 26 startup: function() { 27 if ( this._started ){ return; } 28 this.inherited(arguments); 29 this._setupActions(); 30 domClass.add(this.domNode, "inheritBgColor bg"); 31 this.refresh(); 32 }, 33 _setupActions: function() { 34 if ( this.actions === null ) { 35 return; 20 actions: null, 21 postCreate: function() { 22 dom.setSelectable(this.domNode, false); // Text selection, has nothing to do with object selection! 23 on(this.domNode,'click',lang.hitch(this,'_onClick')); 24 }, 25 startup: function() { 26 if ( this._started ){ return; } 27 this.inherited(arguments); 28 this._setupActions(); 29 domClass.add(this.domNode, "inheritBgColor bg"); 30 this.refresh(); 31 }, 32 _setupActions: function() { 33 if ( this.actions === null ) { 34 return; 35 } 36 for (var action in this.actions) { 37 var properties; 38 if (this.actions[action].properties.blockButton === true) { 39 properties = lang.mixin({ 40 baseClass: 'rftBlockButton', 41 "class": "inheritBgColor light", 42 label: "Default", 43 iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon, 44 title: this.actions[action].properties.tooltip, 45 onClick: lang.hitch(this, function(action, e){ 46 action.callback && action.callback(e); 47 event.stop(e); 48 return false; 49 }, this.actions[action]) 50 }, this.actions[action].properties); 51 new Button(properties).placeAt(this.buttonsNode); 52 } else { 53 properties = lang.mixin({ 54 baseClass: 'rftInlineButton', 55 label: "Default", 56 showLabel: false, 57 iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon, 58 title: this.actions[action].properties.tooltip, 59 onClick: lang.hitch(this, function(action, e){ 60 action.callback && action.callback(e); 61 event.stop(e); 62 return false; 63 }, this.actions[action]) 64 }, this.actions[action].properties); 65 new Button(properties).placeAt(this.buttonsNode); 36 66 } 37 for (var action in this.actions) {38 var properties;39 if (this.actions[action].properties.blockButton == true) {40 properties = lang.mixin({41 baseClass: 'rftBlockButton',42 "class": "inheritBgColor light",43 label: "Default",44 iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon,45 title: this.actions[action].properties.tooltip,46 onClick: lang.hitch(this, function(action, e){47 action.callback && action.callback(e);48 event.stop(e);49 return false;50 }, this.actions[action])51 }, this.actions[action].properties);52 new Button(properties).placeAt(this.buttonsNode);53 } else {54 properties = lang.mixin({55 baseClass: 'rftInlineButton',56 label: "Default",57 showLabel: false,58 iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon,59 title: this.actions[action].properties.tooltip,60 onClick: lang.hitch(this, function(action, e){61 action.callback && action.callback(e);62 event.stop(e);63 return false;64 }, this.actions[action])65 }, this.actions[action].properties);66 new Button(properties).placeAt(this.buttonsNode);67 }68 }69 },70 refresh: function() {71 this.titleNode.innerHTML = this.title;72 },73 _onClick: function(e){74 var preventDefault = this.onClick(e) === false;75 if (preventDefault) {76 event.stop(e);77 }78 return !preventDefault;79 },80 onClick: function(e) {81 },82 _setTitleAttr: function(value){83 this.title = value;84 this.refresh();85 67 } 86 }); 68 }, 69 refresh: function() { 70 this.titleNode.innerHTML = this.title; 71 }, 72 _onClick: function(e){ 73 var preventDefault = this.onClick(e) === false; 74 if (preventDefault) { 75 event.stop(e); 76 } 77 return !preventDefault; 78 }, 79 onClick: function(e) { 80 }, 81 _setTitleAttr: function(value){ 82 this.title = value; 83 this.refresh(); 84 } 87 85 }); 86 });
Note: See TracChangeset
for help on using the changeset viewer.