From bf42400d54dc6493d5c0454c4b42b20a1e44cec7 Mon Sep 17 00:00:00 2001 From: Travis Tidwell Date: Mon, 3 Apr 2017 18:29:41 -0500 Subject: [PATCH] Adding CustomEvent polyfill. --- bower.json | 2 +- build/seamless.parent.js | 45 ++++++++++++++++++++++++++++++++++++ build/seamless.parent.min.js | 2 +- gulpfile.js | 5 +++- package.json | 5 +++- 5 files changed, 55 insertions(+), 4 deletions(-) diff --git a/bower.json b/bower.json index 51364db..7038299 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "seamless", - "version": "1.0.0", + "version": "1.1.0", "homepage": "https://github.com/travist/seamless.js", "authors": [ "Travis Tidwell " diff --git a/build/seamless.parent.js b/build/seamless.parent.js index 9e0357c..1956382 100644 --- a/build/seamless.parent.js +++ b/build/seamless.parent.js @@ -437,6 +437,51 @@ var NO_JQUERY = {}; **/ if (! ("JSON" in window && window.JSON)){JSON={}}(function(){function f(n){return n<10?"0"+n:n}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){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(key){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 quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i]/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 r={showLoadingIndicator:!0,loading:"Loading ...",spinner:"http://www.travistidwell.com/seamless.js/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 i in r)n.hasOwnProperty(i)||(n[i]=r[i]);var l=this.length?this[0]:this;l.seamless_options=n,s.push(l);var c=(l.getAttribute("name")||l.getAttribute("id"),l.getAttribute("src"));l.connection=new e.SeamlessConnection(l.contentWindow,c),l.send=function(e){l.connection.send.call(l.connection,e)},l.receive=function(e,t){l.connection.receive.call(l.connection,e,t)};var u={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 i in u)l.setAttribute(i,u[i]);if(n.showLoadingIndicator){var f=t.createElement("div"),p="background: url("+n.spinner+") no-repeat 10px 13px;";p+="padding: 10px 10px 10px 60px;",p+="width: 100%;",f.setAttribute("style",p);var d=t.createTextNode(n.loading);f.appendChild(d),l.parentNode.insertBefore(f,l)}var g=!0,m=function(){g=!1,f!==a&&f.parentNode.removeChild(f)};if(n.fallback){n.fallbackParams&&(c+=c.search(/\?/)===-1?"?":"&",c+=n.fallbackParams);var h=e.SeamlessBase.getElement("#seamless-fallback-styles");if(!h){var b=function(t){return e.SeamlessBase.filterText(t.join(";"))};h=t.createElement("style"),h.setAttribute("id","seamless-fallback-styles"),h.setAttribute("type","text/css"),e.SeamlessBase.setStyle(h,".seamless-fallback.seamless-styles {"+b(n.fallbackStyles)+"}.seamless-fallback em { padding: 5px; }.seamless-fallback-link.seamless-styles {"+b(n.fallbackLinkStyles)+"}.seamless-fallback-link.seamless-styles:hover {"+b(n.fallbackLinkHoverStyles)+"}"),l.parentNode.insertBefore(h,l)}var y=['"'+c+'"',n.fallbackWindowWidth,n.fallbackWindowHeight],v=t.createElement("a");v.setAttribute("class","seamless-fallback-link"),v.setAttribute("href","#"),v.setAttribute("onclick","seamlessOpenFallback("+y.join(",")+", event)");var k=t.createElement("div");k.setAttribute("class","seamless-fallback"),k.appendChild(t.createElement("em")),l.parentNode.insertBefore(k,l.nextSibling);var w=function(n,a,s,r){r?(e.SeamlessBase.addClass(k,"seamless-styles"),e.SeamlessBase.addClass(v,"seamless-styles")):(e.SeamlessBase.removeClass(k,"seamless-styles"),e.SeamlessBase.removeClass(v,"seamless-styles"));var i=k.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&&w(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.",w(e,n.fallbackLinkText,n.fallbackLinkAfter,!0)},setTimeout(function(){g&&(m(),w("An error has been detected on this page.",n.fallbackLinkText,n.fallbackLinkAfter,!0))},3e4)}return l.seamless_ready=function(t,n){l.connection.id||(l.connection.id=o());var a={id:l.connection.id,styles:l.seamless_options.styles};l.connection.target||(l.connection.target=l[0].contentWindow),e.pm({type:"seamless_connect",target:l.connection.target,url:l.connection.url,data:a,success:function(e){l.seamless_options.onConnect&&l.seamless_options.onConnect(e)}}),l.dispatchEvent(new CustomEvent("connected"))},l.seamless_update=function(e,t){return g&&(m(),l.connection.setActive(!0)),e.height>=0&&(l.style.height=e.height+"px",l.setAttribute("height",e.height+"px")),e},l.seamless_error=function(e,t){m(),l.hide(),w(e.msg,e.linkText,e.afterText,!0)},l};n&&n.fn&&(n.fn.seamless=l),e.seamless=function(e,t){return l.call(e,t)}}(window,document,"undefined"==typeof jQuery?{}:jQuery); \ No newline at end of file +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]/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 r={showLoadingIndicator:!0,loading:"Loading ...",spinner:"http://www.travistidwell.com/seamless.js/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 i in r)n.hasOwnProperty(i)||(n[i]=r[i]);var l=this.length?this[0]:this;l.seamless_options=n,s.push(l);var c=(l.getAttribute("name")||l.getAttribute("id"),l.getAttribute("src"));l.connection=new e.SeamlessConnection(l.contentWindow,c),l.send=function(e){l.connection.send.call(l.connection,e)},l.receive=function(e,t){l.connection.receive.call(l.connection,e,t)};var u={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 i in u)l.setAttribute(i,u[i]);if(n.showLoadingIndicator){var f=t.createElement("div"),d="background: url("+n.spinner+") no-repeat 10px 13px;";d+="padding: 10px 10px 10px 60px;",d+="width: 100%;",f.setAttribute("style",d);var p=t.createTextNode(n.loading);f.appendChild(p),l.parentNode.insertBefore(f,l)}var g=!0,m=function(){g=!1,f!==a&&f.parentNode.removeChild(f)};if(n.fallback){n.fallbackParams&&(c+=c.search(/\?/)===-1?"?":"&",c+=n.fallbackParams);var h=e.SeamlessBase.getElement("#seamless-fallback-styles");if(!h){var b=function(t){return e.SeamlessBase.filterText(t.join(";"))};h=t.createElement("style"),h.setAttribute("id","seamless-fallback-styles"),h.setAttribute("type","text/css"),e.SeamlessBase.setStyle(h,".seamless-fallback.seamless-styles {"+b(n.fallbackStyles)+"}.seamless-fallback em { padding: 5px; }.seamless-fallback-link.seamless-styles {"+b(n.fallbackLinkStyles)+"}.seamless-fallback-link.seamless-styles:hover {"+b(n.fallbackLinkHoverStyles)+"}"),l.parentNode.insertBefore(h,l)}var v=['"'+c+'"',n.fallbackWindowWidth,n.fallbackWindowHeight],y=t.createElement("a");y.setAttribute("class","seamless-fallback-link"),y.setAttribute("href","#"),y.setAttribute("onclick","seamlessOpenFallback("+v.join(",")+", event)");var w=t.createElement("div");w.setAttribute("class","seamless-fallback"),w.appendChild(t.createElement("em")),l.parentNode.insertBefore(w,l.nextSibling);var k=function(n,a,s,r){r?(e.SeamlessBase.addClass(w,"seamless-styles"),e.SeamlessBase.addClass(y,"seamless-styles")):(e.SeamlessBase.removeClass(w,"seamless-styles"),e.SeamlessBase.removeClass(y,"seamless-styles"));var i=w.getElementsByTagName("em")[0];i&&(i.innerHTML=e.SeamlessBase.filterText(n)+" ",y.innerHTML=e.SeamlessBase.filterText(a),i.appendChild(y),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(){g&&(m(),k("An error has been detected on this page.",n.fallbackLinkText,n.fallbackLinkAfter,!0))},3e4)}return l.seamless_ready=function(t,n){l.connection.id||(l.connection.id=o());var a={id:l.connection.id,styles:l.seamless_options.styles};l.connection.target||(l.connection.target=l[0].contentWindow),e.pm({type:"seamless_connect",target:l.connection.target,url:l.connection.url,data:a,success:function(e){l.seamless_options.onConnect&&l.seamless_options.onConnect(e)}}),l.dispatchEvent(new CustomEvent("connected"))},l.seamless_update=function(e,t){return g&&(m(),l.connection.setActive(!0)),e.height>=0&&(l.style.height=e.height+"px",l.setAttribute("height",e.height+"px")),e},l.seamless_error=function(e,t){m(),l.hide(),k(e.msg,e.linkText,e.afterText,!0)},l};n&&n.fn&&(n.fn.seamless=l),e.seamless=function(e,t){return l.call(e,t)}}(window,document,"undefined"==typeof jQuery?{}:jQuery); \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index cf65f4e..65cc8cc 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -54,7 +54,10 @@ gulp.task('scripts-child-nopm', function() { }); gulp.task('scripts-parent', function() { - return gulp.src(['lib/postmessage/postmessage.js'].concat(parentFiles)) + return gulp.src([ + 'lib/postmessage/postmessage.js', + 'node_modules/custom-event-polyfill/custom-event-polyfill.js' + ].concat(parentFiles)) .pipe(concat('seamless.parent.js')) .pipe(gulp.dest('build/')) .pipe(rename('seamless.parent.min.js')) diff --git a/package.json b/package.json index fef4c9e..5363984 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "seamless", - "version": "1.0.0", + "version": "1.1.0", "main": "build/seamless.parent.min.js", "devDependencies": { "gulp": "^3.9.1", @@ -8,5 +8,8 @@ "gulp-eslint": "^3.0.1", "gulp-rename": "^1.2.2", "gulp-uglify": "^2.0.0" + }, + "dependencies": { + "custom-event-polyfill": "^0.3.0" } }