精简js
This commit is contained in:
parent
1a915a94cb
commit
f7b8721ec6
@ -63,7 +63,7 @@ deg是旋转的角度 , 正数表示顺时针旋转 , 负数表示逆时针旋
|
|||||||
同名函数接受2个参数 , 分别表示在X轴和Y轴上的移动距离 , 正数代表向该轴的正方向移动 , 负数代表向负方向移动
|
同名函数接受2个参数 , 分别表示在X轴和Y轴上的移动距离 , 正数代表向该轴的正方向移动 , 负数代表向负方向移动
|
||||||
```css
|
```css
|
||||||
.translate_div {
|
.translate_div {
|
||||||
tranform : translate(100px, 20px);
|
transform : translate(100px, 20px);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||

|

|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
window.yiliaConfig = {
|
window.themeConfig = {
|
||||||
isHome: <%=is_home()%>, // 是否为首页
|
isHome: <%=is_home()%>, // 是否为首页
|
||||||
isPost: <%=is_post()%>, // 是否为文章全文页面
|
isPost: <%=is_post()%>, // 是否为文章全文页面
|
||||||
isArchive: <%=is_archive()%>, // 是否为归档页面
|
isArchive: <%=is_archive()%>, // 是否为归档页面
|
||||||
@ -7,7 +7,8 @@ window.yiliaConfig = {
|
|||||||
isCategory: <%=is_category()%>, // 是否为分类页面
|
isCategory: <%=is_category()%>, // 是否为分类页面
|
||||||
pageid: <%-page.pageid ? `"${page.pageid}"` : 'undefined'%>, // 页面标识, 用于个性化页面开发
|
pageid: <%-page.pageid ? `"${page.pageid}"` : 'undefined'%>, // 页面标识, 用于个性化页面开发
|
||||||
toc_hide_index: <%=theme.toc_hide_index%>, // 目录序号
|
toc_hide_index: <%=theme.toc_hide_index%>, // 目录序号
|
||||||
root: "<%=config.root%>" // 资源根路径
|
root: "<%=config.root%>", // 资源根路径
|
||||||
|
pictureCdn: "<%=config.picture_cdn%>" // 图片存储仓库地址
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<%- partial('script') %>
|
<%- partial('script') %>
|
||||||
|
|||||||
6
themes/yilia/package-lock.json
generated
6
themes/yilia/package-lock.json
generated
@ -2839,12 +2839,6 @@
|
|||||||
"entities": "^1.1.1"
|
"entities": "^1.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dom101": {
|
|
||||||
"version": "1.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/dom101/-/dom101-1.3.0.tgz",
|
|
||||||
"integrity": "sha1-1/yjBoYkAXG2zxfC6FXWoy+iyck=",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"domain-browser": {
|
"domain-browser": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz",
|
||||||
|
|||||||
@ -21,7 +21,6 @@
|
|||||||
"autoprefixer": "^6.5.1",
|
"autoprefixer": "^6.5.1",
|
||||||
"clean-webpack-plugin": "^0.1.15",
|
"clean-webpack-plugin": "^0.1.15",
|
||||||
"css-loader": "^2.1.1",
|
"css-loader": "^2.1.1",
|
||||||
"dom101": "^1.3.0",
|
|
||||||
"file-loader": "^3.0.1",
|
"file-loader": "^3.0.1",
|
||||||
"html-webpack-plugin": "^3.2.0",
|
"html-webpack-plugin": "^3.2.0",
|
||||||
"mini-css-extract-plugin": "^0.6.0",
|
"mini-css-extract-plugin": "^0.6.0",
|
||||||
|
|||||||
@ -48,8 +48,8 @@
|
|||||||
|
|
||||||
.article-entry{
|
.article-entry{
|
||||||
line-height: 1.8em;
|
line-height: 1.8em;
|
||||||
padding-right: 7.6923%;
|
padding-right: $articlePadding;
|
||||||
padding-left: 7.6923%;
|
padding-left: $articlePadding;
|
||||||
.post-count { // 字数统计
|
.post-count { // 字数统计
|
||||||
color: rgb(185, 185, 185);
|
color: rgb(185, 185, 185);
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
@ -61,7 +61,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
img {
|
img {
|
||||||
transition: transform 0.2s ease-out,box-shadow 0.5s ease;
|
transition: transform 0.3s ease-out,box-shadow 0.4s ease;
|
||||||
cursor: zoom-in;
|
cursor: zoom-in;
|
||||||
&:hover {
|
&:hover {
|
||||||
transform: scale(1.05,1.05);
|
transform: scale(1.05,1.05);
|
||||||
|
|||||||
@ -86,7 +86,7 @@
|
|||||||
.article-header{
|
.article-header{
|
||||||
border-left: 5px solid #4d4d4d;
|
border-left: 5px solid #4d4d4d;
|
||||||
padding: 30px 0px 15px 25px;
|
padding: 30px 0px 15px 25px;
|
||||||
padding-left: 7.6923%;
|
padding-left: $articlePadding;
|
||||||
}
|
}
|
||||||
|
|
||||||
.article-meta{
|
.article-meta{
|
||||||
|
|||||||
@ -317,26 +317,11 @@
|
|||||||
from, 60%, 75%, 90%, to {
|
from, 60%, 75%, 90%, to {
|
||||||
animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
|
animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
|
||||||
}
|
}
|
||||||
|
0% {transform: translate3d(0, 0, 0);}
|
||||||
0% {
|
60% {transform: translate3d(325px, 0, 0);}
|
||||||
transform: translate3d(0, 0, 0);
|
75% {transform: translate3d(290px, 0, 0);}
|
||||||
}
|
90% {transform: translate3d(305px, 0, 0);}
|
||||||
|
to {transform: translate3d(300px, 0, 0);}
|
||||||
60% {
|
|
||||||
transform: translate3d(325px, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
75% {
|
|
||||||
transform: translate3d(290px, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
90% {
|
|
||||||
transform: translate3d(305px, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
to {
|
|
||||||
transform: translate3d(300px, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%anmSmallLeftIn {
|
%anmSmallLeftIn {
|
||||||
@ -349,26 +334,11 @@
|
|||||||
from, 60%, 75%, 90%, to {
|
from, 60%, 75%, 90%, to {
|
||||||
animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
|
animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
|
||||||
}
|
}
|
||||||
|
0% {transform: translate3d(333px, 0, 0);}
|
||||||
0% {
|
60% {transform: translate3d(-25px, 0, 0);}
|
||||||
transform: translate3d(333px, 0, 0);
|
75% {transform: translate3d(10px, 0, 0);}
|
||||||
}
|
90% {transform: translate3d(-5px, 0, 0);}
|
||||||
|
to {transform: translate3d(0, 0, 0);}
|
||||||
60% {
|
|
||||||
transform: translate3d(-25px, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
75% {
|
|
||||||
transform: translate3d(10px, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
90% {
|
|
||||||
transform: translate3d(-5px, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
to {
|
|
||||||
transform: translate3d(0, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%anmSmallLeftOut {
|
%anmSmallLeftOut {
|
||||||
|
|||||||
@ -73,8 +73,7 @@ progress {
|
|||||||
|
|
||||||
// Address `[hidden]` styling not present in IE 8/9/10.
|
// Address `[hidden]` styling not present in IE 8/9/10.
|
||||||
// Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22.
|
// Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22.
|
||||||
[hidden],
|
[hidden],template {
|
||||||
template {
|
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,8 +102,7 @@ abbr[title] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Address style set to `bolder` in Firefox 4+, Safari, and Chrome.
|
// Address style set to `bolder` in Firefox 4+, Safari, and Chrome.
|
||||||
b,
|
b,strong {
|
||||||
strong {
|
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,8 +123,7 @@ small {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prevent `sub` and `sup` affecting `line-height` in all browsers.
|
// Prevent `sub` and `sup` affecting `line-height` in all browsers.
|
||||||
sub,
|
sub,sup {
|
||||||
sup {
|
|
||||||
font-size: 75%;
|
font-size: 75%;
|
||||||
line-height: 0;
|
line-height: 0;
|
||||||
position: relative;
|
position: relative;
|
||||||
@ -211,8 +208,7 @@ select { // 2
|
|||||||
// All other form control elements do not inherit `text-transform` values.
|
// All other form control elements do not inherit `text-transform` values.
|
||||||
// Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
|
// Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
|
||||||
// Correct `select` style inheritance in Firefox.
|
// Correct `select` style inheritance in Firefox.
|
||||||
button,
|
button,select {
|
||||||
select {
|
|
||||||
text-transform: none;
|
text-transform: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,8 +314,7 @@ button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Android 下 input focus 消除高亮外框
|
// Android 下 input focus 消除高亮外框
|
||||||
textarea,
|
textarea,input {
|
||||||
input {
|
|
||||||
-webkit-user-modify: read-write-plaintext-only;
|
-webkit-user-modify: read-write-plaintext-only;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,8 +357,7 @@ table {
|
|||||||
border-spacing: 0;
|
border-spacing: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
td,
|
td,th {
|
||||||
th {
|
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,21 +9,13 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: #88acdb;
|
background: #88acdb;
|
||||||
-webkit-transition: all 0.2s ease-in;
|
|
||||||
transition: all 0.2s ease-in;
|
transition: all 0.2s ease-in;
|
||||||
display: -webkit-box;
|
|
||||||
-webkit-box-orient: horizontal;
|
|
||||||
-webkit-box-pack: center;
|
|
||||||
-webkit-box-align: center;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.header-author {
|
.header-author {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin: 0.67em 0;
|
margin: 0.67em 0;
|
||||||
font-size: 30px;
|
font-size: 30px;
|
||||||
-webkit-transition: 0.3s;
|
|
||||||
-moz-transition: 0.3s;
|
|
||||||
-ms-transition: 0.3s;
|
|
||||||
transition: 0.3s;
|
transition: 0.3s;
|
||||||
}
|
}
|
||||||
.header-subtitle {
|
.header-subtitle {
|
||||||
|
|||||||
@ -44,13 +44,9 @@ html, body, #container {
|
|||||||
padding: 5px 20px;
|
padding: 5px 20px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&.show {
|
&.show .header-menu.tools-nav{
|
||||||
.header-menu{
|
|
||||||
&.tools-nav {
|
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#container .header-author.fixed {
|
#container .header-author.fixed {
|
||||||
@ -159,7 +155,7 @@ html, body, #container {
|
|||||||
width: auto;
|
width: auto;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
margin-top: -5px;
|
margin-top: -5px;
|
||||||
position: ralative;
|
position: relative;
|
||||||
.article-date{
|
.article-date{
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
@ -257,9 +253,9 @@ html, body, #container {
|
|||||||
padding: 10px;
|
padding: 10px;
|
||||||
.archive-year-wrap{
|
.archive-year-wrap{
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 0 0 0 0;
|
padding: 0;
|
||||||
a{
|
a{
|
||||||
padding: 0 0 0 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.article-meta{
|
.article-meta{
|
||||||
|
|||||||
@ -103,7 +103,7 @@
|
|||||||
|
|
||||||
.archive-article-date {
|
.archive-article-date {
|
||||||
color: $color9;
|
color: $color9;
|
||||||
margin-right: 7.6923%;
|
margin-right: $articlePadding;
|
||||||
float: right;
|
float: right;
|
||||||
transition: color 0.3s;
|
transition: color 0.3s;
|
||||||
&:hover {
|
&:hover {
|
||||||
|
|||||||
@ -9,7 +9,7 @@ function init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 目录序号
|
// 目录序号
|
||||||
if (yiliaConfig && yiliaConfig.toc_hide_index) {
|
if (window.themeConfig && window.themeConfig.toc_hide_index) {
|
||||||
let $a = document.querySelectorAll('.toc-number')
|
let $a = document.querySelectorAll('.toc-number')
|
||||||
Array.prototype.forEach.call($a, function($em){
|
Array.prototype.forEach.call($a, function($em){
|
||||||
$em.style.display = 'none'
|
$em.style.display = 'none'
|
||||||
|
|||||||
@ -15,12 +15,12 @@ Util.addLoadEvent(function() {
|
|||||||
Aside.init()
|
Aside.init()
|
||||||
})
|
})
|
||||||
const commentConfig = require("../config/comment.json")
|
const commentConfig = require("../config/comment.json")
|
||||||
if(window.yiliaConfig.isPost && commentConfig.valine.enable) {
|
if(window.themeConfig.isPost && commentConfig.valine.enable) {
|
||||||
// 文章详情页面, 并且启用了评论, 则加载评论相关代码
|
// 文章详情页面, 并且启用了评论, 则加载评论相关代码
|
||||||
import(/* webpackChunkName: "comment" */ './comment')
|
import(/* webpackChunkName: "comment" */ './comment')
|
||||||
}
|
}
|
||||||
|
|
||||||
if(window.yiliaConfig.pageid === 'PhotoWall') {
|
if(window.themeConfig.pageid === 'PhotoWall') {
|
||||||
// 自定义的照片墙页面
|
// 自定义的照片墙页面
|
||||||
import(/* webpackChunkName: "photo-wall" */ './photo-wall')
|
import(/* webpackChunkName: "photo-wall" */ './photo-wall')
|
||||||
}
|
}
|
||||||
@ -1,6 +1,3 @@
|
|||||||
import addClass from 'dom101/add-class'
|
|
||||||
import removeClass from 'dom101/remove-class'
|
|
||||||
import after from 'dom101/after'
|
|
||||||
// 浏览器判断
|
// 浏览器判断
|
||||||
import Browser from './browser'
|
import Browser from './browser'
|
||||||
// fix hexo 不支持的配置
|
// fix hexo 不支持的配置
|
||||||
@ -14,11 +11,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){
|
Array.prototype.forEach.call(tabs, function(tab, i){
|
||||||
if (isPathMatch(path, $tab.getAttribute('href'))) {
|
if (isPathMatch(path, tab.getAttribute('href'))) {
|
||||||
addClass($tab, 'active')
|
tab.classList.add('active')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -50,7 +47,12 @@ function scrollStop($dom, top, limit, zIndex, diff) {
|
|||||||
let $newDom = $dom.$newDom
|
let $newDom = $dom.$newDom
|
||||||
if (!$newDom) {
|
if (!$newDom) {
|
||||||
$newDom = $dom.cloneNode(true)
|
$newDom = $dom.cloneNode(true)
|
||||||
after($dom, $newDom)
|
let parentNode = $dom.parentNode
|
||||||
|
if(parentNode.lastChild == $dom){ // 将新生成的节点插入到当前节点之后
|
||||||
|
parentNode.appendChild($newDom)
|
||||||
|
}else{
|
||||||
|
parentNode.insertBefore($newDom, $dom.nextSibling)
|
||||||
|
}
|
||||||
$dom.$newDom = $newDom
|
$dom.$newDom = $newDom
|
||||||
$newDom.style.position = 'fixed'
|
$newDom.style.position = 'fixed'
|
||||||
$newDom.style.top = (limit || nowTop) + 'px'
|
$newDom.style.top = (limit || nowTop) + 'px'
|
||||||
@ -88,14 +90,12 @@ function bindScroll() {
|
|||||||
handleScroll()
|
handleScroll()
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
(function () {
|
||||||
if (Browser.versions.mobile && window.screen.width < 800) {
|
if (Browser.versions.mobile && window.screen.width < 800) {
|
||||||
tabActive()
|
tabActive()
|
||||||
bindScroll()
|
bindScroll()
|
||||||
}
|
}
|
||||||
}
|
})()
|
||||||
|
|
||||||
init();
|
|
||||||
|
|
||||||
Util.addLoadEvent(function() {
|
Util.addLoadEvent(function() {
|
||||||
Fix.init()
|
Fix.init()
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
import addClass from 'dom101/add-class'
|
|
||||||
import removeClass from 'dom101/remove-class'
|
|
||||||
import QRious from 'qrious'
|
import QRious from 'qrious'
|
||||||
|
|
||||||
function generate(url, opts) {
|
function generate(url, opts) {
|
||||||
@ -13,26 +11,24 @@ function generate(url, opts) {
|
|||||||
|
|
||||||
var qrcodeInit = false
|
var qrcodeInit = false
|
||||||
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')
|
||||||
if(!qrcodeInit) {
|
if(!qrcodeInit) {
|
||||||
new QRious({
|
new QRious({
|
||||||
element: document.querySelector('.qrcode-canvas'),
|
element: document.querySelector('.qrcode-canvas'),
|
||||||
value: location.href
|
value: location.href
|
||||||
});
|
})
|
||||||
qrcodeInit = true
|
qrcodeInit = true
|
||||||
}
|
}
|
||||||
addClass($wx, 'in')
|
wx.classList.add('in', 'ready')
|
||||||
addClass($wx, 'ready')
|
mask.classList.add('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')
|
wx.classList.remove('in', 'ready')
|
||||||
removeClass($wx, 'ready')
|
mask.classList.remove('in')
|
||||||
removeClass($mask, 'in')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleClick(type, opts) {
|
function handleClick(type, opts) {
|
||||||
|
|||||||
@ -86,7 +86,7 @@ new Vue({
|
|||||||
},
|
},
|
||||||
filters: {
|
filters: {
|
||||||
urlformat: (str) => {
|
urlformat: (str) => {
|
||||||
return (window.yiliaConfig && window.yiliaConfig.root) ? window.yiliaConfig.root + str : '/' + str;
|
return (window.themeConfig && window.themeConfig.root) ? window.themeConfig.root + str : '/' + str;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@ -101,7 +101,7 @@ new Vue({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
axios.get(window.yiliaConfig.root + 'content.json?t=' + (+ new Date()))
|
axios.get(window.themeConfig.root + 'content.json?t=' + (+ new Date()))
|
||||||
.then((res)=>{
|
.then((res)=>{
|
||||||
this.items = res.data
|
this.items = res.data
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
|
|||||||
@ -36,6 +36,6 @@ function init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// export default { init }
|
// export default { init }
|
||||||
if(!window.yiliaConfig.pageid) { // 非个性化页面的普通文章
|
if(!window.themeConfig.pageid) { // 非个性化页面的普通文章
|
||||||
Util.addLoadEvent(init)
|
Util.addLoadEvent(init)
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user