Debian Codegraph @

dojox/app/tests/longListTestApp/views/LongList4.js

raw symbols SCIP
1 define(["dojo/dom", "dojo/dom-style", "dojo/_base/connect","dijit/registry", "dojo/sniff"],
2 function(dom, domStyle, connect, registry, has){
3 var _connectResults = []; // events connect result
4 var list = null;
5 var listId = 'list4';
6 var backId = 'sc4back1';
7 var insert10Id = 'sc4insert10x';
8 var app = null;
9
10 var loadMore = function(){
11 if(!app){
12 return;
13 }
14 if(!app.listStart){
15 app.listStart = 1;
16 app.listCount = 5;
17 }
18 setTimeout(function(){ // to simulate network latency
19 for(var i = app.listStart; i < app.listStart+5; i++){
20 var newdata = {'label': 'Item #'+i};
21 app.stores.longlistStore.store.put(newdata);
22 }
23 app.listStart += app.listCount;
24 app.listTotal = app.listStart-1;
25 return false;
26 }, 500);
27 };
28 return {
29 init: function(){
30 app = this.app;
31
32 var connectResult = connect.connect(dom.byId(insert10Id), "click", function(){
33 //Add 10 items to the end of the model
34 loadMore();
35 });
36 _connectResults.push(connectResult);
37 },
38
39
40 beforeActivate: function(){
41 // summary:
42 // view life cycle beforeActivate()
43 if(dom.byId(backId) && !has("phone")){
44 domStyle.set(dom.byId(backId), "visibility", "hidden"); // hide the back button in tablet mode
45 }
46
47 app.list4 = registry.byId(listId);
48
49 list = app.list4;
50 if(!list.store){
51 list.setStore(app.stores.longlistStore.store);
52 }
53
54 if(dom.byId("tab1WrapperA")){
55 domStyle.set(dom.byId("tab1WrapperA"), "visibility", "visible"); // show the nav view if it being used
56 domStyle.set(dom.byId("tab1WrapperB"), "visibility", "visible"); // show the nav view if it being used
57 }
58 },
59
60 destroy: function(){
61 var connectResult = _connectResults.pop();
62 while(connectResult){
63 connect.disconnect(connectResult);
64 connectResult = _connectResults.pop();
65 }
66 }
67 };
68 });