vendor/assets/javascripts/map.js in active_frontend-2.0.6 vs vendor/assets/javascripts/map.js in active_frontend-2.0.7

- old
+ new

@@ -1,5 +1,6 @@ +"use strict"; (function(root, factory) { if(typeof exports === 'object') { module.exports = factory(); } else if(typeof define === 'function' && define.amd) { @@ -8,18 +9,10 @@ root.GMaps = factory(); }(this, function() { -/*! - * GMaps.js v0.4.17 - * http://hpneo.github.com/gmaps/ - * - * Copyright 2015, Gustavo Leon - * Released under the MIT License. - */ - if (!(typeof window.google === 'object' && window.google.maps)) { throw 'Google Maps API is required. Please register the following JavaScript library http://maps.google.com/maps/api/js?sensor=true.' } var extend_object = function(obj, new_obj) { @@ -58,11 +51,11 @@ array_length = array.length, i; if (Array.prototype.map && array.map === Array.prototype.map) { array_return = Array.prototype.map.call(array, function(item) { - callback_params = original_callback_params; + var callback_params = original_callback_params.slice(0); callback_params.splice(0, 0, item); return callback.apply(this, callback_params); }); } @@ -115,15 +108,30 @@ } return coords; }; + +var getElementsByClassName = function (class_name, context) { + + var element, + _class = class_name.replace('.', ''); + + if ('jQuery' in this && context) { + element = $("." + _class, context)[0]; + } else { + element = document.getElementsByClassName(_class)[0]; + } + return element; + +}; + var getElementById = function(id, context) { var element, id = id.replace('#', ''); - if ('jQuery' in this && context) { + if ('jQuery' in window && context) { element = $('#' + id, context)[0]; } else { element = document.getElementById(id); }; @@ -162,11 +170,11 @@ 'dragend', 'dragstart', 'idle', 'maptypeid_changed', 'projection_changed', 'resize', 'tilesloaded', 'zoom_changed' ], events_that_doesnt_hide_context_menu = ['mousemove', 'mouseout', 'mouseover'], options_to_be_deleted = ['el', 'lat', 'lng', 'mapType', 'width', 'height', 'markerClusterer', 'enableNewStyle'], - container_id = options.el || options.div, + identifier = options.el || options.div, markerClustererFunction = options.markerClusterer, mapType = google.maps.MapTypeId[options.mapType.toUpperCase()], map_center = new google.maps.LatLng(options.lat, options.lng), zoomControl = options.zoomControl || true, zoomControlOpt = options.zoomControlOpt || { @@ -197,14 +205,20 @@ scaleControl: scaleControl, streetViewControl: streetViewControl, overviewMapControl: overviewMapControl }; - if (typeof(options.el) === 'string' || typeof(options.div) === 'string') { - this.el = getElementById(container_id, options.context); - } else { - this.el = container_id; - } + if (typeof(options.el) === 'string' || typeof(options.div) === 'string') { + + if (identifier.indexOf("#") > -1) { + this.el = getElementById(identifier, options.context); + } else { + this.el = getElementsByClassName.apply(this, [identifier, options.context]); + } + + } else { + this.el = identifier; + } if (typeof(this.el) === 'undefined' || this.el === null) { throw 'No element defined.'; } \ No newline at end of file