-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
62c956c
commit 0d53752
Showing
93 changed files
with
22,469 additions
and
9 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,138 @@ | ||
(function($){ | ||
// Search | ||
var $searchWrap = $('#search-form-wrap'), | ||
isSearchAnim = false, | ||
searchAnimDuration = 200; | ||
|
||
var startSearchAnim = function(){ | ||
isSearchAnim = true; | ||
}; | ||
|
||
var stopSearchAnim = function(callback){ | ||
setTimeout(function(){ | ||
isSearchAnim = false; | ||
callback && callback(); | ||
}, searchAnimDuration); | ||
}; | ||
|
||
$('.nav-search-btn').on('click', function(){ | ||
if (isSearchAnim) return; | ||
|
||
startSearchAnim(); | ||
$searchWrap.addClass('on'); | ||
stopSearchAnim(function(){ | ||
$('.search-form-input').focus(); | ||
}); | ||
}); | ||
|
||
$('.search-form-input').on('blur', function(){ | ||
startSearchAnim(); | ||
$searchWrap.removeClass('on'); | ||
stopSearchAnim(); | ||
}); | ||
|
||
// Share | ||
$('body').on('click', function(){ | ||
$('.article-share-box.on').removeClass('on'); | ||
}).on('click', '.article-share-link', function(e){ | ||
e.stopPropagation(); | ||
|
||
var $this = $(this), | ||
url = $this.attr('data-url'), | ||
encodedUrl = encodeURIComponent(url), | ||
id = 'article-share-box-' + $this.attr('data-id'), | ||
title = $this.attr('data-title'), | ||
offset = $this.offset(); | ||
|
||
if ($('#' + id).length){ | ||
var box = $('#' + id); | ||
|
||
if (box.hasClass('on')){ | ||
box.removeClass('on'); | ||
return; | ||
} | ||
} else { | ||
var html = [ | ||
'<div id="' + id + '" class="article-share-box">', | ||
'<input class="article-share-input" value="' + url + '">', | ||
'<div class="article-share-links">', | ||
'<a href="https://twitter.com/intent/tweet?text=' + encodeURIComponent(title) + '&url=' + encodedUrl + '" class="article-share-twitter" target="_blank" title="Twitter"><span class="fa fa-twitter"></span></a>', | ||
'<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="article-share-facebook" target="_blank" title="Facebook"><span class="fa fa-facebook"></span></a>', | ||
'<a href="http://pinterest.com/pin/create/button/?url=' + encodedUrl + '" class="article-share-pinterest" target="_blank" title="Pinterest"><span class="fa fa-pinterest"></span></a>', | ||
'<a href="https://www.linkedin.com/shareArticle?mini=true&url=' + encodedUrl + '" class="article-share-linkedin" target="_blank" title="LinkedIn"><span class="fa fa-linkedin"></span></a>', | ||
'</div>', | ||
'</div>' | ||
].join(''); | ||
|
||
var box = $(html); | ||
|
||
$('body').append(box); | ||
} | ||
|
||
$('.article-share-box.on').hide(); | ||
|
||
box.css({ | ||
top: offset.top + 25, | ||
left: offset.left | ||
}).addClass('on'); | ||
}).on('click', '.article-share-box', function(e){ | ||
e.stopPropagation(); | ||
}).on('click', '.article-share-box-input', function(){ | ||
$(this).select(); | ||
}).on('click', '.article-share-box-link', function(e){ | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
|
||
window.open(this.href, 'article-share-box-window-' + Date.now(), 'width=500,height=450'); | ||
}); | ||
|
||
// Caption | ||
$('.article-entry').each(function(i){ | ||
$(this).find('img').each(function(){ | ||
if ($(this).parent().hasClass('fancybox') || $(this).parent().is('a')) return; | ||
|
||
var alt = this.alt; | ||
|
||
if (alt) $(this).after('<span class="caption">' + alt + '</span>'); | ||
|
||
$(this).wrap('<a href="' + this.src + '" data-fancybox=\"gallery\" data-caption="' + alt + '"></a>') | ||
}); | ||
|
||
$(this).find('.fancybox').each(function(){ | ||
$(this).attr('rel', 'article' + i); | ||
}); | ||
}); | ||
|
||
if ($.fancybox){ | ||
$('.fancybox').fancybox(); | ||
} | ||
|
||
// Mobile nav | ||
var $container = $('#container'), | ||
isMobileNavAnim = false, | ||
mobileNavAnimDuration = 200; | ||
|
||
var startMobileNavAnim = function(){ | ||
isMobileNavAnim = true; | ||
}; | ||
|
||
var stopMobileNavAnim = function(){ | ||
setTimeout(function(){ | ||
isMobileNavAnim = false; | ||
}, mobileNavAnimDuration); | ||
} | ||
|
||
$('#main-nav-toggle').on('click', function(){ | ||
if (isMobileNavAnim) return; | ||
|
||
startMobileNavAnim(); | ||
$container.toggleClass('mobile-nav-on'); | ||
stopMobileNavAnim(); | ||
}); | ||
|
||
$('#wrap').on('click', function(){ | ||
if (isMobileNavAnim || !$container.hasClass('mobile-nav-on')) return; | ||
|
||
$container.removeClass('mobile-nav-on'); | ||
}); | ||
})(jQuery); |
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,162 @@ | ||
/* ======================================================================== | ||
* Bootstrap: affix.js v3.3.5 | ||
* http://getbootstrap.com/javascript/#affix | ||
* ======================================================================== | ||
* Copyright 2011-2015 Twitter, Inc. | ||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) | ||
* ======================================================================== */ | ||
|
||
|
||
+function ($) { | ||
'use strict'; | ||
|
||
// AFFIX CLASS DEFINITION | ||
// ====================== | ||
|
||
var Affix = function (element, options) { | ||
this.options = $.extend({}, Affix.DEFAULTS, options) | ||
|
||
this.$target = $(this.options.target) | ||
.on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this)) | ||
.on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this)) | ||
|
||
this.$element = $(element) | ||
this.affixed = null | ||
this.unpin = null | ||
this.pinnedOffset = null | ||
|
||
this.checkPosition() | ||
} | ||
|
||
Affix.VERSION = '3.3.5' | ||
|
||
Affix.RESET = 'affix affix-top affix-bottom' | ||
|
||
Affix.DEFAULTS = { | ||
offset: 0, | ||
target: window | ||
} | ||
|
||
Affix.prototype.getState = function (scrollHeight, height, offsetTop, offsetBottom) { | ||
var scrollTop = this.$target.scrollTop() | ||
var position = this.$element.offset() | ||
var targetHeight = this.$target.height() | ||
|
||
if (offsetTop != null && this.affixed == 'top') return scrollTop < offsetTop ? 'top' : false | ||
|
||
if (this.affixed == 'bottom') { | ||
if (offsetTop != null) return (scrollTop + this.unpin <= position.top) ? false : 'bottom' | ||
return (scrollTop + targetHeight <= scrollHeight - offsetBottom) ? false : 'bottom' | ||
} | ||
|
||
var initializing = this.affixed == null | ||
var colliderTop = initializing ? scrollTop : position.top | ||
var colliderHeight = initializing ? targetHeight : height | ||
|
||
if (offsetTop != null && scrollTop <= offsetTop) return 'top' | ||
if (offsetBottom != null && (colliderTop + colliderHeight >= scrollHeight - offsetBottom)) return 'bottom' | ||
|
||
return false | ||
} | ||
|
||
Affix.prototype.getPinnedOffset = function () { | ||
if (this.pinnedOffset) return this.pinnedOffset | ||
this.$element.removeClass(Affix.RESET).addClass('affix') | ||
var scrollTop = this.$target.scrollTop() | ||
var position = this.$element.offset() | ||
return (this.pinnedOffset = position.top - scrollTop) | ||
} | ||
|
||
Affix.prototype.checkPositionWithEventLoop = function () { | ||
setTimeout($.proxy(this.checkPosition, this), 1) | ||
} | ||
|
||
Affix.prototype.checkPosition = function () { | ||
if (!this.$element.is(':visible')) return | ||
|
||
var height = this.$element.height() | ||
var offset = this.options.offset | ||
var offsetTop = offset.top | ||
var offsetBottom = offset.bottom | ||
var scrollHeight = Math.max($(document).height(), $(document.body).height()) | ||
|
||
if (typeof offset != 'object') offsetBottom = offsetTop = offset | ||
if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element) | ||
if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element) | ||
|
||
var affix = this.getState(scrollHeight, height, offsetTop, offsetBottom) | ||
|
||
if (this.affixed != affix) { | ||
if (this.unpin != null) this.$element.css('top', '') | ||
|
||
var affixType = 'affix' + (affix ? '-' + affix : '') | ||
var e = $.Event(affixType + '.bs.affix') | ||
|
||
this.$element.trigger(e) | ||
|
||
if (e.isDefaultPrevented()) return | ||
|
||
this.affixed = affix | ||
this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null | ||
|
||
this.$element | ||
.removeClass(Affix.RESET) | ||
.addClass(affixType) | ||
.trigger(affixType.replace('affix', 'affixed') + '.bs.affix') | ||
} | ||
|
||
if (affix == 'bottom') { | ||
this.$element.offset({ | ||
top: scrollHeight - height - offsetBottom | ||
}) | ||
} | ||
} | ||
|
||
|
||
// AFFIX PLUGIN DEFINITION | ||
// ======================= | ||
|
||
function Plugin(option) { | ||
return this.each(function () { | ||
var $this = $(this) | ||
var data = $this.data('bs.affix') | ||
var options = typeof option == 'object' && option | ||
|
||
if (!data) $this.data('bs.affix', (data = new Affix(this, options))) | ||
if (typeof option == 'string') data[option]() | ||
}) | ||
} | ||
|
||
var old = $.fn.affix | ||
|
||
$.fn.affix = Plugin | ||
$.fn.affix.Constructor = Affix | ||
|
||
|
||
// AFFIX NO CONFLICT | ||
// ================= | ||
|
||
$.fn.affix.noConflict = function () { | ||
$.fn.affix = old | ||
return this | ||
} | ||
|
||
|
||
// AFFIX DATA-API | ||
// ============== | ||
|
||
$(window).on('load', function () { | ||
$('[data-spy="affix"]').each(function () { | ||
var $spy = $(this) | ||
var data = $spy.data() | ||
|
||
data.offset = data.offset || {} | ||
|
||
if (data.offsetBottom != null) data.offset.bottom = data.offsetBottom | ||
if (data.offsetTop != null) data.offset.top = data.offsetTop | ||
|
||
Plugin.call($spy, data) | ||
}) | ||
}) | ||
|
||
}(jQuery); |
Oops, something went wrong.