|
1 | 1 | /* global FLBuilder */ |
2 | 2 |
|
3 | | -if ( parseInt( window.tiTpc.tier ) === 3 ) { |
4 | | - const contextMenu = document.getElementById( 'tmpl-fl-row-overlay' ); |
5 | | - |
6 | | - const tpcExport = ( e ) => { |
7 | | - const row = e.closest( '.fl-row' ); |
8 | | - const node = row.dataset.node; |
9 | | - |
10 | | - const message = `<div class="tpc-template-cloud-export-modal"> |
11 | | - <h1>${ window.tiTpc.exporter.modalLabel }</h1> |
12 | | - <label for="tpc-${ node }">${ window.tiTpc.exporter.textLabel }</label> |
13 | | - <input id="tpc-${ node }" type="text" placeholder="${ window.tiTpc.exporter.textPlaceholder }" /> |
14 | | - </div>`; |
15 | | - |
16 | | - FLBuilder.confirm( { |
17 | | - message, |
18 | | - ok: () => { |
19 | | - const input = document.getElementById( `tpc-${ node }` ); |
20 | | - const title = input.value || 'Template'; |
21 | | - setTimeout( function () { |
22 | | - FLBuilder.showAjaxLoader(); |
23 | | - FLBuilder.ajax( |
24 | | - { |
25 | | - action: 'ti_export_template', |
26 | | - node, |
27 | | - title, |
28 | | - }, |
29 | | - ( res ) => { |
30 | | - if ( undefined !== res.success && ! res.success ) { |
31 | | - FLBuilder.alert( |
32 | | - `<h1>${ window.tiTpc.exporter.exportFailed }</h1> ${ res.data }` |
33 | | - ); |
34 | | - } |
35 | | - |
36 | | - FLBuilder.hideAjaxLoader(); |
| 3 | +const contextMenu = document.getElementById( 'tmpl-fl-row-overlay' ); |
| 4 | + |
| 5 | +const tpcExport = ( e ) => { |
| 6 | + const row = e.closest( '.fl-row' ); |
| 7 | + const node = row.dataset.node; |
| 8 | + |
| 9 | + const message = `<div class="tpc-template-cloud-export-modal"> |
| 10 | + <h1>${ window.tiTpc.exporter.modalLabel }</h1> |
| 11 | + <label for="tpc-${ node }">${ window.tiTpc.exporter.textLabel }</label> |
| 12 | + <input id="tpc-${ node }" type="text" placeholder="${ window.tiTpc.exporter.textPlaceholder }" /> |
| 13 | +</div>`; |
| 14 | + |
| 15 | + FLBuilder.confirm( { |
| 16 | + message, |
| 17 | + ok: () => { |
| 18 | + const input = document.getElementById( `tpc-${ node }` ); |
| 19 | + const title = input.value || 'Template'; |
| 20 | + setTimeout( function () { |
| 21 | + FLBuilder.showAjaxLoader(); |
| 22 | + FLBuilder.ajax( |
| 23 | + { |
| 24 | + action: 'ti_export_template', |
| 25 | + node, |
| 26 | + title, |
| 27 | + }, |
| 28 | + ( res ) => { |
| 29 | + if ( undefined !== res.success && ! res.success ) { |
| 30 | + FLBuilder.alert( |
| 31 | + `<h1>${ window.tiTpc.exporter.exportFailed }</h1> ${ res.data }` |
| 32 | + ); |
37 | 33 | } |
38 | | - ); |
39 | | - }, 1000 ); |
40 | | - }, |
41 | | - strings: { |
42 | | - ok: window.tiTpc.exporter.buttonLabel, |
43 | | - cancel: window.tiTpc.exporter.cancelLabel, |
44 | | - }, |
45 | | - } ); |
46 | | - }; |
47 | | - |
48 | | - window.tiTpc.tpcExport = tpcExport; |
49 | | - |
50 | | - if ( contextMenu ) { |
51 | | - const text = contextMenu.textContent; |
52 | | - contextMenu.textContent = text.replace( |
53 | | - // eslint-disable-next-line prettier/prettier |
54 | | - '<li><a class="fl-block-row-reset" href="javascript:void(0);">Reset Row Width</a></li>', |
55 | | - // eslint-disable-next-line prettier/prettier |
56 | | - '<li><a class="fl-block-row-reset" href="javascript:void(0);">Reset Row Width</a></li><li><a class="fl-block-row-tpc-export" onclick="window.tiTpc.tpcExport(this)" href="javascript:void(0);">Save to Templates Cloud</a></li>' |
57 | | - ); |
58 | | - } |
59 | | - |
60 | | - FLBuilder.addHook( 'tiTpcExport', () => { |
61 | | - window.tiTpc.initModalExport(); |
| 34 | + |
| 35 | + FLBuilder.hideAjaxLoader(); |
| 36 | + } |
| 37 | + ); |
| 38 | + }, 1000 ); |
| 39 | + }, |
| 40 | + strings: { |
| 41 | + ok: window.tiTpc.exporter.buttonLabel, |
| 42 | + cancel: window.tiTpc.exporter.cancelLabel, |
| 43 | + }, |
62 | 44 | } ); |
| 45 | +}; |
| 46 | + |
| 47 | +window.tiTpc.tpcExport = tpcExport; |
| 48 | + |
| 49 | +if ( contextMenu ) { |
| 50 | + const text = contextMenu.textContent; |
| 51 | + contextMenu.textContent = text.replace( |
| 52 | + // eslint-disable-next-line prettier/prettier |
| 53 | + '<li><a class="fl-block-row-reset" href="javascript:void(0);">Reset Row Width</a></li>', |
| 54 | + // eslint-disable-next-line prettier/prettier |
| 55 | + '<li><a class="fl-block-row-reset" href="javascript:void(0);">Reset Row Width</a></li><li><a class="fl-block-row-tpc-export" onclick="window.tiTpc.tpcExport(this)" href="javascript:void(0);">Save to Templates Cloud</a></li>' |
| 56 | + ); |
63 | 57 | } |
| 58 | + |
| 59 | +FLBuilder.addHook( 'tiTpcExport', () => { |
| 60 | + window.tiTpc.initModalExport(); |
| 61 | +} ); |
0 commit comments