From 156bea936b4c8d47401456008adb42155ced58c1 Mon Sep 17 00:00:00 2001 From: flarum-bot Date: Fri, 26 Jul 2024 08:14:31 +0000 Subject: [PATCH] Bundled output for commit 6a13c92f4c1000b811b9606ac761c1e2aa697007 Includes transpiled JS/TS, and Typescript declaration files (typings). [skip ci] --- js/dist/forum.js | 2 +- js/dist/forum.js.map | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/dist/forum.js b/js/dist/forum.js index 4a42ad5..105d3c0 100644 --- a/js/dist/forum.js +++ b/js/dist/forum.js @@ -1,2 +1,2 @@ -(()=>{var t={n:o=>{var e=o&&o.__esModule?()=>o.default:()=>o;return t.d(e,{a:e}),e},d:(o,e)=>{for(var r in e)t.o(e,r)&&!t.o(o,r)&&Object.defineProperty(o,r,{enumerable:!0,get:e[r]})},o:(t,o)=>Object.prototype.hasOwnProperty.call(t,o),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},o={};(()=>{"use strict";t.r(o),t.d(o,{components:()=>G,helpers:()=>K,models:()=>J});const e=flarum.core.compat["forum/app"];var r=t.n(e);const n=flarum.core.compat["common/Model"];var a=t.n(n);const s=flarum.core.compat["common/models/User"];var c=t.n(s);function i(t,o){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,o){return t.__proto__=o,t},i(t,o)}function f(t,o){t.prototype=Object.create(o.prototype),t.prototype.constructor=t,i(t,o)}const u=flarum.core.compat["common/utils/computed"];var l=t.n(u),p=function(t){function o(){for(var o,e=arguments.length,r=new Array(e),n=0;n1?o-1:0),r=1;r{var t={n:o=>{var e=o&&o.__esModule?()=>o.default:()=>o;return t.d(e,{a:e}),e},d:(o,e)=>{for(var r in e)t.o(e,r)&&!t.o(o,r)&&Object.defineProperty(o,r,{enumerable:!0,get:e[r]})},o:(t,o)=>Object.prototype.hasOwnProperty.call(t,o),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},o={};(()=>{"use strict";t.r(o),t.d(o,{components:()=>G,helpers:()=>K,models:()=>J});const e=flarum.core.compat["forum/app"];var r=t.n(e);const n=flarum.core.compat["common/Model"];var a=t.n(n);const s=flarum.core.compat["common/models/User"];var c=t.n(s);function i(t,o){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,o){return t.__proto__=o,t},i(t,o)}function f(t,o){t.prototype=Object.create(o.prototype),t.prototype.constructor=t,i(t,o)}const u=flarum.core.compat["common/utils/computed"];var l=t.n(u),p=function(t){function o(){for(var o,e=arguments.length,r=new Array(e),n=0;n1?o-1:0),r=1;r {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/app'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/Model'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/models/User'];","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n return _setPrototypeOf(o, p);\n}","import setPrototypeOf from \"./setPrototypeOf.js\";\nexport default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n setPrototypeOf(subClass, superClass);\n}","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/utils/computed'];","import Model from 'flarum/common/Model';\nimport computed from 'flarum/common/utils/computed';\n\nexport default class Policy extends Model {\n sort = Model.attribute('sort');\n name = Model.attribute('name');\n url = Model.attribute('url');\n update_message = Model.attribute('update_message');\n terms_updated_at = Model.attribute('terms_updated_at');\n form_key = computed('id', (id) => 'fof_terms_policy_' + id);\n\n apiEndpoint() {\n return '/fof/terms/policies' + (this.exists ? '/' + this.data.id : '');\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/extend'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Page'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/IndexPage'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Modal'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Button'];","export default function (items, attr = 'sort') {\n return items.sort((a, b) => a[attr]() - b[attr]());\n}\n","import app from 'flarum/forum/app';\nimport Modal from 'flarum/common/components/Modal';\nimport Button from 'flarum/common/components/Button';\nimport sortByAttribute from '../../common/helpers/sortByAttribute';\n\n/* global m, dayjs */\n\nexport default class AcceptPoliciesModal extends Modal {\n oninit(vnode) {\n super.oninit(vnode);\n\n app.store.all('fof-terms-policies').forEach((policy) => {\n this[policy.form_key()] = false;\n });\n }\n\n title() {\n return app.translator.trans('fof-terms.forum.accept-modal.title');\n }\n\n content() {\n return m('.Modal-body', this.body());\n }\n\n body() {\n const policies = sortByAttribute(\n app.store.all('fof-terms-policies').filter((policy) => {\n const state = app.session.user.fofTermsPoliciesState()[policy.id()];\n\n return !state || state.has_update;\n })\n );\n\n if (policies.length === 0) {\n return Button.component(\n {\n className: 'Button',\n onclick() {\n app.modal.close();\n },\n },\n app.translator.trans('fof-terms.forum.accept-modal.close')\n );\n }\n\n return policies.map((policy) =>\n m('div', [\n m('h2', policy.name()),\n app.forum.attribute('fof-terms.hide-updated-at')\n ? null\n : m(\n 'p',\n policy.terms_updated_at()\n ? app.translator.trans('fof-terms.forum.accept-modal.updated-at', {\n date: dayjs(policy.terms_updated_at()).format(app.forum.attribute('fof-terms.date-format')),\n })\n : app.translator.trans('fof-terms.forum.accept-modal.updated-recently')\n ),\n policy.update_message() ? m('p', policy.update_message()) : null,\n m(\n '.Form-group',\n m(\n '.FoF-Terms-Check.FoF-Terms-Check--login',\n m('label.checkbox', [\n m('input', {\n type: 'checkbox',\n checked: this[policy.form_key()],\n onchange: () => {\n this[policy.form_key()] = !this[policy.form_key()];\n },\n }),\n app.translator.trans('fof-terms.forum.accept-modal.i-accept', {\n policy: policy.name(),\n a: policy.url()\n ? m('a', {\n href: policy.url(),\n target: '_blank',\n })\n : m('span'),\n }),\n ])\n )\n ),\n Button.component(\n {\n className: 'Button Button--primary',\n disabled: !this[policy.form_key()],\n onclick: () => {\n // We need to save the \"must accept\" property before performing the request\n // Because an updated user serializer will be returned\n const hadToAcceptToInteract = app.session.user.fofTermsPoliciesMustAccept();\n\n app\n .request({\n url: app.forum.attribute('apiUrl') + policy.apiEndpoint() + '/accept',\n method: 'POST',\n errorHandler: this.onerror.bind(this),\n })\n .then((updated) => {\n app.store.pushPayload(updated);\n\n // If this was the last policy to accept, close the modal\n if (policies.length === 1) {\n if (hadToAcceptToInteract) {\n // If the user was previously not allowed to interact with the forum,\n // we refresh to get updated permissions in the frontend\n window.location.reload();\n } else {\n app.modal.close();\n }\n }\n\n m.redraw();\n });\n },\n },\n app.translator.trans('fof-terms.forum.accept-modal.accept')\n ),\n ])\n );\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/SignUpModal'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/IndexPage'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/DiscussionPage'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/UserPage'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/helpers/listItems'];","import app from 'flarum/forum/app';\nimport Button from 'flarum/common/components/Button';\nimport listItems from 'flarum/common/helpers/listItems';\nimport AcceptPoliciesModal from './AcceptPoliciesModal';\n\n/* global m */\n\nlet temporarilyHidden = false;\n\n/**\n * Renders similarly to Flarum's Alert, but with an additional .container inside\n */\nexport default class UpdateAlert {\n shouldShowAlert() {\n if (temporarilyHidden) {\n return false;\n }\n\n const user = app.session.user;\n\n return user && user.fofTermsPoliciesHasUpdate();\n }\n\n view() {\n if (!this.shouldShowAlert()) {\n return m('div');\n }\n\n const controls = [\n Button.component(\n {\n className: 'Button Button--link',\n onclick: () => {\n app.modal.show(AcceptPoliciesModal);\n },\n },\n app.translator.trans('fof-terms.forum.update-alert.review')\n ),\n ];\n\n const dismissControl = [];\n\n if (!app.session.user.fofTermsPoliciesMustAccept()) {\n dismissControl.push(\n Button.component({\n icon: 'fas fa-times',\n className: 'Button Button--link Button--icon Alert-dismiss',\n onclick: () => {\n temporarilyHidden = true;\n },\n })\n );\n }\n\n return m(\n '.Alert.Alert-info',\n m('.container', [\n m(\n 'span.Alert-body',\n app.session.user.fofTermsPoliciesMustAccept()\n ? app.translator.trans('fof-terms.forum.update-alert.must-accept-message')\n : app.translator.trans('fof-terms.forum.update-alert.can-accept-message')\n ),\n m('ul.Alert-controls', listItems(controls.concat(dismissControl))),\n ])\n );\n }\n}\n","import { override } from 'flarum/common/extend';\nimport IndexPage from 'flarum/forum/components/IndexPage';\nimport DiscussionPage from 'flarum/forum/components/DiscussionPage';\nimport UserPage from 'flarum/forum/components/UserPage';\nimport UpdateAlert from './components/UpdateAlert';\n\n/* global m */\n\n// This single method will be used to inject the alert into existing components\n// If the view is already an array, we add our content at the start\n// If it isn't an array we wrap the content into a new array\nfunction addAlertToContent(original, ...originalArgs) {\n const existing = original(...originalArgs);\n const additional = m(UpdateAlert);\n\n // if the existing content is an array, add to it\n // This should only happen with the hero() override as other extensions might return an array there\n if (Array.isArray(existing)) {\n existing.unshift(additional);\n\n return existing;\n }\n\n // Otherwise return a new list of elements\n // Use a container div otherwise when extending view() this will prevent the config() method from running\n // as the Component class won't be able to bind config() to an array\n // We could also add to vnode.children but this could cause weird styling if another extension or custom styles\n // change the look of the base page content by targeting the original view root element based on its class\n // By using a new outer container we make sure the alert always stays full width and unaffected by the page view under it\n return m('div', [additional, existing]);\n}\n\nexport default function () {\n // There's no single place we can inject the banner\n // So we use a few different points so it's visible on most pages\n override(IndexPage.prototype, 'hero', addAlertToContent);\n override(DiscussionPage.prototype, 'view', addAlertToContent);\n\n // Covers user profile and settings\n override(UserPage.prototype, 'view', addAlertToContent);\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/utils/UserControls'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/helpers/humanTime'];","import app from 'flarum/forum/app';\nimport humanTime from 'flarum/common/helpers/humanTime';\nimport Modal from 'flarum/common/components/Modal';\nimport sortByAttribute from '../../common/helpers/sortByAttribute';\n\n/* global m */\n\nexport default class UserPoliciesStateModal extends Modal {\n title() {\n return app.translator.trans('fof-terms.forum.state-modal.title', {\n username: this.attrs.user.username(),\n });\n }\n\n content() {\n return m(\n '.Modal-body',\n m(\n 'ul',\n sortByAttribute(app.store.all('fof-terms-policies')).map((policy) => {\n const state = this.attrs.user.fofTermsPoliciesState()[policy.id()];\n\n return m('li', [\n policy.name() + ': ',\n state && state.accepted_at\n ? app.translator.trans('fof-terms.forum.state-modal.accepted-at', {\n date: humanTime(state.accepted_at),\n })\n : app.translator.trans('fof-terms.forum.state-modal.not-accepted'),\n ]);\n })\n )\n );\n }\n}\n","import AcceptPoliciesModal from './AcceptPoliciesModal';\nimport UpdateAlert from './UpdateAlert';\nimport UserPoliciesStateModal from './UserPoliciesStateModal';\n\nexport const components = {\n AcceptPoliciesModal,\n UpdateAlert,\n UserPoliciesStateModal,\n};\n","import Policy from './Policy';\n\nexport const models = {\n Policy,\n};\n","import sortByAttribute from './sortByAttribute';\n\nexport const helpers = {\n sortByAttribute,\n};\n","import app from 'flarum/forum/app';\nimport Model from 'flarum/common/Model';\nimport User from 'flarum/common/models/User';\nimport Policy from '../common/models/Policy';\nimport addAcceptModal from './addAcceptModal';\nimport addFieldsToRegister from './addFieldsToRegister';\nimport addUpdateAlert from './addUpdateAlert';\nimport addUserPoliciesStateControl from './addUserPoliciesStateControl';\n\nexport * from './components';\nexport * from '../common/models';\nexport * from '../common/helpers';\n\napp.initializers.add('fof-terms', () => {\n app.store.models['fof-terms-policies'] = Policy;\n\n User.prototype.fofTermsPoliciesState = Model.attribute('fofTermsPoliciesState');\n User.prototype.fofTermsPoliciesHasUpdate = Model.attribute('fofTermsPoliciesHasUpdate');\n User.prototype.fofTermsPoliciesMustAccept = Model.attribute('fofTermsPoliciesMustAccept');\n User.prototype.seeFoFTermsPoliciesState = Model.attribute('seeFoFTermsPoliciesState');\n\n addAcceptModal();\n addFieldsToRegister();\n addUpdateAlert();\n addUserPoliciesStateControl();\n});\n","import app from 'flarum/forum/app';\nimport { extend } from 'flarum/common/extend';\nimport Page from 'flarum/common/components/Page';\nimport IndexPage from 'flarum/common/components/IndexPage';\nimport AcceptPoliciesModal from './components/AcceptPoliciesModal';\n\nexport default function () {\n let initialized = false;\n\n extend(Page.prototype, 'oninit', function () {\n if (initialized) {\n return;\n }\n\n // We only show the modal if the first page loaded was the index page\n // And that new updates are available\n // And that the user *must* accept them\n if (app.current.matches(IndexPage)) {\n const user = app.session.user;\n\n if (user && user.fofTermsPoliciesMustAccept()) {\n // Timeout is necessary because there is a redraw error otherwise\n setTimeout(() => {\n app.modal.show(AcceptPoliciesModal);\n }, 0);\n }\n }\n\n initialized = true;\n });\n}\n","import { extend } from 'flarum/common/extend';\nimport app from 'flarum/forum/app';\nimport SignUpModal from 'flarum/forum/components/SignUpModal';\nimport sortByAttribute from '../common/helpers/sortByAttribute';\n\n/* global m */\n\nexport default function () {\n extend(SignUpModal.prototype, 'oninit', function () {\n this.fofTermsPolicies = sortByAttribute(app.store.all('fof-terms-policies'));\n\n this.fofTermsPolicies.forEach((policy) => {\n this[policy.form_key()] = false;\n });\n });\n\n extend(SignUpModal.prototype, 'fields', function (fields) {\n const legalText = app.forum.attribute('fof-terms.signup-legal-text');\n\n if (legalText) {\n fields.add('fof-terms-legal-text', m('.Form-group', m('.FoF-Terms-SignUp-Legal.Alert', legalText)));\n }\n\n this.fofTermsPolicies.forEach((policy) => {\n fields.add(\n 'fof-terms-policy-' + policy.id(),\n m(\n '.Form-group',\n m(\n '.FoF-Terms-Check.FoF-Terms-Check--signup',\n m('label.checkbox', [\n m('input', {\n type: 'checkbox',\n checked: this[policy.form_key()],\n onchange: () => {\n this[policy.form_key()] = !this[policy.form_key()];\n },\n disabled: this.loading,\n }),\n app.translator.trans('fof-terms.forum.signup.i-accept', {\n policy: policy.name(),\n a: policy.url()\n ? m('a', {\n href: policy.url(),\n target: '_blank',\n })\n : m('span'),\n }),\n ])\n )\n )\n );\n });\n });\n\n extend(SignUpModal.prototype, 'submitData', function (data) {\n this.fofTermsPolicies.forEach((policy) => {\n data[policy.form_key()] = this[policy.form_key()];\n });\n });\n}\n","import { extend } from 'flarum/common/extend';\nimport app from 'flarum/forum/app';\nimport UserControls from 'flarum/forum/utils/UserControls';\nimport Button from 'flarum/common/components/Button';\nimport UserPoliciesStateModal from './components/UserPoliciesStateModal';\n\nexport default function () {\n extend(UserControls, 'moderationControls', (items, user) => {\n if (app.forum.attribute('fof-terms.canSeeUserPoliciesState')) {\n items.add(\n 'fof-terms.state',\n Button.component(\n {\n icon: 'fas fa-paperclip',\n onclick() {\n app.modal.show(UserPoliciesStateModal, { user });\n },\n },\n app.translator.trans('fof-terms.forum.user_controls.state_button')\n )\n );\n }\n });\n}\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","flarum","core","compat","_setPrototypeOf","p","setPrototypeOf","bind","__proto__","_inheritsLoose","subClass","superClass","create","constructor","Policy","_Model","_this","_len","arguments","length","args","Array","_key","apply","concat","sort","Model","name","url","update_message","terms_updated_at","form_key","computed","id","apiEndpoint","this","exists","data","items","attr","b","AcceptPoliciesModal","_Modal","_proto","oninit","vnode","app","all","forEach","policy","title","trans","content","m","body","_this2","policies","sortByAttribute","filter","state","user","fofTermsPoliciesState","has_update","Button","className","onclick","close","map","attribute","date","dayjs","format","type","checked","onchange","href","target","disabled","hadToAcceptToInteract","fofTermsPoliciesMustAccept","method","errorHandler","onerror","then","updated","pushPayload","window","location","reload","redraw","Modal","temporarilyHidden","UpdateAlert","shouldShowAlert","fofTermsPoliciesHasUpdate","view","controls","show","dismissControl","push","icon","listItems","addAlertToContent","original","originalArgs","existing","additional","isArray","unshift","UserPoliciesStateModal","username","attrs","accepted_at","humanTime","components","models","helpers","add","initialized","User","seeFoFTermsPoliciesState","extend","Page","matches","IndexPage","setTimeout","SignUpModal","fofTermsPolicies","fields","legalText","loading","_this3","override","DiscussionPage","UserPage","UserControls"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"forum.js","mappings":"MACA,IAAIA,EAAsB,CCA1BA,EAAyBC,IACxB,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,IAAOF,EAAiB,QACxB,IAAM,EAEP,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,CAAM,ECLdF,EAAwB,CAACM,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,KAASR,EAAoBS,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDR,EAAw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OAAQ,WAEVtB,EAAE,cAMlB,GACF,KAEAmE,EAAAA,EAAAA,QAAOK,IAAAA,UAAuB,cAAc,SAAUzF,GAAM,IAAA8F,EAAA,KAC1DhG,KAAK4F,iBAAiB/E,SAAQ,SAACC,GAC7BZ,EAAKY,EAAOlB,YAAcoG,EAAKlF,EAAOlB,WACxC,GACF,KTxBAqG,EAAAA,EAAAA,UAASR,IAAAA,UAAqB,OAAQtB,IACtC8B,EAAAA,EAAAA,UAASC,IAAAA,UAA0B,OAAQ/B,IAG3C8B,EAAAA,EAAAA,UAASE,IAAAA,UAAoB,OAAQhC,IUhCrCmB,EAAAA,EAAAA,QAAOc,IAAc,sBAAsB,SAACjG,EAAOuB,GAC7Cf,IAAAA,MAAUsB,UAAU,sCACtB9B,EAAM+E,IACJ,kBACArD,IAAAA,UACE,CACEoC,KAAM,mBACNnC,QAAO,WACLnB,IAAAA,MAAUmD,KAAKY,EAAwB,CAAEhD,KAAAA,GAC3C,GAEFf,IAAAA,WAAeK,MAAM,+CAI7B,GHGF,G","sources":["webpack://@fof/terms/webpack/bootstrap","webpack://@fof/terms/webpack/runtime/compat get default export","webpack://@fof/terms/webpack/runtime/define property getters","webpack://@fof/terms/webpack/runtime/hasOwnProperty shorthand","webpack://@fof/terms/webpack/runtime/make namespace object","webpack://@fof/terms/external root \"flarum.core.compat['forum/app']\"","webpack://@fof/terms/external root \"flarum.core.compat['common/Model']\"","webpack://@fof/terms/external root \"flarum.core.compat['common/models/User']\"","webpack://@fof/terms/./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js","webpack://@fof/terms/./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://@fof/terms/external root \"flarum.core.compat['common/utils/computed']\"","webpack://@fof/terms/./src/common/models/Policy.js","webpack://@fof/terms/external root \"flarum.core.compat['common/extend']\"","webpack://@fof/terms/external root \"flarum.core.compat['common/components/Page']\"","webpack://@fof/terms/external root \"flarum.core.compat['common/components/IndexPage']\"","webpack://@fof/terms/external root \"flarum.core.compat['common/components/Modal']\"","webpack://@fof/terms/external root \"flarum.core.compat['common/components/Button']\"","webpack://@fof/terms/./src/common/helpers/sortByAttribute.js","webpack://@fof/terms/./src/forum/components/AcceptPoliciesModal.js","webpack://@fof/terms/external root \"flarum.core.compat['forum/components/SignUpModal']\"","webpack://@fof/terms/external root \"flarum.core.compat['forum/components/IndexPage']\"","webpack://@fof/terms/external root \"flarum.core.compat['forum/components/DiscussionPage']\"","webpack://@fof/terms/external root \"flarum.core.compat['forum/components/UserPage']\"","webpack://@fof/terms/external root \"flarum.core.compat['common/helpers/listItems']\"","webpack://@fof/terms/./src/forum/components/UpdateAlert.js","webpack://@fof/terms/./src/forum/addUpdateAlert.js","webpack://@fof/terms/external root \"flarum.core.compat['forum/utils/UserControls']\"","webpack://@fof/terms/external root \"flarum.core.compat['common/helpers/humanTime']\"","webpack://@fof/terms/./src/forum/components/UserPoliciesStateModal.js","webpack://@fof/terms/./src/forum/components/index.js","webpack://@fof/terms/./src/common/models/index.js","webpack://@fof/terms/./src/common/helpers/index.js","webpack://@fof/terms/./src/forum/index.js","webpack://@fof/terms/./src/forum/addAcceptModal.js","webpack://@fof/terms/./src/forum/addFieldsToRegister.js","webpack://@fof/terms/./src/forum/addUserPoliciesStateControl.js"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/app'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/Model'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/models/User'];","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n return _setPrototypeOf(o, p);\n}","import setPrototypeOf from \"./setPrototypeOf.js\";\nexport default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n setPrototypeOf(subClass, superClass);\n}","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/utils/computed'];","import Model from 'flarum/common/Model';\nimport computed from 'flarum/common/utils/computed';\n\nexport default class Policy extends Model {\n sort = Model.attribute('sort');\n name = Model.attribute('name');\n url = Model.attribute('url');\n update_message = Model.attribute('update_message');\n terms_updated_at = Model.attribute('terms_updated_at');\n form_key = computed('id', (id) => 'fof_terms_policy_' + id);\n\n apiEndpoint() {\n return '/fof/terms/policies' + (this.exists ? '/' + this.data.id : '');\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/extend'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Page'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/IndexPage'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Modal'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Button'];","export default function (items, attr = 'sort') {\n return items.sort((a, b) => a[attr]() - b[attr]());\n}\n","import app from 'flarum/forum/app';\nimport Modal from 'flarum/common/components/Modal';\nimport Button from 'flarum/common/components/Button';\nimport sortByAttribute from '../../common/helpers/sortByAttribute';\n\n/* global m, dayjs */\n\nexport default class AcceptPoliciesModal extends Modal {\n oninit(vnode) {\n super.oninit(vnode);\n\n app.store.all('fof-terms-policies').forEach((policy) => {\n this[policy.form_key()] = false;\n });\n }\n\n title() {\n return app.translator.trans('fof-terms.forum.accept-modal.title');\n }\n\n className() {\n return 'AcceptPoliciesModal Modal--medium';\n }\n\n content() {\n return m('.Modal-body', this.body());\n }\n\n body() {\n const policies = sortByAttribute(\n app.store.all('fof-terms-policies').filter((policy) => {\n const state = app.session.user.fofTermsPoliciesState()[policy.id()];\n\n return !state || state.has_update;\n })\n );\n\n if (policies.length === 0) {\n return Button.component(\n {\n className: 'Button',\n onclick() {\n app.modal.close();\n },\n },\n app.translator.trans('fof-terms.forum.accept-modal.close')\n );\n }\n\n return policies.map((policy) =>\n m('div', [\n m('h2', policy.name()),\n app.forum.attribute('fof-terms.hide-updated-at')\n ? null\n : m(\n 'p',\n policy.terms_updated_at()\n ? app.translator.trans('fof-terms.forum.accept-modal.updated-at', {\n date: dayjs(policy.terms_updated_at()).format(app.forum.attribute('fof-terms.date-format')),\n })\n : app.translator.trans('fof-terms.forum.accept-modal.updated-recently')\n ),\n policy.update_message() ? m('p', policy.update_message()) : null,\n m(\n '.Form-group',\n m(\n '.FoF-Terms-Check.FoF-Terms-Check--login',\n m('label.checkbox', [\n m('input', {\n type: 'checkbox',\n checked: this[policy.form_key()],\n onchange: () => {\n this[policy.form_key()] = !this[policy.form_key()];\n },\n }),\n app.translator.trans('fof-terms.forum.accept-modal.i-accept', {\n policy: policy.name(),\n a: policy.url()\n ? m('a', {\n href: policy.url(),\n target: '_blank',\n })\n : m('span'),\n }),\n ])\n )\n ),\n Button.component(\n {\n className: 'Button Button--primary',\n disabled: !this[policy.form_key()],\n onclick: () => {\n // We need to save the \"must accept\" property before performing the request\n // Because an updated user serializer will be returned\n const hadToAcceptToInteract = app.session.user.fofTermsPoliciesMustAccept();\n\n app\n .request({\n url: app.forum.attribute('apiUrl') + policy.apiEndpoint() + '/accept',\n method: 'POST',\n errorHandler: this.onerror.bind(this),\n })\n .then((updated) => {\n app.store.pushPayload(updated);\n\n // If this was the last policy to accept, close the modal\n if (policies.length === 1) {\n if (hadToAcceptToInteract) {\n // If the user was previously not allowed to interact with the forum,\n // we refresh to get updated permissions in the frontend\n window.location.reload();\n } else {\n app.modal.close();\n }\n }\n\n m.redraw();\n });\n },\n },\n app.translator.trans('fof-terms.forum.accept-modal.accept')\n ),\n ])\n );\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/SignUpModal'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/IndexPage'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/DiscussionPage'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/UserPage'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/helpers/listItems'];","import app from 'flarum/forum/app';\nimport Button from 'flarum/common/components/Button';\nimport listItems from 'flarum/common/helpers/listItems';\nimport AcceptPoliciesModal from './AcceptPoliciesModal';\n\n/* global m */\n\nlet temporarilyHidden = false;\n\n/**\n * Renders similarly to Flarum's Alert, but with an additional .container inside\n */\nexport default class UpdateAlert {\n shouldShowAlert() {\n if (temporarilyHidden) {\n return false;\n }\n\n const user = app.session.user;\n\n return user && user.fofTermsPoliciesHasUpdate();\n }\n\n view() {\n if (!this.shouldShowAlert()) {\n return m('div');\n }\n\n const controls = [\n Button.component(\n {\n className: 'Button Button--link',\n onclick: () => {\n app.modal.show(AcceptPoliciesModal);\n },\n },\n app.translator.trans('fof-terms.forum.update-alert.review')\n ),\n ];\n\n const dismissControl = [];\n\n if (!app.session.user.fofTermsPoliciesMustAccept()) {\n dismissControl.push(\n Button.component({\n icon: 'fas fa-times',\n className: 'Button Button--link Button--icon Alert-dismiss',\n onclick: () => {\n temporarilyHidden = true;\n },\n })\n );\n }\n\n return m(\n '.Alert.Alert-info',\n m('.container', [\n m(\n 'span.Alert-body',\n app.session.user.fofTermsPoliciesMustAccept()\n ? app.translator.trans('fof-terms.forum.update-alert.must-accept-message')\n : app.translator.trans('fof-terms.forum.update-alert.can-accept-message')\n ),\n m('ul.Alert-controls', listItems(controls.concat(dismissControl))),\n ])\n );\n }\n}\n","import { override } from 'flarum/common/extend';\nimport IndexPage from 'flarum/forum/components/IndexPage';\nimport DiscussionPage from 'flarum/forum/components/DiscussionPage';\nimport UserPage from 'flarum/forum/components/UserPage';\nimport UpdateAlert from './components/UpdateAlert';\n\n/* global m */\n\n// This single method will be used to inject the alert into existing components\n// If the view is already an array, we add our content at the start\n// If it isn't an array we wrap the content into a new array\nfunction addAlertToContent(original, ...originalArgs) {\n const existing = original(...originalArgs);\n const additional = m(UpdateAlert);\n\n // if the existing content is an array, add to it\n // This should only happen with the hero() override as other extensions might return an array there\n if (Array.isArray(existing)) {\n existing.unshift(additional);\n\n return existing;\n }\n\n // Otherwise return a new list of elements\n // Use a container div otherwise when extending view() this will prevent the config() method from running\n // as the Component class won't be able to bind config() to an array\n // We could also add to vnode.children but this could cause weird styling if another extension or custom styles\n // change the look of the base page content by targeting the original view root element based on its class\n // By using a new outer container we make sure the alert always stays full width and unaffected by the page view under it\n return m('div', [additional, existing]);\n}\n\nexport default function () {\n // There's no single place we can inject the banner\n // So we use a few different points so it's visible on most pages\n override(IndexPage.prototype, 'hero', addAlertToContent);\n override(DiscussionPage.prototype, 'view', addAlertToContent);\n\n // Covers user profile and settings\n override(UserPage.prototype, 'view', addAlertToContent);\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/utils/UserControls'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/helpers/humanTime'];","import app from 'flarum/forum/app';\nimport humanTime from 'flarum/common/helpers/humanTime';\nimport Modal from 'flarum/common/components/Modal';\nimport sortByAttribute from '../../common/helpers/sortByAttribute';\n\n/* global m */\n\nexport default class UserPoliciesStateModal extends Modal {\n title() {\n return app.translator.trans('fof-terms.forum.state-modal.title', {\n username: this.attrs.user.username(),\n });\n }\n\n className() {\n return 'UserPoliciesStateModal Modal--medium';\n }\n\n content() {\n return m(\n '.Modal-body',\n m(\n 'ul',\n sortByAttribute(app.store.all('fof-terms-policies')).map((policy) => {\n const state = this.attrs.user.fofTermsPoliciesState()[policy.id()];\n\n return m('li', [\n policy.name() + ': ',\n state && state.accepted_at\n ? app.translator.trans('fof-terms.forum.state-modal.accepted-at', {\n date: humanTime(state.accepted_at),\n })\n : app.translator.trans('fof-terms.forum.state-modal.not-accepted'),\n ]);\n })\n )\n );\n }\n}\n","import AcceptPoliciesModal from './AcceptPoliciesModal';\nimport UpdateAlert from './UpdateAlert';\nimport UserPoliciesStateModal from './UserPoliciesStateModal';\n\nexport const components = {\n AcceptPoliciesModal,\n UpdateAlert,\n UserPoliciesStateModal,\n};\n","import Policy from './Policy';\n\nexport const models = {\n Policy,\n};\n","import sortByAttribute from './sortByAttribute';\n\nexport const helpers = {\n sortByAttribute,\n};\n","import app from 'flarum/forum/app';\nimport Model from 'flarum/common/Model';\nimport User from 'flarum/common/models/User';\nimport Policy from '../common/models/Policy';\nimport addAcceptModal from './addAcceptModal';\nimport addFieldsToRegister from './addFieldsToRegister';\nimport addUpdateAlert from './addUpdateAlert';\nimport addUserPoliciesStateControl from './addUserPoliciesStateControl';\n\nexport * from './components';\nexport * from '../common/models';\nexport * from '../common/helpers';\n\napp.initializers.add('fof-terms', () => {\n app.store.models['fof-terms-policies'] = Policy;\n\n User.prototype.fofTermsPoliciesState = Model.attribute('fofTermsPoliciesState');\n User.prototype.fofTermsPoliciesHasUpdate = Model.attribute('fofTermsPoliciesHasUpdate');\n User.prototype.fofTermsPoliciesMustAccept = Model.attribute('fofTermsPoliciesMustAccept');\n User.prototype.seeFoFTermsPoliciesState = Model.attribute('seeFoFTermsPoliciesState');\n\n addAcceptModal();\n addFieldsToRegister();\n addUpdateAlert();\n addUserPoliciesStateControl();\n});\n","import app from 'flarum/forum/app';\nimport { extend } from 'flarum/common/extend';\nimport Page from 'flarum/common/components/Page';\nimport IndexPage from 'flarum/common/components/IndexPage';\nimport AcceptPoliciesModal from './components/AcceptPoliciesModal';\n\nexport default function () {\n let initialized = false;\n\n extend(Page.prototype, 'oninit', function () {\n if (initialized) {\n return;\n }\n\n // We only show the modal if the first page loaded was the index page\n // And that new updates are available\n // And that the user *must* accept them\n if (app.current.matches(IndexPage)) {\n const user = app.session.user;\n\n if (user && user.fofTermsPoliciesMustAccept()) {\n // Timeout is necessary because there is a redraw error otherwise\n setTimeout(() => {\n app.modal.show(AcceptPoliciesModal);\n }, 0);\n }\n }\n\n initialized = true;\n });\n}\n","import { extend } from 'flarum/common/extend';\nimport app from 'flarum/forum/app';\nimport SignUpModal from 'flarum/forum/components/SignUpModal';\nimport sortByAttribute from '../common/helpers/sortByAttribute';\n\n/* global m */\n\nexport default function () {\n extend(SignUpModal.prototype, 'oninit', function () {\n this.fofTermsPolicies = sortByAttribute(app.store.all('fof-terms-policies'));\n\n this.fofTermsPolicies.forEach((policy) => {\n this[policy.form_key()] = false;\n });\n });\n\n extend(SignUpModal.prototype, 'fields', function (fields) {\n const legalText = app.forum.attribute('fof-terms.signup-legal-text');\n\n if (legalText) {\n fields.add('fof-terms-legal-text', m('.Form-group', m('.FoF-Terms-SignUp-Legal.Alert', legalText)));\n }\n\n this.fofTermsPolicies.forEach((policy) => {\n fields.add(\n 'fof-terms-policy-' + policy.id(),\n m(\n '.Form-group',\n m(\n '.FoF-Terms-Check.FoF-Terms-Check--signup',\n m('label.checkbox', [\n m('input', {\n type: 'checkbox',\n checked: this[policy.form_key()],\n onchange: () => {\n this[policy.form_key()] = !this[policy.form_key()];\n },\n disabled: this.loading,\n }),\n app.translator.trans('fof-terms.forum.signup.i-accept', {\n policy: policy.name(),\n a: policy.url()\n ? m('a', {\n href: policy.url(),\n target: '_blank',\n })\n : m('span'),\n }),\n ])\n )\n )\n );\n });\n });\n\n extend(SignUpModal.prototype, 'submitData', function (data) {\n this.fofTermsPolicies.forEach((policy) => {\n data[policy.form_key()] = this[policy.form_key()];\n });\n });\n}\n","import { extend } from 'flarum/common/extend';\nimport app from 'flarum/forum/app';\nimport UserControls from 'flarum/forum/utils/UserControls';\nimport Button from 'flarum/common/components/Button';\nimport UserPoliciesStateModal from './components/UserPoliciesStateModal';\n\nexport default function () {\n extend(UserControls, 'moderationControls', (items, user) => {\n if (app.forum.attribute('fof-terms.canSeeUserPoliciesState')) {\n items.add(\n 'fof-terms.state',\n Button.component(\n {\n icon: 'fas fa-paperclip',\n onclick() {\n app.modal.show(UserPoliciesStateModal, { user });\n },\n },\n app.translator.trans('fof-terms.forum.user_controls.state_button')\n )\n );\n }\n });\n}\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","flarum","core","compat","_setPrototypeOf","p","setPrototypeOf","bind","__proto__","_inheritsLoose","subClass","superClass","create","constructor","Policy","_Model","_this","_len","arguments","length","args","Array","_key","apply","concat","sort","Model","name","url","update_message","terms_updated_at","form_key","computed","id","apiEndpoint","this","exists","data","items","attr","b","AcceptPoliciesModal","_Modal","_proto","oninit","vnode","app","all","forEach","policy","title","trans","className","content","m","body","_this2","policies","sortByAttribute","filter","state","user","fofTermsPoliciesState","has_update","Button","onclick","close","map","attribute","date","dayjs","format","type","checked","onchange","href","target","disabled","hadToAcceptToInteract","fofTermsPoliciesMustAccept","method","errorHandler","onerror","then","updated","pushPayload","window","location","reload","redraw","Modal","temporarilyHidden","UpdateAlert","shouldShowAlert","fofTermsPoliciesHasUpdate","view","controls","show","dismissControl","push","icon","listItems","addAlertToContent","original","originalArgs","existing","additional","isArray","unshift","UserPoliciesStateModal","username","attrs","accepted_at","humanTime","components","models","helpers","add","initialized","User","seeFoFTermsPoliciesState","extend","Page","matches","IndexPage","setTimeout","SignUpModal","fofTermsPolicies","fields","legalText","loading","_this3","override","DiscussionPage","UserPage","UserControls"],"sourceRoot":""} \ No newline at end of file