$ -> $('.week-day-toggle').each -> select = $('#week-day-select-'+$(@).data('day')) $(@).addClass(if select.val() == '1' then 'active' else 'inactive') $(@).click -> new_val = Math.abs(select.val() - 1) select.val new_val if new_val == 1 $(@).addClass('active') $(@).removeClass('inactive') else $(@).addClass('inactive') $(@).removeClass('active') $('#full_day-controller').each -> control = $('#product_category_full_day') if control.is(':checked') $('#sub-day-container').addClass('hide') $(@).addClass('active') else $(@).removeClass 'active' $('#sub-day-container').removeClass('hide') $(@).click -> if control.is(':checked') control.prop 'checked', false $(@).removeClass 'active' $('#sub-day-container').removeClass('hide') else $(@).addClass 'active' control.prop 'checked', true $('#sub-day-container').addClass('hide') if Qstorage.getItem('message') container = $('.alert-success'); msg_finder = Qstorage.getItem('message'); msg_finder = 'messages.'+msg_finder if msg_finder.indexOf('.') == -1 container.find('div').text(t(msg_finder)) container.show() Qstorage.removeItem('message') setupTranslations() $('[data-boolean]').each -> $(@).addClass(if $(@).data('boolean') then 'boolean-true' else 'boolean-false') # Hide alert boxes on click $(document).on 'click', '.general-alerts .alert-box', -> $(@).slideUp() $(document).on 'click', '.supplier-is-closed', -> $(@).slideUp() # GOOGLE LOCATION PICKER ### $("input.location_picker").each (i)-> #return if typeof(google) == 'undefined' iconBase = 'https://maps.google.com/mapfiles/kml/' location_input = $(this) map_div = $('
').addClass("location_picker_map") location_input.before(map_div) #this.parentNode.insertBefore(map_div, this) location_input.hide() lat = 52.07436798080633 lng = 4.316811561584473 if (this.value.split(',').length == 2) values = this.value.split(',') lat = values[0] lng = values[1] center = new google.maps.LatLng(lat,lng) mapOptions = zoom: 15 center: center mapTypeId: google.maps.MapTypeId.ROADMAP, zoomControl: true zoomControlOptions: style: google.maps.ZoomControlStyle.SMALL mapTypeControl: false panControl: false scaleControl: false streetViewControl: false map = new google.maps.Map(map_div.get(0), mapOptions) marker = new google.maps.Marker( position: center map: map title: 'Location' icon: '/assets/icons/maps_location.png' ) google.maps.event.addListener(map, 'click', (point)-> marker.setPosition(point.latLng) location_input.val point.latLng.lat() + ','+ point.latLng.lng() ) search_field = $('') search_field.addClass('location_picker_search') autocomplete = new google.maps.places.Autocomplete(search_field.get(0)) autocomplete.bindTo('bounds', map) search_field.keypress( (e) -> if e.which == 13 e.preventDefault() ) window.autocomplete = autocomplete map_div.before(search_field) infowindow = new google.maps.InfoWindow() search_marker = new google.maps.Marker({map: map, icon: iconBase + 'shapes/placemark_circle.png'}) google.maps.event.addListener autocomplete, 'place_changed', -> infowindow.close() search_marker.setVisible(false) place = autocomplete.getPlace() return unless place.geometry #if place.geometry.viewport # map.fitBounds(place.geometry.viewport) #else map.setCenter(place.geometry.location) map.setZoom(17) image = url: place.icon size: new google.maps.Size(71, 71) origin: new google.maps.Point(0, 0) anchor: new google.maps.Point(17, 34) scaledSize: new google.maps.Size(35, 35) #search_marker.setIcon(image) search_marker.setPosition(place.geometry.location) search_marker.setVisible(true) address = '' if place.address_components address = [ (place.address_components[0] && place.address_components[0].short_name || ''), (place.address_components[1] && place.address_components[1].short_name || ''), (place.address_components[2] && place.address_components[2].short_name || '') ].join(' ') infowindow.setContent('
' + place.name + '
' + address + '
') infowindow.open(map, search_marker) # end google location map ###