-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
52 additions
and
62 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict' | ||
|
||
window.Itch = Itch = | ||
version: '0.0.0' | ||
is: (property, value) -> this.app.dataset[property] is value | ||
app: do -> document.body | ||
|
||
$ -> | ||
Itch.context = -> | ||
# get the context from the first class name of body | ||
# https://github.com/TryGhost/Ghost/wiki/Context-aware-Filters-and-Helpers | ||
className = document.body.className.split(' ')[0].split('-')[0] | ||
if className is '' then 'error' else className | ||
|
||
Itch.device = -> | ||
w = window.innerWidth | ||
h = window.innerHeight | ||
return 'mobile' if (w <= 480) | ||
return 'tablet' if (w <= 1024) | ||
'desktop' | ||
|
||
# jQuery.smartresize | ||
`!function(n,r){var t;t=function(n,r,t){var i;return i=void 0,function(){var e,u,a;a=this,e=arguments,u=function(){t||n.apply(a,e),i=null},i?clearTimeout(i):t&&n.apply(a,e),i=setTimeout(u,r||100)}},jQuery.fn[r]=function(n){return n?this.bind("resize",t(n)):this.trigger(r)}}(jQuery,"smartresize");` |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict' | ||
|
||
$(window).load -> | ||
|
||
casperFullImg = do -> | ||
$('img').each -> | ||
contentWidth = $('.post-content').outerWidth() | ||
# Width of the content | ||
imageWidth = $(this)[0].naturalWidth | ||
# Original image resolution | ||
method = if imageWidth >= contentWidth then 'addClass' else 'removeClass' | ||
$(this)[method] 'full-img' | ||
|
||
$(window).smartresize casperFullImg | ||
|
||
$ -> | ||
el = Itch.app | ||
el.dataset.page = Itch.context() | ||
el.dataset.device = Itch.device() | ||
|
||
$('.post-content').fitVids() | ||
|
||
if Itch.is 'device', 'desktop' | ||
$('a').not('[href*="mailto:"]').click -> | ||
if this.href.indexOf(location.hostname) is -1 | ||
window.open $(this).attr 'href' | ||
false | ||
else | ||
FastClick.attach el |
This file was deleted.
Oops, something went wrong.