Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Issue #9 - Adding the ability to have a close button.

Close button is added in a similar fashion to the one for modals
Add a div.lightbox-header and then a button.close with the correct data-dismiss
  • Loading branch information...
commit 48c774485b890c7c4995728f299cf82ad1de975e 1 parent a27d8c9
Jason Butz authored
Showing with 25 additions and 17 deletions.
  1. +13 −0 bootstrap-lightbox.css
  2. +12 −17 bootstrap-lightbox.js
View
13 bootstrap-lightbox.css
@@ -46,3 +46,16 @@
-moz-background-clip: padding-box;
background-clip: padding-box;
}
+.lightbox-header .close {
+ color: white;
+ margin-right: -16px;
+ margin-top: -16px;
+ font-size: 2em;
+ opacity: .8;
+ filter: alpha(opacity=80);
+}
+
+.lightbox-header .close:hover {
+ opacity: .4;
+ filter: alpha(opacity=40);
+}
View
29 bootstrap-lightbox.js
@@ -238,13 +238,13 @@ Lightbox.prototype = {
centerImage: function()
{
var that = this;
- // In the event the image is not loaded re-center everything once loaded
- that.$h = that.$element.find('.lightbox-content').height();
- that.$w = that.$element.find('.lightbox-content').width();
+ that.$h = that.$element.height();
+ that.$w = that.$element.width();
var resizedOffs = 0;
if(that.options.resizeToFit)
{
- var myImg = that.$element.find('img:first');
+ resizedOffs = 10;
+ var myImg = that.$element.find('.lightbox-content').find('img:first');
// Save original filesize
if(!$(myImg).data('osizew')) $(myImg).data('osizew', $(myImg).width());
if(!$(myImg).data('osizeh')) $(myImg).data('osizeh', $(myImg).height());
@@ -257,20 +257,15 @@ Lightbox.prototype = {
$(myImg).css('max-width', 'none');
$(myImg).css('max-height', 'none');
- var bW = osizew > $(window).width();
- var bH = osizeh > $(window).height();
+
+ var sOffs = 40; // STYLE ?
+ if(that.$element.find('.lightbox-header').length > 0)
+ sOffs += 10;
+ $(myImg).css('max-width', $(window).width() - sOffs);
+ $(myImg).css('max-height', $(window).height() - sOffs);
- if(bH || bW)
- {
- var sOffs = 40; // STYLE ?
- $(myImg).css('max-width', $(window).width() - sOffs);
- $(myImg).css('max-height', $(window).height() - sOffs);
-
- that.$w = $(myImg).width();
- that.$h = $(myImg).height();
-
- resizedOffs = 10;
- }
+ that.$w = $(myImg).width();
+ that.$h = $(myImg).height();
}
that.$element.css({

0 comments on commit 48c7744

Please sign in to comment.
Something went wrong with that request. Please try again.