-
Notifications
You must be signed in to change notification settings - Fork 0
/
seamless.parent.min.js
1 lines (1 loc) · 16.7 KB
/
seamless.parent.min.js
1
var NO_JQUERY={};!function(e,t,n){if(!("console"in e)){var a=e.console={};a.log=a.warn=a.error=a.debug=function(){}}t===NO_JQUERY&&(t={fn:{},extend:function(){for(var e=arguments[0],t=1,n=arguments.length;t<n;t++){var a=arguments[t];for(var s in a)e[s]=a[s]}return e}}),t.fn.pm=function(){return console.log("usage: \nto send: $.pm(options)\nto receive: $.pm.bind(type, fn, [origin])"),this},t.pm=e.pm=function(e){s.send(e)},t.pm.bind=e.pm.bind=function(e,t,n,a,r){s.bind(e,t,n,a,!0===r)},t.pm.unbind=e.pm.unbind=function(e,t){s.unbind(e,t)},t.pm.origin=e.pm.origin=null,t.pm.poll=e.pm.poll=200;var s={send:function(e){var n=t.extend({},s.defaults,e),a=n.target;if(!n.target)return void console.warn("postmessage target window required");if(!n.type)return void console.warn("postmessage type required");var r={data:n.data,type:n.type};n.success&&(r.callback=s._callback(n.success)),n.error&&(r.errback=s._callback(n.error)),"postMessage"in a&&!n.hash?(s._bind(),a.postMessage(JSON.stringify(r),n.origin||"*")):(s.hash._bind(),s.hash.send(n,r))},bind:function(e,t,n,a,r){s._replyBind(e,t,n,a,r)},_replyBind:function(n,a,r,i,o){"postMessage"in e&&!i?s._bind():s.hash._bind();var l=s.data("listeners.postmessage");l||(l={},s.data("listeners.postmessage",l));var c=l[n];c||(c=[],l[n]=c),c.push({fn:a,callback:o,origin:r||t.pm.origin})},unbind:function(e,t){var n=s.data("listeners.postmessage");if(n)if(e)if(t){var a=n[e];if(a){for(var r=[],i=0,o=a.length;i<o;i++){var l=a[i];l.fn!==t&&r.push(l)}n[e]=r}}else delete n[e];else for(var i in n)delete n[i]},data:function(e,t){return void 0===t?s._data[e]:(s._data[e]=t,t)},_data:{},_CHARS:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),_random:function(){for(var e=[],t=0;t<32;t++)e[t]=s._CHARS[0|32*Math.random()];return e.join("")},_callback:function(e){var t=s.data("callbacks.postmessage");t||(t={},s.data("callbacks.postmessage",t));var n=s._random();return t[n]=e,n},_bind:function(){s.data("listening.postmessage")||(e.addEventListener?e.addEventListener("message",s._dispatch,!1):e.attachEvent&&e.attachEvent("onmessage",s._dispatch),s.data("listening.postmessage",1))},_dispatch:function(e){function t(t){n.callback&&s.send({target:e.source,data:t,type:n.callback})}try{var n=JSON.parse(e.data)}catch(e){return void console.warn("postmessage data invalid json: ",e)}if(!n.type)return void console.warn("postmessage message type required");var a=s.data("callbacks.postmessage")||{},r=a[n.type];if(r)r(n.data);else for(var i=s.data("listeners.postmessage")||{},o=i[n.type]||[],l=0,c=o.length;l<c;l++){var u=o[l];if(u.origin&&"*"!==u.origin&&e.origin!==u.origin){if(console.warn("postmessage message origin mismatch",e.origin,u.origin),n.errback){var f={message:"postmessage origin mismatch",origin:[e.origin,u.origin]};s.send({target:e.source,data:f,type:n.errback})}}else try{u.callback?u.fn(n.data,t,e):t(u.fn(n.data,e))}catch(t){if(!n.errback)throw t;s.send({target:e.source,data:t,type:n.errback})}}}};s.hash={send:function(t,n){var a=t.target,r=t.url;if(!r)return void console.warn("postmessage target window url is required");r=s.hash._url(r);var i,o=s.hash._url(e.location.href);if(e==a.parent)i="parent";else try{for(var l=0,c=parent.frames.length;l<c;l++){if(parent.frames[l]==e){i=l;break}}}catch(t){i=e.name}if(null==i)return void console.warn("postmessage windows must be direct parent/child windows and the child must be available through the parent window.frames list");var u={"x-requested-with":"postmessage",source:{name:i,url:o},postmessage:n},f="#x-postmessage-id="+s._random();a.location=r+f+encodeURIComponent(JSON.stringify(u))},_regex:/^\#x\-postmessage\-id\=(\w{32})/,_regex_len:"#x-postmessage-id=".length+32,_bind:function(){s.data("polling.postmessage")||(setInterval(function(){var t=""+e.location.hash,n=s.hash._regex.exec(t);if(n){var a=n[1];s.hash._last!==a&&(s.hash._last=a,s.hash._dispatch(t.substring(s.hash._regex_len)))}},t.pm.poll||200),s.data("polling.postmessage",1))},_dispatch:function(t){function n(e){a.callback&&s.send({target:o,data:e,type:a.callback,hash:!0,url:t.source.url})}if(t){try{if(t=JSON.parse(decodeURIComponent(t)),!("postmessage"===t["x-requested-with"]&&t.source&&null!=t.source.name&&t.source.url&&t.postmessage))return}catch(e){return}var a=t.postmessage,r=s.data("callbacks.postmessage")||{},i=r[a.type];if(i)i(a.data);else{var o;o="parent"===t.source.name?e.parent:e.frames[t.source.name];for(var l=s.data("listeners.postmessage")||{},c=l[a.type]||[],u=0,f=c.length;u<f;u++){var d=c[u];if(d.origin){var p=/https?\:\/\/[^\/]*/.exec(t.source.url)[0];if("*"!==d.origin&&p!==d.origin){if(console.warn("postmessage message origin mismatch",p,d.origin),a.errback){var g={message:"postmessage origin mismatch",origin:[p,d.origin]};s.send({target:o,data:g,type:a.errback,hash:!0,url:t.source.url})}continue}}try{d.callback?d.fn(a.data,n):n(d.fn(a.data))}catch(e){if(!a.errback)throw e;s.send({target:o,data:e,type:a.errback,hash:!0,url:t.source.url})}}}}},_url:function(e){return(""+e).replace(/#.*$/,"")}},t.extend(s,{defaults:{target:null,url:null,type:null,data:null,success:null,error:null,origin:"*",hash:!1}})}(this,"undefined"==typeof jQuery?NO_JQUERY:jQuery),"JSON"in window&&window.JSON||(JSON={}),function(){function f(e){return e<10?"0"+e:e}function quote(e){return escapable.lastIndex=0,escapable.test(e)?'"'+e.replace(escapable,function(e){var t=meta[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function str(e,t){var n,a,s,r,i,o=gap,l=t[e];switch(l&&"object"==typeof l&&"function"==typeof l.toJSON&&(l=l.toJSON(e)),"function"==typeof rep&&(l=rep.call(t,e,l)),typeof l){case"string":return quote(l);case"number":return isFinite(l)?String(l):"null";case"boolean":case"null":return String(l);case"object":if(!l)return"null";if(gap+=indent,i=[],"[object Array]"===Object.prototype.toString.apply(l)){for(r=l.length,n=0;n<r;n+=1)i[n]=str(n,l)||"null";return s=0===i.length?"[]":gap?"[\n"+gap+i.join(",\n"+gap)+"\n"+o+"]":"["+i.join(",")+"]",gap=o,s}if(rep&&"object"==typeof rep)for(r=rep.length,n=0;n<r;n+=1)"string"==typeof(a=rep[n])&&(s=str(a,l))&&i.push(quote(a)+(gap?": ":":")+s);else for(a in l)Object.hasOwnProperty.call(l,a)&&(s=str(a,l))&&i.push(quote(a)+(gap?": ":":")+s);return s=0===i.length?"{}":gap?"{\n"+gap+i.join(",\n"+gap)+"\n"+o+"}":"{"+i.join(",")+"}",gap=o,s}}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(e){return this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z"},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(e){return this.valueOf()});var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;"function"!=typeof JSON.stringify&&(JSON.stringify=function(e,t,n){var a;if(gap="",indent="","number"==typeof n)for(a=0;a<n;a+=1)indent+=" ";else"string"==typeof n&&(indent=n);if(rep=t,t&&"function"!=typeof t&&("object"!=typeof t||"number"!=typeof t.length))throw new Error("JSON.stringify");return str("",{"":e})}),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){function walk(e,t){var n,a,s=e[t];if(s&&"object"==typeof s)for(n in s)Object.hasOwnProperty.call(s,n)&&(a=walk(s,n),void 0!==a?s[n]=a:delete s[n]);return reviver.call(e,t,s)}var j;if(cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(e){return"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}();try{var ce=new window.CustomEvent("test");if(ce.preventDefault(),!0!==ce.defaultPrevented)throw new Error("Could not prevent default")}catch(e){var CustomEvent=function(e,t){var n,a;return t=t||{bubbles:!1,cancelable:!1,detail:void 0},n=document.createEvent("CustomEvent"),n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),a=n.preventDefault,n.preventDefault=function(){a.call(this);try{Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})}catch(e){this.defaultPrevented=!0}},n};CustomEvent.prototype=window.Event.prototype,window.CustomEvent=CustomEvent}!function(e,t){"use strict";e.SeamlessBase={isNumeric:function(e){return e-parseFloat(e)+1>=0},getElement:function(e){var n="querySelectorAll";0===e.indexOf("#")&&(n="getElementById",e=e.substr(1,e.length));var a=t[n](e);return a&&"querySelectorAll"===n?a[0]:a},elementHeight:function(e){var n=0,a=0;return t.all?(n=e.currentStyle.height,this.isNumeric(n)||(n=e.offsetHeight),n=parseInt(n,10),a=parseInt(e.currentStyle.marginTop,10)+parseInt(e.currentStyle.marginBottom,10)):(n=parseInt(t.defaultView.getComputedStyle(e,"").getPropertyValue("height"),10),a=parseInt(t.defaultView.getComputedStyle(e,"").getPropertyValue("margin-top"),10)+parseInt(t.defaultView.getComputedStyle(e,"").getPropertyValue("margin-bottom"),10)),n+a},hasClass:function(e,t){return e.classList?e.classList.contains(t):!!e.className.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))},addClass:function(e,t){e.classList?e.classList.add(t):this.hasClass(e,t)||(e.className+=" "+t)},removeClass:function(e,t){if(e.classList)e.classList.remove(t);else if(this.hasClass(e,t)){var n=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className=e.className.replace(n," ")}},getParam:function(t,n){n=n||e.location.search;var a="[?&]"+t+"=([^&#]*)",s=new RegExp(a),r=s.exec(n);return null===r?"":decodeURIComponent(r[1].replace(/\+/g," "))},filterText:function(e){return e.replace(/[<>]/g,"")},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},setStyle:function(t,n){n.length>0&&(n="string"==typeof n?n:n.join(" "),n=e.SeamlessBase.filterText(n),t.styleSheet?t.styleSheet.cssText=n:t.innerHTML=n)},injectStyles:function(n){var a=this.getElement("style#injected-styles");if(a)e.SeamlessBase.setStyle(a,n);else{var s=t.createElement("style");s.setAttribute("type","text/css"),s.setAttribute("id","injected-styles"),e.SeamlessBase.setStyle(s,n);var r=t.head||t.getElementsByTagName("head")[0];r&&r.appendChild(s)}},injectAppendedStyles:function(e){var n=e.join(";"),a=t.head||t.getElementsByTagName("head")[0],s=t.createElement("style");s.type="text/css",s.styleSheet?s.styleSheet.cssText=n:s.appendChild(t.createTextNode(n)),a.appendChild(s)}}}(window,document),function(e){"use strict";e.SeamlessConnection=function(e,t){this.id=0,this.target=e,this.url=t,this.active=!1,this.queue=[]},e.SeamlessConnection.prototype.send=function(t){this.active&&this.target?(t=t||{},t.hasOwnProperty("data")||(t={data:t}),t.target=this.target,t.url=this.url||"index.html",t.type=t.type||"seamless_data",t.data=t.data||{},t.data.__id=this.id,e.pm(t)):this.queue.push(t)},e.SeamlessConnection.prototype.receive=function(t,n){"function"==typeof t&&(n=t,t="seamless_data");var a=this;e.pm.bind(t,function(e,t){return!(!e.__id||e.__id!==a.id)&&n(e,t)})},e.SeamlessConnection.prototype.setActive=function(e){if(this.active=e,this.queue.length>0){for(var t in this.queue)this.send(this.queue[t]);this.queue=[],this.queue.length=0}}}(window),function(e,t,n,a){"use strict";if(!e.hasOwnProperty("pm"))return void console.log("You must install the postmessage.js module to use seamless.js.");e.pm.bind("seamless_noiframe",function(t){t.href=t.href.replace(/noiframe\=[^&?#]+/,""),e.location.replace(t.href)}),e.seamlessOpenFallback=function(t,n,a,s){s.preventDefault?(s.preventDefault(),s.stopPropagation()):s.returnValue=!1,e.open(t,"",["width="+n,"height="+a,"menubar=no","titlebar=no","toolbar=no","status=no","scrollbars=yes","chrome=yes"].join(","))};var s=[],r=!1,i="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),o=function(){for(var e=[],t=0;t<32;t++)e[t]=i[0|32*Math.random()];return e.join("")};e.pm.bind("seamless_ready",function(e,t){if(!r){r=!0;for(var n in s)s.hasOwnProperty(n)&&s[n].seamless_ready(e,t);r=!1}}),e.pm.bind("seamless_update",function(e,t){for(var n in s)if(s.hasOwnProperty(n)){var a=s[n];if(a.connection.id===e.__id)return a.seamless_update(e,t)}return e.height=0,e}),e.pm.bind("seamless_error",function(e,t){for(var n in s)s.hasOwnProperty(n)&&s[n].seamless_error(e,t)});var l=function(n){var a={showLoadingIndicator:!0,loading:"Loading ...",spinner:"https://unpkg.com/seamless@latest/src/loader.gif",onConnect:null,styles:[],fallback:!0,fallbackParams:"",fallbackText:"",fallbackLinkText:"Click here",fallbackLinkAfter:" to open in a separate window.",fallbackStyles:["padding: 15px","border: 1px solid transparent","border-radius: 4px","color: #3a87ad","background-color: #d9edf7","border-color: #bce8f1"],fallbackLinkStyles:["display: inline-block","color: #333","border: 1px solid #ccc","background-color: #fff","padding: 5px 10px","text-decoration: none","font-size: 12px","line-height: 1.5","border-radius: 6px","font-weight: 400","cursor: pointer","-webkit-user-select: none","-moz-user-select: none","-ms-user-select: none","user-select: none"],fallbackLinkHoverStyles:["background-color:#ebebeb","border-color:#adadad"],fallbackWindowWidth:960,fallbackWindowHeight:800};n=n||{};for(var r in a)n.hasOwnProperty(r)||(n[r]=a[r]);var i=this.length?this[0]:this;i.seamless_options=n,s.push(i);var l=(i.getAttribute("name")||i.getAttribute("id"),i.getAttribute("src"));i.connection=new e.SeamlessConnection(i.contentWindow,l),i.send=function(e){i.connection.send.call(i.connection,e)},i.receive=function(e,t){i.connection.receive.call(i.connection,e,t)};var c={scrolling:"no",seamless:"seamless",width:"100%",height:"0px",marginheight:"0",marginwidth:"0",frameborder:"0",horizontalscrolling:"no",verticalscrolling:"no",style:"border: none; overflow-y: hidden;"};for(var r in c)i.setAttribute(r,c[r]);if(n.showLoadingIndicator){var u=t.createElement("div"),f="background: url("+n.spinner+") no-repeat 10px 13px;";f+="padding: 10px 10px 10px 60px;",f+="width: 100%;",u.setAttribute("style",f);var d=t.createTextNode(n.loading);u.appendChild(d),i.parentNode.insertBefore(u,i)}var p=!0,g=function(){p=!1,void 0!==u&&u.parentNode.removeChild(u)};if(n.fallback){n.fallbackParams&&(l+=-1===l.search(/\?/)?"?":"&",l+=n.fallbackParams);var m=e.SeamlessBase.getElement("#seamless-fallback-styles");if(!m){var h=function(t){return e.SeamlessBase.filterText(t.join(";"))};m=t.createElement("style"),m.setAttribute("id","seamless-fallback-styles"),m.setAttribute("type","text/css"),e.SeamlessBase.setStyle(m,".seamless-fallback.seamless-styles {"+h(n.fallbackStyles)+"}.seamless-fallback em { padding: 5px; }.seamless-fallback-link.seamless-styles {"+h(n.fallbackLinkStyles)+"}.seamless-fallback-link.seamless-styles:hover {"+h(n.fallbackLinkHoverStyles)+"}"),i.parentNode.insertBefore(m,i)}var b=['"'+l+'"',n.fallbackWindowWidth,n.fallbackWindowHeight],v=t.createElement("a");v.setAttribute("class","seamless-fallback-link"),v.setAttribute("href","#"),v.setAttribute("onclick","seamlessOpenFallback("+b.join(",")+", event)");var y=t.createElement("div");y.setAttribute("class","seamless-fallback"),y.appendChild(t.createElement("em")),i.parentNode.insertBefore(y,i.nextSibling);var k=function(n,a,s,r){r?(e.SeamlessBase.addClass(y,"seamless-styles"),e.SeamlessBase.addClass(v,"seamless-styles")):(e.SeamlessBase.removeClass(y,"seamless-styles"),e.SeamlessBase.removeClass(v,"seamless-styles"));var i=y.getElementsByTagName("em")[0];i&&(i.innerHTML=e.SeamlessBase.filterText(n)+" ",v.innerHTML=e.SeamlessBase.filterText(a),i.appendChild(v),s&&i.appendChild(t.createTextNode(s)))};n.fallbackText&&k(n.fallbackText,n.fallbackLinkText,n.fallbackLinkAfter,!1),e.onerror=function(){var e="An error has been detected on this page, ";e+="which may cause problems with the operation of this application.",k(e,n.fallbackLinkText,n.fallbackLinkAfter,!0)},setTimeout(function(){p&&(g(),k("An error has been detected on this page.",n.fallbackLinkText,n.fallbackLinkAfter,!0))},3e4)}return i.seamless_ready=function(t,n){i.connection.id||(i.connection.id=o());var a={id:i.connection.id,styles:i.seamless_options.styles};i.connection.target||(i.connection.target=i[0].contentWindow),e.pm({type:"seamless_connect",target:i.connection.target,url:i.connection.url,data:a,success:function(e){i.seamless_options.onConnect&&i.seamless_options.onConnect(e)}}),i.dispatchEvent(new CustomEvent("connected"))},i.seamless_update=function(e,t){return p&&(g(),i.connection.setActive(!0)),e.height>=0&&(i.style.height=e.height+"px",i.setAttribute("height",e.height+"px")),e},i.seamless_error=function(e,t){g(),i.hide(),k(e.msg,e.linkText,e.afterText,!0)},i};n&&n.fn&&(n.fn.seamless=l),e.seamless=function(e,t){return l.call(e,t)}}(window,document,"undefined"==typeof jQuery?{}:jQuery);