1/* 2 * Maps Widget for Google Maps 3 * (c) Web factory Ltd, 2012 - 2021 4 */ 5 6 7jQuery(function($) { 8 if (gmw_data.colorbox_css) { 9 $('head').append('<link id="gmw-colorbox" rel="stylesheet" href="' + gmw_data.colorbox_css + '" type="text/css" media="all">'); 10 } 11 12 // click map to open lightbox 13 $('a.gmw-thumbnail-map.gmw-lightbox-enabled').click(function(e) { 14 e.preventDefault(); 15 16 dialog = $($(this).attr('href')); 17 map_width = dialog.data('map-width'); 18 map_height = dialog.data('map-height'); 19 map_url = dialog.data('map-iframe-url'); 20 map_title = dialog.attr('title'); 21 map_skin = dialog.data('map-skin'); 22 close_button = Boolean(dialog.data('close-button')); 23 show_title = Boolean(dialog.data('show-title')); 24 measure_title = parseInt(dialog.data('measure-title'), 10); 25 close_overlay = Boolean(dialog.data('close-overlay')); 26 close_esc = Boolean(dialog.data('close-esc')); 27 28 // adjust map size if screen is too small 29 if (map_width !== '100%' && map_height !== '100%') { 30 screen_width = $(window).width() - 75; 31 if (screen_width < map_width) { 32 map_width = screen_width; 33 map_height *= screen_width / map_width; 34 } 35 screen_height = $(window).height() - 75; 36 if (screen_height < map_height) { 37 map_height = screen_height; 38 map_width *= screen_height / map_height; 39 } 40 41 map_height += 'px'; 42 map_width += 'px'; 43 } // if !fullscreen 44 45 if (!show_title) { 46 map_title = ''; 47 } 48 49 content = $(dialog.html()); 50 content.filter('.gmw-map').html('<iframe data-measure-title="' + measure_title + '" width="100%" height="100%" src="' + map_url + '" allowfullscreen></iframe>'); 51 52 $.colorbox({ html: content, 53 title: map_title, 54 width: map_width, 55 height: map_height, 56 scrolling: false, 57 preloading: false, 58 arrowKey: false, 59 className: 'gmw-' + map_skin, 60 closeButton: close_button, 61 overlayClose: close_overlay, 62 escKey: close_esc }); 63 64 return false; 65 }); // click map to open lightbox 66 67 68 // click map to replace img with interactive map 69 $('a.gmw-thumbnail-map.gmw-replace-enabled').click(function(e) { 70 e.preventDefault(); 71 72 dialog = $($(this).attr('href')); 73 map_width = dialog.data('map-width'); 74 map_height = dialog.data('map-height'); 75 map_url = dialog.data('map-iframe-url'); 76 77 // adjust map size if screen is too small 78 screen_width = $(window).width() - 50; 79 if (screen_width < map_width) { 80 map_width = screen_width; 81 map_height *= screen_width / map_width; 82 } 83 screen_height = $(window).height() - 50; 84 if (screen_height < map_height) { 85 map_height = screen_height; 86 map_width *= screen_height / map_height; 87 } 88 89 content = $(dialog.html()); 90 content.filter('.gmw-map').html('<iframe width="' + map_width + 'px" height="' + map_height + 'px" src="' + map_url + '" allowfullscreen></iframe>'); 91 92 $(this).parent('p').prev('p').hide(); 93 $(this).parent('p').next('p, span.gmw-powered-by').hide(); 94 $(this).parent('p').replaceWith(content); 95 96 return false; 97 }); // click map to replace img with interactive map 98 99 100 // fix lightbox height when header/footer are used 101 $(document).bind('cbox_complete', function(e){ 102 // test if this is a GMW colorbox 103 colorbox = e.currentTarget.activeElement; 104 if ($('div[class^="gmw-"]', colorbox).length === 0) { 105 return; 106 } 107 108 measure_title = $('iframe', colorbox).data('measure-title'); 109 110 if ($('#cboxTitle', colorbox).html() === '') { 111 $('#cboxTitle').hide(); 112 title_height = 0; 113 } else { 114 title_height = measure_title * parseInt(0 + $('#cboxTitle', colorbox).outerHeight(true), 10); 115 } 116 117 // adjust iframe size 118 container = parseInt(0 + $('#cboxLoadedContent').height(), 10); 119 header = parseInt(0 + $('#cboxLoadedContent div.gmw-header').outerHeight(true), 10); 120 footer = parseInt(0 + $('#cboxLoadedContent div.gmw-header').outerHeight(true), 10); 121 $('.gmw-map iframe').height((container - header - footer - title_height) + 'px'); 122 }); 123}); // onload
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.