Skip to content

Commit

Permalink
Mark private and protected explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
pekam committed May 29, 2020
1 parent af0bfa8 commit c67805e
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/vaadin-time-picker.html
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@
*/
autoOpenDisabled: Boolean,

/** @private */
__dropdownItems: {
type: Array
},
Expand Down Expand Up @@ -383,6 +384,7 @@
];
}

/** @protected */
ready() {
super.ready();

Expand All @@ -407,11 +409,13 @@
});
}

/** @private */
__validDayDivisor(step) {
// valid if undefined, or exact divides a day, or has millisecond resolution
return !step || 24 * 3600 % step === 0 || (step < 1 && step % 1 * 1000 % 1 === 0);
}

/** @private */
__onKeyDown(e) {

if (this.readonly || this.disabled || this.__dropdownItems.length) {
Expand All @@ -427,20 +431,22 @@
}
}


/** @private */
__onArrowPressWithStep(step) {
const objWithStep = this.__addStep(this.__getMsec(this.__memoValue), step, true);
this.__memoValue = objWithStep;
this.__inputElement.value = this.i18n.formatTime(this.__validateTime(objWithStep));
this.__dispatchChange();
}

/** @private */
__dispatchChange() {
this.dispatchEvent(new CustomEvent('change', {bubbles: true}));
}

/**
* Returning milliseconds from Object in the format `{ hours: ..., minutes: ..., seconds: ..., milliseconds: ... }`
* @private
*/
__getMsec(obj) {
let result = (obj && obj.hours || 0) * 60 * 60 * 1000;
Expand All @@ -453,6 +459,7 @@

/**
* Returning seconds from Object in the format `{ hours: ..., minutes: ..., seconds: ..., milliseconds: ... }`
* @private
*/
__getSec(obj) {
let result = (obj && obj.hours || 0) * 60 * 60;
Expand All @@ -467,6 +474,7 @@
* Returning Object in the format `{ hours: ..., minutes: ..., seconds: ..., milliseconds: ... }`
* from the result of adding step value in milliseconds to the milliseconds amount.
* With `precision` parameter rounding the value to the closest step valid interval.
* @private
*/
__addStep(msec, step, precision) {
// If the time is `00:00` and step changes value downwards, it should be considered as `24:00`
Expand Down Expand Up @@ -494,6 +502,7 @@
return {hours: (hh < 24) ? hh : 0, minutes: mm, seconds: ss, milliseconds: msec};
}

/** @private */
__updateDropdownItems(i8n, min, max, step) {
const minTimeObj = this.__validateTime(this.__parseISO(min));
const minSec = this.__getSec(minTimeObj);
Expand All @@ -516,6 +525,7 @@
}
}

/** @private */
__generateDropdownList(minSec, maxSec, step) {
if (step < 15 * 60 || !this.__validDayDivisor(step)) {
return [];
Expand All @@ -537,6 +547,7 @@
return generatedList;
}

/** @private */
__adjustValue(minSec, maxSec, minTimeObj, maxTimeObj) {
// Do not change the value if it is empty
if (!this.__memoValue) {
Expand All @@ -552,6 +563,7 @@
}
}

/** @private */
__valueChanged(value, oldValue) {
const parsedObj = this.__memoValue = this.__parseISO(value);
const newValue = this.__formatISO(parsedObj) || '';
Expand All @@ -565,6 +577,7 @@
}
}

/** @private */
__onInputChange(e) {
const parsedObj = this.i18n.parseTime(this.__dropdownElement.value);
const newValue = this.i18n.formatTime(parsedObj) || '';
Expand All @@ -580,16 +593,19 @@
}
}

/** @private */
__updateValue(obj) {
const timeString = this.__formatISO(this.__validateTime(obj)) || '';
this.value = timeString;
}

/** @private */
__updateInputValue(obj) {
const timeString = this.i18n.formatTime(this.__validateTime(obj)) || '';
this.__dropdownElement.value = timeString;
}

/** @private */
__validateTime(timeObject) {
if (timeObject) {
timeObject.hours = parseInt(timeObject.hours);
Expand All @@ -600,6 +616,7 @@
return timeObject;
}

/** @private */
get __stepSegment() {
if (this.step % 3600 === 0) {
// Accept hours
Expand All @@ -616,11 +633,13 @@
}
}

/** @private */
__formatISO(time) {
// The default i18n formatter implementation is ISO 8601 compliant
return TimePickerElement.properties.i18n.value().formatTime(time);
}

/** @private */
__parseISO(text) {
// The default i18n parser implementation is ISO 8601 compliant
return TimePickerElement.properties.i18n.value().parseTime(text);
Expand All @@ -631,10 +650,12 @@
return this.shadowRoot.querySelector('vaadin-time-picker-text-field');
}

/** @private */
get __inputElement() {
return this.__memoInput || (this.__memoInput = this._getInputElement());
}

/** @private */
get __dropdownElement() {
return this.__memoDropdown ||
(this.__memoDropdown = this.shadowRoot.querySelector('vaadin-combo-box-light'));
Expand Down

0 comments on commit c67805e

Please sign in to comment.