mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(config) add buffer
This commit is contained in:
parent
067a07c1ed
commit
53ff18b38b
6 changed files with 67 additions and 19 deletions
|
|
@ -8,12 +8,20 @@ var Util, DOM;
|
|||
function BufferProto() {
|
||||
var Storage = DOM.Storage,
|
||||
Dialog = DOM.Dialog,
|
||||
Files = DOM.Files,
|
||||
Info = DOM.CurrentInfo,
|
||||
|
||||
CLASS = 'cut-file',
|
||||
|
||||
COPY = 'copy',
|
||||
CUT = 'cut';
|
||||
CUT = 'cut',
|
||||
|
||||
Buffer = {
|
||||
cut : callIfEnabled.bind(null, cut),
|
||||
copy : callIfEnabled.bind(null, copy),
|
||||
clear : callIfEnabled.bind(null, clear),
|
||||
paste : callIfEnabled.bind(null, paste)
|
||||
};
|
||||
|
||||
function getNames() {
|
||||
var name = Info.name,
|
||||
|
|
@ -23,7 +31,7 @@ var Util, DOM;
|
|||
return n ? names : [name];
|
||||
}
|
||||
|
||||
function cut() {
|
||||
function addCutClass() {
|
||||
var files = DOM.getSelectedFiles(),
|
||||
n = files.length;
|
||||
|
||||
|
|
@ -35,7 +43,7 @@ var Util, DOM;
|
|||
});
|
||||
}
|
||||
|
||||
function clear() {
|
||||
function rmCutClass() {
|
||||
var files = DOM.getSelectedFiles(),
|
||||
n = files.length;
|
||||
|
||||
|
|
@ -47,7 +55,23 @@ var Util, DOM;
|
|||
});
|
||||
}
|
||||
|
||||
this.copy = function() {
|
||||
function isEnabled(callback) {
|
||||
Files.get('config', function(error, config) {
|
||||
if (error)
|
||||
Dialog.alert(error);
|
||||
else
|
||||
callback(config.buffer);
|
||||
});
|
||||
}
|
||||
|
||||
function callIfEnabled(callback) {
|
||||
isEnabled(function(is) {
|
||||
if (is)
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
function copy() {
|
||||
var Storage = DOM.Storage,
|
||||
names = getNames(),
|
||||
from = Info.dirPath;
|
||||
|
|
@ -57,30 +81,30 @@ var Util, DOM;
|
|||
from : from,
|
||||
names: names
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
this.cut = function() {
|
||||
function cut() {
|
||||
var Storage = DOM.Storage,
|
||||
names = getNames(),
|
||||
from = Info.dirPath;
|
||||
|
||||
cut();
|
||||
addCutClass();
|
||||
|
||||
Storage.remove(COPY)
|
||||
.set(CUT, {
|
||||
from : from,
|
||||
names: names
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
this.clear = function() {
|
||||
function clear() {
|
||||
Storage.remove(COPY)
|
||||
.remove(CUT);
|
||||
|
||||
clear();
|
||||
};
|
||||
rmCutClass();
|
||||
}
|
||||
|
||||
this.paste = function() {
|
||||
function paste() {
|
||||
var copy = Storage.get.bind(Storage, COPY),
|
||||
cut = Storage.get.bind(Storage, CUT);
|
||||
|
||||
|
|
@ -115,6 +139,8 @@ var Util, DOM;
|
|||
|
||||
clear();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
return Buffer;
|
||||
}
|
||||
})(Util, DOM);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue