Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tocbot

Package Overview
Dependencies
Maintainers
1
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tocbot - npm Package Compare versions

Comparing version 2.3.2 to 2.4.0

CHANGELOG.md

0

bower.json

@@ -0,0 +0,0 @@ {

20

dist/tocbot.min.js

@@ -1,18 +0,2 @@

!function(e){function t(o){if(n[o])return n[o].exports;var l=n[o]={exports:{},id:o,loaded:!1};return e[o].call(l.exports,l,l.exports,t),l.loaded=!0,l.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([/*!*************************!*\
!*** ./src/js/index.js ***!
\*************************/
function(e,t,n){var o,l,r;(function(i){!function(n,i){l=[],o=i(n),r="function"==typeof o?o.apply(t,l):o,!(void 0!==r&&(e.exports=r))}("undefined"!=typeof i?i:this.window||this.global,function(e){"use strict";function t(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];for(var o in n)h.call(n,o)&&(e[o]=n[o])}return e}function o(e,t,n){t||(t=250);var o,l;return function(){var r=n||this,i=+new Date,s=arguments;o&&i<o+t?(clearTimeout(l),l=setTimeout(function(){o=i,e.apply(r,s)},t)):(o=i,e.apply(r,s))}}var l,r,i,s=n(/*! smooth-scroll */1),c=n(/*! ./default-options.js */2),a={},u={},d=n(/*! ./build-html.js */3),f=n(/*! ./parse-content.js */4),m=(e.document,document.body,!!e.document.querySelector&&!!e.addEventListener),h=Object.prototype.hasOwnProperty;return u.destroy=function(){try{document.querySelector(a.tocSelector).innerHTML=""}catch(e){console.warn("Element not found: "+a.tocSelector)}document.removeEventListener("scroll",this._scrollListener,!1),document.removeEventListener("resize",this._scrollListener,!1),l&&document.removeEventListener("click",this._clickListener,!1),s&&s.destroy()},u.init=function(e){if(m&&(a=t(c,e||{}),this.options=a,this.state={},l=d(a),r=f(a),this._buildHtml=l,this._parseContent=r,u.destroy(),i=r.selectHeadings(a.contentSelector,a.headingSelector),null!==i)){var n=r.nestHeadingsArray(i),h=n.nest;return l.render(a.tocSelector,h),this._scrollListener=o(function(){l.updateToc(i)},a.throttleTimeout),this._scrollListener(),document.addEventListener("scroll",this._scrollListener,!1),document.addEventListener("resize",this._scrollListener,!1),this._clickListener=o(function(e){l.disableTocAnimation(e),l.updateToc(i)},a.throttleTimeout),document.addEventListener("click",this._clickListener,!1),s&&(this.smoothScroll=s.init(t(a.smoothScrollOptions,{callback:function(e,t){l.enableTocAnimation(),"function"==typeof a.smoothScrollOptions.callback&&a.smoothScrollOptions.callback(e,t)}}))),this}},u.refresh=function(e){u.destroy(),u.init(e||this.options)},e.tocbot=u,u})}).call(t,function(){return this}())},/*!******************************************************!*\
!*** ./~/smooth-scroll/dist/js/smooth-scroll.min.js ***!
\******************************************************/
function(e,t,n){var o,l,r;(function(n){/*! smooth-scroll v10.3.1 | (c) 2017 Chris Ferdinandi | MIT License | http://github.com/cferdinandi/smooth-scroll */
!function(n,i){l=[],o=i(n),r="function"==typeof o?o.apply(t,l):o,!(void 0!==r&&(e.exports=r))}("undefined"!=typeof n?n:this.window||this.global,function(e){"use strict";var t,n,o,l,r,i,s,c={},a="querySelector"in document&&"addEventListener"in e,u={selector:"[data-scroll]",selectorHeader:null,speed:500,easing:"easeInOutCubic",offset:0,callback:function(){}},d=function(){var e={},t=!1,n=0,o=arguments.length;for("[object Boolean]"===Object.prototype.toString.call(arguments[0])&&(t=arguments[0],n++);n<o;n++){var l=arguments[n];!function(n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t&&"[object Object]"===Object.prototype.toString.call(n[o])?e[o]=d(!0,e[o],n[o]):e[o]=n[o])}(l)}return e},f=function(e){return Math.max(e.scrollHeight,e.offsetHeight,e.clientHeight)},m=function(e,t){for(Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(e){for(var t=(this.document||this.ownerDocument).querySelectorAll(e),n=t.length;--n>=0&&t.item(n)!==this;);return n>-1});e&&e!==document;e=e.parentNode)if(e.matches(t))return e;return null},h=function(e){"#"===e.charAt(0)&&(e=e.substr(1));for(var t,n=String(e),o=n.length,l=-1,r="",i=n.charCodeAt(0);++l<o;){if(0===(t=n.charCodeAt(l)))throw new InvalidCharacterError("Invalid character: the input contains U+0000.");r+=t>=1&&t<=31||127==t||0===l&&t>=48&&t<=57||1===l&&t>=48&&t<=57&&45===i?"\\"+t.toString(16)+" ":t>=128||45===t||95===t||t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122?n.charAt(l):"\\"+n.charAt(l)}return"#"+r},p=function(e,t){var n;return"easeInQuad"===e&&(n=t*t),"easeOutQuad"===e&&(n=t*(2-t)),"easeInOutQuad"===e&&(n=t<.5?2*t*t:(4-2*t)*t-1),"easeInCubic"===e&&(n=t*t*t),"easeOutCubic"===e&&(n=--t*t*t+1),"easeInOutCubic"===e&&(n=t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1),"easeInQuart"===e&&(n=t*t*t*t),"easeOutQuart"===e&&(n=1- --t*t*t*t),"easeInOutQuart"===e&&(n=t<.5?8*t*t*t*t:1-8*--t*t*t*t),"easeInQuint"===e&&(n=t*t*t*t*t),"easeOutQuint"===e&&(n=1+--t*t*t*t*t),"easeInOutQuint"===e&&(n=t<.5?16*t*t*t*t*t:1+16*--t*t*t*t*t),n||t},v=function(e,t,n){var o=0;if(e.offsetParent)do o+=e.offsetTop,e=e.offsetParent;while(e);return o=Math.max(o-t-n,0),Math.min(o,S()-y())},y=function(){return Math.max(document.documentElement.clientHeight,e.innerHeight||0)},S=function(){return Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.body.clientHeight,document.documentElement.clientHeight)},C=function(e){return e&&"object"==typeof JSON&&"function"==typeof JSON.parse?JSON.parse(e):{}},b=function(e){return e?f(e)+e.offsetTop:0},g=function(t,n,o){o||(t.focus(),document.activeElement.id!==t.id&&(t.setAttribute("tabindex","-1"),t.focus(),t.style.outline="none"),e.scrollTo(0,n))};c.animateScroll=function(n,o,i){var c=C(o?o.getAttribute("data-options"):null),a=d(t||u,i||{},c),f="[object Number]"===Object.prototype.toString.call(n),m=f||!n.tagName?null:n;if(f||m){var h=e.pageYOffset;a.selectorHeader&&!l&&(l=document.querySelector(a.selectorHeader)),r||(r=b(l));var y,x,O=f?n:v(m,r,parseInt("function"==typeof a.offset?a.offset():a.offset,10)),E=O-h,N=S(),L=0,H=function(t,l,r){var i=e.pageYOffset;(t==l||i==l||e.innerHeight+i>=N)&&(clearInterval(r),g(n,l,f),a.callback(n,o))},k=function(){L+=16,y=L/parseInt(a.speed,10),y=y>1?1:y,x=h+E*p(a.easing,y),e.scrollTo(0,Math.floor(x)),H(x,O,s)};0===e.pageYOffset&&e.scrollTo(0,0),function(){clearInterval(s),s=setInterval(k,16)}()}};var x=function(t){try{h(decodeURIComponent(e.location.hash))}catch(t){h(e.location.hash)}n&&(n.id=n.getAttribute("data-scroll-id"),c.animateScroll(n,o),n=null,o=null)},O=function(l){if(0===l.button&&!l.metaKey&&!l.ctrlKey&&(o=m(l.target,t.selector))&&"a"===o.tagName.toLowerCase()&&o.hostname===e.location.hostname&&o.pathname===e.location.pathname&&/#/.test(o.href)){var r;try{r=h(decodeURIComponent(o.hash))}catch(e){r=h(o.hash)}if("#"===r){l.preventDefault(),n=document.body;var i=n.id?n.id:"smooth-scroll-top";return n.setAttribute("data-scroll-id",i),n.id="",void(e.location.hash.substring(1)===i?x():e.location.hash=i)}n=document.querySelector(r),n&&(n.setAttribute("data-scroll-id",n.id),n.id="",o.hash===e.location.hash&&(l.preventDefault(),x()))}},E=function(e){i||(i=setTimeout(function(){i=null,r=b(l)},66))};return c.destroy=function(){t&&(document.removeEventListener("click",O,!1),e.removeEventListener("resize",E,!1),t=null,n=null,o=null,l=null,r=null,i=null,s=null)},c.init=function(n){a&&(c.destroy(),t=d(u,n||{}),l=t.selectorHeader?document.querySelector(t.selectorHeader):null,r=b(l),document.addEventListener("click",O,!1),e.addEventListener("hashchange",x,!1),l&&e.addEventListener("resize",E,!1))},c})}).call(t,function(){return this}())},/*!***********************************!*\
!*** ./src/js/default-options.js ***!
\***********************************/
function(e,t){e.exports={tocSelector:".js-toc",contentSelector:".js-toc-content",headingSelector:"h1, h2, h3",ignoreSelector:".js-toc-ignore",linkClass:"toc-link",extraLinkClasses:"",activeLinkClass:"is-active-link",listClass:"toc-list",extraListClasses:"",isCollapsedClass:"is-collapsed",collapsibleClass:"is-collapsible",listItemClass:"toc-list-item",collapseDepth:0,smoothScrollOptions:{easing:"easeInOutCubic",offset:0,speed:300,callback:function(e,t){}},headingsOffset:0,throttleTimeout:50,positionFixedSelector:null,positionFixedClass:"is-position-fixed",fixedSidebarOffset:"auto",includeHtml:!1}},/*!******************************!*\
!*** ./src/js/build-html.js ***!
\******************************/
function(e,t){e.exports=function(e){function t(e,n){var r=n.appendChild(o(e));if(e.children.length){var i=l(e.isCollapsed);e.children.forEach(function(e){t(e,i)}),r.appendChild(i)}}function n(e,n){var o=!1,r=l(o);n.forEach(function(e){t(e,r)});var i=document.querySelector(e);if(null!==i)return i.firstChild&&i.removeChild(i.firstChild),i.appendChild(r)}function o(t){var n=document.createElement("li"),o=document.createElement("a");return e.listItemClass&&n.setAttribute("class",e.listItemClass),e.includeHtml&&t.childNodes.length?u.call(t.childNodes,function(e){o.appendChild(e.cloneNode(!0))}):o.textContent=t.textContent,o.setAttribute("data-scroll",""),o.setAttribute("href","#"+t.id),o.setAttribute("class",e.linkClass+h+"node-name--"+t.nodeName+h+e.extraLinkClasses),n.appendChild(o),n}function l(t){var n=document.createElement("ul"),o=e.listClass+h+e.extraListClasses;return t&&(o+=h+e.collapsibleClass,o+=h+e.isCollapsedClass),n.setAttribute("class",o),n}function r(){var t=document.documentElement.scrollTop||f.scrollTop,n=document.querySelector(e.positionFixedSelector);"auto"===e.fixedSidebarOffset&&(e.fixedSidebarOffset=document.querySelector(e.tocSelector).offsetTop),t>e.fixedSidebarOffset?n.className.indexOf(e.positionFixedClass)===-1&&(n.className+=h+e.positionFixedClass):n.className=n.className.split(h+e.positionFixedClass).join("")}function i(t){var n=document.documentElement.scrollTop||f.scrollTop;e.positionFixedSelector&&r();var o,l=t;if(m&&null!==document.querySelector(e.tocSelector)&&l.length>0){d.call(l,function(t,r){if(t.offsetTop>n+e.headingsOffset+1){var i=0===r?r:r-1;return o=l[i],!0}if(r===l.length-1)return o=l[l.length-1],!0});var i=document.querySelector(e.tocSelector).querySelectorAll("."+e.linkClass);u.call(i,function(t){t.className=t.className.split(h+e.activeLinkClass).join("")});var c=document.querySelector(e.tocSelector).querySelector("."+e.linkClass+".node-name--"+o.nodeName+'[href="#'+o.id+'"]');c.className+=h+e.activeLinkClass;var a=document.querySelector(e.tocSelector).querySelectorAll("."+e.listClass+"."+e.collapsibleClass);u.call(a,function(t){var n=h+e.isCollapsedClass;t.className.indexOf(n)===-1&&(t.className+=h+e.isCollapsedClass)}),c.nextSibling&&(c.nextSibling.className=c.nextSibling.className.split(h+e.isCollapsedClass).join("")),s(c.parentNode.parentNode)}}function s(t){return t.className.indexOf(e.collapsibleClass)!==-1?(t.className=t.className.split(h+e.isCollapsedClass).join(""),s(t.parentNode.parentNode)):t}function c(t){var n=t.target||t.srcElement;"string"==typeof n.className&&n.className.indexOf(e.linkClass)!==-1&&(m=!1)}function a(){m=!0}var u=[].forEach,d=[].some,f=document.body,m=!0,h=" ";return{enableTocAnimation:a,disableTocAnimation:c,render:n,updateToc:i}}},/*!*********************************!*\
!*** ./src/js/parse-content.js ***!
\*********************************/
function(e,t){e.exports=function(e){function t(e){return e[e.length-1]}function n(e){return+e.nodeName.split("H").join("")}function o(t){var o={id:t.id,children:[],nodeName:t.nodeName,headingLevel:n(t),textContent:t.textContent.trim()};return e.includeHtml&&(o.childNodes=t.childNodes),o}function l(l,r){for(var i=o(l),s=n(l),c=r,a=t(c),u=a?a.headingLevel:0,d=s-u;d>0;)a=t(c),a&&void 0!==a.children&&(c=a.children),d--;return s>=e.collapseDepth&&(i.isCollapsed=!0),c.push(i),c}function r(t,n){var o=n;e.ignoreSelector&&(o=n.split(",").map(function(t){return t.trim()+":not("+e.ignoreSelector+")"}));try{return document.querySelector(t).querySelectorAll(o)}catch(e){return console.warn("Element not found: "+t),null}}function i(e){return s.call(e,function(e,t){var n=o(t);return l(n,e.nest),e},{nest:[]})}var s=[].reduce;return{nestHeadingsArray:i,selectHeadings:r}}}]);
//# sourceMappingURL=tocbot.min.js.map
!function(e){function t(o){if(n[o])return n[o].exports;var i=n[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=5)}([function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){(function(n){var o,i,r;/*! smooth-scroll v11.0.2 | (c) 2017 Chris Ferdinandi | GPL-3.0 License | http://github.com/cferdinandi/smooth-scroll */
!function(n,l){i=[],o=l(n),void 0!==(r="function"==typeof o?o.apply(t,i):o)&&(e.exports=r)}(void 0!==n?n:this.window||this.global,function(e){"use strict";var t,n,o,i,r,l,s,c={},a="querySelector"in document&&"addEventListener"in e,u={selector:"[data-scroll]",selectorHeader:null,speed:500,offset:0,easing:"easeInOutCubic",easingPatterns:{},before:function(){},after:function(){}},d=function(){var e={},t=!1,n=0,o=arguments.length;for("[object Boolean]"===Object.prototype.toString.call(arguments[0])&&(t=arguments[0],n++);n<o;n++){var i=arguments[n];!function(n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t&&"[object Object]"===Object.prototype.toString.call(n[o])?e[o]=d(!0,e[o],n[o]):e[o]=n[o])}(i)}return e},f=function(e){return Math.max(e.scrollHeight,e.offsetHeight,e.clientHeight)},m=function(e,t){for(Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(e){for(var t=(this.document||this.ownerDocument).querySelectorAll(e),n=t.length;--n>=0&&t.item(n)!==this;);return n>-1});e&&e!==document;e=e.parentNode)if(e.matches(t))return e;return null},h=function(e){"#"===e.charAt(0)&&(e=e.substr(1));for(var t,n=String(e),o=n.length,i=-1,r="",l=n.charCodeAt(0);++i<o;){if(0===(t=n.charCodeAt(i)))throw new InvalidCharacterError("Invalid character: the input contains U+0000.");r+=t>=1&&t<=31||127==t||0===i&&t>=48&&t<=57||1===i&&t>=48&&t<=57&&45===l?"\\"+t.toString(16)+" ":t>=128||45===t||95===t||t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122?n.charAt(i):"\\"+n.charAt(i)}return"#"+r},p=function(e,t){var n;return"easeInQuad"===e.easing&&(n=t*t),"easeOutQuad"===e.easing&&(n=t*(2-t)),"easeInOutQuad"===e.easing&&(n=t<.5?2*t*t:(4-2*t)*t-1),"easeInCubic"===e.easing&&(n=t*t*t),"easeOutCubic"===e.easing&&(n=--t*t*t+1),"easeInOutCubic"===e.easing&&(n=t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1),"easeInQuart"===e.easing&&(n=t*t*t*t),"easeOutQuart"===e.easing&&(n=1- --t*t*t*t),"easeInOutQuart"===e.easing&&(n=t<.5?8*t*t*t*t:1-8*--t*t*t*t),"easeInQuint"===e.easing&&(n=t*t*t*t*t),"easeOutQuint"===e.easing&&(n=1+--t*t*t*t*t),"easeInOutQuint"===e.easing&&(n=t<.5?16*t*t*t*t*t:1+16*--t*t*t*t*t),e.easingPatterns[e.easing]&&(n=e.easingPatterns[e.easing](t)),n||t},v=function(e,t,n){var o=0;if(e.offsetParent)do{o+=e.offsetTop,e=e.offsetParent}while(e);return o=Math.max(o-t-n,0),Math.min(o,y()-g())},g=function(){return Math.max(document.documentElement.clientHeight,e.innerHeight||0)},y=function(){return Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.body.clientHeight,document.documentElement.clientHeight)},b=function(e){return e&&"object"==typeof JSON&&"function"==typeof JSON.parse?JSON.parse(e):{}},S=function(e){return e?f(e)+e.offsetTop:0},C=function(t,n,o){o||(t.focus(),document.activeElement.id!==t.id&&(t.setAttribute("tabindex","-1"),t.focus(),t.style.outline="none"),e.scrollTo(0,n))};c.animateScroll=function(n,o,l){var c=b(o?o.getAttribute("data-options"):null),a=d(t||u,l||{},c),f="[object Number]"===Object.prototype.toString.call(n),m=f||!n.tagName?null:n;if(f||m){var h=e.pageYOffset;a.selectorHeader&&!i&&(i=document.querySelector(a.selectorHeader)),r||(r=S(i));var g,x,O=f?n:v(m,r,parseInt("function"==typeof a.offset?a.offset():a.offset,10)),E=O-h,N=y(),L=0,H=function(t,i,r){var l=e.pageYOffset;(t==i||l==i||e.innerHeight+l>=N)&&(clearInterval(r),C(n,i,f),a.after(n,o))},A=function(){L+=16,g=L/parseInt(a.speed,10),g=g>1?1:g,x=h+E*p(a,g),e.scrollTo(0,Math.floor(x)),H(x,O,s)};0===e.pageYOffset&&e.scrollTo(0,0),a.before(n,o),function(){clearInterval(s),s=setInterval(A,16)}()}};var x=function(t){try{h(decodeURIComponent(e.location.hash))}catch(t){h(e.location.hash)}n&&(n.id=n.getAttribute("data-scroll-id"),c.animateScroll(n,o),n=null,o=null)},O=function(i){if(0===i.button&&!i.metaKey&&!i.ctrlKey&&(o=m(i.target,t.selector))&&"a"===o.tagName.toLowerCase()&&o.hostname===e.location.hostname&&o.pathname===e.location.pathname&&/#/.test(o.href)){var r;try{r=h(decodeURIComponent(o.hash))}catch(e){r=h(o.hash)}if("#"===r){i.preventDefault(),n=document.body;var l=n.id?n.id:"smooth-scroll-top";return n.setAttribute("data-scroll-id",l),n.id="",void(e.location.hash.substring(1)===l?x():e.location.hash=l)}(n=document.querySelector(r))&&(n.setAttribute("data-scroll-id",n.id),n.id="",o.hash===e.location.hash&&(i.preventDefault(),x()))}},E=function(e){l||(l=setTimeout(function(){l=null,r=S(i)},66))};return c.destroy=function(){t&&(document.removeEventListener("click",O,!1),e.removeEventListener("resize",E,!1),t=null,n=null,o=null,i=null,r=null,l=null,s=null)},c.init=function(n){a&&(c.destroy(),t=d(u,n||{}),i=t.selectorHeader?document.querySelector(t.selectorHeader):null,r=S(i),document.addEventListener("click",O,!1),e.addEventListener("hashchange",x,!1),i&&e.addEventListener("resize",E,!1))},c})}).call(t,n(0))},function(e,t){e.exports=function(e){function t(e,n){var r=n.appendChild(o(e));if(e.children.length){var l=i(e.isCollapsed);e.children.forEach(function(e){t(e,l)}),r.appendChild(l)}}function n(e,n){var o=i(!1);n.forEach(function(e){t(e,o)});var r=document.querySelector(e);if(null!==r)return r.firstChild&&r.removeChild(r.firstChild),r.appendChild(o)}function o(t){var n=document.createElement("li"),o=document.createElement("a");return e.listItemClass&&n.setAttribute("class",e.listItemClass),e.includeHtml&&t.childNodes.length?u.call(t.childNodes,function(e){o.appendChild(e.cloneNode(!0))}):o.textContent=t.textContent,o.setAttribute("data-scroll",""),o.setAttribute("href","#"+t.id),o.setAttribute("class",e.linkClass+h+"node-name--"+t.nodeName+h+e.extraLinkClasses),n.appendChild(o),n}function i(t){var n=document.createElement("ul"),o=e.listClass+h+e.extraListClasses;return t&&(o+=h+e.collapsibleClass,o+=h+e.isCollapsedClass),n.setAttribute("class",o),n}function r(){var t=document.documentElement.scrollTop||f.scrollTop,n=document.querySelector(e.positionFixedSelector);"auto"===e.fixedSidebarOffset&&(e.fixedSidebarOffset=document.querySelector(e.tocSelector).offsetTop),t>e.fixedSidebarOffset?-1===n.className.indexOf(e.positionFixedClass)&&(n.className+=h+e.positionFixedClass):n.className=n.className.split(h+e.positionFixedClass).join("")}function l(t){var n=document.documentElement.scrollTop||f.scrollTop;e.positionFixedSelector&&r();var o,i=t;if(m&&null!==document.querySelector(e.tocSelector)&&i.length>0){d.call(i,function(t,r){if(t.offsetTop>n+e.headingsOffset+1){return o=i[0===r?r:r-1],!0}if(r===i.length-1)return o=i[i.length-1],!0});var l=document.querySelector(e.tocSelector).querySelectorAll("."+e.linkClass);u.call(l,function(t){t.className=t.className.split(h+e.activeLinkClass).join("")});var c=document.querySelector(e.tocSelector).querySelector("."+e.linkClass+".node-name--"+o.nodeName+'[href="#'+o.id+'"]');c.className+=h+e.activeLinkClass;var a=document.querySelector(e.tocSelector).querySelectorAll("."+e.listClass+"."+e.collapsibleClass);u.call(a,function(t){var n=h+e.isCollapsedClass;-1===t.className.indexOf(n)&&(t.className+=h+e.isCollapsedClass)}),c.nextSibling&&(c.nextSibling.className=c.nextSibling.className.split(h+e.isCollapsedClass).join("")),s(c.parentNode.parentNode)}}function s(t){return-1!==t.className.indexOf(e.collapsibleClass)?(t.className=t.className.split(h+e.isCollapsedClass).join(""),s(t.parentNode.parentNode)):t}function c(t){var n=t.target||t.srcElement;"string"==typeof n.className&&-1!==n.className.indexOf(e.linkClass)&&(m=!1)}function a(){m=!0}var u=[].forEach,d=[].some,f=document.body,m=!0,h=" ";return{enableTocAnimation:a,disableTocAnimation:c,render:n,updateToc:l}}},function(e,t){e.exports={tocSelector:".js-toc",contentSelector:".js-toc-content",headingSelector:"h1, h2, h3",ignoreSelector:".js-toc-ignore",linkClass:"toc-link",extraLinkClasses:"",activeLinkClass:"is-active-link",listClass:"toc-list",extraListClasses:"",isCollapsedClass:"is-collapsed",collapsibleClass:"is-collapsible",listItemClass:"toc-list-item",collapseDepth:0,smoothScrollOptions:{easing:"easeInOutCubic",offset:0,speed:300,callback:function(e,t){}},headingsOffset:0,throttleTimeout:50,positionFixedSelector:null,positionFixedClass:"is-position-fixed",fixedSidebarOffset:"auto",includeHtml:!1}},function(e,t){e.exports=function(e){function t(e){return e[e.length-1]}function n(e){return+e.nodeName.split("H").join("")}function o(t){var o={id:t.id,children:[],nodeName:t.nodeName,headingLevel:n(t),textContent:t.textContent.trim()};return e.includeHtml&&(o.childNodes=t.childNodes),o}function i(i,r){for(var l=o(i),s=n(i),c=r,a=t(c),u=a?a.headingLevel:0,d=s-u;d>0;)a=t(c),a&&void 0!==a.children&&(c=a.children),d--;return s>=e.collapseDepth&&(l.isCollapsed=!0),c.push(l),c}function r(t,n){var o=n;e.ignoreSelector&&(o=n.split(",").map(function(t){return t.trim()+":not("+e.ignoreSelector+")"}));try{return document.querySelector(t).querySelectorAll(o)}catch(e){return console.warn("Element not found: "+t),null}}function l(e){return s.call(e,function(e,t){return i(o(t),e.nest),e},{nest:[]})}var s=[].reduce;return{nestHeadingsArray:l,selectHeadings:r}}},function(e,t,n){(function(o){var i,r,l;!function(n,o){r=[],i=o(n),void 0!==(l="function"==typeof i?i.apply(t,r):i)&&(e.exports=l)}(void 0!==o?o:this.window||this.global,function(e){"use strict";function t(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];for(var o in n)h.call(n,o)&&(e[o]=n[o])}return e}function o(e,t,n){t||(t=250);var o,i;return function(){var r=n||this,l=+new Date,s=arguments;o&&l<o+t?(clearTimeout(i),i=setTimeout(function(){o=l,e.apply(r,s)},t)):(o=l,e.apply(r,s))}}var i,r,l,s=n(1),c=n(3),a={},u={},d=n(2),f=n(4),m=(e.document,document.body,!!e.document.querySelector&&!!e.addEventListener),h=Object.prototype.hasOwnProperty;return u.destroy=function(){try{document.querySelector(a.tocSelector).innerHTML=""}catch(e){console.warn("Element not found: "+a.tocSelector)}document.removeEventListener("scroll",this._scrollListener,!1),document.removeEventListener("resize",this._scrollListener,!1),i&&document.removeEventListener("click",this._clickListener,!1),s&&s.destroy()},u.init=function(e){if(m&&(a=t(c,e||{}),this.options=a,this.state={},i=d(a),r=f(a),this._buildHtml=i,this._parseContent=r,u.destroy(),null!==(l=r.selectHeadings(a.contentSelector,a.headingSelector)))){var n=r.nestHeadingsArray(l),h=n.nest;return i.render(a.tocSelector,h),this._scrollListener=o(function(){i.updateToc(l)},a.throttleTimeout),this._scrollListener(),document.addEventListener("scroll",this._scrollListener,!1),document.addEventListener("resize",this._scrollListener,!1),this._clickListener=o(function(e){i.disableTocAnimation(e),i.updateToc(l)},a.throttleTimeout),document.addEventListener("click",this._clickListener,!1),s&&(this.smoothScroll=s.init(t(a.smoothScrollOptions,{callback:function(e,t){i.enableTocAnimation(),"function"==typeof a.smoothScrollOptions.callback&&a.smoothScrollOptions.callback(e,t)}}))),this}},u.refresh=function(e){u.destroy(),u.init(e||this.options)},e.tocbot=u,u})}).call(t,n(0))}]);
{
"name": "tocbot",
"version": "2.3.2",
"version": "2.4.0",
"description": "Generate a table of contents based on the heading structure of a html document.",
"main": "src/js/index.js",
"scripts": {
"build": "npm run clean && npm run mkdirs && npm run build-js && npm run build-js-uglify && npm run build-css && npm run build-docs && npm run build-dist",
"clean": "rm -rf build/ && rm -rf dist/",
"mkdirs": "npm run mkdir-build & npm run mkdir-dist",
"mkdir-build": "mkdir build && cd build && mkdir data && mkdir assets && cd assets && mkdir js && mkdir css",
"clean": "rm -rf dist/",
"mkdir-dist": "mkdir dist",
"build-css": "node-sass --include-path ./node_modules --output-style compressed -o build/assets/css src/scss",
"build-css-watch": "node-sass --source-map-embed --watch --include-path ./node_modules --output-style compressed -o build/assets/css src/scss",
"build-dist": "cp build/assets/js/tocbot.js ./dist/ && cp build/assets/js/tocbot.min.js ./dist/ && cp build/assets/css/tocbot.css ./dist/",
"build-js": "webpack src/js/index.js build/assets/js/tocbot.js -d",
"build-js-watch": "webpack src/js/index.js build/assets/js/tocbot.js -d --watch",
"build-js-uglify": "webpack src/js/index.js build/assets/js/tocbot.min.js -d --optimize-minimize",
"estimate-js-size": "gzip -9 -c build/assets/js/tocbot.min.js | wc -c",
"estimate-css-size": "gzip -9 -c build/assets/css/tocbot.css | wc -c",
"build-docs": "node ./script/parse.js --src **/*.md | babel-node ./script/render.js",
"build-docs-watch": "onchange \"**/*.js\" \"**/*.jsx\" \"**/*.md\" \"src/**/*.html\" -- npm run build-docs",
"build-static": "cp -r src/files/* build/",
"lint": "eslint *.js",
"dev": "parallelshell \"npm run serve\" \"npm run build-js-watch\" \"npm run build-css-watch\" \"npm run build-docs-watch\"",
"serve": "webpack-dev-server --content-base build/ --port 4001",
"start": "npm run clean && npm run mkdirs && npm run build-css && npm run build-docs && npm run dev",
"deploy": "npm run build && gh-pages -d build",
"test": "mocha --grep \"$TEST_NAME\" test/index.js",
"test:debug": "node-debug _mocha --timeout 0 --grep \"$TEST_NAME\" test/index.js",
"test:watch": "mocha --watch test/index.js"
"build": "npm run clean && npm run mkdir-dist && npm run build-js && npm run build-js-uglify && npm run build-css && npm run build-dist && npm run build-docs",
"build-docs": "npm run build-content && npm run next-export && npm run fix-export",
"build-css": "node-sass --include-path ./node_modules --output-style compressed -o static/css src/scss",
"build-css-watch": "node-sass --source-map-embed --watch --include-path ./node_modules --output-style compressed -o static/css src/scss",
"build-dist": "cp static/js/tocbot.js ./dist/ && cp static/js/tocbot.min.js ./dist/ && cp static/css/tocbot.css ./dist/ && cp static/css/styles.css ./dist/",
"build-js": "webpack src/js/index.js static/js/tocbot.js -d",
"build-js-watch": "webpack src/js/index.js static/js/tocbot.js -d --watch",
"build-js-uglify": "webpack src/js/index.js static/js/tocbot.min.js -p",
"build-content": "processto \"*.md\" --outputDir pages --filenamePrefix _",
"fix-export": "bash ./script/fix-export.sh",
"estimate-js-size": "gzip -9 -c dist/tocbot.min.js | wc -c",
"estimate-css-size": "gzip -9 -c dist/tocbot.css | wc -c",
"lint": "",
"dev": "parallelshell \"npm run next\" \"npm run build-js-watch\" \"npm run build-css-watch\"",
"start": "npm run dev",
"deploy": "npm run build && gh-pages -d site",
"test": "mocha test/index.js",
"test:debug": "node-debug _mocha --timeout 0 test/index.js",
"test:watch": "mocha --watch test/index.js",
"next": "next",
"next-build": "next build",
"next-export": "next export",
"next-start": "next start",
"v-patch": "npm version patch && git push --tags && npm publish",
"v-minor": "npm version minor && git push --tags && npm publish",
"v-major": "npm version major && git push --tags && npm publish"
},

@@ -52,31 +56,28 @@ "repository": {

},
"homepage": "https://github.com/tscanlin/tocbot#readme",
"homepage": "https://github.com/tscanlin/tocbot",
"devDependencies": {
"babel-cli": "^6.7.7",
"babel-core": "^6.7.4",
"babel-eslint": "^6.0.0",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-register": "^6.7.2",
"babel-runtime": "^6.3.19",
"chai": "^3.4.1",
"eslint": "^2.4.0",
"gh-pages": "^0.11.0",
"glob": "^7.0.3",
"highlight.js": "^9.0.0",
"js-yaml": "^3.5.5",
"jsdom": "^8.3.1",
"marked": "^0.3.5",
"babel-cli": "^6.24.1",
"babel-core": "^6.24.1",
"babel-eslint": "^7.2.3",
"babel-loader": "^7.0.0",
"babel-plugin-wrap-in-js": "^1.1.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-register": "^6.24.1",
"babel-runtime": "^6.23.0",
"chai": "^3.5.0",
"eslint": "^3.19.0",
"gh-pages": "^0.12.0",
"globby": "^6.1.0",
"js-yaml": "^3.8.3",
"jsdom": "^9.12.0",
"marked": "^0.3.6",
"mkdirp": "^0.5.1",
"mocha": "^2.3.4",
"node-sass": "^3.4.2",
"onchange": "^2.2.0",
"optimizely-oui": "^11.3.0",
"mocha": "^3.2.0",
"next": "git+https://git@github.com/tscanlin/next.js.git",
"node-sass": "^4.5.2",
"parallelshell": "^2.0.0",
"react": "^15.0.1",
"react-dom": "^15.0.1",
"uglify-js": "^2.6.2",
"webpack": "^1.12.14",
"webpack-dev-server": "^1.14.1"
"processto": "^1.4.2",
"react": "^15.5.4",
"react-dom": "^15.5.4"
},

@@ -83,0 +84,0 @@ "dependencies": {

@@ -1,2 +0,2 @@

<h1 class="display--none">
<h1 class="dn">
<a href="http://tscanlin.github.io/tocbot">Tocbot</a>

@@ -56,3 +56,3 @@ <a href="https://travis-ci.org/tscanlin/tocbot" target="_blank"><img src="https://travis-ci.org/tscanlin/tocbot.svg?branch=master" alt="travis-ci" /></a>

```javascript
```js
tocbot.init({

@@ -188,119 +188,5 @@ // Where to render the table of contents.

- More tests
- Option for changing the url hash on scroll
- React.js support
## Changelog
### v2.3.2
#### Fixed
- [patch] Fix for smooth-scroll callback to work properly. [#36](https://github.com/tscanlin/tocbot/issues/36)
- [patch] Fix for cdnjs to update properly. [#35](https://github.com/tscanlin/tocbot/issues/35)
### v2.3.1
#### Fixed
- [patch] Fix for clicking svgs to not throw an exception. [#33](https://github.com/tscanlin/tocbot/issues/33)
### v2.3.0
#### Changed
- [patch] Fix for proper header not being selected due to sub-pixel rounding issues. [#31](https://github.com/tscanlin/tocbot/pull/31)
- [dev] Updated test commands to be able to selectively run tests and debug them more easily. [#29](https://github.com/tscanlin/tocbot/pull/29)
### v2.2.2
#### Changed
- [patch] Removed updateUrl option from docs since it doesn't work, see: [smooth-scroll #283](https://github.com/cferdinandi/smooth-scroll/pull/283).
### v2.2.1
#### Added
- [patch] Made bower.json reference unminified file.
### v2.2.0
#### Added
- [minor] Added bower.json to provide bower support.
### v2.1.5
#### Added
- [patch] Added `overflow-y: auto` to the `.toc selector so that it scrolls` (#17).
- [dev] Added to deploy script to commit /dist files to master.
- [dev] Added to package.json for cdnjs.
### v2.1.4
#### Added
- [patch] `includeHtml` option to mirror markup from the headings in the TOC (#14).
- [patch] `listItemClass` will be omitted if an empty string in passed.
- [dev] `test:watch` command.
- [dev] more tests.
### v2.1.3
#### Added
- [patch] `listItemClass` option to set classes on list items (#12).
### v2.1.2
#### Fixed
- [patch] prevent errors from being thrown when elements are not present and add tests.
### v2.1.1
#### Changed
- [patch] update file size estimates in the docs.
- [patch] switch from throwing errors to using console.warn.
### v2.1
#### Added
- [minor] add `positionFixedSelector` option to specify the element to add a fixed position class to.
- [dev] use travis-ci for builds.
### v2.0
#### Added
- [major] smooth-scroll is included by default now.
- [patch] throttling support to improve performance, also the `throttleTimeout` option.
- [patch] new "try it now" option on documentation site.
#### Changed
- [minor] broke up scss files and separate tocbot styles better.
- [minor] default option for `contentSelector` to be `.js-toc-content`.
- [minor] default option for `ignoreSelector` to be `.js-toc-ignore`.
- [minor] default option for `collapsibleClass` to be `.is-collapsible`.
- [patch] reorder `default-options.js`.
- [patch] update documentation.
#### Removed
- [patch] dependency on classList to improve browser support.
#### Fixed
- [minor] new and improved tests using jsdom.
- [dev] switched from gulp to npm scripts.
- [dev] switched from browserify to webpack.
- [dev] switched from swig to react for building the documentation.
### v1.0
- First published source code.
## Contributing

@@ -320,8 +206,2 @@

#### Specific tests
To filter tests by `describe` or `it` description:
```bash
TEST_NAME="some string that appears in the test description" npm run test
```
#### With debugger

@@ -342,3 +222,3 @@ You can run tests through [node-inspector](https://github.com/node-inspector/node-inspector).

```
TEST_NAME="whatever, this is optional" npm run test:debug
npm run test:debug
```

@@ -345,0 +225,0 @@

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ module.exports = function() {

@@ -31,3 +31,3 @@ var fs = require('fs');

[
'./build/assets/js/tocbot.js'
'./static/js/tocbot.js'
],

@@ -34,0 +34,0 @@ function (err, window) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc