GooFlow.attribute.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. var gooflow = {
  2. vars : {},
  3. functions : {},
  4. buttons : {},
  5. // GooFlow 对象
  6. _this : undefined
  7. };
  8. /**
  9. * 初始化节点的属性列表
  10. * @param {Object} type 节点的类型
  11. */
  12. gooflow.functions.initMsgLayer = function(type) {
  13. gooflow.vars.dom.empty();
  14. // 根据不同的节点设置各自的表单
  15. switch (type) {
  16. case "task":
  17. gooflow.functions.switchToTask();
  18. gooflow.functions.replaceTaskFormContent();
  19. break;
  20. default:
  21. break;
  22. }
  23. }
  24. /**
  25. * 显示属性模态框
  26. * @param {Object} nodeData 节点数据
  27. * @param {Object} modal 模态框的DOM元素id或class
  28. */
  29. gooflow.functions.show = function(nodeData, _this) {
  30. gooflow._this = _this
  31. gooflow.vars.dom = $(_this.$modal);
  32. gooflow.vars.json = nodeData;
  33. gooflow.functions.initMsgLayer(nodeData.realtype)
  34. gooflow.vars.dom.fadeIn(0)
  35. }
  36. /**
  37. * 生成任务节点中需要的表单
  38. */
  39. gooflow.functions.switchToTask = function() {
  40. gooflow.vars.dom.append(gooflow_from.taskHtml());
  41. }
  42. gooflow.functions.replaceTaskFormContent = function() {
  43. var dom = gooflow.vars.dom;
  44. dom.find('#name').val(gooflow.vars.json.name)
  45. var html = '';
  46. for (dict in gooflow._this.dict) {
  47. html += '<option value="' + gooflow._this.dict[dict].class + '">' + gooflow._this.dict[dict].name + '</option>';
  48. }
  49. dom.find('#handleType').html(html);
  50. }
  51. /**
  52. * 保存任务节点的属性
  53. */
  54. gooflow.functions.saveTask = function() {
  55. gooflow.vars.json.name = gooflow.vars.dom.find('#name').val();
  56. console.log(gooflow.vars.json,gooflow.vars.dom.find('#name').val());
  57. gooflow._this.setName(gooflow.vars.json.id, gooflow.vars.dom.find('#name').val(),'node')
  58. gooflow.functions.hide();
  59. }
  60. gooflow.functions.hide = function() {
  61. gooflow.vars.dom.hide();
  62. }
  63. gooflow.buttons.closeButton = "<div onclick='gooflow.functions.hide();'>关闭</div>";