mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
feature(dom) getByClass -> getByClassAll
This commit is contained in:
parent
4f7012d53c
commit
b3c8cc8b33
4 changed files with 39 additions and 32 deletions
|
|
@ -457,7 +457,7 @@ var Util, DOM, CloudFunc;
|
|||
function getJSONfromFileTable() {
|
||||
var current, name, size, uid, mode, ret,
|
||||
left = DOM.getById('js-left'),
|
||||
path = DOM.getByClass('path')[0].textContent,
|
||||
path = DOM.getByClass('path').textContent,
|
||||
|
||||
fileTable = {
|
||||
path : path,
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
lCurrent = DOM.getRefreshButton().parentElement;
|
||||
else {
|
||||
lCurrent = DOM.getCurrentFile();
|
||||
lCurrent = DOM.getByClass('name', lCurrent)[0];
|
||||
lCurrent = DOM.getByClass('name', lCurrent);
|
||||
}
|
||||
|
||||
/* show loading icon if it not showed */
|
||||
|
|
@ -304,11 +304,23 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
};
|
||||
|
||||
/**
|
||||
* Function search element by class name
|
||||
* Function search first element by class name
|
||||
* @param pClass - className
|
||||
* @param pElement - element
|
||||
*/
|
||||
this.getByClass = function(pClass, pElement) {
|
||||
var element = pElement || document,
|
||||
ret = this.getByClassAll(pClass, element)[0];
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
/**
|
||||
* Function search element by class name
|
||||
* @param pClass - className
|
||||
* @param pElement - element
|
||||
*/
|
||||
this.getByClassAll = function(pClass, pElement) {
|
||||
return (pElement || document).getElementsByClassName(pClass);
|
||||
};
|
||||
|
||||
|
|
@ -837,7 +849,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
/* получаем имя каталога в котором находимся */
|
||||
lHref = this.getByClass('path', lPanel);
|
||||
|
||||
lHref = lHref[0].textContent;
|
||||
lHref = lHref.textContent;
|
||||
|
||||
lHref = CloudFunc.rmLastSlash(lHref);
|
||||
lSubstr = lHref.substr(lHref , lHref.lastIndexOf('/'));
|
||||
|
|
@ -851,7 +863,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
*/
|
||||
this.getCurrentDirPath = function(pPanel) {
|
||||
var lPanel = pPanel || this.getPanel(),
|
||||
lPath = this.getByClass('path', lPanel)[0],
|
||||
lPath = this.getByClass('path', lPanel),
|
||||
lRet;
|
||||
|
||||
if (lPath)
|
||||
|
|
@ -865,7 +877,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
*/
|
||||
this.getNotCurrentDirPath = function() {
|
||||
var lPanel = this.getPanel(true),
|
||||
lPath = this.getByClass('path', lPanel)[0],
|
||||
lPath = this.getByClass('path', lPanel),
|
||||
lRet;
|
||||
|
||||
if (lPath)
|
||||
|
|
@ -880,7 +892,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
* @pCurrentFile
|
||||
*/
|
||||
this.getCurrentFile = function() {
|
||||
var lRet = this.getByClass( CURRENT_FILE )[0];
|
||||
var lRet = this.getByClass(CURRENT_FILE);
|
||||
|
||||
return lRet;
|
||||
};
|
||||
|
|
@ -904,7 +916,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
* @pCurrentFile
|
||||
*/
|
||||
this.getSelectedFiles = function() {
|
||||
var lRet = this.getByClass(SELECTED_FILE);
|
||||
var lRet = this.getByClassAll(SELECTED_FILE);
|
||||
|
||||
return lRet.length ? lRet : null;
|
||||
};
|
||||
|
|
@ -917,7 +929,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
var lRet,
|
||||
lCurrent = pCurrentFile || Cmd.getCurrentFile(),
|
||||
lSize = this.getByClass('size', lCurrent);
|
||||
lSize = lSize[0].textContent;
|
||||
lSize = lSize.textContent;
|
||||
/* если это папка - возвращаем слово dir вместо размера*/
|
||||
lRet = Util.removeStrOneTime(lSize, ['<', '>']);
|
||||
|
||||
|
|
@ -984,7 +996,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
lSizeElement = this.getByClass('size', lCurrent),
|
||||
lSize = CloudFunc.getShortSize(pSize);
|
||||
|
||||
lSizeElement[0].textContent = lSize;
|
||||
lSizeElement.textContent = lSize;
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -995,7 +1007,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
var lRet,
|
||||
lCurrent = pCurrentFile || this.getCurrentFile(),
|
||||
lMode = this.getByClass('mode', lCurrent);
|
||||
lRet = lMode[0].textContent;
|
||||
lRet = lMode.textContent;
|
||||
|
||||
return lRet;
|
||||
};
|
||||
|
|
@ -1006,7 +1018,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
this.getCurrentOwner = function(pCurrentFile) {
|
||||
var ret,
|
||||
current = pCurrentFile || this.getCurrentFile(),
|
||||
owner = this.getByClass('owner', current)[0];
|
||||
owner = this.getByClass('owner', current);
|
||||
|
||||
ret = owner.textContent;
|
||||
|
||||
|
|
@ -1128,7 +1140,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
|
||||
var lPanel = this.getPanel(),
|
||||
lRefresh = this.getByClass(CloudFunc.REFRESHICON, lPanel),
|
||||
lRet = lRefresh[0];
|
||||
lRet = lRefresh;
|
||||
|
||||
return lRet;
|
||||
};
|
||||
|
|
@ -1342,7 +1354,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
*/
|
||||
this.isCurrentIsDir = function(pCurrent) {
|
||||
var lCurrent = pCurrent || this.getCurrentFile(),
|
||||
lFileType = this.getByClass('mini-icon', lCurrent)[0],
|
||||
lFileType = this.getByClass('mini-icon', lCurrent),
|
||||
lRet = this.isContainClass(lFileType, 'directory');
|
||||
|
||||
return lRet;
|
||||
|
|
@ -1538,14 +1550,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
return panel;
|
||||
};
|
||||
|
||||
this.getFiles = function(panel) {
|
||||
var files = DOM.getByClass('files', panel)[0];
|
||||
|
||||
return files;
|
||||
};
|
||||
|
||||
this.getFiles = function(element) {
|
||||
var files = DOM.getByClass('files', element)[0],
|
||||
var files = DOM.getByClass('files', element),
|
||||
ret = files.children || [];
|
||||
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ var Util, DOM, CloudCmd;
|
|||
|
||||
this.initKeysPanel = function() {
|
||||
var button, id, func,
|
||||
keysElement = DOM.getByClass('keyspanel')[0];
|
||||
keysElement = DOM.getByClass('keyspanel');
|
||||
|
||||
if (keysElement)
|
||||
Events.addClick(function(event) {
|
||||
|
|
@ -77,10 +77,10 @@ var Util, DOM, CloudCmd;
|
|||
this.changeLinks = function(pPanelID) {
|
||||
/* назначаем кнопку очистить кэш и показываем её */
|
||||
var lPanel = DOM.getById(pPanelID),
|
||||
pathElement = DOM.getByClass('path', lPanel)[0],
|
||||
pathLinks = DOM.getByClass('links', pathElement)[0].children,
|
||||
clearStorage = DOM.getByClass('clear-storage', pathElement)[0],
|
||||
refresh = DOM.getByClass('refresh-icon', pathElement)[0],
|
||||
pathElement = DOM.getByClass('path', lPanel),
|
||||
pathLinks = DOM.getByClass('links', pathElement).children,
|
||||
clearStorage = DOM.getByClass('clear-storage', pathElement),
|
||||
refresh = DOM.getByClass('refresh-icon', pathElement),
|
||||
|
||||
fileClick = function (event) {
|
||||
var ctrl = event.ctrlKey;
|
||||
|
|
@ -156,7 +156,7 @@ var Util, DOM, CloudCmd;
|
|||
},
|
||||
|
||||
i, n, a, ai, current, link, loadDir,
|
||||
filesElement = DOM.getByClass('files', lPanel)[0],
|
||||
filesElement = DOM.getByClass('files', lPanel),
|
||||
files = filesElement.children,
|
||||
lUrl = CloudCmd.HOST,
|
||||
loadDirOnce = CloudCmd.loadDir();
|
||||
|
|
@ -227,7 +227,7 @@ var Util, DOM, CloudCmd;
|
|||
}
|
||||
|
||||
function dragndrop() {
|
||||
var panels = DOM.getByClass('panel'),
|
||||
var panels = DOM.getByClassAll('panel'),
|
||||
i = 0,
|
||||
n = panels.length,
|
||||
preventDefault = function (event) {
|
||||
|
|
|
|||
|
|
@ -75,14 +75,15 @@ var Util, DOM, jQuery;
|
|||
};
|
||||
}
|
||||
|
||||
if(!document.getElementsByClassName){
|
||||
DOM.getByClass = function(pClass, pElement){
|
||||
if (!document.getElementsByClassName) {
|
||||
DOM.getByClassAll = function(pClass, pElement) {
|
||||
var lClass = '.' + pClass,
|
||||
lResult;
|
||||
|
||||
if(pElement)
|
||||
if (pElement)
|
||||
lResult = $(pElement).find(lClass);
|
||||
else lResult = $.find(lClass);
|
||||
else
|
||||
lResult = $.find(lClass);
|
||||
|
||||
return lResult;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue