Skip to content

Commit

Permalink
Add bower.json
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasbynens committed May 31, 2013
1 parent 8a89c30 commit 2bd0482
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 29 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
@@ -1 +1,2 @@
* crlf=input # Automatically normalize line endings for all text-based files
* text=auto
2 changes: 1 addition & 1 deletion .gitignore
@@ -1 +1 @@
.DS_Store .DS_Store
28 changes: 16 additions & 12 deletions README.md
Expand Up @@ -6,20 +6,24 @@ This plugin simplifies the use of HTML5 custom data attributes in your jQuery co


### HTML ### HTML


<p id="foo" data-time="9 AM">…</p> ```html
<p id="foo" data-time="9 AM">…</p>
```


### jQuery ### jQuery


// You can perfectly use this: ```
$('#foo').attr('data-time'); // '9 AM' // You can perfectly use this:
// But I prefer to do it this way, especially when dealing with a lot of data-* $('#foo').attr('data-time'); // '9 AM'
$('#foo').dataAttr('time'); // '9 AM' // But I prefer to do it this way, especially when dealing with a lot of data-*
// Just like $.attr(), $.dataAttr() can be used as a setter $('#foo').dataAttr('time'); // '9 AM'
$('#foo').dataAttr('time', '3 PM'); // Just like $.attr(), $.dataAttr() can be used as a setter
// Computed data-* attribute values are possible as well $('#foo').dataAttr('time', '3 PM');
$('p').dataAttr('id', function() { // Computed data-* attribute values are possible as well
return this.id; $('p').dataAttr('id', function() {
}); // p data-id="foo" return this.id;
}); // p data-id="foo"
```


## Useful? ## Useful?


Expand All @@ -33,4 +37,4 @@ Since `.dataAttr('foo')` minifies to `.x('foo')`, while `.attr('data-foo')` mini


## Credits ## Credits


_[Mathias](http://mathiasbynens.be/)_ _[Mathias](http://mathiasbynens.be/)_
11 changes: 11 additions & 0 deletions 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": [
".*"
]
}
11 changes: 3 additions & 8 deletions jquery.dataAttr.js
@@ -1,9 +1,4 @@
/*! /*! http://git.io/jcda v1.0.0 by @mathias */
* HTML5 custom data attributes plugin for jQuery v1.0 ;jQuery.fn.dataAttr = function(attr, val) {
* @link http://github.com/mathiasbynens/HTML5-custom-data-attributes-plugin-for-jQuery
* @description An easy setter/getter for HTML5 data-* attributes
* @author Mathias Bynens <http://mathiasbynens.be/>
*/
jQuery.fn.dataAttr = function(attr, val) {
return val ? this.attr('data-' + attr, val) : this.attr('data-' + attr); return val ? this.attr('data-' + attr, val) : this.attr('data-' + attr);
}; };
9 changes: 2 additions & 7 deletions jquery.dataAttr.min.js
@@ -1,7 +1,2 @@
/*! /*! http://git.io/jcda v1.0.0 by @mathias */
* HTML5 custom data attributes plugin for jQuery v1.0 ;jQuery.fn.dataAttr=function(a,b){return b?this.attr("data-"+a,b):this.attr("data-"+a)};
* @link http://github.com/mathiasbynens/HTML5-custom-data-attributes-plugin-for-jQuery
* @description An easy setter/getter for HTML5 data-* attributes
* @author Mathias Bynens <http://mathiasbynens.be/>
*/
jQuery.fn.dataAttr=function(a,v){return v?this.attr('data-'+a,v):this.attr('data-'+a)};

0 comments on commit 2bd0482

Please sign in to comment.