-WCF.Conversation={};WCF.Conversation.EditorHandler=Class.extend({_attributes:{},_conversations:{},_permissions:{},init:function(availableLabels){this._conversations={};var self=this;$(".conversation").each(function(index,conversation){var $conversation=$(conversation);var $conversationID=$conversation.data("conversationID");if(!self._conversations[$conversationID]){self._conversations[$conversationID]=$conversation;var $labelIDs=eval($conversation.data("labelIDs"));self._attributes[$conversationID]={isClosed:($conversation.data("isClosed")?true:false),labelIDs:$labelIDs};self._permissions[$conversationID]={canAddParticipants:($conversation.data("canAddParticipants")?true:false),canCloseConversation:($conversation.data("canCloseConversation")?true:false)}}})},getPermission:function(b,a){if(this._permissions[b][a]===undefined){return false}return(this._permissions[b][a])?true:false},getValue:function(b,a){switch(a){case"labelIDs":if(this._attributes[b].labelIDs===undefined){this._attributes[b].labelIDs=[]}return this._attributes[b].labelIDs;break;case"isClosed":return(this._attributes[b].isClosed)?true:false;break}},countAvailableLabels:function(){return(this.getAvailableLabels()).length},getAvailableLabels:function(){var a=[];WCF.Dropdown.getDropdownMenu("conversationLabelFilter").children("li").each(function(c,e){var d=$(e);if(d.hasClass("dropdownDivider")){return false}var b=d.find("span");a.push({cssClassName:b.data("cssClassName"),labelID:b.data("labelID"),label:b.text()})});return a},update:function(i,g,b){if(!this._conversations[i]){console.debug("[WCF.Conversation.EditorHandler] Unknown conversation id '"+i+"'");return}var c=this._conversations[i];switch(g){case"close":$('<li><span class="icon icon16 icon-lock jsTooltip jsIconLock" title="'+WCF.Language.get("wcf.global.state.closed")+'" /></li>').prependTo(c.find(".statusIcons"));this._attributes[i].isClosed=1;break;case"labelIDs":var a={};WCF.Dropdown.getDropdownMenu("conversationLabelFilter").find("li > a > span").each(function(k,l){var j=$(l);a[j.data("labelID")]={cssClassName:j.data("cssClassName"),label:j.text(),url:j.parent().attr("href")}});var f=c.find(".columnSubject > .labelList");if(!b.length){if(f.length){f.remove()}}else{if(!f.length){f=$('<ul class="labelList" />').prependTo(c.find(".columnSubject"))}f.empty();for(var h=0,e=b.length;h<e;h++){var d=a[b[h]];$('<li><a href="'+d.url+'" class="badge label'+(d.cssClassName?" "+d.cssClassName:"")+'">'+WCF.String.escapeHTML(d.label)+"</a> </li>").appendTo(f)}}break;case"open":c.find(".statusIcons li").each(function(j,l){var k=$(l);if(k.children("span.jsIconLock").length){k.remove();return false}});this._attributes[i].isClosed=0;break}WCF.Clipboard.reload()}});WCF.Conversation.EditorHandlerConversation=WCF.Conversation.EditorHandler.extend({_availableLabels:null,init:function(a){this._availableLabels=a||[];this._super()},getAvailableLabels:function(){return this._availableLabels},update:function(k,h,c){if(!this._conversations[k]){console.debug("[WCF.Conversation.EditorHandler] Unknown conversation id '"+k+"'");return}switch(h){case"close":$('<span class="icon icon16 icon-lock jsTooltip jsIconLock" title="'+WCF.Language.get("wcf.global.state.closed")+'" />').appendTo($("#content > header > h1"));this._attributes[k].isClosed=1;break;case"labelIDs":var j=$(".conversationHeadline");if(!c.length){j.find("ul.labelList").remove()}else{var f=j.find("ul.labelList");if(!f.length){f=$('<ul class="labelList" />').appendTo(j)}f.empty();for(var i=0,e=c.length;i<e;i++){var b=c[i];for(var g=0,a=this.getAvailableLabels().length;g<a;g++){var d=this.getAvailableLabels()[g];if(d.labelID==b){$('<li><span class="label badge'+(d.cssClassName?" "+d.cssClassName:"")+'">'+d.label+"</span> </li>").appendTo(f);break}}}}break;case"open":$("#content > header span.jsIconLock").remove();this._attributes[k].isClosed=0;break}}});WCF.Conversation.Clipboard=Class.extend({_editorHandler:null,init:function(editorHandler){this._editorHandler=editorHandler;$(".jsClipboardEditor").each($.proxy(function(index,container){var $container=$(container);var $types=eval($container.data("types"));if(WCF.inArray("com.woltlab.wcf.conversation.conversation",$types)){$container.on("clipboardAction",$.proxy(this._execute,this));$container.on("clipboardActionResponse",$.proxy(this._evaluateResponse,this));return false}},this))},_execute:function(d,b,a,c){if(b==="com.woltlab.wcf.conversation.conversation"&&a==="com.woltlab.wcf.conversation.conversation.assignLabel"){new WCF.Conversation.Label.Editor(this._editorHandler,null,c.objectIDs)}},_evaluateResponse:function(e,f,c,a,d){if(c!=="com.woltlab.wcf.conversation.conversation"){return}switch(a){case"com.woltlab.wcf.conversation.conversation.leave":case"com.woltlab.wcf.conversation.conversation.leavePermanently":case"com.woltlab.wcf.conversation.conversation.restore":window.location.reload();break;case"com.woltlab.wcf.conversation.conversation.close":case"com.woltlab.wcf.conversation.conversation.open":for(var g in f.returnValues.conversationData){var b=f.returnValues.conversationData[g];this._editorHandler.update(g,(b.isClosed?"close":"open"),b)}break}}});WCF.Conversation.InlineEditor=WCF.InlineEditor.extend({_editorHandler:null,_environment:"conversation",_setOptions:function(){this._options=[{label:WCF.Language.get("wcf.conversation.edit.close"),optionName:"close"},{label:WCF.Language.get("wcf.conversation.edit.open"),optionName:"open"},{label:WCF.Language.get("wcf.conversation.edit.assignLabel"),optionName:"assignLabel"},{optionName:"divider"},{label:WCF.Language.get("wcf.conversation.edit.addParticipants"),optionName:"addParticipants"},{label:WCF.Language.get("wcf.conversation.edit.leave"),optionName:"leave"}]},setEditorHandler:function(b,a){this._editorHandler=b;this._environment=(a=="list")?"list":"conversation"},_getTriggerElement:function(a){return a.find(".jsConversationInlineEditor")},_validate:function(a,b){var c=$("#"+a).data("conversationID");switch(b){case"addParticipants":return(this._editorHandler.getPermission(c,"canAddParticipants"));break;case"assignLabel":return(this._editorHandler.countAvailableLabels())?true:false;break;case"close":case"open":if(!this._editorHandler.getPermission(c,"canCloseConversation")){return false}if(b==="close"){return !(this._editorHandler.getValue(c,"isClosed"))}else{return(this._editorHandler.getValue(c,"isClosed"))}break;case"leave":return true;break}return false},_execute:function(a,b){if(!this._validate(a,b)){return false}switch(b){case"addParticipants":new WCF.Conversation.AddParticipants($("#"+a).data("conversationID"));break;case"assignLabel":new WCF.Conversation.Label.Editor(this._editorHandler,a);break;case"close":case"open":this._updateConversation(a,b,{isClosed:(b==="close"?1:0)});break;case"leave":new WCF.Conversation.Leave([$("#"+a).data("conversationID")],this._environment);break}},_updateConversation:function(a,b,c){var d=this._elements[a].data("conversationID");switch(b){case"close":case"open":this._updateData.push({elementID:a,optionName:b,data:c});this._proxy.setOption("data",{actionName:b,className:"wcf\\data\\conversation\\ConversationAction",objectIDs:[d]});this._proxy.sendRequest();break}},_updateState:function(){for(var d=0,c=this._updateData.length;d<c;d++){var a=this._updateData[d];var b=this._elements[a.elementID].data("conversationID");switch(a.optionName){case"close":this._editorHandler.update(b,"close",a.data);break;case"open":this._editorHandler.update(b,"open",a.data);break}}}});WCF.Conversation.Leave=Class.extend({_conversationIDs:[],_dialog:null,_environment:"",_proxy:null,init:function(b,a){this._conversationIDs=b;this._dialog=null;this._environment=a;this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});this._loadDialog()},_loadDialog:function(){this._proxy.setOption("data",{actionName:"getLeaveForm",className:"wcf\\data\\conversation\\ConversationAction",objectIDs:this._conversationIDs});this._proxy.sendRequest()},_success:function(b,c,a){switch(b.returnValues.actionName){case"getLeaveForm":this._showDialog(b);break;case"hideConversation":if(this._environment==="conversation"){window.location=b.returnValues.redirectURL}else{window.location.reload()}break}},_showDialog:function(a){if(this._dialog===null){this._dialog=$("#leaveDialog");if(!this._dialog.length){this._dialog=$('<div id="leaveDialog" />').hide().appendTo(document.body)}}this._dialog.html(a.returnValues.template);this._dialog.wcfDialog({title:WCF.Language.get("wcf.conversation.leave.title")});this._dialog.wcfDialog("render");this._dialog.find("#hideConversation").click($.proxy(this._click,this))},_click:function(){var a=this._dialog.find("input[type=radio]:checked");if(a.length===1){this._proxy.setOption("data",{actionName:"hideConversation",className:"wcf\\data\\conversation\\ConversationAction",objectIDs:this._conversationIDs,parameters:{hideConversation:a.val()}});this._proxy.sendRequest()}}});WCF.Conversation.AddParticipants=Class.extend({_conversationID:0,_dialog:null,_proxy:null,init:function(a){this._conversationID=a;this._dialog=$("#conversationAddParticipants");if(!this._dialog.length){this._dialog=$('<div id="conversationAddParticipants" />').hide().appendTo(document.body)}this._proxy=new WCF.Action.Proxy({autoSend:true,data:{actionName:"getAddParticipantsForm",className:"wcf\\data\\conversation\\ConversationAction",objectIDs:[this._conversationID]},success:$.proxy(this._success,this)})},_success:function(b,d,a){switch(b.returnValues.actionName){case"addParticipants":if(b.returnValues.errorMessage){this._dialog.find("dl.jsAddParticipants").addClass("formError");this._dialog.find("dl.jsAddParticipants > dd small.innerError").remove();$('<small class="innerError">'+b.returnValues.errorMessage+"</small>").appendTo(this._dialog.find("dl.jsAddParticipants > dd"));return}if(b.returnValues.count){var c=new WCF.System.Notification(b.returnValues.successMessage);c.show()}this._dialog.find("dl.jsAddParticipants").removeClass("formError").find("small.innerError").remove();this._dialog.wcfDialog("close");break;case"getAddParticipantsForm":this._renderForm(b);break}},_renderForm:function(c){this._dialog.html(c.returnValues.template);var a=this._dialog.find("#addParticipants").disable().click($.proxy(this._submit,this));new WCF.Search.User("#participantsInput",null,false,c.returnValues.excludeSearchValues,true);var b=$("#participantsInput");b.keyup(function(){if($.trim(b.val())===""){a.disable()}else{a.enable()}});this._dialog.wcfDialog({title:WCF.Language.get("wcf.conversation.edit.addParticipants")})},_submit:function(){var a=$.trim($("#participantsInput").val());if(a==""){this._dialog.wcfDialog("close")}this._proxy.setOption("data",{actionName:"addParticipants",className:"wcf\\data\\conversation\\ConversationAction",objectIDs:[this._conversationID],parameters:{participants:a}});this._proxy.sendRequest()}});WCF.Conversation.RemoveParticipant=WCF.Action.Delete.extend({_conversationID:0,init:function(a){this._conversationID=a;this._super("wcf\\data\\conversation\\ConversationAction",".jsParticipant")},_sendRequest:function(a){this.proxy.setOption("data",{actionName:"removeParticipant",className:this._className,objectIDs:[this._conversationID],parameters:{userID:$(a).data("objectID")}});this.proxy.sendRequest()},_success:function(d,f,c){var b=d.returnValues.userID;for(var a in this._containers){var e=$("#"+this._containers[a]);if(e.find(".jsDeleteButton").data("objectID")==b){e.find(".userLink").addClass("conversationLeft");e.find(".jsDeleteButton").remove()}}}});WCF.Conversation.Label={};WCF.Conversation.Label.Editor=Class.extend({_conversationIDs:0,_dialog:null,_editorHandler:null,_notification:null,_proxy:null,init:function(c,b,a){if(b){this._conversationIDs=[$("#"+b).data("conversationID")]}else{this._conversationIDs=a}this._dialog=null;this._editorHandler=c;this._notification=new WCF.System.Notification(WCF.Language.get("wcf.global.success.edit"));this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});this._loadDialog()},_loadDialog:function(){this._proxy.setOption("data",{actionName:"getLabelForm",className:"wcf\\data\\conversation\\label\\ConversationLabelAction",parameters:{conversationIDs:this._conversationIDs}});this._proxy.sendRequest()},_success:function(b,c,a){switch(b.returnValues.actionName){case"assignLabel":this._assignLabels(b);break;case"getLabelForm":this._renderDialog(b);break}},_renderDialog:function(a){if(this._dialog===null){this._dialog=$("#conversationLabelForm");if(!this._dialog.length){this._dialog=$('<div id="conversationLabelForm" />').hide().appendTo(document.body)}}this._dialog.html(a.returnValues.template);this._dialog.wcfDialog({title:WCF.Language.get("wcf.conversation.label.assignLabels")});this._dialog.wcfDialog("render");$("#assignLabels").click($.proxy(this._save,this))},_save:function(){var a=[];this._dialog.find("input").each(function(b,d){var c=$(d);if(c.is(":checked")){a.push(c.data("labelID"))}});this._proxy.setOption("data",{actionName:"assignLabel",className:"wcf\\data\\conversation\\label\\ConversationLabelAction",parameters:{conversationIDs:this._conversationIDs,labelIDs:a}});this._proxy.sendRequest()},_assignLabels:function(a){for(var c=0,b=this._conversationIDs.length;c<b;c++){this._editorHandler.update(this._conversationIDs[c],"labelIDs",a.returnValues.labelIDs)}this._dialog.wcfDialog("close");this._notification.show()}});WCF.Conversation.Label.Manager=Class.extend({_deletedLabelID:0,_dialog:null,_labels:null,_link:"",_notification:"",_proxy:null,init:function(a){this._deletedLabelID=0;this._link=a;this._labels=WCF.Dropdown.getDropdownMenu("conversationLabelFilter").children(".scrollableDropdownMenu");$("#manageLabel").click($.proxy(this._click,this));this._notification=new WCF.System.Notification(WCF.Language.get("wcf.conversation.label.management.addLabel.success"));this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)})},_click:function(){this._proxy.setOption("data",{actionName:"getLabelManagement",className:"wcf\\data\\conversation\\ConversationAction"});this._proxy.sendRequest()},_success:function(c,d,b){if(this._dialog===null){this._dialog=$('<div id="labelManagement" />').hide().appendTo(document.body)}if(c.returnValues&&c.returnValues.actionName){switch(c.returnValues.actionName){case"add":this._insertLabel(c);break;case"getLabelManagement":this._dialog.empty().html(c.returnValues.template);this._dialog.wcfDialog({title:WCF.Language.get("wcf.conversation.label.management")});this._dialog.wcfDialog("render");this._bindListener();break}}else{if(this._deletedLabelID){var a=new RegExp("(\\?|&)labelID="+this._deletedLabelID);window.location=window.location.toString().replace(a,"")}else{window.location.reload()}}},_insertLabel:function(b){var a=$('<li><a href="'+this._link+"&labelID="+b.returnValues.labelID+'"><span class="badge label'+(b.returnValues.cssClassName?" "+b.returnValues.cssClassName:"")+'">'+b.returnValues.label+"</span></a></li>");a.find("a > span").data("labelID",b.returnValues.labelID).data("cssClassName",b.returnValues.cssClassName);this._labels.append(a);this._notification.show()},_bindListener:function(){$("#labelName").on("keyup keydown keypress",$.proxy(this._updateLabels,this));$("#addLabel").disable().click($.proxy(this._addLabel,this));$("#editLabel").disable();this._dialog.find(".conversationLabelList a.label").click($.proxy(this._edit,this))},_edit:function(c){var b=$(c.currentTarget);var d=WCF.Language.get("wcf.conversation.label.management.editLabel").replace(/#labelName#/,WCF.String.escapeHTML(b.text()));$("#conversationLabelManagementForm").data("labelID",b.data("labelID")).children("legend").html(d);$("#labelName").val(b.text()).trigger("keyup");var a=b.data("cssClassName");$("#labelManagementList input").each(function(f,e){var g=$(e);if(g.val()==a){g.attr("checked","checked")}});$("#addLabel").hide();$("#editLabel").show().click($.proxy(this._editLabel,this));$("#deleteLabel").show().click($.proxy(this._deleteLabel,this))},_editLabel:function(){this._proxy.setOption("data",{actionName:"update",className:"wcf\\data\\conversation\\label\\ConversationLabelAction",objectIDs:[$("#conversationLabelManagementForm").data("labelID")],parameters:{data:{cssClassName:$("#labelManagementList input:checked").val(),label:$("#labelName").val()}}});this._proxy.sendRequest()},_deleteLabel:function(){var a=WCF.Language.get("wcf.conversation.label.management.deleteLabel.confirmMessage").replace(/#labelName#/,$("#labelName").val());WCF.System.Confirmation.show(a,$.proxy(function(b){if(b==="confirm"){this._proxy.setOption("data",{actionName:"delete",className:"wcf\\data\\conversation\\label\\ConversationLabelAction",objectIDs:[$("#conversationLabelManagementForm").data("labelID")]});this._proxy.sendRequest();this._deletedLabelID=$("#conversationLabelManagementForm").data("labelID")}},this))},_updateLabels:function(){var a=$.trim($("#labelName").val());if(a){$("#addLabel, #editLabel").enable()}else{$("#addLabel, #editLabel").disable();a=WCF.Language.get("wcf.conversation.label.placeholder")}$("#labelManagementList").find("span.label").text(a)},_addLabel:function(){var b=$("#labelName").val();var a=$("#labelManagementList input:checked").val();this._proxy.setOption("data",{actionName:"add",className:"wcf\\data\\conversation\\label\\ConversationLabelAction",parameters:{data:{cssClassName:a,labelName:b}}});this._proxy.sendRequest();this._dialog.wcfDialog("close")}});WCF.Conversation.Preview=WCF.Popover.extend({_proxy:null,init:function(){this._super(".conversationLink");this._proxy=new WCF.Action.Proxy({showLoadingOverlay:false});WCF.DOMNodeInsertedHandler.addCallback("WCF.Conversation.Preview",$.proxy(this._initContainers,this))},_loadContent:function(){var b=$("#"+this._activeElementID);this._proxy.setOption("data",{actionName:"getMessagePreview",className:"wcf\\data\\conversation\\ConversationAction",objectIDs:[b.data("conversationID")]});var c=this._activeElementID;var a=this;this._proxy.setOption("success",function(e,f,d){a._insertContent(c,e.returnValues.template,true)});this._proxy.sendRequest()}});WCF.Conversation.UserPanel=WCF.UserPanel.extend({_addLink:"",_showAllLink:"",init:function(a,b){this._addLink=b;this._noItems="wcf.conversation.noMoreItems";this._showAllLink=a;this._super("unreadConversations")},_addDefaultItems:function(a){this._addDivider(a);$('<li><a href="'+this._showAllLink+'">'+WCF.Language.get("wcf.conversation.showAll")+"</a></li>").appendTo(a);this._addDivider(a);$('<li><a href="'+this._addLink+'">'+WCF.Language.get("wcf.conversation.add")+"</a></li>").appendTo(a)},_getParameters:function(){return{actionName:"getUnreadConversations",className:"wcf\\data\\conversation\\ConversationAction"}}});WCF.Conversation.QuickReply=WCF.Message.QuickReply.extend({init:function(a){this._super(true,a)},_getClassName:function(){return"wcf\\data\\conversation\\message\\ConversationMessageAction"},_getObjectID:function(){return this._container.data("conversationID")}});WCF.Conversation.MarkAsRead=Class.extend({_proxy:null,init:function(){this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});$(document).on("dblclick",".conversationList .new .columnAvatar",$.proxy(this._dblclick,this))},_dblclick:function(a){this._proxy.setOption("data",{actionName:"markAsRead",className:"wcf\\data\\conversation\\ConversationAction",objectIDs:[$(a.currentTarget).parents("tr:eq(0)").data("conversationID")]});this._proxy.sendRequest()},_success:function(b,c,a){$(".conversationList .new").each(function(e,f){var d=$(f);if(WCF.inArray(d.data("conversationID"),b.objectIDs)){d.removeClass("new");d.find(".firstNewPost").parent().remove();d.find(".columnAvatar").off("dblclick")}})}});WCF.Conversation.Message={};WCF.Conversation.Message.InlineEditor=WCF.Message.InlineEditor.extend({init:function(a){this._super(a,true)},_getClassName:function(){return"wcf\\data\\conversation\\message\\ConversationMessageAction"}});WCF.Conversation.Message.QuoteHandler=WCF.Message.Quote.Handler.extend({init:function(a){this._super(a,"wcf\\data\\conversation\\message\\ConversationMessageAction","com.woltlab.wcf.conversation.message",".message",".messageBody",".messageBody > div > div.messageText")}});
\ No newline at end of file
+WCF.Conversation={};WCF.Conversation.EditorHandler=Class.extend({_attributes:{},_conversations:{},_permissions:{},init:function(availableLabels){this._conversations={};var self=this;$(".conversation").each(function(index,conversation){var $conversation=$(conversation);var $conversationID=$conversation.data("conversationID");if(!self._conversations[$conversationID]){self._conversations[$conversationID]=$conversation;var $labelIDs=eval($conversation.data("labelIDs"));self._attributes[$conversationID]={isClosed:($conversation.data("isClosed")?true:false),labelIDs:$labelIDs};self._permissions[$conversationID]={canAddParticipants:($conversation.data("canAddParticipants")?true:false),canCloseConversation:($conversation.data("canCloseConversation")?true:false)}}})},getPermission:function(b,a){if(this._permissions[b][a]===undefined){return false}return(this._permissions[b][a])?true:false},getValue:function(b,a){switch(a){case"labelIDs":if(this._attributes[b].labelIDs===undefined){this._attributes[b].labelIDs=[]}return this._attributes[b].labelIDs;break;case"isClosed":return(this._attributes[b].isClosed)?true:false;break}},countAvailableLabels:function(){return(this.getAvailableLabels()).length},getAvailableLabels:function(){var a=[];WCF.Dropdown.getDropdownMenu("conversationLabelFilter").children("li").each(function(c,e){var d=$(e);if(d.hasClass("dropdownDivider")){return false}var b=d.find("span");a.push({cssClassName:b.data("cssClassName"),labelID:b.data("labelID"),label:b.text()})});return a},update:function(i,g,b){if(!this._conversations[i]){console.debug("[WCF.Conversation.EditorHandler] Unknown conversation id '"+i+"'");return}var c=this._conversations[i];switch(g){case"close":$('<li><span class="icon icon16 icon-lock jsTooltip jsIconLock" title="'+WCF.Language.get("wcf.global.state.closed")+'" /></li>').prependTo(c.find(".statusIcons"));this._attributes[i].isClosed=1;break;case"labelIDs":var a={};WCF.Dropdown.getDropdownMenu("conversationLabelFilter").find("li > a > span").each(function(k,l){var j=$(l);a[j.data("labelID")]={cssClassName:j.data("cssClassName"),label:j.text(),url:j.parent().attr("href")}});var f=c.find(".columnSubject > .labelList");if(!b.length){if(f.length){f.remove()}}else{if(!f.length){f=$('<ul class="labelList" />').prependTo(c.find(".columnSubject"))}f.empty();for(var h=0,e=b.length;h<e;h++){var d=a[b[h]];$('<li><a href="'+d.url+'" class="badge label'+(d.cssClassName?" "+d.cssClassName:"")+'">'+WCF.String.escapeHTML(d.label)+"</a> </li>").appendTo(f)}}break;case"open":c.find(".statusIcons li").each(function(j,l){var k=$(l);if(k.children("span.jsIconLock").length){k.remove();return false}});this._attributes[i].isClosed=0;break}WCF.Clipboard.reload()}});WCF.Conversation.EditorHandlerConversation=WCF.Conversation.EditorHandler.extend({_availableLabels:null,init:function(a){this._availableLabels=a||[];this._super()},getAvailableLabels:function(){return this._availableLabels},update:function(k,h,c){if(!this._conversations[k]){console.debug("[WCF.Conversation.EditorHandler] Unknown conversation id '"+k+"'");return}switch(h){case"close":$('<span class="icon icon16 icon-lock jsTooltip jsIconLock" title="'+WCF.Language.get("wcf.global.state.closed")+'" />').appendTo($("#content > header > h1"));this._attributes[k].isClosed=1;break;case"labelIDs":var j=$(".conversationHeadline");if(!c.length){j.find("ul.labelList").remove()}else{var f=j.find("ul.labelList");if(!f.length){f=$('<ul class="labelList" />').appendTo(j)}f.empty();for(var i=0,e=c.length;i<e;i++){var b=c[i];for(var g=0,a=this.getAvailableLabels().length;g<a;g++){var d=this.getAvailableLabels()[g];if(d.labelID==b){$('<li><span class="label badge'+(d.cssClassName?" "+d.cssClassName:"")+'">'+d.label+"</span> </li>").appendTo(f);break}}}}break;case"open":$("#content > header span.jsIconLock").remove();this._attributes[k].isClosed=0;break}}});WCF.Conversation.Clipboard=Class.extend({_editorHandler:null,init:function(editorHandler){this._editorHandler=editorHandler;$(".jsClipboardEditor").each($.proxy(function(index,container){var $container=$(container);var $types=eval($container.data("types"));if(WCF.inArray("com.woltlab.wcf.conversation.conversation",$types)){$container.on("clipboardAction",$.proxy(this._execute,this));$container.on("clipboardActionResponse",$.proxy(this._evaluateResponse,this));return false}},this))},_execute:function(d,b,a,c){if(b==="com.woltlab.wcf.conversation.conversation"&&a==="com.woltlab.wcf.conversation.conversation.assignLabel"){new WCF.Conversation.Label.Editor(this._editorHandler,null,c.objectIDs)}},_evaluateResponse:function(e,f,c,a,d){if(c!=="com.woltlab.wcf.conversation.conversation"){return}switch(a){case"com.woltlab.wcf.conversation.conversation.leave":case"com.woltlab.wcf.conversation.conversation.leavePermanently":case"com.woltlab.wcf.conversation.conversation.restore":window.location.reload();break;case"com.woltlab.wcf.conversation.conversation.close":case"com.woltlab.wcf.conversation.conversation.open":for(var g in f.returnValues.conversationData){var b=f.returnValues.conversationData[g];this._editorHandler.update(g,(b.isClosed?"close":"open"),b)}break}}});WCF.Conversation.InlineEditor=WCF.InlineEditor.extend({_editorHandler:null,_environment:"conversation",_setOptions:function(){this._options=[{label:WCF.Language.get("wcf.conversation.edit.close"),optionName:"close"},{label:WCF.Language.get("wcf.conversation.edit.open"),optionName:"open"},{label:WCF.Language.get("wcf.conversation.edit.assignLabel"),optionName:"assignLabel"},{optionName:"divider"},{label:WCF.Language.get("wcf.conversation.edit.addParticipants"),optionName:"addParticipants"},{label:WCF.Language.get("wcf.conversation.edit.leave"),optionName:"leave"}]},setEditorHandler:function(b,a){this._editorHandler=b;this._environment=(a=="list")?"list":"conversation"},_getTriggerElement:function(a){return a.find(".jsConversationInlineEditor")},_validate:function(a,b){var c=$("#"+a).data("conversationID");switch(b){case"addParticipants":return(this._editorHandler.getPermission(c,"canAddParticipants"));break;case"assignLabel":return(this._editorHandler.countAvailableLabels())?true:false;break;case"close":case"open":if(!this._editorHandler.getPermission(c,"canCloseConversation")){return false}if(b==="close"){return !(this._editorHandler.getValue(c,"isClosed"))}else{return(this._editorHandler.getValue(c,"isClosed"))}break;case"leave":return true;break}return false},_execute:function(a,b){if(!this._validate(a,b)){return false}switch(b){case"addParticipants":new WCF.Conversation.AddParticipants($("#"+a).data("conversationID"));break;case"assignLabel":new WCF.Conversation.Label.Editor(this._editorHandler,a);break;case"close":case"open":this._updateConversation(a,b,{isClosed:(b==="close"?1:0)});break;case"leave":new WCF.Conversation.Leave([$("#"+a).data("conversationID")],this._environment);break}},_updateConversation:function(a,b,c){var d=this._elements[a].data("conversationID");switch(b){case"close":case"open":this._updateData.push({elementID:a,optionName:b,data:c});this._proxy.setOption("data",{actionName:b,className:"wcf\\data\\conversation\\ConversationAction",objectIDs:[d]});this._proxy.sendRequest();break}},_updateState:function(){for(var d=0,c=this._updateData.length;d<c;d++){var a=this._updateData[d];var b=this._elements[a.elementID].data("conversationID");switch(a.optionName){case"close":this._editorHandler.update(b,"close",a.data);break;case"open":this._editorHandler.update(b,"open",a.data);break}}}});WCF.Conversation.Leave=Class.extend({_conversationIDs:[],_dialog:null,_environment:"",_proxy:null,init:function(b,a){this._conversationIDs=b;this._dialog=null;this._environment=a;this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});this._loadDialog()},_loadDialog:function(){this._proxy.setOption("data",{actionName:"getLeaveForm",className:"wcf\\data\\conversation\\ConversationAction",objectIDs:this._conversationIDs});this._proxy.sendRequest()},_success:function(b,c,a){switch(b.returnValues.actionName){case"getLeaveForm":this._showDialog(b);break;case"hideConversation":if(this._environment==="conversation"){window.location=b.returnValues.redirectURL}else{window.location.reload()}break}},_showDialog:function(a){if(this._dialog===null){this._dialog=$("#leaveDialog");if(!this._dialog.length){this._dialog=$('<div id="leaveDialog" />').hide().appendTo(document.body)}}this._dialog.html(a.returnValues.template);this._dialog.wcfDialog({title:WCF.Language.get("wcf.conversation.leave.title")});this._dialog.wcfDialog("render");this._dialog.find("#hideConversation").click($.proxy(this._click,this))},_click:function(){var a=this._dialog.find("input[type=radio]:checked");if(a.length===1){this._proxy.setOption("data",{actionName:"hideConversation",className:"wcf\\data\\conversation\\ConversationAction",objectIDs:this._conversationIDs,parameters:{hideConversation:a.val()}});this._proxy.sendRequest()}}});WCF.Conversation.AddParticipants=Class.extend({_conversationID:0,_dialog:null,_proxy:null,init:function(a){this._conversationID=a;this._dialog=$("#conversationAddParticipants");if(!this._dialog.length){this._dialog=$('<div id="conversationAddParticipants" />').hide().appendTo(document.body)}this._proxy=new WCF.Action.Proxy({autoSend:true,data:{actionName:"getAddParticipantsForm",className:"wcf\\data\\conversation\\ConversationAction",objectIDs:[this._conversationID]},success:$.proxy(this._success,this)})},_success:function(b,d,a){switch(b.returnValues.actionName){case"addParticipants":if(b.returnValues.errorMessage){this._dialog.find("dl.jsAddParticipants").addClass("formError");this._dialog.find("dl.jsAddParticipants > dd small.innerError").remove();$('<small class="innerError">'+b.returnValues.errorMessage+"</small>").appendTo(this._dialog.find("dl.jsAddParticipants > dd"));return}if(b.returnValues.count){var c=new WCF.System.Notification(b.returnValues.successMessage);c.show()}this._dialog.find("dl.jsAddParticipants").removeClass("formError").find("small.innerError").remove();this._dialog.wcfDialog("close");break;case"getAddParticipantsForm":this._renderForm(b);break}},_renderForm:function(c){this._dialog.html(c.returnValues.template);var a=this._dialog.find("#addParticipants").disable().click($.proxy(this._submit,this));new WCF.Search.User("#participantsInput",null,false,c.returnValues.excludeSearchValues,true);var b=$("#participantsInput");b.keyup(function(){if($.trim(b.val())===""){a.disable()}else{a.enable()}});this._dialog.wcfDialog({title:WCF.Language.get("wcf.conversation.edit.addParticipants")})},_submit:function(){var a=$.trim($("#participantsInput").val());if(a==""){this._dialog.wcfDialog("close")}this._proxy.setOption("data",{actionName:"addParticipants",className:"wcf\\data\\conversation\\ConversationAction",objectIDs:[this._conversationID],parameters:{participants:a}});this._proxy.sendRequest()}});WCF.Conversation.RemoveParticipant=WCF.Action.Delete.extend({_conversationID:0,init:function(a){this._conversationID=a;this._super("wcf\\data\\conversation\\ConversationAction",".jsParticipant")},_sendRequest:function(a){this.proxy.setOption("data",{actionName:"removeParticipant",className:this._className,objectIDs:[this._conversationID],parameters:{userID:$(a).data("objectID")}});this.proxy.sendRequest()},_success:function(d,f,c){var b=d.returnValues.userID;for(var a in this._containers){var e=$("#"+this._containers[a]);if(e.find(".jsDeleteButton").data("objectID")==b){e.find(".userLink").addClass("conversationLeft");e.find(".jsDeleteButton").remove()}}}});WCF.Conversation.Label={};WCF.Conversation.Label.Editor=Class.extend({_conversationIDs:0,_dialog:null,_editorHandler:null,_notification:null,_proxy:null,init:function(c,b,a){if(b){this._conversationIDs=[$("#"+b).data("conversationID")]}else{this._conversationIDs=a}this._dialog=null;this._editorHandler=c;this._notification=new WCF.System.Notification(WCF.Language.get("wcf.global.success.edit"));this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});this._loadDialog()},_loadDialog:function(){this._proxy.setOption("data",{actionName:"getLabelForm",className:"wcf\\data\\conversation\\label\\ConversationLabelAction",parameters:{conversationIDs:this._conversationIDs}});this._proxy.sendRequest()},_success:function(b,c,a){switch(b.returnValues.actionName){case"assignLabel":this._assignLabels(b);break;case"getLabelForm":this._renderDialog(b);break}},_renderDialog:function(a){if(this._dialog===null){this._dialog=$("#conversationLabelForm");if(!this._dialog.length){this._dialog=$('<div id="conversationLabelForm" />').hide().appendTo(document.body)}}this._dialog.html(a.returnValues.template);this._dialog.wcfDialog({title:WCF.Language.get("wcf.conversation.label.assignLabels")});this._dialog.wcfDialog("render");$("#assignLabels").click($.proxy(this._save,this))},_save:function(){var a=[];this._dialog.find("input").each(function(b,d){var c=$(d);if(c.is(":checked")){a.push(c.data("labelID"))}});this._proxy.setOption("data",{actionName:"assignLabel",className:"wcf\\data\\conversation\\label\\ConversationLabelAction",parameters:{conversationIDs:this._conversationIDs,labelIDs:a}});this._proxy.sendRequest()},_assignLabels:function(a){for(var c=0,b=this._conversationIDs.length;c<b;c++){this._editorHandler.update(this._conversationIDs[c],"labelIDs",a.returnValues.labelIDs)}this._dialog.wcfDialog("close");this._notification.show()}});WCF.Conversation.Label.Manager=Class.extend({_deletedLabelID:0,_dialog:null,_labels:null,_link:"",_notification:"",_proxy:null,init:function(a){this._deletedLabelID=0;this._link=a;this._labels=WCF.Dropdown.getDropdownMenu("conversationLabelFilter").children(".scrollableDropdownMenu");$("#manageLabel").click($.proxy(this._click,this));this._notification=new WCF.System.Notification(WCF.Language.get("wcf.conversation.label.management.addLabel.success"));this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)})},_click:function(){this._proxy.setOption("data",{actionName:"getLabelManagement",className:"wcf\\data\\conversation\\ConversationAction"});this._proxy.sendRequest()},_success:function(c,d,b){if(this._dialog===null){this._dialog=$('<div id="labelManagement" />').hide().appendTo(document.body)}if(c.returnValues&&c.returnValues.actionName){switch(c.returnValues.actionName){case"add":this._insertLabel(c);break;case"getLabelManagement":this._dialog.empty().html(c.returnValues.template);this._dialog.wcfDialog({title:WCF.Language.get("wcf.conversation.label.management")});this._dialog.wcfDialog("render");this._bindListener();break}}else{if(this._deletedLabelID){var a=new RegExp("(\\?|&)labelID="+this._deletedLabelID);window.location=window.location.toString().replace(a,"")}else{window.location.reload()}}},_insertLabel:function(b){var a=$('<li><a href="'+this._link+"&labelID="+b.returnValues.labelID+'"><span class="badge label'+(b.returnValues.cssClassName?" "+b.returnValues.cssClassName:"")+'">'+b.returnValues.label+"</span></a></li>");a.find("a > span").data("labelID",b.returnValues.labelID).data("cssClassName",b.returnValues.cssClassName);this._labels.append(a);this._notification.show()},_bindListener:function(){$("#labelName").on("keyup keydown keypress",$.proxy(this._updateLabels,this));$("#addLabel").disable().click($.proxy(this._addLabel,this));$("#editLabel").disable();this._dialog.find(".conversationLabelList a.label").click($.proxy(this._edit,this))},_edit:function(c){var b=$(c.currentTarget);var d=WCF.Language.get("wcf.conversation.label.management.editLabel").replace(/#labelName#/,WCF.String.escapeHTML(b.text()));$("#conversationLabelManagementForm").data("labelID",b.data("labelID")).children("legend").html(d);$("#labelName").val(b.text()).trigger("keyup");var a=b.data("cssClassName");$("#labelManagementList input").each(function(f,e){var g=$(e);if(g.val()==a){g.attr("checked","checked")}});$("#addLabel").hide();$("#editLabel").show().click($.proxy(this._editLabel,this));$("#deleteLabel").show().click($.proxy(this._deleteLabel,this))},_editLabel:function(){this._proxy.setOption("data",{actionName:"update",className:"wcf\\data\\conversation\\label\\ConversationLabelAction",objectIDs:[$("#conversationLabelManagementForm").data("labelID")],parameters:{data:{cssClassName:$("#labelManagementList input:checked").val(),label:$("#labelName").val()}}});this._proxy.sendRequest()},_deleteLabel:function(){var a=WCF.Language.get("wcf.conversation.label.management.deleteLabel.confirmMessage").replace(/#labelName#/,$("#labelName").val());WCF.System.Confirmation.show(a,$.proxy(function(b){if(b==="confirm"){this._proxy.setOption("data",{actionName:"delete",className:"wcf\\data\\conversation\\label\\ConversationLabelAction",objectIDs:[$("#conversationLabelManagementForm").data("labelID")]});this._proxy.sendRequest();this._deletedLabelID=$("#conversationLabelManagementForm").data("labelID")}},this))},_updateLabels:function(){var a=$.trim($("#labelName").val());if(a){$("#addLabel, #editLabel").enable()}else{$("#addLabel, #editLabel").disable();a=WCF.Language.get("wcf.conversation.label.placeholder")}$("#labelManagementList").find("span.label").text(a)},_addLabel:function(){var b=$("#labelName").val();var a=$("#labelManagementList input:checked").val();this._proxy.setOption("data",{actionName:"add",className:"wcf\\data\\conversation\\label\\ConversationLabelAction",parameters:{data:{cssClassName:a,labelName:b}}});this._proxy.sendRequest();this._dialog.wcfDialog("close")}});WCF.Conversation.Preview=WCF.Popover.extend({_proxy:null,init:function(){this._super(".conversationLink");this._proxy=new WCF.Action.Proxy({showLoadingOverlay:false});WCF.DOMNodeInsertedHandler.addCallback("WCF.Conversation.Preview",$.proxy(this._initContainers,this))},_loadContent:function(){var b=$("#"+this._activeElementID);this._proxy.setOption("data",{actionName:"getMessagePreview",className:"wcf\\data\\conversation\\ConversationAction",objectIDs:[b.data("conversationID")]});var c=this._activeElementID;var a=this;this._proxy.setOption("success",function(e,f,d){a._insertContent(c,e.returnValues.template,true)});this._proxy.sendRequest()}});WCF.Conversation.UserPanel=WCF.UserPanel.extend({_addLink:"",_showAllLink:"",init:function(a,b){this._addLink=b;this._noItems="wcf.conversation.noMoreItems";this._showAllLink=a;this._super("unreadConversations")},_addDefaultItems:function(a){this._addDivider(a);$('<li><a href="'+this._showAllLink+'">'+WCF.Language.get("wcf.conversation.showAll")+"</a></li>").appendTo(a);this._addDivider(a);$('<li><a href="'+this._addLink+'">'+WCF.Language.get("wcf.conversation.add")+"</a></li>").appendTo(a)},_getParameters:function(){return{actionName:"getUnreadConversations",className:"wcf\\data\\conversation\\ConversationAction"}}});WCF.Conversation.QuickReply=WCF.Message.QuickReply.extend({init:function(a){this._super(true,a)},_getClassName:function(){return"wcf\\data\\conversation\\message\\ConversationMessageAction"},_getObjectID:function(){return this._container.data("conversationID")}});WCF.Conversation.MarkAsRead=Class.extend({_proxy:null,init:function(){this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});$(document).on("dblclick",".conversationList .new .columnAvatar",$.proxy(this._dblclick,this))},_dblclick:function(a){this._proxy.setOption("data",{actionName:"markAsRead",className:"wcf\\data\\conversation\\ConversationAction",objectIDs:[$(a.currentTarget).parents("tr:eq(0)").data("conversationID")]});this._proxy.sendRequest()},_success:function(b,c,a){$(".conversationList .new").each(function(e,f){var d=$(f);if(WCF.inArray(d.data("conversationID"),b.objectIDs)){d.removeClass("new");d.find(".firstNewPost").parent().remove();d.find(".columnAvatar").off("dblclick")}})}});WCF.Conversation.MarkAllAsRead=Class.extend({_proxy:null,init:function(){this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});$(".markAllAsReadButton").click($.proxy(this._dblClick,this))},_dblClick:function(a){this._proxy.setOption("data",{actionName:"markAllAsRead",className:"wcf\\data\\conversation\\ConversationAction"});this._proxy.sendRequest()},_success:function(e,f,d){var a=WCF.Dropdown.getDropdownMenu("unreadConversations");var b=a.children(".jsDropdownPlaceholder").remove();a.data("count",0);a.children().each(function(g,i){var h=$(i);if(h.hasClass("dropdownDivider")){return false}h.remove()});if(!b.length){$("<li><span>"+WCF.Language.get("wcf.conversation.noMoreItems")+"</span></li>").prependTo(a)}$("#unreadConversations .badge").remove();var c=$(".conversationList");c.find(".new").removeClass("new");c.find(".columnAvatar").off("dblclick")}});WCF.Conversation.Message={};WCF.Conversation.Message.InlineEditor=WCF.Message.InlineEditor.extend({init:function(a){this._super(a,true)},_getClassName:function(){return"wcf\\data\\conversation\\message\\ConversationMessageAction"}});WCF.Conversation.Message.QuoteHandler=WCF.Message.Quote.Handler.extend({init:function(a){this._super(a,"wcf\\data\\conversation\\message\\ConversationMessageAction","com.woltlab.wcf.conversation.message",".message",".messageBody",".messageBody > div > div.messageText")}});
\ No newline at end of file