Skip to content

Commit

Permalink
Fix some problems in pjax mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
CY committed May 18, 2020
1 parent 6923b97 commit 1b02b9d
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 117 deletions.
41 changes: 12 additions & 29 deletions component/comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
}

// $commentLevelClass = $comments->levels > 0 ? ' comment-child' : ' comment-parent';
?>
?>

<li id="li-<?php $comments->theId(); ?>" class="comment-body
<?php
if ($comments->levels > 0) {
echo ' comment-child';
$comments->levelsAlt(' comment-level-odd', ' comment-level-even');
} else {
echo ' comment-parent';
}
$comments->alt(' comment-odd', ' comment-even');
echo $commentClass;
?>">
if ($comments->levels > 0) {
echo ' comment-child';
$comments->levelsAlt(' comment-level-odd', ' comment-level-even');
} else {
echo ' comment-parent';
}
$comments->alt(' comment-odd', ' comment-even');
echo $commentClass;
?>">
<div id="<?php $comments->theId(); ?>">
<div class="comment-inner">
<div class="comment-author">
Expand Down Expand Up @@ -64,7 +64,7 @@
<?php if ($this->allow('comment')) : ?>
<h3 class="comment-title">
<?php i18n('评论');
$comments->cancelReply(_i18n('/ 取消评论')); ?>
$comments->cancelReply(_i18n('/ 取消评论')); ?>
</h3>
<form method="post" action="<?php $this->commentUrl() ?>" id="comment-form" role="form">
<?php if ($this->user->hasLogin()) : ?>
Expand All @@ -86,21 +86,4 @@
<?php $comments->pageNav('<i class="iconfont icon-prev-m"></i>', '<i class="iconfont icon-next-m"></i>'); ?>
<?php endif; ?>

</div>

<!-- OwO emoji -->
<?php if (!empty($this->options->feature) && in_array('commentEmoji', $this->options->feature) && $this->allow('comment')) : ?>
<script src="<?php CDNUrl('js/lib/OwO/OwO.min.js'); ?>"></script>

<script>
new OwO({
logo: 'OωO',
container: document.getElementsByClassName('OwO')[0],
target: document.getElementsByClassName('OwO-textarea')[0],
api: '<?php CDNUrl('js/lib/OwO/OwO.json '); ?>',
position: 'down',
width: '100%',
maxHeight: '250px'
})
</script>
<?php endif; ?>
</div>
29 changes: 17 additions & 12 deletions component/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,7 @@
<img src="<?php $this->options->backGroundImage() ?>" alt="This is just a placeholder img.">
</div>

<!-- <canvas id="live2d" class="live2d" width="140" height="250"></canvas> -->

<?php if (!empty($this->options->feature) && in_array('pjax', $this->options->feature)) : ?>
<!-- <script src="<?php CDNUrl('util/pjax.mini.js'); ?>"></script>

<script>
new miniPjax({
target: 'a',
body: '#root',
container: ['.content-wrap', '#sidebar']
})
</script> -->
<script src="<?php CDNUrl('js/lib/instantclick.min.js') ?>" data-no-instant></script>
<script data-no-instant>
InstantClick.init(50);
Expand All @@ -58,7 +47,6 @@


<!-- Lazy load images -->

<?php if (!empty($this->options->feature) && in_array('lazyImg', $this->options->feature)) : ?>
<script src="<?php CDNUrl('util/lazyload.min.js'); ?>"></script>
<?php endif; ?>
Expand All @@ -81,6 +69,23 @@
<script src="<?php CDNUrl('./js/lib/prism/prism.js'); ?>"></script>
<?php endif; ?>

<!-- OwO emoji -->
<?php if (!empty($this->options->feature) && in_array('commentEmoji', $this->options->feature) && $this->allow('comment')) : ?>
<script src="<?php CDNUrl('js/lib/OwO/OwO.min.js'); ?>"></script>

<script>
new OwO({
logo: 'OωO',
container: document.getElementsByClassName('OwO')[0],
target: document.getElementsByClassName('OwO-textarea')[0],
api: '<?php CDNUrl('js/lib/OwO/OwO.json '); ?>',
position: 'down',
width: '100%',
maxHeight: '250px'
})
</script>
<?php endif; ?>

<script>
// Scroll to article area
<?php if (!empty($this->options->StyleSettings) && in_array('Banner', $this->options->StyleSettings) && $this->is('post')) : ?>
Expand Down
8 changes: 8 additions & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
[U] Update Config.
[Doc] Update DOC.

## 2020/5/18 (V1.1.4)

- pjax
- owo
- ribbons

**version tag in candy branch**

## 2019/11/23

[F] #27
Expand Down
3 changes: 2 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

/**
* Sagiri - Lovely theme for Typecho.
*
* @package Sagiri
* @author shiyi
* @version 1.1.7
* @version 1.1.9
* @link https://github.com/shiyiya/typecho-theme-sagiri
*/

Expand Down
129 changes: 70 additions & 59 deletions js/global/ribbons.js
Original file line number Diff line number Diff line change
@@ -1,72 +1,83 @@
var __ribbonsrc__ = {
z: -1,
alpha: 0.9,
size: 120
}

