diff --git a/.gitmodules b/.gitmodules index 7d405884d0..723abcec62 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,9 +13,6 @@ [submodule "public/vendor/shepherd"] path = public/vendor/shepherd url = https://github.com/HubSpot/shepherd -[submodule "public/vendor/flatpickr"] - path = public/vendor/flatpickr - url = https://github.com/chmln/flatpickr [submodule "public/vendor/bar-rating"] path = public/vendor/bar-rating url = https://github.com/antennaio/jquery-bar-rating diff --git a/app/templating/AssetHelper.scala b/app/templating/AssetHelper.scala index df45ff261e..a6be4d98ca 100644 --- a/app/templating/AssetHelper.scala +++ b/app/templating/AssetHelper.scala @@ -80,6 +80,10 @@ trait AssetHelper { self: I18nHelper => s"""""" } + val flatpickrTag = Html { + s"""""" + } + private def cdnOrLocal(cdn: String, test: String, local: String) = Html { if (isProd) s"""""" diff --git a/public/javascripts/vendor/flatpickr.min.js b/public/javascripts/vendor/flatpickr.min.js new file mode 100644 index 0000000000..0c25a25edb --- /dev/null +++ b/public/javascripts/vendor/flatpickr.min.js @@ -0,0 +1,2 @@ +/* flatpickr v4.4.6,, @license MIT */ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.flatpickr=t()}(this,function(){"use strict";var Z=function(e){return("0"+e).slice(-2)},Q=function(e){return!0===e?1:0};function X(n,a,i){var o;return void 0===i&&(i=!1),function(){var e=this,t=arguments;null!==o&&clearTimeout(o),o=window.setTimeout(function(){o=null,i||n.apply(e,t)},a),i&&!o&&n.apply(e,t)}}var ee=function(e){return e instanceof Array?e:[e]},e=function(){},te=function(e,t,n){return n.months[t?"shorthand":"longhand"][e]},D={D:e,F:function(e,t,n){e.setMonth(n.months.longhand.indexOf(t))},G:function(e,t){e.setHours(parseFloat(t))},H:function(e,t){e.setHours(parseFloat(t))},J:function(e,t){e.setDate(parseFloat(t))},K:function(e,t,n){e.setHours(e.getHours()%12+12*Q(new RegExp(n.amPM[1],"i").test(t)))},M:function(e,t,n){e.setMonth(n.months.shorthand.indexOf(t))},S:function(e,t){e.setSeconds(parseFloat(t))},U:function(e,t){return new Date(1e3*parseFloat(t))},W:function(e,t){var n=parseInt(t);return new Date(e.getFullYear(),0,2+7*(n-1),0,0,0,0)},Y:function(e,t){e.setFullYear(parseFloat(t))},Z:function(e,t){return new Date(t)},d:function(e,t){e.setDate(parseFloat(t))},h:function(e,t){e.setHours(parseFloat(t))},i:function(e,t){e.setMinutes(parseFloat(t))},j:function(e,t){e.setDate(parseFloat(t))},l:e,m:function(e,t){e.setMonth(parseFloat(t)-1)},n:function(e,t){e.setMonth(parseFloat(t)-1)},s:function(e,t){e.setSeconds(parseFloat(t))},w:e,y:function(e,t){e.setFullYear(2e3+parseFloat(t))}},ne={D:"(\\w+)",F:"(\\w+)",G:"(\\d\\d|\\d)",H:"(\\d\\d|\\d)",J:"(\\d\\d|\\d)\\w+",K:"",M:"(\\w+)",S:"(\\d\\d|\\d)",U:"(.+)",W:"(\\d\\d|\\d)",Y:"(\\d{4})",Z:"(.+)",d:"(\\d\\d|\\d)",h:"(\\d\\d|\\d)",i:"(\\d\\d|\\d)",j:"(\\d\\d|\\d)",l:"(\\w+)",m:"(\\d\\d|\\d)",n:"(\\d\\d|\\d)",s:"(\\d\\d|\\d)",w:"(\\d\\d|\\d)",y:"(\\d{2})"},c={Z:function(e){return e.toISOString()},D:function(e,t,n){return t.weekdays.shorthand[c.w(e,t,n)]},F:function(e,t,n){return te(c.n(e,t,n)-1,!1,t)},G:function(e,t,n){return Z(c.h(e,t,n))},H:function(e){return Z(e.getHours())},J:function(e,t){return void 0!==t.ordinal?e.getDate()+t.ordinal(e.getDate()):e.getDate()},K:function(e,t){return t.amPM[Q(11Math.min(t,n)&&e",noCalendar:!1,now:new Date,onChange:[],onClose:[],onDayCreate:[],onDestroy:[],onKeyDown:[],onMonthChange:[],onOpen:[],onParseConfig:[],onReady:[],onValueUpdate:[],onYearChange:[],onPreCalendarPosition:[],plugins:[],position:"auto",positionElement:void 0,prevArrow:"",shorthandCurrentMonth:!1,showMonths:1,static:!1,time_24hr:!1,weekNumbers:!1,wrap:!1};function de(e,t,n){if(!0===n)return e.classList.add(t);e.classList.remove(t)}function se(e,t,n){var a=window.document.createElement(e);return t=t||"",n=n||"",a.className=t,void 0!==n&&(a.textContent=n),a}function ue(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function fe(e,t){var n=se("div","numInputWrapper"),a=se("input","numInput "+e),i=se("span","arrowUp"),o=se("span","arrowDown");if(a.type="text",a.pattern="\\d*",void 0!==t)for(var r in t)a.setAttribute(r,t[r]);return n.appendChild(a),n.appendChild(i),n.appendChild(o),n}if("function"!=typeof Object.assign&&(Object.assign=function(n){if(!n)throw TypeError("Cannot convert undefined or null to object");for(var e=arguments.length,a=new Array(1o)&&(p.amPM.textContent=p.l10n.amPM[Q(p.amPM.textContent===p.l10n.amPM[0])]),n.value=Z(l)}}(e),"input"!==e.type?(s(),G()):setTimeout(function(){s(),G()},me))}function s(){if(void 0!==p.hourElement&&void 0!==p.minuteElement){var e,t,n=(parseInt(p.hourElement.value.slice(-2),10)||0)%24,a=(parseInt(p.minuteElement.value,10)||0)%60,i=void 0!==p.secondElement?(parseInt(p.secondElement.value,10)||0)%60:0;void 0!==p.amPM&&(e=n,t=p.amPM.textContent,n=e%12+12*Q(t===p.l10n.amPM[1]));var o=void 0!==p.config.minTime||p.config.minDate&&p.minDateHasTime&&p.latestSelectedDateObj&&0===re(p.latestSelectedDateObj,p.config.minDate,!0);if(void 0!==p.config.maxTime||p.config.maxDate&&p.maxDateHasTime&&p.latestSelectedDateObj&&0===re(p.latestSelectedDateObj,p.config.maxDate,!0)){var r=void 0!==p.config.maxTime?p.config.maxTime:p.config.maxDate;(n=Math.min(n,r.getHours()))===r.getHours()&&(a=Math.min(a,r.getMinutes())),a===r.getMinutes()&&(i=Math.min(i,r.getSeconds()))}if(o){var c=void 0!==p.config.minTime?p.config.minTime:p.config.minDate;(n=Math.max(n,c.getHours()))===c.getHours()&&(a=Math.max(a,c.getMinutes())),a===c.getMinutes()&&(i=Math.max(i,c.getSeconds()))}l(n,a,i)}}function g(e){var t=e||p.latestSelectedDateObj;t&&l(t.getHours(),t.getMinutes(),t.getSeconds())}function l(e,t,n){void 0!==p.latestSelectedDateObj&&p.latestSelectedDateObj.setHours(e%24,t,n||0,0),p.hourElement&&p.minuteElement&&!p.isMobile&&(p.hourElement.value=Z(p.config.time_24hr?e:(12+e)%12+12*Q(e%12==0)),p.minuteElement.value=Z(t),void 0!==p.amPM&&(p.amPM.textContent=p.l10n.amPM[Q(12<=e)]),void 0!==p.secondElement&&(p.secondElement.value=Z(n)))}function n(e){var t=parseInt(e.target.value)+(e.delta||0);(1p.now?p.config.minDate:p.config.maxDate&&p.config.maxDate"+p.config.getWeek(t)+""),B("onDayCreate",r),r}function w(e){e.focus(),"range"===p.config.mode&&P(e)}function b(e){for(var t=0=Math.abs(t))return w(s)}p.changeMonth(i),M(b(i),0)}(a,t):w(a)}function c(e,t){for(var n=(new Date(e,t,1).getDay()-p.l10n.firstDayOfWeek+7)%7,a=p.utils.getDaysInMonth((t-1+12)%12),i=p.utils.getDaysInMonth(t),o=window.document.createDocumentFragment(),r=1\n "+t.join("")+"\n \n "}function k(e,t){void 0===t&&(t=!0);var n=t?e:e-p.currentMonth;n<0&&!0===p._hidePrevMonthArrow||0p.config.maxDate.getFullYear())){var t=e,n=p.currentYear!==t;p.currentYear=t||p.currentYear,p.config.maxDate&&p.currentYear===p.config.maxDate.getFullYear()?p.currentMonth=Math.min(p.config.maxDate.getMonth(),p.currentMonth):p.config.minDate&&p.currentYear===p.config.minDate.getFullYear()&&(p.currentMonth=Math.max(p.config.minDate.getMonth(),p.currentMonth)),n&&(p.redraw(),B("onYearChange"))}}function F(e,t){void 0===t&&(t=!0);var n=p.parseDate(e,void 0,t);if(p.config.minDate&&n&&re(n,p.config.minDate,void 0!==t?t:!p.minDateHasTime)<0||p.config.maxDate&&n&&0=a.from.getTime()&&n.getTime()<=a.to.getTime())return i}return!i}function A(e){return void 0!==p.daysContainer&&(-1===e.className.indexOf("hidden")&&p.daysContainer.contains(e))}function _(e){var t=e.target===p._input,n=I(e.target),a=p.config.allowInput,i=p.isOpen&&(!a||!t),o=p.config.inline&&t&&!a;if(13===e.keyCode&&t){if(a)return p.setDate(p._input.value,!0,e.target===p.altInput?p.config.altFormat:p.config.dateFormat),e.target.blur();p.open()}else if(n||i||o){var r=!!p.timeContainer&&p.timeContainer.contains(e.target);switch(e.keyCode){case 13:r?G():R(e);break;case 27:e.preventDefault(),W();break;case 8:case 46:t&&!p.config.allowInput&&(e.preventDefault(),p.clear());break;case 37:case 39:if(r)p.hourElement&&p.hourElement.focus();else if(e.preventDefault(),void 0!==p.daysContainer&&(!1===a||A(document.activeElement))){var c=39===e.keyCode?1:-1;e.ctrlKey?(k(c),M(b(1),0)):M(void 0,c)}break;case 38:case 40:e.preventDefault();var l=40===e.keyCode?1:-1;p.daysContainer?e.ctrlKey?(S(p.currentYear-l),M(b(1),0)):r||M(void 0,7*l):p.config.enableTime&&(!r&&p.hourElement&&p.hourElement.focus(),d(e),p._debouncedChange());break;case 9:if(!r)break;e.target===p.hourElement?(e.preventDefault(),p.minuteElement.select()):e.target===p.minuteElement&&(p.secondElement||p.amPM)?(e.preventDefault(),void 0!==p.secondElement?p.secondElement.focus():void 0!==p.amPM&&(e.preventDefault(),p.amPM.focus())):e.target===p.secondElement&&p.amPM&&(e.preventDefault(),p.amPM.focus())}}if(void 0!==p.amPM&&e.target===p.amPM)switch(e.key){case p.l10n.amPM[0].charAt(0):case p.l10n.amPM[0].charAt(0).toLowerCase():p.amPM.textContent=p.l10n.amPM[0],s(),G();break;case p.l10n.amPM[1].charAt(0):case p.l10n.amPM[1].charAt(0).toLowerCase():p.amPM.textContent=p.l10n.amPM[1],s(),G()}B("onKeyDown",e)}function P(o){if(1===p.selectedDates.length&&o.classList.contains("flatpickr-day")&&!o.classList.contains("disabled")){for(var r=o.dateObj.getTime(),c=p.parseDate(p.selectedDates[0],void 0,!0).getTime(),e=Math.min(r,p.selectedDates[0].getTime()),t=Math.max(r,p.selectedDates[0].getTime()),l=!1,d=0,s=0,n=e;n=a||(cn,s=window.pageYOffset+c.top+(d?-n-2:t.offsetHeight+2);if(de(p.calendarContainer,"arrowTop",!d),de(p.calendarContainer,"arrowBottom",d),!p.config.inline){var u=window.pageXOffset+c.left-(null!=r&&"center"===r?(a-c.width)/2:0),f=window.document.body.offsetWidth-c.right,m=u+a>window.document.body.offsetWidth;de(p.calendarContainer,"rightMost",m),p.config.static||(p.calendarContainer.style.top=s+"px",m?(p.calendarContainer.style.left="auto",p.calendarContainer.style.right=f+"px"):(p.calendarContainer.style.left=u+"px",p.calendarContainer.style.right="auto"))}}}function L(){p.config.noCalendar||p.isMobile||($(),y())}function W(){p._input.focus(),-1!==window.navigator.userAgent.indexOf("MSIE")||void 0!==navigator.msMaxTouchPoints?setTimeout(p.close,0):p.close()}function R(e){e.preventDefault(),e.stopPropagation();var t=function e(t,n){return n(t)?t:t.parentNode?e(t.parentNode,n):void 0}(e.target,function(e){return e.classList&&e.classList.contains("flatpickr-day")&&!e.classList.contains("disabled")&&!e.classList.contains("notAllowed")});if(void 0!==t){var n=t,a=p.latestSelectedDateObj=new Date(n.dateObj.getTime()),i=(a.getMonth()p.currentMonth+p.config.showMonths-1)&&"range"!==p.config.mode;if(p.selectedDateElem=n,"single"===p.config.mode)p.selectedDates=[a];else if("multiple"===p.config.mode){var o=z(a);o?p.selectedDates.splice(parseInt(o),1):p.selectedDates.push(a)}else"range"===p.config.mode&&(2===p.selectedDates.length&&p.clear(!1),p.selectedDates.push(a),0!==re(a,p.selectedDates[0],!0)&&p.selectedDates.sort(function(e,t){return e.getTime()-t.getTime()}));if(s(),i){var r=p.currentYear!==a.getFullYear();p.currentYear=a.getFullYear(),p.currentMonth=a.getMonth(),r&&B("onYearChange"),B("onMonthChange")}if($(),y(),p.config.minDate&&p.minDateHasTime&&p.config.enableTime&&0===re(a,p.config.minDate)&&g(p.config.minDate),G(),p.config.enableTime&&setTimeout(function(){return p.showTimeInput=!0},50),"range"===p.config.mode&&(1===p.selectedDates.length?P(n):$()),i||"range"===p.config.mode||1!==p.config.showMonths?p.selectedDateElem&&p.selectedDateElem.focus():w(n),void 0!==p.hourElement&&setTimeout(function(){return void 0!==p.hourElement&&p.hourElement.select()},451),p.config.closeOnSelect){var c="single"===p.config.mode&&!p.config.enableTime,l="range"===p.config.mode&&2===p.selectedDates.length&&!p.config.enableTime;(c||l)&&W()}h()}}p.parseDate=oe({config:p.config,l10n:p.l10n}),p._handlers=[],p._bind=o,p._setHoursFromDate=g,p.changeMonth=k,p.changeYear=S,p.clear=function(e){void 0===e&&(e=!0);p.input.value="",void 0!==p.altInput&&(p.altInput.value="");void 0!==p.mobileInput&&(p.mobileInput.value="");p.selectedDates=[],p.latestSelectedDateObj=void 0,!(p.showTimeInput=!1)===p.config.enableTime&&(void 0!==p.config.minDate?g(p.config.minDate):l(p.config.defaultHour,p.config.defaultMinute,p.config.defaultSeconds));p.redraw(),e&&B("onChange")},p.close=function(){p.isOpen=!1,p.isMobile||(p.calendarContainer.classList.remove("open"),p._input.classList.remove("active"));B("onClose")},p._createElement=se,p.destroy=function(){void 0!==p.config&&B("onDestroy");for(var e=p._handlers.length;e--;){var t=p._handlers[e];t.element.removeEventListener(t.event,t.handler,t.options)}p._handlers=[],p.mobileInput?(p.mobileInput.parentNode&&p.mobileInput.parentNode.removeChild(p.mobileInput),p.mobileInput=void 0):p.calendarContainer&&p.calendarContainer.parentNode&&p.calendarContainer.parentNode.removeChild(p.calendarContainer);p.altInput&&(p.input.type="text",p.altInput.parentNode&&p.altInput.parentNode.removeChild(p.altInput),delete p.altInput);p.input&&(p.input.type=p.input._type,p.input.classList.remove("flatpickr-input"),p.input.removeAttribute("readonly"),p.input.value="");["_showTimeInput","latestSelectedDateObj","_hideNextMonthArrow","_hidePrevMonthArrow","__hideNextMonthArrow","__hidePrevMonthArrow","isMobile","isOpen","selectedDateElem","minDateHasTime","maxDateHasTime","days","daysContainer","_input","_positionElement","innerContainer","rContainer","monthNav","todayDateElem","calendarContainer","weekdayContainer","prevMonthNav","nextMonthNav","currentMonthElement","currentYearElement","navigationCurrentMonth","selectedDateElem","config"].forEach(function(e){try{delete p[e]}catch(e){}})},p.isEnabled=F,p.jumpToDate=i,p.open=function(e,t){void 0===t&&(t=p._input);if(!0===p.isMobile)return e&&(e.preventDefault(),e.target&&e.target.blur()),setTimeout(function(){void 0!==p.mobileInput&&p.mobileInput.focus()},0),void B("onOpen");if(p._input.disabled||p.config.inline)return;var n=p.isOpen;p.isOpen=!0,n||(p.calendarContainer.classList.add("open"),p._input.classList.add("active"),B("onOpen"),H(t));!0===p.config.enableTime&&!0===p.config.noCalendar&&(0===p.selectedDates.length&&(p.setDate(void 0!==p.config.minDate?new Date(p.config.minDate.getTime()):(new Date).setHours(p.config.defaultHour,p.config.defaultMinute,p.config.defaultSeconds,0),!1),s(),G()),!1!==p.config.allowInput||void 0!==e&&p.timeContainer.contains(e.relatedTarget)||setTimeout(function(){return p.hourElement.select()},50))},p.redraw=L,p.set=function(e,t){null!==e&&"object"==typeof e?Object.assign(p.config,e):(p.config[e]=t,void 0!==q[e]&&q[e].forEach(function(e){return e()}));p.redraw(),i()},p.setDate=function(e,t,n){void 0===t&&(t=!1);void 0===n&&(n=p.config.dateFormat);if(0!==e&&!e)return p.clear(t);J(e,n),p.showTimeInput=0p.config.maxDate.getMonth():p.currentYear>p.config.maxDate.getFullYear()))}function G(e){if(void 0===e&&(e=!0),0===p.selectedDates.length)return p.clear(e);void 0!==p.mobileInput&&p.mobileFormatStr&&(p.mobileInput.value=void 0!==p.latestSelectedDateObj?p.formatDate(p.latestSelectedDateObj,p.mobileFormatStr):"");var t="range"!==p.config.mode?p.config.conjunction:p.l10n.rangeSeparator;p.input.value=p.selectedDates.map(function(e){return p.formatDate(e,p.config.dateFormat)}).join(t),void 0!==p.altInput&&(p.altInput.value=p.selectedDates.map(function(e){return p.formatDate(e,p.config.altFormat)}).join(t)),!1!==e&&B("onValueUpdate")}function V(e){e.preventDefault();var t=p.prevMonthNav.contains(e.target),n=p.nextMonthNav.contains(e.target);t||n?k(t?-1:1):0<=p.yearElements.indexOf(e.target)?e.target.select():e.target.classList.contains("arrowUp")?p.changeYear(p.currentYear+1):e.target.classList.contains("arrowDown")&&p.changeYear(p.currentYear-1)}return function(){p.element=p.input=u,p.isOpen=!1,function(){var e=["wrap","weekNumbers","allowInput","clickOpens","time_24hr","enableTime","noCalendar","altInput","shorthandCurrentMonth","inline","static","enableSeconds","disableMobile"],t=["onChange","onClose","onDayCreate","onDestroy","onKeyDown","onMonthChange","onOpen","onParseConfig","onReady","onValueUpdate","onYearChange","onPreCalendarPosition"],n=Object.assign({},f,JSON.parse(JSON.stringify(u.dataset||{}))),a={};p.config.parseDate=n.parseDate,p.config.formatDate=n.formatDate,Object.defineProperty(p.config,"enable",{get:function(){return p.config._enable},set:function(e){p.config._enable=K(e)}}),Object.defineProperty(p.config,"disable",{get:function(){return p.config._disable},set:function(e){p.config._disable=K(e)}});var i="time"===n.mode;n.dateFormat||!n.enableTime&&!i||(a.dateFormat=n.noCalendar||i?"H:i"+(n.enableSeconds?":S":""):ge.defaultConfig.dateFormat+" H:i"+(n.enableSeconds?":S":"")),n.altInput&&(n.enableTime||i)&&!n.altFormat&&(a.altFormat=n.noCalendar||i?"h:i"+(n.enableSeconds?":S K":" K"):ge.defaultConfig.altFormat+" h:i"+(n.enableSeconds?":S":"")+" K"),Object.defineProperty(p.config,"minDate",{get:function(){return p.config._minDate},set:Y("min")}),Object.defineProperty(p.config,"maxDate",{get:function(){return p.config._maxDate},set:Y("max")});var o=function(t){return function(e){p.config["min"===t?"_minTime":"_maxTime"]=p.parseDate(e,"H:i")}};Object.defineProperty(p.config,"minTime",{get:function(){return p.config._minTime},set:o("min")}),Object.defineProperty(p.config,"maxTime",{get:function(){return p.config._maxTime},set:o("max")}),"time"===n.mode&&(p.config.noCalendar=!0,p.config.enableTime=!0),Object.assign(p.config,a,n);for(var r=0;rp.now.getTime()?p.config.minDate:p.config.maxDate&&p.config.maxDate.getTime()