[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/resources/lib/jquery.ui/ -> jquery.ui.effect.js (source)

   1  /*!
   2   * jQuery UI Effects 1.9.2
   3   * http://jqueryui.com
   4   *
   5   * Copyright 2012 jQuery Foundation and other contributors
   6   * Released under the MIT license.
   7   * http://jquery.org/license
   8   *
   9   * http://api.jqueryui.com/category/effects-core/
  10   */
  11  ;(jQuery.effects || (function($, undefined) {
  12  
  13  var backCompat = $.uiBackCompat !== false,
  14      // prefix used for storing data on .data()
  15      dataSpace = "ui-effects-";
  16  
  17  $.effects = {
  18      effect: {}
  19  };
  20  
  21  /*!
  22   * jQuery Color Animations v2.0.0
  23   * http://jquery.com/
  24   *
  25   * Copyright 2012 jQuery Foundation and other contributors
  26   * Released under the MIT license.
  27   * http://jquery.org/license
  28   *
  29   * Date: Mon Aug 13 13:41:02 2012 -0500
  30   */
  31  (function( jQuery, undefined ) {
  32  
  33      var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor".split(" "),
  34  
  35      // plusequals test for += 100 -= 100
  36      rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  37      // a set of RE's that can match strings and generate color tuples.
  38      stringParsers = [{
  39              re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
  40              parse: function( execResult ) {
  41                  return [
  42                      execResult[ 1 ],
  43                      execResult[ 2 ],
  44                      execResult[ 3 ],
  45                      execResult[ 4 ]
  46                  ];
  47              }
  48          }, {
  49              re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
  50              parse: function( execResult ) {
  51                  return [
  52                      execResult[ 1 ] * 2.55,
  53                      execResult[ 2 ] * 2.55,
  54                      execResult[ 3 ] * 2.55,
  55                      execResult[ 4 ]
  56                  ];
  57              }
  58          }, {
  59              // this regex ignores A-F because it's compared against an already lowercased string
  60              re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  61              parse: function( execResult ) {
  62                  return [
  63                      parseInt( execResult[ 1 ], 16 ),
  64                      parseInt( execResult[ 2 ], 16 ),
  65                      parseInt( execResult[ 3 ], 16 )
  66                  ];
  67              }
  68          }, {
  69              // this regex ignores A-F because it's compared against an already lowercased string
  70              re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  71              parse: function( execResult ) {
  72                  return [
  73                      parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  74                      parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  75                      parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  76                  ];
  77              }
  78          }, {
  79              re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
  80              space: "hsla",
  81              parse: function( execResult ) {
  82                  return [
  83                      execResult[ 1 ],
  84                      execResult[ 2 ] / 100,
  85                      execResult[ 3 ] / 100,
  86                      execResult[ 4 ]
  87                  ];
  88              }
  89          }],
  90  
  91      // jQuery.Color( )
  92      color = jQuery.Color = function( color, green, blue, alpha ) {
  93          return new jQuery.Color.fn.parse( color, green, blue, alpha );
  94      },
  95      spaces = {
  96          rgba: {
  97              props: {
  98                  red: {
  99                      idx: 0,
 100                      type: "byte"
 101                  },
 102                  green: {
 103                      idx: 1,
 104                      type: "byte"
 105                  },
 106                  blue: {
 107                      idx: 2,
 108                      type: "byte"
 109                  }
 110              }
 111          },
 112  
 113          hsla: {
 114              props: {
 115                  hue: {
 116                      idx: 0,
 117                      type: "degrees"
 118                  },
 119                  saturation: {
 120                      idx: 1,
 121                      type: "percent"
 122                  },
 123                  lightness: {
 124                      idx: 2,
 125                      type: "percent"
 126                  }
 127              }
 128          }
 129      },
 130      propTypes = {
 131          "byte": {
 132              floor: true,
 133              max: 255
 134          },
 135          "percent": {
 136              max: 1
 137          },
 138          "degrees": {
 139              mod: 360,
 140              floor: true
 141          }
 142      },
 143      support = color.support = {},
 144  
 145      // element for support tests
 146      supportElem = jQuery( "<p>" )[ 0 ],
 147  
 148      // colors = jQuery.Color.names
 149      colors,
 150  
 151      // local aliases of functions called often
 152      each = jQuery.each;
 153  
 154  // determine rgba support immediately
 155  supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
 156  support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
 157  
 158  // define cache name and alpha properties
 159  // for rgba and hsla spaces
 160  each( spaces, function( spaceName, space ) {
 161      space.cache = "_" + spaceName;
 162      space.props.alpha = {
 163          idx: 3,
 164          type: "percent",
 165          def: 1
 166      };
 167  });
 168  
 169  function clamp( value, prop, allowEmpty ) {
 170      var type = propTypes[ prop.type ] || {};
 171  
 172      if ( value == null ) {
 173          return (allowEmpty || !prop.def) ? null : prop.def;
 174      }
 175  
 176      // ~~ is an short way of doing floor for positive numbers
 177      value = type.floor ? ~~value : parseFloat( value );
 178  
 179      // IE will pass in empty strings as value for alpha,
 180      // which will hit this case
 181      if ( isNaN( value ) ) {
 182          return prop.def;
 183      }
 184  
 185      if ( type.mod ) {
 186          // we add mod before modding to make sure that negatives values
 187          // get converted properly: -10 -> 350
 188          return (value + type.mod) % type.mod;
 189      }
 190  
 191      // for now all property types without mod have min and max
 192      return 0 > value ? 0 : type.max < value ? type.max : value;
 193  }
 194  
 195  function stringParse( string ) {
 196      var inst = color(),
 197          rgba = inst._rgba = [];
 198  
 199      string = string.toLowerCase();
 200  
 201      each( stringParsers, function( i, parser ) {
 202          var parsed,
 203              match = parser.re.exec( string ),
 204              values = match && parser.parse( match ),
 205              spaceName = parser.space || "rgba";
 206  
 207          if ( values ) {
 208              parsed = inst[ spaceName ]( values );
 209  
 210              // if this was an rgba parse the assignment might happen twice
 211              // oh well....
 212              inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
 213              rgba = inst._rgba = parsed._rgba;
 214  
 215              // exit each( stringParsers ) here because we matched
 216              return false;
 217          }
 218      });
 219  
 220      // Found a stringParser that handled it
 221      if ( rgba.length ) {
 222  
 223          // if this came from a parsed string, force "transparent" when alpha is 0
 224          // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
 225          if ( rgba.join() === "0,0,0,0" ) {
 226              jQuery.extend( rgba, colors.transparent );
 227          }
 228          return inst;
 229      }
 230  
 231      // named colors
 232      return colors[ string ];
 233  }
 234  
 235  color.fn = jQuery.extend( color.prototype, {
 236      parse: function( red, green, blue, alpha ) {
 237          if ( red === undefined ) {
 238              this._rgba = [ null, null, null, null ];
 239              return this;
 240          }
 241          if ( red.jquery || red.nodeType ) {
 242              red = jQuery( red ).css( green );
 243              green = undefined;
 244          }
 245  
 246          var inst = this,
 247              type = jQuery.type( red ),
 248              rgba = this._rgba = [];
 249  
 250          // more than 1 argument specified - assume ( red, green, blue, alpha )
 251          if ( green !== undefined ) {
 252              red = [ red, green, blue, alpha ];
 253              type = "array";
 254          }
 255  
 256          if ( type === "string" ) {
 257              return this.parse( stringParse( red ) || colors._default );
 258          }
 259  
 260          if ( type === "array" ) {
 261              each( spaces.rgba.props, function( key, prop ) {
 262                  rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
 263              });
 264              return this;
 265          }
 266  
 267          if ( type === "object" ) {
 268              if ( red instanceof color ) {
 269                  each( spaces, function( spaceName, space ) {
 270                      if ( red[ space.cache ] ) {
 271                          inst[ space.cache ] = red[ space.cache ].slice();
 272                      }
 273                  });
 274              } else {
 275                  each( spaces, function( spaceName, space ) {
 276                      var cache = space.cache;
 277                      each( space.props, function( key, prop ) {
 278  
 279                          // if the cache doesn't exist, and we know how to convert
 280                          if ( !inst[ cache ] && space.to ) {
 281  
 282                              // if the value was null, we don't need to copy it
 283                              // if the key was alpha, we don't need to copy it either
 284                              if ( key === "alpha" || red[ key ] == null ) {
 285                                  return;
 286                              }
 287                              inst[ cache ] = space.to( inst._rgba );
 288                          }
 289  
 290                          // this is the only case where we allow nulls for ALL properties.
 291                          // call clamp with alwaysAllowEmpty
 292                          inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
 293                      });
 294  
 295                      // everything defined but alpha?
 296                      if ( inst[ cache ] && $.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
 297                          // use the default of 1
 298                          inst[ cache ][ 3 ] = 1;
 299                          if ( space.from ) {
 300                              inst._rgba = space.from( inst[ cache ] );
 301                          }
 302                      }
 303                  });
 304              }
 305              return this;
 306          }
 307      },
 308      is: function( compare ) {
 309          var is = color( compare ),
 310              same = true,
 311              inst = this;
 312  
 313          each( spaces, function( _, space ) {
 314              var localCache,
 315                  isCache = is[ space.cache ];
 316              if (isCache) {
 317                  localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
 318                  each( space.props, function( _, prop ) {
 319                      if ( isCache[ prop.idx ] != null ) {
 320                          same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
 321                          return same;
 322                      }
 323                  });
 324              }
 325              return same;
 326          });
 327          return same;
 328      },
 329      _space: function() {
 330          var used = [],
 331              inst = this;
 332          each( spaces, function( spaceName, space ) {
 333              if ( inst[ space.cache ] ) {
 334                  used.push( spaceName );
 335              }
 336          });
 337          return used.pop();
 338      },
 339      transition: function( other, distance ) {
 340          var end = color( other ),
 341              spaceName = end._space(),
 342              space = spaces[ spaceName ],
 343              startColor = this.alpha() === 0 ? color( "transparent" ) : this,
 344              start = startColor[ space.cache ] || space.to( startColor._rgba ),
 345              result = start.slice();
 346  
 347          end = end[ space.cache ];
 348          each( space.props, function( key, prop ) {
 349              var index = prop.idx,
 350                  startValue = start[ index ],
 351                  endValue = end[ index ],
 352                  type = propTypes[ prop.type ] || {};
 353  
 354              // if null, don't override start value
 355              if ( endValue === null ) {
 356                  return;
 357              }
 358              // if null - use end
 359              if ( startValue === null ) {
 360                  result[ index ] = endValue;
 361              } else {
 362                  if ( type.mod ) {
 363                      if ( endValue - startValue > type.mod / 2 ) {
 364                          startValue += type.mod;
 365                      } else if ( startValue - endValue > type.mod / 2 ) {
 366                          startValue -= type.mod;
 367                      }
 368                  }
 369                  result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
 370              }
 371          });
 372          return this[ spaceName ]( result );
 373      },
 374      blend: function( opaque ) {
 375          // if we are already opaque - return ourself
 376          if ( this._rgba[ 3 ] === 1 ) {
 377              return this;
 378          }
 379  
 380          var rgb = this._rgba.slice(),
 381              a = rgb.pop(),
 382              blend = color( opaque )._rgba;
 383  
 384          return color( jQuery.map( rgb, function( v, i ) {
 385              return ( 1 - a ) * blend[ i ] + a * v;
 386          }));
 387      },
 388      toRgbaString: function() {
 389          var prefix = "rgba(",
 390              rgba = jQuery.map( this._rgba, function( v, i ) {
 391                  return v == null ? ( i > 2 ? 1 : 0 ) : v;
 392              });
 393  
 394          if ( rgba[ 3 ] === 1 ) {
 395              rgba.pop();
 396              prefix = "rgb(";
 397          }
 398  
 399          return prefix + rgba.join() + ")";
 400      },
 401      toHslaString: function() {
 402          var prefix = "hsla(",
 403              hsla = jQuery.map( this.hsla(), function( v, i ) {
 404                  if ( v == null ) {
 405                      v = i > 2 ? 1 : 0;
 406                  }
 407  
 408                  // catch 1 and 2
 409                  if ( i && i < 3 ) {
 410                      v = Math.round( v * 100 ) + "%";
 411                  }
 412                  return v;
 413              });
 414  
 415          if ( hsla[ 3 ] === 1 ) {
 416              hsla.pop();
 417              prefix = "hsl(";
 418          }
 419          return prefix + hsla.join() + ")";
 420      },
 421      toHexString: function( includeAlpha ) {
 422          var rgba = this._rgba.slice(),
 423              alpha = rgba.pop();
 424  
 425          if ( includeAlpha ) {
 426              rgba.push( ~~( alpha * 255 ) );
 427          }
 428  
 429          return "#" + jQuery.map( rgba, function( v ) {
 430  
 431              // default to 0 when nulls exist
 432              v = ( v || 0 ).toString( 16 );
 433              return v.length === 1 ? "0" + v : v;
 434          }).join("");
 435      },
 436      toString: function() {
 437          return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
 438      }
 439  });
 440  color.fn.parse.prototype = color.fn;
 441  
 442  // hsla conversions adapted from:
 443  // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
 444  
 445  function hue2rgb( p, q, h ) {
 446      h = ( h + 1 ) % 1;
 447      if ( h * 6 < 1 ) {
 448          return p + (q - p) * h * 6;
 449      }
 450      if ( h * 2 < 1) {
 451          return q;
 452      }
 453      if ( h * 3 < 2 ) {
 454          return p + (q - p) * ((2/3) - h) * 6;
 455      }
 456      return p;
 457  }
 458  
 459  spaces.hsla.to = function ( rgba ) {
 460      if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
 461          return [ null, null, null, rgba[ 3 ] ];
 462      }
 463      var r = rgba[ 0 ] / 255,
 464          g = rgba[ 1 ] / 255,
 465          b = rgba[ 2 ] / 255,
 466          a = rgba[ 3 ],
 467          max = Math.max( r, g, b ),
 468          min = Math.min( r, g, b ),
 469          diff = max - min,
 470          add = max + min,
 471          l = add * 0.5,
 472          h, s;
 473  
 474      if ( min === max ) {
 475          h = 0;
 476      } else if ( r === max ) {
 477          h = ( 60 * ( g - b ) / diff ) + 360;
 478      } else if ( g === max ) {
 479          h = ( 60 * ( b - r ) / diff ) + 120;
 480      } else {
 481          h = ( 60 * ( r - g ) / diff ) + 240;
 482      }
 483  
 484      if ( l === 0 || l === 1 ) {
 485          s = l;
 486      } else if ( l <= 0.5 ) {
 487          s = diff / add;
 488      } else {
 489          s = diff / ( 2 - add );
 490      }
 491      return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
 492  };
 493  
 494  spaces.hsla.from = function ( hsla ) {
 495      if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
 496          return [ null, null, null, hsla[ 3 ] ];
 497      }
 498      var h = hsla[ 0 ] / 360,
 499          s = hsla[ 1 ],
 500          l = hsla[ 2 ],
 501          a = hsla[ 3 ],
 502          q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
 503          p = 2 * l - q;
 504  
 505      return [
 506          Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
 507          Math.round( hue2rgb( p, q, h ) * 255 ),
 508          Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
 509          a
 510      ];
 511  };
 512  
 513  
 514  each( spaces, function( spaceName, space ) {
 515      var props = space.props,
 516          cache = space.cache,
 517          to = space.to,
 518          from = space.from;
 519  
 520      // makes rgba() and hsla()
 521      color.fn[ spaceName ] = function( value ) {
 522  
 523          // generate a cache for this space if it doesn't exist
 524          if ( to && !this[ cache ] ) {
 525              this[ cache ] = to( this._rgba );
 526          }
 527          if ( value === undefined ) {
 528              return this[ cache ].slice();
 529          }
 530  
 531          var ret,
 532              type = jQuery.type( value ),
 533              arr = ( type === "array" || type === "object" ) ? value : arguments,
 534              local = this[ cache ].slice();
 535  
 536          each( props, function( key, prop ) {
 537              var val = arr[ type === "object" ? key : prop.idx ];
 538              if ( val == null ) {
 539                  val = local[ prop.idx ];
 540              }
 541              local[ prop.idx ] = clamp( val, prop );
 542          });
 543  
 544          if ( from ) {
 545              ret = color( from( local ) );
 546              ret[ cache ] = local;
 547              return ret;
 548          } else {
 549              return color( local );
 550          }
 551      };
 552  
 553      // makes red() green() blue() alpha() hue() saturation() lightness()
 554      each( props, function( key, prop ) {
 555          // alpha is included in more than one space
 556          if ( color.fn[ key ] ) {
 557              return;
 558          }
 559          color.fn[ key ] = function( value ) {
 560              var vtype = jQuery.type( value ),
 561                  fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
 562                  local = this[ fn ](),
 563                  cur = local[ prop.idx ],
 564                  match;
 565  
 566              if ( vtype === "undefined" ) {
 567                  return cur;
 568              }
 569  
 570              if ( vtype === "function" ) {
 571                  value = value.call( this, cur );
 572                  vtype = jQuery.type( value );
 573              }
 574              if ( value == null && prop.empty ) {
 575                  return this;
 576              }
 577              if ( vtype === "string" ) {
 578                  match = rplusequals.exec( value );
 579                  if ( match ) {
 580                      value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
 581                  }
 582              }
 583              local[ prop.idx ] = value;
 584              return this[ fn ]( local );
 585          };
 586      });
 587  });
 588  
 589  // add .fx.step functions
 590  each( stepHooks, function( i, hook ) {
 591      jQuery.cssHooks[ hook ] = {
 592          set: function( elem, value ) {
 593              var parsed, curElem,
 594                  backgroundColor = "";
 595  
 596              if ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) {
 597                  value = color( parsed || value );
 598                  if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
 599                      curElem = hook === "backgroundColor" ? elem.parentNode : elem;
 600                      while (
 601                          (backgroundColor === "" || backgroundColor === "transparent") &&
 602                          curElem && curElem.style
 603                      ) {
 604                          try {
 605                              backgroundColor = jQuery.css( curElem, "backgroundColor" );
 606                              curElem = curElem.parentNode;
 607                          } catch ( e ) {
 608                          }
 609                      }
 610  
 611                      value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
 612                          backgroundColor :
 613                          "_default" );
 614                  }
 615  
 616                  value = value.toRgbaString();
 617              }
 618              try {
 619                  elem.style[ hook ] = value;
 620              } catch( error ) {
 621                  // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
 622              }
 623          }
 624      };
 625      jQuery.fx.step[ hook ] = function( fx ) {
 626          if ( !fx.colorInit ) {
 627              fx.start = color( fx.elem, hook );
 628              fx.end = color( fx.end );
 629              fx.colorInit = true;
 630          }
 631          jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
 632      };
 633  });
 634  
 635  jQuery.cssHooks.borderColor = {
 636      expand: function( value ) {
 637          var expanded = {};
 638  
 639          each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
 640              expanded[ "border" + part + "Color" ] = value;
 641          });
 642          return expanded;
 643      }
 644  };
 645  
 646  // Basic color names only.
 647  // Usage of any of the other color names requires adding yourself or including
 648  // jquery.color.svg-names.js.
 649  colors = jQuery.Color.names = {
 650      // 4.1. Basic color keywords
 651      aqua: "#00ffff",
 652      black: "#000000",
 653      blue: "#0000ff",
 654      fuchsia: "#ff00ff",
 655      gray: "#808080",
 656      green: "#008000",
 657      lime: "#00ff00",
 658      maroon: "#800000",
 659      navy: "#000080",
 660      olive: "#808000",
 661      purple: "#800080",
 662      red: "#ff0000",
 663      silver: "#c0c0c0",
 664      teal: "#008080",
 665      white: "#ffffff",
 666      yellow: "#ffff00",
 667  
 668      // 4.2.3. "transparent" color keyword
 669      transparent: [ null, null, null, 0 ],
 670  
 671      _default: "#ffffff"
 672  };
 673  
 674  })( jQuery );
 675  
 676  
 677  
 678  /******************************************************************************/
 679  /****************************** CLASS ANIMATIONS ******************************/
 680  /******************************************************************************/
 681  (function() {
 682  
 683  var classAnimationActions = [ "add", "remove", "toggle" ],
 684      shorthandStyles = {
 685          border: 1,
 686          borderBottom: 1,
 687          borderColor: 1,
 688          borderLeft: 1,
 689          borderRight: 1,
 690          borderTop: 1,
 691          borderWidth: 1,
 692          margin: 1,
 693          padding: 1
 694      };
 695  
 696  $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
 697      $.fx.step[ prop ] = function( fx ) {
 698          if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
 699              jQuery.style( fx.elem, prop, fx.end );
 700              fx.setAttr = true;
 701          }
 702      };
 703  });
 704  
 705  function getElementStyles() {
 706      var style = this.ownerDocument.defaultView ?
 707              this.ownerDocument.defaultView.getComputedStyle( this, null ) :
 708              this.currentStyle,
 709          newStyle = {},
 710          key,
 711          len;
 712  
 713      // webkit enumerates style porperties
 714      if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
 715          len = style.length;
 716          while ( len-- ) {
 717              key = style[ len ];
 718              if ( typeof style[ key ] === "string" ) {
 719                  newStyle[ $.camelCase( key ) ] = style[ key ];
 720              }
 721          }
 722      } else {
 723          for ( key in style ) {
 724              if ( typeof style[ key ] === "string" ) {
 725                  newStyle[ key ] = style[ key ];
 726              }
 727          }
 728      }
 729  
 730      return newStyle;
 731  }
 732  
 733  
 734  function styleDifference( oldStyle, newStyle ) {
 735      var diff = {},
 736          name, value;
 737  
 738      for ( name in newStyle ) {
 739          value = newStyle[ name ];
 740          if ( oldStyle[ name ] !== value ) {
 741              if ( !shorthandStyles[ name ] ) {
 742                  if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
 743                      diff[ name ] = value;
 744                  }
 745              }
 746          }
 747      }
 748  
 749      return diff;
 750  }
 751  
 752  $.effects.animateClass = function( value, duration, easing, callback ) {
 753      var o = $.speed( duration, easing, callback );
 754  
 755      return this.queue( function() {
 756          var animated = $( this ),
 757              baseClass = animated.attr( "class" ) || "",
 758              applyClassChange,
 759              allAnimations = o.children ? animated.find( "*" ).andSelf() : animated;
 760  
 761          // map the animated objects to store the original styles.
 762          allAnimations = allAnimations.map(function() {
 763              var el = $( this );
 764              return {
 765                  el: el,
 766                  start: getElementStyles.call( this )
 767              };
 768          });
 769  
 770          // apply class change
 771          applyClassChange = function() {
 772              $.each( classAnimationActions, function(i, action) {
 773                  if ( value[ action ] ) {
 774                      animated[ action + "Class" ]( value[ action ] );
 775                  }
 776              });
 777          };
 778          applyClassChange();
 779  
 780          // map all animated objects again - calculate new styles and diff
 781          allAnimations = allAnimations.map(function() {
 782              this.end = getElementStyles.call( this.el[ 0 ] );
 783              this.diff = styleDifference( this.start, this.end );
 784              return this;
 785          });
 786  
 787          // apply original class
 788          animated.attr( "class", baseClass );
 789  
 790          // map all animated objects again - this time collecting a promise
 791          allAnimations = allAnimations.map(function() {
 792              var styleInfo = this,
 793                  dfd = $.Deferred(),
 794                  opts = jQuery.extend({}, o, {
 795                      queue: false,
 796                      complete: function() {
 797                          dfd.resolve( styleInfo );
 798                      }
 799                  });
 800  
 801              this.el.animate( this.diff, opts );
 802              return dfd.promise();
 803          });
 804  
 805          // once all animations have completed:
 806          $.when.apply( $, allAnimations.get() ).done(function() {
 807  
 808              // set the final class
 809              applyClassChange();
 810  
 811              // for each animated element,
 812              // clear all css properties that were animated
 813              $.each( arguments, function() {
 814                  var el = this.el;
 815                  $.each( this.diff, function(key) {
 816                      el.css( key, '' );
 817                  });
 818              });
 819  
 820              // this is guarnteed to be there if you use jQuery.speed()
 821              // it also handles dequeuing the next anim...
 822              o.complete.call( animated[ 0 ] );
 823          });
 824      });
 825  };
 826  
 827  $.fn.extend({
 828      _addClass: $.fn.addClass,
 829      addClass: function( classNames, speed, easing, callback ) {
 830          return speed ?
 831              $.effects.animateClass.call( this,
 832                  { add: classNames }, speed, easing, callback ) :
 833              this._addClass( classNames );
 834      },
 835  
 836      _removeClass: $.fn.removeClass,
 837      removeClass: function( classNames, speed, easing, callback ) {
 838          return speed ?
 839              $.effects.animateClass.call( this,
 840                  { remove: classNames }, speed, easing, callback ) :
 841              this._removeClass( classNames );
 842      },
 843  
 844      _toggleClass: $.fn.toggleClass,
 845      toggleClass: function( classNames, force, speed, easing, callback ) {
 846          if ( typeof force === "boolean" || force === undefined ) {
 847              if ( !speed ) {
 848                  // without speed parameter
 849                  return this._toggleClass( classNames, force );
 850              } else {
 851                  return $.effects.animateClass.call( this,
 852                      (force ? { add: classNames } : { remove: classNames }),
 853                      speed, easing, callback );
 854              }
 855          } else {
 856              // without force parameter
 857              return $.effects.animateClass.call( this,
 858                  { toggle: classNames }, force, speed, easing );
 859          }
 860      },
 861  
 862      switchClass: function( remove, add, speed, easing, callback) {
 863          return $.effects.animateClass.call( this, {
 864              add: add,
 865              remove: remove
 866          }, speed, easing, callback );
 867      }
 868  });
 869  
 870  })();
 871  
 872  /******************************************************************************/
 873  /*********************************** EFFECTS **********************************/
 874  /******************************************************************************/
 875  
 876  (function() {
 877  
 878  $.extend( $.effects, {
 879      version: "1.9.2",
 880  
 881      // Saves a set of properties in a data storage
 882      save: function( element, set ) {
 883          for( var i=0; i < set.length; i++ ) {
 884              if ( set[ i ] !== null ) {
 885                  element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
 886              }
 887          }
 888      },
 889  
 890      // Restores a set of previously saved properties from a data storage
 891      restore: function( element, set ) {
 892          var val, i;
 893          for( i=0; i < set.length; i++ ) {
 894              if ( set[ i ] !== null ) {
 895                  val = element.data( dataSpace + set[ i ] );
 896                  // support: jQuery 1.6.2
 897                  // http://bugs.jquery.com/ticket/9917
 898                  // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
 899                  // We can't differentiate between "" and 0 here, so we just assume
 900                  // empty string since it's likely to be a more common value...
 901                  if ( val === undefined ) {
 902                      val = "";
 903                  }
 904                  element.css( set[ i ], val );
 905              }
 906          }
 907      },
 908  
 909      setMode: function( el, mode ) {
 910          if (mode === "toggle") {
 911              mode = el.is( ":hidden" ) ? "show" : "hide";
 912          }
 913          return mode;
 914      },
 915  
 916      // Translates a [top,left] array into a baseline value
 917      // this should be a little more flexible in the future to handle a string & hash
 918      getBaseline: function( origin, original ) {
 919          var y, x;
 920          switch ( origin[ 0 ] ) {
 921              case "top": y = 0; break;
 922              case "middle": y = 0.5; break;
 923              case "bottom": y = 1; break;
 924              default: y = origin[ 0 ] / original.height;
 925          }
 926          switch ( origin[ 1 ] ) {
 927              case "left": x = 0; break;
 928              case "center": x = 0.5; break;
 929              case "right": x = 1; break;
 930              default: x = origin[ 1 ] / original.width;
 931          }
 932          return {
 933              x: x,
 934              y: y
 935          };
 936      },
 937  
 938      // Wraps the element around a wrapper that copies position properties
 939      createWrapper: function( element ) {
 940  
 941          // if the element is already wrapped, return it
 942          if ( element.parent().is( ".ui-effects-wrapper" )) {
 943              return element.parent();
 944          }
 945  
 946          // wrap the element
 947          var props = {
 948                  width: element.outerWidth(true),
 949                  height: element.outerHeight(true),
 950                  "float": element.css( "float" )
 951              },
 952              wrapper = $( "<div></div>" )
 953                  .addClass( "ui-effects-wrapper" )
 954                  .css({
 955                      fontSize: "100%",
 956                      background: "transparent",
 957                      border: "none",
 958                      margin: 0,
 959                      padding: 0
 960                  }),
 961              // Store the size in case width/height are defined in % - Fixes #5245
 962              size = {
 963                  width: element.width(),
 964                  height: element.height()
 965              },
 966              active = document.activeElement;
 967  
 968          // support: Firefox
 969          // Firefox incorrectly exposes anonymous content
 970          // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
 971          try {
 972              active.id;
 973          } catch( e ) {
 974              active = document.body;
 975          }
 976  
 977          element.wrap( wrapper );
 978  
 979          // Fixes #7595 - Elements lose focus when wrapped.
 980          if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
 981              $( active ).focus();
 982          }
 983  
 984          wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
 985  
 986          // transfer positioning properties to the wrapper
 987          if ( element.css( "position" ) === "static" ) {
 988              wrapper.css({ position: "relative" });
 989              element.css({ position: "relative" });
 990          } else {
 991              $.extend( props, {
 992                  position: element.css( "position" ),
 993                  zIndex: element.css( "z-index" )
 994              });
 995              $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
 996                  props[ pos ] = element.css( pos );
 997                  if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
 998                      props[ pos ] = "auto";
 999                  }
1000              });
1001              element.css({
1002                  position: "relative",
1003                  top: 0,
1004                  left: 0,
1005                  right: "auto",
1006                  bottom: "auto"
1007              });
1008          }
1009          element.css(size);
1010  
1011          return wrapper.css( props ).show();
1012      },
1013  
1014      removeWrapper: function( element ) {
1015          var active = document.activeElement;
1016  
1017          if ( element.parent().is( ".ui-effects-wrapper" ) ) {
1018              element.parent().replaceWith( element );
1019  
1020              // Fixes #7595 - Elements lose focus when wrapped.
1021              if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
1022                  $( active ).focus();
1023              }
1024          }
1025  
1026  
1027          return element;
1028      },
1029  
1030      setTransition: function( element, list, factor, value ) {
1031          value = value || {};
1032          $.each( list, function( i, x ) {
1033              var unit = element.cssUnit( x );
1034              if ( unit[ 0 ] > 0 ) {
1035                  value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
1036              }
1037          });
1038          return value;
1039      }
1040  });
1041  
1042  // return an effect options object for the given parameters:
1043  function _normalizeArguments( effect, options, speed, callback ) {
1044  
1045      // allow passing all options as the first parameter
1046      if ( $.isPlainObject( effect ) ) {
1047          options = effect;
1048          effect = effect.effect;
1049      }
1050  
1051      // convert to an object
1052      effect = { effect: effect };
1053  
1054      // catch (effect, null, ...)
1055      if ( options == null ) {
1056          options = {};
1057      }
1058  
1059      // catch (effect, callback)
1060      if ( $.isFunction( options ) ) {
1061          callback = options;
1062          speed = null;
1063          options = {};
1064      }
1065  
1066      // catch (effect, speed, ?)
1067      if ( typeof options === "number" || $.fx.speeds[ options ] ) {
1068          callback = speed;
1069          speed = options;
1070          options = {};
1071      }
1072  
1073      // catch (effect, options, callback)
1074      if ( $.isFunction( speed ) ) {
1075          callback = speed;
1076          speed = null;
1077      }
1078  
1079      // add options to effect
1080      if ( options ) {
1081          $.extend( effect, options );
1082      }
1083  
1084      speed = speed || options.duration;
1085      effect.duration = $.fx.off ? 0 :
1086          typeof speed === "number" ? speed :
1087          speed in $.fx.speeds ? $.fx.speeds[ speed ] :
1088          $.fx.speeds._default;
1089  
1090      effect.complete = callback || options.complete;
1091  
1092      return effect;
1093  }
1094  
1095  function standardSpeed( speed ) {
1096      // valid standard speeds
1097      if ( !speed || typeof speed === "number" || $.fx.speeds[ speed ] ) {
1098          return true;
1099      }
1100  
1101      // invalid strings - treat as "normal" speed
1102      if ( typeof speed === "string" && !$.effects.effect[ speed ] ) {
1103          // TODO: remove in 2.0 (#7115)
1104          if ( backCompat && $.effects[ speed ] ) {
1105              return false;
1106          }
1107          return true;
1108      }
1109  
1110      return false;
1111  }
1112  
1113  $.fn.extend({
1114      effect: function( /* effect, options, speed, callback */ ) {
1115          var args = _normalizeArguments.apply( this, arguments ),
1116              mode = args.mode,
1117              queue = args.queue,
1118              effectMethod = $.effects.effect[ args.effect ],
1119  
1120              // DEPRECATED: remove in 2.0 (#7115)
1121              oldEffectMethod = !effectMethod && backCompat && $.effects[ args.effect ];
1122  
1123          if ( $.fx.off || !( effectMethod || oldEffectMethod ) ) {
1124              // delegate to the original method (e.g., .show()) if possible
1125              if ( mode ) {
1126                  return this[ mode ]( args.duration, args.complete );
1127              } else {
1128                  return this.each( function() {
1129                      if ( args.complete ) {
1130                          args.complete.call( this );
1131                      }
1132                  });
1133              }
1134          }
1135  
1136  		function run( next ) {
1137              var elem = $( this ),
1138                  complete = args.complete,
1139                  mode = args.mode;
1140  
1141  			function done() {
1142                  if ( $.isFunction( complete ) ) {
1143                      complete.call( elem[0] );
1144                  }
1145                  if ( $.isFunction( next ) ) {
1146                      next();
1147                  }
1148              }
1149  
1150              // if the element is hiddden and mode is hide,
1151              // or element is visible and mode is show
1152              if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
1153                  done();
1154              } else {
1155                  effectMethod.call( elem[0], args, done );
1156              }
1157          }
1158  
1159          // TODO: remove this check in 2.0, effectMethod will always be true
1160          if ( effectMethod ) {
1161              return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
1162          } else {
1163              // DEPRECATED: remove in 2.0 (#7115)
1164              return oldEffectMethod.call(this, {
1165                  options: args,
1166                  duration: args.duration,
1167                  callback: args.complete,
1168                  mode: args.mode
1169              });
1170          }
1171      },
1172  
1173      _show: $.fn.show,
1174      show: function( speed ) {
1175          if ( standardSpeed( speed ) ) {
1176              return this._show.apply( this, arguments );
1177          } else {
1178              var args = _normalizeArguments.apply( this, arguments );
1179              args.mode = "show";
1180              return this.effect.call( this, args );
1181          }
1182      },
1183  
1184      _hide: $.fn.hide,
1185      hide: function( speed ) {
1186          if ( standardSpeed( speed ) ) {
1187              return this._hide.apply( this, arguments );
1188          } else {
1189              var args = _normalizeArguments.apply( this, arguments );
1190              args.mode = "hide";
1191              return this.effect.call( this, args );
1192          }
1193      },
1194  
1195      // jQuery core overloads toggle and creates _toggle
1196      __toggle: $.fn.toggle,
1197      toggle: function( speed ) {
1198          if ( standardSpeed( speed ) || typeof speed === "boolean" || $.isFunction( speed ) ) {
1199              return this.__toggle.apply( this, arguments );
1200          } else {
1201              var args = _normalizeArguments.apply( this, arguments );
1202              args.mode = "toggle";
1203              return this.effect.call( this, args );
1204          }
1205      },
1206  
1207      // helper functions
1208      cssUnit: function(key) {
1209          var style = this.css( key ),
1210              val = [];
1211  
1212          $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
1213              if ( style.indexOf( unit ) > 0 ) {
1214                  val = [ parseFloat( style ), unit ];
1215              }
1216          });
1217          return val;
1218      }
1219  });
1220  
1221  })();
1222  
1223  /******************************************************************************/
1224  /*********************************** EASING ***********************************/
1225  /******************************************************************************/
1226  
1227  (function() {
1228  
1229  // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
1230  
1231  var baseEasings = {};
1232  
1233  $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
1234      baseEasings[ name ] = function( p ) {
1235          return Math.pow( p, i + 2 );
1236      };
1237  });
1238  
1239  $.extend( baseEasings, {
1240      Sine: function ( p ) {
1241          return 1 - Math.cos( p * Math.PI / 2 );
1242      },
1243      Circ: function ( p ) {
1244          return 1 - Math.sqrt( 1 - p * p );
1245      },
1246      Elastic: function( p ) {
1247          return p === 0 || p === 1 ? p :
1248              -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
1249      },
1250      Back: function( p ) {
1251          return p * p * ( 3 * p - 2 );
1252      },
1253      Bounce: function ( p ) {
1254          var pow2,
1255              bounce = 4;
1256  
1257          while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
1258          return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
1259      }
1260  });
1261  
1262  $.each( baseEasings, function( name, easeIn ) {
1263      $.easing[ "easeIn" + name ] = easeIn;
1264      $.easing[ "easeOut" + name ] = function( p ) {
1265          return 1 - easeIn( 1 - p );
1266      };
1267      $.easing[ "easeInOut" + name ] = function( p ) {
1268          return p < 0.5 ?
1269              easeIn( p * 2 ) / 2 :
1270              1 - easeIn( p * -2 + 2 ) / 2;
1271      };
1272  });
1273  
1274  })();
1275  
1276  })(jQuery));


Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1