%PDF- %PDF-
| Direktori : /data/old/home/stash/stash/atlassian-stash/static/feature/comments/ |
| Current File : //data/old/home/stash/stash/atlassian-stash/static/feature/comments/comment-context-min.js |
define("feature/comments/comment-context",["backbone","jquery","underscore","util/client-storage","util/events","feature/comments/comment-container"],function(F,E,B,A,C,D){return F.View.extend({initialize:function(){this._containers={};this.checkForNewContainers();var G=this;C.on("stash.feature.comments.commentAdded",this._commentAddedHandler=function(I,J){if(G.$el.find(J).length&&G.$el.find(".comment").length===1){C.trigger("stash.feature.comments.firstCommentAdded",null,G.$el)}});var H=this.getDrafts()||[];this.unrestoredDrafts=this.drafts=B.isArray(H)?H:[H];this.restoreDrafts()},includesContainer:function(G){return B.has(this._containers,G)},registerContainer:function(I,H){var G=H.getId();if(!this.includesContainer(G)){this._registerContainer(G,I,H)}},_registerContainer:function(H,I,G){this._containers[H]=new D({name:H,context:this,el:I,anchor:G});return this._containers[H]},checkForNewContainers:function(){var G=this;B.forEach(this.findContainerElements(),function(H){G.registerContainer(H,G.getAnchor(H))})},findContainerElements:function(){return this.$(".comment-container")},getAnchor:function(){return this.options.anchor},clarifyAmbiguousDraftProps:function(G){return B.omit(G,"text")},deleteDraftComment:function(G,I){I=B.isBoolean(I)?I:true;var H=B.isEqual.bind(B,this.clarifyAmbiguousDraftProps(G));this.drafts=B.reject(this.drafts,B.compose(H,this.clarifyAmbiguousDraftProps.bind(this)));if(I){this.saveDraftComments()}},getDrafts:function(){return A.getSessionItem(this.getDraftsKey())},getDraftsKey:function(){return A.buildKey(["draft-comment",this.options.anchor.getId()],"user")},restoreDrafts:E.noop,saveDraftComment:function(G){this.deleteDraftComment(G,false);G.text&&this.drafts.push(G);this.saveDraftComments()},saveDraftComments:function(){A.setSessionItem(this.getDraftsKey(),this.drafts)},destroy:function(G,H){if(G){G.remove();delete this._containers[G.options.name];if(!this.$el.has(".comment").length&&!H){C.trigger("stash.feature.comments.lastCommentDeleted",null,this.$el)}}else{H=true;B.invoke(this._containers,"destroy",H);this._containers=null;if(this._commentAddedHandler){C.off("stash.feature.comments.commentAdded",this._commentAddedHandler);delete this._commentAddedHandler}}}})});