mirror of
https://github.com/moparisthebest/mailcatcher
synced 2024-12-22 07:18:53 -05:00
save separator sizing in localStorage if available
This commit is contained in:
parent
7cc20ce471
commit
3ffa6a3237
@ -24,16 +24,17 @@ class MailCatcher
|
||||
@loadMessageAnalysis @selectedMessage()
|
||||
|
||||
$('#resizer').live
|
||||
mousedown: (e) ->
|
||||
mousedown: (e) =>
|
||||
e.preventDefault()
|
||||
$(window).bind events =
|
||||
mouseup: (e) ->
|
||||
mouseup: (e) =>
|
||||
e.preventDefault()
|
||||
$(window).unbind events
|
||||
mousemove: (e) ->
|
||||
mousemove: (e) =>
|
||||
e.preventDefault()
|
||||
$('#messages').css
|
||||
height: e.clientY - $('#messages').offset().top
|
||||
@resizeTo e.clientY
|
||||
|
||||
@resizeToSaved()
|
||||
|
||||
$('nav.app .clear a').live 'click', (e) =>
|
||||
e.preventDefault()
|
||||
@ -307,5 +308,16 @@ class MailCatcher
|
||||
unless @refreshInterval?
|
||||
@refreshInterval = setInterval (=> @refresh()), 1000
|
||||
|
||||
resizeToSavedKey: 'mailcatcherSeparatorHeight'
|
||||
|
||||
resizeTo: (height) ->
|
||||
$('#messages').css
|
||||
height: height - $('#messages').offset().top
|
||||
window.localStorage?.setItem(@resizeToSavedKey, height)
|
||||
|
||||
resizeToSaved: ->
|
||||
height = parseInt(window.localStorage?.getItem(@resizeToSavedKey))
|
||||
unless isNaN height
|
||||
@resizeTo height
|
||||
|
||||
$ -> window.MailCatcher = new MailCatcher
|
||||
|
@ -58,13 +58,12 @@
|
||||
},
|
||||
mousemove: function(e) {
|
||||
e.preventDefault();
|
||||
return $('#messages').css({
|
||||
height: e.clientY - $('#messages').offset().top
|
||||
});
|
||||
return _this.resizeTo(e.clientY);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
this.resizeToSaved();
|
||||
$('nav.app .clear a').live('click', function(e) {
|
||||
e.preventDefault();
|
||||
if (confirm("You will lose all your received messages.\n\nAre you sure you want to clear all messages?")) {
|
||||
@ -397,6 +396,24 @@
|
||||
}
|
||||
};
|
||||
|
||||
MailCatcher.prototype.resizeToSavedKey = 'mailcatcherSeparatorHeight';
|
||||
|
||||
MailCatcher.prototype.resizeTo = function(height) {
|
||||
var _ref;
|
||||
$('#messages').css({
|
||||
height: height - $('#messages').offset().top
|
||||
});
|
||||
return (_ref = window.localStorage) != null ? _ref.setItem(this.resizeToSavedKey, height) : void 0;
|
||||
};
|
||||
|
||||
MailCatcher.prototype.resizeToSaved = function() {
|
||||
var height, _ref;
|
||||
height = parseInt((_ref = window.localStorage) != null ? _ref.getItem(this.resizeToSavedKey) : void 0);
|
||||
if (!isNaN(height)) {
|
||||
return this.resizeTo(height);
|
||||
}
|
||||
};
|
||||
|
||||
return MailCatcher;
|
||||
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user