Remove Moment.js.

This commit is contained in:
Lars Jung 2015-04-11 17:38:49 +02:00
parent 488e321613
commit bcfdec87c9
6 changed files with 54 additions and 17 deletions

View file

@ -2,9 +2,12 @@
* fixes some styles in IE10
* resets IE edge mode
* fixes preview bottom bar for small screen widths
* use wide links in tree view
* updates build process
* updates h5bp styles to 5.1.0
* updates `normalize.css` to 3.0.3
* updates build process
* removes `Moment.js`
## v0.27.0 - *2015-04-06*

View file

@ -1,4 +1,4 @@
modulejs.define('core/format', ['_', 'moment'], function (_, moment) {
modulejs.define('core/format', ['_'], function (_) {
var decimalMetric = {
t: 1000.0,
@ -11,6 +11,21 @@ modulejs.define('core/format', ['_', 'moment'], function (_, moment) {
u: ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']
};
var defaultMetric = decimalMetric;
var datePatterns = [
[/YYYY/, 'Y', 4],
[/YY/, 'Y', 2],
[/Y/, 'Y', 0],
[/MM/, 'M', 2],
[/M/, 'M', 0],
[/DD/, 'D', 2],
[/D/, 'D', 0],
[/HH/, 'H', 2],
[/H/, 'H', 0],
[/mm/, 'm', 2],
[/m/, 'm', 0],
[/ss/, 's', 2],
[/s/, 's', 0]
];
var defaultDateFormat = 'YYYY-MM-DD HH:mm';
@ -42,9 +57,37 @@ modulejs.define('core/format', ['_', 'moment'], function (_, moment) {
defaultDateFormat = dateFormat;
}
function formatDate(millis) {
function formatNumber(number, padding) {
return _.isNumber(millis) && millis ? moment(millis).format(defaultDateFormat) : '';
if (padding) {
number = ('000' + number).substr(-padding);
}
return '' + number;
}
function formatDate(millis, format) {
if (!millis || !_.isNumber(millis)) {
return '';
}
format = format || defaultDateFormat;
var date = new Date(millis);
var d = {
Y: date.getFullYear(),
M: date.getMonth() + 1,
D: date.getDate(),
H: date.getHours(),
m: date.getMinutes(),
s: date.getSeconds()
};
datePatterns.forEach(function (pattern) {
format = format.replace(pattern[0], formatNumber(d[pattern[1]], pattern[2]));
});
return format;
}

View file

@ -1,4 +1,4 @@
modulejs.define('ext/preview-audio', ['_', '$', 'moment', 'core/settings', 'core/event', 'ext/preview'], function (_, $, moment, allsettings, event, preview) {
modulejs.define('ext/preview-audio', ['_', '$', 'core/settings', 'core/event', 'core/format', 'ext/preview'], function (_, $, allsettings, event, format, preview) {
var settings = _.extend({
enabled: false,
@ -39,7 +39,7 @@ modulejs.define('ext/preview-audio', ['_', '$', 'moment', 'core/settings', 'core
preview.setLabels([
currentItem.label,
moment(0).add('seconds', $audio[0].duration).format('m:ss')
format.formatDate($audio[0].duration * 1000, 'm:ss')
]);
}
}

File diff suppressed because one or more lines are too long

View file

@ -4,17 +4,15 @@
// @include "lib/lodash-*.js"
// @include "lib/marked-*.js"
// @include "lib/modulejs-*.js"
// @include "lib/moment-*.js"
// @include "lib/prism-*.js"
(function () {
'use strict';
/*global jQuery, marked, Modernizr, moment, Prism, _ */
/*global jQuery, marked, Modernizr, Prism, _ */
modulejs.define('$', function () { return jQuery; });
modulejs.define('marked', function () { return marked; });
modulejs.define('modernizr', function () { return Modernizr; });
modulejs.define('moment', function () { return moment; });
modulejs.define('prism', function () { return Prism; });
modulejs.define('_', function () { return _; });

View file

@ -13,7 +13,7 @@
"files": "files",
"download": "download",
"noMatch": "no match",
"dateFormat": "YYYY-MM-DD HH:mm", /* syntax as specified on http://momentjs.com */
"dateFormat": "YYYY-MM-DD HH:mm",
"filter": "filter",
"view": "View",
"language": "Language"