Added dispose method to facets so they can clean up themselves.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@495 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-04-17 06:58:30 +00:00
parent 98f12544de
commit d61473e989
5 changed files with 22 additions and 6 deletions

View File

@ -20,6 +20,9 @@ ListFacet.reconstruct = function(div, uiState) {
return new ListFacet(div, uiState.c, uiState.o, uiState.s);
};
ListFacet.prototype.dispose = function() {
};
ListFacet.prototype.reset = function() {
this._selection = [];
this._blankChoice = null;

View File

@ -53,6 +53,9 @@ RangeFacet.reconstruct = function(div, uiState) {
return new RangeFacet(div, uiState.c, uiState.o);
};
RangeFacet.prototype.dispose = function() {
};
RangeFacet.prototype.getUIState = function() {
var json = {
c: this.getJSON(),
@ -62,7 +65,6 @@ RangeFacet.prototype.getUIState = function() {
return json;
};
RangeFacet.prototype.getJSON = function() {
var o = {
type: "range",

View File

@ -19,6 +19,10 @@ ScatterplotFacet.reconstruct = function(div, uiState) {
return new ScatterplotFacet(div, uiState.c, uiState.o);
};
ScatterplotFacet.prototype.dispose = function() {
this._plotImg.imgAreaSelect({ hide : true });
};
ScatterplotFacet.prototype.getUIState = function() {
var json = {
c: this.getJSON(),

View File

@ -13,6 +13,9 @@ TextSearchFacet.reconstruct = function(div, uiState) {
return new TextSearchFacet(div, uiState.c, uiState.o);
};
TextSearchFacet.prototype.dispose = function() {
};
TextSearchFacet.prototype.reset = function() {
this._query = null;
this._div.find(".input-container input").each(function() { this.value = ""; });

View File

@ -140,16 +140,18 @@ BrowsingEngine.prototype._createFacetContainer = function() {
BrowsingEngine.prototype.removeFacet = function(facet) {
var update = facet.hasSelection();
for (var i = this._facets.length - 1;i >= 0; i--) {
if (this._facets[i].facet === facet) {
var elmt = this._facets[i].elmt;
var facetRecord = this._facets[i];
if (facetRecord.facet === facet) {
this._facets.splice(i, 1);
facetRecord.facet.dispose();
// This makes really big facet disappear right away. If you just call remove()
// then it takes a while for all the event handlers to get unwired, and the UI
// appear frozen.
elmt.hide();
facetRecord.elmt.hide();
window.setTimeout(function() {
elmt.remove();
facetRecord.elmt.remove();
}, 300);
break;
@ -207,7 +209,9 @@ BrowsingEngine.prototype.remove = function() {
this._facets = [];
for (var i = 0; i < oldFacets.length; i++) {
oldFacets[i].elmt.hide();
var facet = oldFacets[i];
facet.facet.dispose();
facet.elmt.hide();
}
window.setTimeout(function() {
for (var i = 0; i < oldFacets.length; i++) {