Permalink
Browse files

add: settings for "open in new tab"

Closes #103
  • Loading branch information...
1 parent 36785be commit 6416f538e5ee70a84a0dbddfc44a5b6a53fdfbc8 @MOxFIVE committed Jun 25, 2016
View
@@ -175,9 +175,21 @@ friends:
aboutme: 专注于前端
#aboutme: false
-# 是否在新窗口打开链接
-# Open ALL link in a new tab
-open_in_new: false
+# Open link in a new tab | 是否在新窗口打开链接
+## `global` 0: Set separately, 1: Open all in new 2: Open all in current
+## `global` 0: 分开设置, 1: 全部在新标签打开, 2: 全部在"当前"标签打开
+open_in_new:
+ global: 0 # 0-2
+ title: false # article title in homepage 主页文章标题
+ post: false # link within post/page 正文中的链接
+ tags: false # 标签
+ categories: false # 分类
+ article_nav: false # 导航
+ archives: true # 归档
+ mini_archives: true # 迷你归档
+ menu: false # 边栏菜单
+ friends: true # 友情链接
+ socail: true # 社交图标
# Customize feed link 自定义订阅地址
rss: /atom.xml
@@ -8,5 +8,8 @@
<%- partial('mathjax') %>
<% } %>
<%- partial('scrolling-button') %>
+<%- partial('open-in-new-tab', {
+ global: theme.open_in_new.global
+ }) %>
<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>
@@ -77,7 +77,6 @@ if ( is_archive() ) {
isArchive: <%=is_archive()%>,
isTag: <%=is_tag()%>,
isCategory: <%=is_category()%>,
- open_in_new: <%=theme.open_in_new%>,
fancybox_js: "<%- theme.CDN.fancybox_js %>",
scrollreveal: "<%- theme.CDN.scrollreveal %>",
search: <%= theme.search.on %>
@@ -77,7 +77,7 @@
<nav class="header-nav">
<ul class="social">
<% for (var i in theme.subnav){ %>
- <a class="fa <%= i %>" target="_blank" href="<%- url_for(theme.subnav[i]) %>" title="<%= i %>"></a>
+ <a class="fa <%= i %>" href="<%- url_for(theme.subnav[i]) %>" title="<%= i %>"></a>
<%}%>
</ul>
</nav>
@@ -95,7 +95,7 @@
<section class="switch-part switch-part3">
<div id="js-friends">
<% for (var i in theme.friends){ %>
- <a target="_blank" class="main-nav-link switch-friends-link" href="<%- url_for(theme.friends[i]) %>"><%= i %></a>
+ <a class="main-nav-link switch-friends-link" href="<%- url_for(theme.friends[i]) %>"><%= i %></a>
<% } %>
</div>
</section>
@@ -0,0 +1,26 @@
+<script>
+ // Open in New Window
+ <% if (global === 0) { %>
+ var oOpenInNew = {
+ <% if (theme.github_widget) { %> github: ".github-widget a", <% } %>
+ <% if (theme.open_in_new.title) { %> title: "a.article-title, .article-more-link a", <% } %>
+ <% if (theme.open_in_new.post) { %> post: ".article-entry a[href], .copyright a[href]", <% } %>
+ <% if (theme.open_in_new.tags) { %> tags: ".article-tag a", <% } %>
+ <% if (theme.open_in_new.categories) { %> categories: ".article-category a, a.tag-list-link", <% } %>
+ <% if (theme.open_in_new.article_nav) { %> articleNav: "#article-nav a, #post-nav-button a", <% } %>
+ <% if (theme.open_in_new.archives) { %> archives: ".archive-article-title", <% } %>
+ <% if (theme.open_in_new.mini_archives) { %> miniArchives: "a.post-list-link", <% } %>
+ <% if (theme.open_in_new.menu) { %> menu: ".header-menu a", <% } %>
+ <% if (theme.open_in_new.friends) { %> friends: "#js-friends a", <% } %>
+ <% if (theme.open_in_new.socail) { %> socail: ".social a" <% } %>
+ }
+ for (var x in oOpenInNew) {
+ $(oOpenInNew[x]).attr("target", "_blank");
+ }
+ <% } else if (global === 1) { %>
+ $("a").attr("target", "_blank");
+ $("#scroll a, #toc a").removeAttr("target");
+ <% } else if (global === 2) { %>
+ $("a[target=_blank]").removeAttr("target");
+ <% } %>
+</script>
View
@@ -140,13 +140,6 @@ require([], function (){
require(['toc'], function(){ })
}
- // Open in New Tab
- if(!!yiliaConfig.open_in_new){
- $(".article a[href]").attr("target", "_blank")
- }
- $(".archive-article-title, .github-widget a").attr("target", "_blank");
-
-
// Random Color 边栏顶部随机颜色
var colorList = ["#6da336", "#ff945c", "#66CC66", "#99CC99", "#CC6666", "#76becc", "#c99979", "#918597", "#4d4d4d"];
var id = Math.ceil(Math.random()*(colorList.length-1));
View
@@ -87,7 +87,6 @@ define([], function(){
var miniArchives = function(){
if(yiliaConfig.isPost) {
$(".post-list").addClass("toc-article");
- $(".post-list-item a").attr("target","_blank");
$("#post-nav-button > a:nth-child(2)").click(function() {
$("#post-nav-button .fa-bars,#post-nav-button .fa-times").toggle();
$(".post-list").toggle(300);

0 comments on commit 6416f53

Please sign in to comment.