kityminderEditor.directive.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. angular.module('kityminderEditor')
  2. .directive('kityminderEditor', ['config', 'minder.service', 'revokeDialog', function(config, minderService, revokeDialog) {
  3. return {
  4. restrict: 'EA',
  5. templateUrl: 'ui/directive/kityminderEditor/kityminderEditor.html',
  6. replace: true,
  7. scope: {
  8. onInit: '&'
  9. },
  10. link: function(scope, element, attributes) {
  11. var $minderEditor = element.children('.minder-editor')[0];
  12. function onInit(editor, minder) {
  13. scope.onInit({
  14. editor: editor,
  15. minder: minder
  16. });
  17. minderService.executeCallback();
  18. }
  19. if (typeof(seajs) != 'undefined') {
  20. /* global seajs */
  21. seajs.config({
  22. base: './src'
  23. });
  24. define('demo', function(require) {
  25. var Editor = require('editor');
  26. var editor = window.editor = new Editor($minderEditor);
  27. if (window.localStorage.__dev_minder_content) {
  28. editor.minder.importJson(JSON.parse(window.localStorage.__dev_minder_content));
  29. }
  30. editor.minder.on('contentchange', function() {
  31. window.localStorage.__dev_minder_content = JSON.stringify(editor.minder.exportJson());
  32. });
  33. window.minder = window.km = editor.minder;
  34. scope.editor = editor;
  35. scope.minder = minder;
  36. scope.config = config.get();
  37. //scope.minder.setDefaultOptions(scope.config);
  38. scope.$apply();
  39. onInit(editor, minder);
  40. });
  41. seajs.use('demo');
  42. } else if (window.kityminder && window.kityminder.Editor) {
  43. var editor = new kityminder.Editor($minderEditor);
  44. window.editor = scope.editor = editor;
  45. window.minder = scope.minder = editor.minder;
  46. scope.config = config.get();
  47. //scope.minder.setDefaultOptions(config.getConfig());
  48. onInit(editor, editor.minder);
  49. }
  50. }
  51. }
  52. }]);