committed by
Michael Latouche
parent
97ac1ae629
commit
bdbf9122c9
@@ -77,7 +77,7 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
function LightboxDirective() {
|
||||
function LightboxDirective(focusLockService) {
|
||||
|
||||
function link(scope, el, attr, ctrl) {
|
||||
|
||||
@@ -88,6 +88,9 @@
|
||||
|
||||
el.appendTo("body");
|
||||
|
||||
|
||||
focusLockService.addInertAttribute();
|
||||
|
||||
// clean up
|
||||
scope.$on('$destroy', function() {
|
||||
// unbind watchers
|
||||
@@ -95,6 +98,9 @@
|
||||
eventBindings[e]();
|
||||
}
|
||||
|
||||
focusLockService.removeInertAttribute();
|
||||
|
||||
document.getElementsByClassName("umb-lightbox__close")[0].blur();
|
||||
el.remove();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<div class="umb-lightbox__backdrop" ng-click="close()" hotkey="esc"></div>
|
||||
|
||||
<button type="button" class="btn-reset umb-lightbox__close" localize="title" title="@general_close" ng-click="close()">
|
||||
<button type="button" umb-auto-focus class="btn-reset umb-lightbox__close" localize="title" title="@general_close" ng-click="close()">
|
||||
<umb-icon icon="icon-delete" class="umb-lightbox__control"></umb-icon>
|
||||
<span class="sr-only">
|
||||
<localize key="general_close">Close</localize>
|
||||
|
||||
@@ -168,18 +168,31 @@
|
||||
vm.pagination.totalPages = Math.ceil(pack.total / vm.pagination.pageSize);
|
||||
});
|
||||
}
|
||||
var previousElement = null;
|
||||
|
||||
function openLightbox(itemIndex, items) {
|
||||
|
||||
previousElement = ( document.activeElement || document.body );
|
||||
|
||||
vm.lightbox = {
|
||||
show: true,
|
||||
items: items,
|
||||
activeIndex: itemIndex
|
||||
activeIndex: itemIndex,
|
||||
focus: true
|
||||
};
|
||||
}
|
||||
|
||||
function closeLightbox() {
|
||||
vm.lightbox.show = false;
|
||||
vm.lightbox = null;
|
||||
|
||||
if(previousElement){
|
||||
|
||||
setTimeout(function(){
|
||||
previousElement.focus();
|
||||
previousElement = null;
|
||||
}, 100)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user