Format source code and add a note about knowing we have JQuery available
This commit is contained in:
parent
fdf0f76df2
commit
3f144b8fd5
1 changed files with 22 additions and 19 deletions
|
@ -7,26 +7,29 @@
|
||||||
(function ($) {
|
(function ($) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// Find all iframes
|
// Find all iframes
|
||||||
var $iframes = $( "iframe" );
|
var $iframes = $( "iframe" );
|
||||||
|
|
||||||
// Find and save the aspect ratio for all iframes
|
// Find and save the aspect ratio for all iframes
|
||||||
$iframes.each(function () {
|
$iframes.each(function () {
|
||||||
$( this ).data( "ratio", this.height / this.width )
|
$( this ).data( "ratio", this.height / this.width )
|
||||||
// Remove the hardcoded width & height attributes
|
// Remove the hardcoded width & height attributes
|
||||||
.removeAttr( "width" )
|
.removeAttr( "width" )
|
||||||
.removeAttr( "height" );
|
.removeAttr( "height" );
|
||||||
});
|
|
||||||
|
|
||||||
// Resize the iframes when the window is resized
|
|
||||||
$( window ).resize( function () {
|
|
||||||
$iframes.each( function() {
|
|
||||||
// Get the parent container's width
|
|
||||||
var width = $( this ).parent().width();
|
|
||||||
$( this ).width( width )
|
|
||||||
.height( width * $( this ).data( "ratio" ) );
|
|
||||||
});
|
});
|
||||||
// Resize to fix all iframes on page load.
|
|
||||||
}).resize();
|
// Resize the iframes when the window is resized
|
||||||
|
$( window ).resize( function () {
|
||||||
|
$iframes.each( function() {
|
||||||
|
// Get the parent container's width
|
||||||
|
var width = $( this ).parent().width();
|
||||||
|
$( this ).width( width )
|
||||||
|
.height( width * $( this ).data( "ratio" ) );
|
||||||
|
});
|
||||||
|
// Resize to fix all iframes on page load.
|
||||||
|
}).resize();
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
||||||
|
// Note that we know we have JQuery because our geofresco/global relies on bulma/global
|
||||||
|
// which pulls in JQuery already.
|
||||||
|
|
Loading…
Add table
Reference in a new issue