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