]> asedeno.scripts.mit.edu Git - bluechips.git/blobdiff - bluechips/public/js/mobile.js
added orientation changing interface
[bluechips.git] / bluechips / public / js / mobile.js
index 6d01307dd55fb988d4032efa13b678da71850855..44090eef895342e21dc227d57ddf060ba448ddd3 100644 (file)
@@ -8,12 +8,35 @@ $(function() {
     console.log("ready()");
 
     $('#tabs a').click(function() {
-        $('div.tab').hide();
         $('#tabs a').removeClass('selected');
         $(this).addClass('selected');
-        $('#tab-' + $(this).attr('id')).show();
+        $('div.tab').hide();
+
+        /* See if that tab has been rendered to the page. */
+        tabname = '#tab-' + $(this).attr('id');
+        tab = $(tabname);
+        if(tab.children().length < 1) {
+            /* If not, return true so that we actually reload. */
+            tab.load($(this).attr('href') + ' ' + tabname + '> *');
+        }
+        tab.show();
         return false;
     });
+    $('#tabs a.selected').click();
+
+    $('body').bind('orientationchange', function() {
+        switch(window.orientation) {
+            case 0:
+            case 180:
+                $('body').attr('id', 'portrait');
+                break;
+            case -90:
+            case 90:
+                $('body').attr('id', 'landscape');
+                break;
+        }
+    });
+    $('body').trigger('orientationchange');
 
     console.log("ready() done");
 });