Changeset 384 for Dev/branches/rest-dojo-ui/client/rft/ui
- Timestamp:
- 07/29/12 00:03:52 (13 years ago)
- Location:
- Dev/branches/rest-dojo-ui/client/rft/ui
- Files:
-
- 2 deleted
- 7 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/rft/ui/AccountListView.js
r374 r384 2 2 'dojo/_base/declare', 3 3 'dojo/_base/lang', 4 'dijit/_WidgetBase', 5 'dijit/_TemplatedMixin', 6 'dijit/_WidgetsInTemplateMixin', 7 'dijit/_Container', 4 'dojo/dom-construct', 8 5 'rft/ui/LineWithActionsWidget', 9 'rft/ui/OrderedList', 10 'dojo/text!./templates/AccountListView.html' 6 'rft/ui/OrderedList' 11 7 ],function( 12 8 declare, 13 9 lang, 14 _WidgetBase, 15 _TemplatedMixin, 16 _WidgetsInTemplateMixin, 17 _Container, 10 domConstruct, 18 11 LineWithActionsWidget, 19 OrderedList, 20 templateString 12 OrderedList 21 13 ) { 22 return declare('rft.ui.AccountListView',[OrderedList,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{ 23 templateString: templateString, 14 return declare('rft.ui.AccountListView',[OrderedList],{ 24 15 baseClass: 'rftAccountListView', 25 region: 'center',16 type: 'account', 26 17 27 creatorMethod: function(item, hint) { 28 var node; 29 30 if (hint == "avatar") { 31 node = document.createElement("div"); 32 node.className = "dragAvatar"; 33 node.innerHTML = item.title; 34 } else { 35 var w = new LineWithActionsWidget({ 36 title: item.title, 37 'class': "green", 38 actions: { 39 "Remove" : { 40 callback: lang.hitch(this, function() { 41 this.removeItem(item, w); 42 }), 43 properties: { 44 blockButton: false, 45 icon: "Delete", 46 modifiers: "white" 47 } 48 } 49 } 50 }); 51 w.startup(); 52 node = w.domNode; 53 } 54 var fullItem = { 55 node: node, 56 data: item, 57 type: "ListViewItem" 58 }; 59 return fullItem; 18 _createAvatarNode: function(item){ 19 return domConstruct.create("div",{ 20 'class': 'dragAvatar', 21 innerHTML: item.title 22 }); 23 }, 24 _createListNode: function(item) { 25 var w = new LineWithActionsWidget({ 26 title: item.title, 27 'class': "green", 28 actions: { 29 "Remove" : { 30 callback: lang.hitch(this, 'removeItem', item), 31 properties: { 32 blockButton: false, 33 icon: "Delete", 34 modifiers: "white" 35 } 36 } 37 } 38 }); 39 w.startup(); 40 return w.domNode; 60 41 } 61 62 63 64 42 }); 65 });43 }); -
Dev/branches/rest-dojo-ui/client/rft/ui/CategoryListView.js
r374 r384 2 2 'dojo/_base/declare', 3 3 'dojo/_base/lang', 4 'dijit/_WidgetBase',5 'dijit/_TemplatedMixin',6 'dijit/_WidgetsInTemplateMixin',7 'dijit/_Container',8 4 'rft/ui/LineWithActionsWidget', 9 5 'rft/ui/List', 10 'dojo/text!./templates/List.html'11 6 ],function( 12 7 declare, 13 8 lang, 14 _WidgetBase,15 _TemplatedMixin,16 _WidgetsInTemplateMixin,17 _Container,18 9 LineWithActionsWidget, 19 List, 20 templateString 10 List 21 11 ) { 22 return declare('rft.ui.CategoryListView',[List,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{ 23 templateString: templateString, 12 return declare('rft.ui.CategoryListView',[List],{ 24 13 baseClass: 'rftLineListView', 25 region: 'center',26 14 27 creatorMethod: function(item, hint) { 28 var node; 15 _createAvatarNode: function(item) { 16 var node = document.createElement("div"); 17 node.className = "dragAvatar"; 18 node.innerHTML = item.title; 19 return node; 20 }, 29 21 30 if (hint == "avatar") { 31 node = document.createElement("div"); 32 node.className = "dragAvatar"; 33 node.innerHTML = item.title; 34 } else { 35 var w = new LineWithActionsWidget({ 36 title: item, 37 'class': "orange", 38 actions: { 39 "Remove" : { 40 callback: lang.hitch(this, function() { 41 this.removeItem(item, w); 42 }), 43 properties: { 44 blockButton: false, 45 icon: "Delete", 46 modifiers: "white" 47 } 22 _createListNode: function(item) { 23 var w = new LineWithActionsWidget({ 24 title: item, 25 'class': "orange", 26 actions: { 27 "Remove" : { 28 callback: lang.hitch(this, function() { 29 this.removeItem(item, w); 30 }), 31 properties: { 32 blockButton: false, 33 icon: "Delete", 34 modifiers: "white" 48 35 } 49 36 } 50 }); 51 w.startup(); 52 node = w.domNode; 53 } 54 var fullItem = { 55 node: node, 56 data: item, 57 type: "ListViewItem" 58 }; 59 return fullItem; 37 } 38 }); 39 w.startup(); 40 return w.domNode; 60 41 } 42 61 43 }); 62 });44 }); -
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 -
Dev/branches/rest-dojo-ui/client/rft/ui/MultipleChoiceListView.js
r383 r384 2 2 'dojo/_base/declare', 3 3 'dojo/_base/lang', 4 'dijit/_WidgetBase', 5 'dijit/_TemplatedMixin', 6 'dijit/_WidgetsInTemplateMixin', 7 'dijit/_Container', 4 'dojo/dom-construct', 8 5 'rft/ui/LineWithActionsWidget', 9 'rft/ui/OrderedList', 10 'dojo/text!./templates/AccountListView.html' 6 'rft/ui/OrderedList' 11 7 ],function( 12 8 declare, 13 9 lang, 14 _WidgetBase, 15 _TemplatedMixin, 16 _WidgetsInTemplateMixin, 17 _Container, 10 domConstruct, 18 11 LineWithActionsWidget, 19 OrderedList, 20 templateString 12 OrderedList 21 13 ) { 22 return declare('rft.ui.MultipleChoiceListView',[OrderedList,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{ 23 templateString: templateString, 14 return declare('rft.ui.MultipleChoiceListView',[OrderedList],{ 24 15 baseClass: 'rftMultipleChoiceListView', 25 region: 'center',16 type: 'multipleChoiceOption', 26 17 27 creatorMethod: function(item, hint) { 28 var node; 29 30 if (hint == "avatar") { 31 node = document.createElement("div"); 32 node.className = "dragAvatar"; 33 node.innerHTML = item.title; 34 } else { 35 var w = new LineWithActionsWidget({ 36 title: item.title, 37 'class': "orange", 38 actions: { 39 "Remove" : { 40 callback: lang.hitch(this, function() { 41 this.removeItem(item, w); 42 }), 43 properties: { 44 blockButton: false, 45 icon: "Delete", 46 modifiers: "white" 47 } 18 _createAvatarNode: function(item){ 19 return domConstruct.create("div",{ 20 'class': 'dragAvatar', 21 innerHTML: item.title 22 }); 23 }, 24 _createListNode: function(item) { 25 var w = new LineWithActionsWidget({ 26 title: item.title, 27 'class': "orange", 28 actions: { 29 "Remove" : { 30 callback: lang.hitch(this, 'removeItem', item), 31 properties: { 32 blockButton: false, 33 icon: "Delete", 34 modifiers: "white" 48 35 } 49 36 } 50 }); 51 w.startup(); 52 node = w.domNode; 53 } 54 var fullItem = { 55 node: node, 56 data: item, 57 type: "ListViewItem" 58 }; 59 return fullItem; 37 } 38 }); 39 w.startup(); 40 return w.domNode; 60 41 } 61 42 }); 62 });43 }); -
Dev/branches/rest-dojo-ui/client/rft/ui/OrderedList.js
r383 r384 2 2 'dojo/_base/declare', 3 3 'dojo/_base/lang', 4 'dijit/_WidgetBase', 5 'dijit/_TemplatedMixin', 6 'dijit/_WidgetsInTemplateMixin', 7 'dijit/_Container', 4 'dijit/form/Button', 8 5 'rft/ui/List', 9 6 'dojo/text!./templates/OrderedList.html' … … 11 8 declare, 12 9 lang, 13 _WidgetBase, 14 _TemplatedMixin, 15 _WidgetsInTemplateMixin, 16 _Container, 10 Button, 17 11 List, 18 12 templateString 19 13 ){ 20 return declare('rft.ui.OrderedList',[ _WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container,List],{14 return declare('rft.ui.OrderedList',[List],{ 21 15 templateString: templateString, 22 16 baseClass: 'rftLineListView', 23 17 24 18 postCreate: function() { 25 if (this.title) { 26 this.titleNode.innerHTML = this.title; 27 } else { 28 this.domNode.removeChild(this.titleNode); 29 } 19 this.inherited(arguments); 30 20 31 this.source = new dojo.dnd.Source(this.sourceNode, { 32 isSource: true, 33 accept: ["LineListViewItem"], 34 horizontal: false, 35 withHandles: false, 36 copyOnly: false, 37 selfCopy: false, 38 selfAccept: true, 39 delay: 0, 40 singular: true, 41 creator: lang.hitch(this, this.creatorMethod) 42 }); 43 44 new dijit.form.Button({ 21 new Button({ 45 22 label: "Move up", 46 23 showLabel: false, … … 49 26 'class': "trans", 50 27 onClick: lang.hitch(this, function() { 51 this. moveItem("up");28 this._moveSelectedItem("up"); 52 29 }) 53 }, this.btnListMoveUp) ;30 }, this.btnListMoveUp).startup(); 54 31 55 new dijit.form.Button({32 new Button({ 56 33 label: "Move down", 57 34 showLabel: false, … … 60 37 'class': "trans", 61 38 onClick: lang.hitch(this, function() { 62 this. moveItem("down");39 this._moveSelectedItem("down"); 63 40 }) 64 }, this.btnListMoveDown) ;41 }, this.btnListMoveDown).startup(); 65 42 }, 66 43 67 moveItem: function(dir) {44 _moveSelectedItem: function(dir) { 68 45 var node = this.source.getSelectedNodes()[0]; 69 46 if (node) { … … 92 69 var anchor = this.source.getSelectedNodes()[0]; 93 70 if (anchor) { 94 this.source.insertNodes(false, 71 this.source.insertNodes(false,[item], false, anchor); 95 72 } else { 96 this. source.insertNodes(false, [item]);73 this.appendItem(item); 97 74 } 98 }, 99 getItems: function() { 100 return this.source.getAllNodes() 101 .map(function(node){ 102 return this.source.getItem(node.id).data; 103 },this); 104 }, 75 } 76 105 77 }); 106 78 }); -
Dev/branches/rest-dojo-ui/client/rft/ui/QuestionEditorToolkit.js
r378 r384 84 84 _setupListView: function() { 85 85 this._list = new CategoryListView( { 86 controller: this, 87 removeCallback: lang.hitch(this, this._removeCategory), 86 removeCallback: lang.hitch(this, this._removeCategory) 88 87 }).placeAt(this.listNode); 89 for ( category in this._categories) {90 this._list. insertItem(this._categories[category]);88 for (var category in this._categories) { 89 this._list.appendItem(this._categories[category]); 91 90 } 92 91 this._list.startup(); … … 124 123 _addCategory: function(item) { 125 124 this._categories.push(item); 126 this._list. insertItem(item);125 this._list.appendItem(item); 127 126 }, 128 127 _removeCategory: function(item) { -
Dev/branches/rest-dojo-ui/client/rft/ui/QuestionListView.js
r383 r384 2 2 'dojo/_base/declare', 3 3 'dojo/_base/lang', 4 'dojo/dnd/Source',5 4 'dojo/dom-construct', 6 'dijit/_Container',7 'dijit/_TemplatedMixin',8 'dijit/_WidgetBase',9 'dijit/_WidgetsInTemplateMixin',10 'dijit/form/Button',11 5 'rft/ui/LineWithActionsWidget', 12 ' dojo/text!./templates/OrderedDndList.html'6 'rft/ui/OrderedList' 13 7 ],function( 14 8 declare, 15 9 lang, 16 Source,17 10 domConstruct, 18 _Container,19 _TemplatedMixin,20 _WidgetBase,21 _WidgetsInTemplateMixin,22 Button,23 11 LineWithActionsWidget, 24 templateString12 OrderedList 25 13 ){ 26 return declare('rft.ui.OrderedDndList',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{ 27 templateString: templateString, 14 return declare('rft.ui.QuestionListView',[OrderedList],{ 28 15 baseClass: 'rftSurveyListView', 29 type: 'text', 30 source: null, 16 type: 'question', 31 17 32 postCreate: function() { 33 if (this.title) { 34 this.titleNode.innerHTML = this.title; 35 } else { 36 this.domNode.removeChild(this.titleNode); 37 } 38 39 this.source = new Source(this.sourceNode, { 40 accept: [this.type], 41 horizontal: false, 42 singular: true, 43 creator: lang.hitch(this, this._createQuestionDndItem) 18 _createAvatarNode: function(item){ 19 return domConstruct.create("div",{ 20 'class': 'dragAvatar', 21 innerHTML: item.title 44 22 }); 45 46 new Button({47 label: "Move up",48 showLabel: false,49 iconClass: "rftIcon rftIconFullArrowUp",50 baseClass: "rftBlockButton",51 'class': "trans",52 onClick: lang.hitch(this, function() {53 this._moveSelectedItem("up");54 })55 }, this.btnListMoveUp);56 57 new Button({58 label: "Move down",59 showLabel: false,60 iconClass: "rftIcon rftIconFullArrowDown",61 baseClass: "rftBlockButton",62 'class': "trans",63 onClick: lang.hitch(this, function() {64 this._moveSelectedItem("down");65 })66 }, this.btnListMoveDown);67 23 }, 68 _createQuestionDndItem: function(item, hint) { 69 var node; 70 71 if (hint == "avatar") { 72 node = domConstruct.create("div",{ 73 'class': 'dragAvatar', 74 innerHTML: item.title 75 }); 76 } else { 77 var w = new LineWithActionsWidget({ 78 title: item.title, 79 'class': "inheritBgColor", 80 actions: { 81 "Remove" : { 82 // w not bound in hitch, because it's 83 // not initialized when hitch is called. 84 callback: lang.hitch(this, function(){ 85 this._removeItem(w); 86 }), 87 properties: { 88 blockButton: false, 89 icon: "Delete", 90 modifiers: "white", 91 label: "Remove" 92 } 93 }, 94 "Info" : { 95 callback: function(){ item.description && alert(item.description); }, 96 properties: { 97 blockButton: false, 98 icon: "Inspect", 99 modifiers: "white", 100 label: "Show info" 101 } 24 _createListNode: function(item) { 25 var w = new LineWithActionsWidget({ 26 title: item.title, 27 'class': "inheritBgColor", 28 actions: { 29 "Remove" : { 30 callback: lang.hitch(this, 'removeItem', item), 31 properties: { 32 blockButton: false, 33 icon: "Delete", 34 modifiers: "white", 35 label: "Remove" 36 } 37 }, 38 "Info" : { 39 callback: function(){ item.description && alert(item.description); }, 40 properties: { 41 blockButton: false, 42 icon: "Inspect", 43 modifiers: "white", 44 label: "Show info" 102 45 } 103 46 } 104 });105 w.startup();106 node = w.domNode;107 }108 return {109 node: node,110 data: item,111 type: "question"112 };113 },114 _moveSelectedItem: function(dir) {115 var node = this.source.getSelectedNodes()[0];116 if (node) {117 if (dir == "up") {118 if (node.previousSibling) {119 return node.parentNode.insertBefore(node, node.previousSibling);120 } else {121 return false;122 }123 124 } else if (dir == "down") {125 if (node.nextSibling) {126 return node.parentNode.insertBefore(node.nextSibling, node);127 } else {128 return false;129 }130 } else {131 throw "Invalid move direction passed!";132 47 } 133 } else {134 return false;135 }136 },137 insertItem: function(item) {138 var anchor = this.source.getSelectedNodes()[0];139 if (anchor) {140 this.source.insertNodes(false,[item], false, anchor);141 } else {142 this.appendItem(item);143 }144 },145 appendItem: function(item) {146 this.source.insertNodes(false,[item]);147 },148 getItems: function() {149 return this.source.getAllNodes()150 .map(function(node){151 return this.source.getItem(node.id).data;152 },this);153 },154 deleteItems: function() {155 this.source.getAllNodes()156 .forEach(function(node){157 node.destroy();158 48 }); 159 this.source.sync(); 160 }, 161 _removeItem: function(widget){ 162 widget.destroy(); 163 this.source.sync(); 49 w.startup(); 50 return w.domNode; 164 51 } 165 52 }); -
Dev/branches/rest-dojo-ui/client/rft/ui/TabbedQuestionBrowser.js
r382 r384 77 77 }; 78 78 this._fillTopicSelector(topic,category); 79 w.on('include',lang.hitch(this,this.onSelect));80 79 } 81 80 }, … … 107 106 } 108 107 } else { 109 console.warn(' Busycount <= 0 when _done is called.');108 console.warn('_done() was called more times than _busy().'); 110 109 } 111 110 }, 112 onSelect: function(question) {} 111 destroy: function() { 112 this._busyWidget.destroyRecursive(); 113 this.inherited(arguments); 114 } 113 115 }); 114 116 });
Note: See TracChangeset
for help on using the changeset viewer.