Skip to content

Commit

Permalink
Clockpicker enable/disable widget, register scroll handler
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Jan 28, 2024
1 parent af29e24 commit 5a4916d
Showing 1 changed file with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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();
}
});

0 comments on commit 5a4916d

Please sign in to comment.