diff --git a/public/javascripts/application.coffee b/public/javascripts/application.coffee index ff42833..b316564 100644 --- a/public/javascripts/application.coffee +++ b/public/javascripts/application.coffee @@ -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 diff --git a/public/javascripts/application.js b/public/javascripts/application.js index ba66c46..9b26d24 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -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; })();