%PDF- %PDF-
Direktori : /home/jalalj2hb/www/ftm-admin/assets/js/custom/ |
Current File : /home/jalalj2hb/www/ftm-admin/assets/js/custom/gantt_chart.min.js |
!function(t){"use strict";var e="kinetic-active";window.requestAnimationFrame||(window.requestAnimationFrame=function(){return window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)}}()),t.support=t.support||{},t.extend(t.support,{touch:"ontouchend"in document});var i=function(){return!1},s=function(e,i){return this.settings=i,this.el=e,this.$el=t(e),this._initElements(),this};s.DATA_KEY="kinetic",s.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"}},s.prototype.start=function(e){this.settings=t.extend(this.settings,e),this.velocity=e.velocity||this.velocity,this.velocityY=e.velocityY||this.velocityY,this.settings.decelerate=!1,this._move()},s.prototype.end=function(){this.settings.decelerate=!0},s.prototype.stop=function(){this.velocity=0,this.velocityY=0,this.settings.decelerate=!0,t.isFunction(this.settings.stopped)&&this.settings.stopped.call(this)},s.prototype.detach=function(){this._detachListeners(),this.$el.removeClass(e).css("cursor","")},s.prototype.attach=function(){this.$el.hasClass(e)||(this._attachListeners(this.$el),this.$el.addClass(e).css("cursor",this.settings.cursor))},s.prototype._initElements=function(){this.$el.addClass(e),t.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,t(document).mouseup(t.proxy(this._resetMouse,this)).click(t.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"})},s.prototype._initEvents=function(){var e=this;this.settings.events={touchStart:function(t){var i;e._useTarget(t.target,t)&&(i=t.originalEvent.touches[0],e.threshold=e._threshold(t.target,t),e._start(i.clientX,i.clientY),t.stopPropagation())},touchMove:function(t){var i;e.mouseDown&&(i=t.originalEvent.touches[0],e._inputmove(i.clientX,i.clientY),t.preventDefault&&t.preventDefault())},inputDown:function(t){e._useTarget(t.target,t)&&(e.threshold=e._threshold(t.target,t),e._start(t.clientX,t.clientY),e.elementFocused=t.target,"IMG"===t.target.nodeName&&t.preventDefault(),t.stopPropagation())},inputEnd:function(t){e._useTarget(t.target,t)&&(e._end(),e.elementFocused=null,t.preventDefault&&t.preventDefault())},inputMove:function(t){e.mouseDown&&(e._inputmove(t.clientX,t.clientY),t.preventDefault&&t.preventDefault())},scroll:function(i){t.isFunction(e.settings.moved)&&e.settings.moved.call(e,e.settings),i.preventDefault&&i.preventDefault()},inputClick:function(t){return Math.abs(e.velocity)>0?(t.preventDefault(),!1):void 0},dragStart:function(t){return(!e._useTarget(t.target,t)||!e.elementFocused)&&void 0}},this._attachListeners(this.$el,this.settings)},s.prototype._inputmove=function(e,i){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 n=e-this.xpos,a=i-this.ypos;if(this.threshold>0){var o=Math.sqrt(n*n+a*a);if(this.threshold>o)return;this.threshold=0}this.elementFocused&&(t(this.elementFocused).blur(),this.elementFocused=null,s.focus()),this.settings.decelerate=!1,this.velocity=this.velocityY=0;var r=this.scrollLeft(),l=this.scrollTop();this.scrollLeft(this.settings.x?r-n:r),this.scrollTop(this.settings.y?l-a:l),this.prevXPos=this.xpos,this.prevYPos=this.ypos,this.xpos=e,this.ypos=i,this._calculateVelocities(),this._setMoveClasses(this.settings.movingClass),t.isFunction(this.settings.moved)&&this.settings.moved.call(this,this.settings)}},s.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)},s.prototype._end=function(){this.xpos&&this.prevXPos&&this.settings.decelerate===!1&&(this.settings.decelerate=!0,this._calculateVelocities(),this.xpos=this.prevXPos=this.mouseDown=!1,this._move())},s.prototype._useTarget=function(e,i){return!t.isFunction(this.settings.filterTarget)||this.settings.filterTarget.call(this,e,i)!==!1},s.prototype._threshold=function(e,i){return t.isFunction(this.settings.threshold)?this.settings.threshold.call(this,e,i):this.settings.threshold},s.prototype._start=function(t,e){this.mouseDown=!0,this.velocity=this.prevXPos=0,this.velocityY=this.prevYPos=0,this.xpos=t,this.ypos=e},s.prototype._resetMouse=function(){this.xpos=!1,this.ypos=!1,this.mouseDown=!1},s.prototype._decelerateVelocity=function(t,e){return 0===Math.floor(Math.abs(t))?0:t*e},s.prototype._capVelocity=function(t,e){var i=t;return t>0?t>e&&(i=e):0-e>t&&(i=0-e),i},s.prototype._setMoveClasses=function(t){var e=this.settings,i=this.$el;i.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),this.velocity>0&&i.addClass(t.right),this.velocity<0&&i.addClass(t.left),this.velocityY>0&&i.addClass(t.down),this.velocityY<0&&i.addClass(t.up)},s.prototype._move=function(){var e=(this.$el,this.el),i=this,s=i.settings;s.x&&e.scrollWidth>0?(this.scrollLeft(this.scrollLeft()+this.velocity),Math.abs(this.velocity)>0&&(this.velocity=s.decelerate?i._decelerateVelocity(this.velocity,s.slowdown):this.velocity)):this.velocity=0,s.y&&e.scrollHeight>0?(this.scrollTop(this.scrollTop()+this.velocityY),Math.abs(this.velocityY)>0&&(this.velocityY=s.decelerate?i._decelerateVelocity(this.velocityY,s.slowdown):this.velocityY)):this.velocityY=0,i._setMoveClasses(s.deceleratingClass),t.isFunction(s.moved)&&s.moved.call(this,s),Math.abs(this.velocity)>0||Math.abs(this.velocityY)>0?this.moving||(this.moving=!0,window.requestAnimationFrame(function(){i.moving=!1,i._move()})):i.stop()},s.prototype._getScroller=function(){var e=this.$el;return(this.$el.is("body")||this.$el.is("html"))&&(e=t(window)),e},s.prototype.scrollLeft=function(t){var e=this._getScroller();return"number"!=typeof t?e.scrollLeft():(e.scrollLeft(t),void(this.settings.scrollLeft=t))},s.prototype.scrollTop=function(t){var e=this._getScroller();return"number"!=typeof t?e.scrollTop():(e.scrollTop(t),void(this.settings.scrollTop=t))},s.prototype._attachListeners=function(){var e=this.$el,s=this.settings;t.support.touch&&e.bind("touchstart",s.events.touchStart).bind("touchend",s.events.inputEnd).bind("touchmove",s.events.touchMove),e.mousedown(s.events.inputDown).mouseup(s.events.inputEnd).mousemove(s.events.inputMove),e.click(s.events.inputClick).scroll(s.events.scroll).bind("selectstart",i).bind("dragstart",s.events.dragStart)},s.prototype._detachListeners=function(){var e=this.$el,s=this.settings;t.support.touch&&e.unbind("touchstart",s.events.touchStart).unbind("touchend",s.events.inputEnd).unbind("touchmove",s.events.touchMove),e.unbind("mousedown",s.events.inputDown).unbind("mouseup",s.events.inputEnd).unbind("mousemove",s.events.inputMove),e.unbind("click",s.events.inputClick).unbind("scroll",s.events.scroll).unbind("selectstart",i).unbind("dragstart",s.events.dragStart)},t.Kinetic=s,t.fn.kinetic=function(e,i){return this.each(function(){var n=t(this),a=n.data(s.DATA_KEY),o=t.extend({},s.DEFAULTS,n.data(),"object"==typeof e&&e);a||n.data(s.DATA_KEY,a=new s(this,o)),"string"==typeof e&&a[e](i)})}}(window.jQuery||window.Zepto),function(t){function e(e){function i(){var e=Math.floor(l.slideWidth/l.cellWidth+5),i=a.getBoundaryDatesFromData(l.data,e);l.start=i[0],l.end=i[1],o.each(function(){var e=t(this),i=t("<div>",{"class":"ganttview"});new s(i,l).render(),e.append(i);t("div.ganttview-vtheader",e).outerWidth()+t("div.ganttview-slide-container",e).outerWidth();new n(e,l).apply()})}var o=this,r={showWeekends:!0,toggleProjects:!0,cellWidth:20,slideWidth:400,kineticScroll:!0,behavior:{clickable:!0,draggable:!0,resizable:!0}},l=t.extend(!0,r,e);l.data?i():l.dataUrl&&t.getJSON(l.dataUrl,function(t){l.data=t,i()})}function i(t,e){if("setSlideWidth"==t){var i=$("div.ganttview",this);i.each(function(){var t=$("div.ganttview-vtheader",i).outerWidth();$(i).width(t+e+1),$("div.ganttview-slide-container",this).width(e)})}}t.fn.ganttView=function(){var t=Array.prototype.slice.call(arguments);1==t.length&&"object"==typeof t[0]&&e.call(this,t[0]),2==t.length&&"string"==typeof t[0]&&i.call(this,t[0],t[1])};var s=function(e,i){function s(){o(e,i.data);var s=t("<div>",{"class":"ganttview-slide-container"});dates=n(i.start,i.end),r(s,dates,i.cellWidth,i.showWeekends),l(s,i.data,dates,i.cellWidth,i.showWeekends),d(s,i.data),c(s,i.data,i.cellWidth,i.start),e.append(s),v(e.parent()),i.toggleProjects&&u(e),i.kineticScroll&&!Modernizr.touch&&p(e)}function n(t,e){var i=[];i[t.getFullYear()]=[],i[t.getFullYear()][t.getMonth()]=[t];for(var s=t;moment(e).isAfter(s);){var n=moment(s).add(1,"days")._d;i[n.getFullYear()]||(i[n.getFullYear()]=[]),i[n.getFullYear()][n.getMonth()]||(i[n.getFullYear()][n.getMonth()]=[]),i[n.getFullYear()][n.getMonth()].push(n),s=n}return i}function o(e,i){for(var s=t("<div>",{"class":"ganttview-vtheader"}),n=0;n<i.length;n++){var a=t("<div>",{"class":"ganttview-vtheader-group"});a.append(t("<div>",{"class":"ganttview-vtheader-group-name",id:"groupId_"+n}).append(i[n].name).append("<span/>"));for(var o=t("<div>",{"class":"ganttview-vtheader-series"}),r=0;r<i[n].series.length;r++)o.append(t("<div>",{"class":"ganttview-vtheader-series-row"}).append(function(){var t=i[n].series[r].user_avatar?"<div class='series-user' title='"+i[n].series[r].user_name+"'><img src='"+i[n].series[r].user_avatar+"' /></div>":"";return t+"<div class='series-content'>"+i[n].series[r].name+"<span class='series-date'>"+moment(i[n].series[r].start,"MM/DD/YYYY").format("D MMM")+" - "+moment(i[n].series[r].end,"MM/DD/YYYY").format("D MMM")+"</span></div>"}));a.append(o),s.append(a)}e.append(s)}function r(e,i,s,n){var o=t("<div>",{"class":"ganttview-hzheader"}),r=t("<div>",{"class":"ganttview-hzheader-months"}),l=t("<div>",{"class":"ganttview-hzheader-days"}),d=0;for(var c in i)for(var h in i[c]){var v=i[c][h].length*s;d+=v,r.append(t("<div>",{"class":"ganttview-hzheader-month",css:{width:v-1+"px"}}).append(moment(parseInt(h)+1,"M").format("MMMM")+" "+c));for(var u in i[c][h]){var p=t("<div>",{"class":"ganttview-hzheader-day"});a.isWeekend(i[c][h][u])&&n&&p.addClass("ganttview-weekend"),l.append(p.append(i[c][h][u].getDate()))}}r.css("width",d+"px"),l.css("width",d+"px"),o.append(r).append(l),e.append(o)}function l(e,i,s,n,o){var r=t("<div>",{"class":"ganttview-grid"}),l=t("<div>",{"class":"ganttview-grid-row"});for(var d in s)for(var c in s[d])for(var h in s[d][c]){var v=t("<div>",{"class":"ganttview-grid-row-cell"});a.isWeekend(s[d][c][h])&&o&&v.addClass("ganttview-weekend"),l.append(v)}var u=t("div.ganttview-grid-row-cell",l).length*n;l.css("width",u+"px"),r.css("width",u+"px");for(var p=0;p<i.length;p++){r.append(t("<div>",{"class":"ganttview-grid-spacer","data-click-target":"groupId_"+p}));for(var g=0;g<i[p].series.length;g++)r.append(l.clone().addClass("groupId_"+p))}e.append(r)}function d(e,i){for(var s=t("<div>",{"class":"ganttview-blocks",css:{width:$(e).width()}}),n=0;n<i.length;n++){s.append(t("<div>",{"class":"ganttview-block-spacer"}));for(var a=0;a<i[n].series.length;a++)s.append(t("<div>",{"class":"ganttview-block-container groupId_"+n}))}e.append(s)}function c(e,i,s,n){for(var o=t("div.ganttview-blocks div.ganttview-block-container",e),r=0,l=0;l<i.length;l++)for(var d=0;d<i[l].series.length;d++){var c=i[l].series[d],v=a.daysBetween(c.start,c.end)+1,u=a.daysBetween(n,c.start),p=c.name.replace(/(<([^>]+)>)/gi," "),g=t("<div>",{"class":"ganttview-block",title:p,css:{width:v*s-9+"px","margin-left":u*s+3+"px"}});h(g,i[l],c),i[l].series[d].color&&g.css("background-color",i[l].series[d].color),g.append(t("<div>",{"class":"ganttview-block-text"}).text(moment.duration(v,"days").humanize())),t(o[r]).append(g),r++}}function h(e,i,s){var n={id:i.id,name:i.name};t.extend(n,s),e.data("block-data",n)}function v(e){t("div.ganttview-grid-row div.ganttview-grid-row-cell:last-child",e).addClass("last"),t("div.ganttview-hzheader-days div.ganttview-hzheader-day:last-child",e).addClass("last"),t("div.ganttview-hzheader-months div.ganttview-hzheader-month:last-child",e).addClass("last")}function u(t){$("div.ganttview-vtheader-group-name",t).addClass("toggle_enabled").on("click",function(){$thisId=$(this).attr("id"),$(this).hasClass("projectHidden")?($(this).removeClass("projectHidden").next("div").children().velocity("slideDown",{duration:280,easing:easing_swiftOut}),$(".ganttview-block-container."+$thisId).show(),$(".ganttview-grid-row."+$thisId).velocity("slideDown",{duration:280,easing:easing_swiftOut})):($(this).addClass("projectHidden").next("div").children().velocity("slideUp",{duration:280,easing:easing_swiftOut}),$(".ganttview-block-container."+$thisId).hide(),$(".ganttview-grid-row."+$thisId).velocity("slideUp",{duration:280,easing:easing_swiftOut}))}),$("div.ganttview-grid-spacer",t).on("click",function(){$("#"+$(this).attr("data-click-target")).click()})}function p(e){var i=t("div.ganttview-slide-container",e);$(i).kinetic({y:!1,filterTarget:function(t,e){return!($(t).closest(".ganttview-block").length||$(t).closest(".ganttview-grid-spacer").length)}})}return{render:s}},n=function(e,i){function s(){i.behavior.clickable&&n(e,i.behavior.onClick),i.behavior.resizable&&a(e,i.cellWidth,i.start,i.behavior.onResize),i.behavior.draggable&&o(e,i.cellWidth,i.start,i.behavior.onDrag)}function n(e,i){t("div.ganttview-block",e).on("click",function(){i&&i(t(this).data("block-data"))})}function a(e,i,s,n){t("div.ganttview-block",e).resizable({grid:i,handles:"e,w",stop:function(){var a=t(this);r(e,a,i,s),n&&n(a.data("block-data"))}})}function o(e,i,s,n){t("div.ganttview-block",e).draggable({axis:"x",grid:[i,i],stop:function(){var a=t(this);r(e,a,i,s),n&&n(a.data("block-data"))}})}function r(e,i,s,n){var a=t("div.ganttview-slide-container",e),o=a.scrollLeft(),r=i.offset().left-a.offset().left-1+o,l=Math.round(r/s),d=moment(n).add(l,"days");i.data("block-data").start=d;var c=i.outerWidth(),h=Math.round(c/s)-1;i.data("block-data").end=moment(d).add(h,"days"),t("div.ganttview-block-text",i).text(moment.duration(h+1,"days").humanize()),i.css("top","").css("left","").css("position","relative").css("margin-left",r+"px")}return{apply:s}},a={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 i=new Date;maxEnd=new Date;for(var s=0;s<t.length;s++)for(var n=0;n<t[s].series.length;n++){var a=Date.parse(t[s].series[n].start),o=Date.parse(t[s].series[n].end);0==s&&0==n&&(i=a,maxEnd=o),moment(i).isAfter(a)&&(i=a),moment(maxEnd).isBefore(o)&&(maxEnd=o)}return moment(maxEnd).diff(i,"days")<e&&(maxEnd=moment(i).add(e,"days")),[moment(i)._d,moment(maxEnd)._d]}}}(jQuery);