Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-moment

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-moment - npm Package Compare versions

Comparing version 0.5.2 to 0.6.0

18

angular-moment.js

@@ -1,5 +0,5 @@

/* angular-moment.js / v0.5.2 / (c) 2013 Uri Shaked / MIT Licence */
/* angular-moment.js / v0.6.0 / (c) 2013 Uri Shaked / MIT Licence */
angular.module('angularMoment', [])
.constant('amTimeAgoConfig', { withoutSuffix: false })
.constant('amTimeAgoConfig', { withoutSuffix: false})
.directive('amTimeAgo', ['$window', 'amTimeAgoConfig', function ($window, amTimeAgoConfig) {

@@ -12,2 +12,3 @@ 'use strict';

var currentFormat;
var withoutSuffix = amTimeAgoConfig.withoutSuffix;

@@ -22,3 +23,3 @@ function cancelTimer() {

function updateTime(momentInstance) {
element.text(momentInstance.fromNow(amTimeAgoConfig.withoutSuffix));
element.text(momentInstance.fromNow(withoutSuffix));
var howOld = $window.moment().diff(momentInstance, 'minute');

@@ -64,2 +65,13 @@ var secondsUntilUpdate = 3600;

if (angular.isDefined(attr.amWithoutSuffix)) {
scope.$watch(attr.amWithoutSuffix, function (value) {
if (typeof value === 'boolean') {
withoutSuffix = value;
updateMoment();
} else {
withoutSuffix = amTimeAgoConfig.withoutSuffix;
}
});
}
attr.$observe('amFormat', function (format) {

@@ -66,0 +78,0 @@ currentFormat = format;

2

angular-moment.min.js

@@ -1,1 +0,1 @@

angular.module("angularMoment",[]).constant("amTimeAgoConfig",{withoutSuffix:!1}).directive("amTimeAgo",["$window","amTimeAgoConfig",function(a,b){"use strict";return function(c,d,e){function f(){k&&(a.clearTimeout(k),k=null)}function g(c){d.text(c.fromNow(b.withoutSuffix));var e=a.moment().diff(c,"minute"),f=3600;1>e?f=1:60>e?f=30:180>e&&(f=300),k=a.setTimeout(function(){g(c)},1e3*f)}function h(){f(),g(a.moment(i,j))}var i,j,k=null;c.$watch(e.amTimeAgo,function(a){return"undefined"==typeof a||null===a||""===a?(f(),i&&(d.text(""),i=null),void 0):(angular.isNumber(a)&&(a=new Date(a)),i=a,h(),void 0)}),e.$observe("amFormat",function(a){j=a,i&&h()}),c.$on("$destroy",function(){f()})}}]).filter("amCalendar",["$window",function(a){"use strict";return function(b){return"undefined"==typeof b||null===b?"":(!isNaN(parseFloat(b))&&isFinite(b)&&(b=new Date(parseInt(b,10))),a.moment(b).calendar())}}]).filter("amDateFormat",["$window",function(a){"use strict";return function(b,c){return"undefined"==typeof b||null===b?"":(!isNaN(parseFloat(b))&&isFinite(b)&&(b=new Date(parseInt(b,10))),a.moment(b).format(c))}}]).filter("amDurationFormat",["$window",function(a){"use strict";return function(b,c,d){return"undefined"==typeof b||null===b?"":a.moment.duration(b,c).humanize(d)}}]);
angular.module("angularMoment",[]).constant("amTimeAgoConfig",{withoutSuffix:!1}).directive("amTimeAgo",["$window","amTimeAgoConfig",function(a,b){"use strict";return function(c,d,e){function f(){k&&(a.clearTimeout(k),k=null)}function g(b){d.text(b.fromNow(l));var c=a.moment().diff(b,"minute"),e=3600;1>c?e=1:60>c?e=30:180>c&&(e=300),k=a.setTimeout(function(){g(b)},1e3*e)}function h(){f(),g(a.moment(i,j))}var i,j,k=null,l=b.withoutSuffix;c.$watch(e.amTimeAgo,function(a){return"undefined"==typeof a||null===a||""===a?(f(),i&&(d.text(""),i=null),void 0):(angular.isNumber(a)&&(a=new Date(a)),i=a,h(),void 0)}),angular.isDefined(e.amWithoutSuffix)&&c.$watch(e.amWithoutSuffix,function(a){"boolean"==typeof a?(l=a,h()):l=b.withoutSuffix}),e.$observe("amFormat",function(a){j=a,i&&h()}),c.$on("$destroy",function(){f()})}}]).filter("amCalendar",["$window",function(a){"use strict";return function(b){return"undefined"==typeof b||null===b?"":(!isNaN(parseFloat(b))&&isFinite(b)&&(b=new Date(parseInt(b,10))),a.moment(b).calendar())}}]).filter("amDateFormat",["$window",function(a){"use strict";return function(b,c){return"undefined"==typeof b||null===b?"":(!isNaN(parseFloat(b))&&isFinite(b)&&(b=new Date(parseInt(b,10))),a.moment(b).format(c))}}]).filter("amDurationFormat",["$window",function(a){"use strict";return function(b,c,d){return"undefined"==typeof b||null===b?"":a.moment.duration(b,c).humanize(d)}}]);
{
"name": "angular-moment",
"version": "0.5.2",
"version": "0.6.0",
"description": "Moment.JS directives & filters for Angular.JS (timeago alternative)",

@@ -13,3 +13,3 @@ "author": "Uri Shaked",

"angular": ">=1.0.0 <1.3.0",
"moment": ">=2.0.0 <2.5.0"
"moment": ">=2.0.0 <2.6.0"
},

@@ -16,0 +16,0 @@ "devDependencies": {

# Changelog
## 0.6.0 - 2013-12-24
- Add optional am-without-suffix attribute to am-time-ago ([#22](https://github.com/urish/angular-moment/issues/22), contributed by [hramaker](https://github.com/hramaker))
- Support moment.js v2.5.0. See [here](https://gist.github.com/ichernev/8104451) for changelog.
- Merry Christmas!
## 0.5.2 - 2013-11-17

@@ -4,0 +10,0 @@

{
"name": "angular-moment",
"version": "0.5.2",
"version": "0.6.0",
"repository": {

@@ -14,5 +14,7 @@ "type": "git",

"grunt-contrib-jshint": "~0.6.0",
"grunt-karma": "~0.7.0",
"karma": "~0.10.0",
"karma-coverage": "~0.1.0"
"grunt-karma": "~0.7.2",
"karma": "~0.11.10",
"karma-coverage": "~0.1.0",
"karma-jasmine": "~0.1.5",
"karma-phantomjs-launcher": "~0.1.1"
},

@@ -19,0 +21,0 @@ "engines": {

@@ -5,3 +5,3 @@ /* License: MIT.

/* global describe, inject, module, beforeEach, it, expect, waitsFor, runs, spyOn */
/* global describe, inject, module, beforeEach, afterEach, it, expect, waitsFor, runs, spyOn */

@@ -11,7 +11,6 @@ 'use strict';

describe('module angularMoment', function () {
var $rootScope, $compile, $window, amTimeAgoConfig;
var $rootScope, $compile, $window, amTimeAgoConfig, originalTimeAgoConfig;
beforeEach(module('angularMoment'));
/* jshint camelcase:false */
beforeEach(inject(function ($injector) {

@@ -22,5 +21,10 @@ $rootScope = $injector.get('$rootScope');

amTimeAgoConfig = $injector.get('amTimeAgoConfig');
originalTimeAgoConfig = angular.copy(amTimeAgoConfig);
}));
/* jshint camelcase:true */
afterEach(function() {
// Restore original configuration after each test
amTimeAgoConfig.withoutSuffix = originalTimeAgoConfig.withoutSuffix;
});
describe('am-time-ago directive', function () {

@@ -120,3 +124,3 @@ it('should change the text of the element to "a few seconds ago" when given current time', function () {

it('should not change the contents of the element until a date is given', function() {
it('should not change the contents of the element until a date is given', function () {
$rootScope.testDate = null;

@@ -150,6 +154,44 @@ var element = angular.element('<div am-time-ago="testDate">Initial text</div>');

expect(element.text()).toBe('a few seconds');
// Restore config
amTimeAgoConfig.withoutSuffix = false;
});
describe('am-without-suffix attribute', function () {
it('should generate a time string without suffix when true', function () {
$rootScope.testDate = new Date();
var element = angular.element('<span am-time-ago="testDate" am-without-suffix="true"></span>');
element = $compile(element)($rootScope);
$rootScope.$digest();
expect(element.text()).toBe('a few seconds');
});
it('should generate a time string with suffix when false', function () {
amTimeAgoConfig.withoutSuffix = true;
$rootScope.testDate = new Date();
var element = angular.element('<span am-time-ago="testDate" am-without-suffix="false"></span>');
element = $compile(element)($rootScope);
$rootScope.$digest();
expect(element.text()).toBe('a few seconds ago');
});
it('should support expressions', function () {
$rootScope.testDate = new Date();
$rootScope.withSuffix = false;
var element = angular.element('<span am-time-ago="testDate" am-without-suffix="!withSuffix"></span>');
element = $compile(element)($rootScope);
$rootScope.$digest();
expect(element.text()).toBe('a few seconds');
$rootScope.withSuffix = true;
$rootScope.$digest();
expect(element.text()).toBe('a few seconds ago');
});
it('should ignore non-boolean values', function () {
$rootScope.testDate = new Date();
$rootScope.withoutSuffix = 'string';
var element = angular.element('<span am-time-ago="testDate" am-without-suffix="withoutSuffix"></span>');
element = $compile(element)($rootScope);
$rootScope.$digest();
expect(element.text()).toBe('a few seconds ago');
});
});
describe('am-format attribute', function () {

@@ -156,0 +198,0 @@ it('should support custom date format', function () {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc