修复拖拽效果

This commit is contained in:
joyqi 2014-02-18 10:14:27 +08:00
parent 5be3d08bd0
commit 948953eb33
3 changed files with 47 additions and 3 deletions

View File

@ -20,7 +20,7 @@ $(document).ready(function() {
function updateAttacmentNumber () {
var btn = $('#tab-files-btn'),
balloon = $('.balloon', btn),
count = $('#file-list li').length;
count = $('#file-list li .insert').length;
if (count > 0) {
if (!balloon.length) {
@ -34,6 +34,28 @@ $(document).ready(function() {
}
}
$('.upload-area').bind({
dragenter : function () {
$(this).parent().addClass('drag');
},
dragover : function (e) {
$(this).parent().addClass('drag');
},
drop : function () {
$(this).parent().removeClass('drag');
},
dragend : function () {
$(this).parent().removeClass('drag');
},
dragleave : function () {
$(this).parent().removeClass('drag');
}
});
updateAttacmentNumber();
function fileUploadStart (file) {

View File

@ -13,7 +13,7 @@ if (isset($post) || isset($page)) {
?>
<div id="upload-panel" class="p">
<div class="upload-area"><?php _e('拖放文件到这里<br>或者 %s选择文件上传%s', '<a href="###" class="upload-file">', '</a>'); ?></div>
<div class="upload-area" draggable="true"><?php _e('拖放文件到这里<br>或者 %s选择文件上传%s', '<a href="###" class="upload-file">', '</a>'); ?></div>
<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(); ?>" />

View File

@ -33,7 +33,7 @@ Typecho_Widget::widget('Widget_Contents_Attachment_Edit')->to($attachment);
</p>
<div id="upload-panel" class="p">
<div class="upload-area"><?php _e('拖放文件到这里<br>或者 %s选择文件上传%s', '<a href="###" class="upload-file">', '</a>'); ?></div>
<div class="upload-area" draggable="true"><?php _e('拖放文件到这里<br>或者 %s选择文件上传%s', '<a href="###" class="upload-file">', '</a>'); ?></div>
<ul id="file-list"></ul>
</div>
</div>
@ -66,6 +66,28 @@ $(document).ready(function() {
return false;
});
$('.upload-area').bind({
dragenter : function () {
$(this).parent().addClass('drag');
},
dragover : function (e) {
$(this).parent().addClass('drag');
},
drop : function () {
$(this).parent().removeClass('drag');
},
dragend : function () {
$(this).parent().removeClass('drag');
},
dragleave : function () {
$(this).parent().removeClass('drag');
}
});
function fileUploadStart (file) {
$('<ul id="file-list"></ul>').appendTo('#upload-panel');
$('<li id="' + file.id + '" class="loading">'