Skip to content

Commit

Permalink
Remove text select javascript, closes #141
Browse files Browse the repository at this point in the history
  • Loading branch information
joshbuchea committed Sep 15, 2016
1 parent 19e4127 commit 4cd6e5c
Showing 1 changed file with 0 additions and 38 deletions.
38 changes: 0 additions & 38 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,5 @@ <h1 class="site__title">{{ site.title | xml_escape }}</h1>
</div>
</div>
</body>

<!-- <script src="js/script.js"></script> -->
<script>

// highlight text in code blocks when clicked
var codeBlocks = document.querySelectorAll('.highlighter-rouge code');
var codeBlocksLength = codeBlocks.length;
var i;

for (i = 0; i < codeBlocksLength; i++) {
codeBlocks[i].addEventListener('click', function() {
clip(this);
}, false);
}

var clip = function(el) {
var range = document.createRange();
var sel = window.getSelection();

range.selectNodeContents(el);

sel.removeAllRanges();
sel.addRange(range);
};

// open external links in new tab

This comment has been minimized.

Copy link
@marcobiedermann

marcobiedermann Sep 15, 2016

Collaborator

@joshbuchea You also removed this section, which opens all external links in a new tab

This comment has been minimized.

Copy link
@scottaohara

scottaohara Sep 15, 2016

Collaborator

i don't necessarily see that as a bad thing.

personally I come from the mindset that if people want to have links open in a new tab, that's something they can do themselves. i honestly don't like it when that is done automatically for me, since target="_blank" auto changes tabs, when i may not actually be done with reading the page i was previously on.

all that said, i vote it stays removed. feel free to disagree with me though :)

var links = document.links;
var linksLength = links.length;
var i;

for (i = 0; i < linksLength; i++) {
if (links[i].hostname != window.location.hostname) {
links[i].rel = 'noopener noreferrer';
links[i].target = '_blank';
}
}

</script>
{% include analytics.html %}
</html>

3 comments on commit 4cd6e5c

@joshbuchea
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha go me πŸŽ‰ Yeah that was an accident. @scottaohara I respect your opinion on opening links in new tabs, and I agree for internal links. However, personally, I prefer all external links to open in a new tab. Can't stand it when I assume a link will be opened in a new tab/window and instead it hijacks my tab/window and potentially loses the state of the page/app.

@FlorianWendelborn
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joshbuchea Don't assume, use the appropriate modifier key to open as new tab.

@joshbuchea
Copy link
Owner Author

@joshbuchea joshbuchea commented on 4cd6e5c Sep 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hope would have been a more appropriate word than assume, but point taken @dodekeract πŸ‘

Please sign in to comment.