%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/ceaa/wp-content/plugins/buddypress/bp-core/js/
Upload File :
Create Path :
Current File : /var/www/html/ceaa/wp-content/plugins/buddypress/bp-core/js/avatar.min.js

window.bp=window.bp||{},function(e,t){"undefined"!=typeof BP_Uploader&&(bp.Models=bp.Models||{},bp.Collections=bp.Collections||{},bp.Views=bp.Views||{},bp.Avatar={start:function(){var e=this;this.removeLegacyUI(),this.views=new Backbone.Collection,this.jcropapi={},this.warning=null,this.setupNav(),this.avatars=bp.Uploader.filesUploaded,this.Attachment=new Backbone.Model,bp.Uploader.filesQueue.on("reset",this.cropView,this),t("body.wp-admin").on("tb_unload","#TB_window",function(){e.resetViews()}),t("body.wp-admin").on("click",".bp-xprofile-avatar-user-edit",function(){e.resetViews()})},removeLegacyUI:function(){t("#avatar-upload-form").length?(t("#avatar-upload").remove(),t("#avatar-upload-form p").remove()):t("#group-settings-form").length?(t("#group-settings-form p").each(function(e){0!==e&&t(this).remove()}),t("#delete-group-avatar-button").length&&t("#delete-group-avatar-button").remove()):t("#group-create-body").length?(t(".main-column p #file").remove(),t(".main-column p #upload").remove()):t("#bp_xprofile_user_admin_avatar a.bp-xprofile-avatar-user-admin").length&&t("#bp_xprofile_user_admin_avatar a.bp-xprofile-avatar-user-admin").remove()},setView:function(e){switch(_.isUndefined(this.views.models)||_.each(this.views.models,function(e){e.get("view").remove()},this),this.views.reset(),_.isUndefined(this.avatars)||this.avatars.reset(),_.isEmpty(this.jcropapi)||(this.jcropapi.destroy(),this.jcropapi={}),e){case"upload":this.uploaderView();break;case"delete":this.deleteView()}},resetViews:function(){this.nav.trigger("bp-avatar-view:changed","upload"),_.each(this.navItems.models,function(e){"upload"===e.id?e.set({active:1}):e.set({active:0})})},setupNav:function(){var e,t,a=this;this.navItems=new Backbone.Collection,_.each(BP_Uploader.settings.nav,function(i,s){_.isObject(i)&&(t=0,0===s&&(e=i.id,t=1),a.navItems.add({id:i.id,name:i.caption,href:"#",active:t,hide:_.isUndefined(i.hide)?0:i.hide}))}),this.nav=new bp.Views.Nav({collection:this.navItems}),this.nav.inject(".bp-avatar-nav"),this.setView(e),this.nav.on("bp-avatar-view:changed",_.bind(this.setView,this))},uploaderView:function(){bp.Uploader.filesQueue.on("add",this.uploadProgress,this);var e=new bp.Views.Uploader;this.views.add({id:"upload",view:e}),e.inject(".bp-avatar")},uploadProgress:function(){var e=new bp.Views.uploaderStatus({collection:bp.Uploader.filesQueue});_.isUndefined(this.views.get("status"))?this.views.add({id:"status",view:e}):this.views.set({id:"status",view:e}),e.inject(".bp-avatar-status")},cropView:function(){var e;if(!_.isEmpty(this.avatars.models)){_.isUndefined(this.views.get("status"))||((e=this.views.get("status")).get("view").remove(),this.views.remove({id:"status",view:e}));var t=new bp.Views.Avatars({collection:this.avatars});this.views.add({id:"crop",view:t}),t.inject(".bp-avatar")}},setAvatar:function(e){var a,i=this;_.isUndefined(this.views.get("crop"))||(_.isEmpty(this.jcropapi)||(this.jcropapi.destroy(),this.jcropapi={}),(a=this.views.get("crop")).get("view").remove(),this.views.remove({id:"crop",view:a})),bp.ajax.post("bp_avatar_set",{json:!0,original_file:e.get("url"),crop_w:e.get("w"),crop_h:e.get("h"),crop_x:e.get("x"),crop_y:e.get("y"),item_id:e.get("item_id"),object:e.get("object"),type:_.isUndefined(e.get("type"))?"crop":e.get("type"),nonce:e.get("nonces").set}).done(function(a){var s=new bp.Views.AvatarStatus({value:BP_Uploader.strings.feedback_messages[a.feedback_code],type:"success"});i.views.add({id:"status",view:s}),s.inject(".bp-avatar-status"),t("."+e.get("object")+"-"+a.item_id+"-avatar").each(function(){t(this).prop("src",a.avatar)}),bp.Avatar.navItems.get("delete").set({hide:0}),i.Attachment.set(_.extend(_.pick(e.attributes,["object","item_id"]),{url:a.avatar,action:"uploaded"}))}).fail(function(e){var t=BP_Uploader.strings.default_error;_.isUndefined(e)||(t=BP_Uploader.strings.feedback_messages[e.feedback_code]);var a=new bp.Views.AvatarStatus({value:t,type:"error"});i.views.add({id:"status",view:a}),a.inject(".bp-avatar-status")})},deleteView:function(){var e=new Backbone.Model(_.pick(BP_Uploader.settings.defaults.multipart_params.bp_params,"object","item_id","nonces")),t=new bp.Views.DeleteAvatar({model:e});this.views.add({id:"delete",view:t}),t.inject(".bp-avatar")},deleteAvatar:function(e){var a,i=this;_.isUndefined(this.views.get("delete"))||((a=this.views.get("delete")).get("view").remove(),this.views.remove({id:"delete",view:a})),bp.ajax.post("bp_avatar_delete",{json:!0,item_id:e.get("item_id"),object:e.get("object"),nonce:e.get("nonces").remove}).done(function(a){var s=new bp.Views.AvatarStatus({value:BP_Uploader.strings.feedback_messages[a.feedback_code],type:"success"});i.views.add({id:"status",view:s}),s.inject(".bp-avatar-status"),t("."+e.get("object")+"-"+a.item_id+"-avatar").each(function(){t(this).prop("src",a.avatar)}),bp.Avatar.navItems.get("delete").set({active:0,hide:1}),i.Attachment.set(_.extend(_.pick(e.attributes,["object","item_id"]),{url:a.avatar,action:"deleted"}))}).fail(function(e){var t=BP_Uploader.strings.default_error;_.isUndefined(e)||(t=BP_Uploader.strings.feedback_messages[e.feedback_code]);var a=new bp.Views.AvatarStatus({value:t,type:"error"});i.views.add({id:"status",view:a}),a.inject(".bp-avatar-status")})},removeWarning:function(){_.isNull(this.warning)||this.warning.remove()},displayWarning:function(e){this.removeWarning(),this.warning=new bp.Views.uploaderWarning({value:e}),this.warning.inject(".bp-avatar-status")}},bp.Views.Nav=bp.View.extend({tagName:"ul",className:"avatar-nav-items",events:{"click .bp-avatar-nav-item":"toggleView"},initialize:function(){1!==_.findWhere(this.collection.models,{id:"delete"}).get("hide")&&bp.Avatar.displayWarning(BP_Uploader.strings.has_avatar_warning),_.each(this.collection.models,this.addNavItem,this),this.collection.on("change:hide",this.showHideNavItem,this)},addNavItem:function(e){1!==e.get("hide")&&this.views.add(new bp.Views.NavItem({model:e}))},showHideNavItem:function(e){var t=null;_.each(this.views._views[""],function(a){1===a.model.get("hide")&&a.remove(),e.get("id")===a.model.get("id")&&(t=!0)}),_.isBoolean(t)||this.addNavItem(e)},toggleView:function(e){e.preventDefault(),bp.Avatar.removeWarning();var a=t(e.target).data("nav");_.each(this.collection.models,function(e){e.id===a?(e.set({active:1}),this.trigger("bp-avatar-view:changed",e.id)):e.set({active:0})},this)}}),bp.Views.NavItem=bp.View.extend({tagName:"li",className:"avatar-nav-item",template:bp.template("bp-avatar-nav"),initialize:function(){1===this.model.get("active")&&(this.el.className+=" current"),this.el.id+="bp-avatar-"+this.model.get("id"),this.model.on("change:active",this.setCurrentNav,this)},setCurrentNav:function(e){1===e.get("active")?this.$el.addClass("current"):this.$el.removeClass("current")}}),bp.Views.Avatars=bp.View.extend({className:"items",initialize:function(){_.each(this.collection.models,this.addItemView,this)},addItemView:function(e){var t={full_h:150,full_w:150};_.isUndefined(BP_Uploader.settings.crop.full_h)||_.isUndefined(BP_Uploader.settings.crop.full_w)||(t.full_h=BP_Uploader.settings.crop.full_h,t.full_w=BP_Uploader.settings.crop.full_w),e.set(_.extend(_.pick(BP_Uploader.settings.defaults.multipart_params.bp_params,"object","item_id","nonces"),t)),this.views.add(new bp.Views.Avatar({model:e}))}}),bp.Views.Avatar=bp.View.extend({className:"item",template:bp.template("bp-avatar-item"),events:{"click .avatar-crop-submit":"cropAvatar"},initialize:function(){_.defaults(this.options,{full_h:BP_Uploader.settings.crop.full_h,full_w:BP_Uploader.settings.crop.full_w,aspectRatio:1}),!1!==this.model.get("feedback")&&bp.Avatar.displayWarning(this.model.get("feedback")),this.on("ready",this.initCropper)},initCropper:function(){var e,a,i,s,n,o,r=this,d=this.$el.find("#avatar-to-crop img"),l=this.$el.width(),p={};_.isUndefined(this.options.full_h)||_.isUndefined(this.options.full_w)||(this.options.aspectRatio=this.options.full_w/this.options.full_h),p.w=this.model.get("width"),p.h=this.model.get("height"),this.options.full_w+p.w+20<l&&(t("#avatar-to-crop").addClass("adjust"),this.$el.find(".avatar-crop-management").addClass("adjust")),p.h<=p.w?(e=Math.round(p.h/4),a=(n=o=Math.round(p.h/2))+e,s=o+(i=(p.w-o)/2)):(i=Math.round(p.w/4),n=o=Math.round(p.w/2),s=o+i,a=n+(e=(p.h-n)/2)),d.Jcrop({onChange:_.bind(r.showPreview,r),onSelect:_.bind(r.showPreview,r),aspectRatio:r.options.aspectRatio,setSelect:[i,e,s,a]},function(){bp.Avatar.jcropapi=this})},cropAvatar:function(e){e.preventDefault(),bp.Avatar.setAvatar(this.model)},showPreview:function(e){if(e.w&&e.h&&parseInt(e.w,10)>0){var a=this.options.full_w,i=this.options.full_h,s=a/e.w,n=i/e.h;this.model.set({x:e.x,y:e.y,w:e.w,h:e.h}),t("#avatar-crop-preview").css({maxWidth:"none",width:Math.round(s*this.model.get("width"))+"px",height:Math.round(n*this.model.get("height"))+"px",marginLeft:"-"+Math.round(s*this.model.get("x"))+"px",marginTop:"-"+Math.round(n*this.model.get("y"))+"px"})}}}),bp.Views.AvatarStatus=bp.View.extend({tagName:"p",className:"updated",id:"bp-avatar-feedback",initialize:function(){this.el.className+=" "+this.options.type,this.value=this.options.value},render:function(){return this.$el.html(this.value),this}}),bp.Views.DeleteAvatar=bp.View.extend({tagName:"div",id:"bp-delete-avatar-container",template:bp.template("bp-avatar-delete"),events:{"click #bp-delete-avatar":"deleteAvatar"},deleteAvatar:function(e){e.preventDefault(),bp.Avatar.deleteAvatar(this.model)}}),bp.Avatar.start())}(bp,jQuery);

Zerion Mini Shell 1.0