mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 00:47:01 +00:00
feature(util) rm slice
This commit is contained in:
parent
c26032f088
commit
2021c85989
9 changed files with 21 additions and 62 deletions
|
|
@ -165,7 +165,7 @@ var Util, DOM, CloudFunc, join;
|
|||
|
||||
if (path) {
|
||||
module = query[0];
|
||||
module = Util.slice(module, 1).join('');
|
||||
module = module.slice(1).join('');
|
||||
module = getStrBigFirst(module);
|
||||
|
||||
file = query[1];
|
||||
|
|
|
|||
|
|
@ -42,10 +42,9 @@ var Util, DOM;
|
|||
}
|
||||
|
||||
function rmCutClass() {
|
||||
var files = DOM.getByClassAll(CLASS),
|
||||
array = Util.slice(files);
|
||||
var files = DOM.getByClassAll(CLASS);
|
||||
|
||||
array.forEach(function(element) {
|
||||
[].forEach.call(files, function(element) {
|
||||
DOM.removeClass(element, CLASS);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -734,7 +734,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
this.getSelectedFiles = function() {
|
||||
var panel = DOM.getPanel(),
|
||||
selected = this.getByClassAll(SELECTED_FILE, panel),
|
||||
ret = Util.slice(selected);
|
||||
ret = [].slice.call(selected);
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -33,11 +33,11 @@ var Util, DOM, jQuery;
|
|||
|
||||
if (!Function.bind)
|
||||
Function.prototype.bind = function (context) {
|
||||
var aArgs = Util.slice(arguments, 1),
|
||||
var aArgs = [].slice.call(arguments, 1),
|
||||
fToBind = this,
|
||||
NOP = function () {},
|
||||
fBound = function () {
|
||||
var arr = Util.slice(arguments),
|
||||
var arr = [].slice.call(arguments),
|
||||
args = aArgs.concat(arr);
|
||||
|
||||
return fToBind.apply(context, args);
|
||||
|
|
|
|||
|
|
@ -292,19 +292,19 @@ var CloudCmd, Util, DOM, CloudFunc, $;
|
|||
|
||||
function onOverLayClick(overlay, event) {
|
||||
var isCurrent, isFiles, isFilesPassive,
|
||||
files = Util.slice(Info.files),
|
||||
filesPassive= Util.slice(Info.filesPassive),
|
||||
position = CloudCmd.MousePosition,
|
||||
element = event.target,
|
||||
isOverlay = element === overlay;
|
||||
files = Info.files,
|
||||
filesPassive = Info.filesPassive,
|
||||
position = CloudCmd.MousePosition,
|
||||
element = event.target,
|
||||
isOverlay = element === overlay;
|
||||
|
||||
if (isOverlay) {
|
||||
hideOverlay();
|
||||
element = DOM.getCurrentByPosition(position);
|
||||
|
||||
if (element) {
|
||||
isFiles = ~files.indexOf(element);
|
||||
isFilesPassive = ~filesPassive.indexOf(element);
|
||||
isFiles = ~[].indexOf.call(files, element);
|
||||
isFilesPassive = ~[].indexOf.call(filesPassive, element);
|
||||
|
||||
if (isFiles || isFilesPassive) {
|
||||
isCurrent = DOM.isCurrentFile(element);
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@
|
|||
files.to = mellow.convertPath(files.to);
|
||||
|
||||
if (files.names)
|
||||
data = Util.slice(files.names);
|
||||
data = files.names.slice();
|
||||
else
|
||||
data = files;
|
||||
|
||||
|
|
@ -226,7 +226,7 @@
|
|||
files.from = mellow.convertPath(files.from);
|
||||
files.to = mellow.convertPath(files.to);
|
||||
|
||||
data = Util.slice(files.names);
|
||||
data = files.names.slice();
|
||||
copyFiles(files, flop.copy, function(error) {
|
||||
var msg = formatMsg('copy', data);
|
||||
|
||||
|
|
|
|||
22
lib/util.js
22
lib/util.js
|
|
@ -252,7 +252,7 @@
|
|||
* @param pArg
|
||||
*/
|
||||
this.log = function() {
|
||||
var args = this.slice(arguments),
|
||||
var args = [].slice.call(arguments),
|
||||
console = Scope.console,
|
||||
lDate = '[' + Util.getDate() + '] ';
|
||||
|
||||
|
|
@ -430,20 +430,6 @@
|
|||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* function makes new array based on first
|
||||
*
|
||||
* @param array
|
||||
*/
|
||||
this.slice = function(array, begin, end) {
|
||||
var ret = [];
|
||||
|
||||
if (array)
|
||||
ret = [].slice.call(array, begin, end);
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
this.exec = new ExecProto();
|
||||
|
||||
function ExecProto() {
|
||||
|
|
@ -457,7 +443,7 @@
|
|||
var exec = function(callback) {
|
||||
var ret,
|
||||
isFunc = Util.type.function(callback),
|
||||
args = Util.slice(arguments, 1);
|
||||
args = [].slice.call(arguments, 1);
|
||||
|
||||
if (isFunc)
|
||||
ret = callback.apply(null, args);
|
||||
|
|
@ -485,7 +471,7 @@
|
|||
*/
|
||||
exec.ret = function() {
|
||||
var result,
|
||||
args = Util.slice(arguments);
|
||||
args = [].slice.call(arguments);
|
||||
|
||||
args.unshift(exec);
|
||||
result = exec.with.apply(null, args);
|
||||
|
|
@ -564,7 +550,7 @@
|
|||
}
|
||||
|
||||
function checkFunc(num, data, all) {
|
||||
var args = Util.slice(data, 1),
|
||||
var args = [].slice.call(data, 1),
|
||||
isLast = false,
|
||||
error = data[0],
|
||||
length = args.length;
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@
|
|||
|
||||
Expect += expect;
|
||||
|
||||
isNotOk = Util.slice(Expect).some(function(item, number) {
|
||||
isNotOk = Expect.split('').some(function(item, number) {
|
||||
var ret = result[number] !== item;
|
||||
|
||||
if (ret)
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@
|
|||
it('should return function that try to call callback', function() {
|
||||
var STR = 'hello world',
|
||||
func1 = function() {
|
||||
var args = Util.slice(arguments);
|
||||
var args = [].slice.call(arguments);
|
||||
|
||||
return args.join(' ');
|
||||
},
|
||||
|
|
@ -127,32 +127,6 @@
|
|||
});
|
||||
|
||||
});
|
||||
|
||||
describe('slice', function() {
|
||||
it('should return copy of given array', function() {
|
||||
var arr1 = [1, 2, 3],
|
||||
length = arr1.length,
|
||||
arr2 = Util.slice(arr1);
|
||||
|
||||
arr2.should.be.instanceof(Array)
|
||||
.and.have.lengthOf(length);
|
||||
});
|
||||
|
||||
it('should return empty array on given undefined', function() {
|
||||
var arr = Util.slice(),
|
||||
LENGTH = 0;
|
||||
|
||||
arr.should.be.instanceof(Array)
|
||||
.and.have.lengthOf(LENGTH);
|
||||
});
|
||||
|
||||
it('should return sliced array', function() {
|
||||
var arr = Util.slice([1,2,3], 1);
|
||||
|
||||
arr.should.eql([2, 3]);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue