Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Reduce global scope pollution. Fix some destroy implementations missi…
Browse files Browse the repository at this point in the history
…ng the cache destruction.
  • Loading branch information
cdujeu committed Apr 21, 2015
1 parent 31cd0b1 commit 09bc7e0
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 42 deletions.
2 changes: 1 addition & 1 deletion core/src/plugins/core.notifications/manifest.xml
Expand Up @@ -133,7 +133,7 @@
<component_config className="AjxpPane::navigation_scroller">
<additional_content id="navigation_alerts"><![CDATA[
<div id="navigation_alerts" ajxp_position="0">
<h3 class="colorcode-alert" ajxp_message_id="notification_center.3">AJXP_MESSAGE[notification_center.3] <span class="alerts_number_badge" id="alerts_number" ajxpClass="DataModelProperty" ajxpOptions='{"dmID":"notif_pane","property":"metadata","metadata_sum":"event_occurence"}'></span><small id="alerts_toggler" class="simple-toggler-hide" ajxpClass="VisibilityToggler" ajxpOptions='{"widget_id":"notif_pane"}'>AJXP_MESSAGE[514]</small></h3>
<h3 ajxpClass="AjxpPane" id="alert_title_widget" class="colorcode-alert" ajxp_message_id="notification_center.3">AJXP_MESSAGE[notification_center.3] <span class="alerts_number_badge" id="alerts_number" ajxpClass="DataModelProperty" ajxpOptions='{"dmID":"notif_pane","property":"metadata","metadata_sum":"event_occurence"}'></span><small id="alerts_toggler" class="simple-toggler-hide" ajxpClass="VisibilityToggler" ajxpOptions='{"widget_id":"notif_pane"}'>AJXP_MESSAGE[514]</small></h3>
<div id="notif_pane" ajxpClass="FetchedResultPane" ajxpOptions='{"forceClearOnRepoSwitch":true, "inlineToolbarOptions":{"toolbarsList":["inline-notifications"]}, "fit":"content", "columnsDef":[{"attributeName":"ajxp_label", "messageId":1, "sortType":"String"},{"attributeName":"event_description", "messageString":"Description", "sortType":"String"}], "reloadOnServerMessage":"tree/reload_user_feed", "silentLoading":true, "fixedSortColumn":"event_time", "fixedSortDirection":"desc","nodeProviderProperties":{"get_action":"get_my_feed", "connexion_discrete":true, "format":"xml", "current_repository":"true", "feed_type":"alert", "merge_description":"true"}, "emptyChildrenMessage":"notification_center.8"}'></div>
</div>
]]></additional_content>
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/gui.ajax/res/js/ajaxplorer.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions core/src/plugins/gui.ajax/res/js/lib/prototype/splitter.js
Expand Up @@ -216,6 +216,7 @@ Class.create("Splitter", AjxpPane, {
this.paneB.remove();
this.paneB = null;
}
try{pydio.UI.removeInstanceFromCache(this.htmlElement.id);}catch(e){}
},

