summaryrefslogtreecommitdiffstats
path: root/js/vendor/angular-ui/modules/directives/tinymce/tinymce.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/vendor/angular-ui/modules/directives/tinymce/tinymce.js')
-rw-r--r--js/vendor/angular-ui/modules/directives/tinymce/tinymce.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/js/vendor/angular-ui/modules/directives/tinymce/tinymce.js b/js/vendor/angular-ui/modules/directives/tinymce/tinymce.js
new file mode 100644
index 000000000..a91f1ad34
--- /dev/null
+++ b/js/vendor/angular-ui/modules/directives/tinymce/tinymce.js
@@ -0,0 +1,53 @@
+/**
+ * Binds a TinyMCE widget to <textarea> elements.
+ */
+angular.module('ui.directives').directive('uiTinymce', ['ui.config', function (uiConfig) {
+ uiConfig.tinymce = uiConfig.tinymce || {};
+ return {
+ require: 'ngModel',
+ link: function (scope, elm, attrs, ngModel) {
+ var expression,
+ options = {
+ // Update model on button click
+ onchange_callback: function (inst) {
+ if (inst.isDirty()) {
+ inst.save();
+ ngModel.$setViewValue(elm.val());
+ if (!scope.$$phase)
+ scope.$apply();
+ }
+ },
+ // Update model on keypress
+ handle_event_callback: function (e) {
+ if (this.isDirty()) {
+ this.save();
+ ngModel.$setViewValue(elm.val());
+ if (!scope.$$phase)
+ scope.$apply();
+ }
+ return true; // Continue handling
+ },
+ // Update model when calling setContent (such as from the source editor popup)
+ setup: function (ed) {
+ ed.onSetContent.add(function (ed, o) {
+ if (ed.isDirty()) {
+ ed.save();
+ ngModel.$setViewValue(elm.val());
+ if (!scope.$$phase)
+ scope.$apply();
+ }
+ });
+ }
+ };
+ if (attrs.uiTinymce) {
+ expression = scope.$eval(attrs.uiTinymce);
+ } else {
+ expression = {};
+ }
+ angular.extend(options, uiConfig.tinymce, expression);
+ setTimeout(function () {
+ elm.tinymce(options);
+ });
+ }
+ };
+}]);