/war/src/main/webapp/js/admin/editor.js

http://github.com/b3log/b3log-solo · JavaScript · 91 lines · 37 code · 8 blank · 46 comment · 1 complexity · 4574198a0cb3fdc716e3e5089487ff98 MD5 · raw file

  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. admin.editors = {};
  23. /*
  24. * @description Create Editor can use all editor.
  25. * e.g: TinyMCE, wnd
  26. * @constructor
  27. * @param conf ????????
  28. * @param conf.kind ????? simple/all
  29. * @param conf.id ??????? id
  30. * @param conf.language ???????
  31. * @param conf.type ?????
  32. * @param conf.codeMirrorLanguage codeMirror ?????????
  33. */
  34. var Editor = function (conf) {
  35. this._defaults = {
  36. type: "tinyMCE",
  37. kind: "",
  38. id: "",
  39. language: ""
  40. };
  41. conf.type = Label.editorType;
  42. this.conf = conf;
  43. this._init();
  44. };
  45. $.extend(Editor.prototype, {
  46. /*
  47. * @description ???
  48. */
  49. _init: function () {
  50. this.init();
  51. },
  52. /*
  53. * @description ??????
  54. */
  55. init: function () {
  56. var conf = this.conf;
  57. var types = conf.type.split("-");
  58. if (types.length === 2) {
  59. conf.codeMirrorLanguage = types[1];
  60. conf.type = types[0];
  61. }
  62. admin.editors[conf.type].init(conf);
  63. },
  64. /*
  65. * @description ??????
  66. * @returns {string} ????
  67. */
  68. getContent: function () {
  69. var conf = this.conf;
  70. return admin.editors[conf.type].getContent(conf.id);
  71. },
  72. /*
  73. * @description ??????
  74. * @param {string} content ???????
  75. */
  76. setContent: function (content) {
  77. var conf = this.conf;
  78. admin.editors[conf.type].setContent(conf.id, content);
  79. }
  80. });
  81. admin.editorArticle = {};
  82. admin.editorAbstract = {};
  83. admin.editorPage = {};