riojs 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/VERSION +1 -1
  2. data/public/images/sub-menu-indicator.png +0 -0
  3. data/public/javascripts/components/alert_box.js +34 -24
  4. data/public/javascripts/components/grid_view.js +32 -10
  5. data/public/javascripts/components/input.js +6 -0
  6. data/public/javascripts/components/lightbox.js +137 -141
  7. data/public/javascripts/components/list_view.js +2 -2
  8. data/public/javascripts/components/menu.js +93 -50
  9. data/public/javascripts/components/overlay.js +117 -118
  10. data/public/javascripts/components/popup.js +213 -0
  11. data/public/javascripts/components/toggle_button.js +3 -2
  12. data/public/javascripts/lib/console/docs/files.html +1 -1
  13. data/public/javascripts/lib/console/docs/index.html +1 -1
  14. data/public/javascripts/lib/console/docs/symbols/Object.html +1 -1
  15. data/public/javascripts/lib/console/docs/symbols/_global_.html +1 -1
  16. data/public/javascripts/lib/console/docs/symbols/rio.Application.html +1 -1
  17. data/public/javascripts/lib/console/docs/symbols/rio.Attr.html +1 -1
  18. data/public/javascripts/lib/console/docs/symbols/rio.Binding.html +1 -1
  19. data/public/javascripts/lib/console/docs/symbols/rio.Component.html +1 -1
  20. data/public/javascripts/lib/console/docs/symbols/rio.Cookie.html +1 -1
  21. data/public/javascripts/lib/console/docs/symbols/rio.DelayedTask#initialize.html +1 -1
  22. data/public/javascripts/lib/console/docs/symbols/rio.DelayedTask.html +1 -1
  23. data/public/javascripts/lib/console/docs/symbols/rio.JsTemplate.html +1 -1
  24. data/public/javascripts/lib/console/docs/symbols/rio.Juggernaut.html +1 -1
  25. data/public/javascripts/lib/console/docs/symbols/rio.Model.html +1 -1
  26. data/public/javascripts/lib/console/docs/symbols/rio.Page.html +1 -1
  27. data/public/javascripts/lib/console/docs/symbols/rio.Utils.html +1 -1
  28. data/public/javascripts/lib/console/docs/symbols/rio.html +1 -1
  29. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_model.js.html +506 -493
  30. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_page.js.html +5 -5
  31. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_protohack.js.html +126 -123
  32. data/public/javascripts/lib/model.js +18 -5
  33. data/public/javascripts/lib/page.js +5 -5
  34. data/public/javascripts/lib/protohack.js +12 -9
  35. data/public/javascripts/specs/lib/model_spec.js +13 -0
  36. data/public/stylesheets/components/alert_box.css +5 -1
  37. data/public/stylesheets/components/menu.css +17 -17
  38. data/public/stylesheets/components/popup.css +18 -0
  39. metadata +5 -2
@@ -77,11 +77,11 @@ rio.components.ListView = rio.Component.create(rio.components.Box, "ListView", {
77
77
  }
78
78
  }.bind(this));
79
79
 
