web/static/res/js/inchidebar.js
changeset 78 8c3f0b94d056
child 103 be6c1f9cc258
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/static/res/js/inchidebar.js	Wed Jan 16 08:26:00 2013 +0100
@@ -0,0 +1,82 @@
+var incManageHideBar = function()
+{
+	this.timeoutBarPointer;
+	this.goUp;
+	this.canShowCursor;
+
+    this.showBarPointer = function(state) {
+    	if (state) {
+    		// Bar
+    		this.goUp = true;
+    		$("#controlbar").stop(true);
+			$("#controlbar").animate({bottom: 0}, 500, function() {incHideBar.goUp = false;})
+
+			if (!incPlayer.ipad) {
+                // Pointer
+                document.body.style.cursor = "default";
+                this.canShowCursor = false;
+            }
+
+    	} else {
+
+            if (incPlayer.ipad && !incPlayer.playerIsReady) {
+                // we don't hide the bar on ipad if the player is not in play
+                return;
+            }
+
+    		// Bar
+			$("#controlbar").animate({bottom: -70}, 2000, function() {});
+
+            if (!incPlayer.ipad) {
+                // Pointer
+                document.body.style.cursor = "url(data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==), pointer";
+                setTimeout(function() {incHideBar.canShowCursor = true;}, 300);
+            }
+		}
+    }
+
+    this.hideBarPointerTimeout = function(time) {
+    	this.timeoutBarPointer = setTimeout(function() {	
+    		incHideBar.showBarPointer(false);
+    	}, time);
+	};
+
+
+	this.showBarPointerOnAction = function(hideTime) {
+    	// Controls
+    	if (!this.goUp && this.canShowCursor) {
+        	this.showBarPointer(true);
+            if (this.timeoutBarPointer) {
+	            window.clearTimeout(this.timeoutBarPointer);	                	
+            }
+			this.hideBarPointerTimeout(hideTime);
+    	}
+    };
+
+    this.init = function() {
+        this.goUp = false;
+        this.canShowCursor = incPlayer.ipad;
+
+        if (!incPlayer.ipad) {
+            // Hide bar and pointer in seconds
+            this.hideBarPointerTimeout(4000);
+        }
+
+        if (incPlayer.ipad) {
+            document.ontouchmove = function(e) {
+                e.preventDefault();
+            }; 
+
+            document.ontouchstart = function() {
+                incHideBar.showBarPointerOnAction(6000);
+            };         
+
+        } else {
+            document.onmousemove = function() {
+                incHideBar.showBarPointerOnAction(4000);
+            };
+        }
+    }
+}
+
+var incHideBar = new incManageHideBar();
\ No newline at end of file