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