| 1 |
jQuery(function($) { |
| 2 |
|
| 3 |
$('.wp-color-picker').wpColorPicker(); |
| 4 |
|
| 5 |
var custom_uploader; |
| 6 |
|
| 7 |
$('.image_button').click(function (e) { |
| 8 |
e.preventDefault(); |
| 9 |
window.imgFor = $(this).attr('for'); |
| 10 |
//If the uploader object has already been created, reopen the dialog |
| 11 |
if (custom_uploader) { |
| 12 |
custom_uploader.open(); |
| 13 |
return; |
| 14 |
} |
| 15 |
//Extend the wp.media object |
| 16 |
custom_uploader = wp.media.frames.file_frame = wp.media({ |
| 17 |
title: 'Choose Image', |
| 18 |
button: { |
| 19 |
text: 'Choose Image', |
| 20 |
id: 'test' |
| 21 |
}, |
| 22 |
multiple: false |
| 23 |
}); |
| 24 |
|
| 25 |
//When a file is selected, grab the URL and set it as the text field's value |
| 26 |
custom_uploader.on('select', function () { |
| 27 |
attachment = custom_uploader.state().get('selection').first().toJSON(); |
| 28 |
$('#' + window.imgFor).val(attachment.url); |
| 29 |
}); |
| 30 |
|
| 31 |
//Open the uploader dialog |
| 32 |
custom_uploader.open(); |
| 33 |
}); |
| 34 |
|
| 35 |
$(document).on('click', '.tab', function() { |
| 36 |
container_name = '#tab_container_' + $(this).attr('id').replace('tab_', ''); |
| 37 |
$('.tab_container').css('display', 'none'); |
| 38 |
$(container_name).css('display', 'block'); |
| 39 |
$('.tab').removeClass('active_tab'); |
| 40 |
$(this).addClass('active_tab'); |
| 41 |
if(typeof(Storage) !== "undefined") { |
| 42 |
localStorage.responsive_menu_tab = $(this).attr('id'); |
| 43 |
} |
| 44 |
}); |
| 45 |
|
| 46 |
if(typeof(Storage) !== "undefined") { |
| 47 |
if(localStorage.rmupgrade) { |
| 48 |
$('.upgrade-notes').hide(); |
| 49 |
} else { |
| 50 |
$(document).on('click', '.upgrade-notes-close', function(e) { |
| 51 |
e.stopPropagation(); |
| 52 |
e.preventDefault(); |
| 53 |
$('.upgrade-notes').fadeOut(); |
| 54 |
localStorage.rmupgrade = "true"; |
| 55 |
}); |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
}); |
| 60 |
|