Comparing version 0.4.0 to 0.4.1
{ | ||
"name": "pym.js", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"homepage": "http://blog.apps.npr.org/pym.js/", | ||
@@ -5,0 +5,0 @@ "authors": ["NPR"], |
@@ -1,2 +0,2 @@ | ||
/*! pym.js - v0.4.0 - 2014-12-12 */ | ||
/*! pym.js - v0.4.1 - 2014-12-12 */ | ||
/* | ||
@@ -3,0 +3,0 @@ * Pym.js is library that resizes an iframe based on the width of the parent and the resulting height of the child. |
@@ -1,2 +0,2 @@ | ||
/*! pym.js - v0.4.0 - 2014-12-12 */ | ||
/*! pym.js - v0.4.1 - 2014-12-12 */ | ||
!function(a){"function"==typeof define&&define.amd?define(a):"undefined"!=typeof module&&module.exports?module.exports=a():window.pym=a.call(this)}(function(){var a="xPYMx",b={},c=function(a){var b=new RegExp("[\\?&]"+a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]")+"=([^&#]*)"),c=b.exec(location.search);return null===c?"":decodeURIComponent(c[1].replace(/\+/g," "))},d=function(a,b){return"*"===b.xdomain||a.origin.match(new RegExp(b.xdomain+"$"))?!0:void 0},e=function(b,c,d){var e=["pym",b,c,d];return e.join(a)},f=function(b){var c=["pym",b,"(\\S+)","(.+)"];return new RegExp("^"+c.join(a)+"$")},g=function(){for(var a=document.querySelectorAll("[data-pym-src]:not([data-pym-auto-initialized])"),c=a.length,d=0;c>d;++d){var e=a[d];e.setAttribute("data-pym-auto-initialized",""),""===e.id&&(e.id="pym-"+d);var f=e.getAttribute("data-pym-src"),g=e.getAttribute("data-pym-xdomain"),h={};g&&(h.xdomain=g),new b.Parent(e.id,f,h)}};return b.Parent=function(a,b,c){this.id=a,this.url=b,this.el=document.getElementById(a),this.iframe=null,this.settings={xdomain:"*"},this.messageRegex=f(this.id),this.messageHandlers={},this._constructIframe=function(){var a=this.el.offsetWidth.toString();this.iframe=document.createElement("iframe");var b="",c=this.url.indexOf("#");c>-1&&(b=this.url.substring(c,this.url.length),this.url=this.url.substring(0,c)),this.url+=this.url.indexOf("?")<0?"?":"&",this.iframe.src=this.url+"initialWidth="+a+"&childId="+this.id+b,this.iframe.setAttribute("width","100%"),this.iframe.setAttribute("scrolling","no"),this.iframe.setAttribute("marginheight","0"),this.iframe.setAttribute("frameborder","0"),this.el.appendChild(this.iframe);var d=this;window.addEventListener("resize",function(){d.sendWidth()})},this._fire=function(a,b){if(a in this.messageHandlers)for(var c=0;c<this.messageHandlers[a].length;c++)this.messageHandlers[a][c].call(this,b)},this._processMessage=function(a){if(d(a,this.settings)){var b=a.data.match(this.messageRegex);if(!b||3!==b.length)return!1;var c=b[1],e=b[2];this._fire(c,e)}},this._onHeightMessage=function(a){var b=parseInt(a);this.iframe.setAttribute("height",b+"px")},this.onMessage=function(a,b){a in this.messageHandlers||(this.messageHandlers[a]=[]),this.messageHandlers[a].push(b)},this.sendMessage=function(a,b){this.el.getElementsByTagName("iframe")[0].contentWindow.postMessage(e(this.id,a,b),"*")},this.sendWidth=function(){var a=this.el.offsetWidth.toString();this.sendMessage("width",a)};for(var g in c)this.settings[g]=c[g];this.onMessage("height",this._onHeightMessage);var h=this;return window.addEventListener("message",function(a){return h._processMessage(a)},!1),this._constructIframe(),this},b.Child=function(b){this.parentWidth=null,this.id=null,this.settings={renderCallback:null,xdomain:"*",polling:0},this.messageRegex=null,this.messageHandlers={},this.onMessage=function(a,b){a in this.messageHandlers||(this.messageHandlers[a]=[]),this.messageHandlers[a].push(b)},this._fire=function(a,b){if(a in this.messageHandlers)for(var c=0;c<this.messageHandlers[a].length;c++)this.messageHandlers[a][c].call(this,b)},this._processMessage=function(a){if(d(a,this.settings)){var b=a.data.match(this.messageRegex);if(b&&3===b.length){var c=b[1],e=b[2];this._fire(c,e)}}},this.sendMessage=function(a,b){window.parent.postMessage(e(this.id,a,b),"*")},this.sendHeight=function(){var a=document.getElementsByTagName("body")[0].offsetHeight.toString();h.sendMessage("height",a)},this._onWidthMessage=function(a){var b=parseInt(a);b!==this.parentWidth&&(this.parentWidth=b,this.settings.renderCallback&&this.settings.renderCallback(b),this.sendHeight())},this.id=c("childId")||b.id,this.messageRegex=new RegExp("^pym"+a+this.id+a+"(\\S+)"+a+"(.+)$");var f=parseInt(c("initialWidth"));this.onMessage("width",this._onWidthMessage);for(var g in b)this.settings[g]=b[g];var h=this;return window.addEventListener("message",function(a){h._processMessage(a)},!1),this.settings.renderCallback&&this.settings.renderCallback(f),this.sendHeight(),this.settings.polling&&window.setInterval(this.sendHeight,this.settings.polling),this},g(),b}); |
{ | ||
"name": "pym.js", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Resize an iframe responsively depending on the height of its content and the width of its container.", | ||
@@ -5,0 +5,0 @@ "main": "src/pym.js", |
@@ -25,2 +25,14 @@ # Pym.js | ||
Uniminifiedd source can be regenerated with: | ||
``` | ||
grunt concat | ||
``` | ||
Minified source can be regenerated with: | ||
``` | ||
grunt uglify | ||
``` | ||
API documention can be generated with [jsdoc](https://github.com/jsdoc3/jsdoc): | ||
@@ -43,1 +55,5 @@ | ||
* [David Rogers](https://github.com/al-the-x) | ||
* [Noah Veltman](https://github.com/veltman) | ||
* [Andrei Scheinkman](https://github.com/ascheink) | ||
* [Thomas Wilburn](https://github.com/thomaswilburn) | ||
* [Justin Dearing](https://github.com/zippy1981) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1821979
69
36442
58
1