webdav.client 5.21.6101 → 5.21.6104
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.
- package/Help/ClassReference/Create.html +1809 -0
- package/Help/ClassReference/ITHit.Environment.html +1739 -0
- package/Help/ClassReference/ITHit.LogLevel.html +1985 -0
- package/Help/ClassReference/ITHit.Logger.html +2170 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.AsyncResult.html +1877 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.BrowserExtension.html +2282 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.CancellableResult.html +2049 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.DavConstants.html +3181 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Depth.html +1815 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.DocManager.html +3600 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Encoder.html +1785 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Error.html +1785 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.BadRequestException.html +1883 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.ConflictException.html +1883 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.DependencyFailedException.html +1883 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.ForbiddenException.html +1883 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.Info.Error.html +1753 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.Info.Multistatus.html +1703 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.Info.MultistatusResponse.html +1703 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.Info.PropertyMultistatus.html +1755 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.Info.PropertyMultistatusResponse.html +1703 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.InsufficientStorageException.html +1883 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.IntegrationException.html +1689 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.LockedException.html +1883 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.MethodNotAllowedException.html +1883 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.NotFoundException.html +1883 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.NotImplementedException.html +1883 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.Parsers.InsufficientStorage.html +1805 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.PreconditionFailedException.html +1883 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.PropertyConflictException.html +1929 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.PropertyException.html +1929 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.PropertyForbiddenException.html +1929 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.PropertyNotFoundException.html +1929 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.QuotaNotExceededException.html +1883 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.SufficientDiskSpaceException.html +1883 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.UnauthorizedException.html +1883 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.WebDavException.html +1695 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Exceptions.WebDavHttpException.html +1883 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Features.html +2215 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.File.html +9490 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Folder.html +11459 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.GEditInfo.html +1785 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.HierarchyItem.html +8324 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.HttpStatus.html +3861 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.LockInfo.html +1923 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.LockScope.html +1755 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.LockUriTokenPair.html +1785 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.CancelUpload.html +1691 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.CopyMove.html +1745 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.Delete.html +1691 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.ErrorResponse.html +1751 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.Get.GoAsync.html +1830 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.Get.html +1698 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.Head.html +1691 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.HttpMethod.html +1765 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.Lock.Go.html +1866 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.Lock.GoAsync.html +1884 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.Lock.html +1701 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.LockRefresh.Go.html +1866 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.LockRefresh.GoAsync.html +1884 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.LockRefresh.html +1701 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.Mkcol.html +1691 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.MultiResponse.html +1751 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.Options.html +1748 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.Propfind.html +1745 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.Proppatch.html +1691 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.Propstat.html +1733 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.Put.html +1691 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.Report.html +1761 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.Response.html +1751 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.ResponseFactory.html +1689 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.Search.html +1691 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.SingleResponse.html +1742 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.Undelete.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.Unlock.html +1691 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.UpdateToVersion.html +1691 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Methods.VersionControl.html +1691 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.MsOfficeEditExtensions.html +2103 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Multistatus.html +1785 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.MultistatusResponse.html +1831 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.OptionsInfo.html +1739 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.OrderProperty.html +1960 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.PageResults.html +1785 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Property.html +2017 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.PropertyList.html +2048 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.PropertyMultistatusResponse.html +1883 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.PropertyName.html +1972 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Request.html +2673 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.RequestProgress.html +1969 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.ResourceType.html +1755 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.ResumableUpload.html +2271 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.SPSManager.html +1951 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.SearchQuery.html +1974 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Source.html +1785 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.DocManager.MsOfficeEditExtensions.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.HierarchyItems.CopyMove.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.HierarchyItems.CreateFile.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.HierarchyItems.CreateFolder.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.HierarchyItems.Delete.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.HierarchyItems.GetFolderItems.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.HierarchyItems.GetHeadRequests.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.HierarchyItems.GetItemByFolder.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.HierarchyItems.GetItemBySession.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.HierarchyItems.GetParent.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.HierarchyItems.ItemExists.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.HierarchyItems.MicrosoftOfficeDiscovery.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.HierarchyItems.NameCheck.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.HierarchyItems.Progress.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.HierarchyItems.Refresh.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.HierarchyItems.Search.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.HierarchyItems.SupportedFeatures.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.HierarchyProperties.GetProperties.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.HierarchyProperties.UpdateProperties.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.Locks.CheckSupport.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.Locks.Etag.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.Locks.GetLocks.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.Locks.Lock.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.Locks.RefreshLock.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.Versions.GetVersions.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.Versions.ManageVersions.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.Versions.PutUnderVersion.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.Versions.ReadContent.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Tests.WebDavSession.Events.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.AutoUploader.html +1753 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Collections.Map.html +1916 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Collections.Pair.html +1787 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.ContentWriter.html +1945 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Controls.DropZone.html +1791 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Controls.FSEntryFactory.html +1689 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Controls.HtmlControl.html +1781 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Controls.Input.html +1791 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.DropZoneCollection.html +2140 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Events.AsyncEvent.html +1884 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Events.BaseEvent.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Events.BeforeUploadStarted.html +2030 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Events.Error.html +1695 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Events.EventName.html +1843 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Events.ProgressChanged.html +1791 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Events.QueueChanged.html +1787 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Events.StateChanged.html +1791 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Events.UploadError.html +2174 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Events.UploadItemsCreated.html +2150 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.FSEntry.html +1823 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.FileSpan.html +1806 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Groups.Group.html +1761 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Groups.GroupManager.html +1803 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.InputCollection.html +2140 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.ItemSettings.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Path.Generator.html +1888 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Path.PathCache.html +1693 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Progress.html +1969 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Providers.ProgressTracker.html +1744 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Providers.UploadDiff.html +1786 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Providers.UploadProvider.html +1832 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Queue.html +2618 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.ServerItem.html +1761 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Settings.html +1840 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.State.html +2031 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.States.BaseState.html +1685 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.States.CanceledState.html +1691 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.States.CompletedState.html +1691 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.States.Factory.html +1689 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.States.PausedState.html +1691 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.States.QueuedState.html +1691 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.States.ResumeState.html +1691 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.States.SkippedState.html +1691 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.States.UploadingState.html +1691 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.UploadItem.html +5087 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.UploadLocation.html +1761 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Uploader.html +2106 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.UploaderSession.html +3304 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Utils.DavUrl.html +1779 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Utils.DavUrlBuilder.html +1744 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Upload.Utils.RepeatableAction.html +1863 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.UploadProgressInfo.html +1877 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.Version.html +3357 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.WebDavRequest.html +1689 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.WebDavResponse.html +1689 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.WebDavSession.html +4046 -0
- package/Help/ClassReference/ITHit.WebDAV.Client.WebDavUtil.html +1689 -0
- package/Help/ClassReference/data/search.json +1 -0
- package/Help/ClassReference/fonts/Inconsolata-Regular.ttf +0 -0
- package/Help/ClassReference/fonts/OpenSans-Regular.ttf +0 -0
- package/Help/ClassReference/fonts/WorkSans-Bold.ttf +0 -0
- package/Help/ClassReference/global.html +7914 -0
- package/Help/ClassReference/index.html +2408 -0
- package/Help/ClassReference/scripts/core.js +710 -0
- package/Help/ClassReference/scripts/core.min.js +23 -0
- package/Help/ClassReference/scripts/resize.js +90 -0
- package/Help/ClassReference/scripts/search.js +265 -0
- package/Help/ClassReference/scripts/search.min.js +6 -0
- package/Help/ClassReference/scripts/third-party/Apache-License-2.0.txt +202 -0
- package/Help/ClassReference/scripts/third-party/fuse.js +9 -0
- package/Help/ClassReference/scripts/third-party/hljs-line-num-original.js +369 -0
- package/Help/ClassReference/scripts/third-party/hljs-line-num.js +1 -0
- package/Help/ClassReference/scripts/third-party/hljs-original.js +5171 -0
- package/Help/ClassReference/scripts/third-party/hljs.js +1 -0
- package/Help/ClassReference/scripts/third-party/jquery.min.js +6 -0
- package/Help/ClassReference/scripts/third-party/popper.js +5 -0
- package/Help/ClassReference/scripts/third-party/tippy.js +1 -0
- package/Help/ClassReference/scripts/third-party/tocbot.js +683 -0
- package/Help/ClassReference/scripts/third-party/tocbot.min.js +1 -0
- package/Help/ClassReference/styles/clean-jsdoc-theme-base.css +1053 -0
- package/Help/ClassReference/styles/clean-jsdoc-theme-dark.css +418 -0
- package/Help/ClassReference/styles/clean-jsdoc-theme-light.css +399 -0
- package/Help/ClassReference/styles/clean-jsdoc-theme.min.css +1 -0
- package/ITHitWebDAVClient.js +2 -2
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,683 @@
|
|
|
1
|
+
/* eslint no-var: off */
|
|
2
|
+
var defaultOptions = {
|
|
3
|
+
ignoreSelector: '.js-toc-ignore',
|
|
4
|
+
linkClass: 'toc-link',
|
|
5
|
+
extraLinkClasses: '',
|
|
6
|
+
activeLinkClass: 'is-active-link',
|
|
7
|
+
listClass: 'toc-list',
|
|
8
|
+
extraListClasses: '',
|
|
9
|
+
isCollapsedClass: 'is-collapsed',
|
|
10
|
+
collapsibleClass: 'is-collapsible',
|
|
11
|
+
listItemClass: 'toc-list-item',
|
|
12
|
+
activeListItemClass: 'is-active-li',
|
|
13
|
+
collapseDepth: 0,
|
|
14
|
+
scrollSmooth: true,
|
|
15
|
+
scrollSmoothDuration: 420,
|
|
16
|
+
scrollSmoothOffset: 0,
|
|
17
|
+
scrollEndCallback: function (e) { },
|
|
18
|
+
throttleTimeout: 50,
|
|
19
|
+
positionFixedSelector: null,
|
|
20
|
+
positionFixedClass: 'is-position-fixed',
|
|
21
|
+
fixedSidebarOffset: 'auto',
|
|
22
|
+
includeHtml: false,
|
|
23
|
+
includeTitleTags: false,
|
|
24
|
+
orderedList: true,
|
|
25
|
+
scrollContainer: null,
|
|
26
|
+
skipRendering: false,
|
|
27
|
+
headingLabelCallback: false,
|
|
28
|
+
ignoreHiddenElements: false,
|
|
29
|
+
headingObjectCallback: function(obj) {
|
|
30
|
+
if(obj.headingLevel === 4){
|
|
31
|
+
let newNameObj = document.querySelector('#' + obj.id.replaceAll(":", "\\:")).nextSibling;
|
|
32
|
+
|
|
33
|
+
while(newNameObj && newNameObj.nodeType !== 1) {
|
|
34
|
+
newNameObj = newNameObj.nextSibling
|
|
35
|
+
}
|
|
36
|
+
if(newNameObj && newNameObj.classList.contains('toc-nav-name')) obj.textContent = newNameObj.textContent;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return obj;
|
|
40
|
+
},
|
|
41
|
+
basePath: '',
|
|
42
|
+
disableTocScrollSync: false
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function ParseContent(options) {
|
|
46
|
+
var reduce = [].reduce
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get the last item in an array and return a reference to it.
|
|
50
|
+
* @param {Array} array
|
|
51
|
+
* @return {Object}
|
|
52
|
+
*/
|
|
53
|
+
function getLastItem(array) {
|
|
54
|
+
return array[array.length - 1]
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Get heading level for a heading dom node.
|
|
59
|
+
* @param {HTMLElement} heading
|
|
60
|
+
* @return {Number}
|
|
61
|
+
*/
|
|
62
|
+
function getHeadingLevel(heading) {
|
|
63
|
+
return +heading.nodeName.toUpperCase().replace('H', '')
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Get important properties from a heading element and store in a plain object.
|
|
68
|
+
* @param {HTMLElement} heading
|
|
69
|
+
* @return {Object}
|
|
70
|
+
*/
|
|
71
|
+
function getHeadingObject(heading) {
|
|
72
|
+
// each node is processed twice by this method because nestHeadingsArray() and addNode() calls it
|
|
73
|
+
// first time heading is real DOM node element, second time it is obj
|
|
74
|
+
// that is causing problem so I am processing only original DOM node
|
|
75
|
+
if (!(heading instanceof window.HTMLElement)) return heading
|
|
76
|
+
|
|
77
|
+
if (options.ignoreHiddenElements && (!heading.offsetHeight || !heading.offsetParent)) {
|
|
78
|
+
return null
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const headingLabel = heading.getAttribute('data-heading-label') ||
|
|
82
|
+
(options.headingLabelCallback ? String(options.headingLabelCallback(heading.textContent)) : heading.textContent.trim())
|
|
83
|
+
var obj = {
|
|
84
|
+
id: heading.id,
|
|
85
|
+
children: [],
|
|
86
|
+
nodeName: heading.nodeName,
|
|
87
|
+
headingLevel: getHeadingLevel(heading),
|
|
88
|
+
textContent: headingLabel
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (options.includeHtml) {
|
|
92
|
+
obj.childNodes = heading.childNodes
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (options.headingObjectCallback) {
|
|
96
|
+
return options.headingObjectCallback(obj, heading)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return obj
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Add a node to the nested array.
|
|
104
|
+
* @param {Object} node
|
|
105
|
+
* @param {Array} nest
|
|
106
|
+
* @return {Array}
|
|
107
|
+
*/
|
|
108
|
+
function addNode(node, nest) {
|
|
109
|
+
var obj = getHeadingObject(node)
|
|
110
|
+
var level = obj.headingLevel
|
|
111
|
+
var array = nest
|
|
112
|
+
var lastItem = getLastItem(array)
|
|
113
|
+
var lastItemLevel = lastItem
|
|
114
|
+
? lastItem.headingLevel
|
|
115
|
+
: 0
|
|
116
|
+
var counter = level - lastItemLevel
|
|
117
|
+
|
|
118
|
+
while (counter > 0) {
|
|
119
|
+
lastItem = getLastItem(array)
|
|
120
|
+
// Handle case where there are multiple h5+ in a row.
|
|
121
|
+
if (lastItem && level === lastItem.headingLevel) {
|
|
122
|
+
break
|
|
123
|
+
} else if (lastItem && lastItem.children !== undefined) {
|
|
124
|
+
array = lastItem.children
|
|
125
|
+
}
|
|
126
|
+
counter--
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (level >= options.collapseDepth) {
|
|
130
|
+
obj.isCollapsed = true
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
array.push(obj)
|
|
134
|
+
return array
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Select headings in content area, exclude any selector in options.ignoreSelector
|
|
139
|
+
* @param {HTMLElement} contentElement
|
|
140
|
+
* @param {Array} headingSelector
|
|
141
|
+
* @return {Array}
|
|
142
|
+
*/
|
|
143
|
+
function selectHeadings(contentElement, headingSelector) {
|
|
144
|
+
var selectors = headingSelector
|
|
145
|
+
if (options.ignoreSelector) {
|
|
146
|
+
selectors = headingSelector.split(',')
|
|
147
|
+
.map(function mapSelectors(selector) {
|
|
148
|
+
return selector.trim() + ':not(' + options.ignoreSelector + ')'
|
|
149
|
+
})
|
|
150
|
+
}
|
|
151
|
+
try {
|
|
152
|
+
return contentElement.querySelectorAll(selectors)
|
|
153
|
+
} catch (e) {
|
|
154
|
+
console.warn('Headers not found with selector: ' + selectors); // eslint-disable-line
|
|
155
|
+
return null
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Nest headings array into nested arrays with 'children' property.
|
|
161
|
+
* @param {Array} headingsArray
|
|
162
|
+
* @return {Object}
|
|
163
|
+
*/
|
|
164
|
+
function nestHeadingsArray(headingsArray) {
|
|
165
|
+
return reduce.call(headingsArray, function reducer(prev, curr) {
|
|
166
|
+
var currentHeading = getHeadingObject(curr)
|
|
167
|
+
if (currentHeading) {
|
|
168
|
+
addNode(currentHeading, prev.nest)
|
|
169
|
+
}
|
|
170
|
+
return prev
|
|
171
|
+
}, {
|
|
172
|
+
nest: []
|
|
173
|
+
})
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return {
|
|
177
|
+
nestHeadingsArray: nestHeadingsArray,
|
|
178
|
+
selectHeadings: selectHeadings
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function BuildHtml(options) {
|
|
183
|
+
var forEach = [].forEach
|
|
184
|
+
var some = [].some
|
|
185
|
+
var body = document.body
|
|
186
|
+
var tocElement
|
|
187
|
+
var mainContainer = document.querySelector(options.contentSelector)
|
|
188
|
+
var currentlyHighlighting = true
|
|
189
|
+
var SPACE_CHAR = ' '
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Create link and list elements.
|
|
193
|
+
* @param {Object} d
|
|
194
|
+
* @param {HTMLElement} container
|
|
195
|
+
* @return {HTMLElement}
|
|
196
|
+
*/
|
|
197
|
+
function createEl(d, container) {
|
|
198
|
+
var link = container.appendChild(createLink(d))
|
|
199
|
+
if (d.children.length) {
|
|
200
|
+
var list = createList(d.isCollapsed)
|
|
201
|
+
d.children.forEach(function (child) {
|
|
202
|
+
createEl(child, list)
|
|
203
|
+
})
|
|
204
|
+
link.appendChild(list)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Render nested heading array data into a given element.
|
|
210
|
+
* @param {HTMLElement} parent Optional. If provided updates the {@see tocElement} to match.
|
|
211
|
+
* @param {Array} data
|
|
212
|
+
* @return {HTMLElement}
|
|
213
|
+
*/
|
|
214
|
+
function render(parent, data) {
|
|
215
|
+
var collapsed = false
|
|
216
|
+
var container = createList(collapsed)
|
|
217
|
+
|
|
218
|
+
data.forEach(function (d) {
|
|
219
|
+
createEl(d, container)
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
// Return if no TOC element is provided or known.
|
|
223
|
+
tocElement = parent || tocElement
|
|
224
|
+
if (tocElement === null) {
|
|
225
|
+
return
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Remove existing child if it exists.
|
|
229
|
+
if (tocElement.firstChild) {
|
|
230
|
+
tocElement.removeChild(tocElement.firstChild)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Just return the parent and don't append the list if no links are found.
|
|
234
|
+
if (data.length === 0) {
|
|
235
|
+
return tocElement
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Append the Elements that have been created
|
|
239
|
+
return tocElement.appendChild(container)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Create link element.
|
|
244
|
+
* @param {Object} data
|
|
245
|
+
* @return {HTMLElement}
|
|
246
|
+
*/
|
|
247
|
+
function createLink(data) {
|
|
248
|
+
var item = document.createElement('li')
|
|
249
|
+
var a = document.createElement('a')
|
|
250
|
+
if (options.listItemClass) {
|
|
251
|
+
item.setAttribute('class', options.listItemClass)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (options.onClick) {
|
|
255
|
+
a.onclick = options.onClick
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (options.includeTitleTags) {
|
|
259
|
+
a.setAttribute('title', data.textContent)
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (options.includeHtml && data.childNodes.length) {
|
|
263
|
+
forEach.call(data.childNodes, function (node) {
|
|
264
|
+
a.appendChild(node.cloneNode(true))
|
|
265
|
+
})
|
|
266
|
+
} else {
|
|
267
|
+
// Default behavior.
|
|
268
|
+
a.textContent = data.textContent
|
|
269
|
+
}
|
|
270
|
+
a.setAttribute('href', options.basePath + '#' + data.id)
|
|
271
|
+
a.setAttribute('class', options.linkClass +
|
|
272
|
+
SPACE_CHAR + 'node-name--' + data.nodeName +
|
|
273
|
+
SPACE_CHAR + options.extraLinkClasses)
|
|
274
|
+
item.appendChild(a)
|
|
275
|
+
return item
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Create list element.
|
|
280
|
+
* @param {Boolean} isCollapsed
|
|
281
|
+
* @return {HTMLElement}
|
|
282
|
+
*/
|
|
283
|
+
function createList(isCollapsed) {
|
|
284
|
+
var listElement = (options.orderedList) ? 'ol' : 'ul'
|
|
285
|
+
var list = document.createElement(listElement)
|
|
286
|
+
var classes = options.listClass +
|
|
287
|
+
SPACE_CHAR + options.extraListClasses
|
|
288
|
+
if (isCollapsed) {
|
|
289
|
+
classes += SPACE_CHAR + options.collapsibleClass
|
|
290
|
+
classes += SPACE_CHAR + options.isCollapsedClass
|
|
291
|
+
}
|
|
292
|
+
list.setAttribute('class', classes)
|
|
293
|
+
return list
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Update fixed sidebar class.
|
|
298
|
+
* @return {HTMLElement}
|
|
299
|
+
*/
|
|
300
|
+
function updateFixedSidebarClass() {
|
|
301
|
+
if (options.scrollContainer && document.querySelector(options.scrollContainer)) {
|
|
302
|
+
var top
|
|
303
|
+
top = document.querySelector(options.scrollContainer).scrollTop
|
|
304
|
+
} else {
|
|
305
|
+
top = document.documentElement.scrollTop || body.scrollTop
|
|
306
|
+
}
|
|
307
|
+
var posFixedEl = document.querySelector(options.positionFixedSelector)
|
|
308
|
+
|
|
309
|
+
if (options.fixedSidebarOffset === 'auto') {
|
|
310
|
+
options.fixedSidebarOffset = tocElement.offsetTop
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
if (top > options.fixedSidebarOffset) {
|
|
314
|
+
if (posFixedEl.className.indexOf(options.positionFixedClass) === -1) {
|
|
315
|
+
posFixedEl.className += SPACE_CHAR + options.positionFixedClass
|
|
316
|
+
}
|
|
317
|
+
} else {
|
|
318
|
+
posFixedEl.className = posFixedEl.className.split(SPACE_CHAR + options.positionFixedClass).join('')
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Get top position of heading
|
|
324
|
+
* @param {HTMLElement} obj
|
|
325
|
+
* @return {int} position
|
|
326
|
+
*/
|
|
327
|
+
function getHeadingTopPos(obj) {
|
|
328
|
+
var position = 0
|
|
329
|
+
if (obj !== null) {
|
|
330
|
+
position = obj.offsetTop
|
|
331
|
+
if (options.hasInnerContainers) { position += getHeadingTopPos(obj.offsetParent) }
|
|
332
|
+
}
|
|
333
|
+
return position
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
function updateListActiveElement(topHeader) {
|
|
338
|
+
var forEach = [].forEach
|
|
339
|
+
|
|
340
|
+
var tocLinks = tocElement
|
|
341
|
+
.querySelectorAll('.' + options.linkClass)
|
|
342
|
+
forEach.call(tocLinks, function (tocLink) {
|
|
343
|
+
tocLink.className = tocLink.className.split(SPACE_CHAR + options.activeLinkClass).join('')
|
|
344
|
+
})
|
|
345
|
+
var tocLis = tocElement
|
|
346
|
+
.querySelectorAll('.' + options.listItemClass)
|
|
347
|
+
forEach.call(tocLis, function (tocLi) {
|
|
348
|
+
tocLi.className = tocLi.className.split(SPACE_CHAR + options.activeListItemClass).join('')
|
|
349
|
+
})
|
|
350
|
+
|
|
351
|
+
// Add the active class to the active tocLink.
|
|
352
|
+
var activeTocLink = tocElement
|
|
353
|
+
.querySelector('.' + options.linkClass +
|
|
354
|
+
'.node-name--' + topHeader.nodeName +
|
|
355
|
+
'[href="' + options.basePath + '#' + topHeader.id.replace(/([ #;&,.+*~':"!^$[\]()=>|/@])/g, '\\$1') + '"]')
|
|
356
|
+
if (activeTocLink && activeTocLink.className.indexOf(options.activeLinkClass) === -1) {
|
|
357
|
+
activeTocLink.className += SPACE_CHAR + options.activeLinkClass
|
|
358
|
+
}
|
|
359
|
+
var li = activeTocLink && activeTocLink.parentNode
|
|
360
|
+
if (li && li.className.indexOf(options.activeListItemClass) === -1) {
|
|
361
|
+
li.className += SPACE_CHAR + options.activeListItemClass
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
var tocLists = tocElement
|
|
365
|
+
.querySelectorAll('.' + options.listClass + '.' + options.collapsibleClass)
|
|
366
|
+
|
|
367
|
+
// Collapse the other collapsible lists.
|
|
368
|
+
forEach.call(tocLists, function (list) {
|
|
369
|
+
if (list.className.indexOf(options.isCollapsedClass) === -1) {
|
|
370
|
+
list.className += SPACE_CHAR + options.isCollapsedClass
|
|
371
|
+
}
|
|
372
|
+
})
|
|
373
|
+
|
|
374
|
+
// Expand the active link's collapsible list and its sibling if applicable.
|
|
375
|
+
if (activeTocLink && activeTocLink.nextSibling && activeTocLink.nextSibling.className.indexOf(options.isCollapsedClass) !== -1) {
|
|
376
|
+
activeTocLink.nextSibling.className = activeTocLink.nextSibling.className.split(SPACE_CHAR + options.isCollapsedClass).join('')
|
|
377
|
+
}
|
|
378
|
+
removeCollapsedFromParents(activeTocLink && activeTocLink.parentNode.parentNode)
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Update TOC highlighting and collpased groupings.
|
|
383
|
+
*/
|
|
384
|
+
function updateToc(headingsArray) {
|
|
385
|
+
// If a fixed content container was set
|
|
386
|
+
if (options.scrollContainer && document.querySelector(options.scrollContainer)) {
|
|
387
|
+
var top
|
|
388
|
+
top = document.querySelector(options.scrollContainer).scrollTop
|
|
389
|
+
} else {
|
|
390
|
+
top = document.documentElement.scrollTop || body.scrollTop
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// Add fixed class at offset
|
|
394
|
+
if (options.positionFixedSelector) {
|
|
395
|
+
updateFixedSidebarClass()
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// Get the top most heading currently visible on the page so we know what to highlight.
|
|
399
|
+
var headings = headingsArray
|
|
400
|
+
var topHeader
|
|
401
|
+
// Using some instead of each so that we can escape early.
|
|
402
|
+
if (currentlyHighlighting &&
|
|
403
|
+
tocElement !== null &&
|
|
404
|
+
headings.length > 0) {
|
|
405
|
+
some.call(headings, function (heading, i) {
|
|
406
|
+
var modifiedTopOffset = top + 10
|
|
407
|
+
if (mainContainer) {
|
|
408
|
+
modifiedTopOffset += mainContainer.clientHeight * (mainContainer.scrollTop) / (mainContainer.scrollHeight - mainContainer.clientHeight)
|
|
409
|
+
}
|
|
410
|
+
if (getHeadingTopPos(heading) > modifiedTopOffset) {
|
|
411
|
+
// Don't allow negative index value.
|
|
412
|
+
var index = (i === 0) ? i : i - 1
|
|
413
|
+
topHeader = headings[index]
|
|
414
|
+
return true
|
|
415
|
+
} else if (i === headings.length - 1) {
|
|
416
|
+
// This allows scrolling for the last heading on the page.
|
|
417
|
+
topHeader = headings[headings.length - 1]
|
|
418
|
+
return true
|
|
419
|
+
}
|
|
420
|
+
})
|
|
421
|
+
|
|
422
|
+
// Remove the active class from the other tocLinks.
|
|
423
|
+
updateListActiveElement(topHeader)
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Remove collpased class from parent elements.
|
|
429
|
+
* @param {HTMLElement} element
|
|
430
|
+
* @return {HTMLElement}
|
|
431
|
+
*/
|
|
432
|
+
function removeCollapsedFromParents(element) {
|
|
433
|
+
if (element && element.className.indexOf(options.collapsibleClass) !== -1 && element.className.indexOf(options.isCollapsedClass) !== -1) {
|
|
434
|
+
element.className = element.className.split(SPACE_CHAR + options.isCollapsedClass).join('')
|
|
435
|
+
return removeCollapsedFromParents(element.parentNode.parentNode)
|
|
436
|
+
}
|
|
437
|
+
return element
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Disable TOC Animation when a link is clicked.
|
|
442
|
+
* @param {Event} event
|
|
443
|
+
*/
|
|
444
|
+
function disableTocAnimation(event) {
|
|
445
|
+
var target = event.target || event.srcElement
|
|
446
|
+
if (typeof target.className !== 'string' || target.className.indexOf(options.linkClass) === -1) {
|
|
447
|
+
return
|
|
448
|
+
}
|
|
449
|
+
// Bind to tocLink clicks to temporarily disable highlighting
|
|
450
|
+
// while smoothScroll is animating.
|
|
451
|
+
currentlyHighlighting = false
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Enable TOC Animation.
|
|
456
|
+
*/
|
|
457
|
+
function enableTocAnimation() {
|
|
458
|
+
currentlyHighlighting = true
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
return {
|
|
462
|
+
enableTocAnimation: enableTocAnimation,
|
|
463
|
+
disableTocAnimation: disableTocAnimation,
|
|
464
|
+
render: render,
|
|
465
|
+
updateToc: updateToc,
|
|
466
|
+
updateListActiveElement: updateListActiveElement
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
function updateTocScroll(options) {
|
|
471
|
+
var toc = options.tocElement || document.querySelector(options.tocSelector)
|
|
472
|
+
if (toc && toc.scrollHeight > toc.clientHeight) {
|
|
473
|
+
var activeItem = toc.querySelector('.' + options.activeListItemClass)
|
|
474
|
+
if (activeItem) {
|
|
475
|
+
var topOffset = toc.getBoundingClientRect().top
|
|
476
|
+
toc.scrollTop = activeItem.offsetTop - topOffset
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
(function (root, factory) {
|
|
482
|
+
if (typeof define === 'function' && define.amd) {
|
|
483
|
+
define([], factory(root))
|
|
484
|
+
} else if (typeof exports === 'object') {
|
|
485
|
+
module.exports = factory(root)
|
|
486
|
+
} else {
|
|
487
|
+
root.tocbot = factory(root)
|
|
488
|
+
}
|
|
489
|
+
})(typeof global !== 'undefined' ? global : this.window || this.global, function (root) {
|
|
490
|
+
'use strict'
|
|
491
|
+
|
|
492
|
+
var options = {}
|
|
493
|
+
var tocbot = {}
|
|
494
|
+
var buildHtml
|
|
495
|
+
var parseContent
|
|
496
|
+
|
|
497
|
+
// Just return if its not a browser.
|
|
498
|
+
var supports = !!root && !!root.document && !!root.document.querySelector && !!root.addEventListener // Feature test
|
|
499
|
+
if (typeof window === 'undefined' && !supports) {
|
|
500
|
+
return
|
|
501
|
+
}
|
|
502
|
+
var headingsArray
|
|
503
|
+
|
|
504
|
+
// From: https://github.com/Raynos/xtend
|
|
505
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty
|
|
506
|
+
function extend() {
|
|
507
|
+
var target = {}
|
|
508
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
509
|
+
var source = arguments[i]
|
|
510
|
+
for (var key in source) {
|
|
511
|
+
if (hasOwnProperty.call(source, key)) {
|
|
512
|
+
target[key] = source[key]
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
return target
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// From: https://remysharp.com/2010/07/21/throttling-function-calls
|
|
520
|
+
function throttle(fn, threshhold, scope) {
|
|
521
|
+
threshhold || (threshhold = 250)
|
|
522
|
+
var last
|
|
523
|
+
var deferTimer
|
|
524
|
+
return function () {
|
|
525
|
+
var context = scope || this
|
|
526
|
+
var now = +new Date()
|
|
527
|
+
var args = arguments
|
|
528
|
+
if (last && now < last + threshhold) {
|
|
529
|
+
// hold on to it
|
|
530
|
+
clearTimeout(deferTimer)
|
|
531
|
+
deferTimer = setTimeout(function () {
|
|
532
|
+
last = now
|
|
533
|
+
fn.apply(context, args)
|
|
534
|
+
}, threshhold)
|
|
535
|
+
} else {
|
|
536
|
+
last = now
|
|
537
|
+
fn.apply(context, args)
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
function getContentElement(options) {
|
|
543
|
+
try {
|
|
544
|
+
return options.contentElement || document.querySelector(options.contentSelector)
|
|
545
|
+
} catch (e) {
|
|
546
|
+
console.warn('Contents element not found: ' + options.contentSelector) // eslint-disable-line
|
|
547
|
+
return null
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
function getTocElement(options) {
|
|
552
|
+
try {
|
|
553
|
+
return options.tocElement || document.querySelector(options.tocSelector)
|
|
554
|
+
} catch (e) {
|
|
555
|
+
console.warn('TOC element not found: ' + options.tocSelector) // eslint-disable-line
|
|
556
|
+
return null
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Destroy tocbot.
|
|
562
|
+
*/
|
|
563
|
+
tocbot.destroy = function () {
|
|
564
|
+
var tocElement = getTocElement(options)
|
|
565
|
+
if (tocElement === null) {
|
|
566
|
+
return
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
if (!options.skipRendering) {
|
|
570
|
+
// Clear HTML.
|
|
571
|
+
if (tocElement) {
|
|
572
|
+
tocElement.innerHTML = ''
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
// Remove event listeners.
|
|
577
|
+
if (options.scrollContainer && document.querySelector(options.scrollContainer)) {
|
|
578
|
+
document.querySelector(options.scrollContainer).removeEventListener('scroll', this._scrollListener, false)
|
|
579
|
+
document.querySelector(options.scrollContainer).removeEventListener('resize', this._scrollListener, false)
|
|
580
|
+
} else {
|
|
581
|
+
document.removeEventListener('scroll', this._scrollListener, false)
|
|
582
|
+
document.removeEventListener('resize', this._scrollListener, false)
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Initialize tocbot.
|
|
588
|
+
* @param {object} customOptions
|
|
589
|
+
*/
|
|
590
|
+
tocbot.init = function (customOptions) {
|
|
591
|
+
// feature test
|
|
592
|
+
if (!supports) {
|
|
593
|
+
return
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
// Merge defaults with user options.
|
|
597
|
+
// Set to options variable at the top.
|
|
598
|
+
options = extend(defaultOptions, customOptions || {})
|
|
599
|
+
this.options = options
|
|
600
|
+
this.state = {}
|
|
601
|
+
|
|
602
|
+
// Init smooth scroll if enabled (default).
|
|
603
|
+
if (options.scrollSmooth) {
|
|
604
|
+
options.duration = options.scrollSmoothDuration
|
|
605
|
+
options.offset = options.scrollSmoothOffset
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
// Pass options to these modules.
|
|
609
|
+
buildHtml = BuildHtml(options)
|
|
610
|
+
parseContent = ParseContent(options)
|
|
611
|
+
|
|
612
|
+
// For testing purposes.
|
|
613
|
+
this._buildHtml = buildHtml
|
|
614
|
+
this._parseContent = parseContent
|
|
615
|
+
this._headingsArray = headingsArray
|
|
616
|
+
this.updateTocListActiveElement = buildHtml.updateListActiveElement
|
|
617
|
+
|
|
618
|
+
// Destroy it if it exists first.
|
|
619
|
+
tocbot.destroy()
|
|
620
|
+
|
|
621
|
+
var contentElement = getContentElement(options)
|
|
622
|
+
if (contentElement === null) {
|
|
623
|
+
return
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
var tocElement = getTocElement(options)
|
|
627
|
+
if (tocElement === null) {
|
|
628
|
+
return
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
// Get headings array.
|
|
632
|
+
headingsArray = parseContent.selectHeadings(contentElement, options.headingSelector)
|
|
633
|
+
// Return if no headings are found.
|
|
634
|
+
if (headingsArray === null) {
|
|
635
|
+
return
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
// Build nested headings array.
|
|
639
|
+
var nestedHeadingsObj = parseContent.nestHeadingsArray(headingsArray)
|
|
640
|
+
var nestedHeadings = nestedHeadingsObj.nest
|
|
641
|
+
|
|
642
|
+
// Render.
|
|
643
|
+
if (!options.skipRendering) {
|
|
644
|
+
buildHtml.render(tocElement, nestedHeadings)
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
// Update Sidebar and bind listeners.
|
|
648
|
+
this._scrollListener = throttle(function (e) {
|
|
649
|
+
buildHtml.updateToc(headingsArray)
|
|
650
|
+
!options.disableTocScrollSync && updateTocScroll(options)
|
|
651
|
+
var isTop = e && e.target && e.target.scrollingElement && e.target.scrollingElement.scrollTop === 0
|
|
652
|
+
if ((e && (e.eventPhase === 0 || e.currentTarget === null)) || isTop) {
|
|
653
|
+
buildHtml.updateToc(headingsArray)
|
|
654
|
+
if (options.scrollEndCallback) {
|
|
655
|
+
options.scrollEndCallback(e)
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
}, options.throttleTimeout)
|
|
659
|
+
this._scrollListener()
|
|
660
|
+
if (options.scrollContainer && document.querySelector(options.scrollContainer)) {
|
|
661
|
+
document.querySelector(options.scrollContainer).addEventListener('scroll', this._scrollListener, false)
|
|
662
|
+
document.querySelector(options.scrollContainer).addEventListener('resize', this._scrollListener, false)
|
|
663
|
+
} else {
|
|
664
|
+
document.addEventListener('scroll', this._scrollListener, false)
|
|
665
|
+
document.addEventListener('resize', this._scrollListener, false)
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
return this
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Refresh tocbot.
|
|
673
|
+
*/
|
|
674
|
+
tocbot.refresh = function (customOptions) {
|
|
675
|
+
tocbot.destroy()
|
|
676
|
+
tocbot.init(customOptions || this.options)
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
// Make tocbot available globally.
|
|
680
|
+
root.tocbot = tocbot
|
|
681
|
+
|
|
682
|
+
return tocbot
|
|
683
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var defaultOptions={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",activeListItemClass:"is-active-li",collapseDepth:0,scrollSmooth:!0,scrollSmoothDuration:420,scrollSmoothOffset:0,scrollEndCallback:function(e){},throttleTimeout:50,positionFixedSelector:null,positionFixedClass:"is-position-fixed",fixedSidebarOffset:"auto",includeHtml:!1,includeTitleTags:!1,orderedList:!0,scrollContainer:null,skipRendering:!1,headingLabelCallback:!1,ignoreHiddenElements:!1,headingObjectCallback:function(t){if(4===t.headingLevel){let e=document.querySelector("#"+t.id.replaceAll(":","\\:")).nextSibling;for(;e&&1!==e.nodeType;)e=e.nextSibling;e&&e.classList.contains("toc-nav-name")&&(t.textContent=e.textContent)}return t},basePath:"",disableTocScrollSync:!1};function ParseContent(r){var t=[].reduce;function a(e){return e[e.length-1]}function c(e){if(!(e instanceof window.HTMLElement))return e;if(r.ignoreHiddenElements&&(!e.offsetHeight||!e.offsetParent))return null;var t=e.getAttribute("data-heading-label")||(r.headingLabelCallback?String(r.headingLabelCallback(e.textContent)):e.textContent.trim()),t={id:e.id,children:[],nodeName:e.nodeName,headingLevel:+e.nodeName.toUpperCase().replace("H",""),textContent:t};return r.includeHtml&&(t.childNodes=e.childNodes),r.headingObjectCallback?r.headingObjectCallback(t,e):t}return{nestHeadingsArray:function(e){return t.call(e,function(e,t){t=c(t);if(t){for(var l=e.nest,n=(t=c(t)).headingLevel,o=l,s=a(o),i=n-(s?s.headingLevel:0);0<i&&(!(s=a(o))||n!==s.headingLevel);)s&&void 0!==s.children&&(o=s.children),i--;n>=r.collapseDepth&&(t.isCollapsed=!0),o.push(t)}return e},{nest:[]})},selectHeadings:function(e,t){var l=t;r.ignoreSelector&&(l=t.split(",").map(function(e){return e.trim()+":not("+r.ignoreSelector+")"}));try{return e.querySelectorAll(l)}catch(e){return console.warn("Headers not found with selector: "+l),null}}}}function BuildHtml(i){var r,n=[].forEach,a=[].some,c=document.body,d=document.querySelector(i.contentSelector),u=!0,f=" ";function o(e,t){var l,t=t.appendChild(function(e){var t=document.createElement("li"),l=document.createElement("a");i.listItemClass&&t.setAttribute("class",i.listItemClass);i.onClick&&(l.onclick=i.onClick);i.includeTitleTags&&l.setAttribute("title",e.textContent);i.includeHtml&&e.childNodes.length?n.call(e.childNodes,function(e){l.appendChild(e.cloneNode(!0))}):l.textContent=e.textContent;return l.setAttribute("href",i.basePath+"#"+e.id),l.setAttribute("class",i.linkClass+f+"node-name--"+e.nodeName+f+i.extraLinkClasses),t.appendChild(l),t}(e));e.children.length&&(l=s(e.isCollapsed),e.children.forEach(function(e){o(e,l)}),t.appendChild(l))}function s(e){var t=i.orderedList?"ol":"ul",t=document.createElement(t),l=i.listClass+f+i.extraListClasses;return e&&(l=(l+=f+i.collapsibleClass)+(f+i.isCollapsedClass)),t.setAttribute("class",l),t}function m(e){var t=[].forEach,l=r.querySelectorAll("."+i.linkClass),l=(t.call(l,function(e){e.className=e.className.split(f+i.activeLinkClass).join("")}),r.querySelectorAll("."+i.listItemClass)),l=(t.call(l,function(e){e.className=e.className.split(f+i.activeListItemClass).join("")}),r.querySelector("."+i.linkClass+".node-name--"+e.nodeName+'[href="'+i.basePath+"#"+e.id.replace(/([ #;&,.+*~':"!^$[\]()=>|/@])/g,"\\$1")+'"]')),e=(l&&-1===l.className.indexOf(i.activeLinkClass)&&(l.className+=f+i.activeLinkClass),l&&l.parentNode),e=(e&&-1===e.className.indexOf(i.activeListItemClass)&&(e.className+=f+i.activeListItemClass),r.querySelectorAll("."+i.listClass+"."+i.collapsibleClass));t.call(e,function(e){-1===e.className.indexOf(i.isCollapsedClass)&&(e.className+=f+i.isCollapsedClass)}),l&&l.nextSibling&&-1!==l.nextSibling.className.indexOf(i.isCollapsedClass)&&(l.nextSibling.className=l.nextSibling.className.split(f+i.isCollapsedClass).join("")),function e(t){if(t&&-1!==t.className.indexOf(i.collapsibleClass)&&-1!==t.className.indexOf(i.isCollapsedClass))return t.className=t.className.split(f+i.isCollapsedClass).join(""),e(t.parentNode.parentNode);return t}(l&&l.parentNode.parentNode)}return{enableTocAnimation:function(){u=!0},disableTocAnimation:function(e){"string"==typeof(e=e.target||e.srcElement).className&&-1!==e.className.indexOf(i.linkClass)&&(u=!1)},render:function(e,t){var l=s(!1);if(t.forEach(function(e){o(e,l)}),null!==(r=e||r))return r.firstChild&&r.removeChild(r.firstChild),0===t.length?r:r.appendChild(l)},updateToc:function(e){n=i.scrollContainer&&document.querySelector(i.scrollContainer)?document.querySelector(i.scrollContainer).scrollTop:document.documentElement.scrollTop||c.scrollTop,i.positionFixedSelector&&(t=i.scrollContainer&&document.querySelector(i.scrollContainer)?document.querySelector(i.scrollContainer).scrollTop:document.documentElement.scrollTop||c.scrollTop,l=document.querySelector(i.positionFixedSelector),"auto"===i.fixedSidebarOffset&&(i.fixedSidebarOffset=r.offsetTop),t>i.fixedSidebarOffset?-1===l.className.indexOf(i.positionFixedClass)&&(l.className+=f+i.positionFixedClass):l.className=l.className.split(f+i.positionFixedClass).join(""));var n,t,l,o,s=e;u&&null!==r&&0<s.length&&(a.call(s,function(e,t){var l=n+10;return d&&(l+=d.clientHeight*d.scrollTop/(d.scrollHeight-d.clientHeight)),function e(t){var l=0;return null!==t&&(l=t.offsetTop,i.hasInnerContainers&&(l+=e(t.offsetParent))),l}(e)>l?(o=s[0===t?t:t-1],!0):t===s.length-1?(o=s[s.length-1],!0):void 0}),m(o))},updateListActiveElement:m}}function updateTocScroll(e){var t,l=e.tocElement||document.querySelector(e.tocSelector);l&&l.scrollHeight>l.clientHeight&&((e=l.querySelector("."+e.activeListItemClass))&&(t=l.getBoundingClientRect().top,l.scrollTop=e.offsetTop-t))}!function(e,t){"function"==typeof define&&define.amd?define([],t(e)):"object"==typeof exports?module.exports=t(e):e.tocbot=t(e)}("undefined"!=typeof global?global:this.window||this.global,function(e){"use strict";var l,a,c,d,u={},f={},m=!!(e&&e.document&&e.document.querySelector&&e.addEventListener);if("undefined"!=typeof window||m)return d=Object.prototype.hasOwnProperty,f.destroy=function(){var e=C(u);null!==e&&(u.skipRendering||e&&(e.innerHTML=""),u.scrollContainer&&document.querySelector(u.scrollContainer)?(document.querySelector(u.scrollContainer).removeEventListener("scroll",this._scrollListener,!1),document.querySelector(u.scrollContainer).removeEventListener("resize",this._scrollListener,!1)):(document.removeEventListener("scroll",this._scrollListener,!1),document.removeEventListener("resize",this._scrollListener,!1)))},f.init=function(e){if(m){u=function(){for(var e={},t=0;t<arguments.length;t++){var l,n=arguments[t];for(l in n)d.call(n,l)&&(e[l]=n[l])}return e}(defaultOptions,e||{}),this.options=u,this.state={},u.scrollSmooth&&(u.duration=u.scrollSmoothDuration,u.offset=u.scrollSmoothOffset),l=BuildHtml(u),a=ParseContent(u),this._buildHtml=l,this._parseContent=a,this._headingsArray=c,this.updateTocListActiveElement=l.updateListActiveElement,f.destroy();e=function(t){try{return t.contentElement||document.querySelector(t.contentSelector)}catch(e){return console.warn("Contents element not found: "+t.contentSelector),null}}(u);if(null!==e){var n,o,s,i,r,t=C(u);if(null!==t)if(null!==(c=a.selectHeadings(e,u.headingSelector)))return e=a.nestHeadingsArray(c).nest,u.skipRendering||l.render(t,e),this._scrollListener=(n=function(e){l.updateToc(c),u.disableTocScrollSync||updateTocScroll(u);var t=e&&e.target&&e.target.scrollingElement&&0===e.target.scrollingElement.scrollTop;(e&&(0===e.eventPhase||null===e.currentTarget)||t)&&(l.updateToc(c),u.scrollEndCallback&&u.scrollEndCallback(e))},o=(o=u.throttleTimeout)||250,function(){var e=s||this,t=+new Date,l=arguments;i&&t<i+o?(clearTimeout(r),r=setTimeout(function(){i=t,n.apply(e,l)},o)):(i=t,n.apply(e,l))}),this._scrollListener(),u.scrollContainer&&document.querySelector(u.scrollContainer)?(document.querySelector(u.scrollContainer).addEventListener("scroll",this._scrollListener,!1),document.querySelector(u.scrollContainer).addEventListener("resize",this._scrollListener,!1)):(document.addEventListener("scroll",this._scrollListener,!1),document.addEventListener("resize",this._scrollListener,!1)),this}}},f.refresh=function(e){f.destroy(),f.init(e||this.options)},e.tocbot=f;function C(t){try{return t.tocElement||document.querySelector(t.tocSelector)}catch(e){return console.warn("TOC element not found: "+t.tocSelector),null}}});
|