');d.css({width:a.displayWidth,height:a.displayHeight,top:a.displayTop,left:a.displayLeft});var e=joms.jQuery('
');return e.css({width:a.displayWidth-4,height:a.displayHeight-4,border:"2px solid #222"}).appendTo(d),null!=a.id&&joms.gallery.updatePlaylistTag(a),d},updatePlaylistTag:function(a){var b,c=jsPlaylist.photos[joms.gallery.getPlaylistIndex(a.photoId)].tags;joms.jQuery.each(c,function(){this.id==a.id&&(b=this)}),void 0==b&&(b=c[c.push(joms.gallery.newPhotoTag())-1]),joms.jQuery.extend(b,a)},displayPhotoTags:function(a){joms.gallery.clearPhotoTag(),joms.gallery.clearPhotoTextTag();var b=joms.jQuery("#cGallery .photoImage"),c=joms.jQuery("#cGallery .photoTags");c.css({width:b.width(),height:b.height(),top:b.data("properties").top,left:b.data("properties").left}),joms.gallery.createPhotoTag(a),joms.jQuery(".photoTextTags").empty(),joms.gallery.createPhotoTextTag(a)},addPhotoTag:function(a){var b=joms.jQuery("#cGallery .photoTags"),c=b.data("newPhotoTag");a>0&&jax.call("community","photos,ajaxAddPhotoTag",c.photoId,a,c.top,c.left,c.width,c.height)},removePhotoTag:function(a){jax.call("community","photos,ajaxRemovePhotoTag",a.photoId,a.userId),joms.gallery.clearPhotoTag(a),joms.gallery.clearPhotoTextTag(a);var b=jsPlaylist.photos[joms.gallery.getPlaylistIndex(a.photoId)].tags;joms.jQuery.each(b,function(c){this.id==a.id&&b.splice(c,1)})},clearPhotoTag:function(a){void 0==a?joms.jQuery("#cGallery .photoTag").remove():joms.jQuery("#photoTag-"+a.id).remove()},showPhotoTag:function(a,b){joms.jQuery("#photoTag-"+a).addClass("show"+b)},hidePhotoTag:function(a){joms.jQuery("#photoTag-"+a).removeClass("show showLabel showForce")},createPhotoTextTag:function(tags){var photoTextTags=joms.jQuery(".photoTextTags");0==tags.length&&photoTextTags.html(""),"string"==typeof tags&&(tags=eval("("+tags+")"));var singleTag=!1;joms.jQuery.isArray(tags)||(tags=[tags],singleTag=!0);var newPhotoTextTags=new Array,a=1;return joms.jQuery.each(tags,function(b,c){if(void 0!=c.id){var d=joms.jQuery('
');d.data("tag",c).attr("id","photoTextTag-"+c.id).hover(function(){joms.gallery.showPhotoTag(c.id,"Force")},function(){joms.gallery.hidePhotoTag(c.id)}).appendTo(photoTextTags);var e=joms.jQuery("
");if(e.attr("href",c.profileUrl).html(c.displayName).prependTo(d),c.canRemove){var f=joms.jQuery('');f.appendTo(d);var g=joms.jQuery('');g.addClass("_remove").html(jsPlaylist.language.COM_COMMUNITY_REMOVE).click(function(){joms.gallery.removePhotoTag(c)}).appendTo(f),f.before(" ").prepend("(").append(")")}a++,newPhotoTextTags.push(d)}}),joms.gallery.commifyTextTags(),newPhotoTextTags},commifyTextTags:function(){joms.jQuery(".photoTextTags .comma").remove(),photoTextTag=joms.jQuery(".photoTextTags .photoTextTag"),photoTextTag.each(function(a){if(0!=a){var b=joms.jQuery('
');b.html(", ").prependTo(this)}})},clearPhotoTextTag:function(a){void 0==a?joms.jQuery("#cGallery .photoTextTag").remove():(joms.jQuery("#photoTextTag-"+a.id).remove(),joms.gallery.commifyTextTags())},startTagMode:function(){joms.jQuery(".photoTags").unbindSwipe(),joms.jQuery("#cGallery .photoTagInstructions").slideDown("fast"),joms.jQuery("#startTagMode").hide();var a=joms.jQuery("#cGallery .photoViewport");a.addClass("tagMode");var b=joms.jQuery("#cGallery .photoImage"),c=joms.jQuery("#cGallery .photoTags"),d=joms.jQuery("#cGallery .photoTagActions"),e=joms.jQuery("#cGallery .photoTagAction._select"),f=b.width()/2-jsPlaylist.config.defaultTagWidth/2,g=b.height()/2-jsPlaylist.config.defaultTagHeight/2,h=f+jsPlaylist.config.defaultTagWidth,i=g+jsPlaylist.config.defaultTagHeight,j=function(a){c.data("newPhotoTag",joms.gallery.newPhotoTag({photoId:joms.gallery.currentPhoto().id,top:(a.y1+a.height/2)/b.height(),left:(a.x1+a.width/2)/b.width(),width:a.width/b.width(),height:a.height/b.height()})),d.css({top:a.y1-3,left:a.x1-3,width:a.width,height:a.height}).show(),e.css({bottom:-1*e.outerHeight(!0),left:(a.width-e.outerWidth(!0))/2}),joms.jQuery("div.autocomplete-w1").parent().css("top","-1000px").show()};c.imgAreaSelect({parent:c,x1:f,y1:g,x2:h,y2:i,minWidth:50,minHeight:50,zIndex:6630,show:!0,handles:!0,movable:!0,resizable:!1,persistent:!0,onInit:function(a,b){j(b)},onSelectStart:function(){d.hide()},onSelectChange:function(a,b){d.hide();var e=c.imgAreaSelect({instance:!0});b.x1-75<0&&(b.x1=0),b.y1-75<0&&(b.y1=0),b.x1+150>c.width()&&(b.x1=c.width()-150),b.y1+150>c.height()&&(b.y1=c.height()-150),e.setSelection(b.x1,b.y1,b.x1+150,b.y1+150,!0),e.update()},onSelectEnd:function(a,b){j(b),c.css({cursor:"pointer"}).imgAreaSelect({persistent:!0})}})},stopTagMode:function(){var a=joms.jQuery("#cGallery .photoViewport");a.removeClass("tagMode");var b=joms.jQuery("#cGallery .photoTags");b.css({cursor:"default"}).imgAreaSelect({remove:!0});var c=joms.jQuery("#cGallery .photoTagActions");c.hide(),joms.jQuery("#cGallery .photoTagInstructions").hide(),joms.jQuery("#startTagMode").show(),joms.jQuery("#photoTagQuery").val(""),joms.gallery.swipeablePhoto(),cWindowHide()},selectNewPhotoTagFriend:function(){joms.jQuery("#cGallery .photoTagFriend");cWindowShow(function(){joms.gallery.showPhotoTagFriends()},jsPlaylist.language.COM_COMMUNITY_SELECT_PERSON,300,300),cWindowActions('
")},confirmPhotoTagFriend:function(){joms.jQuery("#cWindow .js-system-message").hide();var a=joms.jQuery("#cWindow .invitation-item-invited input:checked");a.length>0?joms.gallery.addPhotoTag(a.val()):(joms.jQuery("#cWindow .js-system-message").show(),joms.jQuery("#cWindow .js-system-message").fadeOut(5e3))},showPhotoTagFriends:function(){var a=joms.jQuery("#cGallery .photoTags"),b=a.data("newPhotoTag"),c=b.photoId;joms.jQuery("#cWindowContent").empty(),joms.jQuery("#cGallery .photoTagSelectFriend").clone().appendTo("#cWindowContent"),jax.loadingFunction(),joms.friends.showForm("","photos",c,1,"joms.gallery.confirmPhotoTagFriend();"),jax.doneLoadingFunction(),setTimeout("joms.jQuery('#cWindowContent .photoTagFriendFilter').focus()",300)},filterPhotoTagFriend:function(){var a=(joms.jQuery("#cWindow .photoTagFriend"),joms.jQuery("#cWindow .photoTagFriendFilter")),b=joms.jQuery.trim(a.val()),c=joms.jQuery("#cGallery .photoTags"),d=c.data("newPhotoTag"),e=d.photoId;jax.loadingFunction(),joms.friends.loadFriend(b,"photos",e,"0","9"),jax.doneLoadingFunction()},cancelNewPhotoTag:function(){var a=joms.jQuery("#cGallery .photoTags");a.css({cursor:"crosshair"}).imgAreaSelect({hide:!0,persistent:!1});var b=joms.jQuery("#cGallery .photoTagActions");b.hide();{var a=joms.jQuery("#cGallery .photoTags");a.data("newPhotoTag",{})}joms.jQuery("#photoTagQuery").val(""),joms.jQuery("div.autocomplete-w1").parent().hide(),joms.gallery.stopTagMode(),joms.jQuery("#cGallery .photoTag").addClass("showLabel")},displayCreator:function(a){jax.call("community","photos,ajaxDisplayCreator",a)},setProfilePicture:function(){var a="jax.call('community', 'photos,ajaxLinkToProfile', '"+joms.gallery.currentPhoto().id+"');";cWindowShow(a,"",450,100)},rotatePhoto:function(a){if("none"==joms.jQuery("#startTagMode").css("display"))return!1;var b=joms.gallery.currentPhoto().id;joms.ajax.call("photos,ajaxRotatePhoto",[b,a],{success:function(a,b,c){var d=jsPlaylist.photos[joms.gallery.getPlaylistIndex(a)];d.url=b,d.thumbnail=c,joms.gallery.displayPhoto(d)}})},swipeablePhoto:function(){joms.jQuery(".photoTags").unbindSwipe().touchSwipe(function(a){clearTimeout(joms.gallery.loaderTimeout),joms.gallery.displayPhoto("left"==a?joms.gallery.nextPhoto():joms.gallery.prevPhoto()),joms.photos.photoSlider.switchPhoto()})},changeTitle:function(a){var b=joms.jQuery("div#community-wrap > h4");if(b.length>0){var c=joms.jQuery(b).html().split(" - ");joms.jQuery(b).html(c[0]+" - "+a)}}}});