function TimeRangeFacet(div, config, options) { this._div = div; this._config = config; this._options = options; this._from = ("from" in this._config) ? this._config.from : null; this._to = ("to" in this._config) ? this._config.to : null; this._step = ("step" in this._config) ? this._config.step : null; this._selectTime = ("selectTime" in this._config) ? this._config.selectTime : true; this._selectNonTime = ("selectNonTime" in this._config) ? this._config.selectNonTime : true; this._selectBlank = ("selectBlank" in this._config) ? this._config.selectBlank : true; this._selectError = ("selectError" in this._config) ? this._config.selectError : true; this._baseTimeCount = 0; this._baseNonTimeCount = 0; this._baseBlankCount = 0; this._baseErrorCount = 0; this._TimeCount = 0; this._nonTimeCount = 0; this._blankCount = 0; this._errorCount = 0; this._error = false; this._initializedUI = false; } TimeRangeFacet.prototype.reset = function() { this._from = this._config.min; this._to = this._config.max; this._sliderWidget.update( this._config.min, this._config.max, this._config.step, this._from, this._to ); this._selectTime = true; this._selectNonTime = true; this._selectBlank = true; this._selectError = true; this._setRangeIndicators(); }; TimeRangeFacet.reconstruct = function(div, uiState) { return new TimeRangeFacet(div, uiState.c, uiState.o); }; TimeRangeFacet.prototype.dispose = function() { }; TimeRangeFacet.prototype.getUIState = function() { var json = { c: this.getJSON(), o: this._options }; return json; }; TimeRangeFacet.prototype.getJSON = function() { var o = { type: "timerange", name: this._config.name, expression: this._config.expression, columnName: this._config.columnName, selectTime: this._selectTime, selectNonTime: this._selectNonTime, selectBlank: this._selectBlank, selectError: this._selectError }; if (this._from !== null) { o.from = this._from; } if (this._to !== null) { o.to = this._to; } return o; }; TimeRangeFacet.prototype.hasSelection = function() { if (!this._selectTime || !this._selectNonTime || !this._selectBlank || !this._selectError) { return true; } return (this._from !== null && (!this._initializedUI || this._from > this._config.min)) || (this._to !== null && (!this._initializedUI || this._to < this._config.max)); }; TimeRangeFacet.prototype._initializeUI = function() { var self = this; this._div .empty() .show() .html( '
' + '
' + '' + '' + '
 ' + 'reset' + 'change' + '' + '
' + '
' + '
' + '
' + '
Loading...
' + '
' + '
' + '
' + '
' + '
' + '
' ); this._elmts = DOM.bind(this._div); this._elmts.facetTitle.text(this._config.name); this._elmts.changeButton.attr("title","Current Expression: " + this._config.expression).click(function() { self._elmts.expressionDiv.slideToggle(100); }); this._elmts.expressionDiv.text(this._config.expression).click(function() { self._editExpression(); }).hide(); this._elmts.resetButton.click(function() { self.reset(); self._updateRest(); }); this._elmts.removeButton.click(function() { self._remove(); }); this._histogram = new HistogramWidget(this._elmts.histogramDiv, { binColors: [ "#ccccff", "#6666ff" ] }); this._sliderWidget = new SliderWidget(this._elmts.sliderWidgetDiv); this._elmts.sliderWidgetDiv.bind("slide", function(evt, data) { self._from = data.from; self._to = data.to; self._setRangeIndicators(); }).bind("stop", function(evt, data) { self._from = data.from; self._to = data.to; self._selectTime = true; self._updateRest(); }); }; TimeRangeFacet.prototype._renderOtherChoices = function() { var self = this; var container = this._elmts.otherChoicesDiv.empty(); if (this._baseNonTimeCount === 0 && this._baseBlankCount === 0 && this._baseErrorCount === 0) { return; } var facet_id = this._div.attr("id"); var choices = $('
').addClass("facet-range-choices"); // ----------------- time ----------------- var timeCheck = $('').attr("id",facet_id + "-time").appendTo(choices).change(function() { self._selectTime = !self._selectTime; self._updateRest(); }); if (this._selectTime) timeCheck.attr("checked","checked"); var timeLabel = $('