Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Hash: Add transition support

  • Loading branch information...
commit c74f6f4a2bc8c83e57449a2318e922a38a719700 1 parent 2f48de4
Rafael Xavier de Souza authored
Showing with 38 additions and 7 deletions.
  1. +38 −7 ui/jquery.ui.hash.js
45 ui/jquery.ui.hash.js
View
@@ -8,8 +8,8 @@
* http://docs.jquery.com/UI/Hash (to be created)
*
* Depends:
- * jquery.ui.core.js
- * jquery.ui.widget.js
+ * jquery.ui.core.js
+ * jquery.ui.widget.js
*/
(function( $, undefined ) {
@@ -22,18 +22,49 @@ $.widget( "ui.hash", {
options: {
},
+ elements: function() {
+ var elements = $([]);
+ $.each(this.els, function() {
+ elements = elements.add(this);
+ });
+ return elements;
+ },
+
set: function(key, el) {
+ el = $(el);
this.destroy(key);
this.els[key] = el;
+ if($.support.transition) {
+ el.addClass("fade");
+ }
},
- show: function(key) {
- this.clear();
- this.element.html(this.els[key]);
+ show: function(key, cb) {
+ var self = this;
+ this.clear(function() {
+ self.element.html(self.els[key]);
+ if($.support.transition) {
+ self.els[key].addClass("in");
+ }
+ if(cb) {
+ cb();
+ }
+ });
},
- clear: function(ev, key) {
- this.element.children().detach();
+ clear: function(cb) {
+ if($.support.transition && this.elements().hasClass("in")) {
+ var self = this;
+ this.elements().filter(".in")
+ .one($.support.transition.end, function(ev) {
+ self.element.children().detach();
+ cb && cb();
+ })
+ .removeClass("in");
+ } else {
+ this.element.children().detach();
+ cb && cb();
+ }
},
destroy: function(key) {
Please sign in to comment.
Something went wrong with that request. Please try again.