From e69bc54641b9a584439ec934f1ed54e3e310e023 Mon Sep 17 00:00:00 2001 From: Dave Whiteland Date: Tue, 6 Aug 2013 18:24:04 +0100 Subject: make js available in admin pages --- web/js/fixmystreet-admin.js | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 web/js/fixmystreet-admin.js (limited to 'web/js/fixmystreet-admin.js') diff --git a/web/js/fixmystreet-admin.js b/web/js/fixmystreet-admin.js new file mode 100644 index 000000000..f13a66d9c --- /dev/null +++ b/web/js/fixmystreet-admin.js @@ -0,0 +1,4 @@ +$(function(){ + // available for admin pages +}); + -- cgit v1.2.3 From 8acaea9f91c7db24871e6e1bd9268d9bf3b0d52d Mon Sep 17 00:00:00 2001 From: Dave Whiteland Date: Wed, 7 Aug 2013 11:28:23 +0100 Subject: hide open311 inputs for bodies unless needed basically if send method is not email (or there's an endpoint value), don't show the form Maybe we need to have an "show all fields" button/link but for normal use I think this is OK --- web/js/fixmystreet-admin.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'web/js/fixmystreet-admin.js') diff --git a/web/js/fixmystreet-admin.js b/web/js/fixmystreet-admin.js index f13a66d9c..d55bbab21 100644 --- a/web/js/fixmystreet-admin.js +++ b/web/js/fixmystreet-admin.js @@ -1,4 +1,25 @@ $(function(){ // available for admin pages + + // hide the open311_only section and reveal it only when send_method is relevant + var $open311_only = $('.admin-open311-only'); + if ($open311_only) { + function hide_or_show_open311() { + var send_method = $('#send_method').val(); + var show_open311 = false; + if ($('#endpoint').val()) { + show_open311 = true; // always show the form if there is an endpoint value + } else if (send_method && send_method.toLowerCase() != 'email') { + show_open311 = true; + } + if (show_open311) { + $open311_only.slideDown(); + } else { + $open311_only.slideUp(); + } + } + $('#send_method').on('change', hide_or_show_open311); + hide_or_show_open311(); + } }); -- cgit v1.2.3 From 75419ceb142852db15d0d72e05400b163c40caf6 Mon Sep 17 00:00:00 2001 From: Dave Whiteland Date: Wed, 7 Aug 2013 14:18:32 +0100 Subject: add display-on-click hints --- web/js/fixmystreet-admin.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'web/js/fixmystreet-admin.js') diff --git a/web/js/fixmystreet-admin.js b/web/js/fixmystreet-admin.js index d55bbab21..27be7f14d 100644 --- a/web/js/fixmystreet-admin.js +++ b/web/js/fixmystreet-admin.js @@ -21,5 +21,15 @@ $(function(){ $('#send_method').on('change', hide_or_show_open311); hide_or_show_open311(); } + + // admin hints: maybe better implemented as tooltips? + $(".admin-hint").on('click', function(){ + if ($(this).hasClass('admin-hint-show')) { + $(this).removeClass('admin-hint-show'); + } else { + $(this).addClass('admin-hint-show'); + } + }); + }); -- cgit v1.2.3 From f574cd68ac232364ca0d09b95d9f709cd37ad0a5 Mon Sep 17 00:00:00 2001 From: Dave Whiteland Date: Wed, 7 Aug 2013 16:32:31 +0100 Subject: don't hide with slideUp on page load if open311 shouldn't be show, hide it straight away (slideUp animation was distracting) --- web/js/fixmystreet-admin.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'web/js/fixmystreet-admin.js') diff --git a/web/js/fixmystreet-admin.js b/web/js/fixmystreet-admin.js index 27be7f14d..a65fa3650 100644 --- a/web/js/fixmystreet-admin.js +++ b/web/js/fixmystreet-admin.js @@ -4,7 +4,7 @@ $(function(){ // hide the open311_only section and reveal it only when send_method is relevant var $open311_only = $('.admin-open311-only'); if ($open311_only) { - function hide_or_show_open311() { + function hide_or_show_open311(hide_fast) { var send_method = $('#send_method').val(); var show_open311 = false; if ($('#endpoint').val()) { @@ -12,14 +12,18 @@ $(function(){ } else if (send_method && send_method.toLowerCase() != 'email') { show_open311 = true; } - if (show_open311) { - $open311_only.slideDown(); - } else { - $open311_only.slideUp(); + if (show_open311) { + $open311_only.slideDown(); + } else { + if (hide_fast) { + $open311_only.hide(); + } else { + $open311_only.slideUp(); + } } } $('#send_method').on('change', hide_or_show_open311); - hide_or_show_open311(); + hide_or_show_open311(true); } // admin hints: maybe better implemented as tooltips? -- cgit v1.2.3 From 26a116610778e8099a309bf8f6a14fe247bef0a7 Mon Sep 17 00:00:00 2001 From: Dave Whiteland Date: Thu, 8 Aug 2013 15:01:00 +0100 Subject: add toggle button to hide contacts, closes #505 --- web/js/fixmystreet-admin.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'web/js/fixmystreet-admin.js') diff --git a/web/js/fixmystreet-admin.js b/web/js/fixmystreet-admin.js index a65fa3650..cd74522ec 100644 --- a/web/js/fixmystreet-admin.js +++ b/web/js/fixmystreet-admin.js @@ -35,5 +35,24 @@ $(function(){ } }); + // on a body's page, hide/show deleted contact categories + var $table_with_deleted_contacts = $('table tr.is-deleted td.contact-category'); + if ($table_with_deleted_contacts.length == 1) { + $table_with_deleted_contacts = $table_with_deleted_contacts.closest('table'); + var $toggle_deleted_btn = $(""); + $table_with_deleted_contacts.before($toggle_deleted_btn); + $toggle_deleted_btn.on('click', function(e){ + e.preventDefault(); + var $cols = $table_with_deleted_contacts.find('tr.is-deleted'); + if ($cols.first().is(':visible')) { + $cols.hide(); + $(this).prop("value", 'Show deleted contacts'); + } else { + $cols.show(); + $(this).prop("value", 'Hide deleted contacts'); + } + }) + } + }); -- cgit v1.2.3 From 86a366703507d965622a059c56588aeb1a72bc47 Mon Sep 17 00:00:00 2001 From: Dave Whiteland Date: Wed, 14 Aug 2013 19:14:11 +0100 Subject: jslint fixes --- web/js/fixmystreet-admin.js | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'web/js/fixmystreet-admin.js') diff --git a/web/js/fixmystreet-admin.js b/web/js/fixmystreet-admin.js index cd74522ec..64f73ebb7 100644 --- a/web/js/fixmystreet-admin.js +++ b/web/js/fixmystreet-admin.js @@ -3,25 +3,27 @@ $(function(){ // hide the open311_only section and reveal it only when send_method is relevant var $open311_only = $('.admin-open311-only'); - if ($open311_only) { - function hide_or_show_open311(hide_fast) { - var send_method = $('#send_method').val(); - var show_open311 = false; - if ($('#endpoint').val()) { - show_open311 = true; // always show the form if there is an endpoint value - } else if (send_method && send_method.toLowerCase() != 'email') { - show_open311 = true; - } - if (show_open311) { - $open311_only.slideDown(); + + function hide_or_show_open311(hide_fast) { + var send_method = $('#send_method').val(); + var show_open311 = false; + if ($('#endpoint').val()) { + show_open311 = true; // always show the form if there is an endpoint value + } else if (send_method && send_method.toLowerCase() != 'email') { + show_open311 = true; + } + if (show_open311) { + $open311_only.slideDown(); + } else { + if (hide_fast) { + $open311_only.hide(); } else { - if (hide_fast) { - $open311_only.hide(); - } else { - $open311_only.slideUp(); - } + $open311_only.slideUp(); } } + } + + if ($open311_only) { $('#send_method').on('change', hide_or_show_open311); hide_or_show_open311(true); } @@ -51,7 +53,7 @@ $(function(){ $cols.show(); $(this).prop("value", 'Hide deleted contacts'); } - }) + }); } }); -- cgit v1.2.3 From 125d511f3992ddc889bf73c24dde019e05c3433d Mon Sep 17 00:00:00 2001 From: Dave Whiteland Date: Thu, 15 Aug 2013 13:24:57 +0100 Subject: fix deciding-to-hide contacts bug was counting rows and expecting them to be 1, when it should have been counting tables. --- web/js/fixmystreet-admin.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'web/js/fixmystreet-admin.js') diff --git a/web/js/fixmystreet-admin.js b/web/js/fixmystreet-admin.js index 64f73ebb7..76c02128c 100644 --- a/web/js/fixmystreet-admin.js +++ b/web/js/fixmystreet-admin.js @@ -38,9 +38,8 @@ $(function(){ }); // on a body's page, hide/show deleted contact categories - var $table_with_deleted_contacts = $('table tr.is-deleted td.contact-category'); + var $table_with_deleted_contacts = $('table tr.is-deleted td.contact-category').closest('table'); if ($table_with_deleted_contacts.length == 1) { - $table_with_deleted_contacts = $table_with_deleted_contacts.closest('table'); var $toggle_deleted_btn = $(""); $table_with_deleted_contacts.before($toggle_deleted_btn); $toggle_deleted_btn.on('click', function(e){ -- cgit v1.2.3 From 04b187d5347dd2d26874a83902e51c2532ef8a2f Mon Sep 17 00:00:00 2001 From: Dave Whiteland Date: Fri, 6 Sep 2013 10:56:49 +0100 Subject: add show-admin-notes class to body making the admin-notes functionality easier to suppress on installations that don't want it; it's in the default header, i.e., on for new installations --- web/js/fixmystreet-admin.js | 46 +++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) (limited to 'web/js/fixmystreet-admin.js') diff --git a/web/js/fixmystreet-admin.js b/web/js/fixmystreet-admin.js index 76c02128c..1aabf8349 100644 --- a/web/js/fixmystreet-admin.js +++ b/web/js/fixmystreet-admin.js @@ -28,32 +28,34 @@ $(function(){ hide_or_show_open311(true); } - // admin hints: maybe better implemented as tooltips? - $(".admin-hint").on('click', function(){ - if ($(this).hasClass('admin-hint-show')) { - $(this).removeClass('admin-hint-show'); - } else { - $(this).addClass('admin-hint-show'); - } - }); + if ($('body').hasClass("show-admin-notes")) { - // on a body's page, hide/show deleted contact categories - var $table_with_deleted_contacts = $('table tr.is-deleted td.contact-category').closest('table'); - if ($table_with_deleted_contacts.length == 1) { - var $toggle_deleted_btn = $(""); - $table_with_deleted_contacts.before($toggle_deleted_btn); - $toggle_deleted_btn.on('click', function(e){ - e.preventDefault(); - var $cols = $table_with_deleted_contacts.find('tr.is-deleted'); - if ($cols.first().is(':visible')) { - $cols.hide(); - $(this).prop("value", 'Show deleted contacts'); + // admin hints: maybe better implemented as tooltips? + $(".admin-hint").on('click', function(){ + if ($(this).hasClass('admin-hint-show')) { + $(this).removeClass('admin-hint-show'); } else { - $cols.show(); - $(this).prop("value", 'Hide deleted contacts'); + $(this).addClass('admin-hint-show'); } }); - } + // on a body's page, hide/show deleted contact categories + var $table_with_deleted_contacts = $('table tr.is-deleted td.contact-category').closest('table'); + if ($table_with_deleted_contacts.length == 1) { + var $toggle_deleted_btn = $(""); + $table_with_deleted_contacts.before($toggle_deleted_btn); + $toggle_deleted_btn.on('click', function(e){ + e.preventDefault(); + var $cols = $table_with_deleted_contacts.find('tr.is-deleted'); + if ($cols.first().is(':visible')) { + $cols.hide(); + $(this).prop("value", 'Show deleted contacts'); + } else { + $cols.show(); + $(this).prop("value", 'Hide deleted contacts'); + } + }); + } + } }); -- cgit v1.2.3