1/*! jQuery ResponsiveIframe - v0.0.3 - 2013-09-05 2* https://github.com/npr/responsiveiframe 3* Copyright (c) 2013 Irakli Nadareishvili; Licensed MIT, GPL */ 4if (typeof jQuery !== 'undefined') { 5 (function( $ ){ 6 var settings = { 7 xdomain: '*', 8 ie : navigator.userAgent.toLowerCase().indexOf('msie') > -1, 9 scrollToTop: true 10 }; 11 12 var methods = { 13 // initialization for the parent, the one housing this 14 init: function() { 15 return this.each(function(self){ 16 var $this = $(this); 17 18 if (window.postMessage) { 19 if (window.addEventListener) { 20 window.addEventListener('message', function(e) { 21 privateMethods.messageHandler($this,e); 22 } , false); 23 } else if (window.attachEvent) { 24 window.attachEvent('onmessage', function(e) { 25 privateMethods.messageHandler($this,e); 26 }, $this); 27 } 28 } else { 29 setInterval(function () { 30 var hash = window.location.hash, matches = hash.match(/^#h(\d+)(s?)$/); 31 if (matches) { 32 privateMethods.setHeight($this, matches[1]); 33 if (settings.scrollToTop && matches[2] === 's'){ 34 scroll(0,0); 35 } 36 } 37 }, 150); 38 } 39 }); 40 } 41 }; 42 43 var privateMethods = { 44 messageHandler: function (elem, e) { 45 var height, 46 r, 47 matches, 48 strD; 49 50 if (settings.xdomain !== '*') { 51 var regex = new RegExp(settings.xdomain + '$'); 52 if(e.origin == "null"){ 53 throw new Error("messageHandler( elem, e): There is no origin. You are viewing the page from your file system. Please run through a web server."); 54 } 55 if(e.origin.match(regex)){ 56 matches = true; 57 }else{ 58 throw new Error("messageHandler( elem, e): The orgin doesn't match the responsiveiframe xdomain."); 59 } 60 61 } 62 63 if(settings.xdomain === '*' || matches ) { 64 strD = e.data + ""; 65 r = strD.match(/^(\d+)(s?)$/); 66 if(r && r.length === 3){ 67 height = parseInt(r[1], 10); 68 if (!isNaN(height)) { 69 try { 70 privateMethods.setHeight(elem, height); 71 } catch (ex) {} 72 } 73 if (settings.scrollToTop && r[2] === "s"){ 74 scroll(0,0); 75 } 76 } 77 } 78 }, 79 80 // Sets the height of the iframe 81 setHeight : function (elem, height) { 82 elem.css('height', height + 'px'); 83 }, 84 getDocHeight: function () { 85 var D = document; 86 return Math.min( 87 Math.max(D.body.scrollHeight, D.documentElement.scrollHeight), 88 Math.max(D.body.offsetHeight, D.documentElement.offsetHeight), 89 Math.max(D.body.clientHeight, D.documentElement.clientHeight) 90 ); 91 } 92 }; 93 94 $.fn.responsiveIframe = function( method ) { 95 if ( methods[method] ) { 96 return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 )); 97 } else if ( typeof method === 'object' || ! method ) { 98 $.extend(settings, arguments[0]); 99 return methods.init.apply( this ); 100 } else { 101 $.error( 'Method ' + method + ' does not exist on jQuery.responsiveIframe' ); 102 } 103 }; 104 }( jQuery )); 105} 106 107;(function(){ 108 var self, 109 module, 110 ResponsiveIframe = function () {self = this;}; 111 112 ResponsiveIframe.prototype.allowResponsiveEmbedding = function() { 113 if (window.addEventListener) { 114 window.addEventListener("load", self.messageParent, false); 115 window.addEventListener("resize", self.messageParent, false); 116 } else if (window.attachEvent) { 117 window.attachEvent("onload", self.messageParent); 118 window.attachEvent("onresize", self.messageParent); 119 } 120 }; 121 122 ResponsiveIframe.prototype.messageParent = function(scrollTop) { 123 var h = document.body.offsetHeight; 124 h = (scrollTop)? h+'s':h; 125 if(top.postMessage){ 126 top.postMessage( h , '*'); 127 } else { 128 window.location.hash = 'h'+h; 129 } 130 }; 131 132 function responsiveIframe() { 133 return new ResponsiveIframe(); 134 } 135 136 // expose
137 if ('undefined' === typeof exports) { 138 window.responsiveIframe = responsiveIframe; 139 } else { 140 module.exports.responsiveIframe = responsiveIframe; 141 } 142}());
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.