1 | System.registerDynamic("src/directive", ["@angular/core", "brace", "brace/theme/monokai", "brace/mode/html"], true, function ($__require, exports, module) {
|
2 | "use strict";
|
3 |
|
4 | var define,
|
5 | global = this || self,
|
6 | GLOBAL = global;
|
7 | var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
|
8 | var c = arguments.length,
|
9 | r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
10 | d;
|
11 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
12 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
13 | };
|
14 | var __metadata = this && this.__metadata || function (k, v) {
|
15 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
16 | };
|
17 | var core_1 = $__require("@angular/core");
|
18 | $__require("brace");
|
19 | $__require("brace/theme/monokai");
|
20 | $__require("brace/mode/html");
|
21 | var AceEditorDirective = function () {
|
22 | function AceEditorDirective(elementRef) {
|
23 | this.textChanged = new core_1.EventEmitter();
|
24 | this.textChange = new core_1.EventEmitter();
|
25 | this._options = {};
|
26 | this._readOnly = false;
|
27 | this._theme = "monokai";
|
28 | this._mode = "html";
|
29 | this._autoUpdateContent = true;
|
30 | this._durationBeforeCallback = 0;
|
31 | this._text = "";
|
32 | var el = elementRef.nativeElement;
|
33 | this.editor = ace["edit"](el);
|
34 | this.init();
|
35 | this.initEvents();
|
36 | }
|
37 | AceEditorDirective.prototype.init = function () {
|
38 | this.editor.setOptions(this._options || {});
|
39 | this.editor.setTheme("ace/theme/" + this._theme);
|
40 | this.setMode(this._mode);
|
41 | this.editor.setReadOnly(this._readOnly);
|
42 | };
|
43 | AceEditorDirective.prototype.initEvents = function () {
|
44 | var _this = this;
|
45 | var me = this;
|
46 | me.editor.on('change', function () {
|
47 | var newVal = _this.editor.getValue();
|
48 | if (newVal === _this.oldText) return;
|
49 | if (typeof me.oldText !== 'undefined') {
|
50 | if (me._durationBeforeCallback == 0) {
|
51 | me._text = newVal;
|
52 | me.textChange.emit(newVal);
|
53 | me.textChanged.emit(newVal);
|
54 | } else {
|
55 | if (me.timeoutSaving != null) clearTimeout(me.timeoutSaving);
|
56 | me.timeoutSaving = setTimeout(function () {
|
57 | me._text = newVal;
|
58 | me.textChange.emit(newVal);
|
59 | me.textChanged.emit(newVal);
|
60 | me.timeoutSaving = null;
|
61 | }, me._durationBeforeCallback);
|
62 | }
|
63 | }
|
64 | _this.oldText = newVal;
|
65 | });
|
66 | };
|
67 | Object.defineProperty(AceEditorDirective.prototype, "options", {
|
68 | set: function (options) {
|
69 | this._options = options;
|
70 | this.editor.setOptions(options || {});
|
71 | },
|
72 | enumerable: true,
|
73 | configurable: true
|
74 | });
|
75 | Object.defineProperty(AceEditorDirective.prototype, "readOnly", {
|
76 | set: function (readOnly) {
|
77 | this._readOnly = readOnly;
|
78 | this.editor.setReadOnly(readOnly);
|
79 | },
|
80 | enumerable: true,
|
81 | configurable: true
|
82 | });
|
83 | Object.defineProperty(AceEditorDirective.prototype, "theme", {
|
84 | set: function (theme) {
|
85 | this._theme = theme;
|
86 | this.editor.setTheme("ace/theme/" + theme);
|
87 | },
|
88 | enumerable: true,
|
89 | configurable: true
|
90 | });
|
91 | Object.defineProperty(AceEditorDirective.prototype, "mode", {
|
92 | set: function (mode) {
|
93 | this.setMode(mode);
|
94 | },
|
95 | enumerable: true,
|
96 | configurable: true
|
97 | });
|
98 | AceEditorDirective.prototype.setMode = function (mode) {
|
99 | this._mode = mode;
|
100 | if (typeof this._mode == 'object') {
|
101 | this.editor.getSession().setMode(this._mode);
|
102 | } else {
|
103 | this.editor.getSession().setMode("ace/mode/" + this._mode);
|
104 | }
|
105 | };
|
106 | Object.defineProperty(AceEditorDirective.prototype, "text", {
|
107 | get: function () {
|
108 | return this._text;
|
109 | },
|
110 | set: function (text) {
|
111 | this.setText(text);
|
112 | },
|
113 | enumerable: true,
|
114 | configurable: true
|
115 | });
|
116 | AceEditorDirective.prototype.setText = function (text) {
|
117 | if (this._text != text) {
|
118 | if (text == null) text = "";
|
119 | if (this._autoUpdateContent == true) {
|
120 | this._text = text;
|
121 | this.editor.setValue(text);
|
122 | }
|
123 | }
|
124 | };
|
125 | Object.defineProperty(AceEditorDirective.prototype, "autoUpdateContent", {
|
126 | set: function (status) {
|
127 | this._autoUpdateContent = status;
|
128 | },
|
129 | enumerable: true,
|
130 | configurable: true
|
131 | });
|
132 | Object.defineProperty(AceEditorDirective.prototype, "durationBeforeCallback", {
|
133 | set: function (num) {
|
134 | this.setDurationBeforeCallback(num);
|
135 | },
|
136 | enumerable: true,
|
137 | configurable: true
|
138 | });
|
139 | AceEditorDirective.prototype.setDurationBeforeCallback = function (num) {
|
140 | this._durationBeforeCallback = num;
|
141 | };
|
142 | Object.defineProperty(AceEditorDirective.prototype, "aceEditor", {
|
143 | get: function () {
|
144 | return this.editor;
|
145 | },
|
146 | enumerable: true,
|
147 | configurable: true
|
148 | });
|
149 | __decorate([core_1.Output(), __metadata('design:type', Object)], AceEditorDirective.prototype, "textChanged", void 0);
|
150 | __decorate([core_1.Output(), __metadata('design:type', Object)], AceEditorDirective.prototype, "textChange", void 0);
|
151 | __decorate([core_1.Input(), __metadata('design:type', Object), __metadata('design:paramtypes', [Object])], AceEditorDirective.prototype, "options", null);
|
152 | __decorate([core_1.Input(), __metadata('design:type', Object), __metadata('design:paramtypes', [Object])], AceEditorDirective.prototype, "readOnly", null);
|
153 | __decorate([core_1.Input(), __metadata('design:type', Object), __metadata('design:paramtypes', [Object])], AceEditorDirective.prototype, "theme", null);
|
154 | __decorate([core_1.Input(), __metadata('design:type', Object), __metadata('design:paramtypes', [Object])], AceEditorDirective.prototype, "mode", null);
|
155 | __decorate([core_1.Input(), __metadata('design:type', Object)], AceEditorDirective.prototype, "text", null);
|
156 | __decorate([core_1.Input(), __metadata('design:type', Object), __metadata('design:paramtypes', [Object])], AceEditorDirective.prototype, "autoUpdateContent", null);
|
157 | __decorate([core_1.Input(), __metadata('design:type', Number), __metadata('design:paramtypes', [Number])], AceEditorDirective.prototype, "durationBeforeCallback", null);
|
158 | AceEditorDirective = __decorate([core_1.Directive({
|
159 | selector: '[ace-editor]'
|
160 | }), __metadata('design:paramtypes', [core_1.ElementRef])], AceEditorDirective);
|
161 | return AceEditorDirective;
|
162 | }();
|
163 | exports.AceEditorDirective = AceEditorDirective;
|
164 | return module.exports;
|
165 | });
|
166 | System.registerDynamic("src/component", ["@angular/core", "brace", "brace/theme/monokai", "brace/mode/html"], true, function ($__require, exports, module) {
|
167 | "use strict";
|
168 |
|
169 | var define,
|
170 | global = this || self,
|
171 | GLOBAL = global;
|
172 | var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
|
173 | var c = arguments.length,
|
174 | r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
175 | d;
|
176 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
177 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
178 | };
|
179 | var __metadata = this && this.__metadata || function (k, v) {
|
180 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
181 | };
|
182 | var core_1 = $__require("@angular/core");
|
183 | $__require("brace");
|
184 | $__require("brace/theme/monokai");
|
185 | $__require("brace/mode/html");
|
186 | var AceEditorComponent = function () {
|
187 | function AceEditorComponent(elementRef) {
|
188 | this.textChanged = new core_1.EventEmitter();
|
189 | this.textChange = new core_1.EventEmitter();
|
190 | this.style = {};
|
191 | this._options = {};
|
192 | this._readOnly = false;
|
193 | this._theme = "monokai";
|
194 | this._mode = "html";
|
195 | this._autoUpdateContent = true;
|
196 | this._durationBeforeCallback = 0;
|
197 | this._text = "";
|
198 | var el = elementRef.nativeElement;
|
199 | this._editor = ace["edit"](el);
|
200 | this.init();
|
201 | this.initEvents();
|
202 | }
|
203 | AceEditorComponent.prototype.init = function () {
|
204 | this.setOptions(this._options || {});
|
205 | this.setTheme(this._theme);
|
206 | this.setMode(this._mode);
|
207 | this.setReadOnly(this._readOnly);
|
208 | };
|
209 | AceEditorComponent.prototype.initEvents = function () {
|
210 | var me = this;
|
211 | me._editor.on('change', function () {
|
212 | var newVal = me._editor.getValue();
|
213 | if (newVal === me.oldText) return;
|
214 | if (typeof me.oldText !== 'undefined') {
|
215 | if (me._durationBeforeCallback == 0) {
|
216 | me._text = newVal;
|
217 | me.textChange.emit(newVal);
|
218 | me.textChanged.emit(newVal);
|
219 | } else {
|
220 | if (me.timeoutSaving != null) clearTimeout(me.timeoutSaving);
|
221 | me.timeoutSaving = setTimeout(function () {
|
222 | me._text = newVal;
|
223 | me.textChange.emit(newVal);
|
224 | me.textChanged.emit(newVal);
|
225 | me.timeoutSaving = null;
|
226 | }, me._durationBeforeCallback);
|
227 | }
|
228 | }
|
229 | me.oldText = newVal;
|
230 | });
|
231 | };
|
232 | Object.defineProperty(AceEditorComponent.prototype, "options", {
|
233 | set: function (options) {
|
234 | this.setOptions(options);
|
235 | },
|
236 | enumerable: true,
|
237 | configurable: true
|
238 | });
|
239 | AceEditorComponent.prototype.setOptions = function (options) {
|
240 | this._options = options;
|
241 | this._editor.setOptions(options || {});
|
242 | };
|
243 | Object.defineProperty(AceEditorComponent.prototype, "readOnly", {
|
244 | set: function (readOnly) {
|
245 | this.setReadOnly(readOnly);
|
246 | },
|
247 | enumerable: true,
|
248 | configurable: true
|
249 | });
|
250 | AceEditorComponent.prototype.setReadOnly = function (readOnly) {
|
251 | this._readOnly = readOnly;
|
252 | this._editor.setReadOnly(readOnly);
|
253 | };
|
254 | Object.defineProperty(AceEditorComponent.prototype, "theme", {
|
255 | set: function (theme) {
|
256 | this.setTheme(theme);
|
257 | },
|
258 | enumerable: true,
|
259 | configurable: true
|
260 | });
|
261 | AceEditorComponent.prototype.setTheme = function (theme) {
|
262 | this._theme = theme;
|
263 | this._editor.setTheme("ace/theme/" + theme);
|
264 | };
|
265 | Object.defineProperty(AceEditorComponent.prototype, "mode", {
|
266 | set: function (mode) {
|
267 | this.setMode(mode);
|
268 | },
|
269 | enumerable: true,
|
270 | configurable: true
|
271 | });
|
272 | AceEditorComponent.prototype.setMode = function (mode) {
|
273 | this._mode = mode;
|
274 | if (typeof this._mode == 'object') {
|
275 | this._editor.getSession().setMode(this._mode);
|
276 | } else {
|
277 | this._editor.getSession().setMode("ace/mode/" + this._mode);
|
278 | }
|
279 | };
|
280 | Object.defineProperty(AceEditorComponent.prototype, "text", {
|
281 | get: function () {
|
282 | return this._text;
|
283 | },
|
284 | set: function (text) {
|
285 | this.setText(text);
|
286 | },
|
287 | enumerable: true,
|
288 | configurable: true
|
289 | });
|
290 | AceEditorComponent.prototype.setText = function (text) {
|
291 | if (this._text != text) {
|
292 | if (text == null) text = "";
|
293 | if (this._autoUpdateContent == true) {
|
294 | this._text = text;
|
295 | this._editor.setValue(text);
|
296 | }
|
297 | }
|
298 | };
|
299 | Object.defineProperty(AceEditorComponent.prototype, "autoUpdateContent", {
|
300 | set: function (status) {
|
301 | this.setAutoUpdateContent(status);
|
302 | },
|
303 | enumerable: true,
|
304 | configurable: true
|
305 | });
|
306 | AceEditorComponent.prototype.setAutoUpdateContent = function (status) {
|
307 | this._autoUpdateContent = status;
|
308 | };
|
309 | Object.defineProperty(AceEditorComponent.prototype, "durationBeforeCallback", {
|
310 | set: function (num) {
|
311 | this.setDurationBeforeCallback(num);
|
312 | },
|
313 | enumerable: true,
|
314 | configurable: true
|
315 | });
|
316 | AceEditorComponent.prototype.setDurationBeforeCallback = function (num) {
|
317 | this._durationBeforeCallback = num;
|
318 | };
|
319 | AceEditorComponent.prototype.getEditor = function () {
|
320 | return this._editor;
|
321 | };
|
322 | __decorate([core_1.Output(), __metadata('design:type', Object)], AceEditorComponent.prototype, "textChanged", void 0);
|
323 | __decorate([core_1.Output(), __metadata('design:type', Object)], AceEditorComponent.prototype, "textChange", void 0);
|
324 | __decorate([core_1.Input(), __metadata('design:type', Object)], AceEditorComponent.prototype, "style", void 0);
|
325 | __decorate([core_1.Input(), __metadata('design:type', Object), __metadata('design:paramtypes', [Object])], AceEditorComponent.prototype, "options", null);
|
326 | __decorate([core_1.Input(), __metadata('design:type', Object), __metadata('design:paramtypes', [Object])], AceEditorComponent.prototype, "readOnly", null);
|
327 | __decorate([core_1.Input(), __metadata('design:type', Object), __metadata('design:paramtypes', [Object])], AceEditorComponent.prototype, "theme", null);
|
328 | __decorate([core_1.Input(), __metadata('design:type', Object), __metadata('design:paramtypes', [Object])], AceEditorComponent.prototype, "mode", null);
|
329 | __decorate([core_1.Input(), __metadata('design:type', Object)], AceEditorComponent.prototype, "text", null);
|
330 | __decorate([core_1.Input(), __metadata('design:type', Object), __metadata('design:paramtypes', [Object])], AceEditorComponent.prototype, "autoUpdateContent", null);
|
331 | __decorate([core_1.Input(), __metadata('design:type', Number), __metadata('design:paramtypes', [Number])], AceEditorComponent.prototype, "durationBeforeCallback", null);
|
332 | AceEditorComponent = __decorate([core_1.Component({
|
333 | selector: 'ace-editor',
|
334 | template: '',
|
335 | styles: [':host { display:block;width:100%; }']
|
336 | }), __metadata('design:paramtypes', [core_1.ElementRef])], AceEditorComponent);
|
337 | return AceEditorComponent;
|
338 | }();
|
339 | exports.AceEditorComponent = AceEditorComponent;
|
340 | return module.exports;
|
341 | });
|
342 | System.registerDynamic('ng2-ace-editor', ['./src/directive', './src/component'], true, function ($__require, exports, module) {
|
343 | "use strict";
|
344 |
|
345 | var define,
|
346 | global = this || self,
|
347 | GLOBAL = global;
|
348 | var directive_1 = $__require('./src/directive');
|
349 | exports.AceEditorDirective = directive_1.AceEditorDirective;
|
350 | var component_1 = $__require('./src/component');
|
351 | exports.AceEditorComponent = component_1.AceEditorComponent;
|
352 | return module.exports;
|
353 | }); |
\ | No newline at end of file |