Closed mafioznick closed 5 years ago
`
var datepicker = $('#date').pickadate({ min: 'today', max: false, clear: '', container: '#outlet', onSet: function(item) { if ( 'select' in item ) setTimeout( timepicker.open, 0 ) } }).pickadate('picker')
var timepicker = $('#time').pickatime({ format: 'H:i', interval: 15, min: [9,00], max: [21,00], container: '#outlet',
onRender: function() {
$('ul.pickerlist li').removeClass('pickerlist-item--highlighted');
$('<button>back to date</button>').
on('click', function() {
timepicker.close()
datepicker.open()
}).prependTo( this.$root.find('.picker__box') )
},
onSet: function(item) {
if ( 'select' in item ) setTimeout( function() {
$datetime.
off('focus').
val( datepicker.get() + ' at ' + timepicker.get() ).
focus().
on('focus', datepicker.open)
}, 0 )
}
}).pickatime('picker')
var $datetime = $('#datetime'). on('focus', datepicker.open). on('click', function(event) { event.stopPropagation(); datepicker.open() })
var datepicker2 = $('#date2').pickadate({ min: 'today', max: false, clear: '', container: '#outlet2', onSet: function(item) { if ( 'select' in item ) setTimeout( timepicker2.open, 0 ) } }).pickadate('picker')
var timepicker2 = $('#time2').pickatime({ format: 'H:i', interval: 15, min: [9,00], max: [21,00], container: '#outlet2', onRender: function() { $('ul.pickerlist li').removeClass('pickerlist-item--highlighted');
$('<button>back to date</button>').
on('click', function() {
timepicker2.close()
datepicker2.open()
}).prependTo( this.$root.find('.picker__box') )
},
onSet: function(item) {
if ( 'select' in item ) setTimeout( function() {
$datetime2.
off('focus').
val( datepicker2.get() + ' at ' + timepicker2.get() ).
focus().
on('focus', datepicker2.open)
}, 0 )
}
}).pickatime('picker')
var $datetime2 = $('#datetime2'). on('focus', datepicker2.open). on('click', function(event) { event.stopPropagation(); datepicker2.open() })
// Choose date after chosen date script (only date)
var from_$input = $('#date').pickadate(), frompicker = from$input.pickadate('picker')
var to_$input = $('#date2').pickadate(), topicker = to$input.pickadate('picker')
// Check if there’s a “from” or “to” date to start with. if ( from_picker.get('value') ) { to_picker.set('min', from_picker.get('select')) } if ( to_picker.get('value') ) { from_picker.set('max', to_picker.get('select')) }
// When something is selected, update the “from” and “to” limits.
from_picker.on('set', function(event) {
if ( event.select ) {
to_picker.set('min', from_picker.get('select'))
}
else if ( 'clear' in event ) {
to_picker.set('min', false)
}
})
to_picker.on('set', function(event) {
if ( event.select ) {
from_picker.set('max', to_picker.get('select'))
}
else if ( 'clear' in event ) {
from_picker.set('max', false)
}
})
`
@mafioznick did you find a solution?
Hi, how to add some forms to work with one script? for exmpl id="form1" have id="datetime" and id="datetime2", how to make form id="form2".. how to write in script?
https://codepen.io/oleg-gonarov/pen/roaGVG