Skip to content

Instantly share code, notes, and snippets.

@ericf
Created May 7, 2010 19:33
Show Gist options
  • Select an option

  • Save ericf/393913 to your computer and use it in GitHub Desktop.

Select an option

Save ericf/393913 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Fancy Overlay</title>
<style type="text/css">
.yui3-overlay {}
.yui3-overlay-content {
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
background: rgba(0, 0, 0, 0.75);
color: #fff;
}
.yui3-widget-bd {
padding: 10px;
}
</style>
</head>
<body class="yui3-skin-sam">
<h1>Fancy Overlay</h1>
<button>Show Overlay</button>
<script src="http://yui.yahooapis.com/3.1.1/build/yui/yui-min.js"></script>
<script>
YUI().use( 'overlay', 'widget-anim', 'event-resize',
'gallery-overlay-modal', 'gallery-outside-events', function(Y){
Y.on('domready', function(){
var handles = [],
overlay = new Y.Overlay({
bodyContent : '<p>I’m a <em>fancy<\/em> Overlay<\/p>',
width : '400px',
height : '200px',
zIndex : 100,
centered : true,
constrain : true,
render : true,
visible : false,
plugins : [{ fn: Y.Plugin.OverlayModal }, { fn: Y.Plugin.WidgetAnim }],
after : {
visibleChange : function(e){
if (e.newVal === true) {
handles = [
Y.on('windowresize', Y.bind(this.syncUI, this)),
Y.one('window').on('scroll', Y.bind(this.syncUI, this))
];
Y.later(1, this, function(){
handles.push(this.get('contentBox').on('clickoutside', Y.bind(this.hide, this)));
});
} else {
Y.each(handles, function(h){ h.detach(); });
handles = [];
}
}
}
});
Y.one('button').on('click', Y.bind(overlay.show, overlay));
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment