94 lines
3.9 KiB
PHP
94 lines
3.9 KiB
PHP
<?php if(!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
|
<script src="<?php $options->adminUrl('js/jquery.js?v=' . $suffixVersion); ?>"></script>
|
|
<script src="<?php $options->adminUrl('js/jquery-ui.js?v=' . $suffixVersion); ?>"></script>
|
|
<script src="<?php $options->adminUrl('js/typecho.js?v=' . $suffixVersion); ?>"></script>
|
|
<script>
|
|
(function () {
|
|
$(document).ready(function() {
|
|
// 处理消息机制
|
|
(function () {
|
|
var prefix = '<?php echo Typecho_Cookie::getPrefix(); ?>',
|
|
cookies = {
|
|
notice : $.cookie(prefix + '__typecho_notice'),
|
|
noticeType : $.cookie(prefix + '__typecho_notice_type'),
|
|
highlight : $.cookie(prefix + '__typecho_notice_highlight')
|
|
},
|
|
path = '<?php $parts = parse_url($options->siteUrl);
|
|
echo empty($parts['path']) ? '/' : $parts['path']; ?>';
|
|
|
|
if (!!cookies.notice && 'success|notice|error'.indexOf(cookies.noticeType) >= 0) {
|
|
var head = $('.typecho-head-nav'),
|
|
p = $('<div class="message popup ' + cookies.noticeType + '">'
|
|
+ '<ul><li>' + $.parseJSON(cookies.notice).join('</li><li>')
|
|
+ '</li></ul></div>'), offset = 0;
|
|
|
|
if (head.length > 0) {
|
|
p.insertAfter(head);
|
|
offset = head.outerHeight();
|
|
} else {
|
|
p.prependTo(document.body);
|
|
}
|
|
|
|
function checkScroll () {
|
|
if ($(window).scrollTop() >= offset) {
|
|
p.css({
|
|
'position' : 'fixed',
|
|
'top' : 0
|
|
});
|
|
} else {
|
|
p.css({
|
|
'position' : 'absolute',
|
|
'top' : offset
|
|
});
|
|
}
|
|
}
|
|
|
|
$(window).scroll(function () {
|
|
checkScroll();
|
|
});
|
|
|
|
checkScroll();
|
|
|
|
p.slideDown(function () {
|
|
var t = $(this), color = '#C6D880';
|
|
|
|
if (t.hasClass('error')) {
|
|
color = '#FBC2C4';
|
|
} else if (t.hasClass('notice')) {
|
|
color = '#FFD324';
|
|
}
|
|
|
|
t.effect('highlight', {color : color})
|
|
.delay(5000).slideUp(function () {
|
|
$(this).remove();
|
|
});
|
|
});
|
|
|
|
|
|
$.cookie(prefix + '__typecho_notice', null, {path : path});
|
|
$.cookie(prefix + '__typecho_notice_type', null, {path : path});
|
|
}
|
|
|
|
if (cookies.highlight) {
|
|
$('#' + cookies.highlight).effect('highlight', 1000);
|
|
$.cookie(prefix + '__typecho_notice_highlight', null, {path : path});
|
|
}
|
|
})();
|
|
|
|
if ($('.typecho-login').length == 0) {
|
|
$('a').each(function () {
|
|
var t = $(this), href = t.attr('href');
|
|
|
|
if ((href.length > 1 && href[0] == '#')
|
|
|| /^<?php echo preg_quote($options->adminUrl, '/'); ?>.*$/.exec(href)
|
|
|| /^<?php echo substr(preg_quote(Typecho_Common::url('s', $options->index), '/'), 0, -1); ?>action\/[_a-zA-Z0-9\/]+.*$/.exec(href)) {
|
|
return;
|
|
}
|
|
|
|
t.attr('target', '_blank');
|
|
});
|
|
}
|
|
});
|
|
})();
|
|
</script>
|