-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzzrper.min.js
7 lines (7 loc) · 14 KB
/
zzrper.min.js
1
2
3
4
5
6
7
/*!
* zzrper v0.0.2
* (c) 2020 Jyunzn
* Released under the MIT License
*/
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define("zzrper",[],n):"object"==typeof exports?exports.zzrper=n():t.zzrper=n()}(this,(function(){return(()=>{"use strict";var t={163:(t,n,e)=>{function r(t,n,e){return n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}e.d(n,{default:()=>J});var o=function(t){return"[object Array]"===Object.prototype.toString.call(t)};function a(t){if(function(t){return"[object Object]"===Object.prototype.toString.call(t)}(t)){var n={};for(var e in t)n[e]=a(t[e]);return n}if(o(t)){for(var r=[],c=0;c<t.length;c++){var u=t[c];r.push(a(u))}return r}return t}function c(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}function u(t){return function(t){if(Array.isArray(t))return c(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,n){if(t){if("string"==typeof t)return c(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?c(t,n):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var s=function(t,n){if(!o(n))return!1;for(var e=0;e<n.length;e++){var r=n[e];t.classList.add(r)}},l=function(t,n){if(!o(n))return!1;for(var e=0;e<n.length;e++){var r=n[e];t.classList.remove(r)}};function i(t,n){return(i=Object.setPrototypeOf||function(t,n){return t.__proto__=n,t})(t,n)}function f(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function d(t,n,e){return(d=f()?Reflect.construct:function(t,n,e){var r=[null];r.push.apply(r,n);var o=new(Function.bind.apply(t,r));return e&&i(o,e.prototype),o}).apply(null,arguments)}function p(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),e.push.apply(e,r)}return e}function y(t){for(var n=1;n<arguments.length;n++){var e=null!=arguments[n]?arguments[n]:{};n%2?p(Object(e),!0).forEach((function(n){r(t,n,e[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):p(Object(e)).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}))}return t}function h(t,n){var e=t.year,r=t.month,o=t.date,a=n.year,c=n.month,u=n.date;return a<e||a===e&&c<r||a===e&&c===r&&u<o?-1:a===e&&c===r&&u===o?0:1}var v=function(t,n){return[1,3,5,7,8,10,12].includes(n)?31:[4,6,8,9,11].includes(n)?30:function(t){return t%4==0&&t%100!=0||t%400==0}(t)?29:28};function b(t,n){var e=t.start.cur,r=t.end.cur,o=n.pL,a=n.pR,c=y(y({},o),{},{date:1}),u=y(y({},a),{},{date:v(a.year,a.month)});return{lcs:h(c,e),lce:h(c,r),rcs:h(u,e),rce:h(u,r)}}var g={cls_selectStart:"zzrp-select-start",cls_selectEnd:"zzrp-select-end",cls_inRange:"zzrp-in-range"},m={onSelectStart:[],onSelectEnd:[]};function O(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),e.push.apply(e,r)}return e}function C(t){for(var n=1;n<arguments.length;n++){var e=null!=arguments[n]?arguments[n]:{};n%2?O(Object(e),!0).forEach((function(n){r(t,n,e[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):O(Object(e)).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}))}return t}function j(t,n){var e,r=t[n];r&&(e=function(t){if("string"!=typeof t||!t.includes("-"))return null;var n=t.split("-").map((function(t){return 1*t}));n[1]-=1;var e,r=d(Date,u(n));return"number"==typeof(e=r.getTime())&&e!=e?null:r}(r),delete t.cmz_initSelectDate);var o,a=null,c=null;if(e){var s={year:(o=e).getFullYear(),month:o.getMonth()+1,date:o.getDate()};a=C({},s),c=C({},s)}return{cur:c,init:a}}function D(t){t.zzrp={};var n=function(t){var n={};for(var e in t)e.startsWith("zzrp_")&&(n[e.slice(5)]=t[e],delete t[e]);return n}(t),e=function(t){var n=j(t,"cmz_initSelectStart"),e=j(t,"cmz_initSelectEnd");if(function(t,n){if(null!==n){if(null===t)return!0;if(-1===h(t,n))return!0}return!1}(n.cur,e.cur)){var r=[e,n];n=r[0],e=r[1]}return{start:n,end:e}}(n),r=function(t,n){var e={};for(var r in n){var o=t[r];void 0!==o?("string"!=typeof o&&(o=n[r]),delete t[r]):o=n[r],e[r]=o?o.split(" "):[]}return e}(n,g),o=function(t){var n=a(m);return function(t,n,e){for(var r in n){var o=n[r],a=t[r];a&&(c=a,"[object Function]"===Object.prototype.toString.call(c)&&o.push(a),delete t[r])}var c}(t,n),n}(n);return t.zzrp.selectDate=e,t.zzrp.cls=r,{selectDate:e,cls:r,cbs:o}}function R(t,n,e,r,o){var a=t.startComponent,c=t.endComponent,u=n.lcs,s=n.rce;return!(-1!==u||1!==s)||(null!==a||null!==c)&&function(t,n,e,r){var o=t.startComponent,a=t.endComponent,c=n.cs,u=n.ce,s=c.year,l=c.month,i=c.date,f=u.year,d=u.month,p=u.date,y={unCurYears:null,startCurYearUnCurMonths:null,endCurYearUnCurMonths:null,startCurMonthInRange:null,endCurMonthInRange:null};if(null===o)r||(y.unCurYears=Object.keys(e).filter((function(t){return t<f})),y.endCurYearUnCurMonths=Object.keys(e[f]).filter((function(t){return t<d}))),y.endCurMonthInRange=e[f][d].dDs.slice(0,p-1);else if(null===a)y.unCurYears=Object.keys(e).filter((function(t){return t>s})),y.startCurYearUnCurMonths=Object.keys(e[s]).filter((function(t){return t>l})),y.startCurMonthInRange=e[s][l].dDs.slice(i);else if(s===f){var h=e[s];if(l===d){var v=h[l];y.startCurMonthInRange=v.dDs.slice(i,p-1)}else y.startCurYearUnCurMonths=Object.keys(h).filter((function(t){return t>l&&t<d})),y.startCurMonthInRange=e[s][l].dDs.slice(i),y.endCurMonthInRange=e[f][d].dDs.slice(0,p-1)}else y.unCurYears=Object.keys(e).filter((function(t){return t>s&&t<f})),y.startCurYearUnCurMonths=Object.keys(e[s]).filter((function(t){return t>l})),y.endCurYearUnCurMonths=Object.keys(e[f]).filter((function(t){return t<d})),y.startCurMonthInRange=e[s][l].dDs.slice(i),y.endCurMonthInRange=e[f][d].dDs.slice(0,p-1);return Object.keys(y).forEach((function(t){var n=y[t];null!==n&&!n.length&&(y[t]=null)})),y}({startComponent:a,endComponent:c},e,r,o)}function E(t,n,e){return-1===e.l||1===e.r?null:t[n.year]&&t[n.year][n.month]&&t[n.year][n.month].dDs[n.date-1]||null}function z(t,n,e,r){var o=n.start.cur,a=n.end.cur,c=E(t,o,{l:e.lcs,r:e.rcs}),u=E(t,a,{l:e.lce,r:e.rce});return{startComponent:c,endComponent:u,rangeComponents:R({startComponent:c,endComponent:u},e,{cs:o,ce:a},t,r)}}function S(t,n){t&&t.forEach((function(t){return s(t,n)}))}function M(t,n,e,r){var o=n.year;t&&t.forEach((function(t){e[o][t].dDs.forEach((function(t){return s(t,r)}))}))}function w(t,n,e){t&&t.forEach((function(t){var r=n[t];Object.keys(r).forEach((function(t){r[t].dDs.forEach((function(t){return s(t,e)}))}))}))}function P(t,n,e,r){var o=n.year,a=n.month,c=n.date;r[o]||(r[o]={}),"start"===e?r[o][a]={start:c+1,end:c+t.length}:"end"===e&&(r[o][a]={start:c-t.length,end:c-1})}function k(t,n,e){e[n]||(e[n]={}),t.forEach((function(t){e[n][t]={start:1,end:v(1*n,1*t)}}))}function _(t,n,e){n.forEach((function(n){e[n]||(e[n]={}),Object.keys(t[n]).forEach((function(t){e[n][t]={start:1,end:v(1*n,1*t)}}))}))}function Y(t,n,e,r){var o=e.startComponent,a=e.rangeComponents,c=e.endComponent,u=n.start.cur,s=n.end.cur,l={};return l.start=o&&u||null,l.end=c&&s||null,l.inRange=function(t,n,e,r){var o=e.selectStart,a=e.selectEnd,c={};if(!0===n)if(r){var u=r.year;k([r.month],u,c)}else _(t,Object.keys(t),c);else if(!1!==n){var s=n.unCurYears,l=n.startCurYearUnCurMonths,i=n.endCurYearUnCurMonths,f=n.startCurMonthInRange,d=n.endCurMonthInRange,p=o.year,y=a.year;s&&_(t,s,c),l&&k(l,p,c),i&&k(i,y,c),f&&P(f,o,"start",c),d&&P(d,a,"end",c)}return Object.keys(c).length?c:null}(t,a,{selectStart:u,selectEnd:s},r),l}function I(t,n){var e=t.pointers,r=t.doms.ymDs,o=n.selectDate,a=n.cls,c=o.start.cur,u=null;if(null===o.end.cur){var l=c.year,i=c.month,f=c.date,d=r[l],p=d&&d[i],y=p&&p.dDs[f-1];y&&s(y,a.cls_selectStart),u={start:c,end:null,inRange:null}}else{var h=z(r,o,b(o,e));(function(t,n,e,r){var o=t.startComponent,a=t.endComponent,c=t.rangeComponents;!function(t,n){var e=t.startComponent,r=t.endComponent,o=n.cls_selectStart,a=n.cls_selectEnd;e&&s(e,o),r&&s(r,a)}({startComponent:o,endComponent:a},n),function(t,n,e,r){var o=e.cls_inRange;if(!0===t)w(Object.keys(n),n,o);else if(!1!==t){var a=t.unCurYears,c=t.startCurYearUnCurMonths,u=t.endCurYearUnCurMonths,s=t.startCurMonthInRange,l=t.endCurMonthInRange,i=r.start.cur,f=r.end.cur;w(a,n,o),M(c,i,n,o),M(u,f,n,o),S(s,o),S(l,o)}}(c,e,n,r)})(h,a,r,o),u=Y(r,o,h)}t.opts.zzrp.draw=u}function A(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),e.push.apply(e,r)}return e}function x(t){for(var n=1;n<arguments.length;n++){var e=null!=arguments[n]?arguments[n]:{};n%2?A(Object(e),!0).forEach((function(n){r(t,n,e[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):A(Object(e)).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}))}return t}function U(t,n,e){var r=n[t.year],o=r&&r[t.month],a=o&&o.dDs[t.date-1];a&&l(a,e)}function L(t,n){var e=t.opts.cls_date,r=t.doms.ymDs;Object.keys(r).forEach((function(o){var a=r[o];Object.keys(a).forEach((function(r){var o=a[r].mCD;o.addEventListener("click",(function(r){var a=r.target;u(a.classList).includes(e[0])&&function(t,n,e){var r=e.selectDate,o=r.start,a=r.end,c=e.cls.cls_selectStart,u=e.cbs;null===o.cur?(o.cur=t,u.onSelectStart.forEach((function(n){return n.call(null,{start:t,end:null})}))):null===a.cur?(-1===h(o.cur,t)?(U(o.cur,n.doms.ymDs,c),a.cur=o.cur,o.cur=t):a.cur=t,u.onSelectEnd.forEach((function(t){return t.call(null,{start:x({},o.cur),end:x({},a.cur)})}))):(function(t){var n=t.opts.zzrp,e=t.doms.ymDs,r=n.draw,o=n.selectDate,a=n.cls,c=a.cls_inRange,u=a.cls_selectEnd,s=a.cls_selectStart,i=r.start,f=r.end,d=r.inRange;i&&U(i,e,s),f&&U(f,e,u),d&&function(t,n,e){Object.keys(t).forEach((function(r){var o=t[r];Object.keys(o).forEach((function(o){var a=n[r][o],c=t[r][o];a.dDs.slice(c.start-1,c.end).forEach((function(t){return l(t,e)}))}))}))}(d,e,c),r.start=null,r.end=null,r.inRange=null,o.start.cur=null,o.end.cur=null}(n),o.cur=t,u.onSelectStart.forEach((function(n){return n.call(null,{start:t,end:null})}))),I(n,e)}(function(t,n){return x(x({},n.$_ym),{},{date:1*t.textContent})}(a,o),t,n)}))}))}))}function F(t){if(!0===t.opts.zzrp){var n=D(t.opts);null!==n.selectDate.start.cur?I(t,n):t.opts.zzrp.draw={start:null,end:null,inRange:null},L(t,n)}else void 0!==t.opts.zzrp&&delete t.opts.zzrp}function B(t,n){var e=t.year,r=t.month;return n[e]&&n[e][r]||null}function T(t,n){var e=n.year,r=n.month,o=t.year,a=t.month;return e===o&&r===a&&n||null}function $(t,n,e){var r=t[n-1];return r&&s(r,e),!0}function W(t,n,e){var r=t[n-1];return r&&l(r,e),!0}function q(t,n,e,r){var o=t.start,a=t.end,c=e.cls_selectStart,u=e.cls_selectEnd;return{startChange:o&&r(n,o.date,c)||!1,endChange:a&&r(n,a.date,u)||!1}}function G(t,n){var e=t.diffM,r=e.beforeYM,o=e.nextYM,a=t.ymDs,c=n.selectDate,u=n.draw,i=n.cls,f=c.start.cur,d=c.end.cur;if(f&&d){var p=Y(a,c,z(a,c,b(c,{pL:o,pR:o}),!0),o),y=function(t,n){var e=n.start,r=n.end,o=n.inRange,a={};return a.start=e&&T(t,e),a.end=r&&T(t,r),a.inRange=o&&B(t,o),a}(r,u),h=p.inRange;h&&(p.inRange=B(o,h)),function(t,n,e,r){var o=r.cls,a=r.draw,c=r.selectDate,u=e.contentDs.dDs,i=e.diffM,f=q(n,u,o,W),d=q(t,u,o,$),p=function(t,n,e,r){var o=t.inRange,a=n.inRange,c=r.cls_inRange;if(null===o&&null!==a){var u=a.start,i=a.end;return e.slice(u-1,i).forEach((function(t){return l(t,c)})),"rm"}if(null!==o&&null===a){var f=o.start,d=o.end;return e.slice(f-1,d).forEach((function(t){return s(t,c)})),"add"}if(null!==o&&null!==a){var p=function(t,n){var e=t.start,r=t.end,o=n.start,a=n.end,c=[],u=[];if(o>r||a<e)c.push(t),u.push(n);else{var s=o-e,l=a-r;0===s?l<0?c.push({start:a+1,end:r}):l>0&&u.push({start:r+1,end:a}):s>0?(c.push({start:e,end:o-1}),l<0?c.push({start:a+1,end:r}):l>0&&u.push({start:r+1,end:a})):s<0&&(u.push({start:o,end:e-1}),l<0?c.push({start:a+1,end:r}):l>0&&u.push({start:r+1,end:a}))}return{addArr:c,rmArr:u}}(o,a),y=p.addArr,h=p.rmArr;return y.forEach((function(t){var n=t.start,r=t.end;e.slice(n-1,r).forEach((function(t){return s(t,c)}))})),h.forEach((function(t){var n=t.start,r=t.end;e.slice(n-1,r).forEach((function(t){return l(t,c)}))})),"both"}return!1}(t,n,u,o);!function(t,n){var e=t.startChange,r=t.endChange;e&&(n.start=null),r&&(n.end=null)}(f,a),function(t,n,e){var r=e.start.cur,o=e.end.cur,a=t.startChange,c=t.endChange;a&&(n.start=r),c&&(n.end=o)}(d,a,c),function(t,n,e,r){var o=e.beforeYM,a=o.year,c=o.month,u=e.nextYM,s=u.year,l=u.month;!n.inRange&&(n.inRange={});var i=n.inRange;switch(t){case"rm":delete i[a][c];break;case"add":i[s]||(i[s]={}),i[s][l]=r.inRange;break;case"both":delete i[a][c],i[s]||(i[s]={}),i[s][l]=r.inRange}i[a]&&!Object.keys(i[a]).length&&delete i[a],Object.keys(i).length||(n.inRange=null)}(p,a,i,t)}(p,y,t,n)}else if(f){var v=f.year,g=f.month,m=f.date,O=r.year,C=r.month,j=o.year,D=o.month,R=i.cls_selectStart;if(v===O&&g===C){var E=a[j]&&a[j][D]&&a[j][D].dDs[m-1];E&&l(E,R)}else if(v===j&&g===D){var S=a[j]&&a[j][D]&&a[j][D].dDs[m-1];s(S,R)}}}function H(t){var n=t.opts.zzrp;n&&G(t,n)}const J={install:function(t){t.mixin({onCreated:F,onBeforeDomBeAssyAtResetDom:H})}}}},n={};function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{}};return t[r](o,o.exports,e),o.exports}return e.d=(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},e.o=(t,n)=>Object.prototype.hasOwnProperty.call(t,n),e(163)})().default}));
//# sourceMappingURL=zzrper.min.js.map