|
220 | 220 | component.snapshotButton.prop( 'disabled', true );
|
221 | 221 | component.snapshotButton.insertAfter( publishButton );
|
222 | 222 |
|
223 |
| - // Schedule button. |
| 223 | + // Preview link. |
| 224 | + component.previewLink = $( $.trim( wp.template( 'snapshot-preview-link' )() ) ); |
| 225 | + component.previewLink.toggle( api.state( 'snapshot-saved' ).get() ); |
| 226 | + component.previewLink.attr( 'target', component.data.uuid ); |
| 227 | + setPreviewLinkHref = _.debounce( function() { |
| 228 | + if ( api.state( 'snapshot-exists' ).get() ) { |
| 229 | + component.previewLink.attr( 'href', component.getSnapshotFrontendPreviewUrl() ); |
| 230 | + } else { |
| 231 | + component.previewLink.attr( 'href', component.frontendPreviewUrl.get() ); |
| 232 | + } |
| 233 | + } ); |
| 234 | + component.frontendPreviewUrl.bind( setPreviewLinkHref ); |
| 235 | + setPreviewLinkHref(); |
| 236 | + api.state.bind( 'change', setPreviewLinkHref ); |
| 237 | + api.bind( 'saved', setPreviewLinkHref ); |
| 238 | + component.snapshotButton.after( component.previewLink ); |
| 239 | + api.state( 'snapshot-saved' ).bind( function( saved ) { |
| 240 | + component.previewLink.toggle( saved ); |
| 241 | + } ); |
| 242 | + |
| 243 | + // Edit button. |
224 | 244 | component.snapshotExpandButton = $( $.trim( wp.template( 'snapshot-expand-button' )( {} ) ) );
|
225 | 245 | component.snapshotExpandButton.insertAfter( component.snapshotButton );
|
226 | 246 |
|
|
286 | 306 | }
|
287 | 307 | } );
|
288 | 308 |
|
289 |
| - // Preview link. |
290 |
| - component.previewLink = $( $.trim( wp.template( 'snapshot-preview-link' )() ) ); |
291 |
| - component.previewLink.toggle( api.state( 'snapshot-saved' ).get() ); |
292 |
| - component.previewLink.attr( 'target', component.data.uuid ); |
293 |
| - setPreviewLinkHref = _.debounce( function() { |
294 |
| - if ( api.state( 'snapshot-exists' ).get() ) { |
295 |
| - component.previewLink.attr( 'href', component.getSnapshotFrontendPreviewUrl() ); |
296 |
| - } else { |
297 |
| - component.previewLink.attr( 'href', component.frontendPreviewUrl.get() ); |
298 |
| - } |
299 |
| - } ); |
300 |
| - component.frontendPreviewUrl.bind( setPreviewLinkHref ); |
301 |
| - setPreviewLinkHref(); |
302 |
| - api.state.bind( 'change', setPreviewLinkHref ); |
303 |
| - api.bind( 'saved', setPreviewLinkHref ); |
304 |
| - component.snapshotButton.after( component.previewLink ); |
305 |
| - api.state( 'snapshot-saved' ).bind( function( saved ) { |
306 |
| - component.previewLink.toggle( saved ); |
307 |
| - } ); |
308 |
| - |
309 | 309 | // Submit for review button.
|
310 | 310 | if ( ! component.data.currentUserCanPublish ) {
|
311 | 311 | publishButton.hide();
|
|
0 commit comments