aboutsummaryrefslogtreecommitdiff
path: root/js/lib/NJUtils.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/NJUtils.js')
-rwxr-xr-xjs/lib/NJUtils.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js
index 5aaeb5f2..90aebb84 100755
--- a/js/lib/NJUtils.js
+++ b/js/lib/NJUtils.js
@@ -18,16 +18,18 @@ exports.NJUtils = Montage.create(Component, {
18 18
19 ///// Quick "getElementById" 19 ///// Quick "getElementById"
20 $ : { 20 $ : {
21 value: function(id) { 21 value: function(id, doc) {
22 return document.getElementById(id); 22 doc = doc || document;
23 return doc.getElementById(id);
23 } 24 }
24 }, 25 },
25 26
26 ///// Quick "getElementsByClassName" which also returns as an Array 27 ///// Quick "getElementsByClassName" which also returns as an Array
27 ///// Can return as NodeList by passing true as second argument 28 ///// Can return as NodeList by passing true as second argument
28 $$ : { 29 $$ : {
29 value: function(className, asNodeList) { 30 value: function(className, asNodeList, doc) {
30 var list = document.getElementsByClassName(className); 31 doc = doc || document;
32 var list = doc.getElementsByClassName(className);
31 return (asNodeList) ? list : this.toArray(list); 33 return (asNodeList) ? list : this.toArray(list);
32 } 34 }
33 }, 35 },