aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2020-03-17 20:08:15 +0100
committerGitHub <noreply@github.com>2020-03-17 15:08:15 -0400
commit85fb33a65ffa9d5f0c073a01fcb5a7ef1b7311a4 (patch)
tree336f0d1af2a5ab1180d84f23c1ca58351d69222c /web_src/js
parent43c09134a972dc421aa06fb303697671c828cf67 (diff)
downloadgitea-85fb33a65ffa9d5f0c073a01fcb5a7ef1b7311a4.tar.gz
gitea-85fb33a65ffa9d5f0c073a01fcb5a7ef1b7311a4.zip
move jquery-datetimepicker to npm/webpack (#10713)
- update to latest version and move to npm - adapt for api changes and css class rename - add specificity to arc-green rules as dependency css now loads later - use imports-loader to make it load correctly - fix some wrong paths in librejs Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'web_src/js')
-rw-r--r--web_src/js/features/datetimepicker.js8
-rw-r--r--web_src/js/index.js14
2 files changed, 16 insertions, 6 deletions
diff --git a/web_src/js/features/datetimepicker.js b/web_src/js/features/datetimepicker.js
new file mode 100644
index 0000000000..fb9a75a57a
--- /dev/null
+++ b/web_src/js/features/datetimepicker.js
@@ -0,0 +1,8 @@
+export default async function initDateTimePicker(locale) {
+ await Promise.all([
+ import(/* webpackChunkName: "datetimepicker" */'jquery-datetimepicker'),
+ import(/* webpackChunkName: "datetimepicker" */'jquery-datetimepicker/build/jquery.datetimepicker.min.css'),
+ ]);
+
+ $.datetimepicker.setLocale(locale);
+}
diff --git a/web_src/js/index.js b/web_src/js/index.js
index 455e6cc3ff..2db5b08b8b 100644
--- a/web_src/js/index.js
+++ b/web_src/js/index.js
@@ -15,6 +15,7 @@ import initHighlight from './features/highlight.js';
import initGitGraph from './features/gitgraph.js';
import initClipboard from './features/clipboard.js';
import initUserHeatmap from './features/userheatmap.js';
+import initDateTimePicker from './features/datetimepicker.js';
import createDropzone from './features/dropzone.js';
import ActivityTopAuthors from './components/ActivityTopAuthors.vue';
@@ -633,7 +634,7 @@ function initIssueComments() {
});
}
-function initRepository() {
+async function initRepository() {
if ($('.repository').length === 0) {
return;
}
@@ -731,15 +732,16 @@ function initRepository() {
// Milestones
if ($('.repository.new.milestone').length > 0) {
const $datepicker = $('.milestone.datepicker');
+
+ await initDateTimePicker($datepicker.data('lang'));
+
$datepicker.datetimepicker({
- lang: $datepicker.data('lang'),
inline: true,
timepicker: false,
startDate: $datepicker.data('start-date'),
- formatDate: 'Y-m-d',
- onSelectDate(ct) {
- $('#deadline').val(ct.dateFormat('Y-m-d'));
- }
+ onSelectDate(date) {
+ $('#deadline').val(date.toISOString().substring(0, 10));
+ },
});
$('#clear-date').click(() => {
$('#deadline').val('');