D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
cwd
/
wp-content
/
themes
/
newsplus1
/
assets
/
js
/
Filename :
admin-widgets.js
back
Copy
function a4h_widget_ads_toggle($) { $('.mz-options-ad-header select').on('change', function() { $(this).parent().parent().parent().find('.mz-options-ad-content').find('[data-type="' + $(this).val() +'"]').slideDown().siblings().slideUp(); $(this).parent().parent().find('.mz-options-ad-content, .mz-options-ad-footer').slideToggle(); }); $('.mz-options-ad-header select').change(); } function a4h_widget_upload_images($) { $('.upload-image-button').on('click', function() { upload_image_button = true; field_image_src = $(this).parent().parent().find('.mz-image-src'); field_image_width = $(this).parent().find('.mz-image-width'); field_image_height = $(this).parent().find('.mz-image-height'); field_image_id = $(this).parent().find('.mz-image-id'); image_preview = $(this).parent().find('.mz-image-preview'); field_image_preview = $(this).parent().find('.mz-image-preview img'); tb_show('Upload an image', 'media-upload.php?type=image&TB_iframe=true'); if ( upload_image_button == true ) { var oldFunc = window.send_to_editor; window.send_to_editor = function(html) { image_classes = $('img', html).attr('class'); image_src = $('img', html).attr('src'); image_width = $('img', html).attr('width');; image_height = $('img', html).attr('height');; image_id = image_classes.replace(/(.*?)wp-image-/, ''); $(field_image_src).attr('value', image_src); $(field_image_width).val(image_width); $(field_image_height).val(image_height); $(field_image_id).val(image_id); $(image_preview).addClass('active'); $(field_image_preview).attr('src', image_src); tb_remove(); window.send_to_editor = oldFunc; } } upload_image_button = false; }); $('.remove-image-button').on('click', function() { $(this).parent().parent().find('input[type="text"], input[type="hidden"]').attr('value', ''); $(this).parent().parent().find('.mz-image-preview').removeClass('active'); $(this).parent().parent().find('.mz-image-preview img').attr('src', ''); }); } jQuery(document).ready(function() { a4h_widget_ads_toggle(jQuery); a4h_widget_upload_images(jQuery); }); jQuery(document).on('widget-updated', function(e, widget){ a4h_widget_ads_toggle(jQuery); a4h_widget_upload_images(jQuery); }); jQuery(document).on('widget-added', function(e, widget){ a4h_widget_ads_toggle(jQuery); a4h_widget_upload_images(jQuery); });