Skip to content

Commit bb42e14

Browse files
committed
Merge pull request BonsaiDen#276 from fediev/master
Fix the mobile menu problems and clean up js code.
2 parents 16f9e21 + a275c8c commit bb42e14

File tree

4 files changed

+27
-55
lines changed

4 files changed

+27
-55
lines changed

garden.jade

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ html(lang=language)
2424
// Navigation
2525
nav(id='nav_main')
2626
div
27-
ul
27+
ul
2828
- each lang in languages
2929
li(class=lang.id === language ? 'active' : '')
3030
- if (lang.id === baseLanguage)
@@ -54,7 +54,7 @@ html(lang=language)
5454

5555
a(id='nav_next_section', href='#') next section
5656
span(class='nav_section_name') section name
57-
57+
5858
a(id='show_menu') show menu
5959

6060
// Sections
@@ -78,21 +78,18 @@ html(lang=language)
7878
// Footer
7979
footer
8080
p Copyright ©. Built with
81-
|
82-
a(href='http://nodejs.org/') Node.js
83-
| using a
84-
a(href='https://github.com/visionmedia/jade/') jade
85-
| template.
81+
|
82+
a(href='http://nodejs.org/') Node.js
83+
| using a
84+
a(href='https://github.com/visionmedia/jade/') jade
85+
| template.
8686

8787
script(src='//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js')
88-
88+
8989
- if (language === baseLanguage)
9090
script(src='javascript/prettify.js')
91-
script(src='javascript/plugin.js')
9291
script(src='javascript/garden.js')
93-
92+
9493
- else
9594
script(src='../javascript/prettify.js')
96-
script(src='../javascript/plugin.js')
9795
script(src='../javascript/garden.js')
98-

site/javascript/garden.js

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,18 @@ Sections.prototype = {
6060
}
6161
},
6262

63-
expand: function (sectionName) {
63+
expand: function(sectionName) {
6464
var nav = this.page.nav,
6565
index = nav.find('a[href=#' + sectionName + ']')
6666
.closest('nav > ul > li').index();
6767

6868
var height = this.page.window.height()
6969
- $('nav > div').height()
70-
- (33 * this.heights.length),
70+
- (33 * this.heights.length);
7171

72-
sections = [],
73-
currentHeight = 0,
74-
distance = 0;
72+
var sections = [],
73+
currentHeight = 0,
74+
distance = 0;
7575

7676
while ((currentHeight + this.heights[index]) < height) {
7777
sections.push(index);
@@ -135,56 +135,43 @@ function Page() {
135135
section: null,
136136
articule: null
137137
});
138-
138+
139139
this.sections = new Sections(this);
140140
this.init();
141141
}
142142

143143
Page.prototype = {
144144
init: function() {
145145
var that = this,
146-
mainNav = $('#nav_main');
146+
$mainNav = $('#nav_main');
147147

148148
$.extend(this, {
149149
scrollLast: 0,
150150
resizeTimeout: null
151151
});
152-
152+
153153
this.window.scroll(function() {
154154
that.onScroll();
155155
});
156-
156+
157157
this.window.resize(function() {
158158
that.onResize();
159159
});
160160

161-
that.sections.map();
161+
this.sections.map();
162162
setTimeout(function() {
163163
that.sections.highlight();
164164
}, 10);
165165

166-
// Mobile, for position: fixed
167-
if ($.mobile) {
168-
var navs = $('#nav_mobile, #nav_main');
169-
navs.css('position', 'absolute');
170-
this.window.scroll(function(){
171-
navs.offset({
172-
top: that.window.scrollTop()
173-
});
174-
});
175-
}
176-
177-
// Show menu for tablets
178-
$('#show_menu').click(function (){
179-
var scrollTop = $.mobile ? that.window.scrollTop() : 0;
180-
181-
mainNav.slideDown(300).css('top', scrollTop);
166+
// Show menu for tablets and smart phones
167+
$('#show_menu').click(function() {
168+
$mainNav.slideDown(300);
182169
return false;
183170
});
184-
185-
$('#nav_main').click(function(){
171+
172+
$mainNav.click(function() {
186173
if(that.window.width() < 1000)
187-
mainNav.slideUp(300, function() {this.removeAttr('style');});
174+
$mainNav.slideUp(300, function() { $mainNav.removeAttr('style'); });
188175
});
189176
},
190177

site/javascript/plugin.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

site/style/garden.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,10 +443,10 @@ a abbr {
443443

444444
/* "Tablet" Styles */
445445

446-
@media screen and (max-width: 1000px) {
446+
@media screen and (max-width: 999px) {
447447
body {
448448
width: 100%;
449-
max-width: 1000px;
449+
max-width: 999px;
450450
overflow-x: hidden;
451451
}
452452

0 commit comments

Comments
 (0)