-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from open-sausages/pulls/4.0/6626-remove-jquer…
…y-datepicker HTML5 Date and Time Fields
- Loading branch information
Showing
29 changed files
with
15,955 additions
and
16,807 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8872,7 +8872,7 @@ fieldset{ | |
} | ||
|
||
.field input.time{ | ||
width:88px; | ||
width:112px; | ||
} | ||
|
||
.field.remove-splitter{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"minify": true, | ||
"options": [ | ||
"setClasses" | ||
], | ||
"feature-detects": [ | ||
"inputtypes" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,58 @@ | ||
import $ from 'jQuery'; | ||
import i18n from 'i18n'; | ||
import moment from 'moment'; | ||
import modernizr from 'modernizr'; | ||
|
||
// entwine also required, but can't be included more than once without error | ||
require('../../../thirdparty/jquery-ui/jquery-ui.js'); | ||
require('../../../thirdparty/jquery-entwine/dist/jquery.entwine-dist.js'); | ||
|
||
$.fn.extend({ | ||
ssDatepicker: function(opts) { | ||
return $(this).each(function() { | ||
|
||
// disabled, readonly or already applied | ||
if ($(this).prop('disabled') || $(this).prop('readonly') || $(this).hasClass('hasDatepicker')) { | ||
$.entwine('ss', function($) { | ||
$('input[type=date]').entwine({ | ||
onadd: function () { | ||
// Browser supports type=date natively | ||
if (modernizr.inputtypes.date) { | ||
return; | ||
} | ||
|
||
$(this).siblings("button").addClass("ui-icon ui-icon-calendar"); | ||
|
||
let config = $.extend( | ||
{}, | ||
opts || {}, | ||
$(this).data(), | ||
$(this).data('jqueryuiconfig') | ||
); | ||
if(!config.showcalendar) { | ||
// disabled, readonly or already applied | ||
if (this.prop('disabled') || this.prop('readonly') || this.hasClass('hasDatepicker')) { | ||
return; | ||
} | ||
|
||
if(config.locale && $.datepicker.regional[config.locale]) { | ||
// Note: custom config overrides regional settings | ||
config = $.extend({}, $.datepicker.regional[config.locale], config); | ||
} | ||
// Duplicate input field to store ISO value | ||
const hiddenInput = $('<input/>', { type: 'hidden', name: this.attr('name'), value: this.val() }); | ||
this.parent().append(hiddenInput); | ||
|
||
// Initialize and open a datepicker | ||
// live() doesn't have "onmatch", and jQuery.entwine is a bit too heavyweight | ||
// for this, so we need to do this onclick. | ||
$(this).datepicker(config); | ||
}); | ||
} | ||
}); | ||
|
||
$(document).on("click", ".field.date input.text,input.text.date", function() { | ||
$(this).ssDatepicker(); | ||
// Avoid original field being saved | ||
this.removeAttr('name'); | ||
|
||
if($(this).data('datepicker')) { | ||
$(this).datepicker('show'); | ||
} | ||
// Set localised value in original field | ||
moment.locale(this.attr('lang')); | ||
const isoDate = this.val(); | ||
let localDate = ''; | ||
if (isoDate) { | ||
localDate = moment(isoDate).format('L'); | ||
} | ||
this.val(localDate); | ||
|
||
// Set useful localised placeholder | ||
this.attr( | ||
'placeholder', | ||
i18n._t('DateField.DateFormatExample') + ': ' + moment().endOf('month').format('L') | ||
); | ||
|
||
this.updateValue(); | ||
}, | ||
onchange: function () { | ||
// TODO Validation | ||
this.updateValue(); | ||
}, | ||
updateValue: function () { | ||
const localDate = this.val(); | ||
let isoDate = ''; | ||
if (localDate) { | ||
isoDate = moment(localDate, 'L').format('YYYY-MM-DD'); | ||
} | ||
this.parent().find('input[type=hidden]').val(isoDate); | ||
}, | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-da.js
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-de.js
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-en-GB.js
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-en.js
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-es.js
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
thirdparty/jquery-ui/datepicker/i18n/jquery.ui.datepicker-fr.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.