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

Commit

Permalink
Better widget detroy (guiActions and focusables were not cleanly dere…
Browse files Browse the repository at this point in the history
…gistered).

TODO: check legacy themes, the FilesList actions have moved from default to id-actions actionbargroup.
  • Loading branch information
cdujeu committed Oct 15, 2014
1 parent 6d13f4b commit a38d25b
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 21 deletions.
4 changes: 2 additions & 2 deletions core/src/plugins/access.fs/fsTemplatePart.xml
Expand Up @@ -24,7 +24,7 @@
<div id="navigation_folders" ajxp_position="3">
<h3 class="colorcode-folder" ajxp_message_id="130">AJXP_MESSAGE[130]
<small id="folders_pane_toggler" ajxpClass="VisibilityToggler" ajxpOptions='{"widget_id":"folder_pane", "detection_id":"tree_container"}'>AJXP_MESSAGE[514]</small>
<small onclick="$('folder_pane').toggleClassName('show_first_level');$(this).toggleClassName('expand_button_hide');document.fire('ajaxplorer:tree_change');"><span class='expand_label_show' ajxp_message_id="516">AJXP_MESSAGE[516]</span><span class='expand_label_hide'ajxp_message_id="517">AJXP_MESSAGE[517]</span></small>&nbsp;
<small onclick="$('folder_pane').ajxpPaneObject.toggleClassNameSavingPref('show_first_level');$(this).toggleClassName('expand_button_hide');document.fire('ajaxplorer:tree_change');"><span class='expand_label_show' ajxp_message_id="516">AJXP_MESSAGE[516]</span><span class='expand_label_hide'ajxp_message_id="517">AJXP_MESSAGE[517]</span></small>&nbsp;
</h3>
<div id="folder_pane" class="show_first_level" ajxpClass="FoldersTree" ajxpOptions='{"display":"dz","replaceScroller":false,"fit":"content"}' ></div>
</div>
Expand All @@ -35,7 +35,7 @@
<div id="cpane_tabs" ajxpClass="AjxpTabulator" ajxpOptions='{"fit":"height", "fitParent":"browser", "refireResize":0.5, "registerAsEditorOpener":true, "saveState":true,"events":{"ajaxplorer:context_changed":"this.switchTabulator(this.tabulatorData.first().id);"}, "defaultTabId": "files","tabInfos" : [{"id":"files","label":"","iconClass":"icon-folder-open", "element":"files_list_pane"}]}'>
<div id="files_list_pane" ajxpClass="AjxpPane">
<div id="files_list_header" ajxpClass="AjxpPane">
<div id="display_toolbar" class="text_only" ajxpClass="ActionsToolbar" ajxpOptions='{"submenuClassName":"panelHeaderMenu","submenuPosition":"bottom right","submenuOffsetTop":12,"toolbarsList":["default","vertical_splitter-actions"],"skipBubbling":true, "skipCarousel":true,"submenuOffsetTop":5}'></div>
<div id="display_toolbar" class="text_only" ajxpClass="ActionsToolbar" ajxpOptions='{"submenuClassName":"panelHeaderMenu","submenuPosition":"bottom right","submenuOffsetTop":12,"toolbarsList":["content_pane-actions","vertical_splitter-actions"],"skipBubbling":true, "skipCarousel":true,"submenuOffsetTop":5}'></div>
<div style="float:left;position:fixed;" ajxpClass="AjxpPane" id="buttons_bar_cont" ajxpOptions='{"flexTo":"files_list_header", "flexToMargin":30, "resize_events":["switchDisplayMode-FilesList-content_pane"]}'>
<div id="buttons_bar" class="action_bar" ajxpClass="ActionsToolbar" ajxpOptions='{"toolbarsList":["navigation", "change_main"],"groupOtherToolbars":["more", "change", "remote"], "groupOtherLabel":"More","skipBubbling":true, "skipCarousel":true,"submenuOffsetTop":2}'></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/core.conf/class.AbstractConfDriver.php
Expand Up @@ -492,7 +492,7 @@ public function getExposedPreferences($userObject)
}
if ( ConfService::getCoreConf("SKIP_USER_HISTORY", "conf") === true ) {
$stringPrefs = array("display","lang","pending_folder", "thumb_size","plugins_preferences","upload_auto_send","upload_auto_close", "upload_existing","action_bar_style");
$jsonPrefs = array();
$jsonPrefs = array("columns_size", "columns_visibility", "gui_preferences");
$prefs["SKIP_USER_HISTORY"] = array("value" => "true", "type" => "string" );
}
foreach ($stringPrefs as $pref) {
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/gui.ajax/res/js/ajaxplorer.js

Large diffs are not rendered by default.

Expand Up @@ -471,14 +471,15 @@ Class.create("Ajaxplorer", {
if(ajxpOptionsString){
ajxpOptions = ajxpOptionsString.evalJSON();
}
/*
if(Class.objectImplements(oldObj, "IFocusable")){
this._focusables = this.unregisterFocusable(oldObj);
}
if(Class.objectImplements(oldObj, "IActionProvider")){
oldObj.getActions().each(function(act){
this.guiActions.unset(act.key);// = this.guiActions.without(act);
}.bind(this) );
}
}*/
if(oldObj.htmlElement) var anchor = oldObj.htmlElement;
oldObj.destroy();

Expand All @@ -491,6 +492,7 @@ Class.create("Ajaxplorer", {
if(compReg.length) this.initAjxpWidgets(compReg);
}
var obj = new ajxpClass($(ajxpId), ajxpOptions);

if(Class.objectImplements(obj, "IFocusable")){
obj.setFocusBehaviour();
this.registerFocusable(obj);
Expand All @@ -502,6 +504,7 @@ Class.create("Ajaxplorer", {
if(!this.guiActions) this.guiActions = new Hash();
this.guiActions.update(obj.getActions());
}

if($(ajxpId).up('[ajxpClass]') && $(ajxpId).up('[ajxpClass]').ajxpPaneObject && $(ajxpId).up('[ajxpClass]').ajxpPaneObject.scanChildrenPanes){
$(ajxpId).up('[ajxpClass]').ajxpPaneObject.scanChildrenPanes($(ajxpId).up('[ajxpClass]').ajxpPaneObject.htmlElement, true);
}
Expand Down Expand Up @@ -1334,6 +1337,9 @@ Class.create("Ajaxplorer", {
* @param object IAjxpFocusable
*/
focusOn : function(object){
if(!this._focusables || this._focusables.indexOf(object) == -1) {
return;
}
this._focusables.each(function(obj){
if(obj != object) obj.blur();
});
Expand Down
17 changes: 16 additions & 1 deletion core/src/plugins/gui.ajax/res/js/ajaxplorer/class.AjxpPane.js
Expand Up @@ -97,6 +97,9 @@ Class.create("AjxpPane", {
this.scrollbar = new Control.ScrollBar(this.htmlElement,this.scroller, {fixed_scroll_distance:50});
}

if(this.getUserPreference('rootElementClassPreference')){
this.htmlElement.addClassName(this.getUserPreference('rootElementClassPreference'));
}

},

Expand Down Expand Up @@ -263,6 +266,14 @@ Class.create("AjxpPane", {
document.stopObserving(pair.key, pair.value);
});
}
if(Class.objectImplements(this, 'IFocusable')){
ajaxplorer.unregisterFocusable(this);
}
if(Class.objectImplements(this, "IActionProvider")){
this.getActions().each(function(act){
ajaxplorer.guiActions.unset(act.key);
}.bind(this));
}
if(this.configObserver){
document.stopObserving("ajaxplorer:component_config_changed", this.configObserver);
}
Expand Down Expand Up @@ -344,6 +355,10 @@ Class.create("AjxpPane", {
}.bind(this));
},

toggleClassNameSavingPref:function(className){
this.htmlElement.toggleClassName(className);
this.setUserPreference('rootElementClassPreference', this.htmlElement.hasClassName(className)?className:'');
},

getUserPreference : function(prefName){
if(!ajaxplorer || !ajaxplorer.user || !this.htmlElement) return;
Expand All @@ -358,7 +373,7 @@ Class.create("AjxpPane", {

setUserPreference : function(prefName, prefValue){
if(!ajaxplorer || !ajaxplorer.user || !this.htmlElement) return;
if(ajaxplorer.user.getPreference("SKIP_USER_HISTORY") == "true") return;
//if(ajaxplorer.user.getPreference("SKIP_USER_HISTORY") == "true") return;
var guiPref = ajaxplorer.user.getPreference("gui_preferences", true);
if(!guiPref) guiPref = {};
var classkey = this.htmlElement.id+"_"+this.__className;
Expand Down
Expand Up @@ -129,10 +129,10 @@ Class.create("FetchedResultPane", FilesList, {
},

destroy:function($super){
$super();
if(this.options.containerDroppableAction){
Droppables.remove(this.htmlElement);
}
$super();
},

reloadDataModel: function(){
Expand Down Expand Up @@ -199,7 +199,7 @@ Class.create("FetchedResultPane", FilesList, {
},

getActions : function(){

return $H();
}

});
33 changes: 28 additions & 5 deletions core/src/plugins/gui.ajax/res/js/ajaxplorer/class.FilesList.js
Expand Up @@ -248,11 +248,30 @@ Class.create("FilesList", SelectableElements, {
/**
* Implementation of the IAjxpWidget methods
*/
destroy : function(){
destroy : function($super){
$super();
this._clearObservers();
if(window[this.htmlElement.id]){
try{delete window[this.htmlElement.id];}catch(e){}
}
if(this.boundSizeEvents){
this.boundSizeEvents.each(function(pair){
document.stopObserving(pair.key, pair.value);
});
}
if(this.resizeEvents){
this.resizeEvents.each(function(pair){
document.stopObserving(pair.key, pair.value);
});
}
if(Class.objectImplements(this, 'IFocusable')){
ajaxplorer.unregisterFocusable(this);
}
if(Class.objectImplements(this, "IActionProvider")){
this.getActions().each(function(act){
ajaxplorer.guiActions.unset(act.key);
}.bind(this));
}
if(this.slider) this.slider.destroy();
if(this.headerMenu) this.headerMenu.destroy();
this.htmlElement = null;
Expand Down Expand Up @@ -488,7 +507,7 @@ Class.create("FilesList", SelectableElements, {
selection:false,
dir:true,
actionBar:true,
actionBarGroup:'default',
actionBarGroup:oThis.htmlElement.id+'-actions',
contextMenu:false,
infoPanel:false
};
Expand Down Expand Up @@ -534,7 +553,7 @@ Class.create("FilesList", SelectableElements, {
selection:false,
dir:true,
actionBar:true,
actionBarGroup:'default',
actionBarGroup:oThis.htmlElement.id+'-actions',
contextMenu:false,
infoPanel:false
};
Expand Down Expand Up @@ -573,7 +592,7 @@ Class.create("FilesList", SelectableElements, {
selection:false,
dir:true,
actionBar:true,
actionBarGroup:'default',
actionBarGroup:oThis.htmlElement.id+'-actions',
contextMenu:false,
infoPanel:false
};
Expand Down Expand Up @@ -606,7 +625,11 @@ Class.create("FilesList", SelectableElements, {
// Create an action from these options!
var thumbSortAction = new Action(options3, context3, {}, {}, submenuItems3);

return $H({thumb_size:thumbsizeAction, thumb_sort:thumbSortAction, multi_display:multiAction});
var butts = $H();
butts.set(this.htmlElement.id+'-thumb_size', thumbsizeAction);
butts.set(this.htmlElement.id+'-thumb_sort', thumbSortAction);
butts.set(this.htmlElement.id+'-multi_display', multiAction);
return butts;
},

/**
Expand Down
Expand Up @@ -89,7 +89,6 @@ Class.create("FoldersTree", AjxpPane, {
}.bind(this));

this.rootNodeId = this.tree.id;
this.hasFocus;

var ctxChangedObs =function(event){
var path = event.memo.getPath();
Expand Down Expand Up @@ -125,7 +124,7 @@ Class.create("FoldersTree", AjxpPane, {

},

destroy : function(){
destroy : function($super){
this.registeredObservers.each(function (pair){
document.stopObserving(pair.key, pair.value);
});
Expand All @@ -134,6 +133,7 @@ Class.create("FoldersTree", AjxpPane, {
if(window[this.htmlElement.id]){
try{delete window[this.htmlElement.id];}catch(e){}
}
$super();
},

/**
Expand Down
9 changes: 8 additions & 1 deletion core/src/plugins/gui.ajax/res/js/lib/prototype/splitter.js
Expand Up @@ -202,6 +202,9 @@ Class.create("Splitter", AjxpPane, {
document.stopObserving("ajaxplorer:user_logged",this.userLoggedObs);
document.stopObserving("ajaxplorer:component_config_changed", this.compConfigObs);
this.splitbar.remove();
this.getActions().each(function(act){
ajaxplorer.guiActions.unset(act.key);
}.bind(this));
if(this.paneA.ajxpPaneObject) {
this.paneA.ajxpPaneObject.destroy();
this.paneA.remove();
Expand Down Expand Up @@ -438,7 +441,11 @@ Class.create("Splitter", AjxpPane, {
if(this.effectWorking) return;
if(!this.prefoldValue){
this.prefoldValue = 150;
//this.paneA.setStyle(this.makeStyleObject(this.options.adjust, target+'px'));
if(this.options.foldingButton == "A" && this.paneA._min && this.options.foldingMinSize !== undefined) {
this.prefoldValue = this.paneA._min;
} else if(this.options.foldingButton == "B" && this.paneB._min && this.options.foldingMinSize !== undefined) {
this.prefoldValue = this.paneB._min;
}
}
var target = this.options.foldingButton == "A" ? this.prefoldValue : (this.group._adjust - this.prefoldValue);
var presetAdjust = this.prefoldValue;
Expand Down
Expand Up @@ -554,6 +554,8 @@ SelectableElements = Class.create({
},

destroy: function () {
if(!this._htmlElement) return;

if (this._htmlElement.removeEventListener)
this._htmlElement.removeEventListener("click", this._onclick, false);
else if (this._htmlElement.detachEvent)
Expand Down
13 changes: 9 additions & 4 deletions core/src/plugins/gui.ajax/res/themes/orbit/css/ajaxplorer.css
Expand Up @@ -3074,6 +3074,11 @@ div.tabulatorContainer div#display_toolbar{
margin-right: 0;
}

#display_toolbar span.icon-caret-down.ajxp_icon_arrow {
margin-left: 3px;
color: #888;
}

#info_panel span.user_meta_change {
display: inline-block !important;
text-transform: lowercase;
Expand Down Expand Up @@ -5007,11 +5012,11 @@ div.menu a {
.menu.desktop.panelHeaderMenu li.menuTitle {
display: block;
font-size: 12px;
color: #333;
border-bottom: 1px solid #333;
padding: 7px;
color: #555555;
border-bottom: 1px solid #AAAAAA;
padding: 11px 7px;
text-align: left;
background-color: rgba(255,255,255,0.2);
background-color: rgba(227, 227, 227, 0.20);
}

.menu.desktop li.separator {
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/gui.ajax/res/themes/orbit/css/allz.css

Large diffs are not rendered by default.

0 comments on commit a38d25b

Please sign in to comment.