Blame view

web/js/stock.js 3.16 KB
a874d14e   Anastasia   stock
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  $(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);
              }
          );
557ac29e   Anastasia   stock map
22
      $(document).on('blur', '#shoplang-2-address',  function () {
a874d14e   Anastasia   stock
23
24
25
26
27
          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) {
557ac29e   Anastasia   stock map
28
  
a874d14e   Anastasia   stock
29
30
                  $("#lat").val(results[0].geometry.location.lat());
                  $("#lng").val(results[0].geometry.location.lng());
a874d14e   Anastasia   stock
31
32
                  var marker = AddMarker();
                  marker.setMap(map);
bb3c80f4   Anastasia   stock map
33
                  map.setCenter(marker.getPosition());
a874d14e   Anastasia   stock
34
35
36
37
38
              } else {
                  alert("Geocode was not successful for the following reason: " + status);
              }
          });
      });
1b0b689c   Anastasia   stock map
39
40
41
42
  
  
  
  
557ac29e   Anastasia   stock map
43
44
45
46
47
48
49
50
51
52
53
      var lat, lng;
      if ($("#lat").val() !== "" && $("#lng").val() !== ""){
          lat = $("#lat").val();
          lng = $("#lng").val();
      }else{
           lat = '50.435';
           lng =  '30.60';
      }
      console.log(lat);
      console.log(lng);
      var start_position = new google.maps.LatLng(lat, lng);
a874d14e   Anastasia   stock
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
      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;
      }
  });