diff options
-rw-r--r-- | conf/crontab.ugly | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Location.pm | 2 | ||||
-rw-r--r-- | templates/email/fixmybarangay/login.txt | 14 | ||||
-rw-r--r-- | templates/email/fixmybarangay/signature.txt | 2 | ||||
-rwxr-xr-x | templates/web/default/reports/ward.html | 2 | ||||
-rw-r--r-- | templates/web/fixmybarangay/auth/sign_out.html | 8 | ||||
-rw-r--r-- | templates/web/fixmybarangay/footer.html | 57 | ||||
-rw-r--r-- | templates/web/fixmybarangay/report/_message_manager.html | 119 | ||||
-rw-r--r-- | web/cobrands/fixmybarangay/images/fmb-spinner-16x16.gif | bin | 0 -> 1850 bytes | |||
-rw-r--r-- | web/cobrands/fixmybarangay/images/mobile-22x40.png | bin | 0 -> 454 bytes | |||
-rw-r--r-- | web/cobrands/fixmybarangay/message_manager.scss | 89 | ||||
-rw-r--r-- | web/cobrands/fixmybarangay/message_manager_client.js | 88 |
12 files changed, 320 insertions, 63 deletions
diff --git a/conf/crontab.ugly b/conf/crontab.ugly index 1a7236a2d..a88e774d2 100644 --- a/conf/crontab.ugly +++ b/conf/crontab.ugly @@ -20,7 +20,7 @@ MAILTO=!!(*= $user *)!!@mysociety.org #2 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/send-alerts.lock "/data/vhost/!!(*= $vhost *)!!/fixmystreet/bin/cron-wrapper send-alerts" || echo "stalled?" 0,30 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/send-questionnaires.lock "/data/vhost/!!(*= $vhost *)!!/fixmystreet/bin/cron-wrapper send-questionnaires" || echo "stalled?" -!!(* } elsif (($vhost eq 'www.fixmystreet.com') || ($vhost eq 'bromley.test.mysociety.org') || ($vhost eq 'barnet.fixmystreet.staging.mysociety.org') || ($vhost eq 'fixmybarangay.test.mysociety.org') || ($vhost eq 'demo.fixmybarangay.com') || ($vhost eq 'stevenage.test.mysociety.org')) { *)!! +!!(* } elsif (($vhost eq 'www.fixmystreet.com') || ($vhost eq 'bromley.test.mysociety.org') || ($vhost eq 'barnet.fixmystreet.staging.mysociety.org') || ($vhost eq 'fixmybarangay.test.mysociety.org') || ($vhost eq 'demo.fixmybarangay.com') || ($vhost eq 'www.fixmybarangay.com') || ($vhost eq 'stevenage.test.mysociety.org')) { *)!! 5,10,15,20,25,30,35,40,45,50,55 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/send-reports.lock "/data/vhost/!!(*= $vhost *)!!/fixmystreet/bin/cron-wrapper send-reports" || echo "stalled?" 0 0-7,9-11,13-15,17-23 * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/send-reports.lock "/data/vhost/!!(*= $vhost *)!!/fixmystreet/bin/cron-wrapper send-reports" || echo "stalled?" 0 8,12,16 * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/send-reports.lock "/data/vhost/!!(*= $vhost *)!!/fixmystreet/bin/cron-wrapper send-reports --verbose" || echo "stalled?" diff --git a/perllib/FixMyStreet/App/Controller/Location.pm b/perllib/FixMyStreet/App/Controller/Location.pm index 3e44cd748..e8bf2cd1c 100644 --- a/perllib/FixMyStreet/App/Controller/Location.pm +++ b/perllib/FixMyStreet/App/Controller/Location.pm @@ -69,7 +69,7 @@ sub determine_location_from_pc : Private { $c->stash->{longitude} = $2; return $c->forward( 'check_location' ); } - if ( $c->cobrand->country eq 'GB' && $pc =~ /^([A-Z])([A-Z])([\d\s]+)$/i ) { + if ( $c->cobrand->country eq 'GB' && $pc =~ /^([A-Z])([A-Z])([\d\s]{4,})$/i) { if (my $convert = gridref_to_latlon( $1, $2, $3 )) { $c->stash->{latitude} = $convert->{latitude}; $c->stash->{longitude} = $convert->{longitude}; diff --git a/templates/email/fixmybarangay/login.txt b/templates/email/fixmybarangay/login.txt new file mode 100644 index 000000000..3ca8d1323 --- /dev/null +++ b/templates/email/fixmybarangay/login.txt @@ -0,0 +1,14 @@ +Subject: [% loc('Your FixMyBarangay.com account details') %] + +Please click on the link below to confirm your email address. Then you will be +able to view your problem reports and manage them more easily. + +[% c.uri_for_action( 'auth/token', token ) %] + +Note that your can't create new reports on FixMyBarangay unless your account has +been authorised as a staff account, which we can do after it has been created. +Get in touch with the team if you think this applies to you, and we haven't yet +authorised your account. + +[% INCLUDE 'signature.txt' %] + diff --git a/templates/email/fixmybarangay/signature.txt b/templates/email/fixmybarangay/signature.txt new file mode 100644 index 000000000..eb5000f58 --- /dev/null +++ b/templates/email/fixmybarangay/signature.txt @@ -0,0 +1,2 @@ +Yours, +The FixMyBarangay team diff --git a/templates/web/default/reports/ward.html b/templates/web/default/reports/ward.html index 8b65ffb28..4b2ea29a5 100755 --- a/templates/web/default/reports/ward.html +++ b/templates/web/default/reports/ward.html @@ -1 +1 @@ -[% INCLUDE reports/council.html %] +[% INCLUDE reports/body.html %] diff --git a/templates/web/fixmybarangay/auth/sign_out.html b/templates/web/fixmybarangay/auth/sign_out.html new file mode 100644 index 000000000..11888089a --- /dev/null +++ b/templates/web/fixmybarangay/auth/sign_out.html @@ -0,0 +1,8 @@ +[% INCLUDE 'header.html', title = loc('Sign out'), bodyclass = 'fullwidthpage' %] + +<h1>[% loc('You have been signed out') %]</h1> + +<p>Please feel free to <a href="[% c.uri_for('/auth') %]">sign in again</a>, or +go back to the <a href="/">FixMyBarangay front page</a>.</p> + +[% INCLUDE 'footer.html' %] diff --git a/templates/web/fixmybarangay/footer.html b/templates/web/fixmybarangay/footer.html index 737b151ac..966abacd8 100644 --- a/templates/web/fixmybarangay/footer.html +++ b/templates/web/fixmybarangay/footer.html @@ -28,7 +28,7 @@ </div> [% IF global.want_fmb_hidden_dialogs %] - <!-- fancybox hidden dialogues for message-manager reply/hide --> + <!-- fancybox hidden dialogues for message-manager reply/hide/help --> <div style="display:none"> <div id="reply-form-container"> <form action="#" id="reply-form" onsubmit="event.returnValue = false; return false;" method="post" accept-charset="utf-8"> @@ -74,6 +74,61 @@ </form> </div> </div> + <div style="display:none"> + <div id="mm-help" style="font-size:90%;"> + <h2> Accessing Message Manager from FixMyBarangay (FMB)</h2> + <h3> + Logging into Message Manager + </h3> + <p> + You'll need a username and password (ask your manager if you haven't already got one). Your Message Manager password + might not be the same as your FMB password. + </p> + <p> + When you've logged in, you'll see the currently available messages (and any replies that have been sent to them). + You <em>only</em> see messages that are waiting to be used to make reports, and which are tagged with the keywords + your login allows you to see (these may mean you only see messages for your own barangay). + If you want to see any other messages, you'll need to have a manager or admin account on Message Manager: click on the + <a href="[% c.config.MESSAGE_MANAGER_URL %]">admin</a> link to get there. + </p> + <h3> + Creating a new report from a message + </h3> + <p> + If you want to use a message to create a problem report, you'll need to select it first. Click on the radio button. When the message + is selected, it will go bright green. Now when you click on the map, the report will be used to create the report. + </p> + <p> + To stop two people replying to a message at the same time, if anyone else has just started working on it, you'll see a message + warning you, and you won't be able to select the radio button. Normally, if nobody works with a message, such a lock is released + after about 3 minutes. + </p> + <h3> + Replying to a message + </h3> + <p> + You can send an SMS back to the original sender: just hover over the message and click <span class="demo_reply_btn">reply</span>. It will usually + take a few minutes for the message to arrive. + </p> + <h3> + Getting message info + </h3> + <p> + Hover over a message and click on its <span class="demo_info_btn">i</span> button to see when it was sent. + You can also see the sender, although not their + actual number (instead the number is scrambled, but will be the <em>same scrambled number</em> on other messages they've sent). + </p> + <h3> + Hiding a message + </h3> + <p> + If a message can't be used to create a report, you can hide it by hovering over it and clicking its <span class="demo_hide_btn">X</span> button. If you're not + going to create a problem report with this message, you might like to reply first, to tell the person who sent the message why not. + When you click the X, give a reason why you're hiding it so other staff (managers in Message Manager) can see why the message was hidden. + </p> + </div> + </div> + [% END %] <!-- [% INCLUDE 'debug_footer.html' %] --> diff --git a/templates/web/fixmybarangay/report/_message_manager.html b/templates/web/fixmybarangay/report/_message_manager.html index 04ffb0f42..10f627a2e 100644 --- a/templates/web/fixmybarangay/report/_message_manager.html +++ b/templates/web/fixmybarangay/report/_message_manager.html @@ -1,18 +1,35 @@ [% IF c.user && c.user.from_council %] +[% IF problem.external_source_id && problem.external_source == c.config.MESSAGE_MANAGER_URL %] + <p class="mm-submitted-by-sms"> + [%# OK to link to Message Manager here because (currently) we're only showing this to staff users %] + <a href="[%= problem.external_source %]messages/view/[%= problem.external_source_id %]" + title="view in Message Manager admin"><img + src="/cobrands/fixmybarangay/images/mobile-22x40.png" alt="SMS"></a> + This report was submitted via SMS. + </p> +[% END %] + [% IF problem.id %] - <input type="button" class="green-btn" value="Show Messages" id="show_messages"> + <div id="mm-container-for-report-btns"> + <input type="button" class="green-btn" value="Show Messages" id="show_messages"> + </div> [% END %] <ul id="message_manager" class="issue-list-a tab" style="display: none"> + <li id="mm-admin-buttons"> + [% IF problem.id %] + <a style="float:left" id="mm-link-to-toggle-archive" href="#" title="show the message(s) associated with this report">show message for <b>this</b> report</a> + [% END %] + <a id="mm-link-to-refresh" href="#" title="update list of messages">refresh</a> + <a id="mm-link-to-admin" href="[% c.config.MESSAGE_MANAGER_URL %]" title="jump to Message Manager admin">admin</a> + <a id="mm-link-to-help" href="#mm-help" title="show help information">help</a> + </li> <li id="message-control"> - <div id="mm-admin-buttons"> - <a id="mm-link-to-admin" href="[% c.config.MESSAGE_MANAGER_URL %]">[admin]</a> - <a id="mm-link-to-refresh" href="#">[refresh]</a> - </div> <div id="mm-username-container">username: <span id="mm-received-username"></span></div> <div id="mm-status-message-container"> - <div id="mm-status-message"></div> + <img id="mm-spinner" src="/cobrands/fixmybarangay/images/fmb-spinner-16x16.gif" alt=""/> + <p id="mm-status-message"></p> </div> <div id="mm-login-container"> <div> @@ -44,26 +61,33 @@ $(document).ready(function() { var timeout_id = 0; var can_refresh = true; // disable refresh var refresh_period = 60000 * 3; // refresh messages every three minutes + var has_archive_message = false; function sanitise_id(css_id) { return css_id.replace(/\D/g, ""); } + // call this to push the auto-refresh timeout off so it's only triggered + // if there's no activity for a while + function reset_timeout() { + if (refresh_period && can_refresh) { + if (timeout_id) { + clearTimeout(timeout_id); + } + timeout_id = setTimeout(mm_refresh_messages, refresh_period); + } + } + var mm_refresh_messages = function() { $('#mm-link-to-refresh').fadeOut(); $('#available-submit').click(); } var mm_populate_list = function(data) { - $('#mm-status-message-container').text("Accessed Message Manager as " + data['username']); + $('#mm-status-message-container').find('p').text("Accessed Message Manager as " + data['username']); $('input[name=mm_text]').prop('checked', false); // uncheck all $('#mm-link-to-refresh').delay(2000).fadeIn(); - if (refresh_period && can_refresh) { - if (timeout_id) { - clearTimeout(timeout_id); - } - timeout_id = setTimeout(mm_refresh_messages, refresh_period); - } + reset_timeout(); } var mm_selected_message = function(data) { @@ -83,12 +107,14 @@ $(document).ready(function() { } var dummy_reply_cleanup = function(data) { + reset_timeout(); $('#reply_text').val(''); dummy_busy = false; mm_refresh_messages(); } var dummy_hide_cleanup = function(data) { + reset_timeout(); $('#reason_text').val(''); dummy_busy = false; } @@ -105,9 +131,11 @@ $(document).ready(function() { $('#available-submit').click(function(e){ e.preventDefault(); + reset_timeout(); message_manager.get_available_messages({ callback: mm_populate_list, suggest_username: fms_username, + fms_id: problem_id, anim_duration: 500 }); }); @@ -120,6 +148,7 @@ $(document).ready(function() { }); $('#mm-message-list').on('click', '.mm-info', function(e){ + reset_timeout(); message_manager.show_info(sanitise_id($(this).parent().attr('id'))); }); @@ -146,6 +175,7 @@ $(document).ready(function() { $('#hide-submit').click(function(e) { e.preventDefault(); + reset_timeout(); // TODO: pending fancybox callbacks working, force dummy_busy here // this is possibly overly cautious anyway dummy_busy = false; @@ -163,13 +193,15 @@ $(document).ready(function() { // only show on problem display page if (problem_id) { $('<input type="button" value="Copy to update"/>').attr({ - 'id': 'add_support', - 'name': 'add_support', - 'class': 'green-btn' - }).appendTo($('#message_manager')); + 'id': 'copy_to_update', + 'name': 'copy_to_update', + 'class': 'green-btn', + 'title': "add the selected message's text as an update to this report" + }).appendTo($('#mm-container-for-report-btns')); } - $('#add_support').click(function(e){ + $('#copy_to_update').click(function(e){ + reset_timeout(); e.preventDefault(); $('#mm-message-list input:checked').each( function(index) { var id = $(this).attr('id'); @@ -183,8 +215,15 @@ $(document).ready(function() { }); $('#show_messages').on('click', function(e) { - $('#message_manager').toggle(); - $('#show_messages').val( $('#show_messages').val() == 'Show Messages' ? 'Hide Messages' : 'Show Messages' ); + $('#message_manager').slideToggle(1000); + if ($('#show_messages').val() == 'Show Messages') { + $('#show_messages').val('Hide Messages'); + $('#copy_to_update').stop(true,true).fadeIn(); + } else { + $('#show_messages').val('Show Messages'); + $('#copy_to_update').stop(true,true).fadeOut(); + } + }); $('#mm-link-to-refresh').on('click', function(e) { @@ -192,6 +231,46 @@ $(document).ready(function() { mm_refresh_messages(); }); + // suppress fading control while archive messages are displayed, for now + $('#mm-link-to-toggle-archive').on('click', function(e) { + e.preventDefault(); + $('#mm-link-to-toggle-archive').fadeOut(); + if ($('.mm-current', $mm_message_list).is(':visible')) { + $('#copy_to_update').stop(true,true).fadeOut(); + $('#mm-link-to-refresh').stop(true,true).fadeOut(); + $('.mm-empty', $mm_message_list).stop(true,true).fadeOut(); + $('.mm-current', $mm_message_list).stop(true,true).slideUp(1000, function(){ + if($('.mm-archive', $mm_message_list).find('li').length == 0) { + message_manager.say_status("No messages found for this report,"); + } else { + message_manager.say_status("Messages for this report:"); + }; + $('.mm-archive', $mm_message_list).stop(true,true).slideDown(1000, function(){ + $('#mm-link-to-toggle-archive').html('show all available messages') + .attr('title', 'show all available messages (for adding updates)'); + $('#mm-link-to-toggle-archive').fadeIn(); + can_refresh = false; + }) + }); + } else { + $('.mm-archive', $mm_message_list).stop(true,true).slideUp(1000, function(){ + message_manager.say_status("Available messages:"); + $('.mm-current', $mm_message_list).stop(true,true).slideDown(1000, function(){ + $('#mm-link-to-toggle-archive').html("show message for <b>this</b> report") + .attr('title', 'show the original message(s) for this report'); + $('#copy_to_update').stop(true,true).fadeIn(); + $('#mm-link-to-toggle-archive').stop(true,true).fadeIn(); + $('#mm-link-to-refresh').stop(true,true).fadeIn(); + $('.mm-empty', $mm_message_list).stop(true,true).fadeIn(); + can_refresh = true; + reset_timeout(); + }) + }); + } + }); + + $("a#mm-link-to-help").fancybox(); + message_manager.populate_boilerplate_strings('hide-reason'); message_manager.populate_boilerplate_strings('reply'); }); diff --git a/web/cobrands/fixmybarangay/images/fmb-spinner-16x16.gif b/web/cobrands/fixmybarangay/images/fmb-spinner-16x16.gif Binary files differnew file mode 100644 index 000000000..da5ea679a --- /dev/null +++ b/web/cobrands/fixmybarangay/images/fmb-spinner-16x16.gif diff --git a/web/cobrands/fixmybarangay/images/mobile-22x40.png b/web/cobrands/fixmybarangay/images/mobile-22x40.png Binary files differnew file mode 100644 index 000000000..6a85ab097 --- /dev/null +++ b/web/cobrands/fixmybarangay/images/mobile-22x40.png diff --git a/web/cobrands/fixmybarangay/message_manager.scss b/web/cobrands/fixmybarangay/message_manager.scss index 9d9555640..d2b7739c2 100644 --- a/web/cobrands/fixmybarangay/message_manager.scss +++ b/web/cobrands/fixmybarangay/message_manager.scss @@ -13,10 +13,47 @@ $color_bg_reply_5: #BFBFBF; $color_bg_reply_6: #B8B8B8; $color_bg_mm_list: #F6F6F6; +$color_bg_btn_hide: #ff0000; +$color_bg_btn_reply: #008000; +$color_bg_btn_info: #0000ff; + + $weak_text_color: #666; -#message_manager { + +p.mm-submitted-by-sms { + color: $weak_text_color; + font-style: italic; + font-size: 0.8125em; + img { + border: none; + margin-right: 0.5em; + width: 22px; + height: 40px; + vertical-align:middle; + display: inline; + } +} + +#message_manager { + margin-top: 0; + li#mm-admin-buttons { + margin: -0.5em 0 0 0; + text-align: right; + font-size:80%; + padding:4px 8px 4px 0; + a { + padding: 0.25em 0.5em; + border:1px solid $mm_border_color; + margin: 0 0.5em; + display: inline-block; + } + background-color: #fff; + &:hover { + background-color: #fff; + } + } #message-control { #mm-username-container { display: none; // hidden during dev @@ -30,11 +67,22 @@ $weak_text_color: #666; } } #mm-status-message-container { + position: relative; min-height: 1.4em; margin: 0 0 8px 0.5em; - padding: 8px 4px; + padding: 8px 4px 8px 24px; color: $mm_status_message_color; font-style: italic; + p { + margin:0; + padding:0; + } + #mm-spinner { + position: absolute; + left: 4px; + top: 10px; + display: none; + } } #mm-login-container { display: none; // only shown on/after a 403 @@ -49,6 +97,9 @@ $weak_text_color: #666; #mm-message-list { ul { + &.mm-archive { + display: none; // archive only shown on interaction + } list-style-type: none; padding: 0; margin: 0; @@ -97,6 +148,7 @@ $weak_text_color: #666; &.msg-is-active { background-color: $contrast1; color:#fff; p:hover { background-color: $contrast1; color:#fff; } // fix for mouseover on p + p.mm-reply:hover {background-color: #eef; color:#000;} // fix for mouseover on p } span.msg-tag { width: 3em; @@ -122,15 +174,15 @@ $weak_text_color: #666; } .mm-hide { right:0px; - background-color: red; + background-color: $color_bg_btn_hide; } .mm-info { right:1.5em; - background-color: blue; + background-color: $color_bg_btn_info; } .mm-rep { right:2.6em; - background-color: green; + background-color: $color_bg_btn_reply; } } } @@ -139,9 +191,15 @@ $weak_text_color: #666; margin: 1em; } } -#show_messages, #add_support, #reply-submit { // COPY TO UPDATE button +#show_messages, #copy_to_update, #reply-submit { margin: 1em; } +#copy_to_update { + display: none; // show on demand, not before +} +#show_messages { + width: 11em; // hack to stop adjacent button hopping when button message changes +} #reply-form-container, #hide-form-container { @@ -161,14 +219,13 @@ $weak_text_color: #666; display: none; } } -div#mm-admin-buttons { - display:block; - text-align: right; - float:right; - font-size:80%; - padding:4px 8px 4px 0; - a { - display: block; - } - +#mm-help { + .demo_hide_btn, .demo_reply_btn, .demo_info_btn { + color: #fff; + font-weight: bold; + padding: 0.2em 0.4em; + } + .demo_hide_btn { background-color: $color_bg_btn_hide; } + .demo_reply_btn { background-color: $color_bg_btn_reply; } + .demo_info_btn { background-color: $color_bg_btn_info; } } diff --git a/web/cobrands/fixmybarangay/message_manager_client.js b/web/cobrands/fixmybarangay/message_manager_client.js index ba7383933..e9a5c8d6b 100644 --- a/web/cobrands/fixmybarangay/message_manager_client.js +++ b/web/cobrands/fixmybarangay/message_manager_client.js @@ -75,12 +75,19 @@ var message_manager = (function() { var msg_no_config_err = "Config error: no Message Manager URL has been specified"; + // set _want_nice_msgs to avoid using the term "lock" var msg_trying_for_lock = ["Trying for lock...", "Checking message..." ]; var msg_checking_lock = ["Checking lock...", "Checking message..." ]; var msg_claiming_lock = ["Claiming lock...", "Checking message..." ]; var msg_lock_granted_ok = ["Lock granted OK", "Checking message... OK"]; var msg_lock_denied = ["", "Someone is working with that message right now!"]; + // tooltips currently hardcoded, but maybe hide if don't _want_nice_msgs? + var tooltip_hide = "Hide message"; + var tooltip_info = "Get info"; + var tooltip_reply = "Send SMS reply"; + var tooltip_radio = "Select message before clicking on map to create report"; + function get_msg(msg) { return msg[_want_nice_msgs? 1 : 0]; } @@ -197,12 +204,18 @@ var message_manager = (function() { if ($htauth_username.size() && ! $htauth_username.val()) { $htauth_username.val(suggest_username); } - $login_element.stop().slideDown(); + $login_element.stop(true,true).slideDown(); }; - var say_status = function (msg) { + var say_status = function (msg, show_spinner) { if ($status_element) { - $status_element.stop().show().text(msg); + if (show_spinner) { + // slow fade in so that spinner only appears if there's a long delay + $status_element.find('#mm-spinner').stop(true,true).fadeIn(1200); + } else { + $status_element.find('#mm-spinner').stop(true,true).hide(); + } + $status_element.stop(true,true).show().find('p').text(msg); } }; @@ -222,9 +235,9 @@ var message_manager = (function() { var lockkeeper = message_root.Lockkeeper.username; var escaped_text = $('<div/>').text(msg.message).html(); var $p = $('<p/>'); - var $hide_button = $('<a class="mm-msg-action mm-hide" id="mm-hide-' + msg.id + '" href="#hide-form-container">X</a>'); - var $info_button = $('<span class="mm-msg-action mm-info" id="mm-info-' + msg.id + '">i</span>'); - var $reply_button = $('<a class="mm-msg-action mm-rep" id="mm-rep-' + msg.id + '" href="#reply-form-container">reply</a>'); + var $hide_button = $('<a class="mm-msg-action mm-hide" id="mm-hide-' + msg.id + '" href="#hide-form-container" title="' + tooltip_hide + '">X</a>'); + var $info_button = $('<span class="mm-msg-action mm-info" id="mm-info-' + msg.id + '" title="' + tooltip_info + '">i</span>'); + var $reply_button = $('<a class="mm-msg-action mm-rep" id="mm-rep-' + msg.id + '" href="#reply-form-container" title="' + tooltip_reply + '">reply</a>'); if (_use_fancybox) { $reply_button.fancybox(); $hide_button.fancybox(); @@ -235,11 +248,13 @@ var message_manager = (function() { var radio = depth > 0? null : $('<input type="radio"/>').attr({ 'id': 'mm_text_' + msg.id, 'name': 'mm_text', - 'value': escaped_text + 'value': escaped_text, + 'title': tooltip_radio }).wrap('<p/>').parent().html(); - var label = $('<label/>', { + var label = $('<label />').attr({ 'class': 'msg-text', - 'for': 'mm_text_' + msg.id + 'for': 'mm_text_' + msg.id, + 'title': tooltip_radio }).text(escaped_text).wrap('<p/>').parent().html(); $p.append(tag).append(radio).append(label); } else { @@ -270,7 +285,7 @@ var message_manager = (function() { _username = data.username; var $output = $message_list_element; if (anim_duration > 0) { - $output.stop().fadeOut(anim_duration, function(){ + $output.stop(true,true).fadeOut(anim_duration, function(){ render_available_messages(data, anim_duration); }); } else { @@ -280,20 +295,32 @@ var message_manager = (function() { // render allows animation (if required) to hide messages before repainting and then revealing them var render_available_messages = function(data, anim_duration) { + var $output = $message_list_element; + $output.empty(); + var archive = data.messages_for_this_report; + var $archive = ""; + var i, litem; + if (archive instanceof Array) { + var $arch_ul = $('<ul class="mm-root mm-archive"/>'); + for(i=0; i< archive.length; i++) { + litem = get_message_li(archive[i], 0); + $arch_ul.append(litem); + } + $output.append($arch_ul); + } var messages = data.messages; _username = data.username; - var $output = $message_list_element; if (messages instanceof Array) { + var $ul = $('<ul class="mm-root mm-current"/>'); if (messages.length === 0) { - $output.html('<p class="mm-empty">No messages available.</p>'); + $output.append('<p class="mm-empty">No messages available.</p>'); } else { - var $ul = $('<ul class="mm-root"/>'); - for(var i=0; i< messages.length; i++) { - var litem = get_message_li(messages[i], 0); + for(i=0; i< messages.length; i++) { + litem = get_message_li(messages[i], 0); $ul.append(litem); } - $output.empty().append($ul); } + $output.append($ul); } else { $output.html('<p>No messages (server did not send a list).</p>'); } @@ -310,11 +337,11 @@ var message_manager = (function() { var $li = $(this).closest('li'); var id = $li.attr('id').replace(_msg_prefix, ''); if ($li.hasClass('msg-is-locked')) { - say_status(get_msg(msg_trying_for_lock)); + say_status(get_msg(msg_trying_for_lock), true); } else if ($li.hasClass('msg-is-owned')) { - say_status(get_msg(msg_checking_lock)); + say_status(get_msg(msg_checking_lock), true); } else { - say_status(get_msg(msg_claiming_lock)); + say_status(get_msg(msg_claiming_lock), true); } request_lock(id, options); }); @@ -332,11 +359,13 @@ var message_manager = (function() { // gets messages or else requests login // options: suggest_username, if provided, is preloaded into the login form if provided // anim_duration: duration of fade/reveal (0, by defaut, does no animation) + // fms_id: if provided, display an archive of messages for this username var get_available_messages = function(options) { var base_auth = get_current_auth_credentials(); var suggest_username = ""; var anim_duration = 0; var callback = null; + var fms_id = null; if (options) { if (typeof(options.callback) === 'function') { callback = options.callback; @@ -350,25 +379,37 @@ var message_manager = (function() { anim_duration = 0; } } + if (typeof options.fms_id === 'string' || typeof options.fms_id === 'number') { + fms_id = parseInt(options.fms_id, 10); + if (isNaN(fms_id)) { + fms_id = 0; + } + } } if (base_auth === "") { show_login_form(suggest_username); return; } - $login_element.stop().hide(); + $login_element.stop(true,true).hide(); if (_url_root.length === 0) { say_status(msg_no_config_err); } else { + var ajax_url = _url_root +"messages/available.json"; + if (fms_id) { + ajax_url += "?fms_id=" + fms_id; + } + say_status("Fetching messages...", true); $.ajax({ dataType: "json", - type: "post", - url: _url_root +"messages/available.json", + type: "get", + url: ajax_url, beforeSend: function (xhr){ xhr.setRequestHeader('Authorization', get_current_auth_credentials()); xhr.withCredentials = true; }, success: function(data, textStatus) { show_available_messages(data, anim_duration); + say_status("Fetching messages... done, OK", false); // loaded OK if (typeof(callback) === "function") { callback.call($(this), data); // execute callback } @@ -705,6 +746,7 @@ var message_manager = (function() { hide: hide, show_info: show_info, sign_out: sign_out, - populate_boilerplate_strings: populate_boilerplate_strings + populate_boilerplate_strings: populate_boilerplate_strings, + say_status: say_status }; })(); |