@flourish/sdk 3.17.1 → 3.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/site/embedded.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(){"use strict";var e,i,t=!1;function n(e){if(t&&window.top!==window.self){var i=window;"srcdoc"===i.location.pathname&&(i=i.parent);var n,o=(n={},window._Flourish_template_id&&(n.template_id=window._Flourish_template_id),window.Flourish&&window.Flourish.app&&window.Flourish.app.loaded_template_id&&(n.template_id=window.Flourish.app.loaded_template_id),window._Flourish_visualisation_id&&(n.visualisation_id=window._Flourish_visualisation_id),window.Flourish&&window.Flourish.app&&window.Flourish.app.loaded_visualisation&&(n.visualisation_id=window.Flourish.app.loaded_visualisation.id),window.Flourish&&window.Flourish.app&&window.Flourish.app.story&&(n.story_id=window.Flourish.app.story.id,n.slide_count=window.Flourish.app.story.slides.length),window.Flourish&&window.Flourish.app&&window.Flourish.app.current_slide&&(n.slide_index=window.Flourish.app.current_slide.index+1),n),r={sender:"Flourish",method:"customerAnalytics"};for(var a in o)o.hasOwnProperty(a)&&(r[a]=o[a]);for(var a in e)e.hasOwnProperty(a)&&(r[a]=e[a]);i.parent.postMessage(JSON.stringify(r),"*")}}function o(e){if("function"!=typeof e)throw new Error("Analytics callback is not a function");window.Flourish._analytics_listeners.push(e)}function r(){t=!0;[{event_name:"click",action_name:"click",use_capture:!0},{event_name:"keydown",action_name:"key_down",use_capture:!0},{event_name:"mouseenter",action_name:"mouse_enter",use_capture:!1},{event_name:"mouseleave",action_name:"mouse_leave",use_capture:!1}].forEach((function(e){document.body.addEventListener(e.event_name,(function(){n({action:e.action_name})}),e.use_capture)}))}function a(){if(null==e){var i=function(){var e=window.location;"about:srcdoc"==e.href&&(e=window.parent.location);var i={};return function(e,t,n){for(;n=t.exec(e);)i[decodeURIComponent(n[1])]=decodeURIComponent(n[2])}(e.search.substring(1).replace(/\+/g,"%20"),/([^&=]+)=?([^&]*)/g),i}();e="referrer"in i?/^https:\/\/medium.com\//.test(i.referrer):!("auto"in i)}return e}function s(e){var i=e||window.innerWidth;return i>999?650:i>599?575:400}function l(e,t){if(window.top!==window.self){var n=window;if("srcdoc"==n.location.pathname&&(n=n.parent),i)return e=parseInt(e,10),void n.parent.postMessage({sentinel:"amp",type:"embed-size",height:e},"*");var o={sender:"Flourish",context:"iframe.resize",method:"resize",height:e,src:n.location.toString()};if(t)for(var r in t)o[r]=t[r];n.parent.postMessage(JSON.stringify(o),"*")}}function d(){return(-1!==navigator.userAgent.indexOf("Safari")||-1!==navigator.userAgent.indexOf("iPhone"))&&-1==navigator.userAgent.indexOf("Chrome")}function u(e){window.addEventListener("message",(function(i){if(null!=i.source&&(i.origin===document.location.origin||i.origin.match(/\/\/localhost:\d+$|\/\/flourish-api\.com$|\.flourish\.(?:local(:\d+)?|net|rocks|studio)$|\.uri\.sh$/))){var t;try{t=JSON.parse(i.data)}catch(e){return void console.warn("Unexpected non-JSON message: "+JSON.stringify(i.data))}if("Flourish"===t.sender){for(var n=document.querySelectorAll("iframe"),o=0;o<n.length;o++)if(n[o].contentWindow==i.source||n[o].contentWindow==i.source.parent)return void e(t,n[o]);console.warn("could not find frame",t)}}})),d()&&(window.addEventListener("resize",h),h())}function h(){for(var e=document.querySelectorAll(".flourish-embed"),i=0;i<e.length;i++){var t=e[i];if(!t.getAttribute("data-width")){var n=t.querySelector("iframe");if(n){var o=window.getComputedStyle(t),r=t.offsetWidth-parseFloat(o.paddingLeft)-parseFloat(o.paddingRight);n.style.width=r+"px"}}}}function c(e,i,t,n,o){var r=document.createElement("iframe");if(r.setAttribute("scrolling","no"),r.setAttribute("frameborder","0"),r.setAttribute("title","Interactive or visual content"),r.setAttribute("sandbox","allow-same-origin allow-forms allow-scripts allow-downloads allow-popups allow-popups-to-escape-sandbox allow-top-navigation-by-user-activation"),i.appendChild(r),r.offsetParent||"fixed"===getComputedStyle(r).position)f(e,i,r,t,n,o);else{var a={embed_url:e,container:i,iframe:r,width:t,height:n,play_on_load:o};if(window._flourish_poll_items?window._flourish_poll_items.push(a):window._flourish_poll_items=[a],window._flourish_poll_items.length>1)return r;var s=setInterval((function(){window._flourish_poll_items=window._flourish_poll_items.filter((function(e){return!e.iframe.offsetParent||(f(e.embed_url,e.container,e.iframe,e.width,e.height,e.play_on_load),!1)})),window._flourish_poll_items.length||clearInterval(s)}),500)}return r}function f(e,i,t,n,o,r){var a;return n&&"number"==typeof n?(a=n,n+="px"):n&&n.match(/^[ \t\r\n\f]*([+-]?\d+|\d*\.\d+(?:[eE][+-]?\d+)?)(?:\\?[Pp]|\\0{0,4}[57]0(?:\r\n|[ \t\r\n\f])?)(?:\\?[Xx]|\\0{0,4}[57]8(?:\r\n|[ \t\r\n\f])?)[ \t\r\n\f]*$/)&&(a=parseFloat(n)),o&&"number"==typeof o&&(o+="px"),n?t.style.width=n:d()?t.style.width=i.offsetWidth+"px":t.style.width="100%",!!o||(e.match(/\?/)?e+="&auto=1":e+="?auto=1",o=s(a||t.offsetWidth)+"px"),o&&("%"===o.charAt(o.length-1)&&(o=parseFloat(o)/100*i.parentNode.offsetHeight+"px"),t.style.height=o),t.setAttribute("src",e+(r?"#play-on-load":"")),t}function w(e){return!Array.isArray(e)&&"object"==typeof e&&null!=e}function p(e,i){for(var t in i)w(e[t])&&w(i[t])?p(e[t],i[t]):e[t]=i[t];return e}!function(){var e,t=window.top===window.self,h=t?null:(i="#amp=1"==window.location.hash,{createEmbedIframe:c,isFixedHeight:a,getHeightForBreakpoint:s,startEventListeners:u,notifyParentWindow:l,isSafari:d,initCustomerAnalytics:r,addAnalyticsListener:o,sendCustomerAnalyticsMessage:n}),f=!0;function w(){var i;Flourish.fixed_height||(null!=e?i=e:f&&(i=h.getHeightForBreakpoint()),i!==window.innerHeight&&h.notifyParentWindow(i))}function m(){w(),window.addEventListener("resize",w)}Flourish.warn=function(e){if("string"==typeof e&&(e={message:e}),t||"editor"!==Flourish.environment)console.warn(e.message);else{var i={sender:"Flourish",method:"warn",message:e.message,explanation:e.explanation};window.parent.postMessage(JSON.stringify(i),"*")}},Flourish.uploadImage=function(e){if(t||"story_editor"!==Flourish.environment)throw"Invalid upload request";var i={sender:"Flourish",method:"request-upload",name:e.name,accept:e.accept};window.parent.postMessage(JSON.stringify(i),"*")},Flourish.setSetting=function(e,i){if("editor"===Flourish.environment||"sdk"===Flourish.environment){var t={sender:"Flourish",method:"setSetting",name:e,value:i};window.parent.postMessage(JSON.stringify(t),"*")}else if("story_editor"===Flourish.environment){var n={};n[e]=i,p(window.template.state,function(e){var i={};for(var t in e){for(var n=i,o=t.indexOf("."),r=0;o>=0;o=t.indexOf(".",r=o+1)){var a=t.substring(r,o);a in n||(n[a]={}),n=n[a]}n[t.substring(r)]=e[t]}return i}(n))}},Flourish.setHeight=function(i){Flourish.fixed_height||(e=i,f=null==i,w())},Flourish.checkHeight=function(){if(!t){var e=Flourish.__container_height;null!=e?(Flourish.fixed_height=!0,h.notifyParentWindow(e)):h.isFixedHeight()?Flourish.fixed_height=!0:(Flourish.fixed_height=!1,w())}},Flourish.fixed_height=t||h.isFixedHeight(),Flourish.enableCustomerAnalytics=function(){h&&h.initCustomerAnalytics()},"loading"===document.readyState?document.addEventListener("DOMContentLoaded",m):m()}()}();
1
+ !function(){"use strict";var e,t,n=!1;function i(e){if(n&&window.top!==window.self){var t=window;"srcdoc"===t.location.pathname&&(t=t.parent);var i,o=(i={},window._Flourish_template_id&&(i.template_id=window._Flourish_template_id),window.Flourish&&window.Flourish.app&&window.Flourish.app.loaded_template_id&&(i.template_id=window.Flourish.app.loaded_template_id),window._Flourish_visualisation_id&&(i.visualisation_id=window._Flourish_visualisation_id),window.Flourish&&window.Flourish.app&&window.Flourish.app.loaded_visualisation&&(i.visualisation_id=window.Flourish.app.loaded_visualisation.id),window.Flourish&&window.Flourish.app&&window.Flourish.app.story&&(i.story_id=window.Flourish.app.story.id,i.slide_count=window.Flourish.app.story.slides.length),window.Flourish&&window.Flourish.app&&window.Flourish.app.current_slide&&(i.slide_index=window.Flourish.app.current_slide.index+1),i),r={sender:"Flourish",method:"customerAnalytics"};for(var a in o)o.hasOwnProperty(a)&&(r[a]=o[a]);for(var a in e)e.hasOwnProperty(a)&&(r[a]=e[a]);t.parent.postMessage(JSON.stringify(r),"*")}}function o(e){if("function"!=typeof e)throw new Error("Analytics callback is not a function");window.Flourish._analytics_listeners.push(e)}function r(){n=!0;[{event_name:"click",action_name:"click",use_capture:!0},{event_name:"keydown",action_name:"key_down",use_capture:!0},{event_name:"mouseenter",action_name:"mouse_enter",use_capture:!1},{event_name:"mouseleave",action_name:"mouse_leave",use_capture:!1}].forEach((function(e){document.body.addEventListener(e.event_name,(function(){i({action:e.action_name})}),e.use_capture)}))}function a(){if(null==e){var t=function(){var e=window.location;"about:srcdoc"==e.href&&(e=window.parent.location);var t={};return function(e,n,i){for(;i=n.exec(e);)t[decodeURIComponent(i[1])]=decodeURIComponent(i[2])}(e.search.substring(1).replace(/\+/g,"%20"),/([^&=]+)=?([^&]*)/g),t}();e="referrer"in t?/^https:\/\/medium.com\//.test(t.referrer):!("auto"in t)}return e}function s(e){var t=e||window.innerWidth;return t>999?650:t>599?575:400}function l(e,n){if(window.top!==window.self){var i=window;if("srcdoc"==i.location.pathname&&(i=i.parent),t)return e=parseInt(e,10),void i.parent.postMessage({sentinel:"amp",type:"embed-size",height:e},"*");var o={sender:"Flourish",context:"iframe.resize",method:"resize",height:e,src:i.location.toString()};if(n)for(var r in n)o[r]=n[r];i.parent.postMessage(JSON.stringify(o),"*")}}function d(){return(-1!==navigator.userAgent.indexOf("Safari")||-1!==navigator.userAgent.indexOf("iPhone"))&&-1==navigator.userAgent.indexOf("Chrome")}function u(e){return"string"==typeof e||e instanceof String}function c(e){return"warn"!==e.method?(console.warn("BUG: validateWarnMessage called for method"+e.method),!1):!(null!=e.message&&!u(e.message))&&!(null!=e.explanation&&!u(e.explanation))}function h(e){return"resize"!==e.method?(console.warn("BUG: validateResizeMessage called for method"+e.method),!1):!!u(e.src)&&(!!u(e.context)&&!!("number"==typeof(t=e.height)?!isNaN(t)&&t>=0:u(t)&&/\d/.test(t)&&/^[0-9]*(\.[0-9]*)?(cm|mm|Q|in|pc|pt|px|em|ex|ch|rem|lh|vw|vh|vmin|vmax|%)?$/i.test(t)));var t}function f(e){throw new Error("Validation for setSetting is not implemented yet; see issue #4328")}function w(e){return"customerAnalytics"===e.method||(console.warn("BUG: validateCustomerAnalyticsMessage called for method"+e.method),!1)}function p(e){return"request-upload"!==e.method?(console.warn("BUG: validateResizeMessage called for method"+e.method),!1):!!u(e.name)&&!(null!=e.accept&&!u(e.accept))}function m(e,t){var n=function(e){for(var t={warn:c,resize:h,setSetting:f,customerAnalytics:w,"request-upload":p},n={},i=0;i<e.length;i++){var o=e[i];if(!t[o])throw new Error("No validator found for method "+o);n[o]=t[o]}return n}(t);window.addEventListener("message",(function(t){if(null!=t.source&&(t.origin===document.location.origin||t.origin.match(/\/\/localhost:\d+$|\/\/flourish-api\.com$|\.flourish\.(?:local(:\d+)?|net|rocks|studio)$|\.uri\.sh$/))){var i;try{i=JSON.parse(t.data)}catch(e){return void console.warn("Unexpected non-JSON message: "+JSON.stringify(t.data))}if("Flourish"===i.sender)if(i.method)if(Object.prototype.hasOwnProperty.call(n,i.method))if(n[i.method](i)){for(var o=document.querySelectorAll("iframe"),r=0;r<o.length;r++)if(o[r].contentWindow==t.source||o[r].contentWindow==t.source.parent)return void e(i,o[r]);console.warn("could not find frame",i)}else console.warn("Validation failed for the message",i);else console.warn("No validator implemented for message",i);else console.warn("The 'method' property was missing from message",i)}})),d()&&(window.addEventListener("resize",g),g())}function g(){for(var e=document.querySelectorAll(".flourish-embed"),t=0;t<e.length;t++){var n=e[t];if(!n.getAttribute("data-width")){var i=n.querySelector("iframe");if(i){var o=window.getComputedStyle(n),r=n.offsetWidth-parseFloat(o.paddingLeft)-parseFloat(o.paddingRight);i.style.width=r+"px"}}}}function v(e,t,n,i,o){var r=document.createElement("iframe");if(r.setAttribute("scrolling","no"),r.setAttribute("frameborder","0"),r.setAttribute("title","Interactive or visual content"),r.setAttribute("sandbox","allow-same-origin allow-forms allow-scripts allow-downloads allow-popups allow-popups-to-escape-sandbox allow-top-navigation-by-user-activation"),t.appendChild(r),r.offsetParent||"fixed"===getComputedStyle(r).position)_(e,t,r,n,i,o);else{var a={embed_url:e,container:t,iframe:r,width:n,height:i,play_on_load:o};if(window._flourish_poll_items?window._flourish_poll_items.push(a):window._flourish_poll_items=[a],window._flourish_poll_items.length>1)return r;var s=setInterval((function(){window._flourish_poll_items=window._flourish_poll_items.filter((function(e){return!e.iframe.offsetParent||(_(e.embed_url,e.container,e.iframe,e.width,e.height,e.play_on_load),!1)})),window._flourish_poll_items.length||clearInterval(s)}),500)}return r}function _(e,t,n,i,o,r){var a;return i&&"number"==typeof i?(a=i,i+="px"):i&&i.match(/^[ \t\r\n\f]*([+-]?\d+|\d*\.\d+(?:[eE][+-]?\d+)?)(?:\\?[Pp]|\\0{0,4}[57]0(?:\r\n|[ \t\r\n\f])?)(?:\\?[Xx]|\\0{0,4}[57]8(?:\r\n|[ \t\r\n\f])?)[ \t\r\n\f]*$/)&&(a=parseFloat(i)),o&&"number"==typeof o&&(o+="px"),i?n.style.width=i:d()?n.style.width=t.offsetWidth+"px":n.style.width="100%",!!o||(e.match(/\?/)?e+="&auto=1":e+="?auto=1",o=s(a||n.offsetWidth)+"px"),o&&("%"===o.charAt(o.length-1)&&(o=parseFloat(o)/100*t.parentNode.offsetHeight+"px"),n.style.height=o),n.setAttribute("src",e+(r?"#play-on-load":"")),n}function y(e){return!Array.isArray(e)&&"object"==typeof e&&null!=e}function F(e,t){for(var n in t)y(e[n])&&y(t[n])?F(e[n],t[n]):e[n]=t[n];return e}!function(){var e,n=window.top===window.self,u=n?null:(t="#amp=1"==window.location.hash,{createEmbedIframe:v,isFixedHeight:a,getHeightForBreakpoint:s,startEventListeners:m,notifyParentWindow:l,isSafari:d,initCustomerAnalytics:r,addAnalyticsListener:o,sendCustomerAnalyticsMessage:i}),c=!0;function h(){var t;Flourish.fixed_height||(null!=e?t=e:c&&(t=u.getHeightForBreakpoint()),t!==window.innerHeight&&u.notifyParentWindow(t))}function f(){h(),window.addEventListener("resize",h)}Flourish.warn=function(e){if("string"==typeof e&&(e={message:e}),n||"editor"!==Flourish.environment)console.warn(e.message);else{var t={sender:"Flourish",method:"warn",message:e.message,explanation:e.explanation};window.parent.postMessage(JSON.stringify(t),"*")}},Flourish.uploadImage=function(e){if(n||"story_editor"!==Flourish.environment)throw"Invalid upload request";var t={sender:"Flourish",method:"request-upload",name:e.name,accept:e.accept};window.parent.postMessage(JSON.stringify(t),"*")},Flourish.setSetting=function(e,t){if("editor"===Flourish.environment||"sdk"===Flourish.environment){var n={sender:"Flourish",method:"setSetting",name:e,value:t};window.parent.postMessage(JSON.stringify(n),"*")}else if("story_editor"===Flourish.environment){var i={};i[e]=t,F(window.template.state,function(e){var t={};for(var n in e){for(var i=t,o=n.indexOf("."),r=0;o>=0;o=n.indexOf(".",r=o+1)){var a=n.substring(r,o);a in i||(i[a]={}),i=i[a]}i[n.substring(r)]=e[n]}return t}(i))}},Flourish.setHeight=function(t){Flourish.fixed_height||(e=t,c=null==t,h())},Flourish.checkHeight=function(){if(!n){var e=Flourish.__container_height;null!=e?(Flourish.fixed_height=!0,u.notifyParentWindow(e)):u.isFixedHeight()?Flourish.fixed_height=!0:(Flourish.fixed_height=!1,h())}},Flourish.fixed_height=n||u.isFixedHeight(),Flourish.enableCustomerAnalytics=function(){u&&u.initCustomerAnalytics()},"loading"===document.readyState?document.addEventListener("DOMContentLoaded",f):f()}()}();
2
2
  //# sourceMappingURL=embedded.js.map