Roo/mobile/Mobile.js
[roojs1] / Roo / mobile / Mobile.js
1 //<Script type="text/javascript">
2
3 /**
4  * experiments with mobile UI's
5  * 
6  * usage: - mobile is a top level widget..
7  * 
8  * x = new Roo.mobile.Mobile {
9     items : {
10         Roo.mobile.Page
11         *}
12      }
13  * 
14  */
15
16 Roo.mobile.Mobile = function(cfg) {
17      
18     this.addEvents({ 
19         'ready' : true
20     });
21     Roo.util.Observable.call(this,cfg);
22     Roo.onReady(function() {
23         this.init();
24         this.fireEvent('ready');
25     },this,false);
26     
27 }
28
29
30 Roo.extend(Roo.mobile.Mobile, Roo.util.Observable, {
31      init: function()
32     {
33         //var page = iui.getSelectedPage();
34         ///var locPage = getPageFromLoc();
35             
36         //if (page)
37         //        iui.showPage(page);
38         
39         //if (locPage && (locPage != page))
40         //    iui.showPage(locPage);
41         Roo.get(document.head).createChild(
42             '<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>'
43         );
44         //setTimeout(preloadImages, 0);
45         if (typeof window.onorientationchange == "object")
46         {
47             window.onorientationchange=this.orientChangeHandler;
48             hasOrientationEvent = true;
49             this.orientChangeHandler.defer(0, this);
50         }
51         this.checkOrientAndLocation.defer(0, this);
52         this.checkTimer = setInterval(checkOrientAndLocation, 300);
53     }
54     orientChangeHandler: function()
55     {
56         if (window.orientation == 90 || window.orientation = -90) {
57             this.setOrientation("landscape");
58             return;
59         }
60         this.setOrientation("portrait");
61         
62     },
63     
64     setOrientation: function (orient)
65     {
66         document.body.setAttribute("orient", orient);
67         setTimeout(scrollTo, 100, 0, 1);
68     },
69
70 });
71
72