-WCF.Message={};WCF.Message.BBCode={};WCF.Message.BBCode.CodeViewer=Class.extend({_dialog:null,init:function(){this._dialog=null;this._initCodeBoxes();WCF.DOMNodeInsertedHandler.addCallback("WCF.Message.BBCode.CodeViewer",$.proxy(this._initCodeBoxes,this));WCF.DOMNodeInsertedHandler.execute()},_initCodeBoxes:function(){$(".codeBox:not(.jsCodeViewer)").each($.proxy(function(a,c){var b=$(c).addClass("jsCodeViewer");$('<span class="icon icon16 icon-copy pointer jsTooltip" title="'+WCF.Language.get("wcf.message.bbcode.code.copy")+'" />').appendTo(b.find("div > h3")).click($.proxy(this._click,this))},this))},_click:function(b){var a="";$(b.currentTarget).parents("div").next("ol").children("li").each(function(c,d){if(a){a+="\n"}a+=$(d).text().replace(/\n+$/,"")});if(this._dialog===null){this._dialog=$('<div><textarea cols="60" rows="12" readonly="readonly" /></div>').hide().appendTo(document.body);this._dialog.children("textarea").val(a);this._dialog.wcfDialog({title:WCF.Language.get("wcf.message.bbcode.code.copy")})}else{this._dialog.children("textarea").val(a);this._dialog.wcfDialog("open")}this._dialog.children("textarea").select()}});WCF.Message.FormGuard=Class.extend({init:function(){var a=$("form.jsFormGuard").removeClass("jsFormGuard").submit(function(){$(this).find(".formSubmit input[type=submit]").disable()});$(window).unload(function(){a.find(".formSubmit input[type=submit]").enable()})}});WCF.Message.Preview=Class.extend({_className:"",_messageFieldID:"",_messageField:null,_proxy:null,_previewButton:null,_previewButtonLabel:"",init:function(b,a,c){this._className=b;this._messageFieldID=$.wcfEscapeID(a);this._messageField=$("#"+this._messageFieldID);if(!this._messageField.length){console.debug("[WCF.Message.Preview] Unable to find message field identified by '"+this._messageFieldID+"'");return}c=$.wcfEscapeID(c);this._previewButton=$("#"+c);if(!this._previewButton.length){console.debug("[WCF.Message.Preview] Unable to find preview button identified by '"+c+"'");return}this._previewButton.click($.proxy(this._click,this));this._proxy=new WCF.Action.Proxy({failure:$.proxy(this._failure,this),success:$.proxy(this._success,this)})},_click:function(b){var a=this._getMessage();if(a===null){console.debug("[WCF.Message.Preview] Unable to access ckEditor instance of '"+this._messageFieldID+"'");return}this._proxy.setOption("data",{actionName:"getMessagePreview",className:this._className,parameters:this._getParameters(a)});this._proxy.sendRequest();this._previewButtonLabel=this._previewButton.html();this._previewButton.html(WCF.Language.get("wcf.global.loading")).disable();b.stopPropagation();return false},_getParameters:function(b){var a={};$("#settings").find("input[type=checkbox]").each(function(c,e){var d=$(e);if(d.is(":checked")){a[d.prop("name")]=d.prop("value")}});return{data:{message:b},options:a}},_getMessage:function(){if($.browser.mobile){return this._messageField.val()}else{if(this._messageField.data("ckeditorInstance")){var a=this._messageField.ckeditorGet();return a.getData()}}return null},_success:function(b,c,a){this._previewButton.html(this._previewButtonLabel).enable();this._messageField.parent().children("small.innerError").remove();this._handleResponse(b)},_handleResponse:function(a){},_failure:function(a){if(a===null||a.returnValues===undefined||a.returnValues.errorType===undefined){return true}this._previewButton.html(this._previewButtonLabel).enable();var b=this._messageField.next("small.innerError").empty();if(!b.length){b=$('<small class="innerError" />').appendTo(this._messageField.parent())}b.html(a.returnValues.errorType);return false}});WCF.Message.DefaultPreview=WCF.Message.Preview.extend({_attachmentObjectType:null,_attachmentObjectID:null,_tmpHash:null,init:function(b,a,c){this._super("wcf\\data\\bbcode\\MessagePreviewAction","text","previewButton");this._attachmentObjectType=b||null;this._attachmentObjectID=a||null;this._tmpHash=c||null},_handleResponse:function(b){var a=$("#previewContainer");if(!a.length){a=$('<div class="container containerPadding marginTop" id="previewContainer"><fieldset><legend>'+WCF.Language.get("wcf.global.preview")+"</legend><div></div></fieldset>").prependTo($("#messageContainer")).wcfFadeIn()}a.find("div:eq(0)").html(b.returnValues.message)},_getParameters:function(b){var a=this._super(b);if(this._attachmentObjectType!=null){a.attachmentObjectType=this._attachmentObjectType;a.attachmentObjectID=this._attachmentObjectID;a.tmpHash=this._tmpHash}return a}});WCF.Message.Multilingualism=Class.extend({_availableLanguages:{},_languageID:0,_languageInput:null,init:function(c,d,a){this._availableLanguages=d;this._languageID=c||0;this._languageInput=$("#languageID");this._updateLabel();this._languageInput.find(".dropdownMenu > li").click($.proxy(this._click,this));if(!a){var b=this._languageInput.find(".dropdownMenu");$('<li class="dropdownDivider" />').appendTo(b);$('<li><span><span class="badge">'+this._availableLanguages[0]+"</span></span></li>").click($.proxy(this._disable,this)).appendTo(b)}this._languageInput.parents("form").submit($.proxy(this._submit,this))},_click:function(a){this._languageID=$(a.currentTarget).data("languageID");this._updateLabel()},_disable:function(){this._languageID=0;this._updateLabel()},_updateLabel:function(){this._languageInput.find(".dropdownToggle > span").text(this._availableLanguages[this._languageID])},_submit:function(){this._languageInput.next("input[name=languageID]").prop("value",this._languageID)}});WCF.Message.SmileyCategories=Class.extend({_cache:[],_proxy:null,_ckEditor:null,init:function(){this._cache=[];this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});$("#smilies").on("wcftabsbeforeactivate",$.proxy(this._click,this));var a=this;new WCF.PeriodicalExecuter(function(b){b.stop();a._click({},{newTab:$("#smilies > .menu li.ui-state-active")})},100)},_click:function(b,c){var a=parseInt($(c.newTab).children("a").data("smileyCategoryID"));if(a&&!WCF.inArray(a,this._cache)){this._proxy.setOption("data",{actionName:"getSmilies",className:"wcf\\data\\smiley\\category\\SmileyCategoryAction",objectIDs:[a]});this._proxy.sendRequest()}},_success:function(c,d,b){var a=parseInt(c.returnValues.smileyCategoryID);this._cache.push(a);$("#smilies-"+a).html(c.returnValues.template)}});WCF.Message.Smilies=Class.extend({_ckEditor:null,init:function(a){if(a){this._ckEditor=$("#"+a);$(document).on("click",".jsSmiley",$.proxy(this._smileyClick,this))}},_smileyClick:function(c){var e=$(c.currentTarget);var h=e.data("smileyCode");var i=this._ckEditor.ckeditorGet();var f=e.find("img").attr("src");if(!WCF.inArray(h,i.config.smiley_descriptions)){i.config.smiley_descriptions.push(h);i.config.smiley_images.push(f)}if(i.mode==="wysiwyg"){var a=i.document.createElement("img",{attributes:{src:f,"class":"smiley",alt:h}});i.insertText(" ");i.insertElement(a);i.insertText(" ")}else{var g=this._ckEditor.next(".cke_editor_text").find("textarea");var j=g.val();if(j.length==0){g.val(h);g.setCaret(h.length)}else{var d=g.getCaret();var b=((j.substr(d-1,1)!==" ")?" ":"")+h+" ";g.val(j.substr(0,d)+b+j.substr(d));g.setCaret(d+b.length)}}}});WCF.Message.QuickReply=Class.extend({_container:null,_messageField:null,_notification:null,_pendingSave:false,_proxy:null,_quoteManager:null,_scrollHandler:null,_successMessageNonVisible:"",init:function(c,b){this._container=$("#messageQuickReply");this._messageField=$("#text");this._pendingSave=false;if(!this._container||!this._messageField){return}var a=this._container.find(".formSubmit");a.find("button[data-type=save]").click($.proxy(this._save,this));if(c){a.find("button[data-type=extended]").click($.proxy(this._prepareExtended,this))}a.find("button[data-type=cancel]").click($.proxy(this._cancel,this));if(b){this._quoteManager=b}$(".jsQuickReply").data("__api",this).click($.proxy(this.click,this));this._proxy=new WCF.Action.Proxy({failure:$.proxy(this._failure,this),showLoadingOverlay:false,success:$.proxy(this._success,this)});this._scroll=new WCF.Effect.Scroll();this._notification=new WCF.System.Notification(WCF.Language.get("wcf.global.success.add"));this._successMessageNonVisible=""},click:function(b){this._container.toggle();if(this._container.is(":visible")){this._scroll.scrollTo(this._container,true);WCF.Message.Submit.registerButton("text",this._container.find(".formSubmit button[data-type=save]"));if(this._quoteManager){var a=true;if($.browser.touch){a=(!this._messageField.val().length)}else{a=(!this._messageField.ckeditorGet().getData().length)}if(a){this._quoteManager.insertQuotes(this._getClassName(),this._getObjectID(),$.proxy(this._insertQuotes,this))}}new WCF.PeriodicalExecuter($.proxy(function(c){c.stop();if($.browser.mobile){this._messageField.focus()}else{this._messageField.ckeditorGet().ui.editor.focus()}},this),250)}if(b!==null){b.stopPropagation();return false}},getContainer:function(){return this._container},_insertQuotes:function(a){if(!a.returnValues.template){return}if($.browser.mobile){this._messageField.val(a.returnValues.template)}else{this._messageField.ckeditorGet().insertText(a.returnValues.template)}},_save:function(){if(this._pendingSave){return}var b="";if($.browser.mobile){b=$.trim(this._messageField.val())}else{var a=this._messageField.ckeditorGet();b=$.trim(a.getData())}var d=this._messageField.parent().find("small.innerError");if(b===""){if(!d.length){d=$('<small class="innerError" />').appendTo(this._messageField.parent())}d.html(WCF.Language.get("wcf.global.form.error.empty"));return}else{d.remove()}this._pendingSave=true;this._proxy.setOption("data",{actionName:"quickReply",className:this._getClassName(),interfaceName:"wcf\\data\\IMessageQuickReplyAction",parameters:this._getParameters(b)});this._proxy.sendRequest();var c=this._container.find(".messageQuickReplyContent .messageBody");$('<span class="icon icon48 icon-spinner" />').appendTo(c);c.children("#cke_text").hide().end().next().hide()},_getParameters:function(b){var a={objectID:this._getObjectID(),data:{message:b},lastPostTime:this._container.data("lastPostTime"),pageNo:this._container.data("pageNo"),removeQuoteIDs:(this._quoteManager===null?[]:this._quoteManager.getQuotesMarkedForRemoval())};if(this._container.data("anchor")){a.anchor=this._container.data("anchor")}return a},_cancel:function(){this._revertQuickReply(true);if($.browser.mobile){this._messageField.val("")}else{this._messageField.ckeditorGet().setData("")}},_revertQuickReply:function(b){var a=this._container.find(".messageQuickReplyContent .messageBody");if(b){this._container.hide();a.children("small.innerError").remove()}a.children(".icon-spinner").remove();a.children("#cke_text").show();a.next().show()},_prepareExtended:function(){this._pendingSave=true;if(this._quoteManager!==null){this._quoteManager.markQuotesForRemoval()}var b="";if($.browser.mobile){b=this._messageField.val()}else{var a=this._messageField.ckeditorGet();b=a.getData()}new WCF.Action.Proxy({autoSend:true,data:{actionName:"jumpToExtended",className:this._getClassName(),interfaceName:"wcf\\data\\IExtendedMessageQuickReplyAction",parameters:{containerID:this._getObjectID(),message:b}},success:function(d,e,c){window.location=d.returnValues.url}})},_success:function(c,d,b){if(c.returnValues.url){window.location=c.returnValues.url}else{if(c.returnValues.template){var a=$(""+c.returnValues.template);a.insertBefore(this._container);this._container.data("lastPostTime",c.returnValues.lastPostTime);this._notification.show(undefined,undefined,WCF.Language.get("wcf.global.success.add"));this._updateHistory(a.wcfIdentify())}else{var a=(this._successMessageNonVisible)?this._successMessageNonVisible:"wcf.global.success.add";this._notification.show(undefined,5000,WCF.Language.get(a))}if($.browser.mobile){this._messageField.val("")}else{this._messageField.ckeditorGet().setData("")}this._revertQuickReply(true);if(this._quoteManager!==null){this._quoteManager.countQuotes()}this._pendingSave=false}},_failure:function(b){this._pendingSave=false;this._revertQuickReply(false);if(b===null||b.returnValues===undefined||b.returnValues.errorType===undefined){return true}var a=this._container.find(".messageQuickReplyContent .messageBody");var c=a.children("small.innerError").empty();if(!c.length){c=$('<small class="innerError" />').appendTo(a)}c.html(b.returnValues.errorType);return false},_getClassName:function(){return""},_getObjectID:function(){return 0},_updateHistory:function(a){window.location.hash=a}});WCF.Message.InlineEditor=Class.extend({_activeElementID:"",_cache:"",_container:{},_containerID:0,_dropdowns:{},_messageContainerSelector:".jsMessage",_messageEditorIDPrefix:"messageEditor",_notification:null,_proxy:null,_quoteManager:null,_supportExtendedForm:false,init:function(a,c,b){this._activeElementID="";this._cache="";this._container={};this._containerID=parseInt(a);this._dropdowns={};this._quoteManager=b||null;this._supportExtendedForm=(c)?true:false;this._proxy=new WCF.Action.Proxy({failure:$.proxy(this._failure,this),showLoadingOverlay:false,success:$.proxy(this._success,this)});this._notification=new WCF.System.Notification(WCF.Language.get("wcf.global.success.edit"));this.initContainers();WCF.DOMNodeInsertedHandler.addCallback("WCF.Message.InlineEditor",$.proxy(this.initContainers,this))},initContainers:function(){$(this._messageContainerSelector).each($.proxy(function(b,a){var d=$(a);var c=d.wcfIdentify();if(!this._container[c]){this._container[c]=d;if(d.data("canEditInline")){d.find(".jsMessageEditButton:eq(0)").data("containerID",c).click($.proxy(this._clickInline,this)).dblclick($.proxy(this._click,this))}else{if(d.data("canEdit")){d.find(".jsMessageEditButton:eq(0)").data("containerID",c).click($.proxy(this._click,this))}}}},this))},_click:function(c,a){var b=(c===null)?a:$(c.currentTarget).data("containerID");if(this._activeElementID===""){this._activeElementID=b;this._prepare();this._proxy.setOption("data",{actionName:"beginEdit",className:this._getClassName(),interfaceName:"wcf\\data\\IMessageInlineEditorAction",parameters:{containerID:this._containerID,objectID:this._container[b].data("objectID")}});this._proxy.sendRequest()}else{var d=new WCF.System.Notification(WCF.Language.get("wcf.message.error.editorAlreadyInUse"),"warning");d.show()}if(c!==null){c.stopPropagation();return false}},_clickInline:function(c){var d=$(c.currentTarget);if(!d.hasClass("dropdownToggle")){var b=d.data("containerID");d.addClass("dropdownToggle").parent().addClass("dropdown");var a=$('<ul class="dropdownMenu" />').insertAfter(d);this._initDropdownMenu(b,a);WCF.DOMNodeInsertedHandler.execute();this._dropdowns[this._container[b].data("objectID")]=a;WCF.Dropdown.registerCallback(d.parent().wcfIdentify(),$.proxy(this._toggleDropdown,this));d.trigger("click")}c.stopPropagation();return false},_failure:function(b){this._revertEditor();if(b===null||b.returnValues===undefined||b.returnValues.errorType===undefined){return true}var a=this._container[this._activeElementID].find(".messageBody .messageInlineEditor");var c=a.children("small.innerError").empty();if(!c.length){c=$('<small class="innerError" />').insertBefore(a.children(".formSubmit"))}c.html(b.returnValues.errorType);return false},_toggleDropdown:function(a,b){WCF.Dropdown.getDropdown(a).parents(".messageOptions").toggleClass("forceOpen")},_initDropdownMenu:function(a,b){},_prepare:function(){var b=this._container[this._activeElementID].find(".messageBody");$('<span class="icon icon48 icon-spinner" />').appendTo(b);var a=b.find(".messageText");this._cache=a.html();a.empty()},_cancel:function(){var d=this._container[this._activeElementID];try{var a=$("#"+this._messageEditorIDPrefix+d.data("objectID")).ckeditorGet();a.destroy()}catch(c){}var b=d.find(".messageBody");b.children(".icon-spinner").remove();b.find(".messageText").html(this._cache);this._container[this._activeElementID].find(".messageOptions").removeClass("forceHidden");this._activeElementID="";if(this._quoteManager){this._quoteManager.clearAlternativeCKEditor()}},_success:function(b,c,a){switch(b.returnValues.actionName){case"beginEdit":this._showEditor(b);break;case"save":this._showMessage(b);break}},_showEditor:function(e){var c=this._container[this._activeElementID].find(".messageBody");c.children(".icon-spinner").remove();var b=c.find(".messageText");$(""+e.returnValues.template).appendTo(b);var a=b.find(".formSubmit");var d=a.find("button[data-type=save]").click($.proxy(this._save,this));if(this._supportExtendedForm){a.find("button[data-type=extended]").click($.proxy(this._prepareExtended,this))}a.find("button[data-type=cancel]").click($.proxy(this._cancel,this));WCF.Message.Submit.registerButton(this._messageEditorIDPrefix+this._container[this._activeElementID].data("objectID"),d);this._container[this._activeElementID].find(".messageOptions").addClass("forceHidden");new WCF.PeriodicalExecuter($.proxy(function(f){f.stop();var g=$("#"+this._messageEditorIDPrefix+this._container[this._activeElementID].data("objectID"));g.ckeditorGet().ui.editor.focus();if(this._quoteManager){this._quoteManager.setAlternativeCKEditor(g)}},this),250)},_revertEditor:function(){var a=this._container[this._activeElementID].find(".messageBody");a.children("span.icon-spinner").remove();a.find(".messageText").children().show();if(this._quoteManager){this._quoteManager.clearAlternativeCKEditor()}},_save:function(){var d=this._container[this._activeElementID];var c=d.data("objectID");var b="";if($.browser.mobile){b=$("#"+this._messageEditorIDPrefix+c).val()}else{var a=$("#"+this._messageEditorIDPrefix+c).ckeditorGet();b=a.getData()}this._proxy.setOption("data",{actionName:"save",className:this._getClassName(),interfaceName:"wcf\\data\\IMessageInlineEditorAction",parameters:{containerID:this._containerID,data:{message:b},objectID:c}});this._proxy.sendRequest();this._hideEditor()},_prepareExtended:function(){var d=this._container[this._activeElementID];var c=d.data("objectID");var b="";if($.browser.mobile){b=$("#"+this._messageEditorIDPrefix+c).val()}else{var a=$("#"+this._messageEditorIDPrefix+c).ckeditorGet();b=a.getData()}new WCF.Action.Proxy({autoSend:true,data:{actionName:"jumpToExtended",className:this._getClassName(),parameters:{containerID:this._containerID,message:b,messageID:c}},success:function(f,g,e){window.location=f.returnValues.url}})},_hideEditor:function(){var a=this._container[this._activeElementID].find(".messageBody");$('<span class="icon icon48 icon-spinner" />').appendTo(a);a.find(".messageText").children().hide();if(this._quoteManager){this._quoteManager.clearAlternativeCKEditor()}},_showMessage:function(d){var e=this._container[this._activeElementID];var c=e.find(".messageBody");c.children(".icon-spinner").remove();var b=c.find(".messageText");this._container[this._activeElementID].find(".messageOptions").removeClass("forceHidden");if(!$.browser.mobile){var a=$("#"+this._messageEditorIDPrefix+e.data("objectID")).ckeditorGet();a.destroy()}b.empty();b.html(d.returnValues.message);this._activeElementID="";this._updateHistory(this._getHash(e.data("objectID")));this._notification.show();if(this._quoteManager){this._quoteManager.clearAlternativeCKEditor()}},_getClassName:function(){return""},_getHash:function(a){return"#message"+a},_updateHistory:function(a){window.location.hash=a}});WCF.Message.Submit={_buttons:{},registerButton:function(b,a){if(!WCF.Browser.isChrome()){return}this._buttons[b]=$(a)},execute:function(a){if(!this._buttons[a]){return}this._buttons[a].trigger("click")}};WCF.Message.Quote={};WCF.Message.Quote.Handler=Class.extend({_activeContainerID:"",_className:"",_containers:{},_containerSelector:"",_copyQuote:null,_message:"",_messageBodySelector:"",_objectID:0,_objectType:"",_proxy:null,_quoteManager:null,init:function(e,d,b,a,c,f){this._className=d;if(this._className==""){console.debug("[WCF.Message.QuoteManager] Empty class name given, aborting.");return}this._objectType=b;if(this._objectType==""){console.debug("[WCF.Message.QuoteManager] Empty object type name given, aborting.");return}this._containerSelector=a;this._message="";this._messageBodySelector=c;this._messageContentSelector=f;this._objectID=0;this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});this._initContainers();this._initCopyQuote();$(document).mouseup($.proxy(this._mouseUp,this));this._quoteManager=e;this._quoteManager.register(this._objectType,this);WCF.DOMNodeInsertedHandler.addCallback("WCF.Message.Quote.Handler"+b.hashCode(),$.proxy(this._initContainers,this))},_initContainers:function(){var a=this;$(this._containerSelector).each(function(c,b){var e=$(b);var d=e.wcfIdentify();if(!a._containers[d]){a._containers[d]=e;if(e.hasClass("jsInvalidQuoteTarget")){return true}if(a._messageBodySelector!==null){e=e.find(a._messageBodySelector).data("containerID",d)}e.mousedown($.proxy(a._mouseDown,a));a._containers[d].find(".jsQuoteMessage").click($.proxy(a._saveFullQuote,a))}})},_mouseDown:function(a){this._copyQuote.hide();var b=$(a.currentTarget);if(this._messageBodySelector){b=this._containers[b.data("containerID")]}this._activeContainerID=b.wcfIdentify();if($.browser.mozilla){b.find("img").each(function(){var c=$(this);c.data("__alt",c.attr("alt")).removeAttr("alt")})}},_getNodeText:function(d){var c="";for(var b=0;b<d.childNodes.length;b++){if(d.childNodes[b].nodeType==3){c+=d.childNodes[b].nodeValue}else{var a=d.childNodes[b].tagName.toLowerCase();if(a==="li"){c+="\r\n"}c+=this._getNodeText(d.childNodes[b]);if(a==="ul"){c+="\n"}}}return c},_mouseUp:function(a){if(this._activeContainerID==""){this._copyQuote.hide();return}var i=this._containers[this._activeContainerID];var c=this._getSelectedText();var f=$.trim(c);if(f==""){this._copyQuote.hide();return}var d=null;if(this._messageBodySelector){d=this._getNodeText(i.find(this._messageContentSelector).get(0))}else{d=this._getNodeText(i.get(0))}if(this._normalize(d).indexOf(this._normalize(f))===-1){return}this._copyQuote.show();var g=this._getBoundingRectangle(c);var e=this._copyQuote.getDimensions("outer");var b=(g.right-g.left)/2-(e.width/2)+g.left;this._copyQuote.css({top:g.top-e.height-7+"px",left:b+"px"});this._copyQuote.hide();this._activeContainerID="";var h=this;new WCF.PeriodicalExecuter(function(j){j.stop();var k=$.trim(h._getSelectedText());if(k!=""){h._copyQuote.show();h._message=k;h._objectID=i.data("objectID");if($.browser.mozilla){i.find("img").each(function(){var l=$(this);l.attr("alt",l.data("__alt"))})}}},10)},_normalize:function(a){return a.replace(/\r?\n|\r/g,"\n").replace(/\s{2,}/g," ")},_getOffset:function(c,e){c.collapse(e);var g=WCF.getRandomID();var a=document.createElement("span");a.innerHTML='<span id="'+g+'"></span>';var h=document.createDocumentFragment(),b,d;while(b=a.firstChild){d=h.appendChild(b)}c.insertNode(h);a=$("#"+g);var f=a.offset();f.top=f.top-$(window).scrollTop();a.remove();return f},_getBoundingRectangle:function(g){var i=null;if(document.createRange&&typeof document.createRange().getBoundingClientRect!="undefined"){if(g.rangeCount>0){var h=g.getRangeAt(0).getClientRects();if(!$.browser.mozilla&&h.length>1){var d=g.getRangeAt(0);var b=this._getOffset(d,true);var d=g.getRangeAt(0);var a=this._getOffset(d,false);var e={left:(b.left>a.left)?a.left:b.left,right:(b.left>a.left)?b.left:a.left,top:(b.top>a.top)?a.top:b.top}}else{var e=g.getRangeAt(0).getBoundingClientRect()}var c=$(document);var f=c.scrollTop();i={left:e.left,right:e.right,top:e.top+f}}}else{if(document.selection&&document.selection.type!="Control"){var d=document.selection.createRange();i={left:d.boundingLeft,right:d.boundingRight,top:d.boundingTop}}}return i},_initCopyQuote:function(){this._copyQuote=$("#quoteManagerCopy");if(!this._copyQuote.length){this._copyQuote=$('<div id="quoteManagerCopy" class="balloonTooltip"><span>'+WCF.Language.get("wcf.message.quote.quoteSelected")+'</span><span class="pointer"><span></span></span></div>').hide().appendTo(document.body);this._copyQuote.click($.proxy(this._saveQuote,this))}},_getSelectedText:function(){if(window.getSelection){return window.getSelection()}else{if(document.getSelection){return document.getSelection()}else{if(document.selection){return document.selection.createRange().text}}}return""},_saveFullQuote:function(b){var a=$(b.currentTarget);this._proxy.setOption("data",{actionName:"saveFullQuote",className:this._className,interfaceName:"wcf\\data\\IMessageQuoteAction",objectIDs:[a.data("objectID")]});this._proxy.sendRequest();if(a.data("isQuoted")){a.data("isQuoted",false).children("a").removeClass("active")}else{a.data("isQuoted",true).children("a").addClass("active")}b.stopPropagation();return false},_saveQuote:function(){this._proxy.setOption("data",{actionName:"saveQuote",className:this._className,interfaceName:"wcf\\data\\IMessageQuoteAction",objectIDs:[this._objectID],parameters:{message:this._message}});this._proxy.sendRequest()},_success:function(c,d,b){if(c.returnValues.count!==undefined){var a=(c.fullQuoteObjectIDs!==undefined)?c.fullQuoteObjectIDs:{};this._quoteManager.updateCount(c.returnValues.count,a)}},updateFullQuoteObjectIDs:function(b){for(var a in this._containers){this._containers[a].find(".jsQuoteMessage").each(function(c,d){var e=$(d).data("isQuoted",0);e.children("a").removeClass("active");if(WCF.inArray(e.data("objectID"),b)){e.data("isQuoted",1).children("a").addClass("active")}})}}});WCF.Message.Quote.Manager=Class.extend({_buttons:{},_ckEditor:null,_ckEditorAlternative:null,_count:0,_dialog:null,_form:null,_handlers:{},_hasTemplate:false,_insertQuotes:true,_proxy:null,_removeOnSubmit:[],_showQuotes:null,_supportPaste:false,init:function(c,b,a,d){this._buttons={insert:null,remove:null};this._ckEditor=null;this._ckEditorAlternative=null;this._count=parseInt(c)||0;this._dialog=null;this._form=null;this._handlers={};this._hasTemplate=false;this._insertQuotes=true;this._removeOnSubmit=[];this._showQuotes=null;this._supportPaste=false;if(b){this._ckEditor=$("#"+b);if(this._ckEditor.length){this._supportPaste=true;this._form=this._ckEditor.parents("form:eq(0)");if(this._form.length){this._form.submit($.proxy(this._submit,this));this._removeOnSubmit=d||[]}else{this._form=null;this._supportPaste=(a===true)?true:false}}}this._proxy=new WCF.Action.Proxy({showLoadingOverlay:false,success:$.proxy(this._success,this),url:"index.php/MessageQuote/?t="+SECURITY_TOKEN+SID_ARG_2ND});this._toggleShowQuotes()},setAlternativeCKEditor:function(a){this._ckEditorAlternative=a},clearAlternativeCKEditor:function(){this._ckEditorAlternative=null},register:function(a,b){this._handlers[a]=b},updateCount:function(c,b){this._count=parseInt(c)||0;this._toggleShowQuotes();for(var a in this._handlers){if(b[a]){this._handlers[a].updateFullQuoteObjectIDs(b[a])}}},insertQuotes:function(a,b,c){if(!this._insertQuotes){this._insertQuotes=true;return}new WCF.Action.Proxy({autoSend:true,data:{actionName:"getRenderedQuotes",className:a,interfaceName:"wcf\\data\\IMessageQuoteAction",parameters:{parentObjectID:b}},success:c})},_toggleShowQuotes:function(){if(!this._count){if(this._showQuotes!==null){this._showQuotes.hide()}}else{if(this._showQuotes===null){this._showQuotes=$("#showQuotes");if(!this._showQuotes.length){this._showQuotes=$('<div id="showQuotes" class="balloonTooltip" />').click($.proxy(this._click,this)).appendTo(document.body)}}var a=WCF.Language.get("wcf.message.quote.showQuotes").replace(/#count#/,this._count);this._showQuotes.text(a).show()}this._hasTemplate=false},_click:function(){if(this._hasTemplate){this._dialog.wcfDialog("open")}else{this._proxy.showLoadingOverlayOnce();this._proxy.setOption("data",{actionName:"getQuotes",supportPaste:this._supportPaste});this._proxy.sendRequest()}},renderDialog:function(c){if(this._dialog===null){this._dialog=$("#messageQuoteList");if(!this._dialog.length){this._dialog=$('<div id="messageQuoteList" />').hide().appendTo(document.body)}}this._dialog.html(c);var a=$('<div class="formSubmit" />').appendTo(this._dialog);if(this._supportPaste){this._buttons.insert=$("<button>"+WCF.Language.get("wcf.message.quote.insertAllQuotes")+"</button>").click($.proxy(this._insertSelected,this)).appendTo(a)}this._buttons.remove=$("<button>"+WCF.Language.get("wcf.message.quote.removeAllQuotes")+"</button>").click($.proxy(this._removeSelected,this)).appendTo(a);this._dialog.wcfDialog({title:WCF.Language.get("wcf.message.quote.manageQuotes")});this._dialog.wcfDialog("render");this._hasTemplate=true;var d=this._dialog.find(".jsInsertQuote");if(this._supportPaste){d.click($.proxy(this._insertQuote,this))}else{d.hide()}this._dialog.find("input.jsCheckbox").change($.proxy(this._changeButtons,this));if(this._removeOnSubmit.length){var b=this;this._dialog.find("input.jsRemoveQuote").each(function(f,e){var g=$(e).change($.proxy(this._change,this));if(WCF.inArray(g.parent("li").attr("data-quote-id"),b._removeOnSubmit)){g.attr("checked","checked")}})}},_changeButtons:function(){if(this._dialog.find("input.jsCheckbox:checked").length){if(this._supportPaste){this._buttons.insert.html(WCF.Language.get("wcf.message.quote.insertSelectedQuotes"))}this._buttons.remove.html(WCF.Language.get("wcf.message.quote.removeSelectedQuotes"))}else{if(this._supportPaste){this._buttons.insert.html(WCF.Language.get("wcf.message.quote.insertAllQuotes"))}this._buttons.remove.html(WCF.Language.get("wcf.message.quote.removeAllQuotes"))}},_change:function(c){var d=$(c.currentTarget);var b=d.parent("li").attr("data-quote-id");if(d.prop("checked")){this._removeOnSubmit.push(b)}else{for(var a in this._removeOnSubmit){if(this._removeOnSubmit[a]==b){delete this._removeOnSubmit[a];break}}}},_insertSelected:function(){if(this._ckEditorAlternative===null){var a=$(".jsQuickReply:eq(0)").data("__api");if(a&&!a.getContainer().is(":visible")){this._insertQuotes=false;a.click(null)}}if(!this._dialog.find("input.jsCheckbox:checked").length){this._dialog.find("input.jsCheckbox").prop("checked","checked")}this._dialog.find("input.jsCheckbox:checked").each($.proxy(function(c,b){this._insertQuote(null,b)},this));this._dialog.wcfDialog("close")},_insertQuote:function(a,i){if(a!==null&&this._ckEditorAlternative===null){var c=$(".jsQuickReply:eq(0)").data("__api");if(c&&!c.getContainer().is(":visible")){this._insertQuotes=false;c.click(null)}}var g=(a===null)?$(i).parents("li"):$(a.currentTarget).parents("li");var j=$.trim(g.children("div.jsFullQuote").text());var e=g.parents("article.message");j="[quote='"+e.attr("data-username")+"','"+e.data("link")+"']"+j+"[/quote]";var f=null;if(!$.browser.mobile){if(this._ckEditorAlternative===null){f=this._ckEditor.ckeditorGet()}else{f=this._ckEditorAlternative.ckeditorGet()}}if(f!==null&&f.mode==="wysiwyg"){f.insertText(j+"\n\n")}else{var d=null;if(this._ckEditorAlternative===null){d=($.browser.mobile)?this._ckEditor:this._ckEditor.next(".cke_editor_text").find("textarea")}else{d=($.browser.mobile)?this._ckEditorAlternative:this._ckEditorAlternative.next(".cke_editor_text").find("textarea")}var h=d.val();j+="\n\n";if(h.length==0){d.val(j)}else{var b=d.getCaret();d.val(h.substr(0,b)+j+h.substr(b))}}this._removeOnSubmit.push(g.attr("data-quote-id"));if(a!==null){this._dialog.wcfDialog("close")}},_removeSelected:function(){if(!this._dialog.find("input.jsCheckbox:checked").length){this._dialog.find("input.jsCheckbox").prop("checked","checked")}var b=[];this._dialog.find("input.jsCheckbox:checked").each(function(e,d){b.push($(d).parents("li").attr("data-quote-id"))});if(b.length){var c=[];for(var a in this._handlers){c.push(a)}this._proxy.setOption("data",{actionName:"remove",getFullQuoteObjectIDs:this._handlers.length>0,objectTypes:c,quoteIDs:b});this._proxy.sendRequest();this._dialog.wcfDialog("close")}},_submit:function(){if(this._supportPaste&&this._removeOnSubmit.length>0){var a=this._form.find(".formSubmit");for(var b in this._removeOnSubmit){$('<input type="hidden" name="__removeQuoteIDs[]" value="'+this._removeOnSubmit[b]+'" />').appendTo(a)}}},getQuotesMarkedForRemoval:function(){return this._removeOnSubmit},markQuotesForRemoval:function(){if(this._removeOnSubmit.length){this._proxy.setOption("data",{actionName:"markForRemoval",quoteIDs:this._removeOnSubmit});this._proxy.suppressErrors();this._proxy.sendRequest()}},removeMarkedQuotes:function(){if(this._removeOnSubmit.length){this._proxy.setOption("data",{actionName:"removeMarkedQuotes",getFullQuoteObjectIDs:this._handlers.length>0});this._proxy.sendRequest()}},countQuotes:function(){var b=[];for(var a in this._handlers){b.push(a)}this._proxy.setOption("data",{actionName:"count",getFullQuoteObjectIDs:this._handlers.length>0,objectTypes:b});this._proxy.sendRequest()},_success:function(c,d,b){if(c===null){return}if(c.count!==undefined){var a=(c.fullQuoteObjectIDs!==undefined)?c.fullQuoteObjectIDs:{};this.updateCount(c.count,a)}if(c.template!==undefined){if($.trim(c.template)==""){this.updateCount(0,{})}else{this.renderDialog(c.template)}}}});WCF.Message.Share={};WCF.Message.Share.Content=Class.extend({_cache:{},_dialog:null,init:function(){this._cache={};this._dialog=null;this._initLinks();WCF.DOMNodeInsertedHandler.addCallback("WCF.Message.Share.Content",$.proxy(this._initLinks,this))},_initLinks:function(){$("a.jsButtonShare").removeClass("jsButtonShare").click($.proxy(this._click,this))},_click:function(e){e.preventDefault();var a=$(e.currentTarget);var b=a.prop("href");var d=(a.data("linkTitle")?a.data("linkTitle"):b);var c=b.hashCode();if(this._cache[c]===undefined){var g=false;if(this._dialog===null){this._dialog=$("<div />").hide().appendTo(document.body);g=true}else{this._dialog.empty()}var f=$('<fieldset><legend><label for="__sharePermalink">'+WCF.Language.get("wcf.message.share.permalink")+"</label></legend></fieldset>").appendTo(this._dialog);$('<input type="text" id="__sharePermalink" class="long" readonly="readonly" />').attr("value",b).appendTo(f);var f=$('<fieldset><legend><label for="__sharePermalinkBBCode">'+WCF.Language.get("wcf.message.share.permalink.bbcode")+"</label></legend></fieldset>").appendTo(this._dialog);$('<input type="text" id="__sharePermalinkBBCode" class="long" readonly="readonly" />').attr("value","[url='"+b+"']"+d+"[/url]").appendTo(f);var f=$('<fieldset><legend><label for="__sharePermalinkHTML">'+WCF.Language.get("wcf.message.share.permalink.html")+"</label></legend></fieldset>").appendTo(this._dialog);$('<input type="text" id="__sharePermalinkHTML" class="long" readonly="readonly" />').attr("value",'<a href="'+b+'">'+WCF.String.escapeHTML(d)+"</a>").appendTo(f);this._cache[c]=this._dialog.html();if(g){this._dialog.wcfDialog({title:WCF.Language.get("wcf.message.share")})}else{this._dialog.wcfDialog("open")}}else{this._dialog.html(this._cache[c]).wcfDialog("open")}this._dialog.find("input").click(function(){$(this).select()})}});WCF.Message.Share.Page=Class.extend({_ui:{},_pageDescription:"",_pageURL:"",init:function(a){this._pageDescription=encodeURIComponent($('meta[property="og:description"]').prop("content"));this._pageURL=encodeURIComponent($('meta[property="og:url"]').prop("content"));var b=$(".messageShareButtons");this._ui={facebook:b.find(".jsShareFacebook"),google:b.find(".jsShareGoogle"),reddit:b.find(".jsShareReddit"),twitter:b.find(".jsShareTwitter")};this._ui.facebook.children("a").click($.proxy(this._shareFacebook,this));this._ui.google.children("a").click($.proxy(this._shareGoogle,this));this._ui.reddit.children("a").click($.proxy(this._shareReddit,this));this._ui.twitter.children("a").click($.proxy(this._shareTwitter,this));if(a===true){this._fetchFacebook();this._fetchTwitter();this._fetchReddit()}},_share:function(b,a){window.open(a.replace(/{pageURL}/,this._pageURL).replace(/{text}/,this._pageDescription),"height=600,width=600")},_shareFacebook:function(){this._share("facebook","https://www.facebook.com/sharer.php?u={pageURL}&t={text}")},_shareGoogle:function(){this._share("google","https://plus.google.com/share?url={pageURL}")},_shareReddit:function(){this._share("reddit","https://ssl.reddit.com/submit?url={pageURL}")},_shareTwitter:function(){this._share("twitter","https://twitter.com/share?url={pageURL}&text={text}")},_fetchCount:function(b,d,c){var a={autoSend:true,dataType:"jsonp",showLoadingOverlay:false,success:d,suppressErrors:true,type:"GET",url:b.replace(/{pageURL}/,this._pageURL)};if(c){a.jsonp=c}new WCF.Action.Proxy(a)},_fetchFacebook:function(){this._fetchCount("https://graph.facebook.com/?id={pageURL}",$.proxy(function(a){if(a.shares){this._ui.facebook.children("span.badge").show().text(a.shares)}},this))},_fetchTwitter:function(){this._fetchCount("http://urls.api.twitter.com/1/urls/count.json?url={pageURL}",$.proxy(function(a){if(a.count){this._ui.twitter.children("span.badge").show().text(a.count)}},this))},_fetchReddit:function(){this._fetchCount("http://www.reddit.com/api/info.json?url={pageURL}",$.proxy(function(a){if(a.data.children.length){this._ui.reddit.children("span.badge").show().text(a.data.children[0].data.score)}},this),"jsonp")}});
\ No newline at end of file
+WCF.Message={};WCF.Message.BBCode={};WCF.Message.BBCode.CodeViewer=Class.extend({_dialog:null,init:function(){this._dialog=null;this._initCodeBoxes();WCF.DOMNodeInsertedHandler.addCallback("WCF.Message.BBCode.CodeViewer",$.proxy(this._initCodeBoxes,this));WCF.DOMNodeInsertedHandler.execute()},_initCodeBoxes:function(){$(".codeBox:not(.jsCodeViewer)").each($.proxy(function(a,c){var b=$(c).addClass("jsCodeViewer");$('<span class="icon icon16 icon-copy pointer jsTooltip" title="'+WCF.Language.get("wcf.message.bbcode.code.copy")+'" />').appendTo(b.find("div > h3")).click($.proxy(this._click,this))},this))},_click:function(b){var a="";$(b.currentTarget).parents("div").next("ol").children("li").each(function(c,d){if(a){a+="\n"}a+=$(d).text().replace(/\n+$/,"")});if(this._dialog===null){this._dialog=$('<div><textarea cols="60" rows="12" readonly="readonly" /></div>').hide().appendTo(document.body);this._dialog.children("textarea").val(a);this._dialog.wcfDialog({title:WCF.Language.get("wcf.message.bbcode.code.copy")})}else{this._dialog.children("textarea").val(a);this._dialog.wcfDialog("open")}this._dialog.children("textarea").select()}});WCF.Message.FormGuard=Class.extend({init:function(){var a=$("form.jsFormGuard").removeClass("jsFormGuard").submit(function(){$(this).find(".formSubmit input[type=submit]").disable()});$(window).unload(function(){a.find(".formSubmit input[type=submit]").enable()})}});WCF.Message.Preview=Class.extend({_className:"",_messageFieldID:"",_messageField:null,_proxy:null,_previewButton:null,_previewButtonLabel:"",init:function(b,a,c){this._className=b;this._messageFieldID=$.wcfEscapeID(a);this._messageField=$("#"+this._messageFieldID);if(!this._messageField.length){console.debug("[WCF.Message.Preview] Unable to find message field identified by '"+this._messageFieldID+"'");return}c=$.wcfEscapeID(c);this._previewButton=$("#"+c);if(!this._previewButton.length){console.debug("[WCF.Message.Preview] Unable to find preview button identified by '"+c+"'");return}this._previewButton.click($.proxy(this._click,this));this._proxy=new WCF.Action.Proxy({failure:$.proxy(this._failure,this),success:$.proxy(this._success,this)})},_click:function(b){var a=this._getMessage();if(a===null){console.debug("[WCF.Message.Preview] Unable to access ckEditor instance of '"+this._messageFieldID+"'");return}this._proxy.setOption("data",{actionName:"getMessagePreview",className:this._className,parameters:this._getParameters(a)});this._proxy.sendRequest();this._previewButtonLabel=this._previewButton.html();this._previewButton.html(WCF.Language.get("wcf.global.loading")).disable();b.stopPropagation();return false},_getParameters:function(b){var a={};$("#settings").find("input[type=checkbox]").each(function(c,e){var d=$(e);if(d.is(":checked")){a[d.prop("name")]=d.prop("value")}});return{data:{message:b},options:a}},_getMessage:function(){if($.browser.mobile){return this._messageField.val()}else{if(this._messageField.data("ckeditorInstance")){var a=this._messageField.ckeditorGet();return a.getData()}}return null},_success:function(b,c,a){this._previewButton.html(this._previewButtonLabel).enable();this._messageField.parent().children("small.innerError").remove();this._handleResponse(b)},_handleResponse:function(a){},_failure:function(a){if(a===null||a.returnValues===undefined||a.returnValues.errorType===undefined){return true}this._previewButton.html(this._previewButtonLabel).enable();var b=this._messageField.next("small.innerError").empty();if(!b.length){b=$('<small class="innerError" />').appendTo(this._messageField.parent())}b.html(a.returnValues.errorType);return false}});WCF.Message.DefaultPreview=WCF.Message.Preview.extend({_attachmentObjectType:null,_attachmentObjectID:null,_tmpHash:null,init:function(b,a,c){this._super("wcf\\data\\bbcode\\MessagePreviewAction","text","previewButton");this._attachmentObjectType=b||null;this._attachmentObjectID=a||null;this._tmpHash=c||null},_handleResponse:function(b){var a=$("#previewContainer");if(!a.length){a=$('<div class="container containerPadding marginTop" id="previewContainer"><fieldset><legend>'+WCF.Language.get("wcf.global.preview")+"</legend><div></div></fieldset>").prependTo($("#messageContainer")).wcfFadeIn()}a.find("div:eq(0)").html(b.returnValues.message)},_getParameters:function(b){var a=this._super(b);if(this._attachmentObjectType!=null){a.attachmentObjectType=this._attachmentObjectType;a.attachmentObjectID=this._attachmentObjectID;a.tmpHash=this._tmpHash}return a}});WCF.Message.Multilingualism=Class.extend({_availableLanguages:{},_languageID:0,_languageInput:null,init:function(c,d,a){this._availableLanguages=d;this._languageID=c||0;this._languageInput=$("#languageID");this._updateLabel();this._languageInput.find(".dropdownMenu > li").click($.proxy(this._click,this));if(!a){var b=this._languageInput.find(".dropdownMenu");$('<li class="dropdownDivider" />').appendTo(b);$('<li><span><span class="badge">'+this._availableLanguages[0]+"</span></span></li>").click($.proxy(this._disable,this)).appendTo(b)}this._languageInput.parents("form").submit($.proxy(this._submit,this))},_click:function(a){this._languageID=$(a.currentTarget).data("languageID");this._updateLabel()},_disable:function(){this._languageID=0;this._updateLabel()},_updateLabel:function(){this._languageInput.find(".dropdownToggle > span").text(this._availableLanguages[this._languageID])},_submit:function(){this._languageInput.next("input[name=languageID]").prop("value",this._languageID)}});WCF.Message.SmileyCategories=Class.extend({_cache:[],_proxy:null,_ckEditor:null,init:function(){this._cache=[];this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});$("#smilies").on("wcftabsbeforeactivate",$.proxy(this._click,this));var a=this;new WCF.PeriodicalExecuter(function(b){b.stop();a._click({},{newTab:$("#smilies > .menu li.ui-state-active")})},100)},_click:function(b,c){var a=parseInt($(c.newTab).children("a").data("smileyCategoryID"));if(a&&!WCF.inArray(a,this._cache)){this._proxy.setOption("data",{actionName:"getSmilies",className:"wcf\\data\\smiley\\category\\SmileyCategoryAction",objectIDs:[a]});this._proxy.sendRequest()}},_success:function(c,d,b){var a=parseInt(c.returnValues.smileyCategoryID);this._cache.push(a);$("#smilies-"+a).html(c.returnValues.template)}});WCF.Message.Smilies=Class.extend({_ckEditor:null,init:function(a){if(a){this._ckEditor=$("#"+a);$(document).on("click",".jsSmiley",$.proxy(this._smileyClick,this))}},_smileyClick:function(c){var e=$(c.currentTarget);var h=e.data("smileyCode");var i=this._ckEditor.ckeditorGet();var f=e.find("img").attr("src");if(!WCF.inArray(h,i.config.smiley_descriptions)){i.config.smiley_descriptions.push(h);i.config.smiley_images.push(f)}if(i.mode==="wysiwyg"){var a=i.document.createElement("img",{attributes:{src:f,"class":"smiley",alt:h}});i.insertText(" ");i.insertElement(a);i.insertText(" ")}else{var g=this._ckEditor.next(".cke_editor_text").find("textarea");var j=g.val();if(j.length==0){g.val(h);g.setCaret(h.length)}else{var d=g.getCaret();var b=((j.substr(d-1,1)!==" ")?" ":"")+h+" ";g.val(j.substr(0,d)+b+j.substr(d));g.setCaret(d+b.length)}}}});WCF.Message.QuickReply=Class.extend({_container:null,_messageField:null,_notification:null,_pendingSave:false,_proxy:null,_quoteManager:null,_scrollHandler:null,_successMessageNonVisible:"",init:function(c,b){this._container=$("#messageQuickReply");this._messageField=$("#text");this._pendingSave=false;if(!this._container||!this._messageField){return}var a=this._container.find(".formSubmit");a.find("button[data-type=save]").click($.proxy(this._save,this));if(c){a.find("button[data-type=extended]").click($.proxy(this._prepareExtended,this))}a.find("button[data-type=cancel]").click($.proxy(this._cancel,this));if(b){this._quoteManager=b}$(".jsQuickReply").data("__api",this).click($.proxy(this.click,this));this._proxy=new WCF.Action.Proxy({failure:$.proxy(this._failure,this),showLoadingOverlay:false,success:$.proxy(this._success,this)});this._scroll=new WCF.Effect.Scroll();this._notification=new WCF.System.Notification(WCF.Language.get("wcf.global.success.add"));this._successMessageNonVisible=""},click:function(b){this._container.toggle();if(this._container.is(":visible")){this._scroll.scrollTo(this._container,true);WCF.Message.Submit.registerButton("text",this._container.find(".formSubmit button[data-type=save]"));if(this._quoteManager){var a=true;if($.browser.touch){a=(!this._messageField.val().length)}else{a=(!this._messageField.ckeditorGet().getData().length)}if(a){this._quoteManager.insertQuotes(this._getClassName(),this._getObjectID(),$.proxy(this._insertQuotes,this))}}new WCF.PeriodicalExecuter($.proxy(function(c){c.stop();if($.browser.mobile){this._messageField.focus()}else{this._messageField.ckeditorGet().ui.editor.focus()}},this),250)}if(b!==null){b.stopPropagation();return false}},getContainer:function(){return this._container},_insertQuotes:function(a){if(!a.returnValues.template){return}if($.browser.mobile){this._messageField.val(a.returnValues.template)}else{this._messageField.ckeditorGet().insertText(a.returnValues.template)}},_save:function(){if(this._pendingSave){return}var b="";if($.browser.mobile){b=$.trim(this._messageField.val())}else{var a=this._messageField.ckeditorGet();b=$.trim(a.getData())}var d=this._messageField.parent().find("small.innerError");if(b===""){if(!d.length){d=$('<small class="innerError" />').appendTo(this._messageField.parent())}d.html(WCF.Language.get("wcf.global.form.error.empty"));return}else{d.remove()}this._pendingSave=true;this._proxy.setOption("data",{actionName:"quickReply",className:this._getClassName(),interfaceName:"wcf\\data\\IMessageQuickReplyAction",parameters:this._getParameters(b)});this._proxy.sendRequest();var c=this._container.find(".messageQuickReplyContent .messageBody");$('<span class="icon icon48 icon-spinner" />').appendTo(c);c.children("#cke_text").hide().end().next().hide()},_getParameters:function(b){var a={objectID:this._getObjectID(),data:{message:b},lastPostTime:this._container.data("lastPostTime"),pageNo:this._container.data("pageNo"),removeQuoteIDs:(this._quoteManager===null?[]:this._quoteManager.getQuotesMarkedForRemoval())};if(this._container.data("anchor")){a.anchor=this._container.data("anchor")}return a},_cancel:function(){this._revertQuickReply(true);if($.browser.mobile){this._messageField.val("")}else{this._messageField.ckeditorGet().setData("")}},_revertQuickReply:function(b){var a=this._container.find(".messageQuickReplyContent .messageBody");if(b){this._container.hide();a.children("small.innerError").remove()}a.children(".icon-spinner").remove();a.children("#cke_text").show();a.next().show()},_prepareExtended:function(){this._pendingSave=true;if(this._quoteManager!==null){this._quoteManager.markQuotesForRemoval()}var b="";if($.browser.mobile){b=this._messageField.val()}else{var a=this._messageField.ckeditorGet();b=a.getData()}new WCF.Action.Proxy({autoSend:true,data:{actionName:"jumpToExtended",className:this._getClassName(),interfaceName:"wcf\\data\\IExtendedMessageQuickReplyAction",parameters:{containerID:this._getObjectID(),message:b}},success:function(d,e,c){window.location=d.returnValues.url}})},_success:function(c,d,b){if(c.returnValues.url){window.location=c.returnValues.url}else{if(c.returnValues.template){var a=$(""+c.returnValues.template);a.insertBefore(this._container);this._container.data("lastPostTime",c.returnValues.lastPostTime);this._notification.show(undefined,undefined,WCF.Language.get("wcf.global.success.add"));this._updateHistory(a.wcfIdentify())}else{var a=(this._successMessageNonVisible)?this._successMessageNonVisible:"wcf.global.success.add";this._notification.show(undefined,5000,WCF.Language.get(a))}if($.browser.mobile){this._messageField.val("")}else{this._messageField.ckeditorGet().setData("")}this._revertQuickReply(true);if(this._quoteManager!==null){this._quoteManager.countQuotes()}this._pendingSave=false}},_failure:function(b){this._pendingSave=false;this._revertQuickReply(false);if(b===null||b.returnValues===undefined||b.returnValues.errorType===undefined){return true}var a=this._container.find(".messageQuickReplyContent .messageBody");var c=a.children("small.innerError").empty();if(!c.length){c=$('<small class="innerError" />').appendTo(a)}c.html(b.returnValues.errorType);return false},_getClassName:function(){return""},_getObjectID:function(){return 0},_updateHistory:function(a){window.location.hash=a}});WCF.Message.InlineEditor=Class.extend({_activeElementID:"",_cache:"",_container:{},_containerID:0,_dropdowns:{},_messageContainerSelector:".jsMessage",_messageEditorIDPrefix:"messageEditor",_notification:null,_proxy:null,_quoteManager:null,_supportExtendedForm:false,init:function(a,c,b){this._activeElementID="";this._cache="";this._container={};this._containerID=parseInt(a);this._dropdowns={};this._quoteManager=b||null;this._supportExtendedForm=(c)?true:false;this._proxy=new WCF.Action.Proxy({failure:$.proxy(this._failure,this),showLoadingOverlay:false,success:$.proxy(this._success,this)});this._notification=new WCF.System.Notification(WCF.Language.get("wcf.global.success.edit"));this.initContainers();WCF.DOMNodeInsertedHandler.addCallback("WCF.Message.InlineEditor",$.proxy(this.initContainers,this))},initContainers:function(){$(this._messageContainerSelector).each($.proxy(function(b,a){var d=$(a);var c=d.wcfIdentify();if(!this._container[c]){this._container[c]=d;if(d.data("canEditInline")){d.find(".jsMessageEditButton:eq(0)").data("containerID",c).click($.proxy(this._clickInline,this)).dblclick($.proxy(this._click,this))}else{if(d.data("canEdit")){d.find(".jsMessageEditButton:eq(0)").data("containerID",c).click($.proxy(this._click,this))}}}},this))},_click:function(c,a){var b=(c===null)?a:$(c.currentTarget).data("containerID");if(this._activeElementID===""){this._activeElementID=b;this._prepare();this._proxy.setOption("data",{actionName:"beginEdit",className:this._getClassName(),interfaceName:"wcf\\data\\IMessageInlineEditorAction",parameters:{containerID:this._containerID,objectID:this._container[b].data("objectID")}});this._proxy.sendRequest()}else{var d=new WCF.System.Notification(WCF.Language.get("wcf.message.error.editorAlreadyInUse"),"warning");d.show()}if(c!==null){c.stopPropagation();return false}},_clickInline:function(c){var d=$(c.currentTarget);if(!d.hasClass("dropdownToggle")){var b=d.data("containerID");d.addClass("dropdownToggle").parent().addClass("dropdown");var a=$('<ul class="dropdownMenu" />').insertAfter(d);this._initDropdownMenu(b,a);WCF.DOMNodeInsertedHandler.execute();this._dropdowns[this._container[b].data("objectID")]=a;WCF.Dropdown.registerCallback(d.parent().wcfIdentify(),$.proxy(this._toggleDropdown,this));d.trigger("click")}c.stopPropagation();return false},_failure:function(b){this._revertEditor();if(b===null||b.returnValues===undefined||b.returnValues.errorType===undefined){return true}var a=this._container[this._activeElementID].find(".messageBody .messageInlineEditor");var c=a.children("small.innerError").empty();if(!c.length){c=$('<small class="innerError" />').insertBefore(a.children(".formSubmit"))}c.html(b.returnValues.errorType);return false},_toggleDropdown:function(a,b){WCF.Dropdown.getDropdown(a).parents(".messageOptions").toggleClass("forceOpen")},_initDropdownMenu:function(a,b){},_prepare:function(){var b=this._container[this._activeElementID].find(".messageBody");$('<span class="icon icon48 icon-spinner" />').appendTo(b);var a=b.find(".messageText");this._cache=a.html();a.empty()},_cancel:function(){var d=this._container[this._activeElementID];try{var a=$("#"+this._messageEditorIDPrefix+d.data("objectID")).ckeditorGet();a.destroy()}catch(c){}var b=d.find(".messageBody");b.children(".icon-spinner").remove();b.find(".messageText").html(this._cache);this._container[this._activeElementID].find(".messageOptions").removeClass("forceHidden");this._activeElementID="";if(this._quoteManager){this._quoteManager.clearAlternativeCKEditor()}},_success:function(b,c,a){switch(b.returnValues.actionName){case"beginEdit":this._showEditor(b);break;case"save":this._showMessage(b);break}},_showEditor:function(e){var c=this._container[this._activeElementID].find(".messageBody");c.children(".icon-spinner").remove();var b=c.find(".messageText");$(""+e.returnValues.template).appendTo(b);var a=b.find(".formSubmit");var d=a.find("button[data-type=save]").click($.proxy(this._save,this));if(this._supportExtendedForm){a.find("button[data-type=extended]").click($.proxy(this._prepareExtended,this))}a.find("button[data-type=cancel]").click($.proxy(this._cancel,this));WCF.Message.Submit.registerButton(this._messageEditorIDPrefix+this._container[this._activeElementID].data("objectID"),d);this._container[this._activeElementID].find(".messageOptions").addClass("forceHidden");new WCF.PeriodicalExecuter($.proxy(function(f){f.stop();var g=$("#"+this._messageEditorIDPrefix+this._container[this._activeElementID].data("objectID"));g.ckeditorGet().ui.editor.focus();if(this._quoteManager){this._quoteManager.setAlternativeCKEditor(g)}},this),250)},_revertEditor:function(){var a=this._container[this._activeElementID].find(".messageBody");a.children("span.icon-spinner").remove();a.find(".messageText").children().show();if(this._quoteManager){this._quoteManager.clearAlternativeCKEditor()}},_save:function(){var d=this._container[this._activeElementID];var c=d.data("objectID");var b="";if($.browser.mobile){b=$("#"+this._messageEditorIDPrefix+c).val()}else{var a=$("#"+this._messageEditorIDPrefix+c).ckeditorGet();b=a.getData()}this._proxy.setOption("data",{actionName:"save",className:this._getClassName(),interfaceName:"wcf\\data\\IMessageInlineEditorAction",parameters:{containerID:this._containerID,data:{message:b},objectID:c}});this._proxy.sendRequest();this._hideEditor()},_prepareExtended:function(){var d=this._container[this._activeElementID];var c=d.data("objectID");var b="";if($.browser.mobile){b=$("#"+this._messageEditorIDPrefix+c).val()}else{var a=$("#"+this._messageEditorIDPrefix+c).ckeditorGet();b=a.getData()}new WCF.Action.Proxy({autoSend:true,data:{actionName:"jumpToExtended",className:this._getClassName(),parameters:{containerID:this._containerID,message:b,messageID:c}},success:function(f,g,e){window.location=f.returnValues.url}})},_hideEditor:function(){var a=this._container[this._activeElementID].find(".messageBody");$('<span class="icon icon48 icon-spinner" />').appendTo(a);a.find(".messageText").children().hide();if(this._quoteManager){this._quoteManager.clearAlternativeCKEditor()}},_showMessage:function(d){var e=this._container[this._activeElementID];var c=e.find(".messageBody");c.children(".icon-spinner").remove();var b=c.find(".messageText");this._container[this._activeElementID].find(".messageOptions").removeClass("forceHidden");if(!$.browser.mobile){var a=$("#"+this._messageEditorIDPrefix+e.data("objectID")).ckeditorGet();a.destroy()}b.empty();b.html(d.returnValues.message);this._activeElementID="";this._updateHistory(this._getHash(e.data("objectID")));this._notification.show();if(this._quoteManager){this._quoteManager.clearAlternativeCKEditor()}},_getClassName:function(){return""},_getHash:function(a){return"#message"+a},_updateHistory:function(a){window.location.hash=a}});WCF.Message.Submit={_buttons:{},registerButton:function(b,a){if(!WCF.Browser.isChrome()){return}this._buttons[b]=$(a)},execute:function(a){if(!this._buttons[a]){return}this._buttons[a].trigger("click")}};WCF.Message.Quote={};WCF.Message.Quote.Handler=Class.extend({_activeContainerID:"",_className:"",_containers:{},_containerSelector:"",_copyQuote:null,_message:"",_messageBodySelector:"",_objectID:0,_objectType:"",_proxy:null,_quoteManager:null,init:function(e,d,b,a,c,f){this._className=d;if(this._className==""){console.debug("[WCF.Message.QuoteManager] Empty class name given, aborting.");return}this._objectType=b;if(this._objectType==""){console.debug("[WCF.Message.QuoteManager] Empty object type name given, aborting.");return}this._containerSelector=a;this._message="";this._messageBodySelector=c;this._messageContentSelector=f;this._objectID=0;this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});this._initContainers();this._initCopyQuote();$(document).mouseup($.proxy(this._mouseUp,this));this._quoteManager=e;this._quoteManager.register(this._objectType,this);WCF.DOMNodeInsertedHandler.addCallback("WCF.Message.Quote.Handler"+b.hashCode(),$.proxy(this._initContainers,this))},_initContainers:function(){var a=this;$(this._containerSelector).each(function(c,b){var e=$(b);var d=e.wcfIdentify();if(!a._containers[d]){a._containers[d]=e;if(e.hasClass("jsInvalidQuoteTarget")){return true}if(a._messageBodySelector!==null){e=e.find(a._messageBodySelector).data("containerID",d)}e.mousedown($.proxy(a._mouseDown,a));a._containers[d].find(".jsQuoteMessage").click($.proxy(a._saveFullQuote,a))}})},_mouseDown:function(a){this._copyQuote.hide();var b=$(a.currentTarget);if(this._messageBodySelector){b=this._containers[b.data("containerID")]}this._activeContainerID=b.wcfIdentify();if($.browser.mozilla){b.find("img").each(function(){var c=$(this);c.data("__alt",c.attr("alt")).removeAttr("alt")})}},_getNodeText:function(d){var c="";for(var b=0;b<d.childNodes.length;b++){if(d.childNodes[b].nodeType==3){c+=d.childNodes[b].nodeValue}else{var a=d.childNodes[b].tagName.toLowerCase();if(a==="li"){c+="\r\n"}c+=this._getNodeText(d.childNodes[b]);if(a==="ul"){c+="\n"}}}return c},_mouseUp:function(a){if(this._activeContainerID==""){this._copyQuote.hide();return}var i=this._containers[this._activeContainerID];var c=this._getSelectedText();var f=$.trim(c);if(f==""){this._copyQuote.hide();return}var d=null;if(this._messageBodySelector){d=this._getNodeText(i.find(this._messageContentSelector).get(0))}else{d=this._getNodeText(i.get(0))}if(this._normalize(d).indexOf(this._normalize(f))===-1){return}this._copyQuote.show();var g=this._getBoundingRectangle(i,c);var e=this._copyQuote.getDimensions("outer");var b=(g.right-g.left)/2-(e.width/2)+g.left;this._copyQuote.css({top:g.top-e.height-7+"px",left:b+"px"});this._copyQuote.hide();this._activeContainerID="";var h=this;new WCF.PeriodicalExecuter(function(j){j.stop();var k=$.trim(h._getSelectedText());if(k!=""){h._copyQuote.show();h._message=k;h._objectID=i.data("objectID");if($.browser.mozilla){i.find("img").each(function(){var l=$(this);l.attr("alt",l.data("__alt"))})}}},10)},_normalize:function(a){return a.replace(/\r?\n|\r/g,"\n").replace(/\s{2,}/g," ")},_getOffset:function(c,d){c.collapse(d);var f=WCF.getRandomID();var a=document.createElement("span");a.innerHTML='<span id="'+f+'"></span>';var g=document.createDocumentFragment(),b;while(b=a.firstChild){g.appendChild(b)}c.insertNode(g);a=$("#"+f);var e=a.offset();e.top=e.top-$(window).scrollTop();a.remove();return e},_getBoundingRectangle:function(a,i){var k=null;if(document.createRange&&typeof document.createRange().getBoundingClientRect!="undefined"){if(i.rangeCount>0){var j=i.getRangeAt(0).getClientRects();var f={};if(!$.browser.mozilla&&j.length>1){var e=i.getRangeAt(0);var g=this._saveSelection(a.get(0));var c=this._getOffset(e,true);var e=i.getRangeAt(0);var b=this._getOffset(e,false);f={left:(c.left>b.left)?b.left:c.left,right:(c.left>b.left)?c.left:b.left,top:(c.top>b.top)?b.top:c.top};this._restoreSelection(a.get(0),g)}else{f=i.getRangeAt(0).getBoundingClientRect()}var d=$(document);var h=d.scrollTop();k={left:f.left,right:f.right,top:f.top+h}}}else{if(document.selection&&document.selection.type!="Control"){var e=document.selection.createRange();k={left:e.boundingLeft,right:e.boundingRight,top:e.boundingTop}}}return k},_saveSelection:function(d){if(window.getSelection&&document.createRange){var c=window.getSelection().getRangeAt(0);var b=c.cloneRange();b.selectNodeContents(d);b.setEnd(c.startContainer,c.startOffset);var f=b.toString().length;return{start:f,end:f+c.toString().length}}else{var a=document.selection.createRange();var e=document.body.createTextRange();e.moveToElementText(d);e.setEndPoint("EndToStart",a);var f=e.text.length;return{start:f,end:f+a.text.length}}},_restoreSelection:function(j,k){if(window.getSelection&&document.createRange){var a=0,g=document.createRange();g.setStart(j,0);g.collapse(true);var f=[j],c,d=false,l=false;while(!l&&(c=f.pop())){if(c.nodeType==3){var h=a+c.length;if(!d&&k.start>=a&&k.start<=h){g.setStart(c,k.start-a);d=true}if(d&&k.end>=a&&k.end<=h){g.setEnd(c,k.end-a);l=true}a=h}else{var e=c.childNodes.length;while(e--){f.push(c.childNodes[e])}}}var b=window.getSelection();b.removeAllRanges();b.addRange(g)}else{var m=document.body.createTextRange();m.moveToElementText(j);m.collapse(true);m.moveEnd("character",k.end);m.moveStart("character",k.start);m.select()}},_initCopyQuote:function(){this._copyQuote=$("#quoteManagerCopy");if(!this._copyQuote.length){this._copyQuote=$('<div id="quoteManagerCopy" class="balloonTooltip"><span>'+WCF.Language.get("wcf.message.quote.quoteSelected")+'</span><span class="pointer"><span></span></span></div>').hide().appendTo(document.body);this._copyQuote.click($.proxy(this._saveQuote,this))}},_getSelectedText:function(){if(window.getSelection){return window.getSelection()}else{if(document.getSelection){return document.getSelection()}else{if(document.selection){return document.selection.createRange().text}}}return""},_saveFullQuote:function(b){var a=$(b.currentTarget);this._proxy.setOption("data",{actionName:"saveFullQuote",className:this._className,interfaceName:"wcf\\data\\IMessageQuoteAction",objectIDs:[a.data("objectID")]});this._proxy.sendRequest();if(a.data("isQuoted")){a.data("isQuoted",false).children("a").removeClass("active")}else{a.data("isQuoted",true).children("a").addClass("active")}b.stopPropagation();return false},_saveQuote:function(){this._proxy.setOption("data",{actionName:"saveQuote",className:this._className,interfaceName:"wcf\\data\\IMessageQuoteAction",objectIDs:[this._objectID],parameters:{message:this._message}});this._proxy.sendRequest()},_success:function(c,d,b){if(c.returnValues.count!==undefined){var a=(c.fullQuoteObjectIDs!==undefined)?c.fullQuoteObjectIDs:{};this._quoteManager.updateCount(c.returnValues.count,a)}},updateFullQuoteObjectIDs:function(b){for(var a in this._containers){this._containers[a].find(".jsQuoteMessage").each(function(c,d){var e=$(d).data("isQuoted",0);e.children("a").removeClass("active");if(WCF.inArray(e.data("objectID"),b)){e.data("isQuoted",1).children("a").addClass("active")}})}}});WCF.Message.Quote.Manager=Class.extend({_buttons:{},_ckEditor:null,_ckEditorAlternative:null,_count:0,_dialog:null,_form:null,_handlers:{},_hasTemplate:false,_insertQuotes:true,_proxy:null,_removeOnSubmit:[],_showQuotes:null,_supportPaste:false,init:function(c,b,a,d){this._buttons={insert:null,remove:null};this._ckEditor=null;this._ckEditorAlternative=null;this._count=parseInt(c)||0;this._dialog=null;this._form=null;this._handlers={};this._hasTemplate=false;this._insertQuotes=true;this._removeOnSubmit=[];this._showQuotes=null;this._supportPaste=false;if(b){this._ckEditor=$("#"+b);if(this._ckEditor.length){this._supportPaste=true;this._form=this._ckEditor.parents("form:eq(0)");if(this._form.length){this._form.submit($.proxy(this._submit,this));this._removeOnSubmit=d||[]}else{this._form=null;this._supportPaste=(a===true)?true:false}}}this._proxy=new WCF.Action.Proxy({showLoadingOverlay:false,success:$.proxy(this._success,this),url:"index.php/MessageQuote/?t="+SECURITY_TOKEN+SID_ARG_2ND});this._toggleShowQuotes()},setAlternativeCKEditor:function(a){this._ckEditorAlternative=a},clearAlternativeCKEditor:function(){this._ckEditorAlternative=null},register:function(a,b){this._handlers[a]=b},updateCount:function(c,b){this._count=parseInt(c)||0;this._toggleShowQuotes();for(var a in this._handlers){if(b[a]){this._handlers[a].updateFullQuoteObjectIDs(b[a])}}},insertQuotes:function(a,b,c){if(!this._insertQuotes){this._insertQuotes=true;return}new WCF.Action.Proxy({autoSend:true,data:{actionName:"getRenderedQuotes",className:a,interfaceName:"wcf\\data\\IMessageQuoteAction",parameters:{parentObjectID:b}},success:c})},_toggleShowQuotes:function(){if(!this._count){if(this._showQuotes!==null){this._showQuotes.hide()}}else{if(this._showQuotes===null){this._showQuotes=$("#showQuotes");if(!this._showQuotes.length){this._showQuotes=$('<div id="showQuotes" class="balloonTooltip" />').click($.proxy(this._click,this)).appendTo(document.body)}}var a=WCF.Language.get("wcf.message.quote.showQuotes").replace(/#count#/,this._count);this._showQuotes.text(a).show()}this._hasTemplate=false},_click:function(){if(this._hasTemplate){this._dialog.wcfDialog("open")}else{this._proxy.showLoadingOverlayOnce();this._proxy.setOption("data",{actionName:"getQuotes",supportPaste:this._supportPaste});this._proxy.sendRequest()}},renderDialog:function(c){if(this._dialog===null){this._dialog=$("#messageQuoteList");if(!this._dialog.length){this._dialog=$('<div id="messageQuoteList" />').hide().appendTo(document.body)}}this._dialog.html(c);var a=$('<div class="formSubmit" />').appendTo(this._dialog);if(this._supportPaste){this._buttons.insert=$("<button>"+WCF.Language.get("wcf.message.quote.insertAllQuotes")+"</button>").click($.proxy(this._insertSelected,this)).appendTo(a)}this._buttons.remove=$("<button>"+WCF.Language.get("wcf.message.quote.removeAllQuotes")+"</button>").click($.proxy(this._removeSelected,this)).appendTo(a);this._dialog.wcfDialog({title:WCF.Language.get("wcf.message.quote.manageQuotes")});this._dialog.wcfDialog("render");this._hasTemplate=true;var d=this._dialog.find(".jsInsertQuote");if(this._supportPaste){d.click($.proxy(this._insertQuote,this))}else{d.hide()}this._dialog.find("input.jsCheckbox").change($.proxy(this._changeButtons,this));if(this._removeOnSubmit.length){var b=this;this._dialog.find("input.jsRemoveQuote").each(function(f,e){var g=$(e).change($.proxy(this._change,this));if(WCF.inArray(g.parent("li").attr("data-quote-id"),b._removeOnSubmit)){g.attr("checked","checked")}})}},_changeButtons:function(){if(this._dialog.find("input.jsCheckbox:checked").length){if(this._supportPaste){this._buttons.insert.html(WCF.Language.get("wcf.message.quote.insertSelectedQuotes"))}this._buttons.remove.html(WCF.Language.get("wcf.message.quote.removeSelectedQuotes"))}else{if(this._supportPaste){this._buttons.insert.html(WCF.Language.get("wcf.message.quote.insertAllQuotes"))}this._buttons.remove.html(WCF.Language.get("wcf.message.quote.removeAllQuotes"))}},_change:function(c){var d=$(c.currentTarget);var b=d.parent("li").attr("data-quote-id");if(d.prop("checked")){this._removeOnSubmit.push(b)}else{for(var a in this._removeOnSubmit){if(this._removeOnSubmit[a]==b){delete this._removeOnSubmit[a];break}}}},_insertSelected:function(){if(this._ckEditorAlternative===null){var a=$(".jsQuickReply:eq(0)").data("__api");if(a&&!a.getContainer().is(":visible")){this._insertQuotes=false;a.click(null)}}if(!this._dialog.find("input.jsCheckbox:checked").length){this._dialog.find("input.jsCheckbox").prop("checked","checked")}this._dialog.find("input.jsCheckbox:checked").each($.proxy(function(c,b){this._insertQuote(null,b)},this));this._dialog.wcfDialog("close")},_insertQuote:function(a,i){if(a!==null&&this._ckEditorAlternative===null){var c=$(".jsQuickReply:eq(0)").data("__api");if(c&&!c.getContainer().is(":visible")){this._insertQuotes=false;c.click(null)}}var g=(a===null)?$(i).parents("li"):$(a.currentTarget).parents("li");var j=$.trim(g.children("div.jsFullQuote").text());var e=g.parents("article.message");j="[quote='"+e.attr("data-username")+"','"+e.data("link")+"']"+j+"[/quote]";var f=null;if(!$.browser.mobile){if(this._ckEditorAlternative===null){f=this._ckEditor.ckeditorGet()}else{f=this._ckEditorAlternative.ckeditorGet()}}if(f!==null&&f.mode==="wysiwyg"){f.insertText(j+"\n\n")}else{var d=null;if(this._ckEditorAlternative===null){d=($.browser.mobile)?this._ckEditor:this._ckEditor.next(".cke_editor_text").find("textarea")}else{d=($.browser.mobile)?this._ckEditorAlternative:this._ckEditorAlternative.next(".cke_editor_text").find("textarea")}var h=d.val();j+="\n\n";if(h.length==0){d.val(j)}else{var b=d.getCaret();d.val(h.substr(0,b)+j+h.substr(b))}}this._removeOnSubmit.push(g.attr("data-quote-id"));if(a!==null){this._dialog.wcfDialog("close")}},_removeSelected:function(){if(!this._dialog.find("input.jsCheckbox:checked").length){this._dialog.find("input.jsCheckbox").prop("checked","checked")}var b=[];this._dialog.find("input.jsCheckbox:checked").each(function(e,d){b.push($(d).parents("li").attr("data-quote-id"))});if(b.length){var c=[];for(var a in this._handlers){c.push(a)}this._proxy.setOption("data",{actionName:"remove",getFullQuoteObjectIDs:this._handlers.length>0,objectTypes:c,quoteIDs:b});this._proxy.sendRequest();this._dialog.wcfDialog("close")}},_submit:function(){if(this._supportPaste&&this._removeOnSubmit.length>0){var a=this._form.find(".formSubmit");for(var b in this._removeOnSubmit){$('<input type="hidden" name="__removeQuoteIDs[]" value="'+this._removeOnSubmit[b]+'" />').appendTo(a)}}},getQuotesMarkedForRemoval:function(){return this._removeOnSubmit},markQuotesForRemoval:function(){if(this._removeOnSubmit.length){this._proxy.setOption("data",{actionName:"markForRemoval",quoteIDs:this._removeOnSubmit});this._proxy.suppressErrors();this._proxy.sendRequest()}},removeMarkedQuotes:function(){if(this._removeOnSubmit.length){this._proxy.setOption("data",{actionName:"removeMarkedQuotes",getFullQuoteObjectIDs:this._handlers.length>0});this._proxy.sendRequest()}},countQuotes:function(){var b=[];for(var a in this._handlers){b.push(a)}this._proxy.setOption("data",{actionName:"count",getFullQuoteObjectIDs:this._handlers.length>0,objectTypes:b});this._proxy.sendRequest()},_success:function(c,d,b){if(c===null){return}if(c.count!==undefined){var a=(c.fullQuoteObjectIDs!==undefined)?c.fullQuoteObjectIDs:{};this.updateCount(c.count,a)}if(c.template!==undefined){if($.trim(c.template)==""){this.updateCount(0,{})}else{this.renderDialog(c.template)}}}});WCF.Message.Share={};WCF.Message.Share.Content=Class.extend({_cache:{},_dialog:null,init:function(){this._cache={};this._dialog=null;this._initLinks();WCF.DOMNodeInsertedHandler.addCallback("WCF.Message.Share.Content",$.proxy(this._initLinks,this))},_initLinks:function(){$("a.jsButtonShare").removeClass("jsButtonShare").click($.proxy(this._click,this))},_click:function(e){e.preventDefault();var a=$(e.currentTarget);var b=a.prop("href");var d=(a.data("linkTitle")?a.data("linkTitle"):b);var c=b.hashCode();if(this._cache[c]===undefined){var g=false;if(this._dialog===null){this._dialog=$("<div />").hide().appendTo(document.body);g=true}else{this._dialog.empty()}var f=$('<fieldset><legend><label for="__sharePermalink">'+WCF.Language.get("wcf.message.share.permalink")+"</label></legend></fieldset>").appendTo(this._dialog);$('<input type="text" id="__sharePermalink" class="long" readonly="readonly" />').attr("value",b).appendTo(f);var f=$('<fieldset><legend><label for="__sharePermalinkBBCode">'+WCF.Language.get("wcf.message.share.permalink.bbcode")+"</label></legend></fieldset>").appendTo(this._dialog);$('<input type="text" id="__sharePermalinkBBCode" class="long" readonly="readonly" />').attr("value","[url='"+b+"']"+d+"[/url]").appendTo(f);var f=$('<fieldset><legend><label for="__sharePermalinkHTML">'+WCF.Language.get("wcf.message.share.permalink.html")+"</label></legend></fieldset>").appendTo(this._dialog);$('<input type="text" id="__sharePermalinkHTML" class="long" readonly="readonly" />').attr("value",'<a href="'+b+'">'+WCF.String.escapeHTML(d)+"</a>").appendTo(f);this._cache[c]=this._dialog.html();if(g){this._dialog.wcfDialog({title:WCF.Language.get("wcf.message.share")})}else{this._dialog.wcfDialog("open")}}else{this._dialog.html(this._cache[c]).wcfDialog("open")}this._dialog.find("input").click(function(){$(this).select()})}});WCF.Message.Share.Page=Class.extend({_ui:{},_pageDescription:"",_pageURL:"",init:function(a){this._pageDescription=encodeURIComponent($('meta[property="og:description"]').prop("content"));this._pageURL=encodeURIComponent($('meta[property="og:url"]').prop("content"));var b=$(".messageShareButtons");this._ui={facebook:b.find(".jsShareFacebook"),google:b.find(".jsShareGoogle"),reddit:b.find(".jsShareReddit"),twitter:b.find(".jsShareTwitter")};this._ui.facebook.children("a").click($.proxy(this._shareFacebook,this));this._ui.google.children("a").click($.proxy(this._shareGoogle,this));this._ui.reddit.children("a").click($.proxy(this._shareReddit,this));this._ui.twitter.children("a").click($.proxy(this._shareTwitter,this));if(a===true){this._fetchFacebook();this._fetchTwitter();this._fetchReddit()}},_share:function(b,a){window.open(a.replace(/{pageURL}/,this._pageURL).replace(/{text}/,this._pageDescription),"height=600,width=600")},_shareFacebook:function(){this._share("facebook","https://www.facebook.com/sharer.php?u={pageURL}&t={text}")},_shareGoogle:function(){this._share("google","https://plus.google.com/share?url={pageURL}")},_shareReddit:function(){this._share("reddit","https://ssl.reddit.com/submit?url={pageURL}")},_shareTwitter:function(){this._share("twitter","https://twitter.com/share?url={pageURL}&text={text}")},_fetchCount:function(b,d,c){var a={autoSend:true,dataType:"jsonp",showLoadingOverlay:false,success:d,suppressErrors:true,type:"GET",url:b.replace(/{pageURL}/,this._pageURL)};if(c){a.jsonp=c}new WCF.Action.Proxy(a)},_fetchFacebook:function(){this._fetchCount("https://graph.facebook.com/?id={pageURL}",$.proxy(function(a){if(a.shares){this._ui.facebook.children("span.badge").show().text(a.shares)}},this))},_fetchTwitter:function(){this._fetchCount("http://urls.api.twitter.com/1/urls/count.json?url={pageURL}",$.proxy(function(a){if(a.count){this._ui.twitter.children("span.badge").show().text(a.count)}},this))},_fetchReddit:function(){this._fetchCount("http://www.reddit.com/api/info.json?url={pageURL}",$.proxy(function(a){if(a.data.children.length){this._ui.reddit.children("span.badge").show().text(a.data.children[0].data.score)}},this),"jsonp")}});
\ No newline at end of file