var c = document.createElement('canvas'),
c2d = c.getContext('2d'),
pr = window.devicePixelRatio || 1,
width = window.innerWidth,
height = window.innerHeight,
s = __ribbonsrc__.size,
q,
m = Math,
r = 0,
pi = m.PI * 2,
cos = m.cos,
randoMath = m.random
function wrap(params) {
var __ribbonsrc__ = {
z: -1,
alpha: 0.9,
size: 120
}

c.width = width * pr
c.height = height * pr
c.style.cssText =
'opacity: ' +
__ribbonsrc__.alpha +
';position:fixed;top:0;left:0;z-index: ' +
__ribbonsrc__.z +
';width:100%;height:100%;pointer-events:none;'
var c = document.createElement('canvas'),
c2d = c.getContext('2d'),
pr = window.devicePixelRatio || 1,
width = window.innerWidth,
height = window.innerHeight,
s = __ribbonsrc__.size,
q,
m = Math,
r = 0,
pi = m.PI * 2,
cos = m.cos,
randoMath = m.random

c2d.scale(pr, pr)
c2d.globalAlpha = __ribbonsrc__.alpha
c.className = 'sagiri-ribbons'
c.width = width * pr
c.height = height * pr
c.style.cssText =
'opacity: ' +
__ribbonsrc__.alpha +
';position:fixed;top:0;left:0;z-index: ' +
__ribbonsrc__.z +
';width:100%;height:100%;pointer-events:none;'

document.getElementsByTagName('body')[0].appendChild(c)
c2d.scale(pr, pr)
c2d.globalAlpha = __ribbonsrc__.alpha

function redraw() {
c2d.clearRect(0, 0, width, height)
q = [{ x: 0, y: height * 0.7 + s }, { x: 0, y: height * 0.7 - s }]
while (q[1].x < width + s) draw(q[0], q[1])
}
document.getElementsByTagName('body')[0].appendChild(c)

function draw(i, j) {
c2d.beginPath()
c2d.moveTo(i.x, i.y)
c2d.lineTo(j.x, j.y)
var k = j.x + (randoMath() * 2 - 0.25) * s,
n = line(j.y)
c2d.lineTo(k, n)
c2d.closePath()
r -= pi / -50
c2d.fillStyle =
'#' +
(
((cos(r) * 127 + 128) << 16) |
((cos(r + pi / 3) * 127 + 128) << 8) |
(cos(r + (pi / 3) * 2) * 127 + 128)
).toString(16)
c2d.fill()
q[0] = q[1]
q[1] = { x: k, y: n }
}

function line(p) {
var t = p + (randoMath() * 2 - 1.1) * s
return t > height || t < 0 ? line(p) : t
}

function draw(i, j) {
c2d.beginPath()
c2d.moveTo(i.x, i.y)
c2d.lineTo(j.x, j.y)
var k = j.x + (randoMath() * 2 - 0.25) * s,
n = line(j.y)
c2d.lineTo(k, n)
c2d.closePath()
r -= pi / -50
c2d.fillStyle =
'#' +
(
((cos(r) * 127 + 128) << 16) |
((cos(r + pi / 3) * 127 + 128) << 8) |
(cos(r + (pi / 3) * 2) * 127 + 128)
).toString(16)
c2d.fill()
q[0] = q[1]
q[1] = { x: k, y: n }
}

function line(p) {
var t = p + (randoMath() * 2 - 1.1) * s
return t > height || t < 0 ? line(p) : t
return {
redraw() {
const _el = document.getElementsByClassName('sagiri-ribbons')[0];
if (_el) {
c2d = _el.getContext('2d')
}
c2d.clearRect(0, 0, width, height)
q = [{ x: 0, y: height * 0.7 + s }, { x: 0, y: height * 0.7 - s }]
while (q[1].x < width + s) draw(q[0], q[1])
}
}
}

function ribbons() {
document.onclick = redraw
document.ontouchstart = redraw
redraw()
document.onclick = wrap.redraw
document.ontouchstart = wrap.redraw
wrap().redraw()
}

export default ribbons
27 changes: 13 additions & 14 deletions js/global/sagiri.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,21 @@ class Sagiri {

this.F = F // theme Feature GLOBAL F

// copy-right
//DO NOT DELETE !
console.info(
`%c Sagiri ${this.version} %c https://github.com/shiyiya/typecho-theme-sagiri `,
'background: #ed143d7d; padding:5px 0; color: #fff;',
'background: #40b3ec; padding:5px 5px 5px 0; color: #000;'
)

document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function () {
// copy-right
//DO NOT DELETE !
console.info(
`%c Sagiri ${this.version} %c https://github.com/shiyiya/typecho-theme-sagiri `,
'background: #ed143d7d; padding:5px 0; color: #fff;',
'background: #40b3ec; padding:5px 5px 5px 0; color: #000;'
)
console.info(
`%cTime used: ${Math.round(performance.now() * 100) / 100} ms | ${
performance.memory
? `Memory used ${Math.round(
(performance.memory.usedJSHeapSize / 1024) * 100
) / 100} K`
: ''
performance.memory
? `Memory used ${Math.round(
(performance.memory.usedJSHeapSize / 1024) * 100
) / 100} K`
: ''
}`,
'background: #40b3ec; color: #fff; padding:5px ;'
)
Expand Down
2 changes: 1 addition & 1 deletion js/sagiri.min.js

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typecho-theme-sagiri",
"version": "1.1.8",
"version": "1.1.9",
"description": "Lovely theme for Typecho.",
"main": "index.js",
"directories": {
Expand Down

0 comments on commit 1b02b9d

Please sign in to comment.