Skip to content

Commit

Permalink
Fixes for review findings
Browse files Browse the repository at this point in the history
  • Loading branch information
tomivirkki committed Feb 9, 2016
1 parent fe0f6b9 commit 658bdf3
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"iron-icon": "polymerelements/iron-icon#~1.0.7",
"iron-icons": "polymerelements/iron-icons#~1.1.2",
"iron-input": "polymerelements/iron-input#~1.0.8",
"iron-list": "polymerelements/iron-list#~1.2.0",
"iron-list": "polymerelements/iron-list#~1.0.0",
"paper-input": "polymerelements/paper-input#~1.1.5",
"polymer": "Polymer/polymer#^1.2.0",
"paper-styles": "polymerelements/paper-styles#^1.1.3"
Expand Down
13 changes: 10 additions & 3 deletions test/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,20 @@
expect(spy.calledOnce).to.be.true;
});

it('should open on tap', function(done) {
it('should open on input tap', function(done) {
datepicker.addEventListener('iron-overlay-opened', function() {
done();
});
tap(datepicker.$.input);
});

it('should open on label tap', function(done) {
datepicker.addEventListener('iron-overlay-opened', function() {
done();
});
tap(datepicker.$.label);
});

it('should scroll to today by default', function(done) {
var spy = sinon.spy(datepicker.$.overlay, 'scrollToDate');
datepicker.addEventListener('iron-overlay-opened', function() {
Expand All @@ -74,12 +81,12 @@
datepicker._open();
});

it('should close on overlay datetap', function(done) {
it('should close on overlay date tap', function(done) {
datepicker.addEventListener('iron-overlay-closed', function() {
done();
});
datepicker.addEventListener('iron-overlay-opened', function() {
Polymer.Base.fire('datetap', {}, {
Polymer.Base.fire('date-tap', {}, {
bubbles: true,
node: datepicker.$.overlay
});
Expand Down
4 changes: 2 additions & 2 deletions test/month-calendar.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@
expect(valueChangedSpy.calledOnce).to.be.true;
});

it('should fire datetap on tap', function() {
it('should fire date-tap on tap', function() {
tapSpy = sinon.spy();
monthCalendar.addEventListener('datetap', tapSpy);
monthCalendar.addEventListener('date-tap', tapSpy);
var dateElements = monthCalendar.$.monthGrid.querySelectorAll('div:not(.weekday):not(:empty)');
tap(dateElements[10]);
expect(tapSpy.calledOnce).to.be.true;
Expand Down
17 changes: 10 additions & 7 deletions vaadin-date-picker-overlay.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-list/iron-list.html">
<link rel="import" href="../paper-styles/shadow.html">
<link rel="import" href="../paper-styles/typography.html">
<link rel="import" href="vaadin-month-calendar.html">

<dom-module id="vaadin-date-picker-overlay">
Expand Down Expand Up @@ -73,9 +74,11 @@

_visibleMonthIndex: Number,

_months: Array,
_months: {
computed: '_computeMonths(_originIndex)'
},

// As iron-list isn't two way scrollable by default, it needs to pre-scrolled
// As iron-list isn't two way scrollable by default, it needs to be pre-scrolled
// to an index in the middle beforehand. This property states the index of the
// 'origin' position in the array and also dictates the array size at the same
// time.
Expand All @@ -85,12 +88,12 @@

},

ready: function() {
_computeMonths: function(_originIndex) {
var months = [];
for (var i = -this._originIndex; i < this._originIndex; i++) {
months.push(i);
for (var i = -_originIndex; i < _originIndex; i++) {
months.push('' + i);
}
this._months = months;
return months;
},

/**
Expand All @@ -110,7 +113,7 @@

_dateAfterXMonths: function(date, months) {
var result = new Date(date);
result.setMonth(months + date.getMonth());
result.setMonth(parseInt(months) + date.getMonth());
return result;
},

Expand Down
4 changes: 2 additions & 2 deletions vaadin-date-picker.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
@license
Copyright (c) 2015 Vaadin Ltd.
Copyright (c) 2016 Vaadin Ltd.
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
-->

Expand Down Expand Up @@ -60,7 +60,7 @@
</paper-input-container>

<iron-dropdown id="dropdown" allow-outside-scroll on-iron-overlay-opened="_onOverlayOpened" opened="{{_opened}}">
<vaadin-date-picker-overlay id="overlay" on-datetap="_close" selected-date="{{value}}" class="dropdown-content"></vaadin-date-picker-overlay>
<vaadin-date-picker-overlay id="overlay" on-date-tap="_close" selected-date="{{value}}" class="dropdown-content"></vaadin-date-picker-overlay>
</iron-dropdown>

</template>
Expand Down
3 changes: 2 additions & 1 deletion vaadin-month-calendar.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../paper-styles/typography.html">

<dom-module id="vaadin-month-calendar">
<template>
Expand Down Expand Up @@ -181,7 +182,7 @@
_handleTap: function(e) {
if (e.target.date) {
this.selectedDate = e.target.date;
this.fire('datetap');
this.fire('date-tap');
}
}

Expand Down

0 comments on commit 658bdf3

Please sign in to comment.