兼容性调整

This commit is contained in:
结发受长生 2018-06-08 10:48:48 +08:00
parent e7c6945df4
commit 9fa331206c
15 changed files with 226 additions and 286 deletions

View File

@ -11,9 +11,6 @@
<div class="article-entry" itemprop="articleBody"> <div class="article-entry" itemprop="articleBody">
<% if (post.excerpt && index){ %> <% if (post.excerpt && index){ %>
<%- post.excerpt %> <%- post.excerpt %>
<% if (theme.excerpt_link) { %>
<a class="article-more-a" href="<%- url_for(post.path) %>#more"><%= theme.excerpt_link %> >></a>
<% } %>
<% } else { %> <% } else { %>
<%- post.content %> <%- post.content %>
<% } %> <% } %>
@ -78,24 +75,7 @@
<% } %> <% } %>
<%- partial('_partial/aside') %> <%- partial('_partial/aside') %>
<% if (!index && post.comments){ %> <% if (!index && post.comments){ %>
<% if (theme.duoshuo){ %>
<%- partial('post/duoshuo', {
key: post.slug,
title: post.title,
url: config.url+url_for(post.path)
}) %>
<% } %>
<% if (theme.wangyiyun){ %>
<%- partial('post/wangyiyun', {
key: post.slug,
title: post.title,
url: config.url+url_for(post.path)
}) %>
<% } %>
<% if (theme.changyan_appid && theme.changyan_conf){ %> <% if (theme.changyan_appid && theme.changyan_conf){ %>
<%- partial('post/changyan', { <%- partial('post/changyan', {
key: post.slug, key: post.slug,
@ -105,21 +85,21 @@
<% } %> <% } %>
<% if (theme.disqus || config.disqus_shortname){ %> <% if (theme.disqus || config.disqus_shortname){ %>
<section id="comments"> <section id="comments">
<div id="disqus_thread"></div> <div id="disqus_thread"></div>
<script type="text/javascript"> <script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */ /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = '<%= theme.disqus || config.disqus_shortname %>'; // required: replace example with your forum shortname var disqus_shortname = '<%= theme.disqus || config.disqus_shortname %>'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */ /* * * DON'T EDIT BELOW THIS LINE * * */
(function() { (function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})(); })();
</script> </script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</section> </section>
<% } %> <% } %>
<% if(theme.gitalk.enable){ %> <% if(theme.gitalk.enable){ %>

View File

@ -15,12 +15,8 @@
<% if (theme.subtitle){ %> <% if (theme.subtitle){ %>
<p class="header-subtitle"><i class="icon icon-quo-left"></i><%=theme.subtitle%><i class="icon icon-quo-right"></i></p> <p class="header-subtitle"><i class="icon icon-quo-left"></i><%=theme.subtitle%><i class="icon icon-quo-right"></i></p>
<% } %> <% } %>
<% var count = 0%> <% var count = Object.keys(theme.menu).length
<% for (var i in theme.menu){ %> var ulWidth = count > 2 ? '70%' : '50%' %>
<% count++ %>
<% } %>
<% var ulWidth = count > 2 ? '70%' : '50%' %>
<nav class="header-nav"> <nav class="header-nav">
<div class="social"> <div class="social">
<% for (var i in theme.subnav){ %> <% for (var i in theme.subnav){ %>

View File

@ -1,10 +0,0 @@
<div id="cloud-tie-wrapper" class="cloud-tie-wrapper"></div>
<script>
var cloudTieConfig = {
url: "<%=url%>",
sourceId: "<%=key%>",
productKey: "<%=theme.wangyiyun%>",
target: "cloud-tie-wrapper"
};
</script>
<script src="//img1.cache.netease.com/f2e/tie/yun/sdk/loader.js"></script>

View File

@ -1 +1 @@
<%- js('js/mobile.04379a910e1ff32f2a41.js') %> <%- js('js/slider.a725c75e59c2eeae98e0.js') %> <%- js('js/main.254cebd259c4777bdd2e.js') %> <%- js('js/mobile.ea63a7925e7ff5c87e64.js') %> <%- js('js/slider.6142a9af4c6883a7d429.js') %> <%- js('js/main.361198a3fa95601c34df.js') %>

View File

@ -121,7 +121,7 @@
<%if(hasAboutme){%> <%if(hasAboutme){%>
<section class="tools-section tools-section-me" v-show="aboutme"> <section class="tools-section tools-section-me" v-show="aboutme">
<%if(theme.aboutme){%> <%if(theme.aboutme){%>
<div class="aboutme-wrap" id="js-aboutme"><%=theme.aboutme%></div> <div class="aboutme-wrap" id="js-aboutme"><%-theme.aboutme%></div>
<%}%> <%}%>
</section> </section>
<%}%> <%}%>

View File

@ -89,7 +89,4 @@ function init() {
} }
} }
export default { init }
module.exports = {
init: init
}

View File

@ -1,47 +1,47 @@
var backTop = function (domE, ctn, distance) { var backTop = function (domE, ctn, distance) {
if (!domE) return; if (!domE) return;
var timer = null; var timer = null;
var _onscroll = window.onscroll, var _onscroll = window.onscroll,
_onclick = domE.onclick; _onclick = domE.onclick;
(ctn || window).onscroll = throttle(function () { (ctn || window).onscroll = throttle(function () {
typeof _onscroll === 'function' && _onscroll.apply(this, arguments); typeof _onscroll === 'function' && _onscroll.apply(this, arguments);
toggleDomE(); toggleDomE();
}, 100); }, 100);
domE.onclick = function () { domE.onclick = function () {
typeof _onclick === 'function' && _onclick.apply(this, arguments); typeof _onclick === 'function' && _onclick.apply(this, arguments);
var baseCt = ctn.scrollTop || document.documentElement.scrollTop || document.body.scrollTop; var baseCt = ctn.scrollTop || document.documentElement.scrollTop || document.body.scrollTop;
timer = setInterval(function () { //设置一个计时器 timer = setInterval(function () { //设置一个计时器
var ct = ctn.scrollTop || document.documentElement.scrollTop || document.body.scrollTop; //获取距离顶部的距离 var ct = ctn.scrollTop || document.documentElement.scrollTop || document.body.scrollTop; //获取距离顶部的距离
var diff = Math.max(10, ct / 6); var diff = Math.max(10, ct / 6);
ct -= diff; ct -= diff;
if (ct > 0) {//如果与顶部的距离大于零 if (ct > 0) {//如果与顶部的距离大于零
ctn.scrollTop = ctn.scrollTop - diff; ctn.scrollTop = ctn.scrollTop - diff;
window.scrollTo(0, ct);//向上移动10px window.scrollTo(0, ct);//向上移动10px
} else {//如果距离小于等于零 } else {//如果距离小于等于零
ctn.scrollTop = 0; ctn.scrollTop = 0;
window.scrollTo(0, 0);//移动到顶部 window.scrollTo(0, 0);//移动到顶部
clearInterval(timer);//清除计时器 clearInterval(timer);//清除计时器
} }
}, 10);//隔10ms执行一次前面的function展现一种平滑滑动效果 }, 10);//隔10ms执行一次前面的function展现一种平滑滑动效果
}; };
function toggleDomE() { function toggleDomE() {
domE.style.display = (ctn.scrollTop || document.documentElement.scrollTop || document.body.scrollTop) > (distance || 500) ? 'block' : 'none'; domE.style.display = (ctn.scrollTop || document.documentElement.scrollTop || document.body.scrollTop) > (distance || 500) ? 'block' : 'none';
} }
function throttle(func, wait) { function throttle(func, wait) {
var timer = null; var timer = null;
return function () { return function () {
var self = this, args = arguments; var self = this, args = arguments;
if (timer) clearTimeout(timer); if (timer) clearTimeout(timer);
timer = setTimeout(function () { timer = setTimeout(function () {
return typeof func === 'function' && func.apply(self, args); return typeof func === 'function' && func.apply(self, args);
}, wait); }, wait);
}
} }
}
}; };
function init() { function init() {
backTop(document.getElementById('js-jump-container'), document.getElementById('container')); backTop(document.getElementById('js-jump-container'), document.getElementById('container'));
} }
export default { init } export default { init }

View File

@ -1,20 +1,18 @@
var browser = { export default {
versions: function() { versions: function() {
var u = window.navigator.userAgent; var u = window.navigator.userAgent;
return { return {
trident: u.indexOf('Trident') > -1, //IE内核 trident: u.indexOf('Trident') > -1, //IE内核
presto: u.indexOf('Presto') > -1, //opera内核 presto: u.indexOf('Presto') > -1, //opera内核
webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核 webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核 gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端 mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端 ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器 android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器
iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, //是否为iPhone或者安卓QQ浏览器 iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, //是否为iPhone或者安卓QQ浏览器
iPad: u.indexOf('iPad') > -1, //是否为iPad iPad: u.indexOf('iPad') > -1, //是否为iPad
webApp: u.indexOf('Safari') == -1, //是否为web应用程序没有头部与底部 webApp: u.indexOf('Safari') == -1, //是否为web应用程序没有头部与底部
weixin: u.indexOf('MicroMessenger') == -1 //是否为微信浏览器 weixin: u.indexOf('MicroMessenger') == -1 //是否为微信浏览器
}; };
}() }()
} }
module.exports = browser

View File

@ -21,19 +21,10 @@ function init() {
// 目录序号 // 目录序号
if (yiliaConfig && yiliaConfig.toc_hide_index) { if (yiliaConfig && yiliaConfig.toc_hide_index) {
let $a = document.querySelectorAll(('.toc-number')) let $a = document.querySelectorAll(('.toc-number'))
$a.forEach(($em) => { Array.prototype.forEach.call($a, function($em){
$em.style.display = 'none'; $em.style.display = 'none';
}) })
} }
// about me 转义
var $aboutme = document.querySelector('#js-aboutme')
if ($aboutme && $aboutme.length !== 0) {
$aboutme.innerHTML = $aboutme.innerText
}
} }
module.exports = { export default { init }
init: init
}

View File

@ -1,7 +1,5 @@
// 样式 // 样式
import '../css/main.scss' import '../css/main.scss'
// 上报
// import './report'
// 图片查看器 // 图片查看器
import Viewer from './viewer' import Viewer from './viewer'
// 分享 // 分享
@ -9,9 +7,9 @@ import Share from './share'
// 边缘 // 边缘
import Aside from './aside' import Aside from './aside'
import {addLoadEvent} from './util' import Util from './util'
addLoadEvent(function() { Util.addLoadEvent(function() {
Share.init() Share.init()
Viewer.init() Viewer.init()
Aside.init() Aside.init()

View File

@ -6,7 +6,7 @@ import Browser from './browser'
// fix hexo 不支持的配置 // fix hexo 不支持的配置
import Fix from './fix' import Fix from './fix'
import {addLoadEvent} from './util' import Util from './util'
function isPathMatch(path, href) { function isPathMatch(path, href) {
let reg = /\/|index.html/g let reg = /\/|index.html/g
@ -16,13 +16,11 @@ function isPathMatch(path, href) {
function tabActive() { function tabActive() {
let $tabs = document.querySelectorAll('.js-header-menu li a') let $tabs = document.querySelectorAll('.js-header-menu li a')
let path = window.location.pathname let path = window.location.pathname
Array.prototype.forEach.call($tabs, function($tab, i){
for (var i = 0, len = $tabs.length; i < len; i++) {
let $tab = $tabs[i]
if (isPathMatch(path, $tab.getAttribute('href'))) { if (isPathMatch(path, $tab.getAttribute('href'))) {
addClass($tab, 'active') addClass($tab, 'active')
} }
} })
} }
function getElementLeft(element) {     function getElementLeft(element) {    
@ -99,6 +97,6 @@ function init() {
init(); init();
addLoadEvent(function() { Util.addLoadEvent(function() {
Fix.init() Fix.init()
}) })

View File

@ -2,78 +2,74 @@ import addClass from 'dom101/add-class'
import removeClass from 'dom101/remove-class' import removeClass from 'dom101/remove-class'
function generate(url, opts) { function generate(url, opts) {
var url = url.replace(/<%-sUrl%>/g, encodeURIComponent(opts.sUrl)) var url = url.replace(/<%-sUrl%>/g, encodeURIComponent(opts.sUrl))
.replace(/<%-sTitle%>/g, opts.sTitle) .replace(/<%-sTitle%>/g, opts.sTitle)
.replace(/<%-sDesc%>/g, opts.sDesc) .replace(/<%-sDesc%>/g, opts.sDesc)
.replace(/<%-sPic%>/g, encodeURIComponent(opts.sPic)); .replace(/<%-sPic%>/g, encodeURIComponent(opts.sPic));
window.open(url); window.open(url);
} }
function showWX() { function showWX() {
let $wx = document.querySelector('.js-wx-box') let $wx = document.querySelector('.js-wx-box')
let $mask = document.querySelector('.mask') let $mask = document.querySelector('.mask')
addClass($wx, 'in') addClass($wx, 'in')
addClass($wx, 'ready') addClass($wx, 'ready')
addClass($mask, 'in') addClass($mask, 'in')
} }
function hideWX() { function hideWX() {
let $wx = document.querySelector('.js-wx-box') let $wx = document.querySelector('.js-wx-box')
let $mask = document.querySelector('.mask') let $mask = document.querySelector('.mask')
removeClass($wx, 'in') removeClass($wx, 'in')
removeClass($wx, 'ready') removeClass($wx, 'ready')
removeClass($mask, 'in') removeClass($mask, 'in')
} }
function handleClick(type, opts) { function handleClick(type, opts) {
if (type === 'weibo') { if (type === 'weibo') {
generate('http://service.weibo.com/share/share.php?url=<%-sUrl%>&title=<%-sTitle%>&pic=<%-sPic%>', opts) generate('http://service.weibo.com/share/share.php?url=<%-sUrl%>&title=<%-sTitle%>&pic=<%-sPic%>', opts)
} else if (type === 'qq') { } else if (type === 'qq') {
generate('http://connect.qq.com/widget/shareqq/index.html?url=<%-sUrl%>&title=<%-sTitle%>&source=<%-sDesc%>', opts) generate('http://connect.qq.com/widget/shareqq/index.html?url=<%-sUrl%>&title=<%-sTitle%>&source=<%-sDesc%>', opts)
} else if (type === 'douban') { } else if (type === 'douban') {
generate('https://www.douban.com/share/service?image=<%-sPic%>&href=<%-sUrl%>&name=<%-sTitle%>&text=<%-sDesc%>', opts) generate('https://www.douban.com/share/service?image=<%-sPic%>&href=<%-sUrl%>&name=<%-sTitle%>&text=<%-sDesc%>', opts)
} else if (type === 'qzone') { } else if (type === 'qzone') {
generate('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=<%-sUrl%>&title=<%-sTitle%>&pics=<%-sPic%>&summary=<%-sDesc%>', opts) generate('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=<%-sUrl%>&title=<%-sTitle%>&pics=<%-sPic%>&summary=<%-sDesc%>', opts)
} else if (type === 'facebook') { } else if (type === 'facebook') {
generate('https://www.facebook.com/sharer/sharer.php?u=<%-sUrl%>', opts) generate('https://www.facebook.com/sharer/sharer.php?u=<%-sUrl%>', opts)
} else if (type === 'twitter') { } else if (type === 'twitter') {
generate('https://twitter.com/intent/tweet?text=<%-sTitle%>&url=<%-sUrl%>&via=<%-config.url%>', opts) generate('https://twitter.com/intent/tweet?text=<%-sTitle%>&url=<%-sUrl%>&via=<%-config.url%>', opts)
} else if (type === 'google') { } else if (type === 'google') {
generate('https://plus.google.com/share?url=<%-sUrl%>', opts) generate('https://plus.google.com/share?url=<%-sUrl%>', opts)
} else if (type === 'weixin') { } else if (type === 'weixin') {
showWX(); showWX();
} }
} }
let init = function() { let init = function() {
let $sns = document.querySelectorAll('.share-sns'); let $sns = document.querySelectorAll('.share-sns');
if (!$sns || $sns.length === 0) return; if (!$sns || $sns.length === 0) return;
let sUrl = window.location.href; let sUrl = window.location.href;
let sTitle = document.querySelector('title').innerHTML; let sTitle = document.querySelector('title').innerHTML;
let $img = document.querySelectorAll('.article-entry img'); let $img = document.querySelectorAll('.article-entry img');
let sPic = $img.length ? document.querySelector('.article-entry img').getAttribute('src') : ''; let sPic = $img.length ? document.querySelector('.article-entry img').getAttribute('src') : '';
if ((sPic !== '') && !/^(http:|https:)?\/\//.test(sPic)) { if ((sPic !== '') && !/^(http:|https:)?\/\//.test(sPic)) {
sPic = window.location.origin + sPic sPic = window.location.origin + sPic
}
Array.prototype.forEach.call($sns, ($em) => {
$em.onclick = (e) => {
let type = $em.getAttribute('data-type')
handleClick(type, {
sUrl: sUrl,
sPic: sPic,
sTitle: sTitle,
sDesc: sTitle
})
} }
})
$sns.forEach(($em) => { document.querySelector('.mask').onclick = hideWX
$em.onclick = (e) => { document.querySelector('.js-modal-close').onclick = hideWX
let type = $em.getAttribute('data-type')
handleClick(type, {
sUrl: sUrl,
sPic: sPic,
sTitle: sTitle,
sDesc: sTitle
})
}
})
document.querySelector('.mask').onclick = hideWX
document.querySelector('.js-modal-close').onclick = hideWX
} }
module.exports = { export default { init }
init: init
}

View File

@ -15,7 +15,7 @@ function fixzero(str) {
function setScrollZero() { function setScrollZero() {
let $sct = document.querySelectorAll('.tools-section') let $sct = document.querySelectorAll('.tools-section')
$sct.forEach((em) => { Array.prototype.forEach.call($sct, (em) => {
em.scrollTop = 0 em.scrollTop = 0
}) })
} }

View File

@ -1,89 +1,89 @@
var e = function() { const Util = (function(){
function r(e, r, n) { function r(e, r, n) {
return r || n ? String.fromCharCode(r || n) : u[e] || e return r || n ? String.fromCharCode(r || n) : u[e] || e
} }
function n(e) { function n(e) {
return p[e] return p[e]
} }
var t = /&quot;|&lt;|&gt;|&amp;|&nbsp;|&apos;|&#(\d+);|&#(\d+)/g var t = /&quot;|&lt;|&gt;|&amp;|&nbsp;|&apos;|&#(\d+);|&#(\d+)/g
, o = /['<> "&]/g , o = /['<> "&]/g
, u = { , u = {
"&quot;": '"', "&quot;": '"',
"&lt;": "<", "&lt;": "<",
"&gt;": ">", "&gt;": ">",
"&amp;": "&", "&amp;": "&",
"&nbsp;": " " "&nbsp;": " "
} }
, c = /\u00a0/g , c = /\u00a0/g
, a = /<br\s*\/?>/gi , a = /<br\s*\/?>/gi
, i = /\r?\n/g , i = /\r?\n/g
, f = /\s/g , f = /\s/g
, p = {}; , p = {};
for (var s in u) for (var s in u)
p[u[s]] = s; p[u[s]] = s;
return u["&apos;"] = "'", return u["&apos;"] = "'",
p["'"] = "&#39;", p["'"] = "&#39;",
{ {
encode: function(e) { encode: function(e) {
return e ? ("" + e).replace(o, n).replace(i, "<br/>").replace(f, "&nbsp;") : "" return e ? ("" + e).replace(o, n).replace(i, "<br/>").replace(f, "&nbsp;") : ""
}, },
decode: function(e) { decode: function(e) {
return e ? ("" + e).replace(a, "\n").replace(t, r).replace(c, " ") : "" return e ? ("" + e).replace(a, "\n").replace(t, r).replace(c, " ") : ""
}, },
encodeBase16: function(e) { encodeBase16: function(e) {
if (!e) if (!e)
return e; return e;
e += ""; e += "";
for (var r = [], n = 0, t = e.length; t > n; n++) for (var r = [], n = 0, t = e.length; t > n; n++)
r.push(e.charCodeAt(n).toString(16).toUpperCase()); r.push(e.charCodeAt(n).toString(16).toUpperCase());
return r.join("") return r.join("")
}, },
encodeBase16forJSON: function(e) { encodeBase16forJSON: function(e) {
if (!e) if (!e)
return e; return e;
e = e.replace(/[\u4E00-\u9FBF]/gi, function(e) { e = e.replace(/[\u4E00-\u9FBF]/gi, function(e) {
return escape(e).replace("%u", "\\u") return escape(e).replace("%u", "\\u")
}); });
for (var r = [], n = 0, t = e.length; t > n; n++) for (var r = [], n = 0, t = e.length; t > n; n++)
r.push(e.charCodeAt(n).toString(16).toUpperCase()); r.push(e.charCodeAt(n).toString(16).toUpperCase());
return r.join("") return r.join("")
}, },
decodeBase16: function(e) { decodeBase16: function(e) {
if (!e) if (!e)
return e; return e;
e += ""; e += "";
for (var r = [], n = 0, t = e.length; t > n; n += 2) for (var r = [], n = 0, t = e.length; t > n; n += 2)
r.push(String.fromCharCode("0x" + e.slice(n, n + 2))); r.push(String.fromCharCode("0x" + e.slice(n, n + 2)));
return r.join("") return r.join("")
}, },
encodeObject: function(r) { encodeObject: function(r) {
if (r instanceof Array) if (r instanceof Array)
for (var n = 0, t = r.length; t > n; n++) for (var n = 0, t = r.length; t > n; n++)
r[n] = e.encodeObject(r[n]); r[n] = e.encodeObject(r[n]);
else if ("object" == typeof r) else if ("object" == typeof r)
for (var o in r) for (var o in r)
r[o] = e.encodeObject(r[o]); r[o] = e.encodeObject(r[o]);
else if ("string" == typeof r) else if ("string" == typeof r)
return e.encode(r); return e.encode(r);
return r return r
}, },
loadScript: function(path) { loadScript: function(path) {
var $script = document.createElement('script') var $script = document.createElement('script')
document.getElementsByTagName('body')[0].appendChild($script) document.getElementsByTagName('body')[0].appendChild($script)
$script.setAttribute('src', path) $script.setAttribute('src', path)
}, },
addLoadEvent: function(func){ addLoadEvent: function(func){
var oldonload = window.onload; var oldonload = window.onload;
if (typeof window.onload!="function") { if (typeof window.onload !== "function") {
window.onload = func; window.onload = func;
} else { } else {
window.onload = function() { window.onload = function() {
oldonload(); oldonload();
func(); func();
}
}
} }
}
} }
}(); }
})();
module.exports = e export default Util

View File

@ -10,14 +10,12 @@ window.PhotoSwipeUI_Default = PhotoSwipeUI_Default
function init() { function init() {
let pswpElement = document.querySelectorAll('.pswp')[0]; let pswpElement = document.querySelectorAll('.pswp')[0];
let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)')) let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))
Array.prototype.forEach.call($imgArr, ($em, i) => {
$imgArr.forEach(($em, i) => {
$em.onclick = () => { $em.onclick = () => {
// slider展开状态 // slider展开状态
// todo: 这样不好,后面改成状态
if (document.querySelector('.left-col.show')) return if (document.querySelector('.left-col.show')) return
let items = [] let items = []
$imgArr.forEach(($em2, i2) => { Array.prototype.forEach.call($imgArr, ($em2, i2) => {
let img = $em2.getAttribute('data-idx', i2) let img = $em2.getAttribute('data-idx', i2)
let src = $em2.getAttribute('data-target') || $em2.getAttribute('src') let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
let title = $em2.getAttribute('alt') let title = $em2.getAttribute('alt')
@ -40,6 +38,4 @@ function init() {
}) })
} }
module.exports = { export default { init }
init: init
}