-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaterialize.js
88 lines (81 loc) · 3.44 KB
/
materialize.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
<!-- BEGIN MENU -->
jQuery('.materialize-menu-button-wrapper').on('touchstart click', function(e) {
'use strict';
e.preventDefault();
if(jQuery('.materialize-background-color').hasClass('materialize-background-color-active'))
{
/* hide main wrapper */
jQuery('.materialize-main-wrapper').removeClass('materialize-main-wrapper-active');
/* hide background color */
jQuery('.materialize-background-color').removeClass('materialize-background-color-active');
/* hide background image */
jQuery('.materialize-background-image').removeClass('materialize-background-image-active');
/* hide expanded menu button */
jQuery('.materialize-menu-button-wrapper').removeClass('materialize-menu-active');
/* hide menu */
jQuery('.materialize-menu').removeClass('materialize-menu-active');
} else {
/* show main wrapper */
jQuery('.materialize-main-wrapper').addClass('materialize-main-wrapper-active');
/* show background color */
jQuery('.materialize-background-color').addClass('materialize-background-color-active');
/* show background image */
jQuery('.materialize-background-image').addClass('materialize-background-image-active');
/* show expanded menu button */
jQuery('.materialize-menu-button-wrapper').addClass('materialize-menu-active');
/* show menu */
jQuery('.materialize-menu').addClass('materialize-menu-active');
}
});
<!-- END MENU -->
<!-- BEGIN HIDE MENU WHEN ESC BUTTON PRESSED -->
jQuery(document).keyup(function(e) {
if (e.keyCode == 27) {
/* hide main wrapper */
jQuery('.materialize-main-wrapper').removeClass('materialize-main-wrapper-active');
/* hide background color */
jQuery('.materialize-background-color').removeClass('materialize-background-color-active');
/* hide background image */
jQuery('.materialize-background-image').removeClass('materialize-background-image-active');
/* hide expanded menu button */
jQuery('.materialize-menu-button-wrapper').removeClass('materialize-menu-active');
/* hide menu */
jQuery('.materialize-menu').removeClass('materialize-menu-active');
return false;
}
});
<!-- END HIDE MENU WHEN ESC BUTTON PRESSED -->
<!-- BEGIN SHOW SEARCH FORM -->
jQuery('.materialize-search-button, .materialize-search-button-right').on('touchstart click', function(e) {
'use strict';
e.preventDefault();
if(jQuery('.materialize-search-wrapper').hasClass('materialize-search-wrapper-active'))
{
/* hide search field */
jQuery('.materialize-search-wrapper').removeClass('materialize-search-wrapper-active');
jQuery('.materialize-search-wrapper #searchform #s').blur();
} else {
/* show search field */
setTimeout(function(){
jQuery('.materialize-search-wrapper').addClass('materialize-search-wrapper-active');
},100);
/* focus search field */
jQuery('.materialize-search-wrapper #searchform #s').focus();
}
});
<!-- END SHOW SEARCH FORM -->
<!-- BEGIN HIDE SEARCH FORM -->
jQuery('.materialize-search-close-icon').on('touchstart click', function(e) {
'use strict';
e.preventDefault();
/* hide search field */
jQuery('.materialize-search-wrapper').removeClass('materialize-search-wrapper-active');
jQuery('.materialize-search-wrapper #searchform #s').blur();
});
<!-- END HIDE SEARCH FORM -->
<!-- BEGIN REMOVE MENU DESCRIPTION DIV IF NO DESCRIPTION ENTERED -->
jQuery(document).ready(function() {
'use strict';
jQuery('.materialize-menu-item-description:empty').remove();
});
<!-- END REMOVE MENU DESCRIPTION DIV IF NO DESCRIPTION ENTERED -->