MCPcopy
hub / github.com/jonthornton/jquery-timepicker / _formatValue

Method _formatValue

src/timepicker/index.js:599–638  ·  view source on GitHub ↗
(e, origin)

Source from the content-addressed store, hash-verified

597 }
598
599 _formatValue(e, origin) {
600 if (this.targetEl.value === "") {
601 this._setTimeValue(null, origin);
602 return;
603 }
604
605 // IE fires change event before blur
606 if (this._isFocused(this.targetEl) && (!e || e.type != "change")) {
607 return;
608 }
609
610 var settings = this.settings;
611 var seconds = this.anytime2int(this.targetEl.value);
612
613 if (seconds === null) {
614 const timeFormatErrorEvent = new CustomEvent('timeFormatError', EVENT_DEFAULTS);
615 this.targetEl.dispatchEvent(timeFormatErrorEvent);
616 return;
617 }
618
619 var rangeError = this._isTimeRangeError(seconds, settings);
620
621 if (settings.forceRoundTime) {
622 var roundSeconds = settings.roundingFunction(seconds, settings);
623 if (roundSeconds != seconds) {
624 seconds = roundSeconds;
625 origin = null;
626 }
627 }
628
629 var prettyTime = this._int2time(seconds);
630
631 if (rangeError) {
632 this._setTimeValue(prettyTime);
633 const timeRangeErrorEvent = new CustomEvent('timeRangeError', EVENT_DEFAULTS);
634 this.targetEl.dispatchEvent(timeRangeErrorEvent);
635 } else {
636 this._setTimeValue(prettyTime, origin);
637 }
638 }
639
640 _isTimeRangeError(seconds, settings) {
641 // check that the time in within bounds

Callers 8

_handleFormatValueMethod · 0.95
sFunction · 0.80
_keydownhandlerFunction · 0.80
_keydownhandlerFunction · 0.80
timepicker-test.jsFile · 0.80

Calls 5

_setTimeValueMethod · 0.95
_isFocusedMethod · 0.95
anytime2intMethod · 0.95
_isTimeRangeErrorMethod · 0.95
_int2timeMethod · 0.95

Tested by

no test coverage detected