1/** 2 * @file 3 * Colorbox module load js. 4 */ 5(function ($) { 6 7Drupal.behaviors.initColorboxLoad = { 8 attach: function (context, settings) { 9 if (!$.isFunction($.colorbox) || typeof settings.colorbox === 'undefined') { 10 return; 11 } 12 13 if (settings.colorbox.mobiledetect && window.matchMedia) { 14 // Disable Colorbox for small screens. 15 var mq = window.matchMedia("(max-device-width: " + settings.colorbox.mobiledevicewidth + ")"); 16 if (mq.matches) { 17 return; 18 } 19 } 20 21 $.urlParams = function (url) { 22 var p = {}, 23 e, 24 a = /\+/g, // Regex for replacing addition symbol with a space. 25 r = /([^&=]+)=?([^&]*)/g, 26 d = function (s) { return decodeURIComponent(s.replace(a, ' ')); }, 27 q = url.split('?'); 28 while (e = r.exec(q[1])) { 29 e[1] = d(e[1]); 30 e[2] = d(e[2]); 31 switch (e[2].toLowerCase()) { 32 case 'true': 33 case 'yes': 34 e[2] = true; 35 break; 36 case 'false': 37 case 'no': 38 e[2] = false; 39 break; 40 } 41 if (e[1] == 'width') { e[1] = 'innerWidth'; } 42 if (e[1] == 'height') { e[1] = 'innerHeight'; } 43 if (e[2]) { 44 e[2] = Drupal.checkPlain(e[2]); 45 } 46 p[e[1]] = e[2]; 47 } 48 return p; 49 }; 50 51 $('.colorbox-load', context) 52 .once('init-colorbox-load', function () { 53 var href = $(this).attr('href'); 54 55 var params = $.urlParams(href); 56 57 // Always load in an iframe. 58 params.iframe = true; 59 60 // Set inner width and height if not already specified. 61 if (!params.hasOwnProperty('innerWidth')) { 62 params.innerWidth = $(window).width() * .8; 63 } 64 if (!params.hasOwnProperty('innerHeight')) { 65 params.innerHeight = $(window).height() * .8; 66 } 67 68 if (!params.hasOwnProperty('title')) { 69 // If a title attribute is supplied, sanitize it. 70 var title = $(this).attr('title'); 71 if (title) { 72 params.title = Drupal.colorbox.sanitizeMarkup(title); 73 } 74 } 75 $(this).colorbox($.extend({}, settings.colorbox, params)); 76 }); 77 } 78}; 79 80})(jQuery);
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.