2012-10-14 19:05:16 +02:00
|
|
|
(function($) {
|
2012-11-09 12:59:05 +01:00
|
|
|
var frame;
|
|
|
|
|
2012-11-09 12:55:20 +01:00
|
|
|
$( function() {
|
2012-11-09 12:59:05 +01:00
|
|
|
// Fetch available headers and apply jQuery.masonry
|
|
|
|
// once the images have loaded.
|
2012-11-09 12:55:20 +01:00
|
|
|
var $headers = $('.available-headers');
|
2012-10-14 19:05:16 +02:00
|
|
|
|
2012-11-09 12:55:20 +01:00
|
|
|
$headers.imagesLoaded( function() {
|
|
|
|
$headers.masonry({
|
|
|
|
itemSelector: '.default-header'
|
|
|
|
});
|
2012-10-14 19:05:16 +02:00
|
|
|
});
|
2012-11-09 12:59:05 +01:00
|
|
|
|
|
|
|
// 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() {
|
2012-11-12 06:57:12 +01:00
|
|
|
frame.toolbar.view().set({
|
2012-11-09 12:59:05 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2012-11-30 16:19:11 +01:00
|
|
|
frame.setState('library');
|
2012-11-09 12:59:05 +01:00
|
|
|
});
|
2012-10-14 19:05:16 +02:00
|
|
|
});
|
2012-11-09 12:55:20 +01:00
|
|
|
}(jQuery));
|