Skip to content

Commit 7c18991

Browse files
committed
Mobile styles, ready for testing
1 parent 1b3a481 commit 7c18991

File tree

3 files changed

+117
-17
lines changed

3 files changed

+117
-17
lines changed

garden.jade

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ html(lang='en')
3030

3131
- else
3232
a(href= '/JavaScript-Garden/' + lang.id, title=lang.title) #{lang.id}
33+
a(id='top', href='#intro', title='Back to top') #top
34+
a(id='hide_menu', class='tablet') Hide Menu
3335

3436
ul
3537
- each section in navigation
@@ -51,6 +53,8 @@ html(lang='en')
5153

5254
a(id='nav_next_section', href='#') next section
5355
span(class='nav_section_name') section name
56+
57+
a(id='show_menu') show menu
5458

5559
// Sections
5660
- each section in sections

site/javascript/garden.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Sections.prototype = {
99
init: function(attribute) {
1010
this.heights = this.page.nav.find('ul').map(function(idx, ele) {
1111
return $(this).outerHeight();
12-
1312
}).get();
1413

1514
this.links = {
@@ -140,7 +139,8 @@ function Page() {
140139

141140
Page.prototype = {
142141
init: function() {
143-
var that = this;
142+
var that = this,
143+
mainNav = $('#nav_main');
144144

145145
this.scrollLast = 0;
146146
this.window.scroll(function() {
@@ -155,18 +155,31 @@ Page.prototype = {
155155
that.sections.map();
156156
setTimeout(function() {
157157
that.sections.highlight();
158-
159158
}, 10);
160159

161160
// Mobile, for position: fixed
162161
if ($.mobile) {
163-
$('#nav_mobile').css('position', 'absolute');
162+
var navs = $('#nav_mobile, #nav_main');
163+
navs.css('position', 'absolute');
164164
this.window.scroll(function(){
165-
$('#nav_mobile').offset({
165+
navs.offset({
166166
top: that.window.scrollTop()
167167
});
168168
});
169169
}
170+
171+
// Show menu for tablets
172+
$('#show_menu').click(function (){
173+
var scrollTop = $.mobile ? that.window.scrollTop() : 0;
174+
175+
mainNav.slideDown(300).css('top', scrollTop);
176+
return false;
177+
});
178+
179+
$('#nav_main').click(function(){
180+
if(that.window.width() < 1000)
181+
mainNav.slideUp(300);
182+
});
170183
},
171184

172185
onScroll: function() {

site/style/garden.css

Lines changed: 95 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,27 +86,38 @@ nav > div li {
8686
margin-right: 4px;
8787
}
8888

89-
nav > div li a {
90-
padding: 7px 10px 5px 10px;
89+
nav > div li a, #top, #hide_menu {
90+
padding: 7px 10px 9px 10px;
91+
cursor: pointer;
9192
}
9293

9394
nav > div li.active a {
9495
border-top: 4px solid #0D2E4C;
95-
padding: 3px 10px 5px 10px;
96+
padding-top: 3px;
9697
color: #FFC76D;
9798
}
9899

99100
nav > div ul {
100101
height: 40px;
101102
}
102103

104+
#top {
105+
position: absolute;
106+
top: 0;
107+
right: 0;
108+
}
109+
110+
#hide_menu {
111+
display: none;
112+
}
113+
103114
nav li {
104115
font-size: 16px;
105116
margin: 0px;
106117
list-style: none;
107118
}
108119

109-
nav ul li:last-child a {
120+
nav > ul li:last-child a {
110121
padding-bottom: 9px;
111122
}
112123

@@ -262,18 +273,23 @@ section:after {
262273
text-align: center;
263274
}
264275

265-
#object:after { content: '{ }'; }
266-
#array:after { content: '[ ]'; }
276+
/* Not used for desktop version */
277+
nav li h1 a:after {
278+
display: none;
279+
}
280+
281+
nav li.nav_intro h1 a:after { content: 'i'; font-style: italic; }
282+
#object:after, nav li.nav_object h1 a:after { content: '{ }'; }
283+
#array:after, nav li.nav_array h1 a:after { content: '[ ]'; }
284+
#types:after, nav li.nav_types h1 a:after { content: '='; font-weight: bold; }
285+
#core:after, nav li.nav_core h1 a:after { content: 'js'; }
267286

268-
#function:after {
287+
#function:after, nav li.nav_function h1 a:after {
269288
content: 'f(x)';
270289
font-style: italic;
271290
}
272291

273-
#types:after { content: '='; font-weight: bold; }
274-
#core:after { content: 'js'; }
275-
276-
#other:after {
292+
#other:after, nav li.nav_other h1 a:after {
277293
content: '?';
278294
font-size: 100px;
279295
font-family: Arial, Helvetica, sans-serif;
@@ -387,6 +403,15 @@ a abbr {
387403
.dec { color: #606; }
388404
.pln { color: #FFAA3E; }
389405

406+
/* Desktop override */
407+
408+
@media screen and (min-width: 1000px) {
409+
#nav_main {
410+
display: block !important;
411+
top: 0 !important;
412+
}
413+
}
414+
390415
/* "Tablet" Styles */
391416

392417
@media screen and (max-width: 1000px) {
@@ -402,6 +427,59 @@ a abbr {
402427

403428
#nav_main {
404429
display: none;
430+
height: auto;
431+
margin: 0;
432+
width: 100%;
433+
z-index: 100;
434+
padding: 0;
435+
436+
-moz-box-shadow: 0 3px 3px rgba(0, 0, 0, 0.3);
437+
-webkit-box-shadow: 0 3px 3px rgba(0, 0, 0, 0.3);
438+
box-shadow: 0 3px 3px rgba(0, 0, 0, 0.3);
439+
}
440+
441+
#nav_main ul ul {
442+
display: none !important;
443+
}
444+
445+
#nav_main > ul > li {
446+
float: left;
447+
text-align: center;
448+
width: 14.28%;
449+
border-bottom: 0;
450+
}
451+
452+
#nav_main li h1 a {
453+
background-image: none;
454+
height: 70px;
455+
padding: 20px 0 30px;
456+
}
457+
458+
#nav_main li h1 a:after {
459+
display: block;
460+
font-family: Georgia;
461+
font-size: 40px;
462+
font-weight: normal;
463+
margin-top: 10px;
464+
}
465+
466+
#nav_main > div ul {
467+
height: auto;
468+
overflow: hidden;
469+
border-bottom: 1px solid rgba(255, 255, 255, 0.3);
470+
}
471+
472+
nav a:hover,
473+
nav li.active,
474+
nav li.active a {
475+
background-color: #0D2E4C;
476+
}
477+
478+
#hide_menu {
479+
display: block;
480+
position: absolute;
481+
top: 0;
482+
right: 45px;
405483
}
406484

407485
#nav_mobile {
@@ -410,7 +488,7 @@ a abbr {
410488
right: 0;
411489
height: 0;
412490
display: block;
413-
z-index: 1000;
491+
z-index: 50;
414492
}
415493

416494
#nav_mobile a {
@@ -438,6 +516,7 @@ a abbr {
438516

439517
#show_menu {
440518
font-weight: bold;
519+
cursor: pointer;
441520
}
442521

443522
pre {
@@ -487,6 +566,10 @@ screen and (-webkit-min-device-pixel-ratio: 2) {
487566
font-size: 13px;
488567
}
489568

569+
#nav_main > ul > li {
570+
width: 25%;
571+
}
572+
490573
#nav_mobile {
491574
width: 160px;
492575
}

0 commit comments

Comments
 (0)