mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-04 15:24:23 +01:00
8 lines
1.2 KiB
JavaScript
8 lines
1.2 KiB
JavaScript
/**
|
|
* angular-medium-editor
|
|
* @version v0.1.1 - 2015-11-23
|
|
* @link https://github.com/thijsw/angular-medium-editor
|
|
* @author Thijs Wijnmaalen <thijs@wijnmaalen.name>
|
|
* @license MIT License, http://www.opensource.org/licenses/MIT
|
|
*/
|
|
"use strict";angular.module("angular-medium-editor",[]).directive("mediumEditor",function(){return{require:"ngModel",restrict:"AE",scope:{bindOptions:"="},link:function(a,b,c,d){angular.element(b).addClass("angular-medium-editor");var e={},f="",g=function(){c.options&&(e=a.$eval(c.options));var b={};void 0!==a.bindOptions&&(b=a.bindOptions),e=angular.extend(e,b)};g(),f=e.placeholder,a.$watch("bindOptions",function(){d.editor&&d.editor.destroy(),g(),d.$isEmpty(d.$viewValue)||(e.placeholder=""),d.editor=new MediumEditor(b,e)});var h=function(){a.$apply(function(){if("<p><br></p>"===b.html()||""===b.html()){e.placeholder=f;{new MediumEditor(b,e)}}d.$setViewValue(b.html())})};b.on("blur",h),b.on("input",h),b.on("paste",h),d.$render=function(){this.editor||(d.$isEmpty(d.$viewValue)||(e.placeholder=""),this.editor=new MediumEditor(b,e)),b.html(d.$isEmpty(d.$viewValue)?"":d.$viewValue),d.$isEmpty(d.$viewValue)||angular.element(b).removeClass("medium-editor-placeholder")}}}}); |