Skip to content

Commit

Permalink
Hash: Add transition support
Browse files Browse the repository at this point in the history
  • Loading branch information
rxaviers committed May 9, 2013
1 parent 2f48de4 commit c74f6f4
Showing 1 changed file with 38 additions and 7 deletions.
45 changes: 38 additions & 7 deletions ui/jquery.ui.hash.js
Expand Up @@ -8,8 +8,8 @@
* http://docs.jquery.com/UI/Hash (to be created) * http://docs.jquery.com/UI/Hash (to be created)
* *
* Depends: * Depends:
* jquery.ui.core.js * jquery.ui.core.js
* jquery.ui.widget.js * jquery.ui.widget.js
*/ */
(function( $, undefined ) { (function( $, undefined ) {


Expand All @@ -22,18 +22,49 @@ $.widget( "ui.hash", {
options: { options: {
}, },


elements: function() {
var elements = $([]);
$.each(this.els, function() {
elements = elements.add(this);
});
return elements;
},

set: function(key, el) { set: function(key, el) {
el = $(el);
this.destroy(key); this.destroy(key);
this.els[key] = el; this.els[key] = el;
if($.support.transition) {
el.addClass("fade");
}
}, },


show: function(key) { show: function(key, cb) {
this.clear(); var self = this;
this.element.html(this.els[key]); this.clear(function() {
self.element.html(self.els[key]);
if($.support.transition) {
self.els[key].addClass("in");
}
if(cb) {
cb();
}
});
}, },


clear: function(ev, key) { clear: function(cb) {
this.element.children().detach(); 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) { destroy: function(key) {
Expand Down

0 comments on commit c74f6f4

Please sign in to comment.