form-preview.php
89 lines
| 1 | <?php |
| 2 | |
| 3 | // same as default WP from wp-admin/admin-header.php. |
| 4 | $wp_version_class = 'branch-' . str_replace( [ '.', ',' ], '-', floatval( get_bloginfo( 'version' ) ) ); |
| 5 | |
| 6 | set_current_screen(); |
| 7 | ?> |
| 8 | |
| 9 | <!DOCTYPE html> |
| 10 | <html <?php language_attributes(); ?>> |
| 11 | <head> |
| 12 | <meta name="viewport" content="width=device-width" /> |
| 13 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 14 | <title><?php esc_html_e( 'GiveWP › Onboarding Wizard', 'give' ); ?></title> |
| 15 | <?php wp_print_styles( [ 'give-styles' ] ); ?> |
| 16 | |
| 17 | <style> |
| 18 | body { |
| 19 | margin: 0; |
| 20 | padding: 0; |
| 21 | } |
| 22 | |
| 23 | .iframe-loader { |
| 24 | min-height: 776px !important; |
| 25 | } |
| 26 | </style> |
| 27 | </head> |
| 28 | <body class="<?php echo esc_attr( $wp_version_class ); ?>"> |
| 29 | <?php |
| 30 | echo give_form_shortcode( |
| 31 | [ |
| 32 | 'id' => $this->get_preview_form_id(), |
| 33 | ] |
| 34 | ); |
| 35 | ?> |
| 36 | <?php wp_print_scripts( [ 'give' ] ); ?> |
| 37 | </body> |
| 38 | <script> |
| 39 | (function checkForBodySizeChange() { |
| 40 | var last_body_size = { |
| 41 | width: document.body.clientWidth, |
| 42 | height: document.body.clientHeight |
| 43 | }; |
| 44 | |
| 45 | function checkBodySizeChange() |
| 46 | { |
| 47 | var width_changed = last_body_size.width !== document.body.clientWidth, |
| 48 | height_changed = last_body_size.height !== document.body.clientHeight; |
| 49 | |
| 50 | |
| 51 | if(width_changed || height_changed) { |
| 52 | handleBodySizeChange(document.body.clientWidth, document.body.clientHeight); |
| 53 | last_body_size = { |
| 54 | width: document.body.clientWidth, |
| 55 | height: document.body.clientHeight |
| 56 | }; |
| 57 | } |
| 58 | |
| 59 | window.requestAnimationFrame(checkBodySizeChange); |
| 60 | } |
| 61 | |
| 62 | function handleBodySizeChange(width, height) |
| 63 | { |
| 64 | window.parent.postMessage({ |
| 65 | action: 'resize', |
| 66 | payload: { |
| 67 | height, |
| 68 | width |
| 69 | } |
| 70 | }); |
| 71 | } |
| 72 | |
| 73 | window.requestAnimationFrame(checkBodySizeChange); |
| 74 | })(); |
| 75 | </script> |
| 76 | <script> |
| 77 | (function listenForFormLoaded() { |
| 78 | function handleFormLoaded(width, height) |
| 79 | { |
| 80 | window.parent.postMessage({ |
| 81 | action: 'loaded', |
| 82 | payload: {} |
| 83 | }); |
| 84 | } |
| 85 | document.querySelector('iframe').addEventListener('load', handleFormLoaded ); |
| 86 | })(); |
| 87 | </script> |
| 88 | </html> |
| 89 |