mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-05 18:32:23 +01:00
f07c7f5163
* state( id ) becomes setState( id ) * get( id ) becomes state( id ) * state() stays the same * previous() becomes lastState() Props koopersmith fixes #22652 git-svn-id: http://core.svn.wordpress.org/trunk@22952 1a063a9b-81f0-0310-95a4-ce76da25c4cd
47 lines
974 B
JavaScript
47 lines
974 B
JavaScript
(function($) {
|
|
var frame;
|
|
|
|
$( function() {
|
|
// Fetch available headers and apply jQuery.masonry
|
|
// once the images have loaded.
|
|
var $headers = $('.available-headers');
|
|
|
|
$headers.imagesLoaded( function() {
|
|
$headers.masonry({
|
|
itemSelector: '.default-header'
|
|
});
|
|
});
|
|
|
|
// Build the choose from library frame.
|
|
$('#choose-from-library-link').click( function( event ) {
|
|
var $el = $(this);
|
|
event.preventDefault();
|
|
|
|
frame = wp.media({
|
|
title: $el.data('choose'),
|
|
library: {
|
|
type: 'image'
|
|
}
|
|
});
|
|
|
|
frame.toolbar.on( 'activate:select', function() {
|
|
frame.toolbar.view().set({
|
|
select: {
|
|
style: 'primary',
|
|
text: $el.data('update'),
|
|
|
|
click: function() {
|
|
var attachment = frame.state().get('selection').first(),
|
|
link = $el.data('updateLink');
|
|
|
|
window.location = link + '&file=' + attachment.id;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
frame.setState('library');
|
|
});
|
|
});
|
|
}(jQuery));
|