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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
78
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
     1
var incManageHideBar = function()
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
     2
{
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
     3
	this.timeoutBarPointer;
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
     4
	this.goUp;
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
     5
	this.canShowCursor;
103
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
     6
    this.callback;
78
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
     7
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
     8
    this.showBarPointer = function(state) {
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
     9
    	if (state) {
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    10
    		// Bar
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    11
    		this.goUp = true;
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    12
    		$("#controlbar").stop(true);
124
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 103
diff changeset
    13
			$("#controlbar").animate({bottom: 0}, 500, function() {incHideBar.goUp = false;});
78
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    14
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    15
			if (!incPlayer.ipad) {
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    16
                // Pointer
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    17
                document.body.style.cursor = "default";
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    18
                this.canShowCursor = false;
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    19
            }
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    20
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    21
    	} else {
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    22
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    23
            if (incPlayer.ipad && !incPlayer.playerIsReady) {
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    24
                // we don't hide the bar on ipad if the player is not in play
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    25
                return;
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    26
            }
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    27
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    28
    		// Bar
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    29
			$("#controlbar").animate({bottom: -70}, 2000, function() {});
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    30
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    31
            if (!incPlayer.ipad) {
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    32
                // Pointer
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    33
                document.body.style.cursor = "url(data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==), pointer";
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    34
                setTimeout(function() {incHideBar.canShowCursor = true;}, 300);
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    35
            }
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    36
		}
103
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
    37
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
    38
        if (this.callback !== null) {
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
    39
            this.callback(state);
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
    40
        }
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
    41
    };
78
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    42
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    43
    this.hideBarPointerTimeout = function(time) {
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    44
    	this.timeoutBarPointer = setTimeout(function() {	
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    45
    		incHideBar.showBarPointer(false);
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    46
    	}, time);
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    47
	};
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    48
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    49
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    50
	this.showBarPointerOnAction = function(hideTime) {
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    51
    	// Controls
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    52
    	if (!this.goUp && this.canShowCursor) {
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    53
        	this.showBarPointer(true);
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    54
            if (this.timeoutBarPointer) {
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    55
	            window.clearTimeout(this.timeoutBarPointer);	                	
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    56
            }
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    57
			this.hideBarPointerTimeout(hideTime);
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    58
    	}
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    59
    };
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    60
103
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
    61
    this.init = function(callback) {
78
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    62
        this.goUp = false;
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    63
        this.canShowCursor = incPlayer.ipad;
103
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
    64
        this.callback = callback;
78
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    65
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    66
        if (!incPlayer.ipad) {
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    67
            // Hide bar and pointer in seconds
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    68
            this.hideBarPointerTimeout(4000);
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    69
        }
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    70
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    71
        if (incPlayer.ipad) {
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    72
            document.ontouchmove = function(e) {
103
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
    73
                if (typeof( popupOn ) === "undefined" || !popupOn) {
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
    74
                    e.preventDefault();
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
    75
                }
78
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    76
            }; 
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    77
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    78
            document.ontouchstart = function() {
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    79
                incHideBar.showBarPointerOnAction(6000);
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    80
            };         
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    81
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    82
        } else {
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    83
            document.onmousemove = function() {
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    84
                incHideBar.showBarPointerOnAction(4000);
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    85
            };
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    86
        }
124
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 103
diff changeset
    87
    };
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 103
diff changeset
    88
};
78
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    89
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    90
var incHideBar = new incManageHideBar();