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
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview KindEditor
*
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @version 1.0.0.1, May 2, 2012
*/
admin.editors.KindEditor = {
/*
* @description 初始化编辑器
* @param conf 编辑器初始化参数
* @param conf.kind 编辑器类型
* @param conf.id 编辑器渲染元素 id
* @param conf.fun 编辑器首次加载完成后回调函数
*/
init: function (conf) {
var language = "zh_CN";
if ("en_US" === Label.localeString) {
language = "en"
}
if (conf.kind && conf.kind === "simple") {
try {
this[conf.id] = KindEditor.create('#' + conf.id, {
langType : language,
resizeType: 0,
items: ["bold", "italic", "underline", "strikethrough", "|", "undo", "redo", "|",
"insertunorderedlist", "insertorderedlist",
]
});
} catch (e) {
$("#tipMsg").text("KindEditor load fail");
}
} else {
try {
this[conf.id] = KindEditor.create('#' + conf.id, {
langType : language,
items: ["formatblock", "fontname", "fontsize", "|", "bold", "italic", "underline", "strikethrough", "forecolor", "|",
"link", "unlink", "image", "media", "|", "pagebreak", "emoticons", "code", "/",
"undo", "redo", "|", "insertunorderedlist", "insertorderedlist", "indent", "outdent", "|",
"justifyleft", "justifycenter", "justifyright", "justifyfull", "|", "plainpaste", "wordpaste", "|",
"clearhtml", "source", "preview"
],
afterCreate: function () {
if (typeof(conf.fun) === "function") {
conf.fun();
}
}
});
} catch (e) {
$("#tipMsg").text("KindEditor load fail");
}
}
},
/*
* @description 获取编辑器值
* @param {string} id 编辑器id
* @returns {string} 编辑器值
*/
getContent: function (id) {
var content = "";
try {
content = this[id].html();
} catch (e) {
content = $("#" + id).val();
}
return content;
},
/*
* @description 设置编辑器值
* @param {string} id 编辑器 id
* @param {string} content 设置编辑器值
*/
setContent: function (id, content) {
try {
this[id].html(content);
} catch (e) {
$("#" + id).val(content);
}
}
/*
* Copyright (c) 2009, 2010, 2011, 2012, B3log Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview KindEditor
*
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @version 1.0.0.1, May 2, 2012
*/
admin.editors.KindEditor = {
/*
* @description 初始化编辑器
* @param conf 编辑器初始化参数
* @param conf.kind 编辑器类型
* @param conf.id 编辑器渲染元素 id
* @param conf.fun 编辑器首次加载完成后回调函数
*/
init: function (conf) {
var language = "zh_CN";
if ("en_US" === Label.localeString) {
language = "en"
}
if (conf.kind && conf.kind === "simple") {
try {
this[conf.id] = KindEditor.create('#' + conf.id, {
langType : language,
resizeType: 0,
items: ["bold", "italic", "underline", "strikethrough", "|", "undo", "redo", "|",
"insertunorderedlist", "insertorderedlist",
]
});
} catch (e) {
$("#tipMsg").text("KindEditor load fail");
}
} else {
try {
this[conf.id] = KindEditor.create('#' + conf.id, {
langType : language,
items: ["formatblock", "fontname", "fontsize", "|", "bold", "italic", "underline", "strikethrough", "forecolor", "|",
"link", "unlink", "image", "media", "|", "pagebreak", "emoticons", "code", "/",
"undo", "redo", "|", "insertunorderedlist", "insertorderedlist", "indent", "outdent", "|",
"justifyleft", "justifycenter", "justifyright", "justifyfull", "|", "plainpaste", "wordpaste", "|",
"clearhtml", "source", "preview"
],
afterCreate: function () {
if (typeof(conf.fun) === "function") {
conf.fun();
}
}
});
} catch (e) {
$("#tipMsg").text("KindEditor load fail");
}
}
},
/*
* @description 获取编辑器值
* @param {string} id 编辑器id
* @returns {string} 编辑器值
*/
getContent: function (id) {
var content = "";
try {
content = this[id].html();
} catch (e) {
content = $("#" + id).val();
}
return content;
},
/*
* @description 设置编辑器值
* @param {string} id 编辑器 id
* @param {string} content 设置编辑器值
*/
setContent: function (id, content) {
try {
this[id].html(content);
} catch (e) {
$("#" + id).val(content);
}
}
};
\ No newline at end of file
/*
* Copyright (c) 2009, 2010, 2011, 2012, B3log Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview tinyMCE editor
*
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @version 1.0.0.4, May 9, 2012
*/
admin.editors.tinyMCE = {
/*
* @description 初始化编辑器
* @param conf 编辑器初始化参数
* @param conf.kind 编辑器类型
* @param conf.id 编辑器渲染元素 id
* @param conf.fun 编辑器首次加载完成后回调函数
*/
init: function (conf) {
var language = Label.localeString.substring(0, 2);
if (language === "zh") {
language = "zh-cn";
}
if (conf.kind && conf.kind === "simple") {
try {
tinyMCE.init({
// General options
language: language,
mode : "exact",
elements : conf.id,
theme : "advanced",
// Theme options
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,undo,redo,|,bullist,numlist",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
valid_children : "+body[style]"
});
} catch (e) {
$("#tipMsg").text("TinyMCE load fail");
}
} else {
try {
tinyMCE.init({
// General options
language: language,
mode : "exact",
elements : conf.id,
theme : "advanced",
plugins : "autosave,style,advhr,advimage,advlink,preview,inlinepopups,media,paste,syntaxhl,wordcount",
// Theme options
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_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_resizing : true,
theme_advanced_statusbar_location : "bottom",
extended_valid_elements: "link[type|rel|href|charset],pre[name|class],iframe[src|width|height|name|align],+a[*]",
valid_children : "+body[style]",
relative_urls: false,
remove_script_host: false,
oninit : function () {
if (typeof(conf.fun) === "function") {
conf.fun();
}
}
});
} catch (e) {
$("#tipMsg").text("TinyMCE load fail");
}
}
},
/*
* @description 获取编辑器值
* @param {string} id 编辑器id
* @returns {string} 编辑器值
*/
getContent: function (id) {
var content = "";
try {
content = tinyMCE.get(id).getContent();
} catch (e) {
content = $("#" + id).val();
}
return content;
},
/*
* @description 设置编辑器值
* @param {string} id 编辑器 id
* @param {string} content 设置编辑器值
*/
setContent: function (id, content) {
try {
if (tinyMCE.get(id)) {
tinyMCE.get(id).setContent(content);
} else {
$("#" + id).val(content);
}
} catch (e) {
$("#" + id).val(content);
}
}
/*
* Copyright (c) 2009, 2010, 2011, 2012, B3log Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview tinyMCE editor
*
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @version 1.0.0.4, May 9, 2012
*/
admin.editors.tinyMCE = {
/*
* @description 初始化编辑器
* @param conf 编辑器初始化参数
* @param conf.kind 编辑器类型
* @param conf.id 编辑器渲染元素 id
* @param conf.fun 编辑器首次加载完成后回调函数
*/
init: function (conf) {
var language = Label.localeString.substring(0, 2);
if (language === "zh") {
language = "zh-cn";
}
if (conf.kind && conf.kind === "simple") {
try {
tinyMCE.init({
// General options
language: language,
mode : "exact",
elements : conf.id,
theme : "advanced",
// Theme options
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,undo,redo,|,bullist,numlist",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
valid_children : "+body[style]"
});
} catch (e) {
$("#tipMsg").text("TinyMCE load fail");
}
} else {
try {
tinyMCE.init({
// General options
language: language,
mode : "exact",
elements : conf.id,
theme : "advanced",
plugins : "autosave,style,advhr,advimage,advlink,preview,inlinepopups,media,paste,syntaxhl,wordcount",
// Theme options
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_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_resizing : true,
theme_advanced_statusbar_location : "bottom",
extended_valid_elements: "link[type|rel|href|charset],pre[name|class],iframe[src|width|height|name|align],+a[*]",
valid_children : "+body[style]",
relative_urls: false,
remove_script_host: false,
oninit : function () {
if (typeof(conf.fun) === "function") {
conf.fun();
}
}
});
} catch (e) {
$("#tipMsg").text("TinyMCE load fail");
}
}
},
/*
* @description 获取编辑器值
* @param {string} id 编辑器id
* @returns {string} 编辑器值
*/
getContent: function (id) {
var content = "";
try {
content = tinyMCE.get(id).getContent();
} catch (e) {
content = $("#" + id).val();
}
return content;
},
/*
* @description 设置编辑器值
* @param {string} id 编辑器 id
* @param {string} content 设置编辑器值
*/
setContent: function (id, content) {
try {
if (tinyMCE.get(id)) {
tinyMCE.get(id).setContent(content);
} else {
$("#" + id).val(content);
}
} catch (e) {
$("#" + 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
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* table and paginate util
*
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @version 1.0.0.7, Nov 8, 2011
*/
var TablePaginate = function (id) {
this.id = id;
this.currentPage = 1;
};
$.extend(TablePaginate.prototype, {
/*
* 构建 table 框架
* @colModel table 列宽,标题等数据
*/
buildTable: function (colModel, noExpend) {
var tableData = {
colModel: colModel,
noDataTip: Label.noDataLabel
}
if (!noExpend) {
tableData.expendRow = {
index: "expendRow"
}
}
$("#" + this.id + "Table").table(tableData);
},
/*
* 初始化分页
*/
initPagination: function () {
var id = this.id;
$("#" + id + "Pagination").paginate({
"bind": function(currentPage) {
admin.setHashByPage(currentPage);
return true;
},
"currentPage": 1,
"errorMessage": Label.inputErrorLabel,
"nextPageText": Label.nextPagePabel,
"previousPageText": Label.previousPageLabel,
"goText": Label.gotoLabel,
"type": "custom",
"custom": [1],
"pageCount": 1
});
},
/*
* 初始化评论对话框
*/
initCommentsDialog: function () {
var that = this;
$("#" + this.id + "Comments").dialog({
width: 700,
height:500,
"modal": true,
"hideFooter": true,
"close": function () {
admin[that.id + "List"].getList(that.currentPage);
return true;
}
});
},
/*
* 更新 table & paginateion
*/
updateTablePagination: function (data, currentPage, pageInfo) {
currentPage = parseInt(currentPage);
if (currentPage > pageInfo.paginationPageCount && currentPage > 1) {
$("#tipMsg").text(Label.pageLabel + ":" + currentPage + " " + Label.noDataLable);
$("#loadMsg").text("");
return;
}
$("#" + this.id + "Table").table("update", {
data: [{
groupName: "all",
groupData: data
}]
});
if (pageInfo.paginationPageCount === 0) {
pageInfo.paginationPageCount = 1;
}
$("#" + this.id + "Pagination").paginate("update", {
pageCount: pageInfo.paginationPageCount,
currentPage: currentPage,
custom: pageInfo.paginationPageNums
});
this.currentPage = currentPage;
}
/*
* Copyright (c) 2009, 2010, 2011, 2012, B3log Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* table and paginate util
*
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @version 1.0.0.7, Nov 8, 2011
*/
var TablePaginate = function (id) {
this.id = id;
this.currentPage = 1;
};
$.extend(TablePaginate.prototype, {
/*
* 构建 table 框架
* @colModel table 列宽,标题等数据
*/
buildTable: function (colModel, noExpend) {
var tableData = {
colModel: colModel,
noDataTip: Label.noDataLabel
}
if (!noExpend) {
tableData.expendRow = {
index: "expendRow"
}
}
$("#" + this.id + "Table").table(tableData);
},
/*
* 初始化分页
*/
initPagination: function () {
var id = this.id;
$("#" + id + "Pagination").paginate({
"bind": function(currentPage) {
admin.setHashByPage(currentPage);
return true;
},
"currentPage": 1,
"errorMessage": Label.inputErrorLabel,
"nextPageText": Label.nextPagePabel,
"previousPageText": Label.previousPageLabel,
"goText": Label.gotoLabel,
"type": "custom",
"custom": [1],
"pageCount": 1
});
},
/*
* 初始化评论对话框
*/
initCommentsDialog: function () {
var that = this;
$("#" + this.id + "Comments").dialog({
width: 700,
height:500,
"modal": true,
"hideFooter": true,
"close": function () {
admin[that.id + "List"].getList(that.currentPage);
return true;
}
});
},
/*
* 更新 table & paginateion
*/
updateTablePagination: function (data, currentPage, pageInfo) {
currentPage = parseInt(currentPage);
if (currentPage > pageInfo.paginationPageCount && currentPage > 1) {
$("#tipMsg").text(Label.pageLabel + ":" + currentPage + " " + Label.noDataLable);
$("#loadMsg").text("");
return;
}
$("#" + this.id + "Table").table("update", {
data: [{
groupName: "all",
groupData: data
}]
});
if (pageInfo.paginationPageCount === 0) {
pageInfo.paginationPageCount = 1;
}
$("#" + this.id + "Pagination").paginate("update", {
pageCount: pageInfo.paginationPageCount,
currentPage: currentPage,
custom: pageInfo.paginationPageNums
});
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