aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2016-08-26 14:24:57 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2016-08-26 14:24:57 +0100
commitc1178ea85d1879d6533ac09e2a3c813441554b43 (patch)
tree2b422f0628313f8aa534f2ead03ff1d216d00621
parentb575f9e59a12e472f63a8f982e3bbafed1425e4d (diff)
parent4f7664c2b0e79fdfe57028e966642acd8c846568 (diff)
Merge remote-tracking branch 'origin/fix-ajax-moderation'
-rw-r--r--templates/web/base/common_footer_tags.html5
-rw-r--r--web/cobrands/fixmystreet/fixmystreet.js51
-rw-r--r--web/js/moderate.js51
3 files changed, 51 insertions, 56 deletions
diff --git a/templates/web/base/common_footer_tags.html b/templates/web/base/common_footer_tags.html
index debcde402..bed344f8b 100644
--- a/templates/web/base/common_footer_tags.html
+++ b/templates/web/base/common_footer_tags.html
@@ -22,11 +22,6 @@
<script type="text/javascript" src="[% version('/js/fixmystreet-admin.js') %]"></script>
[% END %]
-[% moderating = c.user && c.user.has_permission_to('moderate', problem.bodies_str) %]
-[% IF moderating %]
- <script type="text/javascript" src="[% version('/js/moderate.js') %]"></script>
-[% END %]
-
[% extra_js %]
[% TRY %][% PROCESS 'footer_extra_js.html' %][% CATCH file %][% END %]
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js
index bc728e6ae..914b8e7eb 100644
--- a/web/cobrands/fixmystreet/fixmystreet.js
+++ b/web/cobrands/fixmystreet/fixmystreet.js
@@ -785,6 +785,56 @@ $.extend(fixmystreet.set_up, {
}
});
});
+ },
+
+ moderation: function() {
+ function toggle_original ($input, revert) {
+ $input.prop('disabled', revert);
+ if (revert) {
+ $input.data('currentValue', $input.val());
+ }
+ $input.val($input.data(revert ? 'originalValue' : 'currentValue'));
+ }
+
+ function add_handlers (elem, word) {
+ elem.each( function () {
+ var $elem = $(this);
+ $elem.find('.moderate').click( function () {
+ $elem.find('.moderate-display').hide();
+ $elem.find('.moderate-edit').show();
+ });
+
+ $elem.find('.revert-title').change( function () {
+ toggle_original($elem.find('input[name=problem_title]'), $(this).prop('checked'));
+ });
+
+ $elem.find('.revert-textarea').change( function () {
+ toggle_original($elem.find('textarea'), $(this).prop('checked'));
+ });
+
+ var hide_document = $elem.find('.hide-document');
+ hide_document.change( function () {
+ $elem.find('input[name=problem_title]').prop('disabled', $(this).prop('checked'));
+ $elem.find('textarea').prop('disabled', $(this).prop('checked'));
+ $elem.find('input[type=checkbox]').prop('disabled', $(this).prop('checked'));
+ $(this).prop('disabled', false); // in case disabled above
+ });
+
+ $elem.find('.cancel').click( function () {
+ $elem.find('.moderate-display').show();
+ $elem.find('.moderate-edit').hide();
+ });
+
+ $elem.find('form').submit( function () {
+ if (hide_document.prop('checked')) {
+ return confirm('This will hide the ' + word + ' completely! (You will not be able to undo this without contacting support.)');
+ }
+ return true;
+ });
+ });
+ }
+ add_handlers( $('.problem-header'), 'problem' );
+ add_handlers( $('.item-list__item--updates'), 'update' );
}
});
@@ -1007,6 +1057,7 @@ fixmystreet.display = {
fixmystreet.set_up.fancybox_images();
fixmystreet.set_up.dropzone($sideReport);
fixmystreet.set_up.form_focus_triggers();
+ fixmystreet.set_up.moderation();
window.selected_problem_id = reportId;
var marker = fixmystreet.maps.get_marker_by_id(reportId);
diff --git a/web/js/moderate.js b/web/js/moderate.js
deleted file mode 100644
index 53277d9d9..000000000
--- a/web/js/moderate.js
+++ /dev/null
@@ -1,51 +0,0 @@
-function toggle_original ($input, revert) {
- $input.prop('disabled', revert);
- if (revert) {
- $input.data('currentValue', $input.val());
- }
- $input.val($input.data(revert ? 'originalValue' : 'currentValue'));
-}
-
-function setup_moderation (elem, word) {
-
- elem.each( function () {
- var $elem = $(this);
- $elem.find('.moderate').click( function () {
- $elem.find('.moderate-display').hide();
- $elem.find('.moderate-edit').show();
- });
-
- $elem.find('.revert-title').change( function () {
- toggle_original($elem.find('input[name=problem_title]'), $(this).prop('checked'));
- });
-
- $elem.find('.revert-textarea').change( function () {
- toggle_original($elem.find('textarea'), $(this).prop('checked'));
- });
-
- var hide_document = $elem.find('.hide-document');
- hide_document.change( function () {
- $elem.find('input[name=problem_title]').prop('disabled', $(this).prop('checked'));
- $elem.find('textarea').prop('disabled', $(this).prop('checked'));
- $elem.find('input[type=checkbox]').prop('disabled', $(this).prop('checked'));
- $(this).prop('disabled', false); // in case disabled above
- });
-
- $elem.find('.cancel').click( function () {
- $elem.find('.moderate-display').show();
- $elem.find('.moderate-edit').hide();
- });
-
- $elem.find('form').submit( function () {
- if (hide_document.prop('checked')) {
- return confirm('This will hide the ' + word + ' completely! (You will not be able to undo this without contacting support.)');
- }
- return true;
- });
- });
-}
-
-$(function () {
- setup_moderation( $('.problem-header'), 'problem' );
- setup_moderation( $('.item-list__item--updates'), 'update' );
-});