source: Dev/trunk/src/client/dojox/app/tests/nestedTestApp/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.3 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                        app.list2 = registry.byId(listId);
50
51                        list = app.list2;
52                        if(!list.store){
53                                list.setStore(app.stores.longlistStore.store);
54                        }
55
56                        if(dom.byId("tab1WrapperA")){
57                                domStyle.set(dom.byId("tab1WrapperA"), "visibility", "visible");  // show the nav view if it being used
58                                domStyle.set(dom.byId("tab1WrapperB"), "visibility", "visible");  // show the nav view if it being used
59                        }
60                },
61                afterActivate: function(){
62                        //console.log(MODULE+" afterActivate");
63                        if(!this.app.timedAutoFlow && !this.app.timed100Loops){
64                                return;
65                        }
66                        if(!this.app.loopCount){
67                                this.app.loopCount = 0;
68                                console.log("V2:afterActivate loopCount = 0 start timer");
69                                console.time("timing transition loop");
70                        }
71                        this.app.loopCount++;
72                        //console.log(MODULE+" afterActivate this.app.loopCount="+this.app.loopCount);
73                        var liWidget = null;
74                        if(this.app.timed100Loops){
75                                if(this.app.loopCount < 100) {
76                                        liWidget = registry.byId("dojox_mobile_ListItem_6"); //0 - P1,S1,V1 6 - P2,S2,Ss2,V5+P2,S2,Ss2,V6
77                                        if(liWidget){
78                                                var ev = new TransitionEvent(liWidget.domNode, liWidget.params);
79                                                ev.dispatch();
80                                        }
81                                }else{
82                                        console.log("V2:afterActivate loopCount = 100 stop timer");
83                                        console.timeEnd("timing transition loop");
84                                }
85                                return;
86                        }
87                        if(this.app.loopCount === 1){
88                                liWidget = registry.byId("dojox_mobile_ListItem_1"); //V2
89                        }else if(this.app.loopCount === 2) {
90                                liWidget = registry.byId("dojox_mobile_ListItem_5"); //V4
91                        }else if(this.app.loopCount === 7) {
92                                liWidget = registry.byId("dojox_mobile_ListItem_0"); //P1,S1,V1
93                        }
94                        if(liWidget){
95                                var ev = new TransitionEvent(liWidget.domNode, liWidget.params);
96                                ev.dispatch();
97                        }
98                },
99                beforeDeactivate: function(){
100                        //console.log(MODULE+" beforeDeactivate");
101                },
102                afterDeactivate: function(){
103                        //console.log(MODULE+" afterDeactivate");
104                },
105
106                destroy: function(){
107                        var connectResult = _connectResults.pop();
108                        while(connectResult){
109                                connect.disconnect(connectResult);
110                                connectResult = _connectResults.pop();
111                        }
112                }
113        };
114});
Note: See TracBrowser for help on using the repository browser.