Updating minified JavaScript files
authorWoltLab <woltlab@woltlab.com>
Tue, 12 Apr 2022 12:39:44 +0000 (12:39 +0000)
committerWoltLab <woltlab@woltlab.com>
Tue, 12 Apr 2022 12:39:44 +0000 (12:39 +0000)
wcfsetup/install/files/js/WCF.Combined.min.js
wcfsetup/install/files/js/WCF.Combined.tiny.min.js

index 392a6ab58da1c2d22007b46d8bf52b2d19eb1b23..f481d79dfa0ecd893a4d5bc32a3ff7c08c0b84e9 100755 (executable)
@@ -28,7 +28,7 @@
 (function (window, undefined) { "use strict";WCF.ACL={},WCF.ACL.List=Class.extend({_categoryName:"",_container:null,_containerElements:{},_objectID:0,_objectTypeID:null,_options:{},_proxy:null,_search:null,_values:{group:{},user:{}},init:function(e,t,n,i,a,s,r){var c,l,o,h,p,d;this._objectID=i||0,this._objectTypeID=t,this._categoryName=n,void 0===a&&(a=!0),this._values={group:{},user:{}},this._aclValuesFieldName=r||"aclValues",this._proxy=new WCF.Action.Proxy({showLoadingOverlay:!1,success:$.proxy(this._success,this)}),this._container=$(e).hide().addClass("aclContainer"),c=this._container.children("dd"),l=$('<ul class="aclList containerList" />').appendTo(c),o=$('<input type="text" class="long" placeholder="'+WCF.Language.get("wcf.acl.search."+(a?"":"user.")+"description")+'" />').appendTo(c),h=$('<ul class="aclPermissionList containerList" />').hide().appendTo(c),elData(h[0],"grant",WCF.Language.get("wcf.acl.option.grant")),elData(h[0],"deny",WCF.Language.get("wcf.acl.option.deny")),this._containerElements={aclList:l,denyAll:null,grantAll:null,permissionList:h,searchInput:o},this._search=new WCF.Search.User(o,$.proxy(this.addObject,this),a),(p=this._container.parents("form:eq(0)")).submit($.proxy(this.submit,this)),(d=p.find("input[type=reset]:eq(0)")).length&&d.click($.proxy(this._reset,this)),s?this._success(s):this._loadACL()},_reset:function(){this._values={group:{},user:{}},this._containerElements.aclList.empty(),this._containerElements.searchInput.val(""),this._containerElements.permissionList.hide().find("input[type=checkbox]").prop("checked",!1)},_loadACL:function(){this._proxy.setOption("data",{actionName:"loadAll",className:"wcf\\data\\acl\\option\\ACLOptionAction",parameters:{categoryName:this._categoryName,objectID:this._objectID,objectTypeID:this._objectTypeID}}),this._proxy.sendRequest()},addObject:function(e){var t=this._createListItem(e.objectID,e.label,e.type);this._savePermissions(),this._containerElements.aclList.children("li").removeClass("active"),t.addClass("active"),this._search.addExcludedSearchValue(e.label),this._containerElements.permissionList.find("input[type=checkbox]").prop("checked",!1),this._containerElements.searchInput.val(""),this._containerElements.permissionList.show(),WCF.DOMNodeInsertedHandler.execute()},_createListItem:function(e,t,n){var i=$('<li><span class="icon icon16 fa-user'+("group"===n?"s":"")+'" /> <span class="aclLabel">'+t+"</span></li>").appendTo(this._containerElements.aclList);return i.data("objectID",e).data("type",n).data("label",t).click($.proxy(this._click,this)),$('<span class="icon icon16 fa-times jsTooltip pointer" title="'+WCF.Language.get("wcf.global.button.delete")+'" />').click($.proxy(this._removeItem,this)).appendTo(i),i},_removeItem:function(e){var t,n,i;this._savePermissions(),n=(t=$(e.currentTarget).parent()).data("type"),i=t.data("objectID"),this._search.removeExcludedSearchValue(t.data("label")),t.remove(),this._values[n][i]&&delete this._values[n][i],this._selectFirstEntry()},_selectFirstEntry:function(){var e=this._containerElements.aclList.children("li:eq(0)");e.length?this._select(e,!1):this._reset()},_success:function(e,t,n){var i,a,s,r,c,l,o,h,p,d,u;if($.getLength(e.returnValues.options)){for(s in i=0,a={},e.returnValues.options)r=e.returnValues.options[s],c=$("<li><span>"+r.label+"</span></li>").data("optionID",s).data("optionName",r.optionName),l=$('<input type="checkbox" id="grant'+s+'" />').appendTo(c).wrap('<label for="grant'+s+'" class="jsTooltip" title="'+WCF.Language.get("wcf.acl.option.grant")+'" />'),o=$('<input type="checkbox" id="deny'+s+'" />').appendTo(c).wrap('<label for="deny'+s+'" class="jsTooltip" title="'+WCF.Language.get("wcf.acl.option.deny")+'" />'),l.data("type","grant").data("optionID",s).change($.proxy(this._change,this)),o.data("type","deny").data("optionID",s).change($.proxy(this._change,this)),a[r.categoryName]||(a[r.categoryName]=[]),""===r.categoryName?c.appendTo(this._containerElements.permissionList):a[r.categoryName].push(c),i++;if(i>1&&(c=$('<li class="aclFullAccess"><span>'+WCF.Language.get("wcf.acl.option.fullAccess")+"</span></li>").prependTo(this._containerElements.permissionList),this._containerElements.grantAll=$('<input type="checkbox" id="grantAll_'+this._container.attr("id")+'" />').appendTo(c).wrap('<label class="jsTooltip" title="'+WCF.Language.get("wcf.acl.option.grant")+'" />'),this._containerElements.denyAll=$('<input type="checkbox" id="denyAll_'+this._container.attr("id")+'" />').appendTo(c).wrap('<label class="jsTooltip" title="'+WCF.Language.get("wcf.acl.option.deny")+'" />'),this._containerElements.grantAll.data("type","grant").change($.proxy(this._changeAll,this)),this._containerElements.denyAll.data("type","deny").change($.proxy(this._changeAll,this))),$.getLength(a))for(h in a)for(p=a[h],e.returnValues.categories[h]&&$('<li class="aclCategory">'+e.returnValues.categories[h]+"</li>").appendTo(this._containerElements.permissionList),d=0,u=p.length;d<u;d++)p[d].appendTo(this._containerElements.permissionList);this._parseData(e,"group"),this._parseData(e,"user"),this._container.show(),require(["WoltLabSuite/Core/Form/Builder/Field/Dependency/Manager"],(function(e){e.checkDependencies()})),this._selectFirstEntry()}},_parseData:function(e,t){if($.getLength(e.returnValues[t].option)){for(var n in e.returnValues[t].label)this._createListItem(n,e.returnValues[t].label[n],t),this._search.addExcludedSearchValue(e.returnValues[t].label[n]);this._values[t]=e.returnValues[t].option,WCF.DOMNodeInsertedHandler.execute()}},_click:function(e){var t=$(e.currentTarget);t.hasClass("active")||this._select(t,!0)},_select:function(e,t){t&&this._savePermissions(),this._containerElements.aclList.children("li").removeClass("active"),e.addClass("active"),this._setupPermissions(e.data("type"),e.data("objectID"))},_change:function(e){var t,n=$(e.currentTarget),i=n.data("optionID"),a=n.data("type");n.is(":checked")?"deny"===a?($("#grant"+i).prop("checked",!1),null!==this._containerElements.grantAll&&this._containerElements.grantAll.prop("checked",!1)):($("#deny"+i).prop("checked",!1),null!==this._containerElements.denyAll&&this._containerElements.denyAll.prop("checked",!1)):"deny"===a&&null!==this._containerElements.denyAll?this._containerElements.denyAll.prop("checked",!1):"grant"===a&&null!==this._containerElements.grantAll&&this._containerElements.grantAll.prop("checked",!1),t=!0,this._containerElements.permissionList.find("input[type=checkbox]").each($.proxy((function(e,n){var i=$(n);if(i.data("type")===a&&i.attr("id")!==a+"All_"+this._container.attr("id")&&!i.is(":checked"))return t=!1,!1}),this)),"deny"==a?null!==this._containerElements.denyAll&&(t?this._containerElements.denyAll.prop("checked",!0):this._containerElements.denyAll.prop("checked",!1)):null!==this._containerElements.grantAll&&(t?this._containerElements.grantAll.prop("checked",!0):this._containerElements.grantAll.prop("checked",!1))},_changeAll:function(e){var t=$(e.currentTarget),n=t.data("type");t.is(":checked")?"deny"===n?(this._containerElements.grantAll.prop("checked",!1),this._containerElements.permissionList.find("input[type=checkbox]").each($.proxy((function(e,t){var n=$(t);"deny"===n.data("type")&&n.attr("id")!=="denyAll_"+this._container.attr("id")&&n.prop("checked",!0).trigger("change")}),this))):(this._containerElements.denyAll.prop("checked",!1),this._containerElements.permissionList.find("input[type=checkbox]").each($.proxy((function(e,t){var n=$(t);"grant"===n.data("type")&&n.attr("id")!=="grantAll_"+this._container.attr("id")&&n.prop("checked",!0).trigger("change")}),this))):"deny"===n?(this._containerElements.grantAll.prop("checked",!1),this._containerElements.permissionList.find("input[type=checkbox]").each($.proxy((function(e,t){var n=$(t);"deny"===n.data("type")&&n.attr("id")!=="denyAll_"+this._container.attr("id")&&n.prop("checked",!1).trigger("change")}),this))):(this._containerElements.denyAll.prop("checked",!1),this._containerElements.permissionList.find("input[type=checkbox]").each($.proxy((function(e,t){var n=$(t);"grant"===n.data("type")&&n.attr("id")!=="grantAll_"+this._container.attr("id")&&n.prop("checked",!1).trigger("change")}),this)))},_setupPermissions:function(e,t){if(this._containerElements.permissionList.find("input[type='checkbox']").prop("checked",!1),this._values[e]&&this._values[e][t])for(var n in this._values[e][t])1==this._values[e][t][n]?$("#grant"+n).prop("checked",!0).trigger("change"):$("#deny"+n).prop("checked",!0).trigger("change");this._containerElements.permissionList.show()},_savePermissions:function(){var e,t,n=this._containerElements.aclList.find("li.active");n.length&&(e=n.data("objectID"),t=n.data("type"),this._values[t][e]={},this._containerElements.permissionList.find("input[type='checkbox']").each(function(n,i){var a,s,r=$(i);r.attr("id")!="grantAll_"+this._container.attr("id")&&r.attr("id")!="denyAll_"+this._container.attr("id")&&(a="deny"===r.data("type")?0:1,s=r.data("optionID"),r.is(":checked")?(this._values[t][e][s]=a,r.prop("checked",!1)):this._values[t]&&this._values[t][e]&&this._values[t][e][s]&&this._values[t][e][s]==a&&delete this._values[t][e][s])}.bind(this)))},submit:function(e){this._savePermissions(),this._save("group"),this._save("user")},_save:function(e){var t,n,i,a;if($.getLength(this._values[e]))for(n in t=this._container.parents("form:eq(0)"),this._values[e])for(a in i=this._values[e][n])$('<input type="hidden" name="'+this._aclValuesFieldName+"["+e+"]["+n+"]["+a+']" value="'+i[a]+'" />').appendTo(t)},getData:function(){return this._savePermissions(),this._values}}); })(this);
 
 // WCF.Attachment.js
