assets/javascripts/materialize/timepicker.js in materialize-sass-1.0.0.beta vs assets/javascripts/materialize/timepicker.js in materialize-sass-1.0.0.rc1

- old
+ new

@@ -29,11 +29,18 @@ done: 'Ok' }, autoClose: false, // auto close when minute is selected twelveHour: true, // change to 12 hour AM/PM clock from 24 hour - vibrate: true // vibrate the device when dragging clock hand + vibrate: true, // vibrate the device when dragging clock hand + + // Callbacks + onOpenStart: null, + onOpenEnd: null, + onCloseStart: null, + onCloseEnd: null, + onSelect: null }; /** * @class * @@ -173,10 +180,14 @@ setTimeout(function () { _this2.done(); }, this.options.duration / 2); } + if (typeof this.options.onSelect === 'function') { + this.options.onSelect.call(this, this.hours, this.minutes); + } + // Unbind mousemove event document.removeEventListener('mousemove', this._handleDocumentClickMoveBound); document.removeEventListener('touchmove', this._handleDocumentClickMoveBound); } }, { @@ -198,11 +209,17 @@ key: '_setupModal', value: function _setupModal() { var _this3 = this; this.modal = M.Modal.init(this.modalEl, { + onOpenStart: this.options.onOpenStart, + onOpenEnd: this.options.onOpenEnd, + onCloseStart: this.options.onCloseStart, onCloseEnd: function () { + if (typeof _this3.options.onCloseEnd === 'function') { + _this3.options.onCloseEnd.call(_this3); + } _this3.isOpen = false; } }); } }, { @@ -223,11 +240,10 @@ this.amOrPm = 'PM'; } }, { key: '_pickerSetup', value: function _pickerSetup() { - var $clearBtn = $('<button class="btn-flat timepicker-clear waves-effect" style="visibility: hidden;" type="button" tabindex="' + (this.options.twelveHour ? '3' : '1') + '">' + this.options.i18n.clear + '</button>').appendTo(this.footer).on('click', this.clear.bind(this)); if (this.options.showClearBtn) { $clearBtn.css({ visibility: '' }); } @@ -355,16 +371,16 @@ key: '_updateTimeFromInput', value: function _updateTimeFromInput() { // Get the time var value = ((this.el.value || this.options.defaultTime || '') + '').split(':'); if (this.options.twelveHour && !(typeof value[1] === 'undefined')) { - if (value[1].toUpperCase().indexOf("AM") > 0) { + if (value[1].toUpperCase().indexOf('AM') > 0) { this.amOrPm = 'AM'; } else { this.amOrPm = 'PM'; } - value[1] = value[1].replace("AM", "").replace("PM", ""); + value[1] = value[1].replace('AM', '').replace('PM', ''); } if (value[0] === 'now') { var now = new Date(+new Date() + this.options.fromNow); value = [now.getHours(), now.getMinutes()]; if (this.options.twelveHour) { @@ -379,11 +395,11 @@ this._updateAmPmView(); } }, { key: 'showView', value: function showView(view, delay) { - if (view === 'minutes' && $(this.hoursView).css("visibility") === "visible") { + if (view === 'minutes' && $(this.hoursView).css('visibility') === 'visible') { // raiseCallback(this.options.beforeHourSelect); } var isHours = view === 'hours', nextView = isHours ? this.hoursView : this.minutesView, hideView = isHours ? this.minutesView : this.hoursView; @@ -517,9 +533,10 @@ } this.isOpen = true; this._updateTimeFromInput(); this.showView('hours'); + this.modal.open(); } }, { key: 'close', value: function close() {