From 62d0b48e9660e365502c9882af2ae519b3fe2709 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Mon, 27 Oct 2014 21:31:12 +0300 Subject: [PATCH] Mozilla crash workaround Closes #540 --- app/js/directives.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/app/js/directives.js b/app/js/directives.js index 9dff598f..6ded1e2f 100644 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -868,7 +868,7 @@ angular.module('myApp.directives', ['myApp.filters']) }) - .directive('mySendForm', function ($timeout, $modalStack, Storage, ErrorService, $interpolate) { + .directive('mySendForm', function ($timeout, $modalStack, $http, $interpolate, Storage, ErrorService) { return { link: link, @@ -1055,10 +1055,12 @@ angular.module('myApp.directives', ['myApp.filters']) } function onPastedImageEvent (e) { - var element = e && e.target; - var src; - if (element && (src = element.src) && src.indexOf('data') === 0) { - element.parentNode.removeChild(element); + var element = (e.originalEvent || e).target, + src = (element || {}).src || '', + remove = false; + + if (src.substr(0, 5) == 'data:') { + remove = true; src = src.substr(5).split(';'); var contentType = src[0]; var base64 = atob(src[1].split(',')[1]); @@ -1074,6 +1076,15 @@ angular.module('myApp.directives', ['myApp.filters']) $scope.draftMessage.files = [blob]; $scope.draftMessage.isMedia = true; }); + setZeroTimeout(function () { + element.parentNode.removeChild(element); + }) + } + else if (src && !src.match(/img\/blank\.gif/)) { + var replacementNode = document.createTextNode(' ' + src + ' '); + setTimeout(function () { + element.parentNode.replaceChild(replacementNode, element); + }, 100); } };