Project

General

Profile

1
!function(l){"use strict";var t="kinetic-active";window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)}),l.support=l.support||{},l.extend(l.support,{touch:"ontouchend"in document});var s=function(){return!1},a=function(t,e){return this.settings=e,this.el=t,this.$el=l(t),this._initElements(),this};a.DATA_KEY="kinetic",a.DEFAULTS={cursor:"move",decelerate:!0,triggerHardware:!1,threshold:0,y:!0,x:!0,slowdown:.9,maxvelocity:40,throttleFPS:60,movingClass:{up:"kinetic-moving-up",down:"kinetic-moving-down",left:"kinetic-moving-left",right:"kinetic-moving-right"},deceleratingClass:{up:"kinetic-decelerating-up",down:"kinetic-decelerating-down",left:"kinetic-decelerating-left",right:"kinetic-decelerating-right"}},a.prototype.start=function(t){this.settings=l.extend(this.settings,t),this.velocity=t.velocity||this.velocity,this.velocityY=t.velocityY||this.velocityY,this.settings.decelerate=!1,this._move()},a.prototype.end=function(){this.settings.decelerate=!0},a.prototype.stop=function(){this.velocity=0,this.velocityY=0,this.settings.decelerate=!0,l.isFunction(this.settings.stopped)&&this.settings.stopped.call(this)},a.prototype.detach=function(){this._detachListeners(),this.$el.removeClass(t).css("cursor","")},a.prototype.attach=function(){this.$el.hasClass(t)||(this._attachListeners(this.$el),this.$el.addClass(t).css("cursor",this.settings.cursor))},a.prototype._initElements=function(){this.$el.addClass(t),l.extend(this,{xpos:null,prevXPos:!1,ypos:null,prevYPos:!1,mouseDown:!1,throttleTimeout:1e3/this.settings.throttleFPS,lastMove:null,elementFocused:null}),this.velocity=0,this.velocityY=0,l(document).mouseup(l.proxy(this._resetMouse,this)).click(l.proxy(this._resetMouse,this)),this._initEvents(),this.$el.css("cursor",this.settings.cursor),this.settings.triggerHardware&&this.$el.css({"-webkit-transform":"translate3d(0,0,0)","-webkit-perspective":"1000","-webkit-backface-visibility":"hidden"})},a.prototype._initEvents=function(){var s=this;this.settings.events={touchStart:function(t){var e;s._useTarget(t.target,t)&&(e=t.originalEvent.touches[0],s.threshold=s._threshold(t.target,t),s._start(e.clientX,e.clientY),t.stopPropagation())},touchMove:function(t){var e;s.mouseDown&&(e=t.originalEvent.touches[0],s._inputmove(e.clientX,e.clientY),t.preventDefault&&t.preventDefault())},inputDown:function(t){s._useTarget(t.target,t)&&(s.threshold=s._threshold(t.target,t),s._start(t.clientX,t.clientY),s.elementFocused=t.target,"IMG"===t.target.nodeName&&t.preventDefault(),t.stopPropagation())},inputEnd:function(t){s._useTarget(t.target,t)&&(s._end(),s.elementFocused=null,t.preventDefault&&t.preventDefault())},inputMove:function(t){s.mouseDown&&(s._inputmove(t.clientX,t.clientY),t.preventDefault&&t.preventDefault())},scroll:function(t){l.isFunction(s.settings.moved)&&s.settings.moved.call(s,s.settings),t.preventDefault&&t.preventDefault()},inputClick:function(t){return 0<Math.abs(s.velocity)?(t.preventDefault(),!1):void 0},dragStart:function(t){return(!s._useTarget(t.target,t)||!s.elementFocused)&&void 0}},this._attachListeners(this.$el,this.settings)},a.prototype._inputmove=function(t,e){var s=this.$el;if(this.el,(!this.lastMove||new Date>new Date(this.lastMove.getTime()+this.throttleTimeout))&&(this.lastMove=new Date,this.mouseDown&&(this.xpos||this.ypos))){var i=t-this.xpos,n=e-this.ypos;if(0<this.threshold){var a=Math.sqrt(i*i+n*n);if(this.threshold>a)return;this.threshold=0}this.elementFocused&&(l(this.elementFocused).blur(),this.elementFocused=null,s.focus()),this.settings.decelerate=!1,this.velocity=this.velocityY=0;var o=this.scrollLeft(),r=this.scrollTop();this.scrollLeft(this.settings.x?o-i:o),this.scrollTop(this.settings.y?r-n:r),this.prevXPos=this.xpos,this.prevYPos=this.ypos,this.xpos=t,this.ypos=e,this._calculateVelocities(),this._setMoveClasses(this.settings.movingClass),l.isFunction(this.settings.moved)&&this.settings.moved.call(this,this.settings)}},a.prototype._calculateVelocities=function(){this.velocity=this._capVelocity(this.prevXPos-this.xpos,this.settings.maxvelocity),this.velocityY=this._capVelocity(this.prevYPos-this.ypos,this.settings.maxvelocity)},a.prototype._end=function(){this.xpos&&this.prevXPos&&!1===this.settings.decelerate&&(this.settings.decelerate=!0,this._calculateVelocities(),this.xpos=this.prevXPos=this.mouseDown=!1,this._move())},a.prototype._useTarget=function(t,e){return!l.isFunction(this.settings.filterTarget)||!1!==this.settings.filterTarget.call(this,t,e)},a.prototype._threshold=function(t,e){return l.isFunction(this.settings.threshold)?this.settings.threshold.call(this,t,e):this.settings.threshold},a.prototype._start=function(t,e){this.mouseDown=!0,this.velocity=this.prevXPos=0,this.velocityY=this.prevYPos=0,this.xpos=t,this.ypos=e},a.prototype._resetMouse=function(){this.xpos=!1,this.ypos=!1,this.mouseDown=!1},a.prototype._decelerateVelocity=function(t,e){return 0===Math.floor(Math.abs(t))?0:t*e},a.prototype._capVelocity=function(t,e){var s=t;return 0<t?e<t&&(s=e):t<0-e&&(s=0-e),s},a.prototype._setMoveClasses=function(t){var e=this.settings,s=this.$el;s.removeClass(e.movingClass.up).removeClass(e.movingClass.down).removeClass(e.movingClass.left).removeClass(e.movingClass.right).removeClass(e.deceleratingClass.up).removeClass(e.deceleratingClass.down).removeClass(e.deceleratingClass.left).removeClass(e.deceleratingClass.right),0<this.velocity&&s.addClass(t.right),this.velocity<0&&s.addClass(t.left),0<this.velocityY&&s.addClass(t.down),this.velocityY<0&&s.addClass(t.up)},a.prototype._move=function(){var t=(this.$el,this.el),e=this,s=e.settings;s.x&&0<t.scrollWidth?(this.scrollLeft(this.scrollLeft()+this.velocity),0<Math.abs(this.velocity)&&(this.velocity=s.decelerate?e._decelerateVelocity(this.velocity,s.slowdown):this.velocity)):this.velocity=0,s.y&&0<t.scrollHeight?(this.scrollTop(this.scrollTop()+this.velocityY),0<Math.abs(this.velocityY)&&(this.velocityY=s.decelerate?e._decelerateVelocity(this.velocityY,s.slowdown):this.velocityY)):this.velocityY=0,e._setMoveClasses(s.deceleratingClass),l.isFunction(s.moved)&&s.moved.call(this,s),0<Math.abs(this.velocity)||0<Math.abs(this.velocityY)?this.moving||(this.moving=!0,window.requestAnimationFrame(function(){e.moving=!1,e._move()})):e.stop()},a.prototype._getScroller=function(){var t=this.$el;return(this.$el.is("body")||this.$el.is("html"))&&(t=l(window)),t},a.prototype.scrollLeft=function(t){var e=this._getScroller();return"number"!=typeof t?e.scrollLeft():(e.scrollLeft(t),void(this.settings.scrollLeft=t))},a.prototype.scrollTop=function(t){var e=this._getScroller();return"number"!=typeof t?e.scrollTop():(e.scrollTop(t),void(this.settings.scrollTop=t))},a.prototype._attachListeners=function(){var t=this.$el,e=this.settings;l.support.touch&&t.bind("touchstart",e.events.touchStart).bind("touchend",e.events.inputEnd).bind("touchmove",e.events.touchMove),t.mousedown(e.events.inputDown).mouseup(e.events.inputEnd).mousemove(e.events.inputMove),t.click(e.events.inputClick).scroll(e.events.scroll).bind("selectstart",s).bind("dragstart",e.events.dragStart)},a.prototype._detachListeners=function(){var t=this.$el,e=this.settings;l.support.touch&&t.unbind("touchstart",e.events.touchStart).unbind("touchend",e.events.inputEnd).unbind("touchmove",e.events.touchMove),t.unbind("mousedown",e.events.inputDown).unbind("mouseup",e.events.inputEnd).unbind("mousemove",e.events.inputMove),t.unbind("click",e.events.inputClick).unbind("scroll",e.events.scroll).unbind("selectstart",s).unbind("dragstart",e.events.dragStart)},l.Kinetic=a,l.fn.kinetic=function(i,n){return this.each(function(){var t=l(this),e=t.data(a.DATA_KEY),s=l.extend({},a.DEFAULTS,t.data(),"object"==typeof i&&i);e||t.data(a.DATA_KEY,e=new a(this,s)),"string"==typeof i&&e[i](n)})}}(window.jQuery||window.Zepto),function(t,e){function v(t){var e="";if(!(t=parseInt(t,10))||t<1)return e;for(;t;)e+="0",--t;return e}function p(t,e,s){return null==t&&(t=""),t=""+t,(s?t:"")+v(e-t.length)+(s?"":t)}function g(t,e){var s,i=0,n=t.length;for("function"!=typeof e&&(s=e,e=function(t){return t===s});i<n;){if(e(t[i]))return t[i];i+=1}}function f(t,e){var s=0,i=t.length;if(t&&i)for(;s<i&&!1!==e(t[s],s);)s+=1}function m(t,e){var s=0,i=t.length,n=[];if(!t||!i)return n;for(;s<i;)n[s]=e(t[s],s),s+=1;return n}function w(t,e){return m(t,function(t){return t[e]})}function y(t){var e=[];return f(t,function(t){g(e,t)||e.push(t)}),e}function b(s,i){var n=[];return f(s,function(t,e){if(!i(t))return n=s.slice(e),!1}),n}function k(t,e){for(var s in e)e.hasOwnProperty(s)&&(t[s]=e[s]);return t}var M;if("function"==typeof require)try{M=require("moment")}catch(t){}if(!M&&t.moment&&(M=t.moment),!M)throw"Moment Duration Format cannot find Moment.js";M.duration.fn.format=function(){var t,r,s,i,l,n;t=[].slice.call(arguments);var e,a,o,c,d,h=k({},this.format.defaults),u=M.duration(this);return h.duration=this,f(t,function(t){"string"==typeof t||"function"==typeof t?h.template=t:"number"==typeof t?h.precision=t:"[object Object]"===Object.prototype.toString.call(t)&&k(h,t)}),s=h.types="[object Array]"===Object.prototype.toString.call(h.types)?h.types:h.types.split(" "),"function"==typeof h.template&&(h.template=h.template.apply(h)),t=new RegExp(m(s,function(t){return h[t].source}).join("|"),"g"),i=function(e){return g(s,function(t){return h[t].test(e)})},r=m(h.template.match(t),function(t,e){var s=i(t);return{index:e,length:t.length,token:"escape"===s?t.replace(h.escape,"$1"):t,type:"escape"===s||"general"===s?null:s}}),e=s,a=y((c=w(r,"type"),d=[],f(c,function(t){t&&d.push(t)}),d)),o=[],f(e,function(e){f(a,function(t){e===t&&o.push(e)})}),(l=y(o)).length?(f(l,function(e,t){var s,i,n,a,o;s=u.as(e),i=0<s?Math.floor(s):Math.ceil(s),n=s-i,a=t+1===l.length,o=!t,f(r,function(t){t.type===e&&(k(t,{value:s,wholeValue:i,decimalValue:n,isLeast:a,isMost:o}),o&&null==h.forceLength&&1<t.length&&(h.forceLength=!0))}),u.subtract(i,e)}),h.trim&&(r=("left"===h.trim?b:function(t,e){return b(t.slice().reverse(),e).reverse()})(r,function(t){return!(t.isLeast||null!=t.type&&t.wholeValue)})),n=!1,"right"===h.trim&&r.reverse(),r=m(r,function(t){var e,s;if(!t.type)return t.token;if(e=(e=t.isLeast&&h.precision<0?(Math.floor(t.wholeValue*Math.pow(10,h.precision))*Math.pow(10,-h.precision)).toString():t.wholeValue.toString()).replace(/^\-/,""),1<t.length&&(n||t.isMost||h.forceLength)&&(e=p(e,t.length)),t.isLeast&&0<h.precision)switch(s=t.decimalValue.toString().replace(/^\-/,"").split(/\.|e\-/),s.length){case 1:e+="."+p(s[0],h.precision,!0).slice(0,h.precision);break;case 2:e+="."+p(s[1],h.precision,!0).slice(0,h.precision);break;case 3:e+="."+p(v(+s[2]-1)+(s[0]||"0")+s[1],h.precision,!0).slice(0,h.precision);break;default:throw"Moment Duration Format: unable to parse token decimal value."}return t.isMost&&t.value<0&&(e="-"+e),n=!0,e}),"right"===h.trim&&r.reverse(),r.join("")):w(r,"token").join("")},M.duration.fn.format.defaults={escape:/\[(.+?)\]/,years:/[Yy]+/,months:/M+/,weeks:/[Ww]+/,days:/[Dd]+/,hours:/[Hh]+/,minutes:/m+/,seconds:/s+/,milliseconds:/S+/,general:/.+?/,types:"escape years months weeks days hours minutes seconds milliseconds general",trim:"left",precision:0,forceLength:null,template:function(){var e=this.duration;switch(function(t,e){for(var s=t.length;--s;)if(e(t[s]))return t[s]}(this.types,function(t){return e._data[t]})){case"seconds":return"h:mm:ss";case"minutes":return"d[d] h:mm";case"hours":return"d[d] h[h]";case"days":return"M[m] d[d]";case"weeks":return"y[y] w[w]";case"months":return"y[y] M[m]";case"years":return"y[y]";default:return"y[y] M[m] d[d] h:mm:ss"}}}}(this),function(m){m.fn.ganttView=function(){var t=Array.prototype.slice.call(arguments);1==t.length&&"object"==typeof t[0]&&function(t){var s=this,i=m.extend(!0,{showWeekends:!0,showToday:!0,toggleProjects:!0,cellWidth:20,slideWidth:400,kineticScroll:!0,startDate:!1,endDate:!1,startToday:!1,behavior:{clickable:!1,draggable:!0,resizable:!0}},t);i.data?e():i.dataUrl&&m.getJSON(i.dataUrl,function(t){i.data=t,e()});function e(){var t=Math.floor(i.slideWidth/i.cellWidth+5),e=w.getBoundaryDatesFromData(i.data,t);i.start=i.startDate?moment(i.startDate,"MM/DD/YYYY")._d:e[0],i.end=i.endDate?moment(i.endDate,"MM/DD/YYYY")._d:e[1],s.each(function(){var t=m(this),e=m("<div>",{class:"ganttview"});new n(e,i).render(),t.append(e);m("div.ganttview-vtheader",t).outerWidth(),m("div.ganttview-slide-container",t).outerWidth();new a(t,i).apply()})}}.call(this,t[0]),2==t.length&&"string"==typeof t[0]&&function(t,e){if("setSlideWidth"==t){var s=$("div.ganttview",this);s.each(function(){var t=$("div.ganttview-vtheader",s).outerWidth();$(s).width(t+e+1),$("div.ganttview-slide-container",this).width(e)})}}.call(this,t[0],t[1])};var n=function(n,a){function f(t,e,s){var i={name:e.name};m.extend(i,s),t.data("block-data",i)}return{render:function(){!function(t,e){for(var s=m("<div>",{class:"ganttview-vtheader"}),i=0;i<e.length;i++){var n=m("<div>",{class:"ganttview-vtheader-group"});n.append(m("<div>",{class:"ganttview-vtheader-group-name",id:"groupId_"+i}).append(e[i].name).append("<span/>"));for(var a=m("<div>",{class:"ganttview-vtheader-series"}),o=0;o<e[i].series.length;o++){var r=m("<div>",{class:"ganttview-vtheader-series-row"});if(e[i].series[o].sub_series){var l=m("<div>",{class:"series-content"}),c=m("<div>",{class:"series-dates"});series_users=m("<div>",{class:"series-users"}),l.append('<div class="series-name">'+e[i].series[o].name+"</div>");for(var d=0;d<e[i].series[o].sub_series.length;d++){var h=0<d?'<span class="date-sep">|</span>':"",u=e[i].series[o].sub_series[d];if(u.user_avatar){var v=m("<div>",{class:"series-user"});u.user_name,user_avatar=u.user_avatar,v.append('<span><img src="'+user_avatar+'"/></span>'),series_users.append(v),r.append(series_users)}c.append(function(){return h+"<span data-event-id='"+e[i].series[o].sub_series[d].id+"'>"+moment(u.start,"MM/DD/YYYY").format("D MMM")+" - "+moment(u.end,"MM/DD/YYYY").format("D MMM")+"</span>"}),l.append(c),r.append(l)}}else r.append(function(){var t=e[i].series[o].user_avatar?"<div class='series-user'><span><img src='"+e[i].series[o].user_avatar+"' /></span></div>":"";return t+"<div class='series-content'><div class=\"series-name\">"+e[i].series[o].name+"</div><div class='series-dates'><span data-event-id='"+e[i].series[o].id+"'>"+moment(e[i].series[o].start,"MM/DD/YYYY").format("D MMM")+" - "+moment(e[i].series[o].end,"MM/DD/YYYY").format("D MMM")+"</span></div></div>"});a.append(r)}n.append(a),s.append(n)}t.append(s)}(n,a.data);var t,e,s,i=m("<div>",{class:"ganttview-slide-container"});dates=function(t,e){var s=[];s[t.getFullYear()]=[],s[t.getFullYear()][t.getMonth()]=[t];for(var i=t;moment(e).isAfter(i);){var n=moment(i).add(1,"days")._d;s[n.getFullYear()]||(s[n.getFullYear()]=[]),s[n.getFullYear()][n.getMonth()]||(s[n.getFullYear()][n.getMonth()]=[]),s[n.getFullYear()][n.getMonth()].push(n),i=n}return s}(a.start,a.end),function(t,e,s,i,n,a){var o=m("<div>",{class:"ganttview-hzheader"}),r=m("<div>",{class:"ganttview-hzheader-months"}),l=m("<div>",{class:"ganttview-hzheader-days"}),c=0;for(var d in e)for(var h in e[d]){var u=e[d][h].length*s;for(var v in c+=u,r.append(m("<div>",{class:"ganttview-hzheader-month",css:{width:u-1+"px"}}).append(moment(parseInt(h)+1,"M").format("MMMM")+" "+d)),e[d][h]){var p=m("<div>",{class:"ganttview-hzheader-day"});w.isWeekend(e[d][h][v])&&i&&p.addClass("ganttview-weekend"),moment(e[d][h][v]).isSame(Date.now(),"day")&&n&&p.addClass("ganttview-today"),moment(e[d][h][v]).isSame(Date.now(),"day")&&a&&p.addClass("ganttview-startToday"),l.append(p.append(e[d][h][v].getDate()))}}r.css("width",c+"px"),l.css("width",c+"px"),o.append(r).append(l),t.append(o)}(i,dates,a.cellWidth,a.showWeekends,a.showToday,a.startToday),function(t,e,s,i,n,a){var o=m("<div>",{class:"ganttview-grid"}),r=m("<div>",{class:"ganttview-grid-row"});for(var l in s)for(var c in s[l])for(var d in s[l][c]){var h=m("<div>",{class:"ganttview-grid-row-cell"});w.isWeekend(s[l][c][d])&&n&&h.addClass("ganttview-weekend"),moment(s[l][c][d]).isSame(Date.now(),"day")&&a&&h.addClass("ganttview-today"),r.append(h)}var u=m("div.ganttview-grid-row-cell",r).length*i;r.css("width",u+"px"),o.css("width",u+"px");for(var v=0;v<e.length;v++){o.append(m("<div>",{class:"ganttview-grid-spacer","data-click-target":"groupId_"+v}));for(var p=0;p<e[v].series.length;p++)o.append(r.clone().addClass("groupId_"+v))}t.append(o)}(i,a.data,dates,a.cellWidth,a.showWeekends,a.showToday),function(t,e){for(var s=m("<div>",{class:"ganttview-blocks"}),i=0;i<e.length;i++){s.append(m("<div>",{class:"ganttview-block-spacer"}));for(var n=0;n<e[i].series.length;n++)s.append(m("<div>",{class:"ganttview-block-container groupId_"+i}))}t.append(s)}(i,a.data),function(t,r,l,c){for(var d=m("div.ganttview-blocks div.ganttview-block-container",t),h=0,u=0;u<r.length;u++)for(var e=0;e<r[u].series.length;e++){if(r[u].series[e].sub_series){var v=r[u].series[e].sub_series,p=r[u].series[e].name.replace(/(<([^>]+)>)/gi," ");$.each(v,function(t,e){var s=w.daysBetween(e.start,e.end)+1,i=w.daysBetween(c,e.start),n=e.user_name?" ("+e.user_name+")":"",a=m("<div>",{class:"ganttview-block",title:p+n,"data-id":e.id,css:{width:s*l-7+"px",left:i*l+3+"px"}});f(a,r[u],v[t]),e.color&&a.css("background-color",e.color);var o=e.title?e.link?'<a href="'+e.link+'" title="'+e.link+'">'+e.title+"</a>":e.title:moment.duration(s,"days").format();e.link?a.append(m("<div>",{class:"ganttview-block-text"}).html(o)):a.append(m("<div>",{class:"ganttview-block-text"}).text(o)),m(d[h]).append(a)})}else{var s=r[u].series[e],i=s.name.replace(/(<([^>]+)>)/gi," "),n=w.daysBetween(s.start,s.end)+1,a=w.daysBetween(c,s.start),o=m("<div>",{class:"ganttview-block",title:i,css:{width:n*l-7+"px",left:a*l+3+"px"}});f(o,r[u],s),r[u].series[e].color&&o.css("background-color",r[u].series[e].color);var g=s.title?s.link?'<a href="'+s.link+'" title="'+s.link+'">'+s.title+"</a>":s.title:moment.duration(n,"days").format();s.link?o.append(m("<div>",{class:"ganttview-block-text"}).html(g)):o.append(m("<div>",{class:"ganttview-block-text"}).text(g)),m(d[h]).append(o)}h++}m(".ganttview-blocks").css({width:$(t).width()})}(i,a.data,a.cellWidth,a.start),n.append(i),m(n).find(".ganttview-blocks").width(i.find(".ganttview-grid").width()),t=n.parent(),m("div.ganttview-grid-row div.ganttview-grid-row-cell:last-child",t).addClass("last"),m("div.ganttview-hzheader-days div.ganttview-hzheader-day:last-child",t).addClass("last"),m("div.ganttview-hzheader-months div.ganttview-hzheader-month:last-child",t).addClass("last"),a.toggleProjects&&(e=n,$("div.ganttview-vtheader-group-name",e).addClass("toggle_enabled").on("click",function(){$thisId=$(this).attr("id"),$(this).hasClass("projectHidden")?($(this).removeClass("projectHidden").next("div").children().velocity("slideDown",{duration:180,easing:easing_swiftOut}),$(".ganttview-block-container."+$thisId).show(),$(".ganttview-grid-row."+$thisId).velocity("slideDown",{duration:180,easing:easing_swiftOut})):($(this).addClass("projectHidden").next("div").children().velocity("slideUp",{duration:180,easing:easing_swiftOut}),$(".ganttview-block-container."+$thisId).hide(),$(".ganttview-grid-row."+$thisId).velocity("slideUp",{duration:180,easing:easing_swiftOut}))}),$("div.ganttview-grid-spacer",e).on("click",function(){$("#"+$(this).attr("data-click-target")).click()})),a.kineticScroll&&!Modernizr.touch&&(s=m("div.ganttview-slide-container",n),$(s).kinetic({y:!1,filterTarget:function(t,e){return!($(t).closest(".ganttview-block").length||$(t).closest(".ganttview-grid-spacer").length)}})),a.startToday&&setTimeout(function(){var t=w.daysBetween(a.start,moment()._d);i.scrollLeft(t*a.cellWidth)},100)}}},a=function(d,h){function u(t,e,s,i){var n=m("div.ganttview-slide-container",t),a=n.scrollLeft(),o=e.offset().left-n.offset().left-1+a,r=Math.round(o/s),l=moment(i).add(r,"days");e.data("block-data").start=l;var c=e.outerWidth(),d=Math.round(c/s)-1;e.data("block-data").end=moment(l).add(d,"days"),e.data("block-data").title||m("div.ganttview-block-text",e).text(moment.duration(d+1,"days").format())}return{apply:function(){var t,e,s,i,n,a,o,r,l,c;h.behavior.clickable&&(t=d,e=h.behavior.onClick,m("div.ganttview-block",t).on("click",function(){e&&e(m(this).data("block-data"))})),h.behavior.resizable&&(s=d,i=h.cellWidth,n=h.start,a=h.behavior.onResize,m("div.ganttview-block",s).resizable({grid:i,handles:"e,w",stop:function(){var t=m(this);u(s,t,i,n);var e=t.data("block-data");s.find("[data-event-id="+e.id+"]").text(moment(e.start).format("D MMM")+" - "+moment(e.end).format("D MMM")),a&&a(t.data("block-data"))}})),h.behavior.draggable&&(o=d,r=h.cellWidth,l=h.start,c=h.behavior.onDrag,m("div.ganttview-block",o).draggable({axis:"x",grid:[r,r],containment:"parent",stop:function(){var t=m(this);u(o,t,r,l);var e=t.data("block-data");o.find("[data-event-id="+e.id+"]").text(moment(e.start).format("D MMM")+" - "+moment(e.end).format("D MMM")),c&&c(t.data("block-data"))}}))}}},w={daysBetween:function(t,e){return t&&e?(t=Date.parse(t),e=Date.parse(e),1901==moment(t)._d.getYear()||8099==moment(e)._d.getYear()?0:moment(e).diff(moment(t),"days")):0},isWeekend:function(t){return t.getDay()%6==0},getBoundaryDatesFromData:function(t,e){var n=new Date,a=new Date,s=[];return t.forEach(function(t){t.series.forEach(function(t){t.sub_series?t.sub_series.forEach(function(t){s.push(t)}):s.push(t)})}),s.forEach(function(t,e){var s=Date.parse(t.start),i=Date.parse(t.end);0==e&&(n=s,a=i),moment(n).isAfter(s)&&(n=s),moment(a).isBefore(i)&&(a=i)}),moment(a).diff(n,"days")<e&&(a=moment(n).add(e,"days")),[moment(n)._d,moment(a)._d]}}}(jQuery);
(10-10/27)