Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Hash: Add transition support

  • Loading branch information...
commit c74f6f4a2bc8c83e57449a2318e922a38a719700 1 parent 2f48de4
Rafael Xavier de Souza authored

Showing 1 changed file with 38 additions and 7 deletions. Show diff stats Hide diff stats

  1. +38 7 ui/jquery.ui.hash.js
45 ui/jquery.ui.hash.js
@@ -8,8 +8,8 @@
8 8 * http://docs.jquery.com/UI/Hash (to be created)
9 9 *
10 10 * Depends:
11   - * jquery.ui.core.js
12   - * jquery.ui.widget.js
  11 + * jquery.ui.core.js
  12 + * jquery.ui.widget.js
13 13 */
14 14 (function( $, undefined ) {
15 15
@@ -22,18 +22,49 @@ $.widget( "ui.hash", {
22 22 options: {
23 23 },
24 24
  25 + elements: function() {
  26 + var elements = $([]);
  27 + $.each(this.els, function() {
  28 + elements = elements.add(this);
  29 + });
  30 + return elements;
  31 + },
  32 +
25 33 set: function(key, el) {
  34 + el = $(el);
26 35 this.destroy(key);
27 36 this.els[key] = el;
  37 + if($.support.transition) {
  38 + el.addClass("fade");
  39 + }
28 40 },
29 41
30   - show: function(key) {
31   - this.clear();
32   - this.element.html(this.els[key]);
  42 + show: function(key, cb) {
  43 + var self = this;
  44 + this.clear(function() {
  45 + self.element.html(self.els[key]);
  46 + if($.support.transition) {
  47 + self.els[key].addClass("in");
  48 + }
  49 + if(cb) {
  50 + cb();
  51 + }
  52 + });
33 53 },
34 54
35   - clear: function(ev, key) {
36   - this.element.children().detach();
  55 + clear: function(cb) {
  56 + if($.support.transition && this.elements().hasClass("in")) {
  57 + var self = this;
  58 + this.elements().filter(".in")
  59 + .one($.support.transition.end, function(ev) {
  60 + self.element.children().detach();
  61 + cb && cb();
  62 + })
  63 + .removeClass("in");
  64 + } else {
  65 + this.element.children().detach();
  66 + cb && cb();
  67 + }
37 68 },
38 69
39 70 destroy: function(key) {

0 comments on commit c74f6f4

Please sign in to comment.
Something went wrong with that request. Please try again.