first commit
This commit is contained in:
209
source/js/ayer.js
Normal file
209
source/js/ayer.js
Normal file
@@ -0,0 +1,209 @@
|
||||
(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-item-search').on('click', function () {
|
||||
if (isSearchAnim) return;
|
||||
startSearchAnim();
|
||||
$searchWrap.addClass('on');
|
||||
stopSearchAnim(function () {
|
||||
$('.local-search-input').focus();
|
||||
});
|
||||
});
|
||||
|
||||
$(document).mouseup(function (e) {
|
||||
var _con = $('.local-search');
|
||||
if (!_con.is(e.target) && _con.has(e.target).length === 0) {
|
||||
$searchWrap.removeClass('on');
|
||||
}
|
||||
});
|
||||
|
||||
//
|
||||
// 移动设备侦测
|
||||
var isMobile = {
|
||||
Android: function () {
|
||||
return navigator.userAgent.match(/Android/i);
|
||||
},
|
||||
BlackBerry: function () {
|
||||
return navigator.userAgent.match(/BlackBerry/i);
|
||||
},
|
||||
iOS: function () {
|
||||
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
|
||||
},
|
||||
Opera: function () {
|
||||
return navigator.userAgent.match(/Opera Mini/i);
|
||||
},
|
||||
Windows: function () {
|
||||
return navigator.userAgent.match(/IEMobile/i);
|
||||
},
|
||||
any: function () {
|
||||
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// 建议在移动端不初始化,其实 /search.xml 文件还挺大的,
|
||||
if ($('.local-search').size() && !isMobile.any()) {
|
||||
$.getScript('/js/search.js', function () {
|
||||
searchFunc("/search.xml", 'local-search-input', 'local-search-result');
|
||||
});
|
||||
}
|
||||
|
||||
//
|
||||
// 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'),
|
||||
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?url=' + encodedUrl + '" class="article-share-twitter" target="_blank" title="Twitter"></a>',
|
||||
'<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="article-share-facebook" target="_blank" title="Facebook"></a>',
|
||||
'<a href="http://pinterest.com/pin/create/button/?url=' + encodedUrl + '" class="article-share-pinterest" target="_blank" title="Pinterest"></a>',
|
||||
'<a href="https://plus.google.com/share?url=' + encodedUrl + '" class="article-share-google" target="_blank" title="Google+"></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');
|
||||
});
|
||||
|
||||
//
|
||||
// fancybox
|
||||
if ($.fancybox) {
|
||||
$('[data-fancybox]').fancybox({
|
||||
protect: true
|
||||
});
|
||||
}
|
||||
|
||||
//
|
||||
// lazyload
|
||||
$("img.lazy").lazyload({
|
||||
effect : "fadeIn"
|
||||
});
|
||||
|
||||
//
|
||||
// justifiedGallery
|
||||
$('#gallery').justifiedGallery({
|
||||
rowHeight : 200,
|
||||
margins : 5
|
||||
});
|
||||
|
||||
//
|
||||
$(document).ready(function ($) {
|
||||
$('.anchor').click(function (event) {
|
||||
event.preventDefault();
|
||||
$('main').animate({scrollTop: $(this.hash).offset().top}, 'smooth');
|
||||
});
|
||||
});
|
||||
|
||||
// To top
|
||||
(function($) {
|
||||
// When to show the scroll link
|
||||
// higher number = scroll link appears further down the page
|
||||
var upperLimit = 1000;
|
||||
|
||||
// Our scroll link element
|
||||
var scrollElem = $('#totop');
|
||||
|
||||
// Scroll to top speed
|
||||
var scrollSpeed = 1600;
|
||||
|
||||
// Show and hide the scroll to top link based on scroll position
|
||||
scrollElem.hide();
|
||||
$('.content').scroll(function () {
|
||||
var scrollTop = $('.content').scrollTop();
|
||||
if ( scrollTop > upperLimit ) {
|
||||
$(scrollElem).stop().fadeTo(300, 1); // fade back in
|
||||
}else{
|
||||
$(scrollElem).stop().fadeTo(300, 0); // fade out
|
||||
}
|
||||
});
|
||||
|
||||
// Scroll to top animation on click
|
||||
$(scrollElem).click(function(){
|
||||
$('.content').animate({scrollTop:0}, scrollSpeed); return false;
|
||||
});
|
||||
})(jQuery);
|
||||
|
||||
// Mobile nav
|
||||
var $content = $('.content'),
|
||||
$sidebar = $('.sidebar'),
|
||||
isMobileNavAnim = false,
|
||||
mobileNavAnimDuration = 200;
|
||||
|
||||
var startMobileNavAnim = function () {
|
||||
isMobileNavAnim = true;
|
||||
};
|
||||
|
||||
var stopMobileNavAnim = function () {
|
||||
setTimeout(function () {
|
||||
isMobileNavAnim = false;
|
||||
}, mobileNavAnimDuration);
|
||||
};
|
||||
|
||||
$('.navbar-toggle').on('click', function () {
|
||||
if (isMobileNavAnim) return;
|
||||
startMobileNavAnim();
|
||||
$content.toggleClass('on');
|
||||
$sidebar.toggleClass('on');
|
||||
stopMobileNavAnim();
|
||||
});
|
||||
|
||||
$($content).on('click', function () {
|
||||
if (isMobileNavAnim || !$content.hasClass('on')) return;
|
||||
$content.removeClass('on');
|
||||
$sidebar.removeClass('on');
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
||||
|
1
source/js/busuanzi-2.3.pure.min.js
vendored
Normal file
1
source/js/busuanzi-2.3.pure.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var bszCaller,bszTag;!function(){var c,d,e,a=!1,b=[];ready=function(c){return a||"interactive"===document.readyState||"complete"===document.readyState?c.call(document):b.push(function(){return c.call(this)}),this},d=function(){for(var a=0,c=b.length;c>a;a++)b[a].apply(document);b=[]},e=function(){a||(a=!0,d.call(window),document.removeEventListener?document.removeEventListener("DOMContentLoaded",e,!1):document.attachEvent&&(document.detachEvent("onreadystatechange",e),window==window.top&&(clearInterval(c),c=null)))},document.addEventListener?document.addEventListener("DOMContentLoaded",e,!1):document.attachEvent&&(document.attachEvent("onreadystatechange",function(){/loaded|complete/.test(document.readyState)&&e()}),window==window.top&&(c=setInterval(function(){try{a||document.documentElement.doScroll("left")}catch(b){return}e()},5)))}(),bszCaller={fetch:function(a,b){var c="BusuanziCallback_"+Math.floor(1099511627776*Math.random());window[c]=this.evalCall(b),a=a.replace("=BusuanziCallback","="+c),scriptTag=document.createElement("SCRIPT"),scriptTag.type="text/javascript",scriptTag.defer=!0,scriptTag.src=a,document.getElementsByTagName("HEAD")[0].appendChild(scriptTag)},evalCall:function(a){return function(b){ready(function(){try{a(b),scriptTag.parentElement.removeChild(scriptTag)}catch(c){bszTag.hides()}})}}},bszCaller.fetch("//busuanzi.ibruce.info/busuanzi?jsonpCallback=BusuanziCallback",function(a){bszTag.texts(a),bszTag.shows()}),bszTag={bszs:["site_pv","page_pv","site_uv"],texts:function(a){this.bszs.map(function(b){var c=document.getElementById("busuanzi_value_"+b);c&&(c.innerHTML=a[b])})},hides:function(){this.bszs.map(function(a){var b=document.getElementById("busuanzi_container_"+a);b&&(b.style.display="none")})},shows:function(){this.bszs.map(function(a){var b=document.getElementById("busuanzi_container_"+a);b&&(b.style.display="inline")})}};
|
6
source/js/jquery-2.0.3.min.js
vendored
Normal file
6
source/js/jquery-2.0.3.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
8
source/js/jquery.justifiedGallery.min.js
vendored
Normal file
8
source/js/jquery.justifiedGallery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
8
source/js/lazyload.min.js
vendored
Normal file
8
source/js/lazyload.min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*!
|
||||
* An jQuery | zepto plugin for lazy loading images.
|
||||
* author -> jieyou
|
||||
* see https://github.com/jieyou/lazyload
|
||||
* use some tuupola's code https://github.com/tuupola/jquery_lazyload (BSD)
|
||||
* use component's throttle https://github.com/component/throttle (MIT)
|
||||
*/
|
||||
!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t(window.jQuery||window.Zepto)}(function(t,e){var a,r,n=window,o=t(n),l={threshold:0,failure_limit:0,event:"scroll",effect:"show",effect_params:null,container:n,data_attribute:"original",data_srcset_attribute:"original-srcset",skip_invisible:!0,appear:i,load:i,vertical_only:!1,check_appear_throttle_time:300,url_rewriter_fn:i,no_fake_img_loader:!1,placeholder_data_img:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC",placeholder_real_img:"http://ditu.baidu.cn/yyfm/lazyload/0.0.1/img/placeholder.png"};function i(){}function c(t,e){return(e._$container==o?("innerHeight"in n?n.innerHeight:o.height())+o.scrollTop():e._$container.offset().top+e._$container.height())<=t.offset().top-e.threshold}function f(t,e){return(e._$container==o?o.scrollTop():e._$container.offset().top)>=t.offset().top+e.threshold+t.height()}function _(e,a){var r=0;e.each(function(l,i){var _=e.eq(l);if(!(_.width()<=0&&_.height()<=0||"none"===_.css("display")))if(a.vertical_only)if(f(_,a));else if(c(_,a)){if(++r>a.failure_limit)return!1}else d();else if(f(_,a)||function(e,a){return(a._$container==o?t.fn.scrollLeft?o.scrollLeft():n.pageXOffset:a._$container.offset().left)>=e.offset().left+a.threshold+e.width()}(_,a));else if(c(_,a)||function(e,a){return(a._$container==o?o.width()+(t.fn.scrollLeft?o.scrollLeft():n.pageXOffset):a._$container.offset().left+a._$container.width())<=e.offset().left-a.threshold}(_,a)){if(++r>a.failure_limit)return!1}else d();function d(){_.trigger("_lazyload_appear"),r=0}})}function d(t){return t.filter(function(e){return!t.eq(e).data("_lazyload_loadStarted")})}r=Object.prototype.toString,a=function(t){return r.call(t).replace("[object ","").replace("]","")},t.fn.hasOwnProperty("lazyload")||(t.fn.lazyload=function(e){var r,c,f,s=this;return t.isPlainObject(e)||(e={}),t.each(l,function(r,i){var c=a(e[r]);-1!=t.inArray(r,["threshold","failure_limit","check_appear_throttle_time"])?"String"==c?e[r]=parseInt(e[r],10):"Number"!=c&&(e[r]=i):"container"==r?(e.hasOwnProperty(r)?e[r]==n||e[r]==document?e._$container=o:e._$container=t(e[r]):e._$container=o,delete e.container):!l.hasOwnProperty(r)||e.hasOwnProperty(r)&&c==a(l[r])||(e[r]=i)}),r="scroll"==e.event,f=0==e.check_appear_throttle_time?_:function(t,e){var a,r,n,o,l=0;return function(){a=this,r=arguments;var t=new Date-l;return o||(t>=e?i():o=setTimeout(i,e-t)),n};function i(){o=0,l=+new Date,n=t.apply(a,r),a=null,r=null}}(_,e.check_appear_throttle_time),c=r||"scrollstart"==e.event||"scrollstop"==e.event,s.each(function(a,r){var n=this,o=s.eq(a),l=o.attr("src"),f=o.attr("data-"+e.data_attribute),_=e.url_rewriter_fn==i?f:e.url_rewriter_fn.call(n,o,f),u=o.attr("data-"+e.data_srcset_attribute),h=o.is("img");if(o.data("_lazyload_loadStarted")||l==_)return o.data("_lazyload_loadStarted",!0),void(s=d(s));o.data("_lazyload_loadStarted",!1),h&&!l&&o.one("error",function(){o.attr("src",e.placeholder_real_img)}).attr("src",e.placeholder_data_img),o.one("_lazyload_appear",function(){var a,r=t.isArray(e.effect_params);function l(){a&&o.hide(),h?(u&&o.attr("srcset",u),_&&o.attr("src",_)):o.css("background-image",'url("'+_+'")'),a&&o[e.effect].apply(o,r?e.effect_params:[]),s=d(s)}o.data("_lazyload_loadStarted")||(a="show"!=e.effect&&t.fn[e.effect]&&(!e.effect_params||r&&0==e.effect_params.length),e.appear!=i&&e.appear.call(n,o,s.length,e),o.data("_lazyload_loadStarted",!0),e.no_fake_img_loader||u?(e.load!=i&&o.one("load",function(){e.load.call(n,o,s.length,e)}),l()):t("<img />").one("load",function(){l(),e.load!=i&&e.load.call(n,o,s.length,e)}).attr("src",_))}),c||o.on(e.event,function(){o.data("_lazyload_loadStarted")||o.trigger("_lazyload_appear")})}),c&&e._$container.on(e.event,function(){f(s,e)}),o.on("resize load",function(){f(s,e)}),t(function(){f(s,e)}),this})});
|
2
source/js/pace.min.js
vendored
Normal file
2
source/js/pace.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
127
source/js/search.js
Normal file
127
source/js/search.js
Normal file
@@ -0,0 +1,127 @@
|
||||
// A local search script with the help of [hexo-generator-search](https://github.com/PaicHyperionDev/hexo-generator-search)
|
||||
// Copyright (C) 2015
|
||||
// Joseph Pan <http://github.com/wzpan>
|
||||
// Shuhao Mao <http://github.com/maoshuhao>
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; either version 2.1 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
// 02110-1301 USA
|
||||
//
|
||||
|
||||
var searchFunc = function (path, search_id, content_id) {
|
||||
'use strict';
|
||||
var BTN = "<button type='button' class='local-search-close' id='local-search-close'></button>";
|
||||
$.ajax({
|
||||
url: path,
|
||||
dataType: "xml",
|
||||
success: function (xmlResponse) {
|
||||
// get the contents from search data
|
||||
var datas = $("entry", xmlResponse).map(function () {
|
||||
return {
|
||||
title: $("title", this).text(),
|
||||
content: $("content", this).text(),
|
||||
url: $("url", this).text()
|
||||
};
|
||||
}).get();
|
||||
|
||||
var $input = document.getElementById(search_id);
|
||||
var $resultContent = document.getElementById(content_id);
|
||||
|
||||
$input.addEventListener('input', function () {
|
||||
var str = '<ul class="search-result-list">';
|
||||
var keywords = this.value.trim().toLowerCase().split(/[\s]+/);
|
||||
$resultContent.innerHTML = "";
|
||||
if (this.value.trim().length <= 0) {
|
||||
return;
|
||||
}
|
||||
// perform local searching
|
||||
datas.forEach(function (data) {
|
||||
var isMatch = true;
|
||||
// var content_index = [];
|
||||
if (!data.title || data.title.trim() === '') {
|
||||
data.title = "Untitled";
|
||||
}
|
||||
var data_title = data.title.trim().toLowerCase();
|
||||
var data_content = data.content.trim().replace(/<[^>]+>/g, "").toLowerCase();
|
||||
var data_url = data.url;
|
||||
var index_title = -1;
|
||||
var index_content = -1;
|
||||
var first_occur = -1;
|
||||
// only match artiles with not empty contents
|
||||
if (data_content !== '') {
|
||||
keywords.forEach(function (keyword, i) {
|
||||
index_title = data_title.indexOf(keyword);
|
||||
index_content = data_content.indexOf(keyword);
|
||||
|
||||
if (index_title < 0 && index_content < 0) {
|
||||
isMatch = false;
|
||||
} else {
|
||||
if (index_content < 0) {
|
||||
index_content = 0;
|
||||
}
|
||||
if (i == 0) {
|
||||
first_occur = index_content;
|
||||
}
|
||||
// content_index.push({index_content:index_content, keyword_len:keyword_len});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
isMatch = false;
|
||||
}
|
||||
// show search results
|
||||
if (isMatch) {
|
||||
str += "<li><a href='" + data_url + "' class='search-result-title'>" + data_title + "</a>";
|
||||
var content = data.content.trim().replace(/<[^>]+>/g, "");
|
||||
if (first_occur >= 0) {
|
||||
// cut out 100 characters
|
||||
var start = first_occur - 20;
|
||||
var end = first_occur + 80;
|
||||
|
||||
if (start < 0) {
|
||||
start = 0;
|
||||
}
|
||||
|
||||
if (start == 0) {
|
||||
end = 100;
|
||||
}
|
||||
|
||||
if (end > content.length) {
|
||||
end = content.length;
|
||||
}
|
||||
|
||||
var match_content = content.substr(start, end);
|
||||
|
||||
// highlight all keywords
|
||||
keywords.forEach(function (keyword) {
|
||||
var regS = new RegExp(keyword, "gi");
|
||||
match_content = match_content.replace(regS, "<em class=\"search-keyword\">" + keyword + "</em>");
|
||||
});
|
||||
|
||||
str += "<p class=\"search-result\">" + match_content + "...</p>"
|
||||
}
|
||||
str += "</li>";
|
||||
}
|
||||
});
|
||||
str += "</ul>";
|
||||
if (str.indexOf('<li>') === -1) {
|
||||
return $resultContent.innerHTML = BTN + "<div class=\"search-result-empty\"><p><i class=\"fe fe-tired\"></i> 没有找到内容,更换下搜索词试试吧~<p></div>";
|
||||
}
|
||||
$resultContent.innerHTML = BTN + str;
|
||||
});
|
||||
}
|
||||
});
|
||||
$(document).on('click', '#local-search-close', function () {
|
||||
$('#local-search-input').val('');
|
||||
$('#local-search-result').html('');
|
||||
});
|
||||
};
|
1
source/js/tocbot.min.js
vendored
Normal file
1
source/js/tocbot.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user