mirror of
https://github.com/moparisthebest/mailcatcher
synced 2024-12-22 07:18:53 -05:00
Make sure to prevent default link behaviour for tabs.
This commit is contained in:
parent
51e74fdac2
commit
4ba18f7296
@ -1,10 +1,12 @@
|
|||||||
class MailCatcher
|
class MailCatcher
|
||||||
constructor: ->
|
constructor: ->
|
||||||
$('#messages tr').live 'click', (e) =>
|
$('#messages tr').live 'click', (e) =>
|
||||||
|
e.preventDefault()
|
||||||
@loadMessage $(e.currentTarget).attr 'data-message-id'
|
@loadMessage $(e.currentTarget).attr 'data-message-id'
|
||||||
|
|
||||||
$('#message .views .tab').live 'click', (e) =>
|
$('#message .views .format.tab a').live 'click', (e) =>
|
||||||
@loadMessageBody $('#messages tr.selected').attr('data-message-id'), $(e.currentTarget).attr 'data-message-format'
|
e.preventDefault()
|
||||||
|
@loadMessageBody @selectedMessage(), $($(e.currentTarget).parent('li')).data 'message-format'
|
||||||
|
|
||||||
$('#resizer').live
|
$('#resizer').live
|
||||||
mousedown: (e) ->
|
mousedown: (e) ->
|
||||||
@ -57,6 +59,9 @@ class MailCatcher
|
|||||||
message = message.id if message.id?
|
message = message.id if message.id?
|
||||||
$("#messages tbody tr[data-message-id=\"#{message}\"]").length > 0
|
$("#messages tbody tr[data-message-id=\"#{message}\"]").length > 0
|
||||||
|
|
||||||
|
selectedMessage: ->
|
||||||
|
$('#messages tr.selected').data 'message-id'
|
||||||
|
|
||||||
addMessage: (message) ->
|
addMessage: (message) ->
|
||||||
$('#messages tbody').append \
|
$('#messages tbody').append \
|
||||||
$('<tr />').attr('data-message-id', message.id.toString())
|
$('<tr />').attr('data-message-id', message.id.toString())
|
||||||
@ -104,7 +109,7 @@ class MailCatcher
|
|||||||
@loadMessageBody()
|
@loadMessageBody()
|
||||||
|
|
||||||
loadMessageBody: (id, format) ->
|
loadMessageBody: (id, format) ->
|
||||||
id ||= $('#messages tr.selected').attr 'data-message-id'
|
id ||= @selectedMessage()
|
||||||
format ||= $('#message .views .tab.format.selected').attr 'data-message-format'
|
format ||= $('#message .views .tab.format.selected').attr 'data-message-format'
|
||||||
format ||= 'html'
|
format ||= 'html'
|
||||||
|
|
||||||
|
@ -4,10 +4,12 @@
|
|||||||
MailCatcher = (function() {
|
MailCatcher = (function() {
|
||||||
function MailCatcher() {
|
function MailCatcher() {
|
||||||
$('#messages tr').live('click', __bind(function(e) {
|
$('#messages tr').live('click', __bind(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
return this.loadMessage($(e.currentTarget).attr('data-message-id'));
|
return this.loadMessage($(e.currentTarget).attr('data-message-id'));
|
||||||
}, this));
|
}, this));
|
||||||
$('#message .views .tab').live('click', __bind(function(e) {
|
$('#message .views .format.tab a').live('click', __bind(function(e) {
|
||||||
return this.loadMessageBody($('#messages tr.selected').attr('data-message-id'), $(e.currentTarget).attr('data-message-format'));
|
e.preventDefault();
|
||||||
|
return this.loadMessageBody(this.selectedMessage(), $($(e.currentTarget).parent('li')).data('message-format'));
|
||||||
}, this));
|
}, this));
|
||||||
$('#resizer').live({
|
$('#resizer').live({
|
||||||
mousedown: function(e) {
|
mousedown: function(e) {
|
||||||
@ -78,6 +80,9 @@
|
|||||||
}
|
}
|
||||||
return $("#messages tbody tr[data-message-id=\"" + message + "\"]").length > 0;
|
return $("#messages tbody tr[data-message-id=\"" + message + "\"]").length > 0;
|
||||||
};
|
};
|
||||||
|
MailCatcher.prototype.selectedMessage = function() {
|
||||||
|
return $('#messages tr.selected').data('message-id');
|
||||||
|
};
|
||||||
MailCatcher.prototype.addMessage = function(message) {
|
MailCatcher.prototype.addMessage = function(message) {
|
||||||
return $('#messages tbody').append($('<tr />').attr('data-message-id', message.id.toString()).append($('<td/>').text(message.sender || "No sender").toggleClass("blank", !message.sender)).append($('<td/>').text((message.recipients || []).join(', ') || "No receipients").toggleClass("blank", !message.recipients.length)).append($('<td/>').text(message.subject || "No subject").toggleClass("blank", !message.subject)).append($('<td/>').text(this.formatDate(message.created_at))));
|
return $('#messages tbody').append($('<tr />').attr('data-message-id', message.id.toString()).append($('<td/>').text(message.sender || "No sender").toggleClass("blank", !message.sender)).append($('<td/>').text((message.recipients || []).join(', ') || "No receipients").toggleClass("blank", !message.recipients.length)).append($('<td/>').text(message.subject || "No subject").toggleClass("blank", !message.subject)).append($('<td/>').text(this.formatDate(message.created_at))));
|
||||||
};
|
};
|
||||||
@ -124,7 +129,7 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
MailCatcher.prototype.loadMessageBody = function(id, format) {
|
MailCatcher.prototype.loadMessageBody = function(id, format) {
|
||||||
id || (id = $('#messages tr.selected').attr('data-message-id'));
|
id || (id = this.selectedMessage());
|
||||||
format || (format = $('#message .views .tab.format.selected').attr('data-message-format'));
|
format || (format = $('#message .views .tab.format.selected').attr('data-message-format'));
|
||||||
format || (format = 'html');
|
format || (format = 'html');
|
||||||
$("#message .views .tab[data-message-format=\"" + format + "\"]:not(.selected)").addClass('selected');
|
$("#message .views .tab[data-message-format=\"" + format + "\"]:not(.selected)").addClass('selected');
|
||||||
|
Loading…
Reference in New Issue
Block a user