lddatetimepicker 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/index.js +16 -16
- package/index.min.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/index.js
CHANGED
|
@@ -208,7 +208,12 @@
|
|
|
208
208
|
countScroll = true;
|
|
209
209
|
while (n && n.getAttribute) {
|
|
210
210
|
s = getComputedStyle(n);
|
|
211
|
-
if (n.nodeName === 'BODY'
|
|
211
|
+
if (n.nodeName === 'BODY') {
|
|
212
|
+
if (!nscroll) {
|
|
213
|
+
nscroll = document.scrollingElement;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (['overflow', 'overflow-y', 'overflow-x'].filter(fn$).length) {
|
|
212
217
|
if (!nscroll) {
|
|
213
218
|
nscroll = n;
|
|
214
219
|
}
|
|
@@ -228,24 +233,19 @@
|
|
|
228
233
|
}
|
|
229
234
|
stackb = nstack.getBoundingClientRect();
|
|
230
235
|
scrollb = nscroll.getBoundingClientRect();
|
|
231
|
-
scroll =
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
:
|
|
237
|
-
left: 0,
|
|
238
|
-
top: 0
|
|
239
|
-
};
|
|
240
|
-
if (hb.y + hb.height + cb.height > scrollb.y + scrollb.height) {
|
|
241
|
-
y = hb.y - stackb.y - cb.height + scroll.top - 2;
|
|
236
|
+
scroll = {
|
|
237
|
+
left: nscroll.scrollLeft,
|
|
238
|
+
top: nscroll.scrollTop
|
|
239
|
+
};
|
|
240
|
+
if (hb.y + hb.height + cb.height > scrollb.y + scrollb.height + scroll.top) {
|
|
241
|
+
y = hb.y - stackb.y - cb.height + (countScroll ? scroll.top : 0) - 2;
|
|
242
242
|
} else {
|
|
243
|
-
y = hb.y - stackb.y + hb.height + scroll.top + 2;
|
|
243
|
+
y = hb.y - stackb.y + hb.height + (countScroll ? scroll.top : 0) + 2;
|
|
244
244
|
}
|
|
245
|
-
if (hb.x + cb.width > scrollb.x + scrollb.width) {
|
|
246
|
-
x = hb.x - stackb.x + hb.width - cb.width + scroll.left;
|
|
245
|
+
if (hb.x + cb.width > scrollb.x + scrollb.width + scroll.left) {
|
|
246
|
+
x = hb.x - stackb.x + hb.width - cb.width + (countScroll ? scroll.left : 0);
|
|
247
247
|
} else {
|
|
248
|
-
x = hb.x - stackb.x + scroll.left;
|
|
248
|
+
x = hb.x - stackb.x + (countScroll ? scroll.left : 0);
|
|
249
249
|
}
|
|
250
250
|
c.style.transform = "translate(" + x + "px, " + y + "px)";
|
|
251
251
|
return ref$ = c.style, ref$.top = 0, ref$.left = 0, ref$;
|
package/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){var t;(t=function(t){var e,s=this;if(this.opt=t=null==t?{}:t,this._enabled={time:!(null!=t.time)||t.time},this.evthdr={},this.hdr={mouseup:function(t){if(t.target!==s.host)return s.root.classList.toggle("active",!1),document.removeEventListener("mouseup",s.hdr.mouseup),document.removeEventListener("keydown",s.hdr.keydown)},keydown:function(t){var e;if(s.isOn()&&(13===(e=t.keyCode)||27===e||37===e||38===e||39===e||40===e)&&s.sel)return 13===e||27===e?s.toggle(!1):(t.stopPropagation(),t.preventDefault(),s.sel=37===e?s.sel.subtract(1,"day"):39===e?s.sel.add(1,"day"):38===e?s.sel.subtract(7,"day"):40===e?s.sel.add(7,"day"):void 0,s.cur=s.sel,s.update())}},e=document.createElement("div"),t.host?(this.host="string"==typeof t.host?document.querySelector(t.host):t.host,this.host.parentNode.insertBefore(e,t.host.nextSibling),this.host.addEventListener("mouseup",function(t){return s.toggle()})):document.body.appendChild(e),e.innerHTML='<div class="lddtp">\n <div class="lddtp-h">\n <div class="lddtp-a" data-action="-"></div>\n <div class="lddtp-f"><select class="lddtp-month-sel"></select></div>\n <div class="lddtp-f"><input class="lddtp-year-sel" type="number"/></div>\n <div class="lddtp-a" data-action="+"></div>\n </div>\n <div class="lddtp-ds">\n </div>\n <div class="lddtp-t">\n <div class="lddtp-f"><select class="lddtp-hour-sel"></select></div>\n <div><b>:</b></div>\n <div class="lddtp-f"><select class="lddtp-minute-sel"></select></div>\n </div>\n</div>',this.root=t=e.querySelector(".lddtp"),this.root.addEventListener("mouseup",function(t){return t.stopPropagation()}),this.n={ds:t.querySelector(".lddtp-ds"),t:t.querySelector(".lddtp-t"),sel:{year:t.querySelector(".lddtp-year-sel"),month:t.querySelector(".lddtp-month-sel"),hour:t.querySelector(".lddtp-hour-sel"),minute:t.querySelector(".lddtp-minute-sel")}},this.n.t.style.display=this._enabled.time?"":"none",this.months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],this.wdays=["SUN","MON","TUE","WED","THR","FRI","SAT"],this.n.ds.innerHTML=[0,1,2,3,4,5,6].map(function(t){return'<div class="lddtp-w">'+s.wdays[t]+"</div>"}).join("")+[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41].map(function(t){return'<div class="lddtp-d"></div>'}).join(""),(e=this.n).dh=Array.from(t.querySelectorAll(".lddtp-w")),e.dc=Array.from(t.querySelectorAll(".lddtp-d")),e=[0,1,2].map(function(){return dayjs()}),this.cur=e[0],this.today=e[1],this.sel=e[2],this.n.sel.month.innerHTML=this.months.map(function(t){return'<option value="'+t+'">'+t+"</option>"}).join(""),(t=this.n.sel.year).setAttribute("min",1900),t.setAttribute("max",2300),t.setAttribute("value",this.today.year()),this.n.sel.hour.innerHTML=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23].map(function(t){return'<option value="'+t+'">'+(""+t).padStart(2,"0")+"</option>"}).join(""),this.n.sel.minute.innerHTML=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59].map(function(t){return'<option value="'+t+'">'+(""+t).padStart(2,"0")+"</option>"}).join(""),this.root.addEventListener("click",function(t){t=t.target;return t.classList.contains("lddtp-d")?(s.sel=dayjs(new Date(t.date.year,t.date.month,t.date.date,s.sel.hour(),s.sel.minute())),s.update(s.cur)):"-"===t.getAttribute("data-action")?(s.cur=s.cur.subtract(1,"month"),s.update(s.cur)):"+"===t.getAttribute("data-action")?(s.cur=s.cur.add(1,"month"),s.update(s.cur)):void 0}),this.n.sel.minute.addEventListener("change",function(t){return s.sel=s.sel.minute(t.target.value),s.update()}),this.n.sel.hour.addEventListener("change",function(t){return s.sel=s.sel.hour(t.target.value),s.update()}),this.n.sel.year.addEventListener("change",function(t){return s.cur=dayjs(new Date(s.n.sel.year.value,s.months.indexOf(s.n.sel.month.value),1)),s.update(s.cur)}),this.n.sel.month.addEventListener("change",function(t){return s.cur=dayjs(new Date(s.n.sel.year.value,s.months.indexOf(s.n.sel.month.value),1)),s.update(s.cur)}),this.host&&(e=debounce(function(){var t;try{return t=dayjs(s.host.value).format("YYYY-MM-DDTHH:mm:ssZ"),s.host.value=t,s.value(s.host.value)}catch(t){return t}}),this.host.addEventListener("change",e),this.host.addEventListener("input",e)),this.host&&this.host.value)try{this.host.value=dayjs(this.host.value).format("YYYY-MM-DDTHH:mm:ssZ"),this.value(this.host.value)}catch(t){0}else this.update();return this}).prototype=function(t,e){var s,n={}.hasOwnProperty;for(s in e)n.call(e,s)&&(t[s]=e[s]);return t}(Object.create(Object.prototype),{on:function(t,s){var n=this;return(Array.isArray(t)?t:[t]).map(function(t){var e;return((e=n.evthdr)[t]||(e[t]=[])).push(s)})},fire:function(t){for(var e,s,n,i,o=[],r=[],d=1,a=arguments.length;d<a;++d)r.push(arguments[d]);for(e=r,d=0,n=(s=this.evthdr[t]||[]).length;d<n;++d)i=s[d],o.push(i.apply(this,e));return o},isOn:function(){return this.root.classList.contains("active")},toggle:function(t){var e,s,n,i,o,r,d,a,l,u,h,c,p,v;if(!(t=0===arguments.length?!this.root.classList.contains("active"):t))return this.root.classList.toggle("active",!1),document.removeEventListener("mouseup",this.hdr.mouseup),void document.removeEventListener("keydown",this.hdr.keydown);for(this.isOn()||(document.addEventListener("mouseup",this.hdr.mouseup),document.addEventListener("keydown",this.hdr.keydown)),this.root.classList.toggle("active",!0),e=this.root,s=(n=this.host).parentNode,n=n.getBoundingClientRect(),i=e.getBoundingClientRect(),r=(o=[0,0])[0],d=o[1],a=(o=[null,null])[0],l=o[1],u=!0;s&&s.getAttribute&&(h=getComputedStyle(s),"BODY"
|
|
1
|
+
!function(){var t;(t=function(t){var e,s=this;if(this.opt=t=null==t?{}:t,this._enabled={time:!(null!=t.time)||t.time},this.evthdr={},this.hdr={mouseup:function(t){if(t.target!==s.host)return s.root.classList.toggle("active",!1),document.removeEventListener("mouseup",s.hdr.mouseup),document.removeEventListener("keydown",s.hdr.keydown)},keydown:function(t){var e;if(s.isOn()&&(13===(e=t.keyCode)||27===e||37===e||38===e||39===e||40===e)&&s.sel)return 13===e||27===e?s.toggle(!1):(t.stopPropagation(),t.preventDefault(),s.sel=37===e?s.sel.subtract(1,"day"):39===e?s.sel.add(1,"day"):38===e?s.sel.subtract(7,"day"):40===e?s.sel.add(7,"day"):void 0,s.cur=s.sel,s.update())}},e=document.createElement("div"),t.host?(this.host="string"==typeof t.host?document.querySelector(t.host):t.host,this.host.parentNode.insertBefore(e,t.host.nextSibling),this.host.addEventListener("mouseup",function(t){return s.toggle()})):document.body.appendChild(e),e.innerHTML='<div class="lddtp">\n <div class="lddtp-h">\n <div class="lddtp-a" data-action="-"></div>\n <div class="lddtp-f"><select class="lddtp-month-sel"></select></div>\n <div class="lddtp-f"><input class="lddtp-year-sel" type="number"/></div>\n <div class="lddtp-a" data-action="+"></div>\n </div>\n <div class="lddtp-ds">\n </div>\n <div class="lddtp-t">\n <div class="lddtp-f"><select class="lddtp-hour-sel"></select></div>\n <div><b>:</b></div>\n <div class="lddtp-f"><select class="lddtp-minute-sel"></select></div>\n </div>\n</div>',this.root=t=e.querySelector(".lddtp"),this.root.addEventListener("mouseup",function(t){return t.stopPropagation()}),this.n={ds:t.querySelector(".lddtp-ds"),t:t.querySelector(".lddtp-t"),sel:{year:t.querySelector(".lddtp-year-sel"),month:t.querySelector(".lddtp-month-sel"),hour:t.querySelector(".lddtp-hour-sel"),minute:t.querySelector(".lddtp-minute-sel")}},this.n.t.style.display=this._enabled.time?"":"none",this.months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],this.wdays=["SUN","MON","TUE","WED","THR","FRI","SAT"],this.n.ds.innerHTML=[0,1,2,3,4,5,6].map(function(t){return'<div class="lddtp-w">'+s.wdays[t]+"</div>"}).join("")+[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41].map(function(t){return'<div class="lddtp-d"></div>'}).join(""),(e=this.n).dh=Array.from(t.querySelectorAll(".lddtp-w")),e.dc=Array.from(t.querySelectorAll(".lddtp-d")),e=[0,1,2].map(function(){return dayjs()}),this.cur=e[0],this.today=e[1],this.sel=e[2],this.n.sel.month.innerHTML=this.months.map(function(t){return'<option value="'+t+'">'+t+"</option>"}).join(""),(t=this.n.sel.year).setAttribute("min",1900),t.setAttribute("max",2300),t.setAttribute("value",this.today.year()),this.n.sel.hour.innerHTML=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23].map(function(t){return'<option value="'+t+'">'+(""+t).padStart(2,"0")+"</option>"}).join(""),this.n.sel.minute.innerHTML=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59].map(function(t){return'<option value="'+t+'">'+(""+t).padStart(2,"0")+"</option>"}).join(""),this.root.addEventListener("click",function(t){t=t.target;return t.classList.contains("lddtp-d")?(s.sel=dayjs(new Date(t.date.year,t.date.month,t.date.date,s.sel.hour(),s.sel.minute())),s.update(s.cur)):"-"===t.getAttribute("data-action")?(s.cur=s.cur.subtract(1,"month"),s.update(s.cur)):"+"===t.getAttribute("data-action")?(s.cur=s.cur.add(1,"month"),s.update(s.cur)):void 0}),this.n.sel.minute.addEventListener("change",function(t){return s.sel=s.sel.minute(t.target.value),s.update()}),this.n.sel.hour.addEventListener("change",function(t){return s.sel=s.sel.hour(t.target.value),s.update()}),this.n.sel.year.addEventListener("change",function(t){return s.cur=dayjs(new Date(s.n.sel.year.value,s.months.indexOf(s.n.sel.month.value),1)),s.update(s.cur)}),this.n.sel.month.addEventListener("change",function(t){return s.cur=dayjs(new Date(s.n.sel.year.value,s.months.indexOf(s.n.sel.month.value),1)),s.update(s.cur)}),this.host&&(e=debounce(function(){var t;try{return t=dayjs(s.host.value).format("YYYY-MM-DDTHH:mm:ssZ"),s.host.value=t,s.value(s.host.value)}catch(t){return t}}),this.host.addEventListener("change",e),this.host.addEventListener("input",e)),this.host&&this.host.value)try{this.host.value=dayjs(this.host.value).format("YYYY-MM-DDTHH:mm:ssZ"),this.value(this.host.value)}catch(t){0}else this.update();return this}).prototype=function(t,e){var s,n={}.hasOwnProperty;for(s in e)n.call(e,s)&&(t[s]=e[s]);return t}(Object.create(Object.prototype),{on:function(t,s){var n=this;return(Array.isArray(t)?t:[t]).map(function(t){var e;return((e=n.evthdr)[t]||(e[t]=[])).push(s)})},fire:function(t){for(var e,s,n,i,o=[],r=[],d=1,a=arguments.length;d<a;++d)r.push(arguments[d]);for(e=r,d=0,n=(s=this.evthdr[t]||[]).length;d<n;++d)i=s[d],o.push(i.apply(this,e));return o},isOn:function(){return this.root.classList.contains("active")},toggle:function(t){var e,s,n,i,o,r,d,a,l,u,h,c,p,v;if(!(t=0===arguments.length?!this.root.classList.contains("active"):t))return this.root.classList.toggle("active",!1),document.removeEventListener("mouseup",this.hdr.mouseup),void document.removeEventListener("keydown",this.hdr.keydown);for(this.isOn()||(document.addEventListener("mouseup",this.hdr.mouseup),document.addEventListener("keydown",this.hdr.keydown)),this.root.classList.toggle("active",!0),e=this.root,s=(n=this.host).parentNode,n=n.getBoundingClientRect(),i=e.getBoundingClientRect(),r=(o=[0,0])[0],d=o[1],a=(o=[null,null])[0],l=o[1],u=!0;s&&s.getAttribute&&(h=getComputedStyle(s),"BODY"===s.nodeName&&(a=a||document.scrollingElement),["overflow","overflow-y","overflow-x"].filter(m).length&&(a=a||s),"BODY"!==s.nodeName&&"static"===h.position||l||(l=s,a||(u=!1)),!a||!l);)s=s.parentNode;return c=l.getBoundingClientRect(),p=a.getBoundingClientRect(),v={left:a.scrollLeft,top:a.scrollTop},d=n.y+n.height+i.height>p.y+p.height+v.top?n.y-c.y-i.height+(u?v.top:0)-2:n.y-c.y+n.height+(u?v.top:0)+2,r=n.x+i.width>p.x+p.width+v.left?n.x-c.x+n.width-i.width+(u?v.left:0):n.x-c.x+(u?v.left:0),e.style.transform="translate("+r+"px, "+d+"px)",(o=e.style).top=0,o.left=0,o;function m(t){return"visible"!==h[t]}},update:function(t){s=[(t=t||this.cur).year(),t.month()];var o,e,r,d,a,l,u,h,s,n,c=s[1];if(t=dayjs(new Date(t.year(),t.month(),1)),o=t.subtract(t.day(),"day"),t=(s=[t.year(),t.month(),t.date()])[0],e=s[1],s=[this.today.year(),this.today.month(),this.today.date()],r=s[0],d=s[1],a=s[2],s=this.sel?[this.sel.year(),this.sel.month(),this.sel.date()]:[null,null,null],l=s[0],u=s[1],h=s[2],this.n.sel.month.value=this.months[e],this.n.sel.year.value=t,this.n.sel.minute.value=this.sel.minute(),this.n.sel.hour.value=this.sel.hour(),this.n.dc.map(function(t,e){var e=o.add(e,"day"),s=[e.year(),e.month(),e.date()],n=s[0],i=s[1],s=s[2];return t.date={year:n,month:i,date:s},t.innerText=e.date(),t.classList.toggle("dim",e.month()!==c),t.classList.toggle("today",r===n&&d===i&&a===s),t.classList.toggle("selected",l===n&&u===i&&h===s)}),this.host&&(s=this.host.value,n=this.value(),s!==(this.host.value=n)))return this.fire("change",n)},value:function(t){return arguments.length?(this.sel=dayjs(t),this.cur=dayjs(t),this.update()):this._enabled.time?dayjs(new Date(this.sel.year(),this.sel.month(),this.sel.date(),this.sel.hour(),this.sel.minute())).format("YYYY-MM-DDTHH:mm:ssZ"):dayjs(new Date(this.sel.year(),this.sel.month(),this.sel.date())).format("YYYY-MM-DD")}}),"undefined"!=typeof module&&null!==module?module.exports=t:"undefined"!=typeof window&&null!==window&&(window.lddatetimepicker=t)}.call(this);
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"lddatetimepicker","version":"0.0.
|
|
1
|
+
{"name":"lddatetimepicker","version":"0.0.6","description":"vanilla date/time picker","browser":"index.min.js","main":"index.js","scripts":{"start":"npx server -r web -o true"},"homepage":"https://github.com/loadingio/lddatetimepicker","repository":{"type":"git","url":"https://github.com/loadingio/lddatetimepicker"},"keywords":["date","time","datetime","datepicker","datetimepicker"],"author":"zbryikt","license":"MIT","devDependencies":{"@loadingio/bootstrap.ext":"^0.0.6","@loadingio/debounce.js":"^1.0.1","@zbryikt/template":"^2.3.34","bootstrap":"^4.6.1","dayjs":"^1.11.0","fedep":"^1.1.7","ldcover":"^3.0.1","ldview":"^1.1.1","livescript":"^1.6.0","proxise":"^1.0.1","stylus":"^0.57.0","uglify-js":"^3.15.3","uglifycss":"^0.0.29"},"frontendDependencies":{"root":"web/static/assets/lib","modules":["@loadingio/bootstrap.ext","@loadingio/debounce.js","@loadingio/ldquery","dayjs","bootstrap","ldcover","ldview","proxise"]},"dependencies":{"@loadingio/ldquery":"^3.0.3"}}
|