This repository has been archived by the owner on Nov 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added dependency-loading for scripts & changed how to style images.
- JavaScript now only loads when needed - Featured images now load using the {{image}} helper. - Tag pages now show the blog cover image - Images now use #fragments instead of classes. Enabling styling using markdown.
- Loading branch information
Gustav Lindqvist
committed
Sep 26, 2014
1 parent
90ba513
commit 3c4a718
Showing
15 changed files
with
98 additions
and
59 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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 |
---|---|---|
@@ -1,49 +1,65 @@ | ||
/* global hljs, $, console */ | ||
/* jshint browser: true */ | ||
hljs.initHighlightingOnLoad(); | ||
|
||
$("#main").fitVids(); | ||
|
||
function featuredImage() { | ||
if($('#featured').length){ | ||
$('#header').css('background-image','url('+$('#featured').attr('src')+')'); | ||
} | ||
/******************* | ||
* HIGHLIGHT CODE * | ||
*******************/ | ||
if($("code").length != 0){ | ||
$.getScript("/assets/js/helper/highlight.min.js", function() { | ||
hljs.initHighlightingOnLoad(); | ||
}); | ||
} | ||
|
||
/********************** | ||
* RESPONSIVE VIDEOS * | ||
**********************/ | ||
|
||
function fullImage(){ | ||
$(".full").each(function() { | ||
$(this).addClass("full-loaded"); | ||
$(this).closest("p").css("min-height",$(this).height()); | ||
$(this).closest("p").addClass("full-image-container"); | ||
}); | ||
} | ||
$.getScript("/assets/js/helper/jquery.fitvids.js", function() { | ||
$("#main").fitVids(); | ||
}); | ||
|
||
$(".gallery").imagesLoaded(gallery); | ||
$(window).resize(gallery); | ||
/************ | ||
* GALLERY * | ||
************/ | ||
|
||
if($(".gallery").length != 0){ // If there is a gallery present. | ||
$.getScript("/assets/js/helper/imagesloaded.pkgd.min.js", function() { | ||
$(".gallery").imagesLoaded(gallery); | ||
$(window).resize(gallery); | ||
}); | ||
} | ||
|
||
function gallery(){ | ||
var size = 0; | ||
if ($(window).height() > $(window).width()){ | ||
size = $(window).height(); | ||
} else { | ||
size = $(window).width(); | ||
} | ||
if (size < 210 ){ | ||
size = 210; | ||
} | ||
$('.gallery').removeWhitespace().collagePlus( | ||
{ | ||
'targetHeight':size/5 | ||
$.getScript("/assets/js/helper/gallery.min.js", function() { // Load in script for gallery | ||
var size = 0; | ||
if ($(window).height() > $(window).width()){ | ||
size = $(window).height(); | ||
} else { | ||
size = $(window).width(); | ||
} | ||
); | ||
if (size < 210 ){ | ||
size = 210; | ||
} | ||
$('.gallery').removeWhitespace().collagePlus( | ||
{ | ||
'targetHeight':size/5 | ||
} | ||
); | ||
}); | ||
} | ||
|
||
var timesince=function(t){var n={prefix:"",future:"",suffix:" sedan",seconds:"Några sekunder",minute:"En minut",minutes:"%d minuter",hour:"Mindre än en timme",hours:"%d timmar",day:"En dag",days:"%d dagar",month:"En månad",months:"%d månader",year:"Ungefär ett år",years:"%d år"};var r=function(e,t){return n[e]&&n[e].replace(/%d/i,Math.abs(Math.round(t)))};var i=function(e){if(!e)return;e=parseInt(e)*1e3;e=new Date(e);var t=new Date;var i=(t.getTime()-e)*.001>>0;var s=i/60;var o=s/60;var u=o/24;var a=u/365;return n.prefix+(i<0&&r("future")||i<45&&r("seconds",i)||i<90&&r("minute",1)||s<45&&r("minutes",s)||s<90&&r("hour",1)||o<24&&r("hours",o)||o<42&&r("day",1)||u<30&&r("days",u)||u<45&&r("month",1)||u<365&&r("months",u/30)||a<1.5&&r("year",1)||r("years",a))+(i<0&&""||n.suffix)};var s=document.getElementsByClassName("timesince");for(var o in s){var u=s[o];if(typeof u==="object"){u.innerHTML=i(u.dataset.timesince||u.dataset.timesince)}}setTimeout(timesince,6e4)} | ||
|
||
|
||
$(window).load(timesince); | ||
$("#main").imagesLoaded(fullImage); | ||
$("#main").imagesLoaded(featuredImage); | ||
$(window).resize(fullImage); | ||
/********************** | ||
* FULL WIDTH IMAGES * | ||
**********************/ | ||
|
||
$.getScript("/assets/js/helper/imagesloaded.pkgd.min.js", function() { | ||
function fullImage(){ | ||
$('img[src$="#full"]').each(function() { | ||
$(this).addClass("full-loaded"); | ||
$(this).closest("p").css("min-height",$(this).height()); | ||
$(this).closest("p").addClass("full-image-container"); | ||
}); | ||
} | ||
$("#main").imagesLoaded(fullImage); | ||
$(window).resize(fullImage); | ||
}); |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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