/war/src/main/webapp/js/admin/editor.js
JavaScript | 91 lines | 37 code | 8 blank | 46 comment | 1 complexity | 4574198a0cb3fdc716e3e5089487ff98 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-2.1
1/* 2 * Copyright (c) 2009, 2010, 2011, 2012, B3log Team 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16/** 17 * @fileoverview editor 18 * 19 * @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a> 20 * @version 1.0.0.3, Apr 29, 2012 21 */ 22 23admin.editors = {}; 24 25/* 26 * @description Create Editor can use all editor. 27 * e.g: TinyMCE, wnd 28 * @constructor 29 * @param conf ???????? 30 * @param conf.kind ????? simple/all 31 * @param conf.id ??????? id 32 * @param conf.language ??????? 33 * @param conf.type ????? 34 * @param conf.codeMirrorLanguage codeMirror ????????? 35 */ 36var Editor = function (conf) { 37 this._defaults = { 38 type: "tinyMCE", 39 kind: "", 40 id: "", 41 language: "" 42 }; 43 conf.type = Label.editorType; 44 this.conf = conf; 45 this._init(); 46}; 47 48$.extend(Editor.prototype, { 49 /* 50 * @description ??? 51 */ 52 _init: function () { 53 this.init(); 54 }, 55 56 /* 57 * @description ?????? 58 */ 59 init: function () { 60 var conf = this.conf; 61 62 var types = conf.type.split("-"); 63 if (types.length === 2) { 64 conf.codeMirrorLanguage = types[1]; 65 conf.type = types[0]; 66 } 67 admin.editors[conf.type].init(conf); 68 }, 69 70 /* 71 * @description ?????? 72 * @returns {string} ???? 73 */ 74 getContent: function () { 75 var conf = this.conf; 76 return admin.editors[conf.type].getContent(conf.id); 77 }, 78 79 /* 80 * @description ?????? 81 * @param {string} content ??????? 82 */ 83 setContent: function (content) { 84 var conf = this.conf; 85 admin.editors[conf.type].setContent(conf.id, content); 86 } 87}); 88 89admin.editorArticle = {}; 90admin.editorAbstract = {}; 91admin.editorPage = {};