@websy/websy-designs 0.0.128 → 0.0.129
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/websy-designs.debug.js +116 -51
- package/dist/websy-designs.js +126 -31
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
|
@@ -171,40 +171,72 @@ class WebsyLoadingDialog {
|
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
+
/* global */
|
|
174
175
|
class WebsyNavigationMenu {
|
|
175
176
|
constructor (elementId, options) {
|
|
176
177
|
this.options = Object.assign({}, {
|
|
177
|
-
|
|
178
|
+
collapsible: false,
|
|
178
179
|
orientation: 'horizontal',
|
|
179
180
|
parentMap: {},
|
|
180
|
-
childIndentation: 10
|
|
181
|
+
childIndentation: 10,
|
|
182
|
+
activeSymbol: 'none'
|
|
181
183
|
}, options)
|
|
182
184
|
if (!elementId) {
|
|
183
185
|
console.log('No element Id provided for Websy Menu')
|
|
184
186
|
return
|
|
185
|
-
}
|
|
187
|
+
}
|
|
186
188
|
const el = document.getElementById(elementId)
|
|
187
189
|
if (el) {
|
|
188
190
|
this.elementId = elementId
|
|
191
|
+
this.lowestLevel = 0
|
|
192
|
+
this.flatItems = []
|
|
193
|
+
this.itemMap = {}
|
|
194
|
+
this.flattenItems(0, this.options.items)
|
|
195
|
+
console.log(this.flatItems)
|
|
189
196
|
el.classList.add(`websy-${this.options.orientation}-list-container`)
|
|
190
197
|
el.classList.add('websy-menu')
|
|
198
|
+
if (this.options.align) {
|
|
199
|
+
el.classList.add(`${this.options.align}-align`)
|
|
200
|
+
}
|
|
201
|
+
if (Array.isArray(this.options.classes)) {
|
|
202
|
+
this.options.classes = this.options.classes.join(' ')
|
|
203
|
+
}
|
|
191
204
|
if (this.options.classes) {
|
|
192
|
-
this.options.classes.forEach(c => el.classList.add(c))
|
|
205
|
+
this.options.classes.split(' ').forEach(c => el.classList.add(c))
|
|
193
206
|
}
|
|
194
207
|
el.addEventListener('click', this.handleClick.bind(this))
|
|
195
208
|
this.render()
|
|
196
209
|
}
|
|
197
210
|
}
|
|
211
|
+
flattenItems (index, items, level = 0) {
|
|
212
|
+
if (items[index]) {
|
|
213
|
+
this.lowestLevel = Math.max(level, this.lowestLevel)
|
|
214
|
+
items[index].id = items[index].id || `${this.elementId}_${this.normaliseString(items[index].text)}`
|
|
215
|
+
this.itemMap[items[index].id] = items[index]
|
|
216
|
+
items[index].level = level
|
|
217
|
+
this.flatItems.push(items[index])
|
|
218
|
+
if (items[index].items) {
|
|
219
|
+
this.flattenItems(0, items[index].items, level + 1)
|
|
220
|
+
}
|
|
221
|
+
this.flattenItems(++index, items, level)
|
|
222
|
+
}
|
|
223
|
+
}
|
|
198
224
|
handleClick (event) {
|
|
199
225
|
if (event.target.classList.contains('websy-menu-icon') ||
|
|
200
226
|
event.target.nodeName === 'svg' ||
|
|
201
227
|
event.target.nodeName === 'rect') {
|
|
202
228
|
this.toggleMobileMenu()
|
|
203
229
|
}
|
|
204
|
-
if (event.target.classList.contains('
|
|
205
|
-
event.target.
|
|
206
|
-
|
|
207
|
-
|
|
230
|
+
if (event.target.classList.contains('websy-menu-header')) {
|
|
231
|
+
let item = this.itemMap[event.target.id]
|
|
232
|
+
if (event.target.classList.contains('trigger-item') && item.level === this.lowestLevel) {
|
|
233
|
+
this.toggleMobileMenu('remove')
|
|
234
|
+
}
|
|
235
|
+
if (item.items) {
|
|
236
|
+
event.target.classList.toggle('menu-open')
|
|
237
|
+
this.toggleMenu(item.id)
|
|
238
|
+
}
|
|
239
|
+
}
|
|
208
240
|
if (event.target.classList.contains('websy-menu-mask')) {
|
|
209
241
|
this.toggleMobileMenu()
|
|
210
242
|
}
|
|
@@ -216,7 +248,7 @@ class WebsyNavigationMenu {
|
|
|
216
248
|
const el = document.getElementById(this.elementId)
|
|
217
249
|
if (el) {
|
|
218
250
|
let html = ``
|
|
219
|
-
if (this.options.
|
|
251
|
+
if (this.options.collapsible === true) {
|
|
220
252
|
html += `
|
|
221
253
|
<div id='${this.elementId}_menuIcon' class='websy-menu-icon'>
|
|
222
254
|
<svg viewbox="0 0 40 40" width="30" height="40">
|
|
@@ -228,9 +260,12 @@ class WebsyNavigationMenu {
|
|
|
228
260
|
`
|
|
229
261
|
}
|
|
230
262
|
if (this.options.logo) {
|
|
263
|
+
if (Array.isArray(this.options.logo.classes)) {
|
|
264
|
+
this.options.logo.classes = this.options.logo.classes.join(' ')
|
|
265
|
+
}
|
|
231
266
|
html += `
|
|
232
267
|
<div
|
|
233
|
-
class='logo ${
|
|
268
|
+
class='logo ${this.options.logo.classes || ''}'
|
|
234
269
|
${this.options.logo.attributes && this.options.logo.attributes.join(' ')}
|
|
235
270
|
>
|
|
236
271
|
<img src='${this.options.logo.url}'></img>
|
|
@@ -239,7 +274,7 @@ class WebsyNavigationMenu {
|
|
|
239
274
|
<div id="${this.elementId}_menuContainer" class="websy-menu-block-container">
|
|
240
275
|
`
|
|
241
276
|
}
|
|
242
|
-
html += this.renderBlock(this.options.items, 'main',
|
|
277
|
+
html += this.renderBlock(this.options.items, 'main', 0)
|
|
243
278
|
html += `</div>`
|
|
244
279
|
el.innerHTML = html
|
|
245
280
|
if (this.options.navigator) {
|
|
@@ -247,9 +282,9 @@ class WebsyNavigationMenu {
|
|
|
247
282
|
}
|
|
248
283
|
}
|
|
249
284
|
}
|
|
250
|
-
renderBlock (items, block, level) {
|
|
285
|
+
renderBlock (items, block, level = 0) {
|
|
251
286
|
let html = `
|
|
252
|
-
<ul class='websy-${this.options.orientation}-list ${(block !== 'main' ? 'websy-menu-collapsed' : '')}' id='${this.elementId}_${block}_list'
|
|
287
|
+
<ul class='websy-${this.options.orientation}-list ${level > 0 ? 'websy-child-list' : ''} ${(block !== 'main' ? 'websy-menu-collapsed' : '')}' id='${this.elementId}_${block}_list'
|
|
253
288
|
`
|
|
254
289
|
if (block !== 'main') {
|
|
255
290
|
html += ` data-collapsed='${(block !== 'main' ? 'true' : 'false')}'`
|
|
@@ -260,25 +295,36 @@ class WebsyNavigationMenu {
|
|
|
260
295
|
let selected = '' // items[i].default === true ? 'selected' : ''
|
|
261
296
|
let active = items[i].default === true ? 'active' : ''
|
|
262
297
|
let currentBlock = this.normaliseString(items[i].text)
|
|
263
|
-
let blockId = items[i].id || `${this.elementId}_${currentBlock}_label`
|
|
298
|
+
let blockId = items[i].id // || `${this.elementId}_${currentBlock}_label`
|
|
299
|
+
if (Array.isArray(items[i].classes)) {
|
|
300
|
+
items[i].classes = items[i].classes.join(' ')
|
|
301
|
+
}
|
|
264
302
|
html += `
|
|
265
303
|
<li class='websy-${this.options.orientation}-list-item'>
|
|
266
|
-
<div class='websy-menu-header ${items[i].classes
|
|
304
|
+
<div class='websy-menu-header ${items[i].classes || ''} ${selected} ${active}'
|
|
267
305
|
id='${blockId}'
|
|
268
306
|
data-id='${currentBlock}'
|
|
269
307
|
data-menu-id='${this.elementId}_${currentBlock}_list'
|
|
270
308
|
data-popout-id='${level > 1 ? block : currentBlock}'
|
|
271
309
|
data-text='${items[i].text}'
|
|
272
310
|
style='padding-left: ${level * this.options.childIndentation}px'
|
|
273
|
-
${items[i].attributes && items[i].attributes.join(' ')}
|
|
311
|
+
${(items[i].attributes && items[i].attributes.join(' ')) || ''}
|
|
274
312
|
>
|
|
275
313
|
`
|
|
276
314
|
if (this.options.orientation === 'horizontal') {
|
|
277
315
|
html += items[i].text
|
|
278
316
|
}
|
|
279
|
-
|
|
317
|
+
if (this.options.activeSymbol === 'line') {
|
|
318
|
+
html += `
|
|
280
319
|
<span class='selected-bar'></span>
|
|
320
|
+
`
|
|
321
|
+
}
|
|
322
|
+
if (this.options.activeSymbol === 'triangle') {
|
|
323
|
+
html += `
|
|
281
324
|
<span class='active-square'></span>
|
|
325
|
+
`
|
|
326
|
+
}
|
|
327
|
+
html += `
|
|
282
328
|
<span class='${items[i].items && items[i].items.length > 0 ? 'menu-carat' : ''}'></span>
|
|
283
329
|
`
|
|
284
330
|
if (this.options.orientation === 'vertical') {
|
|
@@ -290,7 +336,7 @@ class WebsyNavigationMenu {
|
|
|
290
336
|
</div>
|
|
291
337
|
`
|
|
292
338
|
if (items[i].items) {
|
|
293
|
-
html += this.renderBlock(items[i].items, currentBlock, level + 1)
|
|
339
|
+
html += this.renderBlock(items[i].items, currentBlock, items[i].level + 1)
|
|
294
340
|
}
|
|
295
341
|
// map the item to it's parent
|
|
296
342
|
if (block && block !== 'main') {
|
|
@@ -304,9 +350,12 @@ class WebsyNavigationMenu {
|
|
|
304
350
|
}
|
|
305
351
|
html += `</ul>`
|
|
306
352
|
return html
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
|
|
353
|
+
}
|
|
354
|
+
toggleMenu (id) {
|
|
355
|
+
const el = document.getElementById(`${id}_list`)
|
|
356
|
+
if (el) {
|
|
357
|
+
el.classList.toggle('websy-menu-collapsed')
|
|
358
|
+
}
|
|
310
359
|
}
|
|
311
360
|
toggleMobileMenu (method) {
|
|
312
361
|
if (typeof method === 'undefined') {
|
|
@@ -1628,9 +1677,9 @@ class WebsyPubSub {
|
|
|
1628
1677
|
class WebsyRouter {
|
|
1629
1678
|
constructor (options) {
|
|
1630
1679
|
const defaults = {
|
|
1631
|
-
triggerClass: 'trigger
|
|
1632
|
-
triggerToggleClass: 'trigger-toggle',
|
|
1633
|
-
viewClass: 'view',
|
|
1680
|
+
triggerClass: 'websy-trigger',
|
|
1681
|
+
triggerToggleClass: 'websy-trigger-toggle',
|
|
1682
|
+
viewClass: 'websy-view',
|
|
1634
1683
|
activeClass: 'active',
|
|
1635
1684
|
viewAttribute: 'data-view',
|
|
1636
1685
|
groupAttribute: 'data-group',
|
|
@@ -1653,19 +1702,7 @@ class WebsyRouter {
|
|
|
1653
1702
|
window.addEventListener('keyup', this.handleKeyUp.bind(this))
|
|
1654
1703
|
window.addEventListener('focus', this.handleFocus.bind(this))
|
|
1655
1704
|
window.addEventListener('click', this.handleClick.bind(this))
|
|
1656
|
-
this.options = Object.assign({}, defaults, options)
|
|
1657
|
-
// add any necessary CSS if the viewClass has been changed
|
|
1658
|
-
if (this.options.viewClass !== defaults.viewClass || this.options.activeClass !== defaults.activeClass) {
|
|
1659
|
-
let style = `
|
|
1660
|
-
<style>
|
|
1661
|
-
.${this.options.viewClass}{ display: none; }
|
|
1662
|
-
.${this.options.viewClass}.${this.options.activeClass}{ display: initial; }
|
|
1663
|
-
.${this.options.triggerClass}{cursor: pointer;}
|
|
1664
|
-
</style>
|
|
1665
|
-
`
|
|
1666
|
-
document.querySelector('head').innerHTML += style
|
|
1667
|
-
}
|
|
1668
|
-
// this.navigate(this.currentPath, this.options.defaultGroup)
|
|
1705
|
+
this.options = Object.assign({}, defaults, options)
|
|
1669
1706
|
}
|
|
1670
1707
|
addGroup (group) {
|
|
1671
1708
|
if (!this.groups[group]) {
|
|
@@ -1753,7 +1790,7 @@ class WebsyRouter {
|
|
|
1753
1790
|
}
|
|
1754
1791
|
}
|
|
1755
1792
|
init () {
|
|
1756
|
-
this.registerElements(document)
|
|
1793
|
+
// this.registerElements(document)
|
|
1757
1794
|
let view = ''
|
|
1758
1795
|
let params = this.formatParams(this.queryParams)
|
|
1759
1796
|
let url
|
|
@@ -2006,6 +2043,9 @@ class WebsyRouter {
|
|
|
2006
2043
|
}
|
|
2007
2044
|
}
|
|
2008
2045
|
}
|
|
2046
|
+
on (event, fn) {
|
|
2047
|
+
this.options.subscribers[event].push(fn)
|
|
2048
|
+
}
|
|
2009
2049
|
onPopState (event) {
|
|
2010
2050
|
if (event.state) {
|
|
2011
2051
|
let url
|
|
@@ -2031,7 +2071,7 @@ class WebsyRouter {
|
|
|
2031
2071
|
}
|
|
2032
2072
|
subscribe (event, fn) {
|
|
2033
2073
|
this.options.subscribers[event].push(fn)
|
|
2034
|
-
}
|
|
2074
|
+
}
|
|
2035
2075
|
get currentPath () {
|
|
2036
2076
|
let path = window.location.pathname.split('/').pop()
|
|
2037
2077
|
if (path.indexOf('.htm') !== -1) {
|
|
@@ -2083,8 +2123,9 @@ class WebsyRouter {
|
|
|
2083
2123
|
|
|
2084
2124
|
/* global XMLHttpRequest fetch ENV */
|
|
2085
2125
|
class APIService {
|
|
2086
|
-
constructor (baseUrl) {
|
|
2126
|
+
constructor (baseUrl = '', options = {}) {
|
|
2087
2127
|
this.baseUrl = baseUrl
|
|
2128
|
+
this.options = Object.assign({}, options)
|
|
2088
2129
|
}
|
|
2089
2130
|
add (entity, data, options = {}) {
|
|
2090
2131
|
const url = this.buildUrl(entity)
|
|
@@ -2206,7 +2247,8 @@ class WebsyPDFButton {
|
|
|
2206
2247
|
const DEFAULTS = {
|
|
2207
2248
|
classes: [],
|
|
2208
2249
|
wait: 0,
|
|
2209
|
-
buttonText: 'Download'
|
|
2250
|
+
buttonText: 'Download',
|
|
2251
|
+
directDownload: false
|
|
2210
2252
|
}
|
|
2211
2253
|
this.elementId = elementId
|
|
2212
2254
|
this.options = Object.assign({}, DEFAULTS, options)
|
|
@@ -2314,15 +2356,22 @@ class WebsyPDFButton {
|
|
|
2314
2356
|
this.service.add('', pdfData, {responseType: 'blob'}).then(response => {
|
|
2315
2357
|
this.loader.hide()
|
|
2316
2358
|
const blob = new Blob([response], {type: 'application/pdf'})
|
|
2359
|
+
let msg = `
|
|
2360
|
+
<div class='text-center websy-pdf-download'>
|
|
2361
|
+
<div>Your file is ready to download</div>
|
|
2362
|
+
<a href='${URL.createObjectURL(blob)}' target='_blank'
|
|
2363
|
+
`
|
|
2364
|
+
if (this.options.directDownload === true) {
|
|
2365
|
+
msg += `download='${this.options.fileName || 'Export'}.pdf'`
|
|
2366
|
+
}
|
|
2367
|
+
msg += `
|
|
2368
|
+
>
|
|
2369
|
+
<button class='websy-btn download-pdf'>${this.options.buttonText}</button>
|
|
2370
|
+
</a>
|
|
2371
|
+
</div>
|
|
2372
|
+
`
|
|
2317
2373
|
this.popup.show({
|
|
2318
|
-
message:
|
|
2319
|
-
<div class='text-center websy-pdf-download'>
|
|
2320
|
-
<div>Your file is ready to download</div>
|
|
2321
|
-
<a href='${URL.createObjectURL(blob)}' target='_blank'>
|
|
2322
|
-
<button class='websy-btn download-pdf'>${this.options.buttonText}</button>
|
|
2323
|
-
</a>
|
|
2324
|
-
</div>
|
|
2325
|
-
`,
|
|
2374
|
+
message: msg,
|
|
2326
2375
|
mask: true
|
|
2327
2376
|
})
|
|
2328
2377
|
}, err => {
|
|
@@ -3875,24 +3924,40 @@ const WebsyUtils = {
|
|
|
3875
3924
|
|
|
3876
3925
|
const WebsyDesigns = {
|
|
3877
3926
|
WebsyPopupDialog,
|
|
3927
|
+
PopupDialog: WebsyPopupDialog,
|
|
3878
3928
|
WebsyLoadingDialog,
|
|
3929
|
+
LoadingDialog: WebsyLoadingDialog,
|
|
3879
3930
|
WebsyNavigationMenu,
|
|
3931
|
+
NavigationMenu: WebsyNavigationMenu,
|
|
3880
3932
|
WebsyForm,
|
|
3933
|
+
Form: WebsyForm,
|
|
3881
3934
|
WebsyDatePicker,
|
|
3935
|
+
DatePicker: WebsyDatePicker,
|
|
3882
3936
|
WebsyDropdown,
|
|
3937
|
+
Dropdown: WebsyDropdown,
|
|
3883
3938
|
WebsyResultList,
|
|
3939
|
+
ResultList: WebsyResultList,
|
|
3884
3940
|
WebsyTemplate,
|
|
3941
|
+
Template: WebsyTemplate,
|
|
3885
3942
|
WebsyPubSub,
|
|
3943
|
+
PubSub: WebsyPubSub,
|
|
3886
3944
|
WebsyRouter,
|
|
3945
|
+
Router: WebsyRouter,
|
|
3887
3946
|
WebsyTable,
|
|
3947
|
+
Table: WebsyTable,
|
|
3888
3948
|
WebsyChart,
|
|
3949
|
+
Chart: WebsyChart,
|
|
3889
3950
|
WebsyChartTooltip,
|
|
3951
|
+
ChartTooltip: WebsyChartTooltip,
|
|
3890
3952
|
WebsyMap,
|
|
3953
|
+
Map: WebsyMap,
|
|
3891
3954
|
WebsyKPI,
|
|
3892
|
-
|
|
3955
|
+
KPI: WebsyKPI,
|
|
3956
|
+
WebsyPDFButton,
|
|
3893
3957
|
PDFButton: WebsyPDFButton,
|
|
3894
3958
|
APIService,
|
|
3895
|
-
WebsyUtils
|
|
3959
|
+
WebsyUtils,
|
|
3960
|
+
Utils: WebsyUtils
|
|
3896
3961
|
}
|
|
3897
3962
|
|
|
3898
3963
|
const GlobalPubSub = new WebsyPubSub('empty', {})
|
package/dist/websy-designs.js
CHANGED
|
@@ -220,16 +220,19 @@ var WebsyLoadingDialog = /*#__PURE__*/function () {
|
|
|
220
220
|
|
|
221
221
|
return WebsyLoadingDialog;
|
|
222
222
|
}();
|
|
223
|
+
/* global */
|
|
224
|
+
|
|
223
225
|
|
|
224
226
|
var WebsyNavigationMenu = /*#__PURE__*/function () {
|
|
225
227
|
function WebsyNavigationMenu(elementId, options) {
|
|
226
228
|
_classCallCheck(this, WebsyNavigationMenu);
|
|
227
229
|
|
|
228
230
|
this.options = _extends({}, {
|
|
229
|
-
|
|
231
|
+
collapsible: false,
|
|
230
232
|
orientation: 'horizontal',
|
|
231
233
|
parentMap: {},
|
|
232
|
-
childIndentation: 10
|
|
234
|
+
childIndentation: 10,
|
|
235
|
+
activeSymbol: 'none'
|
|
233
236
|
}, options);
|
|
234
237
|
|
|
235
238
|
if (!elementId) {
|
|
@@ -241,11 +244,24 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
|
|
|
241
244
|
|
|
242
245
|
if (el) {
|
|
243
246
|
this.elementId = elementId;
|
|
247
|
+
this.lowestLevel = 0;
|
|
248
|
+
this.flatItems = [];
|
|
249
|
+
this.itemMap = {};
|
|
250
|
+
this.flattenItems(0, this.options.items);
|
|
251
|
+
console.log(this.flatItems);
|
|
244
252
|
el.classList.add("websy-".concat(this.options.orientation, "-list-container"));
|
|
245
253
|
el.classList.add('websy-menu');
|
|
246
254
|
|
|
255
|
+
if (this.options.align) {
|
|
256
|
+
el.classList.add("".concat(this.options.align, "-align"));
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (Array.isArray(this.options.classes)) {
|
|
260
|
+
this.options.classes = this.options.classes.join(' ');
|
|
261
|
+
}
|
|
262
|
+
|
|
247
263
|
if (this.options.classes) {
|
|
248
|
-
this.options.classes.forEach(function (c) {
|
|
264
|
+
this.options.classes.split(' ').forEach(function (c) {
|
|
249
265
|
return el.classList.add(c);
|
|
250
266
|
});
|
|
251
267
|
}
|
|
@@ -256,14 +272,42 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
|
|
|
256
272
|
}
|
|
257
273
|
|
|
258
274
|
_createClass(WebsyNavigationMenu, [{
|
|
275
|
+
key: "flattenItems",
|
|
276
|
+
value: function flattenItems(index, items) {
|
|
277
|
+
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
278
|
+
|
|
279
|
+
if (items[index]) {
|
|
280
|
+
this.lowestLevel = Math.max(level, this.lowestLevel);
|
|
281
|
+
items[index].id = items[index].id || "".concat(this.elementId, "_").concat(this.normaliseString(items[index].text));
|
|
282
|
+
this.itemMap[items[index].id] = items[index];
|
|
283
|
+
items[index].level = level;
|
|
284
|
+
this.flatItems.push(items[index]);
|
|
285
|
+
|
|
286
|
+
if (items[index].items) {
|
|
287
|
+
this.flattenItems(0, items[index].items, level + 1);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
this.flattenItems(++index, items, level);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}, {
|
|
259
294
|
key: "handleClick",
|
|
260
295
|
value: function handleClick(event) {
|
|
261
296
|
if (event.target.classList.contains('websy-menu-icon') || event.target.nodeName === 'svg' || event.target.nodeName === 'rect') {
|
|
262
297
|
this.toggleMobileMenu();
|
|
263
298
|
}
|
|
264
299
|
|
|
265
|
-
if (event.target.classList.contains('
|
|
266
|
-
this.
|
|
300
|
+
if (event.target.classList.contains('websy-menu-header')) {
|
|
301
|
+
var item = this.itemMap[event.target.id];
|
|
302
|
+
|
|
303
|
+
if (event.target.classList.contains('trigger-item') && item.level === this.lowestLevel) {
|
|
304
|
+
this.toggleMobileMenu('remove');
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (item.items) {
|
|
308
|
+
event.target.classList.toggle('menu-open');
|
|
309
|
+
this.toggleMenu(item.id);
|
|
310
|
+
}
|
|
267
311
|
}
|
|
268
312
|
|
|
269
313
|
if (event.target.classList.contains('websy-menu-mask')) {
|
|
@@ -283,15 +327,19 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
|
|
|
283
327
|
if (el) {
|
|
284
328
|
var html = "";
|
|
285
329
|
|
|
286
|
-
if (this.options.
|
|
330
|
+
if (this.options.collapsible === true) {
|
|
287
331
|
html += "\n <div id='".concat(this.elementId, "_menuIcon' class='websy-menu-icon'>\n <svg viewbox=\"0 0 40 40\" width=\"30\" height=\"40\"> \n <rect x=\"0\" y=\"0\" width=\"30\" height=\"4\" rx=\"2\"></rect>\n <rect x=\"0\" y=\"12\" width=\"30\" height=\"4\" rx=\"2\"></rect>\n <rect x=\"0\" y=\"24\" width=\"30\" height=\"4\" rx=\"2\"></rect>\n </svg>\n </div>\n ");
|
|
288
332
|
}
|
|
289
333
|
|
|
290
334
|
if (this.options.logo) {
|
|
291
|
-
|
|
335
|
+
if (Array.isArray(this.options.logo.classes)) {
|
|
336
|
+
this.options.logo.classes = this.options.logo.classes.join(' ');
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
html += " \n <div \n class='logo ".concat(this.options.logo.classes || '', "'\n ").concat(this.options.logo.attributes && this.options.logo.attributes.join(' '), "\n >\n <img src='").concat(this.options.logo.url, "'></img>\n </div>\n <div id='").concat(this.elementId, "_mask' class='websy-menu-mask'></div>\n <div id=\"").concat(this.elementId, "_menuContainer\" class=\"websy-menu-block-container\">\n ");
|
|
292
340
|
}
|
|
293
341
|
|
|
294
|
-
html += this.renderBlock(this.options.items, 'main',
|
|
342
|
+
html += this.renderBlock(this.options.items, 'main', 0);
|
|
295
343
|
html += "</div>";
|
|
296
344
|
el.innerHTML = html;
|
|
297
345
|
|
|
@@ -302,8 +350,9 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
|
|
|
302
350
|
}
|
|
303
351
|
}, {
|
|
304
352
|
key: "renderBlock",
|
|
305
|
-
value: function renderBlock(items, block
|
|
306
|
-
var
|
|
353
|
+
value: function renderBlock(items, block) {
|
|
354
|
+
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
355
|
+
var html = "\n\t\t <ul class='websy-".concat(this.options.orientation, "-list ").concat(level > 0 ? 'websy-child-list' : '', " ").concat(block !== 'main' ? 'websy-menu-collapsed' : '', "' id='").concat(this.elementId, "_").concat(block, "_list'\n\t ");
|
|
307
356
|
|
|
308
357
|
if (block !== 'main') {
|
|
309
358
|
html += " data-collapsed='".concat(block !== 'main' ? 'true' : 'false', "'");
|
|
@@ -317,14 +366,27 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
|
|
|
317
366
|
|
|
318
367
|
var active = items[i]["default"] === true ? 'active' : '';
|
|
319
368
|
var currentBlock = this.normaliseString(items[i].text);
|
|
320
|
-
var blockId = items[i].id ||
|
|
321
|
-
|
|
369
|
+
var blockId = items[i].id; // || `${this.elementId}_${currentBlock}_label`
|
|
370
|
+
|
|
371
|
+
if (Array.isArray(items[i].classes)) {
|
|
372
|
+
items[i].classes = items[i].classes.join(' ');
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
html += "\n\t\t\t<li class='websy-".concat(this.options.orientation, "-list-item'>\n\t\t\t\t<div class='websy-menu-header ").concat(items[i].classes || '', " ").concat(selected, " ").concat(active, "' \n\t\t\t\t\t\t id='").concat(blockId, "' \n\t\t\t\t\t\t data-id='").concat(currentBlock, "'\n data-menu-id='").concat(this.elementId, "_").concat(currentBlock, "_list'\n\t\t\t\t\t\t data-popout-id='").concat(level > 1 ? block : currentBlock, "'\n\t\t\t\t\t\t data-text='").concat(items[i].text, "'\n\t\t\t\t\t\t style='padding-left: ").concat(level * this.options.childIndentation, "px'\n\t\t\t\t\t\t ").concat(items[i].attributes && items[i].attributes.join(' ') || '', "\n >\n ");
|
|
322
376
|
|
|
323
377
|
if (this.options.orientation === 'horizontal') {
|
|
324
378
|
html += items[i].text;
|
|
325
379
|
}
|
|
326
380
|
|
|
327
|
-
|
|
381
|
+
if (this.options.activeSymbol === 'line') {
|
|
382
|
+
html += "\n <span class='selected-bar'></span>\n ";
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if (this.options.activeSymbol === 'triangle') {
|
|
386
|
+
html += "\n <span class='active-square'></span>\n ";
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
html += " \n <span class='".concat(items[i].items && items[i].items.length > 0 ? 'menu-carat' : '', "'></span>\n ");
|
|
328
390
|
|
|
329
391
|
if (this.options.orientation === 'vertical') {
|
|
330
392
|
html += "\n \n ";
|
|
@@ -333,7 +395,7 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
|
|
|
333
395
|
html += " \n\t\t\t\t</div>\n\t\t ";
|
|
334
396
|
|
|
335
397
|
if (items[i].items) {
|
|
336
|
-
html += this.renderBlock(items[i].items, currentBlock, level + 1);
|
|
398
|
+
html += this.renderBlock(items[i].items, currentBlock, items[i].level + 1);
|
|
337
399
|
} // map the item to it's parent
|
|
338
400
|
|
|
339
401
|
|
|
@@ -350,8 +412,14 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
|
|
|
350
412
|
return html;
|
|
351
413
|
}
|
|
352
414
|
}, {
|
|
353
|
-
key: "
|
|
354
|
-
value: function
|
|
415
|
+
key: "toggleMenu",
|
|
416
|
+
value: function toggleMenu(id) {
|
|
417
|
+
var el = document.getElementById("".concat(id, "_list"));
|
|
418
|
+
|
|
419
|
+
if (el) {
|
|
420
|
+
el.classList.toggle('websy-menu-collapsed');
|
|
421
|
+
}
|
|
422
|
+
}
|
|
355
423
|
}, {
|
|
356
424
|
key: "toggleMobileMenu",
|
|
357
425
|
value: function toggleMobileMenu(method) {
|
|
@@ -1903,9 +1971,9 @@ var WebsyRouter = /*#__PURE__*/function () {
|
|
|
1903
1971
|
_classCallCheck(this, WebsyRouter);
|
|
1904
1972
|
|
|
1905
1973
|
var defaults = {
|
|
1906
|
-
triggerClass: 'trigger
|
|
1907
|
-
triggerToggleClass: 'trigger-toggle',
|
|
1908
|
-
viewClass: 'view',
|
|
1974
|
+
triggerClass: 'websy-trigger',
|
|
1975
|
+
triggerToggleClass: 'websy-trigger-toggle',
|
|
1976
|
+
viewClass: 'websy-view',
|
|
1909
1977
|
activeClass: 'active',
|
|
1910
1978
|
viewAttribute: 'data-view',
|
|
1911
1979
|
groupAttribute: 'data-group',
|
|
@@ -1931,13 +1999,7 @@ var WebsyRouter = /*#__PURE__*/function () {
|
|
|
1931
1999
|
window.addEventListener('keyup', this.handleKeyUp.bind(this));
|
|
1932
2000
|
window.addEventListener('focus', this.handleFocus.bind(this));
|
|
1933
2001
|
window.addEventListener('click', this.handleClick.bind(this));
|
|
1934
|
-
this.options = _extends({}, defaults, options);
|
|
1935
|
-
|
|
1936
|
-
if (this.options.viewClass !== defaults.viewClass || this.options.activeClass !== defaults.activeClass) {
|
|
1937
|
-
var style = "\n <style>\n .".concat(this.options.viewClass, "{ display: none; }\n .").concat(this.options.viewClass, ".").concat(this.options.activeClass, "{ display: initial; }\n .").concat(this.options.triggerClass, "{cursor: pointer;}\n </style>\n ");
|
|
1938
|
-
document.querySelector('head').innerHTML += style;
|
|
1939
|
-
} // this.navigate(this.currentPath, this.options.defaultGroup)
|
|
1940
|
-
|
|
2002
|
+
this.options = _extends({}, defaults, options);
|
|
1941
2003
|
}
|
|
1942
2004
|
|
|
1943
2005
|
_createClass(WebsyRouter, [{
|
|
@@ -2056,7 +2118,7 @@ var WebsyRouter = /*#__PURE__*/function () {
|
|
|
2056
2118
|
}, {
|
|
2057
2119
|
key: "init",
|
|
2058
2120
|
value: function init() {
|
|
2059
|
-
this.registerElements(document)
|
|
2121
|
+
// this.registerElements(document)
|
|
2060
2122
|
var view = '';
|
|
2061
2123
|
var params = this.formatParams(this.queryParams);
|
|
2062
2124
|
var url;
|
|
@@ -2370,6 +2432,11 @@ var WebsyRouter = /*#__PURE__*/function () {
|
|
|
2370
2432
|
}
|
|
2371
2433
|
}
|
|
2372
2434
|
}
|
|
2435
|
+
}, {
|
|
2436
|
+
key: "on",
|
|
2437
|
+
value: function on(event, fn) {
|
|
2438
|
+
this.options.subscribers[event].push(fn);
|
|
2439
|
+
}
|
|
2373
2440
|
}, {
|
|
2374
2441
|
key: "onPopState",
|
|
2375
2442
|
value: function onPopState(event) {
|
|
@@ -2476,10 +2543,14 @@ var WebsyRouter = /*#__PURE__*/function () {
|
|
|
2476
2543
|
|
|
2477
2544
|
|
|
2478
2545
|
var APIService = /*#__PURE__*/function () {
|
|
2479
|
-
function APIService(
|
|
2546
|
+
function APIService() {
|
|
2547
|
+
var baseUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
2548
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2549
|
+
|
|
2480
2550
|
_classCallCheck(this, APIService);
|
|
2481
2551
|
|
|
2482
2552
|
this.baseUrl = baseUrl;
|
|
2553
|
+
this.options = _extends({}, options);
|
|
2483
2554
|
}
|
|
2484
2555
|
|
|
2485
2556
|
_createClass(APIService, [{
|
|
@@ -2641,7 +2712,8 @@ var WebsyPDFButton = /*#__PURE__*/function () {
|
|
|
2641
2712
|
var DEFAULTS = {
|
|
2642
2713
|
classes: [],
|
|
2643
2714
|
wait: 0,
|
|
2644
|
-
buttonText: 'Download'
|
|
2715
|
+
buttonText: 'Download',
|
|
2716
|
+
directDownload: false
|
|
2645
2717
|
};
|
|
2646
2718
|
this.elementId = elementId;
|
|
2647
2719
|
this.options = _extends({}, DEFAULTS, options);
|
|
@@ -2739,9 +2811,16 @@ var WebsyPDFButton = /*#__PURE__*/function () {
|
|
|
2739
2811
|
var blob = new Blob([response], {
|
|
2740
2812
|
type: 'application/pdf'
|
|
2741
2813
|
});
|
|
2814
|
+
var msg = "\n <div class='text-center websy-pdf-download'>\n <div>Your file is ready to download</div>\n <a href='".concat(URL.createObjectURL(blob), "' target='_blank'\n ");
|
|
2815
|
+
|
|
2816
|
+
if (_this16.options.directDownload === true) {
|
|
2817
|
+
msg += "download='".concat(_this16.options.fileName || 'Export', ".pdf'");
|
|
2818
|
+
}
|
|
2819
|
+
|
|
2820
|
+
msg += "\n >\n <button class='websy-btn download-pdf'>".concat(_this16.options.buttonText, "</button>\n </a>\n </div>\n ");
|
|
2742
2821
|
|
|
2743
2822
|
_this16.popup.show({
|
|
2744
|
-
message:
|
|
2823
|
+
message: msg,
|
|
2745
2824
|
mask: true
|
|
2746
2825
|
});
|
|
2747
2826
|
}, function (err) {
|
|
@@ -4245,24 +4324,40 @@ var WebsyUtils = {
|
|
|
4245
4324
|
};
|
|
4246
4325
|
var WebsyDesigns = {
|
|
4247
4326
|
WebsyPopupDialog: WebsyPopupDialog,
|
|
4327
|
+
PopupDialog: WebsyPopupDialog,
|
|
4248
4328
|
WebsyLoadingDialog: WebsyLoadingDialog,
|
|
4329
|
+
LoadingDialog: WebsyLoadingDialog,
|
|
4249
4330
|
WebsyNavigationMenu: WebsyNavigationMenu,
|
|
4331
|
+
NavigationMenu: WebsyNavigationMenu,
|
|
4250
4332
|
WebsyForm: WebsyForm,
|
|
4333
|
+
Form: WebsyForm,
|
|
4251
4334
|
WebsyDatePicker: WebsyDatePicker,
|
|
4335
|
+
DatePicker: WebsyDatePicker,
|
|
4252
4336
|
WebsyDropdown: WebsyDropdown,
|
|
4337
|
+
Dropdown: WebsyDropdown,
|
|
4253
4338
|
WebsyResultList: WebsyResultList,
|
|
4339
|
+
ResultList: WebsyResultList,
|
|
4254
4340
|
WebsyTemplate: WebsyTemplate,
|
|
4341
|
+
Template: WebsyTemplate,
|
|
4255
4342
|
WebsyPubSub: WebsyPubSub,
|
|
4343
|
+
PubSub: WebsyPubSub,
|
|
4256
4344
|
WebsyRouter: WebsyRouter,
|
|
4345
|
+
Router: WebsyRouter,
|
|
4257
4346
|
WebsyTable: WebsyTable,
|
|
4347
|
+
Table: WebsyTable,
|
|
4258
4348
|
WebsyChart: WebsyChart,
|
|
4349
|
+
Chart: WebsyChart,
|
|
4259
4350
|
WebsyChartTooltip: WebsyChartTooltip,
|
|
4351
|
+
ChartTooltip: WebsyChartTooltip,
|
|
4260
4352
|
WebsyMap: WebsyMap,
|
|
4353
|
+
Map: WebsyMap,
|
|
4261
4354
|
WebsyKPI: WebsyKPI,
|
|
4355
|
+
KPI: WebsyKPI,
|
|
4262
4356
|
WebsyPDFButton: WebsyPDFButton,
|
|
4263
4357
|
PDFButton: WebsyPDFButton,
|
|
4264
4358
|
APIService: APIService,
|
|
4265
|
-
WebsyUtils: WebsyUtils
|
|
4359
|
+
WebsyUtils: WebsyUtils,
|
|
4360
|
+
Utils: WebsyUtils
|
|
4266
4361
|
};
|
|
4267
4362
|
var GlobalPubSub = new WebsyPubSub('empty', {});
|
|
4268
4363
|
|