assets/javascripts/materialize/timepicker.js in materialize-sass-1.0.0.alpha3 vs assets/javascripts/materialize/timepicker.js in materialize-sass-1.0.0.alpha4

- old
+ new

@@ -18,13 +18,18 @@ tickRadius: 20, duration: 350, container: null, defaultTime: 'now', // default time, 'now' or '13:14' e.g. fromnow: 0, // Millisecond offset from the defaultTime - doneText: 'Ok', // done button text - clearText: 'Clear', - cancelText: 'Cancel', + + // internationalization + i18n: { + done: 'Ok', + clear: 'Clear', + cancel: 'Cancel' + }, + 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 }; @@ -146,10 +151,12 @@ this.setHand(x, y, false, true); } }, { key: '_handleDocumentClickEnd', value: function _handleDocumentClickEnd(e) { + var _this2 = this; + e.preventDefault(); document.removeEventListener('mouseup', this._handleDocumentClickEndBound); document.removeEventListener('touchend', this._handleDocumentClickEndBound); var clickPos = Timepicker._Pos(e); var x = clickPos.x - this.x0; @@ -159,13 +166,13 @@ } if (this.currentView === 'hours') { this.showView('minutes', this.options.duration / 2); } else if (this.options.autoClose) { - this.minutesView.addClass('timepicker-dial-out'); + $(this.minutesView).addClass('timepicker-dial-out'); setTimeout(function () { - this.done(); + _this2.done(); }, this.options.duration / 2); } // Unbind mousemove event document.removeEventListener('mousemove', this._handleDocumentClickMoveBound); @@ -187,15 +194,15 @@ } } }, { key: '_setupModal', value: function _setupModal() { - var _this2 = this; + var _this3 = this; this.modal = M.Modal.init(this.modalEl, { onCloseEnd: function () { - _this2.isOpen = false; + _this3.isOpen = false; } }); } }, { key: '_setupVariables', @@ -215,15 +222,15 @@ this.amOrPm = 'PM'; } }, { key: '_pickerSetup', value: function _pickerSetup() { - $('<button class="btn-flat timepicker-clear waves-effect" type="button" tabindex="' + (this.options.twelveHour ? '3' : '1') + '">' + this.options.clearText + '</button>').appendTo(this.footer).on('click', this.clear.bind(this)); + $('<button class="btn-flat timepicker-clear waves-effect" type="button" tabindex="' + (this.options.twelveHour ? '3' : '1') + '">' + this.options.i18n.clear + '</button>').appendTo(this.footer).on('click', this.clear.bind(this)); var confirmationBtnsContainer = $('<div class="confirmation-btns"></div>'); - $('<button class="btn-flat timepicker-close waves-effect" type="button" tabindex="' + (this.options.twelveHour ? '3' : '1') + '">' + this.options.cancelText + '</button>').appendTo(confirmationBtnsContainer).on('click', this.close.bind(this)); - $('<button class="btn-flat timepicker-close waves-effect" type="button" tabindex="' + (this.options.twelveHour ? '3' : '1') + '">' + this.options.doneText + '</button>').appendTo(confirmationBtnsContainer).on('click', this.done.bind(this)); + $('<button class="btn-flat timepicker-close waves-effect" type="button" tabindex="' + (this.options.twelveHour ? '3' : '1') + '">' + this.options.i18n.cancel + '</button>').appendTo(confirmationBtnsContainer).on('click', this.close.bind(this)); + $('<button class="btn-flat timepicker-close waves-effect" type="button" tabindex="' + (this.options.twelveHour ? '3' : '1') + '">' + this.options.i18n.done + '</button>').appendTo(confirmationBtnsContainer).on('click', this.done.bind(this)); confirmationBtnsContainer.appendTo(this.footer); } }, { key: '_clockSetup', value: function _clockSetup() { @@ -417,11 +424,11 @@ } } }, { key: 'setHand', value: function setHand(x, y, roundBy5) { - var _this3 = this; + var _this4 = this; var radian = Math.atan2(x, -y), isHours = this.currentView === 'hours', unit = Math.PI / (isHours || roundBy5 ? 6 : 30), z = Math.sqrt(x * x + y * y), @@ -472,10 +479,10 @@ if (this.vibrate && this.options.vibrate) { // Do not vibrate too frequently if (!this.vibrateTimer) { navigator[this.vibrate](10); this.vibrateTimer = setTimeout(function () { - _this3.vibrateTimer = null; + _this4.vibrateTimer = null; }, 100); } } }