WCF.Comment={};WCF.Comment.Handler=Class.extend({_commentAdd:null,_commentButtonList:{},_comments:{},_container:null,_containerID:"",_displayedComments:0,_loadNextComments:null,_loadNextResponses:{},_proxy:null,_responses:{},_userAvatar:"",_commentData:{},_guestDialog:null,init:function(a,b){this._commentAdd=null;this._commentButtonList={};this._comments={};this._containerID=a;this._displayedComments=0;this._loadNextComments=null;this._loadNextResponses={};this._responses={};this._userAvatar=b;this._container=$("#"+$.wcfEscapeID(this._containerID));if(!this._container.length){console.debug("[WCF.Comment.Handler] Unable to find container identified by '"+this._containerID+"'")}this._proxy=new WCF.Action.Proxy({failure:$.proxy(this._failure,this),success:$.proxy(this._success,this)});this._initComments();this._initResponses();if(this._container.data("canAdd")){this._initAddComment()}WCF.DOMNodeInsertedHandler.execute();WCF.DOMNodeInsertedHandler.addCallback("WCF.Comment.Handler",$.proxy(this._domNodeInserted,this));WCF.System.ObjectStore.add("WCF.Comment.Handler",this)},_handleLoadNextComments:function(){if(this._displayedComments<this._container.data("comments")){if(this._loadNextComments===null){this._loadNextComments=$('<li class="commentLoadNext"><button class="small">'+WCF.Language.get("wcf.comment.more")+"</button></li>").appendTo(this._container);this._loadNextComments.children("button").click($.proxy(this._loadComments,this))}this._loadNextComments.children("button").enable()}else{if(this._loadNextComments!==null){this._loadNextComments.hide()}}},_handleLoadNextResponses:function(a){var b=this._comments[a];b.data("displayedResponses",b.find("ul.commentResponseList > li").length);if(b.data("displayedResponses")<b.data("responses")){if(this._loadNextResponses[a]===undefined){var d=b.data("responses")-b.data("displayedResponses");this._loadNextResponses[a]=$('<li class="jsCommentLoadNextResponses"><a>'+WCF.Language.get("wcf.comment.response.more",{count:d})+"</a></li>").appendTo(this._commentButtonList[a]);this._loadNextResponses[a].children("a").data("commentID",a).click($.proxy(this._loadResponses,this));this._commentButtonList[a].parent().show()}}else{if(this._loadNextResponses[a]!==undefined){var c=this._loadNextResponses[a].next();this._loadNextResponses[a].remove();if(c.length){c.trigger("click")}}}},_loadComments:function(){this._loadNextComments.children("button").disable();this._proxy.setOption("data",{actionName:"loadComments",className:"wcf\\data\\comment\\CommentAction",parameters:{data:{objectID:this._container.data("objectID"),objectTypeID:this._container.data("objectTypeID"),lastCommentTime:this._container.data("lastCommentTime")}}});this._proxy.sendRequest()},_loadResponses:function(a){this._loadResponsesExecute($(a.currentTarget).disable().data("commentID"),false)},_loadResponsesExecute:function(a,b){this._proxy.setOption("data",{actionName:"loadResponses",className:"wcf\\data\\comment\\response\\CommentResponseAction",parameters:{data:{commentID:a,lastResponseTime:this._comments[a].data("lastResponseTime"),loadAllResponses:(b?1:0)}}});this._proxy.sendRequest()},_domNodeInserted:function(){this._initComments();this._initResponses()},_initComments:function(){var a=this;var b=false;this._container.find(".jsComment").each(function(e,g){var f=$(g).removeClass("jsComment");var c=f.data("commentID");a._comments[c]=f;var d=f.find("ul.commentResponseList");if(!d.length){d=f.find(".commentContent")}$container=$('<div class="commentOptionContainer" />').hide().insertAfter(d);a._commentButtonList[c]=$("<ul />").appendTo($container);a._handleLoadNextResponses(c);a._initComment(c,f);a._displayedComments++;b=true});if(b){this._handleLoadNextComments()}},_initComment:function(a,d){if(this._container.data("canAdd")){this._initAddResponse(a,d)}if(d.data("canEdit")){var b=$('<li><a class="jsTooltip" title="'+WCF.Language.get("wcf.global.button.edit")+'"><span class="icon icon16 icon-pencil" /> <span class="invisible">'+WCF.Language.get("wcf.global.button.edit")+"</span></a></li>");b.data("commentID",a).appendTo(d.find("ul.commentOptions:eq(0)")).click($.proxy(this._prepareEdit,this))}if(d.data("canDelete")){var c=$('<li><a class="jsTooltip" title="'+WCF.Language.get("wcf.global.button.delete")+'"><span class="icon icon16 icon-remove" /> <span class="invisible">'+WCF.Language.get("wcf.global.button.delete")+"</span></a></li>");c.data("commentID",a).appendTo(d.find("ul.commentOptions:eq(0)")).click($.proxy(this._delete,this))}},_initResponses:function(){var a=this;this._container.find(".jsCommentResponse").each(function(d,c){var b=$(c).removeClass("jsCommentResponse");var e=b.data("responseID");a._responses[e]=b;a._initResponse(e,b)})},_initResponse:function(a,c){if(c.data("canEdit")){var d=$('<li><a class="jsTooltip" title="'+WCF.Language.get("wcf.global.button.edit")+'"><span class="icon icon16 icon-pencil" /> <span class="invisible">'+WCF.Language.get("wcf.global.button.edit")+"</span></a></li>");var b=this;d.data("responseID",a).appendTo(c.find("ul.commentOptions:eq(0)")).click(function(f){b._prepareEdit(f,true)})}if(c.data("canDelete")){var e=$('<li><a class="jsTooltip" title="'+WCF.Language.get("wcf.global.button.delete")+'"><span class="icon icon16 icon-remove" /> <span class="invisible">'+WCF.Language.get("wcf.global.button.delete")+"</span></a></li>");var b=this;e.data("responseID",a).appendTo(c.find("ul.commentOptions:eq(0)")).click(function(f){b._delete(f,true)})}},_initAddComment:function(){this._commentAdd=$('<li class="box32 jsCommentAdd"><span class="framed">'+this._userAvatar+"</span><div /></li>").prependTo(this._container);var a=this._commentAdd.children("div");var b=$('<textarea placeholder="'+WCF.Language.get("wcf.comment.add")+'" maxlength="65535" class="long" />').appendTo(a).flexible();$('<button class="small">'+WCF.Language.get("wcf.global.button.submit")+"</button>").click($.proxy(this._save,this)).appendTo(a);b.keyup($.proxy(this._keyUp,this))},_initAddResponse:function(d,g){var c=$('<li class="jsCommentShowAddResponse"><a>'+WCF.Language.get("wcf.comment.button.response.add")+"</a></li>").data("commentID",d).click($.proxy(this._showAddResponse,this)).appendTo(this._commentButtonList[d]);var e=$('<div class="box32 commentResponseAdd jsCommentResponseAdd"><span class="framed">'+this._userAvatar+"</span><div /></div>").hide();e.appendTo(this._commentButtonList[d].parent().show());var a=e.children("div");var f=$('<textarea placeholder="'+WCF.Language.get("wcf.comment.response.add")+'" maxlength="65535" class="long" />').data("commentID",d).appendTo(a).flexible();$('<button class="small">'+WCF.Language.get("wcf.global.button.submit")+"</button>").click($.proxy(function(h){this._save(h,true)},this)).appendTo(a);var b=this;f.keyup(function(h){b._keyUp(h,true)});g.data("responsePlaceholder",c).data("responseInput",e)},_prepareEdit:function(c,a){var d=$(c.currentTarget);var b={objectID:this._container.data("objectID"),objectTypeID:this._container.data("objectTypeID")};if(a===true){b.responseID=d.data("responseID")}else{b.commentID=d.data("commentID")}this._proxy.setOption("data",{actionName:"prepareEdit",className:"wcf\\data\\comment\\CommentAction",parameters:{data:b}});this._proxy.sendRequest()},_showAddResponse:function(c){var b=$(c.currentTarget);var a=b.data("commentID");if(b.prev().hasClass("jsCommentLoadNextResponses")){this._loadResponsesExecute(a,true);b.parent().children(".button").disable()}b.remove();var d=this._comments[a].data("responseInput").show();d.find("textarea").focus();d.parents(".commentOptionContainer").addClass("jsAddResponseActive")},_keyUp:function(b,a){if(b.which===$.ui.keyCode.ESCAPE){$(b.currentTarget).val("").trigger("blur",b).trigger("updateHeight");return}else{if(b.which===$.ui.keyCode.ENTER&&b.ctrlKey){this._save(null,a,$(b.currentTarget));return false}}},_save:function(f,b,c){var g=(f===null)?c:$(f.currentTarget).prev("textarea");var e=$.trim(g.val());if(e==""){return}var a="addComment";var d={message:e,objectID:this._container.data("objectID"),objectTypeID:this._container.data("objectTypeID")};if(b===true){a="addResponse";d.commentID=g.data("commentID")}if(!WCF.User.userID){this._commentData=d;this._proxy.setOption("data",{actionName:"getGuestDialog",className:"wcf\\data\\comment\\CommentAction",parameters:{data:{message:e,objectID:this._container.data("objectID"),objectTypeID:this._container.data("objectTypeID")}}});this._proxy.sendRequest()}else{this._proxy.setOption("data",{actionName:a,className:"wcf\\data\\comment\\CommentAction",parameters:{data:d}});this._proxy.sendRequest()}},_delete:function(b,a){WCF.System.Confirmation.show(WCF.Language.get("wcf.comment.delete.confirmMessage"),$.proxy(function(d){if(d==="confirm"){var c={objectID:this._container.data("objectID"),objectTypeID:this._container.data("objectTypeID")};if(a!==true){c.commentID=$(b.currentTarget).data("commentID")}else{c.responseID=$(b.currentTarget).data("responseID")}this._proxy.setOption("data",{actionName:"remove",className:"wcf\\data\\comment\\CommentAction",parameters:{data:c}});this._proxy.sendRequest()}},this))},_failure:function(b,a,d,c){if(!WCF.User.userID&&this._guestDialog){this._guestDialog.find('input[type="submit"]').enable()}return true},_success:function(d,e,b){switch(d.actionName){case"addComment":if(d.returnValues.guestDialog){this._createGuestDialog(d.returnValues.guestDialog,d.returnValues.useCaptcha)}else{this._commentAdd.find("textarea").val("").blur().trigger("updateHeight");$(d.returnValues.template).insertAfter(this._commentAdd).wcfFadeIn();if(!WCF.User.userID){this._guestDialog.wcfDialog("close")}}break;case"addResponse":if(d.returnValues.guestDialog){this._createGuestDialog(d.returnValues.guestDialog,d.returnValues.useCaptcha)}else{var c=this._comments[d.returnValues.commentID];c.find(".jsCommentResponseAdd textarea").val("").blur().trigger("updateHeight");var a=c.find("ul.commentResponseList");if(!a.length){a=$('<ul class="commentResponseList" />').insertBefore(c.find(".commentOptionContainer"))}$(d.returnValues.template).appendTo(a).wcfFadeIn()}if(!WCF.User.userID){this._guestDialog.wcfDialog("close")}break;case"edit":this._update(d);break;case"loadComments":this._insertComments(d);break;case"loadResponses":this._insertResponses(d);break;case"prepareEdit":this._edit(d);break;case"remove":this._remove(d);break;case"getGuestDialog":this._createGuestDialog(d.returnValues.template,d.returnValues.useCaptcha);break}WCF.DOMNodeInsertedHandler.execute()},_insertComments:function(a){$(a.returnValues.template).insertBefore(this._loadNextComments);this._container.data("lastCommentTime",a.returnValues.lastCommentTime)},_insertResponses:function(b){var a=this._comments[b.returnValues.commentID];$(b.returnValues.template).appendTo(a.find("ul.commentResponseList"));a.data("lastResponseTime",b.returnValues.lastResponseTime);this._handleLoadNextResponses(b.returnValues.commentID)},_remove:function(a){if(a.returnValues.commentID){this._comments[a.returnValues.commentID].remove();delete this._comments[a.returnValues.commentID]}else{this._responses[a.returnValues.responseID].remove();delete this._responses[a.returnValues.responseID]}},_edit:function(b){if(b.returnValues.commentID){var a=this._comments[b.returnValues.commentID].find(".commentContent:eq(0) .userMessage:eq(0)")}else{var a=this._responses[b.returnValues.responseID].find(".commentContent:eq(0) .userMessage:eq(0)")}a.html($.proxy(function(d,c){var e=$('<input type="text" class="long" maxlength="65535" /><small>'+WCF.Language.get("wcf.comment.description")+"</small>").val(b.returnValues.message);e.data("__html",c).keyup($.proxy(this._saveEdit,this));if(b.returnValues.commentID){e.data("commentID",b.returnValues.commentID)}else{e.data("responseID",b.returnValues.responseID)}return e},this));a.children("input").focus();a.parent().find(".containerHeadline:eq(0)").hide();a.parent().find(".buttonGroupNavigation:eq(0)").hide()},_update:function(a){if(a.returnValues.commentID){var b=this._comments[a.returnValues.commentID].find(".commentContent:eq(0) .userMessage:eq(0) > input")}else{var b=this._responses[a.returnValues.responseID].find(".commentContent:eq(0) .userMessage:eq(0) > input")}b.data("__html",a.returnValues.message);this._cancelEdit(b)},_createGuestDialog:function(b,a){var c=!!this._guestDialog;if(!this._guestDialog){this._guestDialog=$('<div id="commentAddGuestDialog" />').hide().appendTo(document.body)}this._guestDialog.html(b);this._guestDialog.data("useCaptcha",a);this._guestDialog.find('input[type="submit"]').click($.proxy(this._submit,this));this._guestDialog.find('input[type="text"]').keydown($.proxy(this._keyDown,this));this._guestDialog.wcfDialog({title:WCF.Language.get("wcf.comment.guestDialog.title")})},_keyDown:function(a){if(a.which===$.ui.keyCode.ENTER){this._submit()}},_submit:function(b){var c={actionName:this._commentData.commentID?"addResponse":"addComment",className:"wcf\\data\\comment\\CommentAction"};var a=this._commentData;a.username=this._guestDialog.find('input[name="username"]').val();c.parameters={data:a};c=$.extend(WCF.System.Captcha.getData("commentAdd"),c);this._proxy.setOption("data",c);this._proxy.sendRequest()},_saveEdit:function(c){var d=$(c.currentTarget);if(c.which===27){this._cancelEdit(d);return}else{if(c.which!==13){return}}var b=$.trim(d.val());if(b===""){return}var a={message:b,objectID:this._container.data("objectID"),objectTypeID:this._container.data("objectTypeID")};if(d.data("commentID")){a.commentID=d.data("commentID")}else{a.responseID=d.data("responseID")}this._proxy.setOption("data",{actionName:"edit",className:"wcf\\data\\comment\\CommentAction",parameters:{data:a}});this._proxy.sendRequest()},_cancelEdit:function(a){a.parent().prev(".containerHeadline:eq(0)").show();a.parent().next(".buttonGroupNavigation:eq(0)").show();a.parent().html(a.data("__html"))}});WCF.Comment.Like=WCF.Like.extend({_getContainers:function(){return $(".commentList > li.comment")},_getObjectID:function(a){return this._containers[a].data("commentID")},_buildWidget:function(b,a,d,c,e){this._containers[b].find(".containerHeadline:eq(0) > h3").append(c);if(this._canLike){a.appendTo(this._containers[b].find(".commentOptions:eq(0)"));d.appendTo(this._containers[b].find(".commentOptions:eq(0)"))}},_getWidgetContainer:function(a){},_addWidget:function(a,b){}});WCF.Comment.Response={};WCF.Comment.Response.Like=WCF.Like.extend({_addWidget:function(a,b){},_buildWidget:function(b,a,d,c,e){this._containers[b].find(".containerHeadline:eq(0) > h3").append(c);if(this._canLike){a.appendTo(this._containers[b].find(".commentOptions:eq(0)"));d.appendTo(this._containers[b].find(".commentOptions:eq(0)"))}},_getContainers:function(){return $(".commentResponseList > li.commentResponse")},_getObjectID:function(a){return this._containers[a].data("responseID")},_getWidgetContainer:function(a){}});
// WCF.ImageViewer.js
-WCF.ImageViewer=Class.extend({init:function(){$('<span class="icon icon16 icon-chevron-left jsTooltip" title="'+WCF.Language.get("wcf.imageViewer.previous")+'" />').appendTo($("#lbPrevLink"));$('<span class="icon icon16 icon-chevron-right jsTooltip" title="'+WCF.Language.get("wcf.imageViewer.next")+'" />').appendTo($("#lbNextLink"));$('<span class="icon icon32 icon-remove jsTooltip" title="'+WCF.Language.get("wcf.imageViewer.close")+'" />').appendTo($("#lbCloseLink"));var a=$('<span class="icon icon32 icon-resize-full jsTooltip" title="'+WCF.Language.get("wcf.imageViewer.enlarge")+'" id="lbEnlarge" />').insertAfter($("#lbCloseLink"));a.click($.proxy(this._enlarge,this));this._initImageViewer();WCF.DOMNodeInsertedHandler.addCallback("WCF.ImageViewer",$.proxy(this._domNodeInserted,this));WCF.DOMNodeInsertedHandler.execute()},_domNodeInserted:function(){this._initImageSizeCheck();this._initImageViewer()},_initImageViewer:function(){if($.browser.touch&&/[Mm]obile/.test(navigator.userAgent)){if(!/iPad/.test(navigator.userAgent)){return}}var a=$("a.jsImageViewer");if(a.length){a.removeClass("jsImageViewer").slimbox({counterText:WCF.Language.get("wcf.imageViewer.counter"),loop:true})}},_enlarge:function(){var a=$("#lbImage").css("backgroundImage");if(a){a=a.replace(/^url\((["']?)(.*)\1\)$/,"$2");window.location=a}},_initImageSizeCheck:function(){$(".jsResizeImage").each($.proxy(function(a,b){if(b.complete){this._checkImageSize({currentTarget:b})}},this));$(".jsResizeImage").on("load",$.proxy(this._checkImageSize,this))},_checkImageSize:function(d){var c=$(d.currentTarget);if(!c.is(":visible")){c.off("load");return}c.removeClass("jsResizeImage");var b=c.getDimensions();var a=c.parents("div").innerWidth();if(b.width>a){c.css({height:Math.round(b.height*(a/b.width))+"px",width:a+"px"});if(!c.parents("a").length){c.wrap('<a href="'+c.attr("src")+'" />');c.parent().slimbox()}}}});$.widget("ui.wcfImageViewer",{_active:-1,_activeImage:null,_container:null,_didInit:false,_disableSlideshow:false,_eventNamespace:"",_images:[],_isOpen:false,_items:-1,_maxDimensions:{height:0,width:0},_proxy:null,_slideshowEnabled:false,_thumbnailContainerWidth:0,_thumbnailMarginRight:0,_thumbnailOffset:0,_thumbnailWidth:0,_timer:null,_ui:{buttonNext:null,buttonPrevious:null,header:null,image:null,imageContainer:null,imageList:null,slideshow:{container:null,enlarge:null,next:null,previous:null,toggle:null}},options:{shiftBy:5,enableSlideshow:1,speed:5,className:""},_create:function(){this._active=-1;this._activeImage=null;this._container=null;this._didInit=false;this._disableSlideshow=(this.element.data("disableSlideshow"));this._eventNamespace=this.element.wcfIdentify();this._images=[];this._isOpen=false;this._items=-1;this._maxDimensions={height:document.documentElement.clientHeight,width:document.documentElement.clientWidth};this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});this._slideshowEnabled=false;this._thumbnailContainerWidth=0;this._thumbnailMarginRight=0;this._thumbnailOffset=0;this._thumbnaiLWidth=0;this._timer=null;this._ui={};this.element.click($.proxy(this.open,this))},open:function(a){if(a){a.preventDefault()}if(this._isOpen){return false}if(this._images.length===0){this._loadNextImages(true)}else{this._render(false,this.element.data("targetImageID"));if(this._items>1&&this._slideshowEnabled){this.startSlideshow()}}this._bindListener();this._isOpen=true;WCF.System.DisableScrolling.disable();return true},close:function(a){if(a){a.preventDefault()}if(!this._isOpen){return false}this._container.removeClass("open");if(this._timer!==null){this._timer.stop()}this._unbindListener();this._isOpen=false;WCF.System.DisableScrolling.enable();return true},startSlideshow:function(){if(this._disableSlideshow||this._slideshowEnabled){return false}if(this._timer===null){this._timer=new WCF.PeriodicalExecuter($.proxy(function(){var a=this._active+1;if(a==this._items){a=0}this.showImage(a)},this),this.options.speed*1000)}else{this._timer.resume()}this._slideshowEnabled=true;this._ui.slideshow.toggle.children("span").removeClass("icon-play").addClass("icon-pause");return true},stopSlideshow:function(a){if(!this._slideshowEnabled){return false}this._timer.stop();if(a){this._ui.slideshow.toggle.children("span").removeClass("icon-pause").addClass("icon-play")}this._slideshowEnabled=false;return true},_bindListener:function(){$(document).on("keydown."+this._eventNamespace,$.proxy(this._keyDown,this));$(window).on("resize."+this._eventNamespace,$.proxy(this._renderImage,this))},_unbindListener:function(){$(document).off("keydown."+this._eventNamespace);$(window).off("resize."+this._eventNamespace)},_keyDown:function(b){switch(b.which){case $.ui.keyCode.ESCAPE:this.close();break;case $.ui.keyCode.LEFT:this._previousImage();break;case $.ui.keyCode.RIGHT:this._nextImage();break;case $.ui.keyCode.UP:if(!this._container.hasClass("maximized")){this._toggleView()}break;case $.ui.keyCode.DOWN:if(this._container.hasClass("maximized")){this._toggleView()}break;case $.ui.keyCode.ENTER:var a=this._ui.header.find("> div > h1 > a");if(a.length==1){window.location=a.prop("href")}else{this._ui.slideshow.full.trigger("click")}break;case 80:this._ui.slideshow.toggle.trigger("click");break;default:return true;break}return false},_render:function(c,a){this._container.addClass("open");var b=null;if(c){b=this._ui.imageList.children("li:eq(0)");this._thumbnailMarginRight=parseInt(b.css("marginRight").replace(/px$/,""))||0;this._thumbnailWidth=b.outerWidth(true);this._thumbnailContainerWidth=this._ui.imageList.parent().innerWidth();if(this._items>1&&this.options.enableSlideshow&&!a){this.startSlideshow()}}if(a){this._ui.imageList.children("li").each($.proxy(function(e,f){var d=$(f);if(d.data("objectID")==a){d.trigger("click");this.moveToImage(d.data("index"));return false}},this))}else{if(b!==null){b.trigger("click")}}this._toggleButtons();this._preload()},_preload:function(){if(this._images.length<this._items){var a=this._images.length*this._thumbnailWidth;if(a-this._thumbnailOffset<this._thumbnailContainerWidth){this._loadNextImages(false)}}},_showImage:function(a){this.showImage($(a.currentTarget).data("index"),true)},showImage:function(e,c){if(this._active==e){return false}this.stopSlideshow(c||false);if(this._active!=-1){this._images[this._active].listItem.removeClass("active")}this._active=e;var b=this._images[e];this._ui.imageList.children("li").removeClass("active");b.listItem.addClass("active");var g=this._ui.imageContainer.getDimensions("inner");var i=(this._activeImage?0:1);if(this._activeImage!==null){this._ui.images[this._activeImage].removeClass("active")}this._activeImage=i;var a=this._active;this._ui.imageContainer.addClass("loading");this._ui.images[i].off("load").prop("src",false).on("load",$.proxy(function(){this._imageOnLoad(a,i)},this));this._renderImage(i,b,g);var f=this._ui.header.find("> div > a").prop("href",b.user.link).prop("title",b.user.username);f.children("img").prop("src",b.user.avatarURL);var h=WCF.String.escapeHTML(b.image.title);if(b.image.link){h='<a href="'+b.image.link+'">'+b.image.title+"</a>"}this._ui.header.find("> div > h1").html(h);var d=(b.series&&b.series.title?WCF.String.escapeHTML(b.series.title):"");if(b.series.link){d='<a href="'+b.series.link+'">'+d+"</a>"}this._ui.header.find("> div > h2").html(d);this._ui.header.find("> div > h3").text(WCF.Language.get("wcf.imageViewer.seriesIndex").replace(/{x}/,b.listItem.data("index")+1).replace(/{y}/,this._items));this._ui.slideshow.full.data("link",(b.image.fullURL?b.image.fullURL:b.image.url));this.moveToImage(b.listItem.data("index"));this._toggleButtons();return true},_imageOnLoad:function(b,a){if(b!=this._active){return}this._ui.imageContainer.removeClass("loading");this._ui.images[a].addClass("active");this.startSlideshow()},_renderImage:function(c,g,e){if(!g){c=this._activeImage;g=this._images[this._active];e={height:$(window).height()-(this._container.hasClass("maximized")?0:200),width:this._ui.imageContainer.innerWidth()}}e.height-=22;e.width-=20;this._ui.images[c].prop("src",g.image.url);var d=g.image.height;var b=g.image.width;var a=0;if(d>e.height){a=e.height/d;d=e.height;b=Math.floor(b*a)}if(b>e.width){a=e.width/b;b=e.width;d=Math.floor(d*a)}var f=Math.floor((e.width-b)/2);this._ui.images[c].css({height:d+"px",left:(f+10)+"px",marginTop:(Math.round(d/2)*-1)+"px",width:b+"px"})},_initUI:function(){if(this._didInit){return false}this._didInit=true;this._container=$('<div class="wcfImageViewer" />').appendTo(document.body);var c=$('<div><img class="active" /><img /></div>').appendTo(this._container);var g=$('<footer><span class="wcfImageViewerButtonPrevious icon icon-double-angle-left" /><div><ul /></div><span class="wcfImageViewerButtonNext icon icon-double-angle-right" /></footer>').appendTo(this._container);var e=$("<ul />").appendTo(c);var d=$('<li class="wcfImageViewerSlideshowButtonPrevious"><span class="icon icon48 icon-angle-left" /></li>').appendTo(e);var f=$('<li class="wcfImageViewerSlideshowButtonToggle pointer"><span class="icon icon48 icon-play" /></li>').appendTo(e);var b=$('<li class="wcfImageViewerSlideshowButtonNext"><span class="icon icon48 icon-angle-right" /></li>').appendTo(e);var h=$('<li class="wcfImageViewerSlideshowButtonEnlarge pointer jsTooltip" title="'+WCF.Language.get("wcf.imageViewer.button.enlarge")+'"><span class="icon icon48 icon-resize-full" /></li>').appendTo(e);var a=$('<li class="wcfImageViewerSlideshowButtonFull pointer jsTooltip" title="'+WCF.Language.get("wcf.imageViewer.button.full")+'"><span class="icon icon48 icon-external-link" /></li>').appendTo(e);this._ui={buttonNext:g.children("span.wcfImageViewerButtonNext"),buttonPrevious:g.children("span.wcfImageViewerButtonPrevious"),header:$('<header><div class="box64"><a class="framed jsTooltip"><img /></a><h1 /><h2 /><h3 /></div></header>').appendTo(this._container),imageContainer:c,images:[c.children("img:eq(0)").on("webkitTransitionEnd transitionend msTransitionEnd oTransitionEnd",function(){$(this).removeClass("animateTransformation")}),c.children("img:eq(1)").on("webkitTransitionEnd transitionend msTransitionEnd oTransitionEnd",function(){$(this).removeClass("animateTransformation")})],imageList:g.find("> div > ul"),slideshow:{container:e,enlarge:h,full:a,next:b,previous:d,toggle:f}};this._ui.buttonNext.click($.proxy(this._next,this));this._ui.buttonPrevious.click($.proxy(this._previous,this));b.click($.proxy(this._nextImage,this));d.click($.proxy(this._previousImage,this));h.click($.proxy(this._toggleView,this));f.click($.proxy(function(){if(this._slideshowEnabled){this.stopSlideshow(true)}else{this._disableSlideshow=false;this.startSlideshow()}},this));a.click(function(i){window.location=$(i.currentTarget).data("link")});$('<span class="wcfImageViewerButtonClose icon icon48 icon-remove pointer jsTooltip" title="'+WCF.Language.get("wcf.global.button.close")+'" />').appendTo(this._ui.header).click($.proxy(this.close,this));return true},_toggleView:function(){this._ui.images[this._activeImage].addClass("animateTransformation");this._container.toggleClass("maximized");this._ui.slideshow.enlarge.toggleClass("active").children("span").toggleClass("icon-resize-full").toggleClass("icon-resize-small");this._renderImage(null,undefined,null)},_next:function(c,b){if(this._ui.buttonNext.hasClass("pointer")){if(b==undefined){this.stopSlideshow(true)}var a=Math.max((this._items*this._thumbnailWidth)-this._thumbnailContainerWidth-this._thumbnailMarginRight,0);this._thumbnailOffset=Math.min(this._thumbnailOffset+(this._thumbnailWidth*(b?b:this.options.shiftBy)),a);this._ui.imageList.css("marginLeft",(this._thumbnailOffset*-1))}this._preload();this._toggleButtons()},_previous:function(b,a){if(this._ui.buttonPrevious.hasClass("pointer")){if(a==undefined){this.stopSlideshow(true)}this._thumbnailOffset=Math.max(this._thumbnailOffset-(this._thumbnailWidth*(a?a:this.options.shiftBy)),0);this._ui.imageList.css("marginLeft",(this._thumbnailOffset*-1))}this._toggleButtons()},_nextImage:function(a){if(this._ui.slideshow.next.hasClass("pointer")){this._disableSlideshow=true;this.stopSlideshow(true);this.showImage(this._active+1)}},_previousImage:function(a){if(this._ui.slideshow.previous.hasClass("pointer")){this._disableSlideshow=true;this.stopSlideshow(true);this.showImage(this._active-1)}},moveToImage:function(b){var f=(b-3)*this._thumbnailWidth;var d=f+(this._thumbnailWidth*5);var e=this._thumbnailOffset;var a=this._thumbnailOffset+this._thumbnailContainerWidth;var g=false;if(f<e||d>a){g=true}if(g){var c=0;if(f<e){while(f<e){c++;e-=this._thumbnailWidth}this._previous(null,c)}else{while(d>a){c++;a+=this._thumbnailWidth}this._next(null,c)}}},_toggleButtons:function(){if(this._thumbnailOffset>0){this._ui.buttonPrevious.addClass("pointer")}else{this._ui.buttonPrevious.removeClass("pointer")}var a=(this._images.length*this._thumbnailWidth)-this._thumbnailContainerWidth-this._thumbnailMarginRight;if(this._thumbnailOffset>=a){this._ui.buttonNext.removeClass("pointer")}else{this._ui.buttonNext.addClass("pointer")}if(this._active>0){this._ui.slideshow.previous.addClass("pointer")}else{this._ui.slideshow.previous.removeClass("pointer")}if(this._active+1<this._images.length){this._ui.slideshow.next.addClass("pointer")}else{this._ui.slideshow.next.removeClass("pointer")}},_createThumbnails:function(a){for(var f=0,e=a.length;f<e;f++){var d=a[f];var c=$('<li class="loading pointer"><img src="'+d.thumbnail.url+'" /></li>').appendTo(this._ui.imageList);c.data("index",this._images.length).data("objectID",d.objectID).click($.proxy(this._showImage,this));var b=c.children("img");if(b.get(0).complete){c.removeClass("loading")}else{b.on("load",function(){$(this).parent().removeClass("loading")})}d.listItem=c;this._images.push(d)}},_loadNextImages:function(a){this._proxy.setOption("data",{actionName:"loadNextImages",className:this.options.className,interfaceName:"wcf\\data\\IImageViewerAction",objectIDs:[this.element.data("objectID")],parameters:{maximumHeight:this._maxDimensions.height,maximumWidth:this._maxDimensions.width,offset:this._images.length,targetImageID:(a&&this.element.data("targetImageID")?this.element.data("targetImageID"):0)}});this._proxy.setOption("showLoadingOverlay",false);this._proxy.sendRequest()},_success:function(c,e,b){if(c.returnValues.items){this._items=c.returnValues.items}var a=this._initUI();this._createThumbnails(c.returnValues.images);var d=(c.returnValues.targetImageID?c.returnValues.targetImageID:0);this._render(a,d)}});
+WCF.ImageViewer=Class.extend({init:function(){$('<span class="icon icon16 icon-chevron-left jsTooltip" title="'+WCF.Language.get("wcf.imageViewer.previous")+'" />').appendTo($("#lbPrevLink"));$('<span class="icon icon16 icon-chevron-right jsTooltip" title="'+WCF.Language.get("wcf.imageViewer.next")+'" />').appendTo($("#lbNextLink"));$('<span class="icon icon32 icon-remove jsTooltip" title="'+WCF.Language.get("wcf.imageViewer.close")+'" />').appendTo($("#lbCloseLink"));var a=$('<span class="icon icon32 icon-resize-full jsTooltip" title="'+WCF.Language.get("wcf.imageViewer.enlarge")+'" id="lbEnlarge" />').insertAfter($("#lbCloseLink"));a.click($.proxy(this._enlarge,this));this._initImageViewer();WCF.DOMNodeInsertedHandler.addCallback("WCF.ImageViewer",$.proxy(this._domNodeInserted,this));WCF.DOMNodeInsertedHandler.execute()},_domNodeInserted:function(){this._initImageSizeCheck();this._initImageViewer()},_initImageViewer:function(){if($.browser.touch&&/[Mm]obile/.test(navigator.userAgent)){if(!/iPad/.test(navigator.userAgent)){return}}var a=$("a.jsImageViewer");if(a.length){a.removeClass("jsImageViewer").slimbox({counterText:WCF.Language.get("wcf.imageViewer.counter"),loop:true})}},_enlarge:function(){var a=$("#lbImage").css("backgroundImage");if(a){a=a.replace(/^url\((["']?)(.*)\1\)$/,"$2");window.location=a}},_initImageSizeCheck:function(){$(".jsResizeImage").each($.proxy(function(a,b){if(b.complete){this._checkImageSize({currentTarget:b})}},this));$(".jsResizeImage").on("load",$.proxy(this._checkImageSize,this))},_checkImageSize:function(d){var c=$(d.currentTarget);if(!c.is(":visible")){c.off("load");return}c.removeClass("jsResizeImage");var b=c.getDimensions();var a=c.parents("div").innerWidth();if(b.width>a){c.css({height:Math.round(b.height*(a/b.width))+"px",width:a+"px"});if(!c.parents("a").length){c.wrap('<a href="'+c.attr("src")+'" />');c.parent().slimbox()}}}});$.widget("ui.wcfImageViewer",{_active:-1,_activeImage:null,_container:null,_didInit:false,_disableSlideshow:false,_eventNamespace:"",_images:[],_isOpen:false,_items:-1,_maxDimensions:{height:0,width:0},_proxy:null,_slideshowEnabled:false,_thumbnailContainerWidth:0,_thumbnailMarginRight:0,_thumbnailOffset:0,_thumbnailWidth:0,_timer:null,_ui:{buttonNext:null,buttonPrevious:null,header:null,image:null,imageContainer:null,imageList:null,slideshow:{container:null,enlarge:null,next:null,previous:null,toggle:null}},options:{shiftBy:5,enableSlideshow:1,speed:5,className:""},_create:function(){this._active=-1;this._activeImage=null;this._container=null;this._didInit=false;this._disableSlideshow=(this.element.data("disableSlideshow"));this._eventNamespace=this.element.wcfIdentify();this._images=[];this._isOpen=false;this._items=-1;this._maxDimensions={height:document.documentElement.clientHeight,width:document.documentElement.clientWidth};this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});this._slideshowEnabled=false;this._thumbnailContainerWidth=0;this._thumbnailMarginRight=0;this._thumbnailOffset=0;this._thumbnaiLWidth=0;this._timer=null;this._ui={};this.element.click($.proxy(this.open,this))},open:function(a){if(a){a.preventDefault()}if(this._isOpen){return false}if(this._images.length===0){this._loadNextImages(true)}else{this._render(false,this.element.data("targetImageID"));if(this._items>1&&this._slideshowEnabled){this.startSlideshow()}this._isOpen=true;WCF.System.DisableScrolling.disable()}this._bindListener();return true},close:function(a){if(a){a.preventDefault()}if(!this._isOpen){return false}this._container.removeClass("open");if(this._timer!==null){this._timer.stop()}this._unbindListener();this._isOpen=false;WCF.System.DisableScrolling.enable();return true},startSlideshow:function(){if(this._disableSlideshow||this._slideshowEnabled){return false}if(this._timer===null){this._timer=new WCF.PeriodicalExecuter($.proxy(function(){var a=this._active+1;if(a==this._items){a=0}this.showImage(a)},this),this.options.speed*1000)}else{this._timer.resume()}this._slideshowEnabled=true;this._ui.slideshow.toggle.children("span").removeClass("icon-play").addClass("icon-pause");return true},stopSlideshow:function(a){if(!this._slideshowEnabled){return false}this._timer.stop();if(a){this._ui.slideshow.toggle.children("span").removeClass("icon-pause").addClass("icon-play")}this._slideshowEnabled=false;return true},_bindListener:function(){$(document).on("keydown."+this._eventNamespace,$.proxy(this._keyDown,this));$(window).on("resize."+this._eventNamespace,$.proxy(this._renderImage,this))},_unbindListener:function(){$(document).off("keydown."+this._eventNamespace);$(window).off("resize."+this._eventNamespace)},_keyDown:function(b){switch(b.which){case $.ui.keyCode.ESCAPE:this.close();break;case $.ui.keyCode.LEFT:this._previousImage();break;case $.ui.keyCode.RIGHT:this._nextImage();break;case $.ui.keyCode.UP:if(!this._container.hasClass("maximized")){this._toggleView()}break;case $.ui.keyCode.DOWN:if(this._container.hasClass("maximized")){this._toggleView()}break;case $.ui.keyCode.ENTER:var a=this._ui.header.find("> div > h1 > a");if(a.length==1){window.location=a.prop("href")}else{this._ui.slideshow.full.trigger("click")}break;case 80:this._ui.slideshow.toggle.trigger("click");break;default:return true;break}return false},_render:function(c,a){this._container.addClass("open");var b=null;if(c){b=this._ui.imageList.children("li:eq(0)");this._thumbnailMarginRight=parseInt(b.css("marginRight").replace(/px$/,""))||0;this._thumbnailWidth=b.outerWidth(true);this._thumbnailContainerWidth=this._ui.imageList.parent().innerWidth();if(this._items>1&&this.options.enableSlideshow&&!a){this.startSlideshow()}}if(a){this._ui.imageList.children("li").each($.proxy(function(e,f){var d=$(f);if(d.data("objectID")==a){d.trigger("click");this.moveToImage(d.data("index"));return false}},this))}else{if(b!==null){b.trigger("click")}}this._toggleButtons();this._preload()},_preload:function(){if(this._images.length<this._items){var a=this._images.length*this._thumbnailWidth;if(a-this._thumbnailOffset<this._thumbnailContainerWidth){this._loadNextImages(false)}}},_showImage:function(a){this.showImage($(a.currentTarget).data("index"),true)},showImage:function(e,c){if(this._active==e){return false}this.stopSlideshow(c||false);if(this._active!=-1){this._images[this._active].listItem.removeClass("active")}this._active=e;var b=this._images[e];this._ui.imageList.children("li").removeClass("active");b.listItem.addClass("active");var g=this._ui.imageContainer.getDimensions("inner");var i=(this._activeImage?0:1);if(this._activeImage!==null){this._ui.images[this._activeImage].removeClass("active")}this._activeImage=i;var a=this._active;this._ui.imageContainer.addClass("loading");this._ui.images[i].off("load").prop("src",false).on("load",$.proxy(function(){this._imageOnLoad(a,i)},this));this._renderImage(i,b,g);var f=this._ui.header.find("> div > a").prop("href",b.user.link).prop("title",b.user.username);f.children("img").prop("src",b.user.avatarURL);var h=WCF.String.escapeHTML(b.image.title);if(b.image.link){h='<a href="'+b.image.link+'">'+b.image.title+"</a>"}this._ui.header.find("> div > h1").html(h);var d=(b.series&&b.series.title?WCF.String.escapeHTML(b.series.title):"");if(b.series.link){d='<a href="'+b.series.link+'">'+d+"</a>"}this._ui.header.find("> div > h2").html(d);this._ui.header.find("> div > h3").text(WCF.Language.get("wcf.imageViewer.seriesIndex").replace(/{x}/,b.listItem.data("index")+1).replace(/{y}/,this._items));this._ui.slideshow.full.data("link",(b.image.fullURL?b.image.fullURL:b.image.url));this.moveToImage(b.listItem.data("index"));this._toggleButtons();return true},_imageOnLoad:function(b,a){if(b!=this._active){return}this._ui.imageContainer.removeClass("loading");this._ui.images[a].addClass("active");this.startSlideshow()},_renderImage:function(c,g,e){if(!g){c=this._activeImage;g=this._images[this._active];e={height:$(window).height()-(this._container.hasClass("maximized")?0:200),width:this._ui.imageContainer.innerWidth()}}e.height-=22;e.width-=20;this._ui.images[c].prop("src",g.image.url);var d=g.image.height;var b=g.image.width;var a=0;if(d>e.height){a=e.height/d;d=e.height;b=Math.floor(b*a)}if(b>e.width){a=e.width/b;b=e.width;d=Math.floor(d*a)}var f=Math.floor((e.width-b)/2);this._ui.images[c].css({height:d+"px",left:(f+10)+"px",marginTop:(Math.round(d/2)*-1)+"px",width:b+"px"})},_initUI:function(){if(this._didInit){return false}this._didInit=true;this._container=$('<div class="wcfImageViewer" />').appendTo(document.body);var c=$('<div><img class="active" /><img /></div>').appendTo(this._container);var g=$('<footer><span class="wcfImageViewerButtonPrevious icon icon-double-angle-left" /><div><ul /></div><span class="wcfImageViewerButtonNext icon icon-double-angle-right" /></footer>').appendTo(this._container);var e=$("<ul />").appendTo(c);var d=$('<li class="wcfImageViewerSlideshowButtonPrevious"><span class="icon icon48 icon-angle-left" /></li>').appendTo(e);var f=$('<li class="wcfImageViewerSlideshowButtonToggle pointer"><span class="icon icon48 icon-play" /></li>').appendTo(e);var b=$('<li class="wcfImageViewerSlideshowButtonNext"><span class="icon icon48 icon-angle-right" /></li>').appendTo(e);var h=$('<li class="wcfImageViewerSlideshowButtonEnlarge pointer jsTooltip" title="'+WCF.Language.get("wcf.imageViewer.button.enlarge")+'"><span class="icon icon48 icon-resize-full" /></li>').appendTo(e);var a=$('<li class="wcfImageViewerSlideshowButtonFull pointer jsTooltip" title="'+WCF.Language.get("wcf.imageViewer.button.full")+'"><span class="icon icon48 icon-external-link" /></li>').appendTo(e);this._ui={buttonNext:g.children("span.wcfImageViewerButtonNext"),buttonPrevious:g.children("span.wcfImageViewerButtonPrevious"),header:$('<header><div class="box64"><a class="framed jsTooltip"><img /></a><h1 /><h2 /><h3 /></div></header>').appendTo(this._container),imageContainer:c,images:[c.children("img:eq(0)").on("webkitTransitionEnd transitionend msTransitionEnd oTransitionEnd",function(){$(this).removeClass("animateTransformation")}),c.children("img:eq(1)").on("webkitTransitionEnd transitionend msTransitionEnd oTransitionEnd",function(){$(this).removeClass("animateTransformation")})],imageList:g.find("> div > ul"),slideshow:{container:e,enlarge:h,full:a,next:b,previous:d,toggle:f}};this._ui.buttonNext.click($.proxy(this._next,this));this._ui.buttonPrevious.click($.proxy(this._previous,this));b.click($.proxy(this._nextImage,this));d.click($.proxy(this._previousImage,this));h.click($.proxy(this._toggleView,this));f.click($.proxy(function(){if(this._slideshowEnabled){this.stopSlideshow(true)}else{this._disableSlideshow=false;this.startSlideshow()}},this));a.click(function(i){window.location=$(i.currentTarget).data("link")});$('<span class="wcfImageViewerButtonClose icon icon48 icon-remove pointer jsTooltip" title="'+WCF.Language.get("wcf.global.button.close")+'" />').appendTo(this._ui.header).click($.proxy(this.close,this));return true},_toggleView:function(){this._ui.images[this._activeImage].addClass("animateTransformation");this._container.toggleClass("maximized");this._ui.slideshow.enlarge.toggleClass("active").children("span").toggleClass("icon-resize-full").toggleClass("icon-resize-small");this._renderImage(null,undefined,null)},_next:function(c,b){if(this._ui.buttonNext.hasClass("pointer")){if(b==undefined){this.stopSlideshow(true)}var a=Math.max((this._items*this._thumbnailWidth)-this._thumbnailContainerWidth-this._thumbnailMarginRight,0);this._thumbnailOffset=Math.min(this._thumbnailOffset+(this._thumbnailWidth*(b?b:this.options.shiftBy)),a);this._ui.imageList.css("marginLeft",(this._thumbnailOffset*-1))}this._preload();this._toggleButtons()},_previous:function(b,a){if(this._ui.buttonPrevious.hasClass("pointer")){if(a==undefined){this.stopSlideshow(true)}this._thumbnailOffset=Math.max(this._thumbnailOffset-(this._thumbnailWidth*(a?a:this.options.shiftBy)),0);this._ui.imageList.css("marginLeft",(this._thumbnailOffset*-1))}this._toggleButtons()},_nextImage:function(a){if(this._ui.slideshow.next.hasClass("pointer")){this._disableSlideshow=true;this.stopSlideshow(true);this.showImage(this._active+1)}},_previousImage:function(a){if(this._ui.slideshow.previous.hasClass("pointer")){this._disableSlideshow=true;this.stopSlideshow(true);this.showImage(this._active-1)}},moveToImage:function(b){var f=(b-3)*this._thumbnailWidth;var d=f+(this._thumbnailWidth*5);var e=this._thumbnailOffset;var a=this._thumbnailOffset+this._thumbnailContainerWidth;var g=false;if(f<e||d>a){g=true}if(g){var c=0;if(f<e){while(f<e){c++;e-=this._thumbnailWidth}this._previous(null,c)}else{while(d>a){c++;a+=this._thumbnailWidth}this._next(null,c)}}},_toggleButtons:function(){if(this._thumbnailOffset>0){this._ui.buttonPrevious.addClass("pointer")}else{this._ui.buttonPrevious.removeClass("pointer")}var a=(this._images.length*this._thumbnailWidth)-this._thumbnailContainerWidth-this._thumbnailMarginRight;if(this._thumbnailOffset>=a){this._ui.buttonNext.removeClass("pointer")}else{this._ui.buttonNext.addClass("pointer")}if(this._active>0){this._ui.slideshow.previous.addClass("pointer")}else{this._ui.slideshow.previous.removeClass("pointer")}if(this._active+1<this._images.length){this._ui.slideshow.next.addClass("pointer")}else{this._ui.slideshow.next.removeClass("pointer")}},_createThumbnails:function(a){for(var f=0,e=a.length;f<e;f++){var d=a[f];var c=$('<li class="loading pointer"><img src="'+d.thumbnail.url+'" /></li>').appendTo(this._ui.imageList);c.data("index",this._images.length).data("objectID",d.objectID).click($.proxy(this._showImage,this));var b=c.children("img");if(b.get(0).complete){c.removeClass("loading")}else{b.on("load",function(){$(this).parent().removeClass("loading")})}d.listItem=c;this._images.push(d)}},_loadNextImages:function(a){this._proxy.setOption("data",{actionName:"loadNextImages",className:this.options.className,interfaceName:"wcf\\data\\IImageViewerAction",objectIDs:[this.element.data("objectID")],parameters:{maximumHeight:this._maxDimensions.height,maximumWidth:this._maxDimensions.width,offset:this._images.length,targetImageID:(a&&this.element.data("targetImageID")?this.element.data("targetImageID"):0)}});this._proxy.setOption("showLoadingOverlay",false);this._proxy.sendRequest()},_success:function(c,e,b){if(c.returnValues.items){this._items=c.returnValues.items}var a=this._initUI();this._createThumbnails(c.returnValues.images);var d=(c.returnValues.targetImageID?c.returnValues.targetImageID:0);this._render(a,d);if(!this._isOpen){this._isOpen=true;WCF.System.DisableScrolling.disable()}}});
// WCF.Label.js
WCF.Label={};WCF.Label.ACPList=Class.extend({_labelInput:null,_labelList:[],init:function(){this._labelInput=$("#label").keydown($.proxy(this._keyPressed,this)).keyup($.proxy(this._keyPressed,this)).blur($.proxy(this._keyPressed,this));if($.browser.mozilla&&$.browser.touch){this._labelInput.on("input",$.proxy(this._keyPressed,this))}$("#labelList").find('input[type="radio"]').each($.proxy(function(b,a){var c=$(a);if(c.prop("value")!=="custom"){this._labelList.push($(c.next("span")))}},this))},_keyPressed:function(){var a=this._labelInput.prop("value");if(a===""){a=WCF.Language.get("wcf.acp.label.defaultValue")}for(var c=0,b=this._labelList.length;c<b;c++){this._labelList[c].text(a)}}});WCF.Label.ACPList.Connect=Class.extend({init:function(){var a=$("#connect .structuredList li");if(!a.length){return}a.each($.proxy(function(b,c){$(c).find('input[type="checkbox"]').click($.proxy(this._click,this))},this))},_click:function(c){var a=$(c.currentTarget);if(a.is(":checked")){a=a.parents("li");var b=a.data("depth");while(true){a=a.next();if(!a.length){return true}if(a.data("depth")<=b){return true}a.find('input[type="checkbox"]').prop("checked","checked")}}}});WCF.Label.Chooser=Class.extend({_container:null,_groups:{},_showWithoutSelection:false,init:function(f,b,e,h){this._container=null;this._groups={};this._showWithoutSelection=(h===true);this._initContainers(b);if($.getLength(f)){for(var a in f){var d=this._groups[a];if(d){WCF.Dropdown.getDropdownMenu(d.wcfIdentify()).find("> ul > li:not(.dropdownDivider)").each($.proxy(function(k,j){var i=$(j);var l=i.data("labelID")||0;if(l&&f[a]==l){this._selectLabel(i,true)}},this))}}}for(var c in this._containers){var g=this._containers[c];if(g.data("labelID")===undefined){g.data("labelID",0)}}this._container=$(b);if(e){$(e).click($.proxy(this._submit,this))}else{if(this._container.is("form")){this._container.submit($.proxy(this._submit,this))}}},_initContainers:function(a){$(a).find(".labelChooser").each($.proxy(function(d,i){var f=$(i);var b=f.data("groupID");if(!this._groups[b]){var e=f.wcfIdentify();var c=WCF.Dropdown.getDropdownMenu(e);if(c===null){WCF.Dropdown.initDropdown(f.find(".dropdownToggle"));c=WCF.Dropdown.getDropdownMenu(e)}var h=c;if(c.getTagName()=="div"&&c.children(".scrollableDropdownMenu").length){h=$("<ul />").appendTo(c);c=c.children(".scrollableDropdownMenu")}this._groups[b]=f;c.children("li").data("groupID",b).click($.proxy(this._click,this));if(!f.data("forceSelection")||this._showWithoutSelection){$('<li class="dropdownDivider" />').appendTo(h)}if(this._showWithoutSelection){$('<li data-label-id="-1"><span><span class="badge label">'+WCF.Language.get("wcf.label.withoutSelection")+"</span></span></li>").data("groupID",b).appendTo(h).click($.proxy(this._click,this))}if(!f.data("forceSelection")){var g=$('<li data-label-id="0"><span><span class="badge label">'+WCF.Language.get("wcf.label.none")+"</span></span></li>").data("groupID",b).appendTo(h);g.click($.proxy(this._click,this))}}},this))},_click:function(a){this._selectLabel($(a.currentTarget),false)},_selectLabel:function(a,c){var b=this._groups[a.data("groupID")];if(c&&b.data("labelID")!==undefined){return}if(a.data("labelID")){b.data("labelID",a.data("labelID"))}else{b.data("labelID",0)}a=a.find("span > span");b.find(".dropdownToggle > span").removeClass().addClass(a.attr("class")).text(a.text())},_submit:function(){var b=this._container.find(".formSubmit");b.find('input[type="hidden"]').each(function(e,d){var f=$(d);if(f.attr("name").indexOf("labelIDs[")===0){f.remove()}});for(var a in this._groups){var c=this._groups[a];if(c.data("labelID")){$('<input type="hidden" name="labelIDs['+a+']" value="'+c.data("labelID")+'" />').appendTo(b)}}}});