web/static/res/js/inchidebar.js
author Edwin Razafimahatratra <edwin@robotalismsoft.com>
Wed, 16 Jan 2013 21:26:15 +0100
changeset 80 46b897524cc4
parent 78 8c3f0b94d056
child 103 be6c1f9cc258
permissions -rw-r--r--
resync

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();