Adding smoother transitions between events
[profile/ivi/webdialer.git] / js / dialer.js
index e36ab23..d9bf702 100644 (file)
@@ -7,8 +7,8 @@
  *
  */
 
-var mainCanvas, bgCanvas, buttonCanvas;
-var mainCtx, bgCtx, buttonCtx, mouseCtx;
+var mainCanvas, bgCanvas, buttonCanvas,callCanvas;
+var mainCtx, bgCtx, buttonCtx, mouseCtx, callCtx;
 var drawn = false;
 var screenHeight;
 var screenWidth;
@@ -72,6 +72,8 @@ function resizeCanvas()
     $(buttonCanvas).attr('height', screenHeight);
     $(mouseClicksLayer).attr('width', screenWidth);
     $(mouseClicksLayer).attr('height', screenHeight);
+    $(callCanvas).attr('width', screenWidth);
+    $(callCanvas).attr('height', screenHeight);
 
     if (currentPage)
        initPages();   
@@ -100,6 +102,7 @@ function loadImages(sources, callback)
 
 function init() 
 {   
+    document.documentElement.style.overflow = 'hidden';
     var activeAccount = null;
     var listener = {
        "onAccountUpdated": function(account) {}, 
@@ -136,11 +139,13 @@ function init()
     bgCanvas = document.getElementById("bgCanvas");
     buttonCanvas = document.getElementById("buttonCanvas");
     mouseClicksLayer = document.getElementById("mouseClicks");
+    callCanvas = document.getElementById("callCanvas");
 
     mainCtx = mainCanvas.getContext("2d");
     bgCtx = bgCanvas.getContext("2d");
     buttonCtx = buttonCanvas.getContext("2d");
     mouseCtx = mouseClicksLayer.getContext("2d");
+    callCtx = callCanvas.getContext("2d");
 
     var sources = {
 phoneIcon: "images/bluetooth-smartphone.png",
@@ -198,7 +203,8 @@ onIncoming: function(call) {
                initCallPage(currentState);    
                updateNumber(call.callData.LineIdentification);
                updateCallStateText("Incoming Call...");
-               switchMenu(callPage);
+               animateIncoming();
+               //switchMenu(callPage);
            },
 onDialing: function(call) {
               activeCall = call;
@@ -207,22 +213,37 @@ onAlerting: function(call) {
                activeCall = call;
            },
 onDisconnected: function(call, disconnectReason) {
-                   activeCall = null;
-                   stopTimer();
-                   switchMenu(mainPage);
+                   if (currentState !== "idle")
+                   {
+                       currentState = "idle";
+                       activeCall = null;
+                       stopTimer();
+                       animateFinished();
+                   }
+                   //switchMenu(mainPage);
                },
 onDisconnecting: function(call) {
-                    stopTimer();
-                    switchMenu(mainPage);
+                    if (currentState !== "idle")
+                    {
+                        currentState = "idle";
+                        stopTimer();
+                        animateFinished();
+                    }
+                    //switchMenu(mainPage);
                 },
 onAccepted: function(call) {
                startTimer();
+               initButtons("activeCall");            
                updateCallStateText("Active");
+               callPage.drawMenu();
                activeCall = call;
            },
 onActivated: function(call) {
-                updateCallStateText("Active");
                 startTimer();
+                initButtons("activeCall");            
+                updateCallStateText("Active");
+                callPage.drawMenu();
+                activeCall = call;
             },
 onError: function(call){
             console.log("onError: "); console.log(call);
@@ -233,7 +254,7 @@ onError: function(call){
 
 function switchMenu(nextMenu)
 {   
-    currentPage.visible = false;               
+    //currentPage.visible = false;             
     currentPage = nextMenu; 
     currentPage.visible = true;
     currentPage.drawMenu();