components
1 year ago
data
1 year ago
editor.scss
5 years ago
export.js
1 year ago
icon.js
5 years ago
index.js
5 years ago
export.js
62 lines
| 1 | /* global FLBuilder */ |
| 2 | |
| 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 | ); |
| 33 | } |
| 34 | |
| 35 | FLBuilder.hideAjaxLoader(); |
| 36 | } |
| 37 | ); |
| 38 | }, 1000 ); |
| 39 | }, |
| 40 | strings: { |
| 41 | ok: window.tiTpc.exporter.buttonLabel, |
| 42 | cancel: window.tiTpc.exporter.cancelLabel, |
| 43 | }, |
| 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 | ); |
| 57 | } |
| 58 | |
| 59 | FLBuilder.addHook( 'tiTpcExport', () => { |
| 60 | window.tiTpc.initModalExport(); |
| 61 | } ); |
| 62 |