1(function( $ ) { 2 'use strict'; 3 4 // Create the defaults once 5 var pluginName = "storeLocatorSingle", 6 defaults = { 7 map_container: "#store_locator_single_map", 8 map_min_height: 300, 9 earthRadi: { 10 mi: 3963.1676, 11 km: 6378.1, 12 ft: 20925524.9, 13 mt: 6378100, 14 "in": 251106299, 15 yd: 6975174.98, 16 fa: 3487587.49, 17 na: 3443.89849, 18 ch: 317053.408, 19 rd: 1268213.63, 20 fr: 31705.3408 21 }, 22 }; 23 24 // The actual plugin constructor 25 function Plugin ( element, options ) { 26 this.element = element; 27 this.settings = $.extend( {}, defaults, options ); 28 this._defaults = defaults; 29 30 this.settings.lat = $(element).data('lat'); 31 this.settings.lng = $(element).data('lng'); 32 33 this._name = pluginName; 34 this.init(); 35 } 36 37 // Avoid Plugin.prototype conflicts 38 $.extend( Plugin.prototype, { 39 init: function() { 40 var that = this; 41 this.window = $(window); 42 this.documentHeight = $( document ).height(); 43 this.windowHeight = this.window.height(); 44 this.settings.mapDefaultZoom = parseInt(that.settings.mapDefaultZoom); 45 this.templateCache = {}; 46 47 that.initStoreLocatorSingle(); 48 }, 49 initStoreLocatorSingle: function() { 50 var that = this; 51 52 that.initMap(function(){ 53 that.createMarker(); 54 }); 55 }, 56 initMap: function(callback) { 57 var mapContainer = $(this.settings.map_container); 58 var mapDefaultZoom = this.settings.mapDefaultZoom; 59 var mapDefaultType = this.settings.mapDefaultType; 60 var mapDefaultLat = Number(this.settings.lat); 61 var mapDefaultLng = Number(this.settings.lng); 62 63 var mapStyling = this.settings.mapStyling; 64 if( !this.isEmpty(mapStyling) ) { 65 mapStyling = JSON.parse(mapStyling); 66 } else { 67 mapStyling = ""; 68 } 69 70 // Construct Map 71 this.map = new google.maps.Map(mapContainer[0], { 72 zoom: mapDefaultZoom, 73 center: new google.maps.LatLng(mapDefaultLat, mapDefaultLng), 74 mapTypeId: google.maps.MapTypeId[mapDefaultType], 75 scrollwheel: false, 76 styles: mapStyling 77 }); 78 79 callback(); 80 }, 81 createMarker: function() { 82 var marker; 83 var store = {}; 84 85 store.map = this.map; 86 store.position = new google.maps.LatLng(this.settings.lat, this.settings.lng); 87 store.icon = this.settings.mapDefaultIcon; 88 89 marker = new google.maps.Marker(store); 90 marker.setMap(this.map); 91 }, 92 ////////////////////// 93 ///Helper Functions/// 94 ////////////////////// 95 isEmpty: function(obj) { 96 97 if (obj == null) return true; 98 if (obj.length > 0) return false; 99 if (obj.length === 0) return true; 100 101 for (var key in obj) { 102 if (hasOwnProperty.call(obj, key)) return false; 103 } 104 105 return true; 106 }, 107 sprintf: function parse(str) { 108 var args = [].slice.call(arguments, 1), 109 i = 0; 110 111 return str.replace(/%s/g, function() { 112 return args[i++]; 113 }); 114 }, 115 getCookie: function(cname) { 116 var name = cname + "="; 117 var ca = document.cookie.split(';'); 118 for(var i=0; i<ca.length; i++) { 119 var c = ca[i]; 120 while (c.charAt(0)==' ') c = c.substring(1); 121 if (c.indexOf(name) === 0) return c.substring(name.length, c.length); 122 } 123 return ""; 124 }, 125 } ); 126 127 // Constructor wrapper 128 $.fn[ pluginName ] = function( options ) { 129 return this.each( function() { 130 if ( !$.data( this, "plugin_" + pluginName ) ) { 131 $.data( this, "plugin_" + 132 pluginName, new Plugin( this, options ) ); 133 } 134 } ); 135 }; 136 137 $(document).ready(function() { 138 139 $( "#store_locator_single_map" ).storeLocatorSingle( 140 store_locator_options 141 ); 142 143 } ); 144 145})( 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.