diff --git a/pinry/static/css/messages.css b/pinry/static/css/messages.css index e16fb7a..fee7b2e 100644 --- a/pinry/static/css/messages.css +++ b/pinry/static/css/messages.css @@ -1,19 +1,19 @@ -.messages { +#messages { list-style-type: none; position: absolute; right: 10px; - top: 50px; + top: 60px; z-index: 200; } -.messages li { +#messages li { border: 1px solid #ccc; font-size: 16px - margin: 10px 0; + margin: 5px 0; padding: 18px 28px; } -.messages li:hover { +#messages li:hover { cursor: pointer; -webkit-transform: scale(1.1); -moz-transform: scale(1.1); diff --git a/pinry/static/js/lightbox.js b/pinry/static/js/lightbox.js index 0dadd86..ca2465e 100644 --- a/pinry/static/js/lightbox.js +++ b/pinry/static/js/lightbox.js @@ -75,6 +75,9 @@ $(window).load(function() { promise.success(function(pin) { createBox(pin); }); + promise.error(function() { + message('Problem problem fetching pin data.', 'alert alert-error'); + }); }); }); } diff --git a/pinry/static/js/messages.js b/pinry/static/js/messages.js index 0284a5c..10b6f89 100644 --- a/pinry/static/js/messages.js +++ b/pinry/static/js/messages.js @@ -1,12 +1,17 @@ $(document).ready(function() { - var delayTime = 3000, - alerts = $('.alert'); - - delayTime = delayTime + (alerts.length * 250); - - alerts.each(function() { - $(this).delay(delayTime).fadeOut('slow'); - delayTime -= 250; - console.log(delayTime); - }); + window.message = function(text, classes) { + classes = typeof classes !== 'undefined' ? classes : 'alert'; + messageHtml = renderTemplate('#messages-template', { + text: text, + classes: classes + }); + $('#messages').append(messageHtml); + $('#messages li').each(function() { + $(this).delay(3000).fadeOut(300); + var messageDelayed = $(this); + setTimeout(function() { + messageDelayed.remove(); + }, 3300); + }); + } }); diff --git a/pinry/static/js/pin-form.js b/pinry/static/js/pin-form.js index 4f13610..3983076 100644 --- a/pinry/static/js/pin-form.js +++ b/pinry/static/js/pin-form.js @@ -86,6 +86,9 @@ $(window).load(function() { $('#pin-form-image-url').val(image.thumbnail.image); createPinPreviewFromForm(); }); + promise.error(function() { + message('Problem uploading image.', 'alert alert-error'); + }); }); // If bookmarklet submit if (pinFromUrl) { @@ -118,6 +121,9 @@ $(window).load(function() { dismissModal(modal); uploadedImage = false; }); + promise.error(function() { + message('Problem saving image.', 'alert alert-error'); + }); }); $('#pin-form-close').click(function() { if (pinFromUrl) return window.close(); diff --git a/pinry/static/js/pinry.js b/pinry/static/js/pinry.js index ab8c019..953bc70 100644 --- a/pinry/static/js/pinry.js +++ b/pinry/static/js/pinry.js @@ -58,6 +58,9 @@ $(window).load(function() { thisPin.closest('.pin').remove(); tileLayout(); }); + promise.error(function() { + message('Problem deleting image.', 'alert alert-error'); + }); }); }); diff --git a/pinry/templates/base.html b/pinry/templates/base.html index a993b0c..4eaae32 100644 --- a/pinry/templates/base.html +++ b/pinry/templates/base.html @@ -28,7 +28,9 @@ {% endcompress %} + {% compress css inline %} {% block extra_css %}{% endblock %} + {% endcompress %} @@ -64,15 +66,16 @@ + +