framework/extensions/embed/js/dist/forum.js
flarum-bot 408a1bba51 Bundled output for commit 6f117a24e4
Includes transpiled JS/TS.

[skip ci]
2021-10-13 11:02:15 +00:00

2 lines
16 KiB
JavaScript

module.exports=function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=10)}([function(e,t){e.exports=flarum.core.compat.extend},function(e,t){e.exports=flarum.core.compat.app},function(e,t){e.exports=flarum.core.compat["components/DiscussionPage"]},function(e,t){e.exports=flarum.core.compat["components/PostStream"]},function(e,t){e.exports=flarum.core.compat["utils/Stream"]},function(e,t){e.exports=flarum.core.compat.ForumApplication},function(e,t){e.exports=flarum.core.compat["components/Composer"]},function(e,t){e.exports=flarum.core.compat["components/ModalManager"]},function(e,t){e.exports=flarum.core.compat["components/PostMeta"]},function(e,t,n){!function(t){if("undefined"!=typeof window){var n=!0,o="",i=0,r="",a=null,c="",u=!1,s={resize:1,click:1},d=!0,l=1,f="bodyOffset",m=!0,p="",h={},g=32,v=null,y=!1,b=!1,w="[iFrameSizer]",T=w.length,O="",S={max:1,min:1,bodyScroll:1,documentElementScroll:1},E="child",M=window.parent,I="*",x=0,N=!1,A=null,C=16,k=1,P="scroll",z=window,j=function(){ne("onMessage function not defined")},R=function(){},F=function(){},L={height:function(){return ne("Custom height calculation function not defined"),document.documentElement.offsetHeight},width:function(){return ne("Custom width calculation function not defined"),document.body.scrollWidth}},D={},q=!1;try{var H=Object.create({},{passive:{get:function(){q=!0}}});window.addEventListener("test",$,H),window.removeEventListener("test",$,H)}catch(e){}var W,B,_,J,U,V,X,Y={bodyOffset:function(){return document.body.offsetHeight+me("marginTop")+me("marginBottom")},offset:function(){return Y.bodyOffset()},bodyScroll:function(){return document.body.scrollHeight},custom:function(){return L.height()},documentElementOffset:function(){return document.documentElement.offsetHeight},documentElementScroll:function(){return document.documentElement.scrollHeight},max:function(){return Math.max.apply(null,he(Y))},min:function(){return Math.min.apply(null,he(Y))},grow:function(){return Y.max()},lowestElement:function(){return Math.max(Y.bodyOffset()||Y.documentElementOffset(),pe("bottom",ve()))},taggedElement:function(){return ge("bottom","data-iframe-height")}},K={bodyScroll:function(){return document.body.scrollWidth},bodyOffset:function(){return document.body.offsetWidth},custom:function(){return L.width()},documentElementScroll:function(){return document.documentElement.scrollWidth},documentElementOffset:function(){return document.documentElement.offsetWidth},scroll:function(){return Math.max(K.bodyScroll(),K.documentElementScroll())},max:function(){return Math.max.apply(null,he(K))},min:function(){return Math.min.apply(null,he(K))},rightMostElement:function(){return pe("right",ve())},taggedElement:function(){return ge("right","data-iframe-width")}},Q=(W=ye,U=null,V=0,X=function(){V=Date.now(),U=null,J=W.apply(B,_),U||(B=_=null)},function(){var e=Date.now();V||(V=e);var t=C-(e-V);return B=this,_=arguments,t<=0||t>C?(U&&(clearTimeout(U),U=null),V=e,J=W.apply(B,_),U||(B=_=null)):U||(U=setTimeout(X,t)),J});G(window,"message",(function(t){var n={init:function(){p=t.data,M=t.source,oe(),d=!1,setTimeout((function(){m=!1}),128)},reset:function(){m?te("Page reset ignored by init"):(te("Page size reset by host page"),Te("resetPage"))},resize:function(){be("resizeParent","Parent window requested size check")},moveToAnchor:function(){h.findTarget(i())},inPageLink:function(){this.moveToAnchor()},pageInfo:function(){var e=i();te("PageInfoFromParent called from parent: "+e),F(JSON.parse(e)),te(" --")},message:function(){var e=i();te("onMessage called from parent: "+e),j(JSON.parse(e)),te(" --")}};function o(){return t.data.split("]")[1].split(":")[0]}function i(){return t.data.substr(t.data.indexOf(":")+1)}function r(){return t.data.split(":")[2]in{true:1,false:1}}function a(){var i=o();i in n?n[i]():!e.exports&&"iFrameResize"in window||"jQuery"in window&&"iFrameResize"in window.jQuery.prototype||r()||ne("Unexpected message ("+t.data+")")}w===(""+t.data).substr(0,T)&&(!1===d?a():r()?n.init():te('Ignored message of type "'+o()+'". Received before initialization.'))})),G(window,"readystatechange",Ee),Ee()}function $(){}function G(e,t,n,o){e.addEventListener(t,n,!!q&&(o||{}))}function Z(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ee(e){return w+"["+O+"] "+e}function te(e){y&&"object"==typeof window.console&&console.log(ee(e))}function ne(e){"object"==typeof window.console&&console.warn(ee(e))}function oe(){var e;!function(){function e(e){return"true"===e}var t=p.substr(T).split(":");O=t[0],i=void 0!==t[1]?Number(t[1]):i,u=void 0!==t[2]?e(t[2]):u,y=void 0!==t[3]?e(t[3]):y,g=void 0!==t[4]?Number(t[4]):g,n=void 0!==t[6]?e(t[6]):n,r=t[7],f=void 0!==t[8]?t[8]:f,o=t[9],c=t[10],x=void 0!==t[11]?Number(t[11]):x,h.enable=void 0!==t[12]&&e(t[12]),E=void 0!==t[13]?t[13]:E,P=void 0!==t[14]?t[14]:P,b=void 0!==t[15]?Boolean(t[15]):b}(),te("Initialising iFrame ("+window.location.href+")"),function(){function e(e,t){return"function"==typeof e&&(te("Setup custom "+t+"CalcMethod"),L[t]=e,e="custom"),e}"iFrameResizer"in window&&Object===window.iFrameResizer.constructor&&(t=window.iFrameResizer,te("Reading data from page: "+JSON.stringify(t)),Object.keys(t).forEach(ie,t),j="onMessage"in t?t.onMessage:j,R="onReady"in t?t.onReady:R,I="targetOrigin"in t?t.targetOrigin:I,f="heightCalculationMethod"in t?t.heightCalculationMethod:f,P="widthCalculationMethod"in t?t.widthCalculationMethod:P,f=e(f,"height"),P=e(P,"width"));var t;te("TargetOrigin for parent set to: "+I)}(),function(){void 0===r&&(r=i+"px");re("margin",function(e,t){-1!==t.indexOf("-")&&(ne("Negative CSS value ignored for "+e),t="");return t}("margin",r))}(),re("background",o),re("padding",c),(e=document.createElement("div")).style.clear="both",e.style.display="block",e.style.height="0",document.body.appendChild(e),se(),de(),document.documentElement.style.height="",document.body.style.height="",te('HTML & body height set to "auto"'),te("Enable public methods"),z.parentIFrame={autoResize:function(e){return!0===e&&!1===n?(n=!0,le()):!1===e&&!0===n&&(n=!1,ce("remove"),null!==a&&a.disconnect(),clearInterval(v)),Se(0,0,"autoResize",JSON.stringify(n)),n},close:function(){Se(0,0,"close")},getId:function(){return O},getPageInfo:function(e){"function"==typeof e?(F=e,Se(0,0,"pageInfo")):(F=function(){},Se(0,0,"pageInfoStop"))},moveToAnchor:function(e){h.findTarget(e)},reset:function(){Oe("parentIFrame.reset")},scrollTo:function(e,t){Se(t,e,"scrollTo")},scrollToOffset:function(e,t){Se(t,e,"scrollToOffset")},sendMessage:function(e,t){Se(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod:function(e){f=e,se()},setWidthCalculationMethod:function(e){P=e,de()},setTargetOrigin:function(e){te("Set targetOrigin: "+e),I=e},size:function(e,t){be("size","parentIFrame.size("+(e||"")+(t?","+t:"")+")",e,t)}},function(){if(!0!==b)return;function e(e){Se(0,0,e.type,e.screenY+":"+e.screenX)}function t(t,n){te("Add event listener: "+n),G(window.document,t,e)}t("mouseenter","Mouse Enter"),t("mouseleave","Mouse Leave")}(),le(),h=function(){function e(e){var t=e.getBoundingClientRect(),n={x:void 0!==window.pageXOffset?window.pageXOffset:document.documentElement.scrollLeft,y:void 0!==window.pageYOffset?window.pageYOffset:document.documentElement.scrollTop};return{x:parseInt(t.left,10)+parseInt(n.x,10),y:parseInt(t.top,10)+parseInt(n.y,10)}}function t(t){var n=t.split("#")[1]||t,o=decodeURIComponent(n),i=document.getElementById(o)||document.getElementsByName(o)[0];void 0!==i?function(t){var o=e(t);te("Moving to in page link (#"+n+") at x: "+o.x+" y: "+o.y),Se(o.y,o.x,"scrollToOffset")}(i):(te("In page link (#"+n+") not found in iFrame, so sending to parent"),Se(0,0,"inPageLink","#"+n))}function n(){var e=window.location.hash,n=window.location.href;""!==e&&"#"!==e&&t(n)}h.enable?Array.prototype.forEach&&document.querySelectorAll?(te("Setting up location.hash handlers"),Array.prototype.forEach.call(document.querySelectorAll('a[href^="#"]'),(function(e){"#"!==e.getAttribute("href")&&G(e,"click",(function(e){e.preventDefault(),t(this.getAttribute("href"))}))})),G(window,"hashchange",n),setTimeout(n,128)):ne("In page linking not fully supported in this browser! (See README.md for IE8 workaround)"):te("In page linking not enabled");return{findTarget:t}}(),be("init","Init message from host page"),R()}function ie(e){var t=e.split("Callback");if(2===t.length){var n="on"+t[0].charAt(0).toUpperCase()+t[0].slice(1);this[n]=this[e],delete this[e],ne("Deprecated: '"+e+"' has been renamed '"+n+"'. The old method will be removed in the next major version.")}}function re(e,t){void 0!==t&&""!==t&&"null"!==t&&(document.body.style[e]=t,te("Body "+e+' set to "'+t+'"'))}function ae(e){var t={add:function(t){function n(){be(e.eventName,e.eventType)}D[t]=n,G(window,t,n,{passive:!0})},remove:function(e){var t,n,o,i=D[e];delete D[e],t=window,n=e,o=i,t.removeEventListener(n,o,!1)}};e.eventNames&&Array.prototype.map?(e.eventName=e.eventNames[0],e.eventNames.map(t[e.method])):t[e.method](e.eventName),te(Z(e.method)+" event listener: "+e.eventType)}function ce(e){ae({method:e,eventType:"Animation Start",eventNames:["animationstart","webkitAnimationStart"]}),ae({method:e,eventType:"Animation Iteration",eventNames:["animationiteration","webkitAnimationIteration"]}),ae({method:e,eventType:"Animation End",eventNames:["animationend","webkitAnimationEnd"]}),ae({method:e,eventType:"Input",eventName:"input"}),ae({method:e,eventType:"Mouse Up",eventName:"mouseup"}),ae({method:e,eventType:"Mouse Down",eventName:"mousedown"}),ae({method:e,eventType:"Orientation Change",eventName:"orientationchange"}),ae({method:e,eventType:"Print",eventName:["afterprint","beforeprint"]}),ae({method:e,eventType:"Ready State Change",eventName:"readystatechange"}),ae({method:e,eventType:"Touch Start",eventName:"touchstart"}),ae({method:e,eventType:"Touch End",eventName:"touchend"}),ae({method:e,eventType:"Touch Cancel",eventName:"touchcancel"}),ae({method:e,eventType:"Transition Start",eventNames:["transitionstart","webkitTransitionStart","MSTransitionStart","oTransitionStart","otransitionstart"]}),ae({method:e,eventType:"Transition Iteration",eventNames:["transitioniteration","webkitTransitionIteration","MSTransitionIteration","oTransitionIteration","otransitioniteration"]}),ae({method:e,eventType:"Transition End",eventNames:["transitionend","webkitTransitionEnd","MSTransitionEnd","oTransitionEnd","otransitionend"]}),"child"===E&&ae({method:e,eventType:"IFrame Resized",eventName:"resize"})}function ue(e,t,n,o){return t!==e&&(e in n||(ne(e+" is not a valid option for "+o+"CalculationMethod."),e=t),te(o+' calculation method set to "'+e+'"')),e}function se(){f=ue(f,"bodyOffset",Y,"height")}function de(){P=ue(P,"scroll",K,"width")}function le(){var e;!0===n?(ce("add"),e=0>g,window.MutationObserver||window.WebKitMutationObserver?e?fe():a=function(){function e(e){function t(e){!1===e.complete&&(te("Attach listeners to "+e.src),e.addEventListener("load",o,!1),e.addEventListener("error",i,!1),a.push(e))}"attributes"===e.type&&"src"===e.attributeName?t(e.target):"childList"===e.type&&Array.prototype.forEach.call(e.target.querySelectorAll("img"),t)}function t(e){te("Remove listeners from "+e.src),e.removeEventListener("load",o,!1),e.removeEventListener("error",i,!1),function(e){a.splice(a.indexOf(e),1)}(e)}function n(e,n,o){t(e.target),be(n,o+": "+e.target.src)}function o(e){n(e,"imageLoad","Image loaded")}function i(e){n(e,"imageLoadFailed","Image load failed")}function r(t){be("mutationObserver","mutationObserver: "+t[0].target+" "+t[0].type),t.forEach(e)}var a=[],c=window.MutationObserver||window.WebKitMutationObserver,u=function(){var e=document.querySelector("body");return u=new c(r),te("Create body MutationObserver"),u.observe(e,{attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0}),u}();return{disconnect:function(){"disconnect"in u&&(te("Disconnect body MutationObserver"),u.disconnect(),a.forEach(t))}}}():(te("MutationObserver not supported in this browser!"),fe())):te("Auto Resize disabled")}function fe(){0!==g&&(te("setInterval: "+g+"ms"),v=setInterval((function(){be("interval","setInterval: "+g)}),Math.abs(g)))}function me(e,t){var n=0;return t=t||document.body,n=null!==(n=document.defaultView.getComputedStyle(t,null))?n[e]:0,parseInt(n,10)}function pe(e,t){for(var n=t.length,o=0,i=0,r=Z(e),a=Date.now(),c=0;c<n;c++)(o=t[c].getBoundingClientRect()[e]+me("margin"+r,t[c]))>i&&(i=o);return a=Date.now()-a,te("Parsed "+n+" HTML elements"),te("Element position calculated in "+a+"ms"),function(e){e>C/2&&te("Event throttle increased to "+(C=2*e)+"ms")}(a),i}function he(e){return[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll()]}function ge(e,t){var n=document.querySelectorAll("["+t+"]");return 0===n.length&&(ne("No tagged elements ("+t+") found on page"),document.querySelectorAll("body *")),pe(e,n)}function ve(){return document.querySelectorAll("body *")}function ye(e,t,n,o){var i,r;!function(){function e(e,t){return!(Math.abs(e-t)<=x)}return i=void 0!==n?n:Y[f](),r=void 0!==o?o:K[P](),e(l,i)||u&&e(k,r)}()&&"init"!==e?!(e in{init:1,interval:1,size:1})&&(f in S||u&&P in S)?Oe(t):e in{interval:1}||te("No change in size detected"):(we(),Se(l=i,k=r,e))}function be(e,t,n,o){N&&e in s?te("Trigger event cancelled: "+e):(e in{reset:1,resetPage:1,init:1}||te("Trigger event: "+t),"init"===e?ye(e,t,n,o):Q(e,t,n,o))}function we(){N||(N=!0,te("Trigger event lock on")),clearTimeout(A),A=setTimeout((function(){N=!1,te("Trigger event lock off"),te("--")}),128)}function Te(e){l=Y[f](),k=K[P](),Se(l,k,e)}function Oe(e){var t=f;f="bodyOffset",te("Reset trigger event: "+e),we(),Te("reset"),f=t}function Se(e,t,n,o,i){var r;void 0===i?i=I:te("Message targetOrigin: "+i),te("Sending message to host page ("+(r=O+":"+e+":"+t+":"+n+(void 0!==o?":"+o:""))+")"),M.postMessage(w+r,i)}function Ee(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}}()},function(e,t,n){"use strict";n.r(t);n(9);var o=n(0),i=n(1),r=n.n(i),a=n(4),c=n.n(a),u=n(5),s=n.n(u),d=n(6),l=n.n(d),f=n(3),p=n.n(f),h=n(7),g=n.n(h),v=n(8),y=n.n(v),b=n(2),w=n.n(b);Object(o.extend)(s.a.prototype,"mount",(function(){m.route.param("hideFirstPost")&&Object(o.extend)(p.a.prototype,"view",(function(e){1===e.children[0].attrs["data-number"]&&e.children.splice(0,1)}))})),Object(o.override)(m.route.Link,"view",(function(e,t){return t.attrs.href=t.attrs.href.replace("/embed","/d"),t.attrs.target="_blank",e(t)})),Object(o.override)(y.a.prototype,"getPermalink",(function(e,t){return e(t).replace("/embed","/d")})),r.a.pageInfo=c()({});var T=function(){var e=r.a.pageInfo();this.$().css("top",Math.max(0,e.scrollTop-e.offsetTop))};Object(o.extend)(g.a.prototype,"show",T),Object(o.extend)(l.a.prototype,"show",T),window.iFrameResizer={readyCallback:function(){window.parentIFrame.getPageInfo(r.a.pageInfo)}},Object(o.extend)(p.a.prototype,"goToNumber",(function(e,t){if("reply"===t&&"parentIFrame"in window&&r.a.composer.isFullScreen()){var n=this.$(".PostStream-item:last").offset().top;window.parentIFrame.scrollToOffset(0,n)}})),Object(o.extend)(w.a.prototype,"sidebarItems",(function(e){e.remove("scrubber");var t=this.discussion.replyCount();e.add("replies",m("h3",null,m("a",{route:r.a.route.discussion(this.discussion).replace("/embed","/d")},t," comment",1==t?"":"s")),100);var n=e.get("controls").attrs;n.className=n.className.replace("App-primaryControl","")})),r.a.routes.discussion={path:"/embed/:id",component:w.a},r.a.routes["discussion.near"]={path:"/embed/:id/:near",component:w.a}}]);
//# sourceMappingURL=forum.js.map