Skip to content
This repository has been archived by the owner on Jun 20, 2020. It is now read-only.

Commit

Permalink
Fix partially hidden code link menu. Closes #66
Browse files Browse the repository at this point in the history
  • Loading branch information
Mottie committed Jul 7, 2019
1 parent 9e48c44 commit 50aefb4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
18 changes: 14 additions & 4 deletions github-dark-script.user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name GitHub Dark Script
// @version 2.5.4
// @version 2.5.5
// @description GitHub Dark in userscript form, with a settings panel
// @license MIT
// @author StylishThemes
Expand Down Expand Up @@ -152,8 +152,8 @@
"Monokai Spacegray Eighties": "monokai-spacegray-eighties",
"Obsidian": "obsidian",
"Pastel on Dark": "pastel-on-dark",
"Solarized Dark": "solarized-dark",
"Railscasts": "railscasts",
"Solarized Dark": "solarized-dark",
"Tomorrow Night": "tomorrow-night",
"Tomorrow Night Blue": "tomorrow-night-blue",
"Tomorrow Night Bright": "tomorrow-night-bright",
Expand Down Expand Up @@ -613,9 +613,10 @@
icons next to a pre */
.ghd-wrap-toggle { padding: 3px 5px; position:absolute; right:3px; top:3px; -moz-user-select:none; -webkit-user-select:none; cursor:pointer; z-index:20; }
.ghd-code-wrapper:not(:hover) .ghd-wrap-toggle { border-color:transparent !important; background:transparent !important; }
.ghd-menu { margin-top:45px; }
/* file & diff code tables */
.ghd-wrap-table .blob-code-inner { white-space:pre-wrap !important; word-break:break-all !important; }
.ghd-unwrap-table .blob-code-inner { white-space:pre !important; word-break:normal !important; }
.ghd-wrap-table .blob-code-inner:not(.blob-code-hunk) { white-space:pre-wrap !important; word-break:break-all !important; }
.ghd-unwrap-table .blob-code-inner:not(.blob-code-hunk) { white-space:pre !important; word-break:normal !important; }
.ghd-wrap-toggle > *, .ghd-monospace > *, .ghd-file-toggle > * { pointer-events:none; vertical-align:middle !important; }
/* icons for non-syntax highlighted code blocks; see https://github.com/gjtorikian/html-proofer/blob/master/README.md */
.markdown-body:not(.comment-body) .ghd-wrap-toggle:not(:first-child) { right:3.4em; }
Expand Down Expand Up @@ -759,6 +760,14 @@
target.classList.add("ghd-code-wrapper");
}

function moveMenu(codeWrap) {
const menu = $("details", codeWrap);
if (menu) {
menu.classList.add("ghd-menu");
codeWrap.parentNode.appendChild(menu);
}
}

// Add code wrap toggle
function buildCodeWrap() {
// mutation events happen quick, so we still add an update flag
Expand All @@ -773,6 +782,7 @@
$$(".blob-wrapper").forEach(el => {
if (el && !$(".ghd-wrap-toggle", el)) {
addCodeWrapButton(icon, el);
moveMenu(el); // Fixes #66
}
});
$$(`
Expand Down
18 changes: 15 additions & 3 deletions github-script-code-wrap.user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name GitHub Toggle Code Wrap
// @version 1.1.9
// @version 1.1.10
// @description A userscript that adds a code wrap toggle button
// @license MIT
// @author StylishThemes
Expand Down Expand Up @@ -94,6 +94,14 @@
target.classList.add("ghd-code-wrapper");
}

function moveMenu(codeWrap) {
const menu = $("details", codeWrap);
if (menu) {
menu.classList.add("ghd-menu");
codeWrap.parentNode.appendChild(menu);
}
}

// Add code wrap toggle
function buildCodeWrap() {
if (busy) {
Expand All @@ -114,6 +122,7 @@
while (indx--) {
if (!$(".ghd-wrap-toggle", wrapper[indx])) {
addCodeWrapButton(button, wrapper[indx]);
moveMenu(wrapper[indx]); // Fixes #66
}
}

Expand Down Expand Up @@ -168,12 +177,15 @@
border-color: transparent !important;
background: transparent !important;
}
.ghd-menu {
margin-top: 45px;
}
/* file & diff code tables */
body .ghd-wrap-table td.blob-code-inner {
body .ghd-wrap-table td.blob-code-inner:not(.blob-code-hunk) {
white-space: pre-wrap !important;
word-break: break-all !important;
}
body .ghd-unwrap-table td.blob-code-inner {
body .ghd-unwrap-table td.blob-code-inner:not(.blob-code-hunk) {
white-space: pre !important;
word-break: normal !important;
}
Expand Down

0 comments on commit 50aefb4

Please sign in to comment.