Changeset 316 for Dev/branches/rest-dojo-ui/client/rft/ui
- Timestamp:
- 03/23/12 17:26:55 (13 years ago)
- Location:
- Dev/branches/rest-dojo-ui/client/rft/ui
- Files:
-
- 4 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/rft/ui/AccordionList.js
r311 r316 9 9 return declare('rft.ui.AccordionList',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{ 10 10 templateString: template, 11 store: null,12 11 idProperty: null, 13 12 categoryProperty: null, … … 18 17 this._widgets = {}; 19 18 }, 20 postCreate: function() { 21 this.idProperty = this.idProperty || this.store.idProperty; 22 this.refresh(true); 23 }, 24 refresh: function(initial) { 25 Deferred.when( this.store.query() ) 26 .then(lang.hitch(this,'_addItems',initial)); 27 }, 28 _addItems: function(initial,items) { 29 var newWidgets = {}; 30 array.forEach(this._widgets,domConstruct.destroy); // get everything out of the dom 31 array.forEach(items,lang.hitch(this,function(item){ 32 var widget = this._getWidgetForItem(item); 33 var id = this._getItemProperty(this.idProperty,item); 34 var container = this._getContainerForItem(item); 35 widget.placeAt(container.containerNode); 36 newWidgets[id] = widget; 37 })); 38 var oldWidgets = array.filter(this.items,function(widget){ 39 return array.indexOf(newWidgets,widget) < 0; 19 setItems: function(items) { 20 var obsoleteWidgets = array.filter(this.widgets,function(item){ 21 return array.indexOf(items,item) < 0; 40 22 }); 41 array.forEach(o ldWidgets,function(widget){23 array.forEach(obsoleteWidgets,function(widget){ 42 24 widget.destroy(); 43 25 }); 44 this._widgets = newWidgets; // overwrite, releasing any non-existing items45 initial && this.accordion.selectChild(true);26 array.forEach(this._widgets,domConstruct.destroy); // get everything out of the dom 27 array.forEach(items,lang.hitch(this,"_addItem")); 46 28 this._cleanupEmptyContainers(); 29 }, 30 addItems: function(items) { 31 array.forEach(items,lang.hitch(this,"_addItem")); 32 this._cleanupEmptyContainers(); 33 }, 34 addItem: function(item) { 35 this._addItem(item); 36 this._cleanupEmptyContainers(); 37 }, 38 _addItem: function(item) { 39 var widget = this._getWidgetForItem(item); 40 var container = this._getContainerForItem(item); 41 widget.placeAt(container.containerNode); 42 }, 43 removeItem: function(item) { 44 var id = this._getItemProperty(this.idProperty,item); 45 var widget = this._getWidgetForItem(item); 46 widget && widget.destroy(); 47 delete this._widgets[id]; 47 48 }, 48 49 _getWidgetForItem: function(item) { -
Dev/branches/rest-dojo-ui/client/rft/ui/LineWithActionsWidget.js
r288 r316 1 define(['dojo/_base/declare','dojo/_base/lang','d ijit/form/Button',1 define(['dojo/_base/declare','dojo/_base/lang','dojo/on','dojo/dom','dijit/form/Button', 2 2 'dijit/_WidgetBase','dijit/_TemplatedMixin','dijit/_WidgetsInTemplateMixin', 3 3 'dojo/text!./templates/LineWithActionsWidget.html'], 4 function(declare,lang, Button,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString){4 function(declare,lang,on,dom,Button,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString){ 5 5 return declare('rft.ui.LineWithActionsWidget',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{ 6 6 templateString: templateString, 7 baseClass: 'rftLineWithButtons', 7 8 title: '', 8 9 userObject: null, 9 10 actions: {}, 11 postCreate: function() { 12 dom.setSelectable(this.domNode, false); 13 on(this.titleNode,'click',lang.hitch(this,'_onClick')); 14 }, 10 15 startup: function() { 11 16 this.inherited(arguments); … … 17 22 new Button({ 18 23 label: action, 24 //iconClass: 'dijitIconSearch', 25 //showLabel: false, 19 26 onClick: lang.hitch(this,function(){ 20 27 this.actions[action](this.userObject); 21 28 }) 22 }).placeAt(this. actionBar);29 }).placeAt(this.buttonsNode); 23 30 } 24 31 }, 25 32 refresh: function() { 26 33 this.titleNode.innerHTML = this.title; 27 } 34 }, 35 _onClick: function(e){ 36 var preventDefault = this.onClick(e) === false; 37 if(preventDefault){ 38 e.preventDefault(); 39 } 40 return !preventDefault; 41 }, 42 onClick: function(e) {} 28 43 }); 29 44 }); -
Dev/branches/rest-dojo-ui/client/rft/ui/templates/LineWithActionsWidget.html
r288 r316 1 <div >2 <span data-dojo-attach-point="actionBar"></span>3 <span data-dojo-attach-point="titleNode"></span>1 <div class="${baseClass}"> 2 <span class="${baseClass}Title" data-dojo-attach-point="titleNode"></span> 3 <span class="${baseClass}Buttons" data-dojo-attach-point="buttonsNode"></span> 4 4 </div>
Note: See TracChangeset
for help on using the changeset viewer.