From c1cfd872a1eb90b084cfc02127dfead68a7734b0 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 10 Feb 2014 03:54:02 -0500 Subject: [PATCH] feature(dom) Images: improved access speed --- lib/client/dom.js | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index a34b1a62..d16d124c 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -13,20 +13,25 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; }, ImagesProto = function() { - var LImagesProto = function() { - function getImage(pName) { - var lId = pName + '-image', - lE = DOM.getById(lId); + var ImagesProto = function() { + var Images = { + 'image-loading' : null, + 'image-error' : null + }; + + function getImage(name) { + var id = 'image-' + name, + element = Images[id]; - if (!lE) - lE = DOM.anyload({ + if (!element) + element = Images[id] = DOM.anyload({ name : 'span', - className : 'icon ' + pName, - id : lId, + className : 'icon ' + name, + id : id, not_append : true }); - return lE; + return element; } /* Функция создаёт картинку загрузки */ @@ -39,7 +44,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; return getImage('error'); }; }, - lImages = new LImagesProto(); + Images = new ImagesProto(); /** * Function shows loading spinner * pPosition = {top: true}; @@ -47,8 +52,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; this.showLoad = function(position) { var top = position && position.top, current, - loadingImage = lImages.loading(), - errorImage = lImages.error(), + loadingImage = Images.loading(), + errorImage = Images.error(), parent = loadingImage.parentElement; DOM.hide(errorImage); @@ -72,7 +77,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; * hide load image */ this.hideLoad = function() { - DOM.hide(lImages.loading()); + DOM.hide(Images.loading()); }; /** @@ -80,8 +85,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; */ this.showError = function(jqXHR) { var func, - lLoadingImage = lImages.loading(), - lErrorImage = lImages.error(), + lLoadingImage = Images.loading(), + lErrorImage = Images.error(), lResponse = '', lStatusText = '', lStatus = 0,