From cbe852da55e44530a2ff6418f068a39f5492ba75 Mon Sep 17 00:00:00 2001 From: Heike Reinken <reinken@ub.uni-leipzig.de> Date: Tue, 3 Nov 2020 14:33:30 +0100 Subject: [PATCH] refs #17883_b[master] Remove title attributs having redundant information * Remove title attributs having redundant information related to the content --- themes/finc-accessibility/js/account_ajax.js | 256 ++++++++++++++++++ themes/finc/js/hierarchyTree.js | 5 + .../RecordDriver/SolrAI/result-list.phtml | 3 +- .../RecordTab/holdingsils/standard.phtml | 2 +- .../finc/templates/record/cart-buttons.phtml | 4 +- 5 files changed, 265 insertions(+), 5 deletions(-) create mode 100644 themes/finc-accessibility/js/account_ajax.js diff --git a/themes/finc-accessibility/js/account_ajax.js b/themes/finc-accessibility/js/account_ajax.js new file mode 100644 index 00000000000..9d657d9f5d9 --- /dev/null +++ b/themes/finc-accessibility/js/account_ajax.js @@ -0,0 +1,256 @@ +/*global userIsLoggedIn, VuFind */ +VuFind.register('account', function Account() { + // Retrieved statuses + var LOADING = -1 * Math.PI; // waiting for request + var MISSING = -2 * Math.PI; // no data available + var INACTIVE = -3 * Math.PI; // status element missing + var _statuses = {}; + + // Account Icons + var ICON_LEVELS = { + "NONE": 0, + "GOOD": 1, + "WARNING": 2, + "DANGER": 3 + }; + var _accountIcons = {}; + _accountIcons[ICON_LEVELS.NONE] = "fa fa-user-circle"; + _accountIcons[ICON_LEVELS.GOOD] = "fa fa-bell text-success"; + _accountIcons[ICON_LEVELS.WARNING] = "fa fa-bell text-warning"; + _accountIcons[ICON_LEVELS.DANGER] = "fa fa-exclamation-triangle text-danger"; + + var _submodules = []; + + var _sessionDataPrefix = "vf-account-status-"; + var _save = function _save(module) { + sessionStorage.setItem( + _sessionDataPrefix + module, + JSON.stringify(_statuses[module]) + ); + }; + + // Clearing save forces AJAX update next page load + var clearCache = function clearCache(name) { + if (typeof name === "undefined") { + for (var sub in _submodules) { + if (Object.prototype.hasOwnProperty.call(_submodules, sub)) { + clearCache(sub); + } + } + } else { + sessionStorage.removeItem(_sessionDataPrefix + name); + } + }; + + var _getStatus = function _getStatus(module) { + return (typeof _statuses[module] === "undefined") ? LOADING : _statuses[module]; + }; + + var _render = function _render() { + var accountStatus = ICON_LEVELS.NONE; + for (var sub in _submodules) { + if (Object.prototype.hasOwnProperty.call(_submodules, sub)) { + var $element = $(_submodules[sub].selector); + if (!$element) { + _statuses[sub] = INACTIVE; + continue; + } + var status = _getStatus(sub); + if (status === MISSING) { + $element.addClass('hidden'); + } else { + $element.removeClass('hidden'); + if (status === LOADING) { + $element.html('<i class="fa fa-spin fa-spinner"></i>'); + } else { + var moduleStatus = _submodules[sub].render($element, _statuses[sub], ICON_LEVELS); + if (moduleStatus > accountStatus) { + accountStatus = moduleStatus; + } + } + } + } + } + $("#account-icon").attr("class", _accountIcons[accountStatus]); + if (accountStatus > ICON_LEVELS.NONE) { + $("#account-icon") + .attr("data-toggle", "tooltip") + .attr("data-placement", "bottom") + .attr("title", VuFind.translate("account_has_alerts")) + ; + } else { + $("#account-icon").tooltip("destroy"); + } + }; + var _ajaxLookup = function _ajaxLookup(module) { + $.ajax({ + url: VuFind.path + '/AJAX/JSON?method=' + _submodules[module].ajaxMethod, + dataType: 'json' + }) + .done(function ajaxLookupDone(response) { + _statuses[module] = response.data; + }) + .fail(function ajaxLookupFail() { + _statuses[module] = MISSING; + }) + .always(function ajaxLookupAlways() { + _save(module); + _render(); + }); + }; + + var _load = function _load(module) { + var $element = $(_submodules[module].selector); + if (!$element) { + _statuses[module] = INACTIVE; + } else { + var json = sessionStorage.getItem(_sessionDataPrefix + module); + var session = typeof json === "undefined" ? null : JSON.parse(json); + if ( + session === null || + session === LOADING || + session === MISSING + ) { + _statuses[module] = LOADING; + _ajaxLookup(module); + } else { + _statuses[module] = session; + } + _render(); + } + }; + + var init = function init() { + // Update information when certain actions are performed + $("#renewals").submit(function clearCheckedOut() { + clearCache("checkedOut"); + }); + $('#cancelHold, [name="placeHold"]').submit(function clearHolds() { + clearCache("holds"); + }); + $('#ILLRequestForm, #cancelILLRequest').submit(function clearHolds() { + clearCache("illRequests"); + }); + $('[name="placeStorageRetrievalRequest"], #cancelStorageRetrievalRequest').submit(function clearStorageRetrievals() { + clearCache("storageRetrievalRequests"); + }); + $("#library_card").change(function clearChangeLibraryCard() { + clearCache(/* all */); + }); + }; + + var register = function register(name, module) { + if (typeof _submodules[name] === "undefined") { + _submodules[name] = typeof module == 'function' ? module() : module; + } + var $el = $(_submodules[name].selector); + if ($el.length > 0) { + $el.removeClass("hidden"); + _statuses[name] = LOADING; + _load(name); + } else { + _statuses[name] = INACTIVE; + } + }; + + return { + init: init, + clearCache: clearCache, + // if user is logged out, clear cache instead of register + register: userIsLoggedIn ? register : clearCache + }; +}); + +$(document).ready(function registerAccountAjax() { + + VuFind.account.register("fines", { + selector: ".fines-status", + ajaxMethod: "getUserFines", + render: function render($element, status, ICON_LEVELS) { + if (status.value === 0) { + $element.addClass("hidden"); + return ICON_LEVELS.NONE; + } + $element.html('<span class="badge overdue">' + status.display + '</span>'); + return ICON_LEVELS.DANGER; + } + }); + + VuFind.account.register("checkedOut", { + selector: ".checkedout-status", + ajaxMethod: "getUserTransactions", + render: function render($element, status, ICON_LEVELS) { + var html = ''; + var level = ICON_LEVELS.NONE; + if (status.ok > 0) { + html += '<span class="badge ok" data-toggle="tooltip" title="' + VuFind.translate('Checked Out Items') + '">' + status.ok + '</span>'; + } + if (status.warn > 0) { + html += '<span class="badge warn" data-toggle="tooltip" title="' + VuFind.translate('renew_item_due_tooltip') + '">' + status.warn + '</span>'; + level = ICON_LEVELS.WARNING; + } + if (status.overdue > 0) { + html += '<span class="badge overdue" data-toggle="tooltip" title="' + VuFind.translate('renew_item_overdue_tooltip') + '">' + status.overdue + '</span>'; + level = ICON_LEVELS.DANGER; + } + $element.html(html); + $('[data-toggle="tooltip"]', $element).tooltip(); + return level; + } + }); + + VuFind.account.register("holds", { + selector: ".holds-status", + ajaxMethod: "getUserHolds", + render: function render($element, status, ICON_LEVELS) { + var level = ICON_LEVELS.NONE; + if (status.available > 0) { + $element.html('<i class="fa fa-bell text-success" data-toggle="tooltip" title="' + VuFind.translate('hold_available') + '"></i>'); + level = ICON_LEVELS.GOOD; + } else if (status.in_transit > 0) { + $element.html('<i class="fa fa-clock-o text-warning" data-toggle="tooltip" title="' + VuFind.translate('request_in_transit') + '"></i>'); + } else { + $element.addClass("holds-status hidden"); + } + $('[data-toggle="tooltip"]', $element).tooltip(); + return level; + } + }); + + VuFind.account.register("illRequests", { + selector: ".illrequests-status", + ajaxMethod: "getUserILLRequests", + render: function render($element, status, ICON_LEVELS) { + var level = ICON_LEVELS.NONE; + if (status.available > 0) { + $element.html('<i class="fa fa-bell text-success" data-toggle="tooltip" title="' + VuFind.translate('ill_request_available') + '"></i>'); + level = ICON_LEVELS.GOOD; + } else if (status.in_transit > 0) { + $element.html('<i class="fa fa-clock-o text-warning" data-toggle="tooltip" title="' + VuFind.translate('request_in_transit') + '"></i>'); + } else { + $element.addClass("holds-status hidden"); + } + $('[data-toggle="tooltip"]', $element).tooltip(); + return level; + } + }); + + VuFind.account.register("storageRetrievalRequests", { + selector: ".storageretrievalrequests-status", + ajaxMethod: "getUserStorageRetrievalRequests", + render: function render($element, status, ICON_LEVELS) { + var level = ICON_LEVELS.NONE; + if (status.available > 0) { + $element.html('<i class="fa fa-bell text-success" data-toggle="tooltip" title="' + VuFind.translate('storage_retrieval_request_available') + '"></i>'); + level = ICON_LEVELS.GOOD; + } else if (status.in_transit > 0) { + $element.html('<i class="fa fa-clock-o text-warning" data-toggle="tooltip" title="' + VuFind.translate('request_in_transit') + '"></i>'); + } else { + $element.addClass("holds-status hidden"); + } + $('[data-toggle="tooltip"]', $element).tooltip(); + return level; + } + }); + +}); diff --git a/themes/finc/js/hierarchyTree.js b/themes/finc/js/hierarchyTree.js index d3db7ac718c..a0afca2660e 100644 --- a/themes/finc/js/hierarchyTree.js +++ b/themes/finc/js/hierarchyTree.js @@ -212,6 +212,11 @@ $(document).ready(function hierarchyTreeReady() { scrollToClicked(); }) + + .on('after_open.jstree', function (e, data) { + $(".jstree-anchor").removeAttr("title"); + }) + .jstree({ plugins: ['search', 'types'], core: { diff --git a/themes/finc/templates/RecordDriver/SolrAI/result-list.phtml b/themes/finc/templates/RecordDriver/SolrAI/result-list.phtml index 23ac31912b2..25c28d3b411 100644 --- a/themes/finc/templates/RecordDriver/SolrAI/result-list.phtml +++ b/themes/finc/templates/RecordDriver/SolrAI/result-list.phtml @@ -224,8 +224,7 @@ if ($cover): <?php if ($this->userlist()->getMode() !== 'disabled'): ?> <?php /* if ($this->permission()->allowDisplay('feature.Favorites')): */ ?> <?php /* Add to favorites; finc: keep Icon inside link - CK */ ?> - <a href="<?=$this->recordLink()->getActionUrl($this->driver, 'Save')?>" data-lightbox class="save-record result-link-label" data-id="<?=$this->escapeHtmlAttr($this->driver->getUniqueId())?>" - title="<?=$this->transEsc('Add to favorites')?>"> + <a href="<?=$this->recordLink()->getActionUrl($this->driver, 'Save')?>" data-lightbox class="save-record result-link-label" data-id="<?=$this->escapeHtmlAttr($this->driver->getUniqueId())?>"> <i class="result-link-icon fa fa-fw fa-star" aria-hidden="true"></i> <?=$this->transEsc('Add to favorites')?> </a><br/> <?php elseif ($block = $this->permission()->getAlternateContent('feature.Favorites')): ?> diff --git a/themes/finc/templates/RecordTab/holdingsils/standard.phtml b/themes/finc/templates/RecordTab/holdingsils/standard.phtml index 561d2f01b1e..5c1c993c792 100644 --- a/themes/finc/templates/RecordTab/holdingsils/standard.phtml +++ b/themes/finc/templates/RecordTab/holdingsils/standard.phtml @@ -47,7 +47,7 @@ <?php endif; ?> <?php /* finc-specific additional insert, newspaper orders via mail - #6096 - CK */ ?> <?php if (isset($holding['emailHoldLink']) && $holding['emailHoldLink']): ?> - <a class="<?= $checkEmailHold ? 'checkEmailHold ' : '' ?>placeEmailHold " data-lightbox href="<?= $this->recordLink()->getRequestUrl($holding['emailHoldLink']) ?>" title="<?= $this->transEsc($checkEmailHold ? "EmailHold::email_hold_check_text" : "EmailHold::email_hold_place_text") ?>"> + <a class="<?= $checkEmailHold ? 'checkEmailHold ' : '' ?>placeEmailHold " data-lightbox href="<?= $this->recordLink()->getRequestUrl($holding['emailHoldLink']) ?>"> <i class="fa fa-flag"></i> <?= $this->transEsc($checkEmailHold ? "EmailHold::email_hold_check_text" : "EmailHold::email_hold_place_text") ?> </a> <?php endif; ?> diff --git a/themes/finc/templates/record/cart-buttons.phtml b/themes/finc/templates/record/cart-buttons.phtml index 1e8ba70357f..edb7d83ea32 100644 --- a/themes/finc/templates/record/cart-buttons.phtml +++ b/themes/finc/templates/record/cart-buttons.phtml @@ -6,10 +6,10 @@ <span class="btn-bookbag-toggle" data-cart-id="<?=$this->escapeHtmlAttr($this->id)?>" data-cart-source="<?=$this->escapeHtmlAttr($this->source)?>"> <?php /* Make add-to/remove-from bookbag accessible for keyboard navigation - CK */ ?> <a class="cart-add hidden<?php if (!$cart->contains($cartId)): ?> correct<?php endif ?>" href="javascript:" tabindex="0"> - <i class="cart-link-icon fa fa-plus" aria-hidden="true" title="<?=$this->transEsc('Add to Book Bag')?>"></i><span class="cart-link-label"><?=$this->transEsc('Add to Book Bag')?></span> + <i class="cart-link-icon fa fa-plus" aria-hidden="true"></i><span class="cart-link-label"><?=$this->transEsc('Add to Book Bag')?></span> </a> <a class="cart-remove hidden<?php if ($cart->contains($cartId)): ?> correct<?php endif ?>" href="javascript:" tabindex="0"> - <i class="cart-link-icon fa fa-minus-circle" aria-hidden="true" title="<?=$this->transEsc('Remove from Book Bag')?>"></i> <span class="cart-link-label"><?=$this->transEsc('Remove from Book Bag')?></span> + <i class="cart-link-icon fa fa-minus-circle" aria-hidden="true"></i> <span class="cart-link-label"><?=$this->transEsc('Remove from Book Bag')?></span> </a> <noscript> <form method="post" name="addForm" action="<?=$this->url('cart-processor')?>"> -- GitLab