Skip to content
Browse files

Latest min code

  • Loading branch information...
1 parent afd250f commit 8667cc67cc389d3f9b69d67e044a105452299918 @taitems taitems committed Apr 28, 2012
View
BIN .DS_Store
Binary file not shown.
View
BIN Archive.zip
Binary file not shown.
View
BIN css/.DS_Store
Binary file not shown.
View
BIN img/.DS_Store
Binary file not shown.
View
BIN js/.DS_Store
Binary file not shown.
View
2 js/jquery.fn.gantt.min.js
@@ -7,4 +7,4 @@
*
* Last Modified: Fri Feb 03 2012 8:57:00 +0800
*/
-(function($){"use strict";$.fn.gantt=function(options){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",maxScale:"months",minScale:"hours",waitText:"Please wait..."};$.extend($.expr[":"],{findday:function(a,b,c){var d=new Date(parseInt(c[3]));var e=$(a).attr("id");e=e?e:"";var f=e.indexOf("-")+1;var g=new Date(parseInt(e.substring(f,e.length)));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]));var e=$(a).attr("id");e=e?e:"";var f=e.indexOf("-")+1;d=d.getFullYear()+"-"+d.getDayForWeek().getWeekOfYear();var g=$(a).attr("id").substring(f,$(a).attr("id").length);return d===g}});$.extend($.expr[":"],{findmonth:function(a,b,c){var d=new Date(parseInt(c[3]));d=d.getFullYear()+"-"+d.getMonth();var e=$(a).attr("id");e=e?e:"";var f=e.indexOf("-")+1;var g=$(a).attr("id").substring(f,$(a).attr("id").length);return d===g}});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={create:function(a){$.ajaxSetup({scriptCharset:"utf-8",contentType:"application/json; charset=utf-8"});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.render(a);core.waitToggle(a,true,function(){core.render(a)})},render:function(a){var b=$('<div class="fn-content"/>');b.append(core.leftPanel(a));var c=core.rightPanel(a);b.append(c);b.append(core.navigation(a));var d=c.find(".dataPanel");a.gantt=$('<div class="fn-gantt" />').append(b);$(a).html(a.gantt);a.scrollNavigation.panelMargin=parseInt(d.css("margin-left").replace("px",""));a.scrollNavigation.panelMaxPos=d.width()-c.width();a.scrollNavigation.canScroll=d.width()>c.width();core.markNow(a);core.fillData(a);var e=Math.round((settings.startPos/1e3-a.dateStart/1e3)/86400)-2;if(e>0&&a.hPosition!=0){if(a.scaleOldWidth){var f=d.width()-c.width();var g=f*a.hPosition/a.scaleOldWidth;g=g>0?0:g;d.css({"margin-left":g+"px"});a.scrollNavigation.panelMargin=g;a.hPosition=g;a.scaleOldWidth=null}else{d.css({"margin-left":a.hPosition+"px"});a.scrollNavigation.panelMargin=a.hPosition}core.repositionLabel(a)}else{core.repositionLabel(a)}core.waitToggle(a,false)},leftPanel:function(a){var b=$('<div class="leftPanel"/>').append($('<div class="row spacer"/>').css("height",tools.getCellSize()*a.headerRows+"px").css("width","100%"));$.each(a.data,function(c,d){if(c>=a.pageNum*settings.itemsPerPage&&c<a.pageNum*settings.itemsPerPage+settings.itemsPerPage){b.append($('<div class="row name row'+c+' "/>').append($('<span class="fn-label"/>').html(d.name))).append($('<div class="row desc row'+c+' "/>').append($('<span class="fn-label"/>').html(d.desc)))}});return b},dataPanel:function(a,b){var c=$('<div class="dataPanel" style="width: '+b+'px;"/>');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.mousedown(function(b){if(b.which!=1)return true;if(b.preventDefault)b.preventDefault();a.scrollNavigation.panelMouseDown=true;core.mouseScroll(a,b)}).mousemove(function(b){if(a.scrollNavigation.panelMouseDown){core.mouseScroll(a,b)}});$(document).mouseup(function(b){if(b.which!=1)return true;a.scrollNavigation.panelMouseDown=false;a.scrollNavigation.mouseX=null;var c=$(a).find(".fn-gantt .dataPanel");c.css("cursor","auto");core.repositionLabel(a)});return c},rightPanel:function(a){var b=null;var c=[" sn"," wd"," wd"," wd"," wd"," wd"," sa"];var d=[" sn","","","","",""," sa"];var e=$('<div class="row"/>');var f=0;var g=$('<div class="row"/>');var h=0;var i="";var j=0;var k="";var l="";var m=new Date;m=new Date(m.getFullYear(),m.getMonth(),m.getDate());var n=settings.holidays?settings.holidays.join():"";switch(settings.scale){case"hours":b=tools.parseTimeRange(a.dateStart,a.dateEnd,a.scaleStep);var o=b[0].getFullYear();var p=b[0].getMonth();var q=b[0];for(var r=0;r<b.length;r++){var s=b[r];var t=s.getFullYear();if(t!=o){e.html(e.html()+$('<div class="row header year" style="width: '+tools.getCellSize()*f+'px;"><div class="fn-label">'+o+"</div></div>"));o=t;f=0}f++;var u=s.getMonth();if(u!=p){g.append($('<div class="row header month" style="width: '+tools.getCellSize()*h+'px"><div class="fn-label">'+settings.months[p]+"</div></div>"));p=u;h=0}h++;var v=s.getDay();var w=q.getDay();var x=c[v];var y=q.getTime();if(n.indexOf((new Date(s.getFullYear(),s.getMonth(),s.getDate())).getTime())>-1)x="holiday";if(v!=w){var z=m-q===0?" today":n.indexOf(y)>-1?"holiday":c[w];i+='<div class="row day '+z+'" '+' style="width: '+tools.getCellSize()*j+'px;"> '+' <div class="fn-label">'+q.getDate()+"</div></div>";k+='<div class="row day '+z+'" '+' style="width: '+tools.getCellSize()*j+'px;"> '+' <div class="fn-label">'+settings.dow[w]+"</div></div>";q=s;j=0}j++;l+='<div class="row day '+x+'" id="dh-'+s.getTime()+'"> '+s.getHours()+"</div>"}e.html(e.html()+'<div class="row header year" style="width: '+tools.getCellSize()*f+'px;"><div class="fn-label">'+o+"</div></div>");g.html(g.html()+'<div class="row header month" style="width: '+tools.getCellSize()*h+'px"><div class="fn-label">'+settings.months[p]+"</div></div>");var x=c[q.getDay()];if(n.indexOf((new Date(q.getFullYear(),q.getMonth(),q.getDate())).getTime())>-1)x="holiday";i+='<div class="row day '+x+'" '+' style="width: '+tools.getCellSize()*j+'px;"> '+' <div class="fn-label">'+q.getDate()+"</div></div>";k+='<div class="row day '+x+'" '+' style="width: '+tools.getCellSize()*j+'px;"> '+' <div class="fn-label">'+settings.dow[q.getDay()]+"</div></div>";var A=core.dataPanel(a,b.length*tools.getCellSize());A.append(e);A.append(g);A.append($('<div class="row"/>').html(i));A.append($('<div class="row"/>').html(k));A.append($('<div class="row"/>').html(l));for(var r=0;r<a.data.length;r++){var B=a.data[r];if(r>=a.pageNum*settings.itemsPerPage&&r<a.pageNum*settings.itemsPerPage+settings.itemsPerPage){var C='<div class="row">';for(var D=0;D<b.length;D++){var q=b[D];var E=d[q.getDay()];if(n.indexOf((new Date(q.getFullYear(),q.getMonth(),q.getDate())).getTime())>-1)E=" holiday";C+='<div class="row day'+E+'" id="d'+r+"-"+tools.genId(q.getTime())+'" ></div>'}A.html(A.html()+C+"</div>")}}break;case"weeks":b=tools.parseWeeksRange(a.dateStart,a.dateEnd);var o=b[0].getFullYear();var p=b[0].getMonth();var q=b[0];for(var r=0;r<b.length;r++){var s=b[r];if(s.getFullYear()!=o){e.append($('<div class="row header year" style="width: '+tools.getCellSize()*f+'px;"><div class="fn-label">'+o+"</div></div>"));o=s.getFullYear();f=0}f++;if(s.getMonth()!=p){g.append($('<div class="row header month" style="width:'+tools.getCellSize()*h+'px;"><div class="fn-label">'+settings.months[p]+"</div></div>"));p=s.getMonth();h=0}h++;i+='<div class="row day wd" '+' id="dh-'+s.getFullYear()+"-"+s.getWeekOfYear()+'"> '+' <div class="fn-label">'+s.getWeekOfYear()+"</div></div>"}e.append('<div class="row header year" style="width: '+tools.getCellSize()*f+'px;"><div class="fn-label">'+o+"</div></div>");g.append('<div class="row header month" style="width: '+tools.getCellSize()*h+'px"><div class="fn-label">'+settings.months[p]+"</div></div>");var A=core.dataPanel(a,b.length*tools.getCellSize());A.append(e);A.append(g);A.append($('<div class="row"/>').html(i));A.append($('<div class="row"/>').html(k));for(var r=0;r<a.data.length;r++){var B=a.data[r];if(r>=a.pageNum*settings.itemsPerPage&&r<a.pageNum*settings.itemsPerPage+settings.itemsPerPage){var C='<div class="row">';for(var D=0;D<b.length;D++){q=b[D];C+='<div class="row day" id="d'+r+"-"+tools.genId(q.getTime())+'"></div>'}A.append($(C+"</div>"))}}break;case"months":b=tools.parseMonthsRange(a.dateStart,a.dateEnd);var o=b[0].getFullYear();var p=b[0].getMonth();var q=b[0];for(var r=0;r<b.length;r++){var s=b[r];if(s.getFullYear()!=o){e.append($('<div class="row header year" style="width: '+tools.getCellSize()*f+'px;"><div class="fn-label">'+o+"</div></div>"));o=s.getFullYear();f=0}f++;g.append($('<div class="row day wd" id="dh-'+tools.genId(s.getTime())+'" />').html(s.getMonth()+1))}e.append('<div class="row header year" style="width: '+tools.getCellSize()*f+'px;"><div class="fn-label">'+o+"</div></div>");g.append('<div class="row header month" style="width: '+tools.getCellSize()*h+'px">"<div class="fn-label">'+settings.months[p]+"</div></div>");var A=core.dataPanel(a,b.length*tools.getCellSize());A.append(e);A.append(g);A.append($('<div class="row"/>').html(i));A.append($('<div class="row"/>').html(k));for(var r=0;r<a.data.length;r++){var B=a.data[r];if(r>=a.pageNum*settings.itemsPerPage&&r<a.pageNum*settings.itemsPerPage+settings.itemsPerPage){var C='<div class="row">';for(var D=0;D<b.length;D++){q=b[D];C+='<div class="row day" id="d'+r+"-"+tools.genId(q.getTime())+'" ></div>'}A.append($(C+"</div>"))}}break;default:b=tools.parseDateRange(a.dateStart,a.dateEnd);var o=b[0].getFullYear();var p=b[0].getMonth();var q=b[0];for(var r=0;r<b.length;r++){var s=b[r];if(s.getFullYear()!=o){e.append($('<div class="row header year" style="width:'+tools.getCellSize()*f+'px;"><div class="fn-label">'+o+"</div></div>"));o=s.getFullYear();f=0}f++;if(s.getMonth()!=p){g.append($('<div class="row header month" style="width:'+tools.getCellSize()*h+'px;"><div class="fn-label">'+settings.months[p]+"</div></div>"));p=s.getMonth();h=0}h++;var w=s.getDay();var x=c[w];if(n.indexOf((new Date(s.getFullYear(),s.getMonth(),s.getDate())).getTime())>-1)x="holiday";i+='<div class="row day '+x+'" '+' id="dh-'+tools.genId(s.getTime())+' "> '+' <div class="fn-label">'+s.getDate()+"</div></div>";k+='<div class="row day '+x+'" '+' id="dw-'+tools.genId(s.getTime())+'"> '+' <div class="fn-label">'+settings.dow[w]+"</div></div>"}e.append('<div class="row header year" style="width: '+tools.getCellSize()*f+'px;"><div class="fn-label">'+o+"</div></div>");g.append('<div class="row header month" style="width: '+tools.getCellSize()*h+'px"><div class="fn-label">'+settings.months[p]+"</div></div>");var A=core.dataPanel(a,b.length*tools.getCellSize());A.append(e);A.append(g);A.append($('<div class="row"/>').html(i));A.append($('<div class="row"/>').html(k));for(var r=0;r<a.data.length;r++){var B=a.data[r];if(r>=a.pageNum*settings.itemsPerPage&&r<a.pageNum*settings.itemsPerPage+settings.itemsPerPage){var C='<div class="row">';for(var D=0;D<b.length;D++){q=b[D];var E=d[q.getDay()];if(n.indexOf((new Date(q.getFullYear(),q.getMonth(),q.getDate())).getTime())>-1)E=" holiday";C+='<div class="row day '+E+'" id="d'+r+"-"+tools.genId(q.getTime())+'"></div>'}A.append($(C+"</div>"))}}break}return $('<div class="rightPanel"></div>').append(A)},navigation:function(a){var b=null;if(settings.navigate==="scroll"){b=$('<div class="navigate" />').append($('<div class="nav-slider" />').append($('<div class="nav-slider-left" />').append($('<span role="button" class="nav-link nav-page-back"/>').html("<").click(function(){core.navigatePage(a,-1)})).append($('<div class="page-number"/>').append($("<span/>").html(a.pageNum+1+" of "+a.pageCount))).append($('<span role="button" class="nav-link nav-page-next"/>').html(">").click(function(){core.navigatePage(a,1)})).append($('<span role="button" class="nav-link nav-now"/>').html("&#9679;").click(function(){core.navigateTo(a,"now")})).append($('<span role="button" class="nav-link nav-prev-day"/>').html("<").click(function(){core.navigateTo(a,tools.getCellSize())}))).append($('<div class="nav-slider-content" />').append($('<div class="nav-slider-bar" />').append($('<a class="nav-slider-button" />')).mousedown(function(b){if(b.preventDefault)b.preventDefault();a.scrollNavigation.scrollerMouseDown=true;core.sliderScroll(a,b)}).mousemove(function(b){if(a.scrollNavigation.scrollerMouseDown){core.sliderScroll(a,b)}}))).append($('<div class="nav-slider-right" />').append($('<span role="button" class="nav-link nav-next-day"/>').html(">").click(function(){core.navigateTo(a,tools.getCellSize()*-1)})).append($('<span role="button" class="nav-link nav-zoomIn"/>').html("&#43;").click(function(){core.zoomInOut(a,-1)})).append($('<span role="button" class="nav-link nav-zoomOut"/>').html("&#45;").click(function(){core.zoomInOut(a,1)}))));$(document).mouseup(function(){a.scrollNavigation.scrollerMouseDown=false})}else{b=$('<div class="navigate" />').append($('<span role="button" class="nav-link nav-page-back"/>').html("<").click(function(){core.navigatePage(a,-1)})).append($('<div class="page-number"/>').append($("<span/>").html(a.pageNum+1+" of "+a.pageCount))).append($('<span role="button" class="nav-link nav-page-next"/>').html(">").click(function(){core.navigatePage(a,1)})).append($('<span role="button" class="nav-link nav-begin"/>').html("&#124;<").click(function(){core.navigateTo(a,"begin")})).append($('<span role="button" class="nav-link nav-prev-week"/>').html("<<").click(function(){core.navigateTo(a,tools.getCellSize()*7)})).append($('<span role="button" class="nav-link nav-prev-day"/>').html("<").click(function(){core.navigateTo(a,tools.getCellSize())})).append($('<span role="button" class="nav-link nav-now"/>').html("&#9679;").click(function(){core.navigateTo(a,"now")})).append($('<span role="button" class="nav-link nav-next-day"/>').html(">").click(function(){core.navigateTo(a,tools.getCellSize()*-1)})).append($('<span role="button" class="nav-link nav-next-week"/>').html(">>").click(function(){core.navigateTo(a,tools.getCellSize()*-7)})).append($('<span role="button" class="nav-link nav-end"/>').html(">&#124;").click(function(){core.navigateTo(a,"end")})).append($('<span role="button" class="nav-link nav-zoomIn"/>').html("&#43;").click(function(){core.zoomInOut(a,-1)})).append($('<span role="button" class="nav-link nav-zoomOut"/>').html("&#45;").click(function(){core.zoomInOut(a,1)}))}return $('<div class="bottom"/>').append(b)},createProgressBar:function(a,b,c,d,e){var f=tools.getCellSize();var g=tools.getProgressBarMargin()||0;var h=$('<div class="bar"><div class="fn-label">'+d+"</div></div>").addClass(b).css({width:f*a-g}).data("dataObj",e);if(c){h.mouseover(function(a){var b=$('<div class="fn-gantt-hint" />').html(c);$("body").append(b);b.css("left",a.pageX);b.css("top",a.pageY);b.show()}).mouseout(function(){$(".fn-gantt-hint").remove()}).mousemove(function(a){$(".fn-gantt-hint").css("left",a.pageX);$(".fn-gantt-hint").css("top",a.pageY+15)})}return h},markNow:function(a){switch(settings.scale){case"weeks":var b=Date.parse(new Date);b=Math.floor(b/364e5)*364e5;$(a).find(':findweek("'+b+'")').removeClass("wd").addClass("today");break;case"months":$(a).find(':findmonth("'+(new Date).getTime()+'")').removeClass("wd").addClass("today");break;default:var b=Date.parse(new Date);b=Math.floor(b/364e5)*364e5;$(a).find(':findday("'+b+'")').removeClass("wd").addClass("today");break}},fillData:function(a){var b=function(a){try{a=a.replace("rgb(","").replace(")","");var b=a.split(",");var c=parseInt(b[0]);var d=parseInt(b[1]);var e=parseInt(b[2]);var f=Math.round((255-(.299*c+.587*d+.114*e))*.9,1);return"rgb("+f+", "+f+", "+f+")"}catch(g){return""}};$.each(a.data,function(c,d){if(c>=a.pageNum*settings.itemsPerPage&&c<a.pageNum*settings.itemsPerPage+settings.itemsPerPage){$.each(d.values,function(d,e){var f=null;switch(settings.scale){case"hours":var g=tools.genId(tools.dateDeserialize(e.from).getTime(),a.scaleStep);var h=tools.genId(tools.dateDeserialize(e.to).getTime(),a.scaleStep);var j=$(a).find("#d"+c+"-"+g).offset().left;var k=$(a).find("#d"+c+"-"+h).offset().left;var l=Math.floor((k-j)/tools.getCellSize())+1;f=core.createProgressBar(l,e.customClass?e.customClass:"",e.desc?e.desc:"",e.label?e.label:"",e.dataObj?e.dataObj:null);$(a).find("#d"+c+"-"+tools.genId(tools.dateDeserialize(e.from).getTime(),a.scaleStep)).append(f);break;case"weeks":case"months":var g=tools.genId(tools.dateDeserialize(e.from).getTime());var h=tools.genId(tools.dateDeserialize(e.to).getTime());var j=$(a).find("#d"+c+"-"+g).offset().left;var k=$(a).find("#d"+c+"-"+h).offset().left;var l=Math.round((k-j)/tools.getCellSize())+1;f=core.createProgressBar(l,e.customClass?e.customClass:"",e.desc?e.desc:"",e.label?e.label:"",e.dataObj?e.dataObj:null);$(a).find("#d"+c+"-"+tools.genId(tools.dateDeserialize(e.from).getTime(),a.scaleStep)).append(f);break;default:var g=tools.genId(tools.dateDeserialize(e.from).getTime());var h=tools.genId(tools.dateDeserialize(e.to).getTime());var l=Math.floor((h/1e3-g/1e3)/86400)+1;f=core.createProgressBar(l,e.customClass?e.customClass:"",e.desc?e.desc:"",e.label?e.label:"",e.dataObj?e.dataObj:null);var m=$(a).find("#d"+c+"-"+tools.genId(tools.dateDeserialize(e.from).getTime()));m.append(f);break}var n=f.find(".fn-label");if(n&&f.length){var o=b(f[0].style.backgroundColor);n.css("color",o)}else if(n){n.css("color","")}})}})},navigateTo:function(a,b){var c=$(a).find(".fn-gantt .rightPanel");var d=c.find(".dataPanel");var e=c.width();var f=d.width();switch(b){case"begin":d.animate({"margin-left":"0px"},"fast",function(){core.repositionLabel(a)});a.scrollNavigation.panelMargin=0;break;case"end":var g=f-e;a.scrollNavigation.panelMargin=g*-1;d.animate({"margin-left":"-"+g+"px"},"fast",function(){core.repositionLabel(a)});break;case"now":if(!a.scrollNavigation.canScroll)return false;var h=(f-e)*-1;var i=d.css("margin-left").replace("px","");var b=d.find(".today").offset().left-d.offset().left;b*=-1;if(b>0)b=0;else if(b<h)b=h;d.animate({"margin-left":b+"px"},"fast",core.repositionLabel(a));a.scrollNavigation.panelMargin=b;break;default:var h=(f-e)*-1;var i=d.css("margin-left").replace("px","");var b=parseInt(i)+b;if(b<=0&&b>=h)d.animate({"margin-left":b+"px"},"fast",core.repositionLabel(a));a.scrollNavigation.panelMargin=b;break}},navigatePage:function(a,b){if(a.pageNum+b>=0&&a.pageNum+b<Math.ceil(a.rowsNum/settings.itemsPerPage)){core.waitToggle(a,true,function(){a.pageNum+=b;a.hPosition=$(".fn-gantt .dataPanel").css("margin-left").replace("px","");a.scaleOldWidth=false;core.init(a)})}},zoomInOut:function(a,b){core.waitToggle(a,true,function(){var c=b<0;var d=a.scaleStep+b*3;d=d<=1?1:d===4?3:d;var e=settings.scale;var f=a.headerRows;if(settings.scale==="hours"&&d>=13){e="days";f=4;d=13}else if(settings.scale==="days"&&c){e="hours";f=5;d=12}else if(settings.scale==="days"&&!c){e="weeks";f=3;d=13}else if(settings.scale==="weeks"&&!c){e="months";f=2;d=14}else if(settings.scale==="weeks"&&c){e="days";f=4;d=13}else if(settings.scale==="months"&&c){e="weeks";f=3;d=13}if(c&&$.inArray(e,scales)<$.inArray(settings.minScale,scales)||!c&&$.inArray(e,scales)>$.inArray(settings.maxScale,scales)){core.init(a);return}a.scaleStep=d;settings.scale=e;a.headerRows=f;var g=$(a).find(".fn-gantt .rightPanel");var h=g.find(".dataPanel");a.hPosition=h.css("margin-left").replace("px","");a.scaleOldWidth=h.width()-g.width();core.init(a)})},mouseScroll:function(a,b){var c=$(a).find(".fn-gantt .dataPanel");c.css("cursor","move");var d=c.offset();var e=a.scrollNavigation.mouseX===null?b.pageX:a.scrollNavigation.mouseX;var f=b.pageX-e;a.scrollNavigation.mouseX=b.pageX;core.scrollPanel(a,f);clearTimeout(a.scrollNavigation.repositionDelay);a.scrollNavigation.repositionDelay=setTimeout(core.repositionLabel,50,a)},wheelScroll:function(a,b){var c=b.detail?b.detail*-50:b.wheelDelta/120*50;core.scrollPanel(a,c);clearTimeout(a.scrollNavigation.repositionDelay);a.scrollNavigation.repositionDelay=setTimeout(core.repositionLabel,50,a);if(b.preventDefault)b.preventDefault();else return false},sliderScroll:function(a,b){var c=$(a).find(".nav-slider-bar");var d=c.find(".nav-slider-button");var e=$(a).find(".fn-gantt .rightPanel");var f=e.find(".dataPanel");var g=c.offset();var h=c.width();var i=d.width();if(b.pageX>=g.left&&b.pageX<=g.left+h){var j=b.pageX-g.left;var j=j-i/2;d.css("left",j);var k=f.width()-e.width();var l=j*k/h*-1;if(l>=0){f.css("margin-left","0px");a.scrollNavigation.panelMargin=0}else if(j>=h-i*1){f.css("margin-left",k*-1+"px");a.scrollNavigation.panelMargin=k*-1}else{f.css("margin-left",l+"px");a.scrollNavigation.panelMargin=l}clearTimeout(a.scrollNavigation.repositionDelay);a.scrollNavigation.repositionDelay=setTimeout(core.repositionLabel,50,a)}},scrollPanel:function(a,b){if(!a.scrollNavigation.canScroll)return false;var c=parseInt(a.scrollNavigation.panelMargin)+b;if(c>0){a.scrollNavigation.panelMargin=0;$(a).find(".fn-gantt .dataPanel").css("margin-left",a.scrollNavigation.panelMargin+"px")}else if(c<a.scrollNavigation.panelMaxPos*-1){a.scrollNavigation.panelMargin=a.scrollNavigation.panelMaxPos*-1;$(a).find(".fn-gantt .dataPanel").css("margin-left",a.scrollNavigation.panelMargin+"px")}else{a.scrollNavigation.panelMargin=c;$(a).find(".fn-gantt .dataPanel").css("margin-left",a.scrollNavigation.panelMargin+"px")}},synchronizeScroller:function(a){if(settings.navigate==="scroll"){var b=$(a).find(".fn-gantt .rightPanel");var c=b.find(".dataPanel");var d=$(a).find(".nav-slider-bar");var e=d.find(".nav-slider-button");var f=d.width();var g=e.width();var h=c.width()-b.width();var i=0;if(c.css("margin-left"))i=c.css("margin-left").replace("px","");var j=i*f/h-e.width()*.25;j=j>0?0:j*-1>=f-g*.75?(f-g*1.25)*-1:j;e.css("left",j*-1)}},repositionLabel:function(a){var b=$(".fn-gantt .rightPanel");var c=b.find(".dataPanel");c.stop();var d={offset:b.offset(),width:b.width(),height:b.height()};$(".fn-gantt .rightPanel .year, .fn-gantt .rightPanel .month").each(function(a,b){var c={offset:$(b).offset(),width:$(b).width(),height:$(b).height()};if(c.offset.left+c.width>d.offset.left&&c.offset.left<d.offset.left+d.width){var e={left:c.offset.left>d.offset.left?c.offset.left:d.offset.left,right:c.offset.left+c.width<d.offset.left+d.width?c.offset.left+c.width:d.offset.left+d.width};$(b).children(".fn-label").css("float","left");var f=$(b).children(".fn-label").width();var g=c.offset.left<d.offset.left?d.offset.left-c.offset.left:0;if(e.right-e.left>f)$(b).children(".fn-label").css("margin-left",g+(e.right-e.left)/2-f/2+"px")}});$(".fn-gantt .rightPanel .bar").each(function(a,b){var c={offset:$(b).offset(),width:$(b).width(),height:$(b).height()};if(c.offset.left+c.width>d.offset.left&&c.offset.left<d.offset.left+d.width){var e={left:c.offset.left>d.offset.left?c.offset.left:d.offset.left,right:c.offset.left+c.width<d.offset.left+d.width?c.offset.left+c.width:d.offset.left+d.width};$(b).children(".fn-label").css("float","left");var f=$(b).children(".fn-label").width();var g=c.offset.left<d.offset.left?d.offset.left-c.offset.left:0;if(e.right-e.left>f)$(b).children(".fn-label").css("margin-left",g+(e.right-e.left)/2-f/2+"px")}});core.synchronizeScroller(a)},waitToggle:function(a,b,c){if(b){var d=$(a).offset();var e=$(a).outerWidth();var f=$(a).outerHeight();if(!a.loader){a.loader=$('<div class="fn-gantt-loader" style="position: absolute; top: '+d.top+"px; left: "+d.left+"px; width: "+e+"px; height: "+f+'px;">'+'<div class="fn-gantt-loader-spinner"><span>'+settings.waitText+"</span></div></div>")}$("body").append(a.loader);setTimeout(c,100)}else{if(a.loader)a.loader.remove();a.loader=null}}};var tools={getMaxDate:function(a){var b=null;$.each(a.data,function(a,c){$.each(c.values,function(a,c){b=b<tools.dateDeserialize(c.to)?tools.dateDeserialize(c.to):b})});switch(settings.scale){case"hours":b.setHours(Math.ceil(b.getHours()/a.scaleStep)*a.scaleStep);b.setHours(b.getHours()+a.scaleStep*3);break;case"weeks":var c=new Date(b.getTime());var c=new Date(c.setDate(c.getDate()+3*7));var d=Math.floor(c.getDate()/7)*7;b=new Date(c.getFullYear(),c.getMonth(),d===0?4:d-3);break;case"months":var c=new Date(b.getFullYear(),b.getMonth(),1);c.setMonth(c.getMonth()+2);b=new Date(c.getFullYear(),c.getMonth(),1);break;default:b.setHours(0);b.setDate(b.getDate()+3);break}return b},getMinDate:function(a){var b=null;$.each(a.data,function(a,c){$.each(c.values,function(a,c){b=b>tools.dateDeserialize(c.from)||b===null?tools.dateDeserialize(c.from):b})});switch(settings.scale){case"hours":b.setHours(Math.floor(b.getHours()/a.scaleStep)*a.scaleStep);b.setHours(b.getHours()-a.scaleStep*3);break;case"weeks":var c=new Date(b.getTime());var c=new Date(c.setDate(c.getDate()-3*7));var d=Math.floor(c.getDate()/7)*7;b=new Date(c.getFullYear(),c.getMonth(),d===0?4:d-3);break;case"months":var c=new Date(b.getFullYear(),b.getMonth(),1);c.setMonth(c.getMonth()-3);b=new Date(c.getFullYear(),c.getMonth(),1);break;default:b.setHours(0);b.setDate(b.getDate()-3);break}return b},parseDateRange:function(a,b){var c=new Date(a.getTime());var d=new Date(b.getTime());var e=new Array;var f=0;do{e[f++]=new Date(c.getTime());c.setDate(c.getDate()+1)}while(c.getTime()<=b.getTime());return e},parseTimeRange:function(a,b,c){var d=new Date(a);var e=new Date(b);var f=new Array;var g=0;do{f[g]=new Date(d.getTime());d.setHours(d.getHours()+c);d.setHours(Math.floor(d.getHours()/c)*c);if(d.getDay()!=f[g].getDay())d.setHours(0);g++}while(d.getTime()<=b.getTime());return f},parseWeeksRange:function(a,b){var c=new Date(a);var d=new Date(b);var e=new Array;var f=0;do{if(c.getDay()===0){e[f++]=c.getDayForWeek()}c.setDate(c.getDate()+1)}while(c.getTime()<=b.getTime());return e},parseMonthsRange:function(a,b){var c=new Date(a);var d=new Date(b);var e=new Array;var f=0;do{e[f++]=new Date(c.getFullYear(),c.getMonth(),1);c.setMonth(c.getMonth()+1)}while(c.getTime()<=b.getTime());return e},dateDeserialize:function(dateStr){var date=eval("new"+dateStr.replace(/\//g," "));return new Date(date.getUTCFullYear(),date.getUTCMonth(),date.getUTCDate(),date.getUTCHours(),date.getUTCMinutes())},genId:function(a){var b=new Date(a);switch(settings.scale){case"hours":var c=b.getHours();if(arguments.length>=2)c=Math.floor(b.getHours()/arguments[1])*arguments[1];return(new Date(b.getFullYear(),b.getMonth(),b.getDate(),c)).getTime();break;case"weeks":return b.getFullYear()+"-"+b.getDayForWeek().getWeekOfYear();break;case"months":return b.getFullYear()+"-"+b.getMonth();break;default:return(new Date(b.getFullYear(),b.getMonth(),b.getDate())).getTime();break}},_getCellSize:null,getCellSize:function(){if(!tools._getCellSize){$("body").append($('<div style="display: none; position: absolute;" class="fn-gantt" id="measureCellWidth"><div class="row"></div></div>'));tools._getCellSize=$("#measureCellWidth .row").height();$("#measureCellWidth").empty().remove()}return tools._getCellSize},getRightPanelSize:function(){$("body").append($('<div style="display: none; position: absolute;" class="fn-gantt" id="measureCellWidth"><div class="rightPanel"></div></div>'));var a=$("#measureCellWidth .rightPanel").height();$("#measureCellWidth").empty().remove();return a},getPageHeight:function(a){return a.pageNum+1===a.pageCount?rowsOnLastPage*tools.getCellSize():settings.itemsPerPage*tools.getCellSize()},_getProgressBarMargin:null,getProgressBarMargin:function(){if(!tools._getProgressBarMargin){$("body").append($('<div style="display: none; position: absolute;" id="measureBarWidth" ><div class="fn-gantt"><div class="rightPanel"><div class="dataPanel"><div class="row day"><div class="bar" /></div></div></div></div></div>'));tools._getProgressBarMargin=parseInt($("#measureBarWidth .fn-gantt .rightPanel .day .bar").css("margin-left").replace("px",""));tools._getProgressBarMargin+=parseInt($("#measureBarWidth .fn-gantt .rightPanel .day .bar").css("margin-right").replace("px",""));$("#measureBarWidth").empty().remove()}return tools._getProgressBarMargin}};this.each(function(){if(options)$.extend(settings,options);this.data=null;this.pageNum=0;this.pageCount=0;this.rowsOnLastPage=0;this.rowsNum=0;this.hPosition=0;this.dateStart=null;this.dateEnd=null;this.scrollClicked=false;this.scaleOldWidth=null;this.headerRows=null;switch(settings.scale){case"hours":this.headerRows=5;this.scaleStep=1;break;case"weeks":this.headerRows=3;this.scaleStep=13;break;case"months":this.headerRows=2;this.scaleStep=14;break;default:this.headerRows=4;this.scaleStep=13;break}this.scrollNavigation={panelMouseDown:false,scrollerMouseDown:false,mouseX:null,panelMargin:0,repositionDelay:0,panelMaxPos:0,canScroll:true};this.gantt=null;this.loader=null;core.create(this)})}})(jQuery)
+(function($){"use strict";$.fn.gantt=function(options){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",maxScale:"months",minScale:"hours",waitText:"Please wait..."};$.extend($.expr[":"],{findday:function(a,b,c){var d=new Date(parseInt(c[3]));var e=$(a).attr("id");e=e?e:"";var f=e.indexOf("-")+1;var g=new Date(parseInt(e.substring(f,e.length)));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]));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]));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.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={create:function(a){$.ajaxSetup({scriptCharset:"utf-8",contentType:"application/json; charset=utf-8"});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.render(a);core.waitToggle(a,true,function(){core.render(a)})},render:function(a){var b=$('<div class="fn-content"/>');b.append(core.leftPanel(a));var c=core.rightPanel(a);b.append(c);b.append(core.navigation(a));var d=c.find(".dataPanel");a.gantt=$('<div class="fn-gantt" />').append(b);$(a).html(a.gantt);a.scrollNavigation.panelMargin=parseInt(d.css("margin-left").replace("px",""));a.scrollNavigation.panelMaxPos=d.width()-c.width();a.scrollNavigation.canScroll=d.width()>c.width();core.markNow(a);core.fillData(a);var e=Math.round((settings.startPos/1e3-a.dateStart/1e3)/86400)-2;if(e>0&&a.hPosition!=0){if(a.scaleOldWidth){var f=d.width()-c.width();var g=f*a.hPosition/a.scaleOldWidth;g=g>0?0:g;d.css({"margin-left":g+"px"});a.scrollNavigation.panelMargin=g;a.hPosition=g;a.scaleOldWidth=null}else{d.css({"margin-left":a.hPosition+"px"});a.scrollNavigation.panelMargin=a.hPosition}core.repositionLabel(a)}else{core.repositionLabel(a)}core.waitToggle(a,false)},leftPanel:function(a){var b=$('<div class="leftPanel"/>').append($('<div class="row spacer"/>').css("height",tools.getCellSize()*a.headerRows+"px").css("width","100%"));$.each(a.data,function(c,d){if(c>=a.pageNum*settings.itemsPerPage&&c<a.pageNum*settings.itemsPerPage+settings.itemsPerPage){b.append($('<div class="row name row'+c+' "/>').append($('<span class="fn-label"/>').html(d.name))).append($('<div class="row desc row'+c+' "/>').append($('<span class="fn-label"/>').html(d.desc)))}});return b},dataPanel:function(a,b){var c=$('<div class="dataPanel" style="width: '+b+'px;"/>');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.mousedown(function(b){if(b.which!=1)return true;if(b.preventDefault)b.preventDefault();a.scrollNavigation.panelMouseDown=true;core.mouseScroll(a,b)}).mousemove(function(b){if(a.scrollNavigation.panelMouseDown){core.mouseScroll(a,b)}});$(document).mouseup(function(b){if(b.which!=1)return true;a.scrollNavigation.panelMouseDown=false;a.scrollNavigation.mouseX=null;var c=$(a).find(".fn-gantt .dataPanel");c.css("cursor","auto");core.repositionLabel(a)});return c},rightPanel:function(a){var b=null;var c=[" sn"," wd"," wd"," wd"," wd"," wd"," sa"];var d=[" sn","","","","",""," sa"];var e=$('<div class="row"/>');var f=0;var g=$('<div class="row"/>');var h=0;var i="";var j=0;var k="";var l="";var m=new Date;m=new Date(m.getFullYear(),m.getMonth(),m.getDate());var n=settings.holidays?settings.holidays.join():"";switch(settings.scale){case"hours":b=tools.parseTimeRange(a.dateStart,a.dateEnd,a.scaleStep);var o=b[0].getFullYear();var p=b[0].getMonth();var q=b[0];for(var r=0;r<b.length;r++){var s=b[r];var t=s.getFullYear();if(t!=o){e.html(e.html()+$('<div class="row header year" style="width: '+tools.getCellSize()*f+'px;"><div class="fn-label">'+o+"</div></div>"));o=t;f=0}f++;var u=s.getMonth();if(u!=p){g.append($('<div class="row header month" style="width: '+tools.getCellSize()*h+'px"><div class="fn-label">'+settings.months[p]+"</div></div>"));p=u;h=0}h++;var v=s.getDay();var w=q.getDay();var x=c[v];var y=q.getTime();if(n.indexOf((new Date(s.getFullYear(),s.getMonth(),s.getDate())).getTime())>-1)x="holiday";if(v!=w){var z=m-q===0?" today":n.indexOf(y)>-1?"holiday":c[w];i+='<div class="row day '+z+'" '+' style="width: '+tools.getCellSize()*j+'px;"> '+' <div class="fn-label">'+q.getDate()+"</div></div>";k+='<div class="row day '+z+'" '+' style="width: '+tools.getCellSize()*j+'px;"> '+' <div class="fn-label">'+settings.dow[w]+"</div></div>";q=s;j=0}j++;l+='<div class="row day '+x+'" id="dh-'+s.getTime()+'"> '+s.getHours()+"</div>"}e.html(e.html()+'<div class="row header year" style="width: '+tools.getCellSize()*f+'px;"><div class="fn-label">'+o+"</div></div>");g.html(g.html()+'<div class="row header month" style="width: '+tools.getCellSize()*h+'px"><div class="fn-label">'+settings.months[p]+"</div></div>");var x=c[q.getDay()];if(n.indexOf((new Date(q.getFullYear(),q.getMonth(),q.getDate())).getTime())>-1)x="holiday";i+='<div class="row day '+x+'" '+' style="width: '+tools.getCellSize()*j+'px;"> '+' <div class="fn-label">'+q.getDate()+"</div></div>";k+='<div class="row day '+x+'" '+' style="width: '+tools.getCellSize()*j+'px;"> '+' <div class="fn-label">'+settings.dow[q.getDay()]+"</div></div>";var A=core.dataPanel(a,b.length*tools.getCellSize());A.append(e);A.append(g);A.append($('<div class="row"/>').html(i));A.append($('<div class="row"/>').html(k));A.append($('<div class="row"/>').html(l));for(var r=0;r<a.data.length;r++){var B=a.data[r];if(r>=a.pageNum*settings.itemsPerPage&&r<a.pageNum*settings.itemsPerPage+settings.itemsPerPage){var C='<div class="row">';for(var D=0;D<b.length;D++){var q=b[D];var E=d[q.getDay()];if(n.indexOf((new Date(q.getFullYear(),q.getMonth(),q.getDate())).getTime())>-1)E=" holiday";C+='<div class="row day'+E+'" id="d'+r+"-"+tools.genId(q.getTime())+'" ></div>'}A.html(A.html()+C+"</div>")}}break;case"weeks":b=tools.parseWeeksRange(a.dateStart,a.dateEnd);var o=b[0].getFullYear();var p=b[0].getMonth();var q=b[0];for(var r=0;r<b.length;r++){var s=b[r];if(s.getFullYear()!=o){e.append($('<div class="row header year" style="width: '+tools.getCellSize()*f+'px;"><div class="fn-label">'+o+"</div></div>"));o=s.getFullYear();f=0}f++;if(s.getMonth()!=p){g.append($('<div class="row header month" style="width:'+tools.getCellSize()*h+'px;"><div class="fn-label">'+settings.months[p]+"</div></div>"));p=s.getMonth();h=0}h++;i+='<div class="row day wd" '+' id="dh-'+s.getFullYear()+"-"+s.getWeekOfYear()+'"> '+' <div class="fn-label">'+s.getWeekOfYear()+"</div></div>"}e.append('<div class="row header year" style="width: '+tools.getCellSize()*f+'px;"><div class="fn-label">'+o+"</div></div>");g.append('<div class="row header month" style="width: '+tools.getCellSize()*h+'px"><div class="fn-label">'+settings.months[p]+"</div></div>");var A=core.dataPanel(a,b.length*tools.getCellSize());A.append(e);A.append(g);A.append($('<div class="row"/>').html(i));A.append($('<div class="row"/>').html(k));for(var r=0;r<a.data.length;r++){var B=a.data[r];if(r>=a.pageNum*settings.itemsPerPage&&r<a.pageNum*settings.itemsPerPage+settings.itemsPerPage){var C='<div class="row">';for(var D=0;D<b.length;D++){q=b[D];C+='<div class="row day" id="d'+r+"-"+tools.genId(q.getTime())+'"></div>'}A.append($(C+"</div>"))}}break;case"months":b=tools.parseMonthsRange(a.dateStart,a.dateEnd);var o=b[0].getFullYear();var p=b[0].getMonth();var q=b[0];for(var r=0;r<b.length;r++){var s=b[r];if(s.getFullYear()!=o){e.append($('<div class="row header year" style="width: '+tools.getCellSize()*f+'px;"><div class="fn-label">'+o+"</div></div>"));o=s.getFullYear();f=0}f++;g.append($('<div class="row day wd" id="dh-'+tools.genId(s.getTime())+'" />').html(s.getMonth()+1))}e.append('<div class="row header year" style="width: '+tools.getCellSize()*f+'px;"><div class="fn-label">'+o+"</div></div>");g.append('<div class="row header month" style="width: '+tools.getCellSize()*h+'px">"<div class="fn-label">'+settings.months[p]+"</div></div>");var A=core.dataPanel(a,b.length*tools.getCellSize());A.append(e);A.append(g);A.append($('<div class="row"/>').html(i));A.append($('<div class="row"/>').html(k));for(var r=0;r<a.data.length;r++){var B=a.data[r];if(r>=a.pageNum*settings.itemsPerPage&&r<a.pageNum*settings.itemsPerPage+settings.itemsPerPage){var C='<div class="row">';for(var D=0;D<b.length;D++){q=b[D];C+='<div class="row day" id="d'+r+"-"+tools.genId(q.getTime())+'" ></div>'}A.append($(C+"</div>"))}}break;default:b=tools.parseDateRange(a.dateStart,a.dateEnd);var o=b[0].getFullYear();var p=b[0].getMonth();var q=b[0];for(var r=0;r<b.length;r++){var s=b[r];if(s.getFullYear()!=o){e.append($('<div class="row header year" style="width:'+tools.getCellSize()*f+'px;"><div class="fn-label">'+o+"</div></div>"));o=s.getFullYear();f=0}f++;if(s.getMonth()!=p){g.append($('<div class="row header month" style="width:'+tools.getCellSize()*h+'px;"><div class="fn-label">'+settings.months[p]+"</div></div>"));p=s.getMonth();h=0}h++;var w=s.getDay();var x=c[w];if(n.indexOf((new Date(s.getFullYear(),s.getMonth(),s.getDate())).getTime())>-1)x="holiday";i+='<div class="row day '+x+'" '+' id="dh-'+tools.genId(s.getTime())+' "> '+' <div class="fn-label">'+s.getDate()+"</div></div>";k+='<div class="row day '+x+'" '+' id="dw-'+tools.genId(s.getTime())+'"> '+' <div class="fn-label">'+settings.dow[w]+"</div></div>"}e.append('<div class="row header year" style="width: '+tools.getCellSize()*f+'px;"><div class="fn-label">'+o+"</div></div>");g.append('<div class="row header month" style="width: '+tools.getCellSize()*h+'px"><div class="fn-label">'+settings.months[p]+"</div></div>");var A=core.dataPanel(a,b.length*tools.getCellSize());A.append(e);A.append(g);A.append($('<div class="row"/>').html(i));A.append($('<div class="row"/>').html(k));for(var r=0;r<a.data.length;r++){var B=a.data[r];if(r>=a.pageNum*settings.itemsPerPage&&r<a.pageNum*settings.itemsPerPage+settings.itemsPerPage){var C='<div class="row">';for(var D=0;D<b.length;D++){q=b[D];var E=d[q.getDay()];if(n.indexOf((new Date(q.getFullYear(),q.getMonth(),q.getDate())).getTime())>-1)E=" holiday";C+='<div class="row day '+E+'" id="d'+r+"-"+tools.genId(q.getTime())+'"></div>'}A.append($(C+"</div>"))}}break}return $('<div class="rightPanel"></div>').append(A)},navigation:function(a){var b=null;if(settings.navigate==="scroll"){b=$('<div class="navigate" />').append($('<div class="nav-slider" />').append($('<div class="nav-slider-left" />').append($('<span role="button" class="nav-link nav-page-back"/>').html("<").click(function(){core.navigatePage(a,-1)})).append($('<div class="page-number"/>').append($("<span/>").html(a.pageNum+1+" of "+a.pageCount))).append($('<span role="button" class="nav-link nav-page-next"/>').html(">").click(function(){core.navigatePage(a,1)})).append($('<span role="button" class="nav-link nav-now"/>').html("&#9679;").click(function(){core.navigateTo(a,"now")})).append($('<span role="button" class="nav-link nav-prev-day"/>').html("<").click(function(){core.navigateTo(a,tools.getCellSize())}))).append($('<div class="nav-slider-content" />').append($('<div class="nav-slider-bar" />').append($('<a class="nav-slider-button" />')).mousedown(function(b){if(b.preventDefault)b.preventDefault();a.scrollNavigation.scrollerMouseDown=true;core.sliderScroll(a,b)}).mousemove(function(b){if(a.scrollNavigation.scrollerMouseDown){core.sliderScroll(a,b)}}))).append($('<div class="nav-slider-right" />').append($('<span role="button" class="nav-link nav-next-day"/>').html(">").click(function(){core.navigateTo(a,tools.getCellSize()*-1)})).append($('<span role="button" class="nav-link nav-zoomIn"/>').html("&#43;").click(function(){core.zoomInOut(a,-1)})).append($('<span role="button" class="nav-link nav-zoomOut"/>').html("&#45;").click(function(){core.zoomInOut(a,1)}))));$(document).mouseup(function(){a.scrollNavigation.scrollerMouseDown=false})}else{b=$('<div class="navigate" />').append($('<span role="button" class="nav-link nav-page-back"/>').html("<").click(function(){core.navigatePage(a,-1)})).append($('<div class="page-number"/>').append($("<span/>").html(a.pageNum+1+" of "+a.pageCount))).append($('<span role="button" class="nav-link nav-page-next"/>').html(">").click(function(){core.navigatePage(a,1)})).append($('<span role="button" class="nav-link nav-begin"/>').html("&#124;<").click(function(){core.navigateTo(a,"begin")})).append($('<span role="button" class="nav-link nav-prev-week"/>').html("<<").click(function(){core.navigateTo(a,tools.getCellSize()*7)})).append($('<span role="button" class="nav-link nav-prev-day"/>').html("<").click(function(){core.navigateTo(a,tools.getCellSize())})).append($('<span role="button" class="nav-link nav-now"/>').html("&#9679;").click(function(){core.navigateTo(a,"now")})).append($('<span role="button" class="nav-link nav-next-day"/>').html(">").click(function(){core.navigateTo(a,tools.getCellSize()*-1)})).append($('<span role="button" class="nav-link nav-next-week"/>').html(">>").click(function(){core.navigateTo(a,tools.getCellSize()*-7)})).append($('<span role="button" class="nav-link nav-end"/>').html(">&#124;").click(function(){core.navigateTo(a,"end")})).append($('<span role="button" class="nav-link nav-zoomIn"/>').html("&#43;").click(function(){core.zoomInOut(a,-1)})).append($('<span role="button" class="nav-link nav-zoomOut"/>').html("&#45;").click(function(){core.zoomInOut(a,1)}))}return $('<div class="bottom"/>').append(b)},createProgressBar:function(a,b,c,d,e){var f=tools.getCellSize();var g=tools.getProgressBarMargin()||0;var h=$('<div class="bar"><div class="fn-label">'+d+"</div></div>").addClass(b).css({width:f*a-g}).data("dataObj",e);if(c){h.mouseover(function(a){var b=$('<div class="fn-gantt-hint" />').html(c);$("body").append(b);b.css("left",a.pageX);b.css("top",a.pageY);b.show()}).mouseout(function(){$(".fn-gantt-hint").remove()}).mousemove(function(a){$(".fn-gantt-hint").css("left",a.pageX);$(".fn-gantt-hint").css("top",a.pageY+15)})}return h},markNow:function(a){switch(settings.scale){case"weeks":var b=Date.parse(new Date);b=Math.floor(b/364e5)*364e5;$(a).find(':findweek("'+b+'")').removeClass("wd").addClass("today");break;case"months":$(a).find(':findmonth("'+(new Date).getTime()+'")').removeClass("wd").addClass("today");break;default:var b=Date.parse(new Date);b=Math.floor(b/364e5)*364e5;$(a).find(':findday("'+b+'")').removeClass("wd").addClass("today");break}},fillData:function(a){var b=function(a){try{a=a.replace("rgb(","").replace(")","");var b=a.split(",");var c=parseInt(b[0]);var d=parseInt(b[1]);var e=parseInt(b[2]);var f=Math.round((255-(.299*c+.587*d+.114*e))*.9,1);return"rgb("+f+", "+f+", "+f+")"}catch(g){return""}};$.each(a.data,function(c,d){if(c>=a.pageNum*settings.itemsPerPage&&c<a.pageNum*settings.itemsPerPage+settings.itemsPerPage){$.each(d.values,function(d,e){var f=null;switch(settings.scale){case"hours":var g=tools.genId(tools.dateDeserialize(e.from).getTime(),a.scaleStep);var h=tools.genId(tools.dateDeserialize(e.to).getTime(),a.scaleStep);var j=$(a).find("#d"+c+"-"+g).offset().left;var k=$(a).find("#d"+c+"-"+h).offset().left;var l=Math.floor((k-j)/tools.getCellSize())+1;f=core.createProgressBar(l,e.customClass?e.customClass:"",e.desc?e.desc:"",e.label?e.label:"",e.dataObj?e.dataObj:null);$(a).find("#d"+c+"-"+tools.genId(tools.dateDeserialize(e.from).getTime(),a.scaleStep)).append(f);break;case"weeks":case"months":var g=tools.genId(tools.dateDeserialize(e.from).getTime());var h=tools.genId(tools.dateDeserialize(e.to).getTime());var j=$(a).find("#d"+c+"-"+g).offset().left;var k=$(a).find("#d"+c+"-"+h).offset().left;var l=Math.round((k-j)/tools.getCellSize())+1;f=core.createProgressBar(l,e.customClass?e.customClass:"",e.desc?e.desc:"",e.label?e.label:"",e.dataObj?e.dataObj:null);$(a).find("#d"+c+"-"+tools.genId(tools.dateDeserialize(e.from).getTime(),a.scaleStep)).append(f);break;default:var g=tools.genId(tools.dateDeserialize(e.from).getTime());var h=tools.genId(tools.dateDeserialize(e.to).getTime());var l=Math.floor((h/1e3-g/1e3)/86400)+1;f=core.createProgressBar(l,e.customClass?e.customClass:"",e.desc?e.desc:"",e.label?e.label:"",e.dataObj?e.dataObj:null);var m=$(a).find("#d"+c+"-"+tools.genId(tools.dateDeserialize(e.from).getTime()));m.append(f);break}var n=f.find(".fn-label");if(n&&f.length){var o=b(f[0].style.backgroundColor);n.css("color",o)}else if(n){n.css("color","")}})}})},navigateTo:function(a,b){var c=$(a).find(".fn-gantt .rightPanel");var d=c.find(".dataPanel");var e=c.width();var f=d.width();switch(b){case"begin":d.animate({"margin-left":"0px"},"fast",function(){core.repositionLabel(a)});a.scrollNavigation.panelMargin=0;break;case"end":var g=f-e;a.scrollNavigation.panelMargin=g*-1;d.animate({"margin-left":"-"+g+"px"},"fast",function(){core.repositionLabel(a)});break;case"now":if(!a.scrollNavigation.canScroll)return false;var h=(f-e)*-1;var i=d.css("margin-left").replace("px","");var b=d.find(".today").offset().left-d.offset().left;b*=-1;if(b>0)b=0;else if(b<h)b=h;d.animate({"margin-left":b+"px"},"fast",core.repositionLabel(a));a.scrollNavigation.panelMargin=b;break;default:var h=(f-e)*-1;var i=d.css("margin-left").replace("px","");var b=parseInt(i)+b;if(b<=0&&b>=h)d.animate({"margin-left":b+"px"},"fast",core.repositionLabel(a));a.scrollNavigation.panelMargin=b;break}},navigatePage:function(a,b){if(a.pageNum+b>=0&&a.pageNum+b<Math.ceil(a.rowsNum/settings.itemsPerPage)){core.waitToggle(a,true,function(){a.pageNum+=b;a.hPosition=$(".fn-gantt .dataPanel").css("margin-left").replace("px","");a.scaleOldWidth=false;core.init(a)})}},zoomInOut:function(a,b){core.waitToggle(a,true,function(){var c=b<0;var d=a.scaleStep+b*3;d=d<=1?1:d===4?3:d;var e=settings.scale;var f=a.headerRows;if(settings.scale==="hours"&&d>=13){e="days";f=4;d=13}else if(settings.scale==="days"&&c){e="hours";f=5;d=12}else if(settings.scale==="days"&&!c){e="weeks";f=3;d=13}else if(settings.scale==="weeks"&&!c){e="months";f=2;d=14}else if(settings.scale==="weeks"&&c){e="days";f=4;d=13}else if(settings.scale==="months"&&c){e="weeks";f=3;d=13}if(c&&$.inArray(e,scales)<$.inArray(settings.minScale,scales)||!c&&$.inArray(e,scales)>$.inArray(settings.maxScale,scales)){core.init(a);return}a.scaleStep=d;settings.scale=e;a.headerRows=f;var g=$(a).find(".fn-gantt .rightPanel");var h=g.find(".dataPanel");a.hPosition=h.css("margin-left").replace("px","");a.scaleOldWidth=h.width()-g.width();core.init(a)})},mouseScroll:function(a,b){var c=$(a).find(".fn-gantt .dataPanel");c.css("cursor","move");var d=c.offset();var e=a.scrollNavigation.mouseX===null?b.pageX:a.scrollNavigation.mouseX;var f=b.pageX-e;a.scrollNavigation.mouseX=b.pageX;core.scrollPanel(a,f);clearTimeout(a.scrollNavigation.repositionDelay);a.scrollNavigation.repositionDelay=setTimeout(core.repositionLabel,50,a)},wheelScroll:function(a,b){var c=b.detail?b.detail*-50:b.wheelDelta/120*50;core.scrollPanel(a,c);clearTimeout(a.scrollNavigation.repositionDelay);a.scrollNavigation.repositionDelay=setTimeout(core.repositionLabel,50,a);if(b.preventDefault)b.preventDefault();else return false},sliderScroll:function(a,b){var c=$(a).find(".nav-slider-bar");var d=c.find(".nav-slider-button");var e=$(a).find(".fn-gantt .rightPanel");var f=e.find(".dataPanel");var g=c.offset();var h=c.width();var i=d.width();if(b.pageX>=g.left&&b.pageX<=g.left+h){var j=b.pageX-g.left;var j=j-i/2;d.css("left",j);var k=f.width()-e.width();var l=j*k/h*-1;if(l>=0){f.css("margin-left","0px");a.scrollNavigation.panelMargin=0}else if(j>=h-i*1){f.css("margin-left",k*-1+"px");a.scrollNavigation.panelMargin=k*-1}else{f.css("margin-left",l+"px");a.scrollNavigation.panelMargin=l}clearTimeout(a.scrollNavigation.repositionDelay);a.scrollNavigation.repositionDelay=setTimeout(core.repositionLabel,50,a)}},scrollPanel:function(a,b){if(!a.scrollNavigation.canScroll)return false;var c=parseInt(a.scrollNavigation.panelMargin)+b;if(c>0){a.scrollNavigation.panelMargin=0;$(a).find(".fn-gantt .dataPanel").css("margin-left",a.scrollNavigation.panelMargin+"px")}else if(c<a.scrollNavigation.panelMaxPos*-1){a.scrollNavigation.panelMargin=a.scrollNavigation.panelMaxPos*-1;$(a).find(".fn-gantt .dataPanel").css("margin-left",a.scrollNavigation.panelMargin+"px")}else{a.scrollNavigation.panelMargin=c;$(a).find(".fn-gantt .dataPanel").css("margin-left",a.scrollNavigation.panelMargin+"px")}},synchronizeScroller:function(a){if(settings.navigate==="scroll"){var b=$(a).find(".fn-gantt .rightPanel");var c=b.find(".dataPanel");var d=$(a).find(".nav-slider-bar");var e=d.find(".nav-slider-button");var f=d.width();var g=e.width();var h=c.width()-b.width();var i=0;if(c.css("margin-left"))i=c.css("margin-left").replace("px","");var j=i*f/h-e.width()*.25;j=j>0?0:j*-1>=f-g*.75?(f-g*1.25)*-1:j;e.css("left",j*-1)}},repositionLabel:function(a){var b=$(".fn-gantt .rightPanel");var c=b.find(".dataPanel");c.stop();var d={offset:b.offset(),width:b.width(),height:b.height()};$(".fn-gantt .rightPanel .year, .fn-gantt .rightPanel .month").each(function(a,b){var c={offset:$(b).offset(),width:$(b).width(),height:$(b).height()};if(c.offset.left+c.width>d.offset.left&&c.offset.left<d.offset.left+d.width){var e={left:c.offset.left>d.offset.left?c.offset.left:d.offset.left,right:c.offset.left+c.width<d.offset.left+d.width?c.offset.left+c.width:d.offset.left+d.width};$(b).children(".fn-label").css("float","left");var f=$(b).children(".fn-label").width();var g=c.offset.left<d.offset.left?d.offset.left-c.offset.left:0;if(e.right-e.left>f)$(b).children(".fn-label").css("margin-left",g+(e.right-e.left)/2-f/2+"px")}});$(".fn-gantt .rightPanel .bar").each(function(a,b){var c={offset:$(b).offset(),width:$(b).width(),height:$(b).height()};if(c.offset.left+c.width>d.offset.left&&c.offset.left<d.offset.left+d.width){var e={left:c.offset.left>d.offset.left?c.offset.left:d.offset.left,right:c.offset.left+c.width<d.offset.left+d.width?c.offset.left+c.width:d.offset.left+d.width};$(b).children(".fn-label").css("float","left");var f=$(b).children(".fn-label").width();var g=c.offset.left<d.offset.left?d.offset.left-c.offset.left:0;if(e.right-e.left>f)$(b).children(".fn-label").css("margin-left",g+(e.right-e.left)/2-f/2+"px")}});core.synchronizeScroller(a)},waitToggle:function(a,b,c){if(b){var d=$(a).offset();var e=$(a).outerWidth();var f=$(a).outerHeight();if(!a.loader){a.loader=$('<div class="fn-gantt-loader" style="position: absolute; top: '+d.top+"px; left: "+d.left+"px; width: "+e+"px; height: "+f+'px;">'+'<div class="fn-gantt-loader-spinner"><span>'+settings.waitText+"</span></div></div>")}$("body").append(a.loader);setTimeout(c,100)}else{if(a.loader)a.loader.remove();a.loader=null}}};var tools={getMaxDate:function(a){var b=null;$.each(a.data,function(a,c){$.each(c.values,function(a,c){b=b<tools.dateDeserialize(c.to)?tools.dateDeserialize(c.to):b})});switch(settings.scale){case"hours":b.setHours(Math.ceil(b.getHours()/a.scaleStep)*a.scaleStep);b.setHours(b.getHours()+a.scaleStep*3);break;case"weeks":var c=new Date(b.getTime());var c=new Date(c.setDate(c.getDate()+3*7));var d=Math.floor(c.getDate()/7)*7;b=new Date(c.getFullYear(),c.getMonth(),d===0?4:d-3);break;case"months":var c=new Date(b.getFullYear(),b.getMonth(),1);c.setMonth(c.getMonth()+2);b=new Date(c.getFullYear(),c.getMonth(),1);break;default:b.setHours(0);b.setDate(b.getDate()+3);break}return b},getMinDate:function(a){var b=null;$.each(a.data,function(a,c){$.each(c.values,function(a,c){b=b>tools.dateDeserialize(c.from)||b===null?tools.dateDeserialize(c.from):b})});switch(settings.scale){case"hours":b.setHours(Math.floor(b.getHours()/a.scaleStep)*a.scaleStep);b.setHours(b.getHours()-a.scaleStep*3);break;case"weeks":var c=new Date(b.getTime());var c=new Date(c.setDate(c.getDate()-3*7));var d=Math.floor(c.getDate()/7)*7;b=new Date(c.getFullYear(),c.getMonth(),d===0?4:d-3);break;case"months":var c=new Date(b.getFullYear(),b.getMonth(),1);c.setMonth(c.getMonth()-3);b=new Date(c.getFullYear(),c.getMonth(),1);break;default:b.setHours(0);b.setDate(b.getDate()-3);break}return b},parseDateRange:function(a,b){var c=new Date(a.getTime());var d=new Date(b.getTime());var e=new Array;var f=0;do{e[f++]=new Date(c.getTime());c.setDate(c.getDate()+1)}while(c.getTime()<=b.getTime());return e},parseTimeRange:function(a,b,c){var d=new Date(a);var e=new Date(b);var f=new Array;var g=0;do{f[g]=new Date(d.getTime());d.setHours(d.getHours()+c);d.setHours(Math.floor(d.getHours()/c)*c);if(d.getDay()!=f[g].getDay())d.setHours(0);g++}while(d.getTime()<=b.getTime());return f},parseWeeksRange:function(a,b){var c=new Date(a);var d=new Date(b);var e=new Array;var f=0;do{if(c.getDay()===0){e[f++]=c.getDayForWeek()}c.setDate(c.getDate()+1)}while(c.getTime()<=b.getTime());return e},parseMonthsRange:function(a,b){var c=new Date(a);var d=new Date(b);var e=new Array;var f=0;do{e[f++]=new Date(c.getFullYear(),c.getMonth(),1);c.setMonth(c.getMonth()+1)}while(c.getTime()<=b.getTime());return e},dateDeserialize:function(dateStr){var date=eval("new"+dateStr.replace(/\//g," "));return new Date(date.getUTCFullYear(),date.getUTCMonth(),date.getUTCDate(),date.getUTCHours(),date.getUTCMinutes())},genId:function(a){var b=new Date(a);switch(settings.scale){case"hours":var c=b.getHours();if(arguments.length>=2)c=Math.floor(b.getHours()/arguments[1])*arguments[1];return(new Date(b.getFullYear(),b.getMonth(),b.getDate(),c)).getTime();break;case"weeks":return b.getFullYear()+"-"+b.getDayForWeek().getWeekOfYear();break;case"months":return b.getFullYear()+"-"+b.getMonth();break;default:return(new Date(b.getFullYear(),b.getMonth(),b.getDate())).getTime();break}},_getCellSize:null,getCellSize:function(){if(!tools._getCellSize){$("body").append($('<div style="display: none; position: absolute;" class="fn-gantt" id="measureCellWidth"><div class="row"></div></div>'));tools._getCellSize=$("#measureCellWidth .row").height();$("#measureCellWidth").empty().remove()}return tools._getCellSize},getRightPanelSize:function(){$("body").append($('<div style="display: none; position: absolute;" class="fn-gantt" id="measureCellWidth"><div class="rightPanel"></div></div>'));var a=$("#measureCellWidth .rightPanel").height();$("#measureCellWidth").empty().remove();return a},getPageHeight:function(a){return a.pageNum+1===a.pageCount?rowsOnLastPage*tools.getCellSize():settings.itemsPerPage*tools.getCellSize()},_getProgressBarMargin:null,getProgressBarMargin:function(){if(!tools._getProgressBarMargin){$("body").append($('<div style="display: none; position: absolute;" id="measureBarWidth" ><div class="fn-gantt"><div class="rightPanel"><div class="dataPanel"><div class="row day"><div class="bar" /></div></div></div></div></div>'));tools._getProgressBarMargin=parseInt($("#measureBarWidth .fn-gantt .rightPanel .day .bar").css("margin-left").replace("px",""));tools._getProgressBarMargin+=parseInt($("#measureBarWidth .fn-gantt .rightPanel .day .bar").css("margin-right").replace("px",""));$("#measureBarWidth").empty().remove()}return tools._getProgressBarMargin}};this.each(function(){if(options)$.extend(settings,options);this.data=null;this.pageNum=0;this.pageCount=0;this.rowsOnLastPage=0;this.rowsNum=0;this.hPosition=0;this.dateStart=null;this.dateEnd=null;this.scrollClicked=false;this.scaleOldWidth=null;this.headerRows=null;switch(settings.scale){case"hours":this.headerRows=5;this.scaleStep=1;break;case"weeks":this.headerRows=3;this.scaleStep=13;break;case"months":this.headerRows=2;this.scaleStep=14;break;default:this.headerRows=4;this.scaleStep=13;break}this.scrollNavigation={panelMouseDown:false,scrollerMouseDown:false,mouseX:null,panelMargin:0,repositionDelay:0,panelMaxPos:0,canScroll:true};this.gantt=null;this.loader=null;core.create(this)})}})(jQuery)

0 comments on commit 8667cc6

Please sign in to comment.
Something went wrong with that request. Please try again.