This commit is contained in:
joyqi 2013-10-15 14:10:03 +08:00
parent 8018b2db6b
commit 62d1b08264
6 changed files with 56 additions and 29 deletions

View File

@ -272,6 +272,7 @@ $.TokenList = function (input, url_or_data, settings) {
hidden_input.change();
return false;
}
break;
case KEY.ESCAPE:
@ -489,6 +490,15 @@ $.TokenList = function (input, url_or_data, settings) {
function add_token (item) {
var callback = settings.onAdd;
// fix null bug
if (!item) {
item = {
id : input_box.val()
};
item[settings.propertyToSearch] = input_box.val();
}
// See if the token already exists and select it if we don't want duplicates
if(token_count > 0 && settings.preventDuplicates) {
var found_existing_token = null;

View File

@ -44,22 +44,18 @@ $stat = Typecho_Widget::widget('Widget_Stat');
<form method="post" name="manage_posts" class="operate-form">
<table class="typecho-list-table">
<colgroup>
<col width="20"/>
<col width="3%"/>
<col width="5%"/>
<col width="35%"/>
<col width=""/>
<col width="20"/>
<col width="47%"/>
<col width="10%"/>
<col width="20%"/>
<col width="15%"/>
<col width="18%"/>
</colgroup>
<thead>
<tr>
<th> </th>
<th> </th>
<th><?php _e('标题'); ?></th>
<th> </th>
<th> </th>
<th><?php _e('作者'); ?></th>
<th><?php _e('分类'); ?></th>
<th><?php _e('日期'); ?></th>
@ -72,16 +68,21 @@ $stat = Typecho_Widget::widget('Widget_Stat');
<tr id="<?php $posts->theId(); ?>">
<td><input type="checkbox" value="<?php $posts->cid(); ?>" name="cid[]"/></td>
<td><a href="<?php $options->adminUrl('manage-comments.php?cid=' . $posts->cid); ?>" class="balloon-button size-<?php echo Typecho_Common::splitByCount($posts->commentsNum, 1, 10, 20, 50, 100); ?>"><?php $posts->commentsNum(); ?></a></td>
<td<?php if ('draft' != $posts->status && 'waiting' != $posts->status && 'private' != $posts->status && !$posts->password): ?> colspan="2"<?php endif; ?>>
<a href="<?php $options->adminUrl('write-post.php?cid=' . $posts->cid); ?>"><?php $posts->title(); ?></a>
<?php if ('draft' == $posts->status || 'waiting' == $posts->status || 'private' == $posts->status || $posts->password): ?>
</td>
<td class="right">
<span><?php 'draft' == $posts->status ? _e('草稿') : ('waiting' == $posts->status ? _e('待审核') : ('private' == $posts->status ? _e('私密') : _e(''))); ?> <?php $posts->password ? _e('密码') : _e(''); ?></span>
<?php endif; ?></td>
<td>
<?php if ('publish' == $posts->status): ?>
<a class="right hidden-by-mouse" href="<?php $posts->permalink(); ?>"><img src="<?php $options->adminUrl('images/link.png'); ?>" title="<?php _e('浏览 %s', htmlspecialchars($posts->title)); ?>" width="16" height="16" alt="view" /></a>
<a href="<?php $options->adminUrl('write-post.php?cid=' . $posts->cid); ?>"><?php $posts->title(); ?></a>
<?php
if ($posts->hasSaved() || 'post_draft' == $posts->type) {
echo '<em>(' . _t('草稿') . ')</em>';
} else if ('waiting' == $posts->status) {
echo '<em>(' . _t('待审核') . ')</em>';
} else if ('private' == $posts->status) {
echo '<em>(' . _t('私密') . ')</em>';
} else if ($posts->password) {
echo '<em>(' . _t('密码保护') . ')</em>';
}
?>
<?php if ('#' != $posts->permalink): ?>
<a class="right" href="<?php $posts->permalink(); ?>"><img src="<?php $options->adminUrl('images/link.png'); ?>" title="<?php _e('浏览 %s', htmlspecialchars($posts->title)); ?>" width="16" height="16" alt="view" /></a>
<?php endif; ?>
</td>
<td><a href="<?php $options->adminUrl('manage-posts.php?uid=' . $posts->author->uid); ?>"><?php $posts->author(); ?></a></td>

View File

@ -34,10 +34,27 @@ $(document).ready(function() {
});
// tag autocomplete 提示
$('#tags').tokenInput(<?php
var tags = $('#tags'), tagsPre = [];
var items = tags.val().split(','), result = [];
for (var i = 0; i < items.length; i ++) {
var tag = items[i];
if (!tag) {
continue;
}
tagsPre.push({
id : tag,
tags : tag
});
}
tags.tokenInput(<?php
$data = array();
while ($tags->next()) {
$data[] = array(
'id' => $tags->name,
'tags' => $tags->name
);
}
@ -46,9 +63,11 @@ $(document).ready(function() {
propertyToSearch: 'tags',
tokenValue : 'tags',
searchDelay : 0,
preventDuplicates : true,
animateDropdown : false,
hintText : '<?php _e('请输入标签名'); ?>',
noResultsText : '此标签不存在, 按回车创建'
noResultsText : '此标签不存在, 按回车创建',
prePopulate : tagsPre
});
// tag autocomplete 提示宽度设置

View File

@ -30,9 +30,8 @@ Typecho_Widget::widget('Widget_Contents_Page_Edit')->to($page);
</span>
<span class="right">
<input type="hidden" name="cid" value="<?php $page->cid(); ?>" />
<input type="hidden" name="do" value="publish" />
<button type="button" id="btn-save"><?php _e('保存草稿'); ?></button>
<button type="button" id="btn-submit"><?php _e('发布页面 &raquo;'); ?></button>
<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>

View File

@ -49,10 +49,8 @@ Typecho_Widget::widget('Widget_Contents_Post_Edit')->to($post);
<span class="right">
<input type="hidden" name="cid" value="<?php $post->cid(); ?>" />
<input type="hidden" name="do" value="publish" />
<button type="button" id="btn-preview"><?php _e('预览'); ?></button>
<button type="button" id="btn-save"><?php _e('保存草稿'); ?></button>
<button type="button" class="primary" id="btn-submit"><?php _e('发布文章'); ?></button>
<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>

View File

@ -318,11 +318,11 @@ class Widget_Contents_Post_Edit extends Widget_Abstract_Contents implements Widg
/** 获取文章内容 */
if (!empty($this->request->cid) && 'delete' != $this->request->do) {
$this->db->fetchRow($this->select()
->where('table.contents.type = ?', 'post')
->where('table.contents.type = ? OR table.contents.type = ?', 'post', 'post_draft')
->where('table.contents.cid = ?', $this->request->filter('int')->cid)
->limit(1), array($this, 'push'));
if ('draft' == $this->status && $this->parent) {
if ('post_draft' == $this->type && $this->parent) {
$this->response->redirect(Typecho_Common::url('write-post.php?cid=' . $this->parent, $this->options->adminUrl));
}
@ -343,10 +343,10 @@ class Widget_Contents_Post_Edit extends Widget_Abstract_Contents implements Widg
*/
public function filter(array $value)
{
if ('draft' != $value['status']) {
if ('post' == $value['type']) {
$draft = $this->db->fetchRow($this->widget('Widget_Abstract_Contents')->select()
->where('table.contents.parent = ? AND table.contents.type = ? AND table.contents.status = ?',
$value['cid'], $value['type'], 'draft')
$value['cid'], 'post_draft', $value['status'])
->limit(1));
if (!empty($draft)) {