diff options
Diffstat (limited to 'src/pixelated_www/sandbox.min.js')
-rw-r--r-- | src/pixelated_www/sandbox.min.js | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/pixelated_www/sandbox.min.js b/src/pixelated_www/sandbox.min.js new file mode 100644 index 00000000..b9f6bd6b --- /dev/null +++ b/src/pixelated_www/sandbox.min.js @@ -0,0 +1 @@ +!function(){"use strict";window.onmessage=function(e){if(e.data.html){document.body.innerHTML=e.data.html;var t=e.source;t.postMessage("data ok",e.origin)}}}(),function(e){"use strict";function t(t,n,o){"addEventListener"in e?t.addEventListener(n,o,!1):"attachEvent"in e&&t.attachEvent("on"+n,o)}function n(t,n,o){"removeEventListener"in e?t.removeEventListener(n,o,!1):"detachEvent"in e&&t.detachEvent("on"+n,o)}function o(e){return e.charAt(0).toUpperCase()+e.slice(1)}function i(e){var t,n,o,i=null,r=0,a=function(){r=xe(),i=null,o=e.apply(t,n),i||(t=n=null)};return function(){var u=xe();r||(r=u);var c=Oe-(u-r);return t=this,n=arguments,0>=c||c>Oe?(i&&(clearTimeout(i),i=null),r=u,o=e.apply(t,n),i||(t=n=null)):i||(i=setTimeout(a,c)),o}}function r(e){return fe+"["+ge+"] "+e}function a(t){de&&"object"==typeof e.console&&console.log(r(t))}function u(t){"object"==typeof e.console&&console.warn(r(t))}function c(){s(),a("Initialising iFrame ("+location.href+")"),l(),m(),f("background",Y),f("padding",Z),N(),y(),b(),g(),w(),T(),ce=k(),q("init","Init message from host page"),Ce()}function s(){function e(e){return"true"===e}var t=ue.substr(me).split(":");ge=t[0],$=void 0!==t[1]?Number(t[1]):$,_=void 0!==t[2]?e(t[2]):_,de=void 0!==t[3]?e(t[3]):de,se=void 0!==t[4]?Number(t[4]):se,K=void 0!==t[6]?e(t[6]):K,G=t[7],re=void 0!==t[8]?t[8]:re,Y=t[9],Z=t[10],Te=void 0!==t[11]?Number(t[11]):Te,ce.enable=void 0!==t[12]?e(t[12]):!1,he=void 0!==t[13]?t[13]:he,Ne=void 0!==t[14]?t[14]:Ne}function l(){function t(){var t=e.iFrameResizer;a("Reading data from page: "+JSON.stringify(t)),we="messageCallback"in t?t.messageCallback:we,Ce="readyCallback"in t?t.readyCallback:Ce,be="targetOrigin"in t?t.targetOrigin:be,re="heightCalculationMethod"in t?t.heightCalculationMethod:re,Ne="widthCalculationMethod"in t?t.widthCalculationMethod:Ne}"iFrameResizer"in e&&Object===e.iFrameResizer.constructor&&t(),a("TargetOrigin for parent set to: "+be)}function d(e,t){return-1!==t.indexOf("-")&&(u("Negative CSS value ignored for "+e),t=""),t}function f(e,t){void 0!==t&&""!==t&&"null"!==t&&(document.body.style[e]=t,a("Body "+e+' set to "'+t+'"'))}function m(){void 0===G&&(G=$+"px"),f("margin",d("margin",G))}function g(){document.documentElement.style.height="",document.body.style.height="",a('HTML & body height set to "auto"')}function v(i){function r(){q(i.eventName,i.eventType)}var u={add:function(n){t(e,n,r)},remove:function(t){n(e,t,r)}};i.eventNames&&Array.prototype.map?(i.eventName=i.eventNames[0],i.eventNames.map(u[i.method])):u[i.method](i.eventName),a(o(i.method)+" event listener: "+i.eventType)}function h(e){v({method:e,eventType:"Animation Start",eventNames:["animationstart","webkitAnimationStart"]}),v({method:e,eventType:"Animation Iteration",eventNames:["animationiteration","webkitAnimationIteration"]}),v({method:e,eventType:"Animation End",eventNames:["animationend","webkitAnimationEnd"]}),v({method:e,eventType:"Input",eventName:"input"}),v({method:e,eventType:"Mouse Up",eventName:"mouseup"}),v({method:e,eventType:"Mouse Down",eventName:"mousedown"}),v({method:e,eventType:"Orientation Change",eventName:"orientationchange"}),v({method:e,eventType:"Print",eventName:["afterprint","beforeprint"]}),v({method:e,eventType:"Ready State Change",eventName:"readystatechange"}),v({method:e,eventType:"Touch Start",eventName:"touchstart"}),v({method:e,eventType:"Touch End",eventName:"touchend"}),v({method:e,eventType:"Touch Cancel",eventName:"touchcancel"}),v({method:e,eventType:"Transition Start",eventNames:["transitionstart","webkitTransitionStart","MSTransitionStart","oTransitionStart","otransitionstart"]}),v({method:e,eventType:"Transition Iteration",eventNames:["transitioniteration","webkitTransitionIteration","MSTransitionIteration","oTransitionIteration","otransitioniteration"]}),v({method:e,eventType:"Transition End",eventNames:["transitionend","webkitTransitionEnd","MSTransitionEnd","oTransitionEnd","otransitionend"]}),"child"===he&&v({method:e,eventType:"IFrame Resized",eventName:"resize"})}function p(e,t,n,o){return t!==e&&(e in n||(u(e+" is not a valid option for "+o+"CalculationMethod."),e=t),a(o+' calculation method set to "'+e+'"')),e}function y(){re=p(re,ie,ze,"height")}function b(){Ne=p(Ne,Ie,Re,"width")}function T(){!0===K?(h("add"),x()):a("Auto Resize disabled")}function E(){a("Disable outgoing messages"),pe=!1}function S(){a("Remove event listener: Message"),n(e,"message",U)}function O(){null!==Q&&Q.disconnect()}function M(){h("remove"),O(),clearInterval(le)}function I(){E(),S(),!0===K&&M()}function N(){var e=document.createElement("div");e.style.clear="both",e.style.display="block",document.body.appendChild(e)}function k(){function n(){return{x:void 0!==e.pageXOffset?e.pageXOffset:document.documentElement.scrollLeft,y:void 0!==e.pageYOffset?e.pageYOffset:document.documentElement.scrollTop}}function o(e){var t=e.getBoundingClientRect(),o=n();return{x:parseInt(t.left,10)+parseInt(o.x,10),y:parseInt(t.top,10)+parseInt(o.y,10)}}function i(e){function t(e){var t=o(e);a("Moving to in page link (#"+n+") at x: "+t.x+" y: "+t.y),J(t.y,t.x,"scrollToOffset")}var n=e.split("#")[1]||e,i=decodeURIComponent(n),r=document.getElementById(i)||document.getElementsByName(i)[0];void 0!==r?t(r):(a("In page link (#"+n+") not found in iFrame, so sending to parent"),J(0,0,"inPageLink","#"+n))}function r(){""!==location.hash&&"#"!==location.hash&&i(location.href)}function c(){function e(e){function n(e){e.preventDefault(),i(this.getAttribute("href"))}"#"!==e.getAttribute("href")&&t(e,"click",n)}Array.prototype.forEach.call(document.querySelectorAll('a[href^="#"]'),e)}function s(){t(e,"hashchange",r)}function l(){setTimeout(r,te)}function d(){Array.prototype.forEach&&document.querySelectorAll?(a("Setting up location.hash handlers"),c(),s(),l()):u("In page linking not fully supported in this browser! (See README.md for IE8 workaround)")}return ce.enable?d():a("In page linking not enabled"),{findTarget:i}}function w(){a("Enable public methods"),ke.parentIFrame={autoResize:function(e){return!0===e&&!1===K?(K=!0,T()):!1===e&&!0===K&&(K=!1,M()),K},close:function(){J(0,0,"close"),I()},getId:function(){return ge},getPageInfo:function(e){"function"==typeof e?(Ae=e,J(0,0,"pageInfo")):(Ae=function(){},J(0,0,"pageInfoStop"))},moveToAnchor:function(e){ce.findTarget(e)},reset:function(){V("parentIFrame.reset")},scrollTo:function(e,t){J(t,e,"scrollTo")},scrollToOffset:function(e,t){J(t,e,"scrollToOffset")},sendMessage:function(e,t){J(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod:function(e){re=e,y()},setWidthCalculationMethod:function(e){Ne=e,b()},setTargetOrigin:function(e){a("Set targetOrigin: "+e),be=e},size:function(e,t){var n=""+(e?e:"")+(t?","+t:"");q("size","parentIFrame.size("+n+")",e,t)}}}function C(){0!==se&&(a("setInterval: "+se+"ms"),le=setInterval(function(){q("interval","setInterval: "+se)},Math.abs(se)))}function A(){function t(e){function t(e){!1===e.complete&&(a("Attach listeners to "+e.src),e.addEventListener("load",r,!1),e.addEventListener("error",u,!1),l.push(e))}"attributes"===e.type&&"src"===e.attributeName?t(e.target):"childList"===e.type&&Array.prototype.forEach.call(e.target.querySelectorAll("img"),t)}function n(e){l.splice(l.indexOf(e),1)}function o(e){a("Remove listeners from "+e.src),e.removeEventListener("load",r,!1),e.removeEventListener("error",u,!1),n(e)}function i(e,t,n){o(e.target),q(t,n+": "+e.target.src,void 0,void 0)}function r(e){i(e,"imageLoad","Image loaded")}function u(e){i(e,"imageLoadFailed","Image load failed")}function c(e){q("mutationObserver","mutationObserver: "+e[0].target+" "+e[0].type),e.forEach(t)}function s(){var e=document.querySelector("body"),t={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0};return f=new d(c),a("Create body MutationObserver"),f.observe(e,t),f}var l=[],d=e.MutationObserver||e.WebKitMutationObserver,f=s();return{disconnect:function(){"disconnect"in f&&(a("Disconnect body MutationObserver"),f.disconnect(),l.forEach(o))}}}function x(){var t=0>se;e.MutationObserver||e.WebKitMutationObserver?t?C():Q=A():(a("MutationObserver not supported in this browser!"),C())}function z(e,t){function n(e){var n=/^\d+(px)?$/i;if(n.test(e))return parseInt(e,X);var o=t.style.left,i=t.runtimeStyle.left;return t.runtimeStyle.left=t.currentStyle.left,t.style.left=e||0,e=t.style.pixelLeft,t.style.left=o,t.runtimeStyle.left=i,e}var o=0;return t=t||document.body,"defaultView"in document&&"getComputedStyle"in document.defaultView?(o=document.defaultView.getComputedStyle(t,null),o=null!==o?o[e]:0):o=n(t.currentStyle[e]),parseInt(o,X)}function R(e){e>Oe/2&&(Oe=2*e,a("Event throttle increased to "+Oe+"ms"))}function L(e,t){for(var n=t.length,i=0,r=0,u=o(e),c=xe(),s=0;n>s;s++)i=t[s].getBoundingClientRect()[e]+z("margin"+u,t[s]),i>r&&(r=i);return c=xe()-c,a("Parsed "+n+" HTML elements"),a("Element position calculated in "+c+"ms"),R(c),r}function F(e){return[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll()]}function P(e,t){function n(){return u("No tagged elements ("+t+") found on page"),oe}var o=document.querySelectorAll("["+t+"]");return 0===o.length?n():L(e,o)}function D(){return document.querySelectorAll("body *")}function H(e,t,n,o){function i(){oe=d,Me=f,J(oe,Me,e)}function r(){function e(e,t){var n=Math.abs(e-t)<=Te;return!n}return d=void 0!==n?n:ze[re](),f=void 0!==o?o:Re[Ne](),e(oe,d)||_&&e(Me,f)}function u(){return!(e in{init:1,interval:1,size:1})}function c(){return re in ve||_&&Ne in ve}function s(){a("No change in size detected")}function l(){u()&&c()?V(t):e in{interval:1}||s()}var d,f;r()||"init"===e?(W(),i()):l()}function q(e,t,n,o){function i(){e in{reset:1,resetPage:1,init:1}||a("Trigger event: "+t)}function r(){return Ee&&e in ee}r()?a("Trigger event cancelled: "+e):(i(),Le(e,t,n,o))}function W(){Ee||(Ee=!0,a("Trigger event lock on")),clearTimeout(Se),Se=setTimeout(function(){Ee=!1,a("Trigger event lock off"),a("--")},te)}function B(e){oe=ze[re](),Me=Re[Ne](),J(oe,Me,e)}function V(e){var t=re;re=ie,a("Reset trigger event: "+e),W(),B("reset"),re=t}function J(e,t,n,o,i){function r(){void 0===i?i=be:a("Message targetOrigin: "+i)}function u(){var r=e+":"+t,u=ge+":"+r+":"+n+(void 0!==o?":"+o:"");a("Sending message to host page ("+u+")"),ye.postMessage(fe+u,i)}!0===pe&&(r(),u())}function U(t){function n(){return fe===(""+t.data).substr(0,me)}function o(){ue=t.data,ye=t.source,c(),ne=!1,setTimeout(function(){ae=!1},te)}function i(){ae?a("Page reset ignored by init"):(a("Page size reset by host page"),B("resetPage"))}function r(){q("resizeParent","Parent window requested size check")}function s(){var e=d();ce.findTarget(e)}function l(){return t.data.split("]")[1].split(":")[0]}function d(){return t.data.substr(t.data.indexOf(":")+1)}function f(){return"iFrameResize"in e}function m(){var e=d();a("MessageCallback called from parent: "+e),we(JSON.parse(e)),a(" --")}function g(){var e=d();a("PageInfoFromParent called from parent: "+e),Ae(JSON.parse(e)),a(" --")}function v(){return t.data.split(":")[2]in{"true":1,"false":1}}function h(){switch(l()){case"reset":i();break;case"resize":r();break;case"moveToAnchor":s();break;case"message":m();break;case"pageInfo":g();break;default:f()||v()||u("Unexpected message ("+t.data+")")}}function p(){!1===ne?h():v()?o():a('Ignored message of type "'+l()+'". Received before initialization.')}n()&&p()}function j(){"loading"!==document.readyState&&e.parent.postMessage("[iFrameResizerChild]Ready","*")}var K=!0,X=10,Y="",$=0,G="",Q=null,Z="",_=!1,ee={resize:1,click:1},te=128,ne=!0,oe=1,ie="bodyOffset",re=ie,ae=!0,ue="",ce={},se=32,le=null,de=!1,fe="[iFrameSizer]",me=fe.length,ge="",ve={max:1,min:1,bodyScroll:1,documentElementScroll:1},he="child",pe=!0,ye=e.parent,be="*",Te=0,Ee=!1,Se=null,Oe=16,Me=1,Ie="scroll",Ne=Ie,ke=e,we=function(){u("MessageCallback function not defined")},Ce=function(){},Ae=function(){},xe=Date.now||function(){return(new Date).getTime()},ze={bodyOffset:function(){return document.body.offsetHeight+z("marginTop")+z("marginBottom")},offset:function(){return ze.bodyOffset()},bodyScroll:function(){return document.body.scrollHeight},documentElementOffset:function(){return document.documentElement.offsetHeight},documentElementScroll:function(){return document.documentElement.scrollHeight},max:function(){return Math.max.apply(null,F(ze))},min:function(){return Math.min.apply(null,F(ze))},grow:function(){return ze.max()},lowestElement:function(){return Math.max(ze.bodyOffset(),L("bottom",D()))},taggedElement:function(){return P("bottom","data-iframe-height")}},Re={bodyScroll:function(){return document.body.scrollWidth},bodyOffset:function(){return document.body.offsetWidth},documentElementScroll:function(){return document.documentElement.scrollWidth},documentElementOffset:function(){return document.documentElement.offsetWidth},scroll:function(){return Math.max(Re.bodyScroll(),Re.documentElementScroll())},max:function(){return Math.max.apply(null,F(Re))},min:function(){return Math.min.apply(null,F(Re))},rightMostElement:function(){return L("right",D())},taggedElement:function(){return P("right","data-iframe-width")}},Le=i(H);t(e,"message",U),j()}(window||{}); |