getFoldingAction : function(){
Expand Down
Expand Up @@ -99,15 +99,15 @@ Class.create("ActionsManager", {
}
},

updateGuiActions(actions){
updateGuiActions: function(actions){
this._guiActions.update(actions);
},

deleteFromGuiActions(actionName){
deleteFromGuiActions: function(actionName){
this._guiActions.unset(actionName);
},

refreshGuiActionsI18n(){
refreshGuiActionsI18n: function(){
this._guiActions.each(function(pair){
pair.value.refreshFromI18NHash();
});
Expand Down
Expand Up @@ -95,7 +95,7 @@ Class.create("ActionsToolbar", AjxpPane, {
getDomNode : function(){
return this.element;
},
destroy : function(){
destroy : function($super){
this.emptyToolbars();
if(this.options.manager){
this.options.manager.stopObserving("actions_loaded", this.actionsLoadedObserver);
Expand All @@ -107,6 +107,7 @@ Class.create("ActionsToolbar", AjxpPane, {
}
document.stopObserving("ajaxplorer:component_config_changed", this.componentConfigHandler );
if(this.styleObserver) document.stopObserving("ajaxplorer:user_logged", this.styleObserver);
$super();
},

/**
Expand Down
6 changes: 3 additions & 3 deletions core/src/plugins/gui.ajax/res/js/pydio/ui/class.AjxpPane.js
Expand Up @@ -274,9 +274,9 @@ Class.create("AjxpPane", {
});
if(!this.htmlElement) return;
this.htmlElement.update("");
if(window[this.htmlElement.id]){
try{delete window[this.htmlElement.id];}catch(e){}
}
try{
pydio.UI.removeInstanceFromCache(this.htmlElement.id);
}catch(e){}
this.htmlElement = null;
if(this.boundSizeEvents){
this.boundSizeEvents.each(function(pair){
Expand Down
Expand Up @@ -570,9 +570,7 @@ Class.create("AjxpTabulator", AjxpPane, {
}

this.htmlElement.update("");
if(window[this.htmlElement.id]){
try{delete window[this.htmlElement.id];}catch(e){}
}
try{pydio.UI.removeInstanceFromCache(this.htmlElement.id);}catch(e){}
this.htmlElement = null;
},

Expand Down
4 changes: 2 additions & 2 deletions core/src/plugins/gui.ajax/res/js/pydio/ui/class.Breadcrumb.js
Expand Up @@ -163,9 +163,9 @@ Class.create("Breadcrumb", AjxpPane, {
/**
* Implementation of the IAjxpWidget methods
*/
destroy : function(){
destroy : function($super){
document.stopObserving("ajaxplorer:context_changed",this.observerFunc);
this.element = null;
$super();
},

/**
Expand Down
Expand Up @@ -23,7 +23,8 @@ Class.create("DataModelProperty", {
__implements: ["IAjxpWidget"],

initialize: function(element, options){

this.element = element;
this.element.ajxpPaneObject = this;
options = Object.extend({
dmID: "ajaxplorer-global"
}, options);
Expand All @@ -34,7 +35,7 @@ Class.create("DataModelProperty", {
dm = $(options.dmID).ajxpPaneObject.getDataModel();
}
if(!dm) return;
dm.getRootNode().observe("loaded", function(){
this.observer = function(){
switch (options.property){
case "root_children":
var l = dm.getRootNode().getChildren().length;
Expand All @@ -56,14 +57,23 @@ Class.create("DataModelProperty", {
}


}.bind(this));

}.bind(this);
dm.getRootNode().observe("loaded", this.observer);
this.dm = dm;
},

resize : function(){},
showElement : function(show){},
getDomNode : function(){},
destroy : function(){}
destroy : function(){
if(this.dm && this.dm.getRootNode()){
this.dm.getRootNode().stopObserving(this.observer);
}
try{
pydio.UI.removeInstanceFromCache(this.element.id);
}catch(e){}
this.element = null;
}


});
4 changes: 1 addition & 3 deletions core/src/plugins/gui.ajax/res/js/pydio/ui/class.FilesList.js
Expand Up @@ -259,9 +259,7 @@ Class.create("FilesList", SelectableElements, {
this.empty(true);
$super();
this._clearObservers();
if(window[this.htmlElement.id]){
try{delete window[this.htmlElement.id];}catch(e){}
}
try{pydio.UI.removeInstanceFromCache(this.htmlElement.id);}catch(e){}
if(this.boundSizeEvents){
this.boundSizeEvents.each(function(pair){
document.stopObserving(pair.key, pair.value);
Expand Down
Expand Up @@ -129,9 +129,7 @@ Class.create("FoldersTree", AjxpPane, {
});
if(this.scrollbar) this.scrollbar.destroy();
if(this.tree) this.tree.destroy();
if(window[this.htmlElement.id]){
try{delete window[this.htmlElement.id];}catch(e){}
}
try{pydio.UI.removeInstanceFromCache(this.htmlElement.id);}catch(e){}
$super();
},

Expand Down
4 changes: 1 addition & 3 deletions core/src/plugins/gui.ajax/res/js/pydio/ui/class.InfoPanel.js
Expand Up @@ -103,9 +103,7 @@ Class.create("InfoPanel", AjxpPane, {
this.scroller.remove();
}
this.htmlElement.update("");
if(window[this.htmlElement.id]){
try{delete window[this.htmlElement.id];}catch(e){}
}
try{pydio.UI.removeInstanceFromCache(this.htmlElement.id);}catch(e){}
this.htmlElement = null;
},
/**
Expand Down
14 changes: 9 additions & 5 deletions core/src/plugins/gui.ajax/res/js/pydio/ui/class.PydioUI.js
Expand Up @@ -32,9 +32,13 @@ Class.create("PydioUI", {
this._editorOpener = null;
this._messageBoxReference = null;

this._instancesCache = $H();
},


removeInstanceFromCache: function(instanceId){
this._instancesCache.unset(instanceId);
},
/**
*
* @param passedTarget
Expand Down Expand Up @@ -193,7 +197,7 @@ Class.create("PydioUI", {
var el = compRegistry[i-1];
var ajxpId = el.ajxpId;
compRegistry[i-1] = new el['ajxpClass'](el.ajxpNode, el.ajxpOptions);
window[ajxpId] = compRegistry[i-1];
this._instancesCache.set(ajxpId, compRegistry[i-1]);
lastInst = compRegistry[i-1];
}
if(lastInst){
Expand Down Expand Up @@ -307,9 +311,9 @@ Class.create("PydioUI", {
* @param cdataContent
*/
refreshGuiComponent:function(ajxpId, ajxpClass, ajxpClassName, ajxpOptionsString, cdataContent){
if(!window[ajxpId]) return;
if(!this._instancesCache.get(ajxpId)) return;
// First destroy current component, unregister actions, etc.
var oldObj = window[ajxpId];
var oldObj = this._instancesCache.get(ajxpId);
if(!oldObj.__className) {
if(!$(ajxpId)) return;
oldObj = $(ajxpId).ajxpPaneObject;
Expand Down Expand Up @@ -356,7 +360,7 @@ Class.create("PydioUI", {

obj.__ajxpOptionsString = ajxpOptionsString;

window[ajxpId] = obj;
this._instancesCache.set(ajxpId, obj);
obj.resize();
delete(oldObj);
},
Expand Down Expand Up @@ -445,7 +449,7 @@ Class.create("PydioUI", {



getRegisteredComponentsByClassName(className){
getRegisteredComponentsByClassName: function(className){
return this._guiCompRegistry.select(function(guiComponent){
return (guiComponent.__className == className);
});
Expand Down
Expand Up @@ -56,7 +56,8 @@ Class.create("RepositorySelect", {
* Implementation of the IAjxpWidget methods
*/
destroy : function(){
this.element = null;
try{pydio.UI.removeInstanceFromCache(this.element.id);}catch(e){}
this.element = null;
document.stopObserving("ajaxplorer:repository_list_refreshed", this.observer);
if(this.repoMenu){
this.repoMenu.destroy();
Expand Down
Expand Up @@ -573,20 +573,13 @@ Class.create("SearchEngine", AjxpPane, {
}
document.stopObserving("ajaxplorer:repository_list_refreshed", this.refreshObserver);
document.stopObserving("ajaxplorer:registry_loaded", this.searchModeObserver);
/*
if(this.ctxChangeObserver){
document.stopObserving("ajaxplorer:context_changed", this.ctxChangeObserver);
}
*/
if(this.boundSizeEvents){
this.boundSizeEvents.each(function(pair){
document.stopObserving(pair.key, pair.value);
});
}
this.htmlElement = null;
if(ajxpId && window[ajxpId]){
try {delete window[ajxpId];}catch(e){}
}
try{pydio.UI.removeInstanceFromCache(ajxpId);}catch(e){}
},
/**
* Initialise the options for search Metadata
Expand Down

0 comments on commit 09bc7e0

Please sign in to comment.