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

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix various refresh / focus problems, TAB navigation was broken.
  • Loading branch information
cdujeu committed Nov 15, 2013
1 parent 5397313 commit 198118e
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 38 deletions.
2 changes: 1 addition & 1 deletion core/src/plugins/gui.ajax/res/js/ajaxplorer.js

Large diffs are not rendered by default.

28 changes: 22 additions & 6 deletions core/src/plugins/gui.ajax/res/js/ajaxplorer/class.Ajaxplorer.js
Expand Up @@ -261,7 +261,7 @@ Class.create("Ajaxplorer", {
var obj = compRegistry[j];
if(Class.objectImplements(obj, "IFocusable")){
obj.setFocusBehaviour();
this._focusables.push(obj);
this.registerFocusable(obj);
}
if(Class.objectImplements(obj, "IContextMenuable")){
obj.setContextualMenu(this.contextMenu);
Expand Down Expand Up @@ -377,7 +377,7 @@ Class.create("Ajaxplorer", {
ajxpOptions = ajxpOptionsString.evalJSON();
}
if(Class.objectImplements(oldObj, "IFocusable")){
this._focusables = this._focusables.without(oldObj);
this._focusables = this.unregisterFocusable(oldObj);
}
if(Class.objectImplements(oldObj, "IActionProvider")){
oldObj.getActions().each(function(act){
Expand All @@ -398,7 +398,7 @@ Class.create("Ajaxplorer", {
var obj = new ajxpClass($(ajxpId), ajxpOptions);
if(Class.objectImplements(obj, "IFocusable")){
obj.setFocusBehaviour();
this._focusables.push(obj);
this.registerFocusable(obj);
}
if(Class.objectImplements(obj, "IContextMenuable")){
obj.setContextualMenu(this.contextMenu);
Expand Down Expand Up @@ -1211,8 +1211,24 @@ Class.create("Ajaxplorer", {
if(f.hasFocus) this._lastFocused = f;
f.blur();
}.bind(this) );
},

},

/**
* @param IAjxpFocusable widget
*/
registerFocusable: function(widget){
if(-1 == this._focusables.indexOf(widget) && widget.htmlElement){
this._focusables.push(widget);
}
},

/**
* @param IAjxpFocusable widget
*/
unregisterFocusable: function(widget){
this._focusables = this._focusables.without(widget);
},

/**
* Find last focused IAjxpFocusable and focus it!
*/
Expand All @@ -1232,7 +1248,7 @@ Class.create("Ajaxplorer", {
if(this.blockNavigation) return;
var objects = [];
$A(this._focusables).each(function(el){
if((!el.htmlElement || el.htmlElement.visible())){
if(el.htmlElement && el.htmlElement.visible()){
objects.push(el);
}
});
Expand Down
27 changes: 22 additions & 5 deletions core/src/plugins/gui.ajax/res/js/ajaxplorer/class.AjxpTabulator.js
Expand Up @@ -280,6 +280,9 @@ Class.create("AjxpTabulator", AjxpPane, {
if(!tabInfo.dontFocus){
this.switchTabulator(tabInfo.id);
window.setTimeout(this.resize.bind(this), 750);
}else{
var ajxpObject = this.getAndSetAjxpObject(tabInfo);
ajxpObject.showElement(false);
}
this.resize();
if(!skipStateSave) this.saveState();
Expand Down Expand Up @@ -361,8 +364,10 @@ Class.create("AjxpTabulator", AjxpPane, {
}
}.bind(this));
if(toShow){
if($(toShowElement)) $(toShowElement).show();
toShow.showElement(true);
if($(toShowElement) && !$(toShowElement).visible()){
if($(toShowElement)) $(toShowElement).show();
toShow.showElement(true);
}
var reFold = false;
if(this.htmlElement && this.htmlElement.up('div[ajxpClass="Splitter"]') && this.htmlElement.up('div[ajxpClass="Splitter"]').ajxpPaneObject){
var splitter = this.htmlElement.up('div[ajxpClass="Splitter"]').ajxpPaneObject;
Expand Down Expand Up @@ -436,13 +441,17 @@ Class.create("AjxpTabulator", AjxpPane, {
document.fire("ajaxplorer:resize-AjxpTabulator-" + this.htmlElement.id, this.htmlElement.getDimensions());
},

showElement: function(show){
showElement: function($super, show){
if(!this.htmlElement) return;
this.tabulatorData.each(function(tabInfo){
var ajxpObject = this.getAndSetAjxpObject(tabInfo);
ajxpObject.showElement(show);
}.bind(this));

if(show) {
this.htmlElement.show();
this.resize();
}
else {
} else {
this.htmlElement.hide();
}
},
Expand All @@ -461,6 +470,14 @@ Class.create("AjxpTabulator", AjxpPane, {
this.tabulatorData.each(function(tabInfo){
var ajxpObject = this.getAndSetAjxpObject(tabInfo);
tabInfo.headerElement.stopObserving("click");
if(Class.objectImplements(ajxpObject, "IFocusable")){
ajaxplorer.unregisterFocusable(ajxpObject);
}
if(Class.objectImplements(ajxpObject, "IActionProvider") && ajxpObject.getActions()){
ajxpObject.getActions().each(function(act){
this.guiActions.unset(act.key);// = this.guiActions.without(act);
}.bind(this) );
}
ajxpObject.destroy();
}.bind(this));
if(this.tb){
Expand Down
Expand Up @@ -91,6 +91,8 @@ Class.create("FetchedResultPane", FilesList, {
}.bind(this));
}

//ajaxplorer.registerFocusable(this);

},

reloadDataModel: function(){
Expand Down
10 changes: 5 additions & 5 deletions core/src/plugins/gui.ajax/res/js/ajaxplorer/class.FilesList.js
Expand Up @@ -1166,7 +1166,7 @@ Class.create("FilesList", SelectableElements, {
ajxpNode.observe("node_replaced", newItem.REPLACE_OBS);
ajxpNode.observe("node_removed", newItem.REMOVE_OBS);
var dm = (this._dataModel?this._dataModel:ajaxplorer.getContextHolder());
if(dm.getSelectedNodes() && dm.getSelectedNodes().length)
if(dm.getSelectedNodes() && dm.getSelectedNodes().length && dm.getSelectionSource() == this)
{
var selectedNodes = dm.getSelectedNodes();
this._selectedItems = [];
Expand All @@ -1177,7 +1177,7 @@ Class.create("FilesList", SelectableElements, {
this.selectFile(selectedNodes[f].getPath(), true);
}
}
this.hasFocus = true;
if(dm.getSelectionSource() == this) this.hasFocus = true;
}
//}catch(e){

Expand Down Expand Up @@ -1345,7 +1345,7 @@ Class.create("FilesList", SelectableElements, {
this._sortableTable.updateHeaderArrows();
}
var dm = (this._dataModel?this._dataModel:ajaxplorer.getContextHolder());
if(dm.getSelectedNodes() && dm.getSelectedNodes().length)
if(dm.getSelectedNodes() && dm.getSelectedNodes().length && dm.getSelectionSource() == this)
{
var selectedNodes = dm.getSelectedNodes();
for(var f=0;f<selectedNodes.length; f++){
Expand All @@ -1355,7 +1355,7 @@ Class.create("FilesList", SelectableElements, {
this.selectFile(selectedNodes[f].getPath(), true);
}
}
this.hasFocus = true;
if(dm.getSelectionSource() == this) this.hasFocus = true;
}
if(this.hasFocus){
window.setTimeout(function(){ajaxplorer.focusOn(this);}.bind(this),200);
Expand Down Expand Up @@ -2130,7 +2130,7 @@ Class.create("FilesList", SelectableElements, {
*/
fireChange: function()
{
if(this._fireChange){
if(this._fireChange && this.hasFocus){
if(this._dataModel){
this._dataModel.setSelectedNodes(this.getSelectedNodes());
}else{
Expand Down
26 changes: 17 additions & 9 deletions core/src/plugins/gui.ajax/res/js/ajaxplorer/class.SearchEngine.js
Expand Up @@ -325,6 +325,7 @@ Class.create("SearchEngine", AjxpPane, {
fitParent : this.options.toggleResultsVisibility,
detailThumbSize:22
});
ajaxplorer.registerFocusable(this._fileList);


this.htmlElement.select('a', 'div[id="search_results"]').each(function(element){
Expand All @@ -347,9 +348,7 @@ Class.create("SearchEngine", AjxpPane, {
this._inputBox.select();
if(this.hasResults && this._ajxpOptions.toggleResultsVisibility && !$(this._ajxpOptions.toggleResultsVisibility).visible()){
this.updateSearchResultPosition($(this._ajxpOptions.toggleResultsVisibility));
$(this._ajxpOptions.toggleResultsVisibility).setStyle({
display:'block'
});
this.showToggleResult(true);
}
return false;
}.bind(this));
Expand All @@ -375,14 +374,24 @@ Class.create("SearchEngine", AjxpPane, {
this._inputBox.setValue("");
this.clearResults();
if($(this.options.toggleResultsVisibility)){
$(this._ajxpOptions.toggleResultsVisibility).setStyle({display:'none'});
this.showToggleResult(false);
}
}.bind(this);

document.observe("ajaxplorer:repository_list_refreshed", this.refreshObserver );

this.resize();
},

showToggleResult: function(show){
if(show){
$(this._ajxpOptions.toggleResultsVisibility).setStyle({display:'block'});
}else{
$(this._ajxpOptions.toggleResultsVisibility).setStyle({display:'none'});
}
this._fileList.showElement(show);
},

/**
* Show/Hide the widget
* @param show Boolean
Expand Down Expand Up @@ -423,6 +432,7 @@ Class.create("SearchEngine", AjxpPane, {

destroy : function(){
if(this._fileList){
ajaxplorer.unregisterFocusable(this._fileList);
this._fileList.destroy();
this._fileList = null;
}
Expand Down Expand Up @@ -568,16 +578,14 @@ Class.create("SearchEngine", AjxpPane, {
}
if($(this._ajxpOptions.toggleResultsVisibility).down("span.close_results")){
$(this._ajxpOptions.toggleResultsVisibility).down("span.close_results").observe("click", function(){
$(this._ajxpOptions.toggleResultsVisibility).setStyle({display:"none"});
this.showToggleResult(false);
}.bind(this));
}

if(!$(this._ajxpOptions.toggleResultsVisibility).visible()){
this.updateSearchResultPosition($(this._ajxpOptions.toggleResultsVisibility));
$(this._ajxpOptions.toggleResultsVisibility).setStyle({
display:"block",
position: "absolute"
});
$(this._ajxpOptions.toggleResultsVisibility).setStyle({position: "absolute"});
this.showToggleResult(true);
}
this.resize();
}
Expand Down
26 changes: 15 additions & 11 deletions core/src/plugins/gui.ajax/res/js/lib/prototype/proto.menu.js
Expand Up @@ -62,6 +62,11 @@ Proto.Menu = Class.create({
}
this.options.fade = this.options.fade && !Object.isUndefined(Effect);
this.container = new Element('div', {className: this.options.className, style: 'display:none'});

this.observerFunctionBound = this.observerFunction.bind(this);
this.mouseoverFunctionBound = this.mouseoverFunction.bind(this);
this.mouseoutFunctionBound = this.mouseoutFunction.bind(this);

if(this.options.mouseClick == 'right'){
$(document.body).observe('contextmenu', function(e){Event.stop(e);});
$(document.body).insert(this.container.observe('contextmenu', Event.stop));
Expand All @@ -70,8 +75,8 @@ Proto.Menu = Class.create({
}
if (this.ie) { $(document.body).insert(this.shim); }
if(this.eventToObserve == 'mouseover'){
this.container.observe("mouseover", this.mouseoverFunction.bind(this) );
this.container.observe("mouseout",this.mouseoutFunction.bind(this) );
this.container.observe("mouseover", this.mouseoverFunctionBound );
this.container.observe("mouseout",this.mouseoutFunctionBound );
}

document.observe('click', function(e) {
Expand All @@ -97,7 +102,6 @@ Proto.Menu = Class.create({
},

observerFunction:function(e){
//if (this.options.mouseClick == 'right' && Prototype.Browser.Opera && !e.ctrlKey) return;
if (this.options.mouseClick == 'left' && Event.findElement(e, '.protomenu_selector') && Event.findElement(e, '.protomenu_selector').hasClassName('disabled')){
return;
}
Expand Down Expand Up @@ -126,27 +130,27 @@ Proto.Menu = Class.create({
$$(selectorOrObject).invoke('removeClassName', 'protomenu_selector');
$$(selectorOrObject).invoke('stopObserving',
this.eventToObserve,
this.observerFunction.bind(this));
this.observerFunctionBound);
}else{
$(selectorOrObject).removeClassName('protomenu_selector');
$(selectorOrObject).stopObserving(this.eventToObserve, this.observerFunction.bind(this));
$(selectorOrObject).stopObserving(this.eventToObserve, this.observerFunctionBound);
}
},

addElements:function(selectorOrObject){
if(typeof(selectorOrObject) == "string"){
$$(selectorOrObject).invoke('observe', this.eventToObserve, this.observerFunction.bind(this));
$$(selectorOrObject).invoke('observe', this.eventToObserve, this.observerFunctionBound);
$$(selectorOrObject).invoke('addClassName', 'protomenu_selector');
if(this.eventToObserve == "mouseover"){
$$(selectorOrObject).invoke('observe', 'mouseover', this.mouseoverFunction.bind(this));
$$(selectorOrObject).invoke('observe', 'mouseout', this.mouseoutFunction.bind(this));
$$(selectorOrObject).invoke('observe', 'mouseover', this.mouseoverFunctionBound);
$$(selectorOrObject).invoke('observe', 'mouseout', this.mouseoutFunctionBound);
}
}else{
$(selectorOrObject).observe(this.eventToObserve, this.observerFunction.bind(this));
$(selectorOrObject).observe(this.eventToObserve, this.observerFunctionBound);
$(selectorOrObject).addClassName('protomenu_selector');
if(this.eventToObserve == "mouseover"){
$(selectorOrObject).observe("mouseover", this.mouseoverFunction.bind(this) );
$(selectorOrObject).observe("mouseout", this.mouseoutFunction.bind(this));
$(selectorOrObject).observe("mouseover", this.mouseoverFunctionBound);
$(selectorOrObject).observe("mouseout", this.mouseoutFunctionBound);
}
}
},
Expand Down
Expand Up @@ -292,7 +292,7 @@ SelectableElements = Class.create({
focus: function()
{
this.hasFocus = true;
//this.selectFirst();
if(!this._selectedItems.length) this.selectFirst();
if(this.options && this.options.invisibleSelection) return;
for(var i=0; i < this._selectedItems.length;i++)
{
Expand Down Expand Up @@ -358,6 +358,7 @@ SelectableElements = Class.create({

dblClick: function (e) {
//alert('Dbl Click!');
this.hasFocus = true;
this.fireDblClick();
},

Expand All @@ -380,6 +381,7 @@ SelectableElements = Class.create({
},

click: function (e) {
this.hasFocus = true;
if(e.detail && e.detail > 1)
{
if(this.ie10detailFilter(e)){
Expand Down

0 comments on commit 198118e

Please sign in to comment.