Created
April 16, 2012 13:16
-
-
Save ixth/2398704 to your computer and use it in GitHub Desktop.
jQuery.UI extended slider widget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
$.widget('ui.tooltipSlider', $.ui.slider, { | |
options: { | |
'formatTooltip': function (value) { | |
return value; | |
} | |
}, | |
_create: function () { | |
$.ui.slider.prototype._create.apply(this, arguments); | |
this._formatTooltip = this.options.formatTooltip; | |
this.tooltips = $(document.createElement('span')).addClass('ui-slider-tooltip').appendTo(this.handles); | |
}, | |
_setOption: function (key, value) { | |
$.ui.slider.prototype._setOption.apply(this, arguments); | |
if (key === 'formatTooltip') { | |
this._formatTooltip = value; | |
} | |
}, | |
_refreshValue: function () { | |
var self = this; | |
$.ui.slider.prototype._refreshValue.apply(this, arguments); | |
if (this.tooltips && this.options.values && this.options.values.length ) { | |
self.tooltips.each(function(i, j) { | |
this.innerHTML = self._formatTooltip(self.values(i)); | |
}); | |
} | |
} | |
}); | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment