-
Notifications
You must be signed in to change notification settings - Fork 12
/
menu.js
124 lines (118 loc) · 4.96 KB
/
menu.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
$(document).ready(function () {
var link = $('.play-menu li a'),
expander = $('.show-entries-hover'),
container = $('.menu-container'),
pos1 = 0,
pos2 = "46px",
pos3 = "92px",
pos4 = "138px",
pos5 = "184px",
pos6 = "230px",
left = "-200px"
storeColor = "#444",
appsColor = "#B3C833",
moviesColor = "#CE5043",
musicColor = "#FB8521",
booksColor = "#1AA1E1",
devicesColor = "#658092";
// Initialization, start positions
$('li#store').css('top', pos1);
$('li#store .menu-entry-text').css({'background-color' : storeColor,'color' : 'white'});
$('li#apps').css('top', pos2);
$('li#movies').css('top', pos3);
$('li#music').css('top', pos4);
$('li#books').css('top', pos5);
$('li#devices').css('top', pos6);
// Click function standard
link.each(function() {
$(this).on('click', function() {
// Remove Background-Color when i click on an unselected item
// Hiding is removed for debugging
link.not($(this)).parent().addClass('hide');
expander.removeClass('hidden');
link.not($(this)).children('.menu-entry-text').attr("style", "");
// Hide all menus except the right one
link.not($(this)).next('.sub-menu').css({'opacity' : 0}).addClass('index').removeClass('active');
$(this).next('.sub-menu').css({'opacity' : 1}).addClass('active');
// Changing Background-Color and Position
// "Store"
// This also resets all menu entries to their initial order
if ($(this).children().hasClass('store')) {
$(this).children('.menu-entry-text').css({'background-color' : storeColor,'color' : 'white'});
$(this).parent().css('top', pos1).removeClass('hide');
$('#apps').css('top', pos2);
$('#movies').css('top', pos3);
$('#music').css('top', pos4);
$('#books').css('top', pos5);
$('#devices').css('top', pos6);
$('li').removeClass('hide');
}
// "Apps"
else if ($(this).children().hasClass('apps')) {
$(this).children('.menu-entry-text').css({'background-color' : appsColor,'color' : 'white'});
$(this).parent().css('top', pos1).removeClass('hide');
$('#store').css('top', pos6);
$('#movies').css('top', pos2);
$('#music').css('top', pos3);
$('#books').css('top', pos4);
$('#devices').css('top', pos5);
$('.hide').css({'left': left, 'opacity' : 0, 'transition' : 'all 0s', '-webkit-transition' : 'all 0s', '-moz-transition' : 'all 0s' });
}
// "Movies"
else if ($(this).children().hasClass('movies')) {
$(this).children('.menu-entry-text').css({'background-color' : moviesColor,'color' : 'white'});
$(this).parent().css('top', pos1).removeClass('hide');
$('#store').css('top', pos6);
$('#apps').css('top', pos2);
$('#music').css('top', pos3);
$('#books').css('top', pos4);
$('#devices').css('top', pos5);
$('.hide').css({'left': left, 'opacity' : 0, 'transition' : 'all 0s', '-webkit-transition' : 'all 0s', '-moz-transition' : 'all 0s' });
}
// "Music"
else if ($(this).children().hasClass('music')) {
$(this).children('.menu-entry-text').css({'background-color' : musicColor,'color' : 'white'});
$(this).parent().css('top', pos1).removeClass('hide');
$('#store').css('top', pos6);
$('#apps').css('top', pos2);
$('#movies').css('top', pos3);
$('#books').css('top', pos4);
$('#devices').css('top', pos5);
$('.hide').css({'left': left, 'opacity' : 0, 'transition' : 'all 0s', '-webkit-transition' : 'all 0s', '-moz-transition' : 'all 0s' });
}
// "Books"
else if ($(this).children().hasClass('books')) {
$(this).children('.menu-entry-text').css({'background-color' : booksColor,'color' : 'white'});
$(this).parent().css('top', pos1).removeClass('hide');
$('#store').css('top', pos6);
$('#apps').css('top', pos2);
$('#movies').css('top', pos3);
$('#music').css('top', pos4);
$('#devices').css('top', pos5);
$('.hide').css({'left': left, 'opacity' : 0, 'transition' : 'all 0s', '-webkit-transition' : 'all 0s', '-moz-transition' : 'all 0s' });
}
// "Devices"
else if ($(this).children().hasClass('devices')) {
$(this).children('.menu-entry-text').css({'background-color' : devicesColor,'color' : 'white'});
$(this).parent().css('top', pos1).removeClass('hide');
$('#store').css('top', pos6);
$('#apps').css('top', pos2);
$('#movies').css('top', pos3);
$('#music').css('top', pos4);
$('#books').css('top', pos5);
$('.hide').css({'left': left, 'opacity' : 0, 'transition' : 'all 0s', '-webkit-transition' : 'all 0s', '-moz-transition' : 'all 0s' });
}
return false;
});
});
// Hide menu when you leave the menu container
container.on('mouseleave', function() {
$('.hide').css({'left': left, 'opacity' : 0, 'transition' : '', '-webkit-transition' : '', '-moz-transition' : ''});
$('.sub-menu').removeClass('index');
})
// Show the menu when you hover the trigger
expander.on('mouseover', function() {
$('.hide').css({'left': 0, 'opacity' : 1, 'transition' : '', '-webkit-transition' : '', '-moz-transition' : ''});
$('.sub-menu').addClass('index');
});
});