- Timestamp:
- 07/27/12 14:52:36 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/rft/ui/TabbedQuestionBrowser.js
r370 r382 2 2 'dojo/_base/declare', 3 3 'dojo/_base/lang', 4 'dojo/_base/window', 4 5 'dijit/layout/ContentPane', 5 6 'dijit/layout/TabContainer', 7 'dojox/widget/Standby', 6 8 'rft/store', 7 9 'rft/ui/Selector', 8 10 'dojo/domReady!' 9 11 ], 10 function(declare,lang, ContentPane,TabContainer,store,Selector){12 function(declare,lang,win,ContentPane,TabContainer,Standby,store,Selector){ 11 13 return declare('rft.ui.TabbedQuestionBrowser',[TabContainer],{ 12 14 tabPosition: 'left-h', … … 16 18 17 19 _dataMap: null, 20 _busyCount: 0, 18 21 constructor: function(){ 19 22 this._dataMap = {}; 20 23 }, 21 24 startup: function() { 25 this._busyWidget = new Standby({ 26 target: this.domNode, 27 duration: 200 28 }).placeAt(win.body()); 29 this._busyWidget.startup(); 22 30 this.watch("selectedChildWidget",lang.hitch(this,function(name,oldTab,newTab){ 23 31 this._fillCategoryTab(newTab.__category); … … 44 52 var categoryMap = this._dataMap[category]; 45 53 if (!categoryMap._filled) { 54 this._busy(); 46 55 categoryMap._filled = true; 47 56 store.query('_design/default/_view/questions', {reduce:true,group:true,group_level:2,startkey:[category],endkey:[category,{}]}) 48 57 .forPairs(lang.hitch(this,function(value,key){ 49 58 this._createTopicSelector(key[1],category,value); 59 })).then(lang.hitch(this,function(){ 60 this._done(); 50 61 })); 51 62 } … … 73 84 var topicMap = categoryMap[topic]; 74 85 if (!topicMap._filled) { 86 topicMap._filled = true; 87 this._busy(); 75 88 store.query('_design/default/_view/questions', {reduce:false,include_docs:true,key:[category,topic]}) 76 89 .forEach(lang.hitch(this,function(value){ 77 90 topicMap._widget.addItem(value); 91 })).then(lang.hitch(this,function(){ 92 this._done(); 78 93 })); 94 } 95 }, 96 _busy: function() { 97 if ( this._busyCount === 0 ) { 98 this._busyWidget.show(); 99 } 100 this._busyCount++; 101 }, 102 _done: function() { 103 if ( this._busyCount > 0 ) { 104 this._busyCount--; 105 if ( this._busyCount === 0 ) { 106 this._busyWidget.hide(); 107 } 108 } else { 109 console.warn('Busycount <= 0 when _done is called.'); 79 110 } 80 111 },
Note: See TracChangeset
for help on using the changeset viewer.