make this work with pre-23 versions of Gecko by supporting mozRequestAnimationFrame
[lantea.git] / js / ui.js
index d76f915b46d025713b98a165333c1ea4425b1d4f..c2f64af6871f19ef2aa58580807a733e8163e1ac 100644 (file)
--- a/js/ui.js
+++ b/js/ui.js
@@ -2,10 +2,11 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-// Get the best-available indexedDB object.
+// Get the best-available objects for indexedDB and requestAnimationFrame.
 window.indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB || window.msIndexedDB;
-var mainDB;
+window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
 
+var mainDB;
 var gUIHideCountdown = 0;
 var gWaitCounter = 0;
 var gAction, gActionLabel;
@@ -23,7 +24,7 @@ window.onload = function() {
     mSel.add(opt, null);
   }
 
-  var areas = document.getElementsByClassName('overlayArea');
+  var areas = document.getElementsByClassName("overlayArea");
   for (var i = 0; i <= areas.length - 1; i++) {
     areas[i].addEventListener("mouseup", uiEvHandler, false);
     areas[i].addEventListener("mousemove", uiEvHandler, false);
@@ -65,7 +66,7 @@ function postInit(aEvent) {
   gAction.removeEventListener(aEvent.type, postInit, false);
   console.log("init done, draw map.");
   gMapPrefsLoaded = true;
-  resizeAndDraw();
+  gMap.resizeAndDraw();
   gActionLabel.textContent = "";
   gAction.style.display = "none";
   setTracking(document.getElementById("trackCheckbox"));
@@ -83,7 +84,7 @@ function postInit(aEvent) {
 }
 
 window.onresize = function() {
-  resizeAndDraw();
+  gMap.resizeAndDraw();
 }
 
 function initDB(aEvent) {
@@ -208,6 +209,16 @@ function showUploadDialog() {
   dia.classList.remove("hidden");
 }
 
+function showGLWarningDialog() {
+  var dia = document.getElementById("dialogArea");
+  var areas = dia.children;
+  for (var i = 0; i <= areas.length - 1; i++) {
+    areas[i].style.display = "none";
+  }
+  document.getElementById("noGLwarning").style.display = "block";
+  dia.classList.remove("hidden");
+}
+
 function cancelDialog() {
   document.getElementById("dialogArea").classList.add("hidden");
   document.getElementById("uploadTrackButton").disabled = false;