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'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-12-04 02:26:03 +01:00
|
|
|
frame.on( 'toolbar:render:select', function( view ) {
|
|
|
|
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-12-03 03:38:10 +01:00
|
|
|
frame.setState('library').open();
|
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));
|