Diff: STRATO-apps/wordpress_03/app/wp-admin/js/custom-header.js
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
/**
2
+
* @output wp-admin/js/custom-header.js
3
+
*/
4
+
5
+
/* global isRtl */
6
+
7
+
/**
8
+
* Initializes the custom header selection page.
9
+
*
10
+
* @since 3.5.0
11
+
*
12
+
* @deprecated 4.1.0 The page this is used on is never linked to from the UI.
13
+
* Setting a custom header is completely handled by the Customizer.
14
+
*/
15
+
(function($) {
16
+
var frame;
17
+
18
+
$( function() {
19
+
// Fetch available headers.
20
+
var $headers = $('.available-headers');
21
+
22
+
// Apply jQuery.masonry once the images have loaded.
23
+
$headers.imagesLoaded( function() {
24
+
$headers.masonry({
25
+
itemSelector: '.default-header',
26
+
isRTL: !! ( 'undefined' != typeof isRtl && isRtl )
27
+
});
28
+
});
29
+
30
+
/**
31
+
* Opens the 'choose from library' frame and creates it if it doesn't exist.
32
+
*
33
+
* @since 3.5.0
34
+
* @deprecated 4.1.0
35
+
*
36
+
* @return {void}
37
+
*/
38
+
$('#choose-from-library-link').on( 'click', function( event ) {
39
+
var $el = $(this);
40
+
event.preventDefault();
41
+
42
+
// If the media frame already exists, reopen it.
43
+
if ( frame ) {
44
+
frame.open();
45
+
return;
46
+
}
47
+
48
+
// Create the media frame.
49
+
frame = wp.media.frames.customHeader = wp.media({
50
+
// Set the title of the modal.
51
+
title: $el.data('choose'),
52
+
53
+
// Tell the modal to show only images.
54
+
library: {
55
+
type: 'image'
56
+
},
57
+
58
+
// Customize the submit button.
59
+
button: {
60
+
// Set the text of the button.
61
+
text: $el.data('update'),
62
+
// Tell the button not to close the modal, since we're
63
+
// going to refresh the page when the image is selected.
64
+
close: false
65
+
}
66
+
});
67
+
68
+
/**
69
+
* Updates the window location to include the selected attachment.
70
+
*
71
+
* @since 3.5.0
72
+
* @deprecated 4.1.0
73
+
*
74
+
* @return {void}
75
+
*/
76
+
frame.on( 'select', function() {
77
+
// Grab the selected attachment.
78
+
var attachment = frame.state().get('selection').first(),
79
+
link = $el.data('updateLink');
80
+
81
+
// Tell the browser to navigate to the crop step.
82
+
window.location = link + '&file=' + attachment.id;
83
+
});
84
+
85
+
frame.open();
86
+
});
87
+
});
88
+
}(jQuery));
89
+