1/** 2 * @file 3 * Colorbox JS. 4 */ 5 6(function ($, Drupal) { 7 8 'use strict'; 9 10 Drupal.behaviors.initColorbox = { 11 attach: function (context, settings) { 12 if (!$.isFunction($.colorbox) || typeof settings.colorbox === 'undefined') { 13 return; 14 } 15 16 if (settings.colorbox.mobiledetect && window.matchMedia) { 17 // Disable Colorbox for small screens. 18 var mq = window.matchMedia('(max-device-width: ' + settings.colorbox.mobiledevicewidth + ')'); 19 if (mq.matches) { 20 $.colorbox.remove(); 21 return; 22 } 23 } 24 25 settings.colorbox.rel = function () { 26 return $(this).data('colorbox-gallery') 27 }; 28 29 $('.colorbox', context) 30 .once('init-colorbox').each(function() { 31 // Only images are supported for the "colorbox" class. 32 // The "photo" setting forces the href attribute to be treated as an image. 33 var extendParams = { 34 photo: true 35 }; 36 // If a title attribute is supplied, sanitize it. 37 var title = $(this).attr('title'); 38 if (title) { 39 extendParams.title = Drupal.checkPlain(title); 40 } 41 $(this).colorbox($.extend({}, settings.colorbox, extendParams)); 42 }); 43 44 $('.colorbox', context).colorbox({ 45 onComplete: function (e) { 46 var focus = $('#cboxContent').find('#cboxPrevious').css('display') !== 'none' ? $('#cboxContent').find('#cboxPrevious') : $('#cboxContent').find('#cboxClose'); 47 focus.focus(); 48 49 $('#cboxContent').on('keydown', function (e) { 50 var keyCode = e.keyCode || e.which; 51 var firstElement = $('#cboxContent').find('#cboxPrevious').last().is(':focus'); 52 var lastElement = $('#cboxContent').find('#cboxClose').first().is(':focus'); 53 if (keyCode === 9 && !e.shiftKey && lastElement) { 54 e.preventDefault(); 55 $('#cboxContent').find('#cboxPrevious').first().focus(); 56 } 57 else if (keyCode === 9 && e.shiftKey && firstElement) { 58 e.preventDefault(); 59 $('#cboxContent').find('#cboxClose').first().focus(); 60 } 61 }); 62 } 63 }); 64 } 65 }; 66 67})(jQuery, Drupal);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.