Skip to content

Commit caaaf5c

Browse files
committed
Merge pull request #129 from elpic/master
Add class to the datetimepicker div that indicate the current view - year-view, month-view, day-view, hour-view, and minute-view
2 parents 6dd5eae + ceb90f8 commit caaaf5c

File tree

16 files changed

+278
-2
lines changed

16 files changed

+278
-2
lines changed

src/js/datetimepicker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
return {
9797
restrict: 'E',
9898
require: 'ngModel',
99-
template: '<div class="datetimepicker table-responsive">' +
99+
template: '<div class="datetimepicker table-responsive {{data.currentView}}-view">' +
100100
'<table class="table table-striped">' +
101101
' <thead>' +
102102
' <tr>' +

test/view/de/day.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,25 @@
1212
* @since 7/21/13
1313
*/
1414

15+
describe('current view displayed on the markup', function(){
16+
'use strict';
17+
18+
var $rootScope, element;
19+
20+
beforeEach(module('ui.bootstrap.datetimepicker'));
21+
beforeEach(inject(function (_$compile_, _$rootScope_) {
22+
moment.locale('de');
23+
$rootScope = _$rootScope_;
24+
$rootScope.date = moment('2013-01-22T00:00:00.000').toDate();
25+
element = _$compile_('<datetimepicker data-datetimepicker-config="{ startView: \'day\'}" data-ng-model="date"></datetimepicker>')($rootScope);
26+
$rootScope.$digest();
27+
}));
28+
29+
it('should have `.day-view` class', function () {
30+
expect(jQuery(element).hasClass('day-view')).toBeTruthy();
31+
});
32+
});
33+
1534
describe('German day view with initial date of 2013-01-22', function () {
1635
'use strict';
1736
var $rootScope, element;

test/view/de/hour.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,24 @@
1212
* @since 7/21/13
1313
*/
1414

15+
describe('current view displayed on the markup', function(){
16+
'use strict';
17+
18+
var $rootScope, element;
19+
20+
beforeEach(module('ui.bootstrap.datetimepicker'));
21+
beforeEach(inject(function (_$compile_, _$rootScope_) {
22+
moment.locale('de');
23+
$rootScope = _$rootScope_;
24+
$rootScope.date = moment('2013-01-22T00:00:00.000').toDate();
25+
element = _$compile_('<datetimepicker data-datetimepicker-config="{ startView: \'hour\'}" data-ng-model="date"></datetimepicker>')($rootScope);
26+
$rootScope.$digest();
27+
}));
28+
29+
it('should have `.hour-view` class', function () {
30+
expect(jQuery(element).hasClass('hour-view')).toBeTruthy();
31+
});
32+
});
1533

1634
describe('hour view with initial date of 2013-01-22', function () {
1735
'use strict';

test/view/de/minute.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,24 @@
1212
* @since 7/21/13
1313
*/
1414

15+
describe('current view displayed on the markup', function(){
16+
'use strict';
17+
18+
var $rootScope, element;
19+
20+
beforeEach(module('ui.bootstrap.datetimepicker'));
21+
beforeEach(inject(function (_$compile_, _$rootScope_) {
22+
moment.locale('de');
23+
$rootScope = _$rootScope_;
24+
$rootScope.date = moment('2013-01-22T00:00:00.000').toDate();
25+
element = _$compile_('<datetimepicker data-datetimepicker-config="{ startView: \'minute\'}" data-ng-model="date"></datetimepicker>')($rootScope);
26+
$rootScope.$digest();
27+
}));
28+
29+
it('should have `.minute-view` class', function () {
30+
expect(jQuery(element).hasClass('minute-view')).toBeTruthy();
31+
});
32+
});
1533

1634
describe('minute view with initial date of 2013-01-22 0:00', function () {
1735
'use strict';

test/view/de/month.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,24 @@
1212
* @since 7/21/13
1313
*/
1414

15+
describe('current view displayed on the markup', function(){
16+
'use strict';
17+
18+
var $rootScope, element;
19+
20+
beforeEach(module('ui.bootstrap.datetimepicker'));
21+
beforeEach(inject(function (_$compile_, _$rootScope_) {
22+
moment.locale('de');
23+
$rootScope = _$rootScope_;
24+
$rootScope.date = moment('2013-01-22T00:00:00.000').toDate();
25+
element = _$compile_('<datetimepicker data-datetimepicker-config="{ startView: \'month\'}" data-ng-model="date"></datetimepicker>')($rootScope);
26+
$rootScope.$digest();
27+
}));
28+
29+
it('should have `.month-view` class', function () {
30+
expect(jQuery(element).hasClass('month-view')).toBeTruthy();
31+
});
32+
});
1533

1634
describe('month view with initial date of 2010-10-01', function () {
1735
'use strict';

test/view/de/year.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,25 @@
1212
* @since 7/21/13
1313
*/
1414

15+
describe('current view displayed on the markup', function(){
16+
'use strict';
17+
18+
var $rootScope, element;
19+
20+
beforeEach(module('ui.bootstrap.datetimepicker'));
21+
beforeEach(inject(function (_$compile_, _$rootScope_) {
22+
moment.locale('de');
23+
$rootScope = _$rootScope_;
24+
$rootScope.date = moment('2013-01-22T00:00:00.000').toDate();
25+
element = _$compile_('<datetimepicker data-datetimepicker-config="{ startView: \'year\'}" data-ng-model="date"></datetimepicker>')($rootScope);
26+
$rootScope.$digest();
27+
}));
28+
29+
it('should have `.year-view` class', function () {
30+
expect(jQuery(element).hasClass('year-view')).toBeTruthy();
31+
});
32+
});
33+
1534
describe('year view with ng-model = null', function () {
1635
'use strict';
1736
var $rootScope, $compile, element;

test/view/en/day.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,25 @@
1212
* @since 7/21/13
1313
*/
1414

15+
describe('current view displayed on the markup', function(){
16+
'use strict';
17+
18+
var $rootScope, element;
19+
20+
beforeEach(module('ui.bootstrap.datetimepicker'));
21+
beforeEach(inject(function (_$compile_, _$rootScope_) {
22+
moment.locale('en');
23+
$rootScope = _$rootScope_;
24+
$rootScope.date = moment('2013-01-22T00:00:00.000').toDate();
25+
element = _$compile_('<datetimepicker data-datetimepicker-config="{ startView: \'day\'}" data-ng-model="date"></datetimepicker>')($rootScope);
26+
$rootScope.$digest();
27+
}));
28+
29+
it('should have `.day-view` class', function () {
30+
expect(jQuery(element).hasClass('day-view')).toBeTruthy();
31+
});
32+
});
33+
1534
describe('English day view with initial date of 2013-01-22', function () {
1635
'use strict';
1736
var $rootScope, element;

test/view/en/hour.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,24 @@
1212
* @since 7/21/13
1313
*/
1414

15+
describe('current view displayed on the markup', function(){
16+
'use strict';
17+
18+
var $rootScope, element;
19+
20+
beforeEach(module('ui.bootstrap.datetimepicker'));
21+
beforeEach(inject(function (_$compile_, _$rootScope_) {
22+
moment.locale('en');
23+
$rootScope = _$rootScope_;
24+
$rootScope.date = moment('2013-01-22T00:00:00.000').toDate();
25+
element = _$compile_('<datetimepicker data-datetimepicker-config="{ startView: \'hour\'}" data-ng-model="date"></datetimepicker>')($rootScope);
26+
$rootScope.$digest();
27+
}));
28+
29+
it('should have `.hour-view` class', function () {
30+
expect(jQuery(element).hasClass('hour-view')).toBeTruthy();
31+
});
32+
});
1533

1634
describe('hour view with initial date of 2013-01-22', function () {
1735
'use strict';

test/view/en/minute.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,24 @@
1212
* @since 7/21/13
1313
*/
1414

15+
describe('current view displayed on the markup', function(){
16+
'use strict';
17+
18+
var $rootScope, element;
19+
20+
beforeEach(module('ui.bootstrap.datetimepicker'));
21+
beforeEach(inject(function (_$compile_, _$rootScope_) {
22+
moment.locale('en');
23+
$rootScope = _$rootScope_;
24+
$rootScope.date = moment('2013-01-22T00:00:00.000').toDate();
25+
element = _$compile_('<datetimepicker data-datetimepicker-config="{ startView: \'minute\'}" data-ng-model="date"></datetimepicker>')($rootScope);
26+
$rootScope.$digest();
27+
}));
28+
29+
it('should have `.minute-view` class', function () {
30+
expect(jQuery(element).hasClass('minute-view')).toBeTruthy();
31+
});
32+
});
1533

1634
describe('minute view with initial date of 2013-01-22 0:00', function () {
1735
'use strict';

test/view/en/month.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,24 @@
1212
* @since 7/21/13
1313
*/
1414

15+
describe('current view displayed on the markup', function(){
16+
'use strict';
17+
18+
var $rootScope, element;
19+
20+
beforeEach(module('ui.bootstrap.datetimepicker'));
21+
beforeEach(inject(function (_$compile_, _$rootScope_) {
22+
moment.locale('en');
23+
$rootScope = _$rootScope_;
24+
$rootScope.date = moment('2013-01-22T00:00:00.000').toDate();
25+
element = _$compile_('<datetimepicker data-datetimepicker-config="{ startView: \'month\'}" data-ng-model="date"></datetimepicker>')($rootScope);
26+
$rootScope.$digest();
27+
}));
28+
29+
it('should have `.month-view` class', function () {
30+
expect(jQuery(element).hasClass('month-view')).toBeTruthy();
31+
});
32+
});
1533

1634
describe('month view with initial date of 2010-10-01', function () {
1735
'use strict';

0 commit comments

Comments
 (0)