Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. (function ($) {
  2. "use strict";
  3.  
  4. $(function () {
  5.  
  6. var button = $('.upload-image'),
  7.  
  8.  
  9. button.click(function (e) {
  10.  
  11. e.preventDefault();
  12.  
  13. // If the media frame already exists, reopen it.
  14. if (file_frame) {
  15. file_frame.open();
  16. return;
  17. }
  18.  
  19. var btn = $(this),
  20. media = wp.media;
  21.  
  22.  
  23. // Create the media frame.
  24. var file_frame = media.frames.file_frame = media({
  25. title: jQuery(this).data('uploader_title'),
  26. button: {
  27. text: jQuery(this).data('uploader_button_text')
  28. },
  29. library: {
  30. type: 'image'
  31. },
  32. multiple: false
  33. });
  34.  
  35.  
  36. // Finally, open the modal
  37. file_frame.open();
  38.  
  39. var selection = media.frame.state().get('selection');
  40. // The sidebar boxes get deleted and recreated on each select - hack into this to do the same.
  41. selection.on( 'selection:single', function ( event ) {
  42. console.log('selection:single');
  43. } );
  44.  
  45. selection.on( 'selection:unsingle', function ( event ) {
  46. console.log('selection:unsingle');
  47. } );
  48.  
  49. });
  50.  
  51. });
  52. }(jQuery));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement