From 5a4916d8ca3d720552063476e7723ab624683864 Mon Sep 17 00:00:00 2001 From: melloware Date: Sun, 28 Jan 2024 10:47:40 -0500 Subject: [PATCH] Clockpicker enable/disable widget, register scroll handler --- .../clockpicker/1-clockpicker-widget.js | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/core/src/main/resources/META-INF/resources/primefaces-extensions/clockpicker/1-clockpicker-widget.js b/core/src/main/resources/META-INF/resources/primefaces-extensions/clockpicker/1-clockpicker-widget.js index a5c9f39d6..7ab705062 100644 --- a/core/src/main/resources/META-INF/resources/primefaces-extensions/clockpicker/1-clockpicker-widget.js +++ b/core/src/main/resources/META-INF/resources/primefaces-extensions/clockpicker/1-clockpicker-widget.js @@ -17,11 +17,11 @@ PrimeFaces.widget.ExtClockPicker = PrimeFaces.widget.BaseWidget.extend({ this.jq = $(this.jqEl); this.cfg.donetext = PrimeFaces.getAriaLabel('close') || 'Close'; - this.clockpicker = this.jq.clockpicker(this.cfg); + this.clockpicker = this.createClockPicker(); + // pfs metadata this.jq.data(PrimeFaces.CLIENT_ID_DATA, this.id); this.originalValue = this.jq.val(); - }, // @override @@ -41,6 +41,28 @@ PrimeFaces.widget.ExtClockPicker = PrimeFaces.widget.BaseWidget.extend({ this.remove() }, + createClockPicker: function () { + this.clockpicker = this.jq.clockpicker(this.cfg); + this.bindConstantEvents(); + return this.clockpicker; + }, + + /** + * Sets up the event listeners that only need to be set up once. + * @private + */ + bindConstantEvents: function () { + var $this = this; + + PrimeFaces.utils.registerResizeHandler(this, 'resize.' + this.id + '_hide', undefined, function () { + $this.hide(); + }); + + PrimeFaces.utils.registerScrollHandler(this, 'scroll.' + this.id + '_hide', function () { + $this.hide(); + }); + }, + /** * Hides the clockpicker if it exists. * @function hide @@ -83,6 +105,6 @@ PrimeFaces.widget.ExtClockPicker = PrimeFaces.widget.BaseWidget.extend({ */ enable: function() { PrimeFaces.utils.enableInputWidget(this.jq); - this.clockpicker = this.jq.clockpicker(this.cfg); + this.clockpicker = this.createClockPicker(); } }); \ No newline at end of file