Skip to content

Commit 6b725a9

Browse files
committed
simple hack to make the template responsive
This uses some JavaScript to move all the navigational items to a hamburger menu on smaller screens. Only list items will be copied. There is no RTL support. This will not work without JavaScript. It's a hack.
1 parent 46d2a96 commit 6b725a9

File tree

3 files changed

+170
-0
lines changed

3 files changed

+170
-0
lines changed

script.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* Copy all the navigational links into a single mobile menu
3+
*/
4+
jQuery(function () {
5+
var $mobilemenu = jQuery('<div>')
6+
.addClass('mobile-menu');
7+
8+
9+
var $logo = jQuery('#p-logo')
10+
.clone()
11+
.removeAttr('id')
12+
.addClass('mobile-logo')
13+
;
14+
15+
var $search = jQuery('#p-search form')
16+
.clone()
17+
.removeAttr('id')
18+
.addClass('mobile-search');
19+
$search.find('#simpleSearch').removeAttr('id');
20+
$search.find('button').text('🔍');
21+
22+
$mobilemenu.append($search);
23+
24+
jQuery([
25+
'p-navigation',
26+
'left-navigation',
27+
'right-navigation',
28+
'p-coll-print_export',
29+
'p-tb',
30+
'p-personal'
31+
]).each(function (i, name) {
32+
var ul = jQuery('<ul>');
33+
$mobilemenu.append(ul);
34+
35+
var filter = '#' + name + ' li';
36+
ul.addClass('mobile-' + name);
37+
ul.append(
38+
jQuery(filter)
39+
.not('.selected')
40+
.clone()
41+
.removeAttr('id')
42+
);
43+
});
44+
45+
var $hamburger = jQuery('<div>')
46+
.addClass('mobile-hamburger')
47+
.click(function () {
48+
$mobilemenu.toggleClass('open');
49+
$hamburger.toggleClass('open')
50+
});
51+
52+
53+
jQuery('body')
54+
.append([
55+
$mobilemenu,
56+
$hamburger
57+
])
58+
.prepend(
59+
$logo
60+
)
61+
;
62+
});

static/mobile.less

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
div.mobile-hamburger,
2+
div.mobile-menu,
3+
div.mobile-logo {
4+
display: none;
5+
}
6+
7+
8+
@media only screen and (max-width: 750px) {
9+
10+
div.mobile-hamburger {
11+
display: block;
12+
position: absolute;
13+
top: 0;
14+
left: 0;
15+
z-index: 1000;
16+
17+
cursor: pointer;
18+
font-size: 2.5rem;
19+
line-height: 3rem;
20+
21+
width: 3rem;
22+
height: 3rem;
23+
text-align: center;
24+
25+
&::before {
26+
content: '';
27+
}
28+
}
29+
30+
div.mobile-hamburger.open {
31+
&::before {
32+
content: '';
33+
}
34+
}
35+
36+
div.mobile-logo {
37+
display: block;
38+
a {
39+
display: block;
40+
width: 100%;
41+
height: 3rem;
42+
background-size: contain;
43+
background-repeat: no-repeat;
44+
background-position: center;
45+
}
46+
}
47+
48+
div.mobile-menu {
49+
position: absolute;
50+
top: 0;
51+
left: 0;
52+
53+
height: 100%;
54+
overflow-y: auto;
55+
56+
z-index: 500;
57+
background-color: @ini_background;
58+
box-shadow: 5px 0 5px @ini_border;
59+
60+
padding-top: 3rem;
61+
62+
a {
63+
color: @ini_existing;
64+
}
65+
66+
.mobile-search {
67+
display: block;
68+
margin: 0.25em;
69+
input,
70+
button {
71+
line-height: inherit;
72+
}
73+
}
74+
75+
ul {
76+
padding: 0;
77+
list-style-type: none;
78+
list-style-image: none !important;
79+
margin: 0.25em 0;
80+
81+
border-bottom: 1px solid @ini_border;
82+
83+
li {
84+
margin: 0;
85+
padding: 0.25em;
86+
}
87+
}
88+
}
89+
90+
div.mobile-menu.open {
91+
display: block;
92+
}
93+
94+
#page-base,
95+
#head-base,
96+
#head,
97+
#panel {
98+
display: none;
99+
}
100+
101+
div#content,
102+
div#footer {
103+
margin-left: 0;
104+
}
105+
106+
}

style.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ user/rtl.css = rtl
7676

7777

7878

79+
static/mobile.less = all
80+
7981

8082
; This section is used to configure some placeholder values used in
8183
; the stylesheets. Changing this file is the simplest method to

0 commit comments

Comments
 (0)