From 2bd048249047ad7e8a3219f7e6409a1acc467445 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Fri, 31 May 2013 08:35:23 +0200 Subject: [PATCH] Add bower.json --- .gitattributes | 3 ++- .gitignore | 2 +- README.md | 28 ++++++++++++++++------------ bower.json | 11 +++++++++++ jquery.dataAttr.js | 11 +++-------- jquery.dataAttr.min.js | 9 ++------- 6 files changed, 35 insertions(+), 29 deletions(-) create mode 100644 bower.json diff --git a/.gitattributes b/.gitattributes index f5a0e1b..0a91f75 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ -* crlf=input \ No newline at end of file +# Automatically normalize line endings for all text-based files +* text=auto diff --git a/.gitignore b/.gitignore index 496ee2c..e43b0f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -.DS_Store \ No newline at end of file +.DS_Store diff --git a/README.md b/README.md index 5f2cedc..2d8287c 100644 --- a/README.md +++ b/README.md @@ -6,20 +6,24 @@ This plugin simplifies the use of HTML5 custom data attributes in your jQuery co ### HTML -

+```html +

+``` ### jQuery - // You can perfectly use this: - $('#foo').attr('data-time'); // '9 AM' - // But I prefer to do it this way, especially when dealing with a lot of data-* - $('#foo').dataAttr('time'); // '9 AM' - // Just like $.attr(), $.dataAttr() can be used as a setter - $('#foo').dataAttr('time', '3 PM'); - // Computed data-* attribute values are possible as well - $('p').dataAttr('id', function() { - return this.id; - }); // p data-id="foo" +``` +// You can perfectly use this: +$('#foo').attr('data-time'); // '9 AM' +// But I prefer to do it this way, especially when dealing with a lot of data-* +$('#foo').dataAttr('time'); // '9 AM' +// Just like $.attr(), $.dataAttr() can be used as a setter +$('#foo').dataAttr('time', '3 PM'); +// Computed data-* attribute values are possible as well +$('p').dataAttr('id', function() { + return this.id; +}); // p data-id="foo" +``` ## Useful? @@ -33,4 +37,4 @@ Since `.dataAttr('foo')` minifies to `.x('foo')`, while `.attr('data-foo')` mini ## Credits -_– [Mathias](http://mathiasbynens.be/)_ \ No newline at end of file +_– [Mathias](http://mathiasbynens.be/)_ diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..e5e6a75 --- /dev/null +++ b/bower.json @@ -0,0 +1,11 @@ +{ + "name": "jquery-custom-data-attributes", + "version": "1.0.0", + "main": "jquery.dataAttr.js", + "dependencies": { + "jquery": "<=1.4.1" + }, + "ignore": [ + ".*" + ] +} diff --git a/jquery.dataAttr.js b/jquery.dataAttr.js index 4cc0d35..3ab6b08 100644 --- a/jquery.dataAttr.js +++ b/jquery.dataAttr.js @@ -1,9 +1,4 @@ -/*! - * HTML5 custom data attributes plugin for jQuery v1.0 - * @link http://github.com/mathiasbynens/HTML5-custom-data-attributes-plugin-for-jQuery - * @description An easy setter/getter for HTML5 data-* attributes - * @author Mathias Bynens - */ -jQuery.fn.dataAttr = function(attr, val) { +/*! http://git.io/jcda v1.0.0 by @mathias */ +;jQuery.fn.dataAttr = function(attr, val) { return val ? this.attr('data-' + attr, val) : this.attr('data-' + attr); -}; \ No newline at end of file +}; diff --git a/jquery.dataAttr.min.js b/jquery.dataAttr.min.js index 5b44ab9..57f34e9 100644 --- a/jquery.dataAttr.min.js +++ b/jquery.dataAttr.min.js @@ -1,7 +1,2 @@ -/*! - * HTML5 custom data attributes plugin for jQuery v1.0 - * @link http://github.com/mathiasbynens/HTML5-custom-data-attributes-plugin-for-jQuery - * @description An easy setter/getter for HTML5 data-* attributes - * @author Mathias Bynens - */ -jQuery.fn.dataAttr=function(a,v){return v?this.attr('data-'+a,v):this.attr('data-'+a)}; \ No newline at end of file +/*! http://git.io/jcda v1.0.0 by @mathias */ +;jQuery.fn.dataAttr=function(a,b){return b?this.attr("data-"+a,b):this.attr("data-"+a)}; \ No newline at end of file