Restructured the Facets (#3097)
* added class to List Facet * added class to Timerange Facet * added class to Range Facet * added class to Text Filter Facet * added class to Scatterplot Facet * added base class * added end line in facet.js * fixed indentations facet.js * fixed indentation again * removed fields * added suggested changes
This commit is contained in:
parent
2a86927b2c
commit
5ca5f3cb7b
@ -466,6 +466,7 @@ function init() {
|
|||||||
"scripts/project/exporters.js",
|
"scripts/project/exporters.js",
|
||||||
"scripts/project/scripting.js",
|
"scripts/project/scripting.js",
|
||||||
|
|
||||||
|
"scripts/facets/facet.js",
|
||||||
"scripts/facets/list-facet.js",
|
"scripts/facets/list-facet.js",
|
||||||
"scripts/facets/range-facet.js",
|
"scripts/facets/range-facet.js",
|
||||||
"scripts/facets/timerange-facet.js",
|
"scripts/facets/timerange-facet.js",
|
||||||
|
@ -333,6 +333,7 @@
|
|||||||
"core-facets/big-dot": "Big Dot Size",
|
"core-facets/big-dot": "Big Dot Size",
|
||||||
"core-facets/export-plot": "export plot",
|
"core-facets/export-plot": "export plot",
|
||||||
"core-facets/numeric": "Numeric",
|
"core-facets/numeric": "Numeric",
|
||||||
|
"core-facets/value-range": "$1 — $2",
|
||||||
"core-project/open": "Open",
|
"core-project/open": "Open",
|
||||||
"core-project/permalink": "Permalink",
|
"core-project/permalink": "Permalink",
|
||||||
"core-project/export": "Export",
|
"core-project/export": "Export",
|
||||||
|
67
main/webapp/modules/core/scripts/facets/facet.js
Normal file
67
main/webapp/modules/core/scripts/facets/facet.js
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Copyright 2010, Google Inc.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
|
in the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
* Neither the name of Google Inc. nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Facet {
|
||||||
|
constructor(div, config, options) {
|
||||||
|
this._div = div;
|
||||||
|
this._config = config;
|
||||||
|
this._options = options || {};
|
||||||
|
this._minimizeState = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
_minimize() {
|
||||||
|
if(!this._minimizeState) {
|
||||||
|
this._div.addClass("facet-state-minimize");
|
||||||
|
} else {
|
||||||
|
this._div.removeClass("facet-state-minimize");
|
||||||
|
}
|
||||||
|
|
||||||
|
this._minimizeState = !this._minimizeState;
|
||||||
|
};
|
||||||
|
|
||||||
|
_remove() {
|
||||||
|
ui.browsingEngine.removeFacet(this);
|
||||||
|
|
||||||
|
this._div = null;
|
||||||
|
this._config = null;
|
||||||
|
|
||||||
|
this._selection = null;
|
||||||
|
this._blankChoice = null;
|
||||||
|
this._errorChoice = null;
|
||||||
|
this._data = null;
|
||||||
|
this._options = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
dispose() {
|
||||||
|
};
|
||||||
|
};
|
@ -31,21 +31,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function ListFacet(div, config, options, selection) {
|
class ListFacet extends Facet {
|
||||||
this._div = div;
|
constructor(div, config, options, selection) {
|
||||||
this._config = config;
|
super(div, config, options);
|
||||||
if (!("invert" in this._config)) {
|
|
||||||
this._config.invert = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._options = options || {};
|
|
||||||
if (!("sort" in this._options)) {
|
if (!("sort" in this._options)) {
|
||||||
this._options.sort = "name";
|
this._options.sort = "name";
|
||||||
}
|
}
|
||||||
|
|
||||||
this._selection = selection || [];
|
this._selection = selection || [];
|
||||||
|
|
||||||
this._minimizeState = false;
|
if (!("invert" in this._config)) {
|
||||||
|
this._config.invert = false;
|
||||||
|
}
|
||||||
|
|
||||||
this._blankChoice = (config.selectBlank) ? { s : true, c : 0 } : null;
|
this._blankChoice = (config.selectBlank) ? { s : true, c : 0 } : null;
|
||||||
this._errorChoice = (config.selectError) ? { s : true, c : 0 } : null;
|
this._errorChoice = (config.selectError) ? { s : true, c : 0 } : null;
|
||||||
@ -54,22 +52,15 @@ function ListFacet(div, config, options, selection) {
|
|||||||
|
|
||||||
this._initializeUI();
|
this._initializeUI();
|
||||||
this._update();
|
this._update();
|
||||||
}
|
|
||||||
|
|
||||||
ListFacet.reconstruct = function(div, uiState) {
|
|
||||||
return new ListFacet(div, uiState.c, uiState.o, uiState.s);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ListFacet.prototype.dispose = function() {
|
reset() {
|
||||||
};
|
|
||||||
|
|
||||||
ListFacet.prototype.reset = function() {
|
|
||||||
this._selection = [];
|
this._selection = [];
|
||||||
this._blankChoice = null;
|
this._blankChoice = null;
|
||||||
this._errorChoice = null;
|
this._errorChoice = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
ListFacet.prototype.getUIState = function() {
|
getUIState() {
|
||||||
var json = {
|
var json = {
|
||||||
c: this.getJSON(),
|
c: this.getJSON(),
|
||||||
o: this._options
|
o: this._options
|
||||||
@ -81,7 +72,7 @@ ListFacet.prototype.getUIState = function() {
|
|||||||
return json;
|
return json;
|
||||||
};
|
};
|
||||||
|
|
||||||
ListFacet.prototype.getJSON = function() {
|
getJSON() {
|
||||||
var o = {
|
var o = {
|
||||||
type: "list",
|
type: "list",
|
||||||
name: this._config.name,
|
name: this._config.name,
|
||||||
@ -103,13 +94,13 @@ ListFacet.prototype.getJSON = function() {
|
|||||||
return o;
|
return o;
|
||||||
};
|
};
|
||||||
|
|
||||||
ListFacet.prototype.hasSelection = function() {
|
hasSelection() {
|
||||||
return this._selection.length > 0 ||
|
return this._selection.length > 0 ||
|
||||||
(this._blankChoice !== null && this._blankChoice.s) ||
|
(this._blankChoice !== null && this._blankChoice.s) ||
|
||||||
(this._errorChoice !== null && this._errorChoice.s);
|
(this._errorChoice !== null && this._errorChoice.s);
|
||||||
};
|
};
|
||||||
|
|
||||||
ListFacet.prototype.updateState = function(data) {
|
updateState(data) {
|
||||||
this._data = data;
|
this._data = data;
|
||||||
|
|
||||||
if ("choices" in data) {
|
if ("choices" in data) {
|
||||||
@ -131,7 +122,7 @@ ListFacet.prototype.updateState = function(data) {
|
|||||||
this._update();
|
this._update();
|
||||||
};
|
};
|
||||||
|
|
||||||
ListFacet.prototype._reSortChoices = function() {
|
_reSortChoices() {
|
||||||
this._data.choices.sort(this._options.sort === "name" ?
|
this._data.choices.sort(this._options.sort === "name" ?
|
||||||
function(a, b) {
|
function(a, b) {
|
||||||
return a.v.l.toLowerCase().localeCompare(b.v.l.toLowerCase());
|
return a.v.l.toLowerCase().localeCompare(b.v.l.toLowerCase());
|
||||||
@ -143,7 +134,7 @@ ListFacet.prototype._reSortChoices = function() {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
ListFacet.prototype._initializeUI = function() {
|
_initializeUI() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
var facet_id = this._div.attr("id");
|
var facet_id = this._div.attr("id");
|
||||||
@ -228,7 +219,7 @@ ListFacet.prototype._initializeUI = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ListFacet.prototype._copyChoices = function() {
|
_copyChoices() {
|
||||||
var self = this;
|
var self = this;
|
||||||
var frame = DialogSystem.createDialog();
|
var frame = DialogSystem.createDialog();
|
||||||
frame.width("600px");
|
frame.width("600px");
|
||||||
@ -264,7 +255,7 @@ ListFacet.prototype._copyChoices = function() {
|
|||||||
textarea.select();
|
textarea.select();
|
||||||
};
|
};
|
||||||
|
|
||||||
ListFacet.prototype._update = function(resetScroll) {
|
_update(resetScroll) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
var invert = this._config.invert;
|
var invert = this._config.invert;
|
||||||
@ -484,7 +475,7 @@ ListFacet.prototype._update = function(resetScroll) {
|
|||||||
window.setTimeout(wireEvents, 100);
|
window.setTimeout(wireEvents, 100);
|
||||||
}; // end _update()
|
}; // end _update()
|
||||||
|
|
||||||
ListFacet.prototype._renderBodyControls = function() {
|
_renderBodyControls() {
|
||||||
var self = this;
|
var self = this;
|
||||||
var bodyControls = $('<div>')
|
var bodyControls = $('<div>')
|
||||||
.addClass("facet-body-controls")
|
.addClass("facet-body-controls")
|
||||||
@ -511,7 +502,7 @@ ListFacet.prototype._renderBodyControls = function() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
ListFacet.prototype._getMetaExpression = function() {
|
_getMetaExpression() {
|
||||||
var r = Scripting.parse(this._config.expression);
|
var r = Scripting.parse(this._config.expression);
|
||||||
|
|
||||||
return r.language + ':facetCount(' + [
|
return r.language + ':facetCount(' + [
|
||||||
@ -521,11 +512,11 @@ ListFacet.prototype._getMetaExpression = function() {
|
|||||||
].join(', ') + ')';
|
].join(', ') + ')';
|
||||||
};
|
};
|
||||||
|
|
||||||
ListFacet.prototype._doEdit = function() {
|
_doEdit() {
|
||||||
new ClusteringDialog(this._config.columnName, this._config.expression);
|
new ClusteringDialog(this._config.columnName, this._config.expression);
|
||||||
};
|
};
|
||||||
|
|
||||||
ListFacet.prototype._editChoice = function(choice, choiceDiv) {
|
_editChoice(choice, choiceDiv) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
var menu = MenuSystem.createMenu().addClass("data-table-cell-editor").width("400px");
|
var menu = MenuSystem.createMenu().addClass("data-table-cell-editor").width("400px");
|
||||||
@ -624,7 +615,7 @@ ListFacet.prototype._editChoice = function(choice, choiceDiv) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
ListFacet.prototype._select = function(choice, only) {
|
_select(choice, only) {
|
||||||
if (only) {
|
if (only) {
|
||||||
this._selection = [];
|
this._selection = [];
|
||||||
if (this._blankChoice !== null) {
|
if (this._blankChoice !== null) {
|
||||||
@ -643,7 +634,7 @@ ListFacet.prototype._select = function(choice, only) {
|
|||||||
this._updateRest();
|
this._updateRest();
|
||||||
};
|
};
|
||||||
|
|
||||||
ListFacet.prototype._deselect = function(choice) {
|
_deselect(choice) {
|
||||||
if (choice === this._errorChoice || choice === this._blankChoice) {
|
if (choice === this._errorChoice || choice === this._blankChoice) {
|
||||||
choice.s = false;
|
choice.s = false;
|
||||||
} else {
|
} else {
|
||||||
@ -657,7 +648,7 @@ ListFacet.prototype._deselect = function(choice) {
|
|||||||
this._updateRest();
|
this._updateRest();
|
||||||
};
|
};
|
||||||
|
|
||||||
ListFacet.prototype._reset = function() {
|
_reset() {
|
||||||
this._selection = [];
|
this._selection = [];
|
||||||
this._blankChoice = null;
|
this._blankChoice = null;
|
||||||
this._errorChoice = null;
|
this._errorChoice = null;
|
||||||
@ -666,39 +657,17 @@ ListFacet.prototype._reset = function() {
|
|||||||
this._updateRest();
|
this._updateRest();
|
||||||
};
|
};
|
||||||
|
|
||||||
ListFacet.prototype._invert = function() {
|
_invert() {
|
||||||
this._config.invert = !this._config.invert;
|
this._config.invert = !this._config.invert;
|
||||||
|
|
||||||
this._updateRest();
|
this._updateRest();
|
||||||
};
|
};
|
||||||
|
|
||||||
ListFacet.prototype._remove = function() {
|
_updateRest() {
|
||||||
ui.browsingEngine.removeFacet(this);
|
|
||||||
|
|
||||||
this._div = null;
|
|
||||||
this._config = null;
|
|
||||||
|
|
||||||
this._selection = null;
|
|
||||||
this._blankChoice = null;
|
|
||||||
this._errorChoice = null;
|
|
||||||
this._data = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
ListFacet.prototype._minimize = function() {
|
|
||||||
if(!this._minimizeState) {
|
|
||||||
this._div.addClass("facet-state-minimize");
|
|
||||||
} else {
|
|
||||||
this._div.removeClass("facet-state-minimize");
|
|
||||||
}
|
|
||||||
|
|
||||||
this._minimizeState = !this._minimizeState;
|
|
||||||
};
|
|
||||||
|
|
||||||
ListFacet.prototype._updateRest = function() {
|
|
||||||
Refine.update({ engineChanged: true });
|
Refine.update({ engineChanged: true });
|
||||||
};
|
};
|
||||||
|
|
||||||
ListFacet.prototype._editExpression = function() {
|
_editExpression() {
|
||||||
var self = this;
|
var self = this;
|
||||||
var title = (this._config.columnName) ?
|
var title = (this._config.columnName) ?
|
||||||
($.i18n('core-facets/edit-based-col')+" " + this._config.columnName) :
|
($.i18n('core-facets/edit-based-col')+" " + this._config.columnName) :
|
||||||
@ -733,7 +702,7 @@ ListFacet.prototype._editExpression = function() {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
ListFacet.prototype._setChoiceCountLimit = function(choiceCount) {
|
_setChoiceCountLimit(choiceCount) {
|
||||||
var limit = Math.ceil(choiceCount / 1000) * 1000;
|
var limit = Math.ceil(choiceCount / 1000) * 1000;
|
||||||
var s = window.prompt($.i18n('core-facets/set-max-choices'), limit);
|
var s = window.prompt($.i18n('core-facets/set-max-choices'), limit);
|
||||||
if (s) {
|
if (s) {
|
||||||
@ -759,3 +728,9 @@ ListFacet.prototype._setChoiceCountLimit = function(choiceCount) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
ListFacet.reconstruct = function(div, uiState) {
|
||||||
|
return new ListFacet(div, uiState.c, uiState.o, uiState.s);
|
||||||
|
};
|
||||||
|
|
||||||
|
@ -31,12 +31,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function RangeFacet(div, config, options) {
|
class RangeFacet extends Facet {
|
||||||
this._div = div;
|
constructor(div, config, options) {
|
||||||
this._config = config;
|
super(div, config, options);
|
||||||
this._options = options;
|
|
||||||
|
|
||||||
this._minimizeState = false;
|
|
||||||
|
|
||||||
this._from = ("from" in this._config) ? this._config.from : null;
|
this._from = ("from" in this._config) ? this._config.from : null;
|
||||||
this._to = ("to" in this._config) ? this._config.to : null;
|
this._to = ("to" in this._config) ? this._config.to : null;
|
||||||
@ -46,6 +43,9 @@ function RangeFacet(div, config, options) {
|
|||||||
this._selectBlank = ("selectBlank" in this._config) ? this._config.selectBlank : true;
|
this._selectBlank = ("selectBlank" in this._config) ? this._config.selectBlank : true;
|
||||||
this._selectError = ("selectError" in this._config) ? this._config.selectError : true;
|
this._selectError = ("selectError" in this._config) ? this._config.selectError : true;
|
||||||
|
|
||||||
|
this._lang = Refine.getPreference('userLang', 'en');
|
||||||
|
this._formatter = new Intl.NumberFormat(this._lang, { useGrouping: true, maximumFractionDigits: 2 });
|
||||||
|
|
||||||
this._baseNumericCount = 0;
|
this._baseNumericCount = 0;
|
||||||
this._baseNonNumericCount = 0;
|
this._baseNonNumericCount = 0;
|
||||||
this._baseBlankCount = 0;
|
this._baseBlankCount = 0;
|
||||||
@ -58,9 +58,9 @@ function RangeFacet(div, config, options) {
|
|||||||
|
|
||||||
this._error = false;
|
this._error = false;
|
||||||
this._initializedUI = false;
|
this._initializedUI = false;
|
||||||
}
|
};
|
||||||
|
|
||||||
RangeFacet.prototype.reset = function() {
|
reset() {
|
||||||
this._from = this._config.min;
|
this._from = this._config.min;
|
||||||
this._to = this._config.max;
|
this._to = this._config.max;
|
||||||
this._sliderWidget.update(
|
this._sliderWidget.update(
|
||||||
@ -79,14 +79,7 @@ RangeFacet.prototype.reset = function() {
|
|||||||
this._setRangeIndicators();
|
this._setRangeIndicators();
|
||||||
};
|
};
|
||||||
|
|
||||||
RangeFacet.reconstruct = function(div, uiState) {
|
getUIState() {
|
||||||
return new RangeFacet(div, uiState.c, uiState.o);
|
|
||||||
};
|
|
||||||
|
|
||||||
RangeFacet.prototype.dispose = function() {
|
|
||||||
};
|
|
||||||
|
|
||||||
RangeFacet.prototype.getUIState = function() {
|
|
||||||
var json = {
|
var json = {
|
||||||
c: this.getJSON(),
|
c: this.getJSON(),
|
||||||
o: this._options
|
o: this._options
|
||||||
@ -95,7 +88,7 @@ RangeFacet.prototype.getUIState = function() {
|
|||||||
return json;
|
return json;
|
||||||
};
|
};
|
||||||
|
|
||||||
RangeFacet.prototype.getJSON = function() {
|
getJSON() {
|
||||||
var o = {
|
var o = {
|
||||||
type: "range",
|
type: "range",
|
||||||
name: this._config.name,
|
name: this._config.name,
|
||||||
@ -117,7 +110,7 @@ RangeFacet.prototype.getJSON = function() {
|
|||||||
return o;
|
return o;
|
||||||
};
|
};
|
||||||
|
|
||||||
RangeFacet.prototype.hasSelection = function() {
|
hasSelection() {
|
||||||
if (!this._selectNumeric || !this._selectNonNumeric || !this._selectBlank || !this._selectError) {
|
if (!this._selectNumeric || !this._selectNonNumeric || !this._selectBlank || !this._selectError) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -126,7 +119,7 @@ RangeFacet.prototype.hasSelection = function() {
|
|||||||
(this._to !== null && (!this._initializedUI || this._to < this._config.max));
|
(this._to !== null && (!this._initializedUI || this._to < this._config.max));
|
||||||
};
|
};
|
||||||
|
|
||||||
RangeFacet.prototype._initializeUI = function() {
|
_initializeUI() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this._div
|
this._div
|
||||||
.empty()
|
.empty()
|
||||||
@ -194,7 +187,7 @@ RangeFacet.prototype._initializeUI = function() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
RangeFacet.prototype._renderOtherChoices = function() {
|
_renderOtherChoices() {
|
||||||
var self = this;
|
var self = this;
|
||||||
var container = this._elmts.otherChoicesDiv.empty();
|
var container = this._elmts.otherChoicesDiv.empty();
|
||||||
|
|
||||||
@ -269,23 +262,11 @@ RangeFacet.prototype._renderOtherChoices = function() {
|
|||||||
choices.appendTo(container);
|
choices.appendTo(container);
|
||||||
};
|
};
|
||||||
|
|
||||||
RangeFacet.prototype._setRangeIndicators = function() {
|
_setRangeIndicators() {
|
||||||
this._elmts.statusDiv.html(this._addCommas(this._from.toFixed(2)) + " — " + this._addCommas(this._to.toFixed(2)));
|
this._elmts.statusDiv.html($.i18n('core-facets/value-range', this._formatter.format(this._from), this._formatter.format(this._to)));
|
||||||
};
|
};
|
||||||
|
|
||||||
RangeFacet.prototype._addCommas = function(nStr) {
|
updateState(data) {
|
||||||
nStr += '';
|
|
||||||
x = nStr.split('.');
|
|
||||||
x1 = x[0];
|
|
||||||
x2 = x.length > 1 ? '.' + x[1] : '';
|
|
||||||
var rgx = /(\d+)(\d{3})/;
|
|
||||||
while (rgx.test(x1)) {
|
|
||||||
x1 = x1.replace(rgx, '$1' + ',' + '$2');
|
|
||||||
}
|
|
||||||
return x1 + x2;
|
|
||||||
};
|
|
||||||
|
|
||||||
RangeFacet.prototype.updateState = function(data) {
|
|
||||||
if ("min" in data && "max" in data) {
|
if ("min" in data && "max" in data) {
|
||||||
this._error = false;
|
this._error = false;
|
||||||
|
|
||||||
@ -328,7 +309,7 @@ RangeFacet.prototype.updateState = function(data) {
|
|||||||
this.render();
|
this.render();
|
||||||
};
|
};
|
||||||
|
|
||||||
RangeFacet.prototype.render = function() {
|
render() {
|
||||||
if (!this._initializedUI) {
|
if (!this._initializedUI) {
|
||||||
this._initializeUI();
|
this._initializeUI();
|
||||||
this._initializedUI = true;
|
this._initializedUI = true;
|
||||||
@ -367,29 +348,11 @@ RangeFacet.prototype.render = function() {
|
|||||||
this._renderOtherChoices();
|
this._renderOtherChoices();
|
||||||
};
|
};
|
||||||
|
|
||||||
RangeFacet.prototype._remove = function() {
|
_updateRest() {
|
||||||
ui.browsingEngine.removeFacet(this);
|
|
||||||
|
|
||||||
this._div = null;
|
|
||||||
this._config = null;
|
|
||||||
this._data = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
RangeFacet.prototype._minimize = function() {
|
|
||||||
if(!this._minimizeState) {
|
|
||||||
this._div.addClass("facet-state-minimize");
|
|
||||||
} else {
|
|
||||||
this._div.removeClass("facet-state-minimize");
|
|
||||||
}
|
|
||||||
|
|
||||||
this._minimizeState = !this._minimizeState;
|
|
||||||
};
|
|
||||||
|
|
||||||
RangeFacet.prototype._updateRest = function() {
|
|
||||||
Refine.update({ engineChanged: true });
|
Refine.update({ engineChanged: true });
|
||||||
};
|
};
|
||||||
|
|
||||||
RangeFacet.prototype._editExpression = function() {
|
_editExpression() {
|
||||||
var self = this;
|
var self = this;
|
||||||
var title = (this._config.columnName) ?
|
var title = (this._config.columnName) ?
|
||||||
($.i18n('core-facets/edit-based-col')+" " + this._config.columnName) :
|
($.i18n('core-facets/edit-based-col')+" " + this._config.columnName) :
|
||||||
@ -417,3 +380,8 @@ RangeFacet.prototype._editExpression = function() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
RangeFacet.reconstruct = function(div, uiState) {
|
||||||
|
return new RangeFacet(div, uiState.c, uiState.o);
|
||||||
|
};
|
||||||
|
@ -31,22 +31,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function ScatterplotFacet(div, config, options) {
|
class ScatterplotFacet extends Facet {
|
||||||
this._div = div;
|
constructor(div, config, options) {
|
||||||
this._config = config;
|
super(div, config, options);
|
||||||
this._options = options;
|
|
||||||
|
|
||||||
this._minimizeState = false;
|
|
||||||
|
|
||||||
this._error = false;
|
this._error = false;
|
||||||
this._initializedUI = false;
|
this._initializedUI = false;
|
||||||
}
|
};
|
||||||
|
|
||||||
ScatterplotFacet.prototype.update = function() {
|
update() {
|
||||||
this._plotAreaSelector.update();
|
this._plotAreaSelector.update();
|
||||||
};
|
};
|
||||||
|
|
||||||
ScatterplotFacet.prototype.reset = function() {
|
reset() {
|
||||||
delete this._config.from_x;
|
delete this._config.from_x;
|
||||||
delete this._config.from_y;
|
delete this._config.from_y;
|
||||||
delete this._config.to_x;
|
delete this._config.to_x;
|
||||||
@ -55,15 +52,11 @@ ScatterplotFacet.prototype.reset = function() {
|
|||||||
this._plotAreaSelector.update();
|
this._plotAreaSelector.update();
|
||||||
};
|
};
|
||||||
|
|
||||||
ScatterplotFacet.reconstruct = function(div, uiState) {
|
dispose() {
|
||||||
return new ScatterplotFacet(div, uiState.c, uiState.o);
|
|
||||||
};
|
|
||||||
|
|
||||||
ScatterplotFacet.prototype.dispose = function() {
|
|
||||||
this._elmts.plotImg.imgAreaSelect({ hide : true });
|
this._elmts.plotImg.imgAreaSelect({ hide : true });
|
||||||
};
|
};
|
||||||
|
|
||||||
ScatterplotFacet.prototype.getUIState = function() {
|
getUIState() {
|
||||||
var json = {
|
var json = {
|
||||||
c: this.getJSON(),
|
c: this.getJSON(),
|
||||||
o: this._options
|
o: this._options
|
||||||
@ -72,21 +65,21 @@ ScatterplotFacet.prototype.getUIState = function() {
|
|||||||
return json;
|
return json;
|
||||||
};
|
};
|
||||||
|
|
||||||
ScatterplotFacet.prototype.getJSON = function() {
|
getJSON() {
|
||||||
this._config.type = "scatterplot";
|
this._config.type = "scatterplot";
|
||||||
var dot = this._config.dot;
|
var dot = this._config.dot;
|
||||||
if (typeof dot == 'number') this._config.dot.toFixed(2);
|
if (typeof dot == 'number') this._config.dot.toFixed(2);
|
||||||
return this._config;
|
return this._config;
|
||||||
};
|
};
|
||||||
|
|
||||||
ScatterplotFacet.prototype.hasSelection = function() {
|
hasSelection() {
|
||||||
return ("from_x" in this._config && this._config.from_x !== 0) ||
|
return ("from_x" in this._config && this._config.from_x !== 0) ||
|
||||||
("from_y" in this._config && this._config.from_y !== 0) ||
|
("from_y" in this._config && this._config.from_y !== 0) ||
|
||||||
("to_x" in this._config && this._config.to_x !== 1) ||
|
("to_x" in this._config && this._config.to_x !== 1) ||
|
||||||
("to_y" in this._config && this._config.to_y !== 1);
|
("to_y" in this._config && this._config.to_y !== 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
ScatterplotFacet.prototype._initializeUI = function() {
|
_initializeUI() {
|
||||||
var self = this;
|
var self = this;
|
||||||
var container = this._div.empty().show();
|
var container = this._div.empty().show();
|
||||||
|
|
||||||
@ -227,7 +220,7 @@ ScatterplotFacet.prototype._initializeUI = function() {
|
|||||||
this._elmts.selectors.find(".buttonset").buttonset();
|
this._elmts.selectors.find(".buttonset").buttonset();
|
||||||
};
|
};
|
||||||
|
|
||||||
ScatterplotFacet.prototype._fillSelectionOptions = function(ops) {
|
_fillSelectionOptions(ops) {
|
||||||
if (this.hasSelection()) {
|
if (this.hasSelection()) {
|
||||||
ops.x1 = this._config.l * this._config.from_x;
|
ops.x1 = this._config.l * this._config.from_x;
|
||||||
ops.x2 = this._config.l * this._config.to_x;
|
ops.x2 = this._config.l * this._config.to_x;
|
||||||
@ -241,7 +234,7 @@ ScatterplotFacet.prototype._fillSelectionOptions = function(ops) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ScatterplotFacet.prototype._putSelectionOptions = function(selection) {
|
_putSelectionOptions(selection) {
|
||||||
if (selection.height === 0 || selection.width === 0) {
|
if (selection.height === 0 || selection.width === 0) {
|
||||||
this.reset();
|
this.reset();
|
||||||
} else {
|
} else {
|
||||||
@ -253,19 +246,19 @@ ScatterplotFacet.prototype._putSelectionOptions = function(selection) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ScatterplotFacet.prototype._formulateCurrentImageUrl = function() {
|
_formulateCurrentImageUrl() {
|
||||||
return this._formulateImageUrl(ui.browsingEngine.getJSON(false, this), { color: "ff6a00" });
|
return this._formulateImageUrl(ui.browsingEngine.getJSON(false, this), { color: "ff6a00" });
|
||||||
};
|
};
|
||||||
|
|
||||||
ScatterplotFacet.prototype._formulateBaseImageUrl = function() {
|
_formulateBaseImageUrl() {
|
||||||
return this._formulateImageUrl({},{ color: "888888", dot : this._config.dot * 0.9 });
|
return this._formulateImageUrl({},{ color: "888888", dot : this._config.dot * 0.9 });
|
||||||
};
|
};
|
||||||
|
|
||||||
ScatterplotFacet.prototype._formulateExportImageUrl = function() {
|
_formulateExportImageUrl() {
|
||||||
return this._formulateImageUrl(ui.browsingEngine.getJSON(false, this), { dot : this._config.dot * 5, l: 500, base_color: "888888" });
|
return this._formulateImageUrl(ui.browsingEngine.getJSON(false, this), { dot : this._config.dot * 5, l: 500, base_color: "888888" });
|
||||||
};
|
};
|
||||||
|
|
||||||
ScatterplotFacet.prototype._formulateImageUrl = function(engineConfig, conf) {
|
_formulateImageUrl(engineConfig, conf) {
|
||||||
var options = {};
|
var options = {};
|
||||||
for (var p in this._config) {
|
for (var p in this._config) {
|
||||||
if (this._config.hasOwnProperty(p)) {
|
if (this._config.hasOwnProperty(p)) {
|
||||||
@ -285,7 +278,7 @@ ScatterplotFacet.prototype._formulateImageUrl = function(engineConfig, conf) {
|
|||||||
return "command/core/get-scatterplot?" + $.param(params);
|
return "command/core/get-scatterplot?" + $.param(params);
|
||||||
};
|
};
|
||||||
|
|
||||||
ScatterplotFacet.prototype.updateState = function(data) {
|
updateState(data) {
|
||||||
if ("error" in data) {
|
if ("error" in data) {
|
||||||
this._error = true;
|
this._error = true;
|
||||||
this._errorMessage = "error" in data ? data.error : $.i18n('core-facets/unknown-error')+".";
|
this._errorMessage = "error" in data ? data.error : $.i18n('core-facets/unknown-error')+".";
|
||||||
@ -326,13 +319,13 @@ ScatterplotFacet.prototype.updateState = function(data) {
|
|||||||
this.render();
|
this.render();
|
||||||
};
|
};
|
||||||
|
|
||||||
ScatterplotFacet.prototype.changePlot = function() {
|
changePlot() {
|
||||||
this._elmts.plotBaseImg.attr("src", this._formulateBaseImageUrl());
|
this._elmts.plotBaseImg.attr("src", this._formulateBaseImageUrl());
|
||||||
this._elmts.plotImg.attr("src", this._formulateCurrentImageUrl());
|
this._elmts.plotImg.attr("src", this._formulateCurrentImageUrl());
|
||||||
this._elmts.exportPlotLink.attr("href", this._formulateExportImageUrl());
|
this._elmts.exportPlotLink.attr("href", this._formulateExportImageUrl());
|
||||||
};
|
};
|
||||||
|
|
||||||
ScatterplotFacet.prototype.render = function() {
|
render() {
|
||||||
if (!this._initializedUI) {
|
if (!this._initializedUI) {
|
||||||
this._initializeUI();
|
this._initializeUI();
|
||||||
this._initializedUI = true;
|
this._initializedUI = true;
|
||||||
@ -353,23 +346,11 @@ ScatterplotFacet.prototype.render = function() {
|
|||||||
this._elmts.exportPlotLink.attr("href", this._formulateExportImageUrl());
|
this._elmts.exportPlotLink.attr("href", this._formulateExportImageUrl());
|
||||||
};
|
};
|
||||||
|
|
||||||
ScatterplotFacet.prototype._remove = function() {
|
_updateRest() {
|
||||||
ui.browsingEngine.removeFacet(this);
|
|
||||||
|
|
||||||
this._div = null;
|
|
||||||
this._config = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
ScatterplotFacet.prototype._minimize = function() {
|
|
||||||
if(!this._minimizeState) {
|
|
||||||
this._div.addClass("facet-state-minimize");
|
|
||||||
} else {
|
|
||||||
this._div.removeClass("facet-state-minimize");
|
|
||||||
}
|
|
||||||
|
|
||||||
this._minimizeState = !this._minimizeState;
|
|
||||||
};
|
|
||||||
|
|
||||||
ScatterplotFacet.prototype._updateRest = function() {
|
|
||||||
Refine.update({ engineChanged: true });
|
Refine.update({ engineChanged: true });
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
ScatterplotFacet.reconstruct = function(div, uiState) {
|
||||||
|
return new ScatterplotFacet(div, uiState.c, uiState.o);
|
||||||
|
};
|
||||||
|
@ -31,37 +31,28 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function TextSearchFacet(div, config, options) {
|
class TextSearchFacet extends Facet {
|
||||||
this._div = div;
|
constructor(div, config, options) {
|
||||||
this._config = config;
|
super(div, config, options);
|
||||||
if (!("invert" in this._config)) {
|
if (!("invert" in this._config)) {
|
||||||
this._config.invert = false;
|
this._config.invert = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._options = options;
|
|
||||||
|
|
||||||
this._minimizeState = false;
|
|
||||||
|
|
||||||
this._query = config.query || null;
|
this._query = config.query || null;
|
||||||
this._timerID = null;
|
this._timerID = null;
|
||||||
|
|
||||||
|
this.textSearchFacetCounterForLabels = 0;
|
||||||
|
|
||||||
this._initializeUI();
|
this._initializeUI();
|
||||||
this._update();
|
this._update();
|
||||||
}
|
|
||||||
|
|
||||||
TextSearchFacet.reconstruct = function(div, uiState) {
|
|
||||||
return new TextSearchFacet(div, uiState.c, uiState.o);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TextSearchFacet.prototype.dispose = function() {
|
reset() {
|
||||||
};
|
|
||||||
|
|
||||||
TextSearchFacet.prototype.reset = function() {
|
|
||||||
this._query = null;
|
this._query = null;
|
||||||
this._div.find(".input-container input").each(function() { this.value = ""; });
|
this._div.find(".input-container input").each(function() { this.value = ""; });
|
||||||
};
|
};
|
||||||
|
|
||||||
TextSearchFacet.prototype.getUIState = function() {
|
getUIState() {
|
||||||
var json = {
|
var json = {
|
||||||
c: this.getJSON(),
|
c: this.getJSON(),
|
||||||
o: this._options
|
o: this._options
|
||||||
@ -70,7 +61,7 @@ TextSearchFacet.prototype.getUIState = function() {
|
|||||||
return json;
|
return json;
|
||||||
};
|
};
|
||||||
|
|
||||||
TextSearchFacet.prototype.getJSON = function() {
|
getJSON() {
|
||||||
var o = {
|
var o = {
|
||||||
type: "text",
|
type: "text",
|
||||||
name: this._config.name,
|
name: this._config.name,
|
||||||
@ -83,11 +74,11 @@ TextSearchFacet.prototype.getJSON = function() {
|
|||||||
return o;
|
return o;
|
||||||
};
|
};
|
||||||
|
|
||||||
TextSearchFacet.prototype.hasSelection = function() {
|
hasSelection() {
|
||||||
return this._query !== null;
|
return this._query !== null;
|
||||||
};
|
};
|
||||||
|
|
||||||
TextSearchFacet.prototype._initializeUI = function() {
|
_initializeUI() {
|
||||||
var self = this;
|
var self = this;
|
||||||
var counter = this._uniqueIdForLabels();
|
var counter = this._uniqueIdForLabels();
|
||||||
this._div.empty().show().html(
|
this._div.empty().show().html(
|
||||||
@ -121,7 +112,7 @@ TextSearchFacet.prototype._initializeUI = function() {
|
|||||||
|
|
||||||
this._elmts.titleSpan.text(this._config.name);
|
this._elmts.titleSpan.text(this._config.name);
|
||||||
if (this._config.caseSensitive) {
|
if (this._config.caseSensitive) {
|
||||||
this._elmts.caseSensitiveCheckbox.prop("checked", true);
|
this._elmts.caseSensitiveCheckbox.prop('checked', true);
|
||||||
}
|
}
|
||||||
if (this._config.mode === "regex") {
|
if (this._config.mode === "regex") {
|
||||||
this._elmts.regexCheckbox.prop('checked', true);
|
this._elmts.regexCheckbox.prop('checked', true);
|
||||||
@ -160,15 +151,15 @@ TextSearchFacet.prototype._initializeUI = function() {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TextSearchFacet.prototype.updateState = function(data) {
|
updateState(data) {
|
||||||
this._update();
|
this._update();
|
||||||
};
|
};
|
||||||
|
|
||||||
TextSearchFacet.prototype.render = function() {
|
render() {
|
||||||
this._setRangeIndicators();
|
this._setRangeIndicators();
|
||||||
};
|
};
|
||||||
|
|
||||||
TextSearchFacet.prototype._reset = function() {
|
_reset() {
|
||||||
this._query = null;
|
this._query = null;
|
||||||
this._config.mode = "text";
|
this._config.mode = "text";
|
||||||
this._config.caseSensitive = false;
|
this._config.caseSensitive = false;
|
||||||
@ -180,31 +171,13 @@ TextSearchFacet.prototype._reset = function() {
|
|||||||
this._updateRest();
|
this._updateRest();
|
||||||
};
|
};
|
||||||
|
|
||||||
TextSearchFacet.prototype._invert = function() {
|
_invert() {
|
||||||
this._config.invert = !this._config.invert;
|
this._config.invert = !this._config.invert;
|
||||||
|
|
||||||
this._updateRest();
|
this._updateRest();
|
||||||
};
|
};
|
||||||
|
|
||||||
TextSearchFacet.prototype._remove = function() {
|
_update() {
|
||||||
ui.browsingEngine.removeFacet(this);
|
|
||||||
|
|
||||||
this._div = null;
|
|
||||||
this._config = null;
|
|
||||||
this._options = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
TextSearchFacet.prototype._minimize = function() {
|
|
||||||
if(!this._minimizeState) {
|
|
||||||
this._div.addClass("facet-state-minimize");
|
|
||||||
} else {
|
|
||||||
this._div.removeClass("facet-state-minimize");
|
|
||||||
}
|
|
||||||
|
|
||||||
this._minimizeState = !this._minimizeState;
|
|
||||||
};
|
|
||||||
|
|
||||||
TextSearchFacet.prototype._update = function () {
|
|
||||||
var invert = this._config.invert;
|
var invert = this._config.invert;
|
||||||
if (invert) {
|
if (invert) {
|
||||||
this._elmts.facetTitle.addClass("facet-title-inverted");
|
this._elmts.facetTitle.addClass("facet-title-inverted");
|
||||||
@ -215,7 +188,7 @@ TextSearchFacet.prototype._update = function () {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TextSearchFacet.prototype._scheduleUpdate = function() {
|
_scheduleUpdate() {
|
||||||
if (!this._timerID) {
|
if (!this._timerID) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this._timerID = window.setTimeout(function() {
|
this._timerID = window.setTimeout(function() {
|
||||||
@ -225,11 +198,16 @@ TextSearchFacet.prototype._scheduleUpdate = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TextSearchFacet.prototype._updateRest = function() {
|
_updateRest() {
|
||||||
Refine.update({ engineChanged: true });
|
Refine.update({ engineChanged: true });
|
||||||
};
|
};
|
||||||
|
|
||||||
var textSearchFacetCounterForLabels = 0;
|
_uniqueIdForLabels() {
|
||||||
TextSearchFacet.prototype._uniqueIdForLabels = function() {
|
return this.textSearchFacetCounterForLabels++;
|
||||||
return textSearchFacetCounterForLabels++;
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
TextSearchFacet.reconstruct = function(div, uiState) {
|
||||||
|
return new TextSearchFacet(div, uiState.c, uiState.o);
|
||||||
};
|
};
|
||||||
|
@ -31,12 +31,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function TimeRangeFacet(div, config, options) {
|
class TimeRangeFacet extends Facet{
|
||||||
this._div = div;
|
constructor(div, config, options) {
|
||||||
this._config = config;
|
super(div, config, options);
|
||||||
this._options = options;
|
|
||||||
|
|
||||||
this._minimizeState = false;
|
|
||||||
|
|
||||||
this._from = ("from" in this._config) ? this._config.from : null;
|
this._from = ("from" in this._config) ? this._config.from : null;
|
||||||
this._to = ("to" in this._config) ? this._config.to : null;
|
this._to = ("to" in this._config) ? this._config.to : null;
|
||||||
@ -59,9 +56,9 @@ function TimeRangeFacet(div, config, options) {
|
|||||||
|
|
||||||
this._error = false;
|
this._error = false;
|
||||||
this._initializedUI = false;
|
this._initializedUI = false;
|
||||||
}
|
};
|
||||||
|
|
||||||
TimeRangeFacet.prototype.reset = function() {
|
reset() {
|
||||||
this._from = this._config.min;
|
this._from = this._config.min;
|
||||||
this._to = this._config.max;
|
this._to = this._config.max;
|
||||||
this._sliderWidget.update(
|
this._sliderWidget.update(
|
||||||
@ -80,14 +77,7 @@ TimeRangeFacet.prototype.reset = function() {
|
|||||||
this._setRangeIndicators();
|
this._setRangeIndicators();
|
||||||
};
|
};
|
||||||
|
|
||||||
TimeRangeFacet.reconstruct = function(div, uiState) {
|
getUIState() {
|
||||||
return new TimeRangeFacet(div, uiState.c, uiState.o);
|
|
||||||
};
|
|
||||||
|
|
||||||
TimeRangeFacet.prototype.dispose = function() {
|
|
||||||
};
|
|
||||||
|
|
||||||
TimeRangeFacet.prototype.getUIState = function() {
|
|
||||||
var json = {
|
var json = {
|
||||||
c: this.getJSON(),
|
c: this.getJSON(),
|
||||||
o: this._options
|
o: this._options
|
||||||
@ -96,7 +86,7 @@ TimeRangeFacet.prototype.getUIState = function() {
|
|||||||
return json;
|
return json;
|
||||||
};
|
};
|
||||||
|
|
||||||
TimeRangeFacet.prototype.getJSON = function() {
|
getJSON() {
|
||||||
var o = {
|
var o = {
|
||||||
type: "timerange",
|
type: "timerange",
|
||||||
name: this._config.name,
|
name: this._config.name,
|
||||||
@ -118,7 +108,7 @@ TimeRangeFacet.prototype.getJSON = function() {
|
|||||||
return o;
|
return o;
|
||||||
};
|
};
|
||||||
|
|
||||||
TimeRangeFacet.prototype.hasSelection = function() {
|
hasSelection() {
|
||||||
if (!this._selectTime || !this._selectNonTime || !this._selectBlank || !this._selectError) {
|
if (!this._selectTime || !this._selectNonTime || !this._selectBlank || !this._selectError) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -127,7 +117,7 @@ TimeRangeFacet.prototype.hasSelection = function() {
|
|||||||
(this._to !== null && (!this._initializedUI || this._to < this._config.max));
|
(this._to !== null && (!this._initializedUI || this._to < this._config.max));
|
||||||
};
|
};
|
||||||
|
|
||||||
TimeRangeFacet.prototype._initializeUI = function() {
|
_initializeUI() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this._div
|
this._div
|
||||||
.empty()
|
.empty()
|
||||||
@ -195,7 +185,7 @@ TimeRangeFacet.prototype._initializeUI = function() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
TimeRangeFacet.prototype._renderOtherChoices = function() {
|
_renderOtherChoices() {
|
||||||
var self = this;
|
var self = this;
|
||||||
var container = this._elmts.otherChoicesDiv.empty();
|
var container = this._elmts.otherChoicesDiv.empty();
|
||||||
|
|
||||||
@ -270,21 +260,7 @@ TimeRangeFacet.prototype._renderOtherChoices = function() {
|
|||||||
choices.appendTo(container);
|
choices.appendTo(container);
|
||||||
};
|
};
|
||||||
|
|
||||||
TimeRangeFacet.prototype.steps = [
|
_setRangeIndicators() {
|
||||||
1, // msec
|
|
||||||
1000, // sec
|
|
||||||
1000*60, // min
|
|
||||||
1000*60*60, // hour
|
|
||||||
1000*60*60*24, // day
|
|
||||||
1000*60*60*24*7, // week
|
|
||||||
1000*2629746, // month (average Gregorian year / 12)
|
|
||||||
1000*31556952, // year (average Gregorian year)
|
|
||||||
1000*31556952*10, // decade
|
|
||||||
1000*31556952*100, // century
|
|
||||||
1000*31556952*1000 // millennium
|
|
||||||
];
|
|
||||||
|
|
||||||
TimeRangeFacet.prototype._setRangeIndicators = function() {
|
|
||||||
var fromDate = new Date(this._from);
|
var fromDate = new Date(this._from);
|
||||||
var toDate = new Date(this._to);
|
var toDate = new Date(this._to);
|
||||||
|
|
||||||
@ -301,19 +277,7 @@ TimeRangeFacet.prototype._setRangeIndicators = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TimeRangeFacet.prototype._addCommas = function(nStr) {
|
updateState(data) {
|
||||||
nStr += '';
|
|
||||||
x = nStr.split('.');
|
|
||||||
x1 = x[0];
|
|
||||||
x2 = x.length > 1 ? '.' + x[1] : '';
|
|
||||||
var rgx = /(\d+)(\d{3})/;
|
|
||||||
while (rgx.test(x1)) {
|
|
||||||
x1 = x1.replace(rgx, '$1' + ',' + '$2');
|
|
||||||
}
|
|
||||||
return x1 + x2;
|
|
||||||
};
|
|
||||||
|
|
||||||
TimeRangeFacet.prototype.updateState = function(data) {
|
|
||||||
if ("min" in data && "max" in data) {
|
if ("min" in data && "max" in data) {
|
||||||
this._error = false;
|
this._error = false;
|
||||||
|
|
||||||
@ -358,7 +322,7 @@ TimeRangeFacet.prototype.updateState = function(data) {
|
|||||||
this.render();
|
this.render();
|
||||||
};
|
};
|
||||||
|
|
||||||
TimeRangeFacet.prototype.render = function() {
|
render() {
|
||||||
if (!this._initializedUI) {
|
if (!this._initializedUI) {
|
||||||
this._initializeUI();
|
this._initializeUI();
|
||||||
this._initializedUI = true;
|
this._initializedUI = true;
|
||||||
@ -397,29 +361,11 @@ TimeRangeFacet.prototype.render = function() {
|
|||||||
this._renderOtherChoices();
|
this._renderOtherChoices();
|
||||||
};
|
};
|
||||||
|
|
||||||
TimeRangeFacet.prototype._remove = function() {
|
_updateRest() {
|
||||||
ui.browsingEngine.removeFacet(this);
|
|
||||||
|
|
||||||
this._div = null;
|
|
||||||
this._config = null;
|
|
||||||
this._data = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
TimeRangeFacet.prototype._minimize = function() {
|
|
||||||
if(!this._minimizeState) {
|
|
||||||
this._div.addClass("facet-state-minimize");
|
|
||||||
} else {
|
|
||||||
this._div.removeClass("facet-state-minimize");
|
|
||||||
}
|
|
||||||
|
|
||||||
this._minimizeState = !this._minimizeState;
|
|
||||||
};
|
|
||||||
|
|
||||||
TimeRangeFacet.prototype._updateRest = function() {
|
|
||||||
Refine.update({ engineChanged: true });
|
Refine.update({ engineChanged: true });
|
||||||
};
|
};
|
||||||
|
|
||||||
TimeRangeFacet.prototype._editExpression = function() {
|
_editExpression() {
|
||||||
var self = this;
|
var self = this;
|
||||||
var title = (this._config.columnName) ?
|
var title = (this._config.columnName) ?
|
||||||
($.i18n('core-facets/edit-based-col')+" " + this._config.columnName) :
|
($.i18n('core-facets/edit-based-col')+" " + this._config.columnName) :
|
||||||
@ -447,3 +393,22 @@ TimeRangeFacet.prototype._editExpression = function() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
TimeRangeFacet.reconstruct = function(div, uiState) {
|
||||||
|
return new TimeRangeFacet(div, uiState.c, uiState.o);
|
||||||
|
};
|
||||||
|
|
||||||
|
TimeRangeFacet.prototype.steps = [
|
||||||
|
1, // msec
|
||||||
|
1000, // sec
|
||||||
|
1000*60, // min
|
||||||
|
1000*60*60, // hour
|
||||||
|
1000*60*60*24, // day
|
||||||
|
1000*60*60*24*7, // week
|
||||||
|
1000*2629746, // month (average Gregorian year / 12)
|
||||||
|
1000*31556952, // year (average Gregorian year)
|
||||||
|
1000*31556952*10, // decade
|
||||||
|
1000*31556952*100, // century
|
||||||
|
1000*31556952*1000 // millennium
|
||||||
|
];
|
||||||
|
Loading…
Reference in New Issue
Block a user