(function(){this.Pager={init:function(e,t,n){return this.limit=null!=e?e:0,this.disable=null!=n?n:!1,this.loading=$(".loading").first(),t?(this.offset=0,this.getOld()):this.offset=this.limit,this.initLoadMore()},getOld:function(){return this.loading.show(),$.ajax({type:"GET",url:$(".content_list").data("href")||location.href,data:"limit="+this.limit+"&offset="+this.offset,complete:function(e){return function(){return e.loading.hide()}}(this),success:function(e){return Pager.append(e.count,e.html)},dataType:"json"})},append:function(e,t){return $(".content_list").append(t),e>0?this.offset+=e:this.disable=!0},initLoadMore:function(){return $(document).unbind("scroll"),$(document).endlessScroll({bottomPixels:400,fireDelay:1e3,fireOnce:!0,ceaseFire:function(){return Pager.disable},callback:function(e){return function(t){return e.loading.is(":visible")?void 0:(e.loading.show(),Pager.getOld())}}(this)})}}}).call(this),function(e){window.NestedFormEvents=function(){this.addFields=e.proxy(this.addFields,this),this.removeFields=e.proxy(this.removeFields,this)},NestedFormEvents.prototype={addFields:function(t){var n=t.currentTarget,i=e(n).data("association"),r=e("#"+e(n).data("blueprint-id")),s=r.data("blueprint"),o=(e(n).closest(".fields").closestChild("input, textarea, select").eq(0).attr("name")||"").replace(new RegExp("[[a-z_]+]$"),"");if(o)for(var l=o.match(/[a-z_]+_attributes(?=\]\[(new_)?\d+\])/g)||[],a=o.match(/[0-9]+/g)||[],d=0;d<l.length;d++)a[d]&&(s=s.replace(new RegExp("(_"+l[d]+")_.+?_","g"),"$1_"+a[d]+"_"),s=s.replace(new RegExp("(\\["+l[d]+"\\])\\[.+?\\]","g"),"$1["+a[d]+"]"));var c=new RegExp("new_"+i,"g"),u=this.newId();s=e.trim(s.replace(c,u));var f=this.insertFields(s,i,n);return f.trigger({type:"nested:fieldAdded",field:f}).trigger({type:"nested:fieldAdded:"+i,field:f}),!1},newId:function(){return(new Date).getTime()},insertFields:function(t,n,i){var r=e(i).data("target");return r?e(t).appendTo(e(r)):e(t).insertBefore(i)},removeFields:function(t){var n=e(t.currentTarget),i=n.data("association"),r=n.prev("input[type=hidden]");r.val("1");var s=n.closest(".fields");return s.hide(),s.trigger({type:"nested:fieldRemoved",field:s}).trigger({type:"nested:fieldRemoved:"+i,field:s}),!1}},window.nestedFormEvents=new NestedFormEvents,e(document).delegate("form a.add_nested_fields","click",nestedFormEvents.addFields).delegate("form a.remove_nested_fields","click",nestedFormEvents.removeFields)}(jQuery),/*
 * Copyright 2011, Tobias Lindig
 *
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 */
function(e){e.fn.closestChild=function(t){if(t&&""!=t){var n=[];for(n.push(this);n.length>0;)for(var i=n.shift(),r=i.children(),s=0;s<r.length;++s){var o=e(r[s]);if(o.is(t))return o;n.push(o)}}return e()}}(jQuery),function(){var e;e=function(){function e(t,n){clearInterval(e.interval),this.initScrollButtonAffix(),("running"===n||"pending"===n)&&($("#autoscroll-button").bind("click",function(){var e;return e=$(this).data("state"),"enabled"===e?($(this).data("state","disabled"),$(this).text("enable autoscroll")):($(this).data("state","enabled"),$(this).text("disable autoscroll"))}),e.interval=setInterval(function(e){return function(){return window.location.href.split("#").first()===t?$.ajax({url:t,dataType:"json",success:function(i){return"running"===i.status?($("#build-trace code").html(i.trace_html),$("#build-trace code").append('<i class="fa fa-refresh fa-spin"/>'),e.checkAutoscroll()):i.status!==n?Turbolinks.visit(t):void 0}}):void 0}}(this),4e3))}return e.interval=null,e.prototype.checkAutoscroll=function(){return"enabled"===$("#autoscroll-button").data("state")?$("html,body").scrollTop($("#build-trace").height()):void 0},e.prototype.initScrollButtonAffix=function(){var e,t,n;return t=$("#js-build-scroll"),e=$("body"),n=$("#build-trace"),t.affix({offset:{bottom:function(){return e.outerHeight()-(n.outerHeight()+n.offset().top)}}})},e}(),this.CiBuild=e}.call(this),function(){$(document).on("click",".badge-codes-toggle",function(){return $(".badge-codes-block").toggleClass("hide"),!1})}.call(this),function(){$(document).on("click",".edit-runner-link",function(e){var t,n,i,r;return e.preventDefault(),t=$(this).closest(".runner-description").first(),t.addClass("hide"),i=t.next(".runner-description-form"),n=i.find("input.description"),r=n.val(),i.removeClass("hide"),i.find(".cancel").on("click",function(e){return e.preventDefault(),i.addClass("hide"),n.val(r),t.removeClass("hide")})}),$(document).on("click",".assign-all-runner",function(){return $(this).replaceWith('<i class="fa fa-refresh fa-spin"></i> Assign in progress..')}),window.unbindEvents=function(){return $(document).unbind("scroll"),$(document).off("scroll")},document.addEventListener("page:fetch",unbindEvents)}.call(this);