From a8018910a0ed600db47188f67a2c3359d4984451 Mon Sep 17 00:00:00 2001 From: Heather Billings Date: Wed, 21 Oct 2015 16:53:52 -0500 Subject: [PATCH] some cleanup related to #90 --- static/css/cityhallmonitor.css | 4 +-- static/js/cityhallmonitor.js | 17 +++++++--- static/sass/cityhallmonitor.scss | 3 +- templates/notifications.html | 2 +- templates/search.html | 2 +- templates/subscriptions.html | 53 +++++++++++++++----------------- 6 files changed, 42 insertions(+), 39 deletions(-) diff --git a/static/css/cityhallmonitor.css b/static/css/cityhallmonitor.css index 8dc98e9..4b54b83 100644 --- a/static/css/cityhallmonitor.css +++ b/static/css/cityhallmonitor.css @@ -112,14 +112,14 @@ body { .alert-box { margin: 40px auto; } -#post-subscribe-msg { +.status-msg { text-align: left; padding: 0 0 0 10px; font-family: "Apres RE", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; color: #888; line-height: 1.4em; } - #post-subscribe-msg.error { + .status-msg.error { color: #ce4d28; } /* notifications.html */ diff --git a/static/js/cityhallmonitor.js b/static/js/cityhallmonitor.js index 6c83268..9ed57b7 100644 --- a/static/js/cityhallmonitor.js +++ b/static/js/cityhallmonitor.js @@ -1,6 +1,15 @@ $ = jQuery; var handle_subscribe = function(event, url) { + var showMsg = function(msg, type, detail){ + $('#post-subscribe-msg').text(msg + (detail ? detail : '')); + if ($('#post-subscribe-msg').hasClass('error') && type != 'error') { + $('#post-subscribe-msg').removeClass('error'); + } else if (type == 'error'){ + $('#post-subscribe-msg').addClass('error'); + } + $('#post-subscribe-msg').show(); + } var email = $('#search-subscribe-email').val().trim(); if(!email) { $('#post-subscribe-msg').fadeIn('slow') @@ -21,15 +30,13 @@ var handle_subscribe = function(event, url) { dataType: 'json', timeout: 20000, error: function(xhr, status, err) { - alert('Error making subscription: '+err); + showMsg('Error making subscription: ', 'error', err); }, success: function(data) { if(data.error) { - $('#post-subscribe-msg').fadeIn('slow') - .text('Error making subscription: '+ data.error); + showMsg('Error making subscription: ', 'error', data.error); } else { - $('#post-subscribe-msg').fadeIn('slow') - .text('We sent you an email. Click the link in it to confirm your subscription.'); + showMsg('We sent you an email. Click the link in it to confirm your subscription.', 'success'); } } }); diff --git a/static/sass/cityhallmonitor.scss b/static/sass/cityhallmonitor.scss index e496270..92ef8b4 100644 --- a/static/sass/cityhallmonitor.scss +++ b/static/sass/cityhallmonitor.scss @@ -118,7 +118,7 @@ body { margin: 40px auto; } -#post-subscribe-msg { +.status-msg { text-align: left; padding: 0 0 0 10px; font-family: $font-family-sans-serif; @@ -130,6 +130,7 @@ body { } } + /* notifications.html */ #notifications-list { table.columns { diff --git a/templates/notifications.html b/templates/notifications.html index 3732ff6..9e32d84 100644 --- a/templates/notifications.html +++ b/templates/notifications.html @@ -65,7 +65,7 @@

Manage subscriptions

var self = this; // Server-side code expects an array var sid = [$(this).attr("data-sid")]; - // TODO: add visible state indication for loading and deleted searches + // TODO: add visible state indication for loading $.ajax({ url: '{% url "unsubscribe" %}', type: 'GET', diff --git a/templates/search.html b/templates/search.html index 4ef74f4..af49598 100644 --- a/templates/search.html +++ b/templates/search.html @@ -44,7 +44,7 @@
We found <%= total %> results matching <
-

+

diff --git a/templates/subscriptions.html b/templates/subscriptions.html index e01e323..a3b6e65 100644 --- a/templates/subscriptions.html +++ b/templates/subscriptions.html @@ -1,29 +1,21 @@ {% extends "base.html" %} {% block content %} - - - - -

Manage subscriptions

Enter your email address below, and we'll send you a link to manage your subscriptions.

-
+
-
+
+
+

+
@@ -33,25 +25,28 @@

Manage subscriptions

{% block extra_scripts %} - -