octopress-littlefoot 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 16dd03dc1ff93fa99090da6ba84800187cf291fa
4
+ data.tar.gz: 2195fd2926f8de16d25290e4be44e0ed8ec7c060
5
+ SHA512:
6
+ metadata.gz: 8ff472d3d9fd385a90a18debc5b03efbb47c9fa8a0349ec450cab0bb700ffe26e1cf27d24c147376a14f05066b8862411a2b843032cc7d9e7bd3eca78b550eb2
7
+ data.tar.gz: ce69ee5deadb2e786f05cbe97c126735be33a4c21a79958b5acc3d9e7c591595d32660bd94a190f115aab68c12d4a489e11a0828caaf8a92f354d3a08fb936c2
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Brandon Mathis
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,55 @@
1
+ # Octopress Littlefoot
2
+
3
+ Fancy footnote popovers with native Javascript, for any Jekyll site.
4
+
5
+ [![Build Status](http://img.shields.io/travis/octopress/littlefoot.svg)](https://travis-ci.org/octopress/littlefoot)
6
+ [![Gem Version](http://img.shields.io/gem/v/octopress-littlefoot.svg)](https://rubygems.org/gems/octopress-littlefoot)
7
+ [![License](http://img.shields.io/:license-mit-blue.svg)](http://octopress.mit-license.org)
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ## Installation
14
+
15
+ If you're using bundler add this gem to your site's Gemfile in the `:jekyll_plugins` group:
16
+
17
+ group :jekyll_plugins do
18
+ gem 'octopress-littlefoot'
19
+ end
20
+
21
+ Then install the gem with Bundler
22
+
23
+ $ bundle
24
+
25
+ To install manually without bundler:
26
+
27
+ $ gem install octopress-littlefoot
28
+
29
+ Then add the gem to your Jekyll configuration.
30
+
31
+ gems:
32
+ - octopress-littlefoot
33
+
34
+ ## Setup
35
+
36
+ Add `{% js_asset_tag %}` and `{% css_asset_tag %}` to your
37
+ site's layout to automatically add Littlefoot's assets to your site
38
+ whenever jekyll builds it.
39
+
40
+
41
+ To add a footnote to a Markdown document, use this syntax:
42
+
43
+ ```markdown
44
+ Here is some text containing a footnote.[^1]
45
+
46
+ [^1]: Here is the text of the footnote itself.
47
+ ```
48
+
49
+ ## Contributing
50
+
51
+ 1. Fork it ( https://github.com/octopress/littlefoot/fork )
52
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
53
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
54
+ 4. Push to the branch (`git push origin my-new-feature`)
55
+ 5. Create a new Pull Request
@@ -0,0 +1,10 @@
1
+ theme: light # light or dark
2
+
3
+ # To override footnote theme colors uncomment and change the values below:
4
+ #background: '#fff' # footnote popover background
5
+ #text: '#444' # popover text color
6
+
7
+ button-color: inherit # matches text color
8
+
9
+ font-size: .9em
10
+ max-width: 500px
@@ -0,0 +1,230 @@
1
+ (function(){
2
+
3
+ var LittleFoot = {
4
+ initialize: function(){
5
+ self = this
6
+
7
+ document.addEventListener("DOMContentLoaded", function(event) {
8
+ var anchors = document.querySelectorAll("sup[id^=fnref] a")
9
+
10
+ if (anchors.length > 0) {
11
+
12
+ Array.prototype.forEach.call(anchors, function(anchor){
13
+ self.setup(anchor)
14
+ })
15
+
16
+ document.addEventListener("click", self.click.bind(self))
17
+
18
+ document.querySelector('div.footnotes').remove()
19
+ }
20
+ })
21
+
22
+ },
23
+
24
+ setup: function (anchor) {
25
+ // We want to add the footnote adjacent to the footnote <sup> element
26
+ var sup = getParent(anchor, 'sup')
27
+ sup.insertAdjacentHTML('afterend', this.template.wrapper(anchor));
28
+
29
+ sup.nextElementSibling.footnoteContent = this.template.footnoteContent(anchor)
30
+ sup.remove()
31
+ },
32
+
33
+ click: function (event) {
34
+ self = this
35
+
36
+ // Did a footnote button trigger the click event?
37
+ var button = getParent(event.target, '.littlefoot-button')
38
+
39
+ // Close if the click was outisde of the open footnote
40
+ if (!getParent(event.target, '.littlefoot-container.is-open')) {
41
+ self.close()
42
+ }
43
+
44
+ // Toggle if the click was inside the button
45
+ if (button) { self.toggle(button) }
46
+
47
+ },
48
+
49
+ // Watch the resize event to continually position the footnote popover
50
+ resize: function () {
51
+ self = this
52
+
53
+ // Only reposition this every 50 miliseconds to avoid constant repainting
54
+ window.clearTimeout(self.timeout)
55
+ self.timeout = window.setTimeout( function() {
56
+ self.sizeFootnote()
57
+ self.positionFootnote()
58
+ }, 50)
59
+ },
60
+
61
+ toggle: function (el) {
62
+ if (this.footnote.el){
63
+ this.close()
64
+ } else {
65
+ this.open(el)
66
+ }
67
+ },
68
+
69
+ open: function (el) {
70
+ this.footnote.el = getParent(el, '.littlefoot-container')
71
+ var popover = this.footnote.popover()
72
+
73
+ this.footnote.el.classList.add('is-open')
74
+ this.sizeFootnote()
75
+
76
+ popover.classList.remove('is-hidden')
77
+
78
+ this.positionFootnote()
79
+ popover.classList.add('is-visible')
80
+ window.addEventListener("resize", self.resize.bind(self))
81
+ },
82
+
83
+ close: function () {
84
+ if (this.footnote.el) {
85
+ var popover = this.footnote.popover()
86
+ var footnote = this.footnote.el
87
+
88
+ popover.classList.remove('is-visible')
89
+ window.removeEventListener("resize", self.resize.bind(self))
90
+
91
+ this.footnote.el = null
92
+
93
+ setTimeout(function(){
94
+ footnote.classList.remove('is-open')
95
+ popover.classList.add('is-hidden')
96
+ }, 250)
97
+ }
98
+ },
99
+
100
+ footnote: {
101
+ el: null,
102
+
103
+ popover: function() {
104
+ if (this.el) {
105
+ return this.el.querySelector('.littlefoot-popover')
106
+ }
107
+ },
108
+
109
+ panel: function() {
110
+ if (this.el) {
111
+ return this.el.querySelector('.littlefoot-footnote')
112
+ }
113
+ }
114
+ },
115
+
116
+ positionFootnote: function () {
117
+ panel = this.footnote.panel()
118
+ if (panel && panel.offsetWidth > 0) {
119
+ this.setOrientation()
120
+ this.setPosition()
121
+ }
122
+ },
123
+
124
+ setOrientation: function () {
125
+ var wrapper = this.footnote.el
126
+ wrapper.classList.remove('open-up', 'open-down')
127
+ wrapper.classList.add('open-down')
128
+ var pos = this.footnote.panel().getBoundingClientRect()
129
+
130
+ wrapper.classList.remove('open-up', 'open-down')
131
+
132
+
133
+ if (pos.bottom > window.innerHeight) {
134
+ wrapper.classList.add('open-up')
135
+ } else {
136
+ wrapper.classList.add('open-down')
137
+ }
138
+ },
139
+
140
+ setPosition: function () {
141
+ var container = this.footnote.el.parentElement
142
+ var contentWidth = container.offsetWidth
143
+ var panel = this.footnote.panel()
144
+ var left = this.footnote.el.offsetLeft - container.offsetLeft
145
+ var overlap = panel.offsetWidth + left
146
+
147
+ panel.setAttribute('style', '')
148
+
149
+ if (overlap > contentWidth) {
150
+ panel.setAttribute('style', 'left: -' + String(overlap - contentWidth) + 'px;')
151
+ }
152
+ },
153
+
154
+ sizeFootnote: function() {
155
+ var context = this.footnote.el.parentElement
156
+ var el = document.createElement("div")
157
+ //el.classList.add('littlefoot-container')
158
+ el.insertAdjacentHTML('beforeend', '<div class="littlefoot-test-wrapper"><div class="littlefoot-test">'+ this.footnote.el.footnoteContent+'</div></div>')
159
+ context.appendChild(el)
160
+ var size = {
161
+ h: el.firstChild.offsetHeight + 5,
162
+ w: el.firstChild.offsetWidth + 5
163
+ }
164
+ context.removeChild(el)
165
+
166
+ this.footnote.el.querySelector('.littlefoot-footnote-content').setAttribute('style', 'max-width:'+size.w+'px;')
167
+ },
168
+
169
+ template: {
170
+
171
+ wrapper: function (el) {
172
+ return ' <div class="littlefoot-container open-down">'+this.button(el)+this.popover(el)+'</div>'
173
+ },
174
+
175
+ button: function (el) {
176
+ return '<button class="littlefoot-button" title="view footnote #'+el.textContent+'">'
177
+ +'<svg class="littlefoot-graphic" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 98"><path class="littlefoot-graphic-path" fill="#fff" d="M200 25c0-13.8-11.2-25-25-25H25C11.2 0 0 11.2 0 25v48c0 13.8 11.2 25 25 25h150c13.8 0 25-11.2 25-25V25zM50.5 64.3c-8.3 0-15-6.7-15-15s6.7-15 15-15 15 6.7 15 15-6.8 15-15 15zm50 0c-8.3 0-15-6.7-15-15s6.7-15 15-15 15 6.7 15 15-6.8 15-15 15zm49 0c-8.3 0-15-6.7-15-15s6.7-15 15-15 15 6.7 15 15-6.8 15-15 15z"/></svg>'
178
+ +'</button>'
179
+ },
180
+
181
+ popover: function (el) {
182
+ return '<aside class="littlefoot-popover is-hidden">'
183
+ +'<div class="littlefoot-footnote">'
184
+ +'<div class="littlefoot-footnote-wrapper">'
185
+ +'<div class="littlefoot-footnote-content">'
186
+ +this.footnoteContent(el)
187
+ +'</div>'
188
+ +'</div>'
189
+ +'</div><div class="littlefoot-popover-triangle"></div>'
190
+ +'</aside>'
191
+ },
192
+
193
+ footnoteContent: function(anchor) {
194
+
195
+ // Find the footnote from the id in the anchor's href
196
+ var id = anchor.getAttribute('href').replace(':', "\\:")
197
+ var footnote = document.querySelector(id)
198
+
199
+ // Remove the "return to content" link
200
+ var link = footnote.querySelector('a[href^=\\#fnref]')
201
+ if (link) link.remove()
202
+ var containerWidth = footnote.offsetParent.parentElement.offsetWidth
203
+ return footnote.innerHTML
204
+ }
205
+ }
206
+ }
207
+
208
+ var getParent = function(start, classname) {
209
+ var func;
210
+ var element = start;
211
+
212
+ ['matches', 'webkitMatchesSelector', 'mozMatchesSelector', 'msMatchesSelector', 'oMatchesSelector'].some(function(fn) {
213
+ if (typeof document.body[fn] == 'function') {
214
+ func = fn;
215
+ return true;
216
+ }
217
+ return false;
218
+ });
219
+
220
+ while (element !== null) {
221
+ if (element !== null && element[func](classname)) {
222
+ return element;
223
+ }
224
+ element = element.parentElement;
225
+ }
226
+ }
227
+
228
+ LittleFoot.initialize()
229
+ window.LittleFoot = LittleFoot
230
+ })()
@@ -0,0 +1,25 @@
1
+ @mixin triangle($direction, $color, $size) {
2
+ @if $direction == left {
3
+ border-bottom: $size solid transparent;
4
+ border-right: $size solid $color;
5
+ border-top: $size solid transparent;
6
+ }
7
+ @else if $direction == right {
8
+ border-bottom: $size solid transparent;
9
+ border-left: $size solid $color;
10
+ border-top: $size solid transparent;
11
+ }
12
+ @else if $direction == up {
13
+ border-bottom: $size solid $color;
14
+ border-left: $size solid transparent;
15
+ border-right: $size solid transparent;
16
+ }
17
+ @else if $direction == down {
18
+ border-right: $size solid transparent;
19
+ border-left: $size solid transparent;
20
+ border-top: $size solid $color;
21
+ }
22
+
23
+ height: 0;
24
+ width: 0;
25
+ }
@@ -0,0 +1,172 @@
1
+ @import 'utils';
2
+
3
+ {% if plugin.theme == 'light' %}
4
+ $footnote-bg: #fff;
5
+ $footnote-text: #444;
6
+ {% elsif plugin.theme == 'dark' %}
7
+ $footnote-bg: #444;
8
+ $footnote-text: #ccc;
9
+ {% endif %}
10
+
11
+ {% if plugin.background %}
12
+ $footnote-bg: {{ plugin.background }};
13
+ {% endif %}
14
+
15
+ {% if plugin.text %}
16
+ $footnote-text: {{ plugin.text }};
17
+ {% endif %}
18
+
19
+ $footnote-button: {{ plugin.button-color }};
20
+ $footnote-font-size: {{ plugin.font-size }};
21
+ $footnote-max-width: {{ plugin.max-width }};
22
+
23
+ [class^=littlefoot] {
24
+ box-sizing: border-box;
25
+ }
26
+
27
+ .littlefoot-container {
28
+ position: relative;
29
+ display: inline-block;
30
+ }
31
+
32
+ .littlefoot-button {
33
+ border: none;
34
+ padding: 0;
35
+ background: none;
36
+ margin: 0;
37
+ outline: none;
38
+ cursor: pointer;
39
+ font-size: .75em;
40
+ vertical-align: middle;
41
+ color: $footnote-button;
42
+ transition: {
43
+ property: opacity, color;
44
+ duration: .25s;
45
+ timing-function: ease-out;
46
+ }
47
+ opacity: .3;
48
+ &:hover, .is-open & {
49
+ opacity: .5;
50
+ }
51
+ }
52
+
53
+ .littlefoot-graphic {
54
+ width: 2em;
55
+ }
56
+
57
+ .littlefoot-graphic-path {
58
+ fill: currentColor;
59
+ }
60
+
61
+ .littlefoot-popover {
62
+ position: absolute;
63
+ z-index: 10;
64
+ opacity: 0;
65
+ transform: scale(.8,.8);
66
+ transition: {
67
+ property: opacity, transform;
68
+ duration: .25s;
69
+ timing-function: ease-in-out;
70
+ }
71
+
72
+ .open-down & {
73
+ top: 1.6em;
74
+ }
75
+ .open-up & {
76
+ bottom: 1.6em;
77
+ }
78
+
79
+ &.is-visible {
80
+ opacity: 1;
81
+ transform: scale(1,1);
82
+ }
83
+
84
+ &.is-hidden {
85
+ display: none;
86
+ }
87
+
88
+ }
89
+
90
+ .littlefoot-popover-triangle {
91
+ position: absolute;
92
+ top: -.7em;
93
+ height: .7em;
94
+ width: 2.2em;
95
+ overflow: hidden;
96
+ &:after, &:before {
97
+ position: absolute;
98
+ left: .25em;
99
+ display: block;
100
+ width: 1em;
101
+ height: 1em;
102
+ transform: rotate(45deg);
103
+ }
104
+
105
+ &:after {
106
+ z-index: -1;
107
+ background: transparent;
108
+ box-shadow: rgba(#000, .2) 1px 1px 6px;
109
+ }
110
+
111
+ &:before {
112
+ z-index: 1;
113
+ background: $footnote-bg;
114
+ }
115
+
116
+ .is-open &:before, .is-open &:after {
117
+ content: "";
118
+ }
119
+
120
+ .open-down &:before, .open-down &:after {
121
+ bottom: -.5em;
122
+ }
123
+
124
+ .open-up &:before, .open-up &:after {
125
+ top: -.5em;
126
+ }
127
+ }
128
+
129
+ .littlefoot-footnote {
130
+ font-size: $footnote-font-size;
131
+ color: $footnote-text;
132
+ position: absolute;
133
+ left: -.5em;
134
+ box-shadow: rgba(#000, .2) 0 3px 8px;
135
+ border-radius: .5em;
136
+
137
+ .open-down & {
138
+ top: 0;
139
+ }
140
+ .open-up & {
141
+ bottom: 0;
142
+ }
143
+ }
144
+
145
+ .littlefoot-footnote-wrapper {
146
+ max-height: 250px;
147
+ overflow: auto;
148
+ background: $footnote-bg;
149
+ border-radius: .5em;
150
+ }
151
+ .littlefoot-footnote-content {
152
+ width: 40em;
153
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
154
+ line-height: 1.45em;
155
+ padding: 0 1.4em;
156
+ p {
157
+ margin: 1em 0;
158
+ }
159
+ box-sizing: border-box;
160
+ }
161
+
162
+ .littlefoot-test {
163
+ @extend .littlefoot-footnote-content;
164
+ max-width: $footnote-max-width;
165
+ width: auto;
166
+ display: inline-block;
167
+ }
168
+
169
+ .littlefoot-test-wrapper {
170
+ display: inline-block;
171
+ font-size: $footnote-font-size;
172
+ }
@@ -0,0 +1,13 @@
1
+ require 'octopress-littlefoot/version'
2
+ require 'octopress-ink'
3
+
4
+ Octopress::Ink.add_plugin({
5
+ name: "Octopress Littlefoot",
6
+ slug: "littlefoot",
7
+ gem: "octopress-littlefoot",
8
+ path: File.expand_path(File.join(File.dirname(__FILE__), "..")),
9
+ type: "plugin",
10
+ version: Octopress::Littlefoot::VERSION,
11
+ description: "Fancy footnote popovers with native Javascript",
12
+ source_url: "https://github.com/octopress/littlefoot",
13
+ })
@@ -0,0 +1,5 @@
1
+ module Octopress
2
+ module Littlefoot
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: octopress-littlefoot
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Brandon Mathis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: clash
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: octopress-debugger
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: octopress-ink
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.0.0.pre
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.0.0.pre
83
+ description: Fancy footnote popovers with native Javascript
84
+ email:
85
+ - brandon@imathis.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - LICENSE.txt
91
+ - README.md
92
+ - assets/config.yml
93
+ - assets/javascripts/littlefoot.js
94
+ - assets/stylesheets/_utils.scss
95
+ - assets/stylesheets/littlefoot.scss
96
+ - lib/octopress-littlefoot.rb
97
+ - lib/octopress-littlefoot/version.rb
98
+ homepage: https://github.com/octopress/littlefoot
99
+ licenses:
100
+ - MIT
101
+ metadata: {}
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubyforge_project:
118
+ rubygems_version: 2.2.2
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: Fancy footnote popovers with native Javascript
122
+ test_files: []