From 476b9bff69c1f3a48f9dbeead9af52aeab56397c Mon Sep 17 00:00:00 2001 From: Alice Butcher Date: Mon, 15 Jan 2024 13:47:21 +0000 Subject: [PATCH] refactor: remove mam patch and gallery overrides the new image servers and a small patch to the gallery plugin make all of this unnecessary. mustache was only required by the mam script, so that's been removed too. --- ckanext/nhm/theme/assets/scripts/mam.js | 40 -- .../vendor/mustache/0.5.0-dev/mustache.js | 536 ------------------ .../vendor/mustache/0.5.0-dev/mustache.min.js | 36 -- ckanext/nhm/theme/assets/webassets.yml | 7 - .../templates/gallery/snippets/gallery.html | 6 - .../templates/gallery/snippets/lightbox.html | 5 - pyproject.toml | 2 +- 7 files changed, 1 insertion(+), 631 deletions(-) delete mode 100644 ckanext/nhm/theme/assets/scripts/mam.js delete mode 100644 ckanext/nhm/theme/assets/scripts/vendor/mustache/0.5.0-dev/mustache.js delete mode 100644 ckanext/nhm/theme/assets/scripts/vendor/mustache/0.5.0-dev/mustache.min.js delete mode 100644 ckanext/nhm/theme/templates/gallery/snippets/gallery.html delete mode 100644 ckanext/nhm/theme/templates/gallery/snippets/lightbox.html diff --git a/ckanext/nhm/theme/assets/scripts/mam.js b/ckanext/nhm/theme/assets/scripts/mam.js deleted file mode 100644 index 15a9dae9..00000000 --- a/ckanext/nhm/theme/assets/scripts/mam.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Created by bens3 on 07/11/15. - * - * JH (12/10/21): This no longer uses MAM to download images! Will refactor once confirmed as - * stable. - */ - -var MAM = { - init: function () { - $('#download-tooltip').tooltip({ - position: { - of: '#blueimp-gallery a.gallery-control-download', - my: 'left+60 center', - at: 'left center', - }, - tooltipClass: 'download-tooltip', - }); - var $gallery = $('#blueimp-gallery'); - $gallery - .find('a.gallery-control-download') - .on('click', jQuery.proxy(MAM._hijackDownloadLink)); - // Hide the tooltip if the gallery is clicked - $gallery.on('click', jQuery.proxy(MAM._hideDownloadTooltip)); - }, - _hijackDownloadLink: function (e) { - // Take over the download link - if it's a MAM one show the tooltip options - // Otherwise just propagate to default action - var image = $('#blueimp-gallery').data('image'); - if (!!image.download) { - window.location = image.download; - e.stopPropagation(); - return false; - } - return true; - }, -}; - -$(document).ready(function () { - MAM.init(); -}); diff --git a/ckanext/nhm/theme/assets/scripts/vendor/mustache/0.5.0-dev/mustache.js b/ckanext/nhm/theme/assets/scripts/vendor/mustache/0.5.0-dev/mustache.js deleted file mode 100644 index 641cebd5..00000000 --- a/ckanext/nhm/theme/assets/scripts/vendor/mustache/0.5.0-dev/mustache.js +++ /dev/null @@ -1,536 +0,0 @@ -/*! - * mustache.js - Logic-less {{mustache}} templates with JavaScript - * http://github.com/janl/mustache.js - */ -var Mustache = (typeof module !== "undefined" && module.exports) || {}; - -(function (exports) { - - exports.name = "mustache.js"; - exports.version = "0.5.0-dev"; - exports.tags = ["{{", "}}"]; - exports.parse = parse; - exports.compile = compile; - exports.render = render; - exports.clearCache = clearCache; - - // This is here for backwards compatibility with 0.4.x. - exports.to_html = function (template, view, partials, send) { - var result = render(template, view, partials); - - if (typeof send === "function") { - send(result); - } else { - return result; - } - }; - - var _toString = Object.prototype.toString; - var _isArray = Array.isArray; - var _forEach = Array.prototype.forEach; - var _trim = String.prototype.trim; - - var isArray; - if (_isArray) { - isArray = _isArray; - } else { - isArray = function (obj) { - return _toString.call(obj) === "[object Array]"; - }; - } - - var forEach; - if (_forEach) { - forEach = function (obj, callback, scope) { - return _forEach.call(obj, callback, scope); - }; - } else { - forEach = function (obj, callback, scope) { - for (var i = 0, len = obj.length; i < len; ++i) { - callback.call(scope, obj[i], i, obj); - } - }; - } - - var spaceRe = /^\s*$/; - - function isWhitespace(string) { - return spaceRe.test(string); - } - - var trim; - if (_trim) { - trim = function (string) { - return string == null ? "" : _trim.call(string); - }; - } else { - var trimLeft, trimRight; - - if (isWhitespace("\xA0")) { - trimLeft = /^\s+/; - trimRight = /\s+$/; - } else { - // IE doesn't match non-breaking spaces with \s, thanks jQuery. - trimLeft = /^[\s\xA0]+/; - trimRight = /[\s\xA0]+$/; - } - - trim = function (string) { - return string == null ? "" : - String(string).replace(trimLeft, "").replace(trimRight, ""); - }; - } - - var escapeMap = { - "&": "&", - "<": "<", - ">": ">", - '"': '"', - "'": ''' - }; - - function escapeHTML(string) { - return String(string).replace(/&(?!\w+;)|[<>"']/g, function (s) { - return escapeMap[s] || s; - }); - } - - /** - * Adds the `template`, `line`, and `file` properties to the given error - * object and alters the message to provide more useful debugging information. - */ - function debug(e, template, line, file) { - file = file || "