# This patch file was generated by NetBeans IDE # This patch can be applied using context Tools: Apply Diff Patch action on respective folder. # It uses platform neutral UTF-8 encoding. # Above lines and this line are ignored by the patching process. --- D:\Projects\drupal\views_patchs\ajax_view.original.js +++ D:\Projects\drupal\views_patchs\ajax_view.js @@ -153,7 +153,10 @@ }); } }, - error: function(xhr) { $(this).removeClass('views-throbbing'); Drupal.Views.Ajax.handleErrors(xhr, ajax_path); }, + error: function(xhr, textStatus, errorThrown) { + $(this).removeClass('views-throbbing'); + Drupal.Views.Ajax.handleErrors(xhr, ajax_path, textStatus, errorThrown); + }, dataType: 'json' }); @@ -164,3 +167,47 @@ }); // .each Drupal.settings.views.ajaxViews } // if }; + + +/** + * Get rid of irritating tabledrag messages + */ +Drupal.theme.tableDragChangedWarning = function () { + return '
'; +} + +/** + * Display error in a more fashion way + */ +Drupal.Views.Ajax.handleErrors = function (xhr, path, textStatus, errorThrown) { + var error_text = ''; + + if ((xhr.status == 500 && xhr.responseText) || xhr.status == 200) { + error_text = xhr.responseText; + + // Replace all < and > by < and > + error_text = error_text.replace("/&(lt|gt);/g", function (m, p) { + return (p == "lt")? "<" : ">"; + }); + + // Now, replace all html tags by empty spaces + error_text = error_text.replace(/<("[^"]*"|'[^']*'|[^'">])*>/gi,""); + + // Fix end lines + error_text = error_text.replace(/[\n]+\s+/g,"\n"); + } + else if (xhr.status == 500) { + error_text = xhr.status + ': ' + Drupal.t("Internal server error. Please see server or PHP logs for error information."); + } + else if(textStatus=='timeout'){ + error_text = Drupal.t("The server doesn't answer. Time out."); + } + else if(textStatus=='parsererror') { + error_text = Drupal.t("Error while parsing code"); + } + else { + error_text = xhr.status + ': ' + xhr.statusText; + } + + alert(Drupal.t("An error occurred at @path.\n\nError Description: @error", {'@path': path, '@error': error_text})); +}