Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Issue #16 Fixed

* Pressing Escape should work in Chrome, Opera, Safari, Firefox, and IE now
  • Loading branch information...
commit c2f048eb04b6a101bb8e80d77e28f5fd6f101efd 1 parent 9e5710a
Jason Butz authored
View
4 build/bootstrap-lightbox.js
@@ -131,14 +131,14 @@
var that = this;
if (this.isShown && this.options.keyboard)
{
- this.$element.on('keyup.dismiss.lightbox', function ( e )
+ this.$element.on('keypress.dismiss.lightbox, keyup.dismiss.lightbox', function ( e )
{
e.which == 27 && that.hide();
});
}
else if (!this.isShown)
{
- this.$element.off('keyup.dismiss.lightbox');
+ this.$element.off('keypress.dismiss.lightbox, keyup.dismiss.lightbox');
}
},
hideWithTransition: function ()
View
2  build/bootstrap-lightbox.min.js
@@ -18,4 +18,4 @@
* limitations under the License.
* ========================================================= */
-!function(e){"use strict";var t=function(t,n){this.options=n,this.$element=e(t).delegate('[data-dismiss="lightbox"]',"click.dismiss.lightbox",e.proxy(this.hide,this)),this.options.remote&&this.$element.find(".lightbox-body").load(this.options.remote),this.cloneSize()};t.prototype={constructor:t,toggle:function(){return this[this.isShown?"hide":"show"]()},show:function(){var t=this,n=e.Event("show");this.$element.trigger(n);if(this.isShown||n.isDefaultPrevented())return;this.isShown=!0,this.escape(),this.backdrop(function(){var n=e.support.transition&&t.$element.hasClass("fade");t.$element.parent().length||t.$element.appendTo(document.body),t.$element.show(),n&&t.$element[0].offsetWidth,t.$element.addClass("in").attr("aria-hidden",!1),t.enforceFocus(),n?t.$element.one(e.support.transition.end,function(){t.centerImage(),t.$element.focus().trigger("shown")}):function(){t.centerImage(),t.$element.focus().trigger("shown")}()})},hide:function(t){t&&t.preventDefault();var n=this;t=e.Event("hide"),this.$element.trigger(t);if(!this.isShown||t.isDefaultPrevented())return;this.isShown=!1,this.escape(),e(document).off("focusin.lightbox"),this.$element.removeClass("in").attr("aria-hidden",!0),e.support.transition&&this.$element.hasClass("fade")?this.hideWithTransition():this.hideLightbox()},enforceFocus:function(){var t=this;e(document).on("focusin.lightbox",function(e){t.$element[0]!==e.target&&!t.$element.has(e.target).length&&t.$element.focus()})},escape:function(){var e=this;this.isShown&&this.options.keyboard?this.$element.on("keyup.dismiss.lightbox",function(t){t.which==27&&e.hide()}):this.isShown||this.$element.off("keyup.dismiss.lightbox")},hideWithTransition:function(){var t=this,n=setTimeout(function(){t.$element.off(e.support.transition.end),t.hideLightbox()},500);this.$element.one(e.support.transition.end,function(){clearTimeout(n),t.hideLightbox()})},hideLightbox:function(e){this.$element.hide().trigger("hidden"),this.backdrop()},removeBackdrop:function(){this.$backdrop.remove(),this.$backdrop=null},backdrop:function(t){var n=this,r=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var i=e.support.transition&&r;this.$backdrop=e('<div class="modal-backdrop '+r+'" />').appendTo(document.body),this.$backdrop.click(this.options.backdrop=="static"?e.proxy(this.$element[0].focus,this.$element[0]):e.proxy(this.hide,this)),i&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),i?this.$backdrop.one(e.support.transition.end,t):t()}else!this.isShown&&this.$backdrop?(this.$backdrop.removeClass("in"),e.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one(e.support.transition.end,e.proxy(this.removeBackdrop,this)):this.removeBackdrop()):t&&t()},centerImage:function(){var t=this,n=0,r;t.h=t.$element.height(),t.w=t.$element.width();if(t.options.resizeToFit){n=10,r=t.$element.find(".lightbox-content").find("img:first"),r.data("osizew")||r.data("osizew",r.width()),r.data("osizeh")||r.data("osizeh",r.height());var i=r.data("osizew"),s=r.data("osizeh");r.css("max-width","none"),r.css("max-height","none");var o=40;t.$element.find(".lightbox-header").length>0&&(o+=10),r.css("max-width",e(window).width()-o),r.css("max-height",e(window).height()-o),t.w=r.width(),t.h=r.height()}t.$element.css({position:"fixed",left:e(window).width()/2-t.w/2,top:e(window).height()/2-t.h/2-n}),t.enforceFocus()},cloneSize:function(){var t=this;t.$clone=t.$element.filter(":first").clone().css({position:"absolute",top:-2e3,display:"block",visibility:"visible",opacity:100}).removeClass("fade").appendTo("body"),t.h=t.$clone.height(),t.w=t.$clone.width(),t.$clone.remove(),t.$element.css({position:"fixed",left:e(window).width()/2-t.w/2,top:e(window).height()/2-t.h/2})}},e.fn.lightbox=function(n){return this.each(function(){var r=e(this),i=r.data("lightbox"),s=e.extend({},e.fn.lightbox.defaults,r.data(),typeof n=="object"&&n);i||r.data("lightbox",i=new t(this,s)),typeof n=="string"?i[n]():s.show&&i.show()})},e.fn.lightbox.defaults={backdrop:!0,keyboard:!0,show:!0,resizeToFit:!0},e.fn.lightbox.Constructor=t,e(document).on("click.lightbox.data-api",'[data-toggle="lightbox"]',function(t){var n=e(this),r=n.attr("href"),i=e(n.attr("data-target")||r&&r.replace(/.*(?=#[^\s]+$)/,"")),s=i.data("lightbox")?"toggle":e.extend({remote:!/#/.test(r)&&r},i.data(),n.data()),o=n.attr("data-image")||!1,u;t.preventDefault(),o&&(i.data("original-content",i.find(".lightbox-content").html()),i.find(".lightbox-content").html('<img border="0" src="'+o+'" />')),i.lightbox(s).one("hide",function(){n.focus()}).one("hidden",function(){o&&(i.find(".lightbox-content").html(i.data("original-content")),o=undefined)})})}(window.jQuery);
+!function(e){"use strict";var t=function(t,n){this.options=n,this.$element=e(t).delegate('[data-dismiss="lightbox"]',"click.dismiss.lightbox",e.proxy(this.hide,this)),this.options.remote&&this.$element.find(".lightbox-body").load(this.options.remote),this.cloneSize()};t.prototype={constructor:t,toggle:function(){return this[this.isShown?"hide":"show"]()},show:function(){var t=this,n=e.Event("show");this.$element.trigger(n);if(this.isShown||n.isDefaultPrevented())return;this.isShown=!0,this.escape(),this.backdrop(function(){var n=e.support.transition&&t.$element.hasClass("fade");t.$element.parent().length||t.$element.appendTo(document.body),t.$element.show(),n&&t.$element[0].offsetWidth,t.$element.addClass("in").attr("aria-hidden",!1),t.enforceFocus(),n?t.$element.one(e.support.transition.end,function(){t.centerImage(),t.$element.focus().trigger("shown")}):function(){t.centerImage(),t.$element.focus().trigger("shown")}()})},hide:function(t){t&&t.preventDefault();var n=this;t=e.Event("hide"),this.$element.trigger(t);if(!this.isShown||t.isDefaultPrevented())return;this.isShown=!1,this.escape(),e(document).off("focusin.lightbox"),this.$element.removeClass("in").attr("aria-hidden",!0),e.support.transition&&this.$element.hasClass("fade")?this.hideWithTransition():this.hideLightbox()},enforceFocus:function(){var t=this;e(document).on("focusin.lightbox",function(e){t.$element[0]!==e.target&&!t.$element.has(e.target).length&&t.$element.focus()})},escape:function(){var e=this;this.isShown&&this.options.keyboard?this.$element.on("keypress.dismiss.lightbox, keyup.dismiss.lightbox",function(t){t.which==27&&e.hide()}):this.isShown||this.$element.off("keypress.dismiss.lightbox, keyup.dismiss.lightbox")},hideWithTransition:function(){var t=this,n=setTimeout(function(){t.$element.off(e.support.transition.end),t.hideLightbox()},500);this.$element.one(e.support.transition.end,function(){clearTimeout(n),t.hideLightbox()})},hideLightbox:function(e){this.$element.hide().trigger("hidden"),this.backdrop()},removeBackdrop:function(){this.$backdrop.remove(),this.$backdrop=null},backdrop:function(t){var n=this,r=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var i=e.support.transition&&r;this.$backdrop=e('<div class="modal-backdrop '+r+'" />').appendTo(document.body),this.$backdrop.click(this.options.backdrop=="static"?e.proxy(this.$element[0].focus,this.$element[0]):e.proxy(this.hide,this)),i&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),i?this.$backdrop.one(e.support.transition.end,t):t()}else!this.isShown&&this.$backdrop?(this.$backdrop.removeClass("in"),e.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one(e.support.transition.end,e.proxy(this.removeBackdrop,this)):this.removeBackdrop()):t&&t()},centerImage:function(){var t=this,n=0,r;t.h=t.$element.height(),t.w=t.$element.width();if(t.options.resizeToFit){n=10,r=t.$element.find(".lightbox-content").find("img:first"),r.data("osizew")||r.data("osizew",r.width()),r.data("osizeh")||r.data("osizeh",r.height());var i=r.data("osizew"),s=r.data("osizeh");r.css("max-width","none"),r.css("max-height","none");var o=40;t.$element.find(".lightbox-header").length>0&&(o+=10),r.css("max-width",e(window).width()-o),r.css("max-height",e(window).height()-o),t.w=r.width(),t.h=r.height()}t.$element.css({position:"fixed",left:e(window).width()/2-t.w/2,top:e(window).height()/2-t.h/2-n}),t.enforceFocus()},cloneSize:function(){var t=this;t.$clone=t.$element.filter(":first").clone().css({position:"absolute",top:-2e3,display:"block",visibility:"visible",opacity:100}).removeClass("fade").appendTo("body"),t.h=t.$clone.height(),t.w=t.$clone.width(),t.$clone.remove(),t.$element.css({position:"fixed",left:e(window).width()/2-t.w/2,top:e(window).height()/2-t.h/2})}},e.fn.lightbox=function(n){return this.each(function(){var r=e(this),i=r.data("lightbox"),s=e.extend({},e.fn.lightbox.defaults,r.data(),typeof n=="object"&&n);i||r.data("lightbox",i=new t(this,s)),typeof n=="string"?i[n]():s.show&&i.show()})},e.fn.lightbox.defaults={backdrop:!0,keyboard:!0,show:!0,resizeToFit:!0},e.fn.lightbox.Constructor=t,e(document).on("click.lightbox.data-api",'[data-toggle="lightbox"]',function(t){var n=e(this),r=n.attr("href"),i=e(n.attr("data-target")||r&&r.replace(/.*(?=#[^\s]+$)/,"")),s=i.data("lightbox")?"toggle":e.extend({remote:!/#/.test(r)&&r},i.data(),n.data()),o=n.attr("data-image")||!1,u;t.preventDefault(),o&&(i.data("original-content",i.find(".lightbox-content").html()),i.find(".lightbox-content").html('<img border="0" src="'+o+'" />')),i.lightbox(s).one("hide",function(){n.focus()}).one("hidden",function(){o&&(i.find(".lightbox-content").html(i.data("original-content")),o=undefined)})})}(window.jQuery);
View
2  docs/assets/js/bootstrap-lightbox.min.js
@@ -18,4 +18,4 @@
* limitations under the License.
* ========================================================= */
-!function(e){"use strict";var t=function(t,n){this.options=n,this.$element=e(t).delegate('[data-dismiss="lightbox"]',"click.dismiss.lightbox",e.proxy(this.hide,this)),this.options.remote&&this.$element.find(".lightbox-body").load(this.options.remote),this.cloneSize()};t.prototype={constructor:t,toggle:function(){return this[this.isShown?"hide":"show"]()},show:function(){var t=this,n=e.Event("show");this.$element.trigger(n);if(this.isShown||n.isDefaultPrevented())return;this.isShown=!0,this.escape(),this.backdrop(function(){var n=e.support.transition&&t.$element.hasClass("fade");t.$element.parent().length||t.$element.appendTo(document.body),t.$element.show(),n&&t.$element[0].offsetWidth,t.$element.addClass("in").attr("aria-hidden",!1),t.enforceFocus(),n?t.$element.one(e.support.transition.end,function(){t.centerImage(),t.$element.focus().trigger("shown")}):function(){t.centerImage(),t.$element.focus().trigger("shown")}()})},hide:function(t){t&&t.preventDefault();var n=this;t=e.Event("hide"),this.$element.trigger(t);if(!this.isShown||t.isDefaultPrevented())return;this.isShown=!1,this.escape(),e(document).off("focusin.lightbox"),this.$element.removeClass("in").attr("aria-hidden",!0),e.support.transition&&this.$element.hasClass("fade")?this.hideWithTransition():this.hideLightbox()},enforceFocus:function(){var t=this;e(document).on("focusin.lightbox",function(e){t.$element[0]!==e.target&&!t.$element.has(e.target).length&&t.$element.focus()})},escape:function(){var e=this;this.isShown&&this.options.keyboard?this.$element.on("keyup.dismiss.lightbox",function(t){t.which==27&&e.hide()}):this.isShown||this.$element.off("keyup.dismiss.lightbox")},hideWithTransition:function(){var t=this,n=setTimeout(function(){t.$element.off(e.support.transition.end),t.hideLightbox()},500);this.$element.one(e.support.transition.end,function(){clearTimeout(n),t.hideLightbox()})},hideLightbox:function(e){this.$element.hide().trigger("hidden"),this.backdrop()},removeBackdrop:function(){this.$backdrop.remove(),this.$backdrop=null},backdrop:function(t){var n=this,r=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var i=e.support.transition&&r;this.$backdrop=e('<div class="modal-backdrop '+r+'" />').appendTo(document.body),this.$backdrop.click(this.options.backdrop=="static"?e.proxy(this.$element[0].focus,this.$element[0]):e.proxy(this.hide,this)),i&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),i?this.$backdrop.one(e.support.transition.end,t):t()}else!this.isShown&&this.$backdrop?(this.$backdrop.removeClass("in"),e.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one(e.support.transition.end,e.proxy(this.removeBackdrop,this)):this.removeBackdrop()):t&&t()},centerImage:function(){var t=this,n=0,r;t.h=t.$element.height(),t.w=t.$element.width();if(t.options.resizeToFit){n=10,r=t.$element.find(".lightbox-content").find("img:first"),r.data("osizew")||r.data("osizew",r.width()),r.data("osizeh")||r.data("osizeh",r.height());var i=r.data("osizew"),s=r.data("osizeh");r.css("max-width","none"),r.css("max-height","none");var o=40;t.$element.find(".lightbox-header").length>0&&(o+=10),r.css("max-width",e(window).width()-o),r.css("max-height",e(window).height()-o),t.w=r.width(),t.h=r.height()}t.$element.css({position:"fixed",left:e(window).width()/2-t.w/2,top:e(window).height()/2-t.h/2-n}),t.enforceFocus()},cloneSize:function(){var t=this;t.$clone=t.$element.filter(":first").clone().css({position:"absolute",top:-2e3,display:"block",visibility:"visible",opacity:100}).removeClass("fade").appendTo("body"),t.h=t.$clone.height(),t.w=t.$clone.width(),t.$clone.remove(),t.$element.css({position:"fixed",left:e(window).width()/2-t.w/2,top:e(window).height()/2-t.h/2})}},e.fn.lightbox=function(n){return this.each(function(){var r=e(this),i=r.data("lightbox"),s=e.extend({},e.fn.lightbox.defaults,r.data(),typeof n=="object"&&n);i||r.data("lightbox",i=new t(this,s)),typeof n=="string"?i[n]():s.show&&i.show()})},e.fn.lightbox.defaults={backdrop:!0,keyboard:!0,show:!0,resizeToFit:!0},e.fn.lightbox.Constructor=t,e(document).on("click.lightbox.data-api",'[data-toggle="lightbox"]',function(t){var n=e(this),r=n.attr("href"),i=e(n.attr("data-target")||r&&r.replace(/.*(?=#[^\s]+$)/,"")),s=i.data("lightbox")?"toggle":e.extend({remote:!/#/.test(r)&&r},i.data(),n.data()),o=n.attr("data-image")||!1,u;t.preventDefault(),o&&(i.data("original-content",i.find(".lightbox-content").html()),i.find(".lightbox-content").html('<img border="0" src="'+o+'" />')),i.lightbox(s).one("hide",function(){n.focus()}).one("hidden",function(){o&&(i.find(".lightbox-content").html(i.data("original-content")),o=undefined)})})}(window.jQuery);
+!function(e){"use strict";var t=function(t,n){this.options=n,this.$element=e(t).delegate('[data-dismiss="lightbox"]',"click.dismiss.lightbox",e.proxy(this.hide,this)),this.options.remote&&this.$element.find(".lightbox-body").load(this.options.remote),this.cloneSize()};t.prototype={constructor:t,toggle:function(){return this[this.isShown?"hide":"show"]()},show:function(){var t=this,n=e.Event("show");this.$element.trigger(n);if(this.isShown||n.isDefaultPrevented())return;this.isShown=!0,this.escape(),this.backdrop(function(){var n=e.support.transition&&t.$element.hasClass("fade");t.$element.parent().length||t.$element.appendTo(document.body),t.$element.show(),n&&t.$element[0].offsetWidth,t.$element.addClass("in").attr("aria-hidden",!1),t.enforceFocus(),n?t.$element.one(e.support.transition.end,function(){t.centerImage(),t.$element.focus().trigger("shown")}):function(){t.centerImage(),t.$element.focus().trigger("shown")}()})},hide:function(t){t&&t.preventDefault();var n=this;t=e.Event("hide"),this.$element.trigger(t);if(!this.isShown||t.isDefaultPrevented())return;this.isShown=!1,this.escape(),e(document).off("focusin.lightbox"),this.$element.removeClass("in").attr("aria-hidden",!0),e.support.transition&&this.$element.hasClass("fade")?this.hideWithTransition():this.hideLightbox()},enforceFocus:function(){var t=this;e(document).on("focusin.lightbox",function(e){t.$element[0]!==e.target&&!t.$element.has(e.target).length&&t.$element.focus()})},escape:function(){var e=this;this.isShown&&this.options.keyboard?this.$element.on("keypress.dismiss.lightbox, keyup.dismiss.lightbox",function(t){t.which==27&&e.hide()}):this.isShown||this.$element.off("keypress.dismiss.lightbox, keyup.dismiss.lightbox")},hideWithTransition:function(){var t=this,n=setTimeout(function(){t.$element.off(e.support.transition.end),t.hideLightbox()},500);this.$element.one(e.support.transition.end,function(){clearTimeout(n),t.hideLightbox()})},hideLightbox:function(e){this.$element.hide().trigger("hidden"),this.backdrop()},removeBackdrop:function(){this.$backdrop.remove(),this.$backdrop=null},backdrop:function(t){var n=this,r=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var i=e.support.transition&&r;this.$backdrop=e('<div class="modal-backdrop '+r+'" />').appendTo(document.body),this.$backdrop.click(this.options.backdrop=="static"?e.proxy(this.$element[0].focus,this.$element[0]):e.proxy(this.hide,this)),i&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),i?this.$backdrop.one(e.support.transition.end,t):t()}else!this.isShown&&this.$backdrop?(this.$backdrop.removeClass("in"),e.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one(e.support.transition.end,e.proxy(this.removeBackdrop,this)):this.removeBackdrop()):t&&t()},centerImage:function(){var t=this,n=0,r;t.h=t.$element.height(),t.w=t.$element.width();if(t.options.resizeToFit){n=10,r=t.$element.find(".lightbox-content").find("img:first"),r.data("osizew")||r.data("osizew",r.width()),r.data("osizeh")||r.data("osizeh",r.height());var i=r.data("osizew"),s=r.data("osizeh");r.css("max-width","none"),r.css("max-height","none");var o=40;t.$element.find(".lightbox-header").length>0&&(o+=10),r.css("max-width",e(window).width()-o),r.css("max-height",e(window).height()-o),t.w=r.width(),t.h=r.height()}t.$element.css({position:"fixed",left:e(window).width()/2-t.w/2,top:e(window).height()/2-t.h/2-n}),t.enforceFocus()},cloneSize:function(){var t=this;t.$clone=t.$element.filter(":first").clone().css({position:"absolute",top:-2e3,display:"block",visibility:"visible",opacity:100}).removeClass("fade").appendTo("body"),t.h=t.$clone.height(),t.w=t.$clone.width(),t.$clone.remove(),t.$element.css({position:"fixed",left:e(window).width()/2-t.w/2,top:e(window).height()/2-t.h/2})}},e.fn.lightbox=function(n){return this.each(function(){var r=e(this),i=r.data("lightbox"),s=e.extend({},e.fn.lightbox.defaults,r.data(),typeof n=="object"&&n);i||r.data("lightbox",i=new t(this,s)),typeof n=="string"?i[n]():s.show&&i.show()})},e.fn.lightbox.defaults={backdrop:!0,keyboard:!0,show:!0,resizeToFit:!0},e.fn.lightbox.Constructor=t,e(document).on("click.lightbox.data-api",'[data-toggle="lightbox"]',function(t){var n=e(this),r=n.attr("href"),i=e(n.attr("data-target")||r&&r.replace(/.*(?=#[^\s]+$)/,"")),s=i.data("lightbox")?"toggle":e.extend({remote:!/#/.test(r)&&r},i.data(),n.data()),o=n.attr("data-image")||!1,u;t.preventDefault(),o&&(i.data("original-content",i.find(".lightbox-content").html()),i.find(".lightbox-content").html('<img border="0" src="'+o+'" />')),i.lightbox(s).one("hide",function(){n.focus()}).one("hidden",function(){o&&(i.find(".lightbox-content").html(i.data("original-content")),o=undefined)})})}(window.jQuery);
View
4 js/bootstrap-lightbox.js
@@ -115,14 +115,14 @@
var that = this;
if (this.isShown && this.options.keyboard)
{
- this.$element.on('keyup.dismiss.lightbox', function ( e )
+ this.$element.on('keypress.dismiss.lightbox, keyup.dismiss.lightbox', function ( e )
{
e.which == 27 && that.hide();
});
}
else if (!this.isShown)
{
- this.$element.off('keyup.dismiss.lightbox');
+ this.$element.off('keypress.dismiss.lightbox, keyup.dismiss.lightbox');
}
},
hideWithTransition: function ()
Please sign in to comment.
Something went wrong with that request. Please try again.