mirror of
https://github.com/eiblog/eiblog.git
synced 2026-02-14 18:32:26 +08:00
添加七牛cdn上传功能
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{{.Title}}</title>
|
||||
<meta name="robots" content="noindex, nofollow">
|
||||
<link rel="stylesheet" href="/static/admin/background.css">
|
||||
<link rel="stylesheet" href="/static/admin/style.css">
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<meta content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" name=viewport>
|
||||
<meta name=robots content="noindex, nofollow">
|
||||
<title>登录 | {{.BTitle}}</title>
|
||||
<link rel=stylesheet href="/static/admin/background.css">
|
||||
<link rel=stylesheet href="/static/admin/style.css">
|
||||
</head>
|
||||
|
||||
<body class="body-100">
|
||||
@@ -16,7 +16,7 @@
|
||||
<form action="/admin/login" method=post>
|
||||
<p>
|
||||
<label for=user class="sr-only">用户名</label>
|
||||
<input type=text id=user name=user value="" placeholder="用户名" class="text-l w-100">
|
||||
<input type=text id=user name=user placeholder="用户名" class="text-l w-100">
|
||||
</p>
|
||||
<p>
|
||||
<label for=password class="sr-only">密码</label>
|
||||
|
||||
@@ -41,9 +41,13 @@
|
||||
<section class="typecho-post-option category-option">
|
||||
<label class="typecho-label">专题</label>
|
||||
<ul>
|
||||
<li>
|
||||
<input type="radio" id="serie-0" value="0" name="serie" checked="true"/>
|
||||
<label for="serie-0">默认专题</label>
|
||||
</li>
|
||||
{{range $k,$v:=.Series}}
|
||||
<li>
|
||||
<input type="checkbox" id="serie-{{$v.ID}}" value="{{$v.ID}}" name="serie" {{with $.Edit}}{{if eq .SerieID $v.ID}}checked="true"{{end}}{{end}}/>
|
||||
<input type="radio" id="serie-{{$v.ID}}" value="{{$v.ID}}" name="serie" {{with $.Edit}}{{if eq .SerieID $v.ID}}checked="true"{{end}}{{end}}/>
|
||||
<label for="serie-{{$v.ID}}">{{$v.Name}}</label>
|
||||
</li>
|
||||
{{end}}
|
||||
@@ -143,9 +147,6 @@ $(document).ready(function() {
|
||||
// 聚焦
|
||||
$('#title').select();
|
||||
|
||||
// text 自动拉伸
|
||||
// Typecho.editorResize('text', 'http://localhost/index.php/action/ajax?do=editorResize&_=53e23a1bd0daab03b05d9c23190904a4');
|
||||
|
||||
// tag autocomplete 提示
|
||||
var tags = $('#tags'),
|
||||
tagsPre = [];
|
||||
@@ -329,12 +330,6 @@ $(document).ready(function() {
|
||||
return false;
|
||||
});
|
||||
|
||||
// 高级选项控制
|
||||
$('#advance-panel-btn').click(function() {
|
||||
$('#advance-panel').toggle();
|
||||
return false;
|
||||
});
|
||||
|
||||
// 自动隐藏密码框
|
||||
$('#visibility').change(function() {
|
||||
var val = $(this).val(),
|
||||
@@ -346,10 +341,20 @@ $(document).ready(function() {
|
||||
password.addClass('hidden');
|
||||
}
|
||||
});
|
||||
|
||||
// 草稿删除确认
|
||||
$('.edit-draft-notice a').click(function () {
|
||||
if (confirm('您确认要删除这份草稿吗?')) {
|
||||
window.location.href = $(this).attr('href');
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script src="/static/admin/hyperdown.js"></script>
|
||||
<script src="/static/admin/pagedown.js"></script>
|
||||
<script src="/static/admin/stmd.js"></script>
|
||||
<script src="/static/admin/pagedown-extra.js"></script>
|
||||
<script src="/static/admin/diff.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
@@ -406,36 +411,26 @@ $(document).ready(function() {
|
||||
help: 'Markdown语法帮助'
|
||||
};
|
||||
|
||||
var converter = new Typecho.Markdown,
|
||||
var converter = new HyperDown(),
|
||||
editor = new Markdown.Editor(converter, '', options),
|
||||
diffMatch = new diff_match_patch(),
|
||||
last = '',
|
||||
preview = $('#wmd-preview'),
|
||||
diffMatch = new diff_match_patch(), last = '', preview = $('#wmd-preview'),
|
||||
mark = '@mark' + Math.ceil(Math.random() * 100000000) + '@',
|
||||
span = '<span class="diff" />',
|
||||
cache = {};
|
||||
|
||||
|
||||
// 自动跟随
|
||||
converter.hooks.chain('postConversion', function(html) {
|
||||
// clear special html tags
|
||||
html = html.replace(/<\/?(\!doctype|html|head|body|link|title|input|select|button|textarea|style|noscript)[^>]*>/ig, function(all) {
|
||||
return all.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/'/g, ''')
|
||||
.replace(/"/g, '"');
|
||||
});
|
||||
|
||||
// clear hard breaks
|
||||
html = html.replace(/\s*((?:<br>\n)+)\s*(<\/?(?:p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|form|fieldset|iframe|hr|legend|article|section|nav|aside|hgroup|header|footer|figcaption|li|dd|dt)[^\w])/gm, '$2');
|
||||
|
||||
converter.hook('makeHtml', function (html) {
|
||||
// convert all comment
|
||||
html = html.replace(/<!--(.+?)-->/g, '<!--$1-->');
|
||||
|
||||
if (html.indexOf('<!--more-->') > 0) {
|
||||
var parts = html.split(/\s*<\!\-\-more\-\->\s*/),
|
||||
summary = parts.shift(),
|
||||
details = parts.join('');
|
||||
|
||||
html = '<div class="summary">' + summary + '</div>' + '<div class="details">' + details + '</div>';
|
||||
html = '<div class="summary">' + summary + '</div>'
|
||||
+ '<div class="details">' + details + '</div>';
|
||||
}
|
||||
|
||||
|
||||
@@ -443,22 +438,18 @@ $(document).ready(function() {
|
||||
last = html;
|
||||
|
||||
if (diffs.length > 0) {
|
||||
var stack = [],
|
||||
markStr = mark;
|
||||
|
||||
for (var i = 0; i < diffs.length; i++) {
|
||||
var diff = diffs[i],
|
||||
op = diff[0],
|
||||
str = diff[1]
|
||||
sp = str.lastIndexOf('<'), ep = str.lastIndexOf('>');
|
||||
var stack = [], markStr = mark;
|
||||
|
||||
for (var i = 0; i < diffs.length; i ++) {
|
||||
var diff = diffs[i], op = diff[0], str = diff[1]
|
||||
sp = str.lastIndexOf('<'), ep = str.lastIndexOf('>');
|
||||
|
||||
if (op != 0) {
|
||||
if (sp >= 0 && sp > ep) {
|
||||
if (sp >=0 && sp > ep) {
|
||||
if (op > 0) {
|
||||
stack.push(str.substring(0, sp) + markStr + str.substring(sp));
|
||||
} else {
|
||||
var lastStr = stack[stack.length - 1],
|
||||
lastSp = lastStr.lastIndexOf('<');
|
||||
var lastStr = stack[stack.length - 1], lastSp = lastStr.lastIndexOf('<');
|
||||
stack[stack.length - 1] = lastStr.substring(0, lastSp) + markStr + lastStr.substring(lastSp);
|
||||
}
|
||||
} else {
|
||||
@@ -468,7 +459,7 @@ $(document).ready(function() {
|
||||
stack.push(markStr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
markStr = '';
|
||||
} else {
|
||||
stack.push(str);
|
||||
@@ -478,11 +469,9 @@ $(document).ready(function() {
|
||||
html = stack.join('');
|
||||
|
||||
if (!markStr) {
|
||||
var pos = html.indexOf(mark),
|
||||
prev = html.substring(0, pos),
|
||||
var pos = html.indexOf(mark), prev = html.substring(0, pos),
|
||||
next = html.substr(pos + mark.length),
|
||||
sp = prev.lastIndexOf('<'),
|
||||
ep = prev.lastIndexOf('>');
|
||||
sp = prev.lastIndexOf('<'), ep = prev.lastIndexOf('>');
|
||||
|
||||
if (sp >= 0 && sp > ep) {
|
||||
html = prev.substring(0, sp) + span + prev.substring(sp) + next;
|
||||
@@ -491,55 +480,54 @@ $(document).ready(function() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 替换img
|
||||
html = html.replace(/<(img)\s+([^>]*)\s*src="([^"]+)"([^>]*)>/ig, function(all, tag, prefix, src, suffix) {
|
||||
html = html.replace(/<(img)\s+([^>]*)\s*src="([^"]+)"([^>]*)>/ig, function (all, tag, prefix, src, suffix) {
|
||||
if (!cache[src]) {
|
||||
cache[src] = false;
|
||||
} else {
|
||||
return '<span class="cache" data-width="' + cache[src][0] + '" data-height="' + cache[src][1] + '" ' + 'style="background:url(' + src + ') no-repeat left top; width:' + cache[src][0] + 'px; height:' + cache[src][1] + 'px; display: inline-block; max-width: 100%;' + '-webkit-background-size: contain;-moz-background-size: contain;-o-background-size: contain;background-size: contain;" />';
|
||||
return '<span class="cache" data-width="' + cache[src][0] + '" data-height="' + cache[src][1] + '" '
|
||||
+ 'style="background:url(' + src + ') no-repeat left top; width:'
|
||||
+ cache[src][0] + 'px; height:' + cache[src][1] + 'px; display: inline-block; max-width: 100%;'
|
||||
+ '-webkit-background-size: contain;-moz-background-size: contain;-o-background-size: contain;background-size: contain;" />';
|
||||
}
|
||||
|
||||
return all;
|
||||
});
|
||||
|
||||
// 替换block
|
||||
html = html.replace(/<(iframe|embed)\s+([^>]*)>/ig, function(all, tag, src) {
|
||||
html = html.replace(/<(iframe|embed)\s+([^>]*)>/ig, function (all, tag, src) {
|
||||
if (src[src.length - 1] == '/') {
|
||||
src = src.substring(0, src.length - 1);
|
||||
}
|
||||
|
||||
return '<div style="background: #ddd; height: 40px; overflow: hidden; line-height: 40px; text-align: center; font-size: 12px; color: #777">' + tag + ' : ' + $.trim(src) + '</div>';
|
||||
return '<div style="background: #ddd; height: 40px; overflow: hidden; line-height: 40px; text-align: center; font-size: 12px; color: #777">'
|
||||
+ tag + ' : ' + $.trim(src) + '</div>';
|
||||
});
|
||||
|
||||
return html;
|
||||
});
|
||||
|
||||
function cacheResize() {
|
||||
var t = $(this),
|
||||
w = parseInt(t.data('width')),
|
||||
h = parseInt(t.data('height')),
|
||||
var t = $(this), w = parseInt(t.data('width')), h = parseInt(t.data('height')),
|
||||
ow = t.width();
|
||||
|
||||
t.height(h * ow / w);
|
||||
}
|
||||
|
||||
var to;
|
||||
editor.hooks.chain('onPreviewRefresh', function() {
|
||||
var diff = $('.diff', preview),
|
||||
scrolled = false;
|
||||
editor.hooks.chain('onPreviewRefresh', function () {
|
||||
var diff = $('.diff', preview), scrolled = false;
|
||||
|
||||
if (to) {
|
||||
clearTimeout(to);
|
||||
}
|
||||
|
||||
$('img', preview).load(function() {
|
||||
var t = $(this),
|
||||
src = t.attr('src');
|
||||
$('img', preview).load(function () {
|
||||
var t = $(this), src = t.attr('src');
|
||||
|
||||
if (scrolled) {
|
||||
preview.scrollTo(diff, {
|
||||
offset: -50
|
||||
offset : - 50
|
||||
});
|
||||
}
|
||||
|
||||
@@ -549,64 +537,62 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
$('.cache', preview).resize(cacheResize).each(cacheResize);
|
||||
|
||||
|
||||
var changed = $('.diff', preview).parent();
|
||||
if (!changed.is(preview)) {
|
||||
changed.css('background-color', 'rgba(255,230,0,0.5)');
|
||||
to = setTimeout(function() {
|
||||
to = setTimeout(function () {
|
||||
changed.css('background-color', 'transparent');
|
||||
}, 4500);
|
||||
}
|
||||
|
||||
if (diff.length > 0) {
|
||||
var p = diff.position(),
|
||||
lh = diff.parent().css('line-height');
|
||||
var p = diff.position(), lh = diff.parent().css('line-height');
|
||||
lh = !!lh ? parseInt(lh) : 0;
|
||||
|
||||
if (p.top < 0 || p.top > preview.height() - lh) {
|
||||
preview.scrollTo(diff, {
|
||||
offset: -50
|
||||
offset : - 50
|
||||
});
|
||||
scrolled = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var input = $('#text'), th = textarea.height(), ph = preview.height(),
|
||||
uploadBtn = $('<button type="button" id="btn-fullscreen-upload" class="btn btn-link">'
|
||||
+ '<i class="i-upload">附件</i></button>')
|
||||
.prependTo('.submit .right')
|
||||
.click(function() {
|
||||
$('a', $('.typecho-option-tabs li').not('.active')).trigger('click');
|
||||
return false;
|
||||
});
|
||||
|
||||
var input = $('#text'),
|
||||
th = textarea.height(),
|
||||
ph = preview.height(),
|
||||
uploadBtn = $('<button type="button" id="btn-fullscreen-upload" class="btn btn-link">' + '<i class="i-upload">附件</i></button>')
|
||||
.prependTo('.submit .right')
|
||||
.click(function() {
|
||||
$('a', $('.typecho-option-tabs li').not('.active')).trigger('click');
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.typecho-option-tabs li').click(function() {
|
||||
$('.typecho-option-tabs li').click(function () {
|
||||
uploadBtn.find('i').toggleClass('i-upload-active',
|
||||
$('#tab-files-btn', this).length > 0);
|
||||
});
|
||||
|
||||
editor.hooks.chain('enterFakeFullScreen', function() {
|
||||
editor.hooks.chain('enterFakeFullScreen', function () {
|
||||
th = textarea.height();
|
||||
ph = preview.height();
|
||||
$(document.body).addClass('fullscreen');
|
||||
var h = $(window).height() - toolbar.outerHeight();
|
||||
|
||||
|
||||
textarea.css('height', h);
|
||||
preview.css('height', h);
|
||||
});
|
||||
|
||||
editor.hooks.chain('enterFullScreen', function() {
|
||||
editor.hooks.chain('enterFullScreen', function () {
|
||||
$(document.body).addClass('fullscreen');
|
||||
|
||||
|
||||
var h = window.screen.height - toolbar.outerHeight();
|
||||
textarea.css('height', h);
|
||||
preview.css('height', h);
|
||||
});
|
||||
|
||||
editor.hooks.chain('exitFullScreen', function() {
|
||||
editor.hooks.chain('exitFullScreen', function () {
|
||||
$(document.body).removeClass('fullscreen');
|
||||
textarea.height(th);
|
||||
preview.height(ph);
|
||||
@@ -618,13 +604,13 @@ $(document).ready(function() {
|
||||
var imageButton = $('#wmd-image-button'),
|
||||
linkButton = $('#wmd-link-button');
|
||||
|
||||
Typecho.insertFileToEditor = function(file, url, isImage) {
|
||||
Typecho.insertFileToEditor = function (file, url, isImage) {
|
||||
var button = isImage ? imageButton : linkButton;
|
||||
|
||||
options.strings[isImage ? 'imagename' : 'linkname'] = file;
|
||||
button.trigger('click');
|
||||
|
||||
var checkDialog = setInterval(function() {
|
||||
var checkDialog = setInterval(function () {
|
||||
if ($('.wmd-prompt-dialog').length > 0) {
|
||||
$('.wmd-prompt-dialog input').val(url).select();
|
||||
clearInterval(checkDialog);
|
||||
@@ -633,7 +619,7 @@ $(document).ready(function() {
|
||||
}, 10);
|
||||
};
|
||||
|
||||
Typecho.uploadComplete = function(file) {
|
||||
Typecho.uploadComplete = function (file) {
|
||||
Typecho.insertFileToEditor(file.title, file.url, file.isImage);
|
||||
};
|
||||
|
||||
@@ -645,7 +631,7 @@ $(document).ready(function() {
|
||||
$(".wmd-edittab a").removeClass('active');
|
||||
$(this).addClass("active");
|
||||
$("#wmd-editarea, #wmd-preview").addClass("wmd-hidetab");
|
||||
|
||||
|
||||
var selected_tab = $(this).attr("href"),
|
||||
selected_el = $(selected_tab).removeClass("wmd-hidetab");
|
||||
|
||||
@@ -669,7 +655,7 @@ $(document).ready(function() {
|
||||
<script src="/static/admin/plupload.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
function updateAttacmentNumber() {
|
||||
function updateAttacmentNumber () {
|
||||
var btn = $('#tab-files-btn'),
|
||||
balloon = $('.balloon', btn),
|
||||
count = $('#file-list li .insert').length;
|
||||
@@ -687,38 +673,37 @@ $(document).ready(function() {
|
||||
}
|
||||
|
||||
$('.upload-area').bind({
|
||||
dragenter: function() {
|
||||
dragenter : function () {
|
||||
$(this).parent().addClass('drag');
|
||||
},
|
||||
|
||||
dragover: function(e) {
|
||||
dragover : function (e) {
|
||||
$(this).parent().addClass('drag');
|
||||
},
|
||||
|
||||
drop: function() {
|
||||
drop : function () {
|
||||
$(this).parent().removeClass('drag');
|
||||
},
|
||||
|
||||
dragend : function () {
|
||||
$(this).parent().removeClass('drag');
|
||||
},
|
||||
|
||||
dragend: function() {
|
||||
$(this).parent().removeClass('drag');
|
||||
},
|
||||
|
||||
dragleave: function() {
|
||||
dragleave : function () {
|
||||
$(this).parent().removeClass('drag');
|
||||
}
|
||||
});
|
||||
|
||||
updateAttacmentNumber();
|
||||
|
||||
function fileUploadStart(file) {
|
||||
$('<li id="' + file.id + '" class="loading">' + file.name + '</li>').appendTo('#file-list');
|
||||
function fileUploadStart (file) {
|
||||
$('<li id="' + file.id + '" class="loading">'
|
||||
+ file.name + '</li>').appendTo('#file-list');
|
||||
}
|
||||
|
||||
function fileUploadError(error) {
|
||||
var file = error.file,
|
||||
code = error.code,
|
||||
word;
|
||||
|
||||
function fileUploadError (error) {
|
||||
var file = error.file, code = error.code, word;
|
||||
|
||||
switch (code) {
|
||||
case plupload.FILE_SIZE_ERROR:
|
||||
word = '文件大小超过限制';
|
||||
@@ -744,22 +729,26 @@ $(document).ready(function() {
|
||||
li = $('<li>' + fileError + '<br />' + word + '</li>').appendTo('#file-list');
|
||||
}
|
||||
|
||||
li.effect('highlight', {
|
||||
color: '#FBC2C4'
|
||||
}, 2000, function() {
|
||||
li.effect('highlight', {color : '#FBC2C4'}, 2000, function () {
|
||||
$(this).remove();
|
||||
});
|
||||
|
||||
// fix issue #341
|
||||
this.removeFile(file);
|
||||
}
|
||||
|
||||
var completeFile = null;
|
||||
|
||||
function fileUploadComplete(id, url, data) {
|
||||
var li = $('#' + id).removeClass('loading').data('cid', data.cid)
|
||||
function fileUploadComplete (id, data) {
|
||||
var li = $('#' + id).removeClass('loading').data('name', data.name)
|
||||
.data('url', data.url)
|
||||
.data('image', data.isImage)
|
||||
.html('<input type="hidden" name="attachment[]" value="' + data.cid + '" />' + '<a class="insert" target="_blank" href="###" title="点击插入文件">' + data.title + '</a><div class="info">' + data.bytes + ' <a class="file" target="_blank" href="http://localhost/admin/media.php?cid=' + data.cid + '" title="编辑"><i class="i-edit"></i></a>' + ' <a class="delete" href="###" title="删除"><i class="i-delete"></i></a></div>')
|
||||
.html('<input type="hidden" name="attachment[]" value="' + data.cid + '" />'
|
||||
+ '<a class="insert" target="_blank" href="###" title="点击插入文件">' + data.name + '</a><div class="info">' + data.bytes
|
||||
+ ' <a class="file" target="_blank" href="'
|
||||
+ data.url + '" title="查看"><i class="i-edit"></i></a>'
|
||||
+ ' <a class="delete" href="###" title="删除"><i class="i-delete"></i></a></div>')
|
||||
.effect('highlight', 1000);
|
||||
|
||||
|
||||
attachInsertEvent(li);
|
||||
attachDeleteEvent(li);
|
||||
updateAttacmentNumber();
|
||||
@@ -769,56 +758,53 @@ $(document).ready(function() {
|
||||
}
|
||||
}
|
||||
|
||||
$('#tab-files').bind('init', function() {
|
||||
$('#tab-files').bind('init', function () {
|
||||
var uploader = new plupload.Uploader({
|
||||
browse_button: $('.upload-file').get(0),
|
||||
url: '/admin/api/file-upload',
|
||||
runtimes: 'html5,flash,html4',
|
||||
flash_swf_url: '/static/admin/js/Moxie.swf',
|
||||
drop_element: $('.upload-area').get(0),
|
||||
filters: {
|
||||
max_file_size: '2mb',
|
||||
mime_types: [{
|
||||
'title': '允许上传的文件',
|
||||
'extensions': 'gif,jpg,jpeg,png,tiff,bmp'
|
||||
}],
|
||||
prevent_duplicates: true
|
||||
browse_button : $('.upload-file').get(0),
|
||||
url : '/admin/api/file-upload',
|
||||
runtimes : 'html5,flash,html4',
|
||||
flash_swf_url : '/static/admin/js/Moxie.swf',
|
||||
drop_element : $('.upload-area').get(0),
|
||||
filters : {
|
||||
max_file_size : '2mb',
|
||||
<!-- mime_types : [{'title' : '允许上传的文件', 'extensions' : 'gif,jpg,jpeg,png,tiff,bmp'}], -->
|
||||
prevent_duplicates : true
|
||||
},
|
||||
|
||||
init: {
|
||||
FilesAdded: function(up, files) {
|
||||
plupload.each(files, function(file) {
|
||||
fileUploadStart(file);
|
||||
});
|
||||
init : {
|
||||
FilesAdded : function (up, files) {
|
||||
for (var i = 0; i < files.length; i ++) {
|
||||
fileUploadStart(files[i]);
|
||||
}
|
||||
|
||||
completeFile = null;
|
||||
uploader.start();
|
||||
},
|
||||
|
||||
UploadComplete: function() {
|
||||
UploadComplete : function () {
|
||||
if (completeFile) {
|
||||
Typecho.uploadComplete(completeFile);
|
||||
}
|
||||
},
|
||||
|
||||
FileUploaded: function(up, file, result) {
|
||||
FileUploaded : function (up, file, result) {
|
||||
if (200 == result.status) {
|
||||
var data = $.parseJSON(result.response);
|
||||
|
||||
if (data) {
|
||||
fileUploadComplete(file.id, data[0], data[1]);
|
||||
fileUploadComplete(file.id, data);
|
||||
uploader.removeFile(file);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fileUploadError({
|
||||
code: plupload.HTTP_ERROR,
|
||||
file: file
|
||||
fileUploadError.call(uploader, {
|
||||
code : plupload.HTTP_ERROR,
|
||||
file : file
|
||||
});
|
||||
},
|
||||
|
||||
Error: function(up, error) {
|
||||
fileUploadError(error);
|
||||
Error : function (up, error) {
|
||||
fileUploadError.call(uploader, error);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -826,26 +812,23 @@ $(document).ready(function() {
|
||||
uploader.init();
|
||||
});
|
||||
|
||||
function attachInsertEvent(el) {
|
||||
$('.insert', el).click(function() {
|
||||
var t = $(this),
|
||||
p = t.parents('li');
|
||||
function attachInsertEvent (el) {
|
||||
$('.insert', el).click(function () {
|
||||
var t = $(this), p = t.parents('li');
|
||||
Typecho.insertFileToEditor(t.text(), p.data('url'), p.data('image'));
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
function attachDeleteEvent(el) {
|
||||
function attachDeleteEvent (el) {
|
||||
var file = $('a.insert', el).text();
|
||||
$('.delete', el).click(function() {
|
||||
$('.delete', el).click(function () {
|
||||
if (confirm('确认要删除文件 %s 吗?'.replace('%s', file))) {
|
||||
var cid = $(this).parents('li').data('cid');
|
||||
$.post('http://localhost/index.php/action/contents-attachment-edit?_=53e23a1bd0daab03b05d9c23190904a4', {
|
||||
'do': 'delete',
|
||||
'cid': cid
|
||||
},
|
||||
function() {
|
||||
$(el).fadeOut(function() {
|
||||
var name = $(this).parents('li').data('name');
|
||||
$.post('/admin/api/file-delete',
|
||||
{'name' : name},
|
||||
function () {
|
||||
$(el).fadeOut(function () {
|
||||
$(this).remove();
|
||||
updateAttacmentNumber();
|
||||
});
|
||||
@@ -856,7 +839,7 @@ $(document).ready(function() {
|
||||
});
|
||||
}
|
||||
|
||||
$('#file-list li').each(function() {
|
||||
$('#file-list li').each(function () {
|
||||
attachInsertEvent(this);
|
||||
attachDeleteEvent(this);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user