From b2ca83bbe1a18734676c3026aeebf9362760719c Mon Sep 17 00:00:00 2001 From: Timo Kosse Date: Sun, 26 Mar 2017 13:59:31 +0200 Subject: [PATCH 01/14] Added better caption support --- css/jquery-fullsizable.css | 19 +++++++++++++- js/jquery-fullsizable.coffee | 21 ++++++++++++--- js/jquery-fullsizable.js | 51 ++++++++++++++++++++++++++---------- js/jquery-fullsizable.min.js | 2 +- 4 files changed, 74 insertions(+), 19 deletions(-) diff --git a/css/jquery-fullsizable.css b/css/jquery-fullsizable.css index 9ebf03f..d371f9c 100644 --- a/css/jquery-fullsizable.css +++ b/css/jquery-fullsizable.css @@ -13,7 +13,24 @@ background-position: 50% 50%; background-repeat: no-repeat; } +#fullsized_wrapper { + position: relative; + display: inline-block; + margin-left: 50%; +} +#fullsized_holder { + margin-left: -50%; +} #jquery-fullsizable #fullsized_image_holder img { display: block; - margin: 0 auto; +} +#fullsized_caption_holder { + width: 100%; + position: absolute; + bottom: 0; + padding: 5px 15px; + box-sizing: border-box; + color: #eeeeee; + background: #444; /*Fallback for IE8*/ + background: rgba(0,0,0,0.5); } diff --git a/js/jquery-fullsizable.coffee b/js/jquery-fullsizable.coffee index 3a00d40..670a747 100644 --- a/js/jquery-fullsizable.coffee +++ b/js/jquery-fullsizable.coffee @@ -17,6 +17,7 @@ Options: **preload** (optional, defaults to true) - lookup selector on initialization, set only to false in combination with ``reloadOnOpen: true`` or ``fullsizable:reload`` event. **reloadOnOpen** (optional, defaults to false) - lookup selector every time the viewer opens. **loop** (optional, defaults to false) - don't hide prev/next button on first/last image, so images are looped + **caption** (optional, defaults to false) - displays a caption at the bottom of the image. Caption can be set using ``title`` and ``alt`` attributes of the thumbnail. ### $ = jQuery @@ -24,7 +25,8 @@ $ = jQuery container_id = '#jquery-fullsizable' image_holder_id = '#fullsized_image_holder' spinner_class = 'fullsized_spinner' -$image_holder = $('
') +$image_holder = $('
') +$caption_holder = $('
') images = [] current_image = 0 @@ -69,6 +71,7 @@ showImage = (image, direction = 1, shouldHideChrome = false) -> current_image = image.index $(image_holder_id).hide() $(image_holder_id).html(image) + $caption_holder.html(image.caption) if options.caption && image.caption # show/hide navigation when hitting range limits if options.navigation @@ -136,12 +139,18 @@ makeFullsizable = -> $(options.selector).each -> image = new Image - image.buffer_src = $(this).attr('href') + $this = $(this) + $imageElement = $this.children('img:first'); + image.buffer_src = $this.attr('href') image.index = images.length + if options.caption + image.caption = ''; + image.caption += ('' + $imageElement.attr('title') + '
') if !!$imageElement.attr('title') + image.caption += $imageElement.attr('alt') if !!$imageElement.attr('alt') images.push image if options.openOnClick - $(this).click (e) -> + $this.click (e) -> e.preventDefault() makeFullsizable() if options.reloadOnOpen openViewer(image, this) @@ -172,6 +181,9 @@ prepareCurtain = -> e.stopPropagation() toggleFullscreen() + if options.caption + $image_holder.find('#fullsized_holder').append($caption_holder) + switch options.clickBehaviour when 'close' then $(document).on 'click', container_id, closeViewer when 'next' then $(document).on 'click', container_id, -> nextImage(true) @@ -190,6 +202,7 @@ unbindCurtainEvents = -> $(document).unbind 'fullsizable:close' hideChrome = -> + $caption_holder.toggle(false); $chrome = $image_holder.find('a') if $chrome.is(':visible') == true $chrome.toggle(false) @@ -205,6 +218,7 @@ mouseMovement = (event) -> showChrome() showChrome = -> + $caption_holder.toggle(true); $('#fullsized_close, #fullsized_fullscreen').toggle(true) if options.loop $('#fullsized_go_prev').show() @@ -225,6 +239,7 @@ $.fn.fullsizable = (opts) -> preload: true reloadOnOpen: false loop: false + caption : false , opts || {} prepareCurtain() diff --git a/js/jquery-fullsizable.js b/js/jquery-fullsizable.js index f45f5dc..077736f 100644 --- a/js/jquery-fullsizable.js +++ b/js/jquery-fullsizable.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.12.4 /* jQuery fullsizable plugin v2.1.0 @@ -19,10 +19,11 @@ Options: **preload** (optional, defaults to true) - lookup selector on initialization, set only to false in combination with ``reloadOnOpen: true`` or ``fullsizable:reload`` event. **reloadOnOpen** (optional, defaults to false) - lookup selector every time the viewer opens. **loop** (optional, defaults to false) - don't hide prev/next button on first/last image, so images are looped + **caption** (optional, defaults to false) - displays a caption at the bottom of the image. Caption can be set using ``title`` and ``alt`` attributes of the thumbnail. */ (function() { - var $, $image_holder, bindCurtainEvents, closeFullscreen, closeViewer, container_id, current_image, hasFullscreenSupport, hideChrome, image_holder_id, images, keyPressed, makeFullsizable, mouseMovement, mouseStart, nextImage, openViewer, options, preloadImage, prepareCurtain, prevImage, resizeImage, showChrome, showImage, spinner_class, stored_scroll_position, toggleFullscreen, unbindCurtainEvents; + var $, $caption_holder, $image_holder, bindCurtainEvents, closeFullscreen, closeViewer, container_id, current_image, hasFullscreenSupport, hideChrome, image_holder_id, images, keyPressed, makeFullsizable, mouseMovement, mouseStart, nextImage, openViewer, options, preloadImage, prepareCurtain, prevImage, resizeImage, showChrome, showImage, spinner_class, stored_scroll_position, toggleFullscreen, unbindCurtainEvents; $ = jQuery; @@ -32,7 +33,9 @@ Options: spinner_class = 'fullsized_spinner'; - $image_holder = $('
'); + $image_holder = $('
'); + + $caption_holder = $('
'); images = []; @@ -103,6 +106,9 @@ Options: current_image = image.index; $(image_holder_id).hide(); $(image_holder_id).html(image); + if (options.caption && image.caption) { + $caption_holder.html(image.caption); + } if (options.navigation) { if (shouldHideChrome === true) { hideChrome(); @@ -178,13 +184,24 @@ Options: makeFullsizable = function() { images.length = 0; return $(options.selector).each(function() { - var image; + var $imageElement, $this, image; image = new Image; - image.buffer_src = $(this).attr('href'); + $this = $(this); + $imageElement = $this.children('img:first'); + image.buffer_src = $this.attr('href'); image.index = images.length; + if (options.caption) { + image.caption = ''; + if (!!$imageElement.attr('title')) { + image.caption += '' + $imageElement.attr('title') + '
'; + } + if (!!$imageElement.attr('alt')) { + image.caption += $imageElement.attr('alt'); + } + } images.push(image); if (options.openOnClick) { - return $(this).click(function(e) { + return $this.click(function(e) { e.preventDefault(); if (options.reloadOnOpen) { makeFullsizable(); @@ -225,6 +242,9 @@ Options: return toggleFullscreen(); }); } + if (options.caption) { + $image_holder.find('#fullsized_holder').append($caption_holder); + } switch (options.clickBehaviour) { case 'close': return $(document).on('click', container_id, closeViewer); @@ -257,6 +277,7 @@ Options: hideChrome = function() { var $chrome; + $caption_holder.toggle(false); $chrome = $image_holder.find('a'); if ($chrome.is(':visible') === true) { $chrome.toggle(false); @@ -280,6 +301,7 @@ Options: }; showChrome = function() { + $caption_holder.toggle(true); $('#fullsized_close, #fullsized_fullscreen').toggle(true); if (options.loop) { $('#fullsized_go_prev').show(); @@ -301,7 +323,8 @@ Options: clickBehaviour: 'close', preload: true, reloadOnOpen: false, - loop: false + loop: false, + caption: false }, opts || {}); prepareCurtain(); if (options.preload) { @@ -309,20 +332,20 @@ Options: } $(document).bind('fullsizable:reload', makeFullsizable); $(document).bind('fullsizable:open', function(e, target) { - var image, _i, _len, _results; + var i, image, len, results; if (options.reloadOnOpen) { makeFullsizable(); } - _results = []; - for (_i = 0, _len = images.length; _i < _len; _i++) { - image = images[_i]; + results = []; + for (i = 0, len = images.length; i < len; i++) { + image = images[i]; if (image.buffer_src === $(target).attr('href')) { - _results.push(openViewer(image, target)); + results.push(openViewer(image, target)); } else { - _results.push(void 0); + results.push(void 0); } } - return _results; + return results; }); return this; }; diff --git a/js/jquery-fullsizable.min.js b/js/jquery-fullsizable.min.js index a56ce4b..49f2989 100644 --- a/js/jquery-fullsizable.min.js +++ b/js/jquery-fullsizable.min.js @@ -2,4 +2,4 @@ jQuery fullsizable plugin v2.1.0 (c) 2011-2015 Matthias Schmidt */ -(function(){var e,n,l,t,u,o,i,r,c,d,s,a,f,h,p,g,v,m,w,b,z,_,k,F,S,x,q,y;e=jQuery,o="#jquery-fullsizable",d="#fullsized_image_holder",S="fullsized_spinner",n=e('
'),s=[],i=0,m=null,x=null,_=function(){var n;return n=s[i],null==n.ratio&&(n.ratio=(n.naturalHeight/n.naturalWidth).toFixed(2)),e(window).height()/n.ratio>e(window).width()?(e(n).width(e(window).width()),e(n).height(e(window).width()*n.ratio),e(n).css("margin-top",(e(window).height()-e(n).height())/2)):(e(n).height(e(window).height()),e(n).width(e(window).height()/n.ratio),e(n).css("margin-top",0))},a=function(e){return 27===e.keyCode&&u(),37===e.keyCode&&z(!0),39===e.keyCode?g(!0):void 0},z=function(e){return null==e&&(e=!1),i>0?F(s[i-1],-1,e):m.loop?F(s[s.length-1],-1,e):void 0},g=function(e){return null==e&&(e=!1),i0))return;n=s[i-1]}return n.onload=function(){return this.loaded=!0},""===n.src?n.src=n.buffer_src:void 0},v=function(t,u){return e("body").append(n),e(window).bind("resize",_),F(t),e(o).hide().fadeIn(function(){return null!=m.detach_id&&(x=e(window).scrollTop(),e("#"+m.detach_id).css("display","none"),_()),l(),e(document).trigger("fullsizable:opened",u)})},u=function(){return null!=m.detach_id&&(e("#"+m.detach_id).css("display","block"),e(window).scrollTop(x)),e(o).fadeOut(function(){return n.remove()}),t(),e(o).removeClass(S),y(),e(window).unbind("resize",_)},f=function(){return s.length=0,e(m.selector).each(function(){var n;return n=new Image,n.buffer_src=e(this).attr("href"),n.index=s.length,s.push(n),m.openOnClick?e(this).click(function(e){return e.preventDefault(),m.reloadOnOpen&&f(),v(n,this)}):void 0})},b=function(){switch(m.navigation&&(n.append(''),e(document).on("click","#fullsized_go_prev",function(e){return e.preventDefault(),e.stopPropagation(),z()}),e(document).on("click","#fullsized_go_next",function(e){return e.preventDefault(),e.stopPropagation(),g()})),m.closeButton&&(n.append(''),e(document).on("click","#fullsized_close",function(e){return e.preventDefault(),e.stopPropagation(),u()})),m.fullscreenButton&&r()&&(n.append(''),e(document).on("click","#fullsized_fullscreen",function(e){return e.preventDefault(),e.stopPropagation(),q()})),m.clickBehaviour){case"close":return e(document).on("click",o,u);case"next":return e(document).on("click",o,function(){return g(!0)});default:return e(document).on("click",o,m.clickBehaviour)}},l=function(){return e(document).bind("keydown",a),e(document).bind("fullsizable:next",function(){return g(!0)}),e(document).bind("fullsizable:prev",function(){return z(!0)}),e(document).bind("fullsizable:close",u)},y=function(){return e(document).unbind("keydown",a),e(document).unbind("fullsizable:next"),e(document).unbind("fullsizable:prev"),e(document).unbind("fullsizable:close")},c=function(){var e;return e=n.find("a"),e.is(":visible")===!0?(e.toggle(!1),n.bind("mousemove",h)):void 0},p=null,h=function(e){var l;return null===p&&(p=[e.clientX,e.clientY]),l=Math.round(Math.sqrt(Math.pow(p[1]-e.clientY,2)+Math.pow(p[0]-e.clientX,2))),l>=10?(n.unbind("mousemove",h),p=null,k()):void 0},k=function(){return e("#fullsized_close, #fullsized_fullscreen").toggle(!0),m.loop?(e("#fullsized_go_prev").show(),e("#fullsized_go_next").show()):(e("#fullsized_go_prev").toggle(0!==i),e("#fullsized_go_next").toggle(i!==s.length-1))},e.fn.fullsizable=function(n){return m=e.extend({selector:this.selector,detach_id:null,navigation:!0,closeButton:!0,fullscreenButton:!0,openOnClick:!0,clickBehaviour:"close",preload:!0,reloadOnOpen:!1,loop:!1},n||{}),b(),m.preload&&f(),e(document).bind("fullsizable:reload",f),e(document).bind("fullsizable:open",function(n,l){var t,u,o,i;for(m.reloadOnOpen&&f(),i=[],u=0,o=s.length;o>u;u++)t=s[u],i.push(t.buffer_src===e(l).attr("href")?v(t,l):void 0);return i}),this},r=function(){var e;return e=n.get(0),e.requestFullScreen||e.webkitRequestFullScreen||e.mozRequestFullScreen?!0:!1},t=function(){return q(!0)},q=function(e){var l;return l=n.get(0),l.requestFullScreen?document.fullScreen||e?document.exitFullScreen():l.requestFullScreen():l.webkitRequestFullScreen?document.webkitIsFullScreen||e?document.webkitCancelFullScreen():l.webkitRequestFullScreen():l.mozRequestFullScreen?document.mozFullScreen||e?document.mozCancelFullScreen():l.mozRequestFullScreen():void 0}}).call(this); +(function(){var b,m,f,A,B,n,c,C,D,d,t,p,u,k,q,v,e,w,E,r,h,x,l,y,z,F;b=jQuery;f=b('
');m=b('
');d=[];c=0;y=e=null;h=function(){var a;a=d[c];null==a.ratio&&(a.ratio=(a.naturalHeight/a.naturalWidth).toFixed(2));if(b(window).height()/a.ratio>b(window).width())return b(a).width(b(window).width()),b(a).height(b(window).width()*a.ratio),b(a).css("margin-top",(b(window).height()-b(a).height())/2);b(a).height(b(window).height());b(a).width(b(window).height()/a.ratio);return b(a).css("margin-top",0)};t=function(a){27===a.keyCode&&n();37===a.keyCode&&r(!0);if(39===a.keyCode)return q(!0)};r=function(a){null==a&&(a=!1);if(0"+a.attr("title")+"
"),a.attr("alt")&&(c.caption+=a.attr("alt")));d.push(c);if(e.openOnClick)return g.click(function(a){a.preventDefault();e.reloadOnOpen&&p();return v(c,this)})})};E=function(){e.navigation&&(f.append(''),b(document).on("click","#fullsized_go_prev",function(a){a.preventDefault();a.stopPropagation();return r()}),b(document).on("click","#fullsized_go_next",function(a){a.preventDefault();a.stopPropagation();return q()}));e.closeButton&&(f.append(''),b(document).on("click","#fullsized_close",function(a){a.preventDefault();a.stopPropagation();return n()}));e.fullscreenButton&&C()&&(f.append(''),b(document).on("click","#fullsized_fullscreen",function(a){a.preventDefault();a.stopPropagation();return z()}));e.caption&&f.find("#fullsized_holder").append(m);switch(e.clickBehaviour){case "close":return b(document).on("click","#jquery-fullsizable",n);case "next":return b(document).on("click","#jquery-fullsizable",function(){return q(!0)});default:return b(document).on("click","#jquery-fullsizable",e.clickBehaviour)}};A=function(){b(document).bind("keydown",t);b(document).bind("fullsizable:next",function(){return q(!0)});b(document).bind("fullsizable:prev",function(){return r(!0)});return b(document).bind("fullsizable:close",n)};F=function(){b(document).unbind("keydown",t);b(document).unbind("fullsizable:next");b(document).unbind("fullsizable:prev");return b(document).unbind("fullsizable:close")};D=function(){var a;m.toggle(!1);a=f.find("a");if(!0===a.is(":visible"))return a.toggle(!1),f.bind("mousemove",u)};k=null;u=function(a){null===k&&(k=[a.clientX,a.clientY]);if(10<=Math.round(Math.sqrt(Math.pow(k[1]-a.clientY,2)+Math.pow(k[0]-a.clientX,2))))return f.unbind("mousemove",u),k=null,x()};x=function(){m.toggle(!0);b("#fullsized_close, #fullsized_fullscreen").toggle(!0);if(e.loop)return b("#fullsized_go_prev").show(),b("#fullsized_go_next").show();b("#fullsized_go_prev").toggle(0!==c);return b("#fullsized_go_next").toggle(c!==d.length-1)};b.fn.fullsizable=function(a){e=b.extend({selector:this.selector,detach_id:null,navigation:!0,closeButton:!0,fullscreenButton:!0,openOnClick:!0,clickBehaviour:"close",preload:!0,reloadOnOpen:!1,loop:!1,caption:!1},a||{});E();e.preload&&p();b(document).bind("fullsizable:reload",p);b(document).bind("fullsizable:open",function(a,c){var g,f,k,h;e.reloadOnOpen&&p();h=[];g=0;for(k=d.length;g Date: Sun, 26 Mar 2017 14:47:39 +0200 Subject: [PATCH 02/14] Using 'button' tag for navigation elements instead of 'a' tag because browser displays an overlay for links that flow over the image and caption. --- css/jquery-fullsizable-theme.css | 5 +++++ examples/simple.html | 2 +- examples/themed_with_touch.html | 10 +++++----- js/jquery-fullsizable.coffee | 8 ++++---- js/jquery-fullsizable.js | 8 ++++---- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/css/jquery-fullsizable-theme.css b/css/jquery-fullsizable-theme.css index 7c9ba10..fb19b97 100644 --- a/css/jquery-fullsizable-theme.css +++ b/css/jquery-fullsizable-theme.css @@ -1,3 +1,8 @@ +#fullsized_go_prev, #fullsized_go_next, #fullsized_close, #fullsized_fullscreen { + border: none; + padding: 0; + cursor: pointer; +} #fullsized_go_prev, #fullsized_go_next { position: absolute; top: 40%; diff --git a/examples/simple.html b/examples/simple.html index b978560..194b43b 100644 --- a/examples/simple.html +++ b/examples/simple.html @@ -45,7 +45,7 @@ $(function() { $('a').fullsizable({ detach_id: 'container', - clickBehaviour: 'next' + clickBehaviour: 'next', }); }); diff --git a/examples/themed_with_touch.html b/examples/themed_with_touch.html index 2d57118..2847e5f 100644 --- a/examples/themed_with_touch.html +++ b/examples/themed_with_touch.html @@ -18,7 +18,8 @@ diff --git a/js/jquery-fullsizable.coffee b/js/jquery-fullsizable.coffee index e85febc..a2fe222 100644 --- a/js/jquery-fullsizable.coffee +++ b/js/jquery-fullsizable.coffee @@ -30,7 +30,7 @@ close_id = '#fullsized_close' fullscreen_id = '#fullsized_fullscreen' spinner_class = 'fullsized_spinner' $image_holder = $('
') -$caption_holder = $('
') +$caption_holder = $('
') images = [] current_image = 0 @@ -188,7 +188,7 @@ prepareCurtain = -> e.stopPropagation() toggleFullscreen() - if options.caption + if options.caption and $image_holder.find(fullscreen_id).length == 0 $image_holder.find('#fullsized_holder').append($caption_holder) switch options.clickBehaviour From f1ba4eee8109b47c832cfa68f3e2d1f3a69b7caf Mon Sep 17 00:00:00 2001 From: Timo Kosse Date: Sun, 26 Mar 2017 19:22:07 +0200 Subject: [PATCH 07/14] c&p fault --- js/jquery-fullsizable.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/jquery-fullsizable.coffee b/js/jquery-fullsizable.coffee index a2fe222..d58ab67 100644 --- a/js/jquery-fullsizable.coffee +++ b/js/jquery-fullsizable.coffee @@ -188,7 +188,7 @@ prepareCurtain = -> e.stopPropagation() toggleFullscreen() - if options.caption and $image_holder.find(fullscreen_id).length == 0 + if options.caption $image_holder.find('#fullsized_holder').append($caption_holder) switch options.clickBehaviour From 108ddc1f418c288a36a266f206fb705b0d69ae94 Mon Sep 17 00:00:00 2001 From: Timo Kosse Date: Sun, 26 Mar 2017 19:34:00 +0200 Subject: [PATCH 08/14] Use selected elements in instantiation instead of re-selecting them --- js/jquery-fullsizable.coffee | 4 ++-- js/jquery-fullsizable.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/js/jquery-fullsizable.coffee b/js/jquery-fullsizable.coffee index d58ab67..f9955d4 100644 --- a/js/jquery-fullsizable.coffee +++ b/js/jquery-fullsizable.coffee @@ -144,7 +144,7 @@ closeViewer = -> makeFullsizable = -> images.length = 0 - $(options.selector).each -> + options.fullsizableObject.each -> image = new Image $this = $(this) $imageElement = $this.children('img:first'); @@ -238,7 +238,7 @@ showChrome = -> $.fn.fullsizable = (opts) -> options = $.extend - selector: this.selector + fullsizableObject: this detach_id: null navigation: true closeButton: true diff --git a/js/jquery-fullsizable.js b/js/jquery-fullsizable.js index f554651..2f67924 100644 --- a/js/jquery-fullsizable.js +++ b/js/jquery-fullsizable.js @@ -202,7 +202,7 @@ Options: makeFullsizable = function() { images.length = 0; - return $(options.selector).each(function() { + return options.fullsizableElements.each(function() { var $imageElement, $this, image; image = new Image; $this = $(this); @@ -337,7 +337,7 @@ Options: $.fn.fullsizable = function(opts) { options = $.extend({ - selector: this.selector, + fullsizableElements: this, detach_id: null, navigation: true, closeButton: true, From bce89d9ea82c53c41ea604b26e3be96e618fdf03 Mon Sep 17 00:00:00 2001 From: Timo Kosse Date: Sun, 26 Mar 2017 20:17:48 +0200 Subject: [PATCH 09/14] Edited js file accidentally --- js/jquery-fullsizable.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/jquery-fullsizable.coffee b/js/jquery-fullsizable.coffee index f9955d4..a871488 100644 --- a/js/jquery-fullsizable.coffee +++ b/js/jquery-fullsizable.coffee @@ -144,7 +144,7 @@ closeViewer = -> makeFullsizable = -> images.length = 0 - options.fullsizableObject.each -> + options.fullsizableElements.each -> image = new Image $this = $(this) $imageElement = $this.children('img:first'); @@ -238,7 +238,7 @@ showChrome = -> $.fn.fullsizable = (opts) -> options = $.extend - fullsizableObject: this + fullsizableElements: this detach_id: null navigation: true closeButton: true From 8895ab0189dd677ca7c7ec2c9ac55721a6109ca5 Mon Sep 17 00:00:00 2001 From: Timo Kosse Date: Sun, 26 Mar 2017 20:26:02 +0200 Subject: [PATCH 10/14] Updated version to 2.2.0 and readme file --- README.md | 5 +++++ bower.json | 2 +- fullsizable.jquery.json | 2 +- js/jquery-fullsizable.coffee | 2 +- js/jquery-fullsizable.js | 2 +- js/jquery-fullsizable.min.js | 4 ++-- 6 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 16a61a2..79d7f18 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,8 @@ Style with ``#fullsized_fullscreen`` **loop** (optional, defaults to false) - don't hide prev/next button on first/last image, so images are looped +**caption** (optional, defaults to false) - displays a caption at the bottom of the image. Caption can be set using ``title`` and ``alt`` attributes of the thumbnail. + ## Styling The packaged ``fullsizable.css`` stylesheet provides only the bare bones to make fullsizable work. Everything @@ -161,6 +163,9 @@ Triggers: ``fullsizable:open``, ``fullsizable:close``, ``fullsizable:next``, ``f ## Changelog +* **2.2.0** - 26.03.2017 + * added caption support + * **2.1.0** - 25.06.2015 * allow custom function for ``clickBehaviour`` option (thanks to MatoTominac) * add ``loop`` option (thanks to pohlaniacz) diff --git a/bower.json b/bower.json index 79c2510..b46cbab 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery-fullsizable", - "version": "2.1.0", + "version": "2.2.0", "homepage": "http://mschmidt.github.io/jquery-fullsizable/", "authors": [ "Matthias Schmidt (http://pixelflush.com)" diff --git a/fullsizable.jquery.json b/fullsizable.jquery.json index bc2d7db..9b634fd 100644 --- a/fullsizable.jquery.json +++ b/fullsizable.jquery.json @@ -1,6 +1,6 @@ { "name": "fullsizable", - "version": "2.1.0", + "version": "2.2.0", "title": "jQuery fullsizable", "author": { "name": "Matthias Schmidt", diff --git a/js/jquery-fullsizable.coffee b/js/jquery-fullsizable.coffee index a871488..7a07bfc 100644 --- a/js/jquery-fullsizable.coffee +++ b/js/jquery-fullsizable.coffee @@ -1,5 +1,5 @@ ### -jQuery fullsizable plugin v2.1.0 +jQuery fullsizable plugin v2.2.0 - take full available browser space to show images (c) 2011-2015 Matthias Schmidt diff --git a/js/jquery-fullsizable.js b/js/jquery-fullsizable.js index 2f67924..43c2bdb 100644 --- a/js/jquery-fullsizable.js +++ b/js/jquery-fullsizable.js @@ -1,7 +1,7 @@ // Generated by CoffeeScript 1.12.4 /* -jQuery fullsizable plugin v2.1.0 +jQuery fullsizable plugin v2.2.0 - take full available browser space to show images (c) 2011-2015 Matthias Schmidt diff --git a/js/jquery-fullsizable.min.js b/js/jquery-fullsizable.min.js index f447f3f..ffe7e9f 100644 --- a/js/jquery-fullsizable.min.js +++ b/js/jquery-fullsizable.min.js @@ -1,5 +1,5 @@ /* -jQuery fullsizable plugin v2.1.0 +jQuery fullsizable plugin v2.2.0 (c) 2011-2015 Matthias Schmidt */ -(function(){var b,k,c,A,B,n,f,C,D,e,t,p,u,h,q,v,d,w,E,r,l,x,m,y,z,F;b=jQuery;c=b('
');k=b('
');e=[];f=0;y=d=null;l=function(){var a;a=e[f];null==a.ratio&&(a.ratio=(a.naturalHeight/a.naturalWidth).toFixed(2));if(b(window).height()/a.ratio>b(window).width())return b(a).width(b(window).width()),b(a).height(b(window).width()*a.ratio),b(a).css("margin-top",(b(window).height()-b(a).height())/2);b(a).height(b(window).height());b(a).width(b(window).height()/a.ratio);return b(a).css("margin-top",0)};t=function(a){27===a.keyCode&&n();if(d.navigation&&(37===a.keyCode&&r(!0),39===a.keyCode))return q(!0)};r=function(a){null==a&&(a=!1);if(0"+a.attr("title")+"
"),a.attr("alt")&&(c.caption+=a.attr("alt")));e.push(c);if(d.openOnClick)return g.unbind("click").click(function(a){a.preventDefault();d.reloadOnOpen&&p();return v(c,this)})})};E=function(){d.navigation&&0===c.find("#fullsized_go_prev").length&&(c.append(''),b(document).on("click","#fullsized_go_prev",function(a){a.preventDefault();a.stopPropagation();return r()}),b(document).on("click","#fullsized_go_next",function(a){a.preventDefault();a.stopPropagation();return q()}));d.closeButton&&0===c.find("#fullsized_close").length&&(c.append(''),b(document).on("click","#fullsized_close",function(a){a.preventDefault();a.stopPropagation();return n()}));d.fullscreenButton&&C()&&0===c.find("#fullsized_fullscreen").length&&(c.append(''),b(document).on("click","#fullsized_fullscreen",function(a){a.preventDefault();a.stopPropagation();return z()}));d.caption&&c.find("#fullsized_holder").append(k);switch(d.clickBehaviour){case "close":return b(document).on("click","#jquery-fullsizable",n);case "next":return b(document).on("click","#jquery-fullsizable",function(){return q(!0)});default:return b(document).on("click","#jquery-fullsizable",d.clickBehaviour)}};A=function(){b(document).bind("keydown",t);d.navigation&&(b(document).bind("fullsizable:next",function(){return q(!0)}),b(document).bind("fullsizable:prev",function(){return r(!0)}));return b(document).bind("fullsizable:close",n)};F=function(){b(document).unbind("keydown",t);d.navigation&&(b(document).unbind("fullsizable:next"),b(document).unbind("fullsizable:prev"));return b(document).unbind("fullsizable:close")};D=function(){var a;k.toggle(!1);a=c.find("button");if(!0===a.is(":visible"))return a.toggle(!1),c.bind("mousemove",u)};h=null;u=function(a){null===h&&(h=[a.clientX,a.clientY]);if(10<=Math.round(Math.sqrt(Math.pow(h[1]-a.clientY,2)+Math.pow(h[0]-a.clientX,2))))return c.unbind("mousemove",u),h=null,x()};x=function(){k.toggle(!0);b("#fullsized_close,#fullsized_fullscreen").toggle(!0);if(d.loop)return b("#fullsized_go_prev").show(),b("#fullsized_go_next").show();b("#fullsized_go_prev").toggle(0!==f);return b("#fullsized_go_next").toggle(f!==e.length-1)};b.fn.fullsizable=function(a){d=b.extend({selector:this.selector,detach_id:null,navigation:!0,closeButton:!0,fullscreenButton:!0,openOnClick:!0,clickBehaviour:"close",preload:!0,reloadOnOpen:!1,loop:!1,caption:!1},a||{});E();d.preload&&p();b(document).bind("fullsizable:reload",p);b(document).bind("fullsizable:open",function(a,c){var g,f,k,h;d.reloadOnOpen&&p();h=[];g=0;for(k=e.length;g
');k=b('
');e=[];f=0;y=d=null;l=function(){var a;a=e[f];null==a.ratio&&(a.ratio=(a.naturalHeight/a.naturalWidth).toFixed(2));if(b(window).height()/a.ratio>b(window).width())return b(a).width(b(window).width()),b(a).height(b(window).width()*a.ratio),b(a).css("margin-top",(b(window).height()-b(a).height())/2);b(a).height(b(window).height());b(a).width(b(window).height()/a.ratio);return b(a).css("margin-top",0)};t=function(a){27===a.keyCode&&n();if(d.navigation&&(37===a.keyCode&&r(!0),39===a.keyCode))return q(!0)};r=function(a){null==a&&(a=!1);if(0"+a.attr("title")+"
"),a.attr("alt")&&(c.caption+=a.attr("alt")));e.push(c);if(d.openOnClick)return g.unbind("click").click(function(a){a.preventDefault();d.reloadOnOpen&&p();return v(c,this)})})};E=function(){d.navigation&&0===c.find("#fullsized_go_prev").length&&(c.append(''),b(document).on("click","#fullsized_go_prev",function(a){a.preventDefault();a.stopPropagation();return r()}),b(document).on("click","#fullsized_go_next",function(a){a.preventDefault();a.stopPropagation();return q()}));d.closeButton&&0===c.find("#fullsized_close").length&&(c.append(''),b(document).on("click","#fullsized_close",function(a){a.preventDefault();a.stopPropagation();return n()}));d.fullscreenButton&&C()&&0===c.find("#fullsized_fullscreen").length&&(c.append(''),b(document).on("click","#fullsized_fullscreen",function(a){a.preventDefault();a.stopPropagation();return z()}));d.caption&&c.find("#fullsized_holder").append(k);switch(d.clickBehaviour){case "close":return b(document).on("click","#jquery-fullsizable",n);case "next":return b(document).on("click","#jquery-fullsizable",function(){return q(!0)});default:return b(document).on("click","#jquery-fullsizable",d.clickBehaviour)}};A=function(){b(document).bind("keydown",t);d.navigation&&(b(document).bind("fullsizable:next",function(){return q(!0)}),b(document).bind("fullsizable:prev",function(){return r(!0)}));return b(document).bind("fullsizable:close",n)};F=function(){b(document).unbind("keydown",t);d.navigation&&(b(document).unbind("fullsizable:next"),b(document).unbind("fullsizable:prev"));return b(document).unbind("fullsizable:close")};D=function(){var a;k.toggle(!1);a=c.find("button");if(!0===a.is(":visible"))return a.toggle(!1),c.bind("mousemove",u)};h=null;u=function(a){null===h&&(h=[a.clientX,a.clientY]);if(10<=Math.round(Math.sqrt(Math.pow(h[1]-a.clientY,2)+Math.pow(h[0]-a.clientX,2))))return c.unbind("mousemove",u),h=null,x()};x=function(){k.toggle(!0);b("#fullsized_close,#fullsized_fullscreen").toggle(!0);if(d.loop)return b("#fullsized_go_prev").show(),b("#fullsized_go_next").show();b("#fullsized_go_prev").toggle(0!==f);return b("#fullsized_go_next").toggle(f!==e.length-1)};b.fn.fullsizable=function(a){d=b.extend({fullsizableElements:this,detach_id:null,navigation:!0,closeButton:!0,fullscreenButton:!0,openOnClick:!0,clickBehaviour:"close",preload:!0,reloadOnOpen:!1,loop:!1,caption:!1},a||{});E();d.preload&&p();b(document).bind("fullsizable:reload",p);b(document).bind("fullsizable:open",function(a,c){var g,f,k,h;d.reloadOnOpen&&p();h=[];g=0;for(k=e.length;g Date: Fri, 8 Sep 2017 22:19:49 +0200 Subject: [PATCH 11/14] Reset max-width attribute for images as this can causes wrong width and position calculation --- css/jquery-fullsizable.css | 1 + 1 file changed, 1 insertion(+) diff --git a/css/jquery-fullsizable.css b/css/jquery-fullsizable.css index ac531dc..13d99be 100644 --- a/css/jquery-fullsizable.css +++ b/css/jquery-fullsizable.css @@ -23,6 +23,7 @@ } #jquery-fullsizable #fullsized_image_holder img { display: block; + max-width: none; } #fullsized_caption_holder { width: 100%; From 4de8eef84e2963fa2e53acba6330b1631ff2db98 Mon Sep 17 00:00:00 2001 From: Timo Kosse Date: Fri, 8 Sep 2017 23:11:53 +0200 Subject: [PATCH 12/14] Hide also cursor on key navigation --- js/jquery-fullsizable.coffee | 6 ++++-- js/jquery-fullsizable.js | 2 ++ js/jquery-fullsizable.min.js | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/js/jquery-fullsizable.coffee b/js/jquery-fullsizable.coffee index 7a07bfc..2deb079 100644 --- a/js/jquery-fullsizable.coffee +++ b/js/jquery-fullsizable.coffee @@ -211,10 +211,11 @@ unbindCurtainEvents = -> $(document).unbind 'fullsizable:close' hideChrome = -> - $caption_holder.toggle(false); + $caption_holder.toggle(false) $chrome = $image_holder.find('button') if $chrome.is(':visible') == true $chrome.toggle(false) + $image_holder.css('cursor', 'none') $image_holder.bind 'mousemove', mouseMovement mouseStart = null @@ -227,8 +228,9 @@ mouseMovement = (event) -> showChrome() showChrome = -> - $caption_holder.toggle(true); + $caption_holder.toggle(true) $(close_id+','+fullscreen_id).toggle(true) + $image_holder.css('cursor', 'auto') if options.loop $(prev_id).show() $(next_id).show() diff --git a/js/jquery-fullsizable.js b/js/jquery-fullsizable.js index 43c2bdb..f3296aa 100644 --- a/js/jquery-fullsizable.js +++ b/js/jquery-fullsizable.js @@ -304,6 +304,7 @@ Options: $chrome = $image_holder.find('button'); if ($chrome.is(':visible') === true) { $chrome.toggle(false); + $image_holder.css('cursor', 'none'); return $image_holder.bind('mousemove', mouseMovement); } }; @@ -326,6 +327,7 @@ Options: showChrome = function() { $caption_holder.toggle(true); $(close_id + ',' + fullscreen_id).toggle(true); + $image_holder.css('cursor', 'auto'); if (options.loop) { $(prev_id).show(); return $(next_id).show(); diff --git a/js/jquery-fullsizable.min.js b/js/jquery-fullsizable.min.js index ffe7e9f..1c764a4 100644 --- a/js/jquery-fullsizable.min.js +++ b/js/jquery-fullsizable.min.js @@ -2,4 +2,4 @@ jQuery fullsizable plugin v2.2.0 (c) 2011-2015 Matthias Schmidt */ -(function(){var b,k,c,A,B,n,f,C,D,e,t,p,u,h,q,v,d,w,E,r,l,x,m,y,z,F;b=jQuery;c=b('
');k=b('
');e=[];f=0;y=d=null;l=function(){var a;a=e[f];null==a.ratio&&(a.ratio=(a.naturalHeight/a.naturalWidth).toFixed(2));if(b(window).height()/a.ratio>b(window).width())return b(a).width(b(window).width()),b(a).height(b(window).width()*a.ratio),b(a).css("margin-top",(b(window).height()-b(a).height())/2);b(a).height(b(window).height());b(a).width(b(window).height()/a.ratio);return b(a).css("margin-top",0)};t=function(a){27===a.keyCode&&n();if(d.navigation&&(37===a.keyCode&&r(!0),39===a.keyCode))return q(!0)};r=function(a){null==a&&(a=!1);if(0"+a.attr("title")+"
"),a.attr("alt")&&(c.caption+=a.attr("alt")));e.push(c);if(d.openOnClick)return g.unbind("click").click(function(a){a.preventDefault();d.reloadOnOpen&&p();return v(c,this)})})};E=function(){d.navigation&&0===c.find("#fullsized_go_prev").length&&(c.append(''),b(document).on("click","#fullsized_go_prev",function(a){a.preventDefault();a.stopPropagation();return r()}),b(document).on("click","#fullsized_go_next",function(a){a.preventDefault();a.stopPropagation();return q()}));d.closeButton&&0===c.find("#fullsized_close").length&&(c.append(''),b(document).on("click","#fullsized_close",function(a){a.preventDefault();a.stopPropagation();return n()}));d.fullscreenButton&&C()&&0===c.find("#fullsized_fullscreen").length&&(c.append(''),b(document).on("click","#fullsized_fullscreen",function(a){a.preventDefault();a.stopPropagation();return z()}));d.caption&&c.find("#fullsized_holder").append(k);switch(d.clickBehaviour){case "close":return b(document).on("click","#jquery-fullsizable",n);case "next":return b(document).on("click","#jquery-fullsizable",function(){return q(!0)});default:return b(document).on("click","#jquery-fullsizable",d.clickBehaviour)}};A=function(){b(document).bind("keydown",t);d.navigation&&(b(document).bind("fullsizable:next",function(){return q(!0)}),b(document).bind("fullsizable:prev",function(){return r(!0)}));return b(document).bind("fullsizable:close",n)};F=function(){b(document).unbind("keydown",t);d.navigation&&(b(document).unbind("fullsizable:next"),b(document).unbind("fullsizable:prev"));return b(document).unbind("fullsizable:close")};D=function(){var a;k.toggle(!1);a=c.find("button");if(!0===a.is(":visible"))return a.toggle(!1),c.bind("mousemove",u)};h=null;u=function(a){null===h&&(h=[a.clientX,a.clientY]);if(10<=Math.round(Math.sqrt(Math.pow(h[1]-a.clientY,2)+Math.pow(h[0]-a.clientX,2))))return c.unbind("mousemove",u),h=null,x()};x=function(){k.toggle(!0);b("#fullsized_close,#fullsized_fullscreen").toggle(!0);if(d.loop)return b("#fullsized_go_prev").show(),b("#fullsized_go_next").show();b("#fullsized_go_prev").toggle(0!==f);return b("#fullsized_go_next").toggle(f!==e.length-1)};b.fn.fullsizable=function(a){d=b.extend({fullsizableElements:this,detach_id:null,navigation:!0,closeButton:!0,fullscreenButton:!0,openOnClick:!0,clickBehaviour:"close",preload:!0,reloadOnOpen:!1,loop:!1,caption:!1},a||{});E();d.preload&&p();b(document).bind("fullsizable:reload",p);b(document).bind("fullsizable:open",function(a,c){var g,f,k,h;d.reloadOnOpen&&p();h=[];g=0;for(k=e.length;g
');var g=b('
');var e=[];var f=0;var t=c=null;var h=function(){var a=e[f];null==a.ratio&&(a.ratio=(a.naturalHeight/a.naturalWidth).toFixed(2));if(b(window).height()/a.ratio>b(window).width())return b(a).width(b(window).width()),b(a).height(b(window).width()*a.ratio),b(a).css("margin-top",(b(window).height()-b(a).height())/2);b(a).height(b(window).height());b(a).width(b(window).height()/a.ratio);return b(a).css("margin-top",0)};var u=function(a){27===a.keyCode&&n();if(c.navigation&&(37===a.keyCode&&r(!0),39===a.keyCode))return p(!0)};var r=function(a){null==a&&(a=!1);if(0"+f.attr("title")+"
"),f.attr("alt")&&(a.caption+=f.attr("alt")));e.push(a);if(c.openOnClick)return d.unbind("click").click(function(b){b.preventDefault();c.reloadOnOpen&&q();return x(a,this)})})};var F=function(){c.navigation&&0===d.find("#fullsized_go_prev").length&&(d.append(''),b(document).on("click","#fullsized_go_prev",function(a){a.preventDefault();a.stopPropagation();return r()}),b(document).on("click","#fullsized_go_next",function(a){a.preventDefault();a.stopPropagation();return p()}));c.closeButton&&0===d.find("#fullsized_close").length&&(d.append(''),b(document).on("click","#fullsized_close",function(a){a.preventDefault();a.stopPropagation();return n()}));c.fullscreenButton&&E()&&0===d.find("#fullsized_fullscreen").length&&(d.append(''),b(document).on("click","#fullsized_fullscreen",function(a){a.preventDefault();a.stopPropagation();return y()}));c.caption&&d.find("#fullsized_holder").append(g);switch(c.clickBehaviour){case "close":return b(document).on("click","#jquery-fullsizable",n);case "next":return b(document).on("click","#jquery-fullsizable",function(){return p(!0)});default:return b(document).on("click","#jquery-fullsizable",c.clickBehaviour)}};var B=function(){b(document).bind("keydown",u);c.navigation&&(b(document).bind("fullsizable:next",function(){return p(!0)}),b(document).bind("fullsizable:prev",function(){return r(!0)}));return b(document).bind("fullsizable:close",n)};var D=function(){b(document).unbind("keydown",u);c.navigation&&(b(document).unbind("fullsizable:next"),b(document).unbind("fullsizable:prev"));return b(document).unbind("fullsizable:close")};var A=function(){g.toggle(!1);var a=d.find("button");if(!0===a.is(":visible"))return a.toggle(!1),d.css("cursor","none"),d.bind("mousemove",z)};var m=null;var z=function(a){null===m&&(m=[a.clientX,a.clientY]);if(10<=Math.round(Math.sqrt(Math.pow(m[1]-a.clientY,2)+Math.pow(m[0]-a.clientX,2))))return d.unbind("mousemove",z),m=null,v()};var v=function(){g.toggle(!0);b("#fullsized_close,#fullsized_fullscreen").toggle(!0);d.css("cursor","auto");if(c.loop)return b("#fullsized_go_prev").show(),b("#fullsized_go_next").show();b("#fullsized_go_prev").toggle(0!==f);return b("#fullsized_go_next").toggle(f!==e.length-1)};b.fn.fullsizable=function(a){c=b.extend({fullsizableElements:this,detach_id:null,navigation:!0,closeButton:!0,fullscreenButton:!0,openOnClick:!0,clickBehaviour:"close",preload:!0,reloadOnOpen:!1,loop:!1,caption:!1},a||{});F();c.preload&&q();b(document).bind("fullsizable:reload",q);b(document).bind("fullsizable:open",function(a,d){var f;c.reloadOnOpen&&q();var k=[];var g=0;for(f=e.length;g Date: Sat, 9 Sep 2017 00:15:40 +0200 Subject: [PATCH 13/14] Updated version to 2.2.1 --- README.md | 3 +++ bower.json | 2 +- fullsizable.jquery.json | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 79d7f18..5d334db 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,9 @@ Triggers: ``fullsizable:open``, ``fullsizable:close``, ``fullsizable:next``, ``f ## Changelog +* **2.2.1** - 08.09.2017 + * small fix and improvement + * **2.2.0** - 26.03.2017 * added caption support diff --git a/bower.json b/bower.json index b46cbab..2390557 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery-fullsizable", - "version": "2.2.0", + "version": "2.2.1", "homepage": "http://mschmidt.github.io/jquery-fullsizable/", "authors": [ "Matthias Schmidt (http://pixelflush.com)" diff --git a/fullsizable.jquery.json b/fullsizable.jquery.json index 9b634fd..b525883 100644 --- a/fullsizable.jquery.json +++ b/fullsizable.jquery.json @@ -1,6 +1,6 @@ { "name": "fullsizable", - "version": "2.2.0", + "version": "2.2.1", "title": "jQuery fullsizable", "author": { "name": "Matthias Schmidt", From 8f2598b10c06612f6878d8a8b84534f24d93beb8 Mon Sep 17 00:00:00 2001 From: Timo Kosse Date: Fri, 22 Sep 2017 15:34:57 +0200 Subject: [PATCH 14/14] Added a toggle for hiding the browser scrollbar Should replace in most cases the need to detach a element via a detach_id. --- css/jquery-fullsizable.css | 3 +++ examples/simple.html | 4 ++-- examples/themed_with_touch.html | 1 - js/jquery-fullsizable.coffee | 2 ++ js/jquery-fullsizable.js | 2 ++ js/jquery-fullsizable.min.js | 2 +- 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/css/jquery-fullsizable.css b/css/jquery-fullsizable.css index 13d99be..dfe80e0 100644 --- a/css/jquery-fullsizable.css +++ b/css/jquery-fullsizable.css @@ -35,3 +35,6 @@ background: #666; /*Fallback for IE8*/ background: rgba(102,102,102,0.4); } +.fullsizable-open { + overflow: hidden; +} \ No newline at end of file diff --git a/examples/simple.html b/examples/simple.html index b978560..b5cb46e 100644 --- a/examples/simple.html +++ b/examples/simple.html @@ -44,8 +44,8 @@ diff --git a/examples/themed_with_touch.html b/examples/themed_with_touch.html index 10d78fe..cc04fbb 100644 --- a/examples/themed_with_touch.html +++ b/examples/themed_with_touch.html @@ -18,7 +18,6 @@