Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

Commit fa1efbe

Browse files
committed
Couple of tweaks
- Focus method now looks for first input with `autofocus` attribute - It is now possible to set only one dimension (width or height) for iframes (example: `iframe : { css : { width : '100%' }}`) - Removed `unbind` method for jQuery v3 compatibility
1 parent 8d2d48d commit fa1efbe

File tree

6 files changed

+458
-400
lines changed

6 files changed

+458
-400
lines changed

dist/jquery.fancybox.js

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ==================================================
2-
// fancyBox v3.1.25
2+
// fancyBox v3.1.26
33
//
44
// Licensed GPLv3 for open source use
55
// or fancyBox Commercial License for commercial use
@@ -36,7 +36,7 @@
3636
// Enable infinite gallery navigation
3737
loop : false,
3838

39-
// Space around image, ignored if zoomed-in or viewport smaller than 800px
39+
// Space around image, ignored if zoomed-in or viewport width is smaller than 800px
4040
margin : [44, 0],
4141

4242
// Horizontal space between slides
@@ -227,6 +227,7 @@
227227
autoStart : false,
228228
},
229229

230+
// Set `touch: false` to disable dragging/swiping
230231
touch : {
231232
vertical : true, // Allow to drag content vertically
232233
momentum : true // Continue movement after releasing mouse/touch when panning
@@ -325,7 +326,7 @@
325326
return current.type === 'image' ? 'toggleControls' : false;
326327
},
327328
clickSlide : function( current, event ) {
328-
return current.type === 'image' ? 'toggleControls' : "close";
329+
return current.type === 'image' ? 'toggleControls' : 'close';
329330
},
330331
dblclickContent : function( current, event ) {
331332
return current.type === 'image' ? 'zoom' : false;
@@ -1816,11 +1817,11 @@
18161817

18171818
$slide.on('refresh.fb', function() {
18181819
var $wrap = slide.$content,
1819-
$contents,
1820-
$body,
1820+
frameWidth = opts.css.width,
1821+
frameHeight = opts.css.height,
18211822
scrollWidth,
1822-
frameWidth,
1823-
frameHeight;
1823+
$contents,
1824+
$body;
18241825

18251826
if ( $iframe[0].isReady !== 1 ) {
18261827
return;
@@ -1836,19 +1837,28 @@
18361837
} catch (ignore) {}
18371838

18381839
// Calculate dimensions for the wrapper
1839-
if ( $body && $body.length && !( opts.css.width !== undefined && opts.css.height !== undefined ) ) {
1840+
if ( $body && $body.length ) {
18401841

1841-
scrollWidth = $iframe[0].contentWindow.document.documentElement.scrollWidth;
1842+
if ( frameWidth === undefined ) {
1843+
scrollWidth = $iframe[0].contentWindow.document.documentElement.scrollWidth;
18421844

1843-
frameWidth = Math.ceil( $body.outerWidth(true) + ( $wrap.width() - scrollWidth ) );
1844-
frameHeight = Math.ceil( $body.outerHeight(true) );
1845+
frameWidth = Math.ceil( $body.outerWidth(true) + ( $wrap.width() - scrollWidth ) );
1846+
frameWidth += $wrap.outerWidth() - $wrap.innerWidth();
1847+
}
1848+
1849+
if ( frameHeight === undefined ) {
1850+
frameHeight = Math.ceil( $body.outerHeight(true) );
1851+
frameHeight += $wrap.outerHeight() - $wrap.innerHeight();
1852+
}
18451853

18461854
// Resize wrapper to fit iframe content
1847-
$wrap.css({
1848-
'width' : opts.css.width === undefined ? frameWidth + ( $wrap.outerWidth() - $wrap.innerWidth() ) : opts.css.width,
1849-
'height' : opts.css.height === undefined ? frameHeight + ( $wrap.outerHeight() - $wrap.innerHeight() ) : opts.css.height
1850-
});
1855+
if ( frameWidth ) {
1856+
$wrap.width( frameWidth );
1857+
}
18511858

1859+
if ( frameHeight ) {
1860+
$wrap.height( frameHeight );
1861+
}
18521862
}
18531863

18541864
$wrap.removeClass( 'fancybox-is-hidden' );
@@ -2256,7 +2266,7 @@
22562266

22572267
$.fancybox.stop( slide.$slide );
22582268

2259-
slide.$slide.unbind().remove();
2269+
slide.$slide.off().remove();
22602270
}
22612271
});
22622272

@@ -2310,8 +2320,16 @@
23102320
return;
23112321
}
23122322

2313-
// Skip for images and iframes
2314-
$el = current && current.isComplete ? current.$slide.find('button,:input,[tabindex],a').filter(':not([disabled]):visible:first') : null;
2323+
if ( current && current.isComplete ) {
2324+
2325+
// Look for first input with autofocus attribute
2326+
$el = current.$slide.find('input[autofocus]:enabled:visible:first');
2327+
2328+
if ( !$el.length ) {
2329+
$el = current.$slide.find('button,:input,[tabindex],a').filter(':enabled:visible:first');
2330+
}
2331+
}
2332+
23152333
$el = $el && $el.length ? $el : this.$refs.container;
23162334

23172335
$el.focus();
@@ -2495,7 +2513,6 @@
24952513
instance.activate();
24962514

24972515
} else {
2498-
24992516
$W.scrollTop( self.scrollTop ).scrollLeft( self.scrollLeft );
25002517

25012518
$( 'html' ).removeClass( 'fancybox-enabled' );
@@ -2629,7 +2646,7 @@
26292646

26302647
$.fancybox = {
26312648

2632-
version : "3.1.25",
2649+
version : "3.1.26",
26332650
defaults : defaults,
26342651

26352652

@@ -3265,7 +3282,7 @@
32653282

32663283
var isClickable = function( $el ) {
32673284

3268-
if ( $el.is('a,button,input,select,textarea') || $.isFunction( $el.get(0).onclick ) || $el.data('selectable') ) {
3285+
if ( $el.is('a,button,input,select,textarea,label') || $.isFunction( $el.get(0).onclick ) || $el.data('selectable') ) {
32693286
return true;
32703287
}
32713288

dist/jquery.fancybox.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)