colorbox.js 639 B

123456789101112131415161718192021222324252627
  1. (function ($) {
  2. Drupal.behaviors.initColorbox = {
  3. attach: function (context, settings) {
  4. if (!$.isFunction($.colorbox)) {
  5. return;
  6. }
  7. if (settings.colorbox.mobiledetect && window.matchMedia) {
  8. // Disable Colorbox for small screens.
  9. var mq = window.matchMedia("(max-device-width: " + settings.colorbox.mobiledevicewidth + ")");
  10. if (mq.matches) {
  11. return;
  12. }
  13. }
  14. $('.colorbox', context)
  15. .once('init-colorbox')
  16. .colorbox(settings.colorbox);
  17. $(context).bind('cbox_complete', function () {
  18. Drupal.attachBehaviors('#cboxLoadedContent');
  19. });
  20. }
  21. };
  22. })(jQuery);