69 lines
2.1 KiB
CoffeeScript
69 lines
2.1 KiB
CoffeeScript
$( ->
|
|
week_days_container = $('#week_days-group')
|
|
$('.week-day-select').each( (i)->
|
|
select = $(this)
|
|
toggle = $('<button type="button" class="btn"></button>')
|
|
toggle.attr('data-t', 'product_category.week_days.abbreviation.'+select.data('day'))
|
|
toggle.addClass('active') if select.val() == '1'
|
|
week_days_container.append(toggle)
|
|
toggle.click( -> select.val(Math.abs(select.val() - 1)))
|
|
)
|
|
|
|
$('#full_day-controller').each ->
|
|
control = $('#product_category_full_day')
|
|
unless control.is(':checked')
|
|
$(@).addClass('icon-white')
|
|
$('#sub-day-container').removeClass('hide')
|
|
$(@).click ->
|
|
if control.is(':checked')
|
|
control.prop 'checked', false
|
|
$(@).addClass 'icon-white'
|
|
$('#sub-day-container').removeClass('hide')
|
|
else
|
|
control.prop 'checked', true
|
|
$(@).removeClass 'icon-white'
|
|
$('#sub-day-container').addClass('hide')
|
|
|
|
|
|
# GOOGLE LOCATION PICKER
|
|
$("input.location_picker").each( (i)->
|
|
#return if typeof(google) == 'undefined'
|
|
location_input = $(this)
|
|
map_div = $('<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: 13
|
|
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'
|
|
)
|
|
google.maps.event.addListener(map, 'click', (point)->
|
|
marker.setPosition(point.latLng)
|
|
location_input.val point.latLng.lat() + ','+ point.latLng.lng()
|
|
)
|
|
)
|
|
)
|