Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* options.js: adding options

  • Loading branch information...
commit 532a59092d7cf0e281ef272df1bb8b3091e99e59 1 parent 9efd6d4
David Nolen authored
Showing with 26 additions and 0 deletions.
  1. +26 −0 options.js
View
26 options.js
@@ -0,0 +1,26 @@
+(function() {
+
+ function attributes (el) {
+ var attrs = {},
+ attr;
+ el = (_.isElement(el)) ? el : el[0];
+ _(el.attributes.length).times(function(i) {
+ attr = el.attributes.item(i);
+ if(attr.specified) attrs[attr.name]=attr.value;
+ });
+ return attrs;
+ };
+
+ var root = this;
+ root.Options = _.Module({
+ name: "Options",
+ getOptions: function(el, prefix) {
+ prefix = "data-" + (prefix || "");
+ var r = new RegExp("^"+prefix);
+ return _(attributes(el)).filter(function(v, k) {
+ return k.search(r) != -1;
+ });
+ }
+ });
+
+})();
Please sign in to comment.
Something went wrong with that request. Please try again.