source: Dev/trunk/src/client/dojox/app/tests/notNestedTestApp/views/V2.js

Last change on this file was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 3.4 KB
Line 
1define(["dojo/dom", "dojo/dom-style", "dojo/_base/connect","dijit/registry", "dojo/sniff", "dojox/mobile/TransitionEvent"],
2function(dom, domStyle, connect, registry, has, TransitionEvent){
3                var _connectResults = []; // events connect result
4                var     list = null;
5                var listId = 'list2';
6                var backId = 'sc2back1';
7                var insert10Id = 'sc2insert10x';
8                var app = null;
9                var MODULE = "V2";
10
11        var loadMore = function(){
12                if(!app){
13                        return;
14                }
15                if(!app.listStart){
16                        app.listStart = 1;
17                        app.listCount = 5;
18                }
19                setTimeout(function(){ // to simulate network latency
20                        for(var i = app.listStart; i < app.listStart+5; i++){
21                                var newdata = {'label': 'Item #'+i};
22                                app.stores.longlistStore.store.put(newdata);
23                        }
24                        app.listStart += app.listCount;
25                        app.listTotal = app.listStart-1;
26                        return false;
27                }, 500);
28        };
29        return {
30                init: function(){
31                        app = this.app;
32                       
33                        var connectResult = connect.connect(dom.byId(insert10Id), "click", function(){
34                                //Add 10 items to the end of the model
35                                loadMore();
36                        });
37                        _connectResults.push(connectResult);
38                },
39
40
41                beforeActivate: function(){
42                        // summary:
43                        //              view life cycle beforeActivate()
44                        //console.log(MODULE+" beforeActivate");
45                        if(dom.byId(backId) && !has("phone")){
46                                domStyle.set(dom.byId(backId), "visibility", "hidden"); // hide the back button in tablet mode
47                        }
48
49                        if(registry.byId("heading1")){
50                                registry.byId("heading1").labelDivNode.innerHTML = "Long List Two";
51                        }
52
53                        app.list2 = registry.byId(listId);
54
55                        list = app.list2;
56                        if(!list.store){
57                                list.setStore(app.stores.longlistStore.store);
58                        }
59
60                        if(dom.byId("tab1WrapperA")){
61                                domStyle.set(dom.byId("tab1WrapperA"), "visibility", "visible");  // show the nav view if it being used
62                                domStyle.set(dom.byId("tab1WrapperB"), "visibility", "visible");  // show the nav view if it being used
63                        }
64                },
65                afterActivate: function(){
66                        //console.log(MODULE+" afterActivate");
67                        if(!this.app.timedAutoFlow && !this.app.timed100Loops){
68                                return;
69                        }
70                        if(!this.app.loopCount){
71                                this.app.loopCount = 0;
72                                console.log("V2:afterActivate loopCount = 0 start timer");
73                                console.time("timing transition loop");
74                        }
75                        this.app.loopCount++;
76                        //console.log(MODULE+" afterActivate this.app.loopCount="+this.app.loopCount);
77                        var liWidget = null;
78                        if(this.app.timed100Loops){
79                                if(this.app.loopCount < 100) {
80                                        liWidget = registry.byId("dojox_mobile_ListItem_6"); //0 - P1,S1,V1 6 - P2,S2,Ss2,V5+P2,S2,Ss2,V6
81                                        if(liWidget){
82                                                var ev = new TransitionEvent(liWidget.domNode, liWidget.params);
83                                                ev.dispatch();
84                                        }
85                                }else{
86                                        console.log("V2:afterActivate loopCount = 100 stop timer");
87                                        console.timeEnd("timing transition loop");
88                                }
89                                return;
90                        }
91                        if(this.app.loopCount === 1){
92                                liWidget = registry.byId("dojox_mobile_ListItem_1"); //Nav2+V2
93                        }else if(this.app.loopCount === 2) {
94                                liWidget = registry.byId("dojox_mobile_ListItem_3"); //V4
95                        }else if(this.app.loopCount === 7) {
96                                liWidget = registry.byId("dojox_mobile_ListItem_0"); //P1,S1,V1
97                        }
98                        if(liWidget){
99                                var ev = new TransitionEvent(liWidget.domNode, liWidget.params);
100                                ev.dispatch();
101                        }
102                },
103                beforeDeactivate: function(){
104                        //console.log(MODULE+" beforeDeactivate");
105                },
106                afterDeactivate: function(){
107                        //console.log(MODULE+" afterDeactivate");
108                },
109
110                destroy: function(){
111                        var connectResult = _connectResults.pop();
112                        while(connectResult){
113                                connect.disconnect(connectResult);
114                                connectResult = _connectResults.pop();
115                        }
116                }
117        };
118});
Note: See TracBrowser for help on using the repository browser.