Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Added data(attr) and data(attr, val) functions to jquery compat plugin #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jquery-compat/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
jQuery Compatibility Plug-In for XUI
-------------
Adds functions `add`, `end`, `show` and `hide`, for compatibility with jQuery.
Adds functions `add`, `end`, `show`, `hide` and `data`, for compatibility with jQuery.
63 changes: 38 additions & 25 deletions jquery-compat/jquery-compat.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,41 @@
xui.extend({
/**
* Adds more DOM nodes to the existing element list.
*/
add: function(q) {
[].push.apply(this, slice(xui(q)));
return this.set(this.reduce());
},
/**
* Adds more DOM nodes to the existing element list.
*/
add: function(q) {
[].push.apply(this, slice(xui(q)));
return this.set(this.reduce());
},

/**
* Pops the last selector from XUI
*/
end: function () {
return this.set(this.cache || []);
},
/**
* Sets the `display` CSS property to `block`.
*/
show:function() {
return this.setStyle('display','block');
},
/**
* Sets the `display` CSS property to `none`.
*/
hide:function() {
return this.setStyle('display','none');
}
/**
* Pops the last selector from XUI
*/
end: function () {
return this.set(this.cache || []);
},

/**
* Sets the `display` CSS property to `block`.
*/
show: function() {
return this.setStyle('display','block');
},

/**
* Sets the `display` CSS property to `none`.
*/
hide: function() {
return this.setStyle('display','none');
},

/**
* Gets or sets `data` attributes on elements.
*/
data: function(attr, val) {
if (arguments.length == 2) {
return this.attr('data-' + attr, val);
} else {
return this.attr('data-' + attr);
}
}
});