From 1fde3bdcaeec81702d58e95607076603d61f946e Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 19 Jul 2012 11:54:27 -0700 Subject: Restrict materials popup to appear within our page. Signed-off-by: Nivesh Rajbhandari --- .../materials-library-panel.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'js/panels') diff --git a/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js b/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js index 4b9044ae..c3c2a6de 100755 --- a/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js +++ b/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js @@ -217,15 +217,27 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { willPositionPopup: { value: function(popup, defaultPosition) { - var content = popup.content.element, + var left, + top, + content = popup.content.element, contentHt = parseFloat(content.style.height) || content.offsetHeight || 0, contentWd = parseFloat(content.style.width) || content.offsetWidth || 0, pt = webkitConvertPointFromNodeToPage(this.selectedMaterialNode, new WebKitPoint(0, 0)); - if(!pt) { + + if(!pt) { return defaultPosition; - } else { - return {top: pt.y - contentHt + 10, left: pt.x - contentWd + 10}; + } + + top = pt.y - contentHt + 10; + if(top < 0) { + top = 0; } + left = pt.x - contentWd + 10; + if(left < 0) { + left = 0; + } + + return {top:top, left:left}; } } }); -- cgit v1.2.3