Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

Commit

Permalink
Add shortcut definition for indexing format
Browse files Browse the repository at this point in the history
  • Loading branch information
nghuuphuoc committed Jan 16, 2014
1 parent 5a74786 commit 09e1aaa
Show file tree
Hide file tree
Showing 16 changed files with 247 additions and 108 deletions.
17 changes: 12 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
# Change Log

v1.1.1 (2013/10/21):
* #2: Doesn't work when using the default indexing format
## v1.1.2 (2014/01/16)

v1.1.0 (2013/10/19)
* #1: Allow to define different format for each heading level
* Add shortcut definition for indexing format

## v1.1.1 (2013/10/21):

* ^#2: Doesn't work when using the default indexing format

## v1.1.0 (2013/10/19)

* +#1: Allow to define different format for each heading level

## v1.0.0 (2013/09/26)

v1.0.0 (2013/09/26)
* Generate anchor link for heading
* Automatically scroll to with the help of [Bootstrap ScrollSpy](http://getbootstrap.com/javascript/#scrollspy) plugin
* Easy to customize look and feel
4 changes: 2 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ module.exports = function(grunt) {
' *',
' * Generate a table of contents based on headings',
' *',
' * @author Nguyen Huu Phuoc <phuoc@huuphuoc.me>',
' * @copyright (c) 2013 Nguyen Huu Phuoc',
' * @author http://twitter.com/nghuuphuoc',
' * @copyright (c) 2013 - 2014 Nguyen Huu Phuoc',
' * @license MIT',
' */\n\n'
].join('\n'),
Expand Down
57 changes: 46 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ $(element).toc({

```<formatter>``` is a string and can be:

Value | Description
--------------------|------------
```number``` | The headings will be prefixed with number (1, 2, 3, ...)
```upperAlphabet``` | Prefix headings with uppercase alphabetical characters (A, B, C, ...)
```lowerAlphabet``` | Prefix headings with lowercase alphabetical characters (a, b, c, ...)
```upperRoman``` | Prefix headings with uppercase Roman numerals (I, II, III, ...)
```lowerRoman``` | Prefix headings with lowercase Roman numerals (i, ii, iii, ...)
Value | Description
-----------------------------|------------
```number``` or ```1``` | The headings will be prefixed with number (1, 2, 3, ...)
```upperAlphabet```, ```A``` | Prefix headings with uppercase alphabetical characters (A, B, C, ...)
```lowerAlphabet```, ```a``` | Prefix headings with lowercase alphabetical characters (a, b, c, ...)
```upperRoman```, ```I``` | Prefix headings with uppercase Roman numerals (I, II, III, ...)
```lowerRoman```, ```i``` | Prefix headings with lowercase Roman numerals (i, ii, iii, ...)

You can define different formatter for each heading level, for example:

Expand All @@ -91,12 +91,25 @@ $(element).toc({
'h3': 'lowerAlphabet'
}
});

$(element).toc({
indexingFormats: {
'h1': 'A',
'h2': '1',
'h3': 'a'
}
});

$(element).toc({
indexingFormats: 'A1a'
});
```

If you want to set indexing formats for all levels:

```javascript
$(element).toc({
// <formatter> can be 'number', 'upperAlphabet', 'lowerAlphabet', 'upperRoman', 'lowerRoman'
indexingFormats: '<formatter>'
});
```
Expand Down Expand Up @@ -155,10 +168,32 @@ $ grunt

## Author

Nguyen Huu Phuoc ([Email](mailto: phuoc@huuphuoc.me) / [Twitter](http://twitter.com/nghuuphuoc) / [Github](http://github.com/nghuuphuoc))
Nguyen Huu Phuoc, aka @nghuuphuoc

## License
* [http://github.com/nghuuphuoc](http://github.com/nghuuphuoc)
* [http://twitter.com/nghuuphuoc](http://twitter.com/nghuuphuoc)

Copyright (c) 2013 Nguyen Huu Phuoc
## License

TocJS is licensed under the MIT license.
```
The MIT License (MIT)
Copyright (c) 2013 - 2014 Nguyen Huu Phuoc
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```
25 changes: 24 additions & 1 deletion demo/more-indexing.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ <h2>Hymenaeos Nullam Libero</h2>

<!-- footer: -->
<div style="border-top: 1px solid #ccc;; padding: 10px 0 20px 0;">
<div class="container">Copyright (c) 2013 <a href="http://twitter.com/nghuuphuoc">@nghuuphuoc</a></div>
<div class="container">Copyright (c) 2013 - 2014 <a href="http://twitter.com/nghuuphuoc">@nghuuphuoc</a></div>
</div>
<!-- :footer -->

Expand All @@ -103,6 +103,7 @@ <h2>Hymenaeos Nullam Libero</h2>
$('#toc').width($('#toc').parents().width());

// Generate table of content
/*
$('#toc').toc({
elementClass: 'toc',
ulClass: 'nav',
Expand All @@ -115,6 +116,28 @@ <h2>Hymenaeos Nullam Libero</h2>
'h5': 'number'
}
});
*/

/*
$('#toc').toc({
elementClass: 'toc',
ulClass: 'nav',
heading: 'Table of Contents',
indexingFormats: {
'h1': 'I',
'h2': '1',
'h3': 'A',
'h4': 'a'
}
});
*/

$('#toc').toc({
elementClass: 'toc',
ulClass: 'nav',
heading: 'Table of Contents',
indexingFormats: 'I1Aa'
});

// Scroll to the table of content section when user scroll the mouse
$('body').scrollspy({
Expand Down
2 changes: 1 addition & 1 deletion demo/number-indexing.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ <h2>Hymenaeos Nullam Libero</h2>

<!-- footer: -->
<div style="border-top: 1px solid #ccc;; padding: 10px 0 20px 0;">
<div class="container">Copyright (c) 2013 <a href="http://twitter.com/nghuuphuoc">@nghuuphuoc</a></div>
<div class="container">Copyright (c) 2013 - 2014 <a href="http://twitter.com/nghuuphuoc">@nghuuphuoc</a></div>
</div>
<!-- :footer -->

Expand Down
2 changes: 1 addition & 1 deletion demo/scroll.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ <h2>Hymenaeos Nullam Libero</h2>

<!-- footer: -->
<div style="border-top: 1px solid #ccc;; padding: 10px 0 20px 0;">
<div class="container">Copyright (c) 2013 <a href="http://twitter.com/nghuuphuoc">@nghuuphuoc</a></div>
<div class="container">Copyright (c) 2013 - 2014 <a href="http://twitter.com/nghuuphuoc">@nghuuphuoc</a></div>
</div>
<!-- :footer -->

Expand Down
4 changes: 2 additions & 2 deletions dist/css/toc-scroll.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
*
* Generate a table of contents based on headings
*
* @author Nguyen Huu Phuoc <phuoc@huuphuoc.me>
* @copyright (c) 2013 Nguyen Huu Phuoc
* @author http://twitter.com/nghuuphuoc
* @copyright (c) 2013 - 2014 Nguyen Huu Phuoc
* @license MIT
*/
.toc {
Expand Down
6 changes: 3 additions & 3 deletions dist/css/toc-scroll.min.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* TocJS v1.1.1 (http://github.com/nghuuphuoc/tocjs)
* TocJS v1.1.2 (http://github.com/nghuuphuoc/tocjs)
*
* Generate a table of contents based on headings
*
* @author Nguyen Huu Phuoc <phuoc@huuphuoc.me>
* @copyright (c) 2013 Nguyen Huu Phuoc
* @author http://twitter.com/nghuuphuoc
* @copyright (c) 2013 - 2014 Nguyen Huu Phuoc
* @license MIT
*/

Expand Down
6 changes: 3 additions & 3 deletions dist/css/toc.min.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* TocJS v1.1.1 (http://github.com/nghuuphuoc/tocjs)
* TocJS v1.1.2 (http://github.com/nghuuphuoc/tocjs)
*
* Generate a table of contents based on headings
*
* @author Nguyen Huu Phuoc <phuoc@huuphuoc.me>
* @copyright (c) 2013 Nguyen Huu Phuoc
* @author http://twitter.com/nghuuphuoc
* @copyright (c) 2013 - 2014 Nguyen Huu Phuoc
* @license MIT
*/

Expand Down
4 changes: 2 additions & 2 deletions dist/css/toc.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
*
* Generate a table of contents based on headings
*
* @author Nguyen Huu Phuoc <phuoc@huuphuoc.me>
* @copyright (c) 2013 Nguyen Huu Phuoc
* @author http://twitter.com/nghuuphuoc
* @copyright (c) 2013 - 2014 Nguyen Huu Phuoc
* @license MIT
*/

Expand Down
Loading

0 comments on commit 09e1aaa

Please sign in to comment.