customizer.js
40 lines
| 1 | ( function( $ ) { |
| 2 | |
| 3 | var CEI = { |
| 4 | |
| 5 | init: function() |
| 6 | { |
| 7 | $( 'input[name=cei-export-button]' ).on( 'click', CEI._export ); |
| 8 | $( 'input[name=cei-import-button]' ).on( 'click', CEI._import ); |
| 9 | }, |
| 10 | |
| 11 | _export: function() |
| 12 | { |
| 13 | window.location.href = CEIConfig.customizerURL + '?cei-export=' + CEIConfig.exportNonce; |
| 14 | }, |
| 15 | |
| 16 | _import: function() |
| 17 | { |
| 18 | var win = $( window ), |
| 19 | body = $( 'body' ), |
| 20 | form = $( '<form class="cei-form" method="POST" enctype="multipart/form-data"></form>' ), |
| 21 | controls = $( '.cei-import-controls' ), |
| 22 | file = $( 'input[name=cei-import-file]' ), |
| 23 | message = $( '.cei-uploading' ); |
| 24 | |
| 25 | if ( '' == file.val() ) { |
| 26 | alert( CEIl10n.emptyImport ); |
| 27 | } |
| 28 | else { |
| 29 | win.off( 'beforeunload' ); |
| 30 | body.append( form ); |
| 31 | form.append( controls ); |
| 32 | message.show(); |
| 33 | form.submit(); |
| 34 | } |
| 35 | } |
| 36 | }; |
| 37 | |
| 38 | $( CEI.init ); |
| 39 | |
| 40 | })( jQuery ); |