Remove remnants of moment.js
This commit is contained in:
parent
480f0ed8a7
commit
f3b8c2692c
|
@ -9,6 +9,14 @@ release channel, you can take advantage of these new features and fixes.
|
||||||
|
|
||||||
## Code Quality/Technical Changes
|
## Code Quality/Technical Changes
|
||||||
|
|
||||||
|
- The `moment.js` library, rather bulky in size and now no longer recommended for new application development, has been
|
||||||
|
replaced across the application with the `luxon` library, which relies instead on new JavaScript functionality built
|
||||||
|
directly into the browser to do date/time normalization and localization.
|
||||||
|
|
||||||
|
- Our Vue component build process has been completely overhauled to be fully independent of our legacy asset management;
|
||||||
|
if you're contributing Vue components to our codebase, it should much more intuitively match the experience you would
|
||||||
|
expect from other Vue-based apps using Webpack than before.
|
||||||
|
|
||||||
- A number of security fixes are being incorporated into the software as of this version. See below for details.
|
- A number of security fixes are being incorporated into the software as of this version. See below for details.
|
||||||
|
|
||||||
## Bug Fixes
|
## Bug Fixes
|
||||||
|
|
|
@ -190,32 +190,38 @@ return [
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
// Moment standalone (with locales)
|
'luxon' => [
|
||||||
'moment' => [
|
|
||||||
'order' => 8,
|
'order' => 8,
|
||||||
'files' => [
|
'files' => [
|
||||||
'js' => [
|
'js' => [
|
||||||
[
|
[
|
||||||
'src' => 'dist/lib/moment/moment.min.js',
|
'src' => 'dist/lib/luxon/luxon.min.js',
|
||||||
],
|
|
||||||
[
|
|
||||||
'src' => 'dist/lib/moment/locales.min.js',
|
|
||||||
'charset' => 'UTF-8',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'src' => 'dist/lib/moment-timezone/moment-timezone-with-data-10-year-range.min.js',
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'inline' => [
|
'inline' => [
|
||||||
'js' => [
|
'js' => [
|
||||||
function (Request $request) {
|
function (Request $request) {
|
||||||
return 'moment.locale(App.locale_with_dashes);';
|
return <<<'JS'
|
||||||
|
luxon.Settings.defaultLocale = App.locale_with_dashes;
|
||||||
|
luxon.Settings.defaultZoneName = 'UTC';
|
||||||
|
JS;
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'humanize-duration' => [
|
||||||
|
'order' => 8,
|
||||||
|
'files' => [
|
||||||
|
'js' => [
|
||||||
|
[
|
||||||
|
'src' => 'dist/lib/humanize-duration/humanize-duration.js',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
'clipboard' => [
|
'clipboard' => [
|
||||||
'order' => 10,
|
'order' => 10,
|
||||||
'files' => [
|
'files' => [
|
||||||
|
|
|
@ -79,25 +79,14 @@ var jsFiles = {
|
||||||
'node_modules/select2/dist/js/select2.full.min.js'
|
'node_modules/select2/dist/js/select2.full.min.js'
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
'moment': {
|
'luxon': {
|
||||||
base: 'node_modules/moment/min',
|
|
||||||
files: [
|
files: [
|
||||||
'node_modules/moment/min/moment.min.js',
|
'node_modules/luxon/build/global/luxon.min.js'
|
||||||
'node_modules/moment/min/locales.min.js'
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
'moment-timezone': {
|
'humanize-duration': {
|
||||||
base: 'node_modules/moment-timezone/builds',
|
|
||||||
files: [
|
files: [
|
||||||
'node_modules/moment-timezone/builds/moment-timezone-with-data-10-year-range.min.js'
|
'node_modules/humanize-duration/humanize-duration.js'
|
||||||
]
|
|
||||||
},
|
|
||||||
'codemirror': {
|
|
||||||
base: null,
|
|
||||||
files: [
|
|
||||||
'node_modules/codemirror/lib/codemirror.*',
|
|
||||||
'node_modules/codemirror/mode/css/css.js',
|
|
||||||
'node_modules/codemirror/mode/javascript/javascript.js'
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
'clipboard': {
|
'clipboard': {
|
||||||
|
|
|
@ -1,29 +1,24 @@
|
||||||
$(function() {
|
$(function () {
|
||||||
|
|
||||||
moment.relativeTimeThreshold('ss', 1);
|
|
||||||
moment.relativeTimeRounding(function (value) {
|
|
||||||
return Math.round(value * 10) / 10;
|
|
||||||
});
|
|
||||||
|
|
||||||
$('time[data-content]').each(function () {
|
$('time[data-content]').each(function () {
|
||||||
let tz_display = $(this).data('content');
|
let tz_display = $(this).data('content');
|
||||||
$(this).text(moment.unix(tz_display).format('lll'));
|
$(this).text(luxon.DateTime.fromSeconds(tz_display).toLocaleString(luxon.DateTime.DATETIME_SHORT));
|
||||||
});
|
});
|
||||||
|
|
||||||
$('time[data-duration]').each(function () {
|
$('time[data-duration]').each(function () {
|
||||||
$(this).text(moment.duration($(this).data('duration'), "seconds").humanize(true));
|
$(this).text(humanizeDuration($(this).data('duration') * 1000, {locale: App.locale_short}));
|
||||||
});
|
});
|
||||||
|
|
||||||
$('span[data-file-size]').each(function() {
|
$('span[data-file-size]').each(function () {
|
||||||
let original_size = $(this).data('file-size');
|
let original_size = $(this).data('file-size');
|
||||||
$(this).text(formatFileSize(original_size));
|
$(this).text(formatFileSize(original_size));
|
||||||
});
|
});
|
||||||
|
|
||||||
function formatFileSize(bytes) {
|
function formatFileSize(bytes) {
|
||||||
var s = ['bytes', 'KB','MB','GB','TB','PB','EB'];
|
var s = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'];
|
||||||
for(var pos = 0;bytes >= 1000; pos++,bytes /= 1000);
|
for (var pos = 0; bytes >= 1000; pos++, bytes /= 1000) ;
|
||||||
var d = Math.round(bytes*10);
|
var d = Math.round(bytes * 10);
|
||||||
return pos ? [parseInt(d/10),".",d%10," ",s[pos]].join('') : bytes + ' bytes';
|
return pos ? [parseInt(d / 10), ".", d % 10, " ", s[pos]].join('') : bytes + ' bytes';
|
||||||
}
|
}
|
||||||
|
|
||||||
var log_modal = $('#modal-log-view');
|
var log_modal = $('#modal-log-view');
|
||||||
|
|
|
@ -11,7 +11,8 @@ $this->layout('main', [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$assets
|
$assets
|
||||||
->load('moment')
|
->load('luxon')
|
||||||
|
->load('humanize-duration')
|
||||||
->addInlineJs($this->fetch('admin/backups/index.js'), 99);
|
->addInlineJs($this->fetch('admin/backups/index.js'), 99);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
jQuery(function($) {
|
jQuery(function ($) {
|
||||||
moment.relativeTimeThreshold('ss', 1);
|
$('time[data-duration]').each(function () {
|
||||||
moment.relativeTimeRounding(Math.round);
|
$(this).text(humanizeDuration($(this).data('duration') * 1000, {locale: App.locale_short}));
|
||||||
|
|
||||||
$('time').each(function () {
|
|
||||||
$(this).text(moment.duration(0-$(this).data('duration'), "seconds").humanize(true));
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,7 +11,7 @@ $this->layout('main', [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$assets
|
$assets
|
||||||
->load('moment')
|
->load('humanize-duration')
|
||||||
->addInlineJs($this->fetch('admin/index/index.js'), 99);
|
->addInlineJs($this->fetch('admin/index/index.js'), 99);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
$(function() {
|
$(function () {
|
||||||
moment.relativeTimeThreshold('ss', 1);
|
$('time[data-content]').each(function () {
|
||||||
moment.relativeTimeRounding(function(value) { return Math.round(value * 10) / 10; });
|
|
||||||
|
|
||||||
$('time[data-content]').each(function() {
|
|
||||||
let tz_display = $(this).data('content');
|
let tz_display = $(this).data('content');
|
||||||
$(this).text(moment(tz_display).format('LT'));
|
$(this).text(luxon.DateTime.fromSeconds(tz_display).toLocaleString(luxon.DateTime.TIME_SIMPLE));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,7 +6,7 @@ $this->layout('main', [
|
||||||
|
|
||||||
/** @var \App\Assets $assets */
|
/** @var \App\Assets $assets */
|
||||||
$assets
|
$assets
|
||||||
->load('moment')
|
->load('luxon')
|
||||||
->addInlineJs($this->fetch('admin/relays/index.js'));
|
->addInlineJs($this->fetch('admin/relays/index.js'));
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue