Commit c9216004 authored by Liang Ding's avatar Liang Ding

c

parent a6d5486c
This diff is collapsed.
This diff is collapsed.
/* /*
* Copyright (c) 2009, 2010, 2011, 2012, B3log Team * Copyright (c) 2009, 2010, 2011, 2012, B3log Team
* *
* 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.
*/ */
/** /**
* @fileoverview KindEditor * @fileoverview KindEditor
* *
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a> * @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @version 1.0.0.1, May 2, 2012 * @version 1.0.0.1, May 2, 2012
*/ */
admin.editors.KindEditor = { admin.editors.KindEditor = {
/* /*
* @description 初始化编辑器 * @description 初始化编辑器
* @param conf 编辑器初始化参数 * @param conf 编辑器初始化参数
* @param conf.kind 编辑器类型 * @param conf.kind 编辑器类型
* @param conf.id 编辑器渲染元素 id * @param conf.id 编辑器渲染元素 id
* @param conf.fun 编辑器首次加载完成后回调函数 * @param conf.fun 编辑器首次加载完成后回调函数
*/ */
init: function (conf) { init: function (conf) {
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", "insertunorderedlist", "insertorderedlist",
] ]
}); });
} catch (e) { } catch (e) {
$("#tipMsg").text("KindEditor load fail"); $("#tipMsg").text("KindEditor load fail");
} }
} 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();
} }
} }
}); });
} catch (e) { } catch (e) {
$("#tipMsg").text("KindEditor load fail"); $("#tipMsg").text("KindEditor load fail");
} }
} }
}, },
/* /*
* @description 获取编辑器值 * @description 获取编辑器值
* @param {string} id 编辑器id * @param {string} id 编辑器id
* @returns {string} 编辑器值 * @returns {string} 编辑器值
*/ */
getContent: function (id) { getContent: function (id) {
var content = ""; var content = "";
try { try {
content = this[id].html(); content = this[id].html();
} catch (e) { } catch (e) {
content = $("#" + id).val(); content = $("#" + id).val();
} }
return content; return content;
}, },
/* /*
* @description 设置编辑器值 * @description 设置编辑器值
* @param {string} id 编辑器 id * @param {string} id 编辑器 id
* @param {string} content 设置编辑器值 * @param {string} content 设置编辑器值
*/ */
setContent: function (id, content) { setContent: function (id, content) {
try { try {
this[id].html(content); this[id].html(content);
} catch (e) { } catch (e) {
$("#" + id).val(content); $("#" + id).val(content);
} }
} }
}; };
\ No newline at end of file
/* /*
* Copyright (c) 2009, 2010, 2011, 2012, B3log Team * Copyright (c) 2009, 2010, 2011, 2012, B3log Team
* *
* 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.
*/ */
/** /**
* @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.4, May 9, 2012 * @version 1.0.0.4, May 9, 2012
*/ */
admin.editors.tinyMCE = { admin.editors.tinyMCE = {
/* /*
* @description 初始化编辑器 * @description 初始化编辑器
* @param conf 编辑器初始化参数 * @param conf 编辑器初始化参数
* @param conf.kind 编辑器类型 * @param conf.kind 编辑器类型
* @param conf.id 编辑器渲染元素 id * @param conf.id 编辑器渲染元素 id
* @param conf.fun 编辑器首次加载完成后回调函数 * @param conf.fun 编辑器首次加载完成后回调函数
*/ */
init: function (conf) { init: function (conf) {
var language = Label.localeString.substring(0, 2); var language = Label.localeString.substring(0, 2);
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",
// Theme options // Theme options
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,undo,redo,|,bullist,numlist", theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,undo,redo,|,bullist,numlist",
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");
} }
} else { } else {
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 : "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();
} }
} }
}); });
} catch (e) { } catch (e) {
$("#tipMsg").text("TinyMCE load fail"); $("#tipMsg").text("TinyMCE load fail");
} }
} }
}, },
/* /*
* @description 获取编辑器值 * @description 获取编辑器值
* @param {string} id 编辑器id * @param {string} id 编辑器id
* @returns {string} 编辑器值 * @returns {string} 编辑器值
*/ */
getContent: function (id) { getContent: function (id) {
var content = ""; var content = "";
try { try {
content = tinyMCE.get(id).getContent(); content = tinyMCE.get(id).getContent();
} catch (e) { } catch (e) {
content = $("#" + id).val(); content = $("#" + id).val();
} }
return content; return content;
}, },
/* /*
* @description 设置编辑器值 * @description 设置编辑器值
* @param {string} id 编辑器 id * @param {string} id 编辑器 id
* @param {string} content 设置编辑器值 * @param {string} content 设置编辑器值
*/ */
setContent: function (id, content) { setContent: function (id, content) {
try { try {
if (tinyMCE.get(id)) { if (tinyMCE.get(id)) {
tinyMCE.get(id).setContent(content); tinyMCE.get(id).setContent(content);
} else { } else {
$("#" + id).val(content); $("#" + id).val(content);
} }
} catch (e) { } catch (e) {
$("#" + id).val(content); $("#" + id).val(content);
} }
} }
}; };
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
/* /*
* Copyright (c) 2009, 2010, 2011, 2012, B3log Team * Copyright (c) 2009, 2010, 2011, 2012, B3log Team
* *
* 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.
*/ */
/** /**
* table and paginate util * table and paginate util
* *
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a> * @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @version 1.0.0.7, Nov 8, 2011 * @version 1.0.0.7, Nov 8, 2011
*/ */
var TablePaginate = function (id) { var TablePaginate = function (id) {
this.id = id; this.id = id;
this.currentPage = 1; this.currentPage = 1;
}; };
$.extend(TablePaginate.prototype, { $.extend(TablePaginate.prototype, {
/* /*
* 构建 table 框架 * 构建 table 框架
* @colModel table 列宽,标题等数据 * @colModel table 列宽,标题等数据
*/ */
buildTable: function (colModel, noExpend) { buildTable: function (colModel, noExpend) {
var tableData = { var tableData = {
colModel: colModel, colModel: colModel,
noDataTip: Label.noDataLabel noDataTip: Label.noDataLabel
} }
if (!noExpend) { if (!noExpend) {
tableData.expendRow = { tableData.expendRow = {
index: "expendRow" index: "expendRow"
} }
} }
$("#" + this.id + "Table").table(tableData); $("#" + this.id + "Table").table(tableData);
}, },
/* /*
* 初始化分页 * 初始化分页
*/ */
initPagination: function () { initPagination: function () {
var id = this.id; var id = this.id;
$("#" + id + "Pagination").paginate({ $("#" + id + "Pagination").paginate({
"bind": function(currentPage) { "bind": function(currentPage) {
admin.setHashByPage(currentPage); admin.setHashByPage(currentPage);
return true; return true;
}, },
"currentPage": 1, "currentPage": 1,
"errorMessage": Label.inputErrorLabel, "errorMessage": Label.inputErrorLabel,
"nextPageText": Label.nextPagePabel, "nextPageText": Label.nextPagePabel,
"previousPageText": Label.previousPageLabel, "previousPageText": Label.previousPageLabel,
"goText": Label.gotoLabel, "goText": Label.gotoLabel,
"type": "custom", "type": "custom",
"custom": [1], "custom": [1],
"pageCount": 1 "pageCount": 1
}); });
}, },
/* /*
* 初始化评论对话框 * 初始化评论对话框
*/ */
initCommentsDialog: function () { initCommentsDialog: function () {
var that = this; var that = this;
$("#" + this.id + "Comments").dialog({ $("#" + this.id + "Comments").dialog({
width: 700, width: 700,
height:500, height:500,
"modal": true, "modal": true,
"hideFooter": true, "hideFooter": true,
"close": function () { "close": function () {
admin[that.id + "List"].getList(that.currentPage); admin[that.id + "List"].getList(that.currentPage);
return true; return true;
} }
}); });
}, },
/* /*
* 更新 table & paginateion * 更新 table & paginateion
*/ */
updateTablePagination: function (data, currentPage, pageInfo) { updateTablePagination: function (data, currentPage, pageInfo) {
currentPage = parseInt(currentPage); currentPage = parseInt(currentPage);
if (currentPage > pageInfo.paginationPageCount && currentPage > 1) { if (currentPage > pageInfo.paginationPageCount && currentPage > 1) {
$("#tipMsg").text(Label.pageLabel + ":" + currentPage + " " + Label.noDataLable); $("#tipMsg").text(Label.pageLabel + ":" + currentPage + " " + Label.noDataLable);
$("#loadMsg").text(""); $("#loadMsg").text("");
return; return;
} }
$("#" + this.id + "Table").table("update", { $("#" + this.id + "Table").table("update", {
data: [{ data: [{
groupName: "all", groupName: "all",
groupData: data groupData: data
}] }]
}); });
if (pageInfo.paginationPageCount === 0) { if (pageInfo.paginationPageCount === 0) {
pageInfo.paginationPageCount = 1; pageInfo.paginationPageCount = 1;
} }
$("#" + this.id + "Pagination").paginate("update", { $("#" + this.id + "Pagination").paginate("update", {
pageCount: pageInfo.paginationPageCount, pageCount: pageInfo.paginationPageCount,
currentPage: currentPage, currentPage: currentPage,
custom: pageInfo.paginationPageNums custom: pageInfo.paginationPageNums
}); });
this.currentPage = currentPage; this.currentPage = currentPage;
} }
}); });
\ No newline at end of file
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