@websy/websy-designs 1.4.14 → 1.4.16
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/helpers/v1/pgHelper.js +1 -0
- package/dist/server/routes/v1/recaptcha.js +2 -1
- package/dist/websy-designs-es6.debug.js +82 -44
- package/dist/websy-designs-es6.js +296 -248
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +83 -45
- package/dist/websy-designs.js +300 -252
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
|
@@ -12,7 +12,8 @@ router.post('/checkrecaptcha', function (req, res) {
|
|
|
12
12
|
}
|
|
13
13
|
console.log('recaptcha body')
|
|
14
14
|
console.log(body)
|
|
15
|
-
request.post(`https://www.google.com/recaptcha/api/siteverify?secret=${process.env.RECAPTCHA_SECRET}&response=${req.body.grecaptcharesponse}`, body, (err, response, body) => {
|
|
15
|
+
// request.post(`https://www.google.com/recaptcha/api/siteverify?secret=${process.env.RECAPTCHA_SECRET}&response=${req.body.grecaptcharesponse}`, body, (err, response, body) => {
|
|
16
|
+
request.post(`https://www.google.com/recaptcha/api/siteverify`, {form: body}, (err, response, body) => {
|
|
16
17
|
if (err) {
|
|
17
18
|
res.json({ err: err })
|
|
18
19
|
}
|
|
@@ -2004,25 +2004,26 @@ class WebsyForm {
|
|
|
2004
2004
|
checkRecaptcha () {
|
|
2005
2005
|
return new Promise((resolve, reject) => {
|
|
2006
2006
|
if (this.options.useRecaptcha === true) {
|
|
2007
|
-
|
|
2008
|
-
grecaptcha.ready(() => {
|
|
2009
|
-
grecaptcha.execute(
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
}
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
}
|
|
2018
|
-
}, err => {
|
|
2019
|
-
reject(err)
|
|
2007
|
+
if (this.recaptchaValue) {
|
|
2008
|
+
// grecaptcha.ready(() => {
|
|
2009
|
+
// grecaptcha.execute(this.recaptchaValue, { action: 'submit' }).then(token => {
|
|
2010
|
+
this.apiService.add('google/checkrecaptcha', {grecaptcharesponse: this.recaptchaValue}).then(response => {
|
|
2011
|
+
if (response.success && response.success === true) {
|
|
2012
|
+
resolve(true)
|
|
2013
|
+
grecaptcha.reset(`${this.elementId}_recaptcha`, {sitekey: ENVIRONMENT.RECAPTCHA_KEY})
|
|
2014
|
+
}
|
|
2015
|
+
else {
|
|
2016
|
+
resolve(false)
|
|
2017
|
+
}
|
|
2020
2018
|
})
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
//
|
|
2025
|
-
|
|
2019
|
+
// }, err => {
|
|
2020
|
+
// reject(err)
|
|
2021
|
+
// })
|
|
2022
|
+
// })
|
|
2023
|
+
}
|
|
2024
|
+
else {
|
|
2025
|
+
resolve(false)
|
|
2026
|
+
}
|
|
2026
2027
|
}
|
|
2027
2028
|
else {
|
|
2028
2029
|
resolve(true)
|
|
@@ -2092,10 +2093,12 @@ class WebsyForm {
|
|
|
2092
2093
|
recaptchaReady () {
|
|
2093
2094
|
const el = document.getElementById(`${this.elementId}_recaptcha`)
|
|
2094
2095
|
if (el) {
|
|
2095
|
-
grecaptcha.
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2096
|
+
grecaptcha.ready(() => {
|
|
2097
|
+
grecaptcha.render(`${this.elementId}_recaptcha`, {
|
|
2098
|
+
sitekey: ENVIRONMENT.RECAPTCHA_KEY,
|
|
2099
|
+
callback: this.validateRecaptcha.bind(this)
|
|
2100
|
+
})
|
|
2101
|
+
})
|
|
2099
2102
|
}
|
|
2100
2103
|
}
|
|
2101
2104
|
render (update, data) {
|
|
@@ -2150,6 +2153,12 @@ class WebsyForm {
|
|
|
2150
2153
|
`
|
|
2151
2154
|
}
|
|
2152
2155
|
})
|
|
2156
|
+
if (this.options.useRecaptcha === true) {
|
|
2157
|
+
html += `
|
|
2158
|
+
--><div id='${this.elementId}_recaptcha' data-sitekey='${ENVIRONMENT.RECAPTCHA_KEY}' class='websy-form-recaptcha'></div>
|
|
2159
|
+
<div id='${this.elementId}_recaptchaError' class='websy-alert websy-alert-error websy-hidden'>Invalid recaptcha response</div><!--
|
|
2160
|
+
`
|
|
2161
|
+
}
|
|
2153
2162
|
html += `
|
|
2154
2163
|
--><button class="websy-btn submit ${this.options.submit.classes || ''}">${this.options.submit.text || 'Save'}</button>${this.options.cancel ? '<!--' : ''}
|
|
2155
2164
|
`
|
|
@@ -2162,24 +2171,30 @@ class WebsyForm {
|
|
|
2162
2171
|
</form>
|
|
2163
2172
|
<div id="${this.elementId}_validationFail" class="websy-validation-failure"></div>
|
|
2164
2173
|
`
|
|
2165
|
-
if (this.options.useRecaptcha === true) {
|
|
2166
|
-
html += `
|
|
2167
|
-
<div id='${this.elementId}_recaptcha'></div>
|
|
2168
|
-
`
|
|
2169
|
-
}
|
|
2170
2174
|
el.innerHTML = html
|
|
2171
2175
|
this.processComponents(componentsToProcess, () => {
|
|
2172
2176
|
if (this.options.useRecaptcha === true && typeof grecaptcha !== 'undefined') {
|
|
2173
|
-
|
|
2177
|
+
this.recaptchaReady()
|
|
2174
2178
|
}
|
|
2175
2179
|
})
|
|
2176
2180
|
}
|
|
2177
2181
|
}
|
|
2178
2182
|
submitForm () {
|
|
2179
2183
|
const formEl = document.getElementById(`${this.elementId}Form`)
|
|
2184
|
+
const buttonEl = formEl.querySelector('button.websy-btn.submit')
|
|
2185
|
+
const recaptchErrEl = document.getElementById(`${this.elementId}_recaptchaError`)
|
|
2180
2186
|
if (formEl.reportValidity() === true) {
|
|
2187
|
+
if (buttonEl) {
|
|
2188
|
+
buttonEl.setAttribute('disabled', true)
|
|
2189
|
+
}
|
|
2181
2190
|
this.checkRecaptcha().then(result => {
|
|
2182
|
-
if (
|
|
2191
|
+
if (buttonEl) {
|
|
2192
|
+
buttonEl.removeAttribute('disabled')
|
|
2193
|
+
}
|
|
2194
|
+
if (result === true) {
|
|
2195
|
+
if (recaptchErrEl) {
|
|
2196
|
+
recaptchErrEl.classList.add('websy-hidden')
|
|
2197
|
+
}
|
|
2183
2198
|
const formData = new FormData(formEl)
|
|
2184
2199
|
const data = {}
|
|
2185
2200
|
const temp = new FormData(formEl)
|
|
@@ -2199,6 +2214,7 @@ class WebsyForm {
|
|
|
2199
2214
|
// this.render()
|
|
2200
2215
|
formEl.reset()
|
|
2201
2216
|
}
|
|
2217
|
+
buttonEl.removeAttribute('disabled')
|
|
2202
2218
|
this.options.onSuccess.call(this, result)
|
|
2203
2219
|
}, err => {
|
|
2204
2220
|
console.log('Error submitting form data:', err)
|
|
@@ -2215,7 +2231,12 @@ class WebsyForm {
|
|
|
2215
2231
|
}
|
|
2216
2232
|
}
|
|
2217
2233
|
else {
|
|
2218
|
-
|
|
2234
|
+
if (buttonEl) {
|
|
2235
|
+
buttonEl.removeAttribute('disabled')
|
|
2236
|
+
}
|
|
2237
|
+
if (recaptchErrEl) {
|
|
2238
|
+
recaptchErrEl.classList.remove('websy-hidden')
|
|
2239
|
+
}
|
|
2219
2240
|
}
|
|
2220
2241
|
})
|
|
2221
2242
|
}
|
|
@@ -2527,7 +2548,7 @@ class WebsyNavigationMenu {
|
|
|
2527
2548
|
let lowestItems = this.flatItems.filter(d => d.level === this.maxLevel)
|
|
2528
2549
|
let visibleItems = lowestItems
|
|
2529
2550
|
let defaultMethod = 'remove'
|
|
2530
|
-
if (searchText.length > 1) {
|
|
2551
|
+
if (searchText && searchText.length > 1) {
|
|
2531
2552
|
defaultMethod = 'add'
|
|
2532
2553
|
visibleItems = lowestItems.filter(d => d[this.options.searchProp].toLowerCase().indexOf(searchText.toLowerCase()) !== -1)
|
|
2533
2554
|
}
|
|
@@ -2540,7 +2561,7 @@ class WebsyNavigationMenu {
|
|
|
2540
2561
|
for (let l = 0; l < listEls.length; l++) {
|
|
2541
2562
|
listEls[l].classList.add('websy-menu-collapsed')
|
|
2542
2563
|
}
|
|
2543
|
-
if (searchText.length > 1) {
|
|
2564
|
+
if (searchText && searchText.length > 1) {
|
|
2544
2565
|
visibleItems.forEach(d => {
|
|
2545
2566
|
// show the item and open the list
|
|
2546
2567
|
let pathParts = d.path.split('::')
|
|
@@ -2594,10 +2615,16 @@ class WebsyNavigationMenu {
|
|
|
2594
2615
|
}
|
|
2595
2616
|
html += this.renderBlock(this.elementId, this.elementId, this.options.items, 'main', 0)
|
|
2596
2617
|
html += `</div>`
|
|
2618
|
+
if (this.options.secondaryItems) {
|
|
2619
|
+
html += `<div class='websy-menu-secondary' style='height: ${this.options.secondaryHeight || '100%'}; width: ${this.options.secondaryWidth || '100%'}'>`
|
|
2620
|
+
html += this.renderBlock(this.elementId, this.elementId, this.options.secondaryItems, 'main', 0)
|
|
2621
|
+
html += `</div>`
|
|
2622
|
+
}
|
|
2597
2623
|
el.innerHTML = html
|
|
2598
2624
|
if (this.options.enableSearch === true) {
|
|
2599
2625
|
this.search = new WebsyDesigns.Search(`${this.elementId}_search`, Object.assign({}, {
|
|
2600
|
-
onSearch: this.handleSearch.bind(this)
|
|
2626
|
+
onSearch: this.handleSearch.bind(this),
|
|
2627
|
+
onClear: this.handleSearch.bind(this)
|
|
2601
2628
|
}, this.options.searchOptions))
|
|
2602
2629
|
}
|
|
2603
2630
|
}
|
|
@@ -2632,7 +2659,7 @@ class WebsyNavigationMenu {
|
|
|
2632
2659
|
style='padding-left: ${level * this.options.childIndentation}px'
|
|
2633
2660
|
${(items[i].attributes && items[i].attributes.join(' ')) || ''}
|
|
2634
2661
|
>
|
|
2635
|
-
`
|
|
2662
|
+
`
|
|
2636
2663
|
if (this.options.orientation === 'horizontal') {
|
|
2637
2664
|
html += items[i].text
|
|
2638
2665
|
}
|
|
@@ -2641,22 +2668,33 @@ class WebsyNavigationMenu {
|
|
|
2641
2668
|
<span class='selected-bar'></span>
|
|
2642
2669
|
`
|
|
2643
2670
|
}
|
|
2644
|
-
if (this.options.activeSymbol === 'triangle') {
|
|
2645
|
-
html += `
|
|
2646
|
-
<span class='active-square'></span>
|
|
2647
|
-
`
|
|
2648
|
-
}
|
|
2649
|
-
html += `
|
|
2650
|
-
<span class='${items[i].items && items[i].items.length > 0 ? 'menu-carat' : ''}'></span>
|
|
2651
|
-
`
|
|
2652
2671
|
if (this.options.orientation === 'vertical') {
|
|
2653
2672
|
// html += `
|
|
2654
2673
|
//
|
|
2655
2674
|
// `
|
|
2656
2675
|
}
|
|
2657
2676
|
if (items[i].isLink === true && items[i].href) {
|
|
2658
|
-
html += `<a href='${items[i].href}'
|
|
2659
|
-
}
|
|
2677
|
+
html += `<a href='${items[i].href}' target='${items[i].openInNewTab ? 'blank' : '_self'}'>`
|
|
2678
|
+
}
|
|
2679
|
+
if (items[i].icon) {
|
|
2680
|
+
html += `
|
|
2681
|
+
<div class='websy-menu-item-icon'>${items[i].icon}</div>
|
|
2682
|
+
`
|
|
2683
|
+
}
|
|
2684
|
+
html += `<span>${items[i].text}</span>`
|
|
2685
|
+
if (items[i].isLink === true && items[i].href) {
|
|
2686
|
+
html += `</a>`
|
|
2687
|
+
}
|
|
2688
|
+
if (items[i].items && items[i].items.length > 0) {
|
|
2689
|
+
html += `
|
|
2690
|
+
<span class='menu-carat'></span>
|
|
2691
|
+
`
|
|
2692
|
+
}
|
|
2693
|
+
if (this.options.activeSymbol === 'triangle') {
|
|
2694
|
+
html += `
|
|
2695
|
+
<span class='active-square'></span>
|
|
2696
|
+
`
|
|
2697
|
+
}
|
|
2660
2698
|
html += `
|
|
2661
2699
|
</div>
|
|
2662
2700
|
`
|