angular-ui-bootstrap
Advanced tools
Comparing version 1.1.1 to 1.1.2
{ | ||
"author": "https://github.com/angular-ui/bootstrap/graphs/contributors", | ||
"name": "angular-ui-bootstrap", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"homepage": "http://angular-ui.github.io/bootstrap/", | ||
@@ -6,0 +6,0 @@ "dependencies": {}, |
@@ -94,2 +94,6 @@ angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse']) | ||
}; | ||
var id = 'accordiongroup-' + scope.$id + '-' + Math.floor(Math.random() * 10000); | ||
scope.headingId = id + '-tab'; | ||
scope.panelId = id + '-panel'; | ||
} | ||
@@ -96,0 +100,0 @@ }; |
@@ -126,2 +126,8 @@ describe('uib-accordion', function() { | ||
it('should be a tablist', function() { | ||
element = $compile('<uib-accordion></uib-accordion>')(scope); | ||
scope.$digest(); | ||
expect(element.html()).toContain('role="tablist"'); | ||
}); | ||
it('should expose the controller on the view', function() { | ||
@@ -154,2 +160,5 @@ $templateCache.put('uib/template/accordion/accordion.html', '<div>{{accordion.text}}</div>'); | ||
var element, groups; | ||
var findGroupHeading = function(index) { | ||
return groups.eq(index).find('.panel-heading').eq(0); | ||
}; | ||
var findGroupLink = function(index) { | ||
@@ -182,2 +191,3 @@ return groups.eq(index).find('.accordion-toggle').eq(0); | ||
beforeEach(function() { | ||
spyOn(Math, 'random').and.returnValue(0.1); | ||
var tpl = | ||
@@ -210,2 +220,3 @@ '<uib-accordion>' + | ||
expect(findGroupBody(0).scope().isOpen).toBe(true); | ||
expect(findGroupHeading(0).html()).toContain('aria-expanded="true"'); | ||
@@ -215,3 +226,5 @@ findGroupLink(1).click(); | ||
expect(findGroupBody(0).scope().isOpen).toBe(false); | ||
expect(findGroupHeading(0).html()).toContain('aria-expanded="false"'); | ||
expect(findGroupBody(1).scope().isOpen).toBe(true); | ||
expect(findGroupHeading(1).html()).toContain('aria-expanded="true"'); | ||
}); | ||
@@ -223,5 +236,8 @@ | ||
expect(findGroupBody(0).scope().isOpen).toBe(true); | ||
expect(groups.eq(0).html()).toContain('aria-hidden="false"'); | ||
findGroupLink(0).click(); | ||
scope.$digest(); | ||
expect(findGroupBody(0).scope().isOpen).toBe(false); | ||
expect(groups.eq(0).html()).toContain('aria-hidden="true"'); | ||
}); | ||
@@ -265,2 +281,12 @@ | ||
}); | ||
it('should generate an Id for the heading', function() { | ||
var groupScope = findGroupBody(0).scope(); | ||
expect(groupScope.headingId).toEqual('accordiongroup-' + groupScope.$id + '-1000-tab'); | ||
}); | ||
it('should generate an Id for the panel', function() { | ||
var groupScope = findGroupBody(0).scope(); | ||
expect(groupScope.panelId).toEqual('accordiongroup-' + groupScope.$id + '-1000-panel'); | ||
}); | ||
}); | ||
@@ -267,0 +293,0 @@ |
@@ -10,3 +10,3 @@ angular.module('ui.bootstrap.demo').controller('CarouselDemoCtrl', function ($scope) { | ||
slides.push({ | ||
image: '//lorempixel.com/' + newWidth + '/300', | ||
image: 'http://lorempixel.com/' + newWidth + '/300', | ||
text: ['Nice image','Awesome photograph','That is so cool','I love that'][slides.length % 4], | ||
@@ -13,0 +13,0 @@ id: currIndex++ |
angular.module('ui.bootstrap.dateparser', []) | ||
.service('uibDateParser', ['$log', '$locale', 'orderByFilter', function($log, $locale, orderByFilter) { | ||
.service('uibDateParser', ['$log', '$locale', 'dateFilter', 'orderByFilter', function($log, $locale, dateFilter, orderByFilter) { | ||
// Pulled from https://github.com/mbostock/d3/blob/master/src/format/requote.js | ||
@@ -14,2 +14,3 @@ var SPECIAL_CHARACTERS_REGEXP = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g; | ||
this.parsers = {}; | ||
this.formatters = {}; | ||
@@ -20,3 +21,8 @@ formatCodeToRegex = [ | ||
regex: '\\d{4}', | ||
apply: function(value) { this.year = +value; } | ||
apply: function(value) { this.year = +value; }, | ||
formatter: function(date) { | ||
var _date = new Date(); | ||
_date.setFullYear(Math.abs(date.getFullYear())); | ||
return dateFilter(_date, 'yyyy'); | ||
} | ||
}, | ||
@@ -26,3 +32,8 @@ { | ||
regex: '\\d{2}', | ||
apply: function(value) { this.year = +value + 2000; } | ||
apply: function(value) { this.year = +value + 2000; }, | ||
formatter: function(date) { | ||
var _date = new Date(); | ||
_date.setFullYear(Math.abs(date.getFullYear())); | ||
return dateFilter(_date, 'yy'); | ||
} | ||
}, | ||
@@ -32,3 +43,8 @@ { | ||
regex: '\\d{1,4}', | ||
apply: function(value) { this.year = +value; } | ||
apply: function(value) { this.year = +value; }, | ||
formatter: function(date) { | ||
var _date = new Date(); | ||
_date.setFullYear(Math.abs(date.getFullYear())); | ||
return dateFilter(_date, 'y'); | ||
} | ||
}, | ||
@@ -38,3 +54,11 @@ { | ||
regex: '0?[1-9]|1[0-2]', | ||
apply: function(value) { this.month = value - 1; } | ||
apply: function(value) { this.month = value - 1; }, | ||
formatter: function(date) { | ||
var value = date.getMonth(); | ||
if (/^[0-9]$/.test(value)) { | ||
return dateFilter(date, 'MM'); | ||
} | ||
return dateFilter(date, 'M'); | ||
} | ||
}, | ||
@@ -44,3 +68,4 @@ { | ||
regex: $locale.DATETIME_FORMATS.MONTH.join('|'), | ||
apply: function(value) { this.month = $locale.DATETIME_FORMATS.MONTH.indexOf(value); } | ||
apply: function(value) { this.month = $locale.DATETIME_FORMATS.MONTH.indexOf(value); }, | ||
formatter: function(date) { return dateFilter(date, 'MMMM'); } | ||
}, | ||
@@ -50,3 +75,4 @@ { | ||
regex: $locale.DATETIME_FORMATS.SHORTMONTH.join('|'), | ||
apply: function(value) { this.month = $locale.DATETIME_FORMATS.SHORTMONTH.indexOf(value); } | ||
apply: function(value) { this.month = $locale.DATETIME_FORMATS.SHORTMONTH.indexOf(value); }, | ||
formatter: function(date) { return dateFilter(date, 'MMM'); } | ||
}, | ||
@@ -56,3 +82,4 @@ { | ||
regex: '0[1-9]|1[0-2]', | ||
apply: function(value) { this.month = value - 1; } | ||
apply: function(value) { this.month = value - 1; }, | ||
formatter: function(date) { return dateFilter(date, 'MM'); } | ||
}, | ||
@@ -62,3 +89,4 @@ { | ||
regex: '[1-9]|1[0-2]', | ||
apply: function(value) { this.month = value - 1; } | ||
apply: function(value) { this.month = value - 1; }, | ||
formatter: function(date) { return dateFilter(date, 'M'); } | ||
}, | ||
@@ -68,3 +96,11 @@ { | ||
regex: '[0-2]?[0-9]{1}|3[0-1]{1}', | ||
apply: function(value) { this.date = +value; } | ||
apply: function(value) { this.date = +value; }, | ||
formatter: function(date) { | ||
var value = date.getDate(); | ||
if (/^[1-9]$/.test(value)) { | ||
return dateFilter(date, 'dd'); | ||
} | ||
return dateFilter(date, 'd'); | ||
} | ||
}, | ||
@@ -74,3 +110,4 @@ { | ||
regex: '[0-2][0-9]{1}|3[0-1]{1}', | ||
apply: function(value) { this.date = +value; } | ||
apply: function(value) { this.date = +value; }, | ||
formatter: function(date) { return dateFilter(date, 'dd'); } | ||
}, | ||
@@ -80,11 +117,14 @@ { | ||
regex: '[1-2]?[0-9]{1}|3[0-1]{1}', | ||
apply: function(value) { this.date = +value; } | ||
apply: function(value) { this.date = +value; }, | ||
formatter: function(date) { return dateFilter(date, 'd'); } | ||
}, | ||
{ | ||
key: 'EEEE', | ||
regex: $locale.DATETIME_FORMATS.DAY.join('|') | ||
regex: $locale.DATETIME_FORMATS.DAY.join('|'), | ||
formatter: function(date) { return dateFilter(date, 'EEEE'); } | ||
}, | ||
{ | ||
key: 'EEE', | ||
regex: $locale.DATETIME_FORMATS.SHORTDAY.join('|') | ||
regex: $locale.DATETIME_FORMATS.SHORTDAY.join('|'), | ||
formatter: function(date) { return dateFilter(date, 'EEE'); } | ||
}, | ||
@@ -94,3 +134,4 @@ { | ||
regex: '(?:0|1)[0-9]|2[0-3]', | ||
apply: function(value) { this.hours = +value; } | ||
apply: function(value) { this.hours = +value; }, | ||
formatter: function(date) { return dateFilter(date, 'HH'); } | ||
}, | ||
@@ -100,3 +141,4 @@ { | ||
regex: '0[0-9]|1[0-2]', | ||
apply: function(value) { this.hours = +value; } | ||
apply: function(value) { this.hours = +value; }, | ||
formatter: function(date) { return dateFilter(date, 'hh'); } | ||
}, | ||
@@ -106,3 +148,4 @@ { | ||
regex: '1?[0-9]|2[0-3]', | ||
apply: function(value) { this.hours = +value; } | ||
apply: function(value) { this.hours = +value; }, | ||
formatter: function(date) { return dateFilter(date, 'H'); } | ||
}, | ||
@@ -112,3 +155,4 @@ { | ||
regex: '[0-9]|1[0-2]', | ||
apply: function(value) { this.hours = +value; } | ||
apply: function(value) { this.hours = +value; }, | ||
formatter: function(date) { return dateFilter(date, 'h'); } | ||
}, | ||
@@ -118,3 +162,4 @@ { | ||
regex: '[0-5][0-9]', | ||
apply: function(value) { this.minutes = +value; } | ||
apply: function(value) { this.minutes = +value; }, | ||
formatter: function(date) { return dateFilter(date, 'mm'); } | ||
}, | ||
@@ -124,3 +169,4 @@ { | ||
regex: '[0-9]|[1-5][0-9]', | ||
apply: function(value) { this.minutes = +value; } | ||
apply: function(value) { this.minutes = +value; }, | ||
formatter: function(date) { return dateFilter(date, 'm'); } | ||
}, | ||
@@ -130,3 +176,4 @@ { | ||
regex: '[0-9][0-9][0-9]', | ||
apply: function(value) { this.milliseconds = +value; } | ||
apply: function(value) { this.milliseconds = +value; }, | ||
formatter: function(date) { return dateFilter(date, 'sss'); } | ||
}, | ||
@@ -136,3 +183,4 @@ { | ||
regex: '[0-5][0-9]', | ||
apply: function(value) { this.seconds = +value; } | ||
apply: function(value) { this.seconds = +value; }, | ||
formatter: function(date) { return dateFilter(date, 'ss'); } | ||
}, | ||
@@ -142,3 +190,4 @@ { | ||
regex: '[0-9]|[1-5][0-9]', | ||
apply: function(value) { this.seconds = +value; } | ||
apply: function(value) { this.seconds = +value; }, | ||
formatter: function(date) { return dateFilter(date, 's'); } | ||
}, | ||
@@ -156,3 +205,4 @@ { | ||
} | ||
} | ||
}, | ||
formatter: function(date) { return dateFilter(date, 'a'); } | ||
}, | ||
@@ -169,2 +219,5 @@ { | ||
this.minutes += toInt(sign + minutes); | ||
}, | ||
formatter: function(date) { | ||
return dateFilter(date, 'Z'); | ||
} | ||
@@ -174,23 +227,29 @@ }, | ||
key: 'ww', | ||
regex: '[0-4][0-9]|5[0-3]' | ||
regex: '[0-4][0-9]|5[0-3]', | ||
formatter: function(date) { return dateFilter(date, 'ww'); } | ||
}, | ||
{ | ||
key: 'w', | ||
regex: '[0-9]|[1-4][0-9]|5[0-3]' | ||
regex: '[0-9]|[1-4][0-9]|5[0-3]', | ||
formatter: function(date) { return dateFilter(date, 'w'); } | ||
}, | ||
{ | ||
key: 'GGGG', | ||
regex: $locale.DATETIME_FORMATS.ERANAMES.join('|').replace(/\s/g, '\\s') | ||
regex: $locale.DATETIME_FORMATS.ERANAMES.join('|').replace(/\s/g, '\\s'), | ||
formatter: function(date) { return dateFilter(date, 'GGGG'); } | ||
}, | ||
{ | ||
key: 'GGG', | ||
regex: $locale.DATETIME_FORMATS.ERAS.join('|') | ||
regex: $locale.DATETIME_FORMATS.ERAS.join('|'), | ||
formatter: function(date) { return dateFilter(date, 'GGG'); } | ||
}, | ||
{ | ||
key: 'GG', | ||
regex: $locale.DATETIME_FORMATS.ERAS.join('|') | ||
regex: $locale.DATETIME_FORMATS.ERAS.join('|'), | ||
formatter: function(date) { return dateFilter(date, 'GG'); } | ||
}, | ||
{ | ||
key: 'G', | ||
regex: $locale.DATETIME_FORMATS.ERAS.join('|') | ||
regex: $locale.DATETIME_FORMATS.ERAS.join('|'), | ||
formatter: function(date) { return dateFilter(date, 'G'); } | ||
} | ||
@@ -202,3 +261,3 @@ ]; | ||
function createParser(format) { | ||
function createParser(format, func) { | ||
var map = [], regex = format.split(''); | ||
@@ -251,3 +310,4 @@ | ||
index: index, | ||
apply: data.apply, | ||
key: data.key, | ||
apply: data[func], | ||
matcher: data.regex | ||
@@ -264,2 +324,37 @@ }); | ||
this.filter = function(date, format) { | ||
if (!angular.isDate(date) || isNaN(date) || !format) { | ||
return ''; | ||
} | ||
format = $locale.DATETIME_FORMATS[format] || format; | ||
if ($locale.id !== localeId) { | ||
this.init(); | ||
} | ||
if (!this.formatters[format]) { | ||
this.formatters[format] = createParser(format, 'formatter'); | ||
} | ||
var parser = this.formatters[format], | ||
map = parser.map; | ||
var _format = format; | ||
return map.reduce(function(str, mapper, i) { | ||
var match = _format.match(new RegExp('(.*)' + mapper.key)); | ||
if (match && angular.isString(match[1])) { | ||
str += match[1]; | ||
_format = _format.replace(match[1] + mapper.key, ''); | ||
} | ||
if (mapper.apply) { | ||
return str + mapper.apply.call(null, date); | ||
} | ||
return str; | ||
}, ''); | ||
}; | ||
this.parse = function(input, format, baseDate) { | ||
@@ -278,3 +373,3 @@ if (!angular.isString(input) || !format) { | ||
if (!this.parsers[format]) { | ||
this.parsers[format] = createParser(format); | ||
this.parsers[format] = createParser(format, 'apply'); | ||
} | ||
@@ -367,3 +462,3 @@ | ||
this.convertTimezoneToLocal = convertTimezoneToLocal; | ||
function toTimezone(date, timezone) { | ||
@@ -370,0 +465,0 @@ return date && timezone ? convertTimezoneToLocal(date, timezone) : date; |
@@ -11,2 +11,6 @@ describe('date parser', function() { | ||
function expectFilter(date, format, display) { | ||
expect(dateParser.filter(date, format)).toEqual(display); | ||
} | ||
function expectParse(input, format, date) { | ||
@@ -20,2 +24,245 @@ expect(dateParser.parse(input, format)).toEqual(date); | ||
describe('filter', function() { | ||
it('should work correctly for `dd`, `MM`, `yyyy`', function() { | ||
expectFilter(new Date(2013, 10, 17, 0), 'dd.MM.yyyy', '17.11.2013'); | ||
expectFilter(new Date(2013, 11, 31, 0), 'dd.MM.yyyy', '31.12.2013'); | ||
expectFilter(new Date(1991, 2, 8, 0), 'dd-MM-yyyy', '08-03-1991'); | ||
expectFilter(new Date(1980, 2, 5, 0), 'MM/dd/yyyy', '03/05/1980'); | ||
expectFilter(new Date(1983, 0, 10, 0), 'dd.MM/yyyy', '10.01/1983'); | ||
expectFilter(new Date(1980, 10, 9, 0), 'MM-dd-yyyy', '11-09-1980'); | ||
expectFilter(new Date(2011, 1, 5, 0), 'yyyy/MM/dd', '2011/02/05'); | ||
expectFilter(oldDate, 'yyyy/MM/dd', '0001/03/06'); | ||
}); | ||
it('should work correctly for `yy`', function() { | ||
expectFilter(new Date(2013, 10, 17, 0), 'dd.MM.yy', '17.11.13'); | ||
expectFilter(new Date(2011, 4, 2, 0), 'dd-MM-yy', '02-05-11'); | ||
expectFilter(new Date(2080, 1, 5, 0), 'MM/dd/yy', '02/05/80'); | ||
expectFilter(new Date(2055, 1, 5, 0), 'yy/MM/dd', '55/02/05'); | ||
expectFilter(new Date(2013, 7, 11, 0), 'dd-MM-yy', '11-08-13'); | ||
}); | ||
it('should work correctly for `y`', function() { | ||
expectFilter(new Date(2013, 10, 17, 0), 'dd.MM.y', '17.11.2013'); | ||
expectFilter(new Date(2013, 11, 31, 0), 'dd.MM.y', '31.12.2013'); | ||
expectFilter(new Date(1991, 2, 8, 0), 'dd-MM-y', '08-03-1991'); | ||
expectFilter(new Date(1980, 2, 5, 0), 'MM/dd/y', '03/05/1980'); | ||
expectFilter(new Date(1983, 0, 10, 0), 'dd.MM/y', '10.01/1983'); | ||
expectFilter(new Date(1980, 10, 9, 0), 'MM-dd-y', '11-09-1980'); | ||
expectFilter(new Date(2011, 1, 5, 0), 'y/MM/dd', '2011/02/05'); | ||
}); | ||
it('should work correctly for `MMMM`', function() { | ||
expectFilter(new Date(2013, 10, 17, 0), 'dd.MMMM.yy', '17.November.13'); | ||
expectFilter(new Date(1980, 2, 5, 0), 'dd-MMMM-yyyy', '05-March-1980'); | ||
expectFilter(new Date(1980, 1, 5, 0), 'MMMM/dd/yyyy', 'February/05/1980'); | ||
expectFilter(new Date(1949, 11, 20, 0), 'yyyy/MMMM/dd', '1949/December/20'); | ||
expectFilter(oldDate, 'yyyy/MMMM/dd', '0001/March/06'); | ||
}); | ||
it('should work correctly for `MMM`', function() { | ||
expectFilter(new Date(2010, 8, 30, 0), 'dd.MMM.yy', '30.Sep.10'); | ||
expectFilter(new Date(2011, 4, 2, 0), 'dd-MMM-yy', '02-May-11'); | ||
expectFilter(new Date(1980, 1, 5, 0), 'MMM/dd/yyyy', 'Feb/05/1980'); | ||
expectFilter(new Date(1955, 1, 5, 0), 'yyyy/MMM/dd', '1955/Feb/05'); | ||
expectFilter(oldDate, 'yyyy/MMM/dd', '0001/Mar/06'); | ||
}); | ||
it('should work correctly for `M`', function() { | ||
expectFilter(new Date(2013, 7, 11, 0), 'M/dd/yyyy', '8/11/2013'); | ||
expectFilter(new Date(2005, 10, 7, 0), 'dd.M.yy', '07.11.05'); | ||
expectFilter(new Date(2011, 4, 2, 0), 'dd-M-yy', '02-5-11'); | ||
expectFilter(new Date(1980, 1, 5, 0), 'M/dd/yyyy', '2/05/1980'); | ||
expectFilter(new Date(1955, 1, 5, 0), 'yyyy/M/dd', '1955/2/05'); | ||
expectFilter(new Date(2011, 4, 2, 0), 'dd-M-yy', '02-5-11'); | ||
}); | ||
it('should work correctly for `M!`', function() { | ||
expectFilter(new Date(2013, 7, 11, 0), 'M!/dd/yyyy', '08/11/2013'); | ||
expectFilter(new Date(2005, 10, 7, 0), 'dd.M!.yy', '07.11.05'); | ||
expectFilter(new Date(2011, 4, 2, 0), 'dd-M!-yy', '02-05-11'); | ||
expectFilter(new Date(1980, 1, 5, 0), 'M!/dd/yyyy', '02/05/1980'); | ||
expectFilter(new Date(1955, 1, 5, 0), 'yyyy/M!/dd', '1955/02/05'); | ||
expectFilter(new Date(2011, 4, 2, 0), 'dd-M!-yy', '02-05-11'); | ||
expectFilter(oldDate, 'yyyy/M!/dd', '0001/03/06'); | ||
}); | ||
it('should work correctly for `d`', function() { | ||
expectFilter(new Date(2013, 10, 17, 0), 'd.MMMM.yy', '17.November.13'); | ||
expectFilter(new Date(1991, 2, 8, 0), 'd-MMMM-yyyy', '8-March-1991'); | ||
expectFilter(new Date(1980, 1, 5, 0), 'MMMM/d/yyyy', 'February/5/1980'); | ||
expectFilter(new Date(1955, 1, 5, 0), 'yyyy/MMMM/d', '1955/February/5'); | ||
expectFilter(new Date(2013, 7, 11, 0), 'd-MM-yy', '11-08-13'); | ||
expectFilter(oldDate, 'yyyy/MM/d', '0001/03/6'); | ||
}); | ||
it('should work correctly for `d!`', function() { | ||
expectFilter(new Date(2013, 10, 17, 0), 'd!.MMMM.yy', '17.November.13'); | ||
expectFilter(new Date(1991, 2, 8, 0), 'd!-MMMM-yyyy', '08-March-1991'); | ||
expectFilter(new Date(1980, 1, 5, 0), 'MMMM/d!/yyyy', 'February/05/1980'); | ||
expectFilter(new Date(1955, 1, 5, 0), 'yyyy/MMMM/d!', '1955/February/05'); | ||
expectFilter(new Date(2013, 7, 11, 0), 'd!-MM-yy', '11-08-13'); | ||
expectFilter(oldDate, 'yyyy/MM/d!', '0001/03/06'); | ||
}); | ||
it('should work correctly for `EEEE`', function() { | ||
expectFilter(new Date(2013, 10, 17, 0), 'EEEE.d.MMMM.yy', 'Sunday.17.November.13'); | ||
expectFilter(new Date(1991, 2, 8, 0), 'd-EEEE-MMMM-yyyy', '8-Friday-March-1991'); | ||
expectFilter(new Date(1980, 1, 5, 0), 'MMMM/d/yyyy/EEEE', 'February/5/1980/Tuesday'); | ||
expectFilter(new Date(1955, 1, 5, 0), 'yyyy/EEEE/MMMM/d', '1955/Saturday/February/5'); | ||
}); | ||
it('should work correctly for `EEE`', function() { | ||
expectFilter(new Date(2013, 10, 17, 0), 'EEE.d.MMMM.yy', 'Sun.17.November.13'); | ||
expectFilter(new Date(1991, 2, 8, 0), 'd-EEE-MMMM-yyyy', '8-Fri-March-1991'); | ||
expectFilter(new Date(1980, 1, 5, 0), 'MMMM/d/yyyy/EEE', 'February/5/1980/Tue'); | ||
expectFilter(new Date(1955, 1, 5, 0), 'yyyy/EEE/MMMM/d', '1955/Sat/February/5'); | ||
}); | ||
it('should work correctly for `HH`', function() { | ||
expectFilter(new Date(2015, 2, 22, 22), 'd.MMMM.yy.HH', '22.March.15.22'); | ||
expectFilter(new Date(1991, 2, 8, 11), 'd-MMMM-yyyy-HH', '8-March-1991-11'); | ||
expectFilter(new Date(1980, 1, 5, 0), 'MMMM/d/yyyy/HH', 'February/5/1980/00'); | ||
expectFilter(new Date(1955, 1, 5, 3), 'yyyy/MMMM/d HH', '1955/February/5 03'); | ||
expectFilter(new Date(2013, 7, 11, 23), 'd-MM-yy HH', '11-08-13 23'); | ||
}); | ||
it('should work correctly for `H`', function() { | ||
expectFilter(new Date(2015, 2, 22, 22), 'd.MMMM.yy.H', '22.March.15.22'); | ||
expectFilter(new Date(1991, 2, 8, 11), 'd-MMMM-yyyy-H', '8-March-1991-11'); | ||
expectFilter(new Date(1980, 1, 5, 0), 'MMMM/d/yyyy/H', 'February/5/1980/0'); | ||
expectFilter(new Date(1955, 1, 5, 3), 'yyyy/MMMM/d H', '1955/February/5 3'); | ||
expectFilter(new Date(2013, 7, 11, 23), 'd-MM-yy H', '11-08-13 23'); | ||
}); | ||
it('should work correctly for `hh`', function() { | ||
expectFilter(new Date(2015, 2, 22, 12), 'd.MMMM.yy.hh', '22.March.15.12'); | ||
expectFilter(new Date(1991, 2, 8, 11), 'd-MMMM-yyyy-hh', '8-March-1991-11'); | ||
expectFilter(new Date(1980, 1, 5, 0), 'MMMM/d/yyyy/hh', 'February/5/1980/12'); | ||
expectFilter(new Date(1955, 1, 5, 3), 'yyyy/MMMM/d hh', '1955/February/5 03'); | ||
expectFilter(new Date(2013, 7, 11, 9), 'd-MM-yy hh', '11-08-13 09'); | ||
}); | ||
it('should work correctly for `h`', function() { | ||
expectFilter(new Date(2015, 2, 22, 12), 'd.MMMM.yy.h', '22.March.15.12'); | ||
expectFilter(new Date(1991, 2, 8, 11), 'd-MMMM-yyyy-h', '8-March-1991-11'); | ||
expectFilter(new Date(1980, 1, 5, 0), 'MMMM/d/yyyy/h', 'February/5/1980/12'); | ||
expectFilter(new Date(1955, 1, 5, 3), 'yyyy/MMMM/d h', '1955/February/5 3'); | ||
expectFilter(new Date(2013, 7, 11, 3), 'd-MM-yy h', '11-08-13 3'); | ||
}); | ||
it('should work correctly for `mm`', function() { | ||
expectFilter(new Date(2015, 2, 22, 0, 22), 'd.MMMM.yy.mm', '22.March.15.22'); | ||
expectFilter(new Date(1991, 2, 8, 0, 59), 'd-MMMM-yyyy-mm', '8-March-1991-59'); | ||
expectFilter(new Date(1980, 1, 5, 0, 0), 'MMMM/d/yyyy/mm', 'February/5/1980/00'); | ||
expectFilter(new Date(1955, 1, 5, 0, 3), 'yyyy/MMMM/d mm', '1955/February/5 03'); | ||
expectFilter(new Date(2013, 7, 11, 0, 46), 'd-MM-yy mm', '11-08-13 46'); | ||
expectFilter(new Date(2015, 2, 22, 22, 33), 'd.MMMM.yy.HH:mm', '22.March.15.22:33'); | ||
expectFilter(new Date(2015, 2, 22, 2, 1), 'd.MMMM.yy.H:mm', '22.March.15.2:01'); | ||
}); | ||
it('should work correctly for `m`', function() { | ||
expectFilter(new Date(2015, 2, 22, 0, 22), 'd.MMMM.yy.m', '22.March.15.22'); | ||
expectFilter(new Date(1991, 2, 8, 0, 59), 'd-MMMM-yyyy-m', '8-March-1991-59'); | ||
expectFilter(new Date(1980, 1, 5, 0, 0), 'MMMM/d/yyyy/m', 'February/5/1980/0'); | ||
expectFilter(new Date(1955, 1, 5, 0, 3), 'yyyy/MMMM/d m', '1955/February/5 3'); | ||
expectFilter(new Date(2013, 7, 11, 0, 46), 'd-MM-yy m', '11-08-13 46'); | ||
expectFilter(new Date(2015, 2, 22, 22, 3), 'd.MMMM.yy.HH:m', '22.March.15.22:3'); | ||
expectFilter(new Date(2015, 2, 22, 2, 1), 'd.MMMM.yy.H:m', '22.March.15.2:1'); | ||
}); | ||
it('should work correctly for `sss`', function() { | ||
expectFilter(new Date(2015, 2, 22, 0, 0, 0, 123), 'd.MMMM.yy.sss', '22.March.15.123'); | ||
expectFilter(new Date(1991, 2, 8, 0, 0, 0, 59), 'd-MMMM-yyyy-sss', '8-March-1991-059'); | ||
expectFilter(new Date(1980, 1, 5, 0, 0, 0), 'MMMM/d/yyyy/sss', 'February/5/1980/000'); | ||
expectFilter(new Date(1955, 1, 5, 0, 0, 0, 3), 'yyyy/MMMM/d sss', '1955/February/5 003'); | ||
expectFilter(new Date(2013, 7, 11, 0, 0, 0, 46), 'd-MM-yy sss', '11-08-13 046'); | ||
expectFilter(new Date(2015, 2, 22, 22, 33, 0, 44), 'd.MMMM.yy.HH:mm:sss', '22.March.15.22:33:044'); | ||
expectFilter(new Date(2015, 2, 22, 0, 0, 0, 1), 'd.MMMM.yy.H:m:sss', '22.March.15.0:0:001'); | ||
}); | ||
it('should work correctly for `ss`', function() { | ||
expectFilter(new Date(2015, 2, 22, 0, 0, 22), 'd.MMMM.yy.ss', '22.March.15.22'); | ||
expectFilter(new Date(1991, 2, 8, 0, 0, 59), 'd-MMMM-yyyy-ss', '8-March-1991-59'); | ||
expectFilter(new Date(1980, 1, 5, 0, 0, 0), 'MMMM/d/yyyy/ss', 'February/5/1980/00'); | ||
expectFilter(new Date(1955, 1, 5, 0, 0, 3), 'yyyy/MMMM/d ss', '1955/February/5 03'); | ||
expectFilter(new Date(2013, 7, 11, 0, 0, 46), 'd-MM-yy ss', '11-08-13 46'); | ||
expectFilter(new Date(2015, 2, 22, 22, 33, 44), 'd.MMMM.yy.HH:mm:ss', '22.March.15.22:33:44'); | ||
expectFilter(new Date(2015, 2, 22, 0, 0, 1), 'd.MMMM.yy.H:m:ss', '22.March.15.0:0:01'); | ||
}); | ||
it('should work correctly for `s`', function() { | ||
expectFilter(new Date(2015, 2, 22, 0, 0, 22), 'd.MMMM.yy.s', '22.March.15.22'); | ||
expectFilter(new Date(1991, 2, 8, 0, 0, 59), 'd-MMMM-yyyy-s', '8-March-1991-59'); | ||
expectFilter(new Date(1980, 1, 5, 0, 0, 0), 'MMMM/d/yyyy/s', 'February/5/1980/0'); | ||
expectFilter(new Date(1955, 1, 5, 0, 0, 3), 'yyyy/MMMM/d s', '1955/February/5 3'); | ||
expectFilter(new Date(2013, 7, 11, 0, 0, 46), 'd-MM-yy s', '11-08-13 46'); | ||
expectFilter(new Date(2015, 2, 22, 22, 33, 4), 'd.MMMM.yy.HH:mm:s', '22.March.15.22:33:4'); | ||
expectFilter(new Date(2015, 2, 22, 22, 3, 4), 'd.MMMM.yy.HH:m:s', '22.March.15.22:3:4'); | ||
}); | ||
it('should work correctly for `a`', function() { | ||
expectFilter(new Date(2015, 2, 22, 10), 'd.MMMM.yy.hha', '22.March.15.10AM'); | ||
expectFilter(new Date(2015, 2, 22, 22), 'd.MMMM.yy.hha', '22.March.15.10PM'); | ||
expectFilter(new Date(1991, 2, 8, 11), 'd-MMMM-yyyy-hha', '8-March-1991-11AM'); | ||
expectFilter(new Date(1991, 2, 8, 23), 'd-MMMM-yyyy-hha', '8-March-1991-11PM'); | ||
expectFilter(new Date(1980, 1, 5, 0), 'MMMM/d/yyyy/hha', 'February/5/1980/12AM'); | ||
expectFilter(new Date(1980, 1, 5, 12), 'MMMM/d/yyyy/hha', 'February/5/1980/12PM'); | ||
expectFilter(new Date(1955, 1, 5, 3), 'yyyy/MMMM/d hha', '1955/February/5 03AM'); | ||
expectFilter(new Date(1955, 1, 5, 15), 'yyyy/MMMM/d hha', '1955/February/5 03PM'); | ||
expectFilter(new Date(2013, 7, 11, 9), 'd-MM-yy hha', '11-08-13 09AM'); | ||
expectFilter(new Date(2013, 7, 11, 21), 'd-MM-yy hha', '11-08-13 09PM'); | ||
}); | ||
it('should work correctly for `ww`', function() { | ||
expectFilter(new Date(2013, 10, 17, 0), 'd.MMMM.yy.ww', '17.November.13.47'); | ||
expectFilter(new Date(1991, 2, 8, 0), 'd-MMMM-yyyy-ww', '8-March-1991-10'); | ||
expectFilter(new Date(1980, 1, 5, 0), 'MMMM/d/yyyy/ww', 'February/5/1980/06'); | ||
expectFilter(new Date(1955, 1, 5, 0), 'yyyy/MMMM/d/ww', '1955/February/5/05'); | ||
expectFilter(new Date(2013, 7, 11, 0), 'd-MM-yy ww', '11-08-13 33'); | ||
expectFilter(oldDate, 'yyyy/MM/d ww', '0001/03/6 10'); | ||
}); | ||
it('should work correctly for `w`', function() { | ||
expectFilter(new Date(2013, 10, 17, 0), 'd.MMMM.yy.w', '17.November.13.47'); | ||
expectFilter(new Date(1991, 2, 8, 0), 'd-MMMM-yyyy-w', '8-March-1991-10'); | ||
expectFilter(new Date(1980, 1, 5, 0), 'MMMM/d/yyyy/w', 'February/5/1980/6'); | ||
expectFilter(new Date(1955, 1, 5, 0), 'yyyy/MMMM/d/w', '1955/February/5/5'); | ||
expectFilter(new Date(2013, 7, 11, 0), 'd-MM-yy w', '11-08-13 33'); | ||
expectFilter(oldDate, 'yyyy/MM/d w', '0001/03/6 10'); | ||
}); | ||
it('should work correctly for `G`', function() { | ||
expectFilter(new Date(2013, 10, 17, 0), 'd.MMMM.yy.G', '17.November.13.AD'); | ||
expectFilter(new Date(-1991, 2, 8, 0), 'd-MMMM-yyyy-G', '8-March-1991-BC'); | ||
expectFilter(new Date(1980, 1, 5, 0), 'MMMM/d/yyyy/G', 'February/5/1980/AD'); | ||
expectFilter(new Date(-1955, 1, 5, 0), 'yyyy/MMMM/d/G', '1955/February/5/BC'); | ||
expectFilter(new Date(2013, 7, 11, 0), 'd-MM-yy G', '11-08-13 AD'); | ||
}); | ||
it('should work correctly for `GG`', function() { | ||
expectFilter(new Date(2013, 10, 17, 0), 'd.MMMM.yy.GG', '17.November.13.AD'); | ||
expectFilter(new Date(-1991, 2, 8, 0), 'd-MMMM-yyyy-GG', '8-March-1991-BC'); | ||
expectFilter(new Date(1980, 1, 5, 0), 'MMMM/d/yyyy/GG', 'February/5/1980/AD'); | ||
expectFilter(new Date(-1955, 1, 5, 0), 'yyyy/MMMM/d/GG', '1955/February/5/BC'); | ||
expectFilter(new Date(2013, 7, 11, 0), 'd-MM-yy GG', '11-08-13 AD'); | ||
}); | ||
it('should work correctly for `GGG`', function() { | ||
expectFilter(new Date(2013, 10, 17, 0), 'd.MMMM.yy.GGG', '17.November.13.AD'); | ||
expectFilter(new Date(-1991, 2, 8, 0), 'd-MMMM-yyyy-GGG', '8-March-1991-BC'); | ||
expectFilter(new Date(1980, 1, 5, 0), 'MMMM/d/yyyy/GGG', 'February/5/1980/AD'); | ||
expectFilter(new Date(-1955, 1, 5, 0), 'yyyy/MMMM/d/GGG', '1955/February/5/BC'); | ||
expectFilter(new Date(2013, 7, 11, 0), 'd-MM-yy GGG', '11-08-13 AD'); | ||
}); | ||
it('should work correctly for `GGGG`', function() { | ||
expectFilter(new Date(2013, 10, 17, 0), 'd.MMMM.yy.GGGG', '17.November.13.Anno Domini'); | ||
expectFilter(new Date(-1991, 2, 8, 0), 'd-MMMM-yyyy-GGGG', '8-March-1991-Before Christ'); | ||
expectFilter(new Date(1980, 1, 5, 0), 'MMMM/d/yyyy/GGGG', 'February/5/1980/Anno Domini'); | ||
expectFilter(new Date(-1955, 1, 5, 0), 'yyyy/MMMM/d/GGGG', '1955/February/5/Before Christ'); | ||
expectFilter(new Date(2013, 7, 11, 0), 'd-MM-yy GGGG', '11-08-13 Anno Domini'); | ||
}); | ||
}); | ||
describe('with custom formats', function() { | ||
@@ -396,3 +643,2 @@ it('should work correctly for `dd`, `MM`, `yyyy`', function() { | ||
describe('timezone functions', function() { | ||
@@ -399,0 +645,0 @@ describe('toTimezone', function() { |
@@ -34,46 +34,164 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootstrap.isClass', 'ui.bootstrap.position']) | ||
// Interpolated configuration attributes | ||
angular.forEach(['formatDay', 'formatMonth', 'formatYear', 'formatDayHeader', 'formatDayTitle', 'formatMonthTitle'], function(key) { | ||
self[key] = angular.isDefined($attrs[key]) ? $interpolate($attrs[key])($scope.$parent) : datepickerConfig[key]; | ||
}); | ||
if ($attrs.datepickerOptions) { | ||
angular.forEach([ | ||
'formatDay', | ||
'formatDayHeader', | ||
'formatDayTitle', | ||
'formatMonth', | ||
'formatMonthTitle', | ||
'formatYear', | ||
'initDate', | ||
'maxDate', | ||
'maxMode', | ||
'minDate', | ||
'minMode', | ||
'showWeeks', | ||
'shortcutPropagation', | ||
'startingDay', | ||
'yearColumns', | ||
'yearRows' | ||
], function(key) { | ||
switch (key) { | ||
case 'formatDay': | ||
case 'formatDayHeader': | ||
case 'formatDayTitle': | ||
case 'formatMonth': | ||
case 'formatMonthTitle': | ||
case 'formatYear': | ||
self[key] = angular.isDefined($scope.datepickerOptions[key]) ? $interpolate($scope.datepickerOptions[key])($scope.$parent) : datepickerConfig[key]; | ||
break; | ||
case 'showWeeks': | ||
case 'shortcutPropagation': | ||
case 'yearColumns': | ||
case 'yearRows': | ||
self[key] = angular.isDefined($scope.datepickerOptions[key]) ? | ||
$scope.datepickerOptions[key] : datepickerConfig[key]; | ||
break; | ||
case 'startingDay': | ||
if (angular.isDefined($scope.datepickerOptions.startingDay)) { | ||
self.startingDay = $scope.datepickerOptions.startingDay; | ||
} else if (angular.isNumber(datepickerConfig.startingDay)) { | ||
self.startingDay = datepickerConfig.startingDay; | ||
} else { | ||
self.startingDay = ($locale.DATETIME_FORMATS.FIRSTDAYOFWEEK + 8) % 7; | ||
} | ||
// Evaled configuration attributes | ||
angular.forEach(['showWeeks', 'yearRows', 'yearColumns', 'shortcutPropagation'], function(key) { | ||
self[key] = angular.isDefined($attrs[key]) ? | ||
$scope.$parent.$eval($attrs[key]) : datepickerConfig[key]; | ||
}); | ||
break; | ||
case 'maxDate': | ||
case 'minDate': | ||
if ($scope.datepickerOptions[key]) { | ||
$scope.$watch(function() { return $scope.datepickerOptions[key]; }, function(value) { | ||
if (value) { | ||
if (angular.isDate(value)) { | ||
self[key] = dateParser.fromTimezone(new Date(value), ngModelOptions.timezone); | ||
} else { | ||
self[key] = new Date(dateFilter(value, 'medium')); | ||
} | ||
} else { | ||
self[key] = null; | ||
} | ||
if (angular.isDefined($attrs.startingDay)) { | ||
self.startingDay = $scope.$parent.$eval($attrs.startingDay); | ||
} else if (angular.isNumber(datepickerConfig.startingDay)) { | ||
self.startingDay = datepickerConfig.startingDay; | ||
self.refreshView(); | ||
}); | ||
} else { | ||
self[key] = datepickerConfig[key] ? dateParser.fromTimezone(new Date(datepickerConfig[key]), ngModelOptions.timezone) : null; | ||
} | ||
break; | ||
case 'maxMode': | ||
case 'minMode': | ||
if ($scope.datepickerOptions[key]) { | ||
$scope.$watch(function() { return $scope.datepickerOptions[key]; }, function(value) { | ||
self[key] = $scope[key] = angular.isDefined(value) ? value : datepickerOptions[key]; | ||
if (key === 'minMode' && self.modes.indexOf($scope.datepickerMode) < self.modes.indexOf(self[key]) || | ||
key === 'maxMode' && self.modes.indexOf($scope.datepickerMode) > self.modes.indexOf(self[key])) { | ||
$scope.datepickerMode = self[key]; | ||
} | ||
}); | ||
} else { | ||
self[key] = $scope[key] = datepickerConfig[key] || null; | ||
} | ||
break; | ||
case 'initDate': | ||
if ($scope.datepickerOptions.initDate) { | ||
this.activeDate = dateParser.fromTimezone($scope.datepickerOptions.initDate, ngModelOptions.timezone) || new Date(); | ||
$scope.$watch(function() { return $scope.datepickerOptions.initDate; }, function(initDate) { | ||
if (initDate && (ngModelCtrl.$isEmpty(ngModelCtrl.$modelValue) || ngModelCtrl.$invalid)) { | ||
self.activeDate = dateParser.fromTimezone(initDate, ngModelOptions.timezone); | ||
self.refreshView(); | ||
} | ||
}); | ||
} else { | ||
this.activeDate = new Date(); | ||
} | ||
} | ||
}); | ||
} else { | ||
self.startingDay = ($locale.DATETIME_FORMATS.FIRSTDAYOFWEEK + 8) % 7; | ||
} | ||
// Interpolated configuration attributes | ||
angular.forEach(['formatDay', 'formatMonth', 'formatYear', 'formatDayHeader', 'formatDayTitle', 'formatMonthTitle'], function(key) { | ||
self[key] = angular.isDefined($attrs[key]) ? $interpolate($attrs[key])($scope.$parent) : datepickerConfig[key]; | ||
}); | ||
// Watchable date attributes | ||
angular.forEach(['minDate', 'maxDate'], function(key) { | ||
if ($attrs[key]) { | ||
watchListeners.push($scope.$parent.$watch($attrs[key], function(value) { | ||
self[key] = value ? angular.isDate(value) ? dateParser.fromTimezone(new Date(value), ngModelOptions.timezone) : new Date(dateFilter(value, 'medium')) : null; | ||
self.refreshView(); | ||
})); | ||
// Evaled configuration attributes | ||
angular.forEach(['showWeeks', 'yearRows', 'yearColumns', 'shortcutPropagation'], function(key) { | ||
self[key] = angular.isDefined($attrs[key]) ? | ||
$scope.$parent.$eval($attrs[key]) : datepickerConfig[key]; | ||
}); | ||
if (angular.isDefined($attrs.startingDay)) { | ||
self.startingDay = $scope.$parent.$eval($attrs.startingDay); | ||
} else if (angular.isNumber(datepickerConfig.startingDay)) { | ||
self.startingDay = datepickerConfig.startingDay; | ||
} else { | ||
self[key] = datepickerConfig[key] ? dateParser.fromTimezone(new Date(datepickerConfig[key]), ngModelOptions.timezone) : null; | ||
self.startingDay = ($locale.DATETIME_FORMATS.FIRSTDAYOFWEEK + 8) % 7; | ||
} | ||
}); | ||
angular.forEach(['minMode', 'maxMode'], function(key) { | ||
if ($attrs[key]) { | ||
watchListeners.push($scope.$parent.$watch($attrs[key], function(value) { | ||
self[key] = $scope[key] = angular.isDefined(value) ? value : $attrs[key]; | ||
if (key === 'minMode' && self.modes.indexOf($scope.datepickerMode) < self.modes.indexOf(self[key]) || | ||
key === 'maxMode' && self.modes.indexOf($scope.datepickerMode) > self.modes.indexOf(self[key])) { | ||
$scope.datepickerMode = self[key]; | ||
// Watchable date attributes | ||
angular.forEach(['minDate', 'maxDate'], function(key) { | ||
if ($attrs[key]) { | ||
watchListeners.push($scope.$parent.$watch($attrs[key], function(value) { | ||
if (value) { | ||
if (angular.isDate(value)) { | ||
self[key] = dateParser.fromTimezone(new Date(value), ngModelOptions.timezone); | ||
} else { | ||
self[key] = new Date(dateFilter(value, 'medium')); | ||
} | ||
} else { | ||
self[key] = null; | ||
} | ||
self.refreshView(); | ||
})); | ||
} else { | ||
self[key] = datepickerConfig[key] ? dateParser.fromTimezone(new Date(datepickerConfig[key]), ngModelOptions.timezone) : null; | ||
} | ||
}); | ||
angular.forEach(['minMode', 'maxMode'], function(key) { | ||
if ($attrs[key]) { | ||
watchListeners.push($scope.$parent.$watch($attrs[key], function(value) { | ||
self[key] = $scope[key] = angular.isDefined(value) ? value : $attrs[key]; | ||
if (key === 'minMode' && self.modes.indexOf($scope.datepickerMode) < self.modes.indexOf(self[key]) || | ||
key === 'maxMode' && self.modes.indexOf($scope.datepickerMode) > self.modes.indexOf(self[key])) { | ||
$scope.datepickerMode = self[key]; | ||
} | ||
})); | ||
} else { | ||
self[key] = $scope[key] = datepickerConfig[key] || null; | ||
} | ||
}); | ||
if (angular.isDefined($attrs.initDate)) { | ||
this.activeDate = dateParser.fromTimezone($scope.$parent.$eval($attrs.initDate), ngModelOptions.timezone) || new Date(); | ||
watchListeners.push($scope.$parent.$watch($attrs.initDate, function(initDate) { | ||
if (initDate && (ngModelCtrl.$isEmpty(ngModelCtrl.$modelValue) || ngModelCtrl.$invalid)) { | ||
self.activeDate = dateParser.fromTimezone(initDate, ngModelOptions.timezone); | ||
self.refreshView(); | ||
} | ||
})); | ||
} else { | ||
self[key] = $scope[key] = datepickerConfig[key] || null; | ||
this.activeDate = new Date(); | ||
} | ||
}); | ||
} | ||
@@ -83,14 +201,2 @@ $scope.datepickerMode = $scope.datepickerMode || datepickerConfig.datepickerMode; | ||
if (angular.isDefined($attrs.initDate)) { | ||
this.activeDate = dateParser.fromTimezone($scope.$parent.$eval($attrs.initDate), ngModelOptions.timezone) || new Date(); | ||
watchListeners.push($scope.$parent.$watch($attrs.initDate, function(initDate) { | ||
if (initDate && (ngModelCtrl.$isEmpty(ngModelCtrl.$modelValue) || ngModelCtrl.$invalid)) { | ||
self.activeDate = dateParser.fromTimezone(initDate, ngModelOptions.timezone); | ||
self.refreshView(); | ||
} | ||
})); | ||
} else { | ||
this.activeDate = new Date(); | ||
} | ||
$scope.disabled = angular.isDefined($attrs.disabled) || false; | ||
@@ -159,3 +265,3 @@ if (angular.isDefined($attrs.ngDisabled)) { | ||
date: date, | ||
label: dateFilter(date, format.replace(/d!/, 'dd')).replace(/M!/, 'MM'), | ||
label: dateParser.filter(date, format), | ||
selected: model && this.compare(date, model) === 0, | ||
@@ -507,2 +613,3 @@ disabled: this.isDisabled(date), | ||
datepickerMode: '=?', | ||
datepickerOptions: '=?', | ||
dateDisabled: '&', | ||
@@ -748,7 +855,10 @@ customClass: '&', | ||
} | ||
scope.date = dateParser.fromTimezone(value, ngModelOptions.timezone); | ||
dateFormat = dateFormat.replace(/M!/, 'MM') | ||
.replace(/d!/, 'dd'); | ||
return dateFilter(scope.date, dateFormat); | ||
if (angular.isNumber(scope.date)) { | ||
scope.date = new Date(scope.date); | ||
} | ||
return dateParser.filter(scope.date, dateFormat); | ||
}); | ||
@@ -821,3 +931,3 @@ } else { | ||
} | ||
var date = scope.date ? dateFilter(scope.date, dateFormat) : null; // Setting to NULL is necessary for form validators to function | ||
var date = scope.date ? dateParser.filter(scope.date, dateFormat) : null; // Setting to NULL is necessary for form validators to function | ||
element.val(date); | ||
@@ -824,0 +934,0 @@ ngModel.$setViewValue(date); |
@@ -30,2 +30,25 @@ Our datepicker is flexible and fully customizable. | ||
* `datepicker-options` | ||
<small class="badge">$</small> - | ||
An optional object to configure the datepicker in one place. If this attribute is used, all supported options must be specified instead of the attributes. | ||
The supported options are: | ||
- formatDay | ||
- formatDayHeader | ||
- formatDayTitle | ||
- formatMonth | ||
- formatMonthTitle | ||
- formatYear | ||
- initDate | ||
- maxDate | ||
- maxMode | ||
- minDate | ||
- minMode | ||
- shortcutPropagation | ||
- showWeeks | ||
- startingDay | ||
- yearColumns | ||
- yearRows | ||
* `format-day` | ||
@@ -123,3 +146,3 @@ <small class="badge">C</small> | ||
<small class="badge">C</small> | ||
_(Default: `$locale.DATETIME_FORMATS.FIRSTDAYOFWEEK`)_ - | ||
*(Default: `$locale.DATETIME_FORMATS.FIRSTDAYOFWEEK`)* - | ||
Starting day of the week from 0-6 (0=Sunday, ..., 6=Saturday). | ||
@@ -126,0 +149,0 @@ |
@@ -407,3 +407,3 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap']) | ||
if (evt.shiftKey) { | ||
if ($modalStack.isFocusInFirstItem(evt)) { | ||
if ($modalStack.isFocusInFirstItem(evt) || $modalStack.isModalFocused(evt, modal)) { | ||
focusChanged = $modalStack.focusLastFocusableElement(); | ||
@@ -551,2 +551,12 @@ } | ||
$modalStack.isModalFocused = function(evt, modalWindow) { | ||
if (evt && modalWindow) { | ||
var modalDomEl = modalWindow.value.modalDomEl; | ||
if (modalDomEl && modalDomEl.length) { | ||
return (evt.target || evt.srcElement) === modalDomEl[0]; | ||
} | ||
} | ||
return false; | ||
}; | ||
$modalStack.isFocusInFirstItem = function(evt) { | ||
@@ -553,0 +563,0 @@ if (focusableElementList.length > 0) { |
@@ -623,7 +623,11 @@ describe('$uibResolve', function() { | ||
}); | ||
$rootScope.$digest(); | ||
expect($document).toHaveModalsOpen(1); | ||
triggerKeyDown(angular.element(document.activeElement), 9, true); | ||
expect(document.activeElement.getAttribute('id')).toBe('tab-focus-button'); | ||
var lastElement = angular.element(document.getElementById('tab-focus-link')); | ||
lastElement.focus(); | ||
triggerKeyDown(lastElement, 9, true); | ||
triggerKeyDown(angular.element(document.activeElement), 9, true); | ||
expect(document.activeElement.getAttribute('id')).toBe('tab-focus-button'); | ||
@@ -664,7 +668,11 @@ | ||
}); | ||
$rootScope.$digest(); | ||
expect($document).toHaveModalsOpen(1); | ||
triggerKeyDown(angular.element(document.activeElement), 9, true); | ||
expect(document.activeElement.getAttribute('id')).toBe('tab-focus-button'); | ||
var lastElement = angular.element(document.getElementById('tab-focus-link')); | ||
lastElement.focus(); | ||
triggerKeyDown(lastElement, 9, true); | ||
triggerKeyDown(angular.element(document.activeElement), 9, true); | ||
expect(document.activeElement.getAttribute('id')).toBe('tab-focus-button'); | ||
@@ -671,0 +679,0 @@ |
@@ -1001,21 +1001,2 @@ describe('tooltip', function() { | ||
it('should close on location change', inject(function($rootScope, $compile) { | ||
elmBody = angular.element( | ||
'<div><span uib-tooltip="tooltip text">Selector Text</span></div>' | ||
); | ||
scope = $rootScope; | ||
$compile(elmBody)(scope); | ||
scope.$digest(); | ||
elm = elmBody.find('span'); | ||
elmScope = elm.scope(); | ||
tooltipScope = elmScope.$$childTail; | ||
trigger(elm, 'mouseenter'); | ||
expect(tooltipScope.isOpen).toBe(true); | ||
scope.$broadcast('$locationChangeSuccess'); | ||
scope.$digest(); | ||
expect(tooltipScope.isOpen).toBe(false); | ||
})); | ||
}); | ||
@@ -1022,0 +1003,0 @@ |
@@ -543,14 +543,3 @@ /** | ||
appendToBody = angular.isDefined(appendToBodyVal) ? appendToBodyVal : appendToBody; | ||
// if a tooltip is attached to <body> we need to remove it on | ||
// location change as its parent scope will probably not be destroyed | ||
// by the change. | ||
if (appendToBody) { | ||
scope.$on('$locationChangeSuccess', function closeTooltipOnLocationChangeSuccess() { | ||
if (ttScope.isOpen) { | ||
hide(); | ||
} | ||
}); | ||
} | ||
// Make sure tooltip is destroyed and removed. | ||
@@ -557,0 +546,0 @@ scope.$on('$destroy', function onDestroyTooltip() { |
@@ -250,6 +250,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap.position']) | ||
var firstLabel = scope.matches[0].label; | ||
if (inputValue.length > 0 && firstLabel.slice(0, inputValue.length).toUpperCase() === inputValue.toUpperCase()) { | ||
if (angular.isString(inputValue) && | ||
inputValue.length > 0 && | ||
firstLabel.slice(0, inputValue.length).toUpperCase() === inputValue.toUpperCase()) { | ||
hintInputElem.val(inputValue + firstLabel.slice(inputValue.length)); | ||
} | ||
else { | ||
} else { | ||
hintInputElem.val(''); | ||
@@ -256,0 +257,0 @@ } |
angular.module("uib/template/accordion/accordion-group.html", []).run(["$templateCache", function($templateCache) { | ||
$templateCache.put("uib/template/accordion/accordion-group.html", | ||
"<div class=\"panel\" ng-class=\"panelClass || 'panel-default'\">\n" + | ||
" <div class=\"panel-heading\" ng-keypress=\"toggleOpen($event)\">\n" + | ||
" <div role=\"tab\" id=\"{{::headingId}}\" aria-selected=\"{{isOpen}}\" class=\"panel-heading\" ng-keypress=\"toggleOpen($event)\">\n" + | ||
" <h4 class=\"panel-title\">\n" + | ||
" <a href tabindex=\"0\" class=\"accordion-toggle\" ng-click=\"toggleOpen()\" uib-accordion-transclude=\"heading\"><span ng-class=\"{'text-muted': isDisabled}\">{{heading}}</span></a>\n" + | ||
" <a role=\"button\" data-toggle=\"collapse\" href aria-expanded=\"{{isOpen}}\" aria-controls=\"{{::panelId}}\" tabindex=\"0\" class=\"accordion-toggle\" ng-click=\"toggleOpen()\" uib-accordion-transclude=\"heading\"><span ng-class=\"{'text-muted': isDisabled}\">{{heading}}</span></a>\n" + | ||
" </h4>\n" + | ||
" </div>\n" + | ||
" <div class=\"panel-collapse collapse\" uib-collapse=\"!isOpen\">\n" + | ||
" <div class=\"panel-body\" ng-transclude></div>\n" + | ||
" <div id=\"{{::panelId}}\" aria-labelledby=\"{{::headingId}}\" aria-hidden=\"{{!isOpen}}\" role=\"tabpanel\" class=\"panel-collapse collapse\" uib-collapse=\"!isOpen\">\n" + | ||
" <div class=\"panel-body\" ng-transclude></div>\n" + | ||
" </div>\n" + | ||
@@ -12,0 +12,0 @@ "</div>\n" + |
angular.module("uib/template/accordion/accordion.html", []).run(["$templateCache", function($templateCache) { | ||
$templateCache.put("uib/template/accordion/accordion.html", | ||
"<div class=\"panel-group\" ng-transclude></div>"); | ||
"<div role=\"tablist\" class=\"panel-group\" ng-transclude></div>"); | ||
}]); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1649832
33322