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