Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'linkflags'
  • Loading branch information
andrewmbacon committed Jul 8, 2014
2 parents e005b30 + f747f5f commit 983c6da
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 28 deletions.
41 changes: 24 additions & 17 deletions js/cs.js
Expand Up @@ -13,28 +13,22 @@ jQuery(document).ready(function($) {
var urlExploded = url.split('/')
var site = urlExploded[2]
var extensions = ['3g2', '3gp', 'avi', 'doc', 'docx', 'dotx', 'gif', 'jpg', 'jpeg', 'm4a', 'mid', 'midi', 'mov', 'mp3', 'mp4', 'mpg', 'odt', 'ogg', 'ogv', 'pdf', 'png', 'ppt', 'pptx', 'xls', 'xlsx', 'wav', 'wmv', 'zip', 'vsd']

$('#page a').each(function(){
//console.log('------------a')

function scanLinks(){
var href = $(this).attr('href').toLowerCase()
var img = $(this).children('img').length
var base = null
var last = null
var ext = null
var flag = null

// if (((href.charAt(0) != '?') || (href.charAt(0) != '#')) && img == 0 ){
// if (((href.charAt(0) != '?') || (href.charAt(0) != '#')) && img == 0 ){
if (href.charAt(0) != '#' && img == 0){
if (href.charAt(0) != '/'){
var hrefExploded = href.split('/')
base = hrefExploded[2]

if (base != site) {
//console.log('external link detected, adding icon...')
// is external, and is not a named anchor tag
var icon = '<span class="glyphicon glyphicon-new-window"></span>'
$(this).addClass('external').prepend(icon)
}


//console.log('checking to see if it might be a file...')
last = hrefExploded[hrefExploded.length-1] || ''
Expand All @@ -51,22 +45,35 @@ jQuery(document).ready(function($) {
//console.log('ext:'+ext)
flag.append('.'+ext)
}

})

//console.log('ext:'+ext)
}
if (flag != null){
$(this).append(flag)
}

}
if (base != site) {
//console.log('external link detected, adding icon...')
// is external, and is not a named anchor tag
var icon = '<span class="glyphicon glyphicon-new-window"></span>'
$(this).addClass('external').append(icon)
}
}


}
}

// This will only scan elements in these sections of the site.

var elementsToScan = [
'#comments',
'#site-navigation',
'article.page'
]

$.each(elementsToScan, function(index, value){
$(value+' a').each(scanLinks)
})



/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Nav: Neverwrap
Expand Down
2 changes: 1 addition & 1 deletion js/min/cs.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions style.css
Expand Up @@ -179,19 +179,23 @@ img {
.flag {
background-color: rgba(0, 0, 0, 0.1);
font-size: 80%;
padding: .1em .2em;
padding: .2em .3em;
margin-left: .4em;
border: 1px solid rgba(0, 0, 0, 0.2);
border-radius: .3em;
}

.external .glyphicon {
.btn .flag {
border-width: 0;
opacity: .7;
}

.external .glyphicon-new-window {
font-size: .8em;
margin-right: .4em;
margin-left: .4em;
opacity: .7;
}

.external:hover .glyphicon {
.external:hover .glyphicon-new-window {
opacity: 1;
}

Expand Down
13 changes: 8 additions & 5 deletions style.scss
Expand Up @@ -213,19 +213,22 @@ img {
.flag {
background-color:rgba(0,0,0, .1);
font-size: 80%;
padding: .1em .2em;
padding: .2em .3em;
margin-left: .4em;
border:1px solid rgba(0,0,0, .2);
border-radius:.3em;
}
.btn .flag {
border-width:0;
opacity:.7;
}
.external {
}
.external .glyphicon {
.external .glyphicon-new-window {
font-size:.8em;
margin-right:.4em;
margin-left:.4em;
opacity:.7;
}
.external:hover .glyphicon {
.external:hover .glyphicon-new-window {
opacity:1;
}

Expand Down

0 comments on commit 983c6da

Please sign in to comment.