diff --git a/HISTORY.rst b/HISTORY.rst
index 34d5a796fe..d115ec07cb 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -1,5 +1,9 @@
3.2 (2018-XX-XX)
================
+- Documents: Add a server side template for invalid documents.
+ The new template can be accessed via the templates API.
+ Improve the way invalid documents are detected in the JavaScript
+ code.
- Pagination: Fix page AJAX reload when clicking on pagination active page
link.
- Pagination: Add pure pagination subclass that supports custom page
diff --git a/mayan/apps/appearance/static/appearance/js/mayan_image.js b/mayan/apps/appearance/static/appearance/js/mayan_image.js
index d04f896832..869faf547e 100644
--- a/mayan/apps/appearance/static/appearance/js/mayan_image.js
+++ b/mayan/apps/appearance/static/appearance/js/mayan_image.js
@@ -6,10 +6,11 @@ class MayanImage {
this.load();
}
- static intialize () {
- var app = this;
+ static intialize (options) {
+ this.options = options || {};
+ this.options.templateInvalidDocument = this.options.templateInvalidDocument || 'Error loading document image';
- this.fancybox = $().fancybox({
+ $().fancybox({
animationDuration : 300,
buttons : [
'fullScreen',
@@ -58,30 +59,32 @@ class MayanImage {
}
static timerFunction () {
- $.fn.matchHeight._maintainScroll = true;
$.fn.matchHeight._update();
}
load () {
- var self = this;
var container = this.element.parent().parent().parent();
+ var dataURL = this.element.attr('data-url');
- this.element.attr('src', this.element.attr('data-url'));
- this.element.on('error', function() {
- // Check the .complete property to see if it is a real error
- // or it was a cached image
- if (this.complete === false) {
- // It is a cached image, set the src attribute to trigger
- // it's display.
- this.src = this.src;
- } else {
- container.html(MayanImage.templateInvalidDocument);
- }
- });
-
- $.fn.matchHeight._maintainScroll = true;
+ if (dataURL === '') {
+ container.html(MayanImage.options.templateInvalidDocument);
+ } else {
+ this.element.attr('src', dataURL);
+ this.element.on('error', function() {
+ // Check the .complete property to see if it is a real error
+ // or it was a cached image
+ if (this.complete === false) {
+ // It is a cached image, set the src attribute to trigger
+ // it's display.
+ this.src = this.src;
+ } else {
+ container.html(MayanImage.options.templateInvalidDocument);
+ }
+ });
+ }
};
}
-MayanImage.templateInvalidDocument = $('#template-invalid-document').html();
MayanImage.timer = setTimeout(null);
+
+$.fn.matchHeight._maintainScroll = true;
diff --git a/mayan/apps/appearance/templates/appearance/root.html b/mayan/apps/appearance/templates/appearance/root.html
index 3a98e2d645..b986ffc988 100644
--- a/mayan/apps/appearance/templates/appearance/root.html
+++ b/mayan/apps/appearance/templates/appearance/root.html
@@ -61,17 +61,6 @@
-
-