From e5a968c4f1485c8890d515bb5bcc958546916fc3 Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Fri, 18 Nov 2016 13:23:52 -0600 Subject: [PATCH 1/2] move timeago.js to vendor directory --- app/assets/javascripts/application.js | 1 + .../lib/utils => vendor/assets/javascripts}/timeago.js | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) rename {app/assets/javascripts/lib/utils => vendor/assets/javascripts}/timeago.js (93%) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 76f3c6506ed..9333c6e8586 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -19,6 +19,7 @@ /*= require jquery.scrollTo */ /*= require jquery.turbolinks */ /*= require js.cookie */ +/*= require timeago */ /*= require turbolinks */ /*= require autosave */ /*= require bootstrap/affix */ diff --git a/app/assets/javascripts/lib/utils/timeago.js b/vendor/assets/javascripts/timeago.js similarity index 93% rename from app/assets/javascripts/lib/utils/timeago.js rename to vendor/assets/javascripts/timeago.js index edf0a612374..0eb6f7967a5 100644 --- a/app/assets/javascripts/lib/utils/timeago.js +++ b/vendor/assets/javascripts/timeago.js @@ -1,5 +1,3 @@ -/* eslint-disable no-unused-expressions, wrap-iife, func-names, curly, no-param-reassign, no-trailing-spaces, prefer-arrow-callback, no-var, one-var, quote-props, space-before-function-paren, vars-on-top, radix, prefer-template, space-infix-ops, no-use-before-define, newline-per-chained-call, no-useless-escape, no-nested-ternary, indent, no-undef, no-plusplus, one-var-declaration-per-line, operator-assignment, consistent-return, keyword-spacing, max-len, space-unary-ops, no-shadow, no-restricted-syntax, guard-for-in, eol-last, max-len */ - /** * Copyright (c) 2016 hustcc * License: MIT @@ -14,7 +12,7 @@ module.exports = factory(root); else root.timeago = factory(root); -}(typeof window !== 'undefined' ? window : this, +}(typeof window !== 'undefined' ? window : this, function () { var cnt = 0, // the timer counter, for timer key indexMapEn = 'second_minute_hour_day_week_month_year'.split('_'), @@ -32,7 +30,7 @@ function () { SEC_ARRAY = [60, 60, 24, 7, 365/7/12, 12], SEC_ARRAY_LEN = 6, ATTR_DATETIME = 'datetime'; - + // format Date / string / timestamp to Date instance. function toDate(input) { if (input instanceof Date) return input; @@ -236,4 +234,4 @@ function () { }; return timeagoFactory; -}); \ No newline at end of file +}); From 8ede8603b0f6910886219ab1594eff1c0bfa3252 Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Tue, 22 Nov 2016 23:47:52 -0600 Subject: [PATCH 2/2] timeago should be a dependency of datetime_utility --- app/assets/javascripts/application.js | 1 - .../environments/components/environment_item.js.es6 | 8 ++++---- app/assets/javascripts/lib/utils/datetime_utility.js | 8 +++++++- spec/javascripts/build_spec.js.es6 | 1 - spec/javascripts/merge_request_widget_spec.js | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 9333c6e8586..76f3c6506ed 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -19,7 +19,6 @@ /*= require jquery.scrollTo */ /*= require jquery.turbolinks */ /*= require js.cookie */ -/*= require timeago */ /*= require turbolinks */ /*= require autosave */ /*= require bootstrap/affix */ diff --git a/app/assets/javascripts/environments/components/environment_item.js.es6 b/app/assets/javascripts/environments/components/environment_item.js.es6 index 36a0fec3cab..07f49cce3dc 100644 --- a/app/assets/javascripts/environments/components/environment_item.js.es6 +++ b/app/assets/javascripts/environments/components/environment_item.js.es6 @@ -1,4 +1,7 @@ -/*= require lib/utils/timeago */ +/* global Vue */ +/* global timeago */ + +/*= require timeago */ /*= require lib/utils/text_utility */ /*= require vue_common_component/commit */ /*= require ./environment_actions */ @@ -6,9 +9,6 @@ /*= require ./environment_stop */ /*= require ./environment_rollback */ -/* global Vue */ -/* global timeago */ - (() => { /** * Envrionment Item Component diff --git a/app/assets/javascripts/lib/utils/datetime_utility.js b/app/assets/javascripts/lib/utils/datetime_utility.js index d480fdc882b..963d2851e5f 100644 --- a/app/assets/javascripts/lib/utils/datetime_utility.js +++ b/app/assets/javascripts/lib/utils/datetime_utility.js @@ -1,4 +1,10 @@ -/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, no-param-reassign, no-cond-assign, no-undef, comma-dangle, no-unused-expressions, prefer-template, padded-blocks, max-len */ +/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, no-param-reassign, no-cond-assign, comma-dangle, no-unused-expressions, prefer-template, padded-blocks, max-len */ +/* global timeago */ +/* global dateFormat */ + +/*= require timeago */ +/*= require date.format */ + (function() { (function(w) { var base; diff --git a/spec/javascripts/build_spec.js.es6 b/spec/javascripts/build_spec.js.es6 index ee192c4f18a..4208e076e96 100644 --- a/spec/javascripts/build_spec.js.es6 +++ b/spec/javascripts/build_spec.js.es6 @@ -2,7 +2,6 @@ /* global Build */ /* global Turbolinks */ -//= require lib/utils/timeago //= require lib/utils/datetime_utility //= require build //= require breakpoints diff --git a/spec/javascripts/merge_request_widget_spec.js b/spec/javascripts/merge_request_widget_spec.js index f38e9cb8ef5..62890f1ca96 100644 --- a/spec/javascripts/merge_request_widget_spec.js +++ b/spec/javascripts/merge_request_widget_spec.js @@ -1,6 +1,6 @@ /* eslint-disable space-before-function-paren, quotes, comma-dangle, dot-notation, indent, quote-props, no-var, padded-blocks, max-len */ + /*= require merge_request_widget */ -/*= require lib/utils/timeago */ /*= require lib/utils/datetime_utility */ (function() {