1
1
mirror of https://github.com/go-gitea/gitea.git synced 2024-09-22 04:20:56 +02:00

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>
This commit is contained in:
silverwind 2020-03-17 20:08:15 +01:00 committed by GitHub
parent 43c09134a9
commit 85fb33a65f
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 70 additions and 2665 deletions

38
package-lock.json generated
View File

@ -7470,6 +7470,24 @@
"resolved": "https://registry.npmjs.org/import-regex/-/import-regex-1.1.0.tgz",
"integrity": "sha1-pVxS5McFx2XKIQ6SQqBrvMiqf2Y="
},
"imports-loader": {
"version": "0.8.0",
"resolved": "https://registry.npmjs.org/imports-loader/-/imports-loader-0.8.0.tgz",
"integrity": "sha512-kXWL7Scp8KQ4552ZcdVTeaQCZSLW+e6nJfp3cwUMB673T7Hr98Xjx5JK+ql7ADlJUvj1JS5O01RLbKoutN5QDQ==",
"dev": true,
"requires": {
"loader-utils": "^1.0.2",
"source-map": "^0.6.1"
},
"dependencies": {
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
}
}
},
"imurmurhash": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
@ -8122,11 +8140,26 @@
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.4.1.tgz",
"integrity": "sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw=="
},
"jquery-datetimepicker": {
"version": "2.5.21",
"resolved": "https://registry.npmjs.org/jquery-datetimepicker/-/jquery-datetimepicker-2.5.21.tgz",
"integrity": "sha512-wDTpZ4f1PWd1XGaIIE0n6jLynlm+akBJ7/NjaB1bk2UJSS593CHJPZ3+FNEXoyvNVUeBlBC0oX6WTfCyfUhX/w==",
"requires": {
"jquery": ">= 1.7.2",
"jquery-mousewheel": ">= 3.1.13",
"php-date-formatter": "^1.3.4"
}
},
"jquery-migrate": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/jquery-migrate/-/jquery-migrate-3.1.0.tgz",
"integrity": "sha512-u/MtE1ST2pCr3rCyouJG2xMiw/k3OzLNeRKprjKTeHUezCGr0DyEgeXFdqFLmQfxfR5EsVu+mGo/sCcYdiYcIQ=="
},
"jquery-mousewheel": {
"version": "3.1.13",
"resolved": "https://registry.npmjs.org/jquery-mousewheel/-/jquery-mousewheel-3.1.13.tgz",
"integrity": "sha1-BvAzXxbjU6aV5yBr9QUDy1I6buU="
},
"jquery.are-you-sure": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/jquery.are-you-sure/-/jquery.are-you-sure-1.9.0.tgz",
@ -10137,6 +10170,11 @@
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
},
"php-date-formatter": {
"version": "1.3.4",
"resolved": "https://registry.npmjs.org/php-date-formatter/-/php-date-formatter-1.3.4.tgz",
"integrity": "sha1-CaFa4HZroL6xkAwnwewxnvLkVj4="
},
"picomatch": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.1.tgz",

View File

@ -11,6 +11,7 @@
"fomantic-ui": "2.8.4",
"highlight.js": "9.18.1",
"jquery": "3.4.1",
"jquery-datetimepicker": "2.5.21",
"jquery-migrate": "3.1.0",
"jquery.are-you-sure": "1.9.0",
"swagger-ui": "3.25.0",
@ -33,6 +34,7 @@
"eslint-config-airbnb-base": "14.1.0",
"eslint-plugin-import": "2.20.1",
"fast-glob": "3.2.2",
"imports-loader": "0.8.0",
"less-loader": "5.0.0",
"mini-css-extract-plugin": "0.9.0",
"optimize-css-assets-webpack-plugin": "5.0.3",

View File

@ -11,7 +11,7 @@
</thead>
<tbody>
<tr>
<td><a href="./js/index.js">jquery.are-you-sure.js</a></td>
<td><a href="../js/index.js">jquery.are-you-sure.js</a></td>
<td><a href="http://www.freebsd.org/copyright/freebsd-license.html">Expat</a></td>
<td><a href="https://github.com/codedance/jquery.AreYouSure/archive/1.9.0.tar.gz">jquery.areyousure-1.9.0.tar.gz</a></td>
</tr>
@ -61,19 +61,19 @@
<td><a href="https://github.com/Ranks/emojify.js/archive/1.1.0.tar.gz">emojify-1.1.0.tar.gz</a></td>
</tr>
<tr>
<td><a href="./js/dropzone.js">dropzone.js</a></td>
<td><a href="../js/dropzone.js">dropzone.js</a></td>
<td><a href="https://github.com/enyo/dropzone/blob/master/LICENSE">MIT</a></td>
<td><a href="https://github.com/enyo/dropzone/archive/master.tar.gz">dropzone-master.tar.gz</a></td>
</tr>
<tr>
<td><a href="./highlight.js">highlight.js</a></td>
<td><a href="../js/highlight.js">highlight.js</a></td>
<td><a href="https://github.com/highlightjs/highlight.js/blob/master/LICENSE">BSD 3-Clause</a></td>
<td><a href="https://github.com/highlightjs/highlight.js/archive/9.18.0.tar.gz">highlight.js.tar.gz</a></td>
</tr>
<tr>
<td><a href="./plugins/jquery.datetimepicker/jquery.datetimepicker.js">jquery.datetimepicker.js</a></td>
<td><a href="https://github.com/xdan/datetimepicker/blob/master/MIT-LICENSE.txt">Expat</a></td>
<td><a href="https://github.com/xdan/datetimepicker/archive/2.4.5.tar.gz">jquery.datetimepicker-2.4.5.tar.gz</a></td>
<td><a href="../js/datetimepicker.js">jQuery DateTimePicker</a></td>
<td><a href="https://github.com/xdan/datetimepicker/blob/master/MIT-LICENSE.txt">MIT</a></td>
<td><a href="https://github.com/xdan/datetimepicker/archive/master.zip">jquery.datetimepicker.tar.gz</a></td>
</tr>
<tr>
<td><a href="./plugins/jquery.minicolors/jquery.minicolors.min.js">jquery.minicolors.min.js</a></td>

View File

