Changeset 384 for Dev/branches/rest-dojo-ui/client/rft/ui/List.js
- Timestamp:
- 07/29/12 00:03:52 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/rft/ui/List.js
r374 r384 2 2 'dojo/_base/declare', 3 3 'dojo/_base/lang', 4 'dojo/dnd/Source', 5 'dijit/_Container', 6 'dijit/_TemplatedMixin', 4 7 'dijit/_WidgetBase', 5 'dijit/_TemplatedMixin',6 8 'dijit/_WidgetsInTemplateMixin', 7 'dijit/_Container', 8 'rft/ui/LineWithActionsWidget', 9 'dijit/registry', 9 10 'dojo/text!./templates/List.html' 10 11 ],function( 11 12 declare, 12 13 lang, 14 Source, 15 _Container, 16 _TemplatedMixin, 13 17 _WidgetBase, 14 _TemplatedMixin,15 18 _WidgetsInTemplateMixin, 16 _Container, 17 LineWithActionsWidget, 19 registry, 18 20 templateString 19 21 ){ … … 22 24 baseClass: 'rftList', 23 25 removeCallback: null, 24 creator: null, 25 26 constructor: function() { 27 lang.mixin(this, arguments); 28 }, 26 type: 'text', 27 source: null, 29 28 30 29 postCreate: function() { … … 35 34 } 36 35 37 this.source = new dojo.dnd.Source(this.sourceNode, { 38 isSource: false, 39 accept: ["LineListViewItem"], 36 this.source = new Source(this.sourceNode, { 37 accept: [this.type], 40 38 horizontal: false, 41 withHandles: false,42 selfCopy: false,43 selfAccept: true,44 delay: 0,45 39 singular: true, 46 creator: lang.hitch(this, this. creatorMethod)47 }) 40 creator: lang.hitch(this, this._createNode) 41 }); 48 42 }, 49 43 50 removeItem: function(item, widget) { 51 widget.destroy(); 52 if(this.removeCallback) 53 this.removeCallback(item); 44 _createNode: function(item, hint) { 45 var node = hint === "avatar" ? 46 this._createAvatarNode(item) : this._createListNode(item); 47 return { 48 node: node, 49 data: item, 50 type: this.type 51 }; 52 }, 53 _createListNode: function(item) {}, 54 _createAvatarNode: function(item) {}, 55 56 appendItem: function(item) { 57 this.source.insertNodes(false,[item]); 54 58 }, 55 59 56 insertItem: function(item) { 57 this.source.insertNodes(false, [item]); 60 getItems: function() { 61 return this.source.getAllNodes() 62 .map(function(node){ 63 return this.source.getItem(node.id).data; 64 },this); 65 }, 66 67 deleteItems: function() { 68 this.source.getAllNodes() 69 .forEach(function(node){ 70 registry.byNode(node).destroy(); 71 }); 72 this.source.sync(); 73 }, 74 75 removeItem: function(item){ 76 this.source.getAllNodes() 77 .filter(lang.hitch(this,function(node){ 78 return this.source.getItem(node.id).data === item; 79 })) 80 .forEach(lang.hitch(this,function(node){ 81 registry.byNode(node).destroy(); 82 this.removeCallback && this.removeCallback(item); 83 })); 84 this.source.sync(); 58 85 } 59 86
Note: See TracChangeset
for help on using the changeset viewer.