10 lines
46 KiB
JavaScript
10 lines
46 KiB
JavaScript
/*
|
|
* Kendo UI v2015.3.1111 (http://www.telerik.com/kendo-ui)
|
|
* Copyright 2015 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.data.min","./kendo.popup.min","./kendo.window.min","./kendo.resizable.min","./kendo.gantt.list.min","./kendo.gantt.timeline.min","./kendo.grid.min","./kendo.pdf.min"],e)}(function(){return function(e,t){function n(e){return"["+g.attr("uid")+(e?"='"+e+"']":"]")}function i(e){return delete e.name,delete e.prefix,delete e.remove,delete e.edit,delete e.add,delete e.navigate,e}function o(e){var t,n,i,o,r,s;if(e.filter("[name=end], [name=start]").length){for(t=e.attr("name"),n=g.widgetInstance(e,g.ui),i={},o=e;o!==window&&!r;)o=o.parent(),r=o.data("kendoEditable");return(s=r?r.options.model:null)?(i.start=s.start,i.end=s.end,i[t]=n?n.value():g.parseDate(e.value()),i.end>=i.start):!0}return!0}function r(t,n){var i=t.parents("["+g.attr("role")+'="gantt"]'),o=[],r=s(i);t.attr(L,0),n&&r.each(function(t,n){o[t]=e(n).scrollTop()});try{t[0].setActive()}catch(a){t[0].focus()}n&&r.each(function(t,n){e(n).scrollTop(o[t])})}function s(t){return e(t).parentsUntil("body").filter(function(e,t){var n=g.getComputedStyles(t,["overflow"]);return"visible"!=n.overflow}).add(window)}var a,l,c,u,h,d,f,p,g=window.kendo,m="matchMedia"in window,v=g.support.browser,_=g.support.mobileOS,w=g.Observable,y=g.ui.Widget,b=g.data.DataSource,x=g.data.ObservableObject,k=g.data.ObservableArray,C=g.data.Query,S=e.isArray,T=e.inArray,A=g.isFunction,D=e.proxy,M=e.extend,E=e.isPlainObject,P=e.map,I=g.keys,R=3,B=".kendoGantt",z="p0",L="tabIndex",F="click",O="width",N="string",V={down:{origin:"bottom left",position:"top left"},up:{origin:"top left",position:"bottom left"}},H="aria-activedescendant",U="gantt_active_cell",j="action-option-focused",W=".",G="Are you sure you want to delete this task?",q="Are you sure you want to delete this dependency?",$=g.template('<button class="#=styles.buttonToggle#"><span class="#=styles.iconToggle#">&nbps;</span></button>'),Y='<button class="#=styles.button# #=className#" #if (action) {#data-action="#=action#"#}#><span class="#=iconClass#"></span><span>#=text#</span></button>',Q='<a class="#=className#" #=attr# href="\\#">#=text#</a>',X=g.template('<li class="#=styles.currentView# #=styles.viewButtonDefault#"><a href="\\#" class="#=styles.link#">&nbps;</a></li>'),K=g.template('<ul class="#=styles.viewsWrapper#">#for(var view in views){#<li class="#=styles.viewButtonDefault# #=styles.viewButton#-#= view.toLowerCase() #" data-#=ns#name="#=view#"><a href="\\#" class="#=styles.link#">#=views[view].title#</a></li>#}#</ul>'),Z=g.template('<div class="#=styles.popupWrapper#"><ul class="#=styles.popupList#" role="listbox">#for(var i = 0, l = actions.length; i < l; i++){#<li class="#=styles.item#" data-action="#=actions[i].data#" role="option">#=actions[i].text#</span>#}#</ul></div>'),J=function(t,n){var i={name:n.field},o=n.model.fields[n.field].validation;o&&E(o)&&o.message&&(i[g.attr("dateCompare-msg")]=o.message),e('<input type="text" required '+g.attr("type")+'="date" '+g.attr("role")+'="datetimepicker" '+g.attr("bind")+'="value:'+n.field+'" '+g.attr("validate")+"='true' />").attr(i).appendTo(t),e("<span "+g.attr("for")+'="'+n.field+'" class="k-invalid-msg"/>').hide().appendTo(t)},ee=function(t,n){e('<a href="#" class="'+n.styles.button+'">'+n.messages.assignButton+"</a>").click(n.click).appendTo(t)},te={wrapper:"k-widget k-gantt",rowHeight:"k-gantt-rowheight",listWrapper:"k-gantt-layout k-gantt-treelist",list:"k-gantt-treelist",timelineWrapper:"k-gantt-layout k-gantt-timeline",timeline:"k-gantt-timeline",splitBarWrapper:"k-splitbar k-state-default k-splitbar-horizontal k-splitbar-draggable-horizontal k-gantt-layout",splitBar:"k-splitbar",splitBarHover:"k-splitbar-horizontal-hover",popupWrapper:"k-list-container",popupList:"k-list k-reset",resizeHandle:"k-resize-handle",icon:"k-icon",item:"k-item",line:"k-line",buttonDelete:"k-gantt-delete",buttonCancel:"k-gantt-cancel",buttonSave:"k-gantt-update",buttonToggle:"k-gantt-toggle",primary:"k-primary",hovered:"k-state-hover",selected:"k-state-selected",focused:"k-state-focused",gridHeader:"k-grid-header",gridHeaderWrap:"k-grid-header-wrap",gridContent:"k-grid-content",popup:{form:"k-popup-edit-form",editForm:"k-gantt-edit-form",formContainer:"k-edit-form-container",resourcesFormContainer:"k-resources-form-container",message:"k-popup-message",buttonsContainer:"k-edit-buttons k-state-default",button:"k-button",editField:"k-edit-field",editLabel:"k-edit-label",resourcesField:"k-gantt-resources"},toolbar:{headerWrapper:"k-floatwrap k-header k-gantt-toolbar",footerWrapper:"k-floatwrap k-header k-gantt-toolbar",toolbar:"k-gantt-toolbar",expanded:"k-state-expanded",views:"k-gantt-views",viewsWrapper:"k-reset k-header k-gantt-views",actions:"k-gantt-actions",button:"k-button k-button-icontext",buttonToggle:"k-button k-button-icon k-gantt-toggle",iconPlus:"k-icon k-i-plus",iconPdf:"k-icon k-i-pdf",iconToggle:"k-icon k-i-gantt-toggle",viewButtonDefault:"k-state-default",viewButton:"k-view",currentView:"k-current-view",link:"k-link",pdfButton:"k-gantt-pdf",appendButton:"k-gantt-create"}},ne=w.extend({init:function(e,t){w.fn.init.call(this),this.element=e,this.options=M(!0,{},this.options,t),this._popup()},options:{direction:"down",navigatable:!1},_current:function(e){var t=p.styles,n=this.list.find(W+t.focused),i=n[e]();i.length&&(n.removeClass(t.focused).removeAttr("id"),i.addClass(t.focused).attr("id",j),this.list.find("ul").removeAttr(H).attr(H,j))},_popup:function(){var t=this,n=p.styles,i="li"+W+n.item,o=W+n.toolbar.appendButton,r=this.options.messages.actions,s=this.options.navigatable;this.list=e(Z({styles:n,actions:[{data:"add",text:r.addChild},{data:"insert-before",text:r.insertBefore},{data:"insert-after",text:r.insertAfter}]})),this.element.append(this.list),this.popup=new g.ui.Popup(this.list,M({anchor:this.element.find(o),open:function(){t._adjustListWidth()},animation:this.options.animation},V[this.options.direction])),this.element.on(F+B,o,function(i){var o=e(this),r=o.attr(g.attr("action"));i.preventDefault(),r?t.trigger("command",{type:r}):(t.popup.open(),s&&t.list.find("li:first").addClass(n.focused).attr("id",j).end().find("ul").attr({TABINDEX:0,"aria-activedescendant":j}).focus())}),this.list.find(i).hover(function(){e(this).addClass(n.hovered)},function(){e(this).removeClass(n.hovered)}).end().on(F+B,i,function(){t.trigger("command",{type:e(this).attr(g.attr("action"))}),t.popup.close()}),s&&(this.popup.bind("close",function(){t.list.find(i).removeClass(n.focused).end().find("ul").attr(L,0),t.element.parents("["+g.attr("role")+'="gantt"]').find(W+n.gridContent+" > table:first").focus()}),this.list.find("ul").on("keydown"+B,function(e){var i=e.keyCode;switch(i){case I.UP:e.preventDefault(),t._current("prev");break;case I.DOWN:e.preventDefault(),t._current("next");break;case I.ENTER:t.list.find(W+n.focused).click();break;case I.ESC:e.preventDefault(),t.popup.close()}}))},_adjustListWidth:function(){var e,t,n=this.list,i=p.styles,o=n[0].style.width,r=this.element.find(W+i.toolbar.appendButton),s=n.outerWidth();(n.data(O)||!o)&&(e=window.getComputedStyle?window.getComputedStyle(r[0],null):0,t=e?parseFloat(e.width):r.outerWidth(),e&&(v.mozilla||v.msie)&&(t+=parseFloat(e.paddingLeft)+parseFloat(e.paddingRight)+parseFloat(e.borderLeftWidth)+parseFloat(e.borderRightWidth)),o="border-box"!==n.css("box-sizing")?t-(n.outerWidth()-n.width()):t,s>o&&(o=s),n.css({fontFamily:r.css("font-family"),width:o}).data(O,o))},destroy:function(){clearTimeout(this._focusTimeout),this.popup.destroy(),this.element.off(B),this.list.off(B),this.unbind()}}),ie=function(e,t){return function(n){var i,o;if(n=S(n)?{data:n}:n,i=n||{},o=i.data,i.data=o,!(i instanceof e)&&i instanceof b)throw Error("Incorrect DataSource type. Only "+t+" instances are supported");return i instanceof e?i:new e(i)}},oe=g.data.Model.define({id:"id",fields:{id:{type:"number"},predecessorId:{type:"number"},successorId:{type:"number"},type:{type:"number"}}}),re=b.extend({init:function(e){b.fn.init.call(this,M(!0,{},{schema:{modelBase:oe,model:oe}},e))},successors:function(e){return this._dependencies("predecessorId",e)},predecessors:function(e){return this._dependencies("successorId",e)},dependencies:function(e){var t=this.predecessors(e),n=this.successors(e);return t.push.apply(t,n),t},_dependencies:function(e,t){var n=this.view(),i={field:e,operator:"eq",value:t};return n=new C(n).filter(i).toArray()}});re.create=ie(re,"GanttDependencyDataSource"),l=g.data.Model.define({duration:function(){var e=this.end,t=this.start;return e-t},isMilestone:function(){return 0===this.duration()},_offset:function(e){var t,n,i=["start","end"];for(n=0;i.length>n;n++)t=new Date(this.get(i[n]).getTime()+e),this.set(i[n],t)},id:"id",fields:{id:{type:"number"},parentId:{type:"number",defaultValue:null,validation:{required:!0}},orderId:{type:"number",validation:{required:!0}},title:{type:"string",defaultValue:"New task"},start:{type:"date",validation:{required:!0}},end:{type:"date",validation:{required:!0,dateCompare:o,message:"End date should be after or equal to the start date"}},percentComplete:{type:"number",validation:{required:!0,min:0,max:1,step:.01}},summary:{type:"boolean"},expanded:{type:"boolean",defaultValue:!0}}}),c=b.extend({init:function(e){b.fn.init.call(this,M(!0,{},{schema:{modelBase:l,model:l}},e))},remove:function(e){var t=e.get("parentId"),n=this.taskAllChildren(e);return this._removeItems(n),e=b.fn.remove.call(this,e),this._childRemoved(t,e.get("orderId")),e},add:function(e){return e?(e=this._toGanttTask(e),this.insert(this.taskSiblings(e).length,e)):t},insert:function(e,n){return n?(n=this._toGanttTask(n),n.set("orderId",e),n=b.fn.insert.call(this,e,n),this._reorderSiblings(n,this.taskSiblings(n).length-1),this._resolveSummaryFields(this.taskParent(n)),n):t},taskChildren:function(e){var n,i=this.view(),o={field:"parentId",operator:"eq",value:null},r=this._sort||{field:"orderId",dir:"asc"};if(e){if(n=e.get("id"),n===t||null===n||""===n)return[];o.value=n}return i=new C(i).filter(o).sort(r).toArray()},taskAllChildren:function(e){var t=[],n=this,i=function(e){var o=n.taskChildren(e);t.push.apply(t,o),P(o,i)};return e?i(e):t=this.view(),t},taskSiblings:function(e){if(!e)return null;var t=this.taskParent(e);return this.taskChildren(t)},taskParent:function(e){return e&&null!==e.get("parentId")?this.get(e.parentId):null},taskLevel:function(e){for(var t=0,n=this.taskParent(e);null!==n;)t+=1,n=this.taskParent(n);return t},taskTree:function(e){var t,n,i,o,r=[],s=this.taskChildren(e);for(n=0,i=s.length;i>n;n++)t=s[n],r.push(t),t.get("expanded")&&(o=this.taskTree(t),r.push.apply(r,o));return r},update:function(e,n){var i,o,r=this,s=function(e,t){var n,i,o=r.taskAllChildren(e);for(n=0,i=o.length;i>n;n++)o[n]._offset(t)},a=function(e){var t=e.field,n=e.sender;switch(t){case"start":r._resolveSummaryStart(r.taskParent(n)),s(n,n.get(t).getTime()-i.getTime());break;case"end":r._resolveSummaryEnd(r.taskParent(n));break;case"percentComplete":r._resolveSummaryPercentComplete(r.taskParent(n));break;case"orderId":r._reorderSiblings(n,i)}};n.parentId!==t&&(i=e.get("parentId"),i!==n.parentId&&(e.set("parentId",n.parentId),r._childRemoved(i,e.get("orderId")),e.set("orderId",r.taskSiblings(e).length-1),r._resolveSummaryFields(r.taskParent(e))),delete n.parentId),e.bind("change",a);for(o in n)i=e.get(o),e.set(o,n[o]);e.unbind("change",a)},_resolveSummaryFields:function(e){e&&(this._updateSummary(e),this.taskChildren(e).length&&(this._resolveSummaryStart(e),this._resolveSummaryEnd(e),this._resolveSummaryPercentComplete(e)))},_resolveSummaryStart:function(e){var t=this,n=function(e){var n,i,o,r=t.taskChildren(e),s=r[0].start.getTime();for(i=1,o=r.length;o>i;i++)n=r[i].start.getTime(),s>n&&(s=n);return new Date(s)};this._updateSummaryRecursive(e,"start",n)},_resolveSummaryEnd:function(e){var t=this,n=function(e){var n,i,o,r=t.taskChildren(e),s=r[0].end.getTime();for(i=1,o=r.length;o>i;i++)n=r[i].end.getTime(),n>s&&(s=n);return new Date(s)};this._updateSummaryRecursive(e,"end",n)},_resolveSummaryPercentComplete:function(e){var t=this,n=function(e){var n=t.taskChildren(e),i=new C(n).aggregate([{field:"percentComplete",aggregate:"average"}]);return i.percentComplete.average};this._updateSummaryRecursive(e,"percentComplete",n)},_updateSummaryRecursive:function(e,t,n){var i,o;e&&(i=n(e),e.set(t,i),o=this.taskParent(e),o&&this._updateSummaryRecursive(o,t,n))},_childRemoved:function(e,t){var n,i,o=null===e?null:this.get(e),r=this.taskChildren(o);for(n=t,i=r.length;i>n;n++)r[n].set("orderId",n);this._resolveSummaryFields(o)},_reorderSiblings:function(e,t){var n,i=e.get("orderId"),o=i>t,r=o?t:i,s=o?i:t,a=o?r:r+1,l=this.taskSiblings(e);for(s=Math.min(s,l.length-1),n=r;s>=n;n++)l[n]!==e&&(l[n].set("orderId",a),a+=1)},_updateSummary:function(e){if(null!==e){var t=this.taskChildren(e).length;e.set("summary",t>0)}},_toGanttTask:function(e){if(!(e instanceof l)){var t=e;e=this._createNewModel(),e.accept(t)}return e}}),c.create=ie(c,"GanttDataSource"),M(!0,g.data,{GanttDataSource:c,GanttTask:l,GanttDependencyDataSource:re,GanttDependency:oe}),u={desktop:{dateRange:J,resources:ee}},h=g.Observable.extend({init:function(e,t){g.Observable.fn.init.call(this),this.element=e,this.options=M(!0,{},this.options,t),this.createButton=this.options.createButton},fields:function(t,n){var i,o=this,r=this.options,s=r.messages.editor,a=r.resources,l=function(e){e.preventDefault(),a.editor(o.container.find(W+p.styles.popup.resourcesField),n)};return r.editable.template?i=e.map(n.fields,function(e,t){return{field:t}}):(i=[{field:"title",title:s.title},{field:"start",title:s.start,editor:t.dateRange},{field:"end",title:s.end,editor:t.dateRange},{field:"percentComplete",title:s.percentComplete,format:z}],n.get(a.field)&&i.push({field:a.field,title:s.resources,messages:s,editor:t.resources,click:l,styles:p.styles.popup})),i},_buildEditTemplate:function(e,t,n){var i,o,r,s,a=this.options.resources,l=this.options.editable.template,c=M({},g.Template,this.options.templateSettings),u=c.paramName,h=p.styles.popup,d="";if(l)typeof l===N&&(l=window.unescape(l)),d+=g.template(l,c)(e);else for(i=0,o=t.length;o>i;i++)r=t[i],d+='<div class="'+h.editLabel+'"><label for="'+r.field+'">'+(r.title||r.field||"")+"</label></div>",r.field===a.field&&(d+='<div class="'+h.resourcesField+'" style="display:none"></div>'),!e.editable||e.editable(r.field)?(n.push(r),d+="<div "+g.attr("container-for")+'="'+r.field+'" class="'+h.editField+'"></div>'):(s="#:",r.field?(r=g.expr(r.field,u),s+=r+"==null?'':"+r):s+="''",s+="#",s=g.template(s,c),d+='<div class="'+h.editField+'">'+s(e)+"</div>");return d}}),d=h.extend({destroy:function(){this.close(),this.unbind()},editTask:function(e){this.editable=this._createPopupEditor(e)},close:function(){var e=this,t=function(){e.editable&&(e.editable.destroy(),e.editable=null,e.container=null),e.popup&&(e.popup.destroy(),e.popup=null)};this.editable&&this.container.is(":visible")?this.container.data("kendoWindow").bind("deactivate",t).close():t()},showDialog:function(t){var n,i,o,r,s=t.buttons,a=p.styles.popup,l=g.format('<div class="{0}"><div class="{1}"><p class="{2}">{3}</p><div class="{4}">',a.form,a.formContainer,a.message,t.text,a.buttonsContainer);for(n=0,i=s.length;i>n;n++)l+=this.createButton(s[n]);l+="</div></div></div>",o=this.element,this.popup&&this.popup.destroy(),r=this.popup=e(l).appendTo(o).eq(0).on("click",W+a.button,function(t){t.preventDefault(),r.close();var n=e(t.currentTarget).index();s[n].click()}).kendoWindow({modal:!0,resizable:!1,draggable:!1,title:t.title,visible:!1,close:function(){this.destroy(),o.focus()}}).getKendoWindow(),r.center().open()},_createPopupEditor:function(t){var n,i,o=this,r={},s=this.options.messages,a=p.styles,l=a.popup,c=g.format('<div {0}="{1}" class="{2} {3}"><div class="{4}">',g.attr("uid"),t.uid,l.form,l.editForm,l.formContainer),h=this.fields(u.desktop,t),d=[];return c+=this._buildEditTemplate(t,h,d),c+='<div class="'+l.buttonsContainer+'">',c+=this.createButton({name:"update",text:s.save,className:p.styles.primary}),c+=this.createButton({name:"cancel",text:s.cancel}),c+=this.createButton({name:"delete",text:s.destroy}),c+="</div></div></div>",n=this.container=e(c).appendTo(this.element).eq(0).kendoWindow(M({modal:!0,resizable:!1,draggable:!0,title:s.editor.editorTitle,visible:!1,close:function(e){e.userTriggered&&o.trigger("cancel",{container:n,model:t})&&e.preventDefault()}},r)),i=n.kendoEditable({fields:d,model:t,clearContainer:!1,validateOnBlur:!0,target:o.options.target}).data("kendoEditable"),g.cycleForm(n),this.trigger("edit",{container:n,model:t})?o.trigger("cancel",{container:n,model:t}):(n.data("kendoWindow").center().open(),n.on(F+B,W+a.buttonCancel,function(e){e.preventDefault(),e.stopPropagation(),o.trigger("cancel",{container:n,model:t})}),n.on(F+B,W+a.buttonSave,function(e){var i,r,s,a,l;for(e.preventDefault(),e.stopPropagation(),i=o.fields(u.desktop,t),r={},a=0,l=i.length;l>a;a++)s=i[a].field,r[s]=t.get(s);o.trigger("save",{container:n,model:t,updateInfo:r})}),n.on(F+B,W+a.buttonDelete,function(e){e.preventDefault(),e.stopPropagation(),o.trigger("remove",{container:n,model:t})})),i}}),f=y.extend({init:function(e,t){y.fn.init.call(this,e,t),this.wrapper=this.element,this.model=this.options.model,this.resourcesField=this.options.resourcesField,this.createButton=this.options.createButton,this._initContainer(),this._attachHandlers()},events:["save"],open:function(){this.window.center().open(),this.grid.resize(!0)},close:function(){this.window.bind("deactivate",D(this.destroy,this)).close()},destroy:function(){this._dettachHandlers(),this.grid.destroy(),this.grid=null,this.window.destroy(),this.window=null,y.fn.destroy.call(this),g.destroy(this.wrapper),this.element=this.wrapper=null},_attachHandlers:function(){var t=p.styles,n=this.grid,i=this._cancelProxy=D(this._cancel,this);this.container.on(F+B,W+t.buttonCancel,this._cancelProxy),this._saveProxy=D(this._save,this),this.container.on(F+B,W+t.buttonSave,this._saveProxy),this.window.bind("close",function(e){e.userTriggered&&i(e)}),n.wrapper.on(F+B,"input[type='checkbox']",function(){var t=e(this),i=e(t).closest("tr"),o=n.dataSource.getByUid(i.attr(g.attr("uid"))),r=e(t).is(":checked")?1:"";o.set("value",r)})},_dettachHandlers:function(){this._cancelProxy=null,this._saveProxy=null,this.container.off(B),this.grid.wrapper.off()},_cancel:function(e){e.preventDefault(),this.close()},_save:function(e){e.preventDefault(),this._updateModel(),this.wrapper.is(W+p.styles.popup.resourcesField)||this.trigger("save",{container:this.wrapper,model:this.model}),this.close()},_initContainer:function(){var t=p.styles.popup,n=g.format('<div class="{0} {1}"><div class="{2} {3}"/></div>"',t.form,t.editForm,t.formContainer,t.resourcesFormContainer);n=e(n),this.container=n.find(W+t.resourcesFormContainer),this.window=n.kendoWindow({modal:!0,resizable:!1,draggable:!0,visible:!1,title:this.options.messages.resourcesEditorTitle}).data("kendoWindow"),this._resourceGrid(),this._createButtons()},_resourceGrid:function(){var t=this,n=this.options.messages,i=e('<div id="resources-grid"/>').appendTo(this.container);this.grid=new g.ui.Grid(i,{columns:[{field:"name",title:n.resourcesHeader,template:"<label><input type='checkbox' value='#=name#'# if (value > 0 && value !== null) {#checked='checked'# } #/>#=name#</labe>"},{field:"value",title:n.unitsHeader,template:function(e){var t=e.format,n=null!==e.value?e.value:"";return t?g.toString(n,t):n}}],height:280,sortable:!0,editable:!0,filterable:!0,dataSource:{data:t.options.data,schema:{model:{id:"id",fields:{id:{from:"id"},name:{from:"name",type:"string",editable:!1},value:{from:"value",type:"number",defaultValue:""},format:{from:"format",type:"string"}}}}},save:function(e){var t=!!e.values.value;e.container.parent().find("input[type='checkbox']").prop("checked",t)}})},_createButtons:function(){var e,t,n=this.options.buttons,i='<div class="'+p.styles.popup.buttonsContainer+'">';for(e=0,t=n.length;t>e;e++)i+=this.createButton(n[e]);i+="</div>",this.container.append(i)},_updateModel:function(){var e,t,n,i=[],o=this.grid.dataSource.data();for(t=0,n=o.length;n>t;t++)e=o[t].get("value"),null!==e&&e>0&&i.push(o[t]);this.model[this.resourcesField]=i}}),p=y.extend({init:function(e,t){S(t)&&(t={dataSource:t}),a={append:{text:"Add Task",action:"add",className:p.styles.toolbar.appendButton,iconClass:p.styles.toolbar.iconPlus},pdf:{text:"Export to PDF",className:p.styles.toolbar.pdfButton,iconClass:p.styles.toolbar.iconPdf}},y.fn.init.call(this,e,t),this._wrapper(),this._resources(),this._timeline(),this._toolbar(),this._footer(),this._adjustDimensions(),this._preventRefresh=!0,this.view(this.timeline._selectedViewName),this._preventRefresh=!1,this._dataSource(),this._assignments(),this._dropDowns(),this._list(),this._dependencies(),this._resizable(),this._scrollable(),this._dataBind(),this._attachEvents(),this._createEditor(),g.notify(this)},events:["dataBinding","dataBound","add","edit","remove","cancel","save","change","navigate","moveStart","move","moveEnd","resizeStart","resize","resizeEnd","columnResize"],options:{name:"Gantt",autoBind:!0,navigatable:!1,selectable:!0,editable:!0,resizable:!1,columnResizeHandleWidth:R,columns:[],views:[],dataSource:{},dependencies:{},resources:{},assignments:{},taskTemplate:null,messages:{save:"Save",cancel:"Cancel",destroy:"Delete",deleteTaskConfirmation:G,deleteDependencyConfirmation:q,deleteTaskWindowTitle:"Delete task",deleteDependencyWindowTitle:"Delete dependency",views:{day:"Day",week:"Week",month:"Month",year:"Year",start:"Start",end:"End"},actions:{append:"Add Task",addChild:"Add Child",insertBefore:"Add Above",insertAfter:"Add Below",pdf:"Export to PDF"},editor:{editorTitle:"Task",resourcesEditorTitle:"Resources",title:"Title",start:"Start",end:"End",percentComplete:"Complete",resources:"Resources",assignButton:"Assign",resourcesHeader:"Resources",unitsHeader:"Units"}},showWorkHours:!0,showWorkDays:!0,toolbar:null,workDayStart:new Date(1980,1,1,8,0,0),workDayEnd:new Date(1980,1,1,17,0,0),workWeekStart:1,workWeekEnd:5,hourSpan:1,snap:!0,height:600,listWidth:"30%",rowHeight:null},select:function(e){var n=this.list;return e?(n.select(e),t):n.select()},clearSelection:function(){this.list.clearSelection()},destroy:function(){y.fn.destroy.call(this),this.dataSource&&(this.dataSource.unbind("change",this._refreshHandler),this.dataSource.unbind("progress",this._progressHandler),this.dataSource.unbind("error",this._errorHandler)),this.dependencies&&(this.dependencies.unbind("change",this._dependencyRefreshHandler),this.dependencies.unbind("error",this._dependencyErrorHandler)),this.timeline&&(this.timeline.unbind(),this.timeline.destroy()),this.list&&(this.list.unbind(),this.list.destroy()),this.footerDropDown&&this.footerDropDown.destroy(),this.headerDropDown&&this.headerDropDown.destroy(),this._editor&&this._editor.destroy(),this._resizeDraggable&&this._resizeDraggable.destroy(),this.toolbar.off(B),m&&(this._mediaQuery.removeListener(this._mediaQueryHandler),this._mediaQuery=null),e(window).off("resize"+B,this._resizeHandler),e(this.wrapper).off(B),this.toolbar=null,this.footer=null},_attachEvents:function(){this._resizeHandler=D(this.resize,this,!1),e(window).on("resize"+B,this._resizeHandler)},_wrapper:function(){var e=p.styles,t=[e.icon,e.resizeHandle].join(" "),n=this.options,i=n.height,o=n.width;this.wrapper=this.element.addClass(e.wrapper).append("<div class='"+e.listWrapper+"'><div></div></div>").append("<div class='"+e.splitBarWrapper+"'><div class='"+t+"'></div></div>").append("<div class='"+e.timelineWrapper+"'><div></div></div>"),this.wrapper.find(W+e.list).width(n.listWidth),i&&this.wrapper.height(i),o&&this.wrapper.width(o),n.rowHeight&&this.wrapper.addClass(e.rowHeight)},_toolbar:function(){var t,n,i,o=this,r=p.styles,s=W+r.toolbar.views+" > li",a=W+r.toolbar.pdfButton,l=W+r.buttonToggle,c=W+r.gridContent,u=e(W+r.list),h=e(W+r.timeline),d=r.hovered,f=this.options.toolbar,v=e("<div class='"+r.toolbar.actions+"'>"),_=function(e){e.matches?u.css({display:"none","max-width":0}):(u.css({display:"inline-block",width:"30%","max-width":"none"}),h.css("display","inline-block"),o.refresh(),h.find(c).scrollTop(o.scrollTop)),o._resize()};A(f)||(f=typeof f===N?f:this._actions(f),f=D(g.template(f),this)),i=e($({styles:r.toolbar})),n=e(K({ns:g.ns,views:this.timeline.views,styles:r.toolbar})),v.append(f({})),t=e("<div class='"+r.toolbar.headerWrapper+"'>").append(i).append(n).append(v),n.find("li").length>1&&n.prepend(X({styles:r.toolbar})),this.wrapper.prepend(t),this.toolbar=t,m&&(this._mediaQueryHandler=D(_,this),this._mediaQuery=window.matchMedia("(max-width: 480px)"),this._mediaQuery.addListener(this._mediaQueryHandler)),t.on(F+B,s,function(t){var i,s,a;t.preventDefault(),i=o.list,s=e(this).attr(g.attr("name")),a=n.find(W+r.toolbar.currentView),a.is(":visible")&&a.parent().toggleClass(r.toolbar.expanded),i.editable&&i.editable.trigger("validate")||o.trigger("navigate",{view:s})||o.view(s)}).on(F+B,a,function(e){e.preventDefault(),o.saveAsPDF()}).on(F+B,l,function(e){e.preventDefault(),u.is(":visible")?(u.css({display:"none",width:"0"}),h.css({display:"inline-block",width:"100%"}),o.refresh(),h.find(c).scrollTop(o.scrollTop)):(h.css({display:"none",width:0}),u.css({display:"inline-block",width:"100%","max-width":"none"}).find(c).scrollTop(o.scrollTop)),o._resize()}),this.wrapper.find(W+r.toolbar.toolbar+" li").hover(function(){e(this).addClass(d)},function(){e(this).removeClass(d)})},_actions:function(){var e,t,n=this.options,i=n.toolbar,o="";if(!S(i)){if(!n.editable)return o;i=["append"]}for(e=0,t=i.length;t>e;e++)o+=this._createButton(i[e]);return o},_footer:function(){var t,n,i,o,r;this.options.editable&&(t=p.styles.toolbar,n=this.options.messages.actions,i=e(g.template(Y)(M(!0,{styles:t},a.append,{text:n.append}))),o=e("<div class='"+t.actions+"'>").append(i),r=e("<div class='"+t.footerWrapper+"'>").append(o),this.wrapper.append(r),this.footer=r)},_createButton:function(e){var t=e.template||Y,n=this.options.messages.actions,i=typeof e===N?e:e.name||e.text,o=a[i]?a[i].className:"k-gantt-"+(i||"").replace(/\s/g,""),r={iconClass:"",action:"",text:i,className:o,styles:p.styles.toolbar};if(!(i||E(e)&&e.template))throw Error("Custom commands should have name specified");return r=M(!0,r,a[i],{text:n[i]}),E(e)&&(e.className&&T(r.className,e.className.split(" "))<0&&(e.className+=" "+r.className),r=M(!0,r,e)),g.template(t)(r)},_adjustDimensions:function(){var e=this.element,t=p.styles,n=W+t.list,i=W+t.timeline,o=W+t.splitBar,r=this.toolbar.outerHeight(),s=this.footer?this.footer.outerHeight():0,a=e.height(),l=e.width(),c=e.find(o).outerWidth(),u=e.find(n).outerWidth();e.children([n,i,o].join(",")).height(a-(r+s)).end().children(i).width(l-(c+u)),u+c>l&&e.find(n).width(l-c)},_scrollTo:function(e){var t,i,o=this.timeline.view(),r=this.list,s=g.attr("uid"),a="string"==typeof e?e:e.closest("tr"+n()).attr(s),l=function(){0!==i.length&&t()};o.content.is(":visible")?(i=o.content.find(n(a)),t=function(){o._scrollTo(i)}):(i=r.content.find(n(a)),t=function(){i.get(0).scrollIntoView()}),l()},_dropDowns:function(){var e=this,t=W+p.styles.toolbar.actions,n=this.options.messages.actions,i=this.timeline,o=function(t){var n,o=t.type,r=e.dataSource,s=r._createNewModel(),a=e.dataItem(e.select()),l=r.taskParent(a),c=i.view()._timeSlots()[0],u="add"===o?a:l,h=e.list.editable;h&&h.trigger("validate")||(s.set("title","New task"),u?(s.set("parentId",u.get("id")),s.set("start",u.get("start")),s.set("end",u.get("end"))):(s.set("start",c.start),s.set("end",c.end)),"add"!==o&&(n=a.get("orderId"),n="insert-before"===o?n:n+1),e._createTask(s,n))};this.options.editable&&(this.footerDropDown=new ne(this.footer.children(t).eq(0),{messages:{actions:n},direction:"up",animation:{open:{effects:"slideIn:up"}},navigatable:e.options.navigatable}),this.headerDropDown=new ne(this.toolbar.children(t).eq(0),{messages:{actions:n},navigatable:e.options.navigatable}),this.footerDropDown.bind("command",o),this.headerDropDown.bind("command",o))},_list:function(){var e,t,n=this,i=n.options.navigatable,o=p.styles,s=this.wrapper.find(W+o.list),a=s.find("> div"),l=this.wrapper.find(W+o.toolbar.actions+" > button"),c={columns:this.options.columns||[],dataSource:this.dataSource,selectable:this.options.selectable,editable:this.options.editable,resizable:this.options.resizable,columnResizeHandleWidth:this.options.columnResizeHandleWidth,listWidth:s.outerWidth(),resourcesField:this.resources.field,rowHeight:this.options.rowHeight},u=c.columns,h=function(){i&&(n._current(n._cachedCurrent),r(n.list.content.find("table"),!0)),delete n._cachedCurrent};for(t=0;u.length>t;t++)e=u[t],e.field===this.resources.field&&"function"!=typeof e.editor&&(e.editor=D(this._createResourceEditor,this));this.list=new g.ui.GanttList(a,c),this.list.bind("render",function(){n._navigatable()},!0).bind("edit",function(e){n._cachedCurrent=e.cell,n.trigger("edit",{task:e.model,container:e.cell})&&e.preventDefault()}).bind("cancel",function(e){n.trigger("cancel",{task:e.model,container:e.cell})&&e.preventDefault(),h()}).bind("update",function(e){n._updateTask(e.task,e.updateInfo),h()}).bind("change",function(){n.trigger("change");var e=n.list.select();e.length?(l.removeAttr("data-action","add"),n.timeline.select("[data-uid='"+e.attr("data-uid")+"']")):(l.attr("data-action","add"),n.timeline.clearSelection())}).bind("columnResize",function(e){n.trigger("columnResize",{column:e.column,oldWidth:e.oldWidth,newWidth:e.newWidth})})},_timeline:function(){var e=this,n=p.styles,o=i(M(!0,{resourcesField:this.resources.field},this.options)),r=this.wrapper.find(W+n.timeline+" > div"),s=W+n.toolbar.currentView+" > "+W+n.toolbar.link;this.timeline=new g.ui.GanttTimeline(r,o),this.timeline.bind("navigate",function(t){var i=t.view.replace(/\./g,"\\.").toLowerCase(),o=e.toolbar.find(W+n.toolbar.views+" > li").removeClass(n.selected).end().find(W+n.toolbar.viewButton+"-"+i).addClass(n.selected).find(W+n.toolbar.link).text();e.toolbar.find(s).text(o),e.refresh()}).bind("moveStart",function(n){var i=e.list.editable;return i&&i.trigger("validate")?(n.preventDefault(),t):(e.trigger("moveStart",{task:n.task})&&n.preventDefault(),t)}).bind("move",function(t){var n=t.task,i=t.start,o=new Date(i.getTime()+n.duration());e.trigger("move",{task:n,start:i,end:o})&&t.preventDefault()}).bind("moveEnd",function(t){var n=t.task,i=t.start,o=new Date(i.getTime()+n.duration());e.trigger("moveEnd",{task:n,start:i,end:o})||e._updateTask(e.dataSource.getByUid(n.uid),{start:i,end:o})}).bind("resizeStart",function(n){var i=e.list.editable;return i&&i.trigger("validate")?(n.preventDefault(),t):(e.trigger("resizeStart",{task:n.task})&&n.preventDefault(),t)}).bind("resize",function(t){e.trigger("resize",{task:t.task,start:t.start,end:t.end})&&t.preventDefault()}).bind("resizeEnd",function(t){var n=t.task,i={};t.resizeStart?i.start=t.start:i.end=t.end,e.trigger("resizeEnd",{task:n,start:t.start,end:t.end})||e._updateTask(e.dataSource.getByUid(n.uid),i)}).bind("percentResizeStart",function(t){var n=e.list.editable;n&&n.trigger("validate")&&t.preventDefault()}).bind("percentResizeEnd",function(t){e._updateTask(e.dataSource.getByUid(t.task.uid),{percentComplete:t.percentComplete})}).bind("dependencyDragStart",function(t){var n=e.list.editable;n&&n.trigger("validate")&&t.preventDefault()}).bind("dependencyDragEnd",function(t){var n=e.dependencies._createNewModel({type:t.type,predecessorId:t.predecessor.id,successorId:t.successor.id});e._createDependency(n)}).bind("select",function(t){var n=e.list.editable;n&&n.trigger("validate"),e.select("[data-uid='"+t.uid+"']")}).bind("editTask",function(t){var n=e.list.editable;n&&n.trigger("validate")||e.editTask(t.uid)}).bind("clear",function(){e.clearSelection()}).bind("removeTask",function(t){var n=e.list.editable;n&&n.trigger("validate")||e.removeTask(e.dataSource.getByUid(t.uid))}).bind("removeDependency",function(t){var n=e.list.editable;n&&n.trigger("validate")||e.removeDependency(e.dependencies.getByUid(t.uid));
|
|
})},_dataSource:function(){var e=this.options,t=e.dataSource;t=S(t)?{data:t}:t,this.dataSource&&this._refreshHandler?this.dataSource.unbind("change",this._refreshHandler).unbind("progress",this._progressHandler).unbind("error",this._errorHandler):(this._refreshHandler=D(this.refresh,this),this._progressHandler=D(this._requestStart,this),this._errorHandler=D(this._error,this)),this.dataSource=g.data.GanttDataSource.create(t).bind("change",this._refreshHandler).bind("progress",this._progressHandler).bind("error",this._errorHandler)},_dependencies:function(){var e=this.options.dependencies||{},t=S(e)?{data:e}:e;this.dependencies&&this._dependencyRefreshHandler?this.dependencies.unbind("change",this._dependencyRefreshHandler).unbind("error",this._dependencyErrorHandler):(this._dependencyRefreshHandler=D(this.refreshDependencies,this),this._dependencyErrorHandler=D(this._error,this)),this.dependencies=g.data.GanttDependencyDataSource.create(t).bind("change",this._dependencyRefreshHandler).bind("error",this._dependencyErrorHandler)},_resources:function(){var e=this.options.resources,t=e.dataSource||{};this.resources={field:"resources",dataTextField:"name",dataColorField:"color",dataFormatField:"format"},M(this.resources,e),this.resources.dataSource=g.data.DataSource.create(t)},_assignments:function(){var e=this.options.assignments,t=e.dataSource||{};this.assignments?this.assignments.dataSource.unbind("change",this._assignmentsRefreshHandler):this._assignmentsRefreshHandler=D(this.refresh,this),this.assignments={dataTaskIdField:"taskId",dataResourceIdField:"resourceId",dataValueField:"value"},M(this.assignments,e),this.assignments.dataSource=g.data.DataSource.create(t),this.assignments.dataSource.bind("change",this._assignmentsRefreshHandler)},_createEditor:function(){var e=this,n=this._editor=new d(this.wrapper,M({},this.options,{target:this,resources:{field:this.resources.field,editor:D(this._createResourceEditor,this)},createButton:D(this._createPopupButton,this)}));n.bind("cancel",function(n){var i=e.dataSource.getByUid(n.model.uid);return e.trigger("cancel",{container:n.container,task:i})?(n.preventDefault(),t):(e.cancelTask(),t)}).bind("edit",function(t){var n=e.dataSource.getByUid(t.model.uid);e.trigger("edit",{container:t.container,task:n})&&t.preventDefault()}).bind("save",function(t){var n=e.dataSource.getByUid(t.model.uid);e.saveTask(n,t.updateInfo)}).bind("remove",function(t){e.removeTask(t.model.uid)})},_createResourceEditor:function(e,t){var n=this,i=t instanceof x?t:t.model,o=i.get("id"),r=this.options.messages,s=n.resources.field,a=this._resourceEditor=new f(e,{resourcesField:s,data:this._wrapResourceData(o),model:i,messages:M({},r.editor),buttons:[{name:"update",text:r.save,className:p.styles.primary},{name:"cancel",text:r.cancel}],createButton:D(this._createPopupButton,this),save:function(e){n._updateAssignments(e.model.get("id"),e.model.get(s))}});a.open()},_createPopupButton:function(e){var t=e.name||e.text,n={className:p.styles.popup.button+" k-gantt-"+(t||"").replace(/\s/g,""),text:t,attr:""};if(!(t||E(e)&&e.template))throw Error("Custom commands should have name specified");return E(e)&&(e.className&&(e.className+=" "+n.className),n=M(!0,n,e)),g.template(Q)(n)},view:function(e){return this.timeline.view(e)},dataItem:function(e){var t,n;return e?(t=this.list,n=t.content.find(e),t._modelFromElement(n)):null},setDataSource:function(e){this.options.dataSource=e,this._dataSource(),this.list._setDataSource(this.dataSource),this.options.autoBind&&e.fetch()},setDependenciesDataSource:function(e){this.options.dependencies=e,this._dependencies(),this.options.autoBind&&e.fetch()},items:function(){return this.wrapper.children(".k-task")},_updateAssignments:function(e,t){for(var n,i,o,r,s,a,l,c=this.assignments.dataSource,u=this.assignments.dataTaskIdField,h=this.assignments.dataResourceIdField,d=!1,f=new C(c.view()).filter({field:u,operator:"eq",value:e}).toArray();f.length;){for(n=f[0],r=0,s=t.length;s>r;r++)if(i=t[r],n.get(h)===i.get("id")){o=t[r].get("value"),this._updateAssignment(n,o),t.splice(r,1),d=!0;break}d||this._removeAssignment(n),d=!1,f.shift()}for(a=0,l=t.length;l>a;a++)i=t[a],this._createAssignment(i,e);c.sync()},cancelTask:function(){var e=this._editor,t=e.container;t&&e.close()},editTask:function(e){var t,n="string"==typeof e?this.dataSource.getByUid(e):e;n&&(t=this.dataSource._createNewModel(n.toJSON()),t.uid=n.uid,this.cancelTask(),this._editTask(t))},_editTask:function(e){this._editor.editTask(e)},saveTask:function(e,t){var n=this._editor,i=n.container,o=n.editable;i&&o&&o.end()&&this._updateTask(e,t)},_updateTask:function(e,t){var n=this.resources.field;this.trigger("save",{task:e,values:t})||(this._preventRefresh=!0,this.dataSource.update(e,t),t[n]&&this._updateAssignments(e.get("id"),t[n]),this._syncDataSource())},_updateAssignment:function(e,t){var n=this.assignments.dataValueField;e.set(n,t)},removeTask:function(e){var t=this,n="string"==typeof e?this.dataSource.getByUid(e):e;n&&this._taskConfirm(function(e){e||t._removeTask(n)},n)},_createTask:function(e,n){if(!this.trigger("add",{task:e,dependency:null})){var i=this.dataSource;this._preventRefresh=!0,n===t?i.add(e):i.insert(n,e),this._scrollToUid=e.uid,this._syncDataSource()}},_createDependency:function(e){this.trigger("add",{task:null,dependency:e})||(this._preventDependencyRefresh=!0,this.dependencies.add(e),this._preventDependencyRefresh=!1,this.dependencies.sync())},_createAssignment:function(e,t){var n=this.assignments,i=n.dataSource,o=n.dataTaskIdField,r=n.dataResourceIdField,s=n.dataValueField,a=i._createNewModel();a[o]=t,a[r]=e.get("id"),a[s]=e.get("value"),i.add(a)},removeDependency:function(e){var t=this,n="string"==typeof e?this.dependencies.getByUid(e):e;n&&this._dependencyConfirm(function(e){e||t._removeDependency(n)},n)},_removeTaskDependencies:function(e,t){this._preventDependencyRefresh=!0;for(var n=0,i=t.length;i>n;n++)this.dependencies.remove(t[n]);this._preventDependencyRefresh=!1,this.dependencies.sync()},_removeTaskAssignments:function(e){var t,n,i=this.assignments.dataSource,o=i.view(),r={field:this.assignments.dataTaskIdField,operator:"eq",value:e.get("id")};for(o=new C(o).filter(r).toArray(),this._preventRefresh=!0,t=0,n=o.length;n>t;t++)i.remove(o[t]);this._preventRefresh=!1,i.sync()},_removeTask:function(e){var t=this.dependencies.dependencies(e.id);this.trigger("remove",{task:e,dependencies:t})||(this._removeTaskDependencies(e,t),this._removeTaskAssignments(e),this._preventRefresh=!0,this.dataSource.remove(e)&&this._syncDataSource(),this._preventRefresh=!1)},_removeDependency:function(e){this.trigger("remove",{task:null,dependencies:[e]})||this.dependencies.remove(e)&&this.dependencies.sync()},_removeAssignment:function(e){this.assignments.dataSource.remove(e)},_taskConfirm:function(e,t){var n=this.options.messages;this._confirm(e,{model:t,text:n.deleteTaskConfirmation,title:n.deleteTaskWindowTitle})},_dependencyConfirm:function(e,t){var n=this.options.messages;this._confirm(e,{model:t,text:n.deleteDependencyConfirmation,title:n.deleteDependencyWindowTitle})},_confirm:function(e,t){var n,i,o=this.options.editable;o===!0||o.confirmation!==!1?(n=this.options.messages,i=[{name:"delete",text:n.destroy,className:p.styles.primary,click:function(){e()}},{name:"cancel",text:n.cancel,click:function(){e(!0)}}],this.showDialog(M(!0,{},t,{buttons:i}))):e()},showDialog:function(e){this._editor.showDialog(e)},refresh:function(){var e,t,i,o,r,s;this._preventRefresh||this.list.editable||(this._progress(!1),e=this.dataSource,t=e.taskTree(),i=this._scrollToUid,s=-1,this.current&&(r=this.current.closest("tr").attr(g.attr("uid")),s=this.current.index()),this.trigger("dataBinding")||(0!==this.resources.dataSource.data().length&&this._assignResources(t),this._editor&&this._editor.close(),this.clearSelection(),this.list._render(t),this.timeline._render(t),this.timeline._renderDependencies(this.dependencies.view()),i&&(this._scrollTo(i),this.select(n(i))),(i||r)&&s>=0&&(o=this.list.content.find("tr"+n(i||r)+" > td:eq("+s+")"),this._current(o)),this._scrollToUid=null,this.trigger("dataBound")))},refreshDependencies:function(){this._preventDependencyRefresh||this.trigger("dataBinding")||(this.timeline._renderDependencies(this.dependencies.view()),this.trigger("dataBound"))},_assignResources:function(e){var t,n,i=this.resources,o=this.assignments,r=function(){var e=o.dataSource.view(),t={field:o.dataTaskIdField};return e=new C(e).group(t).toArray()},s=r(),a=function(e,t){var n,o,r=e.get("id");for(g.setter(i.field)(e,new k([])),n=0,o=s.length;o>n;n++)s[n].value===r&&t(e,s[n].items)},l=function(e,t){var n,r,s,a,l,c,u,h;for(n=0,r=t.length;r>n;n++)s=t[n],a=i.dataSource.get(s.get(o.dataResourceIdField)),l=s.get(o.dataValueField),c=s.get(o.dataResourceIdField),u=a.get(i.dataFormatField)||z,h=g.toString(l,u),e[i.field].push(new x({id:c,name:a.get(i.dataTextField),color:a.get(i.dataColorField),value:l,formatedValue:h}))};for(t=0,n=e.length;n>t;t++)a(e[t],l)},_wrapResourceData:function(e){var t,n,i,o=this,r=[],s=this.resources.dataSource.view(),a=this.assignments.dataSource.view(),l=new C(a).filter({field:o.assignments.dataTaskIdField,operator:"eq",value:e}).toArray(),c=function(e){var t=null;return new C(l).filter({field:o.assignments.dataResourceIdField,operator:"eq",value:e}).select(function(e){t+=e.get(o.assignments.dataValueField)}),t};for(n=0,i=s.length;i>n;n++)t=s[n],r.push({id:t.get("id"),name:t.get(o.resources.dataTextField),format:t.get(o.resources.dataFormatField)||z,value:c(t.id)});return r},_syncDataSource:function(){this._preventRefresh=!1,this._requestStart(),this.dataSource.sync()},_requestStart:function(){this._progress(!0)},_error:function(){this._progress(!1)},_progress:function(e){g.ui.progress(this.element,e)},_resizable:function(){var t,n,i,o=this,r=this.wrapper,s=p.styles,a=W+s.gridContent,l=r.find(W+s.list),c=r.find(W+s.timeline);this._resizeDraggable=r.find(W+s.splitBar).height(l.height()).hover(function(){e(this).addClass(s.splitBarHover)},function(){e(this).removeClass(s.splitBarHover)}).end().kendoResizable({orientation:"horizontal",handle:W+s.splitBar,start:function(){t=l.width(),n=c.width(),i=c.find(a).scrollLeft()},resize:function(e){var s=e.x.initialDelta;g.support.isRtl(r)&&(s*=-1),0>t+s||0>n-s||(l.width(t+s),c.width(n-s),c.find(a).scrollLeft(i+s),o.timeline.view()._renderCurrentTime())}}).data("kendoResizable")},_scrollable:function(){var t=this,n=p.styles,i=W+n.gridContent,o=W+n.gridHeaderWrap,r=this.timeline.element.find(o),s=this.timeline.element.find(i),a=this.list.element.find(o),l=this.list.element.find(i);_&&l.css("overflow-y","auto"),s.on("scroll",function(){t.scrollTop=this.scrollTop,r.scrollLeft(this.scrollLeft),l.scrollTop(this.scrollTop)}),l.on("scroll",function(){t.scrollTop=this.scrollTop,a.scrollLeft(this.scrollLeft),s.scrollTop(this.scrollTop)}).on("DOMMouseScroll"+B+" mousewheel"+B,function(t){var n=s.scrollTop(),i=g.wheelDeltaY(t);i&&(t.preventDefault(),e(t.currentTarget).one("wheel"+B,!1),s.scrollTop(n+-i))})},_navigatable:function(){var i,o=this,s=this.options.navigatable,a=this.options.editable,l=this.list.header.find("table"),c=this.list.content.find("table"),u=p.styles,h=g.support.isRtl(this.wrapper),d=this.timeline.element.find(W+u.gridContent),f=l.add(c),m=n(),v={collapse:!1,expand:!0},_=function(e){var t=o.timeline.view()._timeSlots()[0].offsetWidth;d.scrollLeft(d.scrollLeft()+(e?-t:t))},w=function(e){var t=o.current.parent("tr"+n()),i=o.current.index(),s=t[e]();0!==o.select().length&&o.clearSelection(),0!==s.length?(o._current(s.children("td:eq("+i+")")),o._scrollTo(o.current)):o.current.is("td")&&"prev"==e?r(l):o.current.is("th")&&"next"==e&&r(c)},y=function(e){var t=o.current[e]();0!==t.length&&(o._current(t),i=o.current.index())},b=function(e){var t=o.dataItem(o.current);t.summary&&t.expanded!==e&&t.set("expanded",e)},x=function(){var e,t;o.options.editable&&!o.list.editable&&(e=o.select(),t=g.attr("uid"),e.length&&o.removeTask(e.attr(t)))};return e(this.wrapper).on("mousedown"+B,"tr"+m+", div"+m+":not("+W+u.line+")",function(t){var i,l=e(t.currentTarget),c=e(t.target).is(":button,a,:input,a>.k-icon,textarea,span.k-icon,span.k-link,.k-input,.k-multiselect-wrap");t.ctrlKey||(s&&(i=l.is("tr")?e(t.target).closest("td"):o.list.content.find("tr"+n(l.attr(g.attr("uid")))+" > td:first"),o._current(i)),!s&&!a||c||(o._focusTimeout=setTimeout(function(){r(o.list.content.find("table"),!0)},2)))}),s!==!0?(c.on("keydown"+B,function(e){e.keyCode==I.DELETE&&x()}),t):(f.on("focus"+B,function(){var t=this===c.get(0)?"td":"th",n=o.select(),r=o.current||e(n.length?n:this).find(t+":eq("+(i||0)+")");o._current(r)}).on("blur"+B,function(){o._current(),this==l&&e(this).attr(L,-1)}).on("keydown"+B,function(t){var n,i=t.keyCode;if(o.current)switch(n=o.current.is("td"),i){case I.RIGHT:t.preventDefault(),t.altKey?_():t.ctrlKey?b(h?v.collapse:v.expand):y(h?"prev":"next");break;case I.LEFT:t.preventDefault(),t.altKey?_(!0):t.ctrlKey?b(h?v.expand:v.collapse):y(h?"next":"prev");break;case I.UP:t.preventDefault(),w("prev");break;case I.DOWN:t.preventDefault(),w("next");break;case I.SPACEBAR:t.preventDefault(),n&&o.select(o.current.closest("tr"));break;case I.ENTER:t.preventDefault(),n?o.options.editable&&(o._cachedCurrent=o.current,o.list._startEditHandler(o.current),e(this).one("keyup",function(e){e.stopPropagation()})):o.current.children("a.k-link").click();break;case I.ESC:t.stopPropagation();break;case I.DELETE:n&&x();break;default:i>=49&&57>=i&&o.view(o.timeline._viewByIndex(i-49))}}),t)},_current:function(t){var n,i=p.styles;this.current&&this.current.length&&this.current.removeClass(i.focused).removeAttr("id"),t&&t.length?(this.current=t.addClass(i.focused).attr("id",U),n=e(g._activeElement()),n.is("table")&&this.wrapper.find(n).length>0&&n.removeAttr(H).attr(H,U)):this.current=null},_dataBind:function(){var t,n=this;n.options.autoBind&&(this._preventRefresh=!0,this._preventDependencyRefresh=!0,t=e.map([this.dataSource,this.dependencies,this.resources.dataSource,this.assignments.dataSource],function(e){return e.fetch()}),e.when.apply(null,t).done(function(){n._preventRefresh=!1,n._preventDependencyRefresh=!1,n.refresh()}))},_resize:function(){this._adjustDimensions(),this.timeline.view()._adjustHeight(),this.timeline.view()._renderCurrentTime(),this.list._adjustHeight()}}),g.PDFMixin&&(g.PDFMixin.extend(p.fn),p.fn._drawPDF=function(){var e="."+te.list,t=this.wrapper.find(e).width(),n=this.wrapper.clone();return n.find(e).css("width",t),this._drawPDFShadow({content:n},{avoidLinks:this.options.pdf.avoidLinks})}),g.ui.plugin(p),M(!0,p,{styles:te})}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t){t()}); |