diff --git a/july/static/js/app.js b/july/static/js/app.js index be2e3bb..97186fb 100644 --- a/july/static/js/app.js +++ b/july/static/js/app.js @@ -1 +1 @@ -var JULY=JULY||{};ko.bindingHandlers.pageBottom={init:function(a,b,c,d){var e=b(),f=c(),g=f.callbackThreshold||1e3,h=f.callbackInterval||500;if("function"!=typeof e)throw new Error("The value of the pageBottom binding must be a function");e=$.proxy(e,d);var i=$(document),j=$(window);setInterval(function(){i.height()-j.height()-j.scrollTop()0?ko.applyBindings(a,c[0]):console.log('Binding error: no elements found for "'+b+'"')},JULY.csrfSafeMethod=function(a){return/^(GET|HEAD|OPTIONS|TRACE)$/.test(a)},JULY.setCSRFToken=function(a){jQuery.ajaxSetup({crossDomain:!1,beforeSend:function(b,c){JULY.csrfSafeMethod(c.type)||b.setRequestHeader("X-CSRFToken",a)}})},$(document).ready(function(){var a=$("#send-abuse"),b=$("#abuse-form"),c=$("#abuse-modal"),d=$("#abuseli");a.click(function(){var e=b.find("textarea").val();return e?($.ajax({type:b.attr("method"),url:b.attr("action"),data:b.serialize()}),c.find(".modal-footer").html(""),c.find(".modal-body").html("

Thank you !

"),a.remove(),d.remove(),!1):!1})});var JULY=JULY||{};JULY.Badge=Backbone.Model.extend({url:function(){return"/api/v1/user/"+this.userId+"/badge/"+this.params()}}),JULY.BadgeView=function(a){kb.viewModel(a,{},this),this.status=this.awarded()?"Awarded ("+this.total()+")":this.count()+" / "+this.total(),this.progress=this.awarded()?"100%":Math.round(this.count()/this.total()*100)+"%",this.badge_classes=this.level()+" "+(this.awarded()?"awarded":"unawarded");var b=this;b.isVisible=ko.observable(),b.topPosition=ko.observable(),b.leftPosition=ko.observable(),this.toggleVisible=function(a){var c=$(a),d=c.position();b.topPosition(d.top+c.height()+15+"px"),b.leftPosition(d.left+"px"),b.isVisible(!b.isVisible())}},JULY.BadgesCollection=Backbone.Collection.extend({model:JULY.Badge,url:function(){return"/api/v1/user/"+this.userId+"/badges/"},initialize:function(a,b){this.userId=b.userId},parse:function(a){return a.badges}}),JULY.BadgesView=JULY.ViewModel.extend({initialize:function(a){this.badgesCollection=new JULY.BadgesCollection(null,a),this.badgesCollection.fetch(),this.badges=kb.collectionObservable(this.badgesCollection,{view_model:JULY.BadgeView})}});var JULY=JULY||{};JULY.Project=Backbone.Model.extend({url:"/api/v1/project/"}),JULY.BoardCollection=Backbone.Collection.extend({model:JULY.Project,url:function(){return"/api/v1/largeboard/?"+this.params()},initialize:function(a,b){this.limit=b.limit||20,this.offset=b.offset||0,this.total=0,this.hasMore=!1},params:function(){var a={limit:this.limit,offset:this.offset};return jQuery.param(a)},parse:function(a){return this.total=a.meta.total_count,this.offset=a.meta.offset+this.limit,this.hasMore=this.total>this.models.length,a.objects}}),JULY.LargeBoardCollection=JULY.BoardCollection.extend({url:function(){return"/api/v1/largeboard/?"+this.params()}}),JULY.MediumBoardCollection=JULY.BoardCollection.extend({url:function(){return"/api/v1/mediumboard/?"+this.params()}}),JULY.SmallBoardCollection=JULY.BoardCollection.extend({url:function(){return"/api/v1/smallboard/?"+this.params()}}),JULY.BoardView=function(a){this.points=kb.observable(a,"points"),this.project=a.get("project"),this.url="/projects/"+this.project.slug+"/"},JULY.BoardsView=JULY.ViewModel.extend({initialize:function(a){this.l=new JULY.LargeBoardCollection(null,a),this.m=new JULY.MediumBoardCollection(null,a),this.s=new JULY.SmallBoardCollection(null,a),this.l.fetch({add:!0}),this.m.fetch({add:!0}),this.s.fetch({add:!0}),this.largeBoards=kb.collectionObservable(this.l,{view_model:JULY.BoardView}),this.mediumBoards=kb.collectionObservable(this.m,{view_model:JULY.BoardView}),this.smallBoards=kb.collectionObservable(this.s,{view_model:JULY.BoardView})},largeHasMore:function(){return this.largeBoards.collection().hasMore},mediumHasMore:function(){return this.mediumBoards.collection().hasMore},smallHasMore:function(){return this.smallBoards.collection().hasMore},scrolled:function(a,b){var c=b.target;c.scrollTop>c.scrollHeight-c.offsetHeight-200&&this.fetch()},fetch:function(){this.largeHasMore()&&this.largeBoards.collection().fetch({remove:!1}),this.mediumHasMore()&&this.mediumBoards.collection().fetch({remove:!1}),this.smallHasMore()&&this.smallBoards.collection().fetch({remove:!1})}}),function(){var a=function(a,b){this._chartId=a,this._dataUrl=b,this._chartElement=$("#"+a),this._width=this._chartElement.width(),this._height=this._chartElement.height(),this._pad={top:0,left:0,right:0,bottom:0,barX:1,barY:1},this._options={},this._width&&this._height||(this._width=600,this._height=400),this._chart=d3.select("#"+this._chartId).append("svg"),this._chart.attr("class","chart").attr("width",this._width).attr("height",this._height)};a.prototype.load=function(a){return this._stats=a,this},a.prototype.set=function(a,b){var c=this["_set_"+a];return c?c.apply(this,[b]):console.log("No set for option '"+a+"'."),this},a.prototype._set_xLabel=function(a){this._options.xLabel=a,this._pad.bottom+=24},a.prototype._set_title=function(){},a.prototype._set_yLabel=function(a){this._pad.top+=20,this._options.yLabel=a},a.prototype._getChartDimensions=function(){for(var a=this._stats.length,b=this._width-(this._pad.left+this._pad.right)-a*this._pad.barX,c=this._height-(this._pad.bottom+this._pad.top),d=b/a,e=1,f=0;a>f;f++)this._stats[f]>e&&(e=this._stats[f]);return{bars:a,barWidth:d,maxValue:e,width:b,height:c,top:this._pad.top,bottom:this._height-this._pad.bottom,left:this._pad.left,right:this._width-this._pad.right}},a.prototype.render=function(){var a=this._getChartDimensions(),c=this._chart.selectAll("rect"),d=c.data(this._stats),e=d.enter(),f=this;this._addFilters(),e.append("rect").attr("x",function(b,c){return f._pad.left+c*(a.barWidth+1)}).attr("y",function(c){return a.top+(a.height-b(c,a.maxValue,a.height))}).attr("width",a.barWidth).attr("height",function(c){return b(c,a.maxValue,a.height)});for(var g in this._options)if(this._options.hasOwnProperty(g)){var h=this["_render_"+g];h?h.apply(this,[e,this._options[g]]):console.log("No rendering option for '"+g+"'.")}return this},a.prototype._addFilters=function(){var a=this._chart.append("filter").attr("id","dropshadow");a.append("feGaussianBlur").attr("in","SourceAlpha").attr("stdDeviation",.1),a.append("feOffset").attr("dx",0).attr("dy",1).attr("result","offsetblur");var b=a.append("feMerge");b.append("feMergeNode"),b.append("feMergeNode").attr("in","SourceGraphic")},a.prototype._render_xLabel=function(a,b){var d=this._getChartDimensions(),e=this;a.append("text").attr("class","xLabel").attr("x",function(a,b){return e._pad.left+(d.barWidth+e._pad.barX)*b+d.barWidth/2}).attr("y",function(){return e._pad.top+d.height+e._pad.bottom-3}).attr("width",d.barWidth).attr("text-anchor","middle").text(function(a,d){return c(b,a,d)}),this._chart.append("line").attr("class","rule").attr("y1",d.height+this._pad.top+2).attr("y2",d.height+this._pad.top+2).attr("x1",this._pad.left-2).attr("x2",this._pad.left+d.width+d.bars*this._pad.barX)},a.prototype._render_yLabel=function(a,d){var e=this._getChartDimensions(),f=this;a.append("text").attr("class","yLabel").attr("text-anchor","middle").attr("width",e.barWidth).attr("x",function(a,b){return f._pad.left+(e.barWidth+f._pad.barX)*b+e.barWidth/2}).attr("y",function(a){return console.log(e),f._pad.top+(e.height-b(a,e.maxValue,e.height))-5}).text(function(a,b){return c(d,a,b)})};var b=function(a,b,c){var d=a/b*c;return d},c=function(a,b,c){return $.isFunction(a)?a(b,c):a};window.Charts={BarChart:a}}();var JULY=JULY||{};JULY.Commit=Backbone.Model.extend({url:"/api/v1/commit/"}),JULY.CommitCalendarDay=Backbone.Model.extend({idAttribute:"timestamp",date:function(){var a=new Date(this.get("timestamp"));return d3.time.day(a)}}),JULY.CommitCalendar=Backbone.Collection.extend({model:JULY.CommitCalendarDay,url:function(){return"/api/v1/commit/calendar/?"+this.params()},initialize:function(a,b){this.username=b.username||null,this.start=null,this.end=null},start_date:function(){return d3.time.day(this.start)},parse:function(a){this.start=new Date(a.start),this.end=new Date(a.end);var b=d3.time.day(this.start),c=d3.time.day(this.end),d=d3.time.day.offset(b,1),e=d3.time.day.offset(c,1),f=d3.time.days(d,e),g=d3.time.format("%Y-%m-%d"),h=_(f).map(function(a){var b={timestamp:g(a),commit_count:0};return b});return this.reset(h),a.objects},params:function(){var a={};return this.username&&(a.username=this.username),jQuery.param(a)}}),JULY.CommitCollection=Backbone.Collection.extend({model:JULY.Commit,url:function(){return"/api/v1/commit/?"+this.params()},initialize:function(a,b){this.projectId=b.projectId,this.userId=b.userId,this.languages=b.languages||[],this.limit=b.limit||20,this.offset=b.offset||0,this.total=0,this.hasMore=!1,this._pushStream=new PushStream({host:window.location.hostname,port:window.location.port,modes:"websocket|stream",urlPrefixStream:"/events/sub",urlPrefixPublisher:"/events/pub",urlPrefixWebsocket:"/events/ws"}),JULY.collection=this,this._pushStream.onmessage=function(a){console.log("-- New commit from PushStream:",a),JULY.collection.unshift(a)},this._pushStream.onstatuschange=function(a){console.log("-- PushStream state changed: "+a),a===PushStream.CLOSED&&console.log("!! ERROR: PushStream was closed.")};var c=this.projectId?"project-"+this.projectId:this.userId?"user-"+this.userId:"global";console.log("-- Subscribing to PushStream channel: "+c),this._pushStream.addChannel(c),this._pushStream.connect()},params:function(){var a={limit:this.limit,offset:this.offset};return this.projectId&&(a.project=this.projectId),this.userId&&(a.user=this.userId),this.languages&&(a.languages=_(this.languages).reduce(function(a,b,c){var d=c>0;return a.concat((d?";":"")+b)},"",this)),jQuery.param(a)},parse:function(a){return this.total=a.meta.total_count,this.offset=a.meta.offset+this.limit,this.hasMore=this.total>this.models.length,a.objects}}),JULY.CommitsView=JULY.ViewModel.extend({initialize:function(a){this.c=new JULY.CommitCollection(null,a),this.c.fetch({add:!0}),this.commits=kb.collectionObservable(this.c)},hasMore:function(){return this.commits.collection().hasMore},scrolled:function(a,b){var c=b.target;c.scrollTop>c.scrollHeight-c.offsetHeight-200&&this.fetch()},fetch:function(){this.hasMore()&&this.commits.collection().fetch({remove:!1})}}),JULY.makeCalendar=function(a,b){var c=new JULY.CommitCalendar(null,{username:b});c.fetch({async:!1,remove:!1});var d=c.map(function(a){return a.get("commit_count")}),e=12,f=d3.time.format("%w"),g=d3.time.format("%U"),h=7*e,i=6*e,j=d3.scale.linear().domain([0,Math.max.apply(null,d)]).range(["white","darkgreen"]),k=d3.select(a).attr("width",h).attr("height",i),l=k.selectAll("rect").data(c.models).enter().append("rect").attr("width",e).attr("height",e).attr("y",function(a){return e*(g(a.date())-g(c.start_date()))}).attr("x",function(a){return e*f(a.date())}).style("stroke","#BEC9AF").style("fill",function(a){return j(a.get("commit_count"))});l.append("title").text(function(a){return a.get("commit_count")+" commits on "+a.get("timestamp")})};var JULY=JULY||{};if(JULY.parse_url=function(a){return a.replace("https://api.github.com/","/api/v1/github/")},JULY.Repository=Backbone.Model.extend({initialize:function(a){this.url=JULY.parse_url(a.url),this.hooks_url=JULY.parse_url(a.hooks_url),this.hooks=new JULY.HookCollection(null,{url:this.hooks_url}),this.hooks.fetch()}}),JULY.Hook=Backbone.Model.extend({initialize:function(a){this.url=JULY.parse_url(a.url)}}),JULY.RepositoryCollection=Backbone.Collection.extend({model:JULY.Repository,url:function(){return"/api/v1/github/user/repos?"+this.params()},initialize:function(a,b){this.per_page=b.per_page||20,this.page=b.page||1,this.type=b.type||"public",this.total=0,this.hasMore=!0},params:function(){var a={per_page:this.per_page,page:this.page,type:this.type};return jQuery.param(a)},parse:function(a){return this.total+=a.length,this.page+=1,this.hasMore=a.length==this.per_page,a}}),JULY.HookCollection=Backbone.Collection.extend({model:JULY.Hook,url:function(){return this._url},initialize:function(a,b){this._url=b.url,this.per_page=b.per_page||100,this.page=b.page||1,this.total=0,this.hasMore=!1},params:function(){var a={per_page:this.per_page,page:this.page};return jQuery.param(a)},parse:function(a){var b=[];return _.each(a,function(a){var c=a.config||{};"http://www.julython.org/api/v1/github"==c.url&&b.push(a)}),this.total+=b.length,this.page+=1,this.hasMore=b.length==this.per_page,b}}),JULY.HookView=function(a){var b=this;this.last_response=a.get("last_response"),this.test_url=JULY.parse_url(a.get("test_url")),this.updated_at=ko.observable(a.get("updated_at")),this.test=function(a){JULY.setCSRFToken(a),jQuery.post(b.test_url,{action:"test"},function(){var a=new Date;b.updated_at(a.toISOString())})}},JULY.RepoView=function(a){var b=this;this.working=ko.observable(!1),this.name=kb.observable(a,"name"),this.html_url=kb.observable(a,"html_url"),this.description=kb.observable(a,"description"),this.hooks=kb.collectionObservable(a.hooks,{view_model:JULY.HookView}),this.add=function(a){b.working(!0),JULY.setCSRFToken(a);var c=b.hooks.collection().url;jQuery.post(c,{action:"add"},function(){b.hooks.collection().reset([]),b.hooks.collection().fetch(),b.working(!1)})}},JULY.RepositoryView=JULY.ViewModel.extend({initialize:function(a){this.r=new JULY.RepositoryCollection(null,a),this.r.fetch(),this.repos=kb.collectionObservable(this.r,{view_model:JULY.RepoView})},hasMore:function(){return this.repos.collection().hasMore},scrolled:function(a,b){var c=b.target;c.scrollTop>c.scrollHeight-c.offsetHeight-200&&this.fetch()},fetch:function(){this.hasMore()&&this.repos.collection().fetch({remove:!1})}}),!$)var $=null;if(!console)var console=null;var Nav=function(a,b){this._selector=a,this._el=$(a),this._offset=$(window).width()<979?0:b||0,this._startTop=this._el.position().top,this._sectionPadding=20,this._startPadding=Number(this._el.next().css("padding-top").replace("px","")),this._height=this._el.outerHeight()};Nav.prototype.setup=function(){var a=this;this._el.find("button").each(function(){var b=$(this);b.click(function(){var b=$("h2."+this.className),c=b.position().top-a._height-a._offset-a._sectionPadding;$("html, body").animate({scrollTop:c},1100)})})},Nav.prototype.update=function(){var a=$(window);a.scrollTop()+this._offsetthis.models.length,a.objects}}),JULY.LocationCollection=JULY.GroupCollection.extend({url:function(){return"/api/v1/location/?"+this.params()}}),JULY.TeamCollection=JULY.GroupCollection.extend({url:function(){return"/api/v1/team/?"+this.params()}}),JULY.ProfileView=JULY.ViewModel.extend({initialize:function(){this.locations=kb.collectionObservable(new JULY.LocationCollection),this.teams=kb.collectionObservable(new JULY.TeamCollection),JULY.profile=this},filterLocation:function(a){return JULY.profile.locations.collection().filter(a)},filterTeam:function(a){return JULY.profile.teams.collection().filter(a)}}),JULY.UserProjectCollection=Backbone.Collection.extend({model:JULY.Project,url:function(){return"/api/v1/user/"+this.userId+"/projects/?"+this.params()},initialize:function(a,b){this.userId=b.userId,this.limit=b.limit||20,this.offset=b.offset||0,this.total=0,this.hasMore=!1},params:function(){var a={limit:this.limit,offset:this.offset};return jQuery.param(a)},parse:function(a){return this.total=a.meta.total_count,this.offset=a.meta.offset+this.limit,this.hasMore=this.total>this.models.length,a.objects}}),JULY.ProjectsView=JULY.ViewModel.extend({initialize:function(a){this.p=new JULY.UserProjectCollection(null,a),this.p.fetch({add:!0}),this.projects=kb.collectionObservable(this.p)},hasMore:function(){return this.projects.collection().hasMore},scrolled:function(a,b){var c=b.target;c.scrollTop>c.scrollHeight-c.offsetHeight-200&&this.fetch()},fetch:function(){this.hasMore()&&this.projects.collection().fetch({remove:!1})}}); \ No newline at end of file +var JULY=JULY||{};ko.bindingHandlers.pageBottom={init:function(a,b,c,d){var e=b(),f=c(),g=f.callbackThreshold||1e3,h=f.callbackInterval||500;if("function"!=typeof e)throw new Error("The value of the pageBottom binding must be a function");e=$.proxy(e,d);var i=$(document),j=$(window);setInterval(function(){i.height()-j.height()-j.scrollTop()0?ko.applyBindings(a,c[0]):console.log('Binding error: no elements found for "'+b+'"')},JULY.csrfSafeMethod=function(a){return/^(GET|HEAD|OPTIONS|TRACE)$/.test(a)},JULY.setCSRFToken=function(a){jQuery.ajaxSetup({crossDomain:!1,beforeSend:function(b,c){JULY.csrfSafeMethod(c.type)||b.setRequestHeader("X-CSRFToken",a)}})},$(document).ready(function(){var a=$("#send-abuse"),b=$("#abuse-form"),c=$("#abuse-modal"),d=$("#abuseli");a.click(function(){var e=b.find("textarea").val();return e?($.ajax({type:b.attr("method"),url:b.attr("action"),data:b.serialize()}),c.find(".modal-footer").html(""),c.find(".modal-body").html("

Thank you !

"),a.remove(),d.remove(),!1):!1})});var JULY=JULY||{};JULY.Badge=Backbone.Model.extend({url:function(){return"/api/v1/user/"+this.userId+"/badge/"+this.params()}}),JULY.BadgeView=function(a){kb.viewModel(a,{},this),this.status=this.awarded()?"Awarded ("+this.total()+")":this.count()+" / "+this.total(),this.progress=this.awarded()?"100%":Math.round(this.count()/this.total()*100)+"%",this.badge_classes=this.level()+" "+(this.awarded()?"awarded":"unawarded");var b=this;b.isVisible=ko.observable(),b.topPosition=ko.observable(),b.leftPosition=ko.observable(),this.toggleVisible=function(a){var c=$(a),d=c.position();b.topPosition(d.top+c.height()+15+"px"),b.leftPosition(d.left+"px"),b.isVisible(!b.isVisible())}},JULY.BadgesCollection=Backbone.Collection.extend({model:JULY.Badge,url:function(){return"/api/v1/user/"+this.userId+"/badges/"},initialize:function(a,b){this.userId=b.userId},parse:function(a){return a.badges}}),JULY.BadgesView=JULY.ViewModel.extend({initialize:function(a){this.badgesCollection=new JULY.BadgesCollection(null,a),this.badgesCollection.fetch(),this.badges=kb.collectionObservable(this.badgesCollection,{view_model:JULY.BadgeView})}});var JULY=JULY||{};JULY.Project=Backbone.Model.extend({url:"/api/v1/project/"}),JULY.BoardCollection=Backbone.Collection.extend({model:JULY.Project,url:function(){return"/api/v1/largeboard/?"+this.params()},initialize:function(a,b){this.limit=b.limit||20,this.offset=b.offset||0,this.total=0,this.hasMore=!1},params:function(){var a={limit:this.limit,offset:this.offset};return jQuery.param(a)},parse:function(a){return this.total=a.meta.total_count,this.offset=a.meta.offset+this.limit,this.hasMore=this.total>this.models.length,a.objects}}),JULY.LargeBoardCollection=JULY.BoardCollection.extend({url:function(){return"/api/v1/largeboard/?"+this.params()}}),JULY.MediumBoardCollection=JULY.BoardCollection.extend({url:function(){return"/api/v1/mediumboard/?"+this.params()}}),JULY.SmallBoardCollection=JULY.BoardCollection.extend({url:function(){return"/api/v1/smallboard/?"+this.params()}}),JULY.BoardView=function(a){this.points=kb.observable(a,"points"),this.project=a.get("project"),this.url="/projects/"+this.project.slug+"/"},JULY.BoardsView=JULY.ViewModel.extend({initialize:function(a){this.l=new JULY.LargeBoardCollection(null,a),this.m=new JULY.MediumBoardCollection(null,a),this.s=new JULY.SmallBoardCollection(null,a),this.l.fetch({add:!0}),this.m.fetch({add:!0}),this.s.fetch({add:!0}),this.largeBoards=kb.collectionObservable(this.l,{view_model:JULY.BoardView}),this.mediumBoards=kb.collectionObservable(this.m,{view_model:JULY.BoardView}),this.smallBoards=kb.collectionObservable(this.s,{view_model:JULY.BoardView})},largeHasMore:function(){return this.largeBoards.collection().hasMore},mediumHasMore:function(){return this.mediumBoards.collection().hasMore},smallHasMore:function(){return this.smallBoards.collection().hasMore},scrolled:function(a,b){var c=b.target;c.scrollTop>c.scrollHeight-c.offsetHeight-200&&this.fetch()},fetch:function(){this.largeHasMore()&&this.largeBoards.collection().fetch({remove:!1}),this.mediumHasMore()&&this.mediumBoards.collection().fetch({remove:!1}),this.smallHasMore()&&this.smallBoards.collection().fetch({remove:!1})}}),function(){var a=function(a,b){this._chartId=a,this._dataUrl=b,this._chartElement=$("#"+a),this._width=this._chartElement.width(),this._height=this._chartElement.height(),this._pad={top:0,left:0,right:0,bottom:0,barX:1,barY:1},this._options={},this._width&&this._height||(this._width=600,this._height=400),this._chart=d3.select("#"+this._chartId).append("svg"),this._chart.attr("class","chart").attr("width",this._width).attr("height",this._height)};a.prototype.load=function(a){return this._stats=a,this},a.prototype.set=function(a,b){var c=this["_set_"+a];return c?c.apply(this,[b]):console.log("No set for option '"+a+"'."),this},a.prototype._set_xLabel=function(a){this._options.xLabel=a,this._pad.bottom+=24},a.prototype._set_title=function(){},a.prototype._set_yLabel=function(a){this._pad.top+=20,this._options.yLabel=a},a.prototype._getChartDimensions=function(){for(var a=this._stats.length,b=this._width-(this._pad.left+this._pad.right)-a*this._pad.barX,c=this._height-(this._pad.bottom+this._pad.top),d=b/a,e=1,f=0;a>f;f++)this._stats[f]>e&&(e=this._stats[f]);return{bars:a,barWidth:d,maxValue:e,width:b,height:c,top:this._pad.top,bottom:this._height-this._pad.bottom,left:this._pad.left,right:this._width-this._pad.right}},a.prototype.render=function(){var a=this._getChartDimensions(),c=this._chart.selectAll("rect"),d=c.data(this._stats),e=d.enter(),f=this;this._addFilters(),e.append("rect").attr("x",function(b,c){return f._pad.left+c*(a.barWidth+1)}).attr("y",function(c){return a.top+(a.height-b(c,a.maxValue,a.height))}).attr("width",a.barWidth).attr("height",function(c){return b(c,a.maxValue,a.height)});for(var g in this._options)if(this._options.hasOwnProperty(g)){var h=this["_render_"+g];h?h.apply(this,[e,this._options[g]]):console.log("No rendering option for '"+g+"'.")}return this},a.prototype._addFilters=function(){var a=this._chart.append("filter").attr("id","dropshadow");a.append("feGaussianBlur").attr("in","SourceAlpha").attr("stdDeviation",.1),a.append("feOffset").attr("dx",0).attr("dy",1).attr("result","offsetblur");var b=a.append("feMerge");b.append("feMergeNode"),b.append("feMergeNode").attr("in","SourceGraphic")},a.prototype._render_xLabel=function(a,b){var d=this._getChartDimensions(),e=this;a.append("text").attr("class","xLabel").attr("x",function(a,b){return e._pad.left+(d.barWidth+e._pad.barX)*b+d.barWidth/2}).attr("y",function(){return e._pad.top+d.height+e._pad.bottom-3}).attr("width",d.barWidth).attr("text-anchor","middle").text(function(a,d){return c(b,a,d)}),this._chart.append("line").attr("class","rule").attr("y1",d.height+this._pad.top+2).attr("y2",d.height+this._pad.top+2).attr("x1",this._pad.left-2).attr("x2",this._pad.left+d.width+d.bars*this._pad.barX)},a.prototype._render_yLabel=function(a,d){var e=this._getChartDimensions(),f=this;a.append("text").attr("class","yLabel").attr("text-anchor","middle").attr("width",e.barWidth).attr("x",function(a,b){return f._pad.left+(e.barWidth+f._pad.barX)*b+e.barWidth/2}).attr("y",function(a){return console.log(e),f._pad.top+(e.height-b(a,e.maxValue,e.height))-5}).text(function(a,b){return c(d,a,b)})};var b=function(a,b,c){var d=a/b*c;return d},c=function(a,b,c){return $.isFunction(a)?a(b,c):a};window.Charts={BarChart:a}}();var JULY=JULY||{};JULY.Commit=Backbone.Model.extend({url:"/api/v1/commit/"}),JULY.CommitCalendarDay=Backbone.Model.extend({idAttribute:"timestamp",date:function(){var a=new Date(this.get("timestamp"));return d3.time.day(a)}}),JULY.CommitCalendar=Backbone.Collection.extend({model:JULY.CommitCalendarDay,url:function(){return"/api/v1/commit/calendar/?"+this.params()},initialize:function(a,b){this.username=b.username||null,this.start=null,this.end=null},start_date:function(){return d3.time.day(this.start)},parse:function(a){this.start=new Date(a.start),this.end=new Date(a.end);var b=d3.time.day(this.start),c=d3.time.day(this.end),d=d3.time.day.offset(b,1),e=d3.time.day.offset(c,1),f=d3.time.days(d,e),g=d3.time.format("%Y-%m-%d"),h=_(f).map(function(a){var b={timestamp:g(a),commit_count:0};return b});return this.reset(h),a.objects},params:function(){var a={};return this.username&&(a.username=this.username),jQuery.param(a)}}),JULY.CommitCollection=Backbone.Collection.extend({model:JULY.Commit,url:function(){return"/api/v1/commit/?"+this.params()},initialize:function(a,b){this.projectId=b.projectId,this.userId=b.userId,this.languages=b.languages||[],this.limit=b.limit||20,this.offset=b.offset||0,this.total=0,this.hasMore=!1,this._pushStream=new PushStream({host:window.location.hostname,port:window.location.port,modes:"websocket|stream",urlPrefixStream:"/events/sub",urlPrefixPublisher:"/events/pub",urlPrefixWebsocket:"/events/ws"}),JULY.collection=this,this._pushStream.onmessage=function(a){console.log("-- New commit from PushStream:",a),JULY.collection.unshift(a)},this._pushStream.onstatuschange=function(a){console.log("-- PushStream state changed: "+a),a===PushStream.CLOSED&&console.log("!! ERROR: PushStream was closed.")};var c=this.projectId?"project-"+this.projectId:this.userId?"user-"+this.userId:"global";console.log("-- Subscribing to PushStream channel: "+c),this._pushStream.addChannel(c),this._pushStream.connect()},params:function(){var a={limit:this.limit,offset:this.offset};return this.projectId&&(a.project=this.projectId),this.userId&&(a.user=this.userId),this.languages&&(a.languages=_(this.languages).reduce(function(a,b,c){var d=c>0;return a.concat((d?";":"")+b)},"",this)),jQuery.param(a)},parse:function(a){return this.total=a.meta.total_count,this.offset=a.meta.offset+this.limit,this.hasMore=this.total>this.models.length,a.objects}}),JULY.CommitsView=JULY.ViewModel.extend({initialize:function(a){this.c=new JULY.CommitCollection(null,a),this.c.fetch({add:!0}),this.commits=kb.collectionObservable(this.c)},hasMore:function(){return this.commits.collection().hasMore},scrolled:function(a,b){var c=b.target;c.scrollTop>c.scrollHeight-c.offsetHeight-200&&this.fetch()},fetch:function(){this.hasMore()&&this.commits.collection().fetch({remove:!1})}}),JULY.makeCalendar=function(a,b){var c=new JULY.CommitCalendar(null,{username:b});c.fetch({async:!1,remove:!1});var d=c.map(function(a){return a.get("commit_count")}),e=12,f=d3.time.format("%w"),g=d3.time.format("%U"),h=7*e,i=6*e,j=d3.scale.linear().domain([0,Math.max.apply(null,d)]).range(["white","darkgreen"]),k=d3.select(a).attr("width",h).attr("height",i),l=k.selectAll("rect").data(c.models).enter().append("rect").attr("width",e).attr("height",e).attr("y",function(a){return e*(g(a.date())-g(c.start_date()))}).attr("x",function(a){return e*f(a.date())}).style("stroke","#BEC9AF").style("fill",function(a){return j(a.get("commit_count"))});l.append("title").text(function(a){return a.get("commit_count")+" commits on "+a.get("timestamp")})};var JULY=JULY||{};if(JULY.parse_url=function(a){return a.replace("https://api.github.com/","/api/v1/github/")},JULY.Repository=Backbone.Model.extend({initialize:function(a){this.url=JULY.parse_url(a.url),this.hooks_url=JULY.parse_url(a.hooks_url),this.hooks=new JULY.HookCollection(null,{url:this.hooks_url}),this.hooks.fetch()}}),JULY.Hook=Backbone.Model.extend({initialize:function(a){this.url=JULY.parse_url(a.url)}}),JULY.RepositoryCollection=Backbone.Collection.extend({model:JULY.Repository,url:function(){return"/api/v1/github/user/repos?"+this.params()},initialize:function(a,b){this.per_page=b.per_page||20,this.page=b.page||1,this.type=b.type||"public",this.total=0,this.hasMore=!0},params:function(){var a={per_page:this.per_page,page:this.page,type:this.type};return jQuery.param(a)},parse:function(a){return this.total+=a.length,this.page+=1,this.hasMore=a.length==this.per_page,a}}),JULY.HookCollection=Backbone.Collection.extend({model:JULY.Hook,url:function(){return this._url},initialize:function(a,b){this._url=b.url,this.per_page=b.per_page||100,this.page=b.page||1,this.total=0,this.hasMore=!1},params:function(){var a={per_page:this.per_page,page:this.page};return jQuery.param(a)},parse:function(a){var b=[];return _.each(a,function(a){var c=a.config||{};"http://www.julython.org/api/v1/github"==c.url&&b.push(a)}),this.total+=b.length,this.page+=1,this.hasMore=b.length==this.per_page,b}}),JULY.HookView=function(a){var b=this;this.last_response=a.get("last_response"),this.test_url=JULY.parse_url(a.get("test_url")),this.updated_at=ko.observable(a.get("updated_at")),this.test=function(a){JULY.setCSRFToken(a),jQuery.post(b.test_url,{action:"test"},function(){var a=new Date;b.updated_at(a.toISOString())})}},JULY.RepoView=function(a){var b=this;this.working=ko.observable(!1),this.name=kb.observable(a,"name"),this.html_url=kb.observable(a,"html_url"),this.description=kb.observable(a,"description"),this.hooks=kb.collectionObservable(a.hooks,{view_model:JULY.HookView}),this.add=function(a){b.working(!0),JULY.setCSRFToken(a);var c=b.hooks.collection().url;jQuery.post(c,{action:"add"},function(){b.hooks.collection().reset([]),b.hooks.collection().fetch(),b.working(!1)})}},JULY.RepositoryView=JULY.ViewModel.extend({initialize:function(a){this.r=new JULY.RepositoryCollection(null,a),this.r.fetch(),this.repos=kb.collectionObservable(this.r,{view_model:JULY.RepoView})},hasMore:function(){return this.repos.collection().hasMore},scrolled:function(a,b){var c=b.target;c.scrollTop>c.scrollHeight-c.offsetHeight-200&&this.fetch()},fetch:function(){this.hasMore()&&this.repos.collection().fetch({remove:!1})}}),!$)var $=null;var Nav=function(a,b){this._selector=a,this._el=$(a),this._offset=$(window).width()<979?0:b||0,this._startTop=this._el.position().top,this._sectionPadding=20,this._startPadding=Number(this._el.next().css("padding-top").replace("px","")),this._height=this._el.outerHeight()};Nav.prototype.setup=function(){var a=this;this._el.find("button").each(function(){var b=$(this);b.click(function(){var b=$("h2."+this.className),c=b.position().top-a._height-a._offset-a._sectionPadding;$("html, body").animate({scrollTop:c},1100)})})},Nav.prototype.update=function(){var a=$(window);a.scrollTop()+this._offsetthis.models.length,a.objects}}),JULY.LocationCollection=JULY.GroupCollection.extend({url:function(){return"/api/v1/location/?"+this.params()}}),JULY.TeamCollection=JULY.GroupCollection.extend({url:function(){return"/api/v1/team/?"+this.params()}}),JULY.ProfileView=JULY.ViewModel.extend({initialize:function(){this.locations=kb.collectionObservable(new JULY.LocationCollection),this.teams=kb.collectionObservable(new JULY.TeamCollection),JULY.profile=this},filterLocation:function(a){return JULY.profile.locations.collection().filter(a)},filterTeam:function(a){return JULY.profile.teams.collection().filter(a)}}),JULY.UserProjectCollection=Backbone.Collection.extend({model:JULY.Project,url:function(){return"/api/v1/user/"+this.userId+"/projects/?"+this.params()},initialize:function(a,b){this.userId=b.userId,this.limit=b.limit||20,this.offset=b.offset||0,this.total=0,this.hasMore=!1},params:function(){var a={limit:this.limit,offset:this.offset};return jQuery.param(a)},parse:function(a){return this.total=a.meta.total_count,this.offset=a.meta.offset+this.limit,this.hasMore=this.total>this.models.length,a.objects}}),JULY.ProjectsView=JULY.ViewModel.extend({initialize:function(a){this.p=new JULY.UserProjectCollection(null,a),this.p.fetch({add:!0}),this.projects=kb.collectionObservable(this.p)},hasMore:function(){return this.projects.collection().hasMore},scrolled:function(a,b){var c=b.target;c.scrollTop>c.scrollHeight-c.offsetHeight-200&&this.fetch()},fetch:function(){this.hasMore()&&this.projects.collection().fetch({remove:!1})}}); \ No newline at end of file