98eaa9fcd5af184286a8a6de56243de5baa7fda3
[outofuni/stafforg.git] / app / www / js / index.js
1 /*
2  * stafforg: crew organizaion app
3  * author: hackbard@hackdaworld.org
4  *
5  */
6
7 /*
8  * Licensed to the Apache Software Foundation (ASF) under one
9  * or more contributor license agreements.  See the NOTICE file
10  * distributed with this work for additional information
11  * regarding copyright ownership.  The ASF licenses this file
12  * to you under the Apache License, Version 2.0 (the
13  * "License"); you may not use this file except in compliance
14  * with the License.  You may obtain a copy of the License at
15  *
16  * http://www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing,
19  * software distributed under the License is distributed on an
20  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21  * KIND, either express or implied.  See the License for the
22  * specific language governing permissions and limitations
23  * under the License.
24  */
25
26 var stafforg = {
27         init: function() {
28                 document.addEventListener('deviceready',this.startup,false);
29                 window.addEventListener('orientationchange',function() {
30                         setTimeout(function() {
31                                 cl("orientation change ...");
32                         },200);
33                 });
34         },
35         startup: function() {
36                 cl("starting stafforg app ...");
37                 // ui
38                 stafforg.activate_subapp('start');
39                 $('.startbtn').click(function(event) {
40                         cl("clicked "+event.target.id);
41                         stafforg.event_action(event,'start');
42                 });
43                 // db
44         },
45         dbcb: function() {
46         },
47         activate_subapp: function(sapp) {
48                 $('.startbtn').each(function() {
49                         var sappname=this.id.replace(/^sel/,'');
50                         var sappid='#'+sappname;
51                         $(sappid).css('height','100%');
52                         if(sappname==sapp)
53                                 $(sappid).css('display','block');
54                         else
55                                 $(sappid).css('display','none');
56                 });
57                 if(sapp=='start') {
58                         var sappid='#'+sapp;
59                         $(sappid).css('height','100%');
60                         $(sappid).css('display','block');
61                 }
62         },
63         event_action: function() {
64         }
65 };
66
67 $(document).ready(function() {
68         if('cordova' in window) {
69                 stafforg.init();
70         }
71         else {
72                 stafforg.startup();
73         }
74 });
75