Created
March 31, 2016 10:31
-
-
Save m4tlch/14c798199099c4ab05aaac24f2a56a82 to your computer and use it in GitHub Desktop.
JS: Responsive ColorBox Drupal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
========================================================================== | |
$Colorbox Responsive | |
* How to make colorbox responsive | |
* see @ https://www.drupal.org/node/2154099 | |
========================================================================== | |
*/ | |
(function ($, Drupal, window, document, undefined) { | |
//Configure colorbox call back to resize with custom dimensions | |
$.colorbox.settings.onLoad = function() { | |
colorboxResize(); | |
} | |
//Customize colorbox dimensions | |
var colorboxResize = function(resize) { | |
var width = "90%"; | |
var height = "90%"; | |
if($(window).width() > 960) { width = "860" } | |
if($(window).height() > 700) { height = "630" } | |
$.colorbox.settings.height = height; | |
$.colorbox.settings.width = width; | |
//if window is resized while lightbox open | |
if(resize) { | |
$.colorbox.resize({ | |
'height': height, | |
'width': width | |
}); | |
} | |
} | |
//In case of window being resized | |
$(window).resize(function() { | |
colorboxResize(true); | |
}); | |
})(jQuery, Drupal, this, this.document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment