diff --git a/js/jquery.fn.gantt.min.js b/js/jquery.fn.gantt.min.js index 83ba3f4..9d79144 100644 --- a/js/jquery.fn.gantt.min.js +++ b/js/jquery.fn.gantt.min.js @@ -1 +1 @@ -(function($){"use strict";$.fn.gantt=function(options){var cookieKey="jquery.fn.gantt";var scales=["hours","days","weeks","months"];var settings={source:null,itemsPerPage:7,months:["January","February","March","April","May","June","July","August","September","October","November","December"],dow:["S","M","T","W","T","F","S"],startPos:new Date,navigate:"buttons",scale:"days",useCookie:false,maxScale:"months",minScale:"hours",waitText:"Please wait...",onItemClick:function(a){return},onAddClick:function(a){return},scrollToToday:true};$.extend($.expr[":"],{findday:function(a,b,c){var d=new Date(parseInt(c[3],10));var e=$(a).attr("id");e=e?e:"";var f=e.indexOf("-")+1;var g=new Date(parseInt(e.substring(f,e.length),10));d=new Date(d.getFullYear(),d.getMonth(),d.getDate());g=new Date(g.getFullYear(),g.getMonth(),g.getDate());return d.getTime()===g.getTime()}});$.extend($.expr[":"],{findweek:function(a,b,c){var d=new Date(parseInt(c[3],10));var e=$(a).attr("id");e=e?e:"";var f=e.indexOf("-")+1;d=d.getFullYear()+"-"+d.getDayForWeek().getWeekOfYear();var g=e.substring(f,e.length);return d===g}});$.extend($.expr[":"],{findmonth:function(a,b,c){var d=new Date(parseInt(c[3],10));d=d.getFullYear()+"-"+d.getMonth();var e=$(a).attr("id");e=e?e:"";var f=e.indexOf("-")+1;var g=e.substring(f,e.length);return d===g}});Date.prototype.getWeekId=function(){var a=this.getFullYear();var b=this.getDayForWeek().getWeekOfYear();var c=this.getMonth();if(c===11&&b===1){a++}return"dh-"+a+"-"+b};Date.prototype.genRepDate=function(){switch(settings.scale){case"hours":return this.getTime();case"weeks":return this.getDayForWeek().getTime();case"months":return(new Date(this.getFullYear(),this.getMonth(),1)).getTime();default:return this.getTime()}};Date.prototype.getDayOfYear=function(){var a=new Date(this.getFullYear(),0,0);var b=new Date(this.getFullYear(),this.getMonth(),this.getDate());return Math.ceil((b-a)/864e5)};Date.prototype.getWeekOfYear=function(){var a=new Date(this.getFullYear(),0,1);var b=new Date(this.getFullYear(),this.getMonth(),this.getDate());if(a.getDay()>3){a=new Date(b.getFullYear(),0,7-a.getDay())}var c=b.getDayOfYear()-a.getDayOfYear();return Math.ceil(c/7)};Date.prototype.getDaysInMonth=function(){return 32-(new Date(this.getFullYear(),this.getMonth(),32)).getDate()};Date.prototype.hasWeek=function(){var a=new Date(this.valueOf());a.setDate(a.getDate()-a.getDay());var b=new Date(this.valueOf());b.setDate(b.getDate()+(6-b.getDay()));if(a.getMonth()===b.getMonth()){return true}else{return a.getMonth()===this.getMonth()&&b.getDate()<4||a.getMonth()!==this.getMonth()&&b.getDate()>=4}};Date.prototype.getDayForWeek=function(){var a=new Date(this.valueOf());a.setDate(a.getDate()-a.getDay());var b=new Date(this.valueOf());b.setDate(b.getDate()+(6-b.getDay()));if(a.getMonth()===b.getMonth()||a.getMonth()!==b.getMonth()&&b.getDate()>=4){return new Date(b.setDate(b.getDate()-3))}else{return new Date(a.setDate(a.getDate()+3))}};var core={elementFromPoint:function(a,b){if($.browser.msie){a-=$(document).scrollLeft();b-=$(document).scrollTop()}else{a-=window.pageXOffset;b-=window.pageYOffset}return document.elementFromPoint(a,b)},create:function(a){if(typeof settings.source!=="string"){a.data=settings.source;core.init(a)}else{$.getJSON(settings.source,function(b){a.data=b;core.init(a)})}},init:function(a){a.rowsNum=a.data.length;a.pageCount=Math.ceil(a.rowsNum/settings.itemsPerPage);a.rowsOnLastPage=a.rowsNum-Math.floor(a.rowsNum/settings.itemsPerPage)*settings.itemsPerPage;a.dateStart=tools.getMinDate(a);a.dateEnd=tools.getMaxDate(a);core.waitToggle(a,true,function(){core.render(a)})},render:function(a){var b=$('
');var c=core.leftPanel(a);b.append(c);var d=core.rightPanel(a,c);var e,f;b.append(d);b.append(core.navigation(a));var g=d.find(".dataPanel");a.gantt=$('
').append(b);$(a).html(a.gantt);a.scrollNavigation.panelMargin=parseInt(g.css("margin-left").replace("px",""),10);a.scrollNavigation.panelMaxPos=g.width()-d.width();a.scrollNavigation.canScroll=g.width()>d.width();core.markNow(a);core.fillData(a,g,c);if(settings.useCookie){var h=$.cookie(this.cookieKey+"ScrollPos");if(h){a.hPosition=h}}if(settings.scrollToToday){var i=Math.round((settings.startPos/1e3-a.dateStart/1e3)/86400)-2;if(i>0&&a.hPosition!==0){if(a.scaleOldWidth){e=g.width()-d.width();f=e*a.hPosition/a.scaleOldWidth;f=f>0?0:f;g.css({"margin-left":f+"px"});a.scrollNavigation.panelMargin=f;a.hPosition=f;a.scaleOldWidth=null}else{g.css({"margin-left":a.hPosition+"px"});a.scrollNavigation.panelMargin=a.hPosition}core.repositionLabel(a)}else{core.repositionLabel(a)}}else{if(a.hPosition!==0){if(a.scaleOldWidth){e=g.width()-d.width();f=e*a.hPosition/a.scaleOldWidth;f=f>0?0:f;g.css({"margin-left":f+"px"});a.scrollNavigation.panelMargin=f;a.hPosition=f;a.scaleOldWidth=null}else{g.css({"margin-left":a.hPosition+"px"});a.scrollNavigation.panelMargin=a.hPosition}core.repositionLabel(a)}else{core.repositionLabel(a)}}g.css({height:c.height()});core.waitToggle(a,false)},leftPanel:function(a){var b=$('
').append($('
').css("height",tools.getCellSize()*a.headerRows+"px").css("width","100%"));var c=[];$.each(a.data,function(b,d){if(b>=a.pageNum*settings.itemsPerPage&&b');c.push(''+d.name+"");c.push("
");c.push('
');c.push(''+d.desc+"");c.push("
")}});b.append(c.join(""));return b},dataPanel:function(a,b){var c=$('
');var d=/Firefox/i.test(navigator.userAgent)?"DOMMouseScroll":"mousewheel";if(document.attachEvent){a.attachEvent("on"+d,function(b){core.wheelScroll(a,b)})}else if(document.addEventListener){a.addEventListener(d,function(b){core.wheelScroll(a,b)},false)}c.click(function(b){b.stopPropagation();var c,d;var e=$(a).find(".fn-gantt .leftPanel");var f=$(a).find(".fn-gantt .dataPanel");switch(settings.scale){case"weeks":d=tools.getCellSize()*2;break;case"months":d=tools.getCellSize();break;case"hours":case"days":d=tools.getCellSize()*3;break;default:d=tools.getCellSize()*2;break}var g=core.elementFromPoint(b.pageX,f.offset().top+d);if(g.className==="fn-label"){g=$(g.parentNode)}else{g=$(g)}var h=g.attr("repdate");var i=core.elementFromPoint(e.offset().left+e.width()-10,b.pageY);if(i.className.indexOf("fn-label")===0){i=$(i.parentNode)}else{i=$(i)}var j=i.data().id;settings.onAddClick(h,j)});return c},rightPanel:function(a,b){var c=null;var d=[" sn"," wd"," wd"," wd"," wd"," wd"," sa"];var e=[" sn","","","","",""," sa"];var f=['
'];var g=0;var h=['
'];var i=0;var j=[];var k=0;var l=[];var m=[];var n=new Date;n=new Date(n.getFullYear(),n.getMonth(),n.getDate());var o=settings.holidays?settings.holidays.join():"";switch(settings.scale){case"hours":c=tools.parseTimeRange(a.dateStart,a.dateEnd,a.scaleStep);var p=c[0].getFullYear();var q=c[0].getMonth();var r=c[0];for(var s=0;s
'+p+"
");p=u;g=0}g++;var v=t.getMonth();if(v!==q){h.push('
'+settings.months[q]+"
");q=v;i=0}i++;var w=t.getDay();var x=r.getDay();var y=d[w];var z=r.getTime();if(o.indexOf((new Date(t.getFullYear(),t.getMonth(),t.getDate())).getTime())>-1){y="holiday"}if(w!==x){var A=n-r===0?" today":o.indexOf(z)>-1?"holiday":d[x];j.push('
'+'
'+r.getDate()+"
");l.push('
'+'
'+settings.dow[x]+"
");r=t;k=0}k++;m.push('
'+t.getHours()+"
")}f.push('
'+p+"
");h.push('
'+settings.months[q]+"
");var y=d[r.getDay()];if(o.indexOf((new Date(r.getFullYear(),r.getMonth(),r.getDate())).getTime())>-1){y="holiday"}j.push('
'+'
'+r.getDate()+"
");l.push('
'+'
'+settings.dow[r.getDay()]+"
");var B=core.dataPanel(a,c.length*tools.getCellSize());B.append(f.join(""));B.append(h.join(""));B.append($('
').html(j.join("")));B.append($('
').html(l.join("")));B.append($('
').html(m.join("")));break;case"weeks":c=tools.parseWeeksRange(a.dateStart,a.dateEnd);f=['
'];h=['
'];var p=c[0].getFullYear();var q=c[0].getMonth();var r=c[0];for(var s=0;s
'+p+"
");p=t.getFullYear();g=0}g++;if(t.getMonth()!==q){h.push('
'+settings.months[q]+"
");q=t.getMonth();i=0}i++;j.push('
'+'
'+t.getWeekOfYear()+"
")}f.push('
'+p+"
");h.push('
'+settings.months[q]+"
");var B=core.dataPanel(a,c.length*tools.getCellSize());B.append(f.join("")+h.join("")+j.join("")+l.join(""));break;case"months":c=tools.parseMonthsRange(a.dateStart,a.dateEnd);var p=c[0].getFullYear();var q=c[0].getMonth();var r=c[0];for(var s=0;s
'+p+"
");p=t.getFullYear();g=0}g++;h.push('
'+(1+t.getMonth())+"
")}f.push('
'+p+"
");h.push('
"
'+settings.months[q]+"
");var B=core.dataPanel(a,c.length*tools.getCellSize());B.append(f.join(""));B.append(h.join(""));B.append($('
').html(j.join("")));B.append($('
').html(l.join("")));break;default:c=tools.parseDateRange(a.dateStart,a.dateEnd);var p=c[0].getFullYear();var q=c[0].getMonth();var r=c[0];for(var s=0;s
'+p+"
");p=t.getFullYear();g=0}g++;if(t.getMonth()!==q){h.push('
'+settings.months[q]+"
");q=t.getMonth();i=0}i++;var x=t.getDay();var y=d[x];if(o.indexOf((new Date(t.getFullYear(),t.getMonth(),t.getDate())).getTime())>-1){y="holiday"}j.push('
"+'
'+t.getDate()+"
");l.push('
'+'
'+settings.dow[x]+"
")}f.push('
'+p+"
");h.push('
'+settings.months[q]+"
");var B=core.dataPanel(a,c.length*tools.getCellSize());B.append(f.join(""));B.append(h.join(""));B.append($('
').html(j.join("")));B.append($('
').html(l.join("")));break}return $('
').append(B)},navigation:function(a){var b=null;if(settings.navigate==="scroll"){b=$('