source: Dev/trunk/src/client/dojox/app/tests/scrollableTestApp2/views/Scrollable3.js

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

Added Dojo 1.9.3 release.

File size: 2.9 KB
Line 
1define(["dojo/dom", "dojo/dom-style", "dojo/_base/connect", "dojo/_base/lang","dijit/registry", "dojox/mvc/at", "dojox/mobile/TransitionEvent",
2                "dojox/mvc/Repeat", "dojox/mvc/getStateful", "dojox/mvc/Output", "dojo/sniff"],
3function(dom, domStyle, connect, lang, registry, at, TransitionEvent, Repeat, getStateful, Output, has){
4        var _connectResults = []; // events connect result
5
6        var repeatmodel = null; //repeat view data model
7       
8        // these ids are updated here and in the html file to avoid duplicate ids
9        var backId = 'sc3back1';
10        var insert1Id = 'sc3insert1x';
11        var insert10Id = 'sc3insert10x';
12        var remove10Id = 'sc3remove10x';
13
14        var app = null;
15
16        return {
17                // repeat view init
18                init: function(){
19                        app = this.app;
20
21                        repeatmodel = this.loadedModels.repeatmodels;
22                        var connectResult;
23
24                        connectResult = connect.connect(dom.byId(insert1Id), "click", lang.hitch(this,function(e){
25                                this.app.insertResult(repeatmodel.model.length-1,e);
26                        }));
27                        _connectResults.push(connectResult);
28
29                        connectResult = connect.connect(dom.byId(insert10Id), "click", function(){
30                                //Add 10 items to the end of the model
31                                app.showProgressIndicator(true);
32                                setTimeout(lang.hitch(this,function(){
33                                        var maxentries = repeatmodel.model.length+10;
34                                        for(var i = repeatmodel.model.length; i < maxentries; i++){
35                                                var data = {id:Math.random(), "First": "First"+repeatmodel.model.length, "Last": "Last"+repeatmodel.model.length, "Location": "CA", "Office": "", "Email": "", "Tel": "", "Fax": ""};
36                                                repeatmodel.model.splice(repeatmodel.model.length, 0, new getStateful(data));                                   
37                                        }
38                                        app.showProgressIndicator(false);
39                                }), 100);                               
40                               
41                        });
42                        _connectResults.push(connectResult);
43
44                        connectResult = connect.connect(dom.byId(remove10Id), "click", function(){
45                                //remove 10 items to the end of the model
46                                app.showProgressIndicator(true);
47                                setTimeout(lang.hitch(this,function(){                         
48                                        var maxentries = repeatmodel.model.length-10;
49                                        for(var i = repeatmodel.model.length; i >= maxentries; i--){
50                                                repeatmodel.model.splice(i, 1);
51                                        }
52                                        repeatmodel.set("cursorIndex", 0);             
53                                        app.showProgressIndicator(false);
54                                }), 100);                               
55                        });
56                        _connectResults.push(connectResult);
57                },
58
59
60                beforeActivate: function(){
61                        // summary:
62                        //              view life cycle beforeActivate()
63                        if(dom.byId(backId) && !has("phone")){
64                                domStyle.set(dom.byId(backId), "visibility", "hidden"); // hide the back button in tablet mode
65                        }
66                        if(dom.byId("tab1WrapperA")){
67                                domStyle.set(dom.byId("tab1WrapperA"), "visibility", "visible");  // show the nav view if it being used
68                                domStyle.set(dom.byId("tab1WrapperB"), "visibility", "visible");  // show the nav view if it being used
69                        }
70                },
71               
72               
73                destroy: function(){
74                        var connectResult = _connectResults.pop();
75                        while(connectResult){
76                                connect.disconnect(connectResult);
77                                connectResult = _connectResults.pop();
78                        }
79                }
80        };
81});
Note: See TracBrowser for help on using the repository browser.