demo20230512/Scripts/kendo/2014.2.716/kendo.calendar.min.js
2023-05-12 10:20:28 +08:00

16 lines
17 KiB
JavaScript

/**
* Copyright 2014 Telerik AD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
!function(e,define){define(["./kendo.core.min"],e)}(function(){return function(e,t){function n(e,t,n,i){var r,o=e.getFullYear(),a=t.getFullYear(),s=n.getFullYear();return o-=o%i,r=o+(i-1),a>o&&(o=a),r>s&&(r=s),o+"-"+r}function i(e){for(var t,n=0,i=e.min,r=e.max,o=e.start,a=e.setter,l=e.build,u=e.cells||12,c=e.perRow||4,d=e.content||z,f=e.empty||O,h=e.html||'<table tabindex="0" role="grid" class="k-content k-meta-view" cellspacing="0"><tbody><tr role="row">';u>n;n++)n>0&&n%c===0&&(h+='</tr><tr role="row">'),t=l(o,n),h+=s(o,i,r)?d(t):f(t),a(o,1);return h+"</tr></tbody></table>"}function r(e,t,n){var i=e.getFullYear(),r=t.getFullYear(),o=r,a=0;return n&&(r-=r%n,o=r-r%n+n-1),i>o?a=1:r>i&&(a=-1),a}function o(){var e=new pt;return new pt(e.getFullYear(),e.getMonth(),e.getDate())}function a(e,t,n){var i=o();return e&&(i=new pt(+e)),t>i?i=new pt(+t):i>n&&(i=new pt(+n)),i}function s(e,t,n){return+e>=+t&&+n>=+e}function l(e,t){return e.slice(t).concat(e.slice(0,t))}function u(e,t,n){t=t instanceof pt?t.getFullYear():e.getFullYear()+n*t,e.setFullYear(t)}function c(t){e(this).toggleClass($,it.indexOf(t.type)>-1||t.type==tt)}function d(e){e.preventDefault()}function f(e){return D(e).calendars.standard}function h(e){var n=gt[e.start],i=gt[e.depth],r=D(e.culture);e.format=S(e.format||r.calendars.standard.patterns.d),isNaN(n)&&(n=0,e.start=W),(i===t||i>n)&&(e.depth=W),e.dates||(e.dates=[])}function p(e){A&&e.find("*").attr("unselectable","on")}function g(e,t){for(var n=0,i=t.length;i>n;n++)if(e===+t[n])return!0;return!1}function m(e,t){return e?e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate():!1}function v(e,t){return e?e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth():!1}var _,y=window.kendo,b=y.support,w=y.ui,x=w.Widget,k=y.keys,T=y.parseDate,C=y.date.adjustDST,S=y._extractFormat,F=y.template,D=y.getCulture,M=y.support.transitions,E=M?M.css+"transform-origin":"",z=F('<td#=data.cssClass# role="gridcell"><a tabindex="-1" class="k-link" href="\\#" data-#=data.ns#value="#=data.dateString#">#=data.value#</a></td>',{useWithBlock:!1}),O=F('<td role="gridcell">&nbsp;</td>',{useWithBlock:!1}),P=y.support.browser,A=P.msie&&9>P.version,H=".kendoCalendar",N="click"+H,I="keydown"+H,R="id",B="min",L="left",q="slideIn",W="month",j="century",U="change",V="navigate",Y="value",$="k-state-hover",G="k-state-disabled",Q="k-state-focused",J="k-other-month",K=' class="'+J+'"',X="k-nav-today",Z="td:has(.k-link)",et="blur"+H,tt="focus",nt=tt+H,it=b.touch?"touchstart":"mouseenter",rt=b.touch?"touchstart"+H:"mouseenter"+H,ot=b.touch?"touchend"+H+" touchmove"+H:"mouseleave"+H,at=6e4,st=864e5,lt="_prevArrow",ut="_nextArrow",ct="aria-disabled",dt="aria-selected",ft=e.proxy,ht=e.extend,pt=Date,gt={month:0,year:1,decade:2,century:3},mt=x.extend({init:function(t,n){var i,r,o=this;x.fn.init.call(o,t,n),t=o.wrapper=o.element,n=o.options,n.url=window.unescape(n.url),o._templates(),o._header(),o._footer(o.footer),r=t.addClass("k-widget k-calendar").on(rt+" "+ot,Z,c).on(I,"table.k-content",ft(o._move,o)).on(N,Z,function(t){var n=t.currentTarget.firstChild;-1!=n.href.indexOf("#")&&t.preventDefault(),o._click(e(n))}).on("mouseup"+H,"table.k-content, .k-footer",function(){o._focusView(o.options.focusOnNav!==!1)}).attr(R),r&&(o._cellID=r+"_cell_selected"),h(n),i=T(n.value,n.format,n.culture),o._index=gt[n.start],o._current=new pt(+a(i,n.min,n.max)),o._addClassProxy=function(){o._active=!0,o._cell.addClass(Q)},o._removeClassProxy=function(){o._active=!1,o._cell.removeClass(Q)},o.value(i),y.notify(o)},options:{name:"Calendar",value:null,min:new pt(1900,0,1),max:new pt(2099,11,31),dates:[],url:"",culture:"",footer:"",format:"",month:{},start:W,depth:W,animation:{horizontal:{effects:q,reverse:!0,duration:500,divisor:2},vertical:{effects:"zoomIn",duration:400}}},events:[U,V],setOptions:function(e){var t=this;h(e),e.dates[0]||(e.dates=t.options.dates),x.fn.setOptions.call(t,e),t._templates(),t._footer(t.footer),t._index=gt[t.options.start],t.navigate()},destroy:function(){var e=this,t=e._today;e.element.off(H),e._title.off(H),e[lt].off(H),e[ut].off(H),y.destroy(e._table),t&&y.destroy(t.off(H)),x.fn.destroy.call(e)},current:function(){return this._current},view:function(){return this._view},focus:function(e){e=e||this._table,this._bindTable(e),e.focus()},min:function(e){return this._option(B,e)},max:function(e){return this._option("max",e)},navigateToPast:function(){this._navigate(lt,-1)},navigateToFuture:function(){this._navigate(ut,1)},navigateUp:function(){var e=this,t=e._index;e._title.hasClass(G)||e.navigate(e._current,++t)},navigateDown:function(e){var n=this,i=n._index,r=n.options.depth;if(e)return i===gt[r]?(+n._value!=+e&&(n.value(e),n.trigger(U)),t):(n.navigate(e,--i),t)},navigate:function(n,i){i=isNaN(i)?gt[i]:i;var r,o,s,l,u=this,c=u.options,d=c.culture,f=c.min,h=c.max,g=u._title,m=u._table,v=u._oldTable,y=u._value,b=u._current,w=n&&+n>+b,x=i!==t&&i!==u._index;n||(n=b),u._current=n=new pt(+a(n,f,h)),i===t?i=u._index:u._index=i,u._view=o=_.views[i],s=o.compare,l=i===gt[j],g.toggleClass(G,l).attr(ct,l),l=s(n,f)<1,u[lt].toggleClass(G,l).attr(ct,l),l=s(n,h)>-1,u[ut].toggleClass(G,l).attr(ct,l),m&&v&&v.data("animating")&&(v.kendoStop(!0,!0),m.kendoStop(!0,!0)),u._oldTable=m,(!m||u._changeView)&&(g.html(o.title(n,f,h,d)),u._table=r=e(o.content(ht({min:f,max:h,date:n,url:c.url,dates:c.dates,format:c.format,culture:d},u[o.name]))),p(r),u._animate({from:m,to:r,vertical:x,future:w}),u._focus(n),u.trigger(V)),i===gt[c.depth]&&y&&u._class("k-state-selected",o.toDateString(y)),u._class(Q,o.toDateString(n)),!m&&u._cell&&u._cell.removeClass(Q),u._changeView=!0},value:function(e){var n=this,i=n._view,r=n.options,o=n._view,a=r.min,l=r.max;return e===t?n._value:(e=T(e,r.format,r.culture),null!==e&&(e=new pt(+e),s(e,a,l)||(e=null)),n._value=e,o&&null===e&&n._cell?n._cell.removeClass("k-state-selected"):(n._changeView=!e||i&&0!==i.compare(e,n._current),n.navigate(e)),t)},_move:function(t){var n,i,r,o,s=this,l=s.options,u=t.keyCode,c=s._view,d=s._index,f=new pt(+s._current),h=y.support.isRtl(s.wrapper);return t.target===s._table[0]&&(s._active=!0),t.ctrlKey?u==k.RIGHT&&!h||u==k.LEFT&&h?(s.navigateToFuture(),i=!0):u==k.LEFT&&!h||u==k.RIGHT&&h?(s.navigateToPast(),i=!0):u==k.UP?(s.navigateUp(),i=!0):u==k.DOWN&&(s._click(e(s._cell[0].firstChild)),i=!0):(u==k.RIGHT&&!h||u==k.LEFT&&h?(n=1,i=!0):u==k.LEFT&&!h||u==k.RIGHT&&h?(n=-1,i=!0):u==k.UP?(n=0===d?-7:-4,i=!0):u==k.DOWN?(n=0===d?7:4,i=!0):u==k.ENTER?(s._click(e(s._cell[0].firstChild)),i=!0):u==k.HOME||u==k.END?(r=u==k.HOME?"first":"last",o=c[r](f),f=new pt(o.getFullYear(),o.getMonth(),o.getDate(),f.getHours(),f.getMinutes(),f.getSeconds(),f.getMilliseconds()),i=!0):u==k.PAGEUP?(i=!0,s.navigateToPast()):u==k.PAGEDOWN&&(i=!0,s.navigateToFuture()),(n||r)&&(r||c.setDate(f,n),s._focus(a(f,l.min,l.max)))),i&&t.preventDefault(),s._current},_animate:function(e){var t=this,n=e.from,i=e.to,r=t._active;n?n.parent().data("animating")?(n.parent().kendoStop(!0,!0).remove(),n.remove(),i.insertAfter(t.element[0].firstChild),t._focusView(r)):n.is(":visible")&&t.options.animation!==!1?t[e.vertical?"_vertical":"_horizontal"](n,i,e.future):(i.insertAfter(n),n.remove(),t._focusView(r)):(i.insertAfter(t.element[0].firstChild),t._bindTable(i))},_horizontal:function(e,n,i){var r=this,o=r._active,a=r.options.animation.horizontal,s=a.effects,l=e.outerWidth();s&&-1!=s.indexOf(q)&&(e.add(n).css({width:l}),e.wrap("<div/>"),r._focusView(o,e),e.parent().css({position:"relative",width:2*l,"float":L,"margin-left":i?0:-l}),n[i?"insertAfter":"insertBefore"](e),ht(a,{effects:q+":"+(i?"right":L),complete:function(){e.remove(),n.unwrap(),r._focusView(o),r._oldTable=t}}),e.parent().kendoStop(!0,!0).kendoAnimate(a))},_vertical:function(e,n){var i,r,o=this,a=o.options.animation.vertical,s=a.effects,l=o._active;s&&-1!=s.indexOf("zoom")&&(n.css({position:"absolute",top:e.prev().outerHeight(),left:0}).insertBefore(e),E&&(i=o._cellByDate(o._view.toDateString(o._current)),r=i.position(),r=r.left+parseInt(i.width()/2,10)+"px "+(r.top+parseInt(i.height()/2,10)+"px"),n.css(E,r)),e.kendoStop(!0,!0).kendoAnimate({effects:"fadeOut",duration:600,complete:function(){e.remove(),n.css({position:"static",top:0,left:0}),o._focusView(l),o._oldTable=t}}),n.kendoStop(!0,!0).kendoAnimate(a))},_cellByDate:function(t){return this._table.find("td:not(."+J+")").filter(function(){return e(this.firstChild).attr(y.attr(Y))===t})},_class:function(t,n){var i=this,r=i._cellID,o=i._cell;o&&o.removeAttr(dt).removeAttr("aria-label").removeAttr(R),o=i._table.find("td:not(."+J+")").removeClass(t).filter(function(){return e(this.firstChild).attr(y.attr(Y))===n}).attr(dt,!0),t!==Q||i._active||i.options.focusOnNav===!1||(t=""),o.addClass(t),o[0]&&(i._cell=o),r&&(o.attr(R,r),i._table.removeAttr("aria-activedescendant").attr("aria-activedescendant",r))},_bindTable:function(e){e.on(nt,this._addClassProxy).on(et,this._removeClassProxy)},_click:function(e){var t=this,n=t.options,i=new Date(+t._current),r=e.attr(y.attr(Y)).split("/");r=new pt(r[0],r[1],r[2]),C(r,0),t._view.setDate(i,r),t.navigateDown(a(i,n.min,n.max))},_focus:function(e){var t=this,n=t._view;0!==n.compare(e,t._current)?t.navigate(e):(t._current=e,t._class(Q,n.toDateString(e)))},_focusView:function(e,t){e&&this.focus(t)},_footer:function(n){var i=this,r=o(),a=i.element,s=a.find(".k-footer");return n?(s[0]||(s=e('<div class="k-footer"><a href="#" class="k-link k-nav-today"></a></div>').appendTo(a)),i._today=s.show().find(".k-link").html(n(r)).attr("title",y.toString(r,"D",i.options.culture)),i._toggle(),t):(i._toggle(!1),s.hide(),t)},_header:function(){var e,t=this,n=t.element;n.find(".k-header")[0]||n.html('<div class="k-header"><a href="#" role="button" class="k-link k-nav-prev"><span class="k-icon k-i-arrow-w"></span></a><a href="#" role="button" aria-live="assertive" aria-atomic="true" class="k-link k-nav-fast"></a><a href="#" role="button" class="k-link k-nav-next"><span class="k-icon k-i-arrow-e"></span></a></div>'),e=n.find(".k-link").on(rt+" "+ot+" "+nt+" "+et,c).click(!1),t._title=e.eq(1).on(N,function(){t._active=t.options.focusOnNav!==!1,t.navigateUp()}),t[lt]=e.eq(0).on(N,function(){t._active=t.options.focusOnNav!==!1,t.navigateToPast()}),t[ut]=e.eq(2).on(N,function(){t._active=t.options.focusOnNav!==!1,t.navigateToFuture()})},_navigate:function(e,t){var n=this,i=n._index+1,r=new pt(+n._current);e=n[e],e.hasClass(G)||(i>3?r.setFullYear(r.getFullYear()+100*t):_.views[i].setDate(r,t),n.navigate(r))},_option:function(e,n){var i,r=this,o=r.options,a=r._value||r._current;return n===t?o[e]:(n=T(n,o.format,o.culture),n&&(o[e]=new pt(+n),i=e===B?n>a:a>n,(i||v(a,n))&&(i&&(r._value=null),r._changeView=!0),r._changeView||(r._changeView=!(!o.month.content&&!o.month.empty)),r.navigate(r._value),r._toggle()),t)},_toggle:function(e){var n=this,i=n.options,r=n._today;e===t&&(e=s(o(),i.min,i.max)),r&&(r.off(N),e?r.addClass(X).removeClass(G).on(N,ft(n._todayClick,n)):r.removeClass(X).addClass(G).on(N,d))},_todayClick:function(e){var t=this,n=gt[t.options.depth],i=o();e.preventDefault(),0===t._view.compare(t._current,i)&&t._index==n&&(t._changeView=!1),t._value=i,t.navigate(i,n),t.trigger(U)},_templates:function(){var e=this,t=e.options,n=t.footer,i=t.month,r=i.content,o=i.empty;e.month={content:F('<td#=data.cssClass# role="gridcell"><a tabindex="-1" class="k-link#=data.linkClass#" href="#=data.url#" '+y.attr("value")+'="#=data.dateString#" title="#=data.title#">'+(r||"#=data.value#")+"</a></td>",{useWithBlock:!!r}),empty:F('<td role="gridcell">'+(o||"&nbsp;")+"</td>",{useWithBlock:!!o})},e.footer=n!==!1?F(n||'#= kendo.toString(data,"D","'+t.culture+'") #',{useWithBlock:!1}):null}});w.plugin(mt),_={firstDayOfMonth:function(e){return new pt(e.getFullYear(),e.getMonth(),1)},firstVisibleDay:function(e,t){t=t||y.culture().calendar;for(var n=t.firstDay,i=new pt(e.getFullYear(),e.getMonth(),0,e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds());i.getDay()!=n;)_.setTime(i,-1*st);return i},setTime:function(e,t){var n=e.getTimezoneOffset(),i=new pt(e.getTime()+t),r=i.getTimezoneOffset()-n;e.setTime(i.getTime()+r*at)},views:[{name:W,title:function(e,t,n,i){return f(i).months.names[e.getMonth()]+" "+e.getFullYear()},content:function(e){for(var t=this,n=0,r=e.min,o=e.max,a=e.date,s=e.dates,u=e.format,c=e.culture,d=e.url,h=d&&s[0],p=f(c),m=p.firstDay,v=p.days,b=l(v.names,m),w=l(v.namesShort,m),x=_.firstVisibleDay(a,p),k=t.first(a),T=t.last(a),S=t.toDateString,F=new pt,D='<table tabindex="0" role="grid" class="k-content" cellspacing="0"><thead><tr role="row">';7>n;n++)D+='<th scope="col" title="'+b[n]+'">'+w[n]+"</th>";return F=new pt(F.getFullYear(),F.getMonth(),F.getDate()),C(F,0),F=+F,i({cells:42,perRow:7,html:D+='</tr></thead><tbody><tr role="row">',start:new pt(x.getFullYear(),x.getMonth(),x.getDate()),min:new pt(r.getFullYear(),r.getMonth(),r.getDate()),max:new pt(o.getFullYear(),o.getMonth(),o.getDate()),content:e.content,empty:e.empty,setter:t.setDate,build:function(e){var t=[],n=e.getDay(),i="",r="#";return(k>e||e>T)&&t.push(J),+e===F&&t.push("k-today"),(0===n||6===n)&&t.push("k-weekend"),h&&g(+e,s)&&(r=d.replace("{0}",y.toString(e,u,c)),i=" k-action-link"),{date:e,dates:s,ns:y.ns,title:y.toString(e,"D",c),value:e.getDate(),dateString:S(e),cssClass:t[0]?' class="'+t.join(" ")+'"':"",linkClass:i,url:r}}})},first:function(e){return _.firstDayOfMonth(e)},last:function(e){var t=new pt(e.getFullYear(),e.getMonth()+1,0),n=_.firstDayOfMonth(e),i=Math.abs(t.getTimezoneOffset()-n.getTimezoneOffset());return i&&t.setHours(n.getHours()+i/60),t},compare:function(e,t){var n,i=e.getMonth(),r=e.getFullYear(),o=t.getMonth(),a=t.getFullYear();return n=r>a?1:a>r?-1:i==o?0:i>o?1:-1},setDate:function(e,t){var n=e.getHours();t instanceof pt?e.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()):_.setTime(e,t*st),C(e,n)},toDateString:function(e){return e.getFullYear()+"/"+e.getMonth()+"/"+e.getDate()}},{name:"year",title:function(e){return e.getFullYear()},content:function(e){var t=f(e.culture).months.namesAbbr,n=this.toDateString,r=e.min,o=e.max;return i({min:new pt(r.getFullYear(),r.getMonth(),1),max:new pt(o.getFullYear(),o.getMonth(),1),start:new pt(e.date.getFullYear(),0,1),setter:this.setDate,build:function(e){return{value:t[e.getMonth()],ns:y.ns,dateString:n(e),cssClass:""}}})},first:function(e){return new pt(e.getFullYear(),0,e.getDate())},last:function(e){return new pt(e.getFullYear(),11,e.getDate())},compare:function(e,t){return r(e,t)},setDate:function(e,t){var n,i=e.getHours();t instanceof pt?(n=t.getMonth(),e.setFullYear(t.getFullYear(),n,e.getDate()),n!==e.getMonth()&&e.setDate(0)):(n=e.getMonth()+t,e.setMonth(n),n>11&&(n-=12),n>0&&e.getMonth()!=n&&e.setDate(0)),C(e,i)},toDateString:function(e){return e.getFullYear()+"/"+e.getMonth()+"/1"}},{name:"decade",title:function(e,t,i){return n(e,t,i,10)},content:function(e){var t=e.date.getFullYear(),n=this.toDateString;return i({start:new pt(t-t%10-1,0,1),min:new pt(e.min.getFullYear(),0,1),max:new pt(e.max.getFullYear(),0,1),setter:this.setDate,build:function(e,t){return{value:e.getFullYear(),ns:y.ns,dateString:n(e),cssClass:0===t||11==t?K:""}}})},first:function(e){var t=e.getFullYear();return new pt(t-t%10,e.getMonth(),e.getDate())},last:function(e){var t=e.getFullYear();return new pt(t-t%10+9,e.getMonth(),e.getDate())},compare:function(e,t){return r(e,t,10)},setDate:function(e,t){u(e,t,1)},toDateString:function(e){return e.getFullYear()+"/0/1"}},{name:j,title:function(e,t,i){return n(e,t,i,100)},content:function(e){var t=e.date.getFullYear(),n=e.min.getFullYear(),r=e.max.getFullYear(),o=this.toDateString,a=n,s=r;return a-=a%10,s-=s%10,10>s-a&&(s=a+9),i({start:new pt(t-t%100-10,0,1),min:new pt(a,0,1),max:new pt(s,0,1),setter:this.setDate,build:function(e,t){var i=e.getFullYear(),a=i+9;return n>i&&(i=n),a>r&&(a=r),{ns:y.ns,value:i+" - "+a,dateString:o(e),cssClass:0===t||11==t?K:""}}})},first:function(e){var t=e.getFullYear();return new pt(t-t%100,e.getMonth(),e.getDate())},last:function(e){var t=e.getFullYear();return new pt(t-t%100+99,e.getMonth(),e.getDate())},compare:function(e,t){return r(e,t,100)},setDate:function(e,t){u(e,t,10)},toDateString:function(e){var t=e.getFullYear();return t-t%10+"/0/1"}}]},_.isEqualDatePart=m,_.makeUnselectable=p,_.restrictValue=a,_.isInRange=s,_.normalize=h,_.viewsEnum=gt,y.calendar=_}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t){t()});