| | 435 | } |
|---|
| | 436 | |
|---|
| | 437 | public function extend( ...args ):Object { |
|---|
| | 438 | // extend jQuery itself if only one argument is passed |
|---|
| | 439 | if ( args.length == 1 ) { |
|---|
| | 440 | return aQuery.extend( this, args[0] ); |
|---|
| | 441 | } |
|---|
| | 442 | |
|---|
| | 443 | return aQuery.extend.apply( null, args ); |
|---|
| | 444 | } |
|---|
| | 445 | |
|---|
| | 446 | public static function extend( ...args ):Object { |
|---|
| | 447 | // copy reference to target object |
|---|
| | 448 | var target:Object = args[0], a:int = 1, al:int = args.length, deep:Boolean = false; |
|---|
| | 449 | |
|---|
| | 450 | // Handle a deep copy situation |
|---|
| | 451 | if ( target is Boolean ) { |
|---|
| | 452 | deep = Boolean(target); |
|---|
| | 453 | target = args[1] || {}; |
|---|
| | 454 | } |
|---|
| | 455 | |
|---|
| | 456 | var prop:Object; |
|---|
| | 457 | |
|---|
| | 458 | for ( ; a < al; a++ ) |
|---|
| | 459 | // Only deal with non-null/undefined values |
|---|
| | 460 | if ( (prop = args[a]) != null ) |
|---|
| | 461 | // Extend the base object |
|---|
| | 462 | for ( var i:Object in prop ) { |
|---|
| | 463 | // Prevent never-ending loop |
|---|
| | 464 | if ( target == prop[i] ) |
|---|
| | 465 | continue; |
|---|
| | 466 | |
|---|
| | 467 | // Recurse if we're merging object values |
|---|
| | 468 | if ( deep && prop[i] is Object && target[i] ) |
|---|
| | 469 | aQuery.extend( target[i], prop[i] ); |
|---|
| | 470 | |
|---|
| | 471 | // Don't bring in undefined values |
|---|
| | 472 | else if ( prop[i] != undefined ) |
|---|
| | 473 | target[i] = prop[i]; |
|---|
| | 474 | } |
|---|
| | 475 | |
|---|
| | 476 | // Return the modified object |
|---|
| | 477 | return target; |
|---|
| | 1401 | |
|---|
| | 1402 | public function show(speed:Number = 0, callback:Function = null):aQuery { |
|---|
| | 1403 | /*return speed ? |
|---|
| | 1404 | animate({ |
|---|
| | 1405 | height: "show", width: "show", opacity: "show" |
|---|
| | 1406 | }, speed, callback) : |
|---|
| | 1407 | */ |
|---|
| | 1408 | return filter(":hidden").each(function(...args):void{ |
|---|
| | 1409 | this.visible = true; |
|---|
| | 1410 | }).end(); |
|---|
| | 1411 | } |
|---|
| | 1412 | |
|---|
| | 1413 | public function hide(speed:Number = 0, callback:Function = null):aQuery { |
|---|
| | 1414 | /*return speed ? |
|---|
| | 1415 | animate({ |
|---|
| | 1416 | height: "hide", width: "hide", opacity: "hide" |
|---|
| | 1417 | }, speed, callback) : |
|---|
| | 1418 | */ |
|---|
| | 1419 | return filter(":visible").each(function(...args):void{ |
|---|
| | 1420 | this.visible = false; |
|---|
| | 1421 | }).end(); |
|---|
| | 1422 | } |
|---|
| | 1423 | |
|---|
| | 1424 | // Save the old toggle function |
|---|
| | 1425 | // _toggle: jQuery.fn.toggle, |
|---|
| | 1426 | |
|---|
| | 1427 | public function toggle():aQuery {// fn, fn2 ){ |
|---|
| | 1428 | /*return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ? |
|---|
| | 1429 | this._toggle( fn, fn2 ) : |
|---|
| | 1430 | fn ? |
|---|
| | 1431 | this.animate({ |
|---|
| | 1432 | height: "toggle", width: "toggle", opacity: "toggle" |
|---|
| | 1433 | }, fn, fn2) :*/ |
|---|
| | 1434 | return each(function(...args):void{ |
|---|
| | 1435 | aQuery.create(this)[ aQuery.create(this)._is(":hidden") ? "show" : "hide" ](); |
|---|
| | 1436 | }); |
|---|
| | 1437 | } |
|---|
| | 1438 | |
|---|
| | 1439 | /* slideDown: function(speed,callback){ |
|---|
| | 1440 | return this.animate({height: "show"}, speed, callback); |
|---|
| | 1441 | }, |
|---|
| | 1442 | |
|---|
| | 1443 | slideUp: function(speed,callback){ |
|---|
| | 1444 | return this.animate({height: "hide"}, speed, callback); |
|---|
| | 1445 | }, |
|---|
| | 1446 | |
|---|
| | 1447 | slideToggle: function(speed, callback){ |
|---|
| | 1448 | return this.animate({height: "toggle"}, speed, callback); |
|---|
| | 1449 | }, |
|---|
| | 1450 | |
|---|
| | 1451 | fadeIn: function(speed, callback){ |
|---|
| | 1452 | return this.animate({opacity: "show"}, speed, callback); |
|---|
| | 1453 | }, |
|---|
| | 1454 | |
|---|
| | 1455 | fadeOut: function(speed, callback){ |
|---|
| | 1456 | return this.animate({opacity: "hide"}, speed, callback); |
|---|
| | 1457 | }, |
|---|
| | 1458 | |
|---|
| | 1459 | fadeTo: function(speed,to,callback){ |
|---|
| | 1460 | return this.animate({opacity: to}, speed, callback); |
|---|
| | 1461 | }, |
|---|
| | 1462 | |
|---|
| | 1463 | public function animate( prop:Object, speed, easing:Number, callback:Function ):aQuery { |
|---|
| | 1464 | var opt = aQuery.speed(speed, easing, callback); |
|---|
| | 1465 | |
|---|
| | 1466 | return this[ opt.queue === false ? "each" : "queue" ](function(... args):void { |
|---|
| | 1467 | opt = aQuery.extend({}, opt); |
|---|
| | 1468 | var hidden:Boolean = jQuery(this)._is(":hidden"), self:DisplayObject = this; |
|---|
| | 1469 | |
|---|
| | 1470 | for ( var p:String in prop ) { |
|---|
| | 1471 | if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden ) |
|---|
| | 1472 | return aQuery.isFunction(opt.complete) && opt.complete.apply(this); |
|---|
| | 1473 | |
|---|
| | 1474 | if ( p == "height" || p == "width" ) { |
|---|
| | 1475 | // Store display property |
|---|
| | 1476 | opt.display = this.visible; |
|---|
| | 1477 | } |
|---|
| | 1478 | } |
|---|
| | 1479 | |
|---|
| | 1480 | opt.curAnim = aQuery.extend({}, prop); |
|---|
| | 1481 | |
|---|
| | 1482 | jQuery.each( prop, function(name:String, val){ |
|---|
| | 1483 | var e = new jQuery.fx( self, opt, name ); |
|---|
| | 1484 | |
|---|
| | 1485 | if ( /toggle|show|hide/.test(val) ) |
|---|
| | 1486 | e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop ); |
|---|
| | 1487 | else { |
|---|
| | 1488 | var parts = val.toString().match(/^([+-]?)([\d.]+)(.*)$/), |
|---|
| | 1489 | start = e.cur(true) || 0; |
|---|
| | 1490 | |
|---|
| | 1491 | if ( parts ) { |
|---|
| | 1492 | end = parseFloat(parts[2]), |
|---|
| | 1493 | unit = parts[3] || "px"; |
|---|
| | 1494 | |
|---|
| | 1495 | // We need to compute starting value |
|---|
| | 1496 | if ( unit != "px" ) { |
|---|
| | 1497 | self.style[ name ] = end + unit; |
|---|
| | 1498 | start = (end / e.cur(true)) * start; |
|---|
| | 1499 | self.style[ name ] = start + unit; |
|---|
| | 1500 | } |
|---|
| | 1501 | |
|---|
| | 1502 | // If a +/- token was provided, we're doing a relative animation |
|---|
| | 1503 | if ( parts[1] ) |
|---|
| | 1504 | end = ((parts[1] == "-" ? -1 : 1) * end) + start; |
|---|
| | 1505 | |
|---|
| | 1506 | e.custom( start, end, unit ); |
|---|
| | 1507 | } else |
|---|
| | 1508 | e.custom( start, val, "" ); |
|---|
| | 1509 | } |
|---|
| | 1510 | }); |
|---|
| | 1511 | |
|---|
| | 1512 | // For JS strict compliance |
|---|
| | 1513 | return true; |
|---|
| | 1514 | }); |
|---|
| | 1515 | }, |
|---|
| | 1516 | */ |
|---|
| | 1517 | public function queue(type:String, fn:Object):aQuery { |
|---|
| | 1518 | if ( !fn ) { |
|---|
| | 1519 | fn = type; |
|---|
| | 1520 | type = "fx"; |
|---|
| | 1521 | } |
|---|
| | 1522 | |
|---|
| | 1523 | return each(function(... args):void { |
|---|
| | 1524 | if ( fn is Array ) |
|---|
| | 1525 | aQuery.queue(this, type, fn as Array); |
|---|
| | 1526 | else { |
|---|
| | 1527 | aQuery.queue(this, type).push( fn ); |
|---|
| | 1528 | |
|---|
| | 1529 | if ( aQuery.queue(this, type).length == 1 ) |
|---|
| | 1530 | fn.apply(this); |
|---|
| | 1531 | } |
|---|
| | 1532 | }); |
|---|
| | 1533 | } |
|---|
| | 1534 | |
|---|
| | 1535 | /* stop: function(){ |
|---|
| | 1536 | var timers = jQuery.timers; |
|---|
| | 1537 | |
|---|
| | 1538 | return this.each(function(){ |
|---|
| | 1539 | for ( var i = 0; i < timers.length; i++ ) |
|---|
| | 1540 | if ( timers[i].elem == this ) |
|---|
| | 1541 | timers.splice(i--, 1); |
|---|
| | 1542 | }).dequeue(); |
|---|
| | 1543 | } |
|---|
| | 1544 | */ |
|---|
| | 1545 | |
|---|
| | 1546 | static private function queue( elem:DisplayObject, type:String, array:Array = null ):Array { |
|---|
| | 1547 | if ( !elem ) |
|---|
| | 1548 | return []; |
|---|
| | 1549 | |
|---|
| | 1550 | var q:Array = aQuery.data( elem, type + "queue" ) as Array; |
|---|
| | 1551 | |
|---|
| | 1552 | if ( !q || array ) |
|---|
| | 1553 | q = aQuery.data( elem, type + "queue", |
|---|
| | 1554 | array ? aQuery.makeArray(array) : [] ) as Array; |
|---|
| | 1555 | |
|---|
| | 1556 | return q; |
|---|
| | 1557 | } |
|---|
| | 1558 | |
|---|
| | 1559 | public function dequeue(type:String = null):aQuery { |
|---|
| | 1560 | type = type || "fx"; |
|---|
| | 1561 | |
|---|
| | 1562 | return each(function(... args):void{ |
|---|
| | 1563 | var q:Array = aQuery.queue(this, type); |
|---|
| | 1564 | |
|---|
| | 1565 | q.shift(); |
|---|
| | 1566 | |
|---|
| | 1567 | if ( q.length ) |
|---|
| | 1568 | q[0].apply( this ); |
|---|
| | 1569 | }); |
|---|
| | 1570 | } |
|---|
| | 1571 | |
|---|
| | 1572 | static private function speed(speed:Object, easing:String, fn:Function):Object { |
|---|
| | 1573 | var opt:Object = speed && speed is Object ? speed : { |
|---|
| | 1574 | complete: fn || fn != null && easing || |
|---|
| | 1575 | aQuery.isFunction( speed ) && speed, |
|---|
| | 1576 | duration: speed, |
|---|
| | 1577 | easing: fn && easing || easing && !(easing is Function) && easing |
|---|
| | 1578 | }; |
|---|
| | 1579 | |
|---|
| | 1580 | opt.duration = (opt.duration && opt.duration is Number ? |
|---|
| | 1581 | opt.duration : |
|---|
| | 1582 | { slow: 600, fast: 200 }[opt.duration]) || 400; |
|---|
| | 1583 | |
|---|
| | 1584 | // Queueing |
|---|
| | 1585 | opt.old = opt.complete; |
|---|
| | 1586 | opt.complete = function():void{ |
|---|
| | 1587 | aQuery(this).dequeue(); |
|---|
| | 1588 | if ( aQuery.isFunction( opt.old ) ) |
|---|
| | 1589 | opt.old.apply( this ); |
|---|
| | 1590 | }; |
|---|
| | 1591 | |
|---|
| | 1592 | return opt; |
|---|
| | 1593 | } |
|---|
| | 1594 | |
|---|
| | 1595 | /* easing: { |
|---|
| | 1596 | linear: function( p, n, firstNum, diff ) { |
|---|
| | 1597 | return firstNum + diff * p; |
|---|
| | 1598 | }, |
|---|
| | 1599 | swing: function( p, n, firstNum, diff ) { |
|---|
| | 1600 | return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum; |
|---|
| | 1601 | } |
|---|
| | 1602 | }, |
|---|
| | 1603 | |
|---|
| | 1604 | timers: [], |
|---|
| | 1605 | |
|---|
| | 1606 | fx: function( elem, options, prop ){ |
|---|
| | 1607 | this.options = options; |
|---|
| | 1608 | this.elem = elem; |
|---|
| | 1609 | this.prop = prop; |
|---|
| | 1610 | |
|---|
| | 1611 | if ( !options.orig ) |
|---|
| | 1612 | options.orig = {}; |
|---|
| | 1613 | }*/ |
|---|
| | 1614 | |
|---|