zebra-datepicker-rails 1.9.2 → 1.9.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f13f9252b0ac459177ebb727eeb325f89cf55a61
4
- data.tar.gz: a59ade21abe0350f171cb09f9d8603cd21b2605b
3
+ metadata.gz: a77bd1eb0c0a1dcd5ed11abbaa57590863a3e0be
4
+ data.tar.gz: 35745f4232c07389409729121a0e6a648ee305c2
5
5
  SHA512:
6
- metadata.gz: f0f01a874fbfdfc960a443ba3ba96a2d1d73e82e83cffbde9282691ef71f08e6cb07d8e6ae549f35e92df688b85d0fc7b2127b8f4f33e205b5fe10ddd08df6b0
7
- data.tar.gz: 646ee814c1b6eedb0f7ae48ee7e3909ce45ebc91d4180e37c6f794d2fc4de6de0161c7e6071ede1ce05dfb5ee4220e8e7bef48b457197085ee3050e57ae27d0b
6
+ metadata.gz: 2a646b12d55c5109a20ff312e8ed40d1c7544982a17cb1262bca13d23e2403d3d0806471124dc4eeddb44825c042bdbbdd0348fc87c4d218339bf2b2b8e51e48
7
+ data.tar.gz: 8c34aa6784f24a8cd36e5790534cfd5ecc2010a3e33db8afaf5b77ef4704aacace6dde1fdb4cb5e29bdef1e8c120bc2f442a06ec72b336b3358480453623eb81
data/README.md CHANGED
@@ -43,7 +43,7 @@ Use Github Issues.
43
43
 
44
44
  ## Thanks To
45
45
 
46
- This project is based on https://raw.github.com/Nerian/bootstrap-datepicker-rails
46
+ This project is based on https://github.com/Nerian/bootstrap-datepicker-rails
47
47
 
48
48
  ## License
49
49
  Copyright (c) 2013 Marcus Derencius
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ desc "Change css url calls to use sass-rails' asset-url"
4
4
  task :change_css_url do
5
5
  Dir.chdir('vendor/assets/stylesheets/zebra-datepicker/')
6
6
  Dir.glob('*.scss').each do |filename|
7
- content = File.read(filename).gsub!(" url('", " asset-url('zebra-datepicker/")
7
+ content = File.read(filename).gsub!(" url('../images/", " asset-url('zebra-datepicker/")
8
8
  file = File.open(filename, 'w')
9
9
  file.write(content)
10
10
  file.close
@@ -12,16 +12,15 @@ task :change_css_url do
12
12
  end
13
13
 
14
14
  desc 'Copy Assets from Zebra_Datepicker'
15
-
16
15
  task :copy do
