Changeset 43355
- Timestamp:
- 06/16/2018 10:28:56 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/js/_enqueues/lib/auth-check.js
r43347 r43355 9 9 var wrap, next; 10 10 11 /** 12 * Shows the authentication form popup. 13 * 14 * @since 3.6.0 15 * @private 16 */ 11 17 function show() { 12 18 var parent = $('#wp-auth-check'), … … 16 22 17 23 if ( form.length ) { 18 // Add unload confirmation to counter (frame-busting) JS redirects 24 // Add unload confirmation to counter (frame-busting) JS redirects. 19 25 $(window).on( 'beforeunload.wp-auth-check', function(e) { 20 26 e.originalEvent.returnValue = window.authcheckL10n.beforeunload; … … 46 52 parent.css( 'max-height', height + 40 + 'px' ); 47 53 } else if ( ! body || ! body.length ) { 48 // Catch "silent" iframe origin exceptions in WebKit after another page is loaded in the iframe 54 // Catch "silent" iframe origin exceptions in WebKit after another page is 55 // loaded in the iframe. 49 56 wrap.addClass('fallback'); 50 57 parent.css( 'max-height', '' ); … … 62 69 if ( frame ) { 63 70 frame.focus(); 64 // WebKit doesn't throw an error if the iframe fails to load because of "X-Frame-Options: DENY" header. 71 // WebKit doesn't throw an error if the iframe fails to load because of 72 // "X-Frame-Options: DENY" header. 65 73 // Wait for 10 sec. and switch to the fallback text. 66 74 setTimeout( function() { … … 76 84 } 77 85 86 /** 87 * Hides the authentication form popup. 88 * 89 * @since 3.6.0 90 * @private 91 */ 78 92 function hide() { 79 93 $(window).off( 'beforeunload.wp-auth-check' ); 80 94 81 // When on the Edit Post screen, speed up heartbeat after the user logs in to quickly refresh nonces 95 // When on the Edit Post screen, speed up heartbeat after the user logs in to 96 // quickly refresh nonces. 82 97 if ( typeof adminpage !== 'undefined' && ( adminpage === 'post-php' || adminpage === 'post-new-php' ) && 83 98 typeof wp !== 'undefined' && wp.heartbeat ) { … … 94 109 } 95 110 111 /** 112 * Schedules when the next time the authentication check will be done. 113 * 114 * @since 3.6.0 115 * @private 116 */ 96 117 function schedule() { 97 var interval = parseInt( window.authcheckL10n.interval, 10 ) || 180; // in seconds, default 3 min. 118 // In seconds, default 3 min. 119 var interval = parseInt( window.authcheckL10n.interval, 10 ) || 180; 98 120 next = ( new Date() ).getTime() + ( interval * 1000 ); 99 121 } 100 122 123 /** 124 * Binds to the Heartbeat Tick event. 125 * 126 * - Shows the authentication form popup if user is not logged in. 127 * - Hides the authentication form popup if it is already visible and user is 128 * logged in. 129 * 130 * @ignore 131 * 132 * @since 3.6.0 133 * 134 * @param {Object} e The heartbeat-tick event that has been triggered. 135 * @param {Object} data Response data. 136 */ 101 137 $( document ).on( 'heartbeat-tick.wp-auth-check', function( e, data ) { 102 138 if ( 'wp-auth-check' in data ) { … … 108 144 } 109 145 } 146 147 /** 148 * Binds to the Heartbeat Send event. 149 * 150 * @ignore 151 * 152 * @since 3.6.0 153 * 154 * @param {Object} e The heartbeat-send event that has been triggered. 155 * @param {Object} data Response data. 156 */ 110 157 }).on( 'heartbeat-send.wp-auth-check', function( e, data ) { 111 158 if ( ( new Date() ).getTime() > next ) { 112 159 data['wp-auth-check'] = true; 113 160 } 161 114 162 }).ready( function() { 115 163 schedule(); 164 165 /** 166 * Hides the authentication form popup when the close icon is clicked. 167 * 168 * @ignore 169 * 170 * @since 3.6.0 171 */ 116 172 wrap = $('#wp-auth-check-wrap'); 117 173 wrap.find('.wp-auth-check-close').on( 'click', function() {
Note: See TracChangeset
for help on using the changeset viewer.