Commit d556be44 authored by Van's avatar Van

add file upload function

养宝宝不容易啊,终于抽出时间打🐎
parent b3314020
...@@ -16,12 +16,13 @@ ...@@ -16,12 +16,13 @@
# #
# Description: Solo language configurations(en_US). # Description: Solo language configurations(en_US).
# Version: 2.4.2.3, Sep 12, 2015 # Version: 2.5.2.3, Sep 16, 2015
# Author: Liang Ding # Author: Liang Ding
# Author: Liyuan Li # Author: Liyuan Li
# Author: Dongxu Wang # Author: Dongxu Wang
# #
uploadFileLabel=Upload()\uff08Please add the QiNiu link to the reference\uff09
accessKey1Label=Access Key: accessKey1Label=Access Key:
secretKey1Label=Secret Key: secretKey1Label=Secret Key:
domain1Label=\u57df\u540d: domain1Label=\u57df\u540d:
......
...@@ -16,12 +16,13 @@ ...@@ -16,12 +16,13 @@
# #
# Description: Solo default language configurations(zh_CN). # Description: Solo default language configurations(zh_CN).
# Version: 2.4.4.11, Sep 12, 2015 # Version: 2.5.4.11, Sep 16, 2015
# Author: Liang Ding # Author: Liang Ding
# Author: Liyuan Li # Author: Liyuan Li
# Author: Dongxu Wang # Author: Dongxu Wang
# #
uploadFileLabel=\u6587\u4ef6\u4e0a\u4f20\uff08\u8bf7\u5c06\u751f\u6210\u7684\u4e03\u725b\u94fe\u63a5\u6dfb\u52a0\u5230\u5f15\u7528\u5904\uff09
accessKey1Label=Access Key\uff1a accessKey1Label=Access Key\uff1a
secretKey1Label=Secret Key\uff1a secretKey1Label=Secret Key\uff1a
domain1Label=\u57df\u540d\uff1a domain1Label=\u57df\u540d\uff1a
......
...@@ -10,6 +10,12 @@ ...@@ -10,6 +10,12 @@
<textarea id="articleContent" name="articleContent" <textarea id="articleContent" name="articleContent"
style="height: 500px;width:100%;"></textarea> style="height: 500px;width:100%;"></textarea>
</div> </div>
<div>
<label>${uploadFileLabel}</label>
<form id="articleUpload" method="POST" enctype="multipart/form-data">
<input type="file" name="file" multiple=""/>
</form>
</div>
<div> <div>
<label>${tags1WithTips1Label}</label> <label>${tags1WithTips1Label}</label>
<input id="tag" type="text"/> <input id="tag" type="text"/>
......
...@@ -130,6 +130,9 @@ ...@@ -130,6 +130,9 @@
</div> </div>
</div> </div>
<script src="${staticServePath}/js/lib/jquery/jquery.min.js"></script> <script src="${staticServePath}/js/lib/jquery/jquery.min.js"></script>
<script src="${staticServePath}/js/lib/jquery/file-upload-9.10.1/vendor/jquery.ui.widget.js"></script>
<script src="${staticServePath}/js/lib/jquery/file-upload-9.10.1/jquery.iframe-transport.js"></script>
<script src="${staticServePath}/js/lib/jquery/file-upload-9.10.1/jquery.fileupload.js"></script>
<script src="${staticServePath}/js/lib/jquery/jquery.bowknot.min.js?${staticResourceVersion}"></script> <script src="${staticServePath}/js/lib/jquery/jquery.bowknot.min.js?${staticResourceVersion}"></script>
<script src="${servePath}/js/lib/tiny_mce/tiny_mce.js"></script> <script src="${servePath}/js/lib/tiny_mce/tiny_mce.js"></script>
<script src="${staticServePath}/js/lib/KindEditor/kindeditor-min.js"></script> <script src="${staticServePath}/js/lib/KindEditor/kindeditor-min.js"></script>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
* *
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a> * @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.3.3, May 30, 2015 * @version 1.2.3.3, Sep 16, 2015
*/ */
admin.article = { admin.article = {
currentEditorType: '', currentEditorType: '',
...@@ -439,6 +439,39 @@ admin.article = { ...@@ -439,6 +439,39 @@ admin.article = {
} }
}); });
// upload
var qiniu = window.qiniu;
$('#articleUpload').fileupload({
multipart: true,
url: "http://upload.qiniu.com/",
formData: function (form) {
var data = form.serializeArray();
data.push({name: 'token', value: qiniu.qiniuUploadToken});
return data;
},
done: function (e, data) {
var qiniuKey = data.result.key;
if (!qiniuKey) {
alert("Upload error");
return;
}
var t = new Date().getTime();
$('#articleUpload').after('<div><a target="_blank" href="http://' + qiniu.qiniuDomain + qiniuKey + '?' + t
+ '">[' + data.files[0].name + ']</a> http://'
+ qiniu.qiniuDomain + qiniuKey + '?' + t + '</div>');
},
fail: function (e, data) {
alert("Upload error: " + data.errorThrown);
}
}).on('fileuploadprocessalways', function (e, data) {
var currentFile = data.files[data.index];
if (data.files.error && currentFile.error) {
alert(currentFile.error);
}
});
// editor // editor
admin.editors.articleEditor = new Editor({ admin.editors.articleEditor = new Editor({
id: "articleContent", id: "articleContent",
......
...@@ -2814,309 +2814,309 @@ admin.register["link-list"] = { ...@@ -2814,309 +2814,309 @@ admin.register["link-list"] = {
"obj": admin.linkList, "obj": admin.linkList,
"init": admin.linkList.init, "init": admin.linkList.init,
"refresh": admin.linkList.getList "refresh": admin.linkList.getList
}/* }/*
* Copyright (c) 2010-2015, b3log.org * Copyright (c) 2010-2015, b3log.org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/** /**
* preference for admin. * preference for admin.
* *
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a> * @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.1.8, Sep 12, 2015 * @version 1.1.1.8, Sep 12, 2015
*/ */
/* preference 相关操作 */ /* preference 相关操作 */
admin.preference = { admin.preference = {
locale: "", locale: "",
editorType: "", editorType: "",
/* /*
* 初始化 * 初始化
*/ */
init: function () { init: function () {
$("#tabPreference").tabs(); $("#tabPreference").tabs();
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/preference/", url: latkeConfig.servePath + "/console/preference/",
type: "GET", type: "GET",
cache: false, cache: false,
success: function (result, textStatus) { success: function (result, textStatus) {
$("#tipMsg").text(result.msg); $("#tipMsg").text(result.msg);
if (!result.sc) { if (!result.sc) {
$("#loadMsg").text(""); $("#loadMsg").text("");
return; return;
} }
var preference = result.preference; var preference = result.preference;
$("#metaKeywords").val(preference.metaKeywords), $("#metaKeywords").val(preference.metaKeywords),
$("#metaDescription").val(preference.metaDescription), $("#metaDescription").val(preference.metaDescription),
$("#blogTitle").val(preference.blogTitle), $("#blogTitle").val(preference.blogTitle),
$("#blogSubtitle").val(preference.blogSubtitle), $("#blogSubtitle").val(preference.blogSubtitle),
$("#mostCommentArticleDisplayCount").val(preference.mostCommentArticleDisplayCount); $("#mostCommentArticleDisplayCount").val(preference.mostCommentArticleDisplayCount);
$("#mostViewArticleDisplayCount").val(preference.mostViewArticleDisplayCount), $("#mostViewArticleDisplayCount").val(preference.mostViewArticleDisplayCount),
$("#recentCommentDisplayCount").val(preference.recentCommentDisplayCount); $("#recentCommentDisplayCount").val(preference.recentCommentDisplayCount);
$("#mostUsedTagDisplayCount").val(preference.mostUsedTagDisplayCount); $("#mostUsedTagDisplayCount").val(preference.mostUsedTagDisplayCount);
$("#articleListDisplayCount").val(preference.articleListDisplayCount); $("#articleListDisplayCount").val(preference.articleListDisplayCount);
$("#articleListPaginationWindowSize").val(preference.articleListPaginationWindowSize); $("#articleListPaginationWindowSize").val(preference.articleListPaginationWindowSize);
$("#localeString").val(preference.localeString); $("#localeString").val(preference.localeString);
$("#timeZoneId").val(preference.timeZoneId); $("#timeZoneId").val(preference.timeZoneId);
$("#noticeBoard").val(preference.noticeBoard); $("#noticeBoard").val(preference.noticeBoard);
$("#htmlHead").val(preference.htmlHead); $("#htmlHead").val(preference.htmlHead);
$("#externalRelevantArticlesDisplayCount").val(preference.externalRelevantArticlesDisplayCount); $("#externalRelevantArticlesDisplayCount").val(preference.externalRelevantArticlesDisplayCount);
$("#relevantArticlesDisplayCount").val(preference.relevantArticlesDisplayCount); $("#relevantArticlesDisplayCount").val(preference.relevantArticlesDisplayCount);
$("#randomArticlesDisplayCount").val(preference.randomArticlesDisplayCount); $("#randomArticlesDisplayCount").val(preference.randomArticlesDisplayCount);
$("#keyOfSolo").val(preference.keyOfSolo); $("#keyOfSolo").val(preference.keyOfSolo);
preference.enableArticleUpdateHint ? $("#enableArticleUpdateHint").attr("checked", "checked") : $("#enableArticleUpdateHint").removeAttr("checked"); preference.enableArticleUpdateHint ? $("#enableArticleUpdateHint").attr("checked", "checked") : $("#enableArticleUpdateHint").removeAttr("checked");
preference.allowVisitDraftViaPermalink ? $("#allowVisitDraftViaPermalink").attr("checked", "checked") : $("allowVisitDraftViaPermalink").removeAttr("checked"); preference.allowVisitDraftViaPermalink ? $("#allowVisitDraftViaPermalink").attr("checked", "checked") : $("allowVisitDraftViaPermalink").removeAttr("checked");
admin.preference.locale = preference.localeString; admin.preference.locale = preference.localeString;
admin.preference.editorType = preference.editorType; admin.preference.editorType = preference.editorType;
// skin // skin
$("#skinMain").data("skinDirName", preference.skinDirName); $("#skinMain").data("skinDirName", preference.skinDirName);
var skins = eval('(' + preference.skins + ')'); var skins = eval('(' + preference.skins + ')');
var skinsHTML = ""; var skinsHTML = "";
for (var i = 0; i < skins.length; i++) { for (var i = 0; i < skins.length; i++) {
var selectedClass = ""; var selectedClass = "";
if (skins[i].skinName === preference.skinName if (skins[i].skinName === preference.skinName
&& skins[i].skinDirName === preference.skinDirName) { && skins[i].skinDirName === preference.skinDirName) {
selectedClass += " selected"; selectedClass += " selected";
} }
skinsHTML += "<div title='" + skins[i].skinDirName skinsHTML += "<div title='" + skins[i].skinDirName
+ "' class='left skinItem" + selectedClass + "'><img class='skinPreview' src='" + "' class='left skinItem" + selectedClass + "'><img class='skinPreview' src='"
+ latkeConfig.staticServePath + "/skins/" + skins[i].skinDirName + latkeConfig.staticServePath + "/skins/" + skins[i].skinDirName
+ "/preview.png'/><div>" + skins[i].skinName + "</div></div>"; + "/preview.png'/><div>" + skins[i].skinName + "</div></div>";
} }
$("#skinMain").append(skinsHTML + "<div class='clear'></div>"); $("#skinMain").append(skinsHTML + "<div class='clear'></div>");
$(".skinItem").click(function () { $(".skinItem").click(function () {
$(".skinItem").removeClass("selected"); $(".skinItem").removeClass("selected");
$(this).addClass("selected"); $(this).addClass("selected");
$("#skinMain").data("skinDirName", this.title); $("#skinMain").data("skinDirName", this.title);
}); });
// sign // sign
var signs = eval('(' + preference.signs + ')'); var signs = eval('(' + preference.signs + ')');
for (var j = 1; j < signs.length; j++) { for (var j = 1; j < signs.length; j++) {
$("#preferenceSign" + j).val(signs[j].signHTML); $("#preferenceSign" + j).val(signs[j].signHTML);
$("#preferenceSignButton" + j).tip({ $("#preferenceSignButton" + j).tip({
content: signs[j].signHTML === "" ? Label.signIsNullLabel : signs[j].signHTML.replace(/\n/g, "").replace(/<script.*<\/script>/ig, ""), content: signs[j].signHTML === "" ? Label.signIsNullLabel : signs[j].signHTML.replace(/\n/g, "").replace(/<script.*<\/script>/ig, ""),
position: "bottom" position: "bottom"
}); });
} }
// Article list style // Article list style
$("#articleListDisplay").val(preference.articleListStyle); $("#articleListDisplay").val(preference.articleListStyle);
// Editor Type // Editor Type
$("#editorType").val(preference.editorType); $("#editorType").val(preference.editorType);
// Feed output // Feed output
$("#feedOutputMode").val(preference.feedOutputMode); $("#feedOutputMode").val(preference.feedOutputMode);
$("#feedOutputCnt").val(preference.feedOutputCnt); $("#feedOutputCnt").val(preference.feedOutputCnt);
// Commentable // Commentable
preference.commentable ? $("#commentable").attr("checked", "checked") : $("commentable").removeAttr("checked"); preference.commentable ? $("#commentable").attr("checked", "checked") : $("commentable").removeAttr("checked");
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
}); });
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/preference/qiniu", url: latkeConfig.servePath + "/console/preference/qiniu",
type: "GET", type: "GET",
cache: false, cache: false,
success: function (result, textStatus) { success: function (result, textStatus) {
$("#tipMsg").text(result.msg); $("#tipMsg").text(result.msg);
if (!result.sc) { if (!result.sc) {
$("#loadMsg").text(""); $("#loadMsg").text("");
return; return;
} }
$("#qiniuAccessKey").val(result.qiniu.qiniuAccessKey); $("#qiniuAccessKey").val(result.qiniu.qiniuAccessKey);
$("#qiniuSecretKey").val(result.qiniu.qiniuSecretKey); $("#qiniuSecretKey").val(result.qiniu.qiniuSecretKey);
$("#qiniuDomain").val(result.qiniu.qiniuDomain); $("#qiniuDomain").val(result.qiniu.qiniuDomain);
$("#qiniuBucket").val(result.qiniu.qiniuBucket); $("#qiniuBucket").val(result.qiniu.qiniuBucket);
} }
}); });
}, },
/* /*
* @description 参数校验 * @description 参数校验
*/ */
validate: function () { validate: function () {
if (!/^\d+$/.test($("#mostUsedTagDisplayCount").val())) { if (!/^\d+$/.test($("#mostUsedTagDisplayCount").val())) {
$("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.indexTagDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel); $("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.indexTagDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel);
$("#mostUsedTagDisplayCount").focus(); $("#mostUsedTagDisplayCount").focus();
return false; return false;
} else if (!/^\d+$/.test($("#recentCommentDisplayCount").val())) { } else if (!/^\d+$/.test($("#recentCommentDisplayCount").val())) {
$("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.indexRecentCommentDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel); $("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.indexRecentCommentDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel);
$("#recentCommentDisplayCount").focus(); $("#recentCommentDisplayCount").focus();
return false; return false;
} else if (!/^\d+$/.test($("#mostCommentArticleDisplayCount").val())) { } else if (!/^\d+$/.test($("#mostCommentArticleDisplayCount").val())) {
$("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.indexMostCommentArticleDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel); $("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.indexMostCommentArticleDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel);
$("#mostCommentArticleDisplayCount").focus(); $("#mostCommentArticleDisplayCount").focus();
return false; return false;
} else if (!/^\d+$/.test($("#mostViewArticleDisplayCount").val())) { } else if (!/^\d+$/.test($("#mostViewArticleDisplayCount").val())) {
$("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.indexMostViewArticleDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel); $("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.indexMostViewArticleDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel);
$("#mostViewArticleDisplayCount").focus(); $("#mostViewArticleDisplayCount").focus();
return false; return false;
} else if (!/^\d+$/.test($("#articleListDisplayCount").val())) { } else if (!/^\d+$/.test($("#articleListDisplayCount").val())) {
$("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.pageSizeLabel + "] " + Label.nonNegativeIntegerOnlyLabel); $("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.pageSizeLabel + "] " + Label.nonNegativeIntegerOnlyLabel);
$("#articleListDisplayCount").focus(); $("#articleListDisplayCount").focus();
return false; return false;
} else if (!/^\d+$/.test($("#articleListPaginationWindowSize").val())) { } else if (!/^\d+$/.test($("#articleListPaginationWindowSize").val())) {
$("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.windowSizeLabel + "] " + Label.nonNegativeIntegerOnlyLabel); $("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.windowSizeLabel + "] " + Label.nonNegativeIntegerOnlyLabel);
$("#articleListPaginationWindowSize").focus(); $("#articleListPaginationWindowSize").focus();
return false; return false;
} else if (!/^\d+$/.test($("#randomArticlesDisplayCount").val())) { } else if (!/^\d+$/.test($("#randomArticlesDisplayCount").val())) {
$("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.randomArticlesDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel); $("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.randomArticlesDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel);
$("#randomArticlesDisplayCount").focus(); $("#randomArticlesDisplayCount").focus();
return false; return false;
} else if (!/^\d+$/.test($("#relevantArticlesDisplayCount").val())) { } else if (!/^\d+$/.test($("#relevantArticlesDisplayCount").val())) {
$("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.relevantArticlesDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel); $("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.relevantArticlesDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel);
$("#relevantArticlesDisplayCount").focus(); $("#relevantArticlesDisplayCount").focus();
return false; return false;
} else if (!/^\d+$/.test($("#externalRelevantArticlesDisplayCount").val())) { } else if (!/^\d+$/.test($("#externalRelevantArticlesDisplayCount").val())) {
$("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.externalRelevantArticlesDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel); $("#tipMsg").text("[" + Label.paramSettingsLabel + " - " + Label.externalRelevantArticlesDisplayCntLabel + "] " + Label.nonNegativeIntegerOnlyLabel);
$("#externalRelevantArticlesDisplayCount").focus(); $("#externalRelevantArticlesDisplayCount").focus();
return false; return false;
} }
return true; return true;
}, },
/* /*
* @description 更新 * @description 更新
*/ */
update: function () { update: function () {
if (!admin.preference.validate()) { if (!admin.preference.validate()) {
return; return;
} }
$("#tipMsg").text(""); $("#tipMsg").text("");
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
var signs = [{ var signs = [{
"oId": 0, "oId": 0,
"signHTML": "" "signHTML": ""
}, { }, {
"oId": 1, "oId": 1,
"signHTML": $("#preferenceSign1").val() "signHTML": $("#preferenceSign1").val()
}, { }, {
"oId": 2, "oId": 2,
"signHTML": $("#preferenceSign2").val() "signHTML": $("#preferenceSign2").val()
}, { }, {
"oId": 3, "oId": 3,
"signHTML": $("#preferenceSign3").val() "signHTML": $("#preferenceSign3").val()
}]; }];
var requestJSONObject = { var requestJSONObject = {
"preference": { "preference": {
"metaKeywords": $("#metaKeywords").val(), "metaKeywords": $("#metaKeywords").val(),
"metaDescription": $("#metaDescription").val(), "metaDescription": $("#metaDescription").val(),
"blogTitle": $("#blogTitle").val(), "blogTitle": $("#blogTitle").val(),
"blogSubtitle": $("#blogSubtitle").val(), "blogSubtitle": $("#blogSubtitle").val(),
"mostCommentArticleDisplayCount": $("#mostCommentArticleDisplayCount").val(), "mostCommentArticleDisplayCount": $("#mostCommentArticleDisplayCount").val(),
"mostViewArticleDisplayCount": $("#mostViewArticleDisplayCount").val(), "mostViewArticleDisplayCount": $("#mostViewArticleDisplayCount").val(),
"recentCommentDisplayCount": $("#recentCommentDisplayCount").val(), "recentCommentDisplayCount": $("#recentCommentDisplayCount").val(),
"mostUsedTagDisplayCount": $("#mostUsedTagDisplayCount").val(), "mostUsedTagDisplayCount": $("#mostUsedTagDisplayCount").val(),
"articleListDisplayCount": $("#articleListDisplayCount").val(), "articleListDisplayCount": $("#articleListDisplayCount").val(),
"articleListPaginationWindowSize": $("#articleListPaginationWindowSize").val(), "articleListPaginationWindowSize": $("#articleListPaginationWindowSize").val(),
"skinDirName": $("#skinMain").data("skinDirName"), "skinDirName": $("#skinMain").data("skinDirName"),
"localeString": $("#localeString").val(), "localeString": $("#localeString").val(),
"timeZoneId": $("#timeZoneId").val(), "timeZoneId": $("#timeZoneId").val(),
"noticeBoard": $("#noticeBoard").val(), "noticeBoard": $("#noticeBoard").val(),
"htmlHead": $("#htmlHead").val(), "htmlHead": $("#htmlHead").val(),
"externalRelevantArticlesDisplayCount": $("#externalRelevantArticlesDisplayCount").val(), "externalRelevantArticlesDisplayCount": $("#externalRelevantArticlesDisplayCount").val(),
"relevantArticlesDisplayCount": $("#relevantArticlesDisplayCount").val(), "relevantArticlesDisplayCount": $("#relevantArticlesDisplayCount").val(),
"randomArticlesDisplayCount": $("#randomArticlesDisplayCount").val(), "randomArticlesDisplayCount": $("#randomArticlesDisplayCount").val(),
"enableArticleUpdateHint": $("#enableArticleUpdateHint").prop("checked"), "enableArticleUpdateHint": $("#enableArticleUpdateHint").prop("checked"),
"signs": signs, "signs": signs,
"keyOfSolo": $("#keyOfSolo").val(), "keyOfSolo": $("#keyOfSolo").val(),
"allowVisitDraftViaPermalink": $("#allowVisitDraftViaPermalink").prop("checked"), "allowVisitDraftViaPermalink": $("#allowVisitDraftViaPermalink").prop("checked"),
"articleListStyle": $("#articleListDisplay").val(), "articleListStyle": $("#articleListDisplay").val(),
"editorType": $("#editorType").val(), "editorType": $("#editorType").val(),
"feedOutputMode": $("#feedOutputMode").val(), "feedOutputMode": $("#feedOutputMode").val(),
"feedOutputCnt": $("#feedOutputCnt").val(), "feedOutputCnt": $("#feedOutputCnt").val(),
"commentable": $("#commentable").prop("checked") "commentable": $("#commentable").prop("checked")
} }
}; };
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/preference/", url: latkeConfig.servePath + "/console/preference/",
type: "PUT", type: "PUT",
cache: false, cache: false,
data: JSON.stringify(requestJSONObject), data: JSON.stringify(requestJSONObject),
success: function (result, textStatus) { success: function (result, textStatus) {
$("#tipMsg").text(result.msg); $("#tipMsg").text(result.msg);
if (!result.sc) { if (!result.sc) {
$("#loadMsg").text(""); $("#loadMsg").text("");
return; return;
} }
if ($("#localeString").val() !== admin.preference.locale || if ($("#localeString").val() !== admin.preference.locale ||
$("#editorType").val() !== admin.preference.editorType) { $("#editorType").val() !== admin.preference.editorType) {
window.location.reload(); window.location.reload();
} }
// update article and preferences signs // update article and preferences signs
for (var i = 1; i < signs.length; i++) { for (var i = 1; i < signs.length; i++) {
if ($("#articleSign" + signs[i].oId).length === 1) { if ($("#articleSign" + signs[i].oId).length === 1) {
$("#articleSign" + signs[i].oId).tip("option", "content", $("#articleSign" + signs[i].oId).tip("option", "content",
signs[i].signHTML === "" ? Label.signIsNullLabel : signs[i].signHTML.replace(/\n/g, "").replace(/<script.*<\/script>/ig, "")); signs[i].signHTML === "" ? Label.signIsNullLabel : signs[i].signHTML.replace(/\n/g, "").replace(/<script.*<\/script>/ig, ""));
} }
$("#preferenceSignButton" + signs[i].oId).tip("option", "content", $("#preferenceSignButton" + signs[i].oId).tip("option", "content",
signs[i].signHTML === "" ? Label.signIsNullLabel : signs[i].signHTML.replace(/\n/g, "").replace(/<script.*<\/script>/ig, "")); signs[i].signHTML === "" ? Label.signIsNullLabel : signs[i].signHTML.replace(/\n/g, "").replace(/<script.*<\/script>/ig, ""));
} }
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
}); });
}, },
/* /*
* @description 更新 Qiniu 参数 * @description 更新 Qiniu 参数
*/ */
updateQiniu: function () { updateQiniu: function () {
$("#tipMsg").text(""); $("#tipMsg").text("");
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
var requestJSONObject = { var requestJSONObject = {
"qiniuAccessKey": $("#qiniuAccessKey").val(), "qiniuAccessKey": $("#qiniuAccessKey").val(),
"qiniuSecretKey": $("#qiniuSecretKey").val(), "qiniuSecretKey": $("#qiniuSecretKey").val(),
"qiniuDomain": $("#qiniuDomain").val(), "qiniuDomain": $("#qiniuDomain").val(),
"qiniuBucket": $("#qiniuBucket").val() "qiniuBucket": $("#qiniuBucket").val()
}; };
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/preference/qiniu", url: latkeConfig.servePath + "/console/preference/qiniu",
type: "PUT", type: "PUT",
cache: false, cache: false,
data: JSON.stringify(requestJSONObject), data: JSON.stringify(requestJSONObject),
success: function (result, textStatus) { success: function (result, textStatus) {
$("#tipMsg").text(result.msg); $("#tipMsg").text(result.msg);
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
}); });
} }
}; };
/* /*
* 注册到 admin 进行管理 * 注册到 admin 进行管理
*/ */
admin.register["preference"] = { admin.register["preference"] = {
"obj": admin.preference, "obj": admin.preference,
"init": admin.preference.init, "init": admin.preference.init,
"refresh": function () { "refresh": function () {
admin.clearTip(); admin.clearTip();
} }
}; };
/* /*
* Copyright (c) 2010-2015, b3log.org * Copyright (c) 2010-2015, b3log.org
* *
...@@ -3293,365 +3293,365 @@ admin.register["plugin-list"] = { ...@@ -3293,365 +3293,365 @@ admin.register["plugin-list"] = {
admin.claerTip(); admin.claerTip();
} }
}; };
/* /*
* Copyright (c) 2010-2015, b3log.org * Copyright (c) 2010-2015, b3log.org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/** /**
* user list for admin * user list for admin
* *
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a> * @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.1.7, May 28, 2013 * @version 1.0.1.7, May 28, 2013
*/ */
/* user-list 相关操作 */ /* user-list 相关操作 */
admin.userList = { admin.userList = {
tablePagination: new TablePaginate("user"), tablePagination: new TablePaginate("user"),
pageInfo: { pageInfo: {
currentCount: 1, currentCount: 1,
pageCount: 1, pageCount: 1,
currentPage: 1 currentPage: 1
}, },
userInfo: { userInfo: {
'oId': "", 'oId': "",
"userRole": "" "userRole": ""
}, },
/* /*
* 初始化 table, pagination * 初始化 table, pagination
*/ */
init: function(page) { init: function(page) {
this.tablePagination.buildTable([{ this.tablePagination.buildTable([{
style: "padding-left: 12px;", style: "padding-left: 12px;",
text: Label.commentNameLabel, text: Label.commentNameLabel,
index: "userName", index: "userName",
width: 230 width: 230
}, { }, {
style: "padding-left: 12px;", style: "padding-left: 12px;",
text: Label.commentEmailLabel, text: Label.commentEmailLabel,
index: "userEmail", index: "userEmail",
minWidth: 180 minWidth: 180
}, { }, {
style: "padding-left: 12px;", style: "padding-left: 12px;",
text: Label.roleLabel, text: Label.roleLabel,
index: "isAdmin", index: "isAdmin",
width: 120 width: 120
}]); }]);
this.tablePagination.initPagination(); this.tablePagination.initPagination();
this.getList(page); this.getList(page);
$("#userUpdate").dialog({ $("#userUpdate").dialog({
width: 700, width: 700,
height: 230, height: 230,
"modal": true, "modal": true,
"hideFooter": true "hideFooter": true
}); });
}, },
/* /*
* 根据当前页码获取列表 * 根据当前页码获取列表
* @pagNum 当前页码 * @pagNum 当前页码
*/ */
getList: function(pageNum) { getList: function(pageNum) {
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text(""); $("#tipMsg").text("");
this.pageInfo.currentPage = pageNum; this.pageInfo.currentPage = pageNum;
var that = this; var that = this;
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/users/" + pageNum + "/" + Label.PAGE_SIZE + "/" + Label.WINDOW_SIZE, url: latkeConfig.servePath + "/console/users/" + pageNum + "/" + Label.PAGE_SIZE + "/" + Label.WINDOW_SIZE,
type: "GET", type: "GET",
cache: false, cache: false,
success: function(result, textStatus) { success: function(result, textStatus) {
$("#tipMsg").text(result.msg); $("#tipMsg").text(result.msg);
if (!result.sc) { if (!result.sc) {
$("#loadMsg").text(""); $("#loadMsg").text("");
return; return;
} }
var users = result.users; var users = result.users;
var userData = []; var userData = [];
admin.userList.pageInfo.currentCount = users.length; admin.userList.pageInfo.currentCount = users.length;
admin.userList.pageInfo.pageCount = result.pagination.paginationPageCount; admin.userList.pageInfo.pageCount = result.pagination.paginationPageCount;
if (users.length < 1) { if (users.length < 1) {
$("#tipMsg").text("No user " + Label.reportIssueLabel); $("#tipMsg").text("No user " + Label.reportIssueLabel);
$("#loadMsg").text(""); $("#loadMsg").text("");
return; return;
} }
for (var i = 0; i < users.length; i++) { for (var i = 0; i < users.length; i++) {
userData[i] = {}; userData[i] = {};
userData[i].userName = users[i].userName; userData[i].userName = users[i].userName;
userData[i].userEmail = users[i].userEmail; userData[i].userEmail = users[i].userEmail;
if ("adminRole" === users[i].userRole) { if ("adminRole" === users[i].userRole) {
userData[i].isAdmin = "&nbsp;" + Label.administratorLabel; userData[i].isAdmin = "&nbsp;" + Label.administratorLabel;
userData[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.userList.get('" + userData[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.userList.get('" +
users[i].oId + "', '" + users[i].userRole + "')\">" + Label.updateLabel + "</a>"; users[i].oId + "', '" + users[i].userRole + "')\">" + Label.updateLabel + "</a>";
} else { } else {
userData[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.userList.get('" + userData[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.userList.get('" +
users[i].oId + "', '" + users[i].userRole + "')\">" + Label.updateLabel + "</a>\ users[i].oId + "', '" + users[i].userRole + "')\">" + Label.updateLabel + "</a>\
<a href='javascript:void(0)' onclick=\"admin.userList.del('" + users[i].oId + "', '" + users[i].userName + "')\">" + Label.removeLabel + "</a>" + <a href='javascript:void(0)' onclick=\"admin.userList.del('" + users[i].oId + "', '" + users[i].userName + "')\">" + Label.removeLabel + "</a>" +
"<a href='javascript:void(0)' onclick=\"admin.userList.changeRole('" + users[i].oId + "')\">" + Label.changeRoleLabel + "</a>"; "<a href='javascript:void(0)' onclick=\"admin.userList.changeRole('" + users[i].oId + "')\">" + Label.changeRoleLabel + "</a>";
if ("defaultRole" === users[i].userRole) { if ("defaultRole" === users[i].userRole) {
userData[i].isAdmin = Label.commonUserLabel; userData[i].isAdmin = Label.commonUserLabel;
} }
else { else {
userData[i].isAdmin = Label.visitorUserLabel; userData[i].isAdmin = Label.visitorUserLabel;
} }
} }
that.tablePagination.updateTablePagination(userData, pageNum, result.pagination); that.tablePagination.updateTablePagination(userData, pageNum, result.pagination);
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
} }
}); });
}, },
/* /*
* 添加用户 * 添加用户
*/ */
add: function() { add: function() {
if (this.validate()) { if (this.validate()) {
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text(""); $("#tipMsg").text("");
var requestJSONObject = { var requestJSONObject = {
"userName": $("#userName").val(), "userName": $("#userName").val(),
"userEmail": $("#userEmail").val(), "userEmail": $("#userEmail").val(),
"userURL": $("#userURL").val(), "userURL": $("#userURL").val(),
"userPassword": $("#userPassword").val() "userPassword": $("#userPassword").val()
}; };
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/user/", url: latkeConfig.servePath + "/console/user/",
type: "POST", type: "POST",
cache: false, cache: false,
data: JSON.stringify(requestJSONObject), data: JSON.stringify(requestJSONObject),
success: function(result, textStatus) { success: function(result, textStatus) {
$("#tipMsg").text(result.msg); $("#tipMsg").text(result.msg);
if (!result.sc) { if (!result.sc) {
$("#loadMsg").text(""); $("#loadMsg").text("");
return; return;
} }
$("#userName").val(""); $("#userName").val("");
$("#userEmail").val(""); $("#userEmail").val("");
$("#userURL").val(""); $("#userURL").val("");
$("#userPassword").val(""); $("#userPassword").val("");
if (admin.userList.pageInfo.currentCount === Label.PAGE_SIZE && if (admin.userList.pageInfo.currentCount === Label.PAGE_SIZE &&
admin.userList.pageInfo.currentPage === admin.userList.pageInfo.pageCount) { admin.userList.pageInfo.currentPage === admin.userList.pageInfo.pageCount) {
admin.userList.pageInfo.pageCount++; admin.userList.pageInfo.pageCount++;
} }
var hashList = window.location.hash.split("/"); var hashList = window.location.hash.split("/");
if (admin.userList.pageInfo.pageCount !== parseInt(hashList[hashList.length - 1])) { if (admin.userList.pageInfo.pageCount !== parseInt(hashList[hashList.length - 1])) {
admin.setHashByPage(admin.userList.pageInfo.pageCount); admin.setHashByPage(admin.userList.pageInfo.pageCount);
} }
admin.userList.getList(admin.userList.pageInfo.pageCount); admin.userList.getList(admin.userList.pageInfo.pageCount);
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
}); });
} }
}, },
/* /*
* 获取用户 * 获取用户
* @id 用户 id * @id 用户 id
*/ */
get: function(id, userRole) { get: function(id, userRole) {
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text(""); $("#tipMsg").text("");
$("#userUpdate").dialog("open"); $("#userUpdate").dialog("open");
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/user/" + id, url: latkeConfig.servePath + "/console/user/" + id,
type: "GET", type: "GET",
cache: false, cache: false,
success: function(result, textStatus) { success: function(result, textStatus) {
$("#tipMsg").text(result.msg); $("#tipMsg").text(result.msg);
if (!result.sc) { if (!result.sc) {
$("#loadMsg").text(""); $("#loadMsg").text("");
return; return;
} }
var $userEmailUpdate = $("#userEmailUpdate"); var $userEmailUpdate = $("#userEmailUpdate");
$("#userNameUpdate").val(result.user.userName).data("userInfo", { $("#userNameUpdate").val(result.user.userName).data("userInfo", {
'oId': id, 'oId': id,
"userRole": userRole "userRole": userRole
}); });
$userEmailUpdate.val(result.user.userEmail); $userEmailUpdate.val(result.user.userEmail);
if ("adminRole" === userRole) { if ("adminRole" === userRole) {
$userEmailUpdate.attr("disabled", "disabled"); $userEmailUpdate.attr("disabled", "disabled");
} else { } else {
$userEmailUpdate.removeAttr("disabled"); $userEmailUpdate.removeAttr("disabled");
} }
$("#userURLUpdate").val(result.user.userURL); $("#userURLUpdate").val(result.user.userURL);
$("#userPasswordUpdate").val(result.user.userPassword); $("#userPasswordUpdate").val(result.user.userPassword);
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
}); });
}, },
/* /*
* 更新用户 * 更新用户
*/ */
update: function() { update: function() {
if (this.validate("Update")) { if (this.validate("Update")) {
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text(""); $("#tipMsg").text("");
var userInfo = $("#userNameUpdate").data("userInfo"); var userInfo = $("#userNameUpdate").data("userInfo");
var requestJSONObject = { var requestJSONObject = {
"userName": $("#userNameUpdate").val(), "userName": $("#userNameUpdate").val(),
"oId": userInfo.oId, "oId": userInfo.oId,
"userEmail": $("#userEmailUpdate").val(), "userEmail": $("#userEmailUpdate").val(),
"userURL": $("#userURLUpdate").val(), "userURL": $("#userURLUpdate").val(),
"userRole": userInfo.userRole, "userRole": userInfo.userRole,
"userPassword": $("#userPasswordUpdate").val() "userPassword": $("#userPasswordUpdate").val()
}; };
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/user/", url: latkeConfig.servePath + "/console/user/",
type: "PUT", type: "PUT",
cache: false, cache: false,
data: JSON.stringify(requestJSONObject), data: JSON.stringify(requestJSONObject),
success: function(result, textStatus) { success: function(result, textStatus) {
$("#userUpdate").dialog("close"); $("#userUpdate").dialog("close");
$("#tipMsg").text(result.msg); $("#tipMsg").text(result.msg);
if (!result.sc) { if (!result.sc) {
$("#loadMsg").text(""); $("#loadMsg").text("");
return; return;
} }
admin.userList.getList(admin.userList.pageInfo.currentPage); admin.userList.getList(admin.userList.pageInfo.currentPage);
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
}); });
} }
}, },
/* /*
* 删除用户 * 删除用户
* @id 用户 id * @id 用户 id
* @userName 用户名称 * @userName 用户名称
*/ */
del: function(id, userName) { del: function(id, userName) {
var isDelete = confirm(Label.confirmRemoveLabel + Label.userLabel + '"' + userName + '"?'); var isDelete = confirm(Label.confirmRemoveLabel + Label.userLabel + '"' + userName + '"?');
if (isDelete) { if (isDelete) {
$("#loadMsg").text(Label.loadingLabel); $("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text(""); $("#tipMsg").text("");
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/user/" + id, url: latkeConfig.servePath + "/console/user/" + id,
type: "DELETE", type: "DELETE",
cache: false, cache: false,
success: function(result, textStatus) { success: function(result, textStatus) {
$("#tipMsg").text(result.msg); $("#tipMsg").text(result.msg);
if (!result.sc) { if (!result.sc) {
$("#loadMsg").text(""); $("#loadMsg").text("");
return; return;
} }
var pageNum = admin.userList.pageInfo.currentPage; var pageNum = admin.userList.pageInfo.currentPage;
if (admin.userList.pageInfo.currentCount === 1 && admin.userList.pageInfo.pageCount !== 1 && if (admin.userList.pageInfo.currentCount === 1 && admin.userList.pageInfo.pageCount !== 1 &&
admin.userList.pageInfo.currentPage === admin.userList.pageInfo.pageCount) { admin.userList.pageInfo.currentPage === admin.userList.pageInfo.pageCount) {
admin.userList.pageInfo.pageCount--; admin.userList.pageInfo.pageCount--;
pageNum = admin.userList.pageInfo.pageCount; pageNum = admin.userList.pageInfo.pageCount;
} }
var hashList = window.location.hash.split("/"); var hashList = window.location.hash.split("/");
if (pageNum !== parseInt(hashList[hashList.length - 1])) { if (pageNum !== parseInt(hashList[hashList.length - 1])) {
admin.setHashByPage(pageNum); admin.setHashByPage(pageNum);
} }
admin.userList.getList(pageNum); admin.userList.getList(pageNum);
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
}); });
} }
}, },
/** /**
* 修改角色 * 修改角色
* @param id * @param id
*/ */
changeRole: function(id) { changeRole: function(id) {
$("#tipMsg").text(""); $("#tipMsg").text("");
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/changeRole/" + id, url: latkeConfig.servePath + "/console/changeRole/" + id,
type: "GET", type: "GET",
cache: false, cache: false,
success: function(result, textStatus) { success: function(result, textStatus) {
$("#tipMsg").text(result.msg); $("#tipMsg").text(result.msg);
if (!result.sc) { if (!result.sc) {
$("#loadMsg").text(""); $("#loadMsg").text("");
return; return;
} }
var pageNum = admin.userList.pageInfo.currentPage; var pageNum = admin.userList.pageInfo.currentPage;
if (admin.userList.pageInfo.currentCount === 1 && admin.userList.pageInfo.pageCount !== 1 && if (admin.userList.pageInfo.currentCount === 1 && admin.userList.pageInfo.pageCount !== 1 &&
admin.userList.pageInfo.currentPage === admin.userList.pageInfo.pageCount) { admin.userList.pageInfo.currentPage === admin.userList.pageInfo.pageCount) {
admin.userList.pageInfo.pageCount--; admin.userList.pageInfo.pageCount--;
pageNum = admin.userList.pageInfo.pageCount; pageNum = admin.userList.pageInfo.pageCount;
} }
var hashList = window.location.hash.split("/"); var hashList = window.location.hash.split("/");
if (pageNum !== parseInt(hashList[hashList.length - 1])) { if (pageNum !== parseInt(hashList[hashList.length - 1])) {
admin.setHashByPage(pageNum); admin.setHashByPage(pageNum);
} }
admin.userList.getList(pageNum); admin.userList.getList(pageNum);
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
}); });
}, },
/* /*
* 验证字段 * 验证字段
* @status 更新或者添加时进行验证 * @status 更新或者添加时进行验证
*/ */
validate: function(status) { validate: function(status) {
if (!status) { if (!status) {
status = ""; status = "";
} }
var userName = $("#userName" + status).val().replace(/(^\s*)|(\s*$)/g, ""); var userName = $("#userName" + status).val().replace(/(^\s*)|(\s*$)/g, "");
if (2 > userName.length || userName.length > 20) { if (2 > userName.length || userName.length > 20) {
$("#tipMsg").text(Label.nameTooLongLabel); $("#tipMsg").text(Label.nameTooLongLabel);
$("#userName" + status).focus(); $("#userName" + status).focus();
} else if ($("#userEmail" + status).val().replace(/\s/g, "") === "") { } else if ($("#userEmail" + status).val().replace(/\s/g, "") === "") {
$("#tipMsg").text(Label.mailCannotEmptyLabel); $("#tipMsg").text(Label.mailCannotEmptyLabel);
$("#userEmail" + status).focus(); $("#userEmail" + status).focus();
} else if (!/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test($("#userEmail" + status).val())) { } else if (!/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test($("#userEmail" + status).val())) {
$("#tipMsg").text(Label.mailInvalidLabel); $("#tipMsg").text(Label.mailInvalidLabel);
$("#userEmail" + status).focus(); $("#userEmail" + status).focus();
} else if ($("#userPassword" + status).val() === "") { } else if ($("#userPassword" + status).val() === "") {
$("#tipMsg").text(Label.passwordEmptyLabel); $("#tipMsg").text(Label.passwordEmptyLabel);
$("#userPassword" + status).focus(); $("#userPassword" + status).focus();
} else { } else {
return true; return true;
} }
return false; return false;
} }
}; };
/* /*
* 注册到 admin 进行管理 * 注册到 admin 进行管理
*/ */
admin.register["user-list"] = { admin.register["user-list"] = {
"obj": admin.userList, "obj": admin.userList,
"init": admin.userList.init, "init": admin.userList.init,
"refresh": function() { "refresh": function() {
admin.clearTip(); admin.clearTip();
} }
}/* }/*
* Copyright (c) 2010-2015, b3log.org * Copyright (c) 2010-2015, b3log.org
* *
......
/******************************************************************************* /*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet * KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net * Copyright (C) 2006-2011 kindsoft.net
* *
* @author Roddy <luolonghao@gmail.com> * @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/ * @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php * @licence http://www.kindsoft.net/license.php
*******************************************************************************/ *******************************************************************************/
KindEditor.plugin('image', function (K) { KindEditor.plugin('image', function(K) {
var self = this, name = 'image', var self = this, name = 'image',
allowImageUpload = K.undef(self.allowImageUpload, true), allowImageUpload = K.undef(self.allowImageUpload, true),
allowImageRemote = K.undef(self.allowImageRemote, true), formatUploadUrl = K.undef(self.formatUploadUrl, true),
formatUploadUrl = K.undef(self.formatUploadUrl, true), allowFileManager = K.undef(self.allowFileManager, false),
allowFileManager = K.undef(self.allowFileManager, false), uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php'),
uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php'), imageTabIndex = K.undef(self.imageTabIndex, 0),
imageTabIndex = K.undef(self.imageTabIndex, 0), imgPath = self.pluginsPath + 'image/images/',
imgPath = self.pluginsPath + 'image/images/', extraParams = K.undef(self.extraFileUploadParams, {}),
extraParams = K.undef(self.extraFileUploadParams, {}), filePostName = K.undef(self.filePostName, 'imgFile'),
filePostName = K.undef(self.filePostName, 'imgFile'), fillDescAfterUploadImage = K.undef(self.fillDescAfterUploadImage, false),
fillDescAfterUploadImage = K.undef(self.fillDescAfterUploadImage, false), lang = self.lang(name + '.');
lang = self.lang(name + '.');
self.plugin.imageDialog = function (options) { self.plugin.imageDialog = function(options) {
var imageUrl = options.imageUrl, var imageUrl = options.imageUrl,
imageWidth = K.undef(options.imageWidth, ''), imageWidth = K.undef(options.imageWidth, ''),
imageHeight = K.undef(options.imageHeight, ''), imageHeight = K.undef(options.imageHeight, ''),
imageTitle = K.undef(options.imageTitle, ''), imageTitle = K.undef(options.imageTitle, ''),
imageAlign = K.undef(options.imageAlign, ''), imageAlign = K.undef(options.imageAlign, ''),
showRemote = K.undef(options.showRemote, true), showRemote = K.undef(options.showRemote, true),
showLocal = K.undef(options.showLocal, true), showLocal = K.undef(options.showLocal, true),
tabIndex = K.undef(options.tabIndex, 0), tabIndex = K.undef(options.tabIndex, 0),
clickFn = options.clickFn; clickFn = options.clickFn;
var target = 'kindeditor_upload_iframe_' + new Date().getTime(); var target = 'kindeditor_upload_iframe_' + new Date().getTime();
var hiddenElements = []; var hiddenElements = [];
for (var k in extraParams) { for(var k in extraParams){
hiddenElements.push('<input type="hidden" name="' + k + '" value="' + extraParams[k] + '" />'); hiddenElements.push('<input type="hidden" name="' + k + '" value="' + extraParams[k] + '" />');
} }
var html = [ var html = [
'<div style="padding:20px;">', '<div style="padding:20px;">',
//tabs //tabs
'<div class="tabs"></div>', '<div class="tabs"></div>',
//remote image - start //remote image - start
'<div class="tab1" style="display:none;">', '<div class="tab1" style="display:none;">',
//url //url
'<div class="ke-dialog-row">', '<div class="ke-dialog-row">',
'<label for="remoteUrl" style="width:60px;">' + lang.remoteUrl + '</label>', '<label for="remoteUrl" style="width:60px;">' + lang.remoteUrl + '</label>',
'<input type="text" id="remoteUrl" class="ke-input-text" name="url" value="" style="width:200px;" /> &nbsp;', '<input type="text" id="remoteUrl" class="ke-input-text" name="url" value="" style="width:200px;" /> &nbsp;',
'<span class="ke-button-common ke-button-outer">', '<span class="ke-button-common ke-button-outer">',
'<input type="button" class="ke-button-common ke-button" name="viewServer" value="' + lang.viewServer + '" />', '<input type="button" class="ke-button-common ke-button" name="viewServer" value="' + lang.viewServer + '" />',
'</span>', '</span>',
'</div>', '</div>',
//size //size
'<div class="ke-dialog-row">', '<div class="ke-dialog-row">',
'<label for="remoteWidth" style="width:60px;">' + lang.size + '</label>', '<label for="remoteWidth" style="width:60px;">' + lang.size + '</label>',
lang.width + ' <input type="text" id="remoteWidth" class="ke-input-text ke-input-number" name="width" value="" maxlength="4" /> ', lang.width + ' <input type="text" id="remoteWidth" class="ke-input-text ke-input-number" name="width" value="" maxlength="4" /> ',
lang.height + ' <input type="text" class="ke-input-text ke-input-number" name="height" value="" maxlength="4" /> ', lang.height + ' <input type="text" class="ke-input-text ke-input-number" name="height" value="" maxlength="4" /> ',
'<img class="ke-refresh-btn" src="' + imgPath + 'refresh.png" width="16" height="16" alt="" style="cursor:pointer;" title="' + lang.resetSize + '" />', '<img class="ke-refresh-btn" src="' + imgPath + 'refresh.png" width="16" height="16" alt="" style="cursor:pointer;" title="' + lang.resetSize + '" />',
'</div>', '</div>',
//align //align
'<div class="ke-dialog-row">', '<div class="ke-dialog-row">',
'<label style="width:60px;">' + lang.align + '</label>', '<label style="width:60px;">' + lang.align + '</label>',
'<input type="radio" name="align" class="ke-inline-block" value="" checked="checked" /> <img name="defaultImg" src="' + imgPath + 'align_top.gif" width="23" height="25" alt="" />', '<input type="radio" name="align" class="ke-inline-block" value="" checked="checked" /> <img name="defaultImg" src="' + imgPath + 'align_top.gif" width="23" height="25" alt="" />',
' <input type="radio" name="align" class="ke-inline-block" value="left" /> <img name="leftImg" src="' + imgPath + 'align_left.gif" width="23" height="25" alt="" />', ' <input type="radio" name="align" class="ke-inline-block" value="left" /> <img name="leftImg" src="' + imgPath + 'align_left.gif" width="23" height="25" alt="" />',
' <input type="radio" name="align" class="ke-inline-block" value="right" /> <img name="rightImg" src="' + imgPath + 'align_right.gif" width="23" height="25" alt="" />', ' <input type="radio" name="align" class="ke-inline-block" value="right" /> <img name="rightImg" src="' + imgPath + 'align_right.gif" width="23" height="25" alt="" />',
'</div>', '</div>',
//title //title
'<div class="ke-dialog-row">', '<div class="ke-dialog-row">',
'<label for="remoteTitle" style="width:60px;">' + lang.imgTitle + '</label>', '<label for="remoteTitle" style="width:60px;">' + lang.imgTitle + '</label>',
'<input type="text" id="remoteTitle" class="ke-input-text" name="title" value="" style="width:200px;" />', '<input type="text" id="remoteTitle" class="ke-input-text" name="title" value="" style="width:200px;" />',
'</div>', '</div>',
'</div>', '</div>',
//remote image - end //remote image - end
//local upload - start //local upload - start
'<div class="tab2" style="display:none;">', '<div class="tab2">',
'<iframe name="' + target + '" style="display:none;"></iframe>', '<iframe name="' + target + '"></iframe>',
'<form class="ke-upload-area ke-form" method="post" enctype="multipart/form-data" target="' + target + '" action="' + K.addParam(uploadJson, 'dir=image') + '">', '<form class="ke-upload-area ke-form" method="post" enctype="multipart/form-data" target="' + target + '" action="' + K.addParam(uploadJson, 'dir=image') + '">',
//file //file
'<div class="ke-dialog-row">', '<div class="ke-dialog-row">',
hiddenElements.join(''), hiddenElements.join(''),
'<label style="width:60px;">' + lang.localUrl + '</label>', '<label style="width:60px;">' + lang.localUrl + '</label>',
'<input type="text" name="localUrl" class="ke-input-text" tabindex="-1" style="width:200px;" readonly="true" /> &nbsp;', '<input type="text" name="localUrl" class="ke-input-text" tabindex="-1" style="width:200px;" readonly="true" /> &nbsp;',
'<input type="button" class="ke-upload-button" value="' + lang.upload + '" />', '<input type="button" class="ke-upload-button" value="' + lang.upload + '" />',
'</div>', '</div>',
'</form>', '</form>',
'</div>', '</div>',
//local upload - end //local upload - end
'</div>' '</div>'
].join(''); ].join('');
var dialogWidth = showLocal || allowFileManager ? 450 : 400, var dialogWidth = showLocal || allowFileManager ? 450 : 400,
dialogHeight = showLocal && showRemote ? 300 : 250; dialogHeight = showLocal && showRemote ? 300 : 250;
var dialog = self.createDialog({ var dialog = self.createDialog({
name: name, name : name,
width: dialogWidth, width : dialogWidth,
height: dialogHeight, height : dialogHeight,
title: self.lang(name), title : self.lang(name),
body: html, body : html,
yesBtn: { yesBtn : {
name: self.lang('yes'), name : self.lang('yes'),
click: function (e) { click : function(e) {
// Bugfix: http://code.google.com/p/kindeditor/issues/detail?id=319 // Bugfix: http://code.google.com/p/kindeditor/issues/detail?id=319
if (dialog.isLoading) { if (dialog.isLoading) {
return; return;
} }
// insert local image // insert local image
if (showLocal && showRemote && tabs && tabs.selectedIndex === 1 || !showRemote) { if (showLocal && showRemote && tabs && tabs.selectedIndex === 1 || !showRemote) {
if (uploadbutton.fileBox.val() == '') { if (uploadbutton.fileBox.val() == '') {
alert(self.lang('pleaseSelectFile')); alert(self.lang('pleaseSelectFile'));
return; return;
} }
dialog.showLoading(self.lang('uploadLoading')); dialog.showLoading(self.lang('uploadLoading'));
uploadbutton.submit(); uploadbutton.submit();
localUrlBox.val(''); localUrlBox.val('');
return; return;
} }
// insert remote image // insert remote image
var url = K.trim(urlBox.val()), var url = K.trim(urlBox.val()),
width = widthBox.val(), width = widthBox.val(),
height = heightBox.val(), height = heightBox.val(),
title = titleBox.val(), title = titleBox.val(),
align = ''; align = '';
alignBox.each(function () { alignBox.each(function() {
if (this.checked) { if (this.checked) {
align = this.value; align = this.value;
return false; return false;
} }
}); });
if (url == 'http://' || K.invalidUrl(url)) { if (url == 'http://' || K.invalidUrl(url)) {
alert(self.lang('invalidUrl')); alert(self.lang('invalidUrl'));
urlBox[0].focus(); urlBox[0].focus();
return; return;
} }
if (!/^\d*$/.test(width)) { if (!/^\d*$/.test(width)) {
alert(self.lang('invalidWidth')); alert(self.lang('invalidWidth'));
widthBox[0].focus(); widthBox[0].focus();
return; return;
} }
if (!/^\d*$/.test(height)) { if (!/^\d*$/.test(height)) {
alert(self.lang('invalidHeight')); alert(self.lang('invalidHeight'));
heightBox[0].focus(); heightBox[0].focus();
return; return;
} }
clickFn.call(self, url, title, width, height, 0, align); clickFn.call(self, url, title, width, height, 0, align);
} }
}, },
beforeRemove: function () { beforeRemove : function() {
viewServerBtn.unbind(); viewServerBtn.unbind();
widthBox.unbind(); widthBox.unbind();
heightBox.unbind(); heightBox.unbind();
refreshBtn.unbind(); refreshBtn.unbind();
} }
}), }),
div = dialog.div; div = dialog.div;
var urlBox = K('[name="url"]', div), var urlBox = K('[name="url"]', div),
localUrlBox = K('[name="localUrl"]', div), localUrlBox = K('[name="localUrl"]', div),
viewServerBtn = K('[name="viewServer"]', div), viewServerBtn = K('[name="viewServer"]', div),
widthBox = K('.tab1 [name="width"]', div), widthBox = K('.tab1 [name="width"]', div),
heightBox = K('.tab1 [name="height"]', div), heightBox = K('.tab1 [name="height"]', div),
refreshBtn = K('.ke-refresh-btn', div), refreshBtn = K('.ke-refresh-btn', div),
titleBox = K('.tab1 [name="title"]', div), titleBox = K('.tab1 [name="title"]', div),
alignBox = K('.tab1 [name="align"]', div); alignBox = K('.tab1 [name="align"]', div);
var tabs; var tabs;
if (showRemote && showLocal) { if (showRemote && showLocal) {
tabs = K.tabs({ tabs = K.tabs({
src: K('.tabs', div), src : K('.tabs', div),
afterSelect: function (i) {} afterSelect : function(i) {}
}); });
tabs.add({ tabs.add({
title: lang.remoteImage, title : lang.remoteImage,
panel: K('.tab1', div) panel : K('.tab1', div)
}); });
tabs.add({ // tabs.add({
title: lang.localImage, // title : lang.localImage,
panel: K('.tab2', div) // panel : K('.tab2', div)
}); // });
tabs.select(tabIndex); tabs.select(tabIndex);
} else if (showRemote) { } else if (showRemote) {
K('.tab1', div).show(); K('.tab1', div).show();
} else if (showLocal) { } else if (showLocal) {
K('.tab2', div).show(); K('.tab2', div).show();
} }
var uploadbutton = K.uploadbutton({ var uploadbutton = K.uploadbutton({
button: K('.ke-upload-button', div)[0], button : K('.ke-upload-button', div)[0],
fieldName: filePostName, fieldName : filePostName,
form: K('.ke-form', div), url : K.addParam(uploadJson, 'dir=image'),
target: target, form : K('.ke-form', div),
width: 60, target : target,
afterUpload: function (data) { width: 60,
dialog.hideLoading(); afterUpload : function(data) {
if (data.error === 0) { dialog.hideLoading();
var url = data.url; if (data.error === 0) {
if (formatUploadUrl) { var url = data.url;
url = K.formatUrl(url, 'absolute'); if (formatUploadUrl) {
} url = K.formatUrl(url, 'absolute');
if (self.afterUpload) { }
self.afterUpload.call(self, url, data, name); if (self.afterUpload) {
} self.afterUpload.call(self, url, data, name);
if (!fillDescAfterUploadImage) { }
clickFn.call(self, url, data.title, data.width, data.height, data.border, data.align); if (!fillDescAfterUploadImage) {
} else { clickFn.call(self, url, data.title, data.width, data.height, data.border, data.align);
K(".ke-dialog-row #remoteUrl", div).val(url); } else {
K(".ke-tabs-li", div)[0].click(); K(".ke-dialog-row #remoteUrl", div).val(url);
K(".ke-refresh-btn", div).click(); K(".ke-tabs-li", div)[0].click();
} K(".ke-refresh-btn", div).click();
} else { }
alert(data.message); } else {
} alert(data.message);
}, }
afterError: function (html) { },
dialog.hideLoading(); afterError : function(html) {
self.errorDialog(html); dialog.hideLoading();
} self.errorDialog(html);
}); }
uploadbutton.fileBox.change(function (e) { });
localUrlBox.val(uploadbutton.fileBox.val()); uploadbutton.fileBox.change(function(e) {
}); localUrlBox.val(uploadbutton.fileBox.val());
if (allowFileManager) { });
viewServerBtn.click(function (e) { if (allowFileManager) {
self.loadPlugin('filemanager', function () { viewServerBtn.click(function(e) {
self.plugin.filemanagerDialog({ self.loadPlugin('filemanager', function() {
viewType: 'VIEW', self.plugin.filemanagerDialog({
dirName: 'image', viewType : 'VIEW',
clickFn: function (url, title) { dirName : 'image',
if (self.dialogs.length > 1) { clickFn : function(url, title) {
K('[name="url"]', div).val(url); if (self.dialogs.length > 1) {
if (self.afterSelectFile) { K('[name="url"]', div).val(url);
self.afterSelectFile.call(self, url); if (self.afterSelectFile) {
} self.afterSelectFile.call(self, url);
self.hideDialog(); }
} self.hideDialog();
} }
}); }
}); });
}); });
} else { });
viewServerBtn.hide(); } else {
} viewServerBtn.hide();
var originalWidth = 0, originalHeight = 0; }
function setSize(width, height) { var originalWidth = 0, originalHeight = 0;
widthBox.val(width); function setSize(width, height) {
heightBox.val(height); widthBox.val(width);
originalWidth = width; heightBox.val(height);
originalHeight = height; originalWidth = width;
} originalHeight = height;
refreshBtn.click(function (e) { }
var tempImg = K('<img src="' + urlBox.val() + '" />', document).css({ refreshBtn.click(function(e) {
position: 'absolute', var tempImg = K('<img src="' + urlBox.val() + '" />', document).css({
visibility: 'hidden', position : 'absolute',
top: 0, visibility : 'hidden',
left: '-1000px' top : 0,
}); left : '-1000px'
tempImg.bind('load', function () { });
setSize(tempImg.width(), tempImg.height()); tempImg.bind('load', function() {
tempImg.remove(); setSize(tempImg.width(), tempImg.height());
}); tempImg.remove();
K(document.body).append(tempImg); });
}); K(document.body).append(tempImg);
widthBox.change(function (e) { });
if (originalWidth > 0) { widthBox.change(function(e) {
heightBox.val(Math.round(originalHeight / originalWidth * parseInt(this.value, 10))); if (originalWidth > 0) {
} heightBox.val(Math.round(originalHeight / originalWidth * parseInt(this.value, 10)));
}); }
heightBox.change(function (e) { });
if (originalHeight > 0) { heightBox.change(function(e) {
widthBox.val(Math.round(originalWidth / originalHeight * parseInt(this.value, 10))); if (originalHeight > 0) {
} widthBox.val(Math.round(originalWidth / originalHeight * parseInt(this.value, 10)));
}); }
urlBox.val(options.imageUrl); });
setSize(options.imageWidth, options.imageHeight); urlBox.val(options.imageUrl);
titleBox.val(options.imageTitle); setSize(options.imageWidth, options.imageHeight);
alignBox.each(function () { titleBox.val(options.imageTitle);
if (this.value === options.imageAlign) { alignBox.each(function() {
this.checked = true; if (this.value === options.imageAlign) {
return false; this.checked = true;
} return false;
}); }
if (showRemote && tabIndex === 0) { });
urlBox[0].focus(); if (tabIndex === 0) {
urlBox[0].select(); urlBox[0].focus();
} urlBox[0].select();
return dialog; }
}; return dialog;
self.plugin.image = { };
edit: function () { self.plugin.image = {
var img = self.plugin.getSelectedImage(); edit : function() {
self.plugin.imageDialog({ var img = self.plugin.getSelectedImage();
imageUrl: img ? img.attr('data-ke-src') : 'http://', self.plugin.imageDialog({
imageWidth: img ? img.width() : '', imageUrl : img ? img.attr('data-ke-src') : 'http://',
imageHeight: img ? img.height() : '', imageWidth : img ? img.width() : '',
imageTitle: img ? img.attr('title') : '', imageHeight : img ? img.height() : '',
imageAlign: img ? img.attr('align') : '', imageTitle : img ? img.attr('title') : '',
showRemote: allowImageRemote, imageAlign : img ? img.attr('align') : '',
showLocal: allowImageUpload, showRemote : true,
tabIndex: img ? 0 : imageTabIndex, showLocal : allowImageUpload,
clickFn: function (url, title, width, height, border, align) { tabIndex: img ? 0 : imageTabIndex,
if (img) { clickFn : function(url, title, width, height, border, align) {
img.attr('src', url); self.exec('insertimage', url, title, width, height, border, align);
img.attr('data-ke-src', url); // Bugfix: [Firefox] 上传图片后,总是出现正在加载的样式,需要延迟执行hideDialog
img.attr('width', width); setTimeout(function() {
img.attr('height', height); self.hideDialog().focus();
img.attr('title', title); }, 0);
img.attr('align', align); }
img.attr('alt', title); });
} else { },
self.exec('insertimage', url, title, width, height, border, align); 'delete' : function() {
} var target = self.plugin.getSelectedImage();
// Bugfix: [Firefox] 上传图片后,总是出现正在加载的样式,需要延迟执行hideDialog if (target.parent().name == 'a') {
setTimeout(function () { target = target.parent();
self.hideDialog().focus(); }
}, 0); target.remove();
} }
}); };
}, self.clickToolbar(name, self.plugin.image.edit);
'delete': function () { });
var target = self.plugin.getSelectedImage();
if (target.parent().name == 'a') {
target = target.parent();
}
target.remove();
// [IE] 删除图片后立即点击图片按钮出错
self.addBookmark();
}
};
self.clickToolbar(name, self.plugin.image.edit);
});
\ No newline at end of file
...@@ -2,11 +2,6 @@ ...@@ -2,11 +2,6 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title>{#advimage_dlg.dialog_title}</title> <title>{#advimage_dlg.dialog_title}</title>
<script type="text/javascript" src="../../../jquery/jquery.min.js"></script>
<script type="text/javascript" src="../../../jquery/file-upload-9.10.1/vendor/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../../jquery/file-upload-9.10.1/jquery.iframe-transport.js"></script>
<script type="text/javascript" src="../../../jquery/file-upload-9.10.1/jquery.fileupload.js"></script>
<script type="text/javascript" src="../../../jquery/file-upload-9.10.1/jquery.fileupload-process.js"></script>
<script type="text/javascript" src="../../tiny_mce_popup.js"></script> <script type="text/javascript" src="../../tiny_mce_popup.js"></script>
<script type="text/javascript" src="../../utils/mctabs.js"></script> <script type="text/javascript" src="../../utils/mctabs.js"></script>
<script type="text/javascript" src="../../utils/form_utils.js"></script> <script type="text/javascript" src="../../utils/form_utils.js"></script>
...@@ -35,7 +30,7 @@ ...@@ -35,7 +30,7 @@
<table role="presentation" class="properties"> <table role="presentation" class="properties">
<tr> <tr>
<td class="column1"><label id="srclabel" for="src">{#advimage_dlg.src}</label></td> <td class="column1"><label id="srclabel" for="src">{#advimage_dlg.src}</label></td>
<td> <td colspan="2">
<table role="presentation" border="0" cellspacing="0" cellpadding="0"> <table role="presentation" border="0" cellspacing="0" cellpadding="0">
<tr> <tr>
<td><input name="src" type="text" id="src" value="" class="mceFocus" onchange="ImageDialog.showPreviewImage(this.value);" aria-required="true" /></td> <td><input name="src" type="text" id="src" value="" class="mceFocus" onchange="ImageDialog.showPreviewImage(this.value);" aria-required="true" /></td>
...@@ -43,13 +38,6 @@ ...@@ -43,13 +38,6 @@
</tr> </tr>
</table> </table>
</td> </td>
<td>
<label>
Upload
<input type="file" style="width: 1px;opacity: .001;" id="imageUpload"
accept="image/gif, image/jpeg, image/png" />
</label>
</td>
</tr> </tr>
<tr> <tr>
<td><label for="src_list">{#advimage_dlg.image_list}</label></td> <td><label for="src_list">{#advimage_dlg.image_list}</label></td>
......
...@@ -6,8 +6,6 @@ var ImageDialog = { ...@@ -6,8 +6,6 @@ var ImageDialog = {
if (url = tinyMCEPopup.getParam("external_image_list_url")) if (url = tinyMCEPopup.getParam("external_image_list_url"))
document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>'); document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
ImageDialog.uploadImage();
}, },
init: function (ed) { init: function (ed) {
var f = document.forms[0], nl = f.elements, ed = tinyMCEPopup.editor, dom = ed.dom, n = ed.selection.getNode(), fl = tinyMCEPopup.getParam('external_image_list', 'tinyMCEImageList'); var f = document.forms[0], nl = f.elements, ed = tinyMCEPopup.editor, dom = ed.dom, n = ed.selection.getNode(), fl = tinyMCEPopup.getParam('external_image_list', 'tinyMCEImageList');
...@@ -476,49 +474,6 @@ var ImageDialog = { ...@@ -476,49 +474,6 @@ var ImageDialog = {
}, },
changeMouseMove: function () { changeMouseMove: function () {
}, },
uploadImage: function () {
$(function () {
var qiniu = window.parent.qiniu;
console.log(qiniu);
$('#imageUpload').fileupload({
multipart: true,
pasteZone: null,
dropZone: null,
url: "http://upload.qiniu.com/",
formData: function (form) {
var data = form.serializeArray();
data.push({name: 'token', value: qiniu.qiniuUploadToken});
return data;
},
submit: function (e, data) {
},
done: function (e, data) {
// console.log(data.result)
var qiniuKey = data.result.key;
if (!qiniuKey) {
alert("Upload error");
return;
}
var t = new Date().getTime();
$('#src').val(qiniu.qiniuDomain + qiniuKey + '?' + t);
ImageDialog.showPreviewImage(qiniu.qiniuDomain + qiniuKey + '?' + t);
},
fail: function (e, data) {
alert("Upload error: " + data.errorThrown);
}
}).on('fileuploadprocessalways', function (e, data) {
var currentFile = data.files[data.index];
if (data.files.error && currentFile.error) {
alert(currentFile.error);
}
});
});
},
showPreviewImage: function (u, st) { showPreviewImage: function (u, st) {
if (!u) { if (!u) {
tinyMCEPopup.dom.setHTML('prev', ''); tinyMCEPopup.dom.setHTML('prev', '');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment