Skip to content

Commit

Permalink
[mms] Automatically try to rotate embedded inline images when display…
Browse files Browse the repository at this point in the history
…ing a message.

Do this on the browser side instead of the server side.

Today I learned that it is very difficult to deal with binary data
returned in an XHR request in javascript.  Very frustrating.
  • Loading branch information
slusarz committed Jan 8, 2015
1 parent f44fa15 commit 8270ee8
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 16 deletions.
2 changes: 2 additions & 0 deletions imp/docs/CHANGES
Expand Up @@ -2,6 +2,8 @@
v7.0.0-git
----------

[mms] Automatically try to rotate embedded inline images when displaying a
message.
[mms] Add ability to add email groups to the address book.
[mms] Improved contacts loading - all contacts are never shown by default, but
provide simple method for user to load all contacts.
Expand Down
35 changes: 34 additions & 1 deletion imp/js/core.js
Expand Up @@ -193,8 +193,41 @@ var ImpCore = {
case 'html':
IMP_JS.iframeInject(a[1], a[2]);
break;

case 'image':
new Ajax.Request(a[2], {
method: 'get',
onFailure: function(r) {
loadImage(a[2], function(img) {
$(a[1]).replace(img);
});
},
onSuccess: function(r) {
var blob, i,
d = Base64.atob(r.responseText),
b = new Uint8Array(d.length);
for (i = 0; i < d.length; ++i) {
b[i] = d.charCodeAt(i);
}
blob = new Blob(
[ b ],
{ type: r.getResponseHeader('content-type') }
);
loadImage.parseMetaData(blob, function(data) {
loadImage(blob, function(img) {
$(a[1]).replace(img);
}, {
orientation: (data.exif && data.exif.get('Orientation')) || 1
});
});
},
parameters: {
imp_img_base64: 1
}
});
break;
}
});
}, this);
},

updateAtcList: function(atc)
Expand Down
10 changes: 10 additions & 0 deletions imp/js/external/load-image.all.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8270ee8

Please sign in to comment.