您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

52 行
1.2 KiB

  1. wn.make_editable = function(editor, doctype, name, fieldname) {
  2. wn.require("assets/js/editor.min.js");
  3. WebPageEditor = bsEditor.extend({
  4. onhide: function(action) {
  5. this._super(action);
  6. this.toggle_edit_mode(false);
  7. },
  8. setup_editor: function(editor) {
  9. this._super(editor);
  10. this.toggle_edit_mode(false);
  11. },
  12. toggle_edit_mode: function(bool) {
  13. var me = this;
  14. this._super(bool);
  15. if(!bool) {
  16. var $edit_btn = $(repl('<li><a href="#"><i class="icon-fixed-width icon-pencil"></i> Edit %(doctype)s</a></li>\
  17. <li class="divider"></li>', {doctype: doctype}))
  18. .prependTo($("#website-post-login ul.dropdown-menu"));
  19. $edit_btn.find("a")
  20. .on("click", function() {
  21. me.toggle_edit_mode(true);
  22. $edit_btn.remove();
  23. return false;
  24. });
  25. }
  26. }
  27. });
  28. bseditor = new WebPageEditor({
  29. editor: editor,
  30. onsave: function(bseditor) {
  31. wn.call({
  32. type: "POST",
  33. method: "webnotes.client.set_value",
  34. args: {
  35. doctype: doctype,
  36. name: name,
  37. fieldname: fieldname,
  38. value: bseditor.get_value()
  39. },
  40. callback: function(r) {
  41. wn.msgprint(r.exc ? "Error" : "Saved");
  42. if(!r.exc)
  43. editor.html(r.message[0][fieldname]);
  44. }
  45. });
  46. }
  47. });
  48. };