-(function (window, undefined) { "use strict";WCF.Attachment={},WCF.Attachment.Upload=WCF.Upload.extend({_autoInsert:[],_insertAllButton:null,_objectType:"",_objectID:0,_tmpHash:"",_parentObjectID:0,_editorId:"",_replaceOnLoad:{},_options:{},init:function(t,e,i,a,s,n,r,l,o){var c,d;if(this._super(t,e,"wcf\\data\\attachment\\AttachmentAction",{multiple:!0,maxUploads:r}),this._autoInsert=[],this._objectType=i,this._objectID=parseInt(a),this._tmpHash=s,this._parentObjectID=parseInt(n),this._editorId=l,this._options=$.extend(!0,this._options,o||{}),this._buttonSelector.children("p.button").click($.proxy(this._validateLimit,this)),this._fileListSelector.find(".jsButtonInsertAttachment").click($.proxy(this._insert,this)),this._fileListSelector.find(".jsButtonAttachmentInsertThumbnail").click($.proxy(this._insert,this)),this._fileListSelector.find(".jsButtonAttachmentInsertFull").click($.proxy(this._insert,this)),WCF.System.Event.addListener("com.woltlab.wcf.action.delete","attachment",this._onDelete.bind(this)),this._makeSortable(),this._insertAllButton=$('<p class="button jsButtonAttachmentInsertAll">'+WCF.Language.get("wcf.attachment.insertAll")+"</p>").hide(),this._editorId){this._insertAllButton.appendTo(this._buttonSelector),this._insertAllButton.click($.proxy(this._insertAll,this)),this._fileListSelector.children("li:not(.uploadFailed)").length&&this._insertAllButton.show(),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","submit_"+this._editorId,this._submitInline.bind(this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","reset_"+this._editorId,this._reset.bind(this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","dragAndDrop_"+this._editorId,this._editorUpload.bind(this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","pasteFromClipboard_"+this._editorId,this._editorUpload.bind(this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","autosaveMetaData_"+this._editorId,function(t){t.tmpHashes&&Array.isArray(t.tmpHashes)||(t.tmpHashes=[]),t.tmpHashes=t.tmpHashes.filter((t=>t!==s)),this._fileListSelector.children("li:not(.uploadFailed)").length>0&&t.tmpHashes.push(s)}.bind(this));const t=this._fileListSelector[0].closest("form");if(t){const e={};t.dataset.attachmentTmpHashes="",WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","getMetaData_"+this._editorId,e),e.tmpHashes&&Array.isArray(e.tmpHashes)&&e.tmpHashes.length>0&&(t.dataset.attachmentTmpHashes=e.tmpHashes.join(",")),t.addEventListener("submit",(e=>{let i=this._tmpHash;t.dataset.attachmentTmpHashes&&(i+=`,${t.dataset.attachmentTmpHashes}`);const a=t.querySelector('input[name="tmpHash"]');a&&(a.value=i)}))}c=WCF.System.Event.addListener("com.woltlab.wcf.redactor2","metacode_attach_"+this._editorId,function(t){var e,i,a,s,n,r=this._getImageAttachments(),l=t.attributes[0]||0;r.hasOwnProperty(l)&&(e=~~$("#"+this._editorId).data("redactor").opts.woltlab.attachmentThumbnailWidth,i=!0===(i=t.attributes[2])||"true"===i||~~i&&~~i<=e,(a=elCreate("img")).className="woltlabAttachment",a.src=r[l][i?"thumbnailUrl":"url"],elData(a,"attachment-id",l),"left"===(s=t.attributes[1]||"none")?a.classList.add("messageFloatObjectLeft"):"right"===s&&a.classList.add("messageFloatObjectRight"),(n=t.metacode).parentNode.insertBefore(a,n),elRemove(n),t.cancel=!0)}.bind(this)),d=WCF.System.Event.addListener("com.woltlab.wcf.redactor2","sync_"+this._tmpHash,this._sync.bind(this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","destroy_"+this._editorId,function(){WCF.System.Event.removeAllListeners("com.woltlab.wcf.redactor2","submit_"+this._editorId),WCF.System.Event.removeAllListeners("com.woltlab.wcf.redactor2","reset_"+this._editorId),WCF.System.Event.removeAllListeners("com.woltlab.wcf.redactor2","insertAttachment_"+this._editorId),WCF.System.Event.removeAllListeners("com.woltlab.wcf.redactor2","dragAndDrop_"+this._editorId),WCF.System.Event.removeAllListeners("com.woltlab.wcf.redactor2","pasteFromClipboard_"+this._editorId),WCF.System.Event.removeAllListeners("com.woltlab.wcf.redactor2","autosaveMetaData_"+this._editorId),WCF.System.Event.removeListener("com.woltlab.wcf.redactor2","metacode_attach_"+this._editorId,c),WCF.System.Event.removeListener("com.woltlab.wcf.redactor2","sync_"+this._tmpHash,d)}.bind(this))}},_editorUpload:function(t){var e,i=null;this._fileListSelector.closest(".messageTabMenu").messageTabMenu("showTab","attachments",!0),e=function(e){null===i?this._autoInsert.push(e):this._replaceOnLoad[e]=i,t.uploadID=e}.bind(this),t.file?this._upload(void 0,t.file,void 0,e):(this._upload(void 0,void 0,t.blob,e),i=t.replace||null)},_getImageAttachments:function(){var t={};return this._fileListSelector.children("li").each((function(e,i){var a=$(i);a.data("isImage")&&(t[~~a.data("objectID")]={thumbnailUrl:a.find(".jsButtonAttachmentInsertThumbnail").data("url"),url:a.find(".jsButtonAttachmentInsertFull").data("url")})})),t},_submitInline:function(t){if(this._tmpHash){t.tmpHash=this._tmpHash;var e={};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","getMetaData_"+this._editorId,e),e.tmpHashes&&Array.isArray(e.tmpHashes)&&e.tmpHashes.length>0&&(t.tmpHash+=","+e.tmpHashes.join(","))}},_reset:function(){this._fileListSelector.hide().empty(),this._insertAllButton.hide(),this._validateLimit()},_validateLimit:function(){var t,e=this._buttonSelector.next("small.innerError"),i=this._options.maxUploads-this._fileListSelector.children("li:not(.uploadFailed)").length,a=this._fileUpload?this._fileUpload.prop("files").length:0;return i<=0||i<a?(t=i<=0?WCF.Language.get("wcf.attachment.upload.error.reachedLimit"):WCF.Language.get("wcf.attachment.upload.error.reachedRemainingLimit").replace(/#remaining#/,i),e.length||(e=$('<small class="innerError" />').insertAfter(this._buttonSelector)),e.html(t),!1):(e.remove(),!0)},_removeLimitError:function(t){var e=this._fileListSelector.children("li");e.filter(":not(.uploadFailed)").length||this._insertAllButton.hide(),e.length||this._fileListSelector.hide(),this._editorId&&t.button&&WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","deleteAttachment_"+this._editorId,{attachmentId:t.button.data("objectID")})},_upload:function(t,e,i,a){var s=this._super.bind(this);require(["WoltLabSuite/Core/FileUtil","WoltLabSuite/Core/Image/ImageUtil","WoltLabSuite/Core/Image/Resizer","WoltLabSuite/Core/Ajax/Status"],function(n,r,l,o){var c,d,h,m;o.show(),c=[],e?c.push(e):i?c.push(n.blobToFile(i,"pasted-from-clipboard")):c=this._fileUpload.prop("files"),d=Promise.resolve(c),this._options.autoScale&&this._options.autoScale.enable&&(h=this._buttonSelector.data("maxSize"),m=new l,d=Array.prototype.reduce.call(c,function(t,e){return t.then(function(t){var i,a;return-1===["image/png","image/jpeg","image/webp"].indexOf(e.type)?(t.push(e),t):(i=new Promise((function(t,i){setTimeout((function(){t(e)}),1e4)})),a=m.loadFile(e).then(function(t){var a,s,n=t.exif,l=this._options.autoScale.maxWidth,o=this._options.autoScale.maxHeight,c=this._options.autoScale.quality;return window.devicePixelRatio>=2&&(a=window.screen.width*window.devicePixelRatio,s=window.screen.height*window.devicePixelRatio,a-10<t.image.width&&t.image.width<a+10&&s-10<t.image.height&&(l=Math.min(l,window.screen.width))),m.resize(t.image,l,o,c,e.size>h,i).then(function(t){if(void 0===t)return e;var i=this._options.autoScale.fileType;return("keep"===this._options.autoScale.fileType||r.containsTransparentPixels(t))&&(i=e.type),m.saveFile({exif:n,image:t},e.name,i,c)}.bind(this)).then((function(t){return t.size>e.size?(console.debug('[WCF.Attachment] File size of "'+e.name+'" increased, uploading untouched image.'),e):t}))}.bind(this)).catch((function(t){return console.debug('[WCF.Attachment] Failed to resize image "'+e.name+'":',t),e})),Promise.race([i,a]).then((function(e){return t.push(e),t})))}.bind(this))}.bind(this),Promise.resolve([]))),d.then(function(e){var i=void 0;return this._validateLimit()&&(i=s(t,void 0,void 0,e)),this._fileUpload&&(this._removeButton(),this._createButton()),"function"==typeof a&&a(i),i}.bind(this)).catch((function(t){console.debug("[WCF.Attachment] Failed to upload attachments:",t)})).finally(o.hide)}.bind(this),(function(t){console.debug("[WCF.Attachment] Failed to load modules:",t)}))},_createUploadMatrix:function(t){return this._fileListSelector.children("li.uploadFailed").remove(),this._super(t)},_getParameters:function(){return{objectType:this._objectType,objectID:this._objectID,tmpHash:this._tmpHash,parentObjectID:this._parentObjectID}},_initFile:function(t){var e=$('<li class="box64 formAttachmentListItem"><span class="icon icon64 fa-spinner" /><div><div><p>'+WCF.String.escapeHTML(t.name)+'</p><small><progress max="100"></progress></small></div><ul></ul></div></li>').data("filename",t.name);return this._fileListSelector.append(e),this._fileListSelector.show(),this._buttonSelector.data("maxSize")<t.size&&(e.find("progress").remove(),e.children(".fa-spinner").removeClass("fa-spinner").addClass("fa-ban"),e.find("div > div").append($('<small class="innerError">'+WCF.Language.get("wcf.attachment.upload.error.tooLarge")+"</small>")),e.addClass("uploadFailed")),e},_useThumbnail:function(){return!0},_success:function(t,e){var i,a,s,n,r,l,o,c,d,h,m,u;for(a in this._uploadMatrix[t])this._uploadMatrix[t].hasOwnProperty(a)&&((s=this._uploadMatrix[t][a]).find("progress").remove(),n=s.data("filename"),r=s.data("internalFileID"),e.returnValues&&e.returnValues.attachments[r]?(i=e.returnValues.attachments[r],elData(s[0],"object-id",i.attachmentID),s.addClass("jsObjectActionObject"),i.tinyURL?(s.children(".fa-spinner").replaceWith($('<img src="'+i.tinyURL+'" alt="" class="attachmentTinyThumbnail" />')),s.data("height",i.height),s.data("width",i.width),elData(s[0],"is-image",i.isImage)):s.children(".fa-spinner").removeClass("fa-spinner").addClass("fa-"+i.iconName),(l=$('<a href=""></a>')).text(n).attr("href",i.url),l[0].target="_blank",0!=i.isImage&&l.addClass("jsImageViewer").attr("title",n),s.find("p").empty().append(l),s.find("small").append(i.formattedFilesize),o=s.find("ul").addClass("buttonGroup"),c=$('<li><span class="button small jsObjectAction" data-object-action="delete" data-confirm-message="'+WCF.Language.get("wcf.attachment.delete.sure")+'" data-event-name="attachment">'+WCF.Language.get("wcf.global.button.delete")+"</span></li>"),o.append(c),s.data("objectID",i.attachmentID),this._editorId&&(i.tinyURL?(i.thumbnailURL&&$('<li><span class="button small jsButtonAttachmentInsertThumbnail" data-object-id="'+i.attachmentID+'" data-url="'+WCF.String.escapeHTML(i.thumbnailURL)+'">'+WCF.Language.get("wcf.attachment.insertThumbnail")+"</span></li>").appendTo(o),$('<li><span class="button small jsButtonAttachmentInsertFull" data-object-id="'+i.attachmentID+'" data-url="'+WCF.String.escapeHTML(i.url)+'">'+WCF.Language.get("wcf.attachment.insertFull")+"</span></li>").appendTo(o)):$('<li><span class="button small jsButtonAttachmentInsertPlain" data-object-id="'+i.attachmentID+'">'+WCF.Language.get("wcf.attachment.insert")+"</span></li>").appendTo(o)),this._triggerSync("new",{html:s[0].outerHTML}),this._registerEditorButtons(s[0]),this._replaceOnLoad.hasOwnProperty(t)&&(s.hasClass("uploadFailed")||(d=this._replaceOnLoad[t])&&d.parentNode&&WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","replaceAttachment_"+this._editorId,{attachmentId:i.attachmentID,img:d,src:i.thumbnailURL?i.thumbnailURL:i.url}),this._replaceOnLoad[t]=null)):(s.children(".fa-spinner").removeClass("fa-spinner").addClass("fa-ban"),h="",e.returnValues&&e.returnValues.errors[r]?"uploadFailed"===(h=(m=e.returnValues.errors[r]).errorType)&&m.additionalData.phpLimitExceeded&&(h="uploadPhpLimit"):h="uploadFailed",s.find("div > div").append($('<small class="innerError">'+WCF.Language.get("wcf.attachment.upload.error."+h)+"</small>")),s.addClass("uploadFailed")),WCF.inArray(t,this._autoInsert)&&(this._autoInsert.splice(this._autoInsert.indexOf(t),1),s.hasClass("uploadFailed")||((u=s.find(".jsButtonAttachmentInsertThumbnail")).length||(u=s.find(".jsButtonAttachmentInsertFull")),u.trigger("click"))));this._rebuildInterface()},_rebuildInterface:function(){this._makeSortable(),this._fileListSelector.children("li:not(.uploadFailed)").length?this._insertAllButton.show():this._insertAllButton.hide(),WCF.DOMNodeInsertedHandler.execute()},_registerEditorButtons:function(t){this._editorId&&elBySelAll(".jsButtonAttachmentInsertThumbnail, .jsButtonAttachmentInsertFull, .jsButtonAttachmentInsertPlain",t,function(t){t.addEventListener("click",this._insert.bind(this))}.bind(this))},_insert:function(t){WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","insertAttachment_"+this._editorId,{attachmentId:elData(t.currentTarget,"object-id"),url:elData(t.currentTarget,"url")})},_insertAll:function(){var t,e,i,a;for(i=0,a=this._fileListSelector[0].childNodes.length;i<a;i++)"LI"!==(t=this._fileListSelector[0].childNodes[i]).nodeName||t.classList.contains("uploadFailed")||(null===(e=elBySel(".jsButtonAttachmentInsertThumbnail, .jsButtonAttachmentInsertPlain",t))&&(e=elBySel(".jsButtonAttachmentInsertFull, .jsButtonAttachmentInsertPlain",t)),window.jQuery(e).trigger("click"))},_error:function(t){this._fileListSelector.find("li").each((function(e,i){var a=$(i);a.children(".fa-spinner").length&&(a.addClass("uploadFailed").children(".fa-spinner").removeClass("fa-spinner").addClass("fa-ban"),a.find("div > div").append($('<small class="innerError">'+(t.responseJSON&&t.responseJSON.message?t.responseJSON.message:WCF.Language.get("wcf.attachment.upload.error.uploadFailed"))+"</small>")))}))},_makeSortable:function(){var t=this._fileListSelector.children("li:not(.uploadFailed)");t.length&&(t.addClass("sortableAttachment").children("img").addClass("sortableNode"),this._fileListSelector.hasClass("sortableList")||(this._fileListSelector.addClass("sortableList"),require(["Environment"],function(t){"desktop"===t.platform()&&new WCF.Sortable.List(this._fileListSelector.parent().wcfIdentify(),"",0,{axis:!1,items:"li.sortableAttachment",toleranceElement:null,start:function(t,e){e.placeholder[0].style.setProperty("height",e.helper[0].offsetHeight+"px","")},update:function(){var t=[];this._fileListSelector.children("li:not(.uploadFailed)").each((function(e,i){t.push($(i).data("objectID"))})),t.length&&new WCF.Action.Proxy({autoSend:!0,data:{actionName:"updatePosition",className:"wcf\\data\\attachment\\AttachmentAction",parameters:{attachmentIDs:t,objectID:this._objectID,objectType:this._objectType,tmpHash:this._tmpHash}}})}.bind(this)},!0)}.bind(this))))},_onDelete:function(t){var e=elData(t.button[0],"object-id"),i=elBySel('.formAttachmentListItem[data-object-id="'+e+'"]',this._fileListSelector[0]);null!==i&&elRemove(i),this._removeLimitError(t)},_sync:function(t){if(t.source!==this){if("new"!==t.type)throw new Error("Unexpected type '"+t.type+"'");this._syncNew(t.data)}},_syncNew:function(t){require(["Dom/Util"],function(e){var i=e.createFragmentFromHtml(t.html),a=elBySel("li",i);a.id="",this._registerEditorButtons(a),this._fileListSelector[0].appendChild(a),elShow(this._fileListSelector[0]),this._rebuildInterface()}.bind(this))},_triggerSync:function(t,e){WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","sync_"+this._tmpHash,{source:this,type:t,data:e})}}); })(this);
+(function (window, undefined) { "use strict";WCF.Attachment={},WCF.Attachment.Upload=WCF.Upload.extend({_autoInsert:[],_insertAllButton:null,_objectType:"",_objectID:0,_tmpHash:"",_parentObjectID:0,_editorId:"",_replaceOnLoad:{},_options:{},init:function(t,e,i,a,s,n,r,l,o){var c,d;if(this._super(t,e,"wcf\\data\\attachment\\AttachmentAction",{multiple:!0,maxUploads:r}),this._autoInsert=[],this._objectType=i,this._objectID=parseInt(a),this._tmpHash=s,this._parentObjectID=parseInt(n),this._editorId=l,this._options=$.extend(!0,this._options,o||{}),this._buttonSelector.children("p.button").click($.proxy(this._validateLimit,this)),this._fileListSelector.find(".jsButtonInsertAttachment").click($.proxy(this._insert,this)),this._fileListSelector.find(".jsButtonAttachmentInsertThumbnail").click($.proxy(this._insert,this)),this._fileListSelector.find(".jsButtonAttachmentInsertFull").click($.proxy(this._insert,this)),WCF.System.Event.addListener("WoltLabSuite/Core/Ui/Object/Action","delete",(t=>this._onDelete(t))),this._makeSortable(),this._insertAllButton=$('<p class="button jsButtonAttachmentInsertAll">'+WCF.Language.get("wcf.attachment.insertAll")+"</p>").hide(),this._editorId){this._insertAllButton.appendTo(this._buttonSelector),this._insertAllButton.click($.proxy(this._insertAll,this)),this._fileListSelector.children("li:not(.uploadFailed)").length&&this._insertAllButton.show(),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","submit_"+this._editorId,this._submitInline.bind(this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","reset_"+this._editorId,this._reset.bind(this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","dragAndDrop_"+this._editorId,this._editorUpload.bind(this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","pasteFromClipboard_"+this._editorId,this._editorUpload.bind(this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","autosaveMetaData_"+this._editorId,function(t){t.tmpHashes&&Array.isArray(t.tmpHashes)||(t.tmpHashes=[]),t.tmpHashes=t.tmpHashes.filter((t=>t!==s)),this._fileListSelector.children("li:not(.uploadFailed)").length>0&&t.tmpHashes.push(s)}.bind(this));const t=this._fileListSelector[0].closest("form");if(t){const e={};t.dataset.attachmentTmpHashes="",WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","getMetaData_"+this._editorId,e),e.tmpHashes&&Array.isArray(e.tmpHashes)&&e.tmpHashes.length>0&&(t.dataset.attachmentTmpHashes=e.tmpHashes.join(",")),t.addEventListener("submit",(e=>{let i=this._tmpHash;t.dataset.attachmentTmpHashes&&(i+=`,${t.dataset.attachmentTmpHashes}`);const a=t.querySelector('input[name="tmpHash"]');a&&(a.value=i)}))}c=WCF.System.Event.addListener("com.woltlab.wcf.redactor2","metacode_attach_"+this._editorId,function(t){var e,i,a,s,n,r=this._getImageAttachments(),l=t.attributes[0]||0;r.hasOwnProperty(l)&&(e=~~$("#"+this._editorId).data("redactor").opts.woltlab.attachmentThumbnailWidth,i=!0===(i=t.attributes[2])||"true"===i||~~i&&~~i<=e,(a=elCreate("img")).className="woltlabAttachment",a.src=r[l][i?"thumbnailUrl":"url"],elData(a,"attachment-id",l),"left"===(s=t.attributes[1]||"none")?a.classList.add("messageFloatObjectLeft"):"right"===s&&a.classList.add("messageFloatObjectRight"),(n=t.metacode).parentNode.insertBefore(a,n),elRemove(n),t.cancel=!0)}.bind(this)),d=WCF.System.Event.addListener("com.woltlab.wcf.redactor2","sync_"+this._tmpHash,this._sync.bind(this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","destroy_"+this._editorId,function(){WCF.System.Event.removeAllListeners("com.woltlab.wcf.redactor2","submit_"+this._editorId),WCF.System.Event.removeAllListeners("com.woltlab.wcf.redactor2","reset_"+this._editorId),WCF.System.Event.removeAllListeners("com.woltlab.wcf.redactor2","insertAttachment_"+this._editorId),WCF.System.Event.removeAllListeners("com.woltlab.wcf.redactor2","dragAndDrop_"+this._editorId),WCF.System.Event.removeAllListeners("com.woltlab.wcf.redactor2","pasteFromClipboard_"+this._editorId),WCF.System.Event.removeAllListeners("com.woltlab.wcf.redactor2","autosaveMetaData_"+this._editorId),WCF.System.Event.removeListener("com.woltlab.wcf.redactor2","metacode_attach_"+this._editorId,c),WCF.System.Event.removeListener("com.woltlab.wcf.redactor2","sync_"+this._tmpHash,d)}.bind(this))}},_editorUpload:function(t){var e,i=null;this._fileListSelector.closest(".messageTabMenu").messageTabMenu("showTab","attachments",!0),e=function(e){null===i?this._autoInsert.push(e):this._replaceOnLoad[e]=i,t.uploadID=e}.bind(this),t.file?this._upload(void 0,t.file,void 0,e):(this._upload(void 0,void 0,t.blob,e),i=t.replace||null)},_getImageAttachments:function(){var t={};return this._fileListSelector.children("li").each((function(e,i){var a=$(i);a.data("isImage")&&(t[~~a.data("objectID")]={thumbnailUrl:a.find(".jsButtonAttachmentInsertThumbnail").data("url"),url:a.find(".jsButtonAttachmentInsertFull").data("url")})})),t},_submitInline:function(t){if(this._tmpHash){t.tmpHash=this._tmpHash;var e={};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","getMetaData_"+this._editorId,e),e.tmpHashes&&Array.isArray(e.tmpHashes)&&e.tmpHashes.length>0&&(t.tmpHash+=","+e.tmpHashes.join(","))}},_reset:function(){this._fileListSelector.hide().empty(),this._insertAllButton.hide(),this._validateLimit()},_validateLimit:function(){var t,e=this._buttonSelector.next("small.innerError"),i=this._options.maxUploads-this._fileListSelector.children("li:not(.uploadFailed)").length,a=this._fileUpload?this._fileUpload.prop("files").length:0;return i<=0||i<a?(t=i<=0?WCF.Language.get("wcf.attachment.upload.error.reachedLimit"):WCF.Language.get("wcf.attachment.upload.error.reachedRemainingLimit").replace(/#remaining#/,i),e.length||(e=$('<small class="innerError" />').insertAfter(this._buttonSelector)),e.html(t),!1):(e.remove(),!0)},_removeLimitError:function(t){var e=this._fileListSelector.children("li");e.filter(":not(.uploadFailed)").length||this._insertAllButton.hide(),e.length||this._fileListSelector.hide(),this._editorId&&t.button&&WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","deleteAttachment_"+this._editorId,{attachmentId:t.button.data("objectID")})},_upload:function(t,e,i,a){var s=this._super.bind(this);require(["WoltLabSuite/Core/FileUtil","WoltLabSuite/Core/Image/ImageUtil","WoltLabSuite/Core/Image/Resizer","WoltLabSuite/Core/Ajax/Status"],function(n,r,l,o){var c,d,h,m;o.show(),c=[],e?c.push(e):i?c.push(n.blobToFile(i,"pasted-from-clipboard")):c=this._fileUpload.prop("files"),d=Promise.resolve(c),this._options.autoScale&&this._options.autoScale.enable&&(h=this._buttonSelector.data("maxSize"),m=new l,d=Array.prototype.reduce.call(c,function(t,e){return t.then(function(t){var i,a;return-1===["image/png","image/jpeg","image/webp"].indexOf(e.type)?(t.push(e),t):(i=new Promise((function(t,i){setTimeout((function(){t(e)}),1e4)})),a=m.loadFile(e).then(function(t){var a,s,n=t.exif,l=this._options.autoScale.maxWidth,o=this._options.autoScale.maxHeight,c=this._options.autoScale.quality;return window.devicePixelRatio>=2&&(a=window.screen.width*window.devicePixelRatio,s=window.screen.height*window.devicePixelRatio,a-10<t.image.width&&t.image.width<a+10&&s-10<t.image.height&&(l=Math.min(l,window.screen.width))),m.resize(t.image,l,o,c,e.size>h,i).then(function(t){if(void 0===t)return e;var i=this._options.autoScale.fileType;return("keep"===this._options.autoScale.fileType||r.containsTransparentPixels(t))&&(i=e.type),m.saveFile({exif:n,image:t},e.name,i,c)}.bind(this)).then((function(t){return t.size>e.size?(console.debug('[WCF.Attachment] File size of "'+e.name+'" increased, uploading untouched image.'),e):t}))}.bind(this)).catch((function(t){return console.debug('[WCF.Attachment] Failed to resize image "'+e.name+'":',t),e})),Promise.race([i,a]).then((function(e){return t.push(e),t})))}.bind(this))}.bind(this),Promise.resolve([]))),d.then(function(e){var i=void 0;return this._validateLimit()&&(i=s(t,void 0,void 0,e)),this._fileUpload&&(this._removeButton(),this._createButton()),"function"==typeof a&&a(i),i}.bind(this)).catch((function(t){console.debug("[WCF.Attachment] Failed to upload attachments:",t)})).finally(o.hide)}.bind(this),(function(t){console.debug("[WCF.Attachment] Failed to load modules:",t)}))},_createUploadMatrix:function(t){return this._fileListSelector.children("li.uploadFailed").remove(),this._super(t)},_getParameters:function(){return{objectType:this._objectType,objectID:this._objectID,tmpHash:this._tmpHash,parentObjectID:this._parentObjectID}},_initFile:function(t){var e=$('<li class="box64 formAttachmentListItem"><span class="icon icon64 fa-spinner" /><div><div><p>'+WCF.String.escapeHTML(t.name)+'</p><small><progress max="100"></progress></small></div><ul></ul></div></li>').data("filename",t.name);return this._fileListSelector.append(e),this._fileListSelector.show(),this._buttonSelector.data("maxSize")<t.size&&(e.find("progress").remove(),e.children(".fa-spinner").removeClass("fa-spinner").addClass("fa-ban"),e.find("div > div").append($('<small class="innerError">'+WCF.Language.get("wcf.attachment.upload.error.tooLarge")+"</small>")),e.addClass("uploadFailed")),e},_useThumbnail:function(){return!0},_success:function(t,e){var i,a,s,n,r,l,o,c,d,h,m,u;for(a in this._uploadMatrix[t])this._uploadMatrix[t].hasOwnProperty(a)&&((s=this._uploadMatrix[t][a]).find("progress").remove(),n=s.data("filename"),r=s.data("internalFileID"),e.returnValues&&e.returnValues.attachments[r]?(i=e.returnValues.attachments[r],elData(s[0],"object-id",i.attachmentID),s.addClass("jsObjectActionObject"),i.tinyURL?(s.children(".fa-spinner").replaceWith($('<img src="'+i.tinyURL+'" alt="" class="attachmentTinyThumbnail" />')),s.data("height",i.height),s.data("width",i.width),elData(s[0],"is-image",i.isImage)):s.children(".fa-spinner").removeClass("fa-spinner").addClass("fa-"+i.iconName),(l=$('<a href=""></a>')).text(n).attr("href",i.url),l[0].target="_blank",0!=i.isImage&&l.addClass("jsImageViewer").attr("title",n),s.find("p").empty().append(l),s.find("small").append(i.formattedFilesize),o=s.find("ul").addClass("buttonGroup"),c=$('<li><span class="button small jsObjectAction" data-object-action="delete" data-confirm-message="'+WCF.Language.get("wcf.attachment.delete.sure")+'" data-event-name="attachment">'+WCF.Language.get("wcf.global.button.delete")+"</span></li>"),o.append(c),s.data("objectID",i.attachmentID),this._editorId&&(i.tinyURL?(i.thumbnailURL&&$('<li><span class="button small jsButtonAttachmentInsertThumbnail" data-object-id="'+i.attachmentID+'" data-url="'+WCF.String.escapeHTML(i.thumbnailURL)+'">'+WCF.Language.get("wcf.attachment.insertThumbnail")+"</span></li>").appendTo(o),$('<li><span class="button small jsButtonAttachmentInsertFull" data-object-id="'+i.attachmentID+'" data-url="'+WCF.String.escapeHTML(i.url)+'">'+WCF.Language.get("wcf.attachment.insertFull")+"</span></li>").appendTo(o)):$('<li><span class="button small jsButtonAttachmentInsertPlain" data-object-id="'+i.attachmentID+'">'+WCF.Language.get("wcf.attachment.insert")+"</span></li>").appendTo(o)),this._triggerSync("new",{html:s[0].outerHTML}),this._registerEditorButtons(s[0]),this._replaceOnLoad.hasOwnProperty(t)&&(s.hasClass("uploadFailed")||(d=this._replaceOnLoad[t])&&d.parentNode&&WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","replaceAttachment_"+this._editorId,{attachmentId:i.attachmentID,img:d,src:i.thumbnailURL?i.thumbnailURL:i.url}),this._replaceOnLoad[t]=null)):(s.children(".fa-spinner").removeClass("fa-spinner").addClass("fa-ban"),h="",e.returnValues&&e.returnValues.errors[r]?"uploadFailed"===(h=(m=e.returnValues.errors[r]).errorType)&&m.additionalData.phpLimitExceeded&&(h="uploadPhpLimit"):h="uploadFailed",s.find("div > div").append($('<small class="innerError">'+WCF.Language.get("wcf.attachment.upload.error."+h)+"</small>")),s.addClass("uploadFailed")),WCF.inArray(t,this._autoInsert)&&(this._autoInsert.splice(this._autoInsert.indexOf(t),1),s.hasClass("uploadFailed")||((u=s.find(".jsButtonAttachmentInsertThumbnail")).length||(u=s.find(".jsButtonAttachmentInsertFull")),u.trigger("click"))));this._rebuildInterface()},_rebuildInterface:function(){this._makeSortable(),this._fileListSelector.children("li:not(.uploadFailed)").length?this._insertAllButton.show():this._insertAllButton.hide(),WCF.DOMNodeInsertedHandler.execute()},_registerEditorButtons:function(t){this._editorId&&elBySelAll(".jsButtonAttachmentInsertThumbnail, .jsButtonAttachmentInsertFull, .jsButtonAttachmentInsertPlain",t,function(t){t.addEventListener("click",this._insert.bind(this))}.bind(this))},_insert:function(t){WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","insertAttachment_"+this._editorId,{attachmentId:elData(t.currentTarget,"object-id"),url:elData(t.currentTarget,"url")})},_insertAll:function(){var t,e,i,a;for(i=0,a=this._fileListSelector[0].childNodes.length;i<a;i++)"LI"!==(t=this._fileListSelector[0].childNodes[i]).nodeName||t.classList.contains("uploadFailed")||(null===(e=elBySel(".jsButtonAttachmentInsertThumbnail, .jsButtonAttachmentInsertPlain",t))&&(e=elBySel(".jsButtonAttachmentInsertFull, .jsButtonAttachmentInsertPlain",t)),window.jQuery(e).trigger("click"))},_error:function(t){this._fileListSelector.find("li").each((function(e,i){var a=$(i);a.children(".fa-spinner").length&&(a.addClass("uploadFailed").children(".fa-spinner").removeClass("fa-spinner").addClass("fa-ban"),a.find("div > div").append($('<small class="innerError">'+(t.responseJSON&&t.responseJSON.message?t.responseJSON.message:WCF.Language.get("wcf.attachment.upload.error.uploadFailed"))+"</small>")))}))},_makeSortable:function(){var t=this._fileListSelector.children("li:not(.uploadFailed)");t.length&&(t.addClass("sortableAttachment").children("img").addClass("sortableNode"),this._fileListSelector.hasClass("sortableList")||(this._fileListSelector.addClass("sortableList"),require(["Environment"],function(t){"desktop"===t.platform()&&new WCF.Sortable.List(this._fileListSelector.parent().wcfIdentify(),"",0,{axis:!1,items:"li.sortableAttachment",toleranceElement:null,start:function(t,e){e.placeholder[0].style.setProperty("height",e.helper[0].offsetHeight+"px","")},update:function(){var t=[];this._fileListSelector.children("li:not(.uploadFailed)").each((function(e,i){t.push($(i).data("objectID"))})),t.length&&new WCF.Action.Proxy({autoSend:!0,data:{actionName:"updatePosition",className:"wcf\\data\\attachment\\AttachmentAction",parameters:{attachmentIDs:t,objectID:this._objectID,objectType:this._objectType,tmpHash:this._tmpHash}}})}.bind(this)},!0)}.bind(this))))},_onDelete:function(t){if(!t.objectElement.classList.contains("formAttachmentListItem"))return;const e=t.objectElement.dataset.objectId,i=this._fileListSelector[0].querySelector(`.formAttachmentListItem[data-object-id="${e}"]`);null!==i&&i.remove(),this._removeLimitError({})},_sync:function(t){if(t.source!==this){if("new"!==t.type)throw new Error("Unexpected type '"+t.type+"'");this._syncNew(t.data)}},_syncNew:function(t){require(["Dom/Util"],function(e){var i=e.createFragmentFromHtml(t.html),a=elBySel("li",i);a.id="",this._registerEditorButtons(a),this._fileListSelector[0].appendChild(a),elShow(this._fileListSelector[0]),this._rebuildInterface()}.bind(this))},_triggerSync:function(t,e){WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","sync_"+this._tmpHash,{source:this,type:t,data:e})}}); })(this);
 
 // WCF.ColorPicker.js
 (function (window, undefined) { "use strict";WCF.ColorPicker=Class.extend({_bar:null,_barActive:!1,_barSelector:null,_callbackSubmit:null,_dialog:null,_didInit:!1,_elementID:"",_gradient:null,_gradientActive:!1,_gradientSelector:null,_hex:null,_hsv:{},_newColor:null,_oldColor:null,_rgba:{},_rgbaRegExp:null,init:function(t){this._callbackSubmit=null,this._elementID="",this._hsv={h:0,s:100,v:100},this._position={};var i=$(t);i.length?i.click($.proxy(this._open,this)):console.debug("[WCF.ColorPicker] Selector does not match any element, aborting.")},setCallbackSubmit:function(t){this._callbackSubmit=t},_open:function(t){var i,a;this._didInit||(this._initColorPicker(),this._didInit=!0),i=$(t.currentTarget),this._elementID=i.wcfIdentify(),this._parseColor(i),a=this.hsvToRgb(this._hsv.h,this._hsv.s,this._hsv.v),this._oldColor.css({backgroundColor:"rgba("+a.r+", "+a.g+", "+a.b+", "+this._rgba.a.val()/100+")"}),this._dialog.wcfDialog({backdropCloseOnClick:!1,title:WCF.Language.get("wcf.style.colorPicker")}),window.setTimeout(function(){this._hex.focus()}.bind(this),200)},_parseColor:function(t){var i,a,s;if(t.data("hsv")&&t.data("rgb")){for(a in i=t.data("hsv"))this._hsv[a]=i[a];this._updateValues(t.data("rgb"),!0,!0),this._rgba.a.val(parseInt(t.data("alpha")))}else t.data("color").match(/^rgb\((\d{1,3}), ?(\d{1,3}), ?(\d{1,3})\)$/)&&t.data("color","rgba("+RegExp.$1+", "+RegExp.$2+", "+RegExp.$3+", 1)"),null===this._rgbaRegExp&&(this._rgbaRegExp=new RegExp("^rgba\\((\\d{1,3}), ?(\\d{1,3}), ?(\\d{1,3}), ?(1|1\\.00?|0|0?\\.[0-9]{1,2})\\)$")),this._rgbaRegExp.exec(t.data("color")),0===(s=RegExp.$4).indexOf(".")&&(s="0"+s),s*=100,this._updateValues({r:RegExp.$1,g:RegExp.$2,b:RegExp.$3,a:Math.round(s)},!0,!0)},_initColorPicker:function(){this._dialog=$('<div id="colorPickerContainer" />').hide().appendTo(document.body),this._gradient=$('<div id="colorPickerGradient" />').appendTo(this._dialog),this._gradientSelector=$('<span id="colorPickerGradientSelector"><span></span></span>').appendTo(this._gradient),this._bar=$('<div id="colorPickerBar" />').appendTo(this._dialog),this._barSelector=$('<span id="colorPickerBarSelector" />').appendTo(this._bar),this._gradient.mousedown($.proxy(this._mouseDownGradient,this)),this._bar.mousedown($.proxy(this._mouseDownBar,this));var t=this;$(document).mouseup((function(i){t._barActive?(t._barActive=!1,t._mouseBar(i)):t._gradientActive&&(t._gradientActive=!1,t._mouseGradient(i))})).mousemove((function(i){t._barActive?t._mouseBar(i):t._gradientActive&&t._mouseGradient(i)})),this._initColorPickerForm()},_initColorPickerForm:function(){var t,i,a,s,e,r=$('<div id="colorPickerForm" />').appendTo(this._dialog);$("<small>"+WCF.Language.get("wcf.style.colorPicker.new")+"</small>").appendTo(r),t=$('<ul class="colors" />').appendTo(r),this._newColor=$('<li class="new"><span /></li>').appendTo(t).children("span"),this._oldColor=$('<li class="old"><span /></li>').appendTo(t).children("span"),$("<small>"+WCF.Language.get("wcf.style.colorPicker.current")+"</small>").appendTo(r),i=$('<ul class="rgba" />').appendTo(r),this._createInputElement("r","R",0,255).appendTo(i),this._createInputElement("g","G",0,255).appendTo(i),this._createInputElement("b","B",0,255).appendTo(i),this._createInputElement("a","a",0,100).appendTo(i),a=$('<ul class="hex"><li><label><span>#</span></label></li></ul>').appendTo(r),this._hex=$('<input type="text" maxlength="6" />').appendTo(a.find("label")),this._rgba.r.blur($.proxy(this._blurRgba,this)).keyup($.proxy(this._keyUpRGBA,this)),this._rgba.g.blur($.proxy(this._blurRgba,this)).keyup($.proxy(this._keyUpRGBA,this)),this._rgba.b.blur($.proxy(this._blurRgba,this)).keyup($.proxy(this._keyUpRGBA,this)),this._rgba.a.blur($.proxy(this._blurRgba,this)).keyup($.proxy(this._keyUpRGBA,this)),this._hex.blur($.proxy(this._blurHex,this)).keyup($.proxy(this._keyUpHex,this)),s=$('<div class="formSubmit" />').appendTo(this._dialog),$('<button class="buttonPrimary">'+WCF.Language.get("wcf.style.colorPicker.button.apply")+"</button>").appendTo(s).click($.proxy(this._submit,this)),e=this,this._hex.on("paste",(function(){e._hex.attr("maxlength","7"),setTimeout((function(){var t=e._hex.val();"#"==t.substring(0,1)&&(t=t.substr(1)),t.length>6&&(t=t.substring(0,6)),e._hex.attr("maxlength","6").val(t)}),50)})),r.find("input").focus((function(){this.select()}))},_keyUpRGBA:function(t){13==t.which&&(this._blurRgba(),this._submit())},_keyUpHex:function(t){13==t.which&&(this._blurHex(),this._submit())},_submit:function(){var t,i,a=this.hsvToRgb(this._hsv.h,this._hsv.s,this._hsv.v),s={};for(t in this._hsv)s[t]=this._hsv[t];(i=$("#"+this._elementID)).data("hsv",s).css({backgroundColor:"rgba("+a.r+", "+a.g+", "+a.b+", "+this._rgba.a.val()/100+")"}).data("alpha",parseInt(this._rgba.a.val())),i.data("rgb",{r:this._rgba.r.val(),g:this._rgba.g.val(),b:this._rgba.b.val()}),$("#"+i.data("store")).val("rgba("+this._rgba.r.val()+", "+this._rgba.g.val()+", "+this._rgba.b.val()+", "+this._rgba.a.val()/100+")").trigger("change"),this._dialog.wcfDialog("close"),"function"==typeof this._callbackSubmit&&this._callbackSubmit({r:this._rgba.r.val(),g:this._rgba.g.val(),b:this._rgba.b.val(),a:this._rgba.a.val()/100})},_createInputElement:function(t,i,a,s){var e=$('<li class="'+t+'" />'),r=$("<label />").appendTo(e);return $("<span>"+i+"</span>").appendTo(r),this._rgba[t]=$('<input type="number" value="0" min="'+a+'" max="'+s+'" step="1" />').appendTo(r),e},_mouseDownGradient:function(t){this._gradientActive=!0,this._mouseGradient(t)},_mouseGradient:function(t){var i=this._gradient.getOffsets("offset"),a=Math.max(Math.min(t.pageX-i.left,255),0),s=Math.max(Math.min(t.pageY-i.top,255),0);this._hsv.s=100*Math.max(0,Math.min(1,a/255)),this._hsv.v=100*Math.max(0,Math.min(1,(255-s)/255)),this._updateValues(null)},_mouseDownBar:function(t){this._barActive=!0,this._mouseBar(t)},_mouseBar:function(t){var i=this._bar.getOffsets("offset"),a=Math.max(Math.min(t.pageY-i.top,255),0);this._barSelector.css({top:a+"px"}),this._hsv.h=Math.max(0,Math.min(359,Math.round((255-a)/255*360))),this._updateValues(null)},_blurRgba:function(){var t,i;for(t in this._rgba)i=parseInt(this._rgba[t].val())||0,"a"===t?this._rgba[t].val(Math.max(0,Math.min(100,i))):this._rgba[t].val(Math.max(0,Math.min(255,i)));this._updateValues({r:this._rgba.r.val(),g:this._rgba.g.val(),b:this._rgba.b.val()},!0,!0)},_blurHex:function(){var t=this.hexToRgb(this._hex.val());t!==Number.NaN&&this._updateValues(t,!0,!0)},_updateValues:function(t,i,a){var s,e,r,o,h;for(s in i=!0===i,a=!0===a,null===t&&(t=this.hsvToRgb(this._hsv.h,this._hsv.s,this._hsv.v),0==this._rgba.a.val()&&(t.a=100)),void 0===t.a&&(t.a=this._rgba.a.val()),t)this._rgba[s].val(t[s]);this._hex.val(this.rgbToHex(t.r,t.g,t.b)),(i||a)&&(e=this.rgbToHsv(t.r,t.g,t.b),i&&(this._hsv.h=e.h),a&&(this._hsv.s=e.s,this._hsv.v=e.v)),r=Math.max(0,Math.min(255,255-this._hsv.h/360*255)),this._barSelector.css({top:r+"px"}),o=Math.max(0,Math.min(255,this._hsv.s/100*255)),r=Math.max(0,Math.min(255,255-this._hsv.v/100*255)),this._gradientSelector.css({left:o-6+"px",top:r-6+"px"}),this._newColor.css({backgroundColor:"rgba("+t.r+", "+t.g+", "+t.b+", "+t.a/100+")"}),h=this.hsvToRgb(this._hsv.h,100,100),this._gradient.css({backgroundColor:"rgb("+h.r+", "+h.g+", "+h.b+")"})},hsvToRgb:function(t,i,a){return window.__wcf_bc_colorUtil.hsvToRgb(t,i,a)},rgbToHsv:function(t,i,a){return window.__wcf_bc_colorUtil.rgbToHsv(t,i,a)},hexToRgb:function(t){return window.__wcf_bc_colorUtil.hexToRgb(t)},rgbToHex:function(t,i,a){return window.__wcf_bc_colorUtil.rgbToHex(t,i,a)}}),void 0===window.__wcf_bc_colorUtil&&require(["ColorUtil"],(function(t){})),"function"==typeof window.__wcf_bc_colorPickerInit&&window.__wcf_bc_colorPickerInit(); })(this);
index 5fade827d8277e5a8f75ea4e7f7c16f5f344101c..2334a19fff48468a25fbd3d4ef1960249b6d28eb 100644 (file)
@@ -28,7 +28,7 @@
 (function (window, undefined) { "use strict";WCF.ACL={},WCF.ACL.List=Class.extend({_categoryName:"",_container:{},_containerElements:{},_objectID:0,_objectTypeID:{},_options:{},_proxy:{},_search:{},_values:{},init:function(){},_reset:function(){},_loadACL:function(){},addObject:function(){},_createListItem:function(){},_removeItem:function(){},_selectFirstEntry:function(){},_success:function(){},_parseData:function(){},_click:function(){},_select:function(){},_change:function(){},_changeAll:function(){},_setupPermissions:function(){},_savePermissions:function(){},submit:function(){},_save:function(){}}); })(this);
 
 // WCF.Attachment.js
-(function (window, undefined) { "use strict";WCF.Attachment={},WCF.Attachment.Upload=WCF.Upload.extend({_autoInsert:[],_insertAllButton:null,_objectType:"",_objectID:0,_tmpHash:"",_parentObjectID:0,_editorId:"",_replaceOnLoad:{},_options:{},init:function(t,e,i,a,s,n,r,l,o){var c,d;if(this._super(t,e,"wcf\\data\\attachment\\AttachmentAction",{multiple:!0,maxUploads:r}),this._autoInsert=[],this._objectType=i,this._objectID=parseInt(a),this._tmpHash=s,this._parentObjectID=parseInt(n),this._editorId=l,this._options=$.extend(!0,this._options,o||{}),this._buttonSelector.children("p.button").click($.proxy(this._validateLimit,this)),this._fileListSelector.find(".jsButtonInsertAttachment").click($.proxy(this._insert,this)),this._fileListSelector.find(".jsButtonAttachmentInsertThumbnail").click($.proxy(this._insert,this)),this._fileListSelector.find(".jsButtonAttachmentInsertFull").click($.proxy(this._insert,this)),WCF.System.Event.addListener("com.woltlab.wcf.action.delete","attachment",this._onDelete.bind(this)),this._makeSortable(),this._insertAllButton=$('<p class="button jsButtonAttachmentInsertAll">'+WCF.Language.get("wcf.attachment.insertAll")+"</p>").hide(),this._editorId){this._insertAllButton.appendTo(this._buttonSelector),this._insertAllButton.click($.proxy(this._insertAll,this)),this._fileListSelector.children("li:not(.uploadFailed)").length&&this._insertAllButton.show(),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","submit_"+this._editorId,this._submitInline.bind(this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","reset_"+this._editorId,this._reset.bind(this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","dragAndDrop_"+this._editorId,this._editorUpload.bind(this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","pasteFromClipboard_"+this._editorId,this._editorUpload.bind(this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","autosaveMetaData_"+this._editorId,function(t){t.tmpHashes&&Array.isArray(t.tmpHashes)||(t.tmpHashes=[]),t.tmpHashes=t.tmpHashes.filter((t=>t!==s)),this._fileListSelector.children("li:not(.uploadFailed)").length>0&&t.tmpHashes.push(s)}.bind(this));const t=this._fileListSelector[0].closest("form");if(t){const e={};t.dataset.attachmentTmpHashes="",WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","getMetaData_"+this._editorId,e),e.tmpHashes&&Array.isArray(e.tmpHashes)&&e.tmpHashes.length>0&&(t.dataset.attachmentTmpHashes=e.tmpHashes.join(",")),t.addEventListener("submit",(e=>{let i=this._tmpHash;t.dataset.attachmentTmpHashes&&(i+=`,${t.dataset.attachmentTmpHashes}`);const a=t.querySelector('input[name="tmpHash"]');a&&(a.value=i)}))}c=WCF.System.Event.addListener("com.woltlab.wcf.redactor2","metacode_attach_"+this._editorId,function(t){var e,i,a,s,n,r=this._getImageAttachments(),l=t.attributes[0]||0;r.hasOwnProperty(l)&&(e=~~$("#"+this._editorId).data("redactor").opts.woltlab.attachmentThumbnailWidth,i=!0===(i=t.attributes[2])||"true"===i||~~i&&~~i<=e,(a=elCreate("img")).className="woltlabAttachment",a.src=r[l][i?"thumbnailUrl":"url"],elData(a,"attachment-id",l),"left"===(s=t.attributes[1]||"none")?a.classList.add("messageFloatObjectLeft"):"right"===s&&a.classList.add("messageFloatObjectRight"),(n=t.metacode).parentNode.insertBefore(a,n),elRemove(n),t.cancel=!0)}.bind(this)),d=WCF.System.Event.addListener("com.woltlab.wcf.redactor2","sync_"+this._tmpHash,this._sync.bind(this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","destroy_"+this._editorId,function(){WCF.System.Event.removeAllListeners("com.woltlab.wcf.redactor2","submit_"+this._editorId),WCF.System.Event.removeAllListeners("com.woltlab.wcf.redactor2","reset_"+this._editorId),WCF.System.Event.removeAllListeners("com.woltlab.wcf.redactor2","insertAttachment_"+this._editorId),WCF.System.Event.removeAllListeners("com.woltlab.wcf.redactor2","dragAndDrop_"+this._editorId),WCF.System.Event.removeAllListeners("com.woltlab.wcf.redactor2","pasteFromClipboard_"+this._editorId),WCF.System.Event.removeAllListeners("com.woltlab.wcf.redactor2","autosaveMetaData_"+this._editorId),WCF.System.Event.removeListener("com.woltlab.wcf.redactor2","metacode_attach_"+this._editorId,c),WCF.System.Event.removeListener("com.woltlab.wcf.redactor2","sync_"+this._tmpHash,d)}.bind(this))}},_editorUpload:function(t){var e,i=null;this._fileListSelector.closest(".messageTabMenu").messageTabMenu("showTab","attachments",!0),e=function(e){null===i?this._autoInsert.push(e):this._replaceOnLoad[e]=i,t.uploadID=e}.bind(this),t.file?this._upload(void 0,t.file,void 0,e):(this._upload(void 0,void 0,t.blob,e),i=t.replace||null)},_getImageAttachments:function(){var t={};return this._fileListSelector.children("li").each((function(e,i){var a=$(i);a.data("isImage")&&(t[~~a.data("objectID")]={thumbnailUrl:a.find(".jsButtonAttachmentInsertThumbnail").data("url"),url:a.find(".jsButtonAttachmentInsertFull").data("url")})})),t},_submitInline:function(t){if(this._tmpHash){t.tmpHash=this._tmpHash;var e={};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","getMetaData_"+this._editorId,e),e.tmpHashes&&Array.isArray(e.tmpHashes)&&e.tmpHashes.length>0&&(t.tmpHash+=","+e.tmpHashes.join(","))}},_reset:function(){this._fileListSelector.hide().empty(),this._insertAllButton.hide(),this._validateLimit()},_validateLimit:function(){var t,e=this._buttonSelector.next("small.innerError"),i=this._options.maxUploads-this._fileListSelector.children("li:not(.uploadFailed)").length,a=this._fileUpload?this._fileUpload.prop("files").length:0;return i<=0||i<a?(t=i<=0?WCF.Language.get("wcf.attachment.upload.error.reachedLimit"):WCF.Language.get("wcf.attachment.upload.error.reachedRemainingLimit").replace(/#remaining#/,i),e.length||(e=$('<small class="innerError" />').insertAfter(this._buttonSelector)),e.html(t),!1):(e.remove(),!0)},_removeLimitError:function(t){var e=this._fileListSelector.children("li");e.filter(":not(.uploadFailed)").length||this._insertAllButton.hide(),e.length||this._fileListSelector.hide(),this._editorId&&t.button&&WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","deleteAttachment_"+this._editorId,{attachmentId:t.button.data("objectID")})},_upload:function(t,e,i,a){var s=this._super.bind(this);require(["WoltLabSuite/Core/FileUtil","WoltLabSuite/Core/Image/ImageUtil","WoltLabSuite/Core/Image/Resizer","WoltLabSuite/Core/Ajax/Status"],function(n,r,l,o){var c,d,h,m;o.show(),c=[],e?c.push(e):i?c.push(n.blobToFile(i,"pasted-from-clipboard")):c=this._fileUpload.prop("files"),d=Promise.resolve(c),this._options.autoScale&&this._options.autoScale.enable&&(h=this._buttonSelector.data("maxSize"),m=new l,d=Array.prototype.reduce.call(c,function(t,e){return t.then(function(t){var i,a;return-1===["image/png","image/jpeg","image/webp"].indexOf(e.type)?(t.push(e),t):(i=new Promise((function(t,i){setTimeout((function(){t(e)}),1e4)})),a=m.loadFile(e).then(function(t){var a,s,n=t.exif,l=this._options.autoScale.maxWidth,o=this._options.autoScale.maxHeight,c=this._options.autoScale.quality;return window.devicePixelRatio>=2&&(a=window.screen.width*window.devicePixelRatio,s=window.screen.height*window.devicePixelRatio,a-10<t.image.width&&t.image.width<a+10&&s-10<t.image.height&&(l=Math.min(l,window.screen.width))),m.resize(t.image,l,o,c,e.size>h,i).then(function(t){if(void 0===t)return e;var i=this._options.autoScale.fileType;return("keep"===this._options.autoScale.fileType||r.containsTransparentPixels(t))&&(i=e.type),m.saveFile({exif:n,image:t},e.name,i,c)}.bind(this)).then((function(t){return t.size>e.size?(console.debug('[WCF.Attachment] File size of "'+e.name+'" increased, uploading untouched image.'),e):t}))}.bind(this)).catch((function(t){return console.debug('[WCF.Attachment] Failed to resize image "'+e.name+'":',t),e})),Promise.race([i,a]).then((function(e){return t.push(e),t})))}.bind(this))}.bind(this),Promise.resolve([]))),d.then(function(e){var i=void 0;return this._validateLimit()&&(i=s(t,void 0,void 0,e)),this._fileUpload&&(this._removeButton(),this._createButton()),"function"==typeof a&&a(i),i}.bind(this)).catch((function(t){console.debug("[WCF.Attachment] Failed to upload attachments:",t)})).finally(o.hide)}.bind(this),(function(t){console.debug("[WCF.Attachment] Failed to load modules:",t)}))},_createUploadMatrix:function(t){return this._fileListSelector.children("li.uploadFailed").remove(),this._super(t)},_getParameters:function(){return{objectType:this._objectType,objectID:this._objectID,tmpHash:this._tmpHash,parentObjectID:this._parentObjectID}},_initFile:function(t){var e=$('<li class="box64 formAttachmentListItem"><span class="icon icon64 fa-spinner" /><div><div><p>'+WCF.String.escapeHTML(t.name)+'</p><small><progress max="100"></progress></small></div><ul></ul></div></li>').data("filename",t.name);return this._fileListSelector.append(e),this._fileListSelector.show(),this._buttonSelector.data("maxSize")<t.size&&(e.find("progress").remove(),e.children(".fa-spinner").removeClass("fa-spinner").addClass("fa-ban"),e.find("div > div").append($('<small class="innerError">'+WCF.Language.get("wcf.attachment.upload.error.tooLarge")+"</small>")),e.addClass("uploadFailed")),e},_useThumbnail:function(){return!0},_success:function(t,e){var i,a,s,n,r,l,o,c,d,h,m,u;for(a in this._uploadMatrix[t])this._uploadMatrix[t].hasOwnProperty(a)&&((s=this._uploadMatrix[t][a]).find("progress").remove(),n=s.data("filename"),r=s.data("internalFileID"),e.returnValues&&e.returnValues.attachments[r]?(i=e.returnValues.attachments[r],elData(s[0],"object-id",i.attachmentID),s.addClass("jsObjectActionObject"),i.tinyURL?(s.children(".fa-spinner").replaceWith($('<img src="'+i.tinyURL+'" alt="" class="attachmentTinyThumbnail" />')),s.data("height",i.height),s.data("width",i.width),elData(s[0],"is-image",i.isImage)):s.children(".fa-spinner").removeClass("fa-spinner").addClass("fa-"+i.iconName),(l=$('<a href=""></a>')).text(n).attr("href",i.url),l[0].target="_blank",0!=i.isImage&&l.addClass("jsImageViewer").attr("title",n),s.find("p").empty().append(l),s.find("small").append(i.formattedFilesize),o=s.find("ul").addClass("buttonGroup"),c=$('<li><span class="button small jsObjectAction" data-object-action="delete" data-confirm-message="'+WCF.Language.get("wcf.attachment.delete.sure")+'" data-event-name="attachment">'+WCF.Language.get("wcf.global.button.delete")+"</span></li>"),o.append(c),s.data("objectID",i.attachmentID),this._editorId&&(i.tinyURL?(i.thumbnailURL&&$('<li><span class="button small jsButtonAttachmentInsertThumbnail" data-object-id="'+i.attachmentID+'" data-url="'+WCF.String.escapeHTML(i.thumbnailURL)+'">'+WCF.Language.get("wcf.attachment.insertThumbnail")+"</span></li>").appendTo(o),$('<li><span class="button small jsButtonAttachmentInsertFull" data-object-id="'+i.attachmentID+'" data-url="'+WCF.String.escapeHTML(i.url)+'">'+WCF.Language.get("wcf.attachment.insertFull")+"</span></li>").appendTo(o)):$('<li><span class="button small jsButtonAttachmentInsertPlain" data-object-id="'+i.attachmentID+'">'+WCF.Language.get("wcf.attachment.insert")+"</span></li>").appendTo(o)),this._triggerSync("new",{html:s[0].outerHTML}),this._registerEditorButtons(s[0]),this._replaceOnLoad.hasOwnProperty(t)&&(s.hasClass("uploadFailed")||(d=this._replaceOnLoad[t])&&d.parentNode&&WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","replaceAttachment_"+this._editorId,{attachmentId:i.attachmentID,img:d,src:i.thumbnailURL?i.thumbnailURL:i.url}),this._replaceOnLoad[t]=null)):(s.children(".fa-spinner").removeClass("fa-spinner").addClass("fa-ban"),h="",e.returnValues&&e.returnValues.errors[r]?"uploadFailed"===(h=(m=e.returnValues.errors[r]).errorType)&&m.additionalData.phpLimitExceeded&&(h="uploadPhpLimit"):h="uploadFailed",s.find("div > div").append($('<small class="innerError">'+WCF.Language.get("wcf.attachment.upload.error."+h)+"</small>")),s.addClass("uploadFailed")),WCF.inArray(t,this._autoInsert)&&(this._autoInsert.splice(this._autoInsert.indexOf(t),1),s.hasClass("uploadFailed")||((u=s.find(".jsButtonAttachmentInsertThumbnail")).length||(u=s.find(".jsButtonAttachmentInsertFull")),u.trigger("click"))));this._rebuildInterface()},_rebuildInterface:function(){this._makeSortable(),this._fileListSelector.children("li:not(.uploadFailed)").length?this._insertAllButton.show():this._insertAllButton.hide(),WCF.DOMNodeInsertedHandler.execute()},_registerEditorButtons:function(t){this._editorId&&elBySelAll(".jsButtonAttachmentInsertThumbnail, .jsButtonAttachmentInsertFull, .jsButtonAttachmentInsertPlain",t,function(t){t.addEventListener("click",this._insert.bind(this))}.bind(this))},_insert:function(t){WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","insertAttachment_"+this._editorId,{attachmentId:elData(t.currentTarget,"object-id"),url:elData(t.currentTarget,"url")})},_insertAll:function(){var t,e,i,a;for(i=0,a=this._fileListSelector[0].childNodes.length;i<a;i++)"LI"!==(t=this._fileListSelector[0].childNodes[i]).nodeName||t.classList.contains("uploadFailed")||(null===(e=elBySel(".jsButtonAttachmentInsertThumbnail, .jsButtonAttachmentInsertPlain",t))&&(e=elBySel(".jsButtonAttachmentInsertFull, .jsButtonAttachmentInsertPlain",t)),window.jQuery(e).trigger("click"))},_error:function(t){this._fileListSelector.find("li").each((function(e,i){var a=$(i);a.children(".fa-spinner").length&&(a.addClass("uploadFailed").children(".fa-spinner").removeClass("fa-spinner").addClass("fa-ban"),a.find("div > div").append($('<small class="innerError">'+(t.responseJSON&&t.responseJSON.message?t.responseJSON.message:WCF.Language.get("wcf.attachment.upload.error.uploadFailed"))+"</small>")))}))},_makeSortable:function(){var t=this._fileListSelector.children("li:not(.uploadFailed)");t.length&&(t.addClass("sortableAttachment").children("img").addClass("sortableNode"),this._fileListSelector.hasClass("sortableList")||(this._fileListSelector.addClass("sortableList"),require(["Environment"],function(t){"desktop"===t.platform()&&new WCF.Sortable.List(this._fileListSelector.parent().wcfIdentify(),"",0,{axis:!1,items:"li.sortableAttachment",toleranceElement:null,start:function(t,e){e.placeholder[0].style.setProperty("height",e.helper[0].offsetHeight+"px","")},update:function(){var t=[];this._fileListSelector.children("li:not(.uploadFailed)").each((function(e,i){t.push($(i).data("objectID"))})),t.length&&new WCF.Action.Proxy({autoSend:!0,data:{actionName:"updatePosition",className:"wcf\\data\\attachment\\AttachmentAction",parameters:{attachmentIDs:t,objectID:this._objectID,objectType:this._objectType,tmpHash:this._tmpHash}}})}.bind(this)},!0)}.bind(this))))},_onDelete:function(t){var e=elData(t.button[0],"object-id"),i=elBySel('.formAttachmentListItem[data-object-id="'+e+'"]',this._fileListSelector[0]);null!==i&&elRemove(i),this._removeLimitError(t)},_sync:function(t){if(t.source!==this){if("new"!==t.type)throw new Error("Unexpected type '"+t.type+"'");this._syncNew(t.data)}},_syncNew:function(t){require(["Dom/Util"],function(e){var i=e.createFragmentFromHtml(t.html),a=elBySel("li",i);a.id="",this._registerEditorButtons(a),this._fileListSelector[0].appendChild(a),elShow(this._fileListSelector[0]),this._rebuildInterface()}.bind(this))},_triggerSync:function(t,e){WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","sync_"+this._tmpHash,{source:this,type:t,data:e})}}); })(this);
+(function (window, undefined) { "use strict";WCF.Attachment={},WCF.Attachment.Upload=WCF.Upload.extend({_autoInsert:[],_insertAllButton:null,_objectType:"",_objectID:0,_tmpHash:"",_parentObjectID:0,_editorId:"",_replaceOnLoad:{},_options:{},init:function(t,e,i,a,s,n,r,l,o){var c,d;if(this._super(t,e,"wcf\\data\\attachment\\AttachmentAction",{multiple:!0,maxUploads:r}),this._autoInsert=[],this._objectType=i,this._objectID=parseInt(a),this._tmpHash=s,this._parentObjectID=parseInt(n),this._editorId=l,this._options=$.extend(!0,this._options,o||{}),this._buttonSelector.children("p.button").click($.proxy(this._validateLimit,this)),this._fileListSelector.find(".jsButtonInsertAttachment").click($.proxy(this._insert,this)),this._fileListSelector.find(".jsButtonAttachmentInsertThumbnail").click($.proxy(this._insert,this)),this._fileListSelector.find(".jsButtonAttachmentInsertFull").click($.proxy(this._insert,this)),WCF.System.Event.addListener("WoltLabSuite/Core/Ui/Object/Action","delete",(t=>this._onDelete(t))),this._makeSortable(),this._insertAllButton=$('<p class="button jsButtonAttachmentInsertAll">'+WCF.Language.get("wcf.attachment.insertAll")+"</p>").hide(),this._editorId){this._insertAllButton.appendTo(this._buttonSelector),this._insertAllButton.click($.proxy(this._insertAll,this)),this._fileListSelector.children("li:not(.uploadFailed)").length&&this._insertAllButton.show(),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","submit_"+this._editorId,this._submitInline.bind(this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","reset_"+this._editorId,this._reset.bind(this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","dragAndDrop_"+this._editorId,this._editorUpload.bind(this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","pasteFromClipboard_"+this._editorId,this._editorUpload.bind(this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","autosaveMetaData_"+this._editorId,function(t){t.tmpHashes&&Array.isArray(t.tmpHashes)||(t.tmpHashes=[]),t.tmpHashes=t.tmpHashes.filter((t=>t!==s)),this._fileListSelector.children("li:not(.uploadFailed)").length>0&&t.tmpHashes.push(s)}.bind(this));const t=this._fileListSelector[0].closest("form");if(t){const e={};t.dataset.attachmentTmpHashes="",WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","getMetaData_"+this._editorId,e),e.tmpHashes&&Array.isArray(e.tmpHashes)&&e.tmpHashes.length>0&&(t.dataset.attachmentTmpHashes=e.tmpHashes.join(",")),t.addEventListener("submit",(e=>{let i=this._tmpHash;t.dataset.attachmentTmpHashes&&(i+=`,${t.dataset.attachmentTmpHashes}`);const a=t.querySelector('input[name="tmpHash"]');a&&(a.value=i)}))}c=WCF.System.Event.addListener("com.woltlab.wcf.redactor2","metacode_attach_"+this._editorId,function(t){var e,i,a,s,n,r=this._getImageAttachments(),l=t.attributes[0]||0;r.hasOwnProperty(l)&&(e=~~$("#"+this._editorId).data("redactor").opts.woltlab.attachmentThumbnailWidth,i=!0===(i=t.attributes[2])||"true"===i||~~i&&~~i<=e,(a=elCreate("img")).className="woltlabAttachment",a.src=r[l][i?"thumbnailUrl":"url"],elData(a,"attachment-id",l),"left"===(s=t.attributes[1]||"none")?a.classList.add("messageFloatObjectLeft"):"right"===s&&a.classList.add("messageFloatObjectRight"),(n=t.metacode).parentNode.insertBefore(a,n),elRemove(n),t.cancel=!0)}.bind(this)),d=WCF.System.Event.addListener("com.woltlab.wcf.redactor2","sync_"+this._tmpHash,this._sync.bind(this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","destroy_"+this._editorId,function(){WCF.System.Event.removeAllListeners("com.woltlab.wcf.redactor2","submit_"+this._editorId),WCF.System.Event.removeAllListeners("com.woltlab.wcf.redactor2","reset_"+this._editorId),WCF.System.Event.removeAllListeners("com.woltlab.wcf.redactor2","insertAttachment_"+this._editorId),WCF.System.Event.removeAllListeners("com.woltlab.wcf.redactor2","dragAndDrop_"+this._editorId),WCF.System.Event.removeAllListeners("com.woltlab.wcf.redactor2","pasteFromClipboard_"+this._editorId),WCF.System.Event.removeAllListeners("com.woltlab.wcf.redactor2","autosaveMetaData_"+this._editorId),WCF.System.Event.removeListener("com.woltlab.wcf.redactor2","metacode_attach_"+this._editorId,c),WCF.System.Event.removeListener("com.woltlab.wcf.redactor2","sync_"+this._tmpHash,d)}.bind(this))}},_editorUpload:function(t){var e,i=null;this._fileListSelector.closest(".messageTabMenu").messageTabMenu("showTab","attachments",!0),e=function(e){null===i?this._autoInsert.push(e):this._replaceOnLoad[e]=i,t.uploadID=e}.bind(this),t.file?this._upload(void 0,t.file,void 0,e):(this._upload(void 0,void 0,t.blob,e),i=t.replace||null)},_getImageAttachments:function(){var t={};return this._fileListSelector.children("li").each((function(e,i){var a=$(i);a.data("isImage")&&(t[~~a.data("objectID")]={thumbnailUrl:a.find(".jsButtonAttachmentInsertThumbnail").data("url"),url:a.find(".jsButtonAttachmentInsertFull").data("url")})})),t},_submitInline:function(t){if(this._tmpHash){t.tmpHash=this._tmpHash;var e={};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","getMetaData_"+this._editorId,e),e.tmpHashes&&Array.isArray(e.tmpHashes)&&e.tmpHashes.length>0&&(t.tmpHash+=","+e.tmpHashes.join(","))}},_reset:function(){this._fileListSelector.hide().empty(),this._insertAllButton.hide(),this._validateLimit()},_validateLimit:function(){var t,e=this._buttonSelector.next("small.innerError"),i=this._options.maxUploads-this._fileListSelector.children("li:not(.uploadFailed)").length,a=this._fileUpload?this._fileUpload.prop("files").length:0;return i<=0||i<a?(t=i<=0?WCF.Language.get("wcf.attachment.upload.error.reachedLimit"):WCF.Language.get("wcf.attachment.upload.error.reachedRemainingLimit").replace(/#remaining#/,i),e.length||(e=$('<small class="innerError" />').insertAfter(this._buttonSelector)),e.html(t),!1):(e.remove(),!0)},_removeLimitError:function(t){var e=this._fileListSelector.children("li");e.filter(":not(.uploadFailed)").length||this._insertAllButton.hide(),e.length||this._fileListSelector.hide(),this._editorId&&t.button&&WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","deleteAttachment_"+this._editorId,{attachmentId:t.button.data("objectID")})},_upload:function(t,e,i,a){var s=this._super.bind(this);require(["WoltLabSuite/Core/FileUtil","WoltLabSuite/Core/Image/ImageUtil","WoltLabSuite/Core/Image/Resizer","WoltLabSuite/Core/Ajax/Status"],function(n,r,l,o){var c,d,h,m;o.show(),c=[],e?c.push(e):i?c.push(n.blobToFile(i,"pasted-from-clipboard")):c=this._fileUpload.prop("files"),d=Promise.resolve(c),this._options.autoScale&&this._options.autoScale.enable&&(h=this._buttonSelector.data("maxSize"),m=new l,d=Array.prototype.reduce.call(c,function(t,e){return t.then(function(t){var i,a;return-1===["image/png","image/jpeg","image/webp"].indexOf(e.type)?(t.push(e),t):(i=new Promise((function(t,i){setTimeout((function(){t(e)}),1e4)})),a=m.loadFile(e).then(function(t){var a,s,n=t.exif,l=this._options.autoScale.maxWidth,o=this._options.autoScale.maxHeight,c=this._options.autoScale.quality;return window.devicePixelRatio>=2&&(a=window.screen.width*window.devicePixelRatio,s=window.screen.height*window.devicePixelRatio,a-10<t.image.width&&t.image.width<a+10&&s-10<t.image.height&&(l=Math.min(l,window.screen.width))),m.resize(t.image,l,o,c,e.size>h,i).then(function(t){if(void 0===t)return e;var i=this._options.autoScale.fileType;return("keep"===this._options.autoScale.fileType||r.containsTransparentPixels(t))&&(i=e.type),m.saveFile({exif:n,image:t},e.name,i,c)}.bind(this)).then((function(t){return t.size>e.size?(console.debug('[WCF.Attachment] File size of "'+e.name+'" increased, uploading untouched image.'),e):t}))}.bind(this)).catch((function(t){return console.debug('[WCF.Attachment] Failed to resize image "'+e.name+'":',t),e})),Promise.race([i,a]).then((function(e){return t.push(e),t})))}.bind(this))}.bind(this),Promise.resolve([]))),d.then(function(e){var i=void 0;return this._validateLimit()&&(i=s(t,void 0,void 0,e)),this._fileUpload&&(this._removeButton(),this._createButton()),"function"==typeof a&&a(i),i}.bind(this)).catch((function(t){console.debug("[WCF.Attachment] Failed to upload attachments:",t)})).finally(o.hide)}.bind(this),(function(t){console.debug("[WCF.Attachment] Failed to load modules:",t)}))},_createUploadMatrix:function(t){return this._fileListSelector.children("li.uploadFailed").remove(),this._super(t)},_getParameters:function(){return{objectType:this._objectType,objectID:this._objectID,tmpHash:this._tmpHash,parentObjectID:this._parentObjectID}},_initFile:function(t){var e=$('<li class="box64 formAttachmentListItem"><span class="icon icon64 fa-spinner" /><div><div><p>'+WCF.String.escapeHTML(t.name)+'</p><small><progress max="100"></progress></small></div><ul></ul></div></li>').data("filename",t.name);return this._fileListSelector.append(e),this._fileListSelector.show(),this._buttonSelector.data("maxSize")<t.size&&(e.find("progress").remove(),e.children(".fa-spinner").removeClass("fa-spinner").addClass("fa-ban"),e.find("div > div").append($('<small class="innerError">'+WCF.Language.get("wcf.attachment.upload.error.tooLarge")+"</small>")),e.addClass("uploadFailed")),e},_useThumbnail:function(){return!0},_success:function(t,e){var i,a,s,n,r,l,o,c,d,h,m,u;for(a in this._uploadMatrix[t])this._uploadMatrix[t].hasOwnProperty(a)&&((s=this._uploadMatrix[t][a]).find("progress").remove(),n=s.data("filename"),r=s.data("internalFileID"),e.returnValues&&e.returnValues.attachments[r]?(i=e.returnValues.attachments[r],elData(s[0],"object-id",i.attachmentID),s.addClass("jsObjectActionObject"),i.tinyURL?(s.children(".fa-spinner").replaceWith($('<img src="'+i.tinyURL+'" alt="" class="attachmentTinyThumbnail" />')),s.data("height",i.height),s.data("width",i.width),elData(s[0],"is-image",i.isImage)):s.children(".fa-spinner").removeClass("fa-spinner").addClass("fa-"+i.iconName),(l=$('<a href=""></a>')).text(n).attr("href",i.url),l[0].target="_blank",0!=i.isImage&&l.addClass("jsImageViewer").attr("title",n),s.find("p").empty().append(l),s.find("small").append(i.formattedFilesize),o=s.find("ul").addClass("buttonGroup"),c=$('<li><span class="button small jsObjectAction" data-object-action="delete" data-confirm-message="'+WCF.Language.get("wcf.attachment.delete.sure")+'" data-event-name="attachment">'+WCF.Language.get("wcf.global.button.delete")+"</span></li>"),o.append(c),s.data("objectID",i.attachmentID),this._editorId&&(i.tinyURL?(i.thumbnailURL&&$('<li><span class="button small jsButtonAttachmentInsertThumbnail" data-object-id="'+i.attachmentID+'" data-url="'+WCF.String.escapeHTML(i.thumbnailURL)+'">'+WCF.Language.get("wcf.attachment.insertThumbnail")+"</span></li>").appendTo(o),$('<li><span class="button small jsButtonAttachmentInsertFull" data-object-id="'+i.attachmentID+'" data-url="'+WCF.String.escapeHTML(i.url)+'">'+WCF.Language.get("wcf.attachment.insertFull")+"</span></li>").appendTo(o)):$('<li><span class="button small jsButtonAttachmentInsertPlain" data-object-id="'+i.attachmentID+'">'+WCF.Language.get("wcf.attachment.insert")+"</span></li>").appendTo(o)),this._triggerSync("new",{html:s[0].outerHTML}),this._registerEditorButtons(s[0]),this._replaceOnLoad.hasOwnProperty(t)&&(s.hasClass("uploadFailed")||(d=this._replaceOnLoad[t])&&d.parentNode&&WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","replaceAttachment_"+this._editorId,{attachmentId:i.attachmentID,img:d,src:i.thumbnailURL?i.thumbnailURL:i.url}),this._replaceOnLoad[t]=null)):(s.children(".fa-spinner").removeClass("fa-spinner").addClass("fa-ban"),h="",e.returnValues&&e.returnValues.errors[r]?"uploadFailed"===(h=(m=e.returnValues.errors[r]).errorType)&&m.additionalData.phpLimitExceeded&&(h="uploadPhpLimit"):h="uploadFailed",s.find("div > div").append($('<small class="innerError">'+WCF.Language.get("wcf.attachment.upload.error."+h)+"</small>")),s.addClass("uploadFailed")),WCF.inArray(t,this._autoInsert)&&(this._autoInsert.splice(this._autoInsert.indexOf(t),1),s.hasClass("uploadFailed")||((u=s.find(".jsButtonAttachmentInsertThumbnail")).length||(u=s.find(".jsButtonAttachmentInsertFull")),u.trigger("click"))));this._rebuildInterface()},_rebuildInterface:function(){this._makeSortable(),this._fileListSelector.children("li:not(.uploadFailed)").length?this._insertAllButton.show():this._insertAllButton.hide(),WCF.DOMNodeInsertedHandler.execute()},_registerEditorButtons:function(t){this._editorId&&elBySelAll(".jsButtonAttachmentInsertThumbnail, .jsButtonAttachmentInsertFull, .jsButtonAttachmentInsertPlain",t,function(t){t.addEventListener("click",this._insert.bind(this))}.bind(this))},_insert:function(t){WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","insertAttachment_"+this._editorId,{attachmentId:elData(t.currentTarget,"object-id"),url:elData(t.currentTarget,"url")})},_insertAll:function(){var t,e,i,a;for(i=0,a=this._fileListSelector[0].childNodes.length;i<a;i++)"LI"!==(t=this._fileListSelector[0].childNodes[i]).nodeName||t.classList.contains("uploadFailed")||(null===(e=elBySel(".jsButtonAttachmentInsertThumbnail, .jsButtonAttachmentInsertPlain",t))&&(e=elBySel(".jsButtonAttachmentInsertFull, .jsButtonAttachmentInsertPlain",t)),window.jQuery(e).trigger("click"))},_error:function(t){this._fileListSelector.find("li").each((function(e,i){var a=$(i);a.children(".fa-spinner").length&&(a.addClass("uploadFailed").children(".fa-spinner").removeClass("fa-spinner").addClass("fa-ban"),a.find("div > div").append($('<small class="innerError">'+(t.responseJSON&&t.responseJSON.message?t.responseJSON.message:WCF.Language.get("wcf.attachment.upload.error.uploadFailed"))+"</small>")))}))},_makeSortable:function(){var t=this._fileListSelector.children("li:not(.uploadFailed)");t.length&&(t.addClass("sortableAttachment").children("img").addClass("sortableNode"),this._fileListSelector.hasClass("sortableList")||(this._fileListSelector.addClass("sortableList"),require(["Environment"],function(t){"desktop"===t.platform()&&new WCF.Sortable.List(this._fileListSelector.parent().wcfIdentify(),"",0,{axis:!1,items:"li.sortableAttachment",toleranceElement:null,start:function(t,e){e.placeholder[0].style.setProperty("height",e.helper[0].offsetHeight+"px","")},update:function(){var t=[];this._fileListSelector.children("li:not(.uploadFailed)").each((function(e,i){t.push($(i).data("objectID"))})),t.length&&new WCF.Action.Proxy({autoSend:!0,data:{actionName:"updatePosition",className:"wcf\\data\\attachment\\AttachmentAction",parameters:{attachmentIDs:t,objectID:this._objectID,objectType:this._objectType,tmpHash:this._tmpHash}}})}.bind(this)},!0)}.bind(this))))},_onDelete:function(t){if(!t.objectElement.classList.contains("formAttachmentListItem"))return;const e=t.objectElement.dataset.objectId,i=this._fileListSelector[0].querySelector(`.formAttachmentListItem[data-object-id="${e}"]`);null!==i&&i.remove(),this._removeLimitError({})},_sync:function(t){if(t.source!==this){if("new"!==t.type)throw new Error("Unexpected type '"+t.type+"'");this._syncNew(t.data)}},_syncNew:function(t){require(["Dom/Util"],function(e){var i=e.createFragmentFromHtml(t.html),a=elBySel("li",i);a.id="",this._registerEditorButtons(a),this._fileListSelector[0].appendChild(a),elShow(this._fileListSelector[0]),this._rebuildInterface()}.bind(this))},_triggerSync:function(t,e){WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","sync_"+this._tmpHash,{source:this,type:t,data:e})}}); })(this);
 
 // WCF.ColorPicker.js
 (function (window, undefined) { "use strict";WCF.ColorPicker=Class.extend({_bar:{},_barActive:!1,_barSelector:{},_dialog:{},_didInit:!1,_elementID:"",_gradient:{},_gradientActive:!1,_gradientSelector:{},_hex:{},_hsv:{},_newColor:{},_oldColor:{},_rgba:{},_rgbaRegExp:{},init:function(){},_open:function(){},_parseColor:function(){},_initColorPicker:function(){},_initColorPickerForm:function(){},_keyUpRGBA:function(){},_keyUpHex:function(){},_submit:function(){},_createInputElement:function(){},_mouseDownGradient:function(){},_mouseGradient:function(){},_mouseDownBar:function(){},_mouseBar:function(){},_blurRgba:function(){},_blurHex:function(){},_updateValues:function(){},hsvToRgb:function(n,o,t){return window.__wcf_bc_colorUtil.hsvToRgb(n,o,t)},rgbToHsv:function(n,o,t){return window.__wcf_bc_colorUtil.rgbToHsv(n,o,t)},hexToRgb:function(n){return window.__wcf_bc_colorUtil.hexToRgb(n)},rgbToHex:function(n,o,t){return window.__wcf_bc_colorUtil.rgbToHex(n,o,t)}}); })(this);