From ea529196fa12654a3b7b3b5cd2d0adcc461bf9df Mon Sep 17 00:00:00 2001 From: flarum-bot Date: Tue, 25 Jan 2022 13:54:30 +0000 Subject: [PATCH] Bundled output for commit b7a34a86a9d6a7d13a435e65f442e4222478aa6d Includes transpiled JS/TS. [skip ci] --- js/dist/admin.js | 2 +- js/dist/admin.js.map | 2 +- js/dist/forum.js | 2 +- js/dist/forum.js.map | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/js/dist/admin.js b/js/dist/admin.js index 07f88ab5..baeb93a9 100644 --- a/js/dist/admin.js +++ b/js/dist/admin.js @@ -1,2 +1,2 @@ -module.exports=function(t){var e={};function a(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,a),o.l=!0,o.exports}return a.m=t,a.c=e,a.d=function(t,e,n){a.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},a.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(a.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)a.d(n,o,function(e){return t[e]}.bind(null,o));return n},a.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return a.d(e,"a",e),e},a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},a.p="",a(a.s=28)}([,function(t,e){t.exports=flarum.core.compat["admin/app"]},function(t,e){t.exports=flarum.core.compat["common/utils/withAttr"]},,function(t,e,a){"use strict";function n(t,e){return(n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function o(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,n(t,e)}a.d(e,"a",(function(){return o}))},function(t,e){t.exports=flarum.core.compat["common/components/Button"]},,function(t,e){t.exports=flarum.core.compat["common/utils/Stream"]},function(t,e){t.exports=flarum.core.compat["common/components/Select"]},,function(t,e){t.exports=flarum.core.compat["common/components/Alert"]},function(t,e){t.exports=flarum.core.compat["common/components/Switch"]},,,,,,,,,,,,function(t,e){t.exports=flarum.core.compat["admin/utils/saveSettings"]},function(t,e){t.exports=flarum.core.compat["admin/components/UploadImageButton"]},function(t,e){t.exports=flarum.core.compat["admin/components/ExtensionPage"]},function(t,e){t.exports=flarum.core.compat["common/utils/ItemList"]},,function(t,e,a){"use strict";a.r(e),a.d(e,"components",(function(){return k}));var n=a(1),o=a.n(n),s=a(4),i=a(5),l=a.n(i),r=a(23),u=a.n(r),p=a(10),d=a.n(p),f=a(8),c=a.n(f),h=a(11),b=a.n(h),v=a(24),g=a.n(v),y=a(2),w=a.n(y),x=a(7),_=a.n(x),T=a(25),M=a.n(T),S=a(26),P=a.n(S),O=function(t){function e(){return t.apply(this,arguments)||this}Object(s.a)(e,t);var a=e.prototype;return a.oninit=function(e){var a=this;t.prototype.oninit.call(this,e),this.loading=!1,this.fields=["resizeMaxWidth","cdnUrl","maxFileSize","whitelistedClientExtensions","composerButtonVisiblity","watermark","watermarkPosition","imgurClientId","awsS3Key","awsS3Secret","awsS3Bucket","awsS3Region","awsS3Endpoint","awsS3ACL","qiniuKey","qiniuSecret","qiniuBucket"],this.checkboxes=["mustResize","addsWatermarks","disableHotlinkProtection","disableDownloadLogging","awsS3UsePathStyleEndpoint"],this.objects=["mimeTypes"],this.watermarkPositions={"top-left":"top-left","top-right":"top-right","bottom-left":"bottom-left","bottom-right":"bottom-right",center:"center",left:"left",top:"top",right:"right",bottom:"bottom"},this.composerButtonVisiblityOptions={both:o.a.translator.trans("fof-upload.admin.labels.composer_buttons.options.both"),"upload-btn":o.a.translator.trans("fof-upload.admin.labels.composer_buttons.options.upload-btn"),"media-btn":o.a.translator.trans("fof-upload.admin.labels.composer_buttons.options.media-btn")};var n=o.a.data.settings;this.settingsPrefix="fof-upload",this.uploadMethodOptions=n[this.addPrefix("availableUploadMethods")]||{},this.templateOptions=n[this.addPrefix("availableTemplates")]||{},this.values={},this.fields.forEach((function(t){return a.values[t]=_()(n[a.addPrefix(t)])})),this.checkboxes.forEach((function(t){return a.values[t]=_()("1"===n[a.addPrefix(t)])})),this.objects.forEach((function(t){return a.values[t]=n[a.addPrefix(t)]?_()(JSON.parse(n[a.addPrefix(t)])):_()()})),this.defaultAdap=Object.keys(this.uploadMethodOptions)[Object.keys(this.uploadMethodOptions).length-1],this.values.mimeTypes()||(this.values.mimeTypes=_()({"^image\\/.*":{adapter:this.defaultAdap,template:"image-preview"}})),this.newMimeType={regex:_()(""),adapter:_()(this.defaultAdap),template:_()("file")}},a.content=function(){var t=this,e=o.a.data.settings[this.addPrefix("php_ini.post_max_size")],a=o.a.data.settings[this.addPrefix("php_ini.upload_max_filesize")];return[m(".UploadPage",[m(".container",[m("form",{onsubmit:this.onsubmit.bind(this)},[m("fieldset",[m("legend",o.a.translator.trans("fof-upload.admin.labels.preferences.title")),m("label",o.a.translator.trans("fof-upload.admin.labels.preferences.max_file_size")),m("input.FormControl",{value:this.values.maxFileSize()||2048,oninput:w()("value",this.values.maxFileSize),type:"number",min:"0"}),m(".helpText",o.a.translator.trans("fof-upload.admin.labels.preferences.php_ini_values",{post:e,upload:a})),m("label",o.a.translator.trans("fof-upload.admin.labels.preferences.mime_types")),m(".MimeTypes--Container",Object.keys(this.values.mimeTypes()).map((function(e){var a=t.values.mimeTypes()[e];return"object"!=typeof a&&(a={adapter:a,template:"file"}),m("div",[m("input.FormControl.MimeTypes",{value:e,oninput:w()("value",t.updateMimeTypeKey.bind(t,e))}),c.a.component({options:t.uploadMethodOptions,onchange:t.updateMimeTypeAdapter.bind(t,e,a),value:a.adapter||"local"}),c.a.component({options:t.getTemplateOptionsForInput(),onchange:t.updateMimeTypeTemplate.bind(t,e,a),value:a.template||"local"}),l.a.component({type:"button",className:"Button Button--warning",onclick:t.deleteMimeType.bind(t,e)},"x")])})),m("br"),m("div",[m("input.FormControl.MimeTypes.add-MimeType-key",{value:this.newMimeType.regex(),oninput:w()("value",this.newMimeType.regex)}),c.a.component({options:this.uploadMethodOptions,className:"add-MimeType-value",oninput:w()("value",this.newMimeType.adapter),value:this.newMimeType.adapter()}),c.a.component({options:this.getTemplateOptionsForInput(),className:"add-MimeType-value",oninput:w()("value",this.newMimeType.template),value:this.newMimeType.template()}),l.a.component({type:"button",className:"Button Button--warning",onclick:this.addMimeType.bind(this)},"+")])),m(".helpText",o.a.translator.trans("fof-upload.admin.help_texts.mime_types")),m(".helpText",o.a.translator.trans("fof-upload.admin.help_texts.download_templates")),this.templateOptionsDescriptions()]),m("fieldset.composerButtons",[m("legend",o.a.translator.trans("fof-upload.admin.labels.composer_buttons.title")),m(".helpText",o.a.translator.trans("fof-upload.admin.help_texts.composer_buttons")),m("div",[c.a.component({options:this.composerButtonVisiblityOptions,onchange:this.values.composerButtonVisiblity,value:this.values.composerButtonVisiblity()||"both"})])]),m("fieldset",[m("legend",o.a.translator.trans("fof-upload.admin.labels.resize.title")),m(".helpText",o.a.translator.trans("fof-upload.admin.help_texts.resize")),b.a.component({state:this.values.mustResize()||!1,onchange:this.values.mustResize},o.a.translator.trans("fof-upload.admin.labels.resize.toggle")),m("label",o.a.translator.trans("fof-upload.admin.labels.resize.max_width")),m("input",{className:"FormControl",value:this.values.resizeMaxWidth()||100,oninput:w()("value",this.values.resizeMaxWidth),disabled:!this.values.mustResize(),type:"number",min:"0"})]),m("fieldset",[m("legend",o.a.translator.trans("fof-upload.admin.labels.client_extension.title")),m(".helpText",o.a.translator.trans("fof-upload.admin.help_texts.client_extension")),m("input",{className:"FormControl",value:this.values.whitelistedClientExtensions()||"",oninput:w()("value",this.values.whitelistedClientExtensions)})]),m("fieldset",[m("legend",o.a.translator.trans("fof-upload.admin.labels.watermark.title")),m(".helpText",o.a.translator.trans("fof-upload.admin.help_texts.watermark")),b.a.component({state:this.values.addsWatermarks()||!1,onchange:this.values.addsWatermarks},o.a.translator.trans("fof-upload.admin.labels.watermark.toggle")),m("label",o.a.translator.trans("fof-upload.admin.labels.watermark.position")),m("div",[c.a.component({options:this.watermarkPositions,onchange:this.values.watermarkPosition,value:this.values.watermarkPosition()||"bottom-right"})]),m("label",{},o.a.translator.trans("fof-upload.admin.labels.watermark.file")),g.a.component({name:"fof/watermark"})]),m("fieldset",[m("legend",o.a.translator.trans("fof-upload.admin.labels.disable-hotlink-protection.title")),m(".helpText",o.a.translator.trans("fof-upload.admin.help_texts.disable-hotlink-protection")),b.a.component({state:this.values.disableHotlinkProtection()||!1,onchange:this.values.disableHotlinkProtection},o.a.translator.trans("fof-upload.admin.labels.disable-hotlink-protection.toggle")),m("legend",o.a.translator.trans("fof-upload.admin.labels.disable-download-logging.title")),m(".helpText",o.a.translator.trans("fof-upload.admin.help_texts.disable-download-logging")),b.a.component({state:this.values.disableDownloadLogging()||!1,onchange:this.values.disableDownloadLogging},o.a.translator.trans("fof-upload.admin.labels.disable-download-logging.toggle"))]),m("fieldset",[m("legend",o.a.translator.trans("fof-upload.admin.labels.local.title")),m("label",o.a.translator.trans("fof-upload.admin.labels.local.cdn_url")),m("input.FormControl",{value:this.values.cdnUrl()||"",oninput:w()("value",this.values.cdnUrl)})]),this.adaptorItems().toArray(),l.a.component({type:"submit",className:"Button Button--primary",loading:this.loading,disabled:!this.changed()},o.a.translator.trans("core.admin.settings.submit_button"))])])])]},a.adaptorItems=function(){var t=new P.a;return void 0!==this.uploadMethodOptions.imgur&&t.add("imgur",m(".imgur",[m("fieldset",[m("legend",o.a.translator.trans("fof-upload.admin.labels.imgur.title")),m("label",o.a.translator.trans("fof-upload.admin.labels.imgur.client_id")),m("input.FormControl",{value:this.values.imgurClientId()||"",oninput:w()("value",this.values.imgurClientId)})])])),void 0!==this.uploadMethodOptions.qiniu&&t.add("qiniu",m(".qiniu",[m("fieldset",[m("legend",o.a.translator.trans("fof-upload.admin.labels.qiniu.title")),m("label",o.a.translator.trans("fof-upload.admin.labels.qiniu.key")),m("input.FormControl",{value:this.values.qiniuKey()||"",oninput:w()("value",this.values.qiniuKey)}),m("label",{},o.a.translator.trans("fof-upload.admin.labels.qiniu.secret")),m("input.FormControl",{value:this.values.qiniuSecret()||"",oninput:w()("value",this.values.qiniuSecret)}),m("label",{},o.a.translator.trans("fof-upload.admin.labels.qiniu.bucket")),m("input.FormControl",{value:this.values.qiniuBucket()||"",oninput:w()("value",this.values.qiniuBucket)})])])),void 0!==this.uploadMethodOptions["aws-s3"]&&t.add("aws-s3",m(".aws",[m("fieldset",[m("legend",o.a.translator.trans("fof-upload.admin.labels.aws-s3.title")),m("label",o.a.translator.trans("fof-upload.admin.labels.aws-s3.key")),m("input.FormControl",{value:this.values.awsS3Key()||"",oninput:w()("value",this.values.awsS3Key)}),m("label",o.a.translator.trans("fof-upload.admin.labels.aws-s3.secret")),m("input.FormControl",{value:this.values.awsS3Secret()||"",oninput:w()("value",this.values.awsS3Secret)}),m("label",o.a.translator.trans("fof-upload.admin.labels.aws-s3.bucket")),m("input.FormControl",{value:this.values.awsS3Bucket()||"",oninput:w()("value",this.values.awsS3Bucket)}),m("label",o.a.translator.trans("fof-upload.admin.labels.aws-s3.region")),m("input.FormControl",{value:this.values.awsS3Region()||"",oninput:w()("value",this.values.awsS3Region)})]),m("fieldset",[m("legend",o.a.translator.trans("fof-upload.admin.labels.aws-s3.advanced_title")),m(".helpText",o.a.translator.trans("fof-upload.admin.help_texts.s3_compatible_storage")),m("label",o.a.translator.trans("fof-upload.admin.labels.aws-s3.endpoint")),m("input.FormControl",{value:this.values.awsS3Endpoint()||"",oninput:w()("value",this.values.awsS3Endpoint)}),b.a.component({state:this.values.awsS3UsePathStyleEndpoint()||!1,onchange:this.values.awsS3UsePathStyleEndpoint},o.a.translator.trans("fof-upload.admin.labels.aws-s3.use_path_style_endpoint")),m("label",o.a.translator.trans("fof-upload.admin.labels.aws-s3.acl")),m("input.FormControl",{value:this.values.awsS3ACL()||"",oninput:w()("value",this.values.awsS3ACL)}),m(".helpText",o.a.translator.trans("fof-upload.admin.help_texts.s3_acl"))])])),t},a.getTemplateOptionsForInput=function(){var t={};for(var e in this.templateOptions)this.templateOptions.hasOwnProperty(e)&&(t[e]=this.templateOptions[e].name);return t},a.updateMimeTypeKey=function(t,e){this.values.mimeTypes()[e]=this.values.mimeTypes()[t],this.deleteMimeType(t)},a.updateMimeTypeAdapter=function(t,e,a){e.adapter=a,this.values.mimeTypes()[t]=e},a.updateMimeTypeTemplate=function(t,e,a){e.template=a,this.values.mimeTypes()[t]=e},a.deleteMimeType=function(t){delete this.values.mimeTypes()[t]},a.templateOptionsDescriptions=function(){var t=[];for(var e in this.templateOptions)this.templateOptions.hasOwnProperty(e)&&t.push(m("li",null,this.templateOptions[e].name,": ",m.trust(this.templateOptions[e].description)));return m("ul",t)},a.addMimeType=function(){this.values.mimeTypes()[this.newMimeType.regex()]={adapter:this.newMimeType.adapter(),template:this.newMimeType.template()},this.newMimeType.regex(""),this.newMimeType.adapter("local"),this.newMimeType.template("file")},a.changed=function(){var t=this,e=this.fields.some((function(e){return t.values[e]()!==o.a.data.settings[t.addPrefix(e)]})),a=this.checkboxes.some((function(e){return t.values[e]()!==("1"===o.a.data.settings[t.addPrefix(e)])})),n=this.objects.some((function(e){return JSON.stringify(t.values[e]())!==o.a.data.settings[t.addPrefix(e)]}));return e||a||n},a.onsubmit=function(t){var e=this;if(t.preventDefault(),!this.loading){this.loading=!0,o.a.alerts.dismiss(this.successAlert);var a={};this.fields.forEach((function(t){return a[e.addPrefix(t)]=e.values[t]()})),this.checkboxes.forEach((function(t){return a[e.addPrefix(t)]=e.values[t]()})),this.objects.forEach((function(t){return a[e.addPrefix(t)]=JSON.stringify(e.values[t]())})),u()(a).then((function(){e.successAlert=o.a.alerts.show(d.a,{type:"success"},o.a.translator.trans("core.admin.settings.saved_message"))})).catch((function(){})).then((function(){e.loading=!1,m.redraw()}))}},a.addPrefix=function(t){return this.settingsPrefix+"."+t},e}(M.a),k={UploadPage:O};o.a.initializers.add("fof-upload",(function(t){t.extensionData.for("fof-upload").registerPage(O).registerPermission({icon:"far fa-file",label:t.translator.trans("fof-upload.admin.permissions.upload_label"),permission:"fof-upload.upload"},"start",50).registerPermission({icon:"fas fa-download",label:t.translator.trans("fof-upload.admin.permissions.download_label"),permission:"fof-upload.download",allowGuest:!0},"view",50).registerPermission({icon:"fas fa-eye",label:t.translator.trans("fof-upload.admin.permissions.view_user_uploads_label"),permission:"fof-upload.viewUserUploads"},"moderate",50).registerPermission({icon:"fas fa-trash",label:t.translator.trans("fof-upload.admin.permissions.delete_uploads_of_others_label"),permission:"fof-upload.deleteUserUploads"},"moderate",50)}))}]); +(()=>{var t={n:e=>{var a=e&&e.__esModule?()=>e.default:()=>e;return t.d(a,{a}),a},d:(e,a)=>{for(var s in a)t.o(a,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:a[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{"use strict";t.r(e),t.d(e,{components:()=>k});const a=flarum.core.compat["admin/app"];var s=t.n(a);function o(t,e){return o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},o(t,e)}const n=flarum.core.compat["common/components/Button"];var i=t.n(n);const l=flarum.core.compat["admin/utils/saveSettings"];var r=t.n(l);const p=flarum.core.compat["common/components/Alert"];var u=t.n(p);const d=flarum.core.compat["common/components/Select"];var f=t.n(d);const c=flarum.core.compat["common/components/Switch"];var h=t.n(c);const v=flarum.core.compat["admin/components/UploadImageButton"];var b=t.n(v);const g=flarum.core.compat["common/utils/withAttr"];var y=t.n(g);const w=flarum.core.compat["common/utils/Stream"];var x=t.n(w);const T=flarum.core.compat["admin/components/ExtensionPage"];var _=t.n(T);const M=flarum.core.compat["common/utils/ItemList"];var S=t.n(M),P=function(t){var e,a;function n(){return t.apply(this,arguments)||this}a=t,(e=n).prototype=Object.create(a.prototype),e.prototype.constructor=e,o(e,a);var l=n.prototype;return l.oninit=function(e){var a=this;t.prototype.oninit.call(this,e),this.loading=!1,this.fields=["resizeMaxWidth","cdnUrl","maxFileSize","whitelistedClientExtensions","composerButtonVisiblity","watermark","watermarkPosition","imgurClientId","awsS3Key","awsS3Secret","awsS3Bucket","awsS3Region","awsS3Endpoint","awsS3ACL","qiniuKey","qiniuSecret","qiniuBucket"],this.checkboxes=["mustResize","addsWatermarks","disableHotlinkProtection","disableDownloadLogging","awsS3UsePathStyleEndpoint"],this.objects=["mimeTypes"],this.watermarkPositions={"top-left":"top-left","top-right":"top-right","bottom-left":"bottom-left","bottom-right":"bottom-right",center:"center",left:"left",top:"top",right:"right",bottom:"bottom"},this.composerButtonVisiblityOptions={both:s().translator.trans("fof-upload.admin.labels.composer_buttons.options.both"),"upload-btn":s().translator.trans("fof-upload.admin.labels.composer_buttons.options.upload-btn"),"media-btn":s().translator.trans("fof-upload.admin.labels.composer_buttons.options.media-btn")};var o=s().data.settings;this.settingsPrefix="fof-upload",this.uploadMethodOptions=o[this.addPrefix("availableUploadMethods")]||{},this.templateOptions=o[this.addPrefix("availableTemplates")]||{},this.values={},this.fields.forEach((function(t){return a.values[t]=x()(o[a.addPrefix(t)])})),this.checkboxes.forEach((function(t){return a.values[t]=x()("1"===o[a.addPrefix(t)])})),this.objects.forEach((function(t){return a.values[t]=o[a.addPrefix(t)]?x()(JSON.parse(o[a.addPrefix(t)])):x()()})),this.defaultAdap=Object.keys(this.uploadMethodOptions)[Object.keys(this.uploadMethodOptions).length-1],this.values.mimeTypes()||(this.values.mimeTypes=x()({"^image\\/.*":{adapter:this.defaultAdap,template:"image-preview"}})),this.newMimeType={regex:x()(""),adapter:x()(this.defaultAdap),template:x()("file")}},l.content=function(){var t=this,e=s().data.settings[this.addPrefix("php_ini.post_max_size")],a=s().data.settings[this.addPrefix("php_ini.upload_max_filesize")];return[m(".UploadPage",[m(".container",[m("form",{onsubmit:this.onsubmit.bind(this)},[m("fieldset",[m("legend",s().translator.trans("fof-upload.admin.labels.preferences.title")),m("label",s().translator.trans("fof-upload.admin.labels.preferences.max_file_size")),m("input.FormControl",{value:this.values.maxFileSize()||2048,oninput:y()("value",this.values.maxFileSize),type:"number",min:"0"}),m(".helpText",s().translator.trans("fof-upload.admin.labels.preferences.php_ini_values",{post:e,upload:a})),m("label",s().translator.trans("fof-upload.admin.labels.preferences.mime_types")),m(".MimeTypes--Container",Object.keys(this.values.mimeTypes()).map((function(e){var a=t.values.mimeTypes()[e];return"object"!=typeof a&&(a={adapter:a,template:"file"}),m("div",[m("input.FormControl.MimeTypes",{value:e,oninput:y()("value",t.updateMimeTypeKey.bind(t,e))}),f().component({options:t.uploadMethodOptions,onchange:t.updateMimeTypeAdapter.bind(t,e,a),value:a.adapter||"local"}),f().component({options:t.getTemplateOptionsForInput(),onchange:t.updateMimeTypeTemplate.bind(t,e,a),value:a.template||"local"}),i().component({type:"button",className:"Button Button--warning",onclick:t.deleteMimeType.bind(t,e)},"x")])})),m("br"),m("div",[m("input.FormControl.MimeTypes.add-MimeType-key",{value:this.newMimeType.regex(),oninput:y()("value",this.newMimeType.regex)}),f().component({options:this.uploadMethodOptions,className:"add-MimeType-value",oninput:y()("value",this.newMimeType.adapter),value:this.newMimeType.adapter()}),f().component({options:this.getTemplateOptionsForInput(),className:"add-MimeType-value",oninput:y()("value",this.newMimeType.template),value:this.newMimeType.template()}),i().component({type:"button",className:"Button Button--warning",onclick:this.addMimeType.bind(this)},"+")])),m(".helpText",s().translator.trans("fof-upload.admin.help_texts.mime_types")),m(".helpText",s().translator.trans("fof-upload.admin.help_texts.download_templates")),this.templateOptionsDescriptions()]),m("fieldset.composerButtons",[m("legend",s().translator.trans("fof-upload.admin.labels.composer_buttons.title")),m(".helpText",s().translator.trans("fof-upload.admin.help_texts.composer_buttons")),m("div",[f().component({options:this.composerButtonVisiblityOptions,onchange:this.values.composerButtonVisiblity,value:this.values.composerButtonVisiblity()||"both"})])]),m("fieldset",[m("legend",s().translator.trans("fof-upload.admin.labels.resize.title")),m(".helpText",s().translator.trans("fof-upload.admin.help_texts.resize")),h().component({state:this.values.mustResize()||!1,onchange:this.values.mustResize},s().translator.trans("fof-upload.admin.labels.resize.toggle")),m("label",s().translator.trans("fof-upload.admin.labels.resize.max_width")),m("input",{className:"FormControl",value:this.values.resizeMaxWidth()||100,oninput:y()("value",this.values.resizeMaxWidth),disabled:!this.values.mustResize(),type:"number",min:"0"})]),m("fieldset",[m("legend",s().translator.trans("fof-upload.admin.labels.client_extension.title")),m(".helpText",s().translator.trans("fof-upload.admin.help_texts.client_extension")),m("input",{className:"FormControl",value:this.values.whitelistedClientExtensions()||"",oninput:y()("value",this.values.whitelistedClientExtensions)})]),m("fieldset",[m("legend",s().translator.trans("fof-upload.admin.labels.watermark.title")),m(".helpText",s().translator.trans("fof-upload.admin.help_texts.watermark")),h().component({state:this.values.addsWatermarks()||!1,onchange:this.values.addsWatermarks},s().translator.trans("fof-upload.admin.labels.watermark.toggle")),m("label",s().translator.trans("fof-upload.admin.labels.watermark.position")),m("div",[f().component({options:this.watermarkPositions,onchange:this.values.watermarkPosition,value:this.values.watermarkPosition()||"bottom-right"})]),m("label",{},s().translator.trans("fof-upload.admin.labels.watermark.file")),b().component({name:"fof/watermark"})]),m("fieldset",[m("legend",s().translator.trans("fof-upload.admin.labels.disable-hotlink-protection.title")),m(".helpText",s().translator.trans("fof-upload.admin.help_texts.disable-hotlink-protection")),h().component({state:this.values.disableHotlinkProtection()||!1,onchange:this.values.disableHotlinkProtection},s().translator.trans("fof-upload.admin.labels.disable-hotlink-protection.toggle")),m("legend",s().translator.trans("fof-upload.admin.labels.disable-download-logging.title")),m(".helpText",s().translator.trans("fof-upload.admin.help_texts.disable-download-logging")),h().component({state:this.values.disableDownloadLogging()||!1,onchange:this.values.disableDownloadLogging},s().translator.trans("fof-upload.admin.labels.disable-download-logging.toggle"))]),m("fieldset",[m("legend",s().translator.trans("fof-upload.admin.labels.local.title")),m("label",s().translator.trans("fof-upload.admin.labels.local.cdn_url")),m("input.FormControl",{value:this.values.cdnUrl()||"",oninput:y()("value",this.values.cdnUrl)})]),this.adaptorItems().toArray(),i().component({type:"submit",className:"Button Button--primary",loading:this.loading,disabled:!this.changed()},s().translator.trans("core.admin.settings.submit_button"))])])])]},l.adaptorItems=function(){var t=new(S());return void 0!==this.uploadMethodOptions.imgur&&t.add("imgur",m(".imgur",[m("fieldset",[m("legend",s().translator.trans("fof-upload.admin.labels.imgur.title")),m("label",s().translator.trans("fof-upload.admin.labels.imgur.client_id")),m("input.FormControl",{value:this.values.imgurClientId()||"",oninput:y()("value",this.values.imgurClientId)})])])),void 0!==this.uploadMethodOptions.qiniu&&t.add("qiniu",m(".qiniu",[m("fieldset",[m("legend",s().translator.trans("fof-upload.admin.labels.qiniu.title")),m("label",s().translator.trans("fof-upload.admin.labels.qiniu.key")),m("input.FormControl",{value:this.values.qiniuKey()||"",oninput:y()("value",this.values.qiniuKey)}),m("label",{},s().translator.trans("fof-upload.admin.labels.qiniu.secret")),m("input.FormControl",{value:this.values.qiniuSecret()||"",oninput:y()("value",this.values.qiniuSecret)}),m("label",{},s().translator.trans("fof-upload.admin.labels.qiniu.bucket")),m("input.FormControl",{value:this.values.qiniuBucket()||"",oninput:y()("value",this.values.qiniuBucket)})])])),void 0!==this.uploadMethodOptions["aws-s3"]&&t.add("aws-s3",m(".aws",[m("fieldset",[m("legend",s().translator.trans("fof-upload.admin.labels.aws-s3.title")),m("label",s().translator.trans("fof-upload.admin.labels.aws-s3.key")),m("input.FormControl",{value:this.values.awsS3Key()||"",oninput:y()("value",this.values.awsS3Key)}),m("label",s().translator.trans("fof-upload.admin.labels.aws-s3.secret")),m("input.FormControl",{value:this.values.awsS3Secret()||"",oninput:y()("value",this.values.awsS3Secret)}),m("label",s().translator.trans("fof-upload.admin.labels.aws-s3.bucket")),m("input.FormControl",{value:this.values.awsS3Bucket()||"",oninput:y()("value",this.values.awsS3Bucket)}),m("label",s().translator.trans("fof-upload.admin.labels.aws-s3.region")),m("input.FormControl",{value:this.values.awsS3Region()||"",oninput:y()("value",this.values.awsS3Region)})]),m("fieldset",[m("legend",s().translator.trans("fof-upload.admin.labels.aws-s3.advanced_title")),m(".helpText",s().translator.trans("fof-upload.admin.help_texts.s3_compatible_storage")),m("label",s().translator.trans("fof-upload.admin.labels.aws-s3.endpoint")),m("input.FormControl",{value:this.values.awsS3Endpoint()||"",oninput:y()("value",this.values.awsS3Endpoint)}),h().component({state:this.values.awsS3UsePathStyleEndpoint()||!1,onchange:this.values.awsS3UsePathStyleEndpoint},s().translator.trans("fof-upload.admin.labels.aws-s3.use_path_style_endpoint")),m("label",s().translator.trans("fof-upload.admin.labels.aws-s3.acl")),m("input.FormControl",{value:this.values.awsS3ACL()||"",oninput:y()("value",this.values.awsS3ACL)}),m(".helpText",s().translator.trans("fof-upload.admin.help_texts.s3_acl"))])])),t},l.getTemplateOptionsForInput=function(){var t={};for(var e in this.templateOptions)this.templateOptions.hasOwnProperty(e)&&(t[e]=this.templateOptions[e].name);return t},l.updateMimeTypeKey=function(t,e){this.values.mimeTypes()[e]=this.values.mimeTypes()[t],this.deleteMimeType(t)},l.updateMimeTypeAdapter=function(t,e,a){e.adapter=a,this.values.mimeTypes()[t]=e},l.updateMimeTypeTemplate=function(t,e,a){e.template=a,this.values.mimeTypes()[t]=e},l.deleteMimeType=function(t){delete this.values.mimeTypes()[t]},l.templateOptionsDescriptions=function(){var t=[];for(var e in this.templateOptions)this.templateOptions.hasOwnProperty(e)&&t.push(m("li",null,this.templateOptions[e].name,": ",m.trust(this.templateOptions[e].description)));return m("ul",t)},l.addMimeType=function(){this.values.mimeTypes()[this.newMimeType.regex()]={adapter:this.newMimeType.adapter(),template:this.newMimeType.template()},this.newMimeType.regex(""),this.newMimeType.adapter("local"),this.newMimeType.template("file")},l.changed=function(){var t=this,e=this.fields.some((function(e){return t.values[e]()!==s().data.settings[t.addPrefix(e)]})),a=this.checkboxes.some((function(e){return t.values[e]()!==("1"===s().data.settings[t.addPrefix(e)])})),o=this.objects.some((function(e){return JSON.stringify(t.values[e]())!==s().data.settings[t.addPrefix(e)]}));return e||a||o},l.onsubmit=function(t){var e=this;if(t.preventDefault(),!this.loading){this.loading=!0,s().alerts.dismiss(this.successAlert);var a={};this.fields.forEach((function(t){return a[e.addPrefix(t)]=e.values[t]()})),this.checkboxes.forEach((function(t){return a[e.addPrefix(t)]=e.values[t]()})),this.objects.forEach((function(t){return a[e.addPrefix(t)]=JSON.stringify(e.values[t]())})),r()(a).then((function(){e.successAlert=s().alerts.show(u(),{type:"success"},s().translator.trans("core.admin.settings.saved_message"))})).catch((function(){})).then((function(){e.loading=!1,m.redraw()}))}},l.addPrefix=function(t){return this.settingsPrefix+"."+t},n}(_()),k={UploadPage:P};s().initializers.add("fof-upload",(function(t){t.extensionData.for("fof-upload").registerPage(P).registerPermission({icon:"far fa-file",label:t.translator.trans("fof-upload.admin.permissions.upload_label"),permission:"fof-upload.upload"},"start",50).registerPermission({icon:"fas fa-download",label:t.translator.trans("fof-upload.admin.permissions.download_label"),permission:"fof-upload.download",allowGuest:!0},"view",50).registerPermission({icon:"fas fa-eye",label:t.translator.trans("fof-upload.admin.permissions.view_user_uploads_label"),permission:"fof-upload.viewUserUploads"},"moderate",50).registerPermission({icon:"fas fa-trash",label:t.translator.trans("fof-upload.admin.permissions.delete_uploads_of_others_label"),permission:"fof-upload.deleteUserUploads"},"moderate",50)}))})(),module.exports=e})(); //# sourceMappingURL=admin.js.map \ No newline at end of file diff --git a/js/dist/admin.js.map b/js/dist/admin.js.map index 3732aba8..36a13631 100644 --- a/js/dist/admin.js.map +++ b/js/dist/admin.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://@fof/upload/webpack/bootstrap","webpack://@fof/upload/external \"flarum.core.compat['admin/app']\"","webpack://@fof/upload/external \"flarum.core.compat['common/utils/withAttr']\"","webpack://@fof/upload/./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js","webpack://@fof/upload/./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://@fof/upload/external \"flarum.core.compat['common/components/Button']\"","webpack://@fof/upload/external \"flarum.core.compat['common/utils/Stream']\"","webpack://@fof/upload/external \"flarum.core.compat['common/components/Select']\"","webpack://@fof/upload/external \"flarum.core.compat['common/components/Alert']\"","webpack://@fof/upload/external \"flarum.core.compat['common/components/Switch']\"","webpack://@fof/upload/external \"flarum.core.compat['admin/utils/saveSettings']\"","webpack://@fof/upload/external \"flarum.core.compat['admin/components/UploadImageButton']\"","webpack://@fof/upload/external \"flarum.core.compat['admin/components/ExtensionPage']\"","webpack://@fof/upload/external \"flarum.core.compat['common/utils/ItemList']\"","webpack://@fof/upload/./src/admin/components/UploadPage.js","webpack://@fof/upload/./src/admin/components/index.js","webpack://@fof/upload/./src/admin/index.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","flarum","core","compat","_setPrototypeOf","setPrototypeOf","__proto__","_inheritsLoose","subClass","superClass","constructor","UploadPage","oninit","vnode","this","loading","fields","checkboxes","objects","watermarkPositions","center","left","top","right","bottom","composerButtonVisiblityOptions","both","app","translator","trans","settings","data","settingsPrefix","uploadMethodOptions","addPrefix","templateOptions","values","forEach","Stream","JSON","parse","defaultAdap","keys","length","mimeTypes","adapter","template","newMimeType","regex","content","max_post","max_upload","onsubmit","maxFileSize","oninput","withAttr","type","min","post","upload","map","mime","config","updateMimeTypeKey","Select","component","options","onchange","updateMimeTypeAdapter","getTemplateOptionsForInput","updateMimeTypeTemplate","Button","className","onclick","deleteMimeType","addMimeType","templateOptionsDescriptions","composerButtonVisiblity","Switch","state","mustResize","resizeMaxWidth","disabled","whitelistedClientExtensions","addsWatermarks","watermarkPosition","UploadImageButton","disableHotlinkProtection","disableDownloadLogging","cdnUrl","adaptorItems","toArray","changed","items","ItemList","undefined","add","imgurClientId","qiniuKey","qiniuSecret","qiniuBucket","awsS3Key","awsS3Secret","awsS3Bucket","awsS3Region","awsS3Endpoint","awsS3UsePathStyleEndpoint","awsS3ACL","option","children","push","trust","description","fieldsCheck","some","checkboxesCheck","objectsCheck","stringify","e","preventDefault","alerts","dismiss","successAlert","saveSettings","then","show","Alert","redraw","ExtensionPage","components","initializers","extensionData","registerPage","registerPermission","icon","label","permission","allowGuest"],"mappings":"2BACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QA0Df,OArDAF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQrB,EAAoBqB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iBAAVF,GAAsBA,GAASA,EAAMG,WAAY,OAAOH,EAChF,IAAII,EAAKX,OAAOY,OAAO,MAGvB,GAFA1B,EAAoBkB,EAAEO,GACtBX,OAAOC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AO5C,SAG1FmI,IAAa7F,GACR8F,MAAK,WAEF,EAAKF,aAAe/F,IAAI6F,OAAOK,KAAKC,IAAO,CAAEtE,KAAM,WAAa7B,IAAIC,WAAWC,MAAM,yCAH7F,OAKW,eACN+F,MAAK,WAEF,EAAK7G,SAAU,EACf1C,EAAE0J,c,EASd7F,UAAA,SAAU1C,GACN,OAAOsB,KAAKkB,eAAiB,IAAMxC,G,GAhhBHwI,KCZ3BC,EAAa,CACtBtH,cCEJgB,IAAIuG,aAAalC,IAAI,cAAc,SAACrE,GAChCA,EAAIwG,cAAJ,IACS,cACJC,aAAazH,GACb0H,mBACG,CACIC,KAAM,cACNC,MAAO5G,EAAIC,WAAWC,MAAM,6CAC5B2G,WAAY,qBAEhB,QACA,IAEHH,mBACG,CACIC,KAAM,kBACNC,MAAO5G,EAAIC,WAAWC,MAAM,+CAC5B2G,WAAY,sBACZC,YAAY,GAEhB,OACA,IAEHJ,mBACG,CACIC,KAAM,aACNC,MAAO5G,EAAIC,WAAWC,MAAM,wDAC5B2G,WAAY,8BAEhB,WACA,IAEHH,mBACG,CACIC,KAAM,eACNC,MAAO5G,EAAIC,WAAWC,MAAM,+DAC5B2G,WAAY,gCAEhB,WACA","file":"admin.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 28);\n","module.exports = flarum.core.compat['admin/app'];","module.exports = flarum.core.compat['common/utils/withAttr'];","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\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}","module.exports = flarum.core.compat['common/components/Button'];","module.exports = flarum.core.compat['common/utils/Stream'];","module.exports = flarum.core.compat['common/components/Select'];","module.exports = flarum.core.compat['common/components/Alert'];","module.exports = flarum.core.compat['common/components/Switch'];","module.exports = flarum.core.compat['admin/utils/saveSettings'];","module.exports = flarum.core.compat['admin/components/UploadImageButton'];","module.exports = flarum.core.compat['admin/components/ExtensionPage'];","module.exports = flarum.core.compat['common/utils/ItemList'];","import app from 'flarum/admin/app';\nimport Button from 'flarum/common/components/Button';\nimport saveSettings from 'flarum/admin/utils/saveSettings';\nimport Alert from 'flarum/common/components/Alert';\nimport Select from 'flarum/common/components/Select';\nimport Switch from 'flarum/common/components/Switch';\nimport UploadImageButton from 'flarum/admin/components/UploadImageButton';\nimport withAttr from 'flarum/common/utils/withAttr';\nimport Stream from 'flarum/common/utils/Stream';\nimport ExtensionPage from 'flarum/admin/components/ExtensionPage';\nimport ItemList from 'flarum/common/utils/ItemList';\n\n/* global m */\n\nexport default class UploadPage extends ExtensionPage {\n oninit(vnode) {\n super.oninit(vnode);\n // whether we are saving the settings or not right now\n this.loading = false;\n\n // the fields we need to watch and to save\n this.fields = [\n // image\n 'resizeMaxWidth',\n 'cdnUrl',\n 'maxFileSize',\n 'whitelistedClientExtensions',\n 'composerButtonVisiblity',\n // watermark\n 'watermark',\n 'watermarkPosition',\n // Imgur\n 'imgurClientId',\n // AWS\n 'awsS3Key',\n 'awsS3Secret',\n 'awsS3Bucket',\n 'awsS3Region',\n 'awsS3Endpoint',\n 'awsS3ACL',\n // QIniu\n 'qiniuKey',\n 'qiniuSecret',\n 'qiniuBucket',\n ];\n\n // the checkboxes we need to watch and to save.\n this.checkboxes = ['mustResize', 'addsWatermarks', 'disableHotlinkProtection', 'disableDownloadLogging', 'awsS3UsePathStyleEndpoint'];\n\n // fields that are objects\n this.objects = ['mimeTypes'];\n\n // watermark positions\n this.watermarkPositions = {\n 'top-left': 'top-left',\n 'top-right': 'top-right',\n 'bottom-left': 'bottom-left',\n 'bottom-right': 'bottom-right',\n center: 'center',\n left: 'left',\n top: 'top',\n right: 'right',\n bottom: 'bottom',\n };\n\n // Composer button options\n this.composerButtonVisiblityOptions = {\n both: app.translator.trans('fof-upload.admin.labels.composer_buttons.options.both'),\n 'upload-btn': app.translator.trans('fof-upload.admin.labels.composer_buttons.options.upload-btn'),\n 'media-btn': app.translator.trans('fof-upload.admin.labels.composer_buttons.options.media-btn'),\n };\n\n // get the saved settings from the database\n const settings = app.data.settings;\n\n // our package prefix (to be added to every field and checkbox in the setting table)\n this.settingsPrefix = 'fof-upload';\n\n // Options for the Upload methods dropdown menu.\n this.uploadMethodOptions = settings[this.addPrefix('availableUploadMethods')] || {};\n // Options for the Template dropdown menu.\n this.templateOptions = settings[this.addPrefix('availableTemplates')] || {};\n // Contains current values.\n this.values = {};\n // bind the values of the fields and checkboxes to the getter/setter functions\n this.fields.forEach((key) => (this.values[key] = Stream(settings[this.addPrefix(key)])));\n this.checkboxes.forEach((key) => (this.values[key] = Stream(settings[this.addPrefix(key)] === '1')));\n this.objects.forEach(\n (key) => (this.values[key] = settings[this.addPrefix(key)] ? Stream(JSON.parse(settings[this.addPrefix(key)])) : Stream())\n );\n\n // Set a sane default in case no mimeTypes have been configured yet.\n // Since 'local' (or others) can now be disabled, pick the last entry in the object for default\n this.defaultAdap = Object.keys(this.uploadMethodOptions)[Object.keys(this.uploadMethodOptions).length - 1];\n this.values.mimeTypes() ||\n (this.values.mimeTypes = Stream({\n '^image\\\\/.*': {\n adapter: this.defaultAdap,\n template: 'image-preview',\n },\n }));\n\n this.newMimeType = {\n regex: Stream(''),\n adapter: Stream(this.defaultAdap),\n template: Stream('file'),\n };\n }\n\n /**\n * Show the actual ImageUploadPage.\n *\n * @returns {*}\n */\n content() {\n const max_post = app.data.settings[this.addPrefix('php_ini.post_max_size')];\n const max_upload = app.data.settings[this.addPrefix('php_ini.upload_max_filesize')]\n return [\n m('.UploadPage', [\n m('.container', [\n m(\n 'form',\n {\n onsubmit: this.onsubmit.bind(this),\n },\n [\n m('fieldset', [\n m('legend', app.translator.trans('fof-upload.admin.labels.preferences.title')),\n m('label', app.translator.trans('fof-upload.admin.labels.preferences.max_file_size')),\n m('input.FormControl', {\n value: this.values.maxFileSize() || 2048,\n oninput: withAttr('value', this.values.maxFileSize),\n type: 'number',\n min: '0',\n }),\n m('.helpText', app.translator.trans('fof-upload.admin.labels.preferences.php_ini_values', {\n post: max_post,\n upload: max_upload\n })),\n m('label', app.translator.trans('fof-upload.admin.labels.preferences.mime_types')),\n m(\n '.MimeTypes--Container',\n Object.keys(this.values.mimeTypes()).map((mime) => {\n let config = this.values.mimeTypes()[mime];\n // Compatibility for older versions.\n if (typeof config !== 'object') {\n config = {\n adapter: config,\n template: 'file',\n };\n }\n\n return m('div', [\n m('input.FormControl.MimeTypes', {\n value: mime,\n oninput: withAttr('value', this.updateMimeTypeKey.bind(this, mime)),\n }),\n Select.component({\n options: this.uploadMethodOptions,\n onchange: this.updateMimeTypeAdapter.bind(this, mime, config),\n value: config.adapter || 'local',\n }),\n Select.component({\n options: this.getTemplateOptionsForInput(),\n onchange: this.updateMimeTypeTemplate.bind(this, mime, config),\n value: config.template || 'local',\n }),\n Button.component(\n {\n type: 'button',\n className: 'Button Button--warning',\n onclick: this.deleteMimeType.bind(this, mime),\n },\n 'x'\n ),\n ]);\n }),\n m('br'),\n m('div', [\n m('input.FormControl.MimeTypes.add-MimeType-key', {\n value: this.newMimeType.regex(),\n oninput: withAttr('value', this.newMimeType.regex),\n }),\n Select.component({\n options: this.uploadMethodOptions,\n className: 'add-MimeType-value',\n oninput: withAttr('value', this.newMimeType.adapter),\n value: this.newMimeType.adapter(),\n }),\n Select.component({\n options: this.getTemplateOptionsForInput(),\n className: 'add-MimeType-value',\n oninput: withAttr('value', this.newMimeType.template),\n value: this.newMimeType.template(),\n }),\n Button.component(\n {\n type: 'button',\n className: 'Button Button--warning',\n onclick: this.addMimeType.bind(this),\n },\n '+'\n ),\n ])\n ),\n m('.helpText', app.translator.trans('fof-upload.admin.help_texts.mime_types')),\n m('.helpText', app.translator.trans('fof-upload.admin.help_texts.download_templates')),\n this.templateOptionsDescriptions(),\n ]),\n m('fieldset.composerButtons', [\n m('legend', app.translator.trans('fof-upload.admin.labels.composer_buttons.title')),\n m('.helpText', app.translator.trans('fof-upload.admin.help_texts.composer_buttons')),\n m('div', [\n Select.component({\n options: this.composerButtonVisiblityOptions,\n onchange: this.values.composerButtonVisiblity,\n value: this.values.composerButtonVisiblity() || 'both',\n }),\n ]),\n ]),\n m('fieldset', [\n m('legend', app.translator.trans('fof-upload.admin.labels.resize.title')),\n m('.helpText', app.translator.trans('fof-upload.admin.help_texts.resize')),\n Switch.component(\n {\n state: this.values.mustResize() || false,\n onchange: this.values.mustResize,\n },\n app.translator.trans('fof-upload.admin.labels.resize.toggle')\n ),\n m('label', app.translator.trans('fof-upload.admin.labels.resize.max_width')),\n m('input', {\n className: 'FormControl',\n value: this.values.resizeMaxWidth() || 100,\n oninput: withAttr('value', this.values.resizeMaxWidth),\n disabled: !this.values.mustResize(),\n type: 'number',\n min: '0',\n }),\n ]),\n m('fieldset', [\n m('legend', app.translator.trans('fof-upload.admin.labels.client_extension.title')),\n m('.helpText', app.translator.trans('fof-upload.admin.help_texts.client_extension')),\n m('input', {\n className: 'FormControl',\n value: this.values.whitelistedClientExtensions() || '',\n oninput: withAttr('value', this.values.whitelistedClientExtensions),\n }),\n ]),\n m('fieldset', [\n m('legend', app.translator.trans('fof-upload.admin.labels.watermark.title')),\n m('.helpText', app.translator.trans('fof-upload.admin.help_texts.watermark')),\n Switch.component(\n {\n state: this.values.addsWatermarks() || false,\n onchange: this.values.addsWatermarks,\n },\n app.translator.trans('fof-upload.admin.labels.watermark.toggle')\n ),\n m('label', app.translator.trans('fof-upload.admin.labels.watermark.position')),\n m('div', [\n Select.component({\n options: this.watermarkPositions,\n onchange: this.values.watermarkPosition,\n value: this.values.watermarkPosition() || 'bottom-right',\n }),\n ]),\n m('label', {}, app.translator.trans('fof-upload.admin.labels.watermark.file')),\n UploadImageButton.component({\n name: 'fof/watermark',\n }),\n ]),\n m('fieldset', [\n m('legend', app.translator.trans('fof-upload.admin.labels.disable-hotlink-protection.title')),\n m('.helpText', app.translator.trans('fof-upload.admin.help_texts.disable-hotlink-protection')),\n Switch.component(\n {\n state: this.values.disableHotlinkProtection() || false,\n onchange: this.values.disableHotlinkProtection,\n },\n app.translator.trans('fof-upload.admin.labels.disable-hotlink-protection.toggle')\n ),\n m('legend', app.translator.trans('fof-upload.admin.labels.disable-download-logging.title')),\n m('.helpText', app.translator.trans('fof-upload.admin.help_texts.disable-download-logging')),\n Switch.component(\n {\n state: this.values.disableDownloadLogging() || false,\n onchange: this.values.disableDownloadLogging,\n },\n app.translator.trans('fof-upload.admin.labels.disable-download-logging.toggle')\n ),\n ]),\n m('fieldset', [\n m('legend', app.translator.trans('fof-upload.admin.labels.local.title')),\n m('label', app.translator.trans('fof-upload.admin.labels.local.cdn_url')),\n m('input.FormControl', {\n value: this.values.cdnUrl() || '',\n oninput: withAttr('value', this.values.cdnUrl),\n }),\n ]),\n\n this.adaptorItems().toArray(),\n\n Button.component(\n {\n type: 'submit',\n className: 'Button Button--primary',\n loading: this.loading,\n disabled: !this.changed(),\n },\n app.translator.trans('core.admin.settings.submit_button')\n ),\n ]\n ),\n ]),\n ]),\n ];\n }\n\n adaptorItems() {\n const items = new ItemList();\n\n if (this.uploadMethodOptions['imgur'] !== undefined) {\n items.add(\n 'imgur',\n m('.imgur', [\n m('fieldset', [\n m('legend', app.translator.trans('fof-upload.admin.labels.imgur.title')),\n m('label', app.translator.trans('fof-upload.admin.labels.imgur.client_id')),\n m('input.FormControl', {\n value: this.values.imgurClientId() || '',\n oninput: withAttr('value', this.values.imgurClientId),\n }),\n ]),\n ])\n );\n }\n\n if (this.uploadMethodOptions['qiniu'] !== undefined) {\n items.add(\n 'qiniu',\n m('.qiniu', [\n m('fieldset', [\n m('legend', app.translator.trans('fof-upload.admin.labels.qiniu.title')),\n m('label', app.translator.trans('fof-upload.admin.labels.qiniu.key')),\n m('input.FormControl', {\n value: this.values.qiniuKey() || '',\n oninput: withAttr('value', this.values.qiniuKey),\n }),\n m('label', {}, app.translator.trans('fof-upload.admin.labels.qiniu.secret')),\n m('input.FormControl', {\n value: this.values.qiniuSecret() || '',\n oninput: withAttr('value', this.values.qiniuSecret),\n }),\n m('label', {}, app.translator.trans('fof-upload.admin.labels.qiniu.bucket')),\n m('input.FormControl', {\n value: this.values.qiniuBucket() || '',\n oninput: withAttr('value', this.values.qiniuBucket),\n }),\n ]),\n ])\n );\n }\n\n if (this.uploadMethodOptions['aws-s3'] !== undefined) {\n items.add(\n 'aws-s3',\n m('.aws', [\n m('fieldset', [\n m('legend', app.translator.trans('fof-upload.admin.labels.aws-s3.title')),\n m('label', app.translator.trans('fof-upload.admin.labels.aws-s3.key')),\n m('input.FormControl', {\n value: this.values.awsS3Key() || '',\n oninput: withAttr('value', this.values.awsS3Key),\n }),\n m('label', app.translator.trans('fof-upload.admin.labels.aws-s3.secret')),\n m('input.FormControl', {\n value: this.values.awsS3Secret() || '',\n oninput: withAttr('value', this.values.awsS3Secret),\n }),\n m('label', app.translator.trans('fof-upload.admin.labels.aws-s3.bucket')),\n m('input.FormControl', {\n value: this.values.awsS3Bucket() || '',\n oninput: withAttr('value', this.values.awsS3Bucket),\n }),\n m('label', app.translator.trans('fof-upload.admin.labels.aws-s3.region')),\n m('input.FormControl', {\n value: this.values.awsS3Region() || '',\n oninput: withAttr('value', this.values.awsS3Region),\n }),\n ]),\n m('fieldset', [\n m('legend', app.translator.trans('fof-upload.admin.labels.aws-s3.advanced_title')),\n m('.helpText', app.translator.trans('fof-upload.admin.help_texts.s3_compatible_storage')),\n m('label', app.translator.trans('fof-upload.admin.labels.aws-s3.endpoint')),\n m('input.FormControl', {\n value: this.values.awsS3Endpoint() || '',\n oninput: withAttr('value', this.values.awsS3Endpoint),\n }),\n Switch.component(\n {\n state: this.values.awsS3UsePathStyleEndpoint() || false,\n onchange: this.values.awsS3UsePathStyleEndpoint,\n },\n app.translator.trans('fof-upload.admin.labels.aws-s3.use_path_style_endpoint')\n ),\n m('label', app.translator.trans('fof-upload.admin.labels.aws-s3.acl')),\n m('input.FormControl', {\n value: this.values.awsS3ACL() || '',\n oninput: withAttr('value', this.values.awsS3ACL),\n }),\n m('.helpText', app.translator.trans('fof-upload.admin.help_texts.s3_acl')),\n ]),\n ])\n );\n }\n\n return items;\n }\n\n getTemplateOptionsForInput() {\n const options = {};\n\n for (let option in this.templateOptions) {\n if (!this.templateOptions.hasOwnProperty(option)) {\n continue;\n }\n\n options[option] = this.templateOptions[option].name;\n }\n\n return options;\n }\n\n updateMimeTypeKey(mime, value) {\n this.values.mimeTypes()[value] = this.values.mimeTypes()[mime];\n\n this.deleteMimeType(mime);\n }\n\n updateMimeTypeAdapter(mime, config, value) {\n config.adapter = value;\n this.values.mimeTypes()[mime] = config;\n }\n\n updateMimeTypeTemplate(mime, config, value) {\n config.template = value;\n this.values.mimeTypes()[mime] = config;\n }\n\n deleteMimeType(mime) {\n delete this.values.mimeTypes()[mime];\n }\n\n templateOptionsDescriptions() {\n const children = [];\n\n for (let template in this.templateOptions) {\n if (!this.templateOptions.hasOwnProperty(template)) {\n continue;\n }\n\n children.push(\n
  • \n {this.templateOptions[template].name}: {m.trust(this.templateOptions[template].description)}\n
  • \n );\n }\n\n return m('ul', children);\n }\n\n addMimeType() {\n this.values.mimeTypes()[this.newMimeType.regex()] = {\n adapter: this.newMimeType.adapter(),\n template: this.newMimeType.template(),\n };\n\n this.newMimeType.regex('');\n this.newMimeType.adapter('local');\n this.newMimeType.template('file');\n }\n\n /**\n * Checks if the values of the fields and checkboxes are different from\n * the ones stored in the database\n *\n * @returns boolean\n */\n changed() {\n const fieldsCheck = this.fields.some((key) => this.values[key]() !== app.data.settings[this.addPrefix(key)]);\n const checkboxesCheck = this.checkboxes.some((key) => this.values[key]() !== (app.data.settings[this.addPrefix(key)] === '1'));\n const objectsCheck = this.objects.some((key) => JSON.stringify(this.values[key]()) !== app.data.settings[this.addPrefix(key)]);\n\n return fieldsCheck || checkboxesCheck || objectsCheck;\n }\n\n /**\n * Saves the settings to the database and redraw the page\n *\n * @param e\n */\n onsubmit(e) {\n // prevent the usual form submit behaviour\n e.preventDefault();\n\n // if the page is already saving, do nothing\n if (this.loading) return;\n\n // prevents multiple savings\n this.loading = true;\n\n // remove previous success popup\n app.alerts.dismiss(this.successAlert);\n\n const settings = {};\n\n // gets all the values from the form\n this.fields.forEach((key) => (settings[this.addPrefix(key)] = this.values[key]()));\n this.checkboxes.forEach((key) => (settings[this.addPrefix(key)] = this.values[key]()));\n this.objects.forEach((key) => (settings[this.addPrefix(key)] = JSON.stringify(this.values[key]())));\n\n // actually saves everything in the database\n saveSettings(settings)\n .then(() => {\n // on success, show popup\n this.successAlert = app.alerts.show(Alert, { type: 'success' }, app.translator.trans('core.admin.settings.saved_message'));\n })\n .catch(() => {})\n .then(() => {\n // return to the initial state and redraw the page\n this.loading = false;\n m.redraw();\n });\n }\n\n /**\n * Adds the prefix `this.settingsPrefix` at the beginning of `key`\n *\n * @returns string\n */\n addPrefix(key) {\n return this.settingsPrefix + '.' + key;\n }\n}\n","import UploadPage from './UploadPage';\n\nexport const components = {\n UploadPage,\n};\n","import app from 'flarum/admin/app';\nimport UploadPage from './components/UploadPage';\n\nexport * from './components';\n\napp.initializers.add('fof-upload', (app) => {\n app.extensionData\n .for('fof-upload')\n .registerPage(UploadPage)\n .registerPermission(\n {\n icon: 'far fa-file',\n label: app.translator.trans('fof-upload.admin.permissions.upload_label'),\n permission: 'fof-upload.upload',\n },\n 'start',\n 50\n )\n .registerPermission(\n {\n icon: 'fas fa-download',\n label: app.translator.trans('fof-upload.admin.permissions.download_label'),\n permission: 'fof-upload.download',\n allowGuest: true,\n },\n 'view',\n 50\n )\n .registerPermission(\n {\n icon: 'fas fa-eye',\n label: app.translator.trans('fof-upload.admin.permissions.view_user_uploads_label'),\n permission: 'fof-upload.viewUserUploads',\n },\n 'moderate',\n 50\n )\n .registerPermission(\n {\n icon: 'fas fa-trash',\n label: app.translator.trans('fof-upload.admin.permissions.delete_uploads_of_others_label'),\n permission: 'fof-upload.deleteUserUploads',\n },\n 'moderate',\n 50\n );\n});\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"admin.js","mappings":"MACA,IAAIA,EAAsB,CCA1BA,EAAyBC,IACxB,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,IAAOF,EAAiB,QACxB,IAAM,EAEP,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,IACzBH,GCLRF,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,MCJ3ER,EAAwB,CAACc,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFf,EAAyBM,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,M,yDCLvD,MAAM,EAA+BC,OAAOC,KAAKC,OAAO,a,aCAzC,SAASC,EAAgBhB,EAAGiB,GAMzC,OALAD,EAAkBf,OAAOiB,gBAAkB,SAAyBlB,EAAGiB,GAErE,OADAjB,EAAEmB,UAAYF,EACPjB,GAGFgB,EAAgBhB,EAAGiB,GCN5B,MAAM,EAA+BJ,OAAOC,KAAKC,OAAO,4B,aCA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5BC,WAAY,sBACZC,YAAY,GAEd,OACA,IAEDN,mBACC,CACEC,KAAM,aACNC,MAAOvG,EAAIwG,WAAWC,MAAM,wDAC5BC,WAAY,8BAEd,WACA,IAEDL,mBACC,CACEC,KAAM,eACNC,MAAOvG,EAAIwG,WAAWC,MAAM,+DAC5BC,WAAY,gCAEd,WACA,Q","sources":["webpack://@fof/upload/webpack/bootstrap","webpack://@fof/upload/webpack/runtime/compat get default export","webpack://@fof/upload/webpack/runtime/define property getters","webpack://@fof/upload/webpack/runtime/hasOwnProperty shorthand","webpack://@fof/upload/webpack/runtime/make namespace object","webpack://@fof/upload/external root \"flarum.core.compat['admin/app']\"","webpack://@fof/upload/./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js","webpack://@fof/upload/external root \"flarum.core.compat['common/components/Button']\"","webpack://@fof/upload/external root \"flarum.core.compat['admin/utils/saveSettings']\"","webpack://@fof/upload/external root \"flarum.core.compat['common/components/Alert']\"","webpack://@fof/upload/external root \"flarum.core.compat['common/components/Select']\"","webpack://@fof/upload/external root \"flarum.core.compat['common/components/Switch']\"","webpack://@fof/upload/external root \"flarum.core.compat['admin/components/UploadImageButton']\"","webpack://@fof/upload/external root \"flarum.core.compat['common/utils/withAttr']\"","webpack://@fof/upload/external root \"flarum.core.compat['common/utils/Stream']\"","webpack://@fof/upload/external root \"flarum.core.compat['admin/components/ExtensionPage']\"","webpack://@fof/upload/external root \"flarum.core.compat['common/utils/ItemList']\"","webpack://@fof/upload/./src/admin/components/UploadPage.js","webpack://@fof/upload/./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://@fof/upload/./src/admin/components/index.js","webpack://@fof/upload/./src/admin/index.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['admin/app'];","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n\n return _setPrototypeOf(o, p);\n}","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Button'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['admin/utils/saveSettings'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Alert'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Select'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Switch'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['admin/components/UploadImageButton'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/utils/withAttr'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/utils/Stream'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['admin/components/ExtensionPage'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/utils/ItemList'];","import app from 'flarum/admin/app';\nimport Button from 'flarum/common/components/Button';\nimport saveSettings from 'flarum/admin/utils/saveSettings';\nimport Alert from 'flarum/common/components/Alert';\nimport Select from 'flarum/common/components/Select';\nimport Switch from 'flarum/common/components/Switch';\nimport UploadImageButton from 'flarum/admin/components/UploadImageButton';\nimport withAttr from 'flarum/common/utils/withAttr';\nimport Stream from 'flarum/common/utils/Stream';\nimport ExtensionPage from 'flarum/admin/components/ExtensionPage';\nimport ItemList from 'flarum/common/utils/ItemList';\n\n/* global m */\n\nexport default class UploadPage extends ExtensionPage {\n oninit(vnode) {\n super.oninit(vnode);\n // whether we are saving the settings or not right now\n this.loading = false;\n\n // the fields we need to watch and to save\n this.fields = [\n // image\n 'resizeMaxWidth',\n 'cdnUrl',\n 'maxFileSize',\n 'whitelistedClientExtensions',\n 'composerButtonVisiblity',\n // watermark\n 'watermark',\n 'watermarkPosition',\n // Imgur\n 'imgurClientId',\n // AWS\n 'awsS3Key',\n 'awsS3Secret',\n 'awsS3Bucket',\n 'awsS3Region',\n 'awsS3Endpoint',\n 'awsS3ACL',\n // QIniu\n 'qiniuKey',\n 'qiniuSecret',\n 'qiniuBucket',\n ];\n\n // the checkboxes we need to watch and to save.\n this.checkboxes = ['mustResize', 'addsWatermarks', 'disableHotlinkProtection', 'disableDownloadLogging', 'awsS3UsePathStyleEndpoint'];\n\n // fields that are objects\n this.objects = ['mimeTypes'];\n\n // watermark positions\n this.watermarkPositions = {\n 'top-left': 'top-left',\n 'top-right': 'top-right',\n 'bottom-left': 'bottom-left',\n 'bottom-right': 'bottom-right',\n center: 'center',\n left: 'left',\n top: 'top',\n right: 'right',\n bottom: 'bottom',\n };\n\n // Composer button options\n this.composerButtonVisiblityOptions = {\n both: app.translator.trans('fof-upload.admin.labels.composer_buttons.options.both'),\n 'upload-btn': app.translator.trans('fof-upload.admin.labels.composer_buttons.options.upload-btn'),\n 'media-btn': app.translator.trans('fof-upload.admin.labels.composer_buttons.options.media-btn'),\n };\n\n // get the saved settings from the database\n const settings = app.data.settings;\n\n // our package prefix (to be added to every field and checkbox in the setting table)\n this.settingsPrefix = 'fof-upload';\n\n // Options for the Upload methods dropdown menu.\n this.uploadMethodOptions = settings[this.addPrefix('availableUploadMethods')] || {};\n // Options for the Template dropdown menu.\n this.templateOptions = settings[this.addPrefix('availableTemplates')] || {};\n // Contains current values.\n this.values = {};\n // bind the values of the fields and checkboxes to the getter/setter functions\n this.fields.forEach((key) => (this.values[key] = Stream(settings[this.addPrefix(key)])));\n this.checkboxes.forEach((key) => (this.values[key] = Stream(settings[this.addPrefix(key)] === '1')));\n this.objects.forEach((key) => (this.values[key] = settings[this.addPrefix(key)] ? Stream(JSON.parse(settings[this.addPrefix(key)])) : Stream()));\n\n // Set a sane default in case no mimeTypes have been configured yet.\n // Since 'local' (or others) can now be disabled, pick the last entry in the object for default\n this.defaultAdap = Object.keys(this.uploadMethodOptions)[Object.keys(this.uploadMethodOptions).length - 1];\n this.values.mimeTypes() ||\n (this.values.mimeTypes = Stream({\n '^image\\\\/.*': {\n adapter: this.defaultAdap,\n template: 'image-preview',\n },\n }));\n\n this.newMimeType = {\n regex: Stream(''),\n adapter: Stream(this.defaultAdap),\n template: Stream('file'),\n };\n }\n\n /**\n * Show the actual ImageUploadPage.\n *\n * @returns {*}\n */\n content() {\n const max_post = app.data.settings[this.addPrefix('php_ini.post_max_size')];\n const max_upload = app.data.settings[this.addPrefix('php_ini.upload_max_filesize')];\n return [\n m('.UploadPage', [\n m('.container', [\n m(\n 'form',\n {\n onsubmit: this.onsubmit.bind(this),\n },\n [\n m('fieldset', [\n m('legend', app.translator.trans('fof-upload.admin.labels.preferences.title')),\n m('label', app.translator.trans('fof-upload.admin.labels.preferences.max_file_size')),\n m('input.FormControl', {\n value: this.values.maxFileSize() || 2048,\n oninput: withAttr('value', this.values.maxFileSize),\n type: 'number',\n min: '0',\n }),\n m(\n '.helpText',\n app.translator.trans('fof-upload.admin.labels.preferences.php_ini_values', {\n post: max_post,\n upload: max_upload,\n })\n ),\n m('label', app.translator.trans('fof-upload.admin.labels.preferences.mime_types')),\n m(\n '.MimeTypes--Container',\n Object.keys(this.values.mimeTypes()).map((mime) => {\n let config = this.values.mimeTypes()[mime];\n // Compatibility for older versions.\n if (typeof config !== 'object') {\n config = {\n adapter: config,\n template: 'file',\n };\n }\n\n return m('div', [\n m('input.FormControl.MimeTypes', {\n value: mime,\n oninput: withAttr('value', this.updateMimeTypeKey.bind(this, mime)),\n }),\n Select.component({\n options: this.uploadMethodOptions,\n onchange: this.updateMimeTypeAdapter.bind(this, mime, config),\n value: config.adapter || 'local',\n }),\n Select.component({\n options: this.getTemplateOptionsForInput(),\n onchange: this.updateMimeTypeTemplate.bind(this, mime, config),\n value: config.template || 'local',\n }),\n Button.component(\n {\n type: 'button',\n className: 'Button Button--warning',\n onclick: this.deleteMimeType.bind(this, mime),\n },\n 'x'\n ),\n ]);\n }),\n m('br'),\n m('div', [\n m('input.FormControl.MimeTypes.add-MimeType-key', {\n value: this.newMimeType.regex(),\n oninput: withAttr('value', this.newMimeType.regex),\n }),\n Select.component({\n options: this.uploadMethodOptions,\n className: 'add-MimeType-value',\n oninput: withAttr('value', this.newMimeType.adapter),\n value: this.newMimeType.adapter(),\n }),\n Select.component({\n options: this.getTemplateOptionsForInput(),\n className: 'add-MimeType-value',\n oninput: withAttr('value', this.newMimeType.template),\n value: this.newMimeType.template(),\n }),\n Button.component(\n {\n type: 'button',\n className: 'Button Button--warning',\n onclick: this.addMimeType.bind(this),\n },\n '+'\n ),\n ])\n ),\n m('.helpText', app.translator.trans('fof-upload.admin.help_texts.mime_types')),\n m('.helpText', app.translator.trans('fof-upload.admin.help_texts.download_templates')),\n this.templateOptionsDescriptions(),\n ]),\n m('fieldset.composerButtons', [\n m('legend', app.translator.trans('fof-upload.admin.labels.composer_buttons.title')),\n m('.helpText', app.translator.trans('fof-upload.admin.help_texts.composer_buttons')),\n m('div', [\n Select.component({\n options: this.composerButtonVisiblityOptions,\n onchange: this.values.composerButtonVisiblity,\n value: this.values.composerButtonVisiblity() || 'both',\n }),\n ]),\n ]),\n m('fieldset', [\n m('legend', app.translator.trans('fof-upload.admin.labels.resize.title')),\n m('.helpText', app.translator.trans('fof-upload.admin.help_texts.resize')),\n Switch.component(\n {\n state: this.values.mustResize() || false,\n onchange: this.values.mustResize,\n },\n app.translator.trans('fof-upload.admin.labels.resize.toggle')\n ),\n m('label', app.translator.trans('fof-upload.admin.labels.resize.max_width')),\n m('input', {\n className: 'FormControl',\n value: this.values.resizeMaxWidth() || 100,\n oninput: withAttr('value', this.values.resizeMaxWidth),\n disabled: !this.values.mustResize(),\n type: 'number',\n min: '0',\n }),\n ]),\n m('fieldset', [\n m('legend', app.translator.trans('fof-upload.admin.labels.client_extension.title')),\n m('.helpText', app.translator.trans('fof-upload.admin.help_texts.client_extension')),\n m('input', {\n className: 'FormControl',\n value: this.values.whitelistedClientExtensions() || '',\n oninput: withAttr('value', this.values.whitelistedClientExtensions),\n }),\n ]),\n m('fieldset', [\n m('legend', app.translator.trans('fof-upload.admin.labels.watermark.title')),\n m('.helpText', app.translator.trans('fof-upload.admin.help_texts.watermark')),\n Switch.component(\n {\n state: this.values.addsWatermarks() || false,\n onchange: this.values.addsWatermarks,\n },\n app.translator.trans('fof-upload.admin.labels.watermark.toggle')\n ),\n m('label', app.translator.trans('fof-upload.admin.labels.watermark.position')),\n m('div', [\n Select.component({\n options: this.watermarkPositions,\n onchange: this.values.watermarkPosition,\n value: this.values.watermarkPosition() || 'bottom-right',\n }),\n ]),\n m('label', {}, app.translator.trans('fof-upload.admin.labels.watermark.file')),\n UploadImageButton.component({\n name: 'fof/watermark',\n }),\n ]),\n m('fieldset', [\n m('legend', app.translator.trans('fof-upload.admin.labels.disable-hotlink-protection.title')),\n m('.helpText', app.translator.trans('fof-upload.admin.help_texts.disable-hotlink-protection')),\n Switch.component(\n {\n state: this.values.disableHotlinkProtection() || false,\n onchange: this.values.disableHotlinkProtection,\n },\n app.translator.trans('fof-upload.admin.labels.disable-hotlink-protection.toggle')\n ),\n m('legend', app.translator.trans('fof-upload.admin.labels.disable-download-logging.title')),\n m('.helpText', app.translator.trans('fof-upload.admin.help_texts.disable-download-logging')),\n Switch.component(\n {\n state: this.values.disableDownloadLogging() || false,\n onchange: this.values.disableDownloadLogging,\n },\n app.translator.trans('fof-upload.admin.labels.disable-download-logging.toggle')\n ),\n ]),\n m('fieldset', [\n m('legend', app.translator.trans('fof-upload.admin.labels.local.title')),\n m('label', app.translator.trans('fof-upload.admin.labels.local.cdn_url')),\n m('input.FormControl', {\n value: this.values.cdnUrl() || '',\n oninput: withAttr('value', this.values.cdnUrl),\n }),\n ]),\n\n this.adaptorItems().toArray(),\n\n Button.component(\n {\n type: 'submit',\n className: 'Button Button--primary',\n loading: this.loading,\n disabled: !this.changed(),\n },\n app.translator.trans('core.admin.settings.submit_button')\n ),\n ]\n ),\n ]),\n ]),\n ];\n }\n\n adaptorItems() {\n const items = new ItemList();\n\n if (this.uploadMethodOptions['imgur'] !== undefined) {\n items.add(\n 'imgur',\n m('.imgur', [\n m('fieldset', [\n m('legend', app.translator.trans('fof-upload.admin.labels.imgur.title')),\n m('label', app.translator.trans('fof-upload.admin.labels.imgur.client_id')),\n m('input.FormControl', {\n value: this.values.imgurClientId() || '',\n oninput: withAttr('value', this.values.imgurClientId),\n }),\n ]),\n ])\n );\n }\n\n if (this.uploadMethodOptions['qiniu'] !== undefined) {\n items.add(\n 'qiniu',\n m('.qiniu', [\n m('fieldset', [\n m('legend', app.translator.trans('fof-upload.admin.labels.qiniu.title')),\n m('label', app.translator.trans('fof-upload.admin.labels.qiniu.key')),\n m('input.FormControl', {\n value: this.values.qiniuKey() || '',\n oninput: withAttr('value', this.values.qiniuKey),\n }),\n m('label', {}, app.translator.trans('fof-upload.admin.labels.qiniu.secret')),\n m('input.FormControl', {\n value: this.values.qiniuSecret() || '',\n oninput: withAttr('value', this.values.qiniuSecret),\n }),\n m('label', {}, app.translator.trans('fof-upload.admin.labels.qiniu.bucket')),\n m('input.FormControl', {\n value: this.values.qiniuBucket() || '',\n oninput: withAttr('value', this.values.qiniuBucket),\n }),\n ]),\n ])\n );\n }\n\n if (this.uploadMethodOptions['aws-s3'] !== undefined) {\n items.add(\n 'aws-s3',\n m('.aws', [\n m('fieldset', [\n m('legend', app.translator.trans('fof-upload.admin.labels.aws-s3.title')),\n m('label', app.translator.trans('fof-upload.admin.labels.aws-s3.key')),\n m('input.FormControl', {\n value: this.values.awsS3Key() || '',\n oninput: withAttr('value', this.values.awsS3Key),\n }),\n m('label', app.translator.trans('fof-upload.admin.labels.aws-s3.secret')),\n m('input.FormControl', {\n value: this.values.awsS3Secret() || '',\n oninput: withAttr('value', this.values.awsS3Secret),\n }),\n m('label', app.translator.trans('fof-upload.admin.labels.aws-s3.bucket')),\n m('input.FormControl', {\n value: this.values.awsS3Bucket() || '',\n oninput: withAttr('value', this.values.awsS3Bucket),\n }),\n m('label', app.translator.trans('fof-upload.admin.labels.aws-s3.region')),\n m('input.FormControl', {\n value: this.values.awsS3Region() || '',\n oninput: withAttr('value', this.values.awsS3Region),\n }),\n ]),\n m('fieldset', [\n m('legend', app.translator.trans('fof-upload.admin.labels.aws-s3.advanced_title')),\n m('.helpText', app.translator.trans('fof-upload.admin.help_texts.s3_compatible_storage')),\n m('label', app.translator.trans('fof-upload.admin.labels.aws-s3.endpoint')),\n m('input.FormControl', {\n value: this.values.awsS3Endpoint() || '',\n oninput: withAttr('value', this.values.awsS3Endpoint),\n }),\n Switch.component(\n {\n state: this.values.awsS3UsePathStyleEndpoint() || false,\n onchange: this.values.awsS3UsePathStyleEndpoint,\n },\n app.translator.trans('fof-upload.admin.labels.aws-s3.use_path_style_endpoint')\n ),\n m('label', app.translator.trans('fof-upload.admin.labels.aws-s3.acl')),\n m('input.FormControl', {\n value: this.values.awsS3ACL() || '',\n oninput: withAttr('value', this.values.awsS3ACL),\n }),\n m('.helpText', app.translator.trans('fof-upload.admin.help_texts.s3_acl')),\n ]),\n ])\n );\n }\n\n return items;\n }\n\n getTemplateOptionsForInput() {\n const options = {};\n\n for (let option in this.templateOptions) {\n if (!this.templateOptions.hasOwnProperty(option)) {\n continue;\n }\n\n options[option] = this.templateOptions[option].name;\n }\n\n return options;\n }\n\n updateMimeTypeKey(mime, value) {\n this.values.mimeTypes()[value] = this.values.mimeTypes()[mime];\n\n this.deleteMimeType(mime);\n }\n\n updateMimeTypeAdapter(mime, config, value) {\n config.adapter = value;\n this.values.mimeTypes()[mime] = config;\n }\n\n updateMimeTypeTemplate(mime, config, value) {\n config.template = value;\n this.values.mimeTypes()[mime] = config;\n }\n\n deleteMimeType(mime) {\n delete this.values.mimeTypes()[mime];\n }\n\n templateOptionsDescriptions() {\n const children = [];\n\n for (let template in this.templateOptions) {\n if (!this.templateOptions.hasOwnProperty(template)) {\n continue;\n }\n\n children.push(\n
  • \n {this.templateOptions[template].name}: {m.trust(this.templateOptions[template].description)}\n
  • \n );\n }\n\n return m('ul', children);\n }\n\n addMimeType() {\n this.values.mimeTypes()[this.newMimeType.regex()] = {\n adapter: this.newMimeType.adapter(),\n template: this.newMimeType.template(),\n };\n\n this.newMimeType.regex('');\n this.newMimeType.adapter('local');\n this.newMimeType.template('file');\n }\n\n /**\n * Checks if the values of the fields and checkboxes are different from\n * the ones stored in the database\n *\n * @returns boolean\n */\n changed() {\n const fieldsCheck = this.fields.some((key) => this.values[key]() !== app.data.settings[this.addPrefix(key)]);\n const checkboxesCheck = this.checkboxes.some((key) => this.values[key]() !== (app.data.settings[this.addPrefix(key)] === '1'));\n const objectsCheck = this.objects.some((key) => JSON.stringify(this.values[key]()) !== app.data.settings[this.addPrefix(key)]);\n\n return fieldsCheck || checkboxesCheck || objectsCheck;\n }\n\n /**\n * Saves the settings to the database and redraw the page\n *\n * @param e\n */\n onsubmit(e) {\n // prevent the usual form submit behaviour\n e.preventDefault();\n\n // if the page is already saving, do nothing\n if (this.loading) return;\n\n // prevents multiple savings\n this.loading = true;\n\n // remove previous success popup\n app.alerts.dismiss(this.successAlert);\n\n const settings = {};\n\n // gets all the values from the form\n this.fields.forEach((key) => (settings[this.addPrefix(key)] = this.values[key]()));\n this.checkboxes.forEach((key) => (settings[this.addPrefix(key)] = this.values[key]()));\n this.objects.forEach((key) => (settings[this.addPrefix(key)] = JSON.stringify(this.values[key]())));\n\n // actually saves everything in the database\n saveSettings(settings)\n .then(() => {\n // on success, show popup\n this.successAlert = app.alerts.show(Alert, { type: 'success' }, app.translator.trans('core.admin.settings.saved_message'));\n })\n .catch(() => {})\n .then(() => {\n // return to the initial state and redraw the page\n this.loading = false;\n m.redraw();\n });\n }\n\n /**\n * Adds the prefix `this.settingsPrefix` at the beginning of `key`\n *\n * @returns string\n */\n addPrefix(key) {\n return this.settingsPrefix + '.' + key;\n }\n}\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}","import UploadPage from './UploadPage';\n\nexport const components = {\n UploadPage,\n};\n","import app from 'flarum/admin/app';\nimport UploadPage from './components/UploadPage';\n\nexport * from './components';\n\napp.initializers.add('fof-upload', (app) => {\n app.extensionData\n .for('fof-upload')\n .registerPage(UploadPage)\n .registerPermission(\n {\n icon: 'far fa-file',\n label: app.translator.trans('fof-upload.admin.permissions.upload_label'),\n permission: 'fof-upload.upload',\n },\n 'start',\n 50\n )\n .registerPermission(\n {\n icon: 'fas fa-download',\n label: app.translator.trans('fof-upload.admin.permissions.download_label'),\n permission: 'fof-upload.download',\n allowGuest: true,\n },\n 'view',\n 50\n )\n .registerPermission(\n {\n icon: 'fas fa-eye',\n label: app.translator.trans('fof-upload.admin.permissions.view_user_uploads_label'),\n permission: 'fof-upload.viewUserUploads',\n },\n 'moderate',\n 50\n )\n .registerPermission(\n {\n icon: 'fas fa-trash',\n label: app.translator.trans('fof-upload.admin.permissions.delete_uploads_of_others_label'),\n permission: 'fof-upload.deleteUserUploads',\n },\n 'moderate',\n 50\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","__proto__","UploadPage","subClass","superClass","create","constructor","oninit","vnode","this","loading","fields","checkboxes","objects","watermarkPositions","center","left","top","right","bottom","composerButtonVisiblityOptions","both","app","settings","settingsPrefix","uploadMethodOptions","addPrefix","templateOptions","values","forEach","Stream","JSON","parse","defaultAdap","keys","length","mimeTypes","adapter","template","newMimeType","regex","content","max_post","max_upload","m","onsubmit","bind","maxFileSize","oninput","withAttr","type","min","post","upload","map","mime","config","updateMimeTypeKey","Select","options","onchange","updateMimeTypeAdapter","getTemplateOptionsForInput","updateMimeTypeTemplate","Button","className","onclick","deleteMimeType","addMimeType","templateOptionsDescriptions","composerButtonVisiblity","Switch","state","mustResize","resizeMaxWidth","disabled","whitelistedClientExtensions","addsWatermarks","watermarkPosition","UploadImageButton","name","disableHotlinkProtection","disableDownloadLogging","cdnUrl","adaptorItems","toArray","changed","items","ItemList","undefined","add","imgurClientId","qiniuKey","qiniuSecret","qiniuBucket","awsS3Key","awsS3Secret","awsS3Bucket","awsS3Region","awsS3Endpoint","awsS3UsePathStyleEndpoint","awsS3ACL","option","children","push","trust","description","fieldsCheck","some","checkboxesCheck","objectsCheck","stringify","e","preventDefault","successAlert","saveSettings","then","Alert","redraw","ExtensionPage","components","extensionData","registerPage","registerPermission","icon","label","translator","trans","permission","allowGuest"],"sourceRoot":""} \ No newline at end of file diff --git a/js/dist/forum.js b/js/dist/forum.js index 689dc853..18c393cc 100644 --- a/js/dist/forum.js +++ b/js/dist/forum.js @@ -1,2 +1,2 @@ -module.exports=function(t){var e={};function i(o){if(e[o])return e[o].exports;var a=e[o]={i:o,l:!1,exports:{}};return t[o].call(a.exports,a,a.exports,i),a.l=!0,a.exports}return i.m=t,i.c=e,i.d=function(t,e,o){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(i.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)i.d(o,a,function(e){return t[e]}.bind(null,a));return o},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=27)}([function(t,e){t.exports=flarum.core.compat["forum/app"]},,,function(t,e){t.exports=flarum.core.compat["common/Model"]},function(t,e,i){"use strict";function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function a(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}i.d(e,"a",(function(){return a}))},function(t,e){t.exports=flarum.core.compat["common/components/Button"]},function(t,e){t.exports=flarum.core.compat["common/extend"]},,,function(t,e){t.exports=flarum.core.compat["common/Component"]},function(t,e){t.exports=flarum.core.compat["common/components/Alert"]},,function(t,e){t.exports=flarum.core.compat["common/components/LoadingIndicator"]},function(t,e){t.exports=flarum.core.compat["common/components/TextEditor"]},function(t,e){t.exports=flarum.core.compat["common/models/User"]},function(t,e){t.exports=flarum.core.compat["forum/components/UserPage"]},function(t,e){t.exports=flarum.core.compat["common/utils/classList"]},function(t,e){t.exports=flarum.core.compat["common/components/Tooltip"]},function(t,e){t.exports=flarum.core.compat["common/utils/extractText"]},function(t,e){t.exports=flarum.core.compat["common/components/LinkButton"]},function(t,e){t.exports=flarum.core.compat["common/utils/mixin"]},function(t,e){t.exports=flarum.core.compat["forum/components/Post"]},function(t,e){t.exports=flarum.core.compat["common/components/Modal"]},,,,,function(t,e,i){"use strict";i.r(e),i.d(e,"components",(function(){return X}));var o=i(6),a=i(0),n=i.n(a),s=i(15),r=i.n(s),l=i(19),u=i.n(l),d=i(4),p=i(3),f=i.n(p),c=i(20),h=function(t){function e(){return t.apply(this,arguments)||this}return Object(d.a)(e,t),e.prototype.apiEndpoint=function(){return"/fof/uploads"+(this.exists?"/"+this.data.id:"")},e}(i.n(c)()(f.a,{baseName:f.a.attribute("baseName"),path:f.a.attribute("path"),url:f.a.attribute("url"),type:f.a.attribute("type"),size:f.a.attribute("size"),humanSize:f.a.attribute("humanSize"),createdAt:f.a.attribute("createdAt"),uuid:f.a.attribute("uuid"),tag:f.a.attribute("tag"),hidden:f.a.attribute("hidden"),bbcode:f.a.attribute("bbcode")})),g=function(){function t(){this.user=null,this.files=[],this.moreResults=!1,this.loading=!1}var e=t.prototype;return e.setUser=function(t){t!==this.user&&(this.user=t,this.files=[],this.loadResults())},e.loadResults=function(t){if(void 0===t&&(t=0),this.user)return this.loading=!0,n.a.store.find("fof/uploads",{filter:{user:this.user.id()},page:{offset:t}}).then(this.parseResults.bind(this))},e.loadMore=function(){this.loading=!0,this.loadResults(this.files.length).then(this.parseResults.bind(this))},e.parseResults=function(t){var e;return(e=this.files).push.apply(e,t),this.loading=!1,this.moreResults=!!t.payload.links&&!!t.payload.links.next,m.redraw(),t},e.addToList=function(t){var e;Array.isArray(t)?(e=this.files).unshift.apply(e,t):this.files.unshift(t)},e.hasFiles=function(){return this.files.length>0},e.isLoading=function(){return this.loading},e.hasMoreResults=function(){return this.moreResults},e.empty=function(){return!this.hasFiles()&&!this.isLoading()},t}(),b=i(21),v=i.n(b),y=i(13),x=i.n(y),F=i(9),w=i.n(F),N=i(5),_=i.n(N),B=i(12),O=i.n(B),M=i(16),L=i.n(M),S=i(17),C=i.n(S),k=function(t){function e(){return t.apply(this,arguments)||this}Object(d.a)(e,t);var i=e.prototype;return i.oninit=function(e){var i=this;t.prototype.oninit.call(this,e),this.attrs.uploader.on("uploaded",(function(){i.$("form")[0].reset(),m.redraw()})),this.isMediaUploadButton=e.attrs.isMediaUploadButton||!1},i.view=function(){var t=this.attrs.uploader.uploading?n.a.translator.trans("fof-upload.forum.states.loading"):n.a.translator.trans("fof-upload.forum.buttons.upload");return m(C.a,{text:t},m(_.a,{className:L()(["Button","hasIcon","fof-upload-button",!this.isMediaUploadButton&&!this.attrs.uploader.uploading&&"Button--icon",!this.isMediaUploadButton&&!this.attrs.uploader.uploading&&"Button--link",this.attrs.uploader.uploading&&"uploading"]),icon:!this.attrs.uploader.uploading&&"fas fa-file-upload",onclick:this.uploadButtonClicked.bind(this),disabled:this.attrs.disabled},this.attrs.uploader.uploading&&m(O.a,{size:"small",display:"inline",className:"Button-icon"}),(this.isMediaUploadButton||this.attrs.uploader.uploading)&&m("span",{className:"Button-label"},t),m("form",null,m("input",{type:"file",multiple:!0,onchange:this.process.bind(this)}))))},i.process=function(t){var e=this.$("input").prop("files");0!==e.length&&this.attrs.uploader.upload(e,!this.isMediaUploadButton)},i.uploadButtonClicked=function(t){this.$("input").click()},e}(w.a),U=function(){function t(t,e){this.upload=t,this.composerElement=e,this.handlers={},this.supportsFileDragging()&&(this.composerElement.addEventListener("dragover",this.handlers.in=this.in.bind(this)),this.composerElement.addEventListener("dragleave",this.handlers.out=this.out.bind(this)),this.composerElement.addEventListener("dragend",this.handlers.out),this.composerElement.addEventListener("drop",this.handlers.dropping=this.dropping.bind(this)))}var e=t.prototype;return e.supportsFileDragging=function(){var t=document.createElement("div");return("draggable"in t||"ondragstart"in t&&"ondrop"in t)&&"FormData"in window&&"FileReader"in window},e.unload=function(){this.handlers.in&&(this.composerElement.removeEventListener("dragover",this.handlers.in),this.composerElement.removeEventListener("dragleave",this.handlers.out),this.composerElement.removeEventListener("dragend",this.handlers.out),this.composerElement.removeEventListener("drop",this.handlers.dropping))},e.isNotFile=function(t){if(t.dataTransfer.items)for(var e=0;e0&&(t.preventDefault(),this.upload(i))}},t}(),T=function(){function t(){this.callbacks={success:[],failure:[],uploading:[],uploaded:[]},this.uploading=!1}var e=t.prototype;return e.on=function(t,e){this.callbacks[t].push(e)},e.dispatch=function(t,e){this.callbacks[t].forEach((function(t){return t(e)}))},e.upload=function(t,e){var i=this;void 0===e&&(e=!0),this.uploading=!0,this.dispatch("uploading",t),m.redraw();for(var o=new FormData,a=0;a=0?"far fa-file-archive":"application/pdf"===i?"far fa-file-pdf":q.indexOf(i)>=0?"far fa-file-word":i.includes("audio/")?"far fa-file-audio":$.indexOf(i)>=0?"far fa-file-code":"far fa-file"),a=!t.restrictFileType||t.isSelectable(e),s=L()(["fof-file","image"===o&&"fof-file-type-image",t.attrs.selectedFiles&&t.attrs.selectedFiles.indexOf(e.id())>=0&&"fof-file-selected"]),r=e.baseName(),l=t.filesBeingHidden.includes(e.uuid());return m("li",{"aria-busy":l},n.a.session.user&&(t.user===n.a.session.user||n.a.session.user.deleteOthersMediaLibrary())&&m(_.a,{className:"Button Button--icon fof-file-delete",icon:"far fa-trash-alt","aria-label":n.a.translator.trans("fof-upload.forum.file_list.delete_file_a11y_label",{fileName:r}),disabled:l,onclick:t.hideFile.bind(t,e)}),m("button",{className:s,onclick:function(){return t.onFileClick(e)},disabled:!a||l,"aria-label":P()(n.a.translator.trans("fof-upload.forum.file_list.select_file_a11y_label",{fileName:r}))},m("figure",null,"image"===o?m("img",{src:e.url(),className:"fof-file-image-preview",draggable:!1,alt:""}):m("span",{className:"fof-file-icon",role:"presentation"},m("i",{className:"fa-fw "+o})),m("figcaption",{className:"fof-file-name"},r),l&&m("span",{class:"fof-file-loading",role:"status","aria-label":n.a.translator.trans("fof-upload.forum.file_list.hide_file.loading")},m(O.a,null)))))}))),e.hasMoreResults()&&m("div",{className:"fof-load-more-files"},m(_.a,{className:"Button Button--primary",disabled:e.isLoading(),loading:e.isLoading(),onclick:function(){return e.loadMore()}},n.a.translator.trans("fof-upload.forum.file_list.load_more_files_btn"))))},i.onFileClick=function(t){this.attrs.onFileSelect?this.attrs.onFileSelect(t):this.attrs.downloadOnClick&&window.open(t.url())},i.isSelectable=function(t){var e=t.type();return Array.isArray(this.restrictFileType)?this.restrictFileType.indexOf(e)>=0:"image"===this.restrictFileType?e.includes("image/"):"audio"===this.restrictFileType?e.includes("audio/"):"video"===this.restrictFileType&&e.includes("video/")},i.hideFile=function(t){var e=this,i=t.uuid();if(!this.filesBeingHidden.includes(i))if(this.filesBeingHidden.push(i),confirm(P()(n.a.translator.trans("fof-upload.forum.file_list.hide_file.hide_confirmation",{fileName:t.baseName()}))))n.a.request({method:"PATCH",url:n.a.forum.attribute("apiUrl")+"/fof/upload/hide",body:{uuid:i}}).then((function(){n.a.alerts.show(R.a,{type:"success"},n.a.translator.trans("fof-upload.forum.file_list.hide_file.hide_success"))})).catch((function(){n.a.alerts.show(R.a,{type:"error"},n.a.translator.trans("fof-upload.forum.file_list.hide_file.hide_fail",{fileName:t.fileName()}))})).then((function(){var t=n.a.fileListState,o=t.files.findIndex((function(t){return i===t.uuid()}));t.files.splice(o,1);var a=e.filesBeingHidden.indexOf(i);e.filesBeingHidden.splice(a,1)}));else{var o=this.filesBeingHidden.indexOf(i);this.filesBeingHidden.splice(o,1)}},e}(w.a),G=function(t){function e(){return t.apply(this,arguments)||this}Object(d.a)(e,t);var i=e.prototype;return i.oninit=function(e){t.prototype.oninit.call(this,e),this.uploader=e.attrs.uploader,this.selectedFiles=[],this.multiSelect=e.attrs.multiSelect||!0,this.restrictFileType=e.attrs.restrictFileType||null,this.dragDrop=null,this.onUpload()},i.className=function(){return"Modal--large fof-file-manager-modal"},i.oncreate=function(e){var i=this;t.prototype.oncreate.call(this,e),this.dragDrop=new U((function(t){return i.uploader.upload(t,!1)}),this.$().find(".Modal-content")[0])},i.onremove=function(){this.dragDrop&&this.dragDrop.unload()},i.view=function(){var t=this.selectedFiles.length;return m("div",{className:"Modal modal-dialog "+this.className()},m("div",{className:"Modal-content"},m("div",{className:"fof-modal-buttons App-backControl"},m(k,{uploader:this.uploader,disabled:app.fileListState.isLoading(),isMediaUploadButton:!0})),m("div",{className:"fof-drag-and-drop"},m("div",{className:"fof-drag-and-drop-release"},m("i",{className:"fas fa-cloud-upload-alt"}),app.translator.trans("fof-upload.forum.file_list.release_to_upload"))),m("div",{className:"Modal-header"},m("h3",{className:"App-titleControl App-titleControl--text"},app.translator.trans("fof-upload.forum.media_manager"))),this.alertAttrs&&m("div",{className:"Modal-alert"},m(Alert,this.alertAttrs)),m("div",{className:"Modal-body"},m(V,{user:this.attrs.user,selectable:!0,onFileSelect:this.onFileSelect.bind(this),selectedFiles:this.selectedFiles,restrictFileType:this.restrictFileType})),m("div",{className:"Modal-footer"},m(_.a,{onclick:this.hide.bind(this),className:"Button"},app.translator.trans("fof-upload.forum.buttons.cancel")),m(_.a,{onclick:this.onSelect.bind(this),disabled:0===this.selectedFiles.length||!this.multiSelect&&this.selectedFiles.length>1,className:"Button Button--primary"},app.translator.trans("fof-upload.forum.file_list.confirm_selection_btn",{fileCount:t})))))},i.onFileSelect=function(t){var e=this.selectedFiles.indexOf(t.id());e>=0?this.selectedFiles.splice(e,1):this.multiSelect?this.selectedFiles.push(t.id()):this.selectedFiles=[t.id()]},i.onUpload=function(){var t=this;this.uploader.on("success",(function(e){var i=e.file;t.multiSelect?t.selectedFiles.push(i.id()):t.selectedFiles=[i.id()]}))},i.onSelect=function(){this.hide(),this.attrs.onSelect?this.attrs.onSelect(this.selectedFiles):this.selectedFiles.map((function(t){var e=app.store.getById("files",t);app.composer.editor.insertAtCursor(e.bbcode()+"\n",!1)}))},e}(D.a),J=function(t){function e(){return t.apply(this,arguments)||this}Object(d.a)(e,t);var i=e.prototype;return i.view=function(){return m(C.a,{text:n.a.translator.trans("fof-upload.forum.buttons.media")},_.a.component({className:"Button fof-upload-button Button--icon",onclick:this.fileManagerButtonClicked.bind(this),icon:"fas fa-photo-video"}))},i.fileManagerButtonClicked=function(t){t.preventDefault(),n.a.modal.show(G,{uploader:this.attrs.uploader})},e}(w.a),K=function(t){function e(){return t.apply(this,arguments)||this}Object(d.a)(e,t);var i=e.prototype;return i.oninit=function(e){t.prototype.oninit.call(this,e),this.user=null,this.loadUser(m.route.param("username"))},i.content=function(){return n.a.session.user&&(n.a.session.user.viewOthersMediaLibrary()||this.user===n.a.session.user)?this.user&&V.component({user:this.user,selectable:!1,downloadOnClick:!0}):null},i.show=function(e){t.prototype.show.call(this,e),this.user=e},e}(r.a),Q=i(14),W=i.n(Q),X={DragAndDrop:U,FileManagerButton:J,FileManagerModal:G,UserFileList:V,Uploader:T,UploadButton:k};n.a.initializers.add("fof-upload",(function(){W.a.prototype.viewOthersMediaLibrary=f.a.attribute("fof-upload-viewOthersMediaLibrary"),W.a.prototype.deleteOthersMediaLibrary=f.a.attribute("fof-upload-deleteOthersMediaLibrary"),W.a.prototype.uploadCountCurrent=f.a.attribute("fof-upload-uploadCountCurrent"),W.a.prototype.uploadCountAll=f.a.attribute("fof-upload-uploadCountAll"),Object(o.extend)(x.a.prototype,"oninit",(function(){this.uploader=new T})),Object(o.extend)(x.a.prototype,"controlItems",(function(t){if(n.a.forum.attribute("fof-upload.canUpload")){var e=n.a.forum.attribute("fof-upload.composerButtonVisiblity");"both"!==e&&"media-btn"!==e||t.add("fof-upload-media",J.component({uploader:this.uploader})),"both"!==e&&"upload-btn"!==e||t.add("fof-upload",k.component({uploader:this.uploader}))}})),Object(o.extend)(x.a.prototype,"oncreate",(function(t,e){var i=this;n.a.forum.attribute("fof-upload.canUpload")&&(this.uploader.on("success",(function(t){var e=t.file;if(t.addBBcode&&(i.attrs.composer.editor.insertAtCursor(e.bbcode()+"\n",!1),"function"==typeof i.attrs.preview)){var o=n.a.composer.isFullScreen;n.a.composer.isFullScreen=function(){return!1},i.attrs.preview(),n.a.composer.isFullScreen=o}})),this.dragAndDrop=new U((function(t){return i.uploader.upload(t)}),this.$().parents(".Composer")[0]),new j((function(t){return i.uploader.upload(t)}),this.$(".TextEditor-editor")[0]))})),Object(o.extend)(x.a.prototype,"onremove",(function(t,e){n.a.forum.attribute("fof-upload.canUpload")&&this.dragAndDrop.unload()})),Object(o.extend)(v.a.prototype,"oncreate",(function(){var t=this;this.$("[data-fof-upload-download-uuid]").unbind("click").on("click",(function(e){if(e.preventDefault(),e.stopPropagation(),n.a.forum.attribute("fof-upload.canDownload")){var i=n.a.forum.attribute("apiUrl")+"/fof/download";i+="/"+encodeURIComponent(e.currentTarget.dataset.fofUploadDownloadUuid),i+="/"+encodeURIComponent(t.attrs.post.id()),i+="/"+encodeURIComponent(n.a.session.csrfToken),window.open(i)}else alert(n.a.translator.trans("fof-upload.forum.states.unauthorized"))}))})),n.a.store.models.files=h,n.a.fileListState=new g,n.a.routes["user.uploads"]={path:"/u/:username/uploads",component:K},Object(o.extend)(r.a.prototype,"navItems",(function(t){var e=!!n.a.forum.attribute("fof-upload.canUpload"),i=!!this.user.uploadCountCurrent();if(n.a.session.user&&(n.a.session.user.viewOthersMediaLibrary()||this.user===n.a.session.user&&(e||i))){var o=this.user.uploadCountCurrent();t.add("uploads",u.a.component({href:n.a.route("user.uploads",{username:this.user.username()}),name:"uploads",icon:"fas fa-file-upload"},[this.user===n.a.session.user?n.a.translator.trans("fof-upload.forum.buttons.media"):n.a.translator.trans("fof-upload.forum.buttons.user_uploads")," ",o>0?m("span",{className:"Button-badge"},o):""]),80)}}))}))}]); +(()=>{var t={n:e=>{var i=e&&e.__esModule?()=>e.default:()=>e;return t.d(i,{a:i}),i},d:(e,i)=>{for(var o in i)t.o(i,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:i[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{"use strict";t.r(e),t.d(e,{components:()=>X});const i=flarum.core.compat["common/extend"],o=flarum.core.compat["forum/app"];var a=t.n(o);const s=flarum.core.compat["forum/components/UserPage"];var n=t.n(s);const r=flarum.core.compat["common/components/LinkButton"];var l=t.n(r);function u(t,e){return u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},u(t,e)}function d(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,u(t,e)}const p=flarum.core.compat["common/Model"];var c=t.n(p);const f=flarum.core.compat["common/utils/mixin"];var h=function(t){function e(){return t.apply(this,arguments)||this}return d(e,t),e.prototype.apiEndpoint=function(){return"/fof/uploads"+(this.exists?"/"+this.data.id:"")},e}(t.n(f)()(c(),{baseName:c().attribute("baseName"),path:c().attribute("path"),url:c().attribute("url"),type:c().attribute("type"),size:c().attribute("size"),humanSize:c().attribute("humanSize"),createdAt:c().attribute("createdAt"),uuid:c().attribute("uuid"),tag:c().attribute("tag"),hidden:c().attribute("hidden"),bbcode:c().attribute("bbcode")})),g=function(){function t(){this.user=null,this.files=[],this.moreResults=!1,this.loading=!1}var e=t.prototype;return e.setUser=function(t){t!==this.user&&(this.user=t,this.files=[],this.loadResults())},e.loadResults=function(t){if(void 0===t&&(t=0),this.user)return this.loading=!0,a().store.find("fof/uploads",{filter:{user:this.user.id()},page:{offset:t}}).then(this.parseResults.bind(this))},e.loadMore=function(){this.loading=!0,this.loadResults(this.files.length).then(this.parseResults.bind(this))},e.parseResults=function(t){var e;return(e=this.files).push.apply(e,t),this.loading=!1,this.moreResults=!!t.payload.links&&!!t.payload.links.next,m.redraw(),t},e.addToList=function(t){var e;Array.isArray(t)?(e=this.files).unshift.apply(e,t):this.files.unshift(t)},e.hasFiles=function(){return this.files.length>0},e.isLoading=function(){return this.loading},e.hasMoreResults=function(){return this.moreResults},e.empty=function(){return!this.hasFiles()&&!this.isLoading()},t}();const v=flarum.core.compat["forum/components/Post"];var b=t.n(v);const y=flarum.core.compat["common/components/TextEditor"];var F=t.n(y);const w=flarum.core.compat["common/Component"];var N=t.n(w);const B=flarum.core.compat["common/components/Button"];var _=t.n(B);const M=flarum.core.compat["common/components/LoadingIndicator"];var x=t.n(M);const L=flarum.core.compat["common/utils/classList"];var S=t.n(L);const C=flarum.core.compat["common/components/Tooltip"];var k=t.n(C),O=function(t){function e(){return t.apply(this,arguments)||this}d(e,t);var i=e.prototype;return i.oninit=function(e){var i=this;t.prototype.oninit.call(this,e),this.attrs.uploader.on("uploaded",(function(){i.$("form")[0].reset(),m.redraw()})),this.isMediaUploadButton=e.attrs.isMediaUploadButton||!1},i.view=function(){var t=this.attrs.uploader.uploading?a().translator.trans("fof-upload.forum.states.loading"):a().translator.trans("fof-upload.forum.buttons.upload");return m(k(),{text:t},m(_(),{className:S()(["Button","hasIcon","fof-upload-button",!this.isMediaUploadButton&&!this.attrs.uploader.uploading&&"Button--icon",!this.isMediaUploadButton&&!this.attrs.uploader.uploading&&"Button--link",this.attrs.uploader.uploading&&"uploading"]),icon:!this.attrs.uploader.uploading&&"fas fa-file-upload",onclick:this.uploadButtonClicked.bind(this),disabled:this.attrs.disabled},this.attrs.uploader.uploading&&m(x(),{size:"small",display:"inline",className:"Button-icon"}),(this.isMediaUploadButton||this.attrs.uploader.uploading)&&m("span",{className:"Button-label"},t),m("form",null,m("input",{type:"file",multiple:!0,onchange:this.process.bind(this)}))))},i.process=function(t){var e=this.$("input").prop("files");0!==e.length&&this.attrs.uploader.upload(e,!this.isMediaUploadButton)},i.uploadButtonClicked=function(t){this.$("input").click()},e}(N()),U=function(){function t(t,e){this.upload=t,this.composerElement=e,this.handlers={},this.supportsFileDragging()&&(this.composerElement.addEventListener("dragover",this.handlers.in=this.in.bind(this)),this.composerElement.addEventListener("dragleave",this.handlers.out=this.out.bind(this)),this.composerElement.addEventListener("dragend",this.handlers.out),this.composerElement.addEventListener("drop",this.handlers.dropping=this.dropping.bind(this)))}var e=t.prototype;return e.supportsFileDragging=function(){var t=document.createElement("div");return("draggable"in t||"ondragstart"in t&&"ondrop"in t)&&"FormData"in window&&"FileReader"in window},e.unload=function(){this.handlers.in&&(this.composerElement.removeEventListener("dragover",this.handlers.in),this.composerElement.removeEventListener("dragleave",this.handlers.out),this.composerElement.removeEventListener("dragend",this.handlers.out),this.composerElement.removeEventListener("drop",this.handlers.dropping))},e.isNotFile=function(t){if(t.dataTransfer.items)for(var e=0;e0&&(t.preventDefault(),this.upload(i))}},t}(),E=function(){function t(){this.callbacks={success:[],failure:[],uploading:[],uploaded:[]},this.uploading=!1}var e=t.prototype;return e.on=function(t,e){this.callbacks[t].push(e)},e.dispatch=function(t,e){this.callbacks[t].forEach((function(t){return t(e)}))},e.upload=function(t,e){var i=this;void 0===e&&(e=!0),this.uploading=!0,this.dispatch("uploading",t),m.redraw();for(var o=new FormData,s=0;s=0?"far fa-file-archive":"application/pdf"===i?"far fa-file-pdf":q.indexOf(i)>=0?"far fa-file-word":i.includes("audio/")?"far fa-file-audio":$.indexOf(i)>=0?"far fa-file-code":"far fa-file"),s=!t.restrictFileType||t.isSelectable(e),n=S()(["fof-file","image"===o&&"fof-file-type-image",t.attrs.selectedFiles&&t.attrs.selectedFiles.indexOf(e.id())>=0&&"fof-file-selected"]),r=e.baseName(),l=t.filesBeingHidden.includes(e.uuid());return m("li",{"aria-busy":l},a().session.user&&(t.user===a().session.user||a().session.user.deleteOthersMediaLibrary())&&m(_(),{className:"Button Button--icon fof-file-delete",icon:"far fa-trash-alt","aria-label":a().translator.trans("fof-upload.forum.file_list.delete_file_a11y_label",{fileName:r}),disabled:l,onclick:t.hideFile.bind(t,e)}),m("button",{className:n,onclick:function(){return t.onFileClick(e)},disabled:!s||l,"aria-label":P()(a().translator.trans("fof-upload.forum.file_list.select_file_a11y_label",{fileName:r}))},m("figure",null,"image"===o?m("img",{src:e.url(),className:"fof-file-image-preview",draggable:!1,alt:""}):m("span",{className:"fof-file-icon",role:"presentation"},m("i",{className:"fa-fw "+o})),m("figcaption",{className:"fof-file-name"},r),l&&m("span",{class:"fof-file-loading",role:"status","aria-label":a().translator.trans("fof-upload.forum.file_list.hide_file.loading")},m(x(),null)))))}))),e.hasMoreResults()&&m("div",{className:"fof-load-more-files"},m(_(),{className:"Button Button--primary",disabled:e.isLoading(),loading:e.isLoading(),onclick:function(){return e.loadMore()}},a().translator.trans("fof-upload.forum.file_list.load_more_files_btn"))))},i.onFileClick=function(t){this.attrs.onFileSelect?this.attrs.onFileSelect(t):this.attrs.downloadOnClick&&window.open(t.url())},i.isSelectable=function(t){var e=t.type();return Array.isArray(this.restrictFileType)?this.restrictFileType.indexOf(e)>=0:"image"===this.restrictFileType?e.includes("image/"):"audio"===this.restrictFileType?e.includes("audio/"):"video"===this.restrictFileType&&e.includes("video/")},i.hideFile=function(t){var e=this,i=t.uuid();if(!this.filesBeingHidden.includes(i))if(this.filesBeingHidden.push(i),confirm(P()(a().translator.trans("fof-upload.forum.file_list.hide_file.hide_confirmation",{fileName:t.baseName()}))))a().request({method:"PATCH",url:a().forum.attribute("apiUrl")+"/fof/upload/hide",body:{uuid:i}}).then((function(){a().alerts.show(j(),{type:"success"},a().translator.trans("fof-upload.forum.file_list.hide_file.hide_success"))})).catch((function(){a().alerts.show(j(),{type:"error"},a().translator.trans("fof-upload.forum.file_list.hide_file.hide_fail",{fileName:t.fileName()}))})).then((function(){var t=a().fileListState,o=t.files.findIndex((function(t){return i===t.uuid()}));t.files.splice(o,1);var s=e.filesBeingHidden.indexOf(i);e.filesBeingHidden.splice(s,1)}));else{var o=this.filesBeingHidden.indexOf(i);this.filesBeingHidden.splice(o,1)}},e}(N()),G=function(t){function e(){return t.apply(this,arguments)||this}d(e,t);var i=e.prototype;return i.oninit=function(e){t.prototype.oninit.call(this,e),this.uploader=e.attrs.uploader,this.selectedFiles=[],this.multiSelect=e.attrs.multiSelect||!0,this.restrictFileType=e.attrs.restrictFileType||null,this.dragDrop=null,this.onUpload()},i.className=function(){return"Modal--large fof-file-manager-modal"},i.oncreate=function(e){var i=this;t.prototype.oncreate.call(this,e),this.dragDrop=new U((function(t){return i.uploader.upload(t,!1)}),this.$().find(".Modal-content")[0])},i.onremove=function(){this.dragDrop&&this.dragDrop.unload()},i.view=function(){var t=this.selectedFiles.length;return m("div",{className:"Modal modal-dialog "+this.className()},m("div",{className:"Modal-content"},m("div",{className:"fof-modal-buttons App-backControl"},m(O,{uploader:this.uploader,disabled:app.fileListState.isLoading(),isMediaUploadButton:!0})),m("div",{className:"fof-drag-and-drop"},m("div",{className:"fof-drag-and-drop-release"},m("i",{className:"fas fa-cloud-upload-alt"}),app.translator.trans("fof-upload.forum.file_list.release_to_upload"))),m("div",{className:"Modal-header"},m("h3",{className:"App-titleControl App-titleControl--text"},app.translator.trans("fof-upload.forum.media_manager"))),this.alertAttrs&&m("div",{className:"Modal-alert"},m(Alert,this.alertAttrs)),m("div",{className:"Modal-body"},m(V,{user:this.attrs.user,selectable:!0,onFileSelect:this.onFileSelect.bind(this),selectedFiles:this.selectedFiles,restrictFileType:this.restrictFileType})),m("div",{className:"Modal-footer"},m(_(),{onclick:this.hide.bind(this),className:"Button"},app.translator.trans("fof-upload.forum.buttons.cancel")),m(_(),{onclick:this.onSelect.bind(this),disabled:0===this.selectedFiles.length||!this.multiSelect&&this.selectedFiles.length>1,className:"Button Button--primary"},app.translator.trans("fof-upload.forum.file_list.confirm_selection_btn",{fileCount:t})))))},i.onFileSelect=function(t){var e=this.selectedFiles.indexOf(t.id());e>=0?this.selectedFiles.splice(e,1):this.multiSelect?this.selectedFiles.push(t.id()):this.selectedFiles=[t.id()]},i.onUpload=function(){var t=this;this.uploader.on("success",(function(e){var i=e.file;t.multiSelect?t.selectedFiles.push(i.id()):t.selectedFiles=[i.id()]}))},i.onSelect=function(){this.hide(),this.attrs.onSelect?this.attrs.onSelect(this.selectedFiles):this.selectedFiles.map((function(t){var e=app.store.getById("files",t);app.composer.editor.insertAtCursor(e.bbcode()+"\n",!1)}))},e}(A()),J=function(t){function e(){return t.apply(this,arguments)||this}d(e,t);var i=e.prototype;return i.view=function(){return m(k(),{text:a().translator.trans("fof-upload.forum.buttons.media")},_().component({className:"Button fof-upload-button Button--icon",onclick:this.fileManagerButtonClicked.bind(this),icon:"fas fa-photo-video"}))},i.fileManagerButtonClicked=function(t){t.preventDefault(),a().modal.show(G,{uploader:this.attrs.uploader})},e}(N()),K=function(t){function e(){return t.apply(this,arguments)||this}d(e,t);var i=e.prototype;return i.oninit=function(e){t.prototype.oninit.call(this,e),this.user=null,this.loadUser(m.route.param("username"))},i.content=function(){return a().session.user&&(a().session.user.viewOthersMediaLibrary()||this.user===a().session.user)?this.user&&V.component({user:this.user,selectable:!1,downloadOnClick:!0}):null},i.show=function(e){t.prototype.show.call(this,e),this.user=e},e}(n());const Q=flarum.core.compat["common/models/User"];var W=t.n(Q),X={DragAndDrop:U,FileManagerButton:J,FileManagerModal:G,UserFileList:V,Uploader:E,UploadButton:O};a().initializers.add("fof-upload",(function(){W().prototype.viewOthersMediaLibrary=c().attribute("fof-upload-viewOthersMediaLibrary"),W().prototype.deleteOthersMediaLibrary=c().attribute("fof-upload-deleteOthersMediaLibrary"),W().prototype.uploadCountCurrent=c().attribute("fof-upload-uploadCountCurrent"),W().prototype.uploadCountAll=c().attribute("fof-upload-uploadCountAll"),(0,i.extend)(F().prototype,"oninit",(function(){this.uploader=new E})),(0,i.extend)(F().prototype,"controlItems",(function(t){if(a().forum.attribute("fof-upload.canUpload")){var e=a().forum.attribute("fof-upload.composerButtonVisiblity");"both"!==e&&"media-btn"!==e||t.add("fof-upload-media",J.component({uploader:this.uploader})),"both"!==e&&"upload-btn"!==e||t.add("fof-upload",O.component({uploader:this.uploader}))}})),(0,i.extend)(F().prototype,"oncreate",(function(t,e){var i=this;a().forum.attribute("fof-upload.canUpload")&&(this.uploader.on("success",(function(t){var e=t.file;if(t.addBBcode&&(i.attrs.composer.editor.insertAtCursor(e.bbcode()+"\n",!1),"function"==typeof i.attrs.preview)){var o=a().composer.isFullScreen;a().composer.isFullScreen=function(){return!1},i.attrs.preview(),a().composer.isFullScreen=o}})),this.dragAndDrop=new U((function(t){return i.uploader.upload(t)}),this.$().parents(".Composer")[0]),new T((function(t){return i.uploader.upload(t)}),this.$(".TextEditor-editor")[0]))})),(0,i.extend)(F().prototype,"onremove",(function(t,e){a().forum.attribute("fof-upload.canUpload")&&this.dragAndDrop.unload()})),(0,i.extend)(b().prototype,"oncreate",(function(){var t=this;this.$("[data-fof-upload-download-uuid]").unbind("click").on("click",(function(e){if(e.preventDefault(),e.stopPropagation(),a().forum.attribute("fof-upload.canDownload")){var i=a().forum.attribute("apiUrl")+"/fof/download";i+="/"+encodeURIComponent(e.currentTarget.dataset.fofUploadDownloadUuid),i+="/"+encodeURIComponent(t.attrs.post.id()),i+="/"+encodeURIComponent(a().session.csrfToken),window.open(i)}else alert(a().translator.trans("fof-upload.forum.states.unauthorized"))}))})),a().store.models.files=h,a().fileListState=new g,a().routes["user.uploads"]={path:"/u/:username/uploads",component:K},(0,i.extend)(n().prototype,"navItems",(function(t){var e=!!a().forum.attribute("fof-upload.canUpload"),i=!!this.user.uploadCountCurrent();if(a().session.user&&(a().session.user.viewOthersMediaLibrary()||this.user===a().session.user&&(e||i))){var o=this.user.uploadCountCurrent();t.add("uploads",l().component({href:a().route("user.uploads",{username:this.user.username()}),name:"uploads",icon:"fas fa-file-upload"},[this.user===a().session.user?a().translator.trans("fof-upload.forum.buttons.media"):a().translator.trans("fof-upload.forum.buttons.user_uploads")," ",o>0?m("span",{className:"Button-badge"},o):""]),80)}}))}))})(),module.exports=e})(); //# sourceMappingURL=forum.js.map \ No newline at end of file diff --git a/js/dist/forum.js.map b/js/dist/forum.js.map index 27c4d2a3..e1192c3b 100644 --- a/js/dist/forum.js.map +++ b/js/dist/forum.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://@fof/upload/webpack/bootstrap","webpack://@fof/upload/external \"flarum.core.compat['forum/app']\"","webpack://@fof/upload/external \"flarum.core.compat['common/Model']\"","webpack://@fof/upload/./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js","webpack://@fof/upload/./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://@fof/upload/external \"flarum.core.compat['common/components/Button']\"","webpack://@fof/upload/external \"flarum.core.compat['common/extend']\"","webpack://@fof/upload/external \"flarum.core.compat['common/Component']\"","webpack://@fof/upload/external \"flarum.core.compat['common/components/Alert']\"","webpack://@fof/upload/external \"flarum.core.compat['common/components/LoadingIndicator']\"","webpack://@fof/upload/external \"flarum.core.compat['common/components/TextEditor']\"","webpack://@fof/upload/external \"flarum.core.compat['common/models/User']\"","webpack://@fof/upload/external \"flarum.core.compat['forum/components/UserPage']\"","webpack://@fof/upload/external \"flarum.core.compat['common/utils/classList']\"","webpack://@fof/upload/external \"flarum.core.compat['common/components/Tooltip']\"","webpack://@fof/upload/external \"flarum.core.compat['common/utils/extractText']\"","webpack://@fof/upload/external \"flarum.core.compat['common/components/LinkButton']\"","webpack://@fof/upload/external \"flarum.core.compat['common/utils/mixin']\"","webpack://@fof/upload/external \"flarum.core.compat['forum/components/Post']\"","webpack://@fof/upload/external \"flarum.core.compat['common/components/Modal']\"","webpack://@fof/upload/./src/common/models/File.js","webpack://@fof/upload/./src/forum/states/FileListState.js","webpack://@fof/upload/./src/forum/components/UploadButton.js","webpack://@fof/upload/./src/forum/components/DragAndDrop.js","webpack://@fof/upload/./src/forum/components/PasteClipboard.js","webpack://@fof/upload/./src/forum/handler/Uploader.js","webpack://@fof/upload/./src/common/mimeToIcon.js","webpack://@fof/upload/./src/forum/components/UserFileList.js","webpack://@fof/upload/./src/forum/components/FileManagerModal.js","webpack://@fof/upload/./src/forum/components/FileManagerButton.js","webpack://@fof/upload/./src/forum/components/UploadsUserPage.js","webpack://@fof/upload/./src/forum/components/index.js","webpack://@fof/upload/./src/forum/index.js","webpack://@fof/upload/./src/forum/addUploadButton.js","webpack://@fof/upload/./src/forum/downloadButtonInteraction.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","flarum","core","compat","_setPrototypeOf","setPrototypeOf","__proto__","_inheritsLoose","subClass","superClass","constructor","File","apiEndpoint","this","exists","data","id","mixin","Model","baseName","attribute","path","url","type","size","humanSize","createdAt","uuid","tag","hidden","bbcode","FileListState","user","files","moreResults","loading","setUser","loadResults","offset","app","store","find","filter","page","then","parseResults","loadMore","length","results","push","payload","links","next","redraw","addToList","Array","isArray","unshift","hasFiles","isLoading","hasMoreResults","empty","UploadButton","oninit","vnode","attrs","uploader","on","$","reset","isMediaUploadButton","view","buttonText","uploading","translator","trans","text","className","classList","icon","onclick","uploadButtonClicked","disabled","display","multiple","onchange","process","e","prop","upload","click","Component","DragAndDrop","composerElement","handlers","supportsFileDragging","addEventListener","out","dropping","div","document","createElement","window","unload","removeEventListener","isNotFile","event","dataTransfer","items","kind","preventDefault","over","add","remove","PasteClipboard","element","paste","clipboardData","indexOf","getAsFile","Uploader","callbacks","success","failure","uploaded","callback","dispatch","response","forEach","addBBcode","body","FormData","append","request","method","forum","serialize","raw","result","error","file","fileObj","pushObject","fileListState","image","archive","code","word","UserFileList","session","inModal","selectable","restrictFileType","downloadOnClick","filesBeingHidden","state","aria-live","screen","map","fileType","fileIcon","includes","fileSelectable","isSelectable","fileClassNames","selectedFiles","fileName","isFileHiding","aria-busy","deleteOthersMediaLibrary","aria-label","hideFile","onFileClick","extractText","src","draggable","alt","role","class","onFileSelect","open","confirm","alerts","show","Alert","index","findIndex","splice","FileManagerModal","multiSelect","dragDrop","onUpload","oncreate","onremove","fileCount","alertAttrs","hide","onSelect","itemPosition","fileId","getById","composer","editor","insertAtCursor","Modal","FileManagerButton","Button","component","fileManagerButtonClicked","modal","UploadsUserPage","loadUser","route","param","content","viewOthersMediaLibrary","UserPage","components","initializers","User","uploadCountCurrent","uploadCountAll","extend","TextEditor","composerButtonVisiblity","f_","preview","originalIsFullScreen","isFullScreen","dragAndDrop","parents","Post","unbind","stopPropagation","encodeURIComponent","currentTarget","dataset","fofUploadDownloadUuid","post","csrfToken","alert","models","routes","canUpload","hasUploads","uploadCount","LinkButton","href","username"],"mappings":"2BACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,G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vC,UACP,CACIwC,KAAMhN,IAAI6K,MAAM,eAAgB,CAC5BoC,SAAU3O,KAAKmB,KAAKwN,aAExBhR,KAAM,UACNuG,KAAM,sBAEV,CACIlE,KAAKmB,OAASO,IAAI8G,QAAQrH,KACpBO,IAAImC,WAAWC,MAAM,kCACrBpC,IAAImC,WAAWC,MAAM,yCAC3B,IACA0K,EAAc,EAAI,UAAMxK,UAAU,gBAAgBwK,GAAsB,KAGhF","file":"forum.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 27);\n","module.exports = flarum.core.compat['forum/app'];","module.exports = flarum.core.compat['common/Model'];","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\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}","module.exports = flarum.core.compat['common/components/Button'];","module.exports = flarum.core.compat['common/extend'];","module.exports = flarum.core.compat['common/Component'];","module.exports = flarum.core.compat['common/components/Alert'];","module.exports = flarum.core.compat['common/components/LoadingIndicator'];","module.exports = flarum.core.compat['common/components/TextEditor'];","module.exports = flarum.core.compat['common/models/User'];","module.exports = flarum.core.compat['forum/components/UserPage'];","module.exports = flarum.core.compat['common/utils/classList'];","module.exports = flarum.core.compat['common/components/Tooltip'];","module.exports = flarum.core.compat['common/utils/extractText'];","module.exports = flarum.core.compat['common/components/LinkButton'];","module.exports = flarum.core.compat['common/utils/mixin'];","module.exports = flarum.core.compat['forum/components/Post'];","module.exports = flarum.core.compat['common/components/Modal'];","import Model from 'flarum/common/Model';\nimport mixin from 'flarum/common/utils/mixin';\n\nexport default class File extends mixin(Model, {\n baseName: Model.attribute('baseName'),\n path: Model.attribute('path'),\n url: Model.attribute('url'),\n type: Model.attribute('type'),\n size: Model.attribute('size'),\n humanSize: Model.attribute('humanSize'),\n createdAt: Model.attribute('createdAt'),\n uuid: Model.attribute('uuid'),\n tag: Model.attribute('tag'),\n hidden: Model.attribute('hidden'),\n bbcode: Model.attribute('bbcode'),\n}) {\n /**\n * Use FoF Uploads endpoint\n */\n apiEndpoint() {\n return '/fof/uploads' + (this.exists ? '/' + this.data.id : '');\n }\n}\n","import app from 'flarum/forum/app';\n\nexport default class FileListState {\n constructor() {\n this.user = null;\n\n this.files = [];\n\n this.moreResults = false;\n\n this.loading = false;\n }\n\n /**\n * Set user and load list\n *\n * @param user A user to populate the media manager\n */\n setUser(user) {\n // Keep previous state\n if (user === this.user) return;\n\n // Set user\n this.user = user;\n\n // Reset file list\n this.files = [];\n\n // Load user files\n this.loadResults();\n }\n\n /**\n * Load more user files\n *\n * @param offset The index to start the page at.\n */\n loadResults(offset = 0) {\n if (!this.user) return;\n\n this.loading = true;\n\n return app.store\n .find('fof/uploads', {\n filter: {\n user: this.user.id(),\n },\n page: {\n offset,\n },\n })\n .then(this.parseResults.bind(this));\n }\n\n /**\n * Load the next page of discussion results.\n */\n loadMore() {\n this.loading = true;\n\n this.loadResults(this.files.length).then(this.parseResults.bind(this));\n }\n\n /**\n * Parse results and append them to the file list.\n */\n parseResults(results) {\n this.files.push(...results);\n\n this.loading = false;\n this.moreResults = !!results.payload.links && !!results.payload.links.next;\n\n m.redraw();\n\n return results;\n }\n\n /**\n * Add files to the beginning of the list\n */\n addToList(files) {\n if (Array.isArray(files)) {\n this.files.unshift(...files);\n } else {\n this.files.unshift(files);\n }\n }\n\n /**\n * Are there any files in the list?\n */\n hasFiles() {\n return this.files.length > 0;\n }\n\n /**\n * Is the file list loading?\n */\n isLoading() {\n return this.loading;\n }\n\n /**\n * Does this user has more files?\n */\n hasMoreResults() {\n return this.moreResults;\n }\n\n /**\n * Does this user have any files?\n */\n empty() {\n return !this.hasFiles() && !this.isLoading();\n }\n}\n","import app from 'flarum/forum/app';\nimport Component from 'flarum/common/Component';\nimport Button from 'flarum/common/components/Button';\nimport LoadingIndicator from 'flarum/common/components/LoadingIndicator';\nimport classList from 'flarum/common/utils/classList';\nimport Tooltip from 'flarum/common/components/Tooltip';\n\nexport default class UploadButton extends Component {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.attrs.uploader.on('uploaded', () => {\n // reset the button for a new upload\n this.$('form')[0].reset();\n\n // redraw to reflect uploader.loading in the DOM\n m.redraw();\n });\n\n this.isMediaUploadButton = vnode.attrs.isMediaUploadButton || false;\n }\n\n view() {\n const buttonText = this.attrs.uploader.uploading\n ? app.translator.trans('fof-upload.forum.states.loading')\n : app.translator.trans('fof-upload.forum.buttons.upload');\n\n return (\n \n \n {this.attrs.uploader.uploading && }\n {(this.isMediaUploadButton || this.attrs.uploader.uploading) && {buttonText}}\n
    \n \n
    \n \n
    \n );\n }\n\n /**\n * Process the upload event.\n *\n * @param e\n */\n process(e) {\n // get the file from the input field\n const files = this.$('input').prop('files');\n\n if (files.length === 0) {\n // We've got no files to upload, so trying\n // to begin an upload will show an error\n // to the user.\n return;\n }\n\n this.attrs.uploader.upload(files, !this.isMediaUploadButton);\n }\n\n /**\n * Event handler for upload button being clicked\n *\n * @param {PointerEvent} e\n */\n uploadButtonClicked(e) {\n // Trigger click on hidden input element\n // (Opens file dialog)\n this.$('input').click();\n }\n}\n","export default class DragAndDrop {\n constructor(upload, composerElement) {\n this.upload = upload;\n this.composerElement = composerElement;\n\n // Keep references to the bound methods so we can remove the event listeners later\n this.handlers = {};\n\n if (!this.supportsFileDragging()) {\n return;\n }\n\n this.composerElement.addEventListener('dragover', (this.handlers.in = this.in.bind(this)));\n\n this.composerElement.addEventListener('dragleave', (this.handlers.out = this.out.bind(this)));\n this.composerElement.addEventListener('dragend', this.handlers.out);\n\n this.composerElement.addEventListener('drop', (this.handlers.dropping = this.dropping.bind(this)));\n }\n\n supportsFileDragging() {\n // Based on https://css-tricks.com/drag-and-drop-file-uploading/\n const div = document.createElement('div');\n\n return ('draggable' in div || ('ondragstart' in div && 'ondrop' in div)) && 'FormData' in window && 'FileReader' in window;\n }\n\n unload() {\n // If the handlers were not set (drag and drop not supported), we skip removing them\n if (!this.handlers.in) {\n return;\n }\n\n this.composerElement.removeEventListener('dragover', this.handlers.in);\n\n this.composerElement.removeEventListener('dragleave', this.handlers.out);\n this.composerElement.removeEventListener('dragend', this.handlers.out);\n\n this.composerElement.removeEventListener('drop', this.handlers.dropping);\n }\n\n isNotFile(event) {\n // Checking event.dataTransfer.files.length does not work on dragover event, it's always zero\n // So we use the dataTransfer.items property to check whether any file is being dragged\n if (event.dataTransfer.items) {\n for (let i = 0; i < event.dataTransfer.items.length; i++) {\n if (event.dataTransfer.items[i].kind !== 'file') {\n return true;\n }\n }\n }\n\n return false;\n }\n\n in(event) {\n if (this.isNotFile(event)) {\n return;\n }\n\n event.preventDefault();\n\n if (!this.over) {\n this.composerElement.classList.add('fof-upload-dragging');\n this.over = true;\n }\n }\n\n out(event) {\n if (this.isNotFile(event)) {\n return;\n }\n\n event.preventDefault();\n\n if (this.over) {\n this.composerElement.classList.remove('fof-upload-dragging');\n this.over = false;\n }\n }\n\n dropping(event) {\n if (this.isNotFile(event)) {\n return;\n }\n\n event.preventDefault();\n\n this.upload(event.dataTransfer.files);\n\n this.composerElement.classList.remove('fof-upload-dragging');\n }\n}\n","export default class PasteClipboard {\n constructor(upload, element) {\n this.upload = upload;\n\n // We don't need to remove the events listeners, because they'll get removed when the DOM does.\n element.addEventListener('paste', this.paste.bind(this));\n }\n\n paste(e) {\n if (e.clipboardData && e.clipboardData.items) {\n const items = e.clipboardData.items;\n\n const files = [];\n\n for (let i = 0; i < items.length; i++) {\n if (items[i].type.indexOf('image') !== -1) {\n files.push(items[i].getAsFile());\n }\n }\n\n if (files.length > 0) {\n e.preventDefault();\n\n this.upload(files);\n }\n }\n }\n}\n","import app from 'flarum/forum/app';\n\nexport default class Uploader {\n constructor() {\n this.callbacks = {\n success: [],\n failure: [],\n uploading: [],\n uploaded: [],\n };\n this.uploading = false;\n }\n\n on(type, callback) {\n this.callbacks[type].push(callback);\n }\n\n dispatch(type, response) {\n this.callbacks[type].forEach((callback) => callback(response));\n }\n\n upload(files, addBBcode = true) {\n this.uploading = true;\n this.dispatch('uploading', files);\n\n m.redraw(); // Forcing a redraw so that the button also updates if uploadFiles() is called from DragAndDrop or PasteClipboard\n\n const body = new FormData();\n\n for (let i = 0; i < files.length; i++) {\n body.append('files[]', files[i]);\n }\n\n // send a POST request to the api\n return app\n .request({\n method: 'POST',\n url: app.forum.attribute('apiUrl') + '/fof/upload',\n // prevent JSON.stringify'ing the form data in the XHR call\n serialize: (raw) => raw,\n body,\n })\n .then((result) => this.uploaded(result, addBBcode))\n .catch((error) => {\n this.uploading = false;\n m.redraw();\n\n throw error;\n });\n }\n\n uploaded(result, addBBcode = false) {\n this.uploading = false;\n\n result.data.forEach((file) => {\n const fileObj = app.store.pushObject(file);\n\n // Add file to media manager\n app.fileListState.addToList(fileObj);\n\n // Dispatch\n this.dispatch('success', {\n file: fileObj,\n addBBcode,\n });\n });\n\n this.dispatch('uploaded');\n }\n}\n","const image = ['image/png', 'image/jpg', 'image/jpeg', 'image/svg+xml', 'image/gif'];\nconst archive = ['application/zip', 'application/x-7z-compressed', 'application/gzip', 'application/vnd.rar', 'application/x-rar-compressed'];\nconst code = ['text/html', 'text/css', 'text/javascript', 'application/json', 'application/ld+json', 'text/javascript', 'application/x-httpd-php'];\nconst word = [\n 'application/x-abiword',\n 'application/msword',\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n 'application/pdf',\n];\n\n/**\n * Returns a FontAwesome icon class for a specified MIME type.\n *\n * If it's a known image type, it returns `image` instead.\n *\n * @param {string} fileType MIME type\n * @returns {string} Icon for MIME type\n */\nexport default function mimeToIcon(fileType) {\n // Display image (do not display for)\n if (image.includes(fileType)) {\n return 'image';\n }\n // Display image icon for other types\n else if (fileType.includes('image/')) {\n return 'far fa-file-image';\n }\n // Video icon\n else if (fileType.includes('video/')) {\n return 'far fa-file-video';\n }\n // Archive icon\n else if (archive.indexOf(fileType) >= 0) {\n return 'far fa-file-archive';\n }\n // PDF icon\n else if (fileType === 'application/pdf') {\n return 'far fa-file-pdf';\n }\n // Word\n else if (word.indexOf(fileType) >= 0) {\n return 'far fa-file-word';\n }\n // Audio icon\n else if (fileType.includes('audio/')) {\n return 'far fa-file-audio';\n }\n // Code files\n else if (code.indexOf(fileType) >= 0) {\n return 'far fa-file-code';\n }\n\n return 'far fa-file';\n}\n","import app from 'flarum/forum/app';\nimport Component from 'flarum/common/Component';\n\nimport Button from 'flarum/common/components/Button';\nimport Alert from 'flarum/common/components/Alert';\nimport LoadingIndicator from 'flarum/common/components/LoadingIndicator';\n\nimport classList from 'flarum/common/utils/classList';\nimport extractText from 'flarum/common/utils/extractText';\n\nimport mimeToIcon from '../../common/mimeToIcon';\n\nexport default class UserFileList extends Component {\n oninit(vnode) {\n super.oninit(vnode);\n\n // Load file list\n app.fileListState.setUser(vnode.attrs.user || app.session.user);\n\n this.inModal = vnode.attrs.selectable;\n this.restrictFileType = vnode.attrs.restrictFileType || null;\n this.downloadOnClick = this.attrs.downloadOnClick || false;\n /**\n * @type {string[]} List of file UUIDs currently being hidden.\n */\n this.filesBeingHidden = [];\n\n /**\n * The user who's media we are dealing with\n */\n this.user = app.fileListState.user;\n }\n\n view() {\n /**\n * @type {{empty(): boolean, files: import('../../common/models/File').default[]}}\n */\n const state = app.fileListState;\n\n return (\n
    \n {/* Loading */}\n {state.isLoading() && state.files.length === 0 && (\n
    \n {app.translator.trans('fof-upload.forum.file_list.loading')}\n\n \n
    \n )}\n\n {/* Empty personal file list */}\n {this.inModal && state.empty() && (\n

    \n \n\n {app.translator.trans(`fof-upload.forum.file_list.modal_empty_${app.screen() !== 'phone' ? 'desktop' : 'phone'}`)}\n

    \n )}\n\n {/* Empty file list */}\n {!this.inModal && state.empty() &&

    {app.translator.trans('fof-upload.forum.file_list.empty')}

    }\n\n {/* File list */}\n
      \n {state.files.map((file) => {\n const fileIcon = mimeToIcon(file.type());\n const fileSelectable = this.restrictFileType ? this.isSelectable(file) : true;\n\n const fileClassNames = classList([\n 'fof-file',\n // File is image\n fileIcon === 'image' && 'fof-file-type-image',\n // File is selected\n this.attrs.selectedFiles && this.attrs.selectedFiles.indexOf(file.id()) >= 0 && 'fof-file-selected',\n ]);\n\n /**\n * File's baseName (file name + extension)\n * @type {string}\n */\n const fileName = file.baseName();\n\n const isFileHiding = this.filesBeingHidden.includes(file.uuid());\n\n return (\n
    • \n {app.session.user && (this.user === app.session.user || app.session.user.deleteOthersMediaLibrary()) && (\n \n )}\n\n this.onFileClick(file)}\n disabled={!fileSelectable || isFileHiding}\n aria-label={extractText(app.translator.trans('fof-upload.forum.file_list.select_file_a11y_label', { fileName }))}\n >\n
      \n {fileIcon === 'image' ? (\n \n ) : (\n \n \n \n )}\n\n
      {fileName}
      \n\n {isFileHiding && (\n \n \n \n )}\n
      \n \n
    • \n );\n })}\n
    \n\n {/* Load more files */}\n {state.hasMoreResults() && (\n
    \n state.loadMore()}\n >\n {app.translator.trans('fof-upload.forum.file_list.load_more_files_btn')}\n \n
    \n )}\n
    \n );\n }\n\n /**\n * Execute function on file click\n *\n * @param {import('../../common/models/File').default} file\n */\n onFileClick(file) {\n // Custom functionality\n if (this.attrs.onFileSelect) {\n this.attrs.onFileSelect(file);\n return;\n }\n\n // Download on click\n if (this.attrs.downloadOnClick) {\n window.open(file.url());\n return;\n }\n }\n\n /**\n * Check if a file is selectable\n *\n * @param {import('../../common/models/File').default} file\n */\n isSelectable(file) {\n const fileType = file.type();\n\n // Custom defined file types\n if (Array.isArray(this.restrictFileType)) {\n return this.restrictFileType.indexOf(fileType) >= 0;\n }\n\n // Image\n else if (this.restrictFileType === 'image') {\n return fileType.includes('image/');\n }\n\n // Audio\n else if (this.restrictFileType === 'audio') {\n return fileType.includes('audio/');\n }\n\n // Video\n else if (this.restrictFileType === 'video') {\n return fileType.includes('video/');\n }\n\n return false;\n }\n\n /**\n * Begins the hiding process for a file.\n *\n * - Shows a native confirmation dialog\n * - If confirmed, sends AJAX request to the hide file API\n *\n * @param {import('../../common/models/File').default} file File to hide\n */\n hideFile(file) {\n /**\n * @type {string} File UUID\n */\n const uuid = file.uuid();\n\n if (this.filesBeingHidden.includes(uuid)) return;\n\n this.filesBeingHidden.push(uuid);\n\n const confirmHide = confirm(\n extractText(app.translator.trans('fof-upload.forum.file_list.hide_file.hide_confirmation', { fileName: file.baseName() }))\n );\n\n if (confirmHide) {\n app.request({\n method: 'PATCH',\n url: `${app.forum.attribute('apiUrl')}/fof/upload/hide`,\n body: { uuid },\n })\n .then(() => {\n app.alerts.show(Alert, { type: 'success' }, app.translator.trans('fof-upload.forum.file_list.hide_file.hide_success'));\n })\n .catch(() => {\n app.alerts.show(\n Alert,\n { type: 'error' },\n app.translator.trans('fof-upload.forum.file_list.hide_file.hide_fail', { fileName: file.fileName() })\n );\n })\n .then(() => {\n // Remove hidden file from state\n /**\n * @type {{ files: import('../../common/models/File').default[] }}\n */\n const state = app.fileListState;\n\n const index = state.files.findIndex((file) => uuid === file.uuid());\n state.files.splice(index, 1);\n\n // Remove file from hiding list\n const i = this.filesBeingHidden.indexOf(uuid);\n this.filesBeingHidden.splice(i, 1);\n });\n } else {\n // Remove file from hiding list\n const i = this.filesBeingHidden.indexOf(uuid);\n this.filesBeingHidden.splice(i, 1);\n }\n }\n}\n","import Modal from 'flarum/common/components/Modal';\nimport Button from 'flarum/common/components/Button';\nimport UploadButton from './UploadButton';\nimport UserFileList from './UserFileList';\nimport DragAndDrop from './DragAndDrop';\n\nexport default class FileManagerModal extends Modal {\n oninit(vnode) {\n super.oninit(vnode);\n\n // Initialize upload managers\n this.uploader = vnode.attrs.uploader;\n\n // Current selected files\n this.selectedFiles = [];\n\n // Allow multiselect\n this.multiSelect = vnode.attrs.multiSelect || true;\n\n // Restrict file selection to specific types\n this.restrictFileType = vnode.attrs.restrictFileType || null;\n\n // Drag & drop\n this.dragDrop = null;\n\n // Initialize uploads\n this.onUpload();\n }\n\n className() {\n return 'Modal--large fof-file-manager-modal';\n }\n\n /**\n * Initialize drag & drop\n */\n oncreate(vnode) {\n super.oncreate(vnode);\n\n this.dragDrop = new DragAndDrop((files) => this.uploader.upload(files, false), this.$().find('.Modal-content')[0]);\n }\n\n /**\n * Remove events from modal content\n */\n onremove() {\n if (this.dragDrop) {\n this.dragDrop.unload();\n }\n }\n\n view() {\n const fileCount = this.selectedFiles.length;\n\n return (\n
    \n
    \n
    \n \n
    \n\n
    \n
    \n \n\n {app.translator.trans('fof-upload.forum.file_list.release_to_upload')}\n
    \n
    \n\n
    \n

    {app.translator.trans('fof-upload.forum.media_manager')}

    \n
    \n\n {this.alertAttrs && (\n
    \n \n
    \n )}\n\n
    \n \n
    \n\n
    \n \n\n 1)}\n className=\"Button Button--primary\"\n >\n {app.translator.trans('fof-upload.forum.file_list.confirm_selection_btn', { fileCount })}\n \n
    \n
    \n
    \n );\n }\n\n /**\n * Add or remove file from selected files\n *\n * @param {File} file\n */\n onFileSelect(file) {\n const itemPosition = this.selectedFiles.indexOf(file.id());\n\n if (itemPosition >= 0) {\n this.selectedFiles.splice(itemPosition, 1);\n } else {\n if (this.multiSelect) {\n this.selectedFiles.push(file.id());\n } else {\n this.selectedFiles = [file.id()];\n }\n }\n }\n\n /**\n * Add files to file list after upload\n */\n onUpload() {\n this.uploader.on('success', ({ file }) => {\n if (this.multiSelect) {\n this.selectedFiles.push(file.id());\n } else {\n this.selectedFiles = [file.id()];\n }\n });\n }\n\n /**\n * Add selected files to the composer\n */\n onSelect() {\n this.hide();\n\n // Custom callback\n if (this.attrs.onSelect) {\n this.attrs.onSelect(this.selectedFiles);\n\n return;\n }\n\n // Add selected files to composer\n this.selectedFiles.map((fileId) => {\n const file = app.store.getById('files', fileId);\n\n app.composer.editor.insertAtCursor(file.bbcode() + '\\n', false);\n });\n }\n}\n","import app from 'flarum/forum/app';\nimport Component from 'flarum/common/Component';\nimport Button from 'flarum/common/components/Button';\nimport FileManagerModal from './FileManagerModal';\nimport Tooltip from 'flarum/common/components/Tooltip';\n\nexport default class FileManagerButton extends Component {\n view() {\n return (\n \n {Button.component({\n className: 'Button fof-upload-button Button--icon',\n onclick: this.fileManagerButtonClicked.bind(this),\n icon: 'fas fa-photo-video',\n })}\n \n );\n }\n\n /**\n * Event handler for upload button being clicked\n *\n * @param {PointerEvent} e\n */\n fileManagerButtonClicked(e) {\n e.preventDefault();\n\n // Open dialog\n app.modal.show(FileManagerModal, {\n uploader: this.attrs.uploader,\n });\n }\n}\n","import app from 'flarum/forum/app';\nimport UserPage from 'flarum/forum/components/UserPage';\nimport UserFileList from './UserFileList';\n\nexport default class UploadsUserPage extends UserPage {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.user = null;\n\n this.loadUser(m.route.param('username'));\n }\n\n content() {\n if (app.session.user && (app.session.user.viewOthersMediaLibrary() || this.user === app.session.user)) {\n return (\n this.user &&\n UserFileList.component({\n user: this.user,\n selectable: false,\n downloadOnClick: true,\n })\n );\n } else {\n return null;\n }\n }\n\n show(user) {\n super.show(user);\n this.user = user;\n }\n}\n","import Uploader from '../handler/Uploader';\nimport DragAndDrop from './DragAndDrop';\nimport FileManagerButton from './FileManagerButton';\nimport FileManagerModal from './FileManagerModal';\nimport UserFileList from './UserFileList';\nimport UploadButton from './UploadButton';\n\nexport const components = {\n DragAndDrop,\n FileManagerButton,\n FileManagerModal,\n UserFileList,\n Uploader,\n UploadButton,\n};\n","import { extend } from 'flarum/common/extend';\nimport app from 'flarum/forum/app';\nimport UserPage from 'flarum/forum/components/UserPage';\nimport LinkButton from 'flarum/common/components/LinkButton';\n\nimport File from '../common/models/File';\nimport FileListState from './states/FileListState';\nimport downloadButtonInteraction from './downloadButtonInteraction';\nimport addUploadButton from './addUploadButton';\nimport UploadsUserPage from './components/UploadsUserPage';\nimport User from 'flarum/common/models/User';\nimport Model from 'flarum/common/Model';\n\nexport * from './components';\n\napp.initializers.add('fof-upload', () => {\n User.prototype.viewOthersMediaLibrary = Model.attribute('fof-upload-viewOthersMediaLibrary');\n User.prototype.deleteOthersMediaLibrary = Model.attribute('fof-upload-deleteOthersMediaLibrary');\n User.prototype.uploadCountCurrent = Model.attribute('fof-upload-uploadCountCurrent');\n User.prototype.uploadCountAll = Model.attribute('fof-upload-uploadCountAll');\n\n addUploadButton();\n downloadButtonInteraction();\n\n // File model\n app.store.models.files = File;\n\n // File list state\n app.fileListState = new FileListState();\n\n // Add user uploads to the user profile\n app.routes['user.uploads'] = {\n path: '/u/:username/uploads',\n component: UploadsUserPage,\n };\n\n // Add uploads to user page menu items\n extend(UserPage.prototype, 'navItems', function (items) {\n const canUpload = !!app.forum.attribute('fof-upload.canUpload');\n const hasUploads = !!this.user.uploadCountCurrent();\n\n if (app.session.user && (app.session.user.viewOthersMediaLibrary() || (this.user === app.session.user && (canUpload || hasUploads)))) {\n const uploadCount = this.user.uploadCountCurrent();\n\n items.add(\n 'uploads',\n LinkButton.component(\n {\n href: app.route('user.uploads', {\n username: this.user.username(),\n }),\n name: 'uploads',\n icon: 'fas fa-file-upload',\n },\n [\n this.user === app.session.user\n ? app.translator.trans('fof-upload.forum.buttons.media')\n : app.translator.trans('fof-upload.forum.buttons.user_uploads'),\n ' ',\n uploadCount > 0 ? {uploadCount} : '',\n ]\n ),\n 80\n );\n }\n });\n});\n","import app from 'flarum/forum/app';\nimport { extend } from 'flarum/common/extend';\nimport TextEditor from 'flarum/common/components/TextEditor';\nimport UploadButton from './components/UploadButton';\nimport DragAndDrop from './components/DragAndDrop';\nimport PasteClipboard from './components/PasteClipboard';\nimport Uploader from './handler/Uploader';\nimport FileManagerButton from './components/FileManagerButton';\n\nexport default function () {\n extend(TextEditor.prototype, 'oninit', function () {\n this.uploader = new Uploader();\n });\n extend(TextEditor.prototype, 'controlItems', function (items) {\n if (!app.forum.attribute('fof-upload.canUpload')) return;\n\n const composerButtonVisiblity = app.forum.attribute('fof-upload.composerButtonVisiblity');\n\n // Add media button\n if (composerButtonVisiblity === 'both' || composerButtonVisiblity === 'media-btn') {\n items.add(\n 'fof-upload-media',\n FileManagerButton.component({\n uploader: this.uploader,\n })\n );\n }\n\n // Add upload button\n if (composerButtonVisiblity === 'both' || composerButtonVisiblity === 'upload-btn') {\n items.add(\n 'fof-upload',\n UploadButton.component({\n uploader: this.uploader,\n })\n );\n }\n });\n\n extend(TextEditor.prototype, 'oncreate', function (f_, vnode) {\n if (!app.forum.attribute('fof-upload.canUpload')) return;\n\n this.uploader.on('success', ({ file, addBBcode }) => {\n if (!addBBcode) return;\n\n this.attrs.composer.editor.insertAtCursor(file.bbcode() + '\\n', false);\n\n // We wrap this in a typeof check to prevent it running when a user\n // is creating a new discussion. There's nothing to preview in a new\n // discussion, so the `preview` function isn't defined.\n if (typeof this.attrs.preview === 'function') {\n // Scroll the preview into view\n // preview() causes the composer to close on mobile, but we don't want that. We want only the scroll\n // We work around that by temporarily patching the isFullScreen method\n const originalIsFullScreen = app.composer.isFullScreen;\n\n app.composer.isFullScreen = () => false;\n\n this.attrs.preview();\n\n app.composer.isFullScreen = originalIsFullScreen;\n }\n });\n\n this.dragAndDrop = new DragAndDrop((files) => this.uploader.upload(files), this.$().parents('.Composer')[0]);\n\n new PasteClipboard((files) => this.uploader.upload(files), this.$('.TextEditor-editor')[0]);\n });\n\n extend(TextEditor.prototype, 'onremove', function (f_, vnode) {\n if (!app.forum.attribute('fof-upload.canUpload')) return;\n\n this.dragAndDrop.unload();\n });\n}\n","import app from 'flarum/forum/app';\nimport { extend } from 'flarum/common/extend';\nimport Post from 'flarum/forum/components/Post';\n\n/* global $ */\n\nexport default function () {\n extend(Post.prototype, 'oncreate', function () {\n this.$('[data-fof-upload-download-uuid]')\n .unbind('click')\n .on('click', (e) => {\n e.preventDefault();\n e.stopPropagation();\n\n if (!app.forum.attribute('fof-upload.canDownload')) {\n alert(app.translator.trans('fof-upload.forum.states.unauthorized'));\n return;\n }\n\n let url = app.forum.attribute('apiUrl') + '/fof/download';\n\n url += '/' + encodeURIComponent(e.currentTarget.dataset.fofUploadDownloadUuid);\n url += '/' + encodeURIComponent(this.attrs.post.id());\n url += '/' + encodeURIComponent(app.session.csrfToken);\n\n window.open(url);\n });\n });\n}\n"],"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,GCLRF,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,MCJ3ER,EAAwB,CAACc,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFf,EAAyBM,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,M,yDCLvD,MAAM,EAA+BC,OAAOC,KAAKC,OAAO,iBCAlD,EAA+BF,OAAOC,KAAKC,OAAO,a,aCAxD,MAAM,EAA+BF,OAAOC,KAAKC,OAAO,6B,aCAxD,MAAM,EAA+BF,OAAOC,KAAKC,OAAO,gC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,IAAAA,QAAAA,OAAqB2L,GAAaC,IAAe,CACpI,IAAME,EAAcvN,KAAKkB,KAAKoM,qBAE9B3H,EAAMK,IACJ,UACAwH,IAAAA,UACE,CACEC,KAAMhM,IAAAA,MAAU,eAAgB,CAC9BiM,SAAU1N,KAAKkB,KAAKwM,aAEtBC,KAAM,UACN5J,KAAM,sBAER,CACE/D,KAAKkB,OAASO,IAAAA,QAAAA,KACVA,IAAAA,WAAAA,MAAqB,kCACrBA,IAAAA,WAAAA,MAAqB,yCACzB,IACA8L,EAAc,EAAI,UAAM1J,UAAU,gBAAgB0J,GAAsB,KAG5E,Y","sources":["webpack://@fof/upload/webpack/bootstrap","webpack://@fof/upload/webpack/runtime/compat get default export","webpack://@fof/upload/webpack/runtime/define property getters","webpack://@fof/upload/webpack/runtime/hasOwnProperty shorthand","webpack://@fof/upload/webpack/runtime/make namespace object","webpack://@fof/upload/external root \"flarum.core.compat['common/extend']\"","webpack://@fof/upload/external root \"flarum.core.compat['forum/app']\"","webpack://@fof/upload/external root \"flarum.core.compat['forum/components/UserPage']\"","webpack://@fof/upload/external root \"flarum.core.compat['common/components/LinkButton']\"","webpack://@fof/upload/./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js","webpack://@fof/upload/./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://@fof/upload/external root \"flarum.core.compat['common/Model']\"","webpack://@fof/upload/external root \"flarum.core.compat['common/utils/mixin']\"","webpack://@fof/upload/./src/common/models/File.js","webpack://@fof/upload/./src/forum/states/FileListState.js","webpack://@fof/upload/external root \"flarum.core.compat['forum/components/Post']\"","webpack://@fof/upload/external root \"flarum.core.compat['common/components/TextEditor']\"","webpack://@fof/upload/external root \"flarum.core.compat['common/Component']\"","webpack://@fof/upload/external root \"flarum.core.compat['common/components/Button']\"","webpack://@fof/upload/external root \"flarum.core.compat['common/components/LoadingIndicator']\"","webpack://@fof/upload/external root \"flarum.core.compat['common/utils/classList']\"","webpack://@fof/upload/external root \"flarum.core.compat['common/components/Tooltip']\"","webpack://@fof/upload/./src/forum/components/UploadButton.js","webpack://@fof/upload/./src/forum/components/DragAndDrop.js","webpack://@fof/upload/./src/forum/components/PasteClipboard.js","webpack://@fof/upload/./src/forum/handler/Uploader.js","webpack://@fof/upload/external root \"flarum.core.compat['common/components/Modal']\"","webpack://@fof/upload/external root \"flarum.core.compat['common/components/Alert']\"","webpack://@fof/upload/external root \"flarum.core.compat['common/utils/extractText']\"","webpack://@fof/upload/./src/common/mimeToIcon.js","webpack://@fof/upload/./src/forum/components/UserFileList.js","webpack://@fof/upload/./src/forum/components/FileManagerModal.js","webpack://@fof/upload/./src/forum/components/FileManagerButton.js","webpack://@fof/upload/./src/forum/components/UploadsUserPage.js","webpack://@fof/upload/external root \"flarum.core.compat['common/models/User']\"","webpack://@fof/upload/./src/forum/components/index.js","webpack://@fof/upload/./src/forum/index.js","webpack://@fof/upload/./src/forum/addUploadButton.js","webpack://@fof/upload/./src/forum/downloadButtonInteraction.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['common/extend'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/app'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/UserPage'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/LinkButton'];","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\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/Model'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/utils/mixin'];","import Model from 'flarum/common/Model';\nimport mixin from 'flarum/common/utils/mixin';\n\nexport default class File extends mixin(Model, {\n baseName: Model.attribute('baseName'),\n path: Model.attribute('path'),\n url: Model.attribute('url'),\n type: Model.attribute('type'),\n size: Model.attribute('size'),\n humanSize: Model.attribute('humanSize'),\n createdAt: Model.attribute('createdAt'),\n uuid: Model.attribute('uuid'),\n tag: Model.attribute('tag'),\n hidden: Model.attribute('hidden'),\n bbcode: Model.attribute('bbcode'),\n}) {\n /**\n * Use FoF Uploads endpoint\n */\n apiEndpoint() {\n return '/fof/uploads' + (this.exists ? '/' + this.data.id : '');\n }\n}\n","import app from 'flarum/forum/app';\n\nexport default class FileListState {\n constructor() {\n this.user = null;\n\n this.files = [];\n\n this.moreResults = false;\n\n this.loading = false;\n }\n\n /**\n * Set user and load list\n *\n * @param user A user to populate the media manager\n */\n setUser(user) {\n // Keep previous state\n if (user === this.user) return;\n\n // Set user\n this.user = user;\n\n // Reset file list\n this.files = [];\n\n // Load user files\n this.loadResults();\n }\n\n /**\n * Load more user files\n *\n * @param offset The index to start the page at.\n */\n loadResults(offset = 0) {\n if (!this.user) return;\n\n this.loading = true;\n\n return app.store\n .find('fof/uploads', {\n filter: {\n user: this.user.id(),\n },\n page: {\n offset,\n },\n })\n .then(this.parseResults.bind(this));\n }\n\n /**\n * Load the next page of discussion results.\n */\n loadMore() {\n this.loading = true;\n\n this.loadResults(this.files.length).then(this.parseResults.bind(this));\n }\n\n /**\n * Parse results and append them to the file list.\n */\n parseResults(results) {\n this.files.push(...results);\n\n this.loading = false;\n this.moreResults = !!results.payload.links && !!results.payload.links.next;\n\n m.redraw();\n\n return results;\n }\n\n /**\n * Add files to the beginning of the list\n */\n addToList(files) {\n if (Array.isArray(files)) {\n this.files.unshift(...files);\n } else {\n this.files.unshift(files);\n }\n }\n\n /**\n * Are there any files in the list?\n */\n hasFiles() {\n return this.files.length > 0;\n }\n\n /**\n * Is the file list loading?\n */\n isLoading() {\n return this.loading;\n }\n\n /**\n * Does this user has more files?\n */\n hasMoreResults() {\n return this.moreResults;\n }\n\n /**\n * Does this user have any files?\n */\n empty() {\n return !this.hasFiles() && !this.isLoading();\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/Post'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/TextEditor'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/Component'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Button'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/LoadingIndicator'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/utils/classList'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Tooltip'];","import app from 'flarum/forum/app';\nimport Component from 'flarum/common/Component';\nimport Button from 'flarum/common/components/Button';\nimport LoadingIndicator from 'flarum/common/components/LoadingIndicator';\nimport classList from 'flarum/common/utils/classList';\nimport Tooltip from 'flarum/common/components/Tooltip';\n\nexport default class UploadButton extends Component {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.attrs.uploader.on('uploaded', () => {\n // reset the button for a new upload\n this.$('form')[0].reset();\n\n // redraw to reflect uploader.loading in the DOM\n m.redraw();\n });\n\n this.isMediaUploadButton = vnode.attrs.isMediaUploadButton || false;\n }\n\n view() {\n const buttonText = this.attrs.uploader.uploading\n ? app.translator.trans('fof-upload.forum.states.loading')\n : app.translator.trans('fof-upload.forum.buttons.upload');\n\n return (\n \n \n {this.attrs.uploader.uploading && }\n {(this.isMediaUploadButton || this.attrs.uploader.uploading) && {buttonText}}\n
    \n \n
    \n \n
    \n );\n }\n\n /**\n * Process the upload event.\n *\n * @param e\n */\n process(e) {\n // get the file from the input field\n const files = this.$('input').prop('files');\n\n if (files.length === 0) {\n // We've got no files to upload, so trying\n // to begin an upload will show an error\n // to the user.\n return;\n }\n\n this.attrs.uploader.upload(files, !this.isMediaUploadButton);\n }\n\n /**\n * Event handler for upload button being clicked\n *\n * @param {PointerEvent} e\n */\n uploadButtonClicked(e) {\n // Trigger click on hidden input element\n // (Opens file dialog)\n this.$('input').click();\n }\n}\n","export default class DragAndDrop {\n constructor(upload, composerElement) {\n this.upload = upload;\n this.composerElement = composerElement;\n\n // Keep references to the bound methods so we can remove the event listeners later\n this.handlers = {};\n\n if (!this.supportsFileDragging()) {\n return;\n }\n\n this.composerElement.addEventListener('dragover', (this.handlers.in = this.in.bind(this)));\n\n this.composerElement.addEventListener('dragleave', (this.handlers.out = this.out.bind(this)));\n this.composerElement.addEventListener('dragend', this.handlers.out);\n\n this.composerElement.addEventListener('drop', (this.handlers.dropping = this.dropping.bind(this)));\n }\n\n supportsFileDragging() {\n // Based on https://css-tricks.com/drag-and-drop-file-uploading/\n const div = document.createElement('div');\n\n return ('draggable' in div || ('ondragstart' in div && 'ondrop' in div)) && 'FormData' in window && 'FileReader' in window;\n }\n\n unload() {\n // If the handlers were not set (drag and drop not supported), we skip removing them\n if (!this.handlers.in) {\n return;\n }\n\n this.composerElement.removeEventListener('dragover', this.handlers.in);\n\n this.composerElement.removeEventListener('dragleave', this.handlers.out);\n this.composerElement.removeEventListener('dragend', this.handlers.out);\n\n this.composerElement.removeEventListener('drop', this.handlers.dropping);\n }\n\n isNotFile(event) {\n // Checking event.dataTransfer.files.length does not work on dragover event, it's always zero\n // So we use the dataTransfer.items property to check whether any file is being dragged\n if (event.dataTransfer.items) {\n for (let i = 0; i < event.dataTransfer.items.length; i++) {\n if (event.dataTransfer.items[i].kind !== 'file') {\n return true;\n }\n }\n }\n\n return false;\n }\n\n in(event) {\n if (this.isNotFile(event)) {\n return;\n }\n\n event.preventDefault();\n\n if (!this.over) {\n this.composerElement.classList.add('fof-upload-dragging');\n this.over = true;\n }\n }\n\n out(event) {\n if (this.isNotFile(event)) {\n return;\n }\n\n event.preventDefault();\n\n if (this.over) {\n this.composerElement.classList.remove('fof-upload-dragging');\n this.over = false;\n }\n }\n\n dropping(event) {\n if (this.isNotFile(event)) {\n return;\n }\n\n event.preventDefault();\n\n this.upload(event.dataTransfer.files);\n\n this.composerElement.classList.remove('fof-upload-dragging');\n }\n}\n","export default class PasteClipboard {\n constructor(upload, element) {\n this.upload = upload;\n\n // We don't need to remove the events listeners, because they'll get removed when the DOM does.\n element.addEventListener('paste', this.paste.bind(this));\n }\n\n paste(e) {\n if (e.clipboardData && e.clipboardData.items) {\n const items = e.clipboardData.items;\n\n const files = [];\n\n for (let i = 0; i < items.length; i++) {\n if (items[i].type.indexOf('image') !== -1) {\n files.push(items[i].getAsFile());\n }\n }\n\n if (files.length > 0) {\n e.preventDefault();\n\n this.upload(files);\n }\n }\n }\n}\n","import app from 'flarum/forum/app';\n\nexport default class Uploader {\n constructor() {\n this.callbacks = {\n success: [],\n failure: [],\n uploading: [],\n uploaded: [],\n };\n this.uploading = false;\n }\n\n on(type, callback) {\n this.callbacks[type].push(callback);\n }\n\n dispatch(type, response) {\n this.callbacks[type].forEach((callback) => callback(response));\n }\n\n upload(files, addBBcode = true) {\n this.uploading = true;\n this.dispatch('uploading', files);\n\n m.redraw(); // Forcing a redraw so that the button also updates if uploadFiles() is called from DragAndDrop or PasteClipboard\n\n const body = new FormData();\n\n for (let i = 0; i < files.length; i++) {\n body.append('files[]', files[i]);\n }\n\n // send a POST request to the api\n return app\n .request({\n method: 'POST',\n url: app.forum.attribute('apiUrl') + '/fof/upload',\n // prevent JSON.stringify'ing the form data in the XHR call\n serialize: (raw) => raw,\n body,\n })\n .then((result) => this.uploaded(result, addBBcode))\n .catch((error) => {\n this.uploading = false;\n m.redraw();\n\n throw error;\n });\n }\n\n uploaded(result, addBBcode = false) {\n this.uploading = false;\n\n result.data.forEach((file) => {\n const fileObj = app.store.pushObject(file);\n\n // Add file to media manager\n app.fileListState.addToList(fileObj);\n\n // Dispatch\n this.dispatch('success', {\n file: fileObj,\n addBBcode,\n });\n });\n\n this.dispatch('uploaded');\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Modal'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Alert'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/utils/extractText'];","const image = ['image/png', 'image/jpg', 'image/jpeg', 'image/svg+xml', 'image/gif'];\nconst archive = ['application/zip', 'application/x-7z-compressed', 'application/gzip', 'application/vnd.rar', 'application/x-rar-compressed'];\nconst code = ['text/html', 'text/css', 'text/javascript', 'application/json', 'application/ld+json', 'text/javascript', 'application/x-httpd-php'];\nconst word = [\n 'application/x-abiword',\n 'application/msword',\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n 'application/pdf',\n];\n\n/**\n * Returns a FontAwesome icon class for a specified MIME type.\n *\n * If it's a known image type, it returns `image` instead.\n *\n * @param {string} fileType MIME type\n * @returns {string} Icon for MIME type\n */\nexport default function mimeToIcon(fileType) {\n // Display image (do not display for)\n if (image.includes(fileType)) {\n return 'image';\n }\n // Display image icon for other types\n else if (fileType.includes('image/')) {\n return 'far fa-file-image';\n }\n // Video icon\n else if (fileType.includes('video/')) {\n return 'far fa-file-video';\n }\n // Archive icon\n else if (archive.indexOf(fileType) >= 0) {\n return 'far fa-file-archive';\n }\n // PDF icon\n else if (fileType === 'application/pdf') {\n return 'far fa-file-pdf';\n }\n // Word\n else if (word.indexOf(fileType) >= 0) {\n return 'far fa-file-word';\n }\n // Audio icon\n else if (fileType.includes('audio/')) {\n return 'far fa-file-audio';\n }\n // Code files\n else if (code.indexOf(fileType) >= 0) {\n return 'far fa-file-code';\n }\n\n return 'far fa-file';\n}\n","import app from 'flarum/forum/app';\nimport Component from 'flarum/common/Component';\n\nimport Button from 'flarum/common/components/Button';\nimport Alert from 'flarum/common/components/Alert';\nimport LoadingIndicator from 'flarum/common/components/LoadingIndicator';\n\nimport classList from 'flarum/common/utils/classList';\nimport extractText from 'flarum/common/utils/extractText';\n\nimport mimeToIcon from '../../common/mimeToIcon';\n\nexport default class UserFileList extends Component {\n oninit(vnode) {\n super.oninit(vnode);\n\n // Load file list\n app.fileListState.setUser(vnode.attrs.user || app.session.user);\n\n this.inModal = vnode.attrs.selectable;\n this.restrictFileType = vnode.attrs.restrictFileType || null;\n this.downloadOnClick = this.attrs.downloadOnClick || false;\n /**\n * @type {string[]} List of file UUIDs currently being hidden.\n */\n this.filesBeingHidden = [];\n\n /**\n * The user who's media we are dealing with\n */\n this.user = app.fileListState.user;\n }\n\n view() {\n /**\n * @type {{empty(): boolean, files: import('../../common/models/File').default[]}}\n */\n const state = app.fileListState;\n\n return (\n
    \n {/* Loading */}\n {state.isLoading() && state.files.length === 0 && (\n
    \n {app.translator.trans('fof-upload.forum.file_list.loading')}\n\n \n
    \n )}\n\n {/* Empty personal file list */}\n {this.inModal && state.empty() && (\n

    \n \n\n {app.translator.trans(`fof-upload.forum.file_list.modal_empty_${app.screen() !== 'phone' ? 'desktop' : 'phone'}`)}\n

    \n )}\n\n {/* Empty file list */}\n {!this.inModal && state.empty() &&

    {app.translator.trans('fof-upload.forum.file_list.empty')}

    }\n\n {/* File list */}\n
      \n {state.files.map((file) => {\n const fileIcon = mimeToIcon(file.type());\n const fileSelectable = this.restrictFileType ? this.isSelectable(file) : true;\n\n const fileClassNames = classList([\n 'fof-file',\n // File is image\n fileIcon === 'image' && 'fof-file-type-image',\n // File is selected\n this.attrs.selectedFiles && this.attrs.selectedFiles.indexOf(file.id()) >= 0 && 'fof-file-selected',\n ]);\n\n /**\n * File's baseName (file name + extension)\n * @type {string}\n */\n const fileName = file.baseName();\n\n const isFileHiding = this.filesBeingHidden.includes(file.uuid());\n\n return (\n
    • \n {app.session.user && (this.user === app.session.user || app.session.user.deleteOthersMediaLibrary()) && (\n \n )}\n\n this.onFileClick(file)}\n disabled={!fileSelectable || isFileHiding}\n aria-label={extractText(app.translator.trans('fof-upload.forum.file_list.select_file_a11y_label', { fileName }))}\n >\n
      \n {fileIcon === 'image' ? (\n \n ) : (\n \n \n \n )}\n\n
      {fileName}
      \n\n {isFileHiding && (\n \n \n \n )}\n
      \n \n
    • \n );\n })}\n
    \n\n {/* Load more files */}\n {state.hasMoreResults() && (\n
    \n \n
    \n )}\n
    \n );\n }\n\n /**\n * Execute function on file click\n *\n * @param {import('../../common/models/File').default} file\n */\n onFileClick(file) {\n // Custom functionality\n if (this.attrs.onFileSelect) {\n this.attrs.onFileSelect(file);\n return;\n }\n\n // Download on click\n if (this.attrs.downloadOnClick) {\n window.open(file.url());\n return;\n }\n }\n\n /**\n * Check if a file is selectable\n *\n * @param {import('../../common/models/File').default} file\n */\n isSelectable(file) {\n const fileType = file.type();\n\n // Custom defined file types\n if (Array.isArray(this.restrictFileType)) {\n return this.restrictFileType.indexOf(fileType) >= 0;\n }\n\n // Image\n else if (this.restrictFileType === 'image') {\n return fileType.includes('image/');\n }\n\n // Audio\n else if (this.restrictFileType === 'audio') {\n return fileType.includes('audio/');\n }\n\n // Video\n else if (this.restrictFileType === 'video') {\n return fileType.includes('video/');\n }\n\n return false;\n }\n\n /**\n * Begins the hiding process for a file.\n *\n * - Shows a native confirmation dialog\n * - If confirmed, sends AJAX request to the hide file API\n *\n * @param {import('../../common/models/File').default} file File to hide\n */\n hideFile(file) {\n /**\n * @type {string} File UUID\n */\n const uuid = file.uuid();\n\n if (this.filesBeingHidden.includes(uuid)) return;\n\n this.filesBeingHidden.push(uuid);\n\n const confirmHide = confirm(\n extractText(app.translator.trans('fof-upload.forum.file_list.hide_file.hide_confirmation', { fileName: file.baseName() }))\n );\n\n if (confirmHide) {\n app\n .request({\n method: 'PATCH',\n url: `${app.forum.attribute('apiUrl')}/fof/upload/hide`,\n body: { uuid },\n })\n .then(() => {\n app.alerts.show(Alert, { type: 'success' }, app.translator.trans('fof-upload.forum.file_list.hide_file.hide_success'));\n })\n .catch(() => {\n app.alerts.show(\n Alert,\n { type: 'error' },\n app.translator.trans('fof-upload.forum.file_list.hide_file.hide_fail', { fileName: file.fileName() })\n );\n })\n .then(() => {\n // Remove hidden file from state\n /**\n * @type {{ files: import('../../common/models/File').default[] }}\n */\n const state = app.fileListState;\n\n const index = state.files.findIndex((file) => uuid === file.uuid());\n state.files.splice(index, 1);\n\n // Remove file from hiding list\n const i = this.filesBeingHidden.indexOf(uuid);\n this.filesBeingHidden.splice(i, 1);\n });\n } else {\n // Remove file from hiding list\n const i = this.filesBeingHidden.indexOf(uuid);\n this.filesBeingHidden.splice(i, 1);\n }\n }\n}\n","import Modal from 'flarum/common/components/Modal';\nimport Button from 'flarum/common/components/Button';\nimport UploadButton from './UploadButton';\nimport UserFileList from './UserFileList';\nimport DragAndDrop from './DragAndDrop';\n\nexport default class FileManagerModal extends Modal {\n oninit(vnode) {\n super.oninit(vnode);\n\n // Initialize upload managers\n this.uploader = vnode.attrs.uploader;\n\n // Current selected files\n this.selectedFiles = [];\n\n // Allow multiselect\n this.multiSelect = vnode.attrs.multiSelect || true;\n\n // Restrict file selection to specific types\n this.restrictFileType = vnode.attrs.restrictFileType || null;\n\n // Drag & drop\n this.dragDrop = null;\n\n // Initialize uploads\n this.onUpload();\n }\n\n className() {\n return 'Modal--large fof-file-manager-modal';\n }\n\n /**\n * Initialize drag & drop\n */\n oncreate(vnode) {\n super.oncreate(vnode);\n\n this.dragDrop = new DragAndDrop((files) => this.uploader.upload(files, false), this.$().find('.Modal-content')[0]);\n }\n\n /**\n * Remove events from modal content\n */\n onremove() {\n if (this.dragDrop) {\n this.dragDrop.unload();\n }\n }\n\n view() {\n const fileCount = this.selectedFiles.length;\n\n return (\n
    \n
    \n
    \n \n
    \n\n
    \n
    \n \n\n {app.translator.trans('fof-upload.forum.file_list.release_to_upload')}\n
    \n
    \n\n
    \n

    {app.translator.trans('fof-upload.forum.media_manager')}

    \n
    \n\n {this.alertAttrs && (\n
    \n \n
    \n )}\n\n
    \n \n
    \n\n
    \n \n\n 1)}\n className=\"Button Button--primary\"\n >\n {app.translator.trans('fof-upload.forum.file_list.confirm_selection_btn', { fileCount })}\n \n
    \n
    \n
    \n );\n }\n\n /**\n * Add or remove file from selected files\n *\n * @param {File} file\n */\n onFileSelect(file) {\n const itemPosition = this.selectedFiles.indexOf(file.id());\n\n if (itemPosition >= 0) {\n this.selectedFiles.splice(itemPosition, 1);\n } else {\n if (this.multiSelect) {\n this.selectedFiles.push(file.id());\n } else {\n this.selectedFiles = [file.id()];\n }\n }\n }\n\n /**\n * Add files to file list after upload\n */\n onUpload() {\n this.uploader.on('success', ({ file }) => {\n if (this.multiSelect) {\n this.selectedFiles.push(file.id());\n } else {\n this.selectedFiles = [file.id()];\n }\n });\n }\n\n /**\n * Add selected files to the composer\n */\n onSelect() {\n this.hide();\n\n // Custom callback\n if (this.attrs.onSelect) {\n this.attrs.onSelect(this.selectedFiles);\n\n return;\n }\n\n // Add selected files to composer\n this.selectedFiles.map((fileId) => {\n const file = app.store.getById('files', fileId);\n\n app.composer.editor.insertAtCursor(file.bbcode() + '\\n', false);\n });\n }\n}\n","import app from 'flarum/forum/app';\nimport Component from 'flarum/common/Component';\nimport Button from 'flarum/common/components/Button';\nimport FileManagerModal from './FileManagerModal';\nimport Tooltip from 'flarum/common/components/Tooltip';\n\nexport default class FileManagerButton extends Component {\n view() {\n return (\n \n {Button.component({\n className: 'Button fof-upload-button Button--icon',\n onclick: this.fileManagerButtonClicked.bind(this),\n icon: 'fas fa-photo-video',\n })}\n \n );\n }\n\n /**\n * Event handler for upload button being clicked\n *\n * @param {PointerEvent} e\n */\n fileManagerButtonClicked(e) {\n e.preventDefault();\n\n // Open dialog\n app.modal.show(FileManagerModal, {\n uploader: this.attrs.uploader,\n });\n }\n}\n","import app from 'flarum/forum/app';\nimport UserPage from 'flarum/forum/components/UserPage';\nimport UserFileList from './UserFileList';\n\nexport default class UploadsUserPage extends UserPage {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.user = null;\n\n this.loadUser(m.route.param('username'));\n }\n\n content() {\n if (app.session.user && (app.session.user.viewOthersMediaLibrary() || this.user === app.session.user)) {\n return (\n this.user &&\n UserFileList.component({\n user: this.user,\n selectable: false,\n downloadOnClick: true,\n })\n );\n } else {\n return null;\n }\n }\n\n show(user) {\n super.show(user);\n this.user = user;\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/models/User'];","import Uploader from '../handler/Uploader';\nimport DragAndDrop from './DragAndDrop';\nimport FileManagerButton from './FileManagerButton';\nimport FileManagerModal from './FileManagerModal';\nimport UserFileList from './UserFileList';\nimport UploadButton from './UploadButton';\n\nexport const components = {\n DragAndDrop,\n FileManagerButton,\n FileManagerModal,\n UserFileList,\n Uploader,\n UploadButton,\n};\n","import { extend } from 'flarum/common/extend';\nimport app from 'flarum/forum/app';\nimport UserPage from 'flarum/forum/components/UserPage';\nimport LinkButton from 'flarum/common/components/LinkButton';\n\nimport File from '../common/models/File';\nimport FileListState from './states/FileListState';\nimport downloadButtonInteraction from './downloadButtonInteraction';\nimport addUploadButton from './addUploadButton';\nimport UploadsUserPage from './components/UploadsUserPage';\nimport User from 'flarum/common/models/User';\nimport Model from 'flarum/common/Model';\n\nexport * from './components';\n\napp.initializers.add('fof-upload', () => {\n User.prototype.viewOthersMediaLibrary = Model.attribute('fof-upload-viewOthersMediaLibrary');\n User.prototype.deleteOthersMediaLibrary = Model.attribute('fof-upload-deleteOthersMediaLibrary');\n User.prototype.uploadCountCurrent = Model.attribute('fof-upload-uploadCountCurrent');\n User.prototype.uploadCountAll = Model.attribute('fof-upload-uploadCountAll');\n\n addUploadButton();\n downloadButtonInteraction();\n\n // File model\n app.store.models.files = File;\n\n // File list state\n app.fileListState = new FileListState();\n\n // Add user uploads to the user profile\n app.routes['user.uploads'] = {\n path: '/u/:username/uploads',\n component: UploadsUserPage,\n };\n\n // Add uploads to user page menu items\n extend(UserPage.prototype, 'navItems', function (items) {\n const canUpload = !!app.forum.attribute('fof-upload.canUpload');\n const hasUploads = !!this.user.uploadCountCurrent();\n\n if (app.session.user && (app.session.user.viewOthersMediaLibrary() || (this.user === app.session.user && (canUpload || hasUploads)))) {\n const uploadCount = this.user.uploadCountCurrent();\n\n items.add(\n 'uploads',\n LinkButton.component(\n {\n href: app.route('user.uploads', {\n username: this.user.username(),\n }),\n name: 'uploads',\n icon: 'fas fa-file-upload',\n },\n [\n this.user === app.session.user\n ? app.translator.trans('fof-upload.forum.buttons.media')\n : app.translator.trans('fof-upload.forum.buttons.user_uploads'),\n ' ',\n uploadCount > 0 ? {uploadCount} : '',\n ]\n ),\n 80\n );\n }\n });\n});\n","import app from 'flarum/forum/app';\nimport { extend } from 'flarum/common/extend';\nimport TextEditor from 'flarum/common/components/TextEditor';\nimport UploadButton from './components/UploadButton';\nimport DragAndDrop from './components/DragAndDrop';\nimport PasteClipboard from './components/PasteClipboard';\nimport Uploader from './handler/Uploader';\nimport FileManagerButton from './components/FileManagerButton';\n\nexport default function () {\n extend(TextEditor.prototype, 'oninit', function () {\n this.uploader = new Uploader();\n });\n extend(TextEditor.prototype, 'controlItems', function (items) {\n if (!app.forum.attribute('fof-upload.canUpload')) return;\n\n const composerButtonVisiblity = app.forum.attribute('fof-upload.composerButtonVisiblity');\n\n // Add media button\n if (composerButtonVisiblity === 'both' || composerButtonVisiblity === 'media-btn') {\n items.add(\n 'fof-upload-media',\n FileManagerButton.component({\n uploader: this.uploader,\n })\n );\n }\n\n // Add upload button\n if (composerButtonVisiblity === 'both' || composerButtonVisiblity === 'upload-btn') {\n items.add(\n 'fof-upload',\n UploadButton.component({\n uploader: this.uploader,\n })\n );\n }\n });\n\n extend(TextEditor.prototype, 'oncreate', function (f_, vnode) {\n if (!app.forum.attribute('fof-upload.canUpload')) return;\n\n this.uploader.on('success', ({ file, addBBcode }) => {\n if (!addBBcode) return;\n\n this.attrs.composer.editor.insertAtCursor(file.bbcode() + '\\n', false);\n\n // We wrap this in a typeof check to prevent it running when a user\n // is creating a new discussion. There's nothing to preview in a new\n // discussion, so the `preview` function isn't defined.\n if (typeof this.attrs.preview === 'function') {\n // Scroll the preview into view\n // preview() causes the composer to close on mobile, but we don't want that. We want only the scroll\n // We work around that by temporarily patching the isFullScreen method\n const originalIsFullScreen = app.composer.isFullScreen;\n\n app.composer.isFullScreen = () => false;\n\n this.attrs.preview();\n\n app.composer.isFullScreen = originalIsFullScreen;\n }\n });\n\n this.dragAndDrop = new DragAndDrop((files) => this.uploader.upload(files), this.$().parents('.Composer')[0]);\n\n new PasteClipboard((files) => this.uploader.upload(files), this.$('.TextEditor-editor')[0]);\n });\n\n extend(TextEditor.prototype, 'onremove', function (f_, vnode) {\n if (!app.forum.attribute('fof-upload.canUpload')) return;\n\n this.dragAndDrop.unload();\n });\n}\n","import app from 'flarum/forum/app';\nimport { extend } from 'flarum/common/extend';\nimport Post from 'flarum/forum/components/Post';\n\n/* global $ */\n\nexport default function () {\n extend(Post.prototype, 'oncreate', function () {\n this.$('[data-fof-upload-download-uuid]')\n .unbind('click')\n .on('click', (e) => {\n e.preventDefault();\n e.stopPropagation();\n\n if (!app.forum.attribute('fof-upload.canDownload')) {\n alert(app.translator.trans('fof-upload.forum.states.unauthorized'));\n return;\n }\n\n let url = app.forum.attribute('apiUrl') + '/fof/download';\n\n url += '/' + encodeURIComponent(e.currentTarget.dataset.fofUploadDownloadUuid);\n url += '/' + encodeURIComponent(this.attrs.post.id());\n url += '/' + encodeURIComponent(app.session.csrfToken);\n\n window.open(url);\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","__proto__","_inheritsLoose","subClass","superClass","create","constructor","File","apiEndpoint","this","exists","data","id","mixin","Model","baseName","path","url","type","size","humanSize","createdAt","uuid","tag","hidden","bbcode","FileListState","user","files","moreResults","loading","setUser","loadResults","offset","app","filter","page","then","parseResults","bind","loadMore","length","results","push","payload","links","next","m","redraw","addToList","Array","isArray","unshift","hasFiles","isLoading","hasMoreResults","empty","UploadButton","oninit","vnode","attrs","uploader","on","$","reset","isMediaUploadButton","view","buttonText","uploading","text","className","classList","icon","onclick","uploadButtonClicked","disabled","display","multiple","onchange","process","e","upload","click","Component","DragAndDrop","composerElement","handlers","supportsFileDragging","addEventListener","out","dropping","div","document","createElement","window","unload","removeEventListener","isNotFile","event","dataTransfer","items","i","kind","preventDefault","over","add","remove","PasteClipboard","element","paste","clipboardData","indexOf","getAsFile","Uploader","callbacks","success","failure","uploaded","callback","dispatch","response","forEach","addBBcode","body","FormData","append","method","serialize","raw","result","error","file","fileObj","image","archive","code","word","UserFileList","inModal","selectable","restrictFileType","downloadOnClick","filesBeingHidden","state","map","fileType","fileIcon","includes","fileSelectable","isSelectable","fileClassNames","selectedFiles","fileName","isFileHiding","hideFile","onFileClick","extractText","src","draggable","alt","role","class","onFileSelect","open","confirm","Alert","index","findIndex","splice","FileManagerModal","multiSelect","dragDrop","onUpload","oncreate","find","onremove","fileCount","fileListState","translator","trans","alertAttrs","hide","onSelect","itemPosition","fileId","store","getById","composer","editor","insertAtCursor","Modal","FileManagerButton","Button","fileManagerButtonClicked","UploadsUserPage","loadUser","route","param","content","component","show","UserPage","components","User","extend","TextEditor","composerButtonVisiblity","f_","preview","originalIsFullScreen","dragAndDrop","parents","Post","unbind","stopPropagation","encodeURIComponent","currentTarget","dataset","fofUploadDownloadUuid","post","alert","canUpload","hasUploads","uploadCountCurrent","uploadCount","LinkButton","href","username","name"],"sourceRoot":""} \ No newline at end of file