mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
prettier --write
This commit is contained in:
parent
450528ff00
commit
8a0be3212d
164 changed files with 7053 additions and 9008 deletions
|
|
@ -1,26 +1,32 @@
|
|||
|
||||
import window from 'window';
|
||||
import _ from '_';
|
||||
import $ from '$';
|
||||
import moment from 'moment';
|
||||
import {i18n} from 'Common/Translator';
|
||||
import { i18n } from 'Common/Translator';
|
||||
|
||||
let _moment = null;
|
||||
let _momentNow = 0;
|
||||
|
||||
const updateMomentNow = _.debounce(() => {
|
||||
_moment = moment();
|
||||
}, 500, true);
|
||||
const updateMomentNow = _.debounce(
|
||||
() => {
|
||||
_moment = moment();
|
||||
},
|
||||
500,
|
||||
true
|
||||
);
|
||||
|
||||
const updateMomentNowUnix = _.debounce(() => {
|
||||
_momentNow = moment().unix();
|
||||
}, 500, true);
|
||||
const updateMomentNowUnix = _.debounce(
|
||||
() => {
|
||||
_momentNow = moment().unix();
|
||||
},
|
||||
500,
|
||||
true
|
||||
);
|
||||
|
||||
/**
|
||||
* @returns {moment}
|
||||
*/
|
||||
export function momentNow()
|
||||
{
|
||||
export function momentNow() {
|
||||
updateMomentNow();
|
||||
return _moment || moment();
|
||||
}
|
||||
|
|
@ -28,8 +34,7 @@ export function momentNow()
|
|||
/**
|
||||
* @returns {number}
|
||||
*/
|
||||
export function momentNowUnix()
|
||||
{
|
||||
export function momentNowUnix() {
|
||||
updateMomentNowUnix();
|
||||
return _momentNow || 0;
|
||||
}
|
||||
|
|
@ -38,29 +43,31 @@ export function momentNowUnix()
|
|||
* @param {number} date
|
||||
* @returns {string}
|
||||
*/
|
||||
export function searchSubtractFormatDateHelper(date)
|
||||
{
|
||||
return momentNow().clone().subtract(date, 'days').format('YYYY.MM.DD');
|
||||
export function searchSubtractFormatDateHelper(date) {
|
||||
return momentNow()
|
||||
.clone()
|
||||
.subtract(date, 'days')
|
||||
.format('YYYY.MM.DD');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} m
|
||||
* @returns {string}
|
||||
*/
|
||||
function formatCustomShortDate(m)
|
||||
{
|
||||
function formatCustomShortDate(m) {
|
||||
const now = momentNow();
|
||||
if (m && now)
|
||||
{
|
||||
switch (true)
|
||||
{
|
||||
if (m && now) {
|
||||
switch (true) {
|
||||
case 4 >= now.diff(m, 'hours'):
|
||||
return m.fromNow();
|
||||
case now.format('L') === m.format('L'):
|
||||
return i18n('MESSAGE_LIST/TODAY_AT', {
|
||||
TIME: m.format('LT')
|
||||
});
|
||||
case now.clone().subtract(1, 'days').format('L') === m.format('L'):
|
||||
case now
|
||||
.clone()
|
||||
.subtract(1, 'days')
|
||||
.format('L') === m.format('L'):
|
||||
return i18n('MESSAGE_LIST/YESTERDAY_AT', {
|
||||
TIME: m.format('LT')
|
||||
});
|
||||
|
|
@ -78,29 +85,23 @@ function formatCustomShortDate(m)
|
|||
* @param {string} formatStr
|
||||
* @returns {string}
|
||||
*/
|
||||
export function format(timeStampInUTC, formatStr)
|
||||
{
|
||||
|
||||
let
|
||||
m = null,
|
||||
export function format(timeStampInUTC, formatStr) {
|
||||
let m = null,
|
||||
result = '';
|
||||
|
||||
const now = momentNowUnix();
|
||||
|
||||
timeStampInUTC = 0 < timeStampInUTC ? timeStampInUTC : (0 === timeStampInUTC ? now : 0);
|
||||
timeStampInUTC = 0 < timeStampInUTC ? timeStampInUTC : 0 === timeStampInUTC ? now : 0;
|
||||
timeStampInUTC = now < timeStampInUTC ? now : timeStampInUTC;
|
||||
|
||||
m = 0 < timeStampInUTC ? moment.unix(timeStampInUTC) : null;
|
||||
|
||||
if (m && 1970 === m.year())
|
||||
{
|
||||
if (m && 1970 === m.year()) {
|
||||
m = null;
|
||||
}
|
||||
|
||||
if (m)
|
||||
{
|
||||
switch (formatStr)
|
||||
{
|
||||
if (m) {
|
||||
switch (formatStr) {
|
||||
case 'FROMNOW':
|
||||
result = m.fromNow();
|
||||
break;
|
||||
|
|
@ -123,26 +124,20 @@ export function format(timeStampInUTC, formatStr)
|
|||
* @param {Object} element
|
||||
* @returns {void}
|
||||
*/
|
||||
export function momentToNode(element)
|
||||
{
|
||||
let
|
||||
key = '',
|
||||
export function momentToNode(element) {
|
||||
let key = '',
|
||||
time = 0;
|
||||
const
|
||||
$el = $(element);
|
||||
const $el = $(element);
|
||||
|
||||
time = $el.data('moment-time');
|
||||
if (time)
|
||||
{
|
||||
if (time) {
|
||||
key = $el.data('moment-format');
|
||||
if (key)
|
||||
{
|
||||
if (key) {
|
||||
$el.text(format(time, key));
|
||||
}
|
||||
|
||||
key = $el.data('moment-format-title');
|
||||
if (key)
|
||||
{
|
||||
if (key) {
|
||||
$el.attr('title', format(time, key));
|
||||
}
|
||||
}
|
||||
|
|
@ -151,8 +146,7 @@ export function momentToNode(element)
|
|||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
export function reload()
|
||||
{
|
||||
export function reload() {
|
||||
_.defer(() => {
|
||||
$('.moment', window.document).each((index, item) => {
|
||||
momentToNode(item);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue