Created
March 25, 2010 00:29
-
-
Save bangpound/343014 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/*globals Drupal,$ */ | |
"use strict"; | |
Drupal.behaviors.multimediaDetail = function (context) { | |
$('.media-item a:not(.multimedia-detail-processed)', context) | |
.each(function () { | |
// Append a special suffix to the href. Loads simple HTML elements to | |
// display in fancybox. | |
this.href += '/' + Drupal.settings.mediaPlayer.callback; | |
this.rel = 'gallery'; | |
}) | |
.fancybox({ | |
padding: 20, | |
centerOnScroll: true, | |
opacity: true, | |
overlayColor: '#ccc', | |
overlayOpacity: 0.8, | |
titleShow: false, | |
transitionIn: 'elastic', | |
transitionOut: 'elastic', | |
onComplete: function (gallery, index, options) { | |
var width; | |
// Measure the element whose width constrains the fancybox. | |
width = $(Drupal.settings.mediaPlayer.constrain, '#fancybox-inner').width(); | |
// Set the width of the fancybox elements using the width and padding. | |
$('#fancybox-inner').css('width', width + "px"); | |
$('#fancybox-wrap').css('width', width + (options.padding * 2) + "px"); | |
// Shrink the height of the fancybox and recenter it using public | |
// methods. | |
$.fancybox.resize(); | |
$.fancybox.center(); | |
// Fancybox contents contain Drupal elements that need behaviors | |
// attached. Behaviors must already be loaded in DOM. | |
$('#fancybox-inner').each(function () { | |
// Unless the multimediaDetail behavior is removed before calling | |
// Drupal.attachBehaviors(), the $.fn.fancybox function calls | |
// metadata() which then calls data() on a null element in an endless | |
// loop. | |
Drupal.behaviors.multimediaDetail = function (context) {}; | |
Drupal.attachBehaviors(this); | |
}); | |
} | |
}) | |
.addClass('multimedia-detail-processed'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment