Skip to content

Instantly share code, notes, and snippets.

@elson
Created July 14, 2009 14:31
Show Gist options
  • Save elson/146971 to your computer and use it in GitHub Desktop.
Save elson/146971 to your computer and use it in GitHub Desktop.
--- core/src/widgets/mask/mask.js 2008-09-22 11:27:44.000000000 +0100
+++ trunk/src/widgets/mask/mask.js 2008-11-17 11:13:51.000000000 +0000
@@ -65,6 +65,15 @@
zIndex: 9900,
disableScroll: false
}, opts || {});
+
+ /*
+ Property: context
+ If context is specified, the mask is restricted in size
+ to cover the width and height of the context element.
+ */
+ if(this.opts.context) {
+ this.context = opts.context;
+ }
/*
Property: maskElement
@@ -139,9 +148,31 @@
function resizeMask() {
var bodyHeight = body.height();
+
+ var hasContext, context, contextHeight, contextWidth, contextOffset;
+
+ if(that.context) {
+ context = $(that.context);
+ hasContext = context.length > 0;
+ }
+
+ if(hasContext) {
+ contextOffset = context.offset();
+ contextHeight = context.height() + "px";
+ contextWidth = context.width() + "px";
+ } else {
+ contextWidth = "100%";
+ contextHeight = (that.opts.disableScroll ? noScrollContainer.height() : Math.max(bodyHeight, win.height())) + "px";
+ }
+
for (var i = 0; i < 2; i++) {
- that.maskElement.css("width", "100%").
- css("height", (that.opts.disableScroll ? noScrollContainer.height() : Math.max(bodyHeight, win.height())) + "px");
+ that.maskElement.css("width", contextWidth).
+ css("height", contextHeight);
+
+ // position mask over context element
+ if(hasContext) {
+ that.maskElement.css("top", contextOffset.top + "px").css("left", contextOffset.left + "px");
+ }
}
if (glow.env.ie < 7) {
var maskStyle = that.maskElement[0].style;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment