-
Notifications
You must be signed in to change notification settings - Fork 18
icon and menu fixed #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
LastKing
wants to merge
1
commit into
willklein:master
Choose a base branch
from
LastKing:future/fixedMenu
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
|
|
||
| var threeBarSvg = '<svg height="16" width="12" xmlns="http://www.w3.org/2000/svg"><path d="M11.41 9H0.59c-0.59 0-0.59-0.41-0.59-1s0-1 0.59-1h10.81c0.59 0 0.59 0.41 0.59 1s0 1-0.59 1z m0-4H0.59c-0.59 0-0.59-0.41-0.59-1s0-1 0.59-1h10.81c0.59 0 0.59 0.41 0.59 1s0 1-0.59 1zM0.59 11h10.81c0.59 0 0.59 0.41 0.59 1s0 1-0.59 1H0.59c-0.59 0-0.59-0.41-0.59-1s0-1 0.59-1z" /></svg>'; | ||
|
|
||
| var getLinks = function() { | ||
| var getLinks = function () { | ||
| var header, tag, headerLevelStr, depth; | ||
| var headers = document.querySelectorAll('article.markdown-body h1, article.markdown-body h2, article.markdown-body h3, article.markdown-body h4, article.markdown-body h5, article.markdown-body h6'); | ||
| var links = []; | ||
|
|
@@ -23,17 +23,17 @@ var getLinks = function() { | |
| return links; | ||
| }; | ||
|
|
||
| var openList = function(depth) { | ||
| var openList = function (depth) { | ||
| var html = ''; | ||
|
|
||
| while (depth--) { | ||
| html += '<li><ul>'; | ||
| html += '<li><ul style="margin-left:20px;">'; | ||
| } | ||
|
|
||
| return html; | ||
| }; | ||
|
|
||
| var closeList = function(depth) { | ||
| var closeList = function (depth) { | ||
| var html = ''; | ||
|
|
||
| while (depth--) { | ||
|
|
@@ -43,7 +43,7 @@ var closeList = function(depth) { | |
| return html; | ||
| }; | ||
|
|
||
| var buildContents = function(links) { | ||
| var buildContents = function (links) { | ||
| var node; | ||
| var contents = '<ul>'; | ||
| var currentDepth = 1; | ||
|
|
@@ -59,7 +59,7 @@ var buildContents = function(links) { | |
|
|
||
| currentDepth = node.depth; | ||
|
|
||
| contents += '<li><a href="' + node.hash + '">' + node.text + '</a></li>'; | ||
| contents += '<li style="margin-bottom:5px;"><a href="' + node.hash + '">' + node.text + '</a></li>'; | ||
| } | ||
|
|
||
| while (currentDepth--) { | ||
|
|
@@ -69,31 +69,30 @@ var buildContents = function(links) { | |
| return contents; | ||
| }; | ||
|
|
||
| var insertContents = function(contents) { | ||
| var insertContents = function (contents) { | ||
| var fileView = false; | ||
| var readmeTarget = document.querySelectorAll('#readme > .Box-header > h3')[0]; | ||
| var markdownTarget; | ||
|
|
||
| if (!readmeTarget) { | ||
| markdownTarget = document.querySelectorAll('.file-actions')[0]; | ||
| } | ||
|
|
||
| if (!readmeTarget && !markdownTarget) { | ||
| return false; | ||
| } | ||
|
|
||
| var oldLink = document.querySelectorAll('.github-markdown-contents')[0]; | ||
|
|
||
| if (oldLink) { | ||
| oldLink.parentNode.removeChild(oldLink); | ||
| } | ||
|
|
||
| var link = '<span class="github-markdown-contents select-menu js-menu-container js-select-menu"><span class="github-markdown-contents-btn js-select-menu js-menu-target btn btn-sm tooltipped-s' + (markdownTarget ? '' : ' float-right') + '" role="button" aria-label="Show Table of Contents">' + threeBarSvg + '</span><div class="select-menu-modal-holder github-markdown-contents-modal-holder js-menu-content js-navigation-container"><div id="github-markdown-contents-container" class="select-menu-modal">' + contents + '</div></div></span>'; | ||
| if (readmeTarget) { | ||
| readmeTarget.parentNode.innerHTML += link; | ||
| } else { | ||
| markdownTarget.innerHTML += link; | ||
| } | ||
| var link = '<span class="github-markdown-contents select-menu js-menu-container js-select-menu"><span class="github-markdown-contents-btn js-select-menu js-menu-target btn btn-sm tooltipped-s' + '" role="button" aria-label="Show Table of Contents">' + threeBarSvg + '</span>' + | ||
| '<div class="select-menu-modal-holder github-markdown-contents-modal-holder js-menu-content js-navigation-container" style="width:300px;left:-100px;top:20px;">' + | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for making this multiple lines! |
||
| '<div id="github-markdown-contents-container" class="select-menu-modal">' + contents + '</div>' + | ||
| '</div>' + | ||
| '</span>'; | ||
|
|
||
| var fixDiv = document.createElement('div'); | ||
| fixDiv.id = 'github-menu'; | ||
| fixDiv.style.position = 'fixed'; | ||
| fixDiv.style.zIndex = '99999'; | ||
| fixDiv.style.left = '50%'; | ||
| fixDiv.style.top = '0'; | ||
| document.body.append(fixDiv); | ||
|
|
||
| fixDiv.innerHTML = link; | ||
| }; | ||
|
|
||
| var links = getLinks(); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this pull request I'll setup Prettier so this auto-formats consistently going forward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok,My code is idea format .
It's different from your way.