mirror of
https://github.com/moparisthebest/mailcatcher
synced 2024-12-22 07:18:53 -05:00
decoration of the message body in iframe's load event handler
This commit is contained in:
parent
ffb4ec4e4c
commit
2f5c2ff01c
@ -23,6 +23,9 @@ class MailCatcher
|
||||
e.preventDefault()
|
||||
@loadMessageAnalysis @selectedMessage()
|
||||
|
||||
$('#message iframe').load =>
|
||||
@decorateMessageBody()
|
||||
|
||||
$('#resizer').live
|
||||
mousedown: (e) ->
|
||||
e.preventDefault()
|
||||
@ -253,16 +256,15 @@ class MailCatcher
|
||||
$('#message iframe').attr "src", "/messages/#{id}.#{format}"
|
||||
|
||||
app = this
|
||||
$('#message iframe').load ( -> app.decorateMessageBody format )
|
||||
|
||||
decorateMessageBody: (format) ->
|
||||
if format == 'html'
|
||||
setTimeout ( ->
|
||||
decorateMessageBody: ->
|
||||
format = $('#message .views .tab.format.selected').attr 'data-message-format'
|
||||
|
||||
switch format
|
||||
when 'html'
|
||||
body = $('#message iframe').contents().find('body')
|
||||
$("a", body).attr("target", "_blank")
|
||||
), 10
|
||||
|
||||
else if format == 'plain'
|
||||
when 'plain'
|
||||
message_iframe = $('#message iframe').contents()
|
||||
text = message_iframe.text()
|
||||
text = text.replace(/((http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?)/g, '<a href="$1" target="_blank">$1</a>')
|
||||
|
@ -36,6 +36,9 @@
|
||||
e.preventDefault();
|
||||
return _this.loadMessageAnalysis(_this.selectedMessage());
|
||||
});
|
||||
$('#message iframe').load(function() {
|
||||
return _this.decorateMessageBody();
|
||||
});
|
||||
$('#resizer').live({
|
||||
mousedown: function(e) {
|
||||
var events;
|
||||
@ -331,22 +334,18 @@
|
||||
$("#message .views .tab:not([data-message-format=\"" + format + "\"]).selected").removeClass('selected');
|
||||
if (id != null) {
|
||||
$('#message iframe').attr("src", "/messages/" + id + "." + format);
|
||||
app = this;
|
||||
return $('#message iframe').load((function() {
|
||||
return app.decorateMessageBody(format);
|
||||
}));
|
||||
return app = this;
|
||||
}
|
||||
};
|
||||
|
||||
MailCatcher.prototype.decorateMessageBody = function(format) {
|
||||
var message_iframe, text;
|
||||
if (format === 'html') {
|
||||
return setTimeout((function() {
|
||||
var body;
|
||||
MailCatcher.prototype.decorateMessageBody = function() {
|
||||
var body, format, message_iframe, text;
|
||||
format = $('#message .views .tab.format.selected').attr('data-message-format');
|
||||
switch (format) {
|
||||
case 'html':
|
||||
body = $('#message iframe').contents().find('body');
|
||||
return $("a", body).attr("target", "_blank");
|
||||
}), 10);
|
||||
} else if (format === 'plain') {
|
||||
case 'plain':
|
||||
message_iframe = $('#message iframe').contents();
|
||||
text = message_iframe.text();
|
||||
text = text.replace(/((http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?)/g, '<a href="$1" target="_blank">$1</a>');
|
||||
|
Loading…
Reference in New Issue
Block a user