From 27d95bbb7235340788d8f4cd836d5540ae47c4a5 Mon Sep 17 00:00:00 2001 From: st44100 Date: Thu, 4 Jun 2015 18:31:57 +0900 Subject: [PATCH] Fix: Listen textiput event(for IE) --- dist/angular-medium-editor.js | 13 ++++++++++--- dist/angular-medium-editor.min.js | 4 ++-- src/angular-medium-editor.js | 6 +++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/dist/angular-medium-editor.js b/dist/angular-medium-editor.js index 5c02216..fc81fdf 100644 --- a/dist/angular-medium-editor.js +++ b/dist/angular-medium-editor.js @@ -1,3 +1,10 @@ +/** + * angular-medium-editor + * @version v0.1.0 - 2015-06-04 + * @link https://github.com/thijsw/angular-medium-editor + * @author Thijs Wijnmaalen + * @license MIT License, http://www.opensource.org/licenses/MIT + */ 'use strict'; angular.module('angular-medium-editor', []) @@ -58,7 +65,7 @@ angular.module('angular-medium-editor', []) // view -> model iElement.on('blur', onChange); - iElement.on('input', onChange); + iElement.on('input textinput', onChange); // model -> view ctrl.$render = function() { @@ -73,9 +80,9 @@ angular.module('angular-medium-editor', []) } iElement.html(ctrl.$isEmpty(ctrl.$viewValue) ? '' : ctrl.$viewValue); - + // hide placeholder when view is not empty - if(!ctrl.$isEmpty(ctrl.$viewValue)) angular.element(iElement).removeClass('medium-editor-placeholder'); + if(!ctrl.$isEmpty(ctrl.$viewValue)) angular.element(iElement).removeClass('medium-editor-placeholder'); }; } diff --git a/dist/angular-medium-editor.min.js b/dist/angular-medium-editor.min.js index 719ed0b..8a6057e 100644 --- a/dist/angular-medium-editor.min.js +++ b/dist/angular-medium-editor.min.js @@ -1,8 +1,8 @@ /** * angular-medium-editor - * @version v0.1.0 - 2015-04-12 + * @version v0.1.0 - 2015-06-04 * @link https://github.com/thijsw/angular-medium-editor * @author Thijs Wijnmaalen * @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("


"===b.html()||""===b.html()){e.placeholder=f;{new MediumEditor(b,e)}}d.$setViewValue(b.html())})};b.on("blur",h),b.on("input",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")}}}}); \ No newline at end of file +"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("


"===b.html()||""===b.html()){e.placeholder=f;new MediumEditor(b,e)}d.$setViewValue(b.html())})};b.on("blur",h),b.on("input textinput",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")}}}}); \ No newline at end of file diff --git a/src/angular-medium-editor.js b/src/angular-medium-editor.js index 5c02216..f0ac491 100644 --- a/src/angular-medium-editor.js +++ b/src/angular-medium-editor.js @@ -58,7 +58,7 @@ angular.module('angular-medium-editor', []) // view -> model iElement.on('blur', onChange); - iElement.on('input', onChange); + iElement.on('input textinput', onChange); // model -> view ctrl.$render = function() { @@ -73,9 +73,9 @@ angular.module('angular-medium-editor', []) } iElement.html(ctrl.$isEmpty(ctrl.$viewValue) ? '' : ctrl.$viewValue); - + // hide placeholder when view is not empty - if(!ctrl.$isEmpty(ctrl.$viewValue)) angular.element(iElement).removeClass('medium-editor-placeholder'); + if(!ctrl.$isEmpty(ctrl.$viewValue)) angular.element(iElement).removeClass('medium-editor-placeholder'); }; }