From 0bd245803fe8b3e58b1ae6b8dfaed0c0b0cfd258 Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 11 Jan 2015 19:07:25 -0700 Subject: Abstract out platform-specific popup UI JavaScript --- platform/safari/vapi-common.js | 21 -------------------- platform/safari/vapi-popup.js | 45 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 21 deletions(-) create mode 100644 platform/safari/vapi-popup.js (limited to 'platform') diff --git a/platform/safari/vapi-common.js b/platform/safari/vapi-common.js index 406f49d..ecfb046 100644 --- a/platform/safari/vapi-common.js +++ b/platform/safari/vapi-common.js @@ -104,27 +104,6 @@ vAPI.i18n = function(s) { return this.i18nData[s] || s; }; -/******************************************************************************/ - -// update popover size to its content -if (safari.self.identifier === 'popover') { - var whenSizeChanges = function(d,l){(function(a,d){function h(a,b){a.addEventListener("scroll",b)}function e(){k.style.width=b.offsetWidth+10+"px";k.style.height=b.offsetHeight+10+"px";b.scrollLeft=b.scrollWidth;b.scrollTop=b.scrollHeight;c.scrollLeft=c.scrollWidth;c.scrollTop=c.scrollHeight;f=a.offsetWidth;g=a.offsetHeight}a.b=d;a.a=document.createElement("div");a.a.style.cssText="position:absolute;left:0;top:0;right:0;bottom:0;overflow:scroll;z-index:-1;visibility:hidden";a.a.innerHTML='
'; -a.appendChild(a.a);var b=a.a.childNodes[0],k=b.childNodes[0],c=a.a.childNodes[1],f,g;e();h(b,function(){(a.offsetWidth>f||a.offsetHeight>g)&&a.b();e()});h(c,function(){(a.offsetWidth w || elm.offsetHeight > h) && callback(); + reset(); + }); + shrink.addEventListener("scroll", function() { + (elm.offsetWidth < w || elm.offsetHeight < h) && callback(); + reset(); + }); +}; +var onLoaded = function() { + var body = document.body, popover = safari.self; + var updateSize = function() { + popover.width = body.offsetWidth; + popover.height = body.offsetHeight; + }; + updateSize(); + body.style.position = "relative"; // Necessary for size change detection + whenSizeChanges(body, updateSize); +}; +window.addEventListener('load', onLoaded); -- cgit v1.1