/* * author: Miller Augusto S. Martins * e-mail: miller.augusto@gmail.com * github: miamarti * */ (function(l,m){angular.module("ng.ckeditor",["ng"]).directive("ngCkeditor",["$timeout",function(g){CKEDITOR.on("instanceCreated",function(a){var d=a.editor;if("simpleEditor"==d.element.getAttribute("class"))d.on("configLoaded",function(){d.config.removePlugins="colorbutton,find,flash,font, forms,iframe,image,newpage,removeformat, smiley,specialchar,stylescombo,templates";d.removeButtons="About";d.config.toolbarGroups=[{name:"editing",groups:["basicstyles","links"]},{name:"undo"},{name:"clipboard", groups:["selection","clipboard"]}]})});return{restrict:"E",scope:{ngModel:"=ngModel",ngChange:"=ngChange",ngDisabled:"=ngDisabled",ngConfig:"=ngConfig"},link:function(a,d,b){d[0].innerHTML='
';var h=d[0].querySelectorAll(".ng-ckeditor"),e={removeButtons:void 0!=b.removeButtons?"About,"+b.removeButtons:"About",readOnly:a.ngDisabled?a.ngDisabled:!1};void 0!=b.removePlugins&&(e.removePlugins=b.removePlugins);void 0!=b.skin&&(e.skin= b.skin);void 0!=b.width&&(e.width=b.width);void 0!=b.height&&(e.height=b.height);void 0!=b.resizeEnabled&&(e.resize_enabled="false"==b.resizeEnabled?!1:!0);var f=CKEDITOR.appendTo(h[0],a.ngConfig?a.ngConfig:e,""),k=function(c){c.on("change",function(c){g(function(){a.ngModel=c.editor.getData()});d&&void 0!==b.msnCount&&(d[0].querySelector(".totalTypedCharacters").innerHTML=b.msnCount+" "+c.editor.getData().length);a.ngChange&&"function"===typeof a.ngChange&&a.ngChange(c.editor.getData())});c.on("focus", function(b){a.ngModel!==c.getData()&&c.setData(a.ngModel)});c.on("key",function(c){g(function(){a.ngModel=c.editor.getData();void 0!=b.msnCount&&(d[0].querySelector(".totalTypedCharacters").innerHTML=b.msnCount+" "+c.editor.getData().length);a.ngChange&&"function"===typeof a.ngChange&&a.ngChange(c.editor.getData())},0)})};k(f);a.$watch("ngModel",function(a){a!==f.getData()&&f.setData(a||"")});a.$watch("ngDisabled",function(b){e.readOnly=b?!0:!1;f.destroy();f=CKEDITOR.appendTo(h[0],a.ngConfig?a.ngConfig: e,"");k(f);f.setData(a.ngModel)})}}}])})(window,document);