You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

script_manager.js 1.1 KiB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. wn.ui.form.ScriptManager = Class.extend({
  2. init: function(opts) {
  3. $.extend(this, opts);
  4. },
  5. make: function(ControllerClass) {
  6. this.frm.cscript = $.extend(this.frm.cscript, new ControllerClass({frm: this.frm}));
  7. },
  8. trigger: function(event_name, doctype, name) {
  9. doctype = doctype || this.frm.doctype;
  10. name = name || this.frm.docname;
  11. if(this.frm.cscript[event_name])
  12. this.frm.cscript[event_name](this.frm.doc, doctype, name);
  13. if(this.frm.cscript["custom_" + event_name])
  14. this.frm.cscript["custom_" + event_name](this.frm.doc, doctype, name);
  15. },
  16. setup: function() {
  17. var doctype = this.frm.meta;
  18. // js
  19. var cs = doctype.__js;
  20. if(cs) {
  21. var tmp = eval(cs);
  22. }
  23. // css
  24. doctype.__css && wn.dom.set_style(doctype.__css);
  25. },
  26. log_error: function(caller, e) {
  27. show_alert("Error in Client Script.");
  28. console.group && console.group();
  29. console.log("----- error in client script -----");
  30. console.log("method: " + caller);
  31. console.log(e);
  32. console.log("error message: " + e.message);
  33. console.trace && console.trace();
  34. console.log("----- end of error message -----");
  35. console.group && console.groupEnd();
  36. }
  37. })