mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-19 09:24:51 +00:00
feature(listeners) change panel to clicked panel
This commit is contained in:
parent
ae5a50d58f
commit
5f9306d8c2
3 changed files with 54 additions and 27 deletions
|
|
@ -592,7 +592,11 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
CURRENT_FILE = 'current-file',
|
||||
SELECTED_FILE = 'selected-file',
|
||||
SelectType = '*.*',
|
||||
Title;
|
||||
Title,
|
||||
TabPanel = {
|
||||
'js-left' : null,
|
||||
'js-right' : null
|
||||
};
|
||||
|
||||
/**
|
||||
* private function thet unset currentfile
|
||||
|
|
@ -1837,6 +1841,32 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
});
|
||||
};
|
||||
|
||||
this.changePanel = function() {
|
||||
var id, files,
|
||||
Info = CurrentInfo,
|
||||
current = Info.element,
|
||||
panel = Info.panel,
|
||||
filesPassive = Info.filesPassive;
|
||||
|
||||
id = panel.id;
|
||||
TabPanel[id] = current;
|
||||
|
||||
panel = Info.panelPassive;
|
||||
id = panel.id;
|
||||
|
||||
current = TabPanel[id];
|
||||
|
||||
if (current)
|
||||
files = current.parentElement;
|
||||
|
||||
if (!files || !files.parentElement)
|
||||
current = filesPassive[0];
|
||||
|
||||
DOM.setCurrentFile(current);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
this.CurrentInfo = CurrentInfo,
|
||||
|
||||
this.updateCurrentInfo = function(currentFile) {
|
||||
|
|
|
|||
|
|
@ -62,11 +62,7 @@ var CloudCmd, Util, DOM;
|
|||
|
||||
function KeyProto() {
|
||||
var Key = this,
|
||||
Binded,
|
||||
TabPanel = {
|
||||
'js-left' : null,
|
||||
'js-right' : null
|
||||
};
|
||||
Binded;
|
||||
|
||||
this.isBind = function() {return Binded;};
|
||||
|
||||
|
|
@ -160,11 +156,10 @@ var CloudCmd, Util, DOM;
|
|||
}
|
||||
|
||||
function switchKey(event) {
|
||||
var i, id, obj, files, name, isSelected, isDir,
|
||||
var i, obj, name, isSelected, isDir,
|
||||
current = Info.element,
|
||||
panel = Info.panel,
|
||||
path = Info.path,
|
||||
filesPassive = Info.filesPassive,
|
||||
prev = current.previousSibling,
|
||||
next = current.nextSibling,
|
||||
lKeyCode = event.keyCode,
|
||||
|
|
@ -174,23 +169,8 @@ var CloudCmd, Util, DOM;
|
|||
|
||||
switch (lKeyCode) {
|
||||
case Key.TAB:
|
||||
id = panel.id;
|
||||
TabPanel[id] = current;
|
||||
|
||||
panel = Info.panelPassive;
|
||||
id = panel.id;
|
||||
|
||||
current = TabPanel[id];
|
||||
|
||||
if (current)
|
||||
files = current.parentElement;
|
||||
|
||||
if (!files || !files.parentElement)
|
||||
current = filesPassive[0];
|
||||
|
||||
DOM.setCurrentFile(current);
|
||||
|
||||
DOM.preventDefault(event);
|
||||
DOM.changePanel()
|
||||
.preventDefault(event);
|
||||
break;
|
||||
|
||||
case Key.INSERT:
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ var Util, DOM, CloudCmd;
|
|||
'mousedown' : Util.bind(ifExecNotUL, setCurrentFileByEvent),
|
||||
'contextmenu' : Util.bind(ifExecNotUL, onContextMenu),
|
||||
'dragstart' : Util.bind(ifExecNotUL, onDragStart),
|
||||
'click' : Util.bind(ifExecNotUL, onClick),
|
||||
'click' : onClick,
|
||||
'dblclick' : Util.bind(ifExecNotUL, onDblClick),
|
||||
'touchstart' : Util.bind(ifExecNotUL, onTouch)
|
||||
};
|
||||
|
|
@ -180,10 +180,16 @@ var Util, DOM, CloudCmd;
|
|||
}
|
||||
|
||||
function onClick(event) {
|
||||
var ctrl = event.ctrlKey;
|
||||
var ctrl = event.ctrlKey,
|
||||
panel = DOM.getPanel(),
|
||||
files = DOM.getByDataName('js-files', panel),
|
||||
ul = getULElement(event.target);
|
||||
|
||||
if (!ctrl)
|
||||
DOM.preventDefault(event);
|
||||
|
||||
if (ul !== files)
|
||||
DOM.changePanel();
|
||||
}
|
||||
|
||||
function onDblClick(event) {
|
||||
|
|
@ -263,6 +269,17 @@ var Util, DOM, CloudCmd;
|
|||
return element;
|
||||
}
|
||||
|
||||
function getULElement(element) {
|
||||
var tag = element.tagName;
|
||||
|
||||
if (tag !== 'UL')
|
||||
do {
|
||||
element = element.parentElement;
|
||||
tag = element.tagName;
|
||||
} while(tag !== 'UL');
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
function setCurrentFileByEvent(event) {
|
||||
var element = getLIElement(event.target);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue