//-- copyright
// Copyright (C)2013-2014 the OpenProject Foundation (OPF)
// Copyright (C)2011 Stephan Eckardt, Tim Felgentreff, Marnen Laibow-Koser, Sandro Munda
// Copyright (C)2010-2011 friflaj
// Copyright (C)2010 Maxime Guilbot, Andrew Vit, Joakim Kolsjö, ibussieres, Daniel Passos, Jason Vasquez, jpic, Emiliano Heyns
// Copyright (C)2009-2010 Mark Maglana
// Copyright (C)2009 Joe Heck, Nate Lowrie
// The copyright follows:
// Copyright (C) 2010-2011 - Emiliano Heyns, Mark Maglana, friflaj
// Copyright (C) 2011 - Jens Ulferts, Gregor Schmidt - Finn GmbH - Berlin, Germany
// See doc/COPYRIGHT.rdoc for more details.
RB.Story=function(e){return RB.Object.create(RB.WorkPackage,RB.EditableInplace,{initialize:function(t){this.$=e(t),this.el=t,this.$.data("this",this),this.$.find(".editable").live("mouseup",this.handleClick)},beforeSave:function(){this.refreshStory()},afterCreate:function(){this.refreshStory()},afterUpdate:function(){this.refreshStory()},refreshed:function(){this.refreshStory()},editDialogTitle:function(){return"Story #"+this.getID()},editorDisplayed:function(){},getPoints:function(){var e=parseInt(this.$.find(".story_points").first().text(),10);return isNaN(e)?0:e},getType:function(){return"Story"},markIfClosed:function(){},newDialogTitle:function(){return"New Story"},refreshStory:function(){this.recalcVelocity()},recalcVelocity:function(){this.$.parents(".backlog").first().data("this").refresh()},saveDirectives:function(){var e,t,i,n;return t=this.$.prev(),i=this.$.parents(".backlog").data("this").isSprintBacklog()?this.$.parents(".backlog").data("this").getSprint().data("this").getID():"",n="prev="+(1===t.length?t.data("this").getID():"")+"&fixed_version_id="+i,this.$.find(".editor").length>0&&(n+="&"+this.$.find(".editor").serialize()),this.isNew()?e=RB.urlFor("create_story",{sprint_id:i}):(e=RB.urlFor("update_story",{id:this.getID(),sprint_id:i}),n+="&_method=put"),{url:e,data:n}},beforeSaveDragResult:function(){}})}(jQuery);