author | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2011-10-03 16:04:12 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2011-10-03 16:04:12 (UTC) |
commit | 541bb378ddece2eab135a8066a16994e94436dea (patch) (side-by-side diff) | |
tree | ff160ea3e26f7fe07fcfd401387c5a0232ca715e /frontend/beta/js/YUI-extensions/CustomTagReader.js | |
parent | 1bf431fd3d45cbdf4afa3e12afefe5d24f4d3bc7 (diff) | |
parent | ecad5e895831337216544e81f1a467e0c68c4a6a (diff) | |
download | clipperz-541bb378ddece2eab135a8066a16994e94436dea.zip clipperz-541bb378ddece2eab135a8066a16994e94436dea.tar.gz clipperz-541bb378ddece2eab135a8066a16994e94436dea.tar.bz2 |
Merge pull request #1 from gcsolaroli/master
First version of the restructured repository
Diffstat (limited to 'frontend/beta/js/YUI-extensions/CustomTagReader.js') (more/less context) (show whitespace changes)
-rw-r--r-- | frontend/beta/js/YUI-extensions/CustomTagReader.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/frontend/beta/js/YUI-extensions/CustomTagReader.js b/frontend/beta/js/YUI-extensions/CustomTagReader.js new file mode 100644 index 0000000..12faaa9 --- a/dev/null +++ b/frontend/beta/js/YUI-extensions/CustomTagReader.js @@ -0,0 +1,40 @@ +/**
+ * @class YAHOO.ext.CustomTagReader
+ * Utility class to normalize reading of custom tags across browsers.
+ */
+YAHOO.ext.CustomTagReader = function(namespace){
+ this.namespace = namespace;
+};
+YAHOO.ext.CustomTagReader.prototype = {
+ getAttribute : function(el, name, defaultValue){
+ return (this.useNS ?
+ v = el.getAttributeNS(this.namespace, name) : null) ||
+ el.getAttribute(this.namespace+':'+name) ||
+ el.getAttribute(name);
+ },
+
+ getElements : function(tagName, targetEl){
+ targetEl = targetEl || document.body;
+ var els;
+ if(this.useNS){ // no namespaces in IE
+ els = targetEl.getElementsByTagNameNS(this.namespace, tagName);
+ }
+ if(!els || els.length < 1){ // ie6, firefox 1.5, firefox 2 depending on doc type
+ els = targetEl.getElementsByTagName(this.namespace+':'+tagName);
+ }
+ if(!els || els.length < 1){ // everyone else
+ els = targetEl.getElementsByTagName(tagName);
+ }
+ return els;
+ },
+
+ eachElement : function(tagName, targetEl, fn, scope){
+ var els = this.getElements(tagName, targetEl);
+ for(var i = 0, len = els.length; i < len; i++) {
+ var el = els[i];
+ fn.call(scope || el, el);
+ }
+ },
+
+ useNS : (!YAHOO.ext.util.Browser.isIE && document.getElementsByTagNameNS) ? true : false
+}; |