mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Remove datetimepicker directive + default values
This commit is contained in:
committed by
Konrad
parent
5c83a3277e
commit
fb0d922d73
@@ -1,21 +1,4 @@
|
||||
angular.module('admin.orderCycles', ['ngTagsInput', 'admin.indexUtils', 'admin.enterprises'])
|
||||
.directive 'datetimepicker', ($timeout, $parse) ->
|
||||
require: "ngModel"
|
||||
link: (scope, element, attrs, ngModel) ->
|
||||
$timeout ->
|
||||
fp = flatpickr(element, Object.assign({},
|
||||
window.FLATPICKR_DATETIME_DEFAULT, {
|
||||
onOpen: (selectedDates, dateStr, instance) ->
|
||||
instance.setDate(ngModel.$modelValue)
|
||||
instance.input.dispatchEvent(new Event('focus', { bubbles: true }));
|
||||
}));
|
||||
fp.minuteElement.addEventListener "keyup", (e) ->
|
||||
if !isNaN(event.target.value)
|
||||
fp.setDate(fp.selectedDates[0].setMinutes(e.target.value), true)
|
||||
fp.hourElement.addEventListener "keyup", (e) ->
|
||||
if !isNaN(event.target.value)
|
||||
fp.setDate(fp.selectedDates[0].setHours(e.target.value), true)
|
||||
|
||||
.directive 'ofnOnChange', ->
|
||||
(scope, element, attrs) ->
|
||||
element.bind 'change', ->
|
||||
|
||||
@@ -1,70 +1,4 @@
|
||||
$(document).ready(function() {
|
||||
var onClickButtons = function(index, fp) {
|
||||
var date;
|
||||
// Memorize index used for the 'Close' button
|
||||
// (currently it has index of 1)
|
||||
var closeButtonIndex = 1;
|
||||
switch (index) {
|
||||
case 0:
|
||||
date = new Date();
|
||||
break;
|
||||
case closeButtonIndex:
|
||||
fp.close();
|
||||
break;
|
||||
}
|
||||
// Set the date unless clicked button was the 'Close' one
|
||||
if (index != closeButtonIndex) {
|
||||
fp.setDate(date, true);
|
||||
}
|
||||
}
|
||||
window.FLATPICKR_DATE_DEFAULT = {
|
||||
altInput: true,
|
||||
altFormat: Spree.translations.flatpickr_date_format,
|
||||
dateFormat: "Y-m-d",
|
||||
locale: I18n.base_locale,
|
||||
plugins: [
|
||||
ShortcutButtonsPlugin({
|
||||
button: [
|
||||
{
|
||||
label: Spree.translations.today
|
||||
},
|
||||
{
|
||||
label: Spree.translations.close
|
||||
}
|
||||
],
|
||||
label: "or",
|
||||
onClick: onClickButtons
|
||||
}),
|
||||
labelPlugin({})
|
||||
]
|
||||
}
|
||||
window.FLATPICKR_DATETIME_DEFAULT = Object.assign(
|
||||
{},
|
||||
window.FLATPICKR_DATE_DEFAULT,
|
||||
{
|
||||
altInput: true,
|
||||
altFormat: Spree.translations.flatpickr_datetime_format,
|
||||
dateFormat: "Y-m-d H:i",
|
||||
enableTime: true,
|
||||
time_24hr: true,
|
||||
plugins: [
|
||||
ShortcutButtonsPlugin({
|
||||
button: [
|
||||
{
|
||||
label: Spree.translations.now
|
||||
},
|
||||
{
|
||||
label: Spree.translations.close
|
||||
}
|
||||
],
|
||||
label: "or",
|
||||
onClick: onClickButtons
|
||||
}),
|
||||
labelPlugin({})
|
||||
]
|
||||
}
|
||||
);
|
||||
flatpickr(".datetimepicker", window.FLATPICKR_DATETIME_DEFAULT);
|
||||
$('a.close').click(function(event){
|
||||
event.preventDefault();
|
||||
$(this).parent().slideUp(250);
|
||||
|
||||
Reference in New Issue
Block a user