summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/MochiKit/Visual.js
Unidiff
Diffstat (limited to 'frontend/gamma/js/MochiKit/Visual.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/MochiKit/Visual.js39
1 files changed, 20 insertions, 19 deletions
diff --git a/frontend/gamma/js/MochiKit/Visual.js b/frontend/gamma/js/MochiKit/Visual.js
index 648d82a..372d99a 100644
--- a/frontend/gamma/js/MochiKit/Visual.js
+++ b/frontend/gamma/js/MochiKit/Visual.js
@@ -1,35 +1,35 @@
1/*** 1/***
2 2
3MochiKit.Visual 1.5 3MochiKit.Visual 1.5
4 4
5See <http://mochikit.com/> for documentation, downloads, license, etc. 5See <http://mochikit.com/> for documentation, downloads, license, etc.
6 6
7(c) 2005 Bob Ippolito and others. All rights Reserved. 7(c) 2005 Bob Ippolito and others. All rights Reserved.
8 8
9***/ 9***/
10 10
11MochiKit.Base._module('Visual', '1.5', ['Base', 'DOM', 'Style', 'Color', 'Position']); 11MochiKit.Base.module(MochiKit, 'Visual', '1.5', ['Base', 'DOM', 'Style', 'Color', 'Position']);
12 12
13MochiKit.Visual._RoundCorners = function (e, options) { 13MochiKit.Visual._RoundCorners = function (e, options) {
14 e = MochiKit.DOM.getElement(e); 14 e = MochiKit.DOM.getElement(e);
15 this._setOptions(options); 15 this._setOptions(options);
16 if (this.options.__unstable__wrapElement) { 16 if (this.options.__unstable__wrapElement) {
17 e = this._doWrap(e); 17 e = this._doWrap(e);
18 } 18 }
19 19
20 var color = this.options.color; 20 var color = this.options.color;
21 var C = MochiKit.Color.Color; 21 var C = MochiKit.Color.Color;
22 if (this.options.color === "fromElement") { 22 if (this.options.color === "fromElement") {
23 color = C.fromBackground(e); 23 color = C.fromBackground(e);
24 } else if (!(color instanceof C)) { 24 } else if (!(color instanceof C)) {
25 color = C.fromString(color); 25 color = C.fromString(color);
26 } 26 }
27 this.isTransparent = (color.asRGB().a <= 0); 27 this.isTransparent = (color.asRGB().a <= 0);
28 28
29 var bgColor = this.options.bgColor; 29 var bgColor = this.options.bgColor;
30 if (this.options.bgColor === "fromParent") { 30 if (this.options.bgColor === "fromParent") {
31 bgColor = C.fromBackground(e.offsetParent); 31 bgColor = C.fromBackground(e.offsetParent);
32 } else if (!(bgColor instanceof C)) { 32 } else if (!(bgColor instanceof C)) {
33 bgColor = C.fromString(bgColor); 33 bgColor = C.fromString(bgColor);
34 } 34 }
35 35
@@ -448,48 +448,53 @@ MochiKit.Visual.Transitions.flicker = function (pos) {
448 return 0.25 - Math.cos(pos*Math.PI)/4 + Math.random()/2; 448 return 0.25 - Math.cos(pos*Math.PI)/4 + Math.random()/2;
449}; 449};
450 450
451/** @id MochiKit.Visual.Transitions.wobble */ 451/** @id MochiKit.Visual.Transitions.wobble */
452MochiKit.Visual.Transitions.wobble = function (pos) { 452MochiKit.Visual.Transitions.wobble = function (pos) {
453 return 0.5 - Math.cos(9*pos*Math.PI)/2; 453 return 0.5 - Math.cos(9*pos*Math.PI)/2;
454}; 454};
455 455
456/** @id MochiKit.Visual.Transitions.pulse */ 456/** @id MochiKit.Visual.Transitions.pulse */
457MochiKit.Visual.Transitions.pulse = function (pos, pulses) { 457MochiKit.Visual.Transitions.pulse = function (pos, pulses) {
458 if (pulses) { 458 if (pulses) {
459 pos *= 2 * pulses; 459 pos *= 2 * pulses;
460 } else { 460 } else {
461 pos *= 10; 461 pos *= 10;
462 } 462 }
463 var decimals = pos - Math.floor(pos); 463 var decimals = pos - Math.floor(pos);
464 return (Math.floor(pos) % 2 == 0) ? decimals : 1 - decimals; 464 return (Math.floor(pos) % 2 == 0) ? decimals : 1 - decimals;
465}; 465};
466 466
467/** @id MochiKit.Visual.Transitions.parabolic */ 467/** @id MochiKit.Visual.Transitions.parabolic */
468MochiKit.Visual.Transitions.parabolic = function (pos) { 468MochiKit.Visual.Transitions.parabolic = function (pos) {
469 return pos * pos; 469 return pos * pos;
470}; 470};
471 471
472/** @id MochiKit.Visual.Transitions.spring */
473MochiKit.Visual.Transitions.spring = function (pos) {
474 return 1 - (Math.cos(pos * 2.5 * Math.PI) * Math.exp(-pos * 6));
475};
476
472/** @id MochiKit.Visual.Transitions.none */ 477/** @id MochiKit.Visual.Transitions.none */
473MochiKit.Visual.Transitions.none = function (pos) { 478MochiKit.Visual.Transitions.none = function (pos) {
474 return 0; 479 return 0;
475}; 480};
476 481
477/** @id MochiKit.Visual.Transitions.full */ 482/** @id MochiKit.Visual.Transitions.full */
478MochiKit.Visual.Transitions.full = function (pos) { 483MochiKit.Visual.Transitions.full = function (pos) {
479 return 1; 484 return 1;
480}; 485};
481 486
482/*** 487/***
483 488
484Core effects 489Core effects
485 490
486***/ 491***/
487 492
488MochiKit.Visual.ScopedQueue = function () { 493MochiKit.Visual.ScopedQueue = function () {
489 var cls = arguments.callee; 494 var cls = arguments.callee;
490 if (!(this instanceof cls)) { 495 if (!(this instanceof cls)) {
491 return new cls(); 496 return new cls();
492 } 497 }
493 this.__init__(); 498 this.__init__();
494}; 499};
495MochiKit.Visual.ScopedQueue.__export__ = false; 500MochiKit.Visual.ScopedQueue.__export__ = false;
@@ -513,48 +518,53 @@ MochiKit.Base.update(MochiKit.Visual.ScopedQueue.prototype, {
513 // move unstarted effects after this effect 518 // move unstarted effects after this effect
514 ma(function (e) { 519 ma(function (e) {
515 if (e.state == 'idle') { 520 if (e.state == 'idle') {
516 e.startOn += effect.finishOn; 521 e.startOn += effect.finishOn;
517 e.finishOn += effect.finishOn; 522 e.finishOn += effect.finishOn;
518 } 523 }
519 }, this.effects); 524 }, this.effects);
520 break; 525 break;
521 case 'end': 526 case 'end':
522 var finish; 527 var finish;
523 // start effect after last queued effect has finished 528 // start effect after last queued effect has finished
524 ma(function (e) { 529 ma(function (e) {
525 var i = e.finishOn; 530 var i = e.finishOn;
526 if (i >= (finish || i)) { 531 if (i >= (finish || i)) {
527 finish = i; 532 finish = i;
528 } 533 }
529 }, this.effects); 534 }, this.effects);
530 timestamp = finish || timestamp; 535 timestamp = finish || timestamp;
531 break; 536 break;
532 case 'break': 537 case 'break':
533 ma(function (e) { 538 ma(function (e) {
534 e.finalize(); 539 e.finalize();
535 }, this.effects); 540 }, this.effects);
536 break; 541 break;
542 case 'replace':
543 ma(function (e) {
544 e.cancel();
545 }, this.effects);
546 break;
537 } 547 }
538 548
539 effect.startOn += timestamp; 549 effect.startOn += timestamp;
540 effect.finishOn += timestamp; 550 effect.finishOn += timestamp;
541 if (!effect.options.queue.limit || 551 if (!effect.options.queue.limit ||
542 this.effects.length < effect.options.queue.limit) { 552 this.effects.length < effect.options.queue.limit) {
543 this.effects.push(effect); 553 this.effects.push(effect);
544 } 554 }
545 555
546 if (!this.interval) { 556 if (!this.interval) {
547 this.interval = this.startLoop(MochiKit.Base.bind(this.loop, this), 557 this.interval = this.startLoop(MochiKit.Base.bind(this.loop, this),
548 40); 558 40);
549 } 559 }
550 }, 560 },
551 561
552 /** @id MochiKit.Visual.ScopedQueue.prototype.startLoop */ 562 /** @id MochiKit.Visual.ScopedQueue.prototype.startLoop */
553 startLoop: function (func, interval) { 563 startLoop: function (func, interval) {
554 return setInterval(func, interval); 564 return setInterval(func, interval);
555 }, 565 },
556 566
557 /** @id MochiKit.Visual.ScopedQueue.prototype.remove */ 567 /** @id MochiKit.Visual.ScopedQueue.prototype.remove */
558 remove: function (effect) { 568 remove: function (effect) {
559 this.effects = MochiKit.Base.filter(function (e) { 569 this.effects = MochiKit.Base.filter(function (e) {
560 return e != effect; 570 return e != effect;
@@ -641,50 +651,54 @@ MochiKit.Visual.Base.prototype = {
641 loop: function (timePos) { 651 loop: function (timePos) {
642 if (timePos >= this.startOn) { 652 if (timePos >= this.startOn) {
643 if (timePos >= this.finishOn) { 653 if (timePos >= this.finishOn) {
644 return this.finalize(); 654 return this.finalize();
645 } 655 }
646 var pos = (timePos - this.startOn) / (this.finishOn - this.startOn); 656 var pos = (timePos - this.startOn) / (this.finishOn - this.startOn);
647 var frame = 657 var frame =
648 Math.round(pos * this.options.fps * this.options.duration); 658 Math.round(pos * this.options.fps * this.options.duration);
649 if (frame > this.currentFrame) { 659 if (frame > this.currentFrame) {
650 this.render(pos); 660 this.render(pos);
651 this.currentFrame = frame; 661 this.currentFrame = frame;
652 } 662 }
653 } 663 }
654 }, 664 },
655 665
656 /** @id MochiKit.Visual.Base.prototype.render */ 666 /** @id MochiKit.Visual.Base.prototype.render */
657 render: function (pos) { 667 render: function (pos) {
658 if (this.state == 'idle') { 668 if (this.state == 'idle') {
659 this.state = 'running'; 669 this.state = 'running';
660 this.event('beforeSetup'); 670 this.event('beforeSetup');
661 this.setup(); 671 this.setup();
662 this.event('afterSetup'); 672 this.event('afterSetup');
663 } 673 }
664 if (this.state == 'running') { 674 if (this.state == 'running') {
665 if (this.options.transition) { 675 var trans = this.options.transition;
666 pos = this.options.transition(pos); 676 if (typeof(trans) == "string") {
677 trans = MochiKit.Visual.Transitions[trans];
678 }
679 if (typeof(trans) == "function") {
680 pos = trans(pos);
667 } 681 }
668 pos *= (this.options.to - this.options.from); 682 pos *= (this.options.to - this.options.from);
669 pos += this.options.from; 683 pos += this.options.from;
670 this.event('beforeUpdate'); 684 this.event('beforeUpdate');
671 this.update(pos); 685 this.update(pos);
672 this.event('afterUpdate'); 686 this.event('afterUpdate');
673 } 687 }
674 }, 688 },
675 689
676 /** @id MochiKit.Visual.Base.prototype.cancel */ 690 /** @id MochiKit.Visual.Base.prototype.cancel */
677 cancel: function () { 691 cancel: function () {
678 if (!this.options.sync) { 692 if (!this.options.sync) {
679 MochiKit.Visual.Queues.get(typeof(this.options.queue) == 'string' ? 693 MochiKit.Visual.Queues.get(typeof(this.options.queue) == 'string' ?
680 'global' : this.options.queue.scope).remove(this); 694 'global' : this.options.queue.scope).remove(this);
681 } 695 }
682 this.state = 'finished'; 696 this.state = 'finished';
683 }, 697 },
684 698
685 /** @id MochiKit.Visual.Base.prototype.finalize */ 699 /** @id MochiKit.Visual.Base.prototype.finalize */
686 finalize: function () { 700 finalize: function () {
687 this.render(1.0); 701 this.render(1.0);
688 this.cancel(); 702 this.cancel();
689 this.event('beforeFinish'); 703 this.event('beforeFinish');
690 this.finish(); 704 this.finish();
@@ -1665,50 +1679,50 @@ MochiKit.Visual.slideUp = function (element, /* optional */ options) {
1665 s.undoPositioned(effect.element.firstChild); 1679 s.undoPositioned(effect.element.firstChild);
1666 s.undoPositioned(effect.element); 1680 s.undoPositioned(effect.element);
1667 s.setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); 1681 s.setStyle(effect.element.firstChild, {bottom: oldInnerBottom});
1668 } 1682 }
1669 }, options); 1683 }, options);
1670 return new MochiKit.Visual.Scale(element, 0, options); 1684 return new MochiKit.Visual.Scale(element, 0, options);
1671}; 1685};
1672 1686
1673// Bug in opera makes the TD containing this element expand for a instance 1687// Bug in opera makes the TD containing this element expand for a instance
1674// after finish 1688// after finish
1675/** @id MochiKit.Visual.squish */ 1689/** @id MochiKit.Visual.squish */
1676MochiKit.Visual.squish = function (element, /* optional */ options) { 1690MochiKit.Visual.squish = function (element, /* optional */ options) {
1677 /*** 1691 /***
1678 1692
1679 Reduce an element and make it disappear. 1693 Reduce an element and make it disappear.
1680 1694
1681 ***/ 1695 ***/
1682 var d = MochiKit.DOM; 1696 var d = MochiKit.DOM;
1683 var b = MochiKit.Base; 1697 var b = MochiKit.Base;
1684 var s = MochiKit.Style; 1698 var s = MochiKit.Style;
1685 var elementDimensions = s.getElementDimensions(element, true); 1699 var elementDimensions = s.getElementDimensions(element, true);
1686 var elemClip; 1700 var elemClip;
1687 options = b.update({ 1701 options = b.update({
1688 restoreAfterFinish: true, 1702 restoreAfterFinish: true,
1689 scaleMode: {originalHeight: elementDimensions.w, 1703 scaleMode: {originalHeight: elementDimensions.h,
1690 originalWidth: elementDimensions.h}, 1704 originalWidth: elementDimensions.w},
1691 beforeSetupInternal: function (effect) { 1705 beforeSetupInternal: function (effect) {
1692 elemClip = s.makeClipping(effect.element); 1706 elemClip = s.makeClipping(effect.element);
1693 }, 1707 },
1694 afterFinishInternal: function (effect) { 1708 afterFinishInternal: function (effect) {
1695 s.hideElement(effect.element); 1709 s.hideElement(effect.element);
1696 s.undoClipping(effect.element, elemClip); 1710 s.undoClipping(effect.element, elemClip);
1697 } 1711 }
1698 }, options); 1712 }, options);
1699 1713
1700 return new MochiKit.Visual.Scale(element, /Opera/.test(navigator.userAgent) ? 1 : 0, options); 1714 return new MochiKit.Visual.Scale(element, /Opera/.test(navigator.userAgent) ? 1 : 0, options);
1701}; 1715};
1702 1716
1703/** @id MochiKit.Visual.grow */ 1717/** @id MochiKit.Visual.grow */
1704MochiKit.Visual.grow = function (element, /* optional */ options) { 1718MochiKit.Visual.grow = function (element, /* optional */ options) {
1705 /*** 1719 /***
1706 1720
1707 Grow an element to its original size. Make it zero-sized before 1721 Grow an element to its original size. Make it zero-sized before
1708 if necessary. 1722 if necessary.
1709 1723
1710 ***/ 1724 ***/
1711 var d = MochiKit.DOM; 1725 var d = MochiKit.DOM;
1712 var v = MochiKit.Visual; 1726 var v = MochiKit.Visual;
1713 var s = MochiKit.Style; 1727 var s = MochiKit.Style;
1714 element = d.getElement(element); 1728 element = d.getElement(element);
@@ -1937,39 +1951,26 @@ MochiKit.Visual.fold = function (element, /* optional */ options) {
1937 var elemClip = s.makeClipping(element); 1951 var elemClip = s.makeClipping(element);
1938 options = MochiKit.Base.update({ 1952 options = MochiKit.Base.update({
1939 scaleContent: false, 1953 scaleContent: false,
1940 scaleX: false, 1954 scaleX: false,
1941 scaleMode: {originalHeight: elementDimensions.h, 1955 scaleMode: {originalHeight: elementDimensions.h,
1942 originalWidth: elementDimensions.w}, 1956 originalWidth: elementDimensions.w},
1943 afterFinishInternal: function (effect) { 1957 afterFinishInternal: function (effect) {
1944 new v.Scale(element, 1, { 1958 new v.Scale(element, 1, {
1945 scaleContent: false, 1959 scaleContent: false,
1946 scaleY: false, 1960 scaleY: false,
1947 scaleMode: {originalHeight: elementDimensions.h, 1961 scaleMode: {originalHeight: elementDimensions.h,
1948 originalWidth: elementDimensions.w}, 1962 originalWidth: elementDimensions.w},
1949 afterFinishInternal: function (effect) { 1963 afterFinishInternal: function (effect) {
1950 s.hideElement(effect.element); 1964 s.hideElement(effect.element);
1951 s.undoClipping(effect.element, elemClip); 1965 s.undoClipping(effect.element, elemClip);
1952 s.setStyle(effect.element, oldStyle); 1966 s.setStyle(effect.element, oldStyle);
1953 } 1967 }
1954 }); 1968 });
1955 } 1969 }
1956 }, options); 1970 }, options);
1957 return new v.Scale(element, 5, options); 1971 return new v.Scale(element, 5, options);
1958}; 1972};
1959 1973
1960 1974
1961/* end of Rico adaptation */ 1975MochiKit.Base.nameFunctions(MochiKit.Visual);
1962
1963MochiKit.Visual.__new__ = function () {
1964 var m = MochiKit.Base;
1965
1966 // Backwards compatibility aliases
1967 m._deprecated(this, 'Color', 'MochiKit.Color.Color', '1.1');
1968 m._deprecated(this, 'getElementsComputedStyle', 'MochiKit.Style.getStyle', '1.1');
1969
1970 m.nameFunctions(this);
1971};
1972
1973MochiKit.Visual.__new__();
1974
1975MochiKit.Base._exportSymbols(this, MochiKit.Visual); 1976MochiKit.Base._exportSymbols(this, MochiKit.Visual);