revokeDialog.service.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. angular.module('kityminderEditor').service('revokeDialog', ['$modal', 'minder.service', function($modal, minderService) {
  2. minderService.registerEvent(function() {
  3. // 触发导入节点或导出节点对话框
  4. var minder = window.minder;
  5. var editor = window.editor;
  6. var parentFSM = editor.hotbox.getParentFSM();
  7. minder.on('importNodeData', function() {
  8. parentFSM.jump('modal', 'import-text-modal');
  9. var importModal = $modal.open({
  10. animation: true,
  11. templateUrl: 'ui/dialog/imExportNode/imExportNode.tpl.html',
  12. controller: 'imExportNode.ctrl',
  13. size: 'md',
  14. resolve: {
  15. title: function() {
  16. return '导入节点';
  17. },
  18. defaultValue: function() {
  19. return '';
  20. },
  21. type: function() {
  22. return 'import';
  23. }
  24. }
  25. });
  26. importModal.result.then(function(result) {
  27. try{
  28. minder.Text2Children(minder.getSelectedNode(), result);
  29. } catch(e) {
  30. alert(e);
  31. }
  32. parentFSM.jump('normal', 'import-text-finish');
  33. editor.receiver.selectAll();
  34. }, function() {
  35. parentFSM.jump('normal', 'import-text-finish');
  36. editor.receiver.selectAll();
  37. });
  38. });
  39. minder.on('exportNodeData', function() {
  40. parentFSM.jump('modal', 'export-text-modal');
  41. var exportModal = $modal.open({
  42. animation: true,
  43. templateUrl: 'ui/dialog/imExportNode/imExportNode.tpl.html',
  44. controller: 'imExportNode.ctrl',
  45. size: 'md',
  46. resolve: {
  47. title: function() {
  48. return '导出节点';
  49. },
  50. defaultValue: function() {
  51. var selectedNode = minder.getSelectedNode(),
  52. Node2Text = window.kityminder.data.getRegisterProtocol('text').Node2Text;
  53. return Node2Text(selectedNode);
  54. },
  55. type: function() {
  56. return 'export';
  57. }
  58. }
  59. });
  60. exportModal.result.then(function(result) {
  61. parentFSM.jump('normal', 'export-text-finish');
  62. editor.receiver.selectAll();
  63. }, function() {
  64. parentFSM.jump('normal', 'export-text-finish');
  65. editor.receiver.selectAll();
  66. });
  67. });
  68. });
  69. return {};
  70. }]);