kendo.gantt.timeline.min.js 39.8 KB
/** 
 * Kendo UI v2016.1.112 (http://www.telerik.com/kendo-ui)                                                                                                                                               
 * Copyright 2016 Telerik AD. All rights reserved.                                                                                                                                                      
 *                                                                                                                                                                                                      
 * Kendo UI commercial licenses may be obtained at                                                                                                                                                      
 * http://www.telerik.com/purchase/license-agreement/kendo-ui-complete                                                                                                                                  
 * If you do not own a commercial license, this file shall be governed by the trial license terms.                                                                                                      
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       

*/
!function(e,define){define("kendo.gantt.timeline.min",["kendo.dom.min","kendo.touch.min","kendo.draganddrop.min"],e)}(function(){return function(e){function t(e){return delete e.name,delete e.prefix,delete e.views,e}function s(e){var t=[],s=e.workWeekStart;for(t.push(s);e.workWeekEnd!=s;)s>6?s-=7:s++,t.push(s);return t}function i(){var t=kendo._activeElement();t&&"body"!==t.nodeName.toLowerCase()&&e(t).blur()}var n,a,r=kendo.ui.Widget,o=kendo.dom.element,l=kendo.dom.text,d=kendo.dom.html,h=e.isPlainObject,p=e.extend,c=e.proxy,u=kendo.support.browser,k=!1,g=kendo.keys,f=kendo.data.Query,m="string",_=".kendoGanttTimeline",v="click",y="dblclick",w="mousemove",T="mouseenter",D="mouseleave",b="keydown",H=".",W=kendo.template("#=kendo.toString(start, 't')#"),x=kendo.template("#=kendo.toString(start, 'ddd M/dd')#"),z=kendo.template("#=kendo.toString(start, 'ddd M/dd')# - #=kendo.toString(kendo.date.addDays(end, -1), 'ddd M/dd')#"),S=kendo.template("#=kendo.toString(start, 'MMM')#"),M=kendo.template("#=kendo.toString(start, 'yyyy')#"),C=kendo.template('<div class="#=styles.marquee#"><div class="#=styles.marqueeColor#"></div></div>'),P=kendo.template('<div style="z-index: 100002;" class="#=styles.tooltipWrapper#"><div class="#=styles.tooltipContent#"><div>#=messages.start#: #=kendo.toString(start, format)#</div><div>#=messages.end#: #=kendo.toString(end, format)#</div></div></div>'),I=kendo.template('<div style="z-index: 100002;" class="#=styles.tooltipWrapper#" ><div class="#=styles.tooltipContent#">#=text#%</div><div class="#=styles.tooltipCallout#" style="left:13px;"></div></div>'),N=kendo.template('<div class="#=styles.taskDetails#"><strong>#=task.title#</strong><div class="#=styles.taskDetailsPercent#">#=kendo.toString(task.percentComplete, "p0")#</div><ul class="#=styles.reset#"><li>#=messages.start#: #=kendo.toString(task.start, "h:mm tt ddd, MMM d")#</li><li>#=messages.end#: #=kendo.toString(task.end, "h:mm tt ddd, MMM d")#</li></ul></div>'),R="<table style='visibility: hidden;'><tbody><tr style='height:{0}'><td>&nbsp;</td></tr></tbody></table>",V={day:{type:"kendo.ui.GanttDayView"},week:{type:"kendo.ui.GanttWeekView"},month:{type:"kendo.ui.GanttMonthView"},year:{type:"kendo.ui.GanttYearView"}},F={alt:"k-alt",reset:"k-reset",nonWorking:"k-nonwork-hour",header:"k-header",gridHeader:"k-grid-header",gridHeaderWrap:"k-grid-header-wrap",gridContent:"k-grid-content",tasksWrapper:"k-gantt-tables",rowsTable:"k-gantt-rows",columnsTable:"k-gantt-columns",tasksTable:"k-gantt-tasks",dependenciesWrapper:"k-gantt-dependencies",resource:"k-resource",resourceAlt:"k-resource k-alt",task:"k-task",taskSingle:"k-task-single",taskMilestone:"k-task-milestone",taskSummary:"k-task-summary",taskWrap:"k-task-wrap",taskMilestoneWrap:"k-milestone-wrap",resourcesWrap:"k-resources-wrap",taskDot:"k-task-dot",taskDotStart:"k-task-start",taskDotEnd:"k-task-end",taskDragHandle:"k-task-draghandle",taskContent:"k-task-content",taskTemplate:"k-task-template",taskActions:"k-task-actions",taskDelete:"k-task-delete",taskComplete:"k-task-complete",taskDetails:"k-task-details",taskDetailsPercent:"k-task-pct",link:"k-link",icon:"k-icon",iconDelete:"k-si-close",taskResizeHandle:"k-resize-handle",taskResizeHandleWest:"k-resize-w",taskResizeHandleEast:"k-resize-e",taskSummaryProgress:"k-task-summary-progress",taskSummaryComplete:"k-task-summary-complete",line:"k-line",lineHorizontal:"k-line-h",lineVertical:"k-line-v",arrowWest:"k-arrow-w",arrowEast:"k-arrow-e",dragHint:"k-drag-hint",dependencyHint:"k-dependency-hint",tooltipWrapper:"k-widget k-tooltip k-popup k-group k-reset",tooltipContent:"k-tooltip-content",tooltipCallout:"k-callout k-callout-s",callout:"k-callout",marquee:"k-marquee k-gantt-marquee",marqueeColor:"k-marquee-color"},E=kendo.ui.GanttView=r.extend({init:function(e,t){r.fn.init.call(this,e,t),this.title=this.options.title||this.options.name,this.header=this.element.find(H+E.styles.gridHeader),this.content=this.element.find(H+E.styles.gridContent),this.contentWidth=this.content.width(),this._workDays=s(this.options),this._headerTree=t.headerTree,this._taskTree=t.taskTree,this._taskTemplate=t.taskTemplate?kendo.template(t.taskTemplate,p({},kendo.Template,t.templateSettings)):null,this._dependencyTree=t.dependencyTree,this._taskCoordinates={},this._currentTime()},destroy:function(){r.fn.destroy.call(this),clearTimeout(this._tooltipTimeout),this.headerRow=null,this.header=null,this.content=null,this._dragHint=null,this._resizeHint=null,this._resizeTooltip=null,this._taskTooltip=null,this._percentCompleteResizeTooltip=null,this._headerTree=null,this._taskTree=null,this._dependencyTree=null},options:{showWorkHours:!1,showWorkDays:!1,workDayStart:new Date(1980,1,1,8,0,0),workDayEnd:new Date(1980,1,1,17,0,0),workWeekStart:1,workWeekEnd:5,hourSpan:1,slotSize:100,currentTimeMarker:{updateInterval:1e4}},renderLayout:function(){this._slots=this._createSlots(),this._tableWidth=this._calculateTableWidth(),this.createLayout(this._layout()),this._slotDimensions(),this._adjustHeight(),this.content.find(H+E.styles.dependenciesWrapper).width(this._tableWidth)},_adjustHeight:function(){this.content.height(this.element.height()-this.header.outerHeight())},createLayout:function(e){var t=this._headers(e),s=this._colgroup(),i=this._headerTree,n=o("thead",null,t),a=o("table",{style:{width:this._tableWidth+"px"}},[s,n]);i.render([a]),this.headerRow=this.header.find("table:first tr").last()},_slotDimensions:function(){var e,t,s,i,n=this.headerRow[0].children,a=this._timeSlots();for(s=0,i=n.length;i>s;s++)t=n[s],e=a[s],e.offsetLeft=t.offsetLeft,e.offsetWidth=t.offsetWidth},render:function(e){var t,s,i=e.length,n=E.styles,a=this._rowsTable(i),r=this._columnsTable(i),o=this._tasksTable(e),l=this.options.currentTimeMarker,d=this.options.calculatedSize;this._taskTree.render([a,r,o]),t=this.content.find(H+n.rowsTable),d&&(s=d.row*e.length,this.content.find(H+n.tasksTable).height(s),t.height(s)),this._contentHeight=t.height(),this._rowHeight=d?d.row:this._contentHeight/t.find("tr").length,this.content.find(H+n.columnsTable).height(this._contentHeight),l!==!1&&void 0!==l.updateInterval&&this._renderCurrentTime()},_rowsTable:function(e){var t,s,i=[],n=E.styles,a=[null,{className:n.alt}];for(s=0;e>s;s++)t=o("tr",a[s%2],[o("td",null,[l(" ")])]),i.push(t);return this._createTable(1,i,{className:n.rowsTable})},_columnsTable:function(){var e,t,s,i,n,a=[],r=E.styles,d=this._timeSlots(),h=d.length,p=0;for(n=0;h>n;n++)t=d[n],i={},s=t.span,p+=s,1!==s&&(i.colspan=s),t.isNonWorking&&(i.className=r.nonWorking),a.push(o("td",i,[l(" ")]));return e=o("tr",null,a),this._createTable(p,[e],{className:r.columnsTable})},_tasksTable:function(e){var t,s,i,n,a,r,l,d,h=[],p=E.styles,c=this._taskCoordinates={},u=this._calculateMilestoneWidth(),g=Math.round(u.width),f=this.options.resourcesField,m=[p.resource,p.resourceAlt],_=this.options.calculatedSize,v=this._calculateResourcesMargin(),y=this._calculateTaskBorderWidth(),w=function(e){var t=i.left,s=t+i.width;n.isMilestone()&&(t-=g/2,s=t+g),c[n.id]={start:t,end:s,rowIndex:e}};for(l=0,d=e.length;d>l;l++)n=e[l],i=this._taskPosition(n),i.borderWidth=y,t=o("tr",null),s=o("td",null,[this._renderTask(e[l],i)]),n[f]&&n[f].length&&(a=k?this._tableWidth-i.left:Math.max(i.width||u.clientWidth,0)+i.left,r={width:this._tableWidth-(a+v)+"px"},r[k?"right":"left"]=a+"px",_&&(r.height=_.cell+"px"),s.children.push(o("div",{className:p.resourcesWrap,style:r},this._renderResources(n[f],m[l%2])))),t.children.push(s),h.push(t),w(l);return this._createTable(1,h,{className:E.styles.tasksTable})},_createTable:function(e,t,s){var i,n,a,r=[];for(a=0;e>a;a++)r.push(o("col"));return i=o("colgroup",null,r),n=o("tbody",null,t),s.style||(s.style={}),s.style.width=this._tableWidth+"px",o("table",s,[i,n])},_calculateTableWidth:function(){var e,t,s,i,n=this._timeSlots(),a=0,r=0;for(s=0,i=n.length;i>s;s++)e=n[s].span,r+=e,e>a&&(a=e);return t=Math.round(r*this.options.slotSize/a)},_calculateMilestoneWidth:function(){var t,s,i=E.styles.task+" "+E.styles.taskMilestone,n=e("<div class='"+i+"' style='visibility: hidden; position: absolute'>");return this.content.append(n),s=n[0].getBoundingClientRect(),t={width:s.right-s.left,clientWidth:n[0].clientWidth},n.remove(),t},_calculateResourcesMargin:function(){var t,s=e("<div class='"+E.styles.resourcesWrap+"' style='visibility: hidden; position: absolute'>");return this.content.append(s),t=parseInt(s.css(k?"margin-right":"margin-left"),10),s.remove(),t},_calculateTaskBorderWidth:function(){var t,s,i=E.styles.task+" "+E.styles.taskSingle,n=e("<div class='"+i+"' style='visibility: hidden; position: absolute'>");return this.content.append(n),s=kendo.getComputedStyles(n[0],["border-left-width"]),t=parseFloat(s["border-left-width"],10),n.remove(),t},_renderTask:function(e,t){var s,i,n,a=this.options.editable,r=t.left,l=E.styles,d=l.taskWrap,h=this.options.calculatedSize,p={},c={className:d,style:{left:r+"px"}};return h&&(c.style.height=h.cell+"px"),e.summary?i=this._renderSummary(e,t):e.isMilestone()?(i=this._renderMilestone(e,t),c.className+=" "+l.taskMilestoneWrap):i=this._renderSingleTask(e,t),s=o("div",c,[i]),a&&(s.children.push(o("div",{className:l.taskDot+" "+l.taskDotStart})),s.children.push(o("div",{className:l.taskDot+" "+l.taskDotEnd}))),e.summary||e.isMilestone()||!a||null!==this._taskTemplate||(n=Math.round(t.width*e.percentComplete),p[k?"right":"left"]=n+"px",s.children.push(o("div",{className:l.taskDragHandle,style:p}))),s},_renderSingleTask:function(e,t){var s,i,n,a=E.styles,r=Math.round(t.width*e.percentComplete),h=[];return null!==this._taskTemplate?s=d(this._taskTemplate(e)):(s=l(e.title),h.push(o("div",{className:a.taskComplete,style:{width:r+"px"}}))),i=o("div",{className:a.taskContent},[o("div",{className:a.taskTemplate},[s])]),h.push(i),this.options.editable&&(i.children.push(o("span",{className:a.taskActions},[o("a",{className:a.link+" "+a.taskDelete,href:"#"},[o("span",{className:a.icon+" "+a.iconDelete})])])),i.children.push(o("span",{className:a.taskResizeHandle+" "+a.taskResizeHandleWest})),i.children.push(o("span",{className:a.taskResizeHandle+" "+a.taskResizeHandleEast}))),n=o("div",{className:a.task+" "+a.taskSingle,"data-uid":e.uid,style:{width:Math.max(t.width-2*t.borderWidth,0)+"px"}},h)},_renderMilestone:function(e){var t=E.styles,s=o("div",{className:t.task+" "+t.taskMilestone,"data-uid":e.uid});return s},_renderSummary:function(e,t){var s=E.styles,i=Math.round(t.width*e.percentComplete),n=o("div",{className:s.task+" "+s.taskSummary,"data-uid":e.uid,style:{width:t.width+"px"}},[o("div",{className:s.taskSummaryProgress,style:{width:i+"px"}},[o("div",{className:s.taskSummaryComplete,style:{width:t.width+"px"}})])]);return n},_renderResources:function(e,t){var s,i,n,a=[];for(i=0,n=e.length;n>i;i++)s=e[i],a.push(o("span",{className:t,style:{color:s.get("color")}},[l(s.get("name"))]));return k&&a.reverse(),a},_taskPosition:function(e){var t=Math.round,s=t(this._offset(k?e.end:e.start)),i=t(this._offset(k?e.start:e.end));return{left:s,width:i-s}},_offset:function(e){var t,s,i,n,a=this._timeSlots(),r=0;return a.length?(n=this._slotIndex("start",e),t=a[n],e>t.end?r=t.offsetWidth:e>=t.start&&(s=e-t.start,i=t.end-t.start,r=s/i*t.offsetWidth),k&&(r=t.offsetWidth+1-r),t.offsetLeft+r):0},_slotIndex:function(e,t,s){var i,n=this._timeSlots(),a=0,r=n.length-1;s&&(n=[].slice.call(n).reverse());do i=Math.ceil((r+a)/2),t>n[i][e]?a=i:(i===r&&i--,r=i);while(a!==r);return s&&(a=n.length-1-a),a},_timeByPosition:function(t,s,i){var n,a,r,o=this._slotByPosition(t);return s?i?o.end:o.start:(n=t-e(H+E.styles.tasksTable).offset().left,a=o.end-o.start,r=n-o.offsetLeft,k&&(r=o.offsetWidth-r),new Date(o.start.getTime()+a*(r/o.offsetWidth)))},_slotByPosition:function(t){var s=t-e(H+E.styles.tasksTable).offset().left,i=this._slotIndex("offsetLeft",s,k);return this._timeSlots()[i]},_renderDependencies:function(e){var t,s,i=[],n=this._dependencyTree;for(t=0,s=e.length;s>t;t++)i.push.apply(i,this._renderDependency(e[t]));n.render(i)},_renderDependency:function(e){var t,s,i,n,a=this._taskCoordinates[e.predecessorId],r=this._taskCoordinates[e.successorId];if(!a||!r)return[];for(s="_render"+["FF","FS","SF","SS"][k?3-e.type:e.type],t=this[s](a,r),i=0,n=t.length;n>i;i++)t[i].attr["data-uid"]=e.uid;return t},_renderFF:function(e,t){var s=this._dependencyFF(e,t,!1);return s[s.length-1].children[0]=this._arrow(!0),s},_renderSS:function(e,t){var s=this._dependencyFF(t,e,!0);return s[0].children[0]=this._arrow(!1),s.reverse()},_renderFS:function(e,t){var s=this._dependencyFS(e,t,!1);return s[s.length-1].children[0]=this._arrow(!1),s},_renderSF:function(e,t){var s=this._dependencyFS(t,e,!0);return s[0].children[0]=this._arrow(!0),s.reverse()},_dependencyFF:function(e,t,s){var i,n=this,a=[],r=0,o=0,l=0,d=0,h=s?"start":"end",p=2,c=1,u=this._rowHeight,k=10,g=e.rowIndex*u+Math.floor(u/2)-1,f=t.rowIndex*u+Math.floor(u/2)-1,m=E.styles,_=function(){a.push(n._line(m.line+" "+m.lineHorizontal,{left:r+"px",top:o+"px",width:l+"px"}))},v=function(){a.push(n._line(m.line+" "+m.lineVertical,{left:r+"px",top:o+"px",height:d+"px"}))};return r=e[h],o=g,l=k,i=t[h]-e[h],i>0!==s&&(l=Math.abs(i)+k),s?(r-=l,l-=c,_()):(_(),r+=l-p),o>f?(d=o-f,d+=p,o=f,v()):(d=f-o,d+=p,v(),o+=d-p),l=Math.abs(r-t[h]),s||(l-=c,r-=l),_(),a},_dependencyFS:function(e,t,s){var i=this,n=[],a=0,r=0,o=0,l=0,d=this._rowHeight,h=Math.floor(d/2),p=10,c=2*p,u=t.start-e.end,k=2,g=1,f=e.rowIndex*d+Math.floor(d/2)-1,m=t.rowIndex*d+Math.floor(d/2)-1,_=E.styles,v=function(){n.push(i._line(_.line+" "+_.lineHorizontal,{left:a+"px",top:r+"px",width:o+"px"}))},y=function(){n.push(i._line(_.line+" "+_.lineVertical,{left:a+"px",top:r+"px",height:l+"px"}))};return a=e.end,r=f,o=p,s&&(a+=g,u>c&&(o=u-(p-k)),o-=g),v(),a+=o-k,c>=u&&(l=s?Math.abs(m-f)-h:h,f>m?(r-=l,l+=k,y()):(y(),r+=l),o=e.end-t.start+c,p>o&&(o=p),a-=o-k,v()),f>m?(l=r-m,r=m,l+=k,y()):(l=m-r,y(),r+=l),o=t.start-a,s||(o-=g),v(),n},_line:function(e,t){return o("div",{className:e,style:t})},_arrow:function(e){return o("span",{className:e?E.styles.arrowWest:E.styles.arrowEast})},_colgroup:function(){var e,t,s,i=this._timeSlots(),n=i.length,a=[];for(e=0;n>e;e++)for(t=0,s=i[e].span;s>t;t++)a.push(o("col"));return o("colgroup",null,a)},_createDragHint:function(e){this._dragHint=e.clone().addClass(E.styles.dragHint).css("cursor","move"),e.parent().append(this._dragHint)},_updateDragHint:function(e){var t=this._offset(e);this._dragHint.css({left:t})},_removeDragHint:function(){this._dragHint.remove(),this._dragHint=null},_createResizeHint:function(t){var s,i,n=E.styles,a=this._taskCoordinates[t.id].rowIndex*this._rowHeight,r=this.options,o=r.messages;this._resizeHint=e(C({styles:n})).css({top:0,height:this._contentHeight}),this.content.append(this._resizeHint),this._resizeTooltip=e(P({styles:n,start:t.start,end:t.end,messages:o.views,format:r.resizeTooltipFormat})).css({top:0,left:0}),this.content.append(this._resizeTooltip),this._resizeTooltipWidth=this._resizeTooltip.outerWidth(),s=this._resizeTooltip.outerHeight(),i=a-s,0>i&&(i=a+this._rowHeight),this._resizeTooltipTop=i},_updateResizeHint:function(t,s,i){var n=this._offset(k?s:t),a=this._offset(k?t:s),r=a-n,o=i!==k?n:a,l=this._tableWidth-kendo.support.scrollbar(),d=this._resizeTooltipWidth,h=this.options,p=h.messages,c=e(H+E.styles.tasksTable).offset().left-e(H+E.styles.tasksWrapper).offset().left;k&&(n+=c),this._resizeHint.css({left:n,width:r}),this._resizeTooltip&&this._resizeTooltip.remove(),o-=Math.round(d/2),0>o?o=0:o+d>l&&(o=l-d),k&&(o+=c),this._resizeTooltip=e(P({styles:E.styles,start:t,end:s,messages:p.views,format:h.resizeTooltipFormat})).css({top:this._resizeTooltipTop,left:o,"min-width":d}).appendTo(this.content)},_removeResizeHint:function(){this._resizeHint.remove(),this._resizeHint=null,this._resizeTooltip.remove(),this._resizeTooltip=null},_updatePercentCompleteTooltip:function(t,s,i){var n,a,r,o;this._removePercentCompleteTooltip(),n=this._percentCompleteResizeTooltip=e(I({styles:E.styles,text:i})).appendTo(this.element),a=Math.round(n.outerWidth()/2),r=n.find(H+E.styles.callout),o=Math.round(r.outerWidth()/2),n.css({top:t-(n.outerHeight()+o),left:s-a}),r.css("left",a-o)},_removePercentCompleteTooltip:function(){this._percentCompleteResizeTooltip&&this._percentCompleteResizeTooltip.remove(),this._percentCompleteResizeTooltip=null},_updateDependencyDragHint:function(e,t,s){this._removeDependencyDragHint(),s?this._creteVmlDependencyDragHint(e,t):this._creteDependencyDragHint(e,t)},_creteDependencyDragHint:function(t,s){var i=E.styles,n=s.x-t.x,a=s.y-t.y,r=Math.sqrt(n*n+a*a),o=Math.atan(a/n);0>n&&(o+=Math.PI),e("<div class='"+i.line+" "+i.lineHorizontal+" "+i.dependencyHint+"'></div>").css({top:t.y,left:t.x,width:r,"transform-origin":"0% 0","-ms-transform-origin":"0% 0","-webkit-transform-origin":"0% 0",transform:"rotate("+o+"rad)","-ms-transform":"rotate("+o+"rad)","-webkit-transform":"rotate("+o+"rad)"}).appendTo(this.content)},_creteVmlDependencyDragHint:function(t,s){var i=e("<kvml:line class='"+E.styles.dependencyHint+"' style='position:absolute; top: 0px; left: 0px;' strokecolor='black' strokeweight='2px' from='"+t.x+"px,"+t.y+"px' to='"+s.x+"px,"+s.y+"px'></kvml:line>").appendTo(this.content);i[0].outerHTML=i[0].outerHTML},_removeDependencyDragHint:function(){this.content.find(H+E.styles.dependencyHint).remove()},_createTaskTooltip:function(t,s,i){var n,a=E.styles,r=this.options,o=this.content,l=o.offset(),d=o.width(),h=kendo.scrollLeft(o),p=e(s).parents("tr").first(),c=p.offset(),u=r.tooltip&&r.tooltip.template?kendo.template(r.tooltip.template):N,g=k?i-(l.left+h+kendo.support.scrollbar()):i-(l.left-h),f=c.top+p.outerHeight()-l.top+o.scrollTop(),m=this._taskTooltip=e('<div style="z-index: 100002;" class="'+a.tooltipWrapper+'" ><div class="'+a.taskContent+'"></div></div>');m.css({left:g,top:f}).appendTo(o).find(H+a.taskContent).append(u({styles:a,task:t,messages:r.messages.views})),m.outerHeight()<c.top-l.top&&m.css("top",c.top-l.top-m.outerHeight()+o.scrollTop()),n=m.outerWidth(),n+g-h>d&&(g-=n,h>g&&(g=h+d-(n+17)),m.css("left",g))},_removeTaskTooltip:function(){this._taskTooltip&&this._taskTooltip.remove(),this._taskTooltip=null},_scrollTo:function(e){var t=e.offset().left,s=e.width(),i=t+s,n=e.closest("tr"),a=n.offset().top,r=n.height(),o=a+r,l=this.content,d=l.offset(),h=d.top,p=l.height(),c=h+p,u=d.left,k=l.width(),g=u+k,f=kendo.support.scrollbar();h>a?l.scrollTop(l.scrollTop()+(a-h)):o>c&&l.scrollTop(l.scrollTop()+(o+f-c)),u>t&&s>k&&g>i||i>g&&k>s?l.scrollLeft(l.scrollLeft()+(i+f-g)):(i>g&&s>k&&t>u||u>t&&k>s)&&l.scrollLeft(l.scrollLeft()+(t-u))},_timeSlots:function(){return this._slots&&this._slots.length?this._slots[this._slots.length-1]:[]},_headers:function(e){var t,s,i,n,a,r,d,h,p=[],c=E.styles;for(a=0,r=e.length;r>a;a++){for(t=e[a],s=[],d=0,h=t.length;h>d;d++)i=t[d],n=l(i.text),s.push(o("th",{colspan:i.span,className:c.header+(i.isNonWorking?" "+c.nonWorking:"")},[n]));p.push(o("tr",null,s))}return p},_hours:function(e,t){var s,i,n,a=[],r=this.options,o=r.workDayStart.getHours(),l=r.workDayEnd.getHours(),d=r.hourSpan;for(e=new Date(e),t=new Date(t);t>e;)s=new Date(e),n=s.getHours(),i=n>=o&&l>n,s.setHours(s.getHours()+d),n==s.getHours()&&s.setHours(s.getHours()+2*d),(!r.showWorkHours||i)&&a.push({start:e,end:s,isNonWorking:!i,span:1}),e=s;return a},_days:function(e,t){var s,i,n=[];for(e=new Date(e),t=new Date(t);t>e;)s=kendo.date.nextDay(e),i=this._isWorkDay(e),(!this.options.showWorkDays||i)&&n.push({start:e,end:s,isNonWorking:!i,span:1}),e=s;return n},_weeks:function(e,t){var s,i,n,a=[],r=this.calendarInfo().firstDay;for(e=new Date(e),t=new Date(t);t>e;)s=kendo.date.dayOfWeek(kendo.date.addDays(e,1),r,1),s>t&&(s=t),i=this._days(e,s),n=i.length,n>0&&a.push({start:i[0].start,end:i[n-1].end,span:n}),e=s;return a},_months:function(e,t){var s,i,n,a=[];for(e=new Date(e),t=new Date(t);t>e;)s=new Date(e),s.setMonth(s.getMonth()+1),i=this._days(e,s),n=i.length,n>0&&a.push({start:i[0].start,end:i[n-1].end,span:n}),e=s;return a},_years:function(e,t){var s,i=[];for(e=new Date(e),t=new Date(t);t>e;)s=new Date(e),s.setFullYear(s.getFullYear()+1),i.push({start:e,end:s,span:12}),e=s;return i},_slotHeaders:function(e,t){var s,i,n,a=[];for(i=0,n=e.length;n>i;i++)s=e[i],a.push({text:t(s),isNonWorking:!!s.isNonWorking,span:s.span});return a},_isWorkDay:function(e){var t,s,i=e.getDay(),n=this._workDays;for(t=0,s=n.length;s>t;t++)if(n[t]===i)return!0;return!1},calendarInfo:function(){return kendo.getCulture().calendars.standard},_renderCurrentTime:function(){var t,s=this._getCurrentTime(),i=this._offset(s),n=e("<div class='k-current-time'></div>"),a=E.styles,r=e(H+a.tasksWrapper),o=e(H+a.tasksTable);this.content&&this._timeSlots().length&&(this.content.find(".k-current-time").remove(),t=this._timeSlots()[this._slotIndex("start",s)],t.start>s||s>t.end||(r.length&&o.length&&(i+=o.offset().left-r.offset().left),n.css({left:i+"px",top:"0px",width:"1px",height:this._contentHeight+"px"}).appendTo(this.content)))},_getCurrentTime:function(){return new Date},_currentTime:function(){var e=this.options.currentTimeMarker;e!==!1&&void 0!==e.updateInterval&&(this._renderCurrentTime(),this._currentTimeUpdateTimer=setInterval(c(this._renderCurrentTime,this),e.updateInterval))}});p(!0,E,{styles:F}),kendo.ui.GanttDayView=E.extend({name:"day",options:{timeHeaderTemplate:W,dayHeaderTemplate:x,resizeTooltipFormat:"h:mm tt ddd, MMM d"},range:function(e){this.start=kendo.date.getDate(e.start),this.end=kendo.date.getDate(e.end),(kendo.date.getMilliseconds(e.end)>0||this.end.getTime()===this.start.getTime())&&(this.end=kendo.date.addDays(this.end,1))},_createSlots:function(){var e,t,s,i,n=[],a=this._days(this.start,this.end),r=[];for(s=0,i=a.length;i>s;s++)e=a[s],t=this._hours(e.start,e.end),e.span=t.length,r.push.apply(r,t);return n.push(a),n.push(r),n},_layout:function(){var e=[],t=this.options;return e.push(this._slotHeaders(this._slots[0],kendo.template(t.dayHeaderTemplate))),e.push(this._slotHeaders(this._slots[1],kendo.template(t.timeHeaderTemplate))),e}}),kendo.ui.GanttWeekView=E.extend({name:"week",options:{dayHeaderTemplate:x,weekHeaderTemplate:z,resizeTooltipFormat:"h:mm tt ddd, MMM d"},range:function(e){var t=this.calendarInfo(),s=t.firstDay,i=e.end;s===i.getDay()&&i.setDate(i.getDate()+7),this.start=kendo.date.getDate(kendo.date.dayOfWeek(e.start,s,-1)),this.end=kendo.date.getDate(kendo.date.dayOfWeek(i,s,1))},_createSlots:function(){var e=[];return e.push(this._weeks(this.start,this.end)),e.push(this._days(this.start,this.end)),e},_layout:function(){var e=[],t=this.options;return e.push(this._slotHeaders(this._slots[0],kendo.template(t.weekHeaderTemplate))),e.push(this._slotHeaders(this._slots[1],kendo.template(t.dayHeaderTemplate))),e}}),kendo.ui.GanttMonthView=E.extend({name:"month",options:{weekHeaderTemplate:z,monthHeaderTemplate:S,resizeTooltipFormat:"dddd, MMM d, yyyy"},range:function(e){this.start=kendo.date.firstDayOfMonth(e.start),this.end=kendo.date.addDays(kendo.date.getDate(kendo.date.lastDayOfMonth(e.end)),1)},_createSlots:function(){var e=[];return e.push(this._months(this.start,this.end)),e.push(this._weeks(this.start,this.end)),e},_layout:function(){var e=[],t=this.options;return e.push(this._slotHeaders(this._slots[0],kendo.template(t.monthHeaderTemplate))),e.push(this._slotHeaders(this._slots[1],kendo.template(t.weekHeaderTemplate))),e}}),kendo.ui.GanttYearView=E.extend({name:"year",options:{yearHeaderTemplate:M,monthHeaderTemplate:S,resizeTooltipFormat:"dddd, MMM d, yyyy"},range:function(e){this.start=kendo.date.firstDayOfMonth(new Date(e.start.setMonth(0))),this.end=kendo.date.firstDayOfMonth(new Date(e.end.setMonth(12)))},_createSlots:function(){var t=[],s=this._months(this.start,this.end);return e(s).each(function(e,t){t.span=1}),t.push(this._years(this.start,this.end)),t.push(s),t},_layout:function(){var e=[],t=this.options;return e.push(this._slotHeaders(this._slots[0],kendo.template(t.yearHeaderTemplate))),e.push(this._slotHeaders(this._slots[1],kendo.template(t.monthHeaderTemplate))),e}}),n={wrapper:"k-timeline k-grid k-widget",gridHeader:"k-grid-header",gridHeaderWrap:"k-grid-header-wrap",gridContent:"k-grid-content",gridContentWrap:"k-grid-content",tasksWrapper:"k-gantt-tables",dependenciesWrapper:"k-gantt-dependencies",task:"k-task",line:"k-line",taskResizeHandle:"k-resize-handle",taskResizeHandleWest:"k-resize-w",taskDragHandle:"k-task-draghandle",taskComplete:"k-task-complete",taskDelete:"k-task-delete",taskWrapActive:"k-task-wrap-active",taskWrap:"k-task-wrap",taskDot:"k-task-dot",taskDotStart:"k-task-start",taskDotEnd:"k-task-end",hovered:"k-state-hover",selected:"k-state-selected",origin:"k-origin"},a=kendo.ui.GanttTimeline=r.extend({init:function(e,t){r.fn.init.call(this,e,t),this.options.views&&this.options.views.length||(this.options.views=["day","week","month"]),k=kendo.support.isRtl(e),this._wrapper(),this._domTrees(),this._views(),this._selectable(),this._draggable(),this._resizable(),this._percentResizeDraggable(),this._createDependencyDraggable(),this._attachEvents(),this._tooltip()},options:{name:"GanttTimeline",messages:{views:{day:"Day",week:"Week",month:"Month",year:"Year",start:"Start",end:"End"}},snap:!0,selectable:!0,editable:!0},destroy:function(){r.fn.destroy.call(this),clearTimeout(this._tooltipTimeout),this._currentTimeUpdateTimer&&clearInterval(this._currentTimeUpdateTimer),this._unbindView(this._selectedView),this._moveDraggable&&this._moveDraggable.destroy(),this._resizeDraggable&&this._resizeDraggable.destroy(),this._percentDraggable&&this._percentDraggable.destroy(),this._dependencyDraggable&&this._dependencyDraggable.destroy(),this.touch&&this.touch.destroy(),this._headerTree=null,this._taskTree=null,this._dependencyTree=null,this.wrapper.off(_),kendo.destroy(this.wrapper)},_wrapper:function(){var t=a.styles,s=this,i=this.options,n=function(){var n,a,r=typeof i.rowHeight===m?i.rowHeight:i.rowHeight+"px",o=e(kendo.format(R,r)),l=s.wrapper.find(H+t.tasksWrapper);return l.append(o),n=o.find("tr").outerHeight(),a=o.find("td").height(),o.remove(),{row:n,cell:a}};this.wrapper=this.element.addClass(t.wrapper).append("<div class='"+t.gridHeader+"'><div class='"+t.gridHeaderWrap+"'></div></div>").append("<div class='"+t.gridContentWrap+"'><div class='"+t.tasksWrapper+"'></div><div class='"+t.dependenciesWrapper+"'></div></div>"),i.rowHeight&&(this._calculatedSize=n())},_domTrees:function(){var e=a.styles,t=kendo.dom.Tree,s=this.wrapper;this._headerTree=new t(s.find(H+e.gridHeaderWrap)[0]),this._taskTree=new t(s.find(H+e.tasksWrapper)[0]),this._dependencyTree=new t(s.find(H+e.dependenciesWrapper)[0])},_views:function(){var e,t,s,i,n,a,r,o=this.options.views;for(this.views={},a=0,r=o.length;r>a;a++)e=o[a],t=h(e),t&&e.selectable===!1||(s=t?"string"!=typeof e.type?e.title:e.type:e,i=V[s],i&&(t&&(e.type=i.type),i.title=this.options.messages.views[s]),e=p({title:s},i,t?e:{}),s&&(this.views[s]=e,(!n||e.selected)&&(n=s)));n&&(this._selectedViewName=n)},view:function(e){return e&&(this._selectView(e),this.trigger("navigate",{view:e,action:"changeView"})),this._selectedView},_selectView:function(e){e&&this.views[e]&&(this._selectedView&&this._unbindView(this._selectedView),this._selectedView=this._initializeView(e),this._selectedViewName=e)},_viewByIndex:function(e){var t,s=this.views;for(t in s){if(!e)return t;e--}},_initializeView:function(e){var s,i=this.views[e];if(i){if(s=i.type,"string"==typeof s&&(s=kendo.getter(i.type)(window)),!s)throw Error("There is no such view");i=new s(this.wrapper,t(p(!0,{headerTree:this._headerTree,taskTree:this._taskTree,dependencyTree:this._dependencyTree,calculatedSize:this._calculatedSize},i,this.options)))}return i},_unbindView:function(e){e&&e.destroy()},_range:function(e){var t,s,i={field:"start",dir:"asc"},n={field:"end",dir:"desc"};return e&&e.length?(t=new f(e).sort(i).toArray()[0].start||new Date,s=new f(e).sort(n).toArray()[0].end||new Date,{start:new Date(t),end:new Date(s)}):{start:new Date,end:new Date}},_render:function(e){var t=this.view(),s=this._range(e);this._tasks=e,t.range(s),t.renderLayout(),t.render(e)},_renderDependencies:function(e){this.view()._renderDependencies(e)},_taskByUid:function(e){var t,s,i=this._tasks,n=i.length;for(s=0;n>s;s++)if(t=i[s],t.uid===e)return t},_draggable:function(){var e,t,s,n,r=this,o=this.options.snap,l=a.styles,d=function(){r.view()._removeDragHint(),e&&e.css("opacity",1),e=null,t=null,r.dragInProgress=!1};this.options.editable&&(this._moveDraggable=new kendo.ui.Draggable(this.wrapper,{distance:0,filter:H+l.task,holdToDrag:kendo.support.mobileOS,ignore:H+l.taskResizeHandle}),this._moveDraggable.bind("dragstart",function(i){var a=r.view();return e=i.currentTarget.parent(),t=r._taskByUid(i.currentTarget.attr("data-uid")),r.trigger("moveStart",{task:t})?void i.preventDefault():(s=t.start,n=a._timeByPosition(i.x.location,o)-s,a._createDragHint(e),e.css("opacity",.5),clearTimeout(r._tooltipTimeout),void(r.dragInProgress=!0))}).bind("drag",kendo.throttle(function(e){var i,a,l;r.dragInProgress&&(i=r.view(),a=new Date(i._timeByPosition(e.x.location,o)-n),l=a,r.trigger("move",{task:t,start:a})||(s=a,k&&(l=new Date(s.getTime()+t.duration())),i._updateDragHint(l)))},15)).bind("dragend",function(){r.trigger("moveEnd",{task:t,start:s}),d()}).bind("dragcancel",function(){d()}).userEvents.bind("select",function(){i()}))},_resizable:function(){var e,t,s,n,r,o=this,l=this.options.snap,d=a.styles,h=function(){o.view()._removeResizeHint(),e=null,t=null,o.dragInProgress=!1};this.options.editable&&(this._resizeDraggable=new kendo.ui.Draggable(this.wrapper,{distance:0,filter:H+d.taskResizeHandle,holdToDrag:!1}),this._resizeDraggable.bind("dragstart",function(i){return r=i.currentTarget.hasClass(d.taskResizeHandleWest),k&&(r=!r),e=i.currentTarget.closest(H+d.task),t=o._taskByUid(e.attr("data-uid")),o.trigger("resizeStart",{task:t})?void i.preventDefault():(s=t.start,n=t.end,o.view()._createResizeHint(t),clearTimeout(o._tooltipTimeout),void(o.dragInProgress=!0))}).bind("drag",kendo.throttle(function(e){var i,a;o.dragInProgress&&(i=o.view(),a=i._timeByPosition(e.x.location,l,!r),r?s=n>a?a:n:n=a>s?a:s,o.trigger("resize",{task:t,start:s,end:n})||i._updateResizeHint(s,n,r))},15)).bind("dragend",function(){o.trigger("resizeEnd",{task:t,resizeStart:r,start:s,end:n}),h()}).bind("dragcancel",function(){h()}).userEvents.bind("select",function(){i()}))},_percentResizeDraggable:function(){var e,t,s,n,r,o,l,d,h,p,c=this,u=a.styles,g=function(){c.view()._removePercentCompleteTooltip(),t=null,e=null,c.dragInProgress=!1},f=function(e){t.find(H+u.taskComplete).width(e).end().siblings(H+u.taskDragHandle).css(k?"right":"left",e)};this.options.editable&&(this._percentDraggable=new kendo.ui.Draggable(this.wrapper,{distance:0,filter:H+u.taskDragHandle,holdToDrag:!1}),this._percentDraggable.bind("dragstart",function(i){return c.trigger("percentResizeStart")?void i.preventDefault():(t=i.currentTarget.siblings(H+u.task),e=c._taskByUid(t.attr("data-uid")),l=e.percentComplete,s=t.offset(),n=this.element.offset(),r=t.find(H+u.taskComplete).width(),o=t.outerWidth(),clearTimeout(c._tooltipTimeout),void(c.dragInProgress=!0))}).bind("drag",kendo.throttle(function(e){if(c.dragInProgress){p=k?-e.x.initialDelta:e.x.initialDelta;var t=Math.max(0,Math.min(o,r+p));l=Math.round(t/o*100),f(t),d=s.top-n.top,h=s.left+t-n.left,k&&(h+=o-2*t),c.view()._updatePercentCompleteTooltip(d,h,l)}},15)).bind("dragend",function(){c.trigger("percentResizeEnd",{task:e,percentComplete:l/100}),g()}).bind("dragcancel",function(){f(r),g()}).userEvents.bind("select",function(){i()}))},_createDependencyDraggable:function(){var t,s,n,r=this,o=e(),l=e(),d=u.msie&&9>u.version,h=a.styles,p=function(){t.css("display","").removeClass(h.hovered),t.parent().removeClass(h.origin),t=null,c(!1),l=e(),o=e(),r.view()._removeDependencyDragHint(),r.dragInProgress=!1},c=function(e){l.hasClass(h.origin)||(l.find(H+h.taskDot).css("display",e?"block":""),o.toggleClass(h.hovered,e))};this.options.editable&&(d&&document.namespaces&&document.namespaces.add("kvml","urn:schemas-microsoft-com:vml","#default#VML"),
this._dependencyDraggable=new kendo.ui.Draggable(this.wrapper,{distance:0,filter:H+h.taskDot,holdToDrag:!1}),this._dependencyDraggable.bind("dragstart",function(e){var i,a;return r.trigger("dependencyDragStart")?void e.preventDefault():(t=e.currentTarget.css("display","block").addClass(h.hovered),t.parent().addClass(h.origin),i=t.offset(),a=r.wrapper.find(H+h.tasksWrapper).offset(),s=Math.round(i.left-a.left+t.outerHeight()/2),n=Math.round(i.top-a.top+t.outerWidth()/2),clearTimeout(r._tooltipTimeout),void(r.dragInProgress=!0))}).bind("drag",kendo.throttle(function(t){var i,a,p,u;r.dragInProgress&&(r.view()._removeDependencyDragHint(),i=e(kendo.elementUnderCursor(t)),a=r.wrapper.find(H+h.tasksWrapper).offset(),p=t.x.location-a.left,u=t.y.location-a.top,r.view()._updateDependencyDragHint({x:s,y:n},{x:p,y:u},d),c(!1),o=i.hasClass(h.taskDot)?i:e(),l=i.closest(H+h.taskWrap),c(!0))},15)).bind("dragend",function(){var e,s,i,n,a;o.length&&(e=t.hasClass(h.taskDotStart),s=o.hasClass(h.taskDotStart),i=e?s?3:2:s?1:0,n=r._taskByUid(t.siblings(H+h.task).attr("data-uid")),a=r._taskByUid(o.siblings(H+h.task).attr("data-uid")),n!==a&&r.trigger("dependencyDragEnd",{type:i,predecessor:n,successor:a})),p()}).bind("dragcancel",function(){p()}).userEvents.bind("select",function(){i()}))},_selectable:function(){var t=this,s=a.styles;this.options.selectable&&this.wrapper.on(v+_,H+s.task,function(s){s.stopPropagation(),s.ctrlKey?t.trigger("clear"):t.trigger("select",{uid:e(this).attr("data-uid")})}).on(v+_,H+s.taskWrap,function(t){t.stopPropagation(),e(this).css("z-index","0");var i=e(document.elementFromPoint(t.clientX,t.clientY));i.hasClass(s.line)&&i.click(),e(this).css("z-index","")}).on(v+_,H+s.tasksWrapper,function(){t.selectDependency().length>0?t.clearSelection():t.trigger("clear")}).on(v+_,H+s.line,function(e){e.stopPropagation(),t.selectDependency(this)})},select:function(e){var t=this.wrapper.find(e),s=a.styles;return t.length?(this.clearSelection(),t.addClass(s.selected),void(kendo.support.mobileOS&&t.parent().addClass(s.taskWrapActive))):this.wrapper.find(H+s.task+H+s.selected)},selectDependency:function(t){var s,i=this.wrapper.find(t),n=a.styles;return i.length?(this.clearSelection(),this.trigger("clear"),s=e(i).attr("data-uid"),void this.wrapper.find(H+n.line+"[data-uid='"+s+"']").addClass(n.selected)):this.wrapper.find(H+n.line+H+n.selected)},clearSelection:function(){var e=a.styles;this.wrapper.find(H+e.selected).removeClass(e.selected),kendo.support.mobileOS&&this.wrapper.find(H+e.taskWrapActive).removeClass(e.taskWrapActive)},_attachEvents:function(){var t=this,s=a.styles;this.options.editable&&(this._tabindex(),this.wrapper.on(v+_,H+s.taskDelete,function(i){t.trigger("removeTask",{uid:e(this).closest(H+s.task).attr("data-uid")}),i.stopPropagation(),i.preventDefault()}).on(b+_,function(e){var s;e.keyCode===g.DELETE&&(s=t.selectDependency(),s.length&&(t.trigger("removeDependency",{uid:s.attr("data-uid")}),t.clearSelection()))}),kendo.support.mobileOS?this.touch=this.wrapper.kendoTouch({filter:H+s.task,doubletap:function(s){t.trigger("editTask",{uid:e(s.touch.currentTarget).attr("data-uid")})}}).data("kendoTouch"):this.wrapper.on(y+_,H+s.task,function(s){t.trigger("editTask",{uid:e(this).attr("data-uid")}),s.stopPropagation(),s.preventDefault()}))},_tooltip:function(){var t,s=this,i=this.options.tooltip,n=a.styles,r=function(e){t=e.clientX};i&&i.visible===!1||(kendo.support.mobileOS?(this.wrapper.on(v+_,H+n.taskDelete,function(e){e.stopPropagation(),s.view()._removeTaskTooltip()}).on(D+_,H+n.task,function(t){var i=e(t.relatedTarget).parents(H+n.taskWrap,H+n.task);0===i.length&&s.view()._removeTaskTooltip()}),this.touch.bind("tap",function(t){var i=t.touch.target,n=s._taskByUid(e(i).attr("data-uid")),a=t.touch.x.client;s.view()._taskTooltip&&s.view()._removeTaskTooltip(),s.view()._createTaskTooltip(n,i,a)}).bind("doubletap",function(){s.view()._removeTaskTooltip()})):this.wrapper.on(T+_,H+n.task,function(){var i=this,n=s._taskByUid(e(this).attr("data-uid"));s.dragInProgress||(s._tooltipTimeout=setTimeout(function(){s.view()._createTaskTooltip(n,i,t)},800),e(this).on(w,r))}).on(D+_,H+n.task,function(){clearTimeout(s._tooltipTimeout),s.view()._removeTaskTooltip(),e(this).off(w,r)}))}}),p(!0,a,{styles:n})}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t,s){(s||t)()});
//# sourceMappingURL=kendo.gantt.timeline.min.js.map