80
- listItem.observe("click", function() {
80
+ listItem.observe("click", function(e) {
81
81
  if (this.getHandleClickSelection()) {
82
82
  this.setSelectedItem(listItem.getItem());
83
83
  }
84
- this.fire("itemClick", listItem.getItem());
84
+ this.fire("itemClick", listItem.getItem(), e);
85
85
  }.bind(this));
86
86
  listItem.observe("scrollTo", function() {
87
87
  var listItemHtml = listItem.html();
@@ -3,87 +3,130 @@ rio.components.Menu = rio.Component.create("Menu", {
3
3
 
4
4
  attrAccessors: [
5
5
  ["items", []],
6
- ["left", 0],
6
+ "menuItems",
7
+ "left",
8
+ "right",
7
9
  ["top", 0]
8
10
  ],
9
-
10
- attrHtmls: ["overlay"],
11
-
11
+ attrReaders: [
12
+ "className"
13
+ ],
12
14
  methods: {
15
+ initialize: function() {
16
+ this.setMenuItems(this.getItems().map(function(item) {
17
+ var menuItem = new rio.components.MenuItem(Object.extend(item, { menuClassName: this.getClassName() }));
18
+
19
+ menuItem.observe("privateClick", function() {
20
+ this.fire("privateClick");
21
+ this.close();
22
+ }.bind(this));
23
+ menuItem.observe("hideDescendantSubMenus", this.hideDescendantSubMenus.bind(this));
24
+
25
+ return menuItem;
26
+ }.bind(this)));
27
+ },
28
+
13
29
  buildHtml: function() {
14
30
  var menuHtml = rio.Tag.div("", { className: "menu" });
15
-
16
- menuHtml.setStyle({
17
- left: this.getLeft() + "px",
18
- top: this.getTop() + "px"
19
- });
20
-
21
- var insertItem = function(item) {
22
- menuHtml.insert(item.html());
23
- item.observe("click", this.click.bind(this));
24
- }.bind(this);
25
-
26
- var removeItem = function(item) {
27
- item.html().remove();
28
- }.bind(this);
29
-
30
- this.bind("items", {
31
- set: function(items) {
32
- if (items) {
33
- items.each(function(item) {
34
- insertItem(item);
35
- }.bind(this));
36
- }
37
- }.bind(this),
31
+ menuHtml.addClassName(this.getClassName());
38
32
 
39
- insert: insertItem,
40
- remove: removeItem
41
- });
33
+ var position = { top: parseInt(this.getTop(), 10) + "px" };
34
+
35
+ if (this.getRight()) {
36
+ position.right = parseInt(this.getRight(), 10) + "px";
37
+ } else {
38
+ position.left = (parseInt(this.getLeft(), 10) || 0) + "px";
39
+ }
40
+ menuHtml.setStyle(position);
41
+
42
+ this.getMenuItems().each(function(menuItem) {
43
+ menuHtml.insert(menuItem);
44
+ }.bind(this));
42
45
 
43
46
  return menuHtml;
44
47
  },
45
48
 
46
- buildOverlayHtml: function() {
47
- var overlayHtml = rio.Tag.div("", { className: "menuOverlay" });
48
- Event.observe(overlayHtml, "mousedown", this.click.bind(this));
49
- return overlayHtml;
49
+ hideDescendantSubMenus: function(noDelay) {
50
+ this.getMenuItems().each(function(menuItem) {
51
+ menuItem.hideDescendantSubMenus(noDelay);
52
+ });
50
53
  },
51
54
 
52
55
  render: function() {
53
- Element.body().insert(this.overlayHtml());
54
- Element.body().insert(this.html());
56
+ this.popup().activate();
55
57
  },
56
58
 
57
- click: function() {
58
- this.close();
59
+ popup: function() {
60
+ if (!this._popup) {
61
+ this._popup = new rio.components.Popup({
62
+ content: this.html(),
63
+ autoCenter: false,
64
+ wrapContent: false,
65
+ opacity: 0.01,
66
+ animateOverlay: false
67
+ });
68
+ }
69
+ return this._popup;
59
70
  },
60
71
 
61
72
  close: function() {
62
- this.html().remove();
63
- this.overlayHtml().remove();
73
+ this.popup().deactivate();
64
74
  }
65
75
  }
66
76
  });
67
77
 
68
78
  rio.components.MenuItem = rio.Component.create("MenuItem", {
69
- attrAccessors: ["text"],
79
+ attrAccessors: ["label", "iconSrc", ["items", []]],
80
+ attrReaders: ["menuClassName"],
70
81
  attrEvents: ["click"],
71
82
  methods: {
72
83
  buildHtml: function() {
73
- var itemHtml = rio.Tag.div("", { className: "menuItem" });
74
- itemHtml.addHoverClass("menuItemHover");
84
+ var content = [this.getLabel()];
85
+ if (this.getIconSrc()) {
86
+ content.unshift(new rio.components.Image({ src: this.getIconSrc(), className: "menuIcon" }));
87
+ }
88
+ var itemHtml = rio.Tag.div(content, { className: "menuItem" });
75
89
 
76
- this.bind("text", function(text) {
77
- itemHtml.update(text);
78
- });
90
+ var hasSubMenu = !this.getItems().empty();
91
+ if (hasSubMenu) {
92
+ this._subMenu = new rio.components.Menu({
93
+ className: this.getMenuClassName(),
94
+ items: this.getItems(),
95
+ top: -2
96
+ });
97
+ this._subMenu.observe("privateClick", this.fire.bind(this, "privateClick"));
79
98
 
80
- itemHtml.observe("click", this.click.bind(this));
99
+ var subMenuHtml = this._subMenu.html();
100
+ subMenuHtml.hide();
101
+ itemHtml.insert(subMenuHtml);
102
+ itemHtml.insert(new rio.components.Image({ src: "/images/sub-menu-indicator.png", className: "subMenuIndicator" }));
103
+ }
104
+ itemHtml.observe("mouseover", function() {
105
+ if (this._subMenu) {
106
+ this.fire("hideDescendantSubMenus");
107
+ var subMenuHtml = this._subMenu.html();
108
+ subMenuHtml.setStyle({ left: itemHtml.getWidth() + "px" });
109
+ subMenuHtml.show();
110
+ } else {
111
+ this.fire("hideDescendantSubMenus");
112
+ }
113
+ }.bind(this));
114
+
115
+ itemHtml.observe("click", function() {
116
+ if (!hasSubMenu) {
117
+ this.fire("privateClick");
118
+ }
119
+ this.fire("click");
120
+ }.bind(this));
81
121
 
82
122
  return itemHtml;
83
123
  },
84
124
 
85
- click: function() {
86
- this.fire("click");
125
+ hideDescendantSubMenus: function() {
126
+ if (this._subMenu) {
127
+ this._subMenu.hideDescendantSubMenus();
128
+ this._subMenu.html().hide();
129
+ }
87
130
  }
88
131
  }
89
- });
132
+ });
@@ -1,134 +1,133 @@
1
1
  // Copyright 2008, Thinklink
2
- rio.components.Overlay = rio.Component.create();
2
+ rio.components.Overlay = rio.Component.create("Overlay", {
3
+ requireCss: "overlay",
4
+ attrAccessors: [["active", false]],
5
+ attrReaders: [
6
+ ["opacity", 0.8],
7
+ ["deactivateOnEscape", true],
8
+ ["deactivateOnClick", true]
9
+ ],
10
+ attrHtmls: ["overlay"],
11
+ methods: {
12
+ yPos : 0,
13
+ xPos : 0,
3
14
 
4
- rio.components.Overlay.requireCss("overlay");
15
+ initialize: function(options) {
16
+ this._ie = Prototype.Browser.IE;
17
+ this._keyDown = this.keyDown.bind(this);
18
+ },
5
19
 
6
- rio.components.Overlay.attrReader("opacity", 0.8);
7
- rio.components.Overlay.attrReader("deactivateOnEscape", true);
8
- rio.components.Overlay.attrReader("deactivateOnClick", true);
9
- rio.components.Overlay.attrAccessor("active", false);
20
+ activate: function() {
21
+ this.setActive(true);
22
+ if (this.isIE()){
23
+ this.getScroll();
10
24
 
11
- rio.components.Overlay.attrHtml("overlay");
12
-
13
- rio.Component.extend(rio.components.Overlay, {
14
- yPos : 0,
15
- xPos : 0,
25
+ this._initialStyle = {
26
+ height: Element.body().style.height || "auto",
27
+ overflow: Element.body().style.overflow || "auto"
28
+ };
29
+ this.prepareIE('100%', 'hidden');
30
+ this.setScroll(0,0);
31
+ this.hideSelects('hidden');
32
+ }
33
+ Event.observe(document, 'keydown', this._keyDown);
34
+ if (this.getDeactivateOnClick()) {
35
+ Event.observe(this.overlayHtml(), 'click', this._deactivate);
36
+ }
16
37
 
17
- initialize: function(options) {
18
- this._ie = Prototype.Browser.IE;
19
- this._keyDown = this.keyDown.bind(this);
20
- },
38
+ Element.setOpacity(this.overlayHtml(), this.getOpacity());
21
39
 
22
- activate: function() {
23
- this.setActive(true);
24
- if (this.isIE()){
25
- this.getScroll();
40
+ if (this.isIE()) {
41
+ this.overlayHtml().show();
42
+ } else {
43
+ this.overlayHtml().appear({
44
+ from: 0.0,
45
+ to: this.getOpacity(),
46
+ duration: 0.5
47
+ });
48
+ }
49
+ },
26
50
 
27
- this._initialStyle = {
28
- height: Element.body().style.height || "auto",
29
- overflow: Element.body().style.overflow || "auto"
30
- };
31
- this.prepareIE('100%', 'hidden');
32
- this.setScroll(0,0);
33
- this.hideSelects('hidden');
34
- }
35
- Event.observe(document, 'keydown', this._keyDown);
36
- if (this.getDeactivateOnClick()) {
37
- Event.observe(this.overlayHtml(), 'click', this._deactivate);
38
- }
51
+ deactivate: function(skipFade) {
52
+ if (this.isIE()){
53
+ this.setScroll(0,this.yPos);
54
+ var managingLayout = (rio.app.getCurrentPage() && rio.app.getCurrentPage().isManagingLayout());
55
+ if (managingLayout) {
56
+ this.prepareIE("100%", "hidden");
57
+ } else {
58
+ this.prepareIE(this._initialStyle.height, this._initialStyle.overflow);
59
+ }
60
+ this.hideSelects("visible");
61
+ }
62
+ Event.stopObserving(document, 'keydown', this._keyDown);
63
+ if (this.getDeactivateOnClick()) {
64
+ Event.stopObserving(this.overlayHtml(), 'click', this._deactivate);
65
+ }
39
66
 
40
- Element.setOpacity(this.overlayHtml(), this.getOpacity());
41
-
42
- if (this.isIE()) {
43
- this.overlayHtml().show();
44
- } else {
45
- this.overlayHtml().appear({
46
- from: 0.0,
47
- to: this.getOpacity(),
48
- duration: 0.5
49
- });
50
- }
51
- },
52
-
53
- deactivate: function(skipFade) {
54
- if (this.isIE()){
55
- this.setScroll(0,this.yPos);
56
- var managingLayout = (rio.app.getCurrentPage() && rio.app.getCurrentPage().isManagingLayout());
57
- if (managingLayout) {
58
- this.prepareIE("100%", "hidden");
67
+ if (skipFade || this.isIE()) {
68
+ this.overlayHtml().hide();
59
69
  } else {
60
- this.prepareIE(this._initialStyle.height, this._initialStyle.overflow);
70
+ this.overlayHtml().fade({
71
+ from: this.getOpacity(),
72
+ to: 0.0,
73
+ duration: 0.5
74
+ });
61
75
  }
62
- this.hideSelects("visible");
63
- }
64
- Event.stopObserving(document, 'keydown', this._keyDown);
65
- if (this.getDeactivateOnClick()) {
66
- Event.stopObserving(this.overlayHtml(), 'click', this._deactivate);
67
- }
76
+ this.setActive(false);
77
+ },
68
78
 
69
- if (skipFade || this.isIE()) {
70
- this.overlayHtml().hide();
71
- } else {
72
- this.overlayHtml().fade({
73
- from: this.getOpacity(),
74
- to: 0.0,
75
- duration: 0.5
79
+ // Taken from lightbox implementation found at http://www.huddletogether.com/projects/lightbox/
80
+ getScroll: function() {
81
+ if (self.pageYOffset) {
82
+ this.yPos = self.pageYOffset;
83
+ } else if (document.documentElement && document.documentElement.scrollTop){
84
+ this.yPos = document.documentElement.scrollTop;
85
+ } else if (document.body) {
86
+ this.yPos = document.body.scrollTop;
87
+ }
88
+ },
89
+
90
+ setScroll: function(x, y) {
91
+ window.scrollTo(x, y);
92
+ },
93
+
94
+ // In IE, select elements hover on top of the lightbox
95
+ hideSelects: function(visibility){
96
+ selects = document.getElementsByTagName('select');
97
+ for(i = 0; i < selects.length; i++) {
98
+ selects[i].style.visibility = visibility;
99
+ }
100
+ },
101
+
102
+ // Ie requires height to 100% and overflow hidden or else you can scroll down past the lightbox
103
+ prepareIE: function(height, overflow) {
104
+ Element.body().setStyle({
105
+ height: height,
106
+ overflow: overflow
76
107
  });
77
- }
78
- this.setActive(false);
79
- },
80
-
81
- // Taken from lightbox implementation found at http://www.huddletogether.com/projects/lightbox/
82
- getScroll: function() {
83
- if (self.pageYOffset) {
84
- this.yPos = self.pageYOffset;
85
- } else if (document.documentElement && document.documentElement.scrollTop){
86
- this.yPos = document.documentElement.scrollTop;
87
- } else if (document.body) {
88
- this.yPos = document.body.scrollTop;
89
- }
90
- },
91
-
92
- setScroll: function(x, y) {
93
- window.scrollTo(x, y);
94
- },
95
-
96
- // In IE, select elements hover on top of the lightbox
97
- hideSelects: function(visibility){
98
- selects = document.getElementsByTagName('select');
99
- for(i = 0; i < selects.length; i++) {
100
- selects[i].style.visibility = visibility;
101
- }
102
- },
103
-
104
- // Ie requires height to 100% and overflow hidden or else you can scroll down past the lightbox
105
- prepareIE: function(height, overflow) {
106
- Element.body().setStyle({
107
- height: height,
108
- overflow: overflow
109
- });
110
108
 
111
- Element.html().setStyle({
112
- height: height,
113
- overflow: overflow
114
- });
115
- },
116
-
117
- keyDown: function(e) {
118
- if (this.isDeactivateOnEscape() && e.keyCode == Event.KEY_ESC) {
119
- this.deactivate();
120
- e.stop();
109
+ Element.html().setStyle({
110
+ height: height,
111
+ overflow: overflow
112
+ });
113
+ },
114
+
115
+ keyDown: function(e) {
116
+ if (this.isDeactivateOnEscape() && e.keyCode == Event.KEY_ESC) {
117
+ this.deactivate();
118
+ e.stop();
119
+ }
120
+ },
121
+
122
+ buildOverlayHtml: function() {
123
+ var position = Prototype.Browser.IE ? "absolute" : "fixed";
124
+ var overlay = rio.Tag.div('', { className: 'overlay', style: 'display: none; position: ' + position });
125
+ Element.insert(Element.body(), { bottom: overlay });
126
+ return overlay;
127
+ },
128
+
129
+ isIE: function() {
130
+ return this._ie;
121
131
  }
122
- },
123
-
124
- buildOverlayHtml: function() {
125
- var position = Prototype.Browser.IE ? "absolute" : "fixed";
126
- var overlay = rio.Tag.div('', { className: 'overlay', style: 'display: none; position: ' + position });
127
- Element.insert(Element.body(), { bottom: overlay });
128
- return overlay;
129
- },
130
-
131
- isIE: function() {
132
- return this._ie;
133
132
  }
134
133
  });
@@ -0,0 +1,213 @@
1
+ $$('.popupOverlay').invoke("remove");
2
+ rio.components.Popup = rio.Component.create("Popup", {
3
+ requireCss: "popup",
4
+ attrAccessors: [
5
+ "content",
6
+ ["deactivateOnEscape", true],
7
+ ["deactivateOnClick", true],
8
+ ["opacity", 0.8],
9
+ ["autoCenter", true],
10
+ ["wrapContent", true],
11
+ ["animateOverlay", true]
12
+ ],
13
+ attrReaders: [],
14
+ attrHtmls: ["overlay"],
15
+ attrEvents: ["deactivate"],
16
+ methods: {
17
+ buildHtml: function() {
18
+ if (this.getWrapContent()) {
19
+ return rio.Tag.div(this.getContent(), { className: "popupContent" });
20
+ } else {
21
+ return this.getContent();
22
+ }
23
+ },
24
+
25
+ buildOverlayHtml: function() {
26
+ this._overlayHtml = rio.Tag.div("", { className: "popupOverlay", style: "display: none" });
27
+
28
+ if (this.getDeactivateOnClick()) {
29
+ this._overlayHtml.observe("click", function() {
30
+ this.deactivate();
31
+ }.bind(this));
32
+ this._overlayHtml.observe("contextmenu", function(e) {
33
+ this.deactivate();
34
+ e.stop();
35
+ }.bind(this));
36
+ }
37
+
38
+ return this._overlayHtml;
39
+ },
40
+
41
+ activate: function() {
42
+ rio.components.Popup.activate(this);
43
+ },
44
+
45
+ deactivate: function(skipAnimation) {
46
+ rio.components.Popup.deactivate(this, skipAnimation);
47
+ this.fire("deactivate");
48
+ },
49
+
50
+ resize: function() {
51
+ if (!this.getAutoCenter()) { return; }
52
+
53
+ var pHeight = this.html().getHeight();
54
+ var pWidth = this.html().getWidth();
55
+ var wHeight = document.viewport.getHeight();
56
+ var wWidth = document.viewport.getWidth();
57
+
58
+ this.html().setStyle({
59
+ top: Math.max(wHeight - pHeight, 0) / 2 + "px",
60
+ left: Math.max(wWidth - pWidth, 0) / 2 + "px"
61
+ });
62
+ }
63
+ },
64
+ classMethods: {
65
+ _activePopups: [],
66
+ _activeAnimations: [],
67
+
68
+ activate: function(popup) {
69
+ this.cancelActiveAnimations();
70
+
71
+ this._activePopups.push(popup);
72
+ this.updateZIndices();
73
+
74
+ this.resetOverlay(!popup.getAnimateOverlay());
75
+
76
+ Element.body().insert(popup.html());
77
+ Element.body().insert(popup.overlayHtml());
78
+
79
+ popup.resize();
80
+ this.addObservers();
81
+ },
82
+
83
+ deactivate: function(popup, forceSkipAnimation) {
84
+ try {
85
+ popup.html().remove();
86
+
87
+ this._activePopups.splice(this._activePopups.indexOf(popup), 1);
88
+ this.updateZIndices();
89
+ var popupOverlay = popup.overlayHtml();
90
+ if (popup.getAnimateOverlay() && !forceSkipAnimation) {
91
+ this._activeAnimations.push(new Effect.Fade(popupOverlay, {
92
+ from: popupOverlay.getStyle("opacity"),
93
+ to: 0.0,
94
+ duration: 0.5,
95
+ afterFinish: function() {
96
+ popupOverlay.remove();
97
+ }
98
+ }));
99
+
100
+ this.resetOverlay();
101
+ } else {
102
+ popupOverlay.remove();
103
+ this.resetOverlay(true);
104
+ }
105
+ } catch(e) {
106
+ try {
107
+ popupOverlay.remove();
108
+ popup.remove();
109
+ } catch(e2) {}
110
+
111
+ throw(e);
112
+ }
113
+ },
114
+
115
+ cancelActiveAnimations: function() {
116
+ // this._activeAnimations.invoke("cancel");
117
+ // TODO: We need a reliable way of handling simultaneous popup activations/deactivations
118
+ this._activeAnimations.clear();
119
+ },
120
+
121
+ updateZIndices: function() {
122
+ var existingPopups = this._activePopups;
123
+ for (var i=0, length=this._activePopups.length; i<length; i++) {
124
+ this._activePopups[i].overlayHtml().setStyle({ zIndex: 5000 + i * 2 });
125
+ this._activePopups[i].html().setStyle({ zIndex: 5000 + i * 2 + 1 });
126
+ }
127
+ },
128
+
129
+ resize: function() {
130
+ if (this.activePopup()) { this.activePopup().resize(); }
131
+ },
132
+
133
+ resetOverlay: function(skipAnimation) {
134
+ if (!this.activePopup()) { return; }
135
+
136
+ var i;
137
+ var totalOpacity = this._activePopups.max(function(p) { return p.getOpacity(); });
138
+
139
+ var foregroundOpacity = this.activePopup().getOpacity();
140
+ if (totalOpacity > foregroundOpacity) {
141
+
142
+ for (i = 0; i<this._activePopups.length-2; i++) {
143
+ this._activePopups[i].overlayHtml().setStyle({ opacity: 0.0 });
144
+ }
145
+
146
+ var nextPopup = this._activePopups[this._activePopups.length - 2];
147
+ nextPopup.overlayHtml().setStyle({ opacity: totalOpacity });
148
+
149
+ var backgroundOpacity = 1 - (1 - totalOpacity)/(1 - foregroundOpacity);
150
+ if (skipAnimation) {
151
+ nextPopup.overlayHtml().setStyle({ opacity: backgroundOpacity });
152
+ } else {
153
+ this._activeAnimations.push(new Effect.Appear(nextPopup.overlayHtml(), {
154
+ from: totalOpacity,
155
+ to: backgroundOpacity,
156
+ duration: 0.5
157
+ }));
158
+ }
159
+ } else {
160
+ var opacity, p;
161
+ for (i=0; i<this._activePopups.length - 1; i++) {
162
+ p = this._activePopups[i];
163
+ opacity = p.overlayHtml().getStyle("opacity");
164
+ if (opacity > 0.0) {
165
+ if (skipAnimation) {
166
+ p.overlayHtml().setStyle({ opacity: 0.0 });
167
+ } else {
168
+ this._activeAnimations.push(new Effect.Fade(p.overlayHtml(), {
169
+ from: opacity,
170
+ to: 0.0,
171
+ duration: 0.5
172
+ }));
173
+ }
174
+ }
175
+ }
176
+ }
177
+ if (this.activePopup().overlayHtml().getStyle("display") == "none") {
178
+ this.activePopup().overlayHtml().setStyle({ opacity: 0.0 });
179
+ }
180
+
181
+ if (skipAnimation) {
182
+ this.activePopup().overlayHtml().show();
183
+ this.activePopup().overlayHtml().setStyle({ opacity: foregroundOpacity });
184
+ } else {
185
+ this._activeAnimations.push(new Effect.Appear(this.activePopup().overlayHtml(), {
186
+ from: this.activePopup().overlayHtml().getStyle("opacity"),
187
+ to: foregroundOpacity,
188
+ duration: 0.5
189
+ }));
190
+ }
191
+ },
192
+
193
+ activePopup: function() {
194
+ return this._activePopups.last();
195
+ },
196
+
197
+ addObservers: function() {
198
+
199
+ if (this._hasObservers) { return; }
200
+ document.observe("keydown", function(e) {
201
+ if (e.keyCode == Event.KEY_ESC && this.activePopup() && this.activePopup().getDeactivateOnEscape() && e.target.tagName.toLowerCase() != "input") {
202
+ this.activePopup().deactivate();
203
+ }
204
+ }.bindAsEventListener(this));
205
+
206
+ Event.observe(window, "resize", this.resize.bind(this));
207
+
208
+ this._hasObservers = true;
209
+ }
210
+ }
211
+ });
212
+
213
+