-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathangular-orion-directive.js
More file actions
38 lines (31 loc) · 1.24 KB
/
angular-orion-directive.js
File metadata and controls
38 lines (31 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'use strict';
angular.module('angular.directives-orion', []).directive('angOrion', [function () {
var compilationFunction = function (templateElement, templateAttributes, transclude) {
if (templateElement.length === 1) {
var domElement = templateElement[0];
var editorClassName = domElement.getAttribute('editor-class');
require(["orion/editor/edit"], function(edit) {
edit({className: editorClassName});
});
var orionEditor = document.createElement("pre");
orionEditor.innerHTML = 'var aVariable = "Hello World!"';
orionEditor.setAttribute('class', editorClassName);
orionEditor.setAttribute('data-editor-lang', 'js');
orionEditor.setAttribute('data-editor-title', 'Eclipse Orion');
domElement.parentNode.replaceChild(orionEditor, domElement);
}
return {
pre: function preLink(scope, instanceElement, instanceAttributes, controller) {
var data = scope[domElement.getAttribute('editor-model')];
instanceElement[0].innerHTML = data;
},
post: function postLink(scope, instanceElement, instanceAttributes, controller) {}
};
};
var orion = {
restrict: 'E',
compile: compilationFunction,
replace: true
};
return orion;
}]);