mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(config) add buffer
This commit is contained in:
parent
067a07c1ed
commit
53ff18b38b
6 changed files with 67 additions and 19 deletions
1
HELP.md
1
HELP.md
|
|
@ -234,6 +234,7 @@ All main configuration could be done via `json/config.json`.
|
|||
"zip" : true, /* zip text before send / unzip before save */
|
||||
"notifications" : false, /* show notifications when tab is not active*/
|
||||
"localStorage" : true, /* cache directory data */
|
||||
"buffer" : true, /* buffer for copying files */
|
||||
"minify" : true, /* minification of js,css,html and img */
|
||||
"online" : true, /* load js files from cdn or local path */
|
||||
"cache" : true, /* add cache-control */
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
<li><span><input type="checkbox" id="zip" {{ zip }} ></input></span><label for="zip"> Zip</label></li>
|
||||
<li><span><input type="checkbox" id="notifications" {{ notifications }} ></input></span><label for="notifications"> Notifications</label></li>
|
||||
<li><span><input type="checkbox" id="localStorage" {{ localStorage }} ></input></span><label for="localStorage"> Local Storage</label></li>
|
||||
<li><span><input type="checkbox" id="buffer" {{ buffer }} ></input></span> <label for="buffer">Buffer</label></li>
|
||||
<li><span><input type="checkbox" id="minify" {{ minify }} ></input></span><label for="minify"> Minify</label></li>
|
||||
<li><span><input type="checkbox" id="online" {{ online }} ></input></span><label for="online"> Online</label></li>
|
||||
<li><span><input type="checkbox" id="cache" {{ cache }} ></input></span><label for="cache"> Cache</label></li>
|
||||
|
|
|
|||
|
|
@ -52,8 +52,8 @@
|
|||
client + 'load',
|
||||
client + 'notify',
|
||||
client + 'storage',
|
||||
client + 'buffer',
|
||||
client + 'files',
|
||||
client + 'buffer',
|
||||
'client',
|
||||
client + 'listeners',
|
||||
client + 'key'
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
"zip" : true,
|
||||
"notifications": false,
|
||||
"localStorage": true,
|
||||
"buffer": true,
|
||||
"minify": true,
|
||||
"online": true,
|
||||
"cache": true,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -130,6 +130,8 @@ var CloudCmd, Util, DOM;
|
|||
onLocalStorageChange(data);
|
||||
else if (el.id === 'diff')
|
||||
onDiffChange(data);
|
||||
else if (el.id === 'buffer')
|
||||
onBufferChange(data);
|
||||
|
||||
break;
|
||||
case 'number':
|
||||
|
|
@ -155,15 +157,22 @@ var CloudCmd, Util, DOM;
|
|||
}
|
||||
|
||||
function onLocalStorageChange(checked) {
|
||||
var element = DOM.getById('diff', Element),
|
||||
msg = 'Diff do not work without localStorage';
|
||||
var elDiff = DOM.getById('diff', Element),
|
||||
elBuffer = DOM.getById('buffer', Element),
|
||||
msg = 'Diff and Buffer do not work without localStorage';
|
||||
|
||||
if (!checked && element.checked) {
|
||||
if (!checked && (elDiff.checked || elBuffer.checked)) {
|
||||
alert(msg);
|
||||
|
||||
element.checked = false;
|
||||
elDiff.checked =
|
||||
elBuffer.checked = false;
|
||||
|
||||
onChange({
|
||||
target: element
|
||||
target: elDiff
|
||||
});
|
||||
|
||||
onChange({
|
||||
target: elBuffer
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -178,6 +187,16 @@ var CloudCmd, Util, DOM;
|
|||
return element.checked;
|
||||
}
|
||||
|
||||
function onBufferChange(checked) {
|
||||
var element = DOM.getById('localStorage', Element);
|
||||
|
||||
if (!element.checked && checked) {
|
||||
onLocalStorageChange(element.checked);
|
||||
}
|
||||
|
||||
return element.checked;
|
||||
}
|
||||
|
||||
function onKey(event) {
|
||||
var keyCode = event.keyCode,
|
||||
ESC = Key.ESC;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue