kityminderViewer.directive.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. angular.module('kityminderEditor')
  2. .directive('kityminderViewer', ['config', 'minder.service', function(config, minderService) {
  3. return {
  4. restrict: 'EA',
  5. templateUrl: 'ui/directive/kityminderViewer/kityminderViewer.html',
  6. replace: true,
  7. scope: {
  8. onInit: '&'
  9. },
  10. link: function(scope, element, attributes) {
  11. var $minderEditor = element.children('.minder-viewer')[0];
  12. function onInit(editor, minder) {
  13. scope.onInit({
  14. editor: editor,
  15. minder: minder
  16. });
  17. minderService.executeCallback();
  18. }
  19. if (window.kityminder && window.kityminder.Editor) {
  20. var editor = new kityminder.Editor($minderEditor);
  21. window.editor = scope.editor = editor;
  22. window.minder = scope.minder = editor.minder;
  23. onInit(editor, editor.minder);
  24. }
  25. }
  26. }
  27. }]);