web/static/res/js/inchidebar.js
author ymh <ymh.work@gmail.com>
Tue, 12 Feb 2013 10:54:34 +0100
changeset 134 678b07d351ef
parent 124 8d2376eb825c
permissions -rw-r--r--
Added tag V01.25 for changeset fe9ca5cd905e

var incManageHideBar = function()
{
	this.timeoutBarPointer;
	this.goUp;
	this.canShowCursor;
    this.callback;

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

        if (this.callback !== null) {
            this.callback(state);
        }
    };

    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(callback) {
        this.goUp = false;
        this.canShowCursor = incPlayer.ipad;
        this.callback = callback;

        if (!incPlayer.ipad) {
            // Hide bar and pointer in seconds
            this.hideBarPointerTimeout(4000);
        }

        if (incPlayer.ipad) {
            document.ontouchmove = function(e) {
                if (typeof( popupOn ) === "undefined" || !popupOn) {
                    e.preventDefault();
                }
            }; 

            document.ontouchstart = function() {
                incHideBar.showBarPointerOnAction(6000);
            };         

        } else {
            document.onmousemove = function() {
                incHideBar.showBarPointerOnAction(4000);
            };
        }
    };
};

var incHideBar = new incManageHideBar();