zebra-datepicker-rails 1.8.10 → 1.9.2

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: d12cbe8b52d89979deb8a2a343172d0a298e31ea
4
- data.tar.gz: 037f88f5bf48cfbc1ea47f1c143226b086249878
3
+ metadata.gz: f13f9252b0ac459177ebb727eeb325f89cf55a61
4
+ data.tar.gz: a59ade21abe0350f171cb09f9d8603cd21b2605b
5
5
  SHA512:
6
- metadata.gz: 2e0d6843ec6e6f1b8270a801b3f1edceffbe93438108ba8a674b4603dba064af248e080b8f59f1414365d607f83308edff47d737f65100de3207ecea502039b6
7
- data.tar.gz: 96ff62b3a0d234432df1c6eabf2b7f1051d6292e33ccb2d15d15350510b144d8d405d939b226945c055bc12b13275b48d3b338255ea38c79de42a8d56ad7ba34
6
+ metadata.gz: f0f01a874fbfdfc960a443ba3ba96a2d1d73e82e83cffbde9282691ef71f08e6cb07d8e6ae549f35e92df688b85d0fc7b2127b8f4f33e205b5fe10ddd08df6b0
7
+ data.tar.gz: 646ee814c1b6eedb0f7ae48ee7e3909ce45ebc91d4180e37c6f794d2fc4de6de0161c7e6071ede1ce05dfb5ee4220e8e7bef48b457197085ee3050e57ae27d0b
@@ -0,0 +1,3 @@
1
+ [submodule "Zebra_Datepicker"]
2
+ path = Zebra_Datepicker
3
+ url = git@github.com:stefangabos/Zebra_Datepicker.git
data/README.md CHANGED
@@ -1,10 +1,6 @@
1
1
  # Zebra Datepicker for Rails
2
2
 
