mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
added confirmation before (not real) deleting file
This commit is contained in:
parent
08065167c8
commit
9c664055be
4 changed files with 40 additions and 15 deletions
|
|
@ -158,6 +158,8 @@ Added dropbox_id option.
|
|||
|
||||
* Fixed bug with menu load, when dir other then root.
|
||||
|
||||
* Added confirmation before (not real) deleting file.
|
||||
|
||||
|
||||
2012.10.01, Version 0.1.7
|
||||
|
||||
|
|
|
|||
|
|
@ -265,6 +265,19 @@ var CloudCommander, Util, DOM, CloudFunc;
|
|||
|
||||
DOM.Cache = new DOM.Cache();
|
||||
|
||||
/**
|
||||
* delete currentfile, prompt before it
|
||||
*
|
||||
* @pCurrentFile
|
||||
*/
|
||||
DOM.delete = function(pCurrentFile){
|
||||
var lMsg = 'Are you sure thet you wont delete ',
|
||||
lName = DOM.getCurrentName(pCurrentFile),
|
||||
lRet = confirm(lMsg + lName + '?');
|
||||
|
||||
if(lRet)
|
||||
DOM.removeCurrent(pCurrentFile);
|
||||
};
|
||||
|
||||
/**
|
||||
* Function gets id by src
|
||||
|
|
@ -719,9 +732,11 @@ var CloudCommander, Util, DOM, CloudFunc;
|
|||
|
||||
/**
|
||||
* unified way to get current file
|
||||
*
|
||||
* @pCurrentFile
|
||||
*/
|
||||
DOM.getCurrentFile = function(){
|
||||
var lCurrent = DOM.getByClass(getCurrentFile())[0];
|
||||
DOM.getCurrentFile = function(pCurrentFile){
|
||||
var lCurrent = DOM.getByClass( pCurrentFile || getCurrentFile() )[0];
|
||||
if(!lCurrent){
|
||||
DOM.addCloudStatus({
|
||||
code : -1,
|
||||
|
|
@ -998,22 +1013,20 @@ var CloudCommander, Util, DOM, CloudFunc;
|
|||
* @pCurrent
|
||||
*/
|
||||
DOM.removeCurrent = function(pCurrent){
|
||||
var lParent = pCurrent.parentElement;
|
||||
var lCurrent = pCurrent || DOM.getCurrentFile(),
|
||||
lParent = lCurrent.parentElement,
|
||||
lName = DOM.getCurrentName(lCurrent);
|
||||
|
||||
if(!pCurrent)
|
||||
pCurrent = DOM.getCurrentFile();
|
||||
var lName = DOM.getCurrentName(pCurrent);
|
||||
|
||||
if(pCurrent && lParent){
|
||||
if(lCurrent && lParent){
|
||||
if(lName !== '..'){
|
||||
var lNext = pCurrent.nextSibling;
|
||||
var lPrevious = pCurrent.previousSibling;
|
||||
var lNext = lCurrent.nextSibling;
|
||||
var lPrevious = lCurrent.previousSibling;
|
||||
if(lNext)
|
||||
DOM.setCurrentFile(lNext);
|
||||
else if(lPrevious)
|
||||
DOM.setCurrentFile(lPrevious);
|
||||
|
||||
lParent.removeChild(pCurrent);
|
||||
lParent.removeChild(lCurrent);
|
||||
}
|
||||
else
|
||||
DOM.addCloudStatus({
|
||||
|
|
@ -1027,7 +1040,7 @@ var CloudCommander, Util, DOM, CloudFunc;
|
|||
msg : 'Current file (or parent of current) could not be empty'
|
||||
});
|
||||
|
||||
return pCurrent;
|
||||
return lCurrent;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ var CloudCommander, Util, DOM;
|
|||
event.preventDefault();//запрет на дальнейшее действие
|
||||
}
|
||||
else if(lKeyCode === KEY.Delete)
|
||||
DOM.removeCurrent(lCurrentFile);
|
||||
DOM.delete(lCurrentFile);
|
||||
|
||||
/* if f3 or shift+f3 or alt+f3 pressed */
|
||||
else if(lKeyCode === KEY.F3){
|
||||
|
|
|
|||
|
|
@ -57,11 +57,21 @@ var CloudCommander, Util, DOM, CloudFunc, $;
|
|||
showEditor();
|
||||
}},
|
||||
|
||||
'delete': {name: 'Delete',
|
||||
delete: {name: 'Delete',
|
||||
callback: function(key, opt){
|
||||
console.log('delete menu item choosen');
|
||||
DOM.delete();
|
||||
}},
|
||||
|
||||
upload: {
|
||||
name: "Upload",
|
||||
items: {
|
||||
'upload_to_gist': {name: 'to Gist',
|
||||
callback: function(key, opt){
|
||||
console.log('Upload To Gist');
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
download: {name: 'Download',callback: function(key, opt){
|
||||
DOM.Images.showLoad();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue