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) {
|
reset() {
|
||||||
return new ListFacet(div, uiState.c, uiState.o, uiState.s);
|
|
||||||
};
|
|
||||||
|
|
||||||
ListFacet.prototype.dispose = function() {
|
|
||||||
};
|
|
||||||
|
|
||||||
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
|
||||||
@ -79,9 +70,9 @@ ListFacet.prototype.getUIState = function() {
|
|||||||
delete json.c.selection;
|
delete json.c.selection;
|
||||||
|
|
||||||
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,
|
||||||
@ -101,15 +92,15 @@ ListFacet.prototype.getJSON = function() {
|
|||||||
o.selection.push(choice);
|
o.selection.push(choice);
|
||||||
}
|
}
|
||||||
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) {
|
||||||
@ -129,9 +120,9 @@ 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());
|
||||||
@ -141,9 +132,9 @@ ListFacet.prototype._reSortChoices = function() {
|
|||||||
return c !== 0 ? c : a.v.l.localeCompare(b.v.l);
|
return c !== 0 ? c : a.v.l.localeCompare(b.v.l);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
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");
|
||||||
@ -226,9 +217,9 @@ 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");
|
||||||
@ -262,9 +253,9 @@ ListFacet.prototype._copyChoices = function() {
|
|||||||
textarea.value = lines.join("\n");
|
textarea.value = lines.join("\n");
|
||||||
textarea.focus();
|
textarea.focus();
|
||||||
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;
|
||||||
@ -330,15 +321,15 @@ ListFacet.prototype._update = function(resetScroll) {
|
|||||||
|
|
||||||
// None of the following alternatives are significantly faster
|
// None of the following alternatives are significantly faster
|
||||||
|
|
||||||
// this._elmts.bodyInnerDiv.innerHtml = '';
|
// this._elmts.bodyInnerDiv.innerHtml = '';
|
||||||
|
|
||||||
// this._elmts.bodyInnerDiv.detach();
|
// this._elmts.bodyInnerDiv.detach();
|
||||||
// this._elmts.bodyInnerDiv.children().remove();
|
// this._elmts.bodyInnerDiv.children().remove();
|
||||||
// this._elmts.bodyInnerDiv.appendTo('.facet-body');
|
// this._elmts.bodyInnerDiv.appendTo('.facet-body');
|
||||||
|
|
||||||
// this._elmts.bodyInnerDiv.remove();
|
// this._elmts.bodyInnerDiv.remove();
|
||||||
// this._elmts.bodyInnerDiv.html('<div class="facet-body-inner" bind="bodyInnerDiv"></div>');
|
// this._elmts.bodyInnerDiv.html('<div class="facet-body-inner" bind="bodyInnerDiv"></div>');
|
||||||
// this._elmts.bodyInnerDiv.appendTo('.facet-body');
|
// this._elmts.bodyInnerDiv.appendTo('.facet-body');
|
||||||
|
|
||||||
//this._elmts.statusDiv.show();
|
//this._elmts.statusDiv.show();
|
||||||
this._elmts.controlsDiv.show();
|
this._elmts.controlsDiv.show();
|
||||||
@ -482,9 +473,9 @@ 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")
|
||||||
@ -509,9 +500,9 @@ 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(' + [
|
||||||
@ -519,13 +510,13 @@ ListFacet.prototype._getMetaExpression = function() {
|
|||||||
JSON.stringify(this._config.expression),
|
JSON.stringify(this._config.expression),
|
||||||
JSON.stringify(this._config.columnName)
|
JSON.stringify(this._config.columnName)
|
||||||
].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");
|
||||||
@ -622,9 +613,9 @@ ListFacet.prototype._editChoice = function(choice, choiceDiv) {
|
|||||||
elmts.cancelButton.click(function() {
|
elmts.cancelButton.click(function() {
|
||||||
MenuSystem.dismissAll();
|
MenuSystem.dismissAll();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
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) {
|
||||||
@ -641,9 +632,9 @@ 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 {
|
||||||
@ -655,50 +646,28 @@ 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;
|
||||||
this._config.invert = false;
|
this._config.invert = false;
|
||||||
|
|
||||||
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) :
|
||||||
@ -731,9 +700,9 @@ ListFacet.prototype._editExpression = function() {
|
|||||||
self._elmts.expressionDiv.hide();
|
self._elmts.expressionDiv.hide();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
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) {
|
||||||
@ -758,4 +727,10 @@ 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(
|
||||||
@ -77,25 +77,18 @@ RangeFacet.prototype.reset = function() {
|
|||||||
this._selectError = true;
|
this._selectError = true;
|
||||||
|
|
||||||
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
|
||||||
};
|
};
|
||||||
|
|
||||||
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,
|
||||||
@ -115,18 +108,18 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (this._from !== null && (!this._initializedUI || this._from > this._config.min)) ||
|
return (this._from !== null && (!this._initializedUI || this._from > this._config.min)) ||
|
||||||
(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()
|
||||||
@ -192,9 +185,9 @@ RangeFacet.prototype._initializeUI = function() {
|
|||||||
self._selectNumeric = true;
|
self._selectNumeric = true;
|
||||||
self._updateRest();
|
self._updateRest();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
RangeFacet.prototype._renderOtherChoices = function() {
|
_renderOtherChoices() {
|
||||||
var self = this;
|
var self = this;
|
||||||
var container = this._elmts.otherChoicesDiv.empty();
|
var container = this._elmts.otherChoicesDiv.empty();
|
||||||
|
|
||||||
@ -267,25 +260,13 @@ 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;
|
||||||
|
|
||||||
@ -326,9 +307,9 @@ 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;
|
||||||
@ -365,31 +346,13 @@ RangeFacet.prototype.render = function() {
|
|||||||
|
|
||||||
this._setRangeIndicators();
|
this._setRangeIndicators();
|
||||||
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) :
|
||||||
@ -416,4 +379,9 @@ RangeFacet.prototype._editExpression = function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
RangeFacet.reconstruct = function(div, uiState) {
|
||||||
|
return new RangeFacet(div, uiState.c, uiState.o);
|
||||||
};
|
};
|
@ -31,62 +31,55 @@ 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;
|
||||||
delete this._config.to_y;
|
delete this._config.to_y;
|
||||||
this._plotAreaSelector.setOptions({ hide : true });
|
this._plotAreaSelector.setOptions({ hide : true });
|
||||||
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
|
||||||
};
|
};
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
@ -225,9 +218,9 @@ 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;
|
||||||
@ -239,9 +232,9 @@ ScatterplotFacet.prototype._fillSelectionOptions = function(ops) {
|
|||||||
ops.x2 = ops.y2 = this._config.l;
|
ops.x2 = ops.y2 = this._config.l;
|
||||||
ops.hide = true;
|
ops.hide = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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 {
|
||||||
@ -251,21 +244,21 @@ ScatterplotFacet.prototype._putSelectionOptions = function(selection) {
|
|||||||
this._config.from_y = (this._config.l - selection.y2) / this._config.l;
|
this._config.from_y = (this._config.l - selection.y2) / this._config.l;
|
||||||
this._config.to_y = (this._config.l - selection.y1) / this._config.l;
|
this._config.to_y = (this._config.l - selection.y1) / this._config.l;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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)) {
|
||||||
@ -283,9 +276,9 @@ ScatterplotFacet.prototype._formulateImageUrl = function(engineConfig, conf) {
|
|||||||
plotter: JSON.stringify(options)
|
plotter: JSON.stringify(options)
|
||||||
};
|
};
|
||||||
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')+".";
|
||||||
@ -324,15 +317,15 @@ 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;
|
||||||
@ -351,25 +344,13 @@ ScatterplotFacet.prototype.render = function() {
|
|||||||
|
|
||||||
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._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,46 +31,37 @@ 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) {
|
reset() {
|
||||||
return new TextSearchFacet(div, uiState.c, uiState.o);
|
|
||||||
};
|
|
||||||
|
|
||||||
TextSearchFacet.prototype.dispose = function() {
|
|
||||||
};
|
|
||||||
|
|
||||||
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
|
||||||
};
|
};
|
||||||
|
|
||||||
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,
|
||||||
@ -81,13 +72,13 @@ TextSearchFacet.prototype.getJSON = function() {
|
|||||||
query: this._query
|
query: this._query
|
||||||
};
|
};
|
||||||
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);
|
||||||
@ -158,17 +149,17 @@ TextSearchFacet.prototype._initializeUI = function() {
|
|||||||
self._scheduleUpdate();
|
self._scheduleUpdate();
|
||||||
}).focus();
|
}).focus();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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;
|
||||||
@ -178,33 +169,15 @@ TextSearchFacet.prototype._reset = function() {
|
|||||||
this._config.invert = false;
|
this._config.invert = false;
|
||||||
|
|
||||||
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");
|
||||||
@ -213,9 +186,9 @@ TextSearchFacet.prototype._update = function () {
|
|||||||
this._elmts.facetTitle.removeClass("facet-title-inverted");
|
this._elmts.facetTitle.removeClass("facet-title-inverted");
|
||||||
this._elmts.invertButton.removeClass("facet-mode-inverted");
|
this._elmts.invertButton.removeClass("facet-mode-inverted");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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() {
|
||||||
@ -223,13 +196,18 @@ TextSearchFacet.prototype._scheduleUpdate = function() {
|
|||||||
self._updateRest();
|
self._updateRest();
|
||||||
}, self._config.mode === 'regex' ? 1500 : 500);
|
}, self._config.mode === 'regex' ? 1500 : 500);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TextSearchFacet.prototype._updateRest = function() {
|
_updateRest() {
|
||||||
Refine.update({ engineChanged: true });
|
Refine.update({ engineChanged: true });
|
||||||
|
};
|
||||||
|
|
||||||
|
_uniqueIdForLabels() {
|
||||||
|
return this.textSearchFacetCounterForLabels++;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
var textSearchFacetCounterForLabels = 0;
|
|
||||||
TextSearchFacet.prototype._uniqueIdForLabels = function() {
|
TextSearchFacet.reconstruct = function(div, uiState) {
|
||||||
return textSearchFacetCounterForLabels++;
|
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(
|
||||||
@ -78,25 +75,18 @@ TimeRangeFacet.prototype.reset = function() {
|
|||||||
this._selectError = true;
|
this._selectError = true;
|
||||||
|
|
||||||
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
|
||||||
};
|
};
|
||||||
|
|
||||||
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,
|
||||||
@ -116,18 +106,18 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (this._from !== null && (!this._initializedUI || this._from > this._config.min)) ||
|
return (this._from !== null && (!this._initializedUI || this._from > this._config.min)) ||
|
||||||
(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()
|
||||||
@ -193,9 +183,9 @@ TimeRangeFacet.prototype._initializeUI = function() {
|
|||||||
self._selectTime = true;
|
self._selectTime = true;
|
||||||
self._updateRest();
|
self._updateRest();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
TimeRangeFacet.prototype._renderOtherChoices = function() {
|
_renderOtherChoices() {
|
||||||
var self = this;
|
var self = this;
|
||||||
var container = this._elmts.otherChoicesDiv.empty();
|
var container = this._elmts.otherChoicesDiv.empty();
|
||||||
|
|
||||||
@ -268,23 +258,9 @@ 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);
|
||||||
|
|
||||||
@ -299,21 +275,9 @@ TimeRangeFacet.prototype._setRangeIndicators = function() {
|
|||||||
var dayOfYearFormat = "yyyy-MM-dd";
|
var dayOfYearFormat = "yyyy-MM-dd";
|
||||||
this._elmts.statusDiv.html("<b>" + fromDate.toString(dayOfYearFormat) + "</b> " + fromDate.toString(timeOfDayformat) + " — " + "<b>" + toDate.toString(dayOfYearFormat) + "</b> " + toDate.toString(timeOfDayformat) );
|
this._elmts.statusDiv.html("<b>" + fromDate.toString(dayOfYearFormat) + "</b> " + fromDate.toString(timeOfDayformat) + " — " + "<b>" + toDate.toString(dayOfYearFormat) + "</b> " + toDate.toString(timeOfDayformat) );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
@ -356,9 +320,9 @@ 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;
|
||||||
@ -395,31 +359,13 @@ TimeRangeFacet.prototype.render = function() {
|
|||||||
|
|
||||||
this._setRangeIndicators();
|
this._setRangeIndicators();
|
||||||
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) :
|
||||||
@ -446,4 +392,23 @@ 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