Skip to content
Snippets Groups Projects
Commit 751b0bb8 authored by Chris Hallberg's avatar Chris Hallberg Committed by Demian Katz
Browse files

Improve Lightbox accessibility.

parent d88db6b6
No related merge requests found
...@@ -3,11 +3,11 @@ VuFind.register('lightbox', function Lightbox() { ...@@ -3,11 +3,11 @@ VuFind.register('lightbox', function Lightbox() {
// State // State
var _originalUrl = false; var _originalUrl = false;
var _currentUrl = false; var _currentUrl = false;
var _lightboxTitle = ''; var _lightboxTitle = false;
var refreshOnClose = false; var refreshOnClose = false;
var _modalParams = {}; var _modalParams = {};
// Elements // Elements
var _modal, _modalBody, _clickedButton = null; var _modal, _modalBody, _modalTitle, _clickedButton = null;
// Utilities // Utilities
function _storeClickedStatus() { function _storeClickedStatus() {
_clickedButton = this; _clickedButton = this;
...@@ -15,13 +15,9 @@ VuFind.register('lightbox', function Lightbox() { ...@@ -15,13 +15,9 @@ VuFind.register('lightbox', function Lightbox() {
function _html(content) { function _html(content) {
_modalBody.html(content); _modalBody.html(content);
// Set or update title if we have one // Set or update title if we have one
if (_lightboxTitle !== '') { if (_lightboxTitle) {
var h2 = _modalBody.find('h2:first-child'); _modalTitle.text(_lightboxTitle);
if (h2.length === 0) { _lightboxTitle = false;
h2 = $('<h2/>').prependTo(_modalBody);
}
h2.text(_lightboxTitle);
_lightboxTitle = '';
} }
_modal.modal('handleUpdate'); _modal.modal('handleUpdate');
} }
...@@ -242,12 +238,12 @@ VuFind.register('lightbox', function Lightbox() { ...@@ -242,12 +238,12 @@ VuFind.register('lightbox', function Lightbox() {
} }
if (this.href.length > 1) { if (this.href.length > 1) {
event.preventDefault(); event.preventDefault();
var obj = {url: $(this).data('lightboxHref') || this.href}; var obj = {url: $(this).data('lightbox-href') || this.href};
if ("string" === typeof $(this).data('lightboxPost')) { if ("string" === typeof $(this).data('lightbox-post')) {
obj.type = 'POST'; obj.type = 'POST';
obj.data = $(this).data('lightboxPost'); obj.data = $(this).data('lightbox-post');
} }
_lightboxTitle = $(this).data('lightboxTitle') || ''; _lightboxTitle = $(this).data('lightbox-title') || '';
_modalParams = $(this).data(); _modalParams = $(this).data();
VuFind.modal('show'); VuFind.modal('show');
ajax(obj); ajax(obj);
...@@ -322,7 +318,7 @@ VuFind.register('lightbox', function Lightbox() { ...@@ -322,7 +318,7 @@ VuFind.register('lightbox', function Lightbox() {
submit.attr('disabled', 'disabled'); submit.attr('disabled', 'disabled');
} }
// Store custom title // Store custom title
_lightboxTitle = submit.data('lightboxTitle') || $(form).data('lightboxTitle') || ''; _lightboxTitle = submit.data('lightbox-title') || $(form).data('lightbox-title') || '';
// Get Lightbox content // Get Lightbox content
ajax({ ajax({
url: $(form).attr('action') || _currentUrl, url: $(form).attr('action') || _currentUrl,
...@@ -366,7 +362,7 @@ VuFind.register('lightbox', function Lightbox() { ...@@ -366,7 +362,7 @@ VuFind.register('lightbox', function Lightbox() {
}); });
imageCheck.done(function lightboxImageCheckDone(content, status, jq_xhr) { imageCheck.done(function lightboxImageCheckDone(content, status, jq_xhr) {
if ( if (
jq_xhr.status === 200 && jq_xhr.status === 200 &&
jq_xhr.getResponseHeader("content-type").substr(0, 5) === "image" jq_xhr.getResponseHeader("content-type").substr(0, 5) === "image"
) { ) {
render('<div class="lightbox-image"><img src="' + url + '"/></div>'); render('<div class="lightbox-image"><img src="' + url + '"/></div>');
...@@ -388,6 +384,7 @@ VuFind.register('lightbox', function Lightbox() { ...@@ -388,6 +384,7 @@ VuFind.register('lightbox', function Lightbox() {
function init() { function init() {
_modal = $('#modal'); _modal = $('#modal');
_modalBody = _modal.find('.modal-body'); _modalBody = _modal.find('.modal-body');
_modalTitle = _modal.find('#modal-title');
_modal.on('hide.bs.modal', function lightboxHide() { _modal.on('hide.bs.modal', function lightboxHide() {
if (VuFind.lightbox.refreshOnClose) { if (VuFind.lightbox.refreshOnClose) {
VuFind.refreshPage(); VuFind.refreshPage();
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
right: 0; right: 0;
z-index: 2; z-index: 2;
padding: .5rem 1rem; padding: .5rem 1rem;
opacity: .7; opacity: 1;
body.rtl & { body.rtl & {
left: 0; left: 0;
...@@ -15,17 +15,19 @@ ...@@ -15,17 +15,19 @@
} }
@media (min-width: 768px) { @media (min-width: 768px) {
#modal .modal-content > .close { // Fancy side X button #modal .modal-content > .close { // Fancy side X button
right: -50px; right: -60px;
font-size: 32pt; font-size: 32pt;
color: #fff; color: #fff;
background-color: rgba(0,0,0,0);
border-radius: 6px;
body.rtl & { body.rtl & {
left: -50px; left: -60px;
right: auto; right: auto;
} }
} }
} }
#modal .modal-content > .close:hover { opacity: 1; } #modal .modal-content > .close:hover { background-color: #000; }
#modal .modal-body h1, #modal .modal-body h1,
#modal .modal-body h2 { #modal .modal-body h2 {
margin-top: 0.3rem; margin-top: 0.3rem;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment