aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--templates/web/fixmybarangay/report/_message_manager.html98
1 files changed, 49 insertions, 49 deletions
diff --git a/templates/web/fixmybarangay/report/_message_manager.html b/templates/web/fixmybarangay/report/_message_manager.html
index b0ae18671..b2537e907 100644
--- a/templates/web/fixmybarangay/report/_message_manager.html
+++ b/templates/web/fixmybarangay/report/_message_manager.html
@@ -1,10 +1,10 @@
[% IF c.user && c.user.from_body %]
-[% IF problem.external_source_id && problem.external_source == c.config.MESSAGE_MANAGER_URL %]
+[% 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
+ <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>
@@ -41,7 +41,7 @@
<input name="mm-htauth-password" id="mm-htauth-password" type="password"/>
</div>
<div class="submit">
- <input id="available-submit" type="submit" value="Get available messages" class="green-btn"/>
+ <input id="available-submit" type="submit" value="Get available messages" class="green-btn"/>
</div>
</div>
</li>
@@ -49,27 +49,27 @@
<div id="mm-message-list" style="min-height:1em;"></div>
</li>
</ul>
-
+
<script type="text/javascript">
$(document).ready(function() {
var $mm_message_list = $('#mm-message-list');
var mm_url = "[% c.config.MESSAGE_MANAGER_URL %]"; // from config
-
- [%# note that the presence of a problem id implies that this is a report view page, not a problem creation page %]
+
+ [%# note that the presence of a problem id implies that this is a report view page, not a problem creation page %]
var problem_id = "[% problem.id %]";
-
+
var dummy_busy = false;
var fms_username = "[% c.user.email | replace('\@.*', '') %]";
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, "");
+ 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() {
@@ -80,19 +80,19 @@ $(document).ready(function() {
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').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();
reset_timeout();
}
-
+
var mm_selected_message = function(data) {
var msg_text = "";
var service_id = "";
@@ -108,7 +108,7 @@ $(document).ready(function() {
$('#form_detail').val(msg_text);
$('#external_source_id').val(service_id);
}
-
+
var reply_cleanup = function(data) {
reset_timeout();
$('#reply_text').val('');
@@ -133,7 +133,7 @@ $(document).ready(function() {
custom_tooltips = {tt_radio: "Select before clicking 'Copy to Update' to add this message as an update"};
}
message_manager.config({
- url_root: mm_url,
+ url_root: mm_url,
tooltips: custom_tooltips,
want_nice_msgs: true
});
@@ -142,53 +142,53 @@ $(document).ready(function() {
// problem form hidden input "external_source_id": pass the MM id into FMS, if used
var $problem_form = $('#problem_form').size()? $('#problem_form') : $('#form_update_form');
$('<input type="hidden"/>').attr({
- 'id': 'external_source_id',
- 'name': 'external_source_id',
- }).appendTo($problem_form);
+ 'id': 'external_source_id',
+ 'name': 'external_source_id',
+ }).appendTo($problem_form);
$('#available-submit').click(function(e){
e.preventDefault();
reset_timeout();
message_manager.get_available_messages({
- callback: mm_populate_list,
+ callback: mm_populate_list,
suggest_username: fms_username,
fms_id: problem_id,
anim_duration: 500
});
});
$('#available-submit').click();
-
+
$mm_message_list.on('mouseover', 'li.mm-msg', function(e){
e.stopPropagation(); // because replies are nested
$('.mm-msg-action', $mm_message_list).stop().fadeOut(200);
$(this).find('> .mm-msg-action').stop().show();
});
-
+
$('#mm-message-list').on('click', '.mm-info', function(e){
reset_timeout();
message_manager.show_info(sanitise_id($(this).parent().attr('id')));
});
-
+
$('#mm-hide-reasons').change(function(e){
- $('#reason_text').val($(this).val()); // load reason_text with boilerplate reason
+ $('#reason_text').val($(this).val()); // load reason_text with boilerplate reason
});
$('#mm-boilerplate-replies').change(function(e){
- var old_txt = $('#reply_text').val();
- var new_txt = $(this).val().replace(/(^\.\.\.|\.\.\.$)/, old_txt);
- $('#reply_text').val(new_txt); // load reply_text with boilerplate reason
+ var old_txt = $('#reply_text').val();
+ var new_txt = $(this).val().replace(/(^\.\.\.|\.\.\.$)/, old_txt);
+ $('#reply_text').val(new_txt); // load reply_text with boilerplate reason
});
-
+
$('#reply-submit').click(function(e) {
e.preventDefault();
// TODO: pending fancybox callbacks working, force dummy_busy here
- // this is possibly overly cautious anyway
- dummy_busy = false;
+ // this is possibly overly cautious anyway
+ dummy_busy = false;
if (! dummy_busy) {
dummy_busy = true;
message_manager.reply(
- $('#reply_to_msg_id').val(),
- $('#reply_text').val(),
- {callback:reply_cleanup});
+ $('#reply_to_msg_id').val(),
+ $('#reply_text').val(),
+ {callback:reply_cleanup});
}
});
@@ -196,14 +196,14 @@ $(document).ready(function() {
e.preventDefault();
reset_timeout();
// TODO: pending fancybox callbacks working, force dummy_busy here
- // this is possibly overly cautious anyway
- dummy_busy = false;
+ // this is possibly overly cautious anyway
+ dummy_busy = false;
if (! dummy_busy) {
dummy_busy = true;
message_manager.hide(
- $('#hide_msg_id').val(),
- $('#reason_text').val(),
- {callback:hide_cleanup});
+ $('#hide_msg_id').val(),
+ $('#reason_text').val(),
+ {callback:hide_cleanup});
}
});
@@ -212,8 +212,8 @@ $(document).ready(function() {
if (! dummy_busy) {
dummy_busy = true;
message_manager.mark_as_not_a_reply(
- $('#detach_msg_id').val(),
- {callback:detach_cleanup});
+ $('#detach_msg_id').val(),
+ {callback:detach_cleanup});
}
});
@@ -238,7 +238,7 @@ $(document).ready(function() {
$('#external_source_id').val(id);
$('#form_update').val( $(this).val() );
$('#form_update_form').on('submit', function(e) {
- message_manager.assign_fms_id( $('#external_source_id').val(), problem_id, { 'is_async': false } );
+ message_manager.assign_fms_id( $('#external_source_id').val(), problem_id, { 'is_async': false } );
});
});
});
@@ -252,9 +252,9 @@ $(document).ready(function() {
$('#show_messages').val('Show Messages');
$('#copy_to_update').stop(true,true).fadeOut();
}
-
+
});
-
+
$('#mm-link-to-refresh').on('click', function(e) {
e.preventDefault();
mm_refresh_messages();
@@ -279,8 +279,8 @@ $(document).ready(function() {
.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:");
@@ -293,15 +293,15 @@ $(document).ready(function() {
$('.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');
+ message_manager.populate_boilerplate_strings('reply');
});
</script>