Skip to content

Commit

Permalink
Update Overlay to version 0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Arian committed Mar 20, 2010
1 parent 35100e5 commit 82ab447
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Source/Overlay-yui-compressed.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ provides:
- Overlay
...
*/
var Overlay=new Class({Implements:[Options,Events],options:{id:"overlay",color:"#000",duration:500,opacity:0.5,zIndex:5000},initialize:function(a,b){this.setOptions(b);this.container=document.id(a);this.overlay=new Element("div",{id:this.options.id,opacity:0,styles:{position:"absolute",background:this.options.color,left:0,top:0,"z-index":this.options.zIndex},events:{click:function(){this.fireEvent("click");}.bind(this)}}).inject(this.container);this.tween=new Fx.Tween(this.overlay,{duration:this.options.duration,link:"cancel",property:"opacity",onStart:function(){this.overlay.setStyles({width:"100%",height:this.container.getScrollSize().y});}.bind(this),onComplete:function(){this.fireEvent(this.overlay.get("opacity")==this.options.opacity?"show":"hide");}.bind(this)});},open:function(){this.fireEvent("open");this.tween.start(this.options.opacity);return this;},close:function(){this.fireEvent("close");this.tween.start(0);return this;}});
var Overlay=new Class({Implements:[Options,Events],options:{id:"overlay",color:"#000",duration:500,opacity:0.5,zIndex:5000},initialize:function(a,b){this.setOptions(b);this.container=document.id(a);if(Browser.Engine.trident&&Browser.Engine.version<=6){this.ie6=true;}this.overlay=new Element("div",{id:this.options.id,opacity:0,styles:{position:(this.ie6)?"absolute":"fixed",background:this.options.color,left:0,top:0,"z-index":this.options.zIndex},events:{click:function(){this.fireEvent("click");}.bind(this)}}).inject(this.container);this.tween=new Fx.Tween(this.overlay,{duration:this.options.duration,link:"cancel",property:"opacity",onStart:function(){this.overlay.setStyles({width:"100%",height:this.container.getScrollSize().y});}.bind(this),onComplete:function(){this.fireEvent(this.overlay.get("opacity")==this.options.opacity?"show":"hide");}.bind(this)});window.addEvents({resize:function(){this.resize();}.bind(this),scroll:function(){this.scroll();}.bind(this)});},open:function(){this.fireEvent("open");this.tween.start(this.options.opacity);return this;},close:function(){this.fireEvent("close");this.tween.start(0);return this;},resize:function(){this.fireEvent("resize");this.overlay.setStyle("height",this.container.getScrollSize().y);return this;},scroll:function(){this.fireEvent("scroll");if(this.ie6){this.overlay.setStyle("left",window.getScroll().x);}return this;}});
51 changes: 38 additions & 13 deletions Source/Overlay.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
---
description: Overlay
description: Overlay
authors:
- David Walsh (http://davidwalsh.name)
Expand All @@ -9,17 +9,18 @@ license:
- MIT-style license
requires:
core/1.2.1: '*'
core/1.2.1: '*'
provides:
- Overlay
...
*/

var Overlay = new Class({

Implements: [Options,Events],
Implements: [Options, Events],

options: {
options: {
id: 'overlay',
color: '#000',
duration: 500,
Expand All @@ -33,48 +34,72 @@ var Overlay = new Class({
*/
},

initialize: function(container,options) {
initialize: function(container, options){
this.setOptions(options);
this.container = document.id(container);
this.overlay = new Element('div',{
if (Browser.Engine.trident && Browser.Engine.version <= 6) this.ie6 = true;
this.overlay = new Element('div', {
id: this.options.id,
opacity: 0,
styles: {
position: 'absolute',
position: (this.ie6) ? 'absolute' : 'fixed',
background: this.options.color,
left: 0,
top: 0,
'z-index': this.options.zIndex
},
events: {
click: function() {
click: function(){
this.fireEvent('click');
}.bind(this)
}
}).inject(this.container);
this.tween = new Fx.Tween(this.overlay,{
this.tween = new Fx.Tween(this.overlay, {
duration: this.options.duration,
link: 'cancel',
property: 'opacity',
onStart: function() {
onStart: function(){
this.overlay.setStyles({
width: '100%',
height: this.container.getScrollSize().y
});
}.bind(this),
onComplete: function() {
onComplete: function(){
this.fireEvent(this.overlay.get('opacity') == this.options.opacity ? 'show' : 'hide');
}.bind(this)
});
window.addEvents({
'resize': function(){
this.resize();
}.bind(this),
'scroll': function(){
this.scroll();
}.bind(this)
});
},
open: function() {

open: function(){
this.fireEvent('open');
this.tween.start(this.options.opacity);
return this;
},
close: function() {

close: function(){
this.fireEvent('close');
this.tween.start(0);
return this;
},

resize: function(){
this.fireEvent('resize');
this.overlay.setStyle('height', this.container.getScrollSize().y);
return this;
},

scroll: function(){
this.fireEvent('scroll');
if (this.ie6) this.overlay.setStyle('left', window.getScroll().x);
return this;
}

});

0 comments on commit 82ab447

Please sign in to comment.