Skip to content

Commit a05b6d7

Browse files
committed
Update to Leo v1.7.0
1 parent 722c485 commit a05b6d7

File tree

7 files changed

+111
-11
lines changed

7 files changed

+111
-11
lines changed

source/assets/javascripts/application.js.coffee.erb

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
Leo = {}
1+
# -------------------------------------
2+
# Setup
3+
# -> Namespace setup
4+
# -------------------------------------
5+
6+
@Leo = {}
7+
@Leo.Pager = {}
28

39
# -------------------------------------
410
# Heading Links
11+
# -> Adds an anchor link next to each heading
12+
#
13+
# options.els - the heading elements
514
# -------------------------------------
615

716
Leo.headingLinks = (options) ->
@@ -13,14 +22,71 @@ Leo.headingLinks = (options) ->
1322

1423
# -------------------------------------
1524
# Read Time
25+
# -> Adds an estimated reading time to each page
26+
#
27+
# options.text - the text of the page
28+
# options.element - the element to append the reading time to
29+
# options.wordsPerMinute - the words-per-minute to calculate against
1630
# -------------------------------------
1731

1832
Leo.readTime = (options) ->
1933
time = Math.ceil(options.text.split(' ').length / options.wordsPerMinute)
2034
options.element.append("<b>#{time} minute read</b>")
2135

36+
# -------------------------------------
37+
# Pager
38+
# -> Adds keyboard navigation for pages
39+
#
40+
# id - the page id
41+
# -------------------------------------
42+
43+
Leo.Pager = do ->
44+
45+
pageIndex = 0
46+
47+
pages = []
48+
49+
shortcuts =
50+
'next': 39
51+
'prev': 37
52+
53+
init = (id) ->
54+
pageIndex = id
55+
getPages()
56+
setEventHandlers()
57+
58+
getPages = ->
59+
<% get_pages.each do |p| %>
60+
pages.push("<%= p.url %>")
61+
<% end %>
62+
63+
setEventHandlers = ->
64+
$(document).on 'keydown', (e) ->
65+
switch getKeyCode(e)
66+
when shortcuts.next then gotoPage('next')
67+
when shortcuts.prev then gotoPage('prev')
68+
69+
getKeyCode = (e) ->
70+
e = e || window.event
71+
charCode = e.keyCode || e.which
72+
charCode
73+
74+
gotoPage = (dir) ->
75+
switch dir
76+
when 'next'
77+
unless pageIndex == pages.length
78+
window.location = pages[pageIndex]
79+
when 'prev'
80+
unless pageIndex == 1
81+
window.location = pages[pageIndex - 2]
82+
83+
init: init
84+
2285
# -------------------------------------
2386
# Slugify
87+
# -> Converts a string into a title slug
88+
#
89+
# text - the text to convert
2490
# -------------------------------------
2591

2692
Leo.slugify = (text) ->
@@ -44,6 +110,8 @@ jQuery ($) ->
44110
})
45111
<% end %>
46112

113+
Leo.Pager.init( $('body').data('id') )
114+
47115
$('.toggle').on 'click', (e) ->
48116
e.preventDefault()
49117
$(@).toggleClass('is-active')

source/assets/stylesheets/components/_well.sass

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
// *************************************
1313
1414
.well
15-
margin-bottom: $b-whitespace
16-
margin-top: $b-whitespace
15+
+respond-to($breakpoint-tablet)
16+
margin-bottom: $b-whitespace
17+
margin-top: $b-whitespace
1718

1819
// -------------------------------------
1920
// Modifiers

source/assets/stylesheets/foundation/_base.sass

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,29 @@ html
1414

1515
body
1616
font-size: 100%
17-
overflow-x: hidden
17+
&.is-sidebar-open
18+
overflow-y: hidden
19+
position: fixed
20+
+respond-to($breakpoint-tablet)
21+
position: static
1822

1923
.content
24+
+transform(translateX(0))
25+
+transition-transform(0.3s ease-in-out)
2026
margin-bottom: $b-whitespace-xl
2127
padding-top: $b-whitespace-xs
2228
@if $sidebar-collapsible
2329
.is-sidebar-open &
24-
margin-left: $sidebar-width
30+
+transform(translateX($sidebar-width))
31+
margin-left: 0
32+
+respond-to($breakpoint-tablet)
33+
+transform(translateX(0))
34+
margin-left: $sidebar-width
2535
@else
26-
margin-left: $sidebar-width
36+
.is-sidebar-open &
37+
+transform(translateX($sidebar-width))
38+
+respond-to($breakpoint-tablet)
39+
margin-left: $sidebar-width
2740

2841
// -------------------------------------
2942
// Block Content
@@ -82,8 +95,9 @@ h4, .h4,
8295
h5, .h5,
8396
h6, .h6
8497
position: relative
85-
&:hover > a
86-
display: block
98+
+respond-to($breakpoint-desk)
99+
&:hover > a
100+
display: block
87101

88102
h1, .h1
89103
font-size: 200%

source/assets/stylesheets/foundation/_config.sass

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ $f-base: 'Merriweather', serif !default
6363
$f-header: 'Open Sans', serif !default
6464
$f-mono: Courier, monospace !default
6565

66+
// ----- Breakpoints ----- //
67+
68+
$breakpoint-desk: 57.5em !default
69+
$breakpoint-tablet: 41.25em !default
70+
6671
// ----- Header ----- //
6772
6873
$header-background: $c-invert !default

source/assets/stylesheets/structures/_sidebar.sass

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,17 @@
1616
.sidebar
1717
@extend .boxSizing
1818
@if $sidebar-collapsible
19+
+transform(translateX(-100%))
1920
+transition-transform(0.3s ease-in-out)
21+
@else
2022
+transform(translateX(-100%))
23+
+transition-transform(0.3s ease-in-out)
24+
+respond-to($breakpoint-tablet)
25+
+transform(translateX(0))
2126
background: $sidebar-background
2227
bottom: 0
2328
left: 0
29+
overflow: scroll
2430
position: fixed
2531
top: 0
2632
width: $sidebar-width
@@ -33,6 +39,9 @@
3339
@if $sidebar-collapsible
3440
.sidebar.is-open
3541
+transform(translateX(0))
42+
@else
43+
.sidebar.is-open
44+
+transform(translateX(0))
3645

3746
// -------------------------------------
3847
// Scaffolding

source/assets/stylesheets/structures/_toggle.sass

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@
1616
@if $sidebar-collapsible
1717
display: block
1818
@else
19-
display: none
19+
+respond-to($breakpoint-tablet)
20+
display: none
2021
height: 5 * $toggle-height
2122
left: $b-whitespace
22-
position: fixed
23+
position: absolute
2324
top: $b-whitespace
2425
-webkit-backface-visibility: hidden
2526
width: $toggle-width
2627
z-index: 20
28+
+respond-to($breakpoint-tablet)
29+
position: fixed
2730

2831
// -------------------------------------
2932
// States

source/layouts/layout.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
= partial 'shared/google_analytics' if build?
1515

16-
%body{ class: page_classes }
16+
%body{ class: page_classes, 'data-id' => current_page.data.priority }
1717

1818
= link_to '#', class: 'toggle' do
1919
.toggle-icn

0 commit comments

Comments
 (0)