@ -1,19 +0,0 @@
Copyright (c) 2013 http://xdsoft.net
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -88,7 +88,6 @@ func NewMilestone(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.milestones.new")
ctx.Data["PageIsIssueList"] = true
ctx.Data["PageIsMilestones"] = true
ctx.Data["RequireDatetimepicker"] = true
ctx.Data["DateLang"] = setting.DateLang(ctx.Locale.Language())
ctx.HTML(200, tplMilestoneNew)
}
@ -98,7 +97,6 @@ func NewMilestonePost(ctx *context.Context, form auth.CreateMilestoneForm) {
ctx.Data["Title"] = ctx.Tr("repo.milestones.new")
ctx.Data["PageIsIssueList"] = true
ctx.Data["PageIsMilestones"] = true
ctx.Data["RequireDatetimepicker"] = true
ctx.Data["DateLang"] = setting.DateLang(ctx.Locale.Language())
if ctx.HasError() {
@ -136,7 +134,6 @@ func EditMilestone(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.milestones.edit")
ctx.Data["PageIsMilestones"] = true
ctx.Data["PageIsEditMilestone"] = true
ctx.Data["RequireDatetimepicker"] = true
ctx.Data["DateLang"] = setting.DateLang(ctx.Locale.Language())
m, err := models.GetMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
@ -161,7 +158,6 @@ func EditMilestonePost(ctx *context.Context, form auth.CreateMilestoneForm) {
ctx.Data["Title"] = ctx.Tr("repo.milestones.edit")
ctx.Data["PageIsMilestones"] = true
ctx.Data["PageIsEditMilestone"] = true
ctx.Data["RequireDatetimepicker"] = true
ctx.Data["DateLang"] = setting.DateLang(ctx.Locale.Language())
if ctx.HasError() {

View File

@ -26,9 +26,6 @@
{{if .RequireMinicolors}}
<script src="{{StaticUrlPrefix}}/vendor/plugins/jquery.minicolors/jquery.minicolors.min.js"></script>
{{end}}
{{if .RequireDatetimepicker}}
<script src="{{StaticUrlPrefix}}/vendor/plugins/jquery.datetimepicker/jquery.datetimepicker.js"></script>
{{end}}
{{if .RequireU2F}}
<script src="{{StaticUrlPrefix}}/vendor/plugins/u2f/index.js"></script>
{{end}}

View File

@ -87,7 +87,6 @@
AppSubUrl: '{{AppSubUrl}}',
StaticUrlPrefix: '{{StaticUrlPrefix}}',
csrf: '{{.CsrfToken}}',
Datetimepicker: {{if .RequireDatetimepicker}}true{{else}}false{{end}},
HighlightJS: {{if .RequireHighlightJS}}true{{else}}false{{end}},
Minicolors: {{if .RequireMinicolors}}true{{else}}false{{end}},
SimpleMDE: {{if .RequireSimpleMDE}}true{{else}}false{{end}},
@ -120,9 +119,6 @@
</noscript>
{{if .RequireMinicolors}}
<link rel="stylesheet" href="{{StaticUrlPrefix}}/vendor/plugins/jquery.minicolors/jquery.minicolors.css">
{{end}}
{{if .RequireDatetimepicker}}
<link rel="stylesheet" href="{{StaticUrlPrefix}}/vendor/plugins/jquery.datetimepicker/jquery.datetimepicker.css">
{{end}}
<style class="list-search-style"></style>
{{if .PageIsUserProfile}}

View File

@ -10,10 +10,10 @@ var urlsToCache = [
'{{StaticUrlPrefix}}/js/swagger.js?v={{MD5 AppVer}}',
'{{StaticUrlPrefix}}/js/userheatmap.js',
'{{StaticUrlPrefix}}/js/dropzone.js',
'{{StaticUrlPrefix}}/js/datetimepicker.js',
'{{StaticUrlPrefix}}/vendor/plugins/codemirror/addon/mode/loadmode.js',
'{{StaticUrlPrefix}}/vendor/plugins/codemirror/mode/meta.js',
'{{StaticUrlPrefix}}/vendor/plugins/emojify/emojify.custom.js',
'{{StaticUrlPrefix}}/vendor/plugins/jquery.datetimepicker/jquery.datetimepicker.js',
'{{StaticUrlPrefix}}/vendor/plugins/jquery.minicolors/jquery.minicolors.min.js',
'{{StaticUrlPrefix}}/vendor/plugins/simplemde/simplemde.min.js',
@ -22,9 +22,9 @@ var urlsToCache = [
'{{StaticUrlPrefix}}/css/swagger.css?v={{MD5 AppVer}}',
'{{StaticUrlPrefix}}/css/userheatmap.css',
'{{StaticUrlPrefix}}/css/dropzone.css',
'{{StaticUrlPrefix}}/css/datetimepicker.css',
'{{StaticUrlPrefix}}/fomantic/semantic.min.css?v={{MD5 AppVer}}',
'{{StaticUrlPrefix}}/vendor/assets/font-awesome/css/font-awesome.min.css',
'{{StaticUrlPrefix}}/vendor/plugins/jquery.datetimepicker/jquery.datetimepicker.css',
'{{StaticUrlPrefix}}/vendor/plugins/jquery.minicolors/jquery.minicolors.css',
'{{StaticUrlPrefix}}/vendor/plugins/simplemde/simplemde.min.css',
'{{StaticUrlPrefix}}/vendor/plugins/tribute/tribute.css',

View File

@ -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);
}

View File

@ -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('');

View File

@ -1345,12 +1345,12 @@ a.ui.labels .label:hover {
}
}
.xdsoft_datetimepicker {
body .xdsoft_datetimepicker {
background: #2a2e39;
border: 1px solid #4c505c;
color: #9e9e9e;
.xdsoft_mounthpicker {
.xdsoft_monthpicker {
height: 36px;
background: #464c5d;
margin: -2px -8px 2px;
@ -1416,7 +1416,6 @@ a.ui.labels .label:hover {
background: #a0cc75;
color: #000000;
}
}
}

View File

@ -85,6 +85,10 @@ module.exports = {
exclude: /node_modules/,
loader: 'vue-loader',
},
{
test: require.resolve('jquery-datetimepicker'),
use: 'imports-loader?define=>false,exports=>false',
},
{
test: /\.js$/,
exclude: /node_modules/,