expo-93 ready

remotes/origin/1203
pavel 11 years ago
parent 0a98edc903
commit 0defa1dfc9
  1. 94
      templates/client/includes/company/company_object.html
  2. 2
      templates/client/static_client/js/_modules/page.company.js

@ -48,7 +48,17 @@
<hr />
{% endif %}
{% if company.address_inf %}
{{ company.address_inf }}
<div class=" mb-1em address-wrap" id="address-wrap">
<a class="map-toggle " href="javascript:void(0);" data-show-text="{% trans 'Раскрыть карту' %}" data-hide-text="{% trans 'Скрыть карту' %}"><i class="fa fa-map-marker">&nbsp;</i><span class="label">Раскрыть карту</span></a>
<div class="i-descr">
<span id="address-text">{{ company.address_inf }}</span>
</div>
<div class="map-wrap hidden">
<div id="gmap-canvas" style="height: 308px; width:800px; position: relative;">
</div>
</div>
</div>
<hr />
{% endif %}
@ -245,4 +255,86 @@
{% endif %}
</div>
<script>
$(function () {
var Map = function (opt) {
this.opt = opt;
var self = this,
canvasId = this.opt.canvasId,
initGooglemap = function () {
var mapHolder = document.getElementById(self.opt.canvasId);
self.mapOptions = {
zoom: self.opt.zoom
};
self.map = new google.maps.Map(mapHolder, self.mapOptions);
self.geocoder = new google.maps.Geocoder();
self.refresh();
};
google.maps.event.addDomListener(window, 'load', initGooglemap);
this.$wrapper= $(document.getElementById(this.opt.blockId));
this.$toggle = $(".map-toggle",this.$wrapper);
this.$container = $(".map-wrap", this.$wrapper);
this.status ={
visible:false
};
this.$toggle.on("click", function () {
if($(this).hasClass("active")){
self.hideMap();
}else{
self.showMap();
google.maps.event.trigger(self.map, 'resize');
self.refresh();
}
return false;
});
};
Map.prototype = {
showMap: function () {
this.$toggle.addClass("active").children(".label").text(this.$toggle.attr("data-hide-text"));
this.status.visible = true;
this.$container.removeClass("hidden");
},
hideMap: function () {
this.$toggle.removeClass("active").children(".label").text(this.$toggle.attr("data-show-text"));
this.status.visible = false;
this.$container.addClass("hidden");
},
refresh: function () {
var self = this,
address = $.trim($(document.getElementById(self.opt.addressId)).text());
if( address != '' && address){
this.geocoder.geocode({"address":address}, function (results, status) {
if (status == google.maps.GeocoderStatus.OK){
self.map.setCenter(results[0].geometry.location);
if(!self.marker){
self.marker = new google.maps.Marker({
map: self.map,
position: results[0].geometry.location
});
}else{
self.marker.set("position",results[0].geometry.location);
}
}else{
console.log("!ERORR: Geocode was not successful for the following reason: " + status);
}
});
}else{
this.$toggle.addClass("hidden");
this.status.visible = false;
}
}
};
var map = new Map({
blockId: "address-wrap",
canvasId: "gmap-canvas",
addressId:"address-text",
zoom: 14
});
});
</script>
{% endblock %}

@ -712,7 +712,7 @@ if (EXPO.company){
}
};
// methods
// module methods
//инициализация общих свойств
that.init = function(options) {

Loading…
Cancel
Save