Commit 886481c7 authored by Liang Ding's avatar Liang Ding

Merge pull request #12018 from b3log/0.6.9

0.6.9
parents ee3a7ae8 e744ed9c
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
*/ */
package org.b3log.solo.service; package org.b3log.solo.service;
import java.util.List; import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import org.b3log.latke.Keys; import org.b3log.latke.Keys;
...@@ -37,12 +36,11 @@ import org.b3log.solo.util.Comments; ...@@ -37,12 +36,11 @@ import org.b3log.solo.util.Comments;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
/** /**
* Page management service. * Page management service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.7, Jun 8, 2012 * @version 1.1.0.7, May 30, 2015
* @since 0.4.0 * @since 0.4.0
*/ */
@Service @Service
...@@ -98,8 +96,7 @@ public class PageMgmtService { ...@@ -98,8 +96,7 @@ public class PageMgmtService {
/** /**
* Updates a page by the specified request json object. * Updates a page by the specified request json object.
* *
* @param requestJSONObject the specified request json object, for example, * @param requestJSONObject the specified request json object, for example, <pre>
* <pre>
* { * {
* "page": { * "page": {
* "oId": "", * "oId": "",
...@@ -110,10 +107,12 @@ public class PageMgmtService { ...@@ -110,10 +107,12 @@ public class PageMgmtService {
* "pagePermalink": "", * "pagePermalink": "",
* "pageCommentable": boolean, * "pageCommentable": boolean,
* "pageType": "", * "pageType": "",
* "pageOpenTarget": "" * "pageOpenTarget": "",
* "pageEditorType": "" // optional, preference specified if not exists this key
* } * }
* }, see {@link Page} for more details * }, see {@link Page} for more details
* </pre> * </pre>
*
* @throws ServiceException service exception * @throws ServiceException service exception
*/ */
public void updatePage(final JSONObject requestJSONObject) throws ServiceException { public void updatePage(final JSONObject requestJSONObject) throws ServiceException {
...@@ -167,10 +166,11 @@ public class PageMgmtService { ...@@ -167,10 +166,11 @@ public class PageMgmtService {
processCommentsForPageUpdate(newPage); processCommentsForPageUpdate(newPage);
} }
// Editor type // Set editor type
final JSONObject preference = preferenceQueryService.getPreference(); if (!newPage.has(Page.PAGE_EDITOR_TYPE)) {
final JSONObject preference = preferenceQueryService.getPreference();
newPage.put(Page.PAGE_EDITOR_TYPE, preference.optString(Preference.EDITOR_TYPE)); newPage.put(Page.PAGE_EDITOR_TYPE, preference.optString(Preference.EDITOR_TYPE));
}
pageRepository.update(pageId, newPage); pageRepository.update(pageId, newPage);
...@@ -216,9 +216,8 @@ public class PageMgmtService { ...@@ -216,9 +216,8 @@ public class PageMgmtService {
/** /**
* Adds a page with the specified request json object. * Adds a page with the specified request json object.
* *
* @param requestJSONObject the specified request json object, for example, * @param requestJSONObject the specified request json object, for example, <pre>
* <pre>
* { * {
* "page": { * "page": {
* "pageTitle": "", * "pageTitle": "",
...@@ -226,13 +225,14 @@ public class PageMgmtService { ...@@ -226,13 +225,14 @@ public class PageMgmtService {
* "pageOpenTarget": "", * "pageOpenTarget": "",
* "pageCommentable": boolean, * "pageCommentable": boolean,
* "pageType": "", * "pageType": "",
* "pagePermalink": "" // optional * "pagePermalink": "", // optional
* "pageEditorType": "" // optional, preference specified if not exists this key
* } * }
* }, see {@link Page} for more details * }, see {@link Page} for more details
* </pre> * </pre>
*
* @return generated page id * @return generated page id
* @throws ServiceException if permalink format checks failed or persists * @throws ServiceException if permalink format checks failed or persists failed
* failed
*/ */
public String addPage(final JSONObject requestJSONObject) throws ServiceException { public String addPage(final JSONObject requestJSONObject) throws ServiceException {
final Transaction transaction = pageRepository.beginTransaction(); final Transaction transaction = pageRepository.beginTransaction();
...@@ -274,11 +274,12 @@ public class PageMgmtService { ...@@ -274,11 +274,12 @@ public class PageMgmtService {
} }
page.put(Page.PAGE_PERMALINK, permalink.replaceAll(" ", "-")); page.put(Page.PAGE_PERMALINK, permalink.replaceAll(" ", "-"));
// Editor type
final JSONObject preference = preferenceQueryService.getPreference();
page.put(Page.PAGE_EDITOR_TYPE, preference.optString(Preference.EDITOR_TYPE)); // Set editor type
if (!page.has(Page.PAGE_EDITOR_TYPE)) {
final JSONObject preference = preferenceQueryService.getPreference();
page.put(Page.PAGE_EDITOR_TYPE, preference.optString(Preference.EDITOR_TYPE));
}
final String ret = pageRepository.add(page); final String ret = pageRepository.add(page);
...@@ -303,8 +304,7 @@ public class PageMgmtService { ...@@ -303,8 +304,7 @@ public class PageMgmtService {
} }
/** /**
* Changes the order of a page specified by the given page id with * Changes the order of a page specified by the given page id with the specified direction.
* the specified direction.
* *
* @param pageId the given page id * @param pageId the given page id
* @param direction the specified direction, "up"/"down" * @param direction the specified direction, "up"/"down"
...@@ -381,9 +381,9 @@ public class PageMgmtService { ...@@ -381,9 +381,9 @@ public class PageMgmtService {
/** /**
* Processes comments for page update. * Processes comments for page update.
* *
* @param page the specified page to update * @param page the specified page to update
* @throws Exception exception * @throws Exception exception
*/ */
public void processCommentsForPageUpdate(final JSONObject page) throws Exception { public void processCommentsForPageUpdate(final JSONObject page) throws Exception {
final String pageId = page.getString(Keys.OBJECT_ID); final String pageId = page.getString(Keys.OBJECT_ID);
...@@ -409,7 +409,7 @@ public class PageMgmtService { ...@@ -409,7 +409,7 @@ public class PageMgmtService {
/** /**
* Sets the permalink query service with the specified permalink query service. * Sets the permalink query service with the specified permalink query service.
* *
* @param permalinkQueryService the specified permalink query service * @param permalinkQueryService the specified permalink query service
*/ */
public void setPermalinkQueryService(final PermalinkQueryService permalinkQueryService) { public void setPermalinkQueryService(final PermalinkQueryService permalinkQueryService) {
...@@ -418,7 +418,7 @@ public class PageMgmtService { ...@@ -418,7 +418,7 @@ public class PageMgmtService {
/** /**
* Set the page repository with the specified page repository. * Set the page repository with the specified page repository.
* *
* @param pageRepository the specified page repository * @param pageRepository the specified page repository
*/ */
public void setPageRepository(final PageRepository pageRepository) { public void setPageRepository(final PageRepository pageRepository) {
...@@ -427,7 +427,7 @@ public class PageMgmtService { ...@@ -427,7 +427,7 @@ public class PageMgmtService {
/** /**
* Sets the preference query service with the specified preference query service. * Sets the preference query service with the specified preference query service.
* *
* @param preferenceQueryService the specified preference query service * @param preferenceQueryService the specified preference query service
*/ */
public void setPreferenceQueryService(final PreferenceQueryService preferenceQueryService) { public void setPreferenceQueryService(final PreferenceQueryService preferenceQueryService) {
...@@ -436,7 +436,7 @@ public class PageMgmtService { ...@@ -436,7 +436,7 @@ public class PageMgmtService {
/** /**
* Sets the statistic query service with the specified statistic query service. * Sets the statistic query service with the specified statistic query service.
* *
* @param statisticQueryService the specified statistic query service * @param statisticQueryService the specified statistic query service
*/ */
public void setStatisticQueryService(final StatisticQueryService statisticQueryService) { public void setStatisticQueryService(final StatisticQueryService statisticQueryService) {
...@@ -445,7 +445,7 @@ public class PageMgmtService { ...@@ -445,7 +445,7 @@ public class PageMgmtService {
/** /**
* Sets the statistic management service with the specified statistic management service. * Sets the statistic management service with the specified statistic management service.
* *
* @param statisticMgmtService the specified statistic management service * @param statisticMgmtService the specified statistic management service
*/ */
public void setStatisticMgmtService(final StatisticMgmtService statisticMgmtService) { public void setStatisticMgmtService(final StatisticMgmtService statisticMgmtService) {
...@@ -454,7 +454,7 @@ public class PageMgmtService { ...@@ -454,7 +454,7 @@ public class PageMgmtService {
/** /**
* Sets the comment repository with the specified comment repository. * Sets the comment repository with the specified comment repository.
* *
* @param commentRepository the specified comment repository * @param commentRepository the specified comment repository
*/ */
public void setCommentRepository(final CommentRepository commentRepository) { public void setCommentRepository(final CommentRepository commentRepository) {
...@@ -463,7 +463,7 @@ public class PageMgmtService { ...@@ -463,7 +463,7 @@ public class PageMgmtService {
/** /**
* Sets the language service with the specified language service. * Sets the language service with the specified language service.
* *
* @param langPropsService the specified language service * @param langPropsService the specified language service
*/ */
public void setLangPropsService(final LangPropsService langPropsService) { public void setLangPropsService(final LangPropsService langPropsService) {
......
...@@ -16,11 +16,12 @@ ...@@ -16,11 +16,12 @@
# #
# Description: B3log configurations for testing. # Description: B3log configurations for testing.
# Version: 1.1.0.0, Jan 13, 2015 # Version: 1.2.0.0, May 25, 2015
# Author: Liang Ding # Author: Liang Ding
# #
rhythm.servePath=http://localhost:8081 rhythm.servePath=http://localhost:8081
symphony.servePath=http://localhost:8084 symphony.servePath=http://localhost:8084
gravatar=http://gravatar.duoshuo.com/avatar/
faviconAPI=http://api.byi.pw/favicon?url= faviconAPI=http://api.byi.pw/favicon?url=
\ No newline at end of file
...@@ -6,9 +6,7 @@ ...@@ -6,9 +6,7 @@
<title>${blogTitle} - ${adminConsoleLabel}</title> <title>${blogTitle} - ${adminConsoleLabel}</title>
<link type="text/css" rel="stylesheet" href="${staticServePath}/css/default-base${miniPostfix}.css?${staticResourceVersion}" /> <link type="text/css" rel="stylesheet" href="${staticServePath}/css/default-base${miniPostfix}.css?${staticResourceVersion}" />
<link type="text/css" rel="stylesheet" href="${staticServePath}/css/default-admin${miniPostfix}.css?${staticResourceVersion}" /> <link type="text/css" rel="stylesheet" href="${staticServePath}/css/default-admin${miniPostfix}.css?${staticResourceVersion}" />
<#if "CodeMirror-Markdown" == editorType>
<link type="text/css" rel="stylesheet" href="${staticServePath}/js/lib/CodeMirror/codemirror.css?${staticResourceVersion}" /> <link type="text/css" rel="stylesheet" href="${staticServePath}/js/lib/CodeMirror/codemirror.css?${staticResourceVersion}" />
</#if>
<link rel="icon" type="image/png" href="${staticServePath}/favicon.png" /> <link rel="icon" type="image/png" href="${staticServePath}/favicon.png" />
</head> </head>
<body onhashchange="admin.setCurByHash();"> <body onhashchange="admin.setCurByHash();">
...@@ -133,24 +131,16 @@ ...@@ -133,24 +131,16 @@
</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/jquery.bowknot.min.js?${staticResourceVersion}"></script> <script src="${staticServePath}/js/lib/jquery/jquery.bowknot.min.js?${staticResourceVersion}"></script>
<#if "tinyMCE" == editorType>
<script src="${servePath}/js/lib/tiny_mce/tiny_mce.js"></script> <script src="${servePath}/js/lib/tiny_mce/tiny_mce.js"></script>
<#elseif "KindEditor" == editorType>
<script src="${staticServePath}/js/lib/KindEditor/kindeditor-min.js"></script> <script src="${staticServePath}/js/lib/KindEditor/kindeditor-min.js"></script>
<#else>
<script src="${staticServePath}/js/lib/CodeMirror/codemirror.js"></script> <script src="${staticServePath}/js/lib/CodeMirror/codemirror.js"></script>
</#if>
<script src="${staticServePath}/js/common${miniPostfix}.js"></script> <script src="${staticServePath}/js/common${miniPostfix}.js"></script>
<#if "" == miniPostfix> <#if "" == miniPostfix>
<script src="${staticServePath}/js/admin/admin.js"></script> <script src="${staticServePath}/js/admin/admin.js"></script>
<script src="${staticServePath}/js/admin/editor.js"></script> <script src="${staticServePath}/js/admin/editor.js"></script>
<#if "tinyMCE" == editorType>
<script src="${staticServePath}/js/admin/editorTinyMCE.js"></script> <script src="${staticServePath}/js/admin/editorTinyMCE.js"></script>
<#elseif "KindEditor" == editorType>
<script src="${staticServePath}/js/admin/editorKindEditor.js"></script> <script src="${staticServePath}/js/admin/editorKindEditor.js"></script>
<#else>
<script src="${staticServePath}/js/admin/editorCodeMirror.js"></script> <script src="${staticServePath}/js/admin/editorCodeMirror.js"></script>
</#if>
<script src="${staticServePath}/js/admin/tablePaginate.js"></script> <script src="${staticServePath}/js/admin/tablePaginate.js"></script>
<script src="${staticServePath}/js/admin/article.js"></script> <script src="${staticServePath}/js/admin/article.js"></script>
<script src="${staticServePath}/js/admin/comment.js"></script> <script src="${staticServePath}/js/admin/comment.js"></script>
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* admin style * admin style
* *
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a> * @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @version 1.0.4.1, Dec 24, 2012 * @version 1.0.5.1, May 30, 2015
*/ */
/* start resset */ /* start resset */
...@@ -647,7 +647,7 @@ button#submitArticle { ...@@ -647,7 +647,7 @@ button#submitArticle {
float: left; float: left;
height: 16px; height: 16px;
width: 16px; width: 16px;
background-position: -79px -32px; background-position: -81px -32px;
} }
.table-upIcon { .table-upIcon {
background-position: -64px -32px; background-position: -64px -32px;
......
This diff is collapsed.
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* @fileoverview editor * @fileoverview editor
* *
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a> * @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @version 1.0.0.4, Jan 29, 2013 * @version 1.1.0.4, May 30, 2015
*/ */
admin.editors = {}; admin.editors = {};
...@@ -52,21 +52,23 @@ $.extend(Editor.prototype, { ...@@ -52,21 +52,23 @@ $.extend(Editor.prototype, {
_init: function () { _init: function () {
this.init(); this.init();
}, },
/* /*
* @description 初始化编辑器 * @description 初始化编辑器
*/ */
init: function () { init: function (type) {
var conf = this.conf; var conf = this.conf;
if (type) {
conf.type = type;
}
var types = conf.type.split("-"); var types = conf.type.split("-");
if (types.length === 2) { if (types.length === 2) {
conf.codeMirrorLanguage = types[1]; conf.codeMirrorLanguage = types[1];
conf.type = types[0]; conf.type = types[0];
} }
admin.editors[conf.type].init(conf); admin.editors[conf.type].init(conf);
}, },
/* /*
* @description 获取编辑器值 * @description 获取编辑器值
* @returns {string} 编辑器值 * @returns {string} 编辑器值
...@@ -75,7 +77,6 @@ $.extend(Editor.prototype, { ...@@ -75,7 +77,6 @@ $.extend(Editor.prototype, {
var conf = this.conf; var conf = this.conf;
return admin.editors[conf.type].getContent(conf.id); return admin.editors[conf.type].getContent(conf.id);
}, },
/* /*
* @description 设置编辑器值 * @description 设置编辑器值
* @param {string} content 编辑器回填内容 * @param {string} content 编辑器回填内容
...@@ -83,6 +84,13 @@ $.extend(Editor.prototype, { ...@@ -83,6 +84,13 @@ $.extend(Editor.prototype, {
setContent: function (content) { setContent: function (content) {
var conf = this.conf; var conf = this.conf;
admin.editors[conf.type].setContent(conf.id, content); admin.editors[conf.type].setContent(conf.id, content);
},
/*
* @description 移除编辑器值
*/
remove: function () {
var conf = this.conf;
admin.editors[conf.type].remove(conf.id);
} }
}); });
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* @fileoverview markdowm CodeMirror editor * @fileoverview markdowm CodeMirror editor
* *
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a> * @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @version 1.0.0.4, May 30, 2013 * @version 1.1.0.4, May 30, 2015
*/ */
admin.editors.CodeMirror = { admin.editors.CodeMirror = {
/* /*
...@@ -32,19 +32,19 @@ admin.editors.CodeMirror = { ...@@ -32,19 +32,19 @@ admin.editors.CodeMirror = {
*/ */
init: function (conf) { init: function (conf) {
var it = this; var it = this;
// load preview and clear // load preview and clear
var previewHTML = "<div class='clear'></div>"; var previewHTML = "<div class='clear'></div>";
if (conf.kind !== "simple") { if (conf.kind !== "simple") {
previewHTML = "<div class='markdown-preivew'>" + previewHTML = "<div class='markdown-preivew'>" +
"<div class='markdown-help ico-close'></div>" + "<div class='markdown-help ico-close'></div>" +
"<div class='clear'></div>" + "<div class='clear'></div>" +
"<div class='markdown-preview-main none'></div>" + "<div class='markdown-preview-main none'></div>" +
"<div class='markdown-help-main'>" + Label.markdownHelpLabel + "</div>" "<div class='markdown-help-main'>" + Label.markdownHelpLabel + "</div>"
+ "</div><div class='clear'></div>"; + "</div><div class='clear'></div>";
} }
$("#" + conf.id).after(previewHTML); $("#" + conf.id).after(previewHTML);
// init codemirror // init codemirror
if (conf.kind === "simple") { if (conf.kind === "simple") {
this[conf.id] = CodeMirror.fromTextArea(document.getElementById(conf.id), { this[conf.id] = CodeMirror.fromTextArea(document.getElementById(conf.id), {
...@@ -57,12 +57,12 @@ admin.editors.CodeMirror = { ...@@ -57,12 +57,12 @@ admin.editors.CodeMirror = {
} else { } else {
// preview 执行队列 // preview 执行队列
it[conf.id + "Timers"] = []; it[conf.id + "Timers"] = [];
// 该编辑器是否第一次触发 preivew 事件 // 该编辑器是否第一次触发 preivew 事件
it[conf.id + "IsFirst"] = true; it[conf.id + "IsFirst"] = true;
var $preview = $("#" + conf.id).parent().find(".markdown-preivew"), var $preview = $("#" + conf.id).parent().find(".markdown-preivew"),
$help = $("#" + conf.id).parent().find(".markdown-preivew").find(".markdown-help"); $help = $("#" + conf.id).parent().find(".markdown-preivew").find(".markdown-help");
this[conf.id] = CodeMirror.fromTextArea(document.getElementById(conf.id), { this[conf.id] = CodeMirror.fromTextArea(document.getElementById(conf.id), {
mode: 'markdown', mode: 'markdown',
lineNumbers: true, lineNumbers: true,
...@@ -74,19 +74,19 @@ admin.editors.CodeMirror = { ...@@ -74,19 +74,19 @@ admin.editors.CodeMirror = {
if (it[conf.id].getValue() === "") { if (it[conf.id].getValue() === "") {
return; return;
} }
$.ajax({ $.ajax({
url: latkeConfig.servePath + "/console/markdown/2html", url: latkeConfig.servePath + "/console/markdown/2html",
type: "POST", type: "POST",
cache: false, cache: false,
data: JSON.stringify({markdownText:it[conf.id].getValue()}), data: JSON.stringify({markdownText: it[conf.id].getValue()}),
success: function(data, textStatus) { success: function (data, textStatus) {
if (data.sc) { if (data.sc) {
if (it[conf.id + "IsFirst"] && $help.hasClass("ico-close")) { if (it[conf.id + "IsFirst"] && $help.hasClass("ico-close")) {
$help.click(); $help.click();
} }
it[conf.id + "IsFirst"] = false; it[conf.id + "IsFirst"] = false;
$preview.find(".markdown-preview-main").html(data.html); $preview.find(".markdown-preview-main").html(data.html);
} else { } else {
$preview.find(".markdown-preview-main").html(data.msg); $preview.find(".markdown-preview-main").html(data.msg);
...@@ -94,14 +94,14 @@ admin.editors.CodeMirror = { ...@@ -94,14 +94,14 @@ admin.editors.CodeMirror = {
} }
}); });
} }
it[conf.id + "Timers"].push(update); it[conf.id + "Timers"].push(update);
} }
}); });
this._callPreview(conf.id, it[conf.id + "Timers"]); this._callPreview(conf.id, it[conf.id + "Timers"]);
} }
if (conf.kind === "simple") { if (conf.kind === "simple") {
// 摘要不需要 preview,设置其宽度 // 摘要不需要 preview,设置其宽度
$("#" + conf.id).next().width("99%"); $("#" + conf.id).next().width("99%");
...@@ -109,13 +109,12 @@ admin.editors.CodeMirror = { ...@@ -109,13 +109,12 @@ admin.editors.CodeMirror = {
// 有 preview 时,绑定 preview 事件 // 有 preview 时,绑定 preview 事件
this._bindEvent(conf.id); this._bindEvent(conf.id);
} }
// after render, call back function // after render, call back function
if (typeof(conf.fun) === "function") { if (typeof (conf.fun) === "function") {
conf.fun(); conf.fun();
} }
}, },
/* /*
* @description 当有更新时每隔3秒 preview * @description 当有更新时每隔3秒 preview
* @param {string} id 编辑器 id * @param {string} id 编辑器 id
...@@ -128,14 +127,13 @@ admin.editors.CodeMirror = { ...@@ -128,14 +127,13 @@ admin.editors.CodeMirror = {
admin.editors.CodeMirror[id + "Timers"] = []; admin.editors.CodeMirror[id + "Timers"] = [];
}, 2000); }, 2000);
}, },
/* /*
* @description 绑定编辑器 preview 事件 * @description 绑定编辑器 preview 事件
* @param {string} id 编辑器id * @param {string} id 编辑器id
*/ */
_bindEvent: function (id) { _bindEvent: function (id) {
var $preview = $("#" + id).parent().find(".markdown-preivew"); var $preview = $("#" + id).parent().find(".markdown-preivew");
$preview.find(".markdown-help").click(function () { $preview.find(".markdown-help").click(function () {
var $it = $(this); var $it = $(this);
if ($it.hasClass("ico-help")) { if ($it.hasClass("ico-help")) {
...@@ -149,7 +147,6 @@ admin.editors.CodeMirror = { ...@@ -149,7 +147,6 @@ admin.editors.CodeMirror = {
} }
}); });
}, },
/* /*
* @description 获取编辑器值 * @description 获取编辑器值
* @param {string} id 编辑器id * @param {string} id 编辑器id
...@@ -158,7 +155,6 @@ admin.editors.CodeMirror = { ...@@ -158,7 +155,6 @@ admin.editors.CodeMirror = {
getContent: function (id) { getContent: function (id) {
return this[id].getValue(); return this[id].getValue();
}, },
/* /*
* @description 设置编辑器值 * @description 设置编辑器值
* @param {string} id 编辑器 id * @param {string} id 编辑器 id
...@@ -166,5 +162,15 @@ admin.editors.CodeMirror = { ...@@ -166,5 +162,15 @@ admin.editors.CodeMirror = {
*/ */
setContent: function (id, content) { setContent: function (id, content) {
this[id].setValue(content); this[id].setValue(content);
var $preview = $("#" + id).parent().find(".markdown-preivew");
$preview.find(".markdown-preview-main").html(content);
},
/*
* @description 销毁编辑器值
* @param {string} id 编辑器 id
*/
remove: function (id) {
this[id].toTextArea();
$(".markdown-preivew").remove();
} }
}; };
\ No newline at end of file
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* plugins/media/media.js 注释 26 & 28 * plugins/media/media.js 注释 26 & 28
* *
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a> * @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @version 1.0.0.2, Jun 19, 2012 * @version 1.1.0.2, May 30, 2015
*/ */
admin.editors.KindEditor = { admin.editors.KindEditor = {
/* /*
...@@ -33,15 +33,15 @@ admin.editors.KindEditor = { ...@@ -33,15 +33,15 @@ admin.editors.KindEditor = {
var language = "zh_CN"; var language = "zh_CN";
if ("en_US" === Label.localeString) { if ("en_US" === Label.localeString) {
language = "en" language = "en"
} }
if (conf.kind && conf.kind === "simple") { if (conf.kind && conf.kind === "simple") {
try { try {
this[conf.id] = KindEditor.create('#' + conf.id, { this[conf.id] = KindEditor.create('#' + conf.id, {
langType : language, langType: language,
resizeType: 0, resizeType: 0,
items: ["bold", "italic", "underline", "strikethrough", "|", "undo", "redo", "|", items: ["bold", "italic", "underline", "strikethrough", "|", "undo", "redo", "|",
"insertunorderedlist", "insertorderedlist", "|", "source" "insertunorderedlist", "insertorderedlist", "|", "source"
] ]
}); });
} catch (e) { } catch (e) {
...@@ -50,15 +50,15 @@ admin.editors.KindEditor = { ...@@ -50,15 +50,15 @@ admin.editors.KindEditor = {
} else { } else {
try { try {
this[conf.id] = KindEditor.create('#' + conf.id, { this[conf.id] = KindEditor.create('#' + conf.id, {
langType : language, langType: language,
items: ["formatblock", "fontname", "fontsize", "|", "bold", "italic", "underline", "strikethrough", "forecolor", "|", items: ["formatblock", "fontname", "fontsize", "|", "bold", "italic", "underline", "strikethrough", "forecolor", "|",
"link", "unlink", "image", "media", "|", "pagebreak", "emoticons", "code", "/", "link", "unlink", "image", "media", "|", "pagebreak", "emoticons", "code", "/",
"undo", "redo", "|", "insertunorderedlist", "insertorderedlist", "indent", "outdent", "|", "undo", "redo", "|", "insertunorderedlist", "insertorderedlist", "indent", "outdent", "|",
"justifyleft", "justifycenter", "justifyright", "justifyfull", "|", "plainpaste", "wordpaste", "|", "justifyleft", "justifycenter", "justifyright", "justifyfull", "|", "plainpaste", "wordpaste", "|",
"clearhtml", "source", "preview" "clearhtml", "source", "preview"
], ],
afterCreate: function () { afterCreate: function () {
if (typeof(conf.fun) === "function") { if (typeof (conf.fun) === "function") {
conf.fun(); conf.fun();
} }
} }
...@@ -68,7 +68,6 @@ admin.editors.KindEditor = { ...@@ -68,7 +68,6 @@ admin.editors.KindEditor = {
} }
} }
}, },
/* /*
* @description 获取编辑器值 * @description 获取编辑器值
* @param {string} id 编辑器id * @param {string} id 编辑器id
...@@ -83,7 +82,6 @@ admin.editors.KindEditor = { ...@@ -83,7 +82,6 @@ admin.editors.KindEditor = {
} }
return content; return content;
}, },
/* /*
* @description 设置编辑器值 * @description 设置编辑器值
* @param {string} id 编辑器 id * @param {string} id 编辑器 id
...@@ -95,5 +93,12 @@ admin.editors.KindEditor = { ...@@ -95,5 +93,12 @@ admin.editors.KindEditor = {
} catch (e) { } catch (e) {
$("#" + id).val(content); $("#" + id).val(content);
} }
},
/*
* @description 移除编辑器
* @param {string} id 编辑器 id
*/
remove: function (id) {
this[id].remove();
} }
}; };
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* @fileoverview tinyMCE editor * @fileoverview tinyMCE editor
* *
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a> * @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @version 1.0.0.6, Sep 26, 2012 * @version 1.1.0.6, May 30, 2015
*/ */
admin.editors.tinyMCE = { admin.editors.tinyMCE = {
/* /*
...@@ -32,25 +32,23 @@ admin.editors.tinyMCE = { ...@@ -32,25 +32,23 @@ admin.editors.tinyMCE = {
if (language === "zh") { if (language === "zh") {
language = "zh-cn"; language = "zh-cn";
} }
if (conf.kind && conf.kind === "simple") { if (conf.kind && conf.kind === "simple") {
try { try {
tinyMCE.init({ tinyMCE.init({
// General options // General options
language: language, language: language,
mode : "exact", mode: "exact",
elements : conf.id, elements: conf.id,
theme : "advanced", theme: "advanced",
plugins: "media", plugins: "media",
// Theme options // Theme options
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,undo,redo,|,bullist,numlist,|,code", theme_advanced_buttons1: "bold,italic,underline,strikethrough,|,undo,redo,|,bullist,numlist,|,code",
theme_advanced_buttons2 : "", theme_advanced_buttons2: "",
theme_advanced_buttons3 : "", theme_advanced_buttons3: "",
theme_advanced_toolbar_location : "top", theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align : "left", theme_advanced_toolbar_align: "left",
valid_children: "+body[style]"
valid_children : "+body[style]"
}); });
} catch (e) { } catch (e) {
$("#tipMsg").text("TinyMCE load fail"); $("#tipMsg").text("TinyMCE load fail");
...@@ -60,27 +58,24 @@ admin.editors.tinyMCE = { ...@@ -60,27 +58,24 @@ admin.editors.tinyMCE = {
tinyMCE.init({ tinyMCE.init({
// General options // General options
language: language, language: language,
mode : "exact", mode: "exact",
elements : conf.id, elements: conf.id,
theme : "advanced", theme: "advanced",
plugins : "autosave,style,advhr,advimage,advlink,preview,inlinepopups,media,paste,syntaxhl,wordcount", plugins: "autosave,style,advhr,advimage,advlink,preview,inlinepopups,media,paste,syntaxhl,wordcount",
// Theme options // Theme options
theme_advanced_buttons1 : "formatselect,fontselect,fontsizeselect,|,bold,italic,underline,strikethrough,forecolor,|,advhr,blockquote,syntaxhl,", theme_advanced_buttons1: "formatselect,fontselect,fontsizeselect,|,bold,italic,underline,strikethrough,forecolor,|,advhr,blockquote,syntaxhl,",
theme_advanced_buttons2 : "undo,redo,|,bullist,numlist,outdent,indent,|,justifyleft,justifycenter,justifyright,justifyfull,|,pastetext,pasteword,|,link,unlink,image,iespell,media,|,cleanup,code,preview,", theme_advanced_buttons2: "undo,redo,|,bullist,numlist,outdent,indent,|,justifyleft,justifycenter,justifyright,justifyfull,|,pastetext,pasteword,|,link,unlink,image,iespell,media,|,cleanup,code,preview,",
theme_advanced_buttons3 : "", theme_advanced_buttons3: "",
theme_advanced_toolbar_location : "top", theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align : "left", theme_advanced_toolbar_align: "left",
theme_advanced_resizing : true, theme_advanced_resizing: true,
theme_advanced_statusbar_location : "bottom", theme_advanced_statusbar_location: "bottom",
extended_valid_elements: "link[type|rel|href|charset],pre[name|class],iframe[src|width|height|name|align],+a[*]", extended_valid_elements: "link[type|rel|href|charset],pre[name|class],iframe[src|width|height|name|align],+a[*]",
valid_children: "+body[style]",
valid_children : "+body[style]",
relative_urls: false, relative_urls: false,
remove_script_host: false, remove_script_host: false,
oninit : function () { oninit: function () {
if (typeof(conf.fun) === "function") { if (typeof (conf.fun) === "function") {
conf.fun(); conf.fun();
} }
} }
...@@ -90,7 +85,6 @@ admin.editors.tinyMCE = { ...@@ -90,7 +85,6 @@ admin.editors.tinyMCE = {
} }
} }
}, },
/* /*
* @description 获取编辑器值 * @description 获取编辑器值
* @param {string} id 编辑器id * @param {string} id 编辑器id
...@@ -105,7 +99,6 @@ admin.editors.tinyMCE = { ...@@ -105,7 +99,6 @@ admin.editors.tinyMCE = {
} }
return content; return content;
}, },
/* /*
* @description 设置编辑器值 * @description 设置编辑器值
* @param {string} id 编辑器 id * @param {string} id 编辑器 id
...@@ -121,5 +114,12 @@ admin.editors.tinyMCE = { ...@@ -121,5 +114,12 @@ admin.editors.tinyMCE = {
} catch (e) { } catch (e) {
$("#" + id).val(content); $("#" + id).val(content);
} }
},
/*
* @description 移除编辑器
* @param {string} id 编辑器 id
*/
remove: function (id) {
tinyMCE.get(id).remove();
} }
}; };
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
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