This commit is contained in:
fen 2013-10-17 12:31:54 +08:00
commit cbc848be88
6 changed files with 244 additions and 130 deletions

View File

@ -26,7 +26,9 @@
p.slideDown();
}
p.delay(5000).fadeOut();
p.sticky({
getWidthFrom : document.body
}).delay(5000).fadeOut();
}
})();

View File

@ -432,6 +432,7 @@ button.primary:active, button.primary.active {
text-align: center;
font-weight: bold;
display: none;
margin: 0;
-moz-border-radius: 0;
-moz-border-radius: 0;

View File

@ -1031,3 +1031,133 @@ jQuery.cookie = function (key, value, options) {
return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};
// Sticky Plugin v1.0.0 for jQuery
// =============
// Author: Anthony Garand
// Improvements by German M. Bravo (Kronuz) and Ruud Kamphuis (ruudk)
// Improvements by Leonardo C. Daronco (daronco)
// Created: 2/14/2011
// Date: 2/12/2012
// Website: http://labs.anthonygarand.com/sticky
// Description: Makes an element on the page stick on the screen as you scroll
// It will only set the 'top' and 'position' of your element, you
// might need to adjust the width in some cases.
(function($) {
var defaults = {
topSpacing: 0,
bottomSpacing: 0,
className: 'is-sticky',
wrapperClassName: 'sticky-wrapper',
center: false,
getWidthFrom: ''
},
$window = $(window),
$document = $(document),
sticked = [],
windowHeight = $window.height(),
scroller = function() {
var scrollTop = $window.scrollTop(),
documentHeight = $document.height(),
dwh = documentHeight - windowHeight,
extra = (scrollTop > dwh) ? dwh - scrollTop : 0;
for (var i = 0; i < sticked.length; i++) {
var s = sticked[i],
elementTop = s.stickyWrapper.offset().top,
etse = elementTop - s.topSpacing - extra;
if (scrollTop <= etse) {
if (s.currentTop !== null) {
s.stickyElement
.css('position', '')
.css('top', '');
s.stickyElement.parent().removeClass(s.className);
s.currentTop = null;
}
}
else {
var newTop = documentHeight - s.stickyElement.outerHeight()
- s.topSpacing - s.bottomSpacing - scrollTop - extra;
if (newTop < 0) {
newTop = newTop + s.topSpacing;
} else {
newTop = s.topSpacing;
}
if (s.currentTop != newTop) {
s.stickyElement
.css('position', 'fixed')
.css('top', newTop);
if (typeof s.getWidthFrom !== 'undefined') {
s.stickyElement.css('width', $(s.getWidthFrom).width());
}
s.stickyElement.parent().addClass(s.className);
s.currentTop = newTop;
}
}
}
},
resizer = function() {
windowHeight = $window.height();
},
methods = {
init: function(options) {
var o = $.extend(defaults, options);
return this.each(function() {
var stickyElement = $(this);
var stickyId = stickyElement.attr('id');
var wrapper = $('<div></div>')
.attr('id', stickyId + '-sticky-wrapper')
.addClass(o.wrapperClassName);
stickyElement.wrapAll(wrapper);
if (o.center) {
stickyElement.parent().css({width:stickyElement.outerWidth(),marginLeft:"auto",marginRight:"auto"});
}
if (stickyElement.css("float") == "right") {
stickyElement.css({"float":"none"}).parent().css({"float":"right"});
}
var stickyWrapper = stickyElement.parent();
// stickyWrapper.css('height', stickyElement.outerHeight());
sticked.push({
topSpacing: o.topSpacing,
bottomSpacing: o.bottomSpacing,
stickyElement: stickyElement,
currentTop: null,
stickyWrapper: stickyWrapper,
className: o.className,
getWidthFrom: o.getWidthFrom
});
});
},
update: scroller
};
// should be more efficient than using $window.scroll(scroller) and $window.resize(resizer):
if (window.addEventListener) {
window.addEventListener('scroll', scroller, false);
window.addEventListener('resize', resizer, false);
} else if (window.attachEvent) {
window.attachEvent('onscroll', scroller);
window.attachEvent('onresize', resizer);
}
$.fn.sticky = function(method) {
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method ) {
return methods.init.apply( this, arguments );
} else {
$.error('Method ' + method + ' does not exist on jQuery.sticky');
}
};
$(function() {
setTimeout(scroller, 0);
});
})(jQuery);

View File

@ -36,51 +36,53 @@ $(document).ready(function() {
// tag autocomplete 提示
var tags = $('#tags'), tagsPre = [];
var items = tags.val().split(','), result = [];
for (var i = 0; i < items.length; i ++) {
var tag = items[i];
if (tags.length > 0) {
var items = tags.val().split(','), result = [];
for (var i = 0; i < items.length; i ++) {
var tag = items[i];
if (!tag) {
continue;
if (!tag) {
continue;
}
tagsPre.push({
id : tag,
tags : tag
});
}
tagsPre.push({
id : tag,
tags : tag
tags.tokenInput(<?php
$data = array();
while ($tags->next()) {
$data[] = array(
'id' => $tags->name,
'tags' => $tags->name
);
}
echo json_encode($data);
?>, {
propertyToSearch: 'tags',
tokenValue : 'tags',
searchDelay : 0,
preventDuplicates : true,
animateDropdown : false,
hintText : '<?php _e('请输入标签名'); ?>',
noResultsText : '此标签不存在, 按回车创建',
prePopulate : tagsPre,
onResult : function (result) {
return result.slice(0, 5);
}
});
// tag autocomplete 提示宽度设置
$('#token-input-tags').focus(function() {
var t = $('.token-input-dropdown'),
offset = t.outerWidth() - t.width();
t.width($('.token-input-list').outerWidth() - offset);
});
}
tags.tokenInput(<?php
$data = array();
while ($tags->next()) {
$data[] = array(
'id' => $tags->name,
'tags' => $tags->name
);
}
echo json_encode($data);
?>, {
propertyToSearch: 'tags',
tokenValue : 'tags',
searchDelay : 0,
preventDuplicates : true,
animateDropdown : false,
hintText : '<?php _e('请输入标签名'); ?>',
noResultsText : '此标签不存在, 按回车创建',
prePopulate : tagsPre,
onResult : function (result) {
return result.slice(0, 5);
}
});
// tag autocomplete 提示宽度设置
$('#token-input-tags').focus(function() {
var t = $('.token-input-dropdown'),
offset = t.outerWidth() - t.width();
t.width($('.token-input-list').outerWidth() - offset);
});
// 缩略名自适应宽度
var slug = $('#slug'), sw = slug.width();

View File

@ -7,43 +7,57 @@ Typecho_Widget::widget('Widget_Contents_Page_Edit')->to($page);
<div class="main">
<div class="body container">
<?php include 'page-title.php'; ?>
<div class="col-group typecho-page-main typecho-post-option typecho-post-area">
<div class="col-group typecho-page-main typecho-post-area">
<form action="<?php $options->index('/action/contents-page-edit'); ?>" method="post" name="write_page">
<div class="col-9 suffix">
<div>
<label for="title" class="typecho-label"><?php _e('标题'); ?>
<?php if ($page->draft && $page->draft['cid'] != $page->cid): ?>
<?php $pageModifyDate = new Typecho_Date($page->draft['modified']); ?>
<cite><?php _e('当前正在编辑的是保存于%s的草稿, 你可以<a href="%s">删除它</a>', $pageModifyDate->word(),
<div class="col-mb-12 col-tb-9">
<?php if ($page->draft && $page->draft['cid'] != $page->cid): ?>
<?php $pageModifyDate = new Typecho_Date($page->draft['modified']); ?>
<cite class="edit-draft-notice"><?php _e('当前正在编辑的是保存于%s的草稿, 你可以<a href="%s">删除它</a>', $pageModifyDate->word(),
Typecho_Common::url('/action/contents-page-edit?do=deleteDraft&cid=' . $page->cid, $options->index)); ?></cite>
<?php endif; ?>
</label>
<p class="title"><input type="text" id="title" name="title" value="<?php echo htmlspecialchars($page->title); ?>" class="text title" /></p>
<label for="text" class="typecho-label"><?php _e('内容'); ?><cite id="auto-save-message"></cite></label>
<p><textarea style="height: <?php $options->editorSize(); ?>px" autocomplete="off" id="text" name="text"><?php echo htmlspecialchars($page->text); ?></textarea></p>
<?php Typecho_Plugin::factory('admin/write-page.php')->content($page); ?>
<p class="submit">
<span class="left">
<span class="typecho-preview-label"><input type="checkbox" name="preview" id="btn-preview" /> <label for="btn-preview"><?php _e('预览内容'); ?></label></span>
<span class="advance close" tabindex="0"><?php _e('展开高级选项'); ?></span>
<span class="attach" tabindex="0"><?php _e('展开附件'); ?></span>
</span>
<span class="right">
<input type="hidden" name="cid" value="<?php $page->cid(); ?>" />
<button type="submit" name="do" value="save" id="btn-save"><?php _e('保存草稿'); ?></button>
<button type="submit" name="do" value="publish" class="primary" id="btn-submit"><?php _e('发布页面'); ?></button>
</span>
</p>
</div>
<?php endif; ?>
<p class="title"><input type="text" id="title" name="title" value="<?php echo htmlspecialchars($page->title); ?>" placeholder="<?php _e('标题'); ?>" class="w-100 text title" /></p>
<?php $permalink = Typecho_Common::url($options->routingTable['page']['url'], $options->index);
list ($scheme, $permalink) = explode(':', $permalink, 2);
$permalink = ltrim($permalink, '/');
?>
<?php if (preg_match("/\[slug:?[_0-9a-z-:]*\]/i", $permalink)):
$input = '<input type="text" id="slug" name="slug" value="' . htmlspecialchars($page->slug) . '" class="mono" />';
?>
<p class="mono url-slug"><?php echo preg_replace("/\[slug:?[_0-9a-z-:]*\]/i", $input, $permalink); ?></p>
<?php endif; ?>
<p>
<textarea style="height: <?php $options->editorSize(); ?>px" autocomplete="off" id="text" name="text" class="w-100 mono"><?php echo htmlspecialchars($page->text); ?></textarea>
<span id="auto-save-message"></span>
</p>
<ul id="advance-panel" class="typecho-post-option col-9">
<li class="col-9">
<div class="col-12">
<label for="order" class="typecho-label"><?php _e('页面顺序'); ?></label>
<p><input type="text" id="order" name="order" value="<?php $page->order(); ?>" class="mini" /></p>
<p class="description"><?php _e('为你的自定义页面设定一个序列值以后, 能够使得它们按此值从小到大排列'); ?></p>
<br />
<label for="template" class="typecho-label"><?php _e('自定义模板'); ?></label>
<?php include 'file-upload.php'; ?>
<?php Typecho_Plugin::factory('admin/write-page.php')->content($page); ?>
<p class="submit">
<span class="right">
<input type="hidden" name="cid" value="<?php $page->cid(); ?>" />
<button type="submit" name="do" value="save" id="btn-save"><?php _e('保存草稿'); ?></button>
<button type="submit" name="do" value="publish" class="primary" id="btn-submit"><?php _e('发布页面'); ?></button>
</span>
</p>
<div id="typecho-preview-box"></div>
</div>
<div class="col-mb-12 col-tb-3">
<section class="typecho-post-option">
<label for="date" class="typecho-label"><?php _e('发布日期'); ?></label>
<p><input class="typecho-date w-100" type="text" name="date" id="date" value="<?php $page->have() ? $page->date('Y-m-d H:i') : ''; ?>" /></p>
</section>
<section class="typecho-post-option">
<label for="order" class="typecho-label"><?php _e('页面顺序'); ?></label>
<p><input type="text" id="order" name="order" value="<?php $page->order(); ?>" class="mini" /></p>
<p class="description"><?php _e('为你的自定义页面设定一个序列值以后, 能够使得它们按此值从小到大排列'); ?></p>
</section>
<section class="typecho-post-option">
<label for="template" class="typecho-label"><?php _e('自定义模板'); ?></label>
<p>
<select name="template" id="template">
<option value=""><?php _e('不选择'); ?></option>
@ -53,9 +67,11 @@ Typecho_Widget::widget('Widget_Contents_Page_Edit')->to($page);
</select>
</p>
<p class="description"><?php _e('如果你为此页面选择了一个自定义模板, 系统将按照你选择的模板文件展现它'); ?></p>
<?php Typecho_Plugin::factory('admin/write-page.php')->advanceOptionLeft($page); ?>
</div>
<div class="col-3">
</section>
<?php Typecho_Plugin::factory('admin/write-page.php')->option($page); ?>
<div id="advance-panel">
<section class="typecho-post-option allow-option">
<label class="typecho-label"><?php _e('权限控制'); ?></label>
<ul>
<li><input id="allowComment" name="allowComment" type="checkbox" value="1" <?php if($page->allow('comment')): ?>checked="true"<?php endif; ?> />
@ -64,59 +80,22 @@ Typecho_Widget::widget('Widget_Contents_Page_Edit')->to($page);
<label for="allowPing"><?php _e('允许被引用'); ?></label></li>
<li><input id="allowFeed" name="allowFeed" type="checkbox" value="1" <?php if($page->allow('feed')): ?>checked="true"<?php endif; ?> />
<label for="allowFeed"><?php _e('允许在聚合中出现'); ?></label></li>
<?php Typecho_Plugin::factory('admin/write-page.php')->advanceOptionRight($page); ?>
</ul>
</div>
</li>
</ul>
<ul id="upload-panel" class="col-9">
<li class="col-9">
<?php include 'file-upload.php'; ?>
</li>
</ul>
<div id="typecho-preview-box"></div>
</div>
<div class="col-3">
<ul class="typecho-post-option">
<li>
<label for="date" class="typecho-label"><?php _e('日期'); ?></label>
<p>
<select disabled class="typecho-date" name="month" id="month">
<option value="1" <?php if (1 == $page->date->format('n')): ?>selected="true"<?php endif; ?>><?php _e('一月'); ?></option>
<option value="2" <?php if (2 == $page->date->format('n')): ?>selected="true"<?php endif; ?>><?php _e('二月'); ?></option>
<option value="3" <?php if (3 == $page->date->format('n')): ?>selected="true"<?php endif; ?>><?php _e('三月'); ?></option>
<option value="4" <?php if (4 == $page->date->format('n')): ?>selected="true"<?php endif; ?>><?php _e('四月'); ?></option>
<option value="5" <?php if (5 == $page->date->format('n')): ?>selected="true"<?php endif; ?>><?php _e('五月'); ?></option>
<option value="6" <?php if (6 == $page->date->format('n')): ?>selected="true"<?php endif; ?>><?php _e('六月'); ?></option>
<option value="7" <?php if (7 == $page->date->format('n')): ?>selected="true"<?php endif; ?>><?php _e('七月'); ?></option>
<option value="8" <?php if (8 == $page->date->format('n')): ?>selected="true"<?php endif; ?>><?php _e('八月'); ?></option>
<option value="9" <?php if (9 == $page->date->format('n')): ?>selected="true"<?php endif; ?>><?php _e('九月'); ?></option>
<option value="10" <?php if (10 == $page->date->format('n')): ?>selected="true"<?php endif; ?>><?php _e('十月'); ?></option>
<option value="11" <?php if (11 == $page->date->format('n')): ?>selected="true"<?php endif; ?>><?php _e('十一月'); ?></option>
<option value="12" <?php if (12 == $page->date->format('n')): ?>selected="true"<?php endif; ?>><?php _e('十二月'); ?></option>
</select>
<input disabled class="typecho-date" size="4" maxlength="4" type="text" name="day" id="day" value="<?php $page->date('d'); ?>" />
,
<input disabled class="typecho-date" size="4" maxlength="4" type="text" name="year" id="year" value="<?php $page->date('Y'); ?>" />
@
<input disabled class="typecho-date" size="2" maxlength="2" type="text" name="hour" id="hour" value="<?php $page->date('H'); ?>" />
:
<input disabled class="typecho-date" size="2" maxlength="2" type="text" name="min" id="min" value="<?php $page->date('i'); ?>" />
</p>
<p class="description"><?php _e('请选择一个发布日期'); ?></p>
</li>
<li>
<label for="slug" class="typecho-label"><?php _e('缩略名'); ?></label>
<p><input type="text" id="slug" name="slug" value="<?php $page->slug(); ?>" class="mini" /></p>
<p class="description"><?php _e('为这篇日志自定义链接地址, 有利于搜索引擎收录'); ?></p>
</li>
<?php Typecho_Plugin::factory('admin/write-page.php')->option($page); ?>
</section>
<?php Typecho_Plugin::factory('admin/write-page.php')->advanceOption($page); ?>
</div>
<a href="###" id="advance-panel-btn"><?php _e('高级选项'); ?></a>
<?php if($page->have()): ?>
<?php $modified = new Typecho_Date($page->modified); ?>
<li>
<label class="typecho-label"><?php _e('本页面由 %s 创建', $page->author->screenName); ?></label>
<p class="description"><?php _e('最后修改于 %s', $modified->word()); ?></p>
</li>
<section class="typecho-post-option">
<p class="description">
<br>&mdash;<br>
<?php _e('本页面由 <a href="%s">%s</a> 创建',
Typecho_Common::url('manage-pages.php?uid=' . $page->author->uid, $options->adminUrl), $page->author->screenName); ?><br>
<?php _e('最后更新于 %s', $modified->word()); ?>
</p>
</section>
<?php endif; ?>
</ul>
</div>

View File

@ -88,6 +88,8 @@ Typecho_Widget::widget('Widget_Contents_Post_Edit')->to($post);
<p><input id="tags" name="tags" type="text" value="<?php $post->tags(',', false); ?>" class="w-100 text" /></p>
</section>
<?php Typecho_Plugin::factory('admin/write-post.php')->option($post); ?>
<div id="advance-panel">
<?php if($user->pass('editor', true)): ?>
<section class="typecho-post-option visibility-option">
@ -105,7 +107,6 @@ Typecho_Widget::widget('Widget_Contents_Post_Edit')->to($post);
<label for="trackback" class="typecho-label"><?php _e('引用通告'); ?></label>
<p><textarea id="trackback" class="w-100 mono" name="trackback" rows="3"></textarea></p>
<p class="description"><?php _e('每一行一个引用地址, 用回车隔开'); ?></p>
<?php Typecho_Plugin::factory('admin/write-post.php')->advanceOptionLeft($post); ?>
</section>
<section class="typecho-post-option allow-option">
@ -117,13 +118,12 @@ Typecho_Widget::widget('Widget_Contents_Post_Edit')->to($post);
<label for="allowPing"><?php _e('允许被引用'); ?></label></li>
<li><input id="allowFeed" name="allowFeed" type="checkbox" value="1" <?php if($post->allow('feed')): ?>checked="true"<?php endif; ?> />
<label for="allowFeed"><?php _e('允许在聚合中出现'); ?></label></li>
<?php Typecho_Plugin::factory('admin/write-post.php')->advanceOptionRight($post); ?>
</ul>
</section>
<?php Typecho_Plugin::factory('admin/write-post.php')->advanceOption($post); ?>
</div><!-- end #advance-panel -->
<a href="###" id="advance-panel-btn"><?php _e('高级选项'); ?></a>
<?php Typecho_Plugin::factory('admin/write-post.php')->option($post); ?>
<?php if($post->have()): ?>
<?php $modified = new Typecho_Date($post->modified); ?>
<section class="typecho-post-option">