simple_toc 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc635e459d66becbcdffa4e1818101ea6c8fd853
4
- data.tar.gz: 03ae80d42122e13a51059002df1ff4632e69db74
3
+ metadata.gz: 6dbfde6098820f377ffd3935b4745596d551bce9
4
+ data.tar.gz: 8428f488a7fe955a8e8475c9ffbdfe33cd0157ea
5
5
  SHA512:
6
- metadata.gz: 619966c04d8b9294ef9e25324c57c57edf89b5c30978850c2482c5e4c5f7a3900bb057bc7f1aebdc4144d908481ee837e7ede89bff690d23a4dc9392b2ca878c
7
- data.tar.gz: eb5bbfc22491f18deefc9ead783cbecaed9f21f7021e0c6cdfc005721dfc3782a307fe16856b7f4267bda494a3d501603e1733d68a6f8583a7dc53a0baaa11ab
6
+ metadata.gz: e209fb5edf423b0c8333a6ad29fdbb80714bfa0069a8da6d41f789ec3d56fab04b94cdaec743c64ef660cbadf9b7832def15cfb8f11f33ae45505bdbb813992c
7
+ data.tar.gz: 92d8f524624d53b76ea5af101e6448b24af539f804695cdb1c0b9a9955684eeb68a60bd65209a2abc2a7083ee4f8a0e29a754b1f8f2df702633b9c98fe4fe89f
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  /.bundle/
2
+ /vendor/bundle
2
3
  /.yardoc
3
4
  /Gemfile.lock
4
5
  /_yardoc/
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # SimpleToc
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/simple_toc.svg)](https://badge.fury.io/rb/simple_toc) [![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)
4
+
3
5
  'simple-toc' makes a simple table of contents from DOM structure.
4
6
 
5
7
  ## Installation
@@ -31,10 +33,10 @@ This plugin require jQuery.
31
33
  ``` javascript
32
34
  $(function() {
33
35
  # simple case
34
- $('.toc').simpleToc();
36
+ $('#toc').simpleToc();
35
37
 
36
38
  # advance case
37
- $('.toc').simpleToc({
39
+ $('#toc').simpleToc({
38
40
  listType: '<ol/>',
39
41
  selectors: 'h1,h2,h3',
40
42
  prefix: 'toc',
@@ -42,6 +44,16 @@ $(function() {
42
44
  });
43
45
  ```
44
46
 
47
+ ``` html
48
+ <div class="#toc"></div>
49
+
50
+ <h2>hoge</h2>
51
+ <h2>fuga</h2>
52
+ <h3>fuga > fuga</h3>
53
+ <h2>piyo</h2>
54
+ ```
55
+
56
+
45
57
  ## Contributing
46
58
 
47
59
  Bug reports and pull requests are welcome on GitHub at https://github.com/miraoto/simple_toc. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -1,3 +1,3 @@
1
1
  module SimpleToc
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -32,7 +32,6 @@
32
32
  var ul = $(plugin.settings.listType);
33
33
 
34
34
  headers.each(function(i, header) {
35
- console.log(header)
36
35
  var $h = $(header);
37
36
  var anchorName = plugin.settings.anchorName(i, plugin.settings.prefix);
38
37
 
@@ -41,7 +40,10 @@
41
40
  }
42
41
 
43
42
  var a = $('<a/>').text(plugin.settings.headerText($h))
44
- .attr('href', '#' + anchorName);
43
+ .attr('href', '#' + anchorName)
44
+ .on('click', function(){
45
+ $('html,body').animate({scrollTop: $h.offset().top}, 500, 'linear');
46
+ });
45
47
  var li = $('<li/>').addClass(plugin.settings.listClass(i, header, $h, plugin.settings.prefix))
46
48
  .append(a);
47
49
  ul.append(li);
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_toc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - miraoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-10 00:00:00.000000000 Z
11
+ date: 2017-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  requirements: []
93
93
  rubyforge_project:
94
- rubygems_version: 2.6.8
94
+ rubygems_version: 2.5.1
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: "'simple-toc' makes a simple table of contents from DOM structure."