让slug输入框随输入扩展

This commit is contained in:
joyqi 2013-10-15 16:56:23 +08:00
parent e545168101
commit ce0d0d1dc0
3 changed files with 35 additions and 15 deletions

View File

@ -32,23 +32,21 @@ include 'menu.php';
<form method="post" name="manage_users" class="operate-form">
<table class="typecho-list-table">
<colgroup>
<col width="20"/>
<col width="20%"/>
<col width="20%"/>
<col width="20"/>
<col width="3%"/>
<col width="5%"/>
<col width="30%"/>
<col width=""/>
<col width="10%"/>
<col width="25%"/>
<col width="25%"/>
<col width="12%"/>
</colgroup>
<thead>
<tr>
<th> </th>
<th> </th>
<th><?php _e('用户名'); ?></th>
<th><?php _e('昵称'); ?></th>
<th> </th>
<th><?php _e('电子邮件'); ?></th>
<th><?php _e('用户组'); ?></th>
<th><?php _e('文章'); ?></th>
</tr>
</thead>
<tbody>
@ -56,11 +54,11 @@ include 'menu.php';
<?php while($users->next()): ?>
<tr id="user-<?php $users->uid(); ?>">
<td><input type="checkbox" value="<?php $users->uid(); ?>" name="uid[]"/></td>
<td><a href="<?php $options->adminUrl('user.php?uid=' . $users->uid); ?>"><?php $users->name(); ?></a></td>
<td><?php $users->screenName(); ?></td>
<td>
<a class="right hidden-by-mouse" href="<?php $users->permalink(); ?>"><img src="<?php $options->adminUrl('images/link.png'); ?>" title="<?php _e('浏览 %s', $users->screenName); ?>" width="16" height="16" alt="view" /></a>
<td><a href="<?php $options->adminUrl('manage-posts.php?uid=' . $users->uid); ?>" class="balloon-button left size-<?php echo Typecho_Common::splitByCount($users->postsNum, 1, 10, 20, 50, 100); ?>"><?php $users->postsNum(); ?></a></td>
<td><a href="<?php $options->adminUrl('user.php?uid=' . $users->uid); ?>"><?php $users->name(); ?></a>
<a class="right" href="<?php $users->permalink(); ?>"><img src="<?php $options->adminUrl('images/link.png'); ?>" title="<?php _e('浏览 %s', $users->screenName); ?>" width="16" height="16" alt="view" /></a>
</td>
<td><?php $users->screenName(); ?></td>
<td><?php if($users->mail): ?><a href="mailto:<?php $users->mail(); ?>"><?php $users->mail(); ?></a><?php else: _e('暂无'); endif; ?></td>
<td><?php switch ($users->group) {
case 'administrator':
@ -81,7 +79,6 @@ include 'menu.php';
default:
break;
} ?></td>
<td><a href="<?php $options->adminUrl('manage-posts.php?uid=' . $users->uid); ?>" class="balloon-button left size-<?php echo Typecho_Common::splitByCount($users->postsNum, 1, 10, 20, 50, 100); ?>"><?php $users->postsNum(); ?></a></td>
</tr>
<?php endwhile; ?>
</tbody>

View File

@ -77,6 +77,22 @@ $(document).ready(function() {
t.width($('.token-input-list').outerWidth() - offset);
});
var slug = $('#slug'), sw = slug.width();
if (slug.val().length > 0) {
slug.css('width', 'auto').attr('size', slug.val().length);
}
slug.bind('input propertychange', function () {
var t = $(this), l = t.val().length;
if (l > 0) {
t.css('width', 'auto').attr('size', l);
} else {
t.css('width', sw).removeAttr('size');
}
}).width();
// 高级选项控制
$('#advance-panel-btn').click(function() {
$('#advance-panel').toggle();

View File

@ -16,8 +16,15 @@ Typecho_Widget::widget('Widget_Contents_Post_Edit')->to($post);
Typecho_Common::url('/action/contents-post-edit?do=deleteDraft&cid=' . $post->cid, $options->index)); ?></cite>
<?php endif; ?>
<p class="title"><input type="text" id="title" name="title" value="<?php echo htmlspecialchars($post->title); ?>" placeholder="<?php _e('标题'); ?>" class="w-100 text title" /></p>
<p class="mono url-slug"><?php _e('缩略名'); ?> http://xxxxxxxxxxxx.com/2011/08/29/<input type="text" id="slug" name="slug" value="<?php $post->slug(); ?>" class="mono" />/</p>
<?php $permalink = Typecho_Common::url($options->routingTable['post']['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($post->slug) . '" class="mono" />';
?>
<p class="mono url-slug"><?php echo preg_replace("/\[slug:?[_0-9a-z-:]*\]/i", $input, $permalink); ?></p>
<?php endif; ?>
<p class="editor">
<span class="btnBold">bold</span><!--