17
16
  {
18
17
  'public/css/bootstrap.css' => 'vendor/assets/stylesheets/zebra-datepicker/bootstrap.scss',
19
18
  'public/css/default.css' => 'vendor/assets/stylesheets/zebra-datepicker/default.scss',
20
19
  'public/css/metallic.css' => 'vendor/assets/stylesheets/zebra-datepicker/metallic.scss',
21
20
 
22
- 'public/css/metallic/' => 'vendor/assets/images/zebra-datepicker/',
23
- 'public/css/calendar-disabled.png' => 'vendor/assets/images/zebra-datepicker/',
24
- 'public/css/calendar.png' => 'vendor/assets/images/zebra-datepicker/',
21
+ 'public/images/metallic/' => 'vendor/assets/images/zebra-datepicker/',
22
+ 'public/images/calendar-disabled.png' => 'vendor/assets/images/zebra-datepicker/',
23
+ 'public/images/calendar.png' => 'vendor/assets/images/zebra-datepicker/',
25
24
 
26
25
  'public/javascript/zebra_datepicker.js' => 'vendor/assets/javascripts/zebra-datepicker/',
27
26
  'public/javascript/zebra_datepicker.src.js' => 'vendor/assets/javascripts/zebra-datepicker/'
@@ -1,5 +1,5 @@
1
1
  module ZebraDatepickerRails
2
2
  module Rails
3
- VERSION = "1.9.2"
3
+ VERSION = "1.9.5"
4
4
  end
5
5
  end
@@ -1 +1 @@
1
- !function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){"use strict";a.Zebra_DatePicker=function(b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O={always_visible:!1,container:a("body"),days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],days_abbr:!1,default_position:"above",direction:0,disabled_dates:!1,enabled_dates:!1,first_day_of_week:1,format:"Y-m-d",header_captions:{days:"F, Y",months:"Y",years:"Y1 - Y2"},header_navigation:["&#171;","&#187;"],inside:!0,lang_clear_date:"Clear date",months:["January","February","March","April","May","June","July","August","September","October","November","December"],months_abbr:!1,offset:[5,-5],pair:!1,readonly_element:!0,select_other_months:!1,show_clear_date:0,show_icon:!0,show_other_months:!0,show_select_today:"Today",show_week_number:!1,start_date:!1,strict:!1,view:"days",weekend_days:[0,6],zero_pad:!1,onChange:null,onClear:null,onOpen:null,onClose:null,onSelect:null},P=this;P.settings={};var Q=a(b),R=function(b){if(N=Math.floor(65536*(1+Math.random())).toString(16),!b){P.settings=a.extend({},O,c);for(var y in Q.data())0===y.indexOf("zdp_")&&(y=y.replace(/^zdp\_/,""),void 0!==O[y]&&(P.settings[y]="pair"==y?a(Q.data("zdp_"+y)):Q.data("zdp_"+y)))}P.settings.readonly_element&&Q.attr("readonly","readonly");var E={days:["d","j","D"],months:["F","m","M","n","t"],years:["o","Y","y"]},F=!1,G=!1,R=!1,U=null;for(U in E)a.each(E[U],function(a,b){P.settings.format.indexOf(b)>-1&&("days"==U?F=!0:"months"==U?G=!0:"years"==U&&(R=!0))});H=F&&G&&R?["years","months","days"]:!F&&G&&R?["years","months"]:F&&G&&!R?["months","days"]:F||G||!R?F||!G||R?["years","months","days"]:["months"]:["years"],-1==a.inArray(P.settings.view,H)&&(P.settings.view=H[H.length-1]),x=[],w=[];for(var V,W=0;2>W;W++)V=0===W?P.settings.disabled_dates:P.settings.enabled_dates,a.isArray(V)&&V.length>0&&a.each(V,function(){for(var b=this.split(" "),c=0;4>c;c++){b[c]||(b[c]="*"),b[c]=b[c].indexOf(",")>-1?b[c].split(","):new Array(b[c]);for(var d=0;d<b[c].length;d++)if(b[c][d].indexOf("-")>-1){var e=b[c][d].match(/^([0-9]+)\-([0-9]+)/);if(null!==e){for(var f=fa(e[1]);f<=fa(e[2]);f++)-1==a.inArray(f,b[c])&&b[c].push(f+"");b[c].splice(d,1)}}for(d=0;d<b[c].length;d++)b[c][d]=isNaN(fa(b[c][d]))?b[c][d]:fa(b[c][d])}0===W?x.push(b):w.push(b)});var X,Y,Z=new Date,aa=P.settings.reference_date?P.settings.reference_date:Q.data("zdp_reference_date")&&void 0!==Q.data("zdp_reference_date")?Q.data("zdp_reference_date"):Z;if(z=void 0,A=void 0,o=aa.getMonth(),l=Z.getMonth(),p=aa.getFullYear(),m=Z.getFullYear(),q=aa.getDate(),n=Z.getDate(),P.settings.direction===!0)z=aa;else if(P.settings.direction===!1)A=aa,D=A.getMonth(),C=A.getFullYear(),B=A.getDate();else if(!a.isArray(P.settings.direction)&&_(P.settings.direction)&&fa(P.settings.direction)>0||a.isArray(P.settings.direction)&&((X=S(P.settings.direction[0]))||P.settings.direction[0]===!0||_(P.settings.direction[0])&&P.settings.direction[0]>0)&&((Y=S(P.settings.direction[1]))||P.settings.direction[1]===!1||_(P.settings.direction[1])&&P.settings.direction[1]>=0))z=X?X:new Date(p,o,q+fa(a.isArray(P.settings.direction)?P.settings.direction[0]===!0?0:P.settings.direction[0]:P.settings.direction)),o=z.getMonth(),p=z.getFullYear(),q=z.getDate(),Y&&+Y>=+z?A=Y:!Y&&P.settings.direction[1]!==!1&&a.isArray(P.settings.direction)&&(A=new Date(p,o,q+fa(P.settings.direction[1]))),A&&(D=A.getMonth(),C=A.getFullYear(),B=A.getDate());else if(!a.isArray(P.settings.direction)&&_(P.settings.direction)&&fa(P.settings.direction)<0||a.isArray(P.settings.direction)&&(P.settings.direction[0]===!1||_(P.settings.direction[0])&&P.settings.direction[0]<0)&&((X=S(P.settings.direction[1]))||_(P.settings.direction[1])&&P.settings.direction[1]>=0))A=new Date(p,o,q+fa(a.isArray(P.settings.direction)?P.settings.direction[0]===!1?0:P.settings.direction[0]:P.settings.direction)),D=A.getMonth(),C=A.getFullYear(),B=A.getDate(),X&&+A>+X?z=X:!X&&a.isArray(P.settings.direction)&&(z=new Date(C,D,B-fa(P.settings.direction[1]))),z&&(o=z.getMonth(),p=z.getFullYear(),q=z.getDate());else if(a.isArray(P.settings.disabled_dates)&&P.settings.disabled_dates.length>0)for(var da in x)if("*"==x[da][0]&&"*"==x[da][1]&&"*"==x[da][2]&&"*"==x[da][3]){var ha=[];if(a.each(w,function(){var a=this;"*"!=a[2][0]&&ha.push(parseInt(a[2][0]+("*"==a[1][0]?"12":ea(a[1][0],2))+("*"==a[0][0]?"*"==a[1][0]?"31":new Date(a[2][0],a[1][0],0).getDate():ea(a[0][0],2)),10))}),ha.sort(),ha.length>0){var ja=(ha[0]+"").match(/([0-9]{4})([0-9]{2})([0-9]{2})/);p=parseInt(ja[1],10),o=parseInt(ja[2],10)-1,q=parseInt(ja[3],10)}break}if($(p,o,q)){for(;$(p);)z?(p++,o=0):(p--,o=11);for(;$(p,o);)z?(o++,q=1):(o--,q=new Date(p,o+1,0).getDate()),o>11?(p++,o=0,q=1):0>o&&(p--,o=11,q=new Date(p,o+1,0).getDate());for(;$(p,o,q);)z?q++:q--,Z=new Date(p,o,q),p=Z.getFullYear(),o=Z.getMonth(),q=Z.getDate();Z=new Date(p,o,q),p=Z.getFullYear(),o=Z.getMonth(),q=Z.getDate()}var ka=S(Q.val()||(P.settings.start_date?P.settings.start_date:""));if(ka&&P.settings.strict&&$(ka.getFullYear(),ka.getMonth(),ka.getDate())&&Q.val(""),b||void 0===z&&void 0===ka||ga(void 0!==z?z:ka),!P.settings.always_visible){if(!b){if(P.settings.show_icon){"firefox"==ia.name&&Q.is('input[type="text"]')&&"inline"==Q.css("display")&&Q.css("display","inline-block");var la=a('<span class="Zebra_DatePicker_Icon_Wrapper"></span>').css({display:Q.css("display"),position:"static"==Q.css("position")?"relative":Q.css("position"),"float":Q.css("float"),top:Q.css("top"),right:Q.css("right"),bottom:Q.css("bottom"),left:Q.css("left")});Q.wrap(la).css({position:"relative",top:"auto",right:"auto",bottom:"auto",left:"auto"}),f=a('<button type="button" class="Zebra_DatePicker_Icon'+("disabled"==Q.attr("disabled")?" Zebra_DatePicker_Icon_Disabled":"")+'">Pick a date</button>'),P.icon=f,I=f.add(Q)}else I=Q;I.bind("click",function(a){a.preventDefault(),Q.attr("disabled")||(e.hasClass("dp_visible")?P.hide():P.show())}),void 0!==f&&f.insertAfter(Q)}if(void 0!==f){f.attr("style",""),P.settings.inside&&f.addClass("Zebra_DatePicker_Icon_Inside");var ma=Q.outerWidth(),na=Q.outerHeight(),oa=parseInt(Q.css("marginLeft"),10)||0,pa=parseInt(Q.css("marginTop"),10)||0,qa=f.outerWidth(),ra=f.outerHeight(),sa=parseInt(f.css("marginLeft"),10)||0,ta=parseInt(f.css("marginRight"),10)||0;f.css(P.settings.inside?{top:pa+(na-ra)/2,left:oa+(ma-qa-ta)}:{top:pa+(na-ra)/2,left:oa+ma+sa}),f.removeClass(" Zebra_DatePicker_Icon_Disabled"),"disabled"==Q.attr("disabled")&&f.addClass("Zebra_DatePicker_Icon_Disabled")}}if(L=P.settings.show_select_today!==!1&&a.inArray("days",H)>-1&&!$(m,l,n)?P.settings.show_select_today:!1,!b){a(window).bind("resize.Zebra_DatePicker_"+N,function(){P.hide(),void 0!==f&&(clearTimeout(M),M=setTimeout(function(){P.update()},100))});var ua='<div class="Zebra_DatePicker"><table class="dp_header"><tr><td class="dp_previous">'+P.settings.header_navigation[0]+'</td><td class="dp_caption">&#032;</td><td class="dp_next">'+P.settings.header_navigation[1]+'</td></tr></table><table class="dp_daypicker"></table><table class="dp_monthpicker"></table><table class="dp_yearpicker"></table><table class="dp_footer"><tr><td class="dp_today"'+(P.settings.show_clear_date!==!1?' style="width:50%"':"")+">"+L+'</td><td class="dp_clear"'+(L!==!1?' style="width:50%"':"")+">"+P.settings.lang_clear_date+"</td></tr></table></div>";e=a(ua),P.datepicker=e,g=a("table.dp_header",e),h=a("table.dp_daypicker",e),i=a("table.dp_monthpicker",e),j=a("table.dp_yearpicker",e),K=a("table.dp_footer",e),J=a("td.dp_today",K),k=a("td.dp_clear",K),P.settings.always_visible?Q.attr("disabled")||(P.settings.always_visible.append(e),P.show()):P.settings.container.append(e),e.delegate("td:not(.dp_disabled, .dp_weekend_disabled, .dp_not_in_month, .dp_week_number)","mouseover",function(){a(this).addClass("dp_hover")}).delegate("td:not(.dp_disabled, .dp_weekend_disabled, .dp_not_in_month, .dp_week_number)","mouseout",function(){a(this).removeClass("dp_hover")}),T(a("td",g)),a(".dp_previous",g).bind("click",function(){"months"==d?s--:"years"==d?s-=12:--r<0&&(r=11,s--),ba()}),a(".dp_caption",g).bind("click",function(){d="days"==d?a.inArray("months",H)>-1?"months":a.inArray("years",H)>-1?"years":"days":"months"==d?a.inArray("years",H)>-1?"years":a.inArray("days",H)>-1?"days":"months":a.inArray("days",H)>-1?"days":a.inArray("months",H)>-1?"months":"years",ba()}),a(".dp_next",g).bind("click",function(){"months"==d?s++:"years"==d?s+=12:12==++r&&(r=0,s++),ba()}),h.delegate("td:not(.dp_disabled, .dp_weekend_disabled, .dp_not_in_month, .dp_week_number)","click",function(){P.settings.select_other_months&&a(this).attr("class")&&null!==(ja=a(this).attr("class").match(/date\_([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])/))?ca(ja[1],ja[2]-1,ja[3],"days",a(this)):ca(s,r,fa(a(this).html()),"days",a(this))}),i.delegate("td:not(.dp_disabled)","click",function(){var b=a(this).attr("class").match(/dp\_month\_([0-9]+)/);r=fa(b[1]),-1==a.inArray("days",H)?ca(s,r,1,"months",a(this)):(d="days",P.settings.always_visible&&Q.val(""),ba())}),j.delegate("td:not(.dp_disabled)","click",function(){s=fa(a(this).html()),-1==a.inArray("months",H)?ca(s,1,1,"years",a(this)):(d="months",P.settings.always_visible&&Q.val(""),ba())}),a(J).bind("click",function(b){b.preventDefault(),ca(m,l,n,"days",a(".dp_current",h)),P.settings.always_visible&&P.show(),P.hide()}),a(k).bind("click",function(b){b.preventDefault(),Q.val(""),P.settings.always_visible?(t=null,u=null,v=null,a("td.dp_selected",e).removeClass("dp_selected")):(t=null,u=null,v=null,r=null,s=null),P.hide(),P.settings.onClear&&"function"==typeof P.settings.onClear&&P.settings.onClear.call(Q,Q)}),P.settings.always_visible||(a(document).bind("mousedown.Zebra_DatePicker_"+N+", touchstart.Zebra_DatePicker_"+N,function(b){if(e.hasClass("dp_visible")){if(P.settings.show_icon&&a(b.target).get(0)===f.get(0))return!0;0===a(b.target).parents().filter(".Zebra_DatePicker").length&&P.hide()}}),a(document).bind("keyup.Zebra_DatePicker_"+N,function(a){e.hasClass("dp_visible")&&27==a.which&&P.hide()})),ba()}};P.destroy=function(){void 0!==P.icon&&P.icon.remove(),P.datepicker.remove(),a(document).unbind("keyup.Zebra_DatePicker_"+N),a(document).unbind("mousedown.Zebra_DatePicker_"+N),a(window).unbind("resize.Zebra_DatePicker_"+N),Q.removeData("Zebra_DatePicker")},P.hide=function(){P.settings.always_visible||(Z("hide"),e.removeClass("dp_visible").addClass("dp_hidden"),P.settings.onClose&&"function"==typeof P.settings.onClose&&P.settings.onClose.call(Q,Q))},P.show=function(){d=P.settings.view;var b=S(Q.val()||(P.settings.start_date?P.settings.start_date:""));if(b?(u=b.getMonth(),r=b.getMonth(),v=b.getFullYear(),s=b.getFullYear(),t=b.getDate(),$(v,u,t)&&(P.settings.strict&&Q.val(""),r=o,s=p)):(r=o,s=p),ba(),P.settings.always_visible)e.removeClass("dp_hidden").addClass("dp_visible");else{if(P.settings.container.is("body")){var c=e.outerWidth(),g=e.outerHeight(),h=(void 0!==f?f.offset().left+f.outerWidth(!0):Q.offset().left+Q.outerWidth(!0))+P.settings.offset[0],i=(void 0!==f?f.offset().top:Q.offset().top)-g+P.settings.offset[1],j=a(window).width(),k=a(window).height(),l=a(window).scrollTop(),m=a(window).scrollLeft();"below"==P.settings.default_position&&(i=(void 0!==f?f.offset().top:Q.offset().top)+P.settings.offset[1]),h+c>m+j&&(h=m+j-c),m>h&&(h=m),i+g>l+k&&(i=l+k-g),l>i&&(i=l),e.css({left:h,top:i})}else e.css({left:0,top:0});e.removeClass("dp_hidden").addClass("dp_visible"),Z()}P.settings.onOpen&&"function"==typeof P.settings.onOpen&&P.settings.onOpen.call(Q,Q)},P.update=function(b){P.original_direction&&(P.original_direction=P.direction),P.settings=a.extend(P.settings,b),R(!0)};var S=function(b){if(b+="",""!==a.trim(b)){for(var c=U(P.settings.format),d=["d","D","j","l","N","S","w","F","m","M","n","Y","y"],e=[],f=[],g=null,h=null,i=0;i<d.length;i++)(g=c.indexOf(d[i]))>-1&&e.push({character:d[i],position:g});if(e.sort(function(a,b){return a.position-b.position}),a.each(e,function(a,b){switch(b.character){case"d":f.push("0[1-9]|[12][0-9]|3[01]");break;case"D":f.push("[a-z]{3}");break;case"j":f.push("[1-9]|[12][0-9]|3[01]");break;case"l":f.push("[a-z]+");break;case"N":f.push("[1-7]");break;case"S":f.push("st|nd|rd|th");break;case"w":f.push("[0-6]");break;case"F":f.push("[a-z]+");break;case"m":f.push("0[1-9]|1[012]+");break;case"M":f.push("[a-z]{3}");break;case"n":f.push("[1-9]|1[012]");break;case"Y":f.push("[0-9]{4}");break;case"y":f.push("[0-9]{2}")}}),f.length&&(e.reverse(),a.each(e,function(a,b){c=c.replace(b.character,"("+f[f.length-a-1]+")")}),f=new RegExp("^"+c+"$","ig"),h=f.exec(b))){var j,k=new Date,l=1,m=k.getMonth()+1,n=k.getFullYear(),o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],p=["January","February","March","April","May","June","July","August","September","October","November","December"],q=!0;if(e.reverse(),a.each(e,function(b,c){if(!q)return!0;switch(c.character){case"m":case"n":m=fa(h[b+1]);break;case"d":case"j":l=fa(h[b+1]);break;case"D":case"l":case"F":case"M":j="D"==c.character||"l"==c.character?P.settings.days:P.settings.months,q=!1,a.each(j,function(a,d){if(q)return!0;if(h[b+1].toLowerCase()==d.substring(0,"D"==c.character||"M"==c.character?3:d.length).toLowerCase()){switch(c.character){case"D":h[b+1]=o[a].substring(0,3);break;case"l":h[b+1]=o[a];break;case"F":h[b+1]=p[a],m=a+1;break;case"M":h[b+1]=p[a].substring(0,3),m=a+1}q=!0}});break;case"Y":n=fa(h[b+1]);break;case"y":n="19"+fa(h[b+1])}}),q){var r=new Date(n,(m||1)-1,l||1);if(r.getFullYear()==n&&r.getDate()==(l||1)&&r.getMonth()==(m||1)-1)return r}}return!1}},T=function(a){"firefox"==ia.name?a.css("MozUserSelect","none"):"explorer"==ia.name?a.bind("selectstart",function(){return!1}):a.mousedown(function(){return!1})},U=function(a){return a.replace(/([-.,*+?^${}()|[\]\/\\])/g,"\\$1")},V=function(b){for(var c="",d=b.getDate(),e=b.getDay(),f=P.settings.days[e],g=b.getMonth()+1,h=P.settings.months[g-1],i=b.getFullYear()+"",j=0;j<P.settings.format.length;j++){var k=P.settings.format.charAt(j);switch(k){case"y":i=i.substr(2);case"Y":c+=i;break;case"m":g=ea(g,2);case"n":c+=g;break;case"M":h=a.isArray(P.settings.months_abbr)&&void 0!==P.settings.months_abbr[g-1]?P.settings.months_abbr[g-1]:P.settings.months[g-1].substr(0,3);case"F":c+=h;break;case"d":d=ea(d,2);case"j":c+=d;break;case"D":f=a.isArray(P.settings.days_abbr)&&void 0!==P.settings.days_abbr[e]?P.settings.days_abbr[e]:P.settings.days[e].substr(0,3);case"l":c+=f;break;case"N":e++;case"w":c+=e;break;case"S":c+=d%10==1&&"11"!=d?"st":d%10==2&&"12"!=d?"nd":d%10==3&&"13"!=d?"rd":"th";break;default:c+=k}}return c},W=function(){var b=new Date(s,r+1,0).getDate(),c=new Date(s,r,1).getDay(),d=new Date(s,r,0).getDate(),e=c-P.settings.first_day_of_week;e=0>e?7+e:e,aa(P.settings.header_captions.days);var f="<tr>";P.settings.show_week_number&&(f+="<th>"+P.settings.show_week_number+"</th>");for(var g=0;7>g;g++)f+="<th>"+(a.isArray(P.settings.days_abbr)&&void 0!==P.settings.days_abbr[(P.settings.first_day_of_week+g)%7]?P.settings.days_abbr[(P.settings.first_day_of_week+g)%7]:P.settings.days[(P.settings.first_day_of_week+g)%7].substr(0,2))+"</th>";for(f+="</tr><tr>",g=0;42>g;g++){g>0&&g%7===0&&(f+="</tr><tr>"),g%7===0&&P.settings.show_week_number&&(f+='<td class="dp_week_number">'+ha(new Date(s,r,g-e+1))+"</td>");var i=g-e+1;if(P.settings.select_other_months&&(e>g||i>b)){var j=new Date(s,r,i),k=j.getFullYear(),o=j.getMonth(),p=j.getDate();j=k+ea(o+1,2)+ea(p,2)}if(e>g)f+='<td class="'+(P.settings.select_other_months&&!$(k,o,p)?"dp_not_in_month_selectable date_"+j:"dp_not_in_month")+'">'+(P.settings.select_other_months||P.settings.show_other_months?ea(d-e+g+1,P.settings.zero_pad?2:0):"&nbsp;")+"</td>";else if(i>b)f+='<td class="'+(P.settings.select_other_months&&!$(k,o,p)?"dp_not_in_month_selectable date_"+j:"dp_not_in_month")+'">'+(P.settings.select_other_months||P.settings.show_other_months?ea(i-b,P.settings.zero_pad?2:0):"&nbsp;")+"</td>";else{var q=(P.settings.first_day_of_week+g)%7,w="";$(s,r,i)?(a.inArray(q,P.settings.weekend_days)>-1?w="dp_weekend_disabled":w+=" dp_disabled",r==l&&s==m&&n==i&&(w+=" dp_disabled_current")):(a.inArray(q,P.settings.weekend_days)>-1&&(w="dp_weekend"),r==u&&s==v&&t==i&&(w+=" dp_selected"),r==l&&s==m&&n==i&&(w+=" dp_current")),f+="<td"+(""!==w?' class="'+a.trim(w)+'"':"")+">"+((P.settings.zero_pad?ea(i,2):i)||"")+"</td>"}}f+="</tr>",h.html(a(f)),P.settings.always_visible&&(E=a("td:not(.dp_disabled, .dp_weekend_disabled, .dp_not_in_month, .dp_week_number)",h)),h.show()},X=function(){aa(P.settings.header_captions.months);for(var b="<tr>",c=0;12>c;c++){c>0&&c%3===0&&(b+="</tr><tr>");var d="dp_month_"+c;$(s,c)?d+=" dp_disabled":u!==!1&&u==c&&s==v?d+=" dp_selected":l==c&&m==s&&(d+=" dp_current"),b+='<td class="'+a.trim(d)+'">'+(a.isArray(P.settings.months_abbr)&&void 0!==P.settings.months_abbr[c]?P.settings.months_abbr[c]:P.settings.months[c].substr(0,3))+"</td>"}b+="</tr>",i.html(a(b)),P.settings.always_visible&&(F=a("td:not(.dp_disabled)",i)),i.show()},Y=function(){aa(P.settings.header_captions.years);for(var b="<tr>",c=0;12>c;c++){c>0&&c%3===0&&(b+="</tr><tr>");var d="";$(s-7+c)?d+=" dp_disabled":v&&v==s-7+c?d+=" dp_selected":m==s-7+c&&(d+=" dp_current"),b+="<td"+(""!==a.trim(d)?' class="'+a.trim(d)+'"':"")+">"+(s-7+c)+"</td>"}b+="</tr>",j.html(a(b)),P.settings.always_visible&&(G=a("td:not(.dp_disabled)",j)),j.show()},Z=function(b){if("explorer"==ia.name&&6==ia.version){if(!y){var c=fa(e.css("zIndex"))-1;y=a("<iframe>",{src:'javascript:document.write("")',scrolling:"no",frameborder:0,css:{zIndex:c,position:"absolute",top:-1e3,left:-1e3,width:e.outerWidth(),height:e.outerHeight(),filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=0)",display:"none"}}),a("body").append(y)}switch(b){case"hide":y.hide();break;default:var d=e.offset();y.css({top:d.top,left:d.left,display:"block"})}}},$=function(b,c,d){if((void 0===b||isNaN(b))&&(void 0===c||isNaN(c))&&(void 0===d||isNaN(d)))return!1;if(a.isArray(P.settings.direction)||0!==fa(P.settings.direction)){var e=fa(da(b,"undefined"!=typeof c?ea(c,2):"","undefined"!=typeof d?ea(d,2):"")),f=(e+"").length;if(8==f&&("undefined"!=typeof z&&e<fa(da(p,ea(o,2),ea(q,2)))||"undefined"!=typeof A&&e>fa(da(C,ea(D,2),ea(B,2)))))return!0;if(6==f&&("undefined"!=typeof z&&e<fa(da(p,ea(o,2)))||"undefined"!=typeof A&&e>fa(da(C,ea(D,2)))))return!0;if(4==f&&("undefined"!=typeof z&&p>e||"undefined"!=typeof A&&e>C))return!0}"undefined"!=typeof c&&(c+=1);var g=!1,h=!1;return x&&a.each(x,function(){if(!g){var e=this;if((a.inArray(b,e[2])>-1||a.inArray("*",e[2])>-1)&&("undefined"!=typeof c&&a.inArray(c,e[1])>-1||a.inArray("*",e[1])>-1)&&("undefined"!=typeof d&&a.inArray(d,e[0])>-1||a.inArray("*",e[0])>-1)){if("*"==e[3])return g=!0;var f=new Date(b,c-1,d).getDay();if(a.inArray(f,e[3])>-1)return g=!0}}}),w&&a.each(w,function(){if(!h){var e=this;if((a.inArray(b,e[2])>-1||a.inArray("*",e[2])>-1)&&(h=!0,"undefined"!=typeof c))if(h=!0,a.inArray(c,e[1])>-1||a.inArray("*",e[1])>-1){if("undefined"!=typeof d)if(h=!0,a.inArray(d,e[0])>-1||a.inArray("*",e[0])>-1){if("*"==e[3])return h=!0;var f=new Date(b,c-1,d).getDay();if(a.inArray(f,e[3])>-1)return h=!0;h=!1}else h=!1}else h=!1}}),w&&h?!1:x&&g?!0:!1},_=function(a){return(a+"").match(/^\-?[0-9]+$/)?!0:!1},aa=function(b){!isNaN(parseFloat(r))&&isFinite(r)&&(b=b.replace(/\bm\b|\bn\b|\bF\b|\bM\b/,function(b){switch(b){case"m":return ea(r+1,2);case"n":return r+1;case"F":return P.settings.months[r];case"M":return a.isArray(P.settings.months_abbr)&&void 0!==P.settings.months_abbr[r]?P.settings.months_abbr[r]:P.settings.months[r].substr(0,3);default:return b}})),!isNaN(parseFloat(s))&&isFinite(s)&&(b=b.replace(/\bY\b/,s).replace(/\by\b/,(s+"").substr(2)).replace(/\bY1\b/i,s-7).replace(/\bY2\b/i,s+4)),a(".dp_caption",g).html(b)},ba=function(){if(""===h.text()||"days"==d){if(""===h.text()){P.settings.always_visible||e.css("left",-1e3),e.css("visibility","visible"),W();var b=h.outerWidth(),c=h.outerHeight();i.css({width:b,height:c}),j.css({width:b,height:c}),g.css("width",b),K.css("width",b),e.css("visibility","").addClass("dp_hidden")}else W();i.hide(),j.hide()}else"months"==d?(X(),h.hide(),j.hide()):"years"==d&&(Y(),h.hide(),i.hide());if(P.settings.onChange&&"function"==typeof P.settings.onChange&&void 0!==d){var f="days"==d?h.find("td:not(.dp_disabled, .dp_weekend_disabled, .dp_not_in_month)"):"months"==d?i.find("td:not(.dp_disabled, .dp_weekend_disabled, .dp_not_in_month)"):j.find("td:not(.dp_disabled, .dp_weekend_disabled, .dp_not_in_month)");f.each(function(){if("days"==d)if(a(this).hasClass("dp_not_in_month_selectable")){var b=a(this).attr("class").match(/date\_([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])/);a(this).data("date",b[1]+"-"+b[2]+"-"+b[3])}else a(this).data("date",s+"-"+ea(r+1,2)+"-"+ea(fa(a(this).text()),2));else if("months"==d){var b=a(this).attr("class").match(/dp\_month\_([0-9]+)/);a(this).data("date",s+"-"+ea(fa(b[1])+1,2))}else a(this).data("date",fa(a(this).text()))}),P.settings.onChange.call(Q,d,f,Q)}K.show(),P.settings.show_clear_date===!0||0===P.settings.show_clear_date&&""!==Q.val()||P.settings.always_visible&&P.settings.show_clear_date!==!1?(k.show(),L?(J.css("width","50%"),k.css("width","50%")):(J.hide(),k.css("width","100%"))):(k.hide(),L?J.show().css("width","100%"):K.hide())},ca=function(a,b,c,d,e){var f=new Date(a,b,c,12,0,0),g="days"==d?E:"months"==d?F:G,h=V(f);Q.val(h),P.settings.always_visible&&(u=f.getMonth(),r=f.getMonth(),v=f.getFullYear(),s=f.getFullYear(),t=f.getDate(),g.removeClass("dp_selected"),e.addClass("dp_selected"),"days"==d&&e.hasClass("dp_not_in_month_selectable")&&P.show()),P.hide(),ga(f),P.settings.onSelect&&"function"==typeof P.settings.onSelect&&P.settings.onSelect.call(Q,h,a+"-"+ea(b+1,2)+"-"+ea(c,2),f,Q,ha(f)),Q.focus()},da=function(){for(var a="",b=0;b<arguments.length;b++)a+=arguments[b]+"";return a},ea=function(a,b){for(a+="";a.length<b;)a="0"+a;return a},fa=function(a){return parseInt(a,10)},ga=function(b){P.settings.pair&&a.each(P.settings.pair,function(){var c=a(this);if(c.data&&c.data("Zebra_DatePicker")){var d=c.data("Zebra_DatePicker");d.update({reference_date:b,direction:0===d.settings.direction?1:d.settings.direction}),d.settings.always_visible&&d.show()}else c.data("zdp_reference_date",b)})},ha=function(a){var b,c,d,e,f,g,h,i,j,k=a.getFullYear(),l=a.getMonth()+1,m=a.getDate();return 3>l?(b=k-1,c=(b/4|0)-(b/100|0)+(b/400|0),d=((b-1)/4|0)-((b-1)/100|0)+((b-1)/400|0),e=c-d,f=0,g=m-1+31*(l-1)):(b=k,c=(b/4|0)-(b/100|0)+(b/400|0),d=((b-1)/4|0)-((b-1)/100|0)+((b-1)/400|0),e=c-d,f=e+1,g=m+((153*(l-3)+2)/5|0)+58+e),h=(b+c)%7,m=(g+h-f)%7,i=g+3-m,j=0>i?53-((h-e)/5|0):i>364+e?1:(i/7|0)+1},ia={init:function(){this.name=this.searchString(this.dataBrowser)||"",this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||""},searchString:function(a){for(var b=0;b<a.length;b++){var c=a[b].string,d=a[b].prop;if(this.versionSearchString=a[b].versionSearch||a[b].identity,c){if(-1!=c.indexOf(a[b].subString))return a[b].identity}else if(d)return a[b].identity}},searchVersion:function(a){var b=a.indexOf(this.versionSearchString);if(-1!=b)return parseFloat(a.substring(b+this.versionSearchString.length+1))},dataBrowser:[{string:navigator.userAgent,subString:"Firefox",identity:"firefox"},{string:navigator.userAgent,subString:"MSIE",identity:"explorer",versionSearch:"MSIE"}]};ia.init(),R()},a.fn.Zebra_DatePicker=function(b){return this.each(function(){void 0!==a(this).data("Zebra_DatePicker")&&a(this).data("Zebra_DatePicker").destroy();var c=new a.Zebra_DatePicker(this,b);a(this).data("Zebra_DatePicker",c)})}});
1
+ !function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){"use strict";a.Zebra_DatePicker=function(b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q={always_visible:!1,container:a("body"),custom_classes:!1,days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],days_abbr:!1,default_position:"above",direction:0,disabled_dates:!1,enabled_dates:!1,first_day_of_week:1,format:"Y-m-d",header_captions:{days:"F, Y",months:"Y",years:"Y1 - Y2"},header_navigation:["&#171;","&#187;"],icon_position:"right",inside:!0,lang_clear_date:"Clear date",months:["January","February","March","April","May","June","July","August","September","October","November","December"],months_abbr:!1,offset:[5,-5],open_icon_only:!1,pair:!1,readonly_element:!0,select_other_months:!1,show_clear_date:0,show_icon:!0,show_other_months:!0,show_select_today:"Today",show_week_number:!1,start_date:!1,strict:!1,view:"days",weekend_days:[0,6],zero_pad:!1,onChange:null,onClear:null,onOpen:null,onClose:null,onSelect:null},R={},S=this;S.settings={};var T=a(b),U=function(b){if(N=Math.floor(65536*(1+Math.random())).toString(16),!b){S.settings=a.extend({},Q,c),R.readonly=T.attr("readonly"),R.style=T.attr("style");for(var y in T.data())0===y.indexOf("zdp_")&&(y=y.replace(/^zdp\_/,""),void 0!==Q[y]&&(S.settings[y]="pair"==y?a(T.data("zdp_"+y)):T.data("zdp_"+y)))}S.settings.readonly_element&&T.attr("readonly","readonly");var E={days:["d","j","D"],months:["F","m","M","n","t"],years:["o","Y","y"]},F=!1,G=!1,U=!1,X=null;for(X in E)a.each(E[X],function(a,b){S.settings.format.indexOf(b)>-1&&("days"==X?F=!0:"months"==X?G=!0:"years"==X&&(U=!0))});H=F&&G&&U?["years","months","days"]:!F&&G&&U?["years","months"]:F&&G&&!U?["months","days"]:F||G||!U?F||!G||U?["years","months","days"]:["months"]:["years"],-1==a.inArray(S.settings.view,H)&&(S.settings.view=H[H.length-1]),x=[],w=[],O={},P=[];var Y;for(var Z in S.settings.custom_classes)S.settings.custom_classes.hasOwnProperty(Z)&&P.push(Z);for(var $=0;$<2+P.length;$++)Y=0===$?S.settings.disabled_dates:1==$?S.settings.enabled_dates:S.settings.custom_classes[P[$-2]],a.isArray(Y)&&Y.length>0&&a.each(Y,function(){for(var b=this.split(" "),c=0;4>c;c++){b[c]||(b[c]="*"),b[c]=b[c].indexOf(",")>-1?b[c].split(","):new Array(b[c]);for(var d=0;d<b[c].length;d++)if(b[c][d].indexOf("-")>-1){var e=b[c][d].match(/^([0-9]+)\-([0-9]+)/);if(null!==e){for(var f=ja(e[1]);f<=ja(e[2]);f++)-1==a.inArray(f,b[c])&&b[c].push(f+"");b[c].splice(d,1)}}for(d=0;d<b[c].length;d++)b[c][d]=isNaN(ja(b[c][d]))?b[c][d]:ja(b[c][d])}0===$?x.push(b):1==$?w.push(b):(void 0===O[P[$-2]]&&(O[P[$-2]]=[]),O[P[$-2]].push(b))});var _,aa,ba=new Date,ea=S.settings.reference_date?S.settings.reference_date:T.data("zdp_reference_date")&&void 0!==T.data("zdp_reference_date")?T.data("zdp_reference_date"):ba;if(z=void 0,A=void 0,o=ea.getMonth(),l=ba.getMonth(),p=ea.getFullYear(),m=ba.getFullYear(),q=ea.getDate(),n=ba.getDate(),S.settings.direction===!0)z=ea;else if(S.settings.direction===!1)A=ea,D=A.getMonth(),C=A.getFullYear(),B=A.getDate();else if(!a.isArray(S.settings.direction)&&da(S.settings.direction)&&ja(S.settings.direction)>0||a.isArray(S.settings.direction)&&((_=V(S.settings.direction[0]))||S.settings.direction[0]===!0||da(S.settings.direction[0])&&S.settings.direction[0]>0)&&((aa=V(S.settings.direction[1]))||S.settings.direction[1]===!1||da(S.settings.direction[1])&&S.settings.direction[1]>=0))z=_?_:new Date(p,o,q+ja(a.isArray(S.settings.direction)?S.settings.direction[0]===!0?0:S.settings.direction[0]:S.settings.direction)),o=z.getMonth(),p=z.getFullYear(),q=z.getDate(),aa&&+aa>=+z?A=aa:!aa&&S.settings.direction[1]!==!1&&a.isArray(S.settings.direction)&&(A=new Date(p,o,q+ja(S.settings.direction[1]))),A&&(D=A.getMonth(),C=A.getFullYear(),B=A.getDate());else if(!a.isArray(S.settings.direction)&&da(S.settings.direction)&&ja(S.settings.direction)<0||a.isArray(S.settings.direction)&&(S.settings.direction[0]===!1||da(S.settings.direction[0])&&S.settings.direction[0]<0)&&((_=V(S.settings.direction[1]))||da(S.settings.direction[1])&&S.settings.direction[1]>=0))A=new Date(p,o,q+ja(a.isArray(S.settings.direction)?S.settings.direction[0]===!1?0:S.settings.direction[0]:S.settings.direction)),D=A.getMonth(),C=A.getFullYear(),B=A.getDate(),_&&+A>+_?z=_:!_&&a.isArray(S.settings.direction)&&(z=new Date(C,D,B-ja(S.settings.direction[1]))),z&&(o=z.getMonth(),p=z.getFullYear(),q=z.getDate());else if(a.isArray(S.settings.disabled_dates)&&S.settings.disabled_dates.length>0)for(var ha in x)if("*"==x[ha][0]&&"*"==x[ha][1]&&"*"==x[ha][2]&&"*"==x[ha][3]){var la=[];if(a.each(w,function(){var a=this;"*"!=a[2][0]&&la.push(parseInt(a[2][0]+("*"==a[1][0]?"12":ia(a[1][0],2))+("*"==a[0][0]?"*"==a[1][0]?"31":new Date(a[2][0],a[1][0],0).getDate():ia(a[0][0],2)),10))}),la.sort(),la.length>0){var na=(la[0]+"").match(/([0-9]{4})([0-9]{2})([0-9]{2})/);p=parseInt(na[1],10),o=parseInt(na[2],10)-1,q=parseInt(na[3],10)}break}if(ca(p,o,q)){for(;ca(p);)z?(p++,o=0):(p--,o=11);for(;ca(p,o);)z?(o++,q=1):(o--,q=new Date(p,o+1,0).getDate()),o>11?(p++,o=0,q=1):0>o&&(p--,o=11,q=new Date(p,o+1,0).getDate());for(;ca(p,o,q);)z?q++:q--,ba=new Date(p,o,q),p=ba.getFullYear(),o=ba.getMonth(),q=ba.getDate();ba=new Date(p,o,q),p=ba.getFullYear(),o=ba.getMonth(),q=ba.getDate()}var oa=V(T.val()||(S.settings.start_date?S.settings.start_date:""));if(oa&&S.settings.strict&&ca(oa.getFullYear(),oa.getMonth(),oa.getDate())&&T.val(""),b||void 0===z&&void 0===oa||ka(void 0!==oa?oa:z),!S.settings.always_visible){if(!b){if(S.settings.show_icon){"firefox"==ma.name&&T.is('input[type="text"]')&&"inline"==T.css("display")&&T.css("display","inline-block");var pa=a('<span class="Zebra_DatePicker_Icon_Wrapper"></span>').css({display:T.css("display"),position:"static"==T.css("position")?"relative":T.css("position"),"float":T.css("float"),top:T.css("top"),right:T.css("right"),bottom:T.css("bottom"),left:T.css("left")});"block"==T.css("display")&&pa.css("width",T.outerWidth(!0)),T.wrap(pa).css({position:"relative",top:"auto",right:"auto",bottom:"auto",left:"auto"}),f=a('<button type="button" class="Zebra_DatePicker_Icon'+("disabled"==T.attr("disabled")?" Zebra_DatePicker_Icon_Disabled":"")+'">Pick a date</button>'),S.icon=f,I=S.settings.open_icon_only?f:f.add(T)}else I=T;I.bind("click.Zebra_DatePicker_"+N,function(a){a.preventDefault(),T.attr("disabled")||(e.hasClass("dp_visible")?S.hide():S.show())}),!S.settings.readonly_element&&S.settings.pair&&T.bind("blur.Zebra_DatePicker_"+N,function(){var b;(b=V(a(this).val()))&&!ca(b.getFullYear(),b.getMonth(),b.getDate())&&ka(b)}),void 0!==f&&f.insertAfter(T)}if(void 0!==f){f.attr("style",""),S.settings.inside&&f.addClass("Zebra_DatePicker_Icon_Inside_"+("right"==S.settings.icon_position?"Right":"Left"));var qa=T.outerWidth(),ra=T.outerHeight(),sa=parseInt(T.css("marginLeft"),10)||0,ta=parseInt(T.css("marginTop"),10)||0,ua=(f.outerWidth(),f.outerHeight()),va=parseInt(f.css("marginLeft"),10)||0;parseInt(f.css("marginRight"),10)||0;S.settings.inside?(f.css("top",ta+(ra-ua)/2),"right"==S.settings.icon_position?f.css("right",0):f.css("left",0)):f.css({top:ta+(ra-ua)/2,left:sa+qa+va}),f.removeClass(" Zebra_DatePicker_Icon_Disabled"),"disabled"==T.attr("disabled")&&f.addClass("Zebra_DatePicker_Icon_Disabled")}}if(L=S.settings.show_select_today!==!1&&a.inArray("days",H)>-1&&!ca(m,l,n)?S.settings.show_select_today:!1,b)return a(".dp_previous",e).html(S.settings.header_navigation[0]),a(".dp_next",e).html(S.settings.header_navigation[1]),a(".dp_clear",e).html(S.settings.lang_clear_date),void a(".dp_today",e).html(S.settings.show_select_today);a(window).bind("resize.Zebra_DatePicker_"+N+", orientationchange.Zebra_DatePicker_"+N,function(){S.hide(),void 0!==f&&(clearTimeout(M),M=setTimeout(function(){S.update()},100))});var wa='<div class="Zebra_DatePicker"><table class="dp_header"><tr><td class="dp_previous">'+S.settings.header_navigation[0]+'</td><td class="dp_caption">&#032;</td><td class="dp_next">'+S.settings.header_navigation[1]+'</td></tr></table><table class="dp_daypicker"></table><table class="dp_monthpicker"></table><table class="dp_yearpicker"></table><table class="dp_footer"><tr><td class="dp_today"'+(S.settings.show_clear_date!==!1?' style="width:50%"':"")+">"+L+'</td><td class="dp_clear"'+(L!==!1?' style="width:50%"':"")+">"+S.settings.lang_clear_date+"</td></tr></table></div>";e=a(wa),S.datepicker=e,g=a("table.dp_header",e),h=a("table.dp_daypicker",e),i=a("table.dp_monthpicker",e),j=a("table.dp_yearpicker",e),K=a("table.dp_footer",e),J=a("td.dp_today",K),k=a("td.dp_clear",K),S.settings.always_visible?T.attr("disabled")||(S.settings.always_visible.append(e),S.show()):S.settings.container.append(e),e.delegate("td:not(.dp_disabled, .dp_weekend_disabled, .dp_not_in_month, .dp_week_number)","mouseover",function(){a(this).addClass("dp_hover")}).delegate("td:not(.dp_disabled, .dp_weekend_disabled, .dp_not_in_month, .dp_week_number)","mouseout",function(){a(this).removeClass("dp_hover")}),W(a("td",g)),a(".dp_previous",g).bind("click",function(){"months"==d?s--:"years"==d?s-=12:--r<0&&(r=11,s--),fa()}),a(".dp_caption",g).bind("click",function(){d="days"==d?a.inArray("months",H)>-1?"months":a.inArray("years",H)>-1?"years":"days":"months"==d?a.inArray("years",H)>-1?"years":a.inArray("days",H)>-1?"days":"months":a.inArray("days",H)>-1?"days":a.inArray("months",H)>-1?"months":"years",fa()}),a(".dp_next",g).bind("click",function(){"months"==d?s++:"years"==d?s+=12:12==++r&&(r=0,s++),fa()}),h.delegate("td:not(.dp_disabled, .dp_weekend_disabled, .dp_not_in_month, .dp_week_number)","click",function(){S.settings.select_other_months&&a(this).attr("class")&&null!==(na=a(this).attr("class").match(/date\_([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])/))?ga(na[1],na[2]-1,na[3],"days",a(this)):ga(s,r,ja(a(this).html()),"days",a(this))}),i.delegate("td:not(.dp_disabled)","click",function(){var b=a(this).attr("class").match(/dp\_month\_([0-9]+)/);r=ja(b[1]),-1==a.inArray("days",H)?ga(s,r,1,"months",a(this)):(d="days",S.settings.always_visible&&T.val(""),fa())}),j.delegate("td:not(.dp_disabled)","click",function(){s=ja(a(this).html()),-1==a.inArray("months",H)?ga(s,1,1,"years",a(this)):(d="months",S.settings.always_visible&&T.val(""),fa())}),a(J).bind("click",function(b){b.preventDefault(),ga(m,l,n,"days",a(".dp_current",h)),S.settings.always_visible&&S.show(),S.hide()}),a(k).bind("click",function(b){b.preventDefault(),T.val(""),S.settings.always_visible?(t=null,u=null,v=null,a("td.dp_selected",e).removeClass("dp_selected")):(t=null,u=null,v=null,r=null,s=null),S.hide(),S.settings.onClear&&"function"==typeof S.settings.onClear&&S.settings.onClear.call(T,T)}),S.settings.always_visible||(a(document).bind("mousedown.Zebra_DatePicker_"+N+", touchstart.Zebra_DatePicker_"+N,function(b){if(e.hasClass("dp_visible")){if(S.settings.show_icon&&a(b.target).get(0)===f.get(0))return!0;0===a(b.target).parents().filter(".Zebra_DatePicker").length&&S.hide()}}),a(document).bind("keyup.Zebra_DatePicker_"+N,function(a){e.hasClass("dp_visible")&&27==a.which&&S.hide()})),fa()};S.clear_date=function(){a(k).trigger("click")},S.destroy=function(){void 0!==S.icon&&S.icon.remove(),S.datepicker.remove(),S.settings.show_icon&&!S.settings.always_visible&&T.unwrap(),T.unbind("click.Zebra_DatePicker_"+N),T.unbind("blur.Zebra_DatePicker_"+N),a(document).unbind("keyup.Zebra_DatePicker_"+N),a(document).unbind("mousedown.Zebra_DatePicker_"+N),a(window).unbind("resize.Zebra_DatePicker_"+N),a(window).unbind("orientationchange.Zebra_DatePicker_"+N),T.removeData("Zebra_DatePicker"),T.attr("readonly",R.readonly?!0:!1),T.attr("style",R.style?R.style:"")},S.hide=function(){S.settings.always_visible||(ba("hide"),e.removeClass("dp_visible").addClass("dp_hidden"),S.settings.onClose&&"function"==typeof S.settings.onClose&&S.settings.onClose.call(T,T))},S.set_date=function(a){var b;(b=V(a))&&!ca(b.getFullYear(),b.getMonth(),b.getDate())&&(T.val(a),ka(b))},S.show=function(){d=S.settings.view;var b=V(T.val()||(S.settings.start_date?S.settings.start_date:""));if(b?(u=b.getMonth(),r=b.getMonth(),v=b.getFullYear(),s=b.getFullYear(),t=b.getDate(),ca(v,u,t)&&(S.settings.strict&&T.val(""),r=o,s=p)):(r=o,s=p),fa(),S.settings.always_visible)e.removeClass("dp_hidden").addClass("dp_visible");else{if(S.settings.container.is("body")){var c=e.outerWidth(),g=e.outerHeight(),h=(void 0!==f?f.offset().left+f.outerWidth(!0):T.offset().left+T.outerWidth(!0))+S.settings.offset[0],i=(void 0!==f?f.offset().top:T.offset().top)-g+S.settings.offset[1],j=a(window).width(),k=a(window).height(),l=a(window).scrollTop(),m=a(window).scrollLeft();"below"==S.settings.default_position&&(i=(void 0!==f?f.offset().top:T.offset().top)+S.settings.offset[1]),h+c>m+j&&(h=m+j-c),m>h&&(h=m),i+g>l+k&&(i=l+k-g),l>i&&(i=l),e.css({left:h,top:i})}else e.css({left:0,top:0});e.removeClass("dp_hidden").addClass("dp_visible"),ba()}S.settings.onOpen&&"function"==typeof S.settings.onOpen&&S.settings.onOpen.call(T,T)},S.update=function(b){S.original_direction&&(S.original_direction=S.direction),S.settings=a.extend(S.settings,b),U(!0)};var V=function(b){if(b+="",""!==a.trim(b)){for(var c=X(S.settings.format),d=["d","D","j","l","N","S","w","F","m","M","n","Y","y"],e=[],f=[],g=null,h=null,i=0;i<d.length;i++)(g=c.indexOf(d[i]))>-1&&e.push({character:d[i],position:g});if(e.sort(function(a,b){return a.position-b.position}),a.each(e,function(a,b){switch(b.character){case"d":f.push("0[1-9]|[12][0-9]|3[01]");break;case"D":f.push("[a-z]{3}");break;case"j":f.push("[1-9]|[12][0-9]|3[01]");break;case"l":f.push("[a-z]+");break;case"N":f.push("[1-7]");break;case"S":f.push("st|nd|rd|th");break;case"w":f.push("[0-6]");break;case"F":f.push("[a-z]+");break;case"m":f.push("0[1-9]|1[012]+");break;case"M":f.push("[a-z]{3}");break;case"n":f.push("[1-9]|1[012]");break;case"Y":f.push("[0-9]{4}");break;case"y":f.push("[0-9]{2}")}}),f.length&&(e.reverse(),a.each(e,function(a,b){c=c.replace(b.character,"("+f[f.length-a-1]+")")}),f=new RegExp("^"+c+"$","ig"),h=f.exec(b))){var j,k=new Date,l=1,m=k.getMonth()+1,n=k.getFullYear(),o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],p=["January","February","March","April","May","June","July","August","September","October","November","December"],q=!0;if(e.reverse(),a.each(e,function(b,c){if(!q)return!0;switch(c.character){case"m":case"n":m=ja(h[b+1]);break;case"d":case"j":l=ja(h[b+1]);break;case"D":case"l":case"F":case"M":j="D"==c.character||"l"==c.character?S.settings.days:S.settings.months,q=!1,a.each(j,function(a,d){if(q)return!0;if(h[b+1].toLowerCase()==d.substring(0,"D"==c.character||"M"==c.character?3:d.length).toLowerCase()){switch(c.character){case"D":h[b+1]=o[a].substring(0,3);break;case"l":h[b+1]=o[a];break;case"F":h[b+1]=p[a],m=a+1;break;case"M":h[b+1]=p[a].substring(0,3),m=a+1}q=!0}});break;case"Y":n=ja(h[b+1]);break;case"y":n="19"+ja(h[b+1])}}),q){var r=new Date(n,(m||1)-1,l||1);if(r.getFullYear()==n&&r.getDate()==(l||1)&&r.getMonth()==(m||1)-1)return r}}return!1}},W=function(a){"firefox"==ma.name?a.css("MozUserSelect","none"):"explorer"==ma.name?a.bind("selectstart",function(){return!1}):a.mousedown(function(){return!1})},X=function(a){return a.replace(/([-.,*+?^${}()|[\]\/\\])/g,"\\$1")},Y=function(b){for(var c="",d=b.getDate(),e=b.getDay(),f=S.settings.days[e],g=b.getMonth()+1,h=S.settings.months[g-1],i=b.getFullYear()+"",j=0;j<S.settings.format.length;j++){var k=S.settings.format.charAt(j);switch(k){case"y":i=i.substr(2);case"Y":c+=i;break;case"m":g=ia(g,2);case"n":c+=g;break;case"M":h=a.isArray(S.settings.months_abbr)&&void 0!==S.settings.months_abbr[g-1]?S.settings.months_abbr[g-1]:S.settings.months[g-1].substr(0,3);case"F":c+=h;break;case"d":d=ia(d,2);case"j":c+=d;break;case"D":f=a.isArray(S.settings.days_abbr)&&void 0!==S.settings.days_abbr[e]?S.settings.days_abbr[e]:S.settings.days[e].substr(0,3);case"l":c+=f;break;case"N":e++;case"w":c+=e;break;case"S":c+=d%10==1&&"11"!=d?"st":d%10==2&&"12"!=d?"nd":d%10==3&&"13"!=d?"rd":"th";break;default:c+=k}}return c},Z=function(){var b=new Date(s,r+1,0).getDate(),c=new Date(s,r,1).getDay(),d=new Date(s,r,0).getDate(),e=c-S.settings.first_day_of_week;e=0>e?7+e:e,ea(S.settings.header_captions.days);var f="<tr>";S.settings.show_week_number&&(f+="<th>"+S.settings.show_week_number+"</th>");for(var g=0;7>g;g++)f+="<th>"+(a.isArray(S.settings.days_abbr)&&void 0!==S.settings.days_abbr[(S.settings.first_day_of_week+g)%7]?S.settings.days_abbr[(S.settings.first_day_of_week+g)%7]:S.settings.days[(S.settings.first_day_of_week+g)%7].substr(0,2))+"</th>";for(f+="</tr><tr>",g=0;42>g;g++){g>0&&g%7===0&&(f+="</tr><tr>"),g%7===0&&S.settings.show_week_number&&(f+='<td class="dp_week_number">'+la(new Date(s,r,g-e+1))+"</td>");var i=g-e+1;if(S.settings.select_other_months&&(e>g||i>b)){var j=new Date(s,r,i),k=j.getFullYear(),o=j.getMonth(),p=j.getDate();j=k+ia(o+1,2)+ia(p,2)}if(e>g)f+='<td class="'+(S.settings.select_other_months&&!ca(k,o,p)?"dp_not_in_month_selectable date_"+j:"dp_not_in_month")+'">'+(S.settings.select_other_months||S.settings.show_other_months?ia(d-e+g+1,S.settings.zero_pad?2:0):"&nbsp;")+"</td>";else if(i>b)f+='<td class="'+(S.settings.select_other_months&&!ca(k,o,p)?"dp_not_in_month_selectable date_"+j:"dp_not_in_month")+'">'+(S.settings.select_other_months||S.settings.show_other_months?ia(i-b,S.settings.zero_pad?2:0):"&nbsp;")+"</td>";else{var q=(S.settings.first_day_of_week+g)%7,w="",x=aa(s,r,i);ca(s,r,i)?(a.inArray(q,S.settings.weekend_days)>-1?w="dp_weekend_disabled":w+=" dp_disabled",r==l&&s==m&&n==i&&(w+=" dp_disabled_current"),""!=x&&(w+=" "+x+"_disabled")):(a.inArray(q,S.settings.weekend_days)>-1&&(w="dp_weekend"),r==u&&s==v&&t==i&&(w+=" dp_selected"),r==l&&s==m&&n==i&&(w+=" dp_current"),""!=x&&(w+=" "+x)),f+="<td"+(""!==w?' class="'+a.trim(w)+'"':"")+">"+((S.settings.zero_pad?ia(i,2):i)||"&nbsp;")+"</td>"}}f+="</tr>",h.html(a(f)),S.settings.always_visible&&(E=a("td:not(.dp_disabled, .dp_weekend_disabled, .dp_not_in_month, .dp_week_number)",h)),h.show()},$=function(){ea(S.settings.header_captions.months);for(var b="<tr>",c=0;12>c;c++){c>0&&c%3===0&&(b+="</tr><tr>");var d="dp_month_"+c;ca(s,c)?d+=" dp_disabled":u!==!1&&u==c&&s==v?d+=" dp_selected":l==c&&m==s&&(d+=" dp_current"),b+='<td class="'+a.trim(d)+'">'+(a.isArray(S.settings.months_abbr)&&void 0!==S.settings.months_abbr[c]?S.settings.months_abbr[c]:S.settings.months[c].substr(0,3))+"</td>"}b+="</tr>",i.html(a(b)),S.settings.always_visible&&(F=a("td:not(.dp_disabled)",i)),i.show()},_=function(){ea(S.settings.header_captions.years);for(var b="<tr>",c=0;12>c;c++){c>0&&c%3===0&&(b+="</tr><tr>");var d="";ca(s-7+c)?d+=" dp_disabled":v&&v==s-7+c?d+=" dp_selected":m==s-7+c&&(d+=" dp_current"),b+="<td"+(""!==a.trim(d)?' class="'+a.trim(d)+'"':"")+">"+(s-7+c)+"</td>"}b+="</tr>",j.html(a(b)),S.settings.always_visible&&(G=a("td:not(.dp_disabled)",j)),j.show()},aa=function(b,c,d){var e,f,g;"undefined"!=typeof c&&(c+=1);for(f in P)if(e=P[f],g=!1,a.isArray(O[e])&&a.each(O[e],function(){if(!g){var f=this;if((a.inArray(b,f[2])>-1||a.inArray("*",f[2])>-1)&&("undefined"!=typeof c&&a.inArray(c,f[1])>-1||a.inArray("*",f[1])>-1)&&("undefined"!=typeof d&&a.inArray(d,f[0])>-1||a.inArray("*",f[0])>-1)){if("*"==f[3])return g=e;var h=new Date(b,c-1,d).getDay();if(a.inArray(h,f[3])>-1)return g=e}}}),g)return g;return g||""},ba=function(b){if("explorer"==ma.name&&6==ma.version){if(!y){var c=ja(e.css("zIndex"))-1;y=a("<iframe>",{src:'javascript:document.write("")',scrolling:"no",frameborder:0,css:{zIndex:c,position:"absolute",top:-1e3,left:-1e3,width:e.outerWidth(),height:e.outerHeight(),filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=0)",display:"none"}}),a("body").append(y)}switch(b){case"hide":y.hide();break;default:var d=e.offset();y.css({top:d.top,left:d.left,display:"block"})}}},ca=function(b,c,d){if(!(void 0!==b&&!isNaN(b)||void 0!==c&&!isNaN(c)||void 0!==d&&!isNaN(d)))return!1;if(1e3>b)return!0;if(a.isArray(S.settings.direction)||0!==ja(S.settings.direction)){var e=ja(ha(b,"undefined"!=typeof c?ia(c,2):"","undefined"!=typeof d?ia(d,2):"")),f=(e+"").length;if(8==f&&("undefined"!=typeof z&&e<ja(ha(p,ia(o,2),ia(q,2)))||"undefined"!=typeof A&&e>ja(ha(C,ia(D,2),ia(B,2)))))return!0;if(6==f&&("undefined"!=typeof z&&e<ja(ha(p,ia(o,2)))||"undefined"!=typeof A&&e>ja(ha(C,ia(D,2)))))return!0;if(4==f&&("undefined"!=typeof z&&p>e||"undefined"!=typeof A&&e>C))return!0}"undefined"!=typeof c&&(c+=1);var g=!1,h=!1;return a.isArray(x)&&x.length&&a.each(x,function(){if(!g){var e=this;if((a.inArray(b,e[2])>-1||a.inArray("*",e[2])>-1)&&("undefined"!=typeof c&&a.inArray(c,e[1])>-1||a.inArray("*",e[1])>-1)&&("undefined"!=typeof d&&a.inArray(d,e[0])>-1||a.inArray("*",e[0])>-1)){if("*"==e[3])return g=!0;var f=new Date(b,c-1,d).getDay();if(a.inArray(f,e[3])>-1)return g=!0}}}),w&&a.each(w,function(){if(!h){var e=this;if((a.inArray(b,e[2])>-1||a.inArray("*",e[2])>-1)&&(h=!0,"undefined"!=typeof c))if(h=!0,a.inArray(c,e[1])>-1||a.inArray("*",e[1])>-1){if("undefined"!=typeof d)if(h=!0,a.inArray(d,e[0])>-1||a.inArray("*",e[0])>-1){if("*"==e[3])return h=!0;var f=new Date(b,c-1,d).getDay();if(a.inArray(f,e[3])>-1)return h=!0;h=!1}else h=!1}else h=!1}}),w&&h?!1:x&&g?!0:!1},da=function(a){return(a+"").match(/^\-?[0-9]+$/)?!0:!1},ea=function(b){!isNaN(parseFloat(r))&&isFinite(r)&&(b=b.replace(/\bm\b|\bn\b|\bF\b|\bM\b/,function(b){switch(b){case"m":return ia(r+1,2);case"n":return r+1;case"F":return S.settings.months[r];case"M":return a.isArray(S.settings.months_abbr)&&void 0!==S.settings.months_abbr[r]?S.settings.months_abbr[r]:S.settings.months[r].substr(0,3);default:return b}})),!isNaN(parseFloat(s))&&isFinite(s)&&(b=b.replace(/\bY\b/,s).replace(/\by\b/,(s+"").substr(2)).replace(/\bY1\b/i,s-7).replace(/\bY2\b/i,s+4)),a(".dp_caption",g).html(b)},fa=function(){if(""===h.text()||"days"==d){if(""===h.text()){S.settings.always_visible||e.css("left",-1e3),e.css("visibility","visible"),Z();var b=h.outerWidth(),c=h.outerHeight();i.css({width:b,height:c}),j.css({width:b,height:c}),g.css("width",b),K.css("width",b),e.css("visibility","").addClass("dp_hidden")}else Z();i.hide(),j.hide()}else"months"==d?($(),h.hide(),j.hide()):"years"==d&&(_(),h.hide(),i.hide());if(S.settings.onChange&&"function"==typeof S.settings.onChange&&void 0!==d){var f="days"==d?h.find("td:not(.dp_disabled, .dp_weekend_disabled, .dp_not_in_month)"):"months"==d?i.find("td:not(.dp_disabled, .dp_weekend_disabled, .dp_not_in_month)"):j.find("td:not(.dp_disabled, .dp_weekend_disabled, .dp_not_in_month)");f.each(function(){var b;"days"==d?a(this).hasClass("dp_not_in_month_selectable")?(b=a(this).attr("class").match(/date\_([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])/),a(this).data("date",b[1]+"-"+b[2]+"-"+b[3])):a(this).data("date",s+"-"+ia(r+1,2)+"-"+ia(ja(a(this).text()),2)):"months"==d?(b=a(this).attr("class").match(/dp\_month\_([0-9]+)/),a(this).data("date",s+"-"+ia(ja(b[1])+1,2))):a(this).data("date",ja(a(this).text()))}),S.settings.onChange.call(T,d,f,T)}K.show(),S.settings.show_clear_date===!0||0===S.settings.show_clear_date&&""!==T.val()||S.settings.always_visible&&S.settings.show_clear_date!==!1?(k.show(),L?(J.css("width","50%"),k.css("width","50%")):(J.hide(),k.css("width","100%"))):(k.hide(),L?J.show().css("width","100%"):K.hide())},ga=function(a,b,c,d,e){var f=new Date(a,b,c,12,0,0),g="days"==d?E:"months"==d?F:G,h=Y(f);T.val(h),S.settings.always_visible&&(u=f.getMonth(),r=f.getMonth(),v=f.getFullYear(),s=f.getFullYear(),t=f.getDate(),g.removeClass("dp_selected"),e.addClass("dp_selected"),"days"==d&&e.hasClass("dp_not_in_month_selectable")&&S.show()),S.hide(),ka(f),S.settings.onSelect&&"function"==typeof S.settings.onSelect&&S.settings.onSelect.call(T,h,a+"-"+ia(b+1,2)+"-"+ia(c,2),f,T,la(f)),T.focus()},ha=function(){for(var a="",b=0;b<arguments.length;b++)a+=arguments[b]+"";return a},ia=function(a,b){for(a+="";a.length<b;)a="0"+a;return a},ja=function(a){return parseInt(a,10)},ka=function(b){S.settings.pair&&a.each(S.settings.pair,function(){var c=a(this);if(c.data&&c.data("Zebra_DatePicker")){var d=c.data("Zebra_DatePicker");d.update({reference_date:b,direction:0===d.settings.direction?1:d.settings.direction}),d.settings.always_visible&&d.show()}else c.data("zdp_reference_date",b)})},la=function(a){var b,c,d,e,f,g,h,i,j,k=a.getFullYear(),l=a.getMonth()+1,m=a.getDate();return 3>l?(b=k-1,c=(b/4|0)-(b/100|0)+(b/400|0),d=((b-1)/4|0)-((b-1)/100|0)+((b-1)/400|0),e=c-d,f=0,g=m-1+31*(l-1)):(b=k,c=(b/4|0)-(b/100|0)+(b/400|0),d=((b-1)/4|0)-((b-1)/100|0)+((b-1)/400|0),e=c-d,f=e+1,g=m+((153*(l-3)+2)/5|0)+58+e),h=(b+c)%7,m=(g+h-f)%7,i=g+3-m,j=0>i?53-((h-e)/5|0):i>364+e?1:(i/7|0)+1},ma={init:function(){this.name=this.searchString(this.dataBrowser)||"",this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||""},searchString:function(a){for(var b=0;b<a.length;b++){var c=a[b].string,d=a[b].prop;if(this.versionSearchString=a[b].versionSearch||a[b].identity,c){if(-1!=c.indexOf(a[b].subString))return a[b].identity}else if(d)return a[b].identity}},searchVersion:function(a){var b=a.indexOf(this.versionSearchString);if(-1!=b)return parseFloat(a.substring(b+this.versionSearchString.length+1))},dataBrowser:[{string:navigator.userAgent,subString:"Firefox",identity:"firefox"},{string:navigator.userAgent,subString:"MSIE",identity:"explorer",versionSearch:"MSIE"}]};ma.init(),U()},a.fn.Zebra_DatePicker=function(b){return this.each(function(){void 0!==a(this).data("Zebra_DatePicker")&&a(this).data("Zebra_DatePicker").destroy();var c=new a.Zebra_DatePicker(this,b);a(this).data("Zebra_DatePicker",c)})}});
@@ -8,8 +8,8 @@
8
8
  * For more resources visit {@link http://stefangabos.ro/}
9
9
  *
10
10
  * @author Stefan Gabos <contact@stefangabos.ro>
11
- * @version 1.9.2 (last revision: April 30, 2015)
12
- * @copyright (c) 2011 - 2015 Stefan Gabos
11
+ * @version 1.9.5 (last revision: May 13, 2016)
12
+ * @copyright (c) 2011 - 2016 Stefan Gabos
13
13
  * @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU LESSER GENERAL PUBLIC LICENSE
14
14
  * @package Zebra_DatePicker
15
15
  */
@@ -46,6 +46,27 @@
46
46
  // default is $('body')
47
47
  container: $('body'),
48
48
 
49
+ // dates that should have custom classes applied to them
50
+ // an object in the form of
51
+ // {
52
+ // 'myclass1': [dates_to_apply_the_custom_class_to],
53
+ // 'myclass2': [dates_to_apply_the_custom_class_to]
54
+ // }
55
+ // where "dates_to_apply_the_custom_class_to" is an array of dates in the same format as required for
56
+ // "disabled_dates" property.
57
+ //
58
+ // custom classes will be applied *only* in the day picker view and not on month/year views!
59
+ // also note that the class name will have the "_disabled" suffix added if the day the class is applied to
60
+ // is disabled
61
+ //
62
+ // in order for the styles in your custom classes to be applied, make sure you are using the following syntax:
63
+ //
64
+ // .Zebra_DatePicker .dp_daypicker td.myclass1 { .. }
65
+ // .Zebra_DatePicker .dp_daypicker td.myclass1_disabled { .. }
66
+ //
67
+ // default is FALSE, no custom classes
68
+ custom_classes: false,
69
+
49
70
  // days of the week; Sunday to Saturday
50
71
  days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
51
72
 
@@ -184,6 +205,12 @@
184
205
  // default is ['&#171;','&#187;']
185
206
  header_navigation: ['&#171;', '&#187;'],
186
207
 
208
+ // icon's position
209
+ // accepted values are "left" and "right"
210
+ //
211
+ // default is "right"
212
+ icon_position: 'right',
213
+
187
214
  // should the icon for opening the datepicker be inside the element?
188
215
  // if set to FALSE, the icon will be placed to the right of the parent element, while if set to TRUE it will
189
216
  // be placed to the right of the parent element, but *inside* the element itself
@@ -215,6 +242,12 @@
215
242
  // default is [5, -5]
216
243
  offset: [5, -5],
217
244
 
245
+ // set whether the date picker should be shown *only* when clicking the icon
246
+ // note that if you set the "show_icon" property to FALSE, you will not be able to show the date picker anymore!
247
+ //
248
+ // default is FALSE
249
+ open_icon_only: false,
250
+
218
251
  // if set as a jQuery element with a Zebra_DatePicker attached, that particular date picker will use the
219
252
  // current date picker's value as starting date
220
253
  // note that the rules set in the "direction" property will still apply, only that the reference date will
@@ -371,7 +404,7 @@
371
404
  current_system_day, first_selectable_month, first_selectable_year, first_selectable_day, selected_month, selected_year,
372
405
  default_day, default_month, default_year, enabled_dates, disabled_dates, shim, start_date, end_date, last_selectable_day,
373
406
  last_selectable_year, last_selectable_month, daypicker_cells, monthpicker_cells, yearpicker_cells, views, clickables,
374
- selecttoday, footer, show_select_today, timeout, uniqueid;
407
+ selecttoday, footer, show_select_today, timeout, uniqueid, custom_classes, custom_class_names, original_attributes = {};
375
408
 
376
409
  var plugin = this;
377
410
 
@@ -393,12 +426,16 @@
393
426
  // the code is taken from http://stackoverflow.com/a/105074
394
427
  uniqueid = Math.floor((1 + Math.random()) * 0x10000).toString(16);
395
428
 
396
- // unless we're just updating settings
429
+ // unless we're not just updating settings
397
430
  if (!update) {
398
431
 
399
432
  // merge default settings with user-settings (
400
433
  plugin.settings = $.extend({}, defaults, options);
401
434
 
435
+ // preserve some of element's original attributes
436
+ original_attributes['readonly'] = $element.attr('readonly');
437
+ original_attributes['style'] = $element.attr('style');
438
+
402
439
  // iterate through the element's data attributes (if any)
403
440
  for (var data in $element.data())
404
441
 
@@ -482,18 +519,23 @@
482
519
  // parse the rules for disabling dates and turn them into arrays of arrays
483
520
 
484
521
  // array that will hold the rules for enabling/disabling dates
485
- disabled_dates = []; enabled_dates = [];
522
+ disabled_dates = []; enabled_dates = []; custom_classes = {}; custom_class_names = [];
486
523
 
487
524
  var dates;
488
525
 
489
- // it's the same logic for preparing the enabled/disable dates...
490
- for (var l = 0; l < 2; l++) {
526
+ for (var k in plugin.settings.custom_classes) if (plugin.settings.custom_classes.hasOwnProperty(k)) custom_class_names.push(k);
527
+
528
+ // it's the same logic for preparing the enabled/disable dates, as well as dates that have custom classes
529
+ for (var l = 0; l < 2 + custom_class_names.length; l++) {
491
530
 
492
531
  // first time we're doing disabled dates,
493
532
  if (l === 0) dates = plugin.settings.disabled_dates;
494
533
 
495
534
  // second time we're doing enabled_dates
496
- else dates = plugin.settings.enabled_dates;
535
+ else if (l == 1) dates = plugin.settings.enabled_dates;
536
+
537
+ // otherwise, we're doing dates that will have custom classes
538
+ else dates = plugin.settings.custom_classes[custom_class_names[l - 2]];
497
539
 
498
540
  // if we have a non-empty array
499
541
  if ($.isArray(dates) && dates.length > 0)
@@ -552,7 +594,15 @@
552
594
  if (l === 0) disabled_dates.push(rules);
553
595
 
554
596
  // second time we're doing enabled_dates
555
- else enabled_dates.push(rules);
597
+ else if (l == 1) enabled_dates.push(rules);
598
+
599
+ // otherwise, we're doing the dates to which custom classes need to be applied
600
+ else {
601
+
602
+ if (undefined === custom_classes[custom_class_names[l - 2]]) custom_classes[custom_class_names[l - 2]] = [];
603
+ custom_classes[custom_class_names[l - 2]].push(rules);
604
+
605
+ }
556
606
 
557
607
  });
558
608
 
@@ -909,7 +959,7 @@
909
959
 
910
960
  // updates value for the date picker whose starting date depends on the selected date (if any)
911
961
  if (!update && (undefined !== start_date || undefined !== default_date))
912
- update_dependent(undefined !== start_date ? start_date : default_date);
962
+ update_dependent(undefined !== default_date ? default_date : start_date);
913
963
 
914
964
  // if date picker is not always visible
915
965
  if (!plugin.settings.always_visible) {
@@ -938,6 +988,10 @@
938
988
  'left': $element.css('left')
939
989
  });
940
990
 
991
+ // if parent element has its "display" property set to "block"
992
+ // the wrapper has to have its "width" set
993
+ if ($element.css('display') == 'block') icon_wrapper.css('width', $element.outerWidth(true));
994
+
941
995
  // put wrapper around the element
942
996
  // also, make sure we set some important css properties for it
943
997
  $element.wrap(icon_wrapper).css({
@@ -955,13 +1009,14 @@
955
1009
  plugin.icon = icon;
956
1010
 
957
1011
  // the date picker will open when clicking both the icon and the element the plugin is attached to
958
- clickables = icon.add($element);
1012
+ // (or the icon only, if set so)
1013
+ clickables = plugin.settings.open_icon_only ? icon : icon.add($element);
959
1014
 
960
1015
  // if calendar icon is not visible, the date picker will open when clicking the element
961
1016
  } else clickables = $element;
962
1017
 
963
1018
  // attach the click event to the clickable elements (icon and/or element)
964
- clickables.bind('click', function(e) {
1019
+ clickables.bind('click.Zebra_DatePicker_' + uniqueid, function(e) {
965
1020
 
966
1021
  e.preventDefault();
967
1022
 
@@ -976,6 +1031,19 @@
976
1031
 
977
1032
  });
978
1033
 
1034
+ // if users can manually enter dates and a pair date element exists
1035
+ if (!plugin.settings.readonly_element && plugin.settings.pair)
1036
+
1037
+ // whenever the element looses focus
1038
+ $element.bind('blur.Zebra_DatePicker_' + uniqueid, function() {
1039
+
1040
+ var date;
1041
+
1042
+ // if a valid date was entered, update the paired date picker
1043
+ if ((date = check_date($(this).val())) && !is_disabled(date.getFullYear(), date.getMonth(), date.getDate())) update_dependent(date);
1044
+
1045
+ });
1046
+
979
1047
  // if icon exists, inject it into the DOM, right after the parent element (and inside the wrapper)
980
1048
  if (undefined !== icon) icon.insertAfter($element);
981
1049
 
@@ -990,11 +1058,11 @@
990
1058
 
991
1059
  // if calendar icon is to be placed *inside* the element
992
1060
  // add an extra class to the icon
993
- if (plugin.settings.inside) icon.addClass('Zebra_DatePicker_Icon_Inside');
1061
+ if (plugin.settings.inside) icon.addClass('Zebra_DatePicker_Icon_Inside_' + (plugin.settings.icon_position == 'right' ? 'Right' : 'Left'));
994
1062
 
995
1063
  var
996
1064
 
997
- // get element' width and height (including margins)
1065
+ // get element's width and height (including margins)
998
1066
  element_width = $element.outerWidth(),
999
1067
  element_height = $element.outerHeight(),
1000
1068
  element_margin_left = parseInt($element.css('marginLeft'), 10) || 0,
@@ -1008,16 +1076,18 @@
1008
1076
 
1009
1077
  // if icon is to be placed *inside* the element
1010
1078
  // position the icon accordingly
1011
- if (plugin.settings.inside)
1079
+ if (plugin.settings.inside) {
1012
1080
 
1013
- icon.css({
1014
- 'top': element_margin_top + ((element_height - icon_height) / 2),
1015
- 'left': element_margin_left + (element_width - icon_width - icon_margin_right)
1016
- });
1081
+ // set icon's top
1082
+ icon.css('top', element_margin_top + ((element_height - icon_height) / 2));
1083
+
1084
+ // place icon to the right or to the left, according to the settings
1085
+ if (plugin.settings.icon_position == 'right') icon.css('right', 0);
1086
+ else icon.css('left', 0);
1017
1087
 
1018
1088
  // if icon is to be placed to the right of the element
1019
1089
  // position the icon accordingly
1020
- else
1090
+ } else
1021
1091
 
1022
1092
  icon.css({
1023
1093
  'top': element_margin_top + ((element_height - icon_height) / 2),
@@ -1038,11 +1108,22 @@
1038
1108
  // (the "days" view is available and "today" is not a disabled date)
1039
1109
  show_select_today = (plugin.settings.show_select_today !== false && $.inArray('days', views) > -1 && !is_disabled(current_system_year, current_system_month, current_system_day) ? plugin.settings.show_select_today : false);
1040
1110
 
1041
- // if we just needed to recompute the things above, return now
1042
- if (update) return;
1111
+ // if we just needed to recompute the things above
1112
+ if (update) {
1113
+
1114
+ // make sure we update these strings, in case they've changed
1115
+ $('.dp_previous', datepicker).html(plugin.settings.header_navigation[0]);
1116
+ $('.dp_next', datepicker).html(plugin.settings.header_navigation[1]);
1117
+ $('.dp_clear', datepicker).html(plugin.settings.lang_clear_date);
1118
+ $('.dp_today', datepicker).html(plugin.settings.show_select_today);
1119
+
1120
+ // don't go further
1121
+ return;
1122
+
1123
+ }
1043
1124
 
1044
- // update icon/date picker position on resize
1045
- $(window).bind('resize.Zebra_DatePicker_' + uniqueid, function() {
1125
+ // update icon/date picker position on resize and/or changing orientation
1126
+ $(window).bind('resize.Zebra_DatePicker_' + uniqueid + ', orientationchange.Zebra_DatePicker_' + uniqueid, function() {
1046
1127
 
1047
1128
  // hide the date picker
1048
1129
  plugin.hide();
@@ -1369,6 +1450,17 @@
1369
1450
 
1370
1451
  };
1371
1452
 
1453
+ /**
1454
+ * Clears the selected date.
1455
+ *
1456
+ * @return void
1457
+ */
1458
+ plugin.clear_date = function() {
1459
+
1460
+ $(cleardate).trigger('click');
1461
+
1462
+ };
1463
+
1372
1464
  /**
1373
1465
  * Destroys the date picker.
1374
1466
  *
@@ -1382,14 +1474,27 @@
1382
1474
  // ...and the calendar
1383
1475
  plugin.datepicker.remove();
1384
1476
 
1477
+ // if calendar icon was shown and the date picker was not always visible,
1478
+ // also remove the wrapper needed for positioning it
1479
+ if (plugin.settings.show_icon && !plugin.settings.always_visible) $element.unwrap();
1480
+
1481
+ // remove associated event handlers from the element
1482
+ $element.unbind('click.Zebra_DatePicker_' + uniqueid);
1483
+ $element.unbind('blur.Zebra_DatePicker_' + uniqueid);
1484
+
1385
1485
  // remove associated event handlers from the document
1386
1486
  $(document).unbind('keyup.Zebra_DatePicker_' + uniqueid);
1387
1487
  $(document).unbind('mousedown.Zebra_DatePicker_' + uniqueid);
1388
1488
  $(window).unbind('resize.Zebra_DatePicker_' + uniqueid);
1489
+ $(window).unbind('orientationchange.Zebra_DatePicker_' + uniqueid);
1389
1490
 
1390
1491
  // remove association with the element
1391
1492
  $element.removeData('Zebra_DatePicker');
1392
1493
 
1494
+ // restore element's modified attributes
1495
+ $element.attr('readonly', original_attributes['readonly'] ? true : false);
1496
+ $element.attr('style', original_attributes['style'] ? original_attributes['style'] : '');
1497
+
1393
1498
  };
1394
1499
 
1395
1500
  /**
@@ -1417,6 +1522,30 @@
1417
1522
 
1418
1523
  };
1419
1524
 
1525
+ /**
1526
+ * Set the date picker's value
1527
+ *
1528
+ * Must be in the format set by the "format" property!
1529
+ *
1530
+ * @return void
1531
+ */
1532
+ plugin.set_date = function(date) {
1533
+
1534
+ var dateObj;
1535
+
1536
+ // if a valid date was entered, and date is not disabled
1537
+ if ((dateObj = check_date(date)) && !is_disabled(dateObj.getFullYear(), dateObj.getMonth(), dateObj.getDate())) {
1538
+
1539
+ // set the element's value
1540
+ $element.val(date);
1541
+
1542
+ // update the paired date picker (if any)
1543
+ update_dependent(dateObj);
1544
+
1545
+ }
1546
+
1547
+ };
1548
+
1420
1549
  /**
1421
1550
  * Shows the date picker.
1422
1551
  *
@@ -2018,7 +2147,10 @@
2018
2147
  // get the week day (0 to 6, Sunday to Saturday)
2019
2148
  weekday = (plugin.settings.first_day_of_week + i) % 7,
2020
2149
 
2021
- class_name = '';
2150
+ class_name = '',
2151
+
2152
+ // custom class, if any
2153
+ custom_class_name = get_custom_class(selected_year, selected_month, day);
2022
2154
 
2023
2155
  // if date needs to be disabled
2024
2156
  if (is_disabled(selected_year, selected_month, day)) {
@@ -2032,6 +2164,9 @@
2032
2164
  // highlight the current system date
2033
2165
  if (selected_month == current_system_month && selected_year == current_system_year && current_system_day == day) class_name += ' dp_disabled_current';
2034
2166
 
2167
+ // apply custom class, with the "_disabled" suffix, if a custom class exists
2168
+ if (custom_class_name != '') class_name += ' ' + custom_class_name + '_disabled';
2169
+
2035
2170
  // if there are no restrictions
2036
2171
  } else {
2037
2172
 
@@ -2044,10 +2179,13 @@
2044
2179
  // highlight the current system date
2045
2180
  if (selected_month == current_system_month && selected_year == current_system_year && current_system_day == day) class_name += ' dp_current';
2046
2181
 
2182
+ // apply custom class, if a custom class exists
2183
+ if (custom_class_name != '') class_name += ' ' + custom_class_name;
2184
+
2047
2185
  }
2048
2186
 
2049
2187
  // print the day of the month (if "day" is NaN, use an empty string instead)
2050
- html += '<td' + (class_name !== '' ? ' class="' + $.trim(class_name) + '"' : '') + '>' + ((plugin.settings.zero_pad ? str_pad(day, 2) : day) || '') + '</td>';
2188
+ html += '<td' + (class_name !== '' ? ' class="' + $.trim(class_name) + '"' : '') + '>' + ((plugin.settings.zero_pad ? str_pad(day, 2) : day) || '&nbsp;') + '</td>';
2051
2189
 
2052
2190
  }
2053
2191
 
@@ -2181,6 +2319,76 @@
2181
2319
 
2182
2320
  };
2183
2321
 
2322
+ /**
2323
+ * Return the name of a custom class to be applied to the given date.
2324
+ *
2325
+ * @return string The name of a custom class to be applied to the given date, or an empty string if no custom
2326
+ * class needs to be applied.
2327
+ *
2328
+ * @param integer year The year to check
2329
+ * @param integer month The month to check
2330
+ * @param integer day The day to check
2331
+ *
2332
+ * @access private
2333
+ */
2334
+ var get_custom_class = function(year, month, day) {
2335
+
2336
+ var class_name, i, found;
2337
+
2338
+ // if month is given as argument, increment it (as JavaScript uses 0 for January, 1 for February...)
2339
+ if (typeof month != 'undefined') month = month + 1;
2340
+
2341
+ // iterate through the custom classes
2342
+ for (i in custom_class_names) {
2343
+
2344
+ // the class name we're currently checking
2345
+ class_name = custom_class_names[i]; found = false;
2346
+
2347
+ // if there are any custom classes defined
2348
+ if ($.isArray(custom_classes[class_name]))
2349
+
2350
+ // iterate through the rules for which the custom class to be applied
2351
+ $.each(custom_classes[class_name], function() {
2352
+
2353
+ // if a custom class needs to be applied to the date we're checking, don't look further
2354
+ if (found) return;
2355
+
2356
+ var rule = this;
2357
+
2358
+ // if the rules apply for the current year
2359
+ if ($.inArray(year, rule[2]) > -1 || $.inArray('*', rule[2]) > -1)
2360
+
2361
+ // if the rules apply for the current month
2362
+ if ((typeof month != 'undefined' && $.inArray(month, rule[1]) > -1) || $.inArray('*', rule[1]) > -1)
2363
+
2364
+ // if the rules apply for the current day
2365
+ if ((typeof day != 'undefined' && $.inArray(day, rule[0]) > -1) || $.inArray('*', rule[0]) > -1) {
2366
+
2367
+ // if custom class is to be applied whatever the day
2368
+ // don't look any further
2369
+ if (rule[3] == '*') return (found = class_name);
2370
+
2371
+ // get the weekday
2372
+ var weekday = new Date(year, month - 1, day).getDay();
2373
+
2374
+ // if custom class is to be applied to weekday
2375
+ // don't look any further
2376
+ if ($.inArray(weekday, rule[3]) > -1) return (found = class_name);
2377
+
2378
+ }
2379
+
2380
+ });
2381
+
2382
+ // if a custom class needs to be applied to the date we're checking, don't look further
2383
+ if (found) return found;
2384
+
2385
+ }
2386
+
2387
+ // return what we've found
2388
+ return found || '';
2389
+
2390
+ };
2391
+
2184
2392
  /**
2185
2393
  * Generates an iFrame shim in Internet Explorer 6 so that the date picker appears above select boxes.
2186
2394
  *
@@ -2270,6 +2478,9 @@
2270
2478
  // don't check bogus values
2271
2479
  if ((undefined === year || isNaN(year)) && (undefined === month || isNaN(month)) && (undefined === day || isNaN(day))) return false;
2272
2480
 
2481
+ // this date picker cannot handle years before 1000, so we return false in this case
2482
+ else if (year < 1000) return true;
2483
+
2273
2484
  // if calendar has direction restrictions
2274
2485
  if (!(!$.isArray(plugin.settings.direction) && to_int(plugin.settings.direction) === 0)) {
2275
2486
 
@@ -2325,7 +2536,7 @@
2325
2536
  var disabled = false, enabled = false;
2326
2537
 
2327
2538
  // if there are rules for disabling dates
2328
- if (disabled_dates)
2539
+ if ($.isArray(disabled_dates) && disabled_dates.length)
2329
2540
 
2330
2541
  // iterate through the rules for disabling dates
2331
2542
  $.each(disabled_dates, function() {
@@ -2618,6 +2829,8 @@
2618
2829
  // so it's easy to identify elements in the list
2619
2830
  elements.each(function() {
2620
2831
 
2832
+ var matches;
2833
+
2621
2834
  // if view is "days"
2622
2835
  if (view == 'days') {
2623
2836
 
@@ -2625,7 +2838,7 @@
2625
2838
  if ($(this).hasClass('dp_not_in_month_selectable')) {
2626
2839
 
2627
2840
  // extract date from the attached class
2628
- var matches = $(this).attr('class').match(/date\_([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])/);
2841
+ matches = $(this).attr('class').match(/date\_([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])/);
2629
2842
 
2630
2843
  // attach a "date" data attribute to each element in the form of of YYYY-MM-DD for easily identifying sought elements
2631
2844
  $(this).data('date', matches[1] + '-' + matches[2] + '-' + matches[3]);
@@ -2640,7 +2853,7 @@
2640
2853
  } else if (view == 'months') {
2641
2854
 
2642
2855
  // get the month's number for the element's class
2643
- var matches = $(this).attr('class').match(/dp\_month\_([0-9]+)/);
2856
+ matches = $(this).attr('class').match(/dp\_month\_([0-9]+)/);
2644
2857
 
2645
2858
  // attach a "date" data attribute to each element in the form of of YYYY-MM for easily identifying sought elements
2646
2859
  $(this).data('date', selected_year + '-' + str_pad(to_int(matches[1]) + 1, 2));
@@ -2838,7 +3051,7 @@
2838
3051
  var to_int = function(str) {
2839
3052
 
2840
3053
  // return the integer representation of the string given as argument
2841
- return parseInt(str , 10);
3054
+ return parseInt(str, 10);
2842
3055
 
2843
3056
  };
2844
3057
 
@@ -92,4 +92,5 @@ button.Zebra_DatePicker_Icon_Disabled { background-image: asset-url('zebra
92
92
 
93
93
  /* don't set vertical margins! */
94
94
  button.Zebra_DatePicker_Icon { margin: 0 0 0 3px }
95
- button.Zebra_DatePicker_Icon_Inside { margin: 0 3px 0 0 }
95
+ button.Zebra_DatePicker_Icon_Inside_Right { margin: 0 3px 0 0 }
96
+ button.Zebra_DatePicker_Icon_Inside_Left { margin: 0 0 0 3px }
@@ -99,4 +99,5 @@ button.Zebra_DatePicker_Icon_Disabled { background-image: asset-url('zebra
99
99
 
100
100
  /* don't set vertical margins! */
101
101
  button.Zebra_DatePicker_Icon { margin: 0 0 0 3px }
102
- button.Zebra_DatePicker_Icon_Inside { margin: 0 3px 0 0 }
102
+ button.Zebra_DatePicker_Icon_Inside_Right { margin: 0 3px 0 0 }
103
+ button.Zebra_DatePicker_Icon_Inside_Left { margin: 0 0 0 3px }
@@ -102,5 +102,6 @@ button.Zebra_DatePicker_Icon { display: block; position: absolute; wi
102
102
  button.Zebra_DatePicker_Icon_Disabled { background-image: asset-url('zebra-datepicker/calendar-disabled.png') }
103
103
 
104
104
  /* don't set vertical margins! */
105
- button.Zebra_DatePicker_Icon { margin: 0 0 0 3px }
106
- button.Zebra_DatePicker_Icon_Inside { margin: 0 3px 0 0 }
105
+ button.Zebra_DatePicker_Icon { margin: 0 0 0 3px }
106
+ button.Zebra_DatePicker_Icon_Inside_Right { margin: 0 3px 0 0 }
107
+ button.Zebra_DatePicker_Icon_Inside_Left { margin: 0 0 0 3px }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zebra-datepicker-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.2
4
+ version: 1.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcus Derencius
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-21 00:00:00.000000000 Z
11
+ date: 2017-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  version: '0'
117
117
  requirements: []
118
118
  rubyforge_project:
119
- rubygems_version: 2.4.5
119
+ rubygems_version: 2.6.8
120
120
  signing_key:
121
121
  specification_version: 4
122
122
  summary: Zebra Datepicker (http://stefangabos.ro/jquery/zebra-datepicker/) packaged