@websy/websy-designs 1.2.4 → 1.2.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/dist/server/websy-designs-server.js +4 -4
- package/dist/websy-designs-es6.debug.js +498 -26
- package/dist/websy-designs-es6.js +528 -169
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +453 -25
- package/dist/websy-designs.js +513 -141
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/package.json +4 -5
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
WebsyCarousel
|
|
27
27
|
WebsyLogin
|
|
28
28
|
WebsySignup
|
|
29
|
+
ResponsiveText
|
|
29
30
|
Pager
|
|
30
31
|
*/
|
|
31
32
|
|
|
@@ -400,6 +401,8 @@ class WebsyDatePicker {
|
|
|
400
401
|
minAllowedYear: 1970,
|
|
401
402
|
maxAllowedYear: new Date().getFullYear(),
|
|
402
403
|
daysOfWeek: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
|
|
404
|
+
monthsOfYear: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
|
405
|
+
hours: new Array(24).fill(0).map((d, i) => (i < 10 ? '0' : '') + i + ':00'),
|
|
403
406
|
mode: 'date',
|
|
404
407
|
monthMap: {
|
|
405
408
|
0: 'Jan',
|
|
@@ -465,7 +468,26 @@ class WebsyDatePicker {
|
|
|
465
468
|
label: 'Last 10 Years',
|
|
466
469
|
range: [new Date().getFullYear() - 9, DEFAULTS.maxAllowedYear]
|
|
467
470
|
}
|
|
468
|
-
]
|
|
471
|
+
],
|
|
472
|
+
monthyear: [
|
|
473
|
+
{
|
|
474
|
+
label: 'All',
|
|
475
|
+
range: [DEFAULTS.minAllowedDate, DEFAULTS.maxAllowedDate]
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
label: 'Last 12 Months',
|
|
479
|
+
range: [this.floorDate(new Date(new Date(new Date().setDate(1)).setMonth(new Date().getMonth() - 12))), this.floorDate(new Date(new Date().setDate(1)))]
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
label: 'Last 18 Months',
|
|
483
|
+
range: [this.floorDate(new Date(new Date(new Date().setDate(1)).setMonth(new Date().getMonth() - 18))), this.floorDate(new Date(new Date().setDate(1)))]
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
label: 'Last 24 Months',
|
|
487
|
+
range: [this.floorDate(new Date(new Date(new Date().setDate(1)).setMonth(new Date().getMonth() - 24))), this.floorDate(new Date(new Date().setDate(1)))]
|
|
488
|
+
}
|
|
489
|
+
],
|
|
490
|
+
hour: []
|
|
469
491
|
}
|
|
470
492
|
this.options = Object.assign({}, DEFAULTS, options)
|
|
471
493
|
this.selectedRange = this.options.defaultRange || 0
|
|
@@ -487,7 +509,7 @@ class WebsyDatePicker {
|
|
|
487
509
|
document.addEventListener('keydown', this.handleKeyDown.bind(this))
|
|
488
510
|
document.addEventListener('keyup', this.handleKeyUp.bind(this))
|
|
489
511
|
let html = `
|
|
490
|
-
<div class='websy-date-picker-container'>
|
|
512
|
+
<div class='websy-date-picker-container ${this.options.mode}'>
|
|
491
513
|
<span class='websy-dropdown-header-label'>${this.options.label || 'Date'}</span>
|
|
492
514
|
<div id="${this.elementId}_header" class='websy-date-picker-header ${this.options.allowClear === true ? 'allow-clear' : ''}'>
|
|
493
515
|
<span id='${this.elementId}_selectedRange'>${this.options.ranges[this.options.mode][this.selectedRange].label}</span>
|
|
@@ -538,6 +560,8 @@ class WebsyDatePicker {
|
|
|
538
560
|
contentEl.classList.remove('active')
|
|
539
561
|
if (confirm === true) {
|
|
540
562
|
if (this.options.onChange) {
|
|
563
|
+
console.log('confirm', this.selectedRangeDates)
|
|
564
|
+
console.log('confirm', this.currentselection)
|
|
541
565
|
if (this.customRangeSelected === true) {
|
|
542
566
|
this.options.onChange(this.selectedRangeDates, true)
|
|
543
567
|
}
|
|
@@ -607,7 +631,7 @@ class WebsyDatePicker {
|
|
|
607
631
|
handleMouseDown (event) {
|
|
608
632
|
if (this.shiftPressed === true && this.currentselection.length > 0) {
|
|
609
633
|
this.mouseDownId = this.currentselection[this.currentselection.length - 1]
|
|
610
|
-
this.selectDate(+event.target.id.split('_')[
|
|
634
|
+
this.selectDate(+event.target.id.split('_')[1])
|
|
611
635
|
}
|
|
612
636
|
else {
|
|
613
637
|
this.mouseDown = true
|
|
@@ -620,7 +644,7 @@ class WebsyDatePicker {
|
|
|
620
644
|
this.currentselection = []
|
|
621
645
|
this.customRangeSelected = false
|
|
622
646
|
}
|
|
623
|
-
this.mouseDownId = +event.target.id.split('_')[
|
|
647
|
+
this.mouseDownId = +event.target.id.split('_')[1]
|
|
624
648
|
this.selectDate(this.mouseDownId)
|
|
625
649
|
}
|
|
626
650
|
}
|
|
@@ -631,9 +655,9 @@ class WebsyDatePicker {
|
|
|
631
655
|
if (event.target.classList.contains('websy-disabled-date')) {
|
|
632
656
|
return
|
|
633
657
|
}
|
|
634
|
-
if (event.target.id.split('_')[
|
|
658
|
+
if (event.target.id.split('_')[1] !== this.mouseDownId) {
|
|
635
659
|
this.dragging = true
|
|
636
|
-
this.selectDate(+event.target.id.split('_')[
|
|
660
|
+
this.selectDate(+event.target.id.split('_')[1])
|
|
637
661
|
}
|
|
638
662
|
}
|
|
639
663
|
}
|
|
@@ -655,7 +679,8 @@ class WebsyDatePicker {
|
|
|
655
679
|
return
|
|
656
680
|
}
|
|
657
681
|
if (this.customRangeSelected === true) {
|
|
658
|
-
console.log('if date selection', this.currentselection)
|
|
682
|
+
console.log('if date selection', this.currentselection)
|
|
683
|
+
console.log('if month selection', this.currentselection.map(d => new Date(d)))
|
|
659
684
|
let diff
|
|
660
685
|
if (this.options.mode === 'date') {
|
|
661
686
|
diff = Math.floor((this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime() - this.selectedRangeDates[0].getTime()) / this.oneDay)
|
|
@@ -669,6 +694,15 @@ class WebsyDatePicker {
|
|
|
669
694
|
// diff += 1
|
|
670
695
|
}
|
|
671
696
|
}
|
|
697
|
+
else if (this.options.mode === 'monthyear') {
|
|
698
|
+
let yearDiff = (this.selectedRangeDates[this.selectedRangeDates.length - 1].getFullYear() - this.selectedRangeDates[0].getFullYear()) * 12
|
|
699
|
+
diff = Math.floor((this.selectedRangeDates[this.selectedRangeDates.length - 1].getMonth() - this.selectedRangeDates[0].getMonth())) + yearDiff
|
|
700
|
+
console.log('year diff', yearDiff)
|
|
701
|
+
console.log('diff', diff)
|
|
702
|
+
}
|
|
703
|
+
else if (this.options.mode === 'hour') {
|
|
704
|
+
//
|
|
705
|
+
}
|
|
672
706
|
for (let i = 0; i < diff + 1; i++) {
|
|
673
707
|
let d
|
|
674
708
|
let rangeStart
|
|
@@ -684,12 +718,29 @@ class WebsyDatePicker {
|
|
|
684
718
|
rangeStart = this.selectedRangeDates[0]
|
|
685
719
|
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1]
|
|
686
720
|
}
|
|
721
|
+
else if (this.options.mode === 'monthyear') {
|
|
722
|
+
d = new Date(this.selectedRangeDates[0].getTime()).setMonth(this.selectedRangeDates[0].getMonth() + i)
|
|
723
|
+
rangeStart = this.selectedRangeDates[0].getTime()
|
|
724
|
+
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime()
|
|
725
|
+
}
|
|
726
|
+
else if (this.options.mode === 'hour') {
|
|
727
|
+
//
|
|
728
|
+
}
|
|
687
729
|
let dateEl
|
|
688
730
|
if (this.options.mode === 'date') {
|
|
689
|
-
dateEl = document.getElementById(`${d}_date`)
|
|
731
|
+
dateEl = document.getElementById(`${this.elementId}_${d}_date`)
|
|
690
732
|
}
|
|
691
733
|
else if (this.options.mode === 'year') {
|
|
692
|
-
dateEl = document.getElementById(`${d}_year`)
|
|
734
|
+
dateEl = document.getElementById(`${this.elementId}_${d}_year`)
|
|
735
|
+
}
|
|
736
|
+
else if (this.options.mode === 'monthyear') {
|
|
737
|
+
console.log('d', d)
|
|
738
|
+
console.log(this.selectedRangeDates)
|
|
739
|
+
console.log(rangeStart, rangeEnd)
|
|
740
|
+
dateEl = document.getElementById(`${this.elementId}_${d}_monthyear`)
|
|
741
|
+
}
|
|
742
|
+
else if (this.options.mode === 'hour') {
|
|
743
|
+
//
|
|
693
744
|
}
|
|
694
745
|
if (dateEl) {
|
|
695
746
|
dateEl.classList.add('selected')
|
|
@@ -706,10 +757,16 @@ class WebsyDatePicker {
|
|
|
706
757
|
this.currentselection.forEach(d => {
|
|
707
758
|
let dateEl
|
|
708
759
|
if (this.options.mode === 'date') {
|
|
709
|
-
dateEl = document.getElementById(`${d}_date`)
|
|
760
|
+
dateEl = document.getElementById(`${this.elementId}_${d}_date`)
|
|
710
761
|
}
|
|
711
762
|
else if (this.options.mode === 'year') {
|
|
712
|
-
dateEl = document.getElementById(`${d}_year`)
|
|
763
|
+
dateEl = document.getElementById(`${this.elementId}_${d}_year`)
|
|
764
|
+
}
|
|
765
|
+
else if (this.options.mode === 'monthyear') {
|
|
766
|
+
dateEl = document.getElementById(`${this.elementId}_${d}_monthyear`)
|
|
767
|
+
}
|
|
768
|
+
else if (this.options.mode === 'hour') {
|
|
769
|
+
//
|
|
713
770
|
}
|
|
714
771
|
dateEl.classList.add('selected')
|
|
715
772
|
dateEl.classList.add('first')
|
|
@@ -751,6 +808,8 @@ class WebsyDatePicker {
|
|
|
751
808
|
let disabled = []
|
|
752
809
|
this.validDates = []
|
|
753
810
|
this.validYears = []
|
|
811
|
+
this.monthYears = {}
|
|
812
|
+
this.monthYearMonths = []
|
|
754
813
|
if (disabledDates) {
|
|
755
814
|
disabled = disabledDates.map(d => {
|
|
756
815
|
if (this.options.mode === 'date') {
|
|
@@ -759,6 +818,12 @@ class WebsyDatePicker {
|
|
|
759
818
|
else if (this.options.mode === 'year') {
|
|
760
819
|
return d
|
|
761
820
|
}
|
|
821
|
+
else if (this.options.mode === 'monthyear') {
|
|
822
|
+
//
|
|
823
|
+
}
|
|
824
|
+
else if (this.options.mode === 'hour') {
|
|
825
|
+
//
|
|
826
|
+
}
|
|
762
827
|
return d.getTime()
|
|
763
828
|
})
|
|
764
829
|
}
|
|
@@ -771,15 +836,34 @@ class WebsyDatePicker {
|
|
|
771
836
|
else if (this.options.mode === 'year') {
|
|
772
837
|
diff = (this.options.maxAllowedYear - this.options.minAllowedYear) + 1
|
|
773
838
|
}
|
|
839
|
+
else if (this.options.mode === 'monthyear') {
|
|
840
|
+
diff = Math.ceil((this.options.maxAllowedDate.getTime() - this.options.minAllowedDate.getTime()) / this.oneDay) + 1
|
|
841
|
+
}
|
|
842
|
+
else if (this.options.mode === 'hour') {
|
|
843
|
+
//
|
|
844
|
+
}
|
|
774
845
|
let months = {}
|
|
775
846
|
let yearList = []
|
|
776
847
|
for (let i = 0; i < diff; i++) {
|
|
777
|
-
if (this.options.mode === 'date') {
|
|
848
|
+
if (this.options.mode === 'date' || this.options.mode === 'monthyear') {
|
|
778
849
|
let d = this.floorDate(new Date(this.options.minAllowedDate.getTime() + (i * this.oneDay)))
|
|
779
850
|
let monthYear = `${this.options.monthMap[d.getMonth()]} ${d.getFullYear()}`
|
|
780
851
|
if (!months[monthYear]) {
|
|
781
852
|
months[monthYear] = []
|
|
782
853
|
}
|
|
854
|
+
if (!this.monthYears[d.getFullYear()]) {
|
|
855
|
+
this.monthYears[d.getFullYear()] = []
|
|
856
|
+
}
|
|
857
|
+
if (this.monthYearMonths.indexOf(`${d.getMonth()}-${d.getFullYear()}`) === -1) {
|
|
858
|
+
this.monthYearMonths.push(`${d.getMonth()}-${d.getFullYear()}`)
|
|
859
|
+
this.monthYears[d.getFullYear()].push({
|
|
860
|
+
date: new Date(d.setDate(1)),
|
|
861
|
+
month: this.options.monthMap[d.getMonth()],
|
|
862
|
+
monthNum: d.getMonth(),
|
|
863
|
+
year: d.getFullYear(),
|
|
864
|
+
id: d.setDate(1)
|
|
865
|
+
})
|
|
866
|
+
}
|
|
783
867
|
if (disabled.indexOf(d.getTime()) === -1) {
|
|
784
868
|
this.validDates.push(d.getTime())
|
|
785
869
|
}
|
|
@@ -792,11 +876,14 @@ class WebsyDatePicker {
|
|
|
792
876
|
this.validYears.push(d)
|
|
793
877
|
}
|
|
794
878
|
}
|
|
879
|
+
else if (this.options.mode === 'hour') {
|
|
880
|
+
//
|
|
881
|
+
}
|
|
795
882
|
}
|
|
796
883
|
// check each range to see if it can be enabled
|
|
797
884
|
for (let i = 0; i < this.options.ranges[this.options.mode].length; i++) {
|
|
798
885
|
const r = this.options.ranges[this.options.mode][i]
|
|
799
|
-
if (this.options.mode === 'date') {
|
|
886
|
+
if (this.options.mode === 'date' || this.options.mode === 'monthyear') {
|
|
800
887
|
// check the first date
|
|
801
888
|
if (this.validDates.indexOf(r.range[0].getTime()) !== -1) {
|
|
802
889
|
r.disabled = false
|
|
@@ -836,6 +923,12 @@ class WebsyDatePicker {
|
|
|
836
923
|
}
|
|
837
924
|
}
|
|
838
925
|
}
|
|
926
|
+
}
|
|
927
|
+
else if (this.options.mode === 'monthyear') {
|
|
928
|
+
//
|
|
929
|
+
}
|
|
930
|
+
else if (this.options.mode === 'hour') {
|
|
931
|
+
//
|
|
839
932
|
}
|
|
840
933
|
}
|
|
841
934
|
let html = ''
|
|
@@ -861,7 +954,7 @@ class WebsyDatePicker {
|
|
|
861
954
|
}
|
|
862
955
|
html += paddedDays.join('')
|
|
863
956
|
}
|
|
864
|
-
html += months[key].map(d => `<li id='${d.id}_date' class='websy-dp-date ${d.disabled === true ? 'websy-disabled-date' : ''}'>${d.dayOfMonth}</li>`).join('')
|
|
957
|
+
html += months[key].map(d => `<li id='${this.elementId}_${d.id}_date' class='websy-dp-date ${d.disabled === true ? 'websy-disabled-date' : ''}'>${d.dayOfMonth}</li>`).join('')
|
|
865
958
|
html += `
|
|
866
959
|
</ul>
|
|
867
960
|
</div>
|
|
@@ -874,8 +967,30 @@ class WebsyDatePicker {
|
|
|
874
967
|
yearList.reverse()
|
|
875
968
|
}
|
|
876
969
|
html += `<div id='${this.elementId}_dateList' class='websy-dp-date-list'><ul>`
|
|
877
|
-
html += yearList.map(d => `<li id='${d.id}_year' class='websy-dp-date websy-dp-year ${d.disabled === true ? 'websy-disabled-date' : ''}'>${d.year}</li>`).join('')
|
|
970
|
+
html += yearList.map(d => `<li id='${this.elementId}_${d.id}_year' class='websy-dp-date websy-dp-year ${d.disabled === true ? 'websy-disabled-date' : ''}'>${d.year}</li>`).join('')
|
|
878
971
|
html += `</ul></div>`
|
|
972
|
+
}
|
|
973
|
+
else if (this.options.mode === 'monthyear') {
|
|
974
|
+
html += `<div id='${this.elementId}_dateList' class='websy-dp-monthyear-container'>`
|
|
975
|
+
for (const year in this.monthYears) {
|
|
976
|
+
html += `
|
|
977
|
+
<ul>
|
|
978
|
+
<li>${year}</li>
|
|
979
|
+
`
|
|
980
|
+
if (this.monthYears[year][0].monthNum > 0) {
|
|
981
|
+
let paddedMonths = []
|
|
982
|
+
for (let i = 0; i < this.monthYears[year][0].monthNum; i++) {
|
|
983
|
+
paddedMonths.push(`<li> </li>`)
|
|
984
|
+
}
|
|
985
|
+
html += paddedMonths.join('')
|
|
986
|
+
}
|
|
987
|
+
html += this.monthYears[year].map(d => `<li id='${this.elementId}_${d.id}_monthyear' data-year='${d.year}' class='websy-dp-date websy-dp-monthyear'>${d.month}</li>`).join('')
|
|
988
|
+
html += `</ul>`
|
|
989
|
+
}
|
|
990
|
+
html += `</div>`
|
|
991
|
+
}
|
|
992
|
+
else if (this.options.mode === 'hour') {
|
|
993
|
+
//
|
|
879
994
|
}
|
|
880
995
|
return html
|
|
881
996
|
}
|
|
@@ -888,16 +1003,22 @@ class WebsyDatePicker {
|
|
|
888
1003
|
if (this.selectedRangeDates[0]) {
|
|
889
1004
|
let el
|
|
890
1005
|
if (this.options.mode === 'date') {
|
|
891
|
-
el = document.getElementById(`${this.selectedRangeDates[0].getTime()}_date`)
|
|
1006
|
+
el = document.getElementById(`${this.elementId}_${this.selectedRangeDates[0].getTime()}_date`)
|
|
892
1007
|
}
|
|
893
1008
|
else if (this.options.mode === 'year') {
|
|
894
1009
|
if (this.options.sortDirection === 'desc') {
|
|
895
|
-
el = document.getElementById(`${this.selectedRangeDates[this.selectedRangeDates.length - 1]}_year`)
|
|
1010
|
+
el = document.getElementById(`${this.elementId}_${this.selectedRangeDates[this.selectedRangeDates.length - 1]}_year`)
|
|
896
1011
|
}
|
|
897
1012
|
else {
|
|
898
|
-
el = document.getElementById(`${this.selectedRangeDates[0]}_year`)
|
|
1013
|
+
el = document.getElementById(`${this.elementId}_${this.selectedRangeDates[0]}_year`)
|
|
899
1014
|
}
|
|
900
1015
|
}
|
|
1016
|
+
else if (this.options.mode === 'monthyear') {
|
|
1017
|
+
//
|
|
1018
|
+
}
|
|
1019
|
+
else if (this.options.mode === 'hour') {
|
|
1020
|
+
//
|
|
1021
|
+
}
|
|
901
1022
|
const parentEl = document.getElementById(`${this.elementId}_dateList`)
|
|
902
1023
|
if (el && parentEl) {
|
|
903
1024
|
parentEl.scrollTo(0, el.offsetTop)
|
|
@@ -918,6 +1039,7 @@ class WebsyDatePicker {
|
|
|
918
1039
|
this.currentselection.splice(0, 0, timestamp)
|
|
919
1040
|
}
|
|
920
1041
|
this.customRangeSelected = true
|
|
1042
|
+
console.log('current selection', this.currentselection)
|
|
921
1043
|
}
|
|
922
1044
|
else {
|
|
923
1045
|
this.currentselection.push(timestamp)
|
|
@@ -925,12 +1047,19 @@ class WebsyDatePicker {
|
|
|
925
1047
|
this.customRangeSelected = false
|
|
926
1048
|
}
|
|
927
1049
|
}
|
|
928
|
-
if (this.options.mode === 'date') {
|
|
1050
|
+
if (this.options.mode === 'date' || this.options.mode === 'monthyear') {
|
|
929
1051
|
this.selectedRangeDates = [new Date(this.currentselection[0]), new Date(this.currentselection[1] || this.currentselection[0])]
|
|
1052
|
+
console.log('selected range', this.selectedRangeDates)
|
|
930
1053
|
}
|
|
931
1054
|
else if (this.options.mode === 'year') {
|
|
932
1055
|
this.selectedRangeDates = [this.currentselection[0], this.currentselection[1] || this.currentselection[0]]
|
|
933
1056
|
}
|
|
1057
|
+
else if (this.options.mode === 'monthyear') {
|
|
1058
|
+
//
|
|
1059
|
+
}
|
|
1060
|
+
else if (this.options.mode === 'hour') {
|
|
1061
|
+
//
|
|
1062
|
+
}
|
|
934
1063
|
// if (this.currentselection.length === 2) {
|
|
935
1064
|
// this.currentselection = []
|
|
936
1065
|
// }
|
|
@@ -977,7 +1106,7 @@ class WebsyDatePicker {
|
|
|
977
1106
|
this.updateRange()
|
|
978
1107
|
}
|
|
979
1108
|
setDateBounds (range) {
|
|
980
|
-
if (['All Dates', 'All Years'].indexOf(this.options.ranges[this.options.mode][0].label) !== -1) {
|
|
1109
|
+
if (['All Dates', 'All Years', 'All'].indexOf(this.options.ranges[this.options.mode][0].label) !== -1) {
|
|
981
1110
|
this.options.ranges[this.options.mode][0].range = [range[0], range[1] || range[0]]
|
|
982
1111
|
}
|
|
983
1112
|
if (this.options.mode === 'date') {
|
|
@@ -987,6 +1116,13 @@ class WebsyDatePicker {
|
|
|
987
1116
|
else if (this.options.mode === 'year') {
|
|
988
1117
|
this.options.minAllowedYear = range[0]
|
|
989
1118
|
this.options.maxAllowedYear = range[1] || range[0]
|
|
1119
|
+
}
|
|
1120
|
+
else if (this.options.mode === 'monthyear') {
|
|
1121
|
+
this.options.minAllowedDate = range[0]
|
|
1122
|
+
this.options.maxAllowedDate = range[1] || range[0]
|
|
1123
|
+
}
|
|
1124
|
+
else if (this.options.mode === 'hour') {
|
|
1125
|
+
//
|
|
990
1126
|
}
|
|
991
1127
|
}
|
|
992
1128
|
updateRange () {
|
|
@@ -1002,6 +1138,15 @@ class WebsyDatePicker {
|
|
|
1002
1138
|
else if (this.options.mode === 'year') {
|
|
1003
1139
|
return d
|
|
1004
1140
|
}
|
|
1141
|
+
else if (this.options.mode === 'monthyear') {
|
|
1142
|
+
if (!d.getMonth) {
|
|
1143
|
+
d = new Date(d)
|
|
1144
|
+
}
|
|
1145
|
+
return `${this.options.monthMap[d.getMonth()]} ${d.getFullYear()}`
|
|
1146
|
+
}
|
|
1147
|
+
else if (this.options.mode === 'hour') {
|
|
1148
|
+
//
|
|
1149
|
+
}
|
|
1005
1150
|
})
|
|
1006
1151
|
let start = list[0]
|
|
1007
1152
|
let end = ''
|
|
@@ -1048,7 +1193,8 @@ class WebsyDropdown {
|
|
|
1048
1193
|
disabled: false,
|
|
1049
1194
|
minSearchCharacters: 2,
|
|
1050
1195
|
showCompleteSelectedList: false,
|
|
1051
|
-
closeAfterSelection: true
|
|
1196
|
+
closeAfterSelection: true,
|
|
1197
|
+
customActions: []
|
|
1052
1198
|
}
|
|
1053
1199
|
this.options = Object.assign({}, DEFAULTS, options)
|
|
1054
1200
|
if (this.options.items.length > 0) {
|
|
@@ -1074,7 +1220,7 @@ class WebsyDropdown {
|
|
|
1074
1220
|
const headerLabel = this.selectedItems.map(s => this.options.items[s].label || this.options.items[s].value).join(this.options.multiValueDelimiter)
|
|
1075
1221
|
const headerValue = this.selectedItems.map(s => this.options.items[s].value || this.options.items[s].label).join(this.options.multiValueDelimiter)
|
|
1076
1222
|
let html = `
|
|
1077
|
-
<div id='${this.elementId}_container' class='websy-dropdown-container ${this.options.disabled ? 'disabled' : ''} ${this.options.disableSearch !== true ? 'with-search' : ''} ${this.options.style}'>
|
|
1223
|
+
<div id='${this.elementId}_container' class='websy-dropdown-container ${this.options.disabled ? 'disabled' : ''} ${this.options.disableSearch !== true ? 'with-search' : ''} ${this.options.style} ${this.options.customActions.length > 0 ? 'with-actions' : ''}'>
|
|
1078
1224
|
<div id='${this.elementId}_header' class='websy-dropdown-header ${this.selectedItems.length === 1 ? 'one-selected' : ''} ${this.options.allowClear === true ? 'allow-clear' : ''}'>
|
|
1079
1225
|
<svg class='search' width="20" height="20" viewBox="0 0 512 512"><path d="M221.09,64A157.09,157.09,0,1,0,378.18,221.09,157.1,157.1,0,0,0,221.09,64Z" style="fill:none;stroke:#000;stroke-miterlimit:10;stroke-width:32px"/><line x1="338.29" y1="338.29" x2="448" y2="448" style="fill:none;stroke:#000;stroke-linecap:round;stroke-miterlimit:10;stroke-width:32px"/></svg>
|
|
1080
1226
|
<span id='${this.elementId}_headerLabel' class='websy-dropdown-header-label'>${this.options.label}</span>
|
|
@@ -1092,6 +1238,24 @@ class WebsyDropdown {
|
|
|
1092
1238
|
<div id='${this.elementId}_mask' class='websy-dropdown-mask'></div>
|
|
1093
1239
|
<div id='${this.elementId}_content' class='websy-dropdown-content'>
|
|
1094
1240
|
`
|
|
1241
|
+
if (this.options.customActions.length > 0) {
|
|
1242
|
+
html += `
|
|
1243
|
+
<div class='websy-dropdown-action-container'>
|
|
1244
|
+
<button class='websy-dropdown-action-button'>
|
|
1245
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 512 512">><circle cx="256" cy="256" r="32" style="fill:none;stroke:#000;stroke-miterlimit:10;stroke-width:32px"/><circle cx="416" cy="256" r="32" style="fill:none;stroke:#000;stroke-miterlimit:10;stroke-width:32px"/><circle cx="96" cy="256" r="32" style="fill:none;stroke:#000;stroke-miterlimit:10;stroke-width:32px"/></svg>
|
|
1246
|
+
</button>
|
|
1247
|
+
<ul id='${this.elementId}_actionContainer'>
|
|
1248
|
+
`
|
|
1249
|
+
this.options.customActions.forEach((a, i) => {
|
|
1250
|
+
html += `
|
|
1251
|
+
<li class='websy-dropdown-custom-action' data-index='${i}'>${a.label}</li>
|
|
1252
|
+
`
|
|
1253
|
+
})
|
|
1254
|
+
html += `
|
|
1255
|
+
</ul>
|
|
1256
|
+
</div>
|
|
1257
|
+
`
|
|
1258
|
+
}
|
|
1095
1259
|
if (this.options.disableSearch !== true) {
|
|
1096
1260
|
html += `
|
|
1097
1261
|
<input id='${this.elementId}_search' class='websy-dropdown-search' placeholder='${this.options.searchPlaceholder || 'Search'}'>
|
|
@@ -1153,6 +1317,10 @@ class WebsyDropdown {
|
|
|
1153
1317
|
const maskEl = document.getElementById(`${this.elementId}_mask`)
|
|
1154
1318
|
const contentEl = document.getElementById(`${this.elementId}_content`)
|
|
1155
1319
|
const scrollEl = document.getElementById(`${this.elementId}_itemsContainer`)
|
|
1320
|
+
const actionEl = document.getElementById(`${this.elementId}_actionContainer`)
|
|
1321
|
+
if (actionEl) {
|
|
1322
|
+
actionEl.classList.remove('active')
|
|
1323
|
+
}
|
|
1156
1324
|
const el = document.getElementById(this.elementId)
|
|
1157
1325
|
if (el) {
|
|
1158
1326
|
el.style.zIndex = ''
|
|
@@ -1193,6 +1361,18 @@ class WebsyDropdown {
|
|
|
1193
1361
|
const el = document.getElementById(`${this.elementId}_container`)
|
|
1194
1362
|
el.classList.toggle('search-open')
|
|
1195
1363
|
}
|
|
1364
|
+
else if (event.target.classList.contains('websy-dropdown-custom-action')) {
|
|
1365
|
+
const actionIndex = +event.target.getAttribute('data-index')
|
|
1366
|
+
if (this.options.customActions[actionIndex] && this.options.customActions[actionIndex].fn) {
|
|
1367
|
+
this.options.customActions[actionIndex].fn()
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
else if (event.target.classList.contains('websy-dropdown-action-button')) {
|
|
1371
|
+
const el = document.getElementById(`${this.elementId}_actionContainer`)
|
|
1372
|
+
if (el) {
|
|
1373
|
+
el.classList.toggle('active')
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1196
1376
|
}
|
|
1197
1377
|
handleKeyUp (event) {
|
|
1198
1378
|
if (event.target.classList.contains('websy-dropdown-search')) {
|
|
@@ -2429,6 +2609,250 @@ class WebsyPubSub {
|
|
|
2429
2609
|
}
|
|
2430
2610
|
}
|
|
2431
2611
|
|
|
2612
|
+
class ResponsiveText {
|
|
2613
|
+
constructor (elementId, options) {
|
|
2614
|
+
const DEFAULTS = {
|
|
2615
|
+
textAlign: 'center',
|
|
2616
|
+
verticalAlign: 'flex-end',
|
|
2617
|
+
wrapText: false
|
|
2618
|
+
}
|
|
2619
|
+
this.options = Object.assign({}, DEFAULTS, options)
|
|
2620
|
+
this.elementId = elementId
|
|
2621
|
+
this.canvas = document.createElement('canvas')
|
|
2622
|
+
window.addEventListener('resize', () => this.render())
|
|
2623
|
+
const el = document.getElementById(this.elementId)
|
|
2624
|
+
if (el) {
|
|
2625
|
+
this.render()
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
css (element, property) {
|
|
2629
|
+
return window.getComputedStyle(element, null).getPropertyValue(property)
|
|
2630
|
+
}
|
|
2631
|
+
render (text) {
|
|
2632
|
+
if (typeof text !== 'undefined') {
|
|
2633
|
+
this.options.text = text
|
|
2634
|
+
}
|
|
2635
|
+
if (this.options.text) {
|
|
2636
|
+
let wrappingRequired = false
|
|
2637
|
+
const el = document.getElementById(this.elementId)
|
|
2638
|
+
let cx = this.canvas.getContext('2d')
|
|
2639
|
+
let f = 0
|
|
2640
|
+
let fits = false
|
|
2641
|
+
// let el = document.getElementById(`${layout.qInfo.qId}_responsiveInner`)
|
|
2642
|
+
let height = el.clientHeight
|
|
2643
|
+
if (typeof this.options.maxHeight === 'string' && this.options.maxHeight.indexOf('%') !== -1) {
|
|
2644
|
+
let p = +this.options.maxHeight.replace('%', '')
|
|
2645
|
+
if (!isNaN(p)) {
|
|
2646
|
+
this.options.maxHeight = Math.floor(height * (p / 100))
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
else if (
|
|
2650
|
+
typeof this.options.maxHeight === 'string' &&
|
|
2651
|
+
this.options.maxHeight.indexOf('px') !== -1
|
|
2652
|
+
) {
|
|
2653
|
+
this.options.maxHeight = +this.options.maxHeight.replace('px', '')
|
|
2654
|
+
}
|
|
2655
|
+
if (typeof this.options.minHeight === 'string' && this.options.minHeight.indexOf('%') !== -1) {
|
|
2656
|
+
let p = +this.options.minHeight.replace('%', '')
|
|
2657
|
+
if (!isNaN(p)) {
|
|
2658
|
+
this.options.minHeight = Math.floor(height * (p / 100))
|
|
2659
|
+
}
|
|
2660
|
+
}
|
|
2661
|
+
else if (
|
|
2662
|
+
typeof this.options.minHeight === 'string' &&
|
|
2663
|
+
this.options.minHeight.indexOf('px') !== -1
|
|
2664
|
+
) {
|
|
2665
|
+
this.options.minHeight = +this.options.minHeight.replace('px', '')
|
|
2666
|
+
}
|
|
2667
|
+
|
|
2668
|
+
const fontFamily = this.css(el, 'font-family')
|
|
2669
|
+
const fontWeight = this.css(el, 'font-weight')
|
|
2670
|
+
let allowedWidth = el.clientWidth
|
|
2671
|
+
if (allowedWidth === 0) {
|
|
2672
|
+
// check for a max-width property
|
|
2673
|
+
if (
|
|
2674
|
+
el.style.maxWidth &&
|
|
2675
|
+
el.style.maxWidth !== 'auto'
|
|
2676
|
+
) {
|
|
2677
|
+
if (el.parentElement.clientWidth > 0) {
|
|
2678
|
+
let calc = el.style.maxWidth
|
|
2679
|
+
if (calc.indexOf('calc') !== -1) {
|
|
2680
|
+
// this logic currently only handles calc statements using % and px
|
|
2681
|
+
// and only + or - formulas
|
|
2682
|
+
calc = calc.replace('calc(', '').replace(')', '')
|
|
2683
|
+
calc = calc.split(' ')
|
|
2684
|
+
if (calc[0].indexOf('px') !== -1) {
|
|
2685
|
+
allowedWidth = calc[0].replace('px', '')
|
|
2686
|
+
}
|
|
2687
|
+
else if (calc[0].indexOf('%') !== -1) {
|
|
2688
|
+
allowedWidth = el.parentElement.clientWidth * (+calc[0].replace('%', '') / 100)
|
|
2689
|
+
}
|
|
2690
|
+
if (calc[2] && calc[4]) {
|
|
2691
|
+
// this means we have an operator and a second value
|
|
2692
|
+
// handle -
|
|
2693
|
+
if (calc[2] === '-') {
|
|
2694
|
+
if (calc[4].indexOf('px') !== -1) {
|
|
2695
|
+
allowedWidth -= +calc[4].replace('px', '')
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2698
|
+
if (calc[2] === '+') {
|
|
2699
|
+
if (calc[4].indexOf('px') !== -1) {
|
|
2700
|
+
allowedWidth += +calc[4].replace('px', '')
|
|
2701
|
+
}
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
}
|
|
2705
|
+
else if (calc.indexOf('px') !== -1) {
|
|
2706
|
+
allowedWidth = +calc.replace('px', '')
|
|
2707
|
+
}
|
|
2708
|
+
else if (calc.indexOf('%') !== -1) {
|
|
2709
|
+
allowedWidth =
|
|
2710
|
+
el.parentElement.clientWidth *
|
|
2711
|
+
(+calc.replace('%', '') / 100)
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
}
|
|
2715
|
+
}
|
|
2716
|
+
// console.log('max height', this.options.maxHeight);
|
|
2717
|
+
let innerElHeight = el.clientHeight
|
|
2718
|
+
while (fits === false) {
|
|
2719
|
+
f++
|
|
2720
|
+
cx.font = `${fontWeight} ${f}px ${fontFamily}`
|
|
2721
|
+
let measurements = cx.measureText(this.options.text)
|
|
2722
|
+
// add support for safari where some elements end up with zero height
|
|
2723
|
+
if (navigator.userAgent.indexOf('Safari') !== -1) {
|
|
2724
|
+
// get the closest parent that has a height
|
|
2725
|
+
let heightFound = false
|
|
2726
|
+
let currEl = el
|
|
2727
|
+
while (heightFound === false) {
|
|
2728
|
+
if (currEl.clientHeight > 0) {
|
|
2729
|
+
innerElHeight = currEl.clientHeight
|
|
2730
|
+
heightFound = true
|
|
2731
|
+
}
|
|
2732
|
+
else if (currEl.parentNode) {
|
|
2733
|
+
currEl = currEl.parentNode
|
|
2734
|
+
}
|
|
2735
|
+
else {
|
|
2736
|
+
// prevent the loop from running indefinitely
|
|
2737
|
+
heightFound = true
|
|
2738
|
+
}
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
if (typeof this.options.maxHeight !== 'undefined' && f === this.options.maxHeight) {
|
|
2742
|
+
f = this.options.maxHeight
|
|
2743
|
+
height = measurements.actualBoundingBoxAscent
|
|
2744
|
+
fits = true
|
|
2745
|
+
}
|
|
2746
|
+
else if (
|
|
2747
|
+
measurements.width > allowedWidth ||
|
|
2748
|
+
measurements.actualBoundingBoxAscent >= innerElHeight
|
|
2749
|
+
) {
|
|
2750
|
+
f--
|
|
2751
|
+
height = measurements.actualBoundingBoxAscent
|
|
2752
|
+
fits = true
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
if (this.options.minHeight === '') {
|
|
2756
|
+
this.options.minHeight = undefined
|
|
2757
|
+
}
|
|
2758
|
+
if (typeof this.options.minHeight !== 'undefined') {
|
|
2759
|
+
if (this.options.minHeight > f && this.options.wrapText === true) {
|
|
2760
|
+
// we run the process again but this time separating the words onto separate lines
|
|
2761
|
+
// this currently only supports wrapping onto 2 lines
|
|
2762
|
+
wrappingRequired = true
|
|
2763
|
+
fits = false
|
|
2764
|
+
f = this.options.minHeight
|
|
2765
|
+
let spaceCount = this.options.text.match(/ /g)
|
|
2766
|
+
if (spaceCount && spaceCount.length > 0) {
|
|
2767
|
+
spaceCount = spaceCount.length
|
|
2768
|
+
let words = this.options.text.split(' ')
|
|
2769
|
+
while (fits === false) {
|
|
2770
|
+
f++
|
|
2771
|
+
cx.font = `${fontWeight} ${f}px ${fontFamily}`
|
|
2772
|
+
for (let i = spaceCount; i > 0; i--) {
|
|
2773
|
+
let fitsCount = 0
|
|
2774
|
+
let lines = [
|
|
2775
|
+
words.slice(0, i).join(' '),
|
|
2776
|
+
words.slice(i, words.length).join(' ')
|
|
2777
|
+
]
|
|
2778
|
+
let longestLine = lines.reduce(
|
|
2779
|
+
(a, b) => (a.length > b.length ? a : b),
|
|
2780
|
+
''
|
|
2781
|
+
)
|
|
2782
|
+
// lines.forEach(l => {
|
|
2783
|
+
let measurements = cx.measureText(longestLine)
|
|
2784
|
+
// add support for safari where some elements end up with zero height
|
|
2785
|
+
if (navigator.userAgent.indexOf('Safari') !== -1) {
|
|
2786
|
+
// get the closest parent that has a height
|
|
2787
|
+
let heightFound = false
|
|
2788
|
+
let currEl = el
|
|
2789
|
+
while (heightFound === false) {
|
|
2790
|
+
if (currEl.clientHeight > 0) {
|
|
2791
|
+
innerElHeight = currEl.clientHeight
|
|
2792
|
+
heightFound = true
|
|
2793
|
+
}
|
|
2794
|
+
else if (currEl.parentNode) {
|
|
2795
|
+
currEl = currEl.parentNode
|
|
2796
|
+
}
|
|
2797
|
+
else {
|
|
2798
|
+
// prevent the loop from running indefinitely
|
|
2799
|
+
heightFound = true
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
if (typeof this.options.maxHeight !== 'undefined' && f === this.options.maxHeight) {
|
|
2804
|
+
f = this.options.maxHeight
|
|
2805
|
+
height = measurements.actualBoundingBoxAscent
|
|
2806
|
+
fits = true
|
|
2807
|
+
break
|
|
2808
|
+
}
|
|
2809
|
+
else if (
|
|
2810
|
+
measurements.width > allowedWidth ||
|
|
2811
|
+
measurements.actualBoundingBoxAscent >=
|
|
2812
|
+
(innerElHeight / 2) * 0.75
|
|
2813
|
+
) {
|
|
2814
|
+
f--
|
|
2815
|
+
height = measurements.actualBoundingBoxAscent
|
|
2816
|
+
fits = true
|
|
2817
|
+
break
|
|
2818
|
+
}
|
|
2819
|
+
// })
|
|
2820
|
+
}
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
if (typeof this.options.minHeight !== 'undefined' && this.options.minHeight > f) {
|
|
2824
|
+
f = this.options.minHeight
|
|
2825
|
+
}
|
|
2826
|
+
}
|
|
2827
|
+
else if (this.options.minHeight > f) {
|
|
2828
|
+
f = this.options.minHeight
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
let spanHeight = Math.min(innerElHeight, height)
|
|
2832
|
+
el.innerHTML = `
|
|
2833
|
+
<div
|
|
2834
|
+
class='websy-responsive-text'
|
|
2835
|
+
style='
|
|
2836
|
+
justify-content: ${this.options.verticalAlign};
|
|
2837
|
+
font-size: ${f}px;
|
|
2838
|
+
font-weight: ${fontWeight || 'normal'};
|
|
2839
|
+
'
|
|
2840
|
+
>
|
|
2841
|
+
<span
|
|
2842
|
+
style='
|
|
2843
|
+
white-space: ${this.options.wrapText === true ? 'normal' : 'nowrap'};
|
|
2844
|
+
height: ${Math.floor(wrappingRequired === true ? spanHeight * ((1 * 1) / 3) * 2 : spanHeight)}px;
|
|
2845
|
+
line-height: ${Math.ceil(wrappingRequired === true ? f * 1.2 : spanHeight)}px;
|
|
2846
|
+
justify-content: ${this.options.textAlign};
|
|
2847
|
+
text-align: ${this.options.textAlign};
|
|
2848
|
+
'
|
|
2849
|
+
>${this.options.text}</span>
|
|
2850
|
+
</div>
|
|
2851
|
+
`
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2854
|
+
}
|
|
2855
|
+
|
|
2432
2856
|
/* global WebsyDesigns */
|
|
2433
2857
|
class WebsyResultList {
|
|
2434
2858
|
constructor (elementId, options) {
|
|
@@ -4268,7 +4692,9 @@ class WebsyTable2 {
|
|
|
4268
4692
|
handleGlobalMouseUp (event) {
|
|
4269
4693
|
this.scrolling = false
|
|
4270
4694
|
const el = document.getElementById(this.elementId)
|
|
4271
|
-
el
|
|
4695
|
+
if (el) {
|
|
4696
|
+
el.classList.remove('scrolling')
|
|
4697
|
+
}
|
|
4272
4698
|
}
|
|
4273
4699
|
handleMouseUp (event) {
|
|
4274
4700
|
this.scrolling = false
|
|
@@ -5988,7 +6414,7 @@ class WebsyMap {
|
|
|
5988
6414
|
const el = document.getElementById(this.elementId)
|
|
5989
6415
|
if (el) {
|
|
5990
6416
|
if (typeof d3 === 'undefined') {
|
|
5991
|
-
console.error('d3 library has not been loaded')
|
|
6417
|
+
// console.error('d3 library has not been loaded')
|
|
5992
6418
|
}
|
|
5993
6419
|
if (typeof L === 'undefined') {
|
|
5994
6420
|
console.error('Leaflet library has not been loaded')
|
|
@@ -6281,7 +6707,9 @@ const WebsyDesigns = {
|
|
|
6281
6707
|
WebsyLogin,
|
|
6282
6708
|
Login: WebsyLogin,
|
|
6283
6709
|
WebsySignup,
|
|
6284
|
-
Signup: WebsySignup
|
|
6710
|
+
Signup: WebsySignup,
|
|
6711
|
+
ResponsiveText,
|
|
6712
|
+
WebsyResponsiveText: ResponsiveText
|
|
6285
6713
|
}
|
|
6286
6714
|
|
|
6287
6715
|
WebsyDesigns.service = new WebsyDesigns.APIService('')
|