From 7f5e41c885cb892a53b48efe46f52565078a4140 Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Fri, 20 Nov 2015 13:41:23 -0500 Subject: [PATCH] Add basic 403 handling to table.js --- .../public/js/airtime/library/library.js | 25 ++++++++++--------- .../public/js/airtime/widgets/table.js | 12 +++------ 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index 3bf80d800..1b9f82a2c 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -542,6 +542,18 @@ var AIRTIME = (function(AIRTIME) { } }; + mod.handleAjaxError = function (r) { + // If the request was denied due to permissioning + if (r.status === 403) { + // Hide the processing div + var wrapper = $("#library_display_wrapper"); + wrapper.find(".dt-process-rel").hide(); + wrapper.find('.empty_placeholder_text').text($.i18n._("You don't have permission to view the library.")); + wrapper.find('.empty_placeholder').show(); + } + }; + + libraryInit = function() { $libContent = $("#library_content"); @@ -706,7 +718,7 @@ var AIRTIME = (function(AIRTIME) { "url": sSource, "data": aoData, "success": fnCallback, - "error": handleAjaxError + "error": mod.handleAjaxError }).done(function (data) { var filterMessage = $libContent.find('.filter-message'); if (data.iTotalRecords > data.iTotalDisplayRecords) { @@ -904,17 +916,6 @@ var AIRTIME = (function(AIRTIME) { } - function handleAjaxError(r) { - // If the request was denied due to permissioning - if (r.status === 403) { - // Hide the processing div - $("#library_display_wrapper").find(".dt-process-rel").hide(); - $('.empty_placeholder_text').text($.i18n._("You don't have permission to view the library.")); - - $('.empty_placeholder').show(); - } - } - var selected = $("a[href$='"+location.hash+"']"), table; if (selected.parent().data("selection-id") == AIRTIME.library.MediaTypeIntegerEnum.PODCAST) { table = mod.DataTableTypeEnum.PODCAST; diff --git a/airtime_mvc/public/js/airtime/widgets/table.js b/airtime_mvc/public/js/airtime/widgets/table.js index aaf3b75b9..dc23f8df8 100644 --- a/airtime_mvc/public/js/airtime/widgets/table.js +++ b/airtime_mvc/public/js/airtime/widgets/table.js @@ -399,15 +399,9 @@ var AIRTIME = (function(AIRTIME) { Table.prototype._handleAjaxError = function(r) { // If the request was denied due to permissioning if (r.status === 403) { - // Hide the processing div - /* - $("#library_display_wrapper").find(".dt-process-rel").hide(); - $.getJSON( "ajax/library_placeholders.json", function( data ) { - $('.empty_placeholder_text').text($.i18n._(data.unauthorized)); - }) ; - - $('.empty_placeholder').show(); - */ + $(".dt-process-rel").hide(); + $('.empty_placeholder_text').text($.i18n._("You don't have permission to view this resource.")); + $('.empty_placeholder').show(); } };