3
- zebra-datepicker-rails gem integrates the Zebra Datepicker with Rails assets pipeline.
4
-
5
- http://github.com/derencius/zebra-datepicker-rails
6
-
7
- https://github.com/stefangabos/Zebra_Datepicker/
3
+ [zebra-datepicker-rails](http://github.com/derencius/zebra-datepicker-rails) gem integrates the [Zebra Datepicker](https://github.com/stefangabos/Zebra_Datepicker) with Rails assets pipeline.
8
4
 
9
5
  ## Rails > 3.1
10
6
  Include zebra-datepicker-rails in Gemfile;
@@ -54,4 +50,4 @@ Copyright (c) 2013 Marcus Derencius
54
50
 
55
51
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
56
52
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
57
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
53
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require "bundler/gem_tasks"
3
3
  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
- Dir.glob('*.css.scss').each do |filename|
6
+ Dir.glob('*.scss').each do |filename|
7
7
  content = File.read(filename).gsub!(" url('", " asset-url('zebra-datepicker/")
8
8
  file = File.open(filename, 'w')
9
9
  file.write(content)
@@ -15,18 +15,17 @@ desc 'Copy Assets from Zebra_Datepicker'
15
15
 
16
16
  task :copy do
17
17
  {
18
- 'public/css/bootstrap.css' => 'vendor/assets/stylesheets/zebra-datepicker/bootstrap.css.scss',
19
- 'public/css/default.css' => 'vendor/assets/stylesheets/zebra-datepicker/default.css.scss',
20
- 'public/css/metallic.css' => 'vendor/assets/stylesheets/zebra-datepicker/metallic.css.scss',
18
+ 'public/css/bootstrap.css' => 'vendor/assets/stylesheets/zebra-datepicker/bootstrap.scss',
19
+ 'public/css/default.css' => 'vendor/assets/stylesheets/zebra-datepicker/default.scss',
20
+ 'public/css/metallic.css' => 'vendor/assets/stylesheets/zebra-datepicker/metallic.scss',
21
21
 
22
- 'public/css/metallic/' => 'vendor/assets/images/zebra-datepicker/',
22
+ 'public/css/metallic/' => 'vendor/assets/images/zebra-datepicker/',
23
23
  'public/css/calendar-disabled.png' => 'vendor/assets/images/zebra-datepicker/',
24
- 'public/css/calendar.png' => 'vendor/assets/images/zebra-datepicker/',
24
+ 'public/css/calendar.png' => 'vendor/assets/images/zebra-datepicker/',
25
25
 
26
26
  'public/javascript/zebra_datepicker.js' => 'vendor/assets/javascripts/zebra-datepicker/',
27
27
  'public/javascript/zebra_datepicker.src.js' => 'vendor/assets/javascripts/zebra-datepicker/'
28
28
  }.each do |src, dest|
29
- FileUtils.cp_r("../Zebra_Datepicker/#{src}", dest)
29
+ FileUtils.cp_r("Zebra_Datepicker/#{src}", dest)
30
30
  end
31
31
  end
32
-
@@ -1,5 +1,5 @@
1
1
  module ZebraDatepickerRails
2
2
  module Rails
3
- VERSION = "1.8.10"
3
+ VERSION = "1.9.2"
4
4
  end
5
5
  end
@@ -1 +1 @@
1
- !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={always_visible:!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;"],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,onSelect:null},O=this;O.settings={};var P=a(b),Q=function(b){if(!b){O.settings=a.extend({},N,c);for(var y in P.data())0===y.indexOf("zdp_")&&(y=y.replace(/^zdp\_/,""),void 0!==N[y]&&(O.settings[y]="pair"==y?a(P.data("zdp_"+y)):P.data("zdp_"+y)))}O.settings.readonly_element&&P.attr("readonly","readonly");var E={days:["d","j","D"],months:["F","m","M","n","t"],years:["o","Y","y"]},F=!1,G=!1,Q=!1,T=null;for(T in E)a.each(E[T],function(a,b){O.settings.format.indexOf(b)>-1&&("days"==T?F=!0:"months"==T?G=!0:"years"==T&&(Q=!0))});H=F&&G&&Q?["years","months","days"]:!F&&G&&Q?["years","months"]:F&&G&&!Q?["months","days"]:F||G||!Q?F||!G||Q?["years","months","days"]:["months"]:["years"],-1==a.inArray(O.settings.view,H)&&(O.settings.view=H[H.length-1]),x=[],w=[];for(var U,V=0;2>V;V++)U=0===V?O.settings.disabled_dates:O.settings.enabled_dates,a.isArray(U)&&U.length>0&&a.each(U,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=eb(e[1]);f<=eb(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(eb(b[c][d]))?b[c][d]:eb(b[c][d])}0===V?x.push(b):w.push(b)});var W,X,Y=new Date,_=O.settings.reference_date?O.settings.reference_date:P.data("zdp_reference_date")&&void 0!==P.data("zdp_reference_date")?P.data("zdp_reference_date"):Y;if(z=void 0,A=void 0,o=_.getMonth(),l=Y.getMonth(),p=_.getFullYear(),m=Y.getFullYear(),q=_.getDate(),n=Y.getDate(),O.settings.direction===!0)z=_;else if(O.settings.direction===!1)A=_,D=A.getMonth(),C=A.getFullYear(),B=A.getDate();else if(!a.isArray(O.settings.direction)&&$(O.settings.direction)&&eb(O.settings.direction)>0||a.isArray(O.settings.direction)&&((W=R(O.settings.direction[0]))||O.settings.direction[0]===!0||$(O.settings.direction[0])&&O.settings.direction[0]>0)&&((X=R(O.settings.direction[1]))||O.settings.direction[1]===!1||$(O.settings.direction[1])&&O.settings.direction[1]>=0))z=W?W:new Date(p,o,q+(a.isArray(O.settings.direction)?eb(O.settings.direction[0]===!0?0:O.settings.direction[0]):eb(O.settings.direction))),o=z.getMonth(),p=z.getFullYear(),q=z.getDate(),X&&+X>=+z?A=X:!X&&O.settings.direction[1]!==!1&&a.isArray(O.settings.direction)&&(A=new Date(p,o,q+eb(O.settings.direction[1]))),A&&(D=A.getMonth(),C=A.getFullYear(),B=A.getDate());else if(!a.isArray(O.settings.direction)&&$(O.settings.direction)&&eb(O.settings.direction)<0||a.isArray(O.settings.direction)&&(O.settings.direction[0]===!1||$(O.settings.direction[0])&&O.settings.direction[0]<0)&&((W=R(O.settings.direction[1]))||$(O.settings.direction[1])&&O.settings.direction[1]>=0))A=new Date(p,o,q+(a.isArray(O.settings.direction)?eb(O.settings.direction[0]===!1?0:O.settings.direction[0]):eb(O.settings.direction))),D=A.getMonth(),C=A.getFullYear(),B=A.getDate(),W&&+A>+W?z=W:!W&&a.isArray(O.settings.direction)&&(z=new Date(C,D,B-eb(O.settings.direction[1]))),z&&(o=z.getMonth(),p=z.getFullYear(),q=z.getDate());else if(a.isArray(O.settings.disabled_dates)&&O.settings.disabled_dates.length>0)for(var cb in x)if("*"==x[cb][0]&&"*"==x[cb][1]&&"*"==x[cb][2]&&"*"==x[cb][3]){var gb=[];if(a.each(w,function(){var a=this;"*"!=a[2][0]&&gb.push(parseInt(a[2][0]+("*"==a[1][0]?"12":db(a[1][0],2))+("*"==a[0][0]?"*"==a[1][0]?"31":new Date(a[2][0],a[1][0],0).getDate():db(a[0][0],2)),10))}),gb.sort(),gb.length>0){var ib=(gb[0]+"").match(/([0-9]{4})([0-9]{2})([0-9]{2})/);p=parseInt(ib[1],10),o=parseInt(ib[2],10)-1,q=parseInt(ib[3],10)}break}if(Z(p,o,q)){for(;Z(p);)z?(p++,o=0):(p--,o=11);for(;Z(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(;Z(p,o,q);)z?q++:q--,Y=new Date(p,o,q),p=Y.getFullYear(),o=Y.getMonth(),q=Y.getDate();Y=new Date(p,o,q),p=Y.getFullYear(),o=Y.getMonth(),q=Y.getDate()}var jb=R(P.val()||(O.settings.start_date?O.settings.start_date:""));if(jb&&O.settings.strict&&Z(jb.getFullYear(),jb.getMonth(),jb.getDate())&&P.val(""),b||void 0===z&&void 0===jb||fb(void 0!==z?z:jb),!O.settings.always_visible){if(!b){if(O.settings.show_icon){"firefox"==hb.name&&P.is('input[type="text"]')&&"inline"==P.css("display")&&P.css("display","inline-block");var kb=a('<span class="Zebra_DatePicker_Icon_Wrapper"></span>').css({display:P.css("display"),position:"static"==P.css("position")?"relative":P.css("position"),"float":P.css("float"),top:P.css("top"),right:P.css("right"),bottom:P.css("bottom"),left:P.css("left")});P.wrap(kb).css({position:"relative",top:"auto",right:"auto",bottom:"auto",left:"auto"}),f=a('<button type="button" class="Zebra_DatePicker_Icon'+("disabled"==P.attr("disabled")?" Zebra_DatePicker_Icon_Disabled":"")+'">Pick a date</button>'),O.icon=f,I=f.add(P)}else I=P;I.bind("click",function(a){a.preventDefault(),P.attr("disabled")||(e.hasClass("dp_visible")?O.hide():O.show())}),void 0!==f&&f.insertAfter(P)}if(void 0!==f){f.attr("style",""),O.settings.inside&&f.addClass("Zebra_DatePicker_Icon_Inside");var lb=P.outerWidth(),mb=P.outerHeight(),nb=parseInt(P.css("marginLeft"),10)||0,ob=parseInt(P.css("marginTop"),10)||0,pb=f.outerWidth(),qb=f.outerHeight(),rb=parseInt(f.css("marginLeft"),10)||0,sb=parseInt(f.css("marginRight"),10)||0;O.settings.inside?f.css({top:ob+(mb-qb)/2,left:nb+(lb-pb-sb)}):f.css({top:ob+(mb-qb)/2,left:nb+lb+rb}),f.removeClass(" Zebra_DatePicker_Icon_Disabled"),"disabled"==P.attr("disabled")&&f.addClass("Zebra_DatePicker_Icon_Disabled")}}if(L=O.settings.show_select_today!==!1&&a.inArray("days",H)>-1&&!Z(m,l,n)?O.settings.show_select_today:!1,!b){a(window).bind("resize.Zebra_DatePicker",function(){O.hide(),void 0!==f&&(clearTimeout(M),M=setTimeout(function(){O.update()},100))});var tb='<div class="Zebra_DatePicker"><table class="dp_header"><tr><td class="dp_previous">'+O.settings.header_navigation[0]+'</td><td class="dp_caption">&#032;</td><td class="dp_next">'+O.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"'+(O.settings.show_clear_date!==!1?' style="width:50%"':"")+">"+L+'</td><td class="dp_clear"'+(L!==!1?' style="width:50%"':"")+">"+O.settings.lang_clear_date+"</td></tr></table></div>";e=a(tb),O.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),O.settings.always_visible?P.attr("disabled")||(O.settings.always_visible.append(e),O.show()):a("body").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")}),S(a("td",g)),a(".dp_previous",g).bind("click",function(){"months"==d?s--:"years"==d?s-=12:--r<0&&(r=11,s--),ab()}),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",ab()}),a(".dp_next",g).bind("click",function(){"months"==d?s++:"years"==d?s+=12:12==++r&&(r=0,s++),ab()}),h.delegate("td:not(.dp_disabled, .dp_weekend_disabled, .dp_not_in_month, .dp_week_number)","click",function(){O.settings.select_other_months&&null!==(ib=a(this).attr("class").match(/date\_([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])/))?bb(ib[1],ib[2]-1,ib[3],"days",a(this)):bb(s,r,eb(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=eb(b[1]),-1==a.inArray("days",H)?bb(s,r,1,"months",a(this)):(d="days",O.settings.always_visible&&P.val(""),ab())}),j.delegate("td:not(.dp_disabled)","click",function(){s=eb(a(this).html()),-1==a.inArray("months",H)?bb(s,1,1,"years",a(this)):(d="months",O.settings.always_visible&&P.val(""),ab())}),a(J).bind("click",function(b){b.preventDefault(),bb(m,l,n,"days",a(".dp_current",h)),O.settings.always_visible&&O.show(),O.hide()}),a(k).bind("click",function(b){b.preventDefault(),P.val(""),O.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),O.hide(),O.settings.onClear&&"function"==typeof O.settings.onClear&&O.settings.onClear.call(P,P)}),O.settings.always_visible||a(document).bind({"mousedown.Zebra_DatePicker":function(b){if(e.hasClass("dp_visible")){if(O.settings.show_icon&&a(b.target).get(0)===f.get(0))return!0;0===a(b.target).parents().filter(".Zebra_DatePicker").length&&O.hide()}},"keyup.Zebra_DatePicker":function(a){e.hasClass("dp_visible")&&27==a.which&&O.hide()}}),ab()}};O.destroy=function(){void 0!==O.icon&&O.icon.remove(),O.datepicker.remove(),a(document).unbind("keyup.Zebra_DatePicker"),a(document).unbind("mousedown.Zebra_DatePicker"),a(window).unbind("resize.Zebra_DatePicker"),P.removeData("Zebra_DatePicker")},O.hide=function(){O.settings.always_visible||(Y("hide"),e.removeClass("dp_visible").addClass("dp_hidden"))},O.show=function(){d=O.settings.view;var b=R(P.val()||(O.settings.start_date?O.settings.start_date:""));if(b?(u=b.getMonth(),r=b.getMonth(),v=b.getFullYear(),s=b.getFullYear(),t=b.getDate(),Z(v,u,t)&&(O.settings.strict&&P.val(""),r=o,s=p)):(r=o,s=p),ab(),O.settings.always_visible)e.removeClass("dp_hidden").addClass("dp_visible");else{var c=e.outerWidth(),g=e.outerHeight(),h=(void 0!==f?f.offset().left+f.outerWidth(!0):P.offset().left+P.outerWidth(!0))+O.settings.offset[0],i=(void 0!==f?f.offset().top:P.offset().top)-g+O.settings.offset[1],j=a(window).width(),k=a(window).height(),l=a(window).scrollTop(),m=a(window).scrollLeft();"below"==O.settings.default_position&&(i=(void 0!==f?f.offset().top:P.offset().top)+O.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}),e.removeClass("dp_hidden").addClass("dp_visible"),Y()}O.settings.onOpen&&"function"==typeof O.settings.onOpen&&O.settings.onOpen.call(P,P)},O.update=function(b){O.original_direction&&(O.original_direction=O.direction),O.settings=a.extend(O.settings,b),Q(!0)};var R=function(b){if(b+="",""!==a.trim(b)){for(var c=T(O.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=eb(h[b+1]);break;case"d":case"j":l=eb(h[b+1]);break;case"D":case"l":case"F":case"M":j="D"==c.character||"l"==c.character?O.settings.days:O.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=eb(h[b+1]);break;case"y":n="19"+eb(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}},S=function(a){"firefox"==hb.name?a.css("MozUserSelect","none"):"explorer"==hb.name?a.bind("selectstart",function(){return!1}):a.mousedown(function(){return!1})},T=function(a){return a.replace(/([-.,*+?^${}()|[\]\/\\])/g,"\\$1")},U=function(b){for(var c="",d=b.getDate(),e=b.getDay(),f=O.settings.days[e],g=b.getMonth()+1,h=O.settings.months[g-1],i=b.getFullYear()+"",j=0;j<O.settings.format.length;j++){var k=O.settings.format.charAt(j);switch(k){case"y":i=i.substr(2);case"Y":c+=i;break;case"m":g=db(g,2);case"n":c+=g;break;case"M":h=a.isArray(O.settings.months_abbr)&&void 0!==O.settings.months_abbr[g-1]?O.settings.months_abbr[g-1]:O.settings.months[g-1].substr(0,3);case"F":c+=h;break;case"d":d=db(d,2);case"j":c+=d;break;case"D":f=a.isArray(O.settings.days_abbr)&&void 0!==O.settings.days_abbr[e]?O.settings.days_abbr[e]:O.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},V=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-O.settings.first_day_of_week;e=0>e?7+e:e,_(O.settings.header_captions.days);var f="<tr>";O.settings.show_week_number&&(f+="<th>"+O.settings.show_week_number+"</th>");for(var g=0;7>g;g++)f+="<th>"+(a.isArray(O.settings.days_abbr)&&void 0!==O.settings.days_abbr[(O.settings.first_day_of_week+g)%7]?O.settings.days_abbr[(O.settings.first_day_of_week+g)%7]:O.settings.days[(O.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&&O.settings.show_week_number&&(f+='<td class="dp_week_number">'+gb(new Date(s,r,g-e+1))+"</td>");var i=g-e+1;if(O.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+db(o+1,2)+db(p,2)}if(e>g)f+='<td class="'+(O.settings.select_other_months&&!Z(k,o,p)?"dp_not_in_month_selectable date_"+j:"dp_not_in_month")+'">'+(O.settings.select_other_months||O.settings.show_other_months?db(d-e+g+1,O.settings.zero_pad?2:0):"&nbsp;")+"</td>";else if(i>b)f+='<td class="'+(O.settings.select_other_months&&!Z(k,o,p)?"dp_not_in_month_selectable date_"+j:"dp_not_in_month")+'">'+(O.settings.select_other_months||O.settings.show_other_months?db(i-b,O.settings.zero_pad?2:0):"&nbsp;")+"</td>";else{var q=(O.settings.first_day_of_week+g)%7,w="";Z(s,r,i)?(a.inArray(q,O.settings.weekend_days)>-1?w="dp_weekend_disabled":w+=" dp_disabled",r==l&&s==m&&n==i&&(w+=" dp_disabled_current")):(a.inArray(q,O.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)+'"':"")+">"+(O.settings.zero_pad?db(i,2):i)+"</td>"}}f+="</tr>",h.html(a(f)),O.settings.always_visible&&(E=a("td:not(.dp_disabled, .dp_weekend_disabled, .dp_not_in_month, .dp_week_number)",h)),h.show()},W=function(){_(O.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;Z(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(O.settings.months_abbr)&&void 0!==O.settings.months_abbr[c]?O.settings.months_abbr[c]:O.settings.months[c].substr(0,3))+"</td>"}b+="</tr>",i.html(a(b)),O.settings.always_visible&&(F=a("td:not(.dp_disabled)",i)),i.show()},X=function(){_(O.settings.header_captions.years);for(var b="<tr>",c=0;12>c;c++){c>0&&c%3===0&&(b+="</tr><tr>");var d="";Z(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)),O.settings.always_visible&&(G=a("td:not(.dp_disabled)",j)),j.show()},Y=function(b){if("explorer"==hb.name&&6==hb.version){if(!y){var c=eb(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"})}}},Z=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(O.settings.direction)||0!==eb(O.settings.direction)){var e=eb(cb(b,"undefined"!=typeof c?db(c,2):"","undefined"!=typeof d?db(d,2):"")),f=(e+"").length;if(8==f&&("undefined"!=typeof z&&e<eb(cb(p,db(o,2),db(q,2)))||"undefined"!=typeof A&&e>eb(cb(C,db(D,2),db(B,2)))))return!0;if(6==f&&("undefined"!=typeof z&&e<eb(cb(p,db(o,2)))||"undefined"!=typeof A&&e>eb(cb(C,db(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},_=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 db(r+1,2);case"n":return r+1;case"F":return O.settings.months[r];case"M":return a.isArray(O.settings.months_abbr)&&void 0!==O.settings.months_abbr[r]?O.settings.months_abbr[r]:O.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)},ab=function(){if(""===h.text()||"days"==d){if(""===h.text()){O.settings.always_visible||e.css("left",-1e3),e.css("visibility","visible"),V();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 V();i.hide(),j.hide()}else"months"==d?(W(),h.hide(),j.hide()):"years"==d&&(X(),h.hide(),i.hide());if(O.settings.onChange&&"function"==typeof O.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+"-"+db(r+1,2)+"-"+db(eb(a(this).text()),2));else if("months"==d){var b=a(this).attr("class").match(/dp\_month\_([0-9]+)/);a(this).data("date",s+"-"+db(eb(b[1])+1,2))}else a(this).data("date",eb(a(this).text()))}),O.settings.onChange.call(P,d,f,P)}K.show(),O.settings.show_clear_date===!0||0===O.settings.show_clear_date&&""!==P.val()||O.settings.always_visible&&O.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())},bb=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=U(f);P.val(h),O.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")&&O.show()),O.hide(),fb(f),O.settings.onSelect&&"function"==typeof O.settings.onSelect&&O.settings.onSelect.call(P,h,a+"-"+db(b+1,2)+"-"+db(c,2),f,P,gb(f)),P.focus()},cb=function(){for(var a="",b=0;b<arguments.length;b++)a+=arguments[b]+"";return a},db=function(a,b){for(a+="";a.length<b;)a="0"+a;return a},eb=function(a){return parseInt(a,10)},fb=function(b){O.settings.pair&&a.each(O.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)})},gb=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},hb={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"}]};hb.init(),Q()},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)})}}(jQuery);
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)})}});
@@ -8,12 +8,25 @@
8
8
  * For more resources visit {@link http://stefangabos.ro/}
9
9
  *
10
10
  * @author Stefan Gabos <contact@stefangabos.ro>
11
- * @version 1.8.9 (last revision: August 16, 2014)
12
- * @copyright (c) 2011 - 2014 Stefan Gabos
11
+ * @version 1.9.2 (last revision: April 30, 2015)
12
+ * @copyright (c) 2011 - 2015 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
  */
16
- ;(function($) {
16
+ ;(function(factory) {
17
+
18
+ 'use strict';
19
+
20
+ // AMD
21
+ if (typeof define === 'function' && define.amd) define(['jquery'], factory);
22
+
23
+ // CommonJS
24
+ else if (typeof exports === 'object') factory(require('jquery'));
25
+
26
+ // browser globals
27
+ else factory(jQuery);
28
+
29
+ }(function($) {
17
30
 
18
31
  'use strict';
19
32
 
@@ -25,6 +38,14 @@
25
38
  // element being the date picker's container;
26
39
  always_visible: false,
27
40
 
41
+ // by default, the date picker is injected into the <body>; use this property to tell the library to inject
42
+ // the date picker into a custom element - useful when you want the date picker to open at a specific position
43
+ //
44
+ // must be a jQuery element
45
+ //
46
+ // default is $('body')
47
+ container: $('body'),
48
+
28
49
  // days of the week; Sunday to Saturday
29
50
  days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
30
51
 
@@ -89,6 +110,9 @@
89
110
  // ['01 07 2012', '02 07 2012', '* 08 2012'] would disable 1st and 2nd of July 2012, and all of August of 2012
90
111
  //
91
112
  // default is FALSE, no disabled dates
113
+ //
114
+ // DISABLING ALL DATES AND NOT SPECIFYING AT LEAST ONE ENABLED DATE WILL SEND THE SCRIPT INTO AN INFINITE
115
+ // LOOP SEARCHING FOR AN ENABLED DATE TO DISPLAY!
92
116
  disabled_dates: false,
93
117
 
94
118
  // an array of enabled dates in the same format as required for "disabled_dates" property.
@@ -319,6 +343,15 @@
319
343
  // the "this" keyword inside the callback function refers to the element the date picker is attached to!
320
344
  onOpen: null,
321
345
 
346
+ // callback function to be executed when the date picker is closed, but only when the "always_visible"
347
+ // property is set to FALSE
348
+ // the callback function takes a single argument:
349
+ // - a reference to the element the date picker is attached to, as a jQuery object (deprecated - use the
350
+ // "this" keyword inside the callback function to refer to the element the date picker is attached to)
351
+ //
352
+ // the "this" keyword inside the callback function refers to the element the date picker is attached to!
353
+ onClose: null,
354
+
322
355
  // callback function to be executed when a date is selected
323
356
  // the callback function takes 5 arguments:
324
357
  // - the date in the format specified by the "format" attribute;
@@ -338,7 +371,7 @@
338
371
  current_system_day, first_selectable_month, first_selectable_year, first_selectable_day, selected_month, selected_year,
339
372
  default_day, default_month, default_year, enabled_dates, disabled_dates, shim, start_date, end_date, last_selectable_day,
340
373
  last_selectable_year, last_selectable_month, daypicker_cells, monthpicker_cells, yearpicker_cells, views, clickables,
341
- selecttoday, footer, show_select_today, timeout;
374
+ selecttoday, footer, show_select_today, timeout, uniqueid;
342
375
 
343
376
  var plugin = this;
344
377
 
@@ -355,6 +388,11 @@
355
388
  */
356
389
  var init = function(update) {
357
390
 
391
+ // generate a random ID for each date picker (we'll use this if later a certain date picker is destroyed to
392
+ // remove related events)
393
+ // the code is taken from http://stackoverflow.com/a/105074
394
+ uniqueid = Math.floor((1 + Math.random()) * 0x10000).toString(16);
395
+
358
396
  // unless we're just updating settings
359
397
  if (!update) {
360
398
 
@@ -1004,7 +1042,7 @@
1004
1042
  if (update) return;
1005
1043
 
1006
1044
  // update icon/date picker position on resize
1007
- $(window).bind('resize.Zebra_DatePicker', function() {
1045
+ $(window).bind('resize.Zebra_DatePicker_' + uniqueid, function() {
1008
1046
 
1009
1047
  // hide the date picker
1010
1048
  plugin.hide();
@@ -1067,7 +1105,7 @@
1067
1105
  if (!plugin.settings.always_visible)
1068
1106
 
1069
1107
  // inject the container into the DOM
1070
- $('body').append(datepicker);
1108
+ plugin.settings.container.append(datepicker);
1071
1109
 
1072
1110
  // otherwise, if element is not disabled
1073
1111
  else if (!$element.attr('disabled')) {
@@ -1169,7 +1207,7 @@
1169
1207
  daypicker.delegate('td:not(.dp_disabled, .dp_weekend_disabled, .dp_not_in_month, .dp_week_number)', 'click', function() {
1170
1208
 
1171
1209
  // if other months are selectable and currently clicked cell contains a class with the cell's date
1172
- if (plugin.settings.select_other_months && null !== (matches = $(this).attr('class').match(/date\_([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])/)))
1210
+ if (plugin.settings.select_other_months && $(this).attr('class') && null !== (matches = $(this).attr('class').match(/date\_([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])/)))
1173
1211
 
1174
1212
  // use the stored date
1175
1213
  select_date(matches[1], matches[2] - 1, matches[3], 'days', $(this));
@@ -1294,41 +1332,38 @@
1294
1332
  });
1295
1333
 
1296
1334
  // if date picker is not always visible
1297
- if (!plugin.settings.always_visible)
1298
-
1299
- // bind some events to the document
1300
- $(document).bind({
1301
-
1302
- //whenever anything is clicked on the page
1303
- 'mousedown.Zebra_DatePicker': function(e) {
1335
+ if (!plugin.settings.always_visible) {
1304
1336
 
1305
- // if the date picker is visible
1306
- if (datepicker.hasClass('dp_visible')) {
1337
+ //whenever anything is clicked on the page
1338
+ $(document).bind('mousedown.Zebra_DatePicker_' + uniqueid + ', touchstart.Zebra_DatePicker_' + uniqueid, function(e) {
1307
1339
 
1308
- // if the calendar icon is visible and we clicked it, let the onClick event of the icon to handle the event
1309
- // (we want it to toggle the date picker)
1310
- if (plugin.settings.show_icon && $(e.target).get(0) === icon.get(0)) return true;
1340
+ // if the date picker is visible
1341
+ if (datepicker.hasClass('dp_visible')) {
1311
1342
 
1312
- // if what's clicked is not inside the date picker
1313
- // hide the date picker
1314
- if ($(e.target).parents().filter('.Zebra_DatePicker').length === 0) plugin.hide();
1343
+ // if the calendar icon is visible and we clicked it, let the onClick event of the icon to handle the event
1344
+ // (we want it to toggle the date picker)
1345
+ if (plugin.settings.show_icon && $(e.target).get(0) === icon.get(0)) return true;
1315
1346
 
1316
- }
1347
+ // if what's clicked is not inside the date picker
1348
+ // hide the date picker
1349
+ if ($(e.target).parents().filter('.Zebra_DatePicker').length === 0) plugin.hide();
1317
1350
 
1318
- },
1351
+ }
1319
1352
 
1320
- //whenever a key is pressed on the page
1321
- 'keyup.Zebra_DatePicker': function(e) {
1353
+ });
1322
1354
 
1323
- // if the date picker is visible
1324
- // and the pressed key is ESC
1325
- // hide the date picker
1326
- if (datepicker.hasClass('dp_visible') && e.which == 27) plugin.hide();
1355
+ //whenever a key is pressed on the page
1356
+ $(document).bind('keyup.Zebra_DatePicker_' + uniqueid, function(e) {
1327
1357
 
1328
- }
1358
+ // if the date picker is visible
1359
+ // and the pressed key is ESC
1360
+ // hide the date picker
1361
+ if (datepicker.hasClass('dp_visible') && e.which == 27) plugin.hide();
1329
1362
 
1330
1363
  });
1331
1364
 
1365
+ }
1366
+
1332
1367
  // last thing is to pre-render some of the date picker right away
1333
1368
  manage_views();
1334
1369
 
@@ -1348,9 +1383,9 @@
1348
1383
  plugin.datepicker.remove();
1349
1384
 
1350
1385
  // remove associated event handlers from the document
1351
- $(document).unbind('keyup.Zebra_DatePicker');
1352
- $(document).unbind('mousedown.Zebra_DatePicker');
1353
- $(window).unbind('resize.Zebra_DatePicker');
1386
+ $(document).unbind('keyup.Zebra_DatePicker_' + uniqueid);
1387
+ $(document).unbind('mousedown.Zebra_DatePicker_' + uniqueid);
1388
+ $(window).unbind('resize.Zebra_DatePicker_' + uniqueid);
1354
1389
 
1355
1390
  // remove association with the element
1356
1391
  $element.removeData('Zebra_DatePicker');
@@ -1373,6 +1408,11 @@
1373
1408
  // hide the date picker
1374
1409
  datepicker.removeClass('dp_visible').addClass('dp_hidden');
1375
1410
 
1411
+ // if a callback function exists for when hiding the date picker
1412
+ if (plugin.settings.onClose && typeof plugin.settings.onClose == 'function')
1413
+
1414
+ // execute the callback function and pass as argument the element the plugin is attached to
1415
+ plugin.settings.onClose.call($element, $element);
1376
1416
  }
1377
1417
 
1378
1418
  };
@@ -1430,42 +1470,53 @@
1430
1470
  // if date picker is not always visible and the calendar icon is visible
1431
1471
  if (!plugin.settings.always_visible) {
1432
1472
 
1433
- var
1473
+ // if date picker is to be injected into the <body>
1474
+ if (plugin.settings.container.is('body')) {
1434
1475
 
1435
- // get the date picker width and height
1436
- datepicker_width = datepicker.outerWidth(),
1437
- datepicker_height = datepicker.outerHeight(),
1476
+ var
1438
1477
 
1439
- // compute the date picker's default left and top
1440
- // this will be computed relative to the icon's top-right corner (if the calendar icon exists), or
1441
- // relative to the element's top-right corner otherwise, to which the offsets given at initialization
1442
- // are added/subtracted
1443
- left = (undefined !== icon ? icon.offset().left + icon.outerWidth(true) : $element.offset().left + $element.outerWidth(true)) + plugin.settings.offset[0],
1444
- top = (undefined !== icon ? icon.offset().top : $element.offset().top) - datepicker_height + plugin.settings.offset[1],
1478
+ // get the date picker width and height
1479
+ datepicker_width = datepicker.outerWidth(),
1480
+ datepicker_height = datepicker.outerHeight(),
1445
1481
 
1446
- // get browser window's width and height
1447
- window_width = $(window).width(),
1448
- window_height = $(window).height(),
1482
+ // compute the date picker's default left and top
1483
+ // this will be computed relative to the icon's top-right corner (if the calendar icon exists), or
1484
+ // relative to the element's top-right corner otherwise, to which the offsets given at initialization
1485
+ // are added/subtracted
1486
+ left = (undefined !== icon ? icon.offset().left + icon.outerWidth(true) : $element.offset().left + $element.outerWidth(true)) + plugin.settings.offset[0],
1487
+ top = (undefined !== icon ? icon.offset().top : $element.offset().top) - datepicker_height + plugin.settings.offset[1],
1449
1488
 
1450
- // get browser window's horizontal and vertical scroll offsets
1451
- window_scroll_top = $(window).scrollTop(),
1452
- window_scroll_left = $(window).scrollLeft();
1489
+ // get browser window's width and height
1490
+ window_width = $(window).width(),
1491
+ window_height = $(window).height(),
1453
1492
 
1454
- if (plugin.settings.default_position == 'below')
1455
- top = (undefined !== icon ? icon.offset().top : $element.offset().top) + plugin.settings.offset[1];
1493
+ // get browser window's horizontal and vertical scroll offsets
1494
+ window_scroll_top = $(window).scrollTop(),
1495
+ window_scroll_left = $(window).scrollLeft();
1456
1496
 
1457
- // if date picker is outside the viewport, adjust its position so that it is visible
1458
- if (left + datepicker_width > window_scroll_left + window_width) left = window_scroll_left + window_width - datepicker_width;
1459
- if (left < window_scroll_left) left = window_scroll_left;
1497
+ if (plugin.settings.default_position == 'below')
1498
+ top = (undefined !== icon ? icon.offset().top : $element.offset().top) + plugin.settings.offset[1];
1460
1499
 
1461
- if (top + datepicker_height > window_scroll_top + window_height) top = window_scroll_top + window_height - datepicker_height;
1462
- if (top < window_scroll_top) top = window_scroll_top;
1500
+ // if date picker is outside the viewport, adjust its position so that it is visible
1501
+ if (left + datepicker_width > window_scroll_left + window_width) left = window_scroll_left + window_width - datepicker_width;
1502
+ if (left < window_scroll_left) left = window_scroll_left;
1463
1503
 
1464
- // make the date picker visible
1465
- datepicker.css({
1466
- 'left': left,
1467
- 'top': top
1468
- });
1504
+ if (top + datepicker_height > window_scroll_top + window_height) top = window_scroll_top + window_height - datepicker_height;
1505
+ if (top < window_scroll_top) top = window_scroll_top;
1506
+
1507
+ // make the date picker visible
1508
+ datepicker.css({
1509
+ 'left': left,
1510
+ 'top': top
1511
+ });
1512
+
1513
+ // if date picker is to be injected into a custom container element
1514
+ } else
1515
+
1516
+ datepicker.css({
1517
+ 'left': 0,
1518
+ 'top': 0
1519
+ });
1469
1520
 
1470
1521
  // fade-in the date picker
1471
1522
  // for Internet Explorer < 9 show the date picker instantly or fading alters the font's weight
@@ -1995,8 +2046,8 @@
1995
2046
 
1996
2047
  }
1997
2048
 
1998
- // print the day of the month
1999
- html += '<td' + (class_name !== '' ? ' class="' + $.trim(class_name) + '"' : '') + '>' + (plugin.settings.zero_pad ? str_pad(day, 2) : day) + '</td>';
2049
+ // 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>';
2000
2051
 
2001
2052
  }
2002
2053
 
@@ -2728,7 +2779,7 @@
2728
2779
  // execute the callback function
2729
2780
  // make "this" inside the callback function refer to the element the date picker is attached to
2730
2781
  plugin.settings.onSelect.call($element, selected_value, year + '-' + str_pad(month + 1, 2) + '-' + str_pad(day, 2), default_date, $element, getWeekNumber(default_date));
2731
-
2782
+
2732
2783
  // move focus to the element the plugin is attached to
2733
2784
  $element.focus();
2734
2785
 
@@ -2962,4 +3013,4 @@
2962
3013
 
2963
3014
  };
2964
3015
 
2965
- })(jQuery);
3016
+ }));
@@ -13,7 +13,7 @@
13
13
  .Zebra_DatePicker *:after,
14
14
  .Zebra_DatePicker *:before { -moz-box-sizing: content-box !important; -webkit-box-sizing: content-box !important; box-sizing: content-box !important }
15
15
 
16
- .Zebra_DatePicker { position: absolute; background: #FFF; border: 1px solid #999; z-index: 100; padding: 5px }
16
+ .Zebra_DatePicker { position: absolute; background: #FFF; border: 1px solid #999; z-index: 1200; padding: 5px; top: 0 }
17
17
 
18
18
  .Zebra_DatePicker * { margin: 0; padding: 0; color: #373737; background: transparent; border: none }
19
19
 
@@ -13,7 +13,7 @@
13
13
  .Zebra_DatePicker *:after,
14
14
  .Zebra_DatePicker *:before { -moz-box-sizing: content-box !important; -webkit-box-sizing: content-box !important; box-sizing: content-box !important }
15
15
 
16
- .Zebra_DatePicker { position: absolute; background: #666; border: 3px solid #666; z-index: 100; font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 13px; }
16
+ .Zebra_DatePicker { position: absolute; background: #666; border: 3px solid #666; z-index: 1200; font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 13px; top: 0 }
17
17
 
18
18
  .Zebra_DatePicker * { margin: 0; padding: 0; color: #000; background: transparent; border: none }
19
19
 
@@ -13,7 +13,7 @@
13
13
  .Zebra_DatePicker *:after,
14
14
  .Zebra_DatePicker *:before { -moz-box-sizing: content-box !important; -webkit-box-sizing: content-box !important; box-sizing: content-box !important }
15
15
 
16
- .Zebra_DatePicker { position: absolute; background: #373737; border: 3px solid #373737; z-index: 100; font-family: Geneva, 'Lucida Sans', 'Lucida Grande', 'Lucida Sans Unicode', Verdana, sans-serif; font-size: 13px }
16
+ .Zebra_DatePicker { position: absolute; background: #373737; border: 3px solid #373737; z-index: 1200; font-family: Geneva, 'Lucida Sans', 'Lucida Grande', 'Lucida Sans Unicode', Verdana, sans-serif; font-size: 13px; top: 0 }
17
17
 
18
18
  .Zebra_DatePicker * { margin: 0; padding: 0; color: #666; background: transparent; border: none }
19
19
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zebra-datepicker-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.10
4
+ version: 1.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcus Derencius
@@ -74,6 +74,7 @@ extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
76
  - ".gitignore"
77
+ - ".gitmodules"
77
78
  - Gemfile
78
79
  - LICENSE.txt
79
80
  - README.md