From 7216c8d5cbd7b53dfca4c460adc1dc9315c06d84 Mon Sep 17 00:00:00 2001 From: Dan Hansen Date: Fri, 15 Apr 2011 23:37:17 -0500 Subject: [PATCH] DRY up timeago.js, add license to i18n.js & timeago.js --- public/javascripts/widgets/i18n.js | 14 +++------ public/javascripts/widgets/timeago.js | 45 +++++++++------------------ 2 files changed, 20 insertions(+), 39 deletions(-) diff --git a/public/javascripts/widgets/i18n.js b/public/javascripts/widgets/i18n.js index ade4fccba..eac849a5e 100644 --- a/public/javascripts/widgets/i18n.js +++ b/public/javascripts/widgets/i18n.js @@ -1,15 +1,11 @@ -/** - * Created by . - * User: dan - * Date: Jan 25, 2011 - * Time: 5:18:32 PM - * To change this template use File | Settings | File Templates. +/* Copyright (c) 2010, Diaspora Inc. This file is + * licensed under the Affero General Public License version 3 or later. See + * the COPYRIGHT file. */ -Diaspora.widgets.add("i18n", function() { - this.start = $.noop; +Diaspora.widgets.add("i18n", function() { this.language = "en"; - this.locale = {}; + this.locale = { }; this.loadLocale = function(locale, language) { this.language = language; diff --git a/public/javascripts/widgets/timeago.js b/public/javascripts/widgets/timeago.js index cd5ffca65..cc3c4e0d8 100644 --- a/public/javascripts/widgets/timeago.js +++ b/public/javascripts/widgets/timeago.js @@ -1,41 +1,26 @@ -/** - * Created by . - * User: dan - * Date: Jan 25, 2011 - * Time: 8:49:02 PM - * To change this template use File | Settings | File Templates. +/* Copyright (c) 2010, Diaspora Inc. This file is + * licensed under the Affero General Public License version 3 or later. See + * the COPYRIGHT file. */ + Diaspora.widgets.add("timeago", function() { this.selector = "abbr.timeago"; this.start = function() { - InfiniteScroll.postScroll(function(){ - Diaspora.widgets.timeago.updateTimeAgo(); - }); - if(Diaspora.widgets.i18n.language === "en") { - return; - } + InfiniteScroll.postScroll(function(){ + Diaspora.widgets.timeago.updateTimeAgo(); + }); - jQuery.timeago.settings.strings = { - prefixAgo: Diaspora.widgets.i18n.t("timeago.prefixAgo"), - prefixFromNow: Diaspora.widgets.i18n.t("timeago.prefixFromNow"), - suffixAgo: Diaspora.widgets.i18n.t("timeago.suffixAgo"), - suffixFromNow: Diaspora.widgets.i18n.t("timeago.suffixFromNow"), - seconds: Diaspora.widgets.i18n.t("timeago.seconds"), - minute: Diaspora.widgets.i18n.t("timeago.minute"), - minutes: Diaspora.widgets.i18n.t("timeago.minutes"), - hour: Diaspora.widgets.i18n.t("timeago.hour"), - hours: Diaspora.widgets.i18n.t("timeago.hours"), - day: Diaspora.widgets.i18n.t("timeago.day"), - days: Diaspora.widgets.i18n.t("timeago.days"), - month: Diaspora.widgets.i18n.t("timeago.month"), - months: Diaspora.widgets.i18n.t("timeago.months"), - year: Diaspora.widgets.i18n.t("timeago.year"), - years: Diaspora.widgets.i18n.t("timeago.years") - }; + if(Diaspora.widgets.i18n.language === "en") { + return; + } - Diaspora.widgets.timeago.updateTimeAgo("abbr"); + $.each($.timeago.settings.strings, function(index, element) { + $.timeago.settings.strings[index] = Diaspora.widgets.i18n.t("timeago." + element); + }); + + Diaspora.widgets.timeago.updateTimeAgo("abbr"); }; this.updateTimeAgo = function(selector) {