Skip to content

Commit

Permalink
fix point through the mask
Browse files Browse the repository at this point in the history
  • Loading branch information
yscoder committed Nov 25, 2016
1 parent 1dfefcd commit cece4e6
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 21 deletions.
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# hexo-theme-indigo
# https://github.com/yscoder/hexo-theme-indigo
version: 1.2.6
version: 1.2.7

#添加新菜单项遵循以下规则
# menu:
Expand Down
2 changes: 1 addition & 1 deletion layout/_partial/google-analytics.ejs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% if (theme.google_analytics){ %>
<!-- Google Analytics -->
<script type="text/javascript">
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hexo-theme-material-indigo",
"version": "1.2.6",
"version": "1.2.7",
"description": "Material Design theme for Hexo.",
"keywords": [
"hexo",
Expand Down
4 changes: 1 addition & 3 deletions scripts/plugins.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
hexo.extend.tag.register('image', function (args) {
const src = args[0]
const title = args[1]
hexo.extend.tag.register('image', ([src, title]) => {
return `<figure class="image-bubble">
<img src="${src}" alt="${title}">
<div class="image-caption">${title}</div>
Expand Down
17 changes: 17 additions & 0 deletions source/css/_partial/article.less
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,14 @@
line-height: 1.8;

.highlight,
.image-bubble,
> pre {
margin-left: -35px;
margin-right: -35px;
}

.highlight,
> pre {
padding: 20px 35px;
}

Expand Down Expand Up @@ -515,6 +520,18 @@
.has-jax {
font-size: 10px;
}
.post-content {
.highlight,
.image-bubble,
> pre {
margin-left: -16px;
margin-right: -16px;
}
.highlight,
> pre {
padding: 16px;
}
}
}

.duoshuo {
Expand Down
30 changes: 16 additions & 14 deletions source/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
forEach = Array.prototype.forEach,
even = ('ontouchstart' in w && /Mobile|Android|iOS|iPhone|iPad|iPod|Windows Phone|KFAPWI/i.test(navigator.userAgent)) ? 'touchstart' : 'click',
isWX = /micromessenger/i.test(navigator.userAgent),
noop = function() {},
offset = function(el) {
noop = function () { },
offset = function (el) {
var x = el.offsetLeft,
y = el.offsetTop;

Expand Down Expand Up @@ -56,7 +56,7 @@
gotop.classList.remove('in');
}
},
toggleMenu: function(flag) {
toggleMenu: function (flag) {
var main = $('#main');
if (flag) {
menu.classList.remove('hide');
Expand All @@ -65,7 +65,7 @@
mask.classList.add('in');
menu.classList.add('show');

if(isWX) {
if (isWX) {
var top = docEl.scrollTop;
main.classList.add('lock');
main.scrollTop = top;
Expand All @@ -77,7 +77,7 @@
} else {
menu.classList.remove('show');
mask.classList.remove('in');
if(isWX) {
if (isWX) {
var top = main.scrollTop;
main.classList.remove('lock');
docEl.scrollTop = top;
Expand Down Expand Up @@ -145,40 +145,37 @@
}
}
})(),
hideOnMask: [],
modal: function (target) {
this.$modal = $(target);
this.$off = this.$modal.querySelector('.close');

var _this = this;

function hideByBody(e) {
if (!_this.$modal.contains(e.target)) {
_this.hide();
}
}

this.show = function () {
mask.classList.add('in');
_this.$modal.classList.add('ready');
setTimeout(function () {
_this.$modal.classList.add('in');
d.addEventListener(even, hideByBody);
}, 0)
}

this.onHide = noop;

this.hide = function () {
_this.onHide();
mask.classList.remove('in');
_this.$modal.classList.remove('in');
setTimeout(function () {
_this.$modal.classList.remove('ready');
d.removeEventListener(even, hideByBody);
}, 300)
}

this.toggle = function () {
return _this.$modal.classList.contains('in') ? _this.hide() : _this.show();
}

Blog.hideOnMask.push(this.hide);
this.$off && this.$off.addEventListener(even, this.hide);
},
share: function () {
Expand All @@ -201,6 +198,7 @@
}

var wxModal = new this.modal('#wxShare');
wxModal.onHide = shareModal.hide;

forEach.call($$('.wxFab'), function (el) {
el.addEventListener(even, wxModal.toggle)
Expand Down Expand Up @@ -305,8 +303,12 @@
menu.classList.add('hide');
}, false);

mask.addEventListener(even, function () {
mask.addEventListener(even, function (e) {
Blog.toggleMenu();
Blog.hideOnMask.forEach(function (hide) {
hide()
});
e.preventDefault();
}, false);

d.addEventListener('scroll', function () {
Expand Down
2 changes: 1 addition & 1 deletion source/js/main.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 comments on commit cece4e6

@Wegome
Copy link

@Wegome Wegome commented on cece4e6 Nov 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yscoder
$ hexo clean && hexo g
ERROR Script load failed: themes\indigocard\scripts\plugins.js
SyntaxError: Unexpected token [

是什么原因呢?

@yscoder
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Wegome 你的 Node 版本多少?可能是对 ES6 支持不够。

@Wegome
Copy link

@Wegome Wegome commented on cece4e6 Nov 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4.6.0

@Wegome
Copy link

@Wegome Wegome commented on cece4e6 Nov 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请问下什么版本支持比较好?

@yscoder
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Wegome 升级 6.x 吧,而且 NPM 也会升级到 3.x,模块由递归依赖改为平铺依赖。

@Wegome
Copy link

@Wegome Wegome commented on cece4e6 Nov 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yscoder 谢谢。幸苦了。

Please sign in to comment.