From af00d74e075c5e3d344aa0ca33c43b419366776d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 6 May 2013 06:25:41 -0400 Subject: [PATCH] Moved all methods of DOM module to prototype --- json/config.json | 2 +- lib/client/dom.js | 810 +++++++++++++++++++++++----------------------- 2 files changed, 413 insertions(+), 399 deletions(-) diff --git a/json/config.json b/json/config.json index 5f9fc6cf..3a8b6f66 100644 --- a/json/config.json +++ b/json/config.json @@ -2,7 +2,7 @@ "api_url" : "/api/v1", "appcache" : false, "minification" : { - "js" : true, + "js" : false, "css" : true, "html" : true, "img" : true diff --git a/lib/client/dom.js b/lib/client/dom.js index d8ebddc0..73b37bed 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1,41 +1,116 @@ -var CloudCommander, Util, DOM = {}, CloudFunc; +var CloudCommander, Util, DOM, CloudFunc; -(function(Util, DOM){ +(function(Util){ 'use strict'; - var CURRENT_FILE = 'current-file', - SELECTED_FILE = 'selected-file', + var DOMConstructor = function(){}, + CURRENT_FILE = 'current-file', + SELECTED_FILE = 'selected-file', XMLHTTP, Title, /* Обьект содержит функции для отображения картинок */ - Images = function (){ - function getImage(pName){ - var lId = pName + '-image', - lE = DOM.getById(lId); - if (!lE) - lE = DOM.anyload({ - name : 'span', - className : 'icon ' + pName, - id : lId, - not_append : true - }); + ImagesProto = function(){ + var LImagesProto = function (){ + function getImage(pName){ + var lId = pName + '-image', + lE = DOMProto.getById(lId); + + if (!lE) + lE = DOMProto.anyload({ + name : 'span', + className : 'icon ' + pName, + id : lId, + not_append : true + }); + + return lE; + } + + /* Функция создаёт картинку загрузки */ + this.loading = function(){ + return getImage('loading'); + }; - return lE; - } - - /* Функция создаёт картинку загрузки*/ - this.loading = function(){ - return getImage('loading'); + /* Функция создаёт картинку ошибки загрузки */ + this.error = function(){ + return getImage('error'); + }; + }, + lImages = new LImagesProto(); + /** + * Function shows loading spinner + * pPosition = {top: true}; + */ + this.showLoad = function(pPosition){ + var lRet_b, + lLoadingImage = lImages.loading(), + lErrorImage = lImages.error(); + + DOMProto.hide(lErrorImage); + + var lCurrent; + if(pPosition && pPosition.top) + lCurrent = DOMProto.getRefreshButton().parentElement; + else{ + var lFile = DOMProto.getCurrentFile(); + lCurrent = DOMProto.getByClass('name', lFile)[0]; + } + + /* show loading icon if it not showed */ + + var lParent = lLoadingImage.parentElement; + if(!lParent || (lParent && lParent !== lCurrent)) + lCurrent.appendChild(lLoadingImage); + + lRet_b = DOMProto.show(lLoadingImage); /* показываем загрузку*/ + + return lRet_b; }; - /* Функция создаёт картинку ошибки загрузки*/ - this.error = function(){ - return getImage('error'); + /** + * hide load image + */ + this.hideLoad = function(){ + + DOMProto.hide( lImages.loading() ); + }; + + /** + * show error image (usualy after error on ajax request) + */ + this.showError = function(jqXHR, textStatus, errorThrown){ + var lLoadingImage = lImages.loading(), + lErrorImage = lImages.error(), + lResponce = jqXHR.responseText, + lStatusText = jqXHR.statusText, + lStatus = jqXHR.status, + lText = (lStatus === 404 ? lResponce : lStatusText); + + /* если файла не существует*/ + if( Util.isContainStr(lText, 'Error: ENOENT, ') ) + lText = lText.replace('Error: ENOENT, n','N'); + + /* если не хватает прав для чтения файла*/ + else if( Util.isContainStr(lText, 'Error: EACCES,') ) + lText = lText.replace('Error: EACCES, p','P'); + + + DOMProto.show(lErrorImage); + lErrorImage.title = lText; + + var lParent = lLoadingImage.parentElement; + if(lParent) + lParent.appendChild(lErrorImage); + + DOMProto.hide(lLoadingImage); + + Util.log(lText); + + setTimeout( Util.retExec(alert, lText), 100); }; }, - /* Обьект содержит функции для работы с CloudCmd API */ - RESTfull = function(){ + RESTfullProto = function(){ this.delete = function(pUrl, pData, pCallBack, pQuery){ sendRequest({ method : 'DELETE', @@ -87,7 +162,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; if(lRet){ var p = pParams; - DOM.Images.showLoad( p.imgPosition ); + DOMProto.Images.showLoad( p.imgPosition ); CloudCommander.getConfig(function(pConfig){ var lData; @@ -100,13 +175,13 @@ var CloudCommander, Util, DOM = {}, CloudFunc; lData = p.data; p.url = pConfig && pConfig.api_url + p.url, - DOM.ajax({ + DOMProto.ajax({ method : p.method, url : p.url, data : lData, - error : DOM.Images.showError, + error : DOMProto.Images.showError, success : function(pData){ - DOM.Images.hideLoad(); + DOMProto.Images.hideLoad(); Util.log(pData); Util.exec(p.callback, pData); } @@ -116,12 +191,89 @@ var CloudCommander, Util, DOM = {}, CloudFunc; return lRet; } - }; + }, + DOMTreeProto = function(){ + /** + * add class to element + * + * @param pElement + * @param pClass + */ + this.addClass = function(pElement, pClass){ + var lRet; + + if(pElement){ + var lClassList = pElement.classList; + lRet = !this.isContainClass(pElement, pClass); + + if( lRet ) + lClassList.add(pClass); + } + + return lRet; + }; + + /** + * check class of element + * + * @param pElement + * @param pClass + */ + this.isContainClass = function(pElement, pClass){ + var lRet, + lClassList = pElement && pElement.classList; + + if( lClassList ) + lRet = lClassList.contains(pClass); + + return lRet; + }; + + /** + * Function search element by tag + * @param pTag - className + * @param pElement - element + */ + this.getByTag = function(pTag, pElement){ + return (pElement || document).getElementsByTagName(pTag); + }; + + /** + * Function search element by id + * @param Id - className + * @param pElement - element + */ + this.getById = function(pId, pElement){ + return (pElement || document).getElementById(pId); + }; + + /** + * Function search element by class name + * @param pClass - className + * @param pElement - element + */ + this.getByClass = function(pClass, pElement){ + return (pElement || document).getElementsByClassName(pClass); + }; + }, + RESTfull = function(){}, + Images = function(){}, + DOMTreeConstructor = function(){}, + DOMTree, + DOMProto; - Images = new Images(); + DOMTreeConstructor.prototype= new DOMTreeProto(); + DOMTree = new DOMTreeConstructor(); - DOM.RESTfull = new RESTfull(); + DOMProto = new DOMTreeConstructor(); + DOMConstructor.prototype = DOMProto; + DOM = new DOMConstructor(); + RESTfull.prototype = new RESTfullProto(); + DOMProto.RESTfull = new RESTfull(); + + Images.prototype = new ImagesProto(); + DOMProto.Images = new Images(); /** * private function thet unset currentfile @@ -129,49 +281,14 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @pCurrentFile */ function unsetCurrentFile(pCurrentFile){ - var lRet = DOM.isCurrentFile(pCurrentFile); + var lRet = DOMProto.isCurrentFile(pCurrentFile); if(lRet) - DOM.removeClass(pCurrentFile, CURRENT_FILE); + DOMProto.removeClass(pCurrentFile, CURRENT_FILE); return lRet; } - /** - * add class to element - * - * @param pElement - * @param pClass - */ - DOM.addClass = function(pElement, pClass){ - var lRet; - - if(pElement){ - var lClassList = pElement.classList; - lRet = !DOM.isContainClass(pElement, pClass); - - if( lRet ) - lClassList.add(pClass); - } - - return lRet; - }; - - /** - * check class of element - * - * @param pElement - * @param pClass - */ - DOM.isContainClass = function(pElement, pClass){ - var lRet, - lClassList = pElement && pElement.classList; - - if( lClassList ) - lRet = lClassList.contains(pClass); - - return lRet; - }; /** * safe add event listener @@ -181,7 +298,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pUseCapture * @param pElement {document by default} */ - DOM.addListener = function(pType, pListener, pElement, pUseCapture){ + DOMProto.addListener = function(pType, pListener, pElement, pUseCapture){ var lRet = this, lElement = (pElement || window); @@ -203,14 +320,14 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pUseCapture * @param pElement {document by default} */ - DOM.addOneTimeListener = function(pType, pListener, pElement, pUseCapture){ + DOMProto.addOneTimeListener = function(pType, pListener, pElement, pUseCapture){ var lRet = this, lOneTime = function (pEvent){ - DOM.removeListener(pType, lOneTime, pElement, pUseCapture); + DOMProto.removeListener(pType, lOneTime, pElement, pUseCapture); pListener(pEvent); }; - DOM.addListener(pType, lOneTime, pElement, pUseCapture); + DOMProto.addListener(pType, lOneTime, pElement, pUseCapture); return lRet; }; @@ -223,7 +340,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pUseCapture * @param pElement {document by default} */ - DOM.removeListener = function(pType, pListener, pElement, pUseCapture){ + DOMProto.removeListener = function(pType, pListener, pElement, pUseCapture){ var lRet = this; (pElement || window).removeEventListener( @@ -242,8 +359,8 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pListener * @param pUseCapture */ - DOM.addKeyListener = function(pListener, pElement, pUseCapture){ - return DOM.addListener('keydown', pListener, pElement, pUseCapture); + DOMProto.addKeyListener = function(pListener, pElement, pUseCapture){ + return DOMProto.addListener('keydown', pListener, pElement, pUseCapture); }; /** @@ -252,12 +369,12 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pListener * @param pUseCapture */ - DOM.addClickListener = function(pListener, pElement, pUseCapture){ - return DOM.addListener('click', pListener, pElement, pUseCapture); + DOMProto.addClickListener = function(pListener, pElement, pUseCapture){ + return DOMProto.addListener('click', pListener, pElement, pUseCapture); }; - DOM.addContextMenuListener = function(pListener, pElement, pUseCapture){ - return DOM.addListener('contextmenu', pListener, pElement, pUseCapture); + DOMProto.addContextMenuListener = function(pListener, pElement, pUseCapture){ + return DOMProto.addListener('contextmenu', pListener, pElement, pUseCapture); }; /** @@ -266,8 +383,8 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pListener * @param pUseCapture */ - DOM.addErrorListener = function(pListener, pElement, pUseCapture){ - return DOM.addListener('error', pListener, pElement, pUseCapture); + DOMProto.addErrorListener = function(pListener, pElement, pUseCapture){ + return DOMProto.addListener('error', pListener, pElement, pUseCapture); }; /** @@ -276,7 +393,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pEventName * @param pKeyCode - not necessarily */ - DOM.createEvent = function(pEventName, pKeyCode){ + DOMProto.createEvent = function(pEventName, pKeyCode){ var lEvent = document.createEvent('Event'); lEvent.initEvent(pEventName, true, true); @@ -297,8 +414,8 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pKeyCode */ - DOM.createKeyEvent = function(pKeyCode){ - return DOM.createEvent('keydown', pKeyCode); + DOMProto.createKeyEvent = function(pKeyCode){ + return DOMProto.createEvent('keydown', pKeyCode); }; /** @@ -306,8 +423,8 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pKeyCode */ - DOM.createClickEvent = function(){ - return DOM.createEvent('click'); + DOMProto.createClickEvent = function(){ + return DOMProto.createEvent('click'); }; /** @@ -315,8 +432,8 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pKeyCode */ - DOM.createDblClickEvent = function(){ - return DOM.createEvent('dblclick'); + DOMProto.createDblClickEvent = function(){ + return DOMProto.createEvent('dblclick'); }; /** @@ -324,7 +441,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pEvent */ - DOM.dispatch = function(pEvent, pElement){ + DOMProto.dispatch = function(pEvent, pElement){ return (pElement || window).dispatchEvent(pEvent); }; @@ -334,9 +451,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pKeyCode * @param pElement */ - DOM.dispatchKeyEvent = function(pKeyCode, pElement){ - var lEvent = DOM.createKeyEvent(pKeyCode), - lRet = DOM.dispatch(lEvent, pElement); + DOMProto.dispatchKeyEvent = function(pKeyCode, pElement){ + var lEvent = DOMProto.createKeyEvent(pKeyCode), + lRet = DOMProto.dispatch(lEvent, pElement); return lRet; }; @@ -346,9 +463,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pElement */ - DOM.dispatchClickEvent = function(pElement){ - var lEvent = DOM.createClickEvent(), - lRet = DOM.dispatch(lEvent, pElement); + DOMProto.dispatchClickEvent = function(pElement){ + var lEvent = DOMProto.createClickEvent(), + lRet = DOMProto.dispatch(lEvent, pElement); return lRet; }; @@ -358,9 +475,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pElement */ - DOM.dispatchDblClickEvent = function(pElement){ - var lEvent = DOM.createDblClickEvent(), - lRet = DOM.dispatch(lEvent, pElement); + DOMProto.dispatchDblClickEvent = function(pElement){ + var lEvent = DOMProto.createDblClickEvent(), + lRet = DOMProto.dispatch(lEvent, pElement); return lRet; }; @@ -371,7 +488,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pParams */ - DOM.ajax = function(pParams){ + DOMProto.ajax = function(pParams){ var lRet = Util.checkObjTrue(pParams, ['url', 'success']); if(lRet){ var p = pParams, @@ -420,7 +537,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * работы с LocalStorage, webdb, * indexed db etc. */ - DOM.Cache = function(){ + DOMProto.Cache = function(){ /* приватный переключатель возможности работы с кэшем */ var CacheAllowed; @@ -493,15 +610,15 @@ var CloudCommander, Util, DOM = {}, CloudFunc; }; }; - DOM.Cache = new DOM.Cache(); + DOMProto.Cache = new DOMProto.Cache(); /** * create new folder * * @pCurrentFile */ - DOM.promptNewDir = function(){ - DOM.promptNewFile('directory', '?dir'); + DOMProto.promptNewDir = function(){ + DOMProto.promptNewFile('directory', '?dir'); }; /** @@ -509,9 +626,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @pCurrentFile */ - DOM.promptNewFile = function(pTypeName, pType){ - var lName = DOM.getCurrentName(), - lDir = DOM.getCurrentDirPath(), + DOMProto.promptNewFile = function(pTypeName, pType){ + var lName = DOMProto.getCurrentName(), + lDir = DOMProto.getCurrentDirPath(), lMsg = 'New ' + pTypeName || 'File', lType = Util.isString(pType) ? pType : ''; @@ -521,7 +638,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; lName = prompt(lMsg, lName); if(lName) - DOM.RESTfull.save(lDir + lName + lType, null, CloudCommander.refresh); + DOMProto.RESTfull.save(lDir + lName + lType, null, CloudCommander.refresh); }; @@ -531,14 +648,14 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @pCurrentFile */ - DOM.promptDeleteSelected = function(pCurrentFile){ + DOMProto.promptDeleteSelected = function(pCurrentFile){ var lRet, lCurrent, lQuery, lMsg, lName = '', lMsgAsk = 'Do you really want to delete the ', lMsgSel = 'selected ', - lFiles = DOM.getSelectedFiles(), - lSelected = DOM.getSelectedNames(lFiles), + lFiles = DOMProto.getSelectedFiles(), + lSelected = DOMProto.getSelectedNames(lFiles), i, n = lSelected && lSelected.length; if(n > 1){ @@ -557,9 +674,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; if( pCurrentFile && !pCurrentFile.pType) lCurrent = pCurrentFile; else - lCurrent = DOM.getCurrentFile(); + lCurrent = DOMProto.getCurrentFile(); - lIsDir = DOM.isCurrentIsDir(lCurrent); + lIsDir = DOMProto.isCurrentIsDir(lCurrent); if(lIsDir){ lQuery = '?dir'; @@ -570,7 +687,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; lType += ' '; - lName = DOM.getCurrentName(lCurrent); + lName = DOMProto.getCurrentName(lCurrent); lMsg = lMsgAsk + lMsgSel + lType + lName + '?'; } @@ -582,24 +699,24 @@ var CloudCommander, Util, DOM = {}, CloudFunc; var lUrl; if(lCurrent) - lUrl = DOM.getCurrentPath(lCurrent); + lUrl = DOMProto.getCurrentPath(lCurrent); else{ - lUrl = DOM.getCurrentDirPath(); + lUrl = DOMProto.getCurrentDirPath(); lCurrent = lFiles[0]; } if(lCurrent || lSelected) - DOM.RESTfull.delete(lUrl, lSelected, function(){ + DOMProto.RESTfull.delete(lUrl, lSelected, function(){ if(n > 1) - DOM.deleteSelected(lFiles); + DOMProto.deleteSelected(lFiles); else - DOM.deleteCurrent(lCurrent); + DOMProto.deleteCurrent(lCurrent); var lDir = CloudFunc.removeLastSlash( - DOM.getCurrentDirPath() + DOMProto.getCurrentDirPath() ); - DOM.Cache.remove(lDir); + DOMProto.Cache.remove(lDir); }, lQuery); return lCurrent; @@ -614,7 +731,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * Example: http://domain.com/1.js -> 1_js */ - DOM.getIdBySrc = function(pSrc){ + DOMProto.getIdBySrc = function(pSrc){ var lRet = Util.isString(pSrc); if(lRet){ @@ -639,26 +756,26 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pParams_a * @param pFunc - onload function */ - DOM.anyLoadOnLoad = function(pParams_a, pFunc){ + DOMProto.anyLoadOnLoad = function(pParams_a, pFunc){ var lRet = this; if( Util.isArray(pParams_a) ) { var lParam = pParams_a.pop(), lFunc = function(){ - DOM.anyLoadOnLoad(pParams_a, pFunc); + DOMProto.anyLoadOnLoad(pParams_a, pFunc); }; if( Util.isString(lParam) ) lParam = { src : lParam }; else if( Util.isArray(lParam) ){ - DOM.anyLoadInParallel(lParam, lFunc); + DOMProto.anyLoadInParallel(lParam, lFunc); } if(lParam && !lParam.func){ lParam.func = lFunc; - DOM.anyload(lParam); + DOMProto.anyload(lParam); }else Util.exec(pFunc); @@ -675,7 +792,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pParams_a * @param pFunc - onload function */ - DOM.anyLoadInParallel = function(pParams_a, pFunc){ + DOMProto.anyLoadInParallel = function(pParams_a, pFunc){ var lRet = this, lDone = [], @@ -702,7 +819,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; var lFunc = lParam.func; lParam.func = Util.retExec(lDoneFunc, lFunc); - DOM.anyload(lParam); + DOMProto.anyload(lParam); } } @@ -727,7 +844,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * not_append - false by default * } */ - DOM.anyload = function(pParams_o){ + DOMProto.anyload = function(pParams_o){ if( !pParams_o ) return; @@ -738,7 +855,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; if( Util.isArray(pParams_o) ){ var lElements_a = []; for(var i = 0, n = pParams_o.length; i < n ; i++) - lElements_a[i] = DOM.anyload(pParams_o[i]); + lElements_a[i] = DOMProto.anyload(pParams_o[i]); return lElements_a; } @@ -761,9 +878,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; } /* убираем путь к файлу, оставляя только название файла */ if(!lID && lSrc) - lID = DOM.getIdBySrc(lSrc); + lID = DOMProto.getIdBySrc(lSrc); - var lElement = DOM.getById(lID); + var lElement = DOMProto.getById(lID); /* если скрипт еще не загружен */ if(!lElement){ @@ -809,8 +926,8 @@ var CloudCommander, Util, DOM = {}, CloudFunc; */ var lLoad = function(pEvent){ - DOM.removeListener('load', lLoad, lElement); - DOM.removeListener('error', lError, lElement); + DOMProto.removeListener('load', lLoad, lElement); + DOMProto.removeListener('error', lError, lElement); Util.exec(lFunc, pEvent); }, @@ -818,7 +935,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; lError = function(){ lParent.removeChild(lElement); - DOM.Images.showError({ + DOMProto.Images.showError({ responseText: 'file ' + lSrc + ' could not be loaded', @@ -828,8 +945,8 @@ var CloudCommander, Util, DOM = {}, CloudFunc; Util.exec(lOnError); }; - DOM.addListener('load', lLoad, lElement); - DOM.addErrorListener(lError, lElement); + DOMProto.addListener('load', lLoad, lElement); + DOMProto.addErrorListener(lError, lElement); if(lStyle) lElement.style.cssText = lStyle; @@ -858,15 +975,15 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pSrc * @param pFunc */ - DOM.jsload = function(pSrc, pFunc){ + DOMProto.jsload = function(pSrc, pFunc){ if( Util.isArray(pSrc) ){ for(var i=0; i < pSrc.length; i++) pSrc[i].name = 'script'; - return DOM.anyload(pSrc); + return DOMProto.anyload(pSrc); } - return DOM.anyload({ + return DOMProto.anyload({ name : 'script', src : pSrc, func : pFunc @@ -876,9 +993,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; /** * returns jsload functions */ - DOM.retJSLoad = function(pSrc, pFunc){ + DOMProto.retJSLoad = function(pSrc, pFunc){ var lRet = function(){ - return DOM.jsload(pSrc, pFunc); + return DOMProto.jsload(pSrc, pFunc); }; return lRet; @@ -891,11 +1008,11 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * образом: {src: ' ',func: '', id: '', element: '', inner: ''} * все параметры опциональны */ - DOM.cssSet = function(pParams_o){ + DOMProto.cssSet = function(pParams_o){ pParams_o.name = 'style'; pParams_o.parent = pParams_o.parent || document.head; - return DOM.anyload(pParams_o); + return DOMProto.anyload(pParams_o); }, /** @@ -904,14 +1021,14 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * образом: {src: ' ',func: '', id: '', element: '', inner: ''} * все параметры опциональны */ - DOM.cssLoad = function(pParams_o){ + DOMProto.cssLoad = function(pParams_o){ if( Util.isArray(pParams_o) ){ for(var i = 0, n = pParams_o.length; i < n; i++){ pParams_o[i].name = 'link'; pParams_o[i].parent = pParams_o.parent || document.head; } - return DOM.anyload(pParams_o); + return DOMProto.anyload(pParams_o); } else if( Util.isString(pParams_o) ) @@ -920,25 +1037,25 @@ var CloudCommander, Util, DOM = {}, CloudFunc; pParams_o.name = 'link'; pParams_o.parent = pParams_o.parent || document.head; - return DOM.anyload(pParams_o); + return DOMProto.anyload(pParams_o); }; /** * load jquery from google cdn or local copy * @param pCallBack */ - DOM.jqueryLoad = function(pCallBack){ + DOMProto.jqueryLoad = function(pCallBack){ /* загружаем jquery: */ - DOM.jsload('//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js',{ + DOMProto.jsload('//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js',{ onload: Util.retExec(pCallBack), onerror: function(){ - DOM.jsload('/lib/client/jquery.js'); + DOMProto.jsload('/lib/client/jquery.js'); /* if could not load jquery from google server * maybe we offline, load font from local * directory */ - DOM.cssSet({ + DOMProto.cssSet({ id :'local-droids-font', element : document.head, inner : '@font-face {font-family: "Droid Sans Mono";' + @@ -954,123 +1071,20 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * load socket.io * @param pCallBack */ - DOM.socketLoad = function(pCallBack){ - DOM.jsload('/lib/client/socket.js', Util.retExec(pCallBack) ); + DOMProto.socketLoad = function(pCallBack){ + DOMProto.jsload('/lib/client/socket.js', Util.retExec(pCallBack) ); }; - /* DOM */ - - /** - * Function search element by tag - * @param pTag - className - * @param pElement - element - */ - DOM.getByTag = function(pTag, pElement){ - return (pElement || document).getElementsByTagName(pTag); - }; - - /** - * Function search element by id - * @param Id - className - * @param pElement - element - */ - DOM.getById = function(pId, pElement){ - return (pElement || document).getElementById(pId); - }; - - /** - * Function search element by class name - * @param pClass - className - * @param pElement - element - */ - DOM.getByClass = function(pClass, pElement){ - return (pElement || document).getElementsByClassName(pClass); - }; - - - DOM.Images = { - /** - * Function shows loading spinner - * pPosition = {top: true}; - */ - showLoad : function(pPosition){ - var lRet_b, - lLoadingImage = Images.loading(), - lErrorImage = Images.error(); - - DOM.hide(lErrorImage); - - var lCurrent; - if(pPosition && pPosition.top) - lCurrent = DOM.getRefreshButton().parentElement; - else{ - var lFile = DOM.getCurrentFile(); - lCurrent = DOM.getByClass('name', lFile)[0]; - } - - /* show loading icon if it not showed */ - - var lParent = lLoadingImage.parentElement; - if(!lParent || (lParent && lParent !== lCurrent)) - lCurrent.appendChild(lLoadingImage); - - lRet_b = DOM.show(lLoadingImage); /* показываем загрузку*/ - - return lRet_b; - }, - - /** - * hide load image - */ - hideLoad : function(){ - - DOM.hide( Images.loading() ); - }, - - /** - * show error image (usualy after error on ajax request) - */ - showError : function(jqXHR, textStatus, errorThrown){ - var lLoadingImage = Images.loading(), - lErrorImage = Images.error(), - lResponce = jqXHR.responseText, - lStatusText = jqXHR.statusText, - lStatus = jqXHR.status, - lText = (lStatus === 404 ? lResponce : lStatusText); - - /* если файла не существует*/ - if( Util.isContainStr(lText, 'Error: ENOENT, ') ) - lText = lText.replace('Error: ENOENT, n','N'); - - /* если не хватает прав для чтения файла*/ - else if( Util.isContainStr(lText, 'Error: EACCES,') ) - lText = lText.replace('Error: EACCES, p','P'); - - - DOM.show(lErrorImage); - lErrorImage.title = lText; - - var lParent = lLoadingImage.parentElement; - if(lParent) - lParent.appendChild(lErrorImage); - - DOM.hide(lLoadingImage); - - Util.log(lText); - - setTimeout( Util.retExec(alert, lText), 100); - } - }; /** * get current direcotory name */ - DOM.getCurrentDirName = function(){ + DOMProto.getCurrentDirName = function(){ var lRet, lSubstr, - lPanel = DOM.getPanel(), + lPanel = DOMProto.getPanel(), /* получаем имя каталога в котором находимся */ - lHref = DOM.getByClass('path', lPanel); + lHref = DOMProto.getByClass('path', lPanel); lHref = lHref[0].textContent; @@ -1084,9 +1098,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; /** * get current direcotory path */ - DOM.getCurrentDirPath = function(pPanel){ - var lPanel = pPanel || DOM.getPanel(), - lPath = DOM.getByClass('path', lPanel)[0], + DOMProto.getCurrentDirPath = function(pPanel){ + var lPanel = pPanel || DOMProto.getPanel(), + lPath = DOMProto.getByClass('path', lPanel)[0], lRet; if(lPath) @@ -1098,9 +1112,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; /** * get current direcotory path */ - DOM.getNotCurrentDirPath = function(){ - var lPanel = DOM.getPanel(true), - lPath = DOM.getByClass('path', lPanel)[0], + DOMProto.getNotCurrentDirPath = function(){ + var lPanel = DOMProto.getPanel(true), + lPath = DOMProto.getByClass('path', lPanel)[0], lRet; if(lPath) @@ -1114,8 +1128,8 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @pCurrentFile */ - DOM.getCurrentFile = function(){ - var lRet = DOM.getByClass( CURRENT_FILE )[0]; + DOMProto.getCurrentFile = function(){ + var lRet = DOMProto.getByClass( CURRENT_FILE )[0]; return lRet; }; @@ -1125,8 +1139,8 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @pCurrentFile */ - DOM.getSelectedFiles = function(){ - var lRet = DOM.getByClass(SELECTED_FILE); + DOMProto.getSelectedFiles = function(){ + var lRet = DOMProto.getByClass(SELECTED_FILE); return lRet.length ? lRet : null; }; @@ -1135,10 +1149,10 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * get size * @pCurrentFile */ - DOM.getCurrentSize = function(pCurrentFile){ + DOMProto.getCurrentSize = function(pCurrentFile){ var lRet, - lCurrent = pCurrentFile || DOM.getCurrentFile(), - lSize = DOM.getByClass('size', lCurrent); + lCurrent = pCurrentFile || DOMProto.getCurrentFile(), + lSize = DOMProto.getByClass('size', lCurrent); lSize = lSize[0].textContent; /* если это папка - возвращаем слово dir вместо размера*/ lRet = Util.removeStrOneTime(lSize, ['<', '>']); @@ -1150,16 +1164,16 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * get size * @pCurrentFile */ - DOM.loadCurrentSize = function(pCallBack, pCurrent){ + DOMProto.loadCurrentSize = function(pCallBack, pCurrent){ var lRet, - lCurrent = pCurrent || DOM.getCurrentFile(), - lLink = DOM.getCurrentPath(lCurrent), - lName = DOM.getCurrentName(lCurrent); + lCurrent = pCurrent || DOMProto.getCurrentFile(), + lLink = DOMProto.getCurrentPath(lCurrent), + lName = DOMProto.getCurrentName(lCurrent); /* если это папка - возвращаем слово dir вместо размера*/ if(lName !== '..') - DOM.RESTfull.read(lLink, function(pSize){ - DOM.setCurrentSize(pSize, lCurrent); + DOMProto.RESTfull.read(lLink, function(pSize){ + DOMProto.setCurrentSize(pSize, lCurrent); Util.exec(pCallBack, lCurrent); }, '?size'); @@ -1170,9 +1184,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * set size * @pCurrentFile */ - DOM.setCurrentSize = function(pSize, pCurrentFile){ - var lCurrent = pCurrentFile || DOM.getCurrentFile(), - lSizeElement = DOM.getByClass('size', lCurrent), + DOMProto.setCurrentSize = function(pSize, pCurrentFile){ + var lCurrent = pCurrentFile || DOMProto.getCurrentFile(), + lSizeElement = DOMProto.getByClass('size', lCurrent), lSize = CloudFunc.getShortSize(pSize); lSizeElement[0].textContent = lSize; @@ -1182,10 +1196,10 @@ var CloudCommander, Util, DOM = {}, CloudFunc; /** * @pCurrentFile */ - DOM.getCurrentMode = function(pCurrentFile){ + DOMProto.getCurrentMode = function(pCurrentFile){ var lRet, - lCurrent = pCurrentFile || DOM.getCurrentFile(), - lMode = DOM.getByClass('mode', lCurrent); + lCurrent = pCurrentFile || DOMProto.getCurrentFile(), + lMode = DOMProto.getByClass('mode', lCurrent); lRet = lMode[0].textContent; return lRet; @@ -1197,15 +1211,15 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @pCallBack - callback function or data struct {sucess, error} * @pCurrentFile */ - DOM.getCurrentFileContent = function(pParams, pCurrentFile){ + DOMProto.getCurrentFileContent = function(pParams, pCurrentFile){ var lRet, - lCurrentFile = pCurrentFile ? pCurrentFile : DOM.getCurrentFile(), + lCurrentFile = pCurrentFile ? pCurrentFile : DOMProto.getCurrentFile(), lParams = pParams ? pParams : {}, - lPath = DOM.getCurrentPath(lCurrentFile), + lPath = DOMProto.getCurrentPath(lCurrentFile), lErrorWas = pParams.error, lError = function(jqXHR){ Util.exec(lErrorWas); - DOM.Images.showError(jqXHR); + DOMProto.Images.showError(jqXHR); }; if( Util.isFunction(lParams) ) @@ -1214,13 +1228,13 @@ var CloudCommander, Util, DOM = {}, CloudFunc; lParams.error = lError; - if( DOM.isCurrentIsDir(lCurrentFile) ) + if( DOMProto.isCurrentIsDir(lCurrentFile) ) lPath += '?json'; if(!lParams.url) lParams.url = CloudFunc.FS + lPath; - lRet = DOM.ajax(lParams); + lRet = DOMProto.ajax(lParams); return lRet; }; @@ -1231,12 +1245,12 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @pCallBack - function({data, name}){} * @pCurrentFile */ - DOM.getCurrentData = function(pCallBack, pCurrentFile){ + DOMProto.getCurrentData = function(pCallBack, pCurrentFile){ var lParams, - lCurrentFile = pCurrentFile ? pCurrentFile : DOM.getCurrentFile(), + lCurrentFile = pCurrentFile ? pCurrentFile : DOMProto.getCurrentFile(), lFunc = function(pData){ - var lName = DOM.getCurrentName(lCurrentFile); + var lName = DOMProto.getCurrentName(lCurrentFile); if( Util.isObject(pData) ){ pData = Util.stringifyJSON(pData); @@ -1260,15 +1274,15 @@ var CloudCommander, Util, DOM = {}, CloudFunc; }; - return DOM.getCurrentFileContent(lParams, lCurrentFile); + return DOMProto.getCurrentFileContent(lParams, lCurrentFile); }; /** * unified way to get RefreshButton */ - DOM.getRefreshButton = function(){ - var lPanel = DOM.getPanel(), - lRefresh = DOM.getByClass(CloudFunc.REFRESHICON, lPanel), + DOMProto.getRefreshButton = function(){ + var lPanel = DOMProto.getPanel(), + lRefresh = DOMProto.getByClass(CloudFunc.REFRESHICON, lPanel), lRet = lRefresh[0]; return lRet; @@ -1278,9 +1292,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; /** * unified way to set current file */ - DOM.setCurrentFile = function(pCurrentFile){ + DOMProto.setCurrentFile = function(pCurrentFile){ var lRet, - lCurrentFileWas = DOM.getCurrentFile(); + lCurrentFileWas = DOMProto.getCurrentFile(); if(pCurrentFile){ if (pCurrentFile.className === 'path') @@ -1292,10 +1306,10 @@ var CloudCommander, Util, DOM = {}, CloudFunc; if(lCurrentFileWas) unsetCurrentFile(lCurrentFileWas); - DOM.addClass(pCurrentFile, CURRENT_FILE); + DOMProto.addClass(pCurrentFile, CURRENT_FILE); /* scrolling to current file */ - DOM.scrollIntoViewIfNeeded(pCurrentFile); + DOMProto.scrollIntoViewIfNeeded(pCurrentFile); lRet = true; } @@ -1307,12 +1321,12 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * select current file * @param pCurrent */ - DOM.setSelectedFile = function(pCurrent){ - var lCurrent = pCurrent || DOM.getCurrentFile(), - lRet = DOM.addClass(pCurrent, SELECTED_FILE); + DOMProto.setSelectedFile = function(pCurrent){ + var lCurrent = pCurrent || DOMProto.getCurrentFile(), + lRet = DOMProto.addClass(pCurrent, SELECTED_FILE); if(!lRet) - DOM.unsetSelectedFile(lCurrent); + DOMProto.unsetSelectedFile(lCurrent); return lRet; }; @@ -1321,9 +1335,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * unselect current file * @param pCurrent */ - DOM.unsetSelectedFile = function(pCurrent){ - var lCurrent = pCurrent || DOM.getCurrentFile(), - lRet = DOM.removeClass(lCurrent, SELECTED_FILE); + DOMProto.unsetSelectedFile = function(pCurrent){ + var lCurrent = pCurrent || DOMProto.getCurrentFile(), + lRet = DOMProto.removeClass(lCurrent, SELECTED_FILE); return lRet; }; @@ -1331,7 +1345,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; /** * setting history wrapper */ - DOM.setHistory = function(pData, pTitle, pUrl){ + DOMProto.setHistory = function(pData, pTitle, pUrl){ var lRet = window.history; if(lRet) @@ -1344,7 +1358,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * set onclick handler on buttons f1-f10 * @param pKey - 'f1'-'f10' */ - DOM.setButtonKey = function(pKey, pFunc){ + DOMProto.setButtonKey = function(pKey, pFunc){ Util.tryCatchLog(function(){ CloudCommander.KeysPanel[pKey].onclick = pFunc; }); @@ -1357,10 +1371,10 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pName */ - DOM.setTitle = function(pName){ + DOMProto.setTitle = function(pName){ if(!Title) - Title = DOM.getByTag('title')[0] || - DOM.anyload({ + Title = DOMProto.getByTag('title')[0] || + DOMProto.anyload({ name:'title', parentElement: document.head, innerHTML: pName @@ -1376,11 +1390,11 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pCurrentFile */ - DOM.isCurrentFile = function(pCurrent){ + DOMProto.isCurrentFile = function(pCurrent){ var lRet; if( pCurrent ) - lRet = DOM.isContainClass(pCurrent, CURRENT_FILE); + lRet = DOMProto.isContainClass(pCurrent, CURRENT_FILE); return lRet; }; @@ -1390,11 +1404,11 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pCurrentFile */ - DOM.isSelected = function(pSelected){ + DOMProto.isSelected = function(pSelected){ var lRet; if( pSelected ) - lRet = DOM.isContainClass(pSelected, SELECTED_FILE); + lRet = DOMProto.isContainClass(pSelected, SELECTED_FILE); return lRet; }; @@ -1404,10 +1418,10 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pCurrentFile */ - DOM.isCurrentIsDir = function(pCurrent){ - var lCurrent = pCurrent || DOM.getCurrentFile(), - lFileType = DOM.getByClass('mini-icon', lCurrent)[0], - lRet = DOM.isContainClass(lFileType, 'directory'); + DOMProto.isCurrentIsDir = function(pCurrent){ + var lCurrent = pCurrent || DOMProto.getCurrentFile(), + lFileType = DOMProto.getByClass('mini-icon', lCurrent)[0], + lRet = DOMProto.isContainClass(lFileType, 'directory'); return lRet; }; @@ -1418,8 +1432,8 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pCurrentFile - current file by default */ - DOM.getCurrentLink = function(pCurrentFile){ - var lLink = DOM.getByTag( 'a', pCurrentFile || DOM.getCurrentFile() ), + DOMProto.getCurrentLink = function(pCurrentFile){ + var lLink = DOMProto.getByTag( 'a', pCurrentFile || DOMProto.getCurrentFile() ), lRet = lLink.length > 0 ? lLink[0] : -1; @@ -1431,9 +1445,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pCurrentFile - current file by default */ - DOM.getCurrentPath = function(pCurrentFile){ - var lCurrent = pCurrentFile || DOM.getCurrentFile(), - lPath = DOM.getCurrentLink( lCurrent ).href; + DOMProto.getCurrentPath = function(pCurrentFile){ + var lCurrent = pCurrentFile || DOMProto.getCurrentFile(), + lPath = DOMProto.getCurrentLink( lCurrent ).href; lPath = decodeURI(lPath); /* убираем адрес хоста*/ @@ -1447,9 +1461,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pCurrentFile */ - DOM.getCurrentName = function(pCurrentFile){ - var lCurrent = pCurrentFile || DOM.getCurrentFile(), - lLink = DOM.getCurrentLink( lCurrent ); + DOMProto.getCurrentName = function(pCurrentFile){ + var lCurrent = pCurrentFile || DOMProto.getCurrentFile(), + lLink = DOMProto.getCurrentLink( lCurrent ); if( Util.isObject(lLink) ) lLink = lLink.title || lLink.textContent; @@ -1457,19 +1471,19 @@ var CloudCommander, Util, DOM = {}, CloudFunc; return lLink; }; - DOM.getSelectedNames = function(pSelected){ - var lSelected = pSelected || DOM.getSelectedFiles(), + DOMProto.getSelectedNames = function(pSelected){ + var lSelected = pSelected || DOMProto.getSelectedFiles(), lRet = lSelected ? [] : null; if(lRet){ var lFirst = lSelected[0], - lName = DOM.getCurrentName( lFirst ); + lName = DOMProto.getCurrentName( lFirst ); if(lName === '..') - DOM.unsetSelectedFile( lFirst ); + DOMProto.unsetSelectedFile( lFirst ); for(var i = 0, n = lSelected.length; i < n;i++) - lRet[i] = DOM.getCurrentName( lSelected[i] ); + lRet[i] = DOMProto.getCurrentName( lSelected[i] ); } return lRet; }; @@ -1479,9 +1493,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pCurrentFile */ - DOM.setCurrentName = function(pName, pCurrentFile){ - var lLink = DOM.getCurrentLink( pCurrentFile ), - lDir = DOM.getCurrentDirName() + '/'; + DOMProto.setCurrentName = function(pName, pCurrentFile){ + var lLink = DOMProto.getCurrentLink( pCurrentFile ), + lDir = DOMProto.getCurrentDirName() + '/'; lLink.title = lLink.textContent = pName; lLink.href = lDir + pName; @@ -1492,20 +1506,20 @@ var CloudCommander, Util, DOM = {}, CloudFunc; /** function getting FM * @param pPanel_o = {active: true} */ - DOM.getFM = function(){ - return DOM.getPanel().parentElement; + DOMProto.getFM = function(){ + return DOMProto.getPanel().parentElement; }; /** function getting panel active, or passive * @param pPanel_o = {active: true} */ - DOM.getPanel = function(pActive){ - var lPanel = DOM.getCurrentFile().parentElement; + DOMProto.getPanel = function(pActive){ + var lPanel = DOMProto.getCurrentFile().parentElement; /* if {active : false} getting passive panel */ if(pActive && !pActive.active){ var lId = lPanel.id === 'left' ? 'right' : 'left'; - lPanel = DOM.getById(lId); + lPanel = DOMProto.getById(lId); } /* if two panels showed @@ -1513,7 +1527,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * panel */ if(window.innerWidth < CloudCommander.MIN_ONE_PANEL_WIDTH) - lPanel = DOM.getById('left'); + lPanel = DOMProto.getById('left'); if(!lPanel) @@ -1523,7 +1537,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; }; /** prevent default event */ - DOM.preventDefault = function(pEvent){ + DOMProto.preventDefault = function(pEvent){ var lRet, lPreventDefault = pEvent && pEvent.preventDefault, lFunc = Util.bind(lPreventDefault, pEvent); @@ -1533,19 +1547,19 @@ var CloudCommander, Util, DOM = {}, CloudFunc; return lRet; }; - DOM.show = function(pElement){ - DOM.removeClass(pElement, 'hidden'); + DOMProto.show = function(pElement){ + DOMProto.removeClass(pElement, 'hidden'); }; /** * shows panel right or left (or active) */ - DOM.showPanel = function(pActive){ + DOMProto.showPanel = function(pActive){ var lRet = true, - lPanel = DOM.getPanel(pActive); + lPanel = DOMProto.getPanel(pActive); if(lPanel) - DOM.show(lPanel); + DOMProto.show(lPanel); else lRet = false; @@ -1555,12 +1569,12 @@ var CloudCommander, Util, DOM = {}, CloudFunc; /** * hides panel right or left (or active) */ - DOM.hidePanel = function(pActive){ + DOMProto.hidePanel = function(pActive){ var lRet = false, - lPanel = DOM.getPanel(pActive); + lPanel = DOMProto.getPanel(pActive); if(lPanel) - lRet = DOM.hide(lPanel); + lRet = DOMProto.hide(lPanel); return lRet; }; @@ -1570,15 +1584,15 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pElement */ - DOM.hide = function(pElement){ - return DOM.addClass(pElement, 'hidden'); + DOMProto.hide = function(pElement){ + return DOMProto.addClass(pElement, 'hidden'); }; /** * open window with URL * @param pUrl */ - DOM.openWindow = function(pUrl){ + DOMProto.openWindow = function(pUrl){ var left = 140, top = 187, width = 1000, @@ -1601,7 +1615,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pChild * @param pElement */ - DOM.remove = function(pChild, pElement){ + DOMProto.remove = function(pChild, pElement){ return (pElement || document.body).removeChild(pChild); }; @@ -1610,7 +1624,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pElement * @param pClass */ - DOM.removeClass = function(pElement, pClass){ + DOMProto.removeClass = function(pElement, pClass){ var lRet_b = true, lClassList = pElement.classList; @@ -1627,10 +1641,10 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * remove current file from file table * @pCurrent */ - DOM.deleteCurrent = function(pCurrent, pNextFile, pPreviousFile, pNotSet){ - var lCurrent = pCurrent || DOM.getCurrentFile(), + DOMProto.deleteCurrent = function(pCurrent, pNextFile, pPreviousFile, pNotSet){ + var lCurrent = pCurrent || DOMProto.getCurrentFile(), lParent = lCurrent && lCurrent.parentElement, - lName = DOM.getCurrentName(lCurrent); + lName = DOMProto.getCurrentName(lCurrent); if(lCurrent && lParent && lName !== '..'){ var lNext = pNextFile || lCurrent.nextSibling, @@ -1638,9 +1652,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; if(!pNotSet) if(lNext) - DOM.setCurrentFile(lNext); + DOMProto.setCurrentFile(lNext); else if(lPrevious) - DOM.setCurrentFile(lPrevious); + DOMProto.setCurrentFile(lPrevious); lParent.removeChild(lCurrent); } @@ -1652,8 +1666,8 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * remove selected files from file table * @Selected */ - DOM.deleteSelected = function(pSelected){ - var lSelected = pSelected || DOM.getSelectedFiles(); + DOMProto.deleteSelected = function(pSelected){ + var lSelected = pSelected || DOMProto.getSelectedFiles(); if(lSelected){ var n = lSelected.length, @@ -1665,7 +1679,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * when we remove 0 element, it's removed from lSelected to */ for(var i = 0; i < n; i++) - DOM.deleteCurrent( lSelected[0], lNext, lPrev, i !== lLast); + DOMProto.deleteCurrent( lSelected[0], lNext, lPrev, i !== lLast); } return lSelected; @@ -1676,14 +1690,14 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @pCurrent */ - DOM.renameCurrent = function(pCurrentFile){ - if( !DOM.isCurrentFile(pCurrentFile) ) + DOMProto.renameCurrent = function(pCurrentFile){ + if( !DOMProto.isCurrentFile(pCurrentFile) ) pCurrentFile = null; - var lCurrent = pCurrentFile || DOM.getCurrentFile(), - lFrom = DOM.getCurrentName(lCurrent), + var lCurrent = pCurrentFile || DOMProto.getCurrentFile(), + lFrom = DOMProto.getCurrentName(lCurrent), lTo = prompt('Rename', lFrom) || lFrom, - lDirPath = DOM.getCurrentDirPath(); + lDirPath = DOMProto.getCurrentDirPath(); if( !Util.strCmp(lFrom, lTo) ){ var lFiles = { @@ -1691,8 +1705,8 @@ var CloudCommander, Util, DOM = {}, CloudFunc; to : lDirPath + lTo }; - DOM.RESTfull.mv(lFiles, function(){ - DOM.setCurrentName(lTo, lCurrent); + DOMProto.RESTfull.mv(lFiles, function(){ + DOMProto.setCurrentName(lTo, lCurrent); }); } }; @@ -1702,14 +1716,14 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @pCurrent */ - DOM.moveCurrent = function(pCurrentFile){ - if( !DOM.isCurrentFile(pCurrentFile) ) + DOMProto.moveCurrent = function(pCurrentFile){ + if( !DOMProto.isCurrentFile(pCurrentFile) ) pCurrentFile = null; - var lCurrent = pCurrentFile || DOM.getCurrentFile(), - lName = DOM.getCurrentName(lCurrent), - lFromPath = DOM.getCurrentPath(), - lToPath = DOM.getNotCurrentDirPath() + lName; + var lCurrent = pCurrentFile || DOMProto.getCurrentFile(), + lName = DOMProto.getCurrentName(lCurrent), + lFromPath = DOMProto.getCurrentPath(), + lToPath = DOMProto.getNotCurrentDirPath() + lName; lToPath = prompt( 'Rename/Move file "' + lName + '"', lToPath ); @@ -1719,13 +1733,13 @@ var CloudCommander, Util, DOM = {}, CloudFunc; to : lToPath }; - DOM.RESTfull.mv(lFiles, function(){ - DOM.deleteCurrent(lCurrent); + DOMProto.RESTfull.mv(lFiles, function(){ + DOMProto.deleteCurrent(lCurrent); - var lPanel = DOM.getPanel(true), - lDotDot = DOM.getById( '..(' + lPanel.id + ')'); + var lPanel = DOMProto.getPanel(true), + lDotDot = DOMProto.getById( '..(' + lPanel.id + ')'); - DOM.setCurrentFile ( lDotDot ); + DOMProto.setCurrentFile ( lDotDot ); CloudCommander.refresh(); }); } @@ -1736,14 +1750,14 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @pCurrent */ - DOM.copyCurrent = function(pCurrentFile){ - if( !DOM.isCurrentFile(pCurrentFile) ) + DOMProto.copyCurrent = function(pCurrentFile){ + if( !DOMProto.isCurrentFile(pCurrentFile) ) pCurrentFile = null; - var lCurrent = pCurrentFile || DOM.getCurrentFile(), - lName = DOM.getCurrentName(lCurrent), - lFromPath = DOM.getCurrentPath(), - lToPath = DOM.getNotCurrentDirPath() + lName; + var lCurrent = pCurrentFile || DOMProto.getCurrentFile(), + lName = DOMProto.getCurrentName(lCurrent), + lFromPath = DOMProto.getCurrentPath(), + lToPath = DOMProto.getNotCurrentDirPath() + lName; lToPath = prompt( 'Copy file "' + lName + '" to', lToPath ); if( lToPath && !Util.strCmp(lFromPath, lToPath) ){ @@ -1752,11 +1766,11 @@ var CloudCommander, Util, DOM = {}, CloudFunc; to : lToPath }; - DOM.RESTfull.cp(lFiles, function(){ - var lPanel = DOM.getPanel(true), - lDotDot = DOM.getById( '..(' + lPanel.id + ')'); + DOMProto.RESTfull.cp(lFiles, function(){ + var lPanel = DOMProto.getPanel(true), + lDotDot = DOMProto.getById( '..(' + lPanel.id + ')'); - DOM.setCurrentFile ( lDotDot ); + DOMProto.setCurrentFile ( lDotDot ); CloudCommander.refresh(); }); } @@ -1767,7 +1781,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * (native suporte by webkit only) * @param pElement */ - DOM.scrollIntoViewIfNeeded = function(pElement){ + DOMProto.scrollIntoViewIfNeeded = function(pElement){ var lRet = pElement && pElement.scrollIntoViewIfNeeded; if(lRet) @@ -1777,7 +1791,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; }; /* scroll on one page*/ - DOM.scrollByPages = function(pElement, pPages){ + DOMProto.scrollByPages = function(pElement, pPages){ var lRet = pElement && pElement.scrollByPages && pPages; if(lRet) @@ -1789,7 +1803,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; /** * function gets time */ - DOM.getTime = function(){ + DOMProto.getTime = function(){ var lRet, lDate = new Date(), lHours = lDate.getHours(), @@ -1804,4 +1818,4 @@ var CloudCommander, Util, DOM = {}, CloudFunc; return lRet; }; -})(Util, DOM); \ No newline at end of file +})(Util); \ No newline at end of file