Skip to content

Commit

Permalink
Refactored CSS classes.
Browse files Browse the repository at this point in the history
A bit more BEM.
  • Loading branch information
Duncan McDougall committed Jun 19, 2015
1 parent 1e7a8ad commit b323e09
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 32 deletions.
38 changes: 24 additions & 14 deletions jquery.lightbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,31 @@
-webkit-filter: none !important;
z-index: 9997;
}

.lightbox img {
display: block;
position: absolute;
border: 5px solid #fff;
box-shadow: 0 0 20px #000;
border-radius: 1px;
}

body.blurred > * {
-webkit-filter: blur(2px);
-webkit-transform: translate3d(0, 0, 0);
}
.lightbox-loading {

.lightbox__loading {
background: url(loading.gif) center center no-repeat;
width: 31px;
height: 31px;
width: 32px;
height: 32px;
margin: -16px 0 0 -16px;
position: absolute;
top: 48%;
top: 50%;
left: 50%;
}
.lightbox-caption {

.lightbox__caption {
display: none;
position: absolute;
left: 0;
Expand All @@ -43,7 +47,7 @@ body.blurred > * {
background: rgba(0,0,0,0.7);
}

.lightbox-caption p {
.lightbox__caption p {
margin: 0 auto;
max-width: 70%;
display: inline-block;
Expand All @@ -55,7 +59,7 @@ body.blurred > * {
line-height: 18px;
}

.lightbox-button {
.lightbox__button {
position: absolute;
z-index: 9999;
background: no-repeat center center;
Expand All @@ -68,27 +72,33 @@ body.blurred > * {
transition: all 0.3s;
}

.lightbox-button:hover,
.lightbox-button:focus {
.lightbox__button:hover,
.lightbox__button:focus {
opacity: 1;
-webkit-transform: scale(1.4);
-moz-transform: scale(1.4);
-ms-transform: scale(1.4);
transform: scale(1.4);
}

.lightbox-close {
.lightbox__close {
right: 10px;
top: 10px;
background-image: url('close.png');
}
.lightbox-next {

.lightbox__nav {
top: 50%;
margin-top: -16px;
}

.lightbox__nav--next {
right: 10px;
top: 48%;
background-image: url('next.png');
}
.lightbox-previous {

.lightbox__nav--prev {
left: 10px;
top: 48%;
background-image: url('previous.png');
}
}
28 changes: 13 additions & 15 deletions jquery.lightbox.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* jquery.lightbox.js v1.1
* jquery.lightbox.js v1.2
* https://github.com/duncanmcdougall/Responsive-Lightbox
* Copyright 2015 Duncan McDougall and other contributors; @license Creative Commons Attribution 2.5
*
Expand Down Expand Up @@ -39,23 +39,21 @@
if (!plugin.lightbox) {
$('body').append(
'<div id="'+id+'" class="lightbox" style="display:none;">'+
'<a href="#" class="lightbox-close lightbox-button"></a>' +
'<div class="lightbox-nav">'+
'<a href="#" class="lightbox-previous lightbox-button"></a>' +
'<a href="#" class="lightbox-next lightbox-button"></a>' +
'</div>' +
'<div href="#" class="lightbox-caption"><p></p></div>' +
'<a href="#" class="lightbox__close lightbox__button"></a>' +
'<a href="#" class="lightbox__nav lightbox__nav--prev lightbox__button"></a>' +
'<a href="#" class="lightbox__nav lightbox__nav--next lightbox__button"></a>' +
'<div href="#" class="lightbox__caption"><p></p></div>' +
'</div>'
);

plugin.lightbox = $("#"+id);
plugin.caption = $('.lightbox-caption', plugin.lightbox);
plugin.caption = $('.lightbox__caption', plugin.lightbox);
}

if (plugin.items.length > 1 && opts.nav) {
$('.lightbox-nav', plugin.lightbox).show();
$('.lightbox__nav', plugin.lightbox).show();
} else {
$('.lightbox-nav', plugin.lightbox).hide();
$('.lightbox__nav', plugin.lightbox).hide();
}

plugin.bindEvents();
Expand All @@ -67,12 +65,12 @@
$("body").addClass("blurred");
}
$("img", plugin.lightbox).remove();
plugin.lightbox.fadeIn('fast').append('<span class="lightbox-loading"></span>');
plugin.lightbox.fadeIn('fast').append('<span class="lightbox__loading"></span>');

var img = $('<img src="' + $(plugin.current).attr('href') + '" draggable="false">');

$(img).load(function () {
$('.lightbox-loading').remove();
$('.lightbox__loading').remove();
plugin.lightbox.append(img);
plugin.image = $("img", plugin.lightbox).hide();
plugin.resizeImage();
Expand Down Expand Up @@ -179,19 +177,19 @@
});

// Previous click
$(plugin.lightbox).on('click', '.lightbox-previous', function () {
$(plugin.lightbox).on('click', '.lightbox__nav--prev', function () {
plugin.previous();
return false;
});

// Next click
$(plugin.lightbox).on('click', '.lightbox-next', function () {
$(plugin.lightbox).on('click', '.lightbox__nav--next', function () {
plugin.next();
return false;
});

// Close click
$(plugin.lightbox).on('click', '.lightbox-close', function () {
$(plugin.lightbox).on('click', '.lightbox__close', function () {
plugin.close();
return false;
});
Expand Down
2 changes: 1 addition & 1 deletion jquery.lightbox.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions jquery.lightbox.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b323e09

Please sign in to comment.