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