Changeset 1994656
- Timestamp:
- 12/14/2018 10:27:38 AM (7 years ago)
- Location:
- raw-html-modal-window/trunk
- Files:
-
- 5 edited
-
includes/css/default-user-styles.css (modified) (3 diffs)
-
includes/css/styles.css (modified) (1 diff)
-
includes/js/modal_window.js (modified) (5 diffs)
-
modal_window.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
raw-html-modal-window/trunk/includes/css/default-user-styles.css
r1976470 r1994656 1 1 /* --- An Example of styles you can add to control the layout --- */ 2 3 4 /* You can control the scrolling of the page underneath the 5 * modal window by overriding the following style: */ 6 7 .efmw_active { 8 /* Removing the comment tags on the next line will make your page scrollable */ 9 /* overflow: visible; */ 10 } 11 12 /* Note: the efmw_active class is appended to the body tag 13 * when the modal window is displayed and removed when closed. 14 */ 2 15 3 16 … … 12 25 color: white; 13 26 background: #888888 url('wp-content/plugins/raw-html-modal-window/includes/images/demo-background-image.jpg') no-repeat top center / cover; 27 28 /* Note, if you want your modal window to be displayed 29 * with the a background image on 30 * more than the home page, specify the full absolute 31 * path to your image, for example: 32 * 33 * https://your-site.com/wp-content/uploads/year/your-background-image.jpg 34 */ 35 14 36 border:1px solid #AAA; 15 37 text-align:center; … … 25 47 color: white; 26 48 } 49 50 51 #efmw_modalContent h2 { 52 color: white; 53 } -
raw-html-modal-window/trunk/includes/css/styles.css
r1976470 r1994656 1 .efmw_active { 2 overflow: hidden; 3 } 4 5 1 6 #efmw_modal, 2 7 #efmw_modalMask { -
raw-html-modal-window/trunk/includes/js/modal_window.js
r1976470 r1994656 21 21 // Make the modal DIV visible: 22 22 document.getElementById('efmw_modal').style.opacity = 1; 23 document.body.className += ' efmw_active'; 24 25 window.addEventListener('keydown', function(evt) { 26 if (parseInt(evt.keyCode, 10) === 27) { 27 closeModal(); 28 } 29 }); 23 30 24 31 } // End of openModal() function. … … 29 36 function closeModal() { 30 37 'use strict'; 38 39 // For debugging: 40 // console.log('efmw_obj.delay_time: ' + efmw_obj.delay_time); 41 // console.log('efmw_obj.fade_out_duration: ' + efmw_obj.fade_out_duration); 31 42 32 43 // Make the modal DIV invisible: … … 43 54 setTimeout(function() { 44 55 var modal = document.getElementById('efmw_modal'); 45 modal.parentNode.removeChild(modal); 46 }, efmw_fade_out_duration); 56 modal.parentElement.removeChild(modal); 57 }, efmw_obj.fade_out_duration); 58 59 //document.body.style.overflow = 'visible'; 60 61 if (document.body.classList) { 62 document.body.classList.remove('efmw_active'); 63 } else { 64 document.body.className = document.body.className.replace(/efmw_active/, ''); 65 } 47 66 48 67 } // End of closeModal() function. … … 58 77 openModal(); 59 78 60 }, efmw_ delay_time );79 }, efmw_obj.delay_time ); 61 80 62 81 }); … … 64 83 })(); 65 84 85 66 86 /* @license-end */ -
raw-html-modal-window/trunk/modal_window.php
r1976470 r1994656 4 4 * Plugin URI: 5 5 * Description: Show Modal Window on any page or post by specifying post id. This plugin is intended for users that feel comfortable editing HTML and CSS code for ultimate control of a pop-up window. 6 * Version: 1. 06 * Version: 1.1 7 7 * Author: electric-fire 8 8 * Author URI: https://f-guitar.com/office … … 76 76 // ************ DISPLAYING THE RESULT ************ // 77 77 78 function efmw_display_modal_window( $opt ) { 79 80 echo '<script> 81 var efmw_obj = {}; 82 efmw_obj.delay_time = parseInt( ' . $opt['delay'] . ', 10 ); 83 efmw_obj.fade_out_duration = parseInt( ' . $opt['fade_in_duration'] . ', 10 ); 84 </script>'; 85 86 echo '<script>' . file_get_contents( plugin_dir_path( __FILE__ ) . 'includes/js/modal_window.js' ) . '</script>'; 87 88 89 /* Note: 90 * Four <div> structure for modal window is used 91 * becaue three <div> gets partially covered by 92 * the header with some themes. 93 */ 94 ?> 95 <div id="efmw_modal" style="transition-duration:<?php echo $opt['fade_in_duration']; ?>ms;"> 96 <div id="efmw_modalMask" <?php 97 98 echo 'style="opacity:' . 99 ( (int) $opt['mask_opacity'] / 100 ) . 100 ';filter:alpha(opacity=' . 101 $opt['mask_opacity'] . 102 ');z-index:' . 103 $opt['z_index'] . 104 '"></div>'; 105 ?> 106 <div id="efmw_modalFixedDiv" style="z-index:<?php 107 108 echo ( (int) $opt['z_index'] + 8999 ); 109 110 ?>"> 111 <div id="efmw_modalContent"> 112 <a alt="Close Modal Window" title="Close Modal Window" id="efmw_closeModal" style="/* transition-duration:<?php /* echo $opt['fade_out_duration']; */ ?>ms; */">×</a> 113 <?php echo $opt['item_content']; ?> 114 </div> 115 </div> 116 </div> 117 <?php 118 119 } // End of efmw_display_modal_window() function. 120 121 122 function efmw_check_page( $opt ) { 123 $flag = false; 124 125 if ( ( empty( $opt['only_on_pages'] ) ) && is_front_page() ) { 126 127 $flag = true; 128 129 } elseif ( empty( $opt['only_on_pages'] ) ) { 130 131 $flag = false; 132 133 } else { 134 135 $arr = explode( ' ', $opt['only_on_pages'] ); 136 137 foreach ( $arr as $v ) { 138 139 if ( (int) $v === (int) get_the_ID() ) { 140 $flag = true; 141 break; 142 } 143 } // End of FOREACH loop. 144 145 } // End of IF-ELSE. 146 147 return $flag; 148 149 } // End of efmw_check_page() function. 150 151 152 153 78 154 // Register function to add output to page footer: 79 155 add_action( 'init', function() { 80 156 157 // For debugging: 158 /* 159 add_action( 'wp_head', function() { 160 161 $options = efmw_get_options(); 162 if ( efmw_check_page( $options ) ) { 163 echo 'true'; 164 } else { 165 echo 'false'; 166 } 167 exit; 168 } ); // End of wp_head. 169 */ 170 171 81 172 $options = efmw_get_options(); 82 173 83 ##if (true) { 84 if ( !isset( $options['item_disabled'] ) || !$options['item_disabled'] ) { 85 86 add_action( 'wp_footer', function() { // Need this extra add_action() function()to solve the checkbox auto checking and page id not available issue. 87 88 $options = efmw_get_options(); 89 90 if ( ( empty( $options['only_on_pages'] ) ) && is_front_page() ) { 91 efmw_display_modal_window(); 92 return; 93 } 94 95 $arr = explode( ' ', $options['only_on_pages'] ); 96 97 foreach ( $arr as $v ) { 98 99 if ( (int) $v === (int) get_the_ID() ) { 100 efmw_display_modal_window(); 101 break; 102 } 103 104 } // End of FOREACH loop. 105 106 } ); // End of wp_head. 107 108 } // End of IF. 109 } ); 110 111 112 function efmw_display_modal_window() { 113 114 $options = efmw_get_options(); 115 echo '<script> 116 var efmw_delay_time = parseInt( ' . $options['delay'] . ', 10 ); 117 var efmw_fade_out_duration = parseInt( ' . $options['fade_in_duration'] . ', 10 ); 118 </script>'; 119 120 echo '<script>' . file_get_contents( plugin_dir_path( __FILE__ ) . 'includes/js/modal_window.js' ) . '</script>'; 121 122 ?> 123 124 <?php 125 126 } // End of efmw_display_modal_window() function. 127 128 if ( !empty( efmw_get_options()['extra_styles'] ) ) { 129 130 // DO NOT CHANGE INDENTATION: 131 add_action( 'wp_head', function() { 132 174 if ( isset( $options['item_disabled'] ) && ( (int) $options['item_disabled'] === 1 ) ) { 175 return; 176 } // End of item_disabled IF. 177 178 179 // DO NOT CHANGE INDENTATION: 180 add_action( 'wp_head', function() { 181 182 $options = efmw_get_options(); 183 if ( !efmw_check_page( $options ) ) { 184 return; 185 } 186 // Output base styles: 133 187 echo '<style> 134 188 ' . file_get_contents( plugin_dir_path( __FILE__ ) . 'includes/css/styles.css' ) . ' 135 189 </style> 136 '; 137 138 $options = efmw_get_options(); 190 '; 191 192 // Output styles entered by user: 193 if ( !empty( $options['extra_styles'] ) ) { 139 194 ?> 140 <style type="text/css"> 141 <?php echo $options['extra_styles']; ?> 142 </style> 143 <?php 144 145 } ); 146 147 148 add_action( 'wp_footer', function() { 149 $options = efmw_get_options(); 150 151 /* Note: 152 * Four <div> structure for modal window is used 153 * becaue three <div> gets partially covered by 154 * the header with some themes. 155 */ 156 ?> 157 <div id="efmw_modal" style="transition-duration:<?php echo $options['fade_in_duration']; ?>ms;"> 158 <div id="efmw_modalMask" <?php 159 160 echo 'style="opacity:' . 161 ( (int) $options['mask_opacity'] / 100 ) . 162 ';filter:alpha(opacity=' . 163 $options['mask_opacity'] . 164 ');z-index:' . 165 $options['z_index'] . 166 '"></div>'; 167 ?> 168 <div id="efmw_modalFixedDiv" style="z-index:<?php 169 170 echo ( (int) $options['z_index'] + 8999 ); 171 172 ?>"> 173 <div id="efmw_modalContent"> 174 <a alt="Close Modal Window" title="Close Modal Window" id="efmw_closeModal" style="/* transition-duration:<?php /* echo $options['fade_out_duration']; */ ?>ms; */">×</a> 175 <?php echo $options['item_content']; ?> 176 </div> 177 </div> 178 </div> 179 <?php 180 181 } ); 182 183 } 195 <style type="text/css"> 196 <?php echo $options['extra_styles']; ?> 197 </style> 198 <?php 199 } 200 201 } ); // End of wp_head add_action. 202 203 204 205 add_action( 'wp_footer', function() { // Need this extra add_action() function()to solve the checkbox auto checking and page id not available issue. 206 207 $options = efmw_get_options(); 208 209 if ( efmw_check_page( $options ) ) { 210 efmw_display_modal_window( $options ); 211 } 212 213 } ); // End of wp_footer. 214 215 216 } ); // End add_action init. 217 184 218 185 219 // ************ DISPLAYING THE RESULT ************ // -
raw-html-modal-window/trunk/readme.txt
r1977459 r1994656 5 5 Requires at least: 4.0 6 6 Requires PHP: 5.5.37 7 Tested up to: 4.9.57 Tested up to: 5.0 8 8 Stable tag: 4.3 9 9 License: GPLv2 or later … … 33 33 == Changelog == 34 34 35 = 1.1 = 36 * Now the plugin appends the efmw_active css class to the body tag when the modal window displayed to control the scrolling of the page underneath. 37 * Added event listener for the escape button to close the window when it's pressed. 38 35 39 = 1.0 = 36 40 * First version of the plugin.
Note: See TracChangeset
for help on using the changeset viewer.