stock.js
2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
$(function() {
$(document)
.on("click","#add-data",function () {
var count = $(this).data('count');
$("<div><label>Дата</label><input type='date' name='Shop[modeStr][data]["+count+"][data]'><label>c</label><input type='time' size='10' name='Shop[modeStr][data]["+count+"][from]'><label>до</label><input type='time' name='Shop[modeStr][data]["+count+"][to]'><label>выходной</label><input type='checkbox' name='Shop[modeStr][data]["+count+"][off]'><a class='delete-day-item'>Удалить</a></div>").insertBefore($(this))
count+=1;
$(this).data('count', count);
});
$(document)
.on(
'click', '.delete-day-item', function() {
var count = $("#add-data").data('count');
$(this)
.parent()
.remove();
count-=1;
$("#add-data").data('count', count);
}
);
$(document).on( '#shoplang-2-address','blur', function () {
var address = $("#shoplang-2-address").val() + " "+$("#select2-w2-container").text();
console.log(address);
geocoder.geocode( { 'address': address}, function(results, status) {
console.log(status);
if (status == google.maps.GeocoderStatus.OK) {
//console.log(results[0].geometry.location.lat()+" "+results[0].geometry.location.lng());
$("#lat").val(results[0].geometry.location.lat());
$("#lng").val(results[0].geometry.location.lng());
var marker = AddMarker();
marker.setMap(map);
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
});
var start_position = new google.maps.LatLng('50.435', '30.60');
var styles = [
{
stylers: [
{saturation: -100}
]
}
];
var settings = {
styles: styles,
zoom: 12,
scrollwheel: false,
center: start_position,
mapTypeControl: true,
mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
navigationControl: false,
navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
scaleControl: true,
streetViewControl: true,
rotateControl: true,
zoomControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), settings);
if ($("#lat").val() !== "" && $("#lng").val() !== ""){
var marker = AddMarker();
marker.setMap(map);
}
var geocoder = new google.maps.Geocoder();
function AddMarker(){
var newLat = $("#lat").val();
var newLng = $("#lng").val();
var coords = new google.maps.LatLng(newLat, newLng);
var marker = new google.maps.Marker({
position: coords
});
return marker;
}
});