Browse Source

Mozilla crash workaround

Closes #540
master
Igor Zhukov 10 years ago
parent
commit
62d0b48e96
  1. 21
      app/js/directives.js

21
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 { return {
link: link, link: link,
@ -1055,10 +1055,12 @@ angular.module('myApp.directives', ['myApp.filters'])
} }
function onPastedImageEvent (e) { function onPastedImageEvent (e) {
var element = e && e.target; var element = (e.originalEvent || e).target,
var src; src = (element || {}).src || '',
if (element && (src = element.src) && src.indexOf('data') === 0) { remove = false;
element.parentNode.removeChild(element);
if (src.substr(0, 5) == 'data:') {
remove = true;
src = src.substr(5).split(';'); src = src.substr(5).split(';');
var contentType = src[0]; var contentType = src[0];
var base64 = atob(src[1].split(',')[1]); var base64 = atob(src[1].split(',')[1]);
@ -1074,6 +1076,15 @@ angular.module('myApp.directives', ['myApp.filters'])
$scope.draftMessage.files = [blob]; $scope.draftMessage.files = [blob];
$scope.draftMessage.isMedia = true; $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);
} }
}; };

Loading…
Cancel
Save