{I" class:ETI"ProcessedAsset;FI"logical_path;TI"$maps/jquery_ui_addresspicker.js;FI" pathname;TI"u/Users/austin/Sites/berlinmagic/magic_addresses/vendor/assets/javascripts/maps/jquery_ui_addresspicker.js.coffee;FI"content_type;TI"application/javascript;TI" mtime;Tl+e°ėTI" length;Ti3'I" digest;TI"%13002bfefeb7040bee10f633b56e75f2;FI" source;TI"3'(function() { (function($, window, document) { if (typeof google !== "undefined" && google !== null) { $.widget("ui.addresspicker", { options: { appendAddressString: "", draggableMarker: true, regionBias: null, mapOptions: { zoom: 5, center: new google.maps.LatLng(52, 13), scrollwheel: false, mapTypeId: google.maps.MapTypeId.ROADMAP }, elements: { map: false, lat: false, lng: false, locality: false, sublocality: false, administrative_area_level_1: false, administrative_area_level_2: false, administrative_area_level_3: false, country: false, postal_code: false, type: false, streetNumber: false, route: false, country_code: false, formatted_address: false } }, marker: function() { return this.gmarker; }, map: function() { return this.gmap; }, updatePosition: function() { return this._updatePosition(this.gmarker.getPosition()); }, reloadPosition: function() { this.gmarker.setVisible(true); this.gmarker.setPosition(new google.maps.LatLng(this.lat.val(), this.lng.val())); return this.gmap.setCenter(this.gmarker.getPosition()); }, selected: function() { return this.selectedResult; }, _create: function() { this.geocoder = new google.maps.Geocoder(); this.element.autocomplete({ source: $.proxy(this._geocode, this), focus: $.proxy(this._focusAddress, this), select: $.proxy(this._selectAddress, this) }); this.lat = $(this.options.elements.lat); this.lng = $(this.options.elements.lng); this.locality = $(this.options.elements.locality); this.sublocality = $(this.options.elements.sublocality); this.administrative_area_level_1 = $(this.options.elements.administrative_area_level_1); this.administrative_area_level_2 = $(this.options.elements.administrative_area_level_2); this.administrative_area_level_3 = $(this.options.elements.administrative_area_level_3); this.country = $(this.options.elements.country); this.country_code = $(this.options.elements.country_code); this.postal_code = $(this.options.elements.postal_code); this.streetNumber = $(this.options.elements.streetNumber); this.route = $(this.options.elements.route); this.type = $(this.options.elements.type); this.formatted_address = $(this.options.elements.formatted_address); if (this.options.elements.map) { this.mapElement = $(this.options.elements.map); return this._initMap(); } }, _initMap: function() { if (this.lat && this.lat.val()) { this.options.mapOptions.center = new google.maps.LatLng(this.lat.val(), this.lng.val()); } this.gmap = new google.maps.Map(this.mapElement[0], this.options.mapOptions); this.gmarker = new google.maps.Marker({ position: this.options.mapOptions.center, map: this.gmap, draggable: this.options.draggableMarker, raiseOnDrag: true, icon: magic_marker_image, shadow: magic_marker_shadow, shape: magic_marker_shape }); google.maps.event.addListener(this.gmarker, "dragend", $.proxy(this._markerMoved, this)); return this.gmarker.setVisible(false); }, _updatePosition: function(location) { if (this.lat) { this.lat.val(location.lat()); } if (this.lng) { return this.lng.val(location.lng()); } }, _markerMoved: function() { return this._updatePosition(this.gmarker.getPosition()); }, _geocode: function(request, response) { var address, self; address = request.term; self = this; return this.geocoder.geocode({ address: address + this.options.appendAddressString, language: "ru" }, function(results, status) { var i; if (status === google.maps.GeocoderStatus.OK) { i = 0; while (i < results.length) { results[i].label = results[i].formatted_address; i++; } } return response(results); }); }, _findInfo: function(result, type) { var component, i; i = 0; while (i < result.address_components.length) { component = result.address_components[i]; if (component.types.indexOf(type) !== -1) { return component.long_name; } i++; } return false; }, _findShortInfo: function(result, type) { var component, i; i = 0; while (i < result.address_components.length) { component = result.address_components[i]; if (component.types.indexOf(type) !== -1) { return component.short_name; } i++; } return false; }, _focusAddress: function(event, ui) { var address; address = ui.item; if (!address) { return; } if (this.gmarker) { this.gmarker.setPosition(address.geometry.location); this.gmarker.setVisible(true); this.gmap.fitBounds(address.geometry.viewport); } this._updatePosition(address.geometry.location); if (this.locality) { if (this._findInfo(address, "locality")) { this.locality.val(this._findInfo(address, "locality")); } else { this.locality.val(""); } } if (this.sublocality) { if (this._findInfo(address, "sublocality")) { this.sublocality.val(this._findInfo(address, "sublocality")); } else { this.sublocality.val(""); } } if (this.administrative_area_level_1) { if (this._findInfo(address, "administrative_area_level_1")) { this.administrative_area_level_1.val(this._findInfo(address, "administrative_area_level_1")); } else { this.administrative_area_level_1.val(""); } } if (this.administrative_area_level_2) { if (this._findInfo(address, "administrative_area_level_2")) { this.administrative_area_level_2.val(this._findInfo(address, "administrative_area_level_2")); } else { this.administrative_area_level_2.val(""); } } if (this.administrative_area_level_3) { if (this._findInfo(address, "administrative_area_level_3")) { this.administrative_area_level_3.val(this._findInfo(address, "administrative_area_level_3")); } else { this.administrative_area_level_3.val(""); } } if (this.route) { if (this._findInfo(address, "route")) { this.route.val(this._findInfo(address, "route")); } else { this.route.val(""); } } if (this.streetNumber) { if (this._findInfo(address, "street_number")) { this.streetNumber.val(this._findInfo(address, "street_number")); } else { this.streetNumber.val(""); } } if (this.country) { if (this._findInfo(address, "country")) { this.country.val(this._findInfo(address, "country")); } else { this.country.val(""); } } if (this.country_code) { if (this._findShortInfo(address, "country")) { this.country_code.val(this._findShortInfo(address, "country")); } else { this.country_code.val(""); } } if (this.postal_code) { if (this._findInfo(address, "postal_code")) { this.postal_code.val(this._findInfo(address, "postal_code")); } else { this.postal_code.val(""); } } if (this.formatted_address) { if (address["formatted_address"]) { this.formatted_address.val(address["formatted_address"]); } else { this.formatted_address.val(""); } } console.log(address); if (this.type) { return this.type.val(address.types[0]); } }, _selectAddress: function(event, ui) { this.selectedResult = ui.item; if ($(this.element).closest(".map_form").find(".hidden_mgca_form").length > 0) { $(this.element).closest(".map_form").find(".hidden_mgca_form").fadeIn(); $(this.element).fadeOut(); if ($(this.element).closest(".map_form").find(".mgca_txt.street_number").val() === "") { return $(this.element).closest(".map_form").find(".mgca_txt.street_number").focus(); } } } }); $.extend($.ui.addresspicker, { version: "@VERSION" }); if (!Array.indexOf) { return Array.prototype.indexOf = function(obj) { var i; i = 0; while (i < this.length) { if (this[i] === obj) { return i; } i++; } return -1; }; } } })(jQuery, window, document); }).call(this); ;TI"dependency_digest;TI"%29e263999d565350ed9bc98dfb2fdc9c;FI"required_paths;T[I"u/Users/austin/Sites/berlinmagic/magic_addresses/vendor/assets/javascripts/maps/jquery_ui_addresspicker.js.coffee;FI"dependency_paths;T[{I" path;TI"u/Users/austin/Sites/berlinmagic/magic_addresses/vendor/assets/javascripts/maps/jquery_ui_addresspicker.js.coffee;FI" mtime;TI"2015-02-23T23:57:41+01:00;TI" digest;TI"%679895f78bd25bbae304a4cfd32bf2ec;FI" _version;TI"%64e62ddc273c2f5847f30d698ca14b67;F