修正插入文件bug

This commit is contained in:
joyqi
2013-10-19 19:46:29 +08:00
parent 279c44e8e0
commit 44aabf9769
5 changed files with 15 additions and 7 deletions

View File

@@ -37,7 +37,7 @@ $(document).ready(function() {
.data('url', data.url)
.data('image', data.isImage)
.html('<input type="hidden" name="attachment[]" value="' + data.cid + '" />'
+ '<a class="insert" target="_blank" href="###">' + data.title + '</a> ' + data.bytes
+ '<a class="insert" target="_blank" href="###" title="<?php _e('点击插入文件'); ?>">' + data.title + '</a> ' + data.bytes
+ ' <a class="file" target="_blank" href="<?php $options->adminUrl('media.php'); ?>?cid='
+ data.cid + '" title="<?php _e('编辑'); ?>"><i class="i-edit"></i></a>'
+ ' <a class="delete" href="###" title="<?php _e('删除'); ?>"><i class="i-delete"></i></a>')

View File

@@ -17,7 +17,7 @@ if (isset($post) || isset($page)) {
<ul id="file-list">
<?php while ($attachment->next()): ?>
<li data-cid="<?php $attachment->cid(); ?>" data-url="<?php echo $attachment->attachment->url; ?>" data-image="<?php echo $attachment->attachment->isImage ? 1 : 0; ?>"><input type="hidden" name="attachment[]" value="<?php $attachment->cid(); ?>" />
<a class="insert" href="###"><?php $attachment->title(); ?></a>
<a class="insert" title="<?php _e('点击插入文件'); ?>" href="###"><?php $attachment->title(); ?></a>
<?php echo number_format(ceil($attachment->attachment->size / 1024)); ?> Kb
<a class="file" target="_blank" href="<?php $options->adminUrl('media.php?cid=' . $attachment->cid); ?>" title="<?php _e('编辑'); ?>"><i class="i-edit"></i></a>
<a href="###" class="delete" title="<?php _e('删除'); ?>"><i class="i-delete"></i></a></li>

View File

@@ -939,10 +939,6 @@ jQuery.fn.extend({
return;
}
if ($.browser.opera && $.browser.version >= 9.5 && len == 0) {
return false;
}
if (e.setSelectionRange) {
e.focus();
e.setSelectionRange(start, end);

View File

@@ -69,7 +69,7 @@ $stat = Typecho_Widget::widget('Widget_Stat');
<td><?php $attachments->author(); ?></td>
<td>
<?php if ($attachments->parentPost->cid): ?>
<a href="<?php $options->adminUrl('write-' . $attachments->parentPost->type . '.php?cid=' . $attachments->parentPost->cid); ?>"><?php $attachments->parentPost->title(); ?></a>
<a href="<?php $options->adminUrl('write-' . (0 === strpos($attachments->parentPost->type, 'post') ? 'post' : 'page') . '.php?cid=' . $attachments->parentPost->cid); ?>"><?php $attachments->parentPost->title(); ?></a>
<?php else: ?>
<span class="description"><?php _e('未归档'); ?></span>
<?php endif; ?>

View File

@@ -101,6 +101,18 @@ $(document).ready(function() {
}
}).width();
// 原始的插入图片和文件
Typecho.insertFileToEditor = function (url, isImage) {
var textarea = $('#text'), sel = textarea.getSelection(),
file = url.split('/').pop(),
html = isImage ? '<img src="' + url + '" alt="' + file + '" />'
: '<a href="' + url + '">' + file + '</a>',
offset = (sel ? sel.start : 0) + html.length;
textarea.replaceSelection(html);
textarea.setSelection(offset, offset);
};
// 自动保存
<?php if ($options->autoSave): ?>
var savedData = null, locked = false,