From 78037c944dd656f8445dd193abfb5e2e7a485b48 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 20 Feb 2014 04:54:42 -0500 Subject: [PATCH] feature(refactor) .js-left -> [data=js-left] --- html/path.html | 2 +- lib/client/dom.js | 27 ++++++++++++++++++++------- test/test.js | 2 +- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/html/path.html b/html/path.html index a2e79700..59a309f4 100644 --- a/html/path.html +++ b/html/path.html @@ -1 +1 @@ -
{{ path }}
\ No newline at end of file +
{{ path }}
\ No newline at end of file diff --git a/lib/client/dom.js b/lib/client/dom.js index cada95bd..7e53a599 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -319,6 +319,18 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; return ret; }; + this.getByAttr = function(attribute, element) { + var ret, + selector = '[' + 'data="' + attribute + '"]'; + + if (!element) + element = document; + + ret = element.querySelector(selector); + + return ret; + }; + /** * Function search element by class name * @param pClass - className @@ -768,15 +780,16 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; /** * get current direcotory path */ - this.getCurrentDirPath = function(pPanel) { - var lPanel = pPanel || this.getPanel(), - lPath = this.getByClass('js-path', lPanel), - lRet; + this.getCurrentDirPath = function(panel) { + var ret, path; - if (lPath) - lRet = lPath.textContent; + if (!panel) + panel = this.getPanel(), - return lRet; + path = this.getByAttr('js-path', panel); + ret = path && path.textContent; + + return ret; }; /** diff --git a/test/test.js b/test/test.js index 625fa5a3..ec18c584 100644 --- a/test/test.js +++ b/test/test.js @@ -34,7 +34,7 @@ Expect = - '
' + + '
' + '' + '' +