Files
easystream-main/f_scripts/shared/datepicker/tiny-date-picker.min.js
SamiAhmed7777 0b7e2d0a5b feat: Add comprehensive documentation suite and reorganize project structure
- Created complete documentation in docs/ directory
- Added PROJECT_OVERVIEW.md with feature highlights and getting started guide
- Added ARCHITECTURE.md with system design and technical details
- Added SECURITY.md with comprehensive security implementation guide
- Added DEVELOPMENT.md with development workflows and best practices
- Added DEPLOYMENT.md with production deployment instructions
- Added API.md with complete REST API documentation
- Added CONTRIBUTING.md with contribution guidelines
- Added CHANGELOG.md with version history and migration notes
- Reorganized all documentation files into docs/ directory for better organization
- Updated README.md with proper documentation links and quick navigation
- Enhanced project structure with professional documentation standards
2025-10-21 00:39:45 -07:00

2 lines
9.8 KiB
JavaScript

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.TinyDatePicker=t()}(this,function(){"use strict";function e(){var e=new Date;return e.setHours(0,0,0,0),e}function t(e,t){return(e&&e.toDateString())===(t&&t.toDateString())}function n(e,t){return e=new Date(e),e.setDate(e.getDate()+t),e}function a(e,t,n){e=new Date(e);var a=e.getDate(),r=e.getMonth()+t;return e.setDate(1),e.setMonth(n?(12+r)%12:r),e.setDate(a),e.getDate()<a&&e.setDate(0),e}function r(e,t){return e=new Date(e),e.setFullYear(e.getFullYear()+t),e}function o(e,t){return e=new Date(e),e.setFullYear(t),e}function i(e,t){return a(e,t-e.getMonth())}function u(e){return function(t){return"string"==typeof t?e(t):t}}function c(e,t,n){return e<t?t:e>n?n:e}function s(t){t=t||{},t=f(d(),t);var n=u(t.parse);return t.lang=f(U,t.lang),t.parse=n,t.inRange=l(t),t.min=n(t.min||r(e(),-100)),t.max=n(t.max||r(e(),100)),t.hilightedDate=t.parse(t.hilightedDate),t}function d(){return{lang:U,mode:"dp-modal",hilightedDate:e(),format:function(e){return e.getMonth()+1+"/"+e.getDate()+"/"+e.getFullYear()},parse:function(t){var n=new Date(t);return isNaN(n)?e():n},dateClass:function(){},inRange:function(){return!0}}}function l(e){var t=e.inRange;return function(n,a){return t(n,a)&&e.min<=n&&e.max>=n}}function f(e,t){t=t||{};for(var n in t)e[n]=t[n];return e}function p(e,t,n){return t.addEventListener(e,n,!0),function(){t.removeEventListener(e,n,!0)}}function h(n){var a=n.opts,r=a.lang,o=n.state,i=r.days,u=a.dayOffset||0,c=o.selectedDate,s=o.hilightedDate,d=s.getMonth(),l=e().getTime();return'<div class="dp-cal"><header class="dp-cal-header"><a tabindex="-1" href="javascript:;" class="dp-prev">Prev</a><a tabindex="-1" href="javascript:;" class="dp-cal-month">'+r.months[d]+'</a><a tabindex="-1" href="javascript:;" class="dp-cal-year">'+s.getFullYear()+'</a><a tabindex="-1" href="javascript:;" class="dp-next">Next</a></header><div class="dp-days">'+i.map(function(e,t){return'<span class="dp-col-header">'+i[(t+u)%i.length]+"</span>"}).join("")+x(s,u,function(e){var r=e.getMonth()!==d,o=!a.inRange(e),i=e.getTime()===l,u="dp-day";return u+=r?" dp-edge-day":"",u+=t(e,s)?" dp-current":"",u+=t(e,c)?" dp-selected":"",u+=o?" dp-day-disabled":"",u+=i?" dp-day-today":"",'<a tabindex="-1" href="javascript:;" class="'+(u+=" "+a.dateClass(e,n))+'" data-date="'+e.getTime()+'">'+e.getDate()+"</a>"})+'</div><footer class="dp-cal-footer"><a tabindex="-1" href="javascript:;" class="dp-today">'+r.today+'</a><a tabindex="-1" href="javascript:;" class="dp-clear">'+r.clear+'</a><a tabindex="-1" href="javascript:;" class="dp-close">'+r.close+"</a></footer></div>"}function v(e,t){var a=e.keyCode,r=a===X.left?-1:a===X.right?1:a===X.up?-7:a===X.down?7:0;a===X.esc?t.close():r&&(e.preventDefault(),t.setState({hilightedDate:n(t.state.hilightedDate,r)}))}function g(t,n){n.setState({selectedDate:e()})}function m(e,t){t.setState({selectedDate:null})}function D(e,t){t.close()}function y(e,t){t.setState({view:"month"})}function b(e,t){t.setState({view:"year"})}function w(e,t){var n=t.state.hilightedDate;t.setState({hilightedDate:a(n,1)})}function S(e,t){var n=t.state.hilightedDate;t.setState({hilightedDate:a(n,-1)})}function j(e,t){t.setState({selectedDate:new Date(parseInt(e.target.getAttribute("data-date")))})}function x(e,t,n){var a="",r=new Date(e);r.setDate(1),r.setDate(1-r.getDay()+t),t&&r.getDate()===t+1&&r.setDate(t-6);for(var o=0;o<42;++o)a+=n(r),r.setDate(r.getDate()+1);return a}function F(e,t){t.setState({hilightedDate:i(t.state.hilightedDate,parseInt(e.target.getAttribute("data-month"))),view:"day"})}function C(e){var t=e.opts,n=t.lang,a=n.months,r=e.state.hilightedDate,o=r.getMonth();return'<div class="dp-months">'+a.map(function(e,t){var n="dp-month";return'<a tabindex="-1" href="javascript:;" class="'+(n+=o===t?" dp-current":"")+'" data-month="'+t+'">'+e+"</a>"}).join("")+"</div>"}function T(e,t){var n=e.keyCode,r=n===X.left?-1:n===X.right?1:n===X.up?-3:n===X.down?3:0;n===X.esc?t.setState({view:"day"}):r&&(e.preventDefault(),t.setState({hilightedDate:a(t.state.hilightedDate,r,!0)}))}function E(e){var t=e.state,n=t.hilightedDate.getFullYear(),a=t.selectedDate.getFullYear();return'<div class="dp-years">'+k(e,function(e){var t="dp-year";return t+=e===n?" dp-current":"",'<a tabindex="-1" href="javascript:;" class="'+(t+=e===a?" dp-selected":"")+'" data-year="'+e+'">'+e+"</a>"})+"</div>"}function M(e,t){t.setState({hilightedDate:o(t.state.hilightedDate,parseInt(e.target.getAttribute("data-year"))),view:"day"})}function O(e,t){var n=e.keyCode,a=t.opts,o=n===X.left||n===X.up?1:n===X.right||n===X.down?-1:0;if(n===X.esc)t.setState({view:"day"});else if(o){e.preventDefault();var i=r(t.state.hilightedDate,o);t.setState({hilightedDate:c(i,a.min,a.max)})}}function k(e,t){for(var n="",a=e.opts.max.getFullYear(),r=a;r>=e.opts.min.getFullYear();--r)n+=t(r);return n}function N(e,t){var n=void 0;return function(){clearTimeout(n),n=setTimeout(t,e)}}function H(){}function R(e,t,n){var a,r,o=!1,i={el:void 0,opts:n,shouldFocusOnBlur:!0,shouldFocusOnRender:!0,state:function(){return{get selectedDate(){return r},set selectedDate(e){e&&!n.inRange(e)||(e?(r=new Date(e),i.state.hilightedDate=r):r=e,i.updateInput(r),t("select"),i.close())},view:"day"}}(),adjustPosition:H,containerHTML:'<div class="dp"></div>',attachToDom:function(){document.body.appendChild(i.el)},updateInput:function(t){var a=new Z("change",{bubbles:!0});a.simulated=!0,e.value=t?n.format(t):"",e.dispatchEvent(a)},computeSelectedDate:function(){return n.parse(e.value)},currentView:function(){return te[i.state.view]},open:function(){o||(i.el||(i.el=P(n,i.containerHTML),V(i)),r=c(i.computeSelectedDate(),n.min,n.max),i.state.hilightedDate=r||n.hilightedDate,i.state.view="day",i.attachToDom(),i.render(),t("open"))},isVisible:function(){return!!i.el&&!!i.el.parentNode},hasFocus:function(){return i.el&&i.el.contains(document.activeElement)},shouldHide:function(){return i.isVisible()},close:function(n){var a=i.el;if(i.isVisible()){if(a){var r=a.parentNode;r&&r.removeChild(a)}o=!0,n&&i.shouldFocusOnBlur&&A(e),setTimeout(function(){o=!1},100),t("close")}},destroy:function(){i.close(),a()},render:function(){if(i.el){var e=i.hasFocus(),t=i.currentView().render(i);t&&(i.el.firstChild.innerHTML=t),i.adjustPosition(),(e||i.shouldFocusOnRender)&&L(i)}},setState:function(e){for(var n in e)i.state[n]=e[n];t("statechange"),i.render()}};return a=Y(e,i),i}function P(e,t){var n=document.createElement("div");return n.className=e.mode,n.innerHTML=t,n}function Y(e,t){var n=N(5,function(){t.shouldHide()?t.close():t.open()}),a=[p("blur",e,N(5,function(){t.hasFocus()||t.close(!0)})),p("mousedown",e,function(){e===document.activeElement&&n()}),p("focus",e,n),p("input",e,function(e){var n=t.opts.parse(e.target.value);isNaN(n)||t.setState({hilightedDate:n})})];return function(){a.forEach(function(e){e()})}}function L(e){var t=e.el.querySelector(".dp-current");return t&&t.focus()}function V(e){function t(t){t.target.className.split(" ").forEach(function(n){var a=e.currentView().onClick[n];a&&a(t,e)})}var n=e.el,a=n.querySelector(".dp");p("blur",a,N(10,function(){a.contains(document.activeElement)||e.close(!0)})),p("keydown",n,function(n){n.keyCode===X.enter?t(n):e.currentView().onKeyDown(n,e)}),p("mousedown",a,function(t){document.activeElement!==t.target&&(t.preventDefault(),L(e))}),p("click",n,t)}function A(e){e.focus(),/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream&&e.blur()}function I(e,t,n){var a=R(e,t,n);return e.readonly=!0,a.containerHTML+='<a href="#" class="dp-focuser">.</a>',a}function B(e,t,n){var a=R(e,t,n);return a.shouldFocusOnBlur=!1,Object.defineProperty(a,"shouldFocusOnRender",{get:function(){return e!==document.activeElement}}),a.adjustPosition=function(){K(e,a)},a}function K(e,t){var n=e.getBoundingClientRect(),a=document.documentElement;J(t,n,a),q(t,n,a),t.el.style.visibility=""}function q(e,t,n){var a=e.el,r=n.scrollLeft,o=t.left+r,i=n.clientWidth+r,u=a.offsetWidth,c=o+u,s=i-u,d=c>i&&s>0?s:o;a.style.left=d+"px"}function J(e,t,n){var a=e.el,r=n.scrollTop,o=r+t.top,i=a.offsetHeight,u=o+t.height+8,c=o-i-8,s=c>0&&u+i>r+n.clientHeight?c:u;a.style.top=s+"px"}function W(e,t,n){var a=R(e,t,n);return a.close=H,a.destroy=H,a.updateInput=H,a.shouldFocusOnRender=!1,a.computeSelectedDate=function(){return n.hilightedDate},a.attachToDom=function(){e.appendChild(a.el)},a.open(),a}function z(e,t,n){return e=e&&e.tagName?e:document.querySelector(e),"dp-modal"===n.mode?I(e,t,n):"dp-below"===n.mode?B(e,t,n):"dp-permanent"===n.mode?W(e,t,n):void 0}function G(){function e(e,t){(n[e]=n[e]||[]).push(t)}function t(t){for(var n in t)e(n,t[n])}var n={};return{on:function(n,a){return a?e(n,a):t(n),this},emit:function(e,t){(n[e]||[]).forEach(function(n){n(e,t)})},off:function(e,t){return e?n[e]=t?(n[e]||[]).filter(function(e){return e!==t}):[]:n={},this}}}function Q(e,t){function n(e){a.emit(e,i)}var a=G(),r=s(t),o=z(e,n,r),i={get state(){return o.state},on:a.on,off:a.off,setState:o.setState,open:o.open,close:o.close,destroy:o.destroy};return i}var U={days:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],today:"Today",clear:"Clear",close:"Close"},X={left:37,up:38,right:39,down:40,enter:13,esc:27},Z=function(){var e=window.CustomEvent;return"function"!=typeof e&&(e=function(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n},e.prototype=window.Event.prototype),e}(),$={onKeyDown:v,onClick:{"dp-day":j,"dp-next":w,"dp-prev":S,"dp-today":g,"dp-clear":m,"dp-close":D,"dp-cal-month":y,"dp-cal-year":b},render:h},_={onKeyDown:T,onClick:{"dp-month":F},render:C},ee={render:E,onKeyDown:O,onClick:{"dp-year":M}},te={day:$,year:ee,month:_};return Q});
//# sourceMappingURL=dist/tiny-date-picker.min.js.map