D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
sadaunjx
/
alshaer-news.com
/
wp-content
/
themes
/
newsplus
/
assets
/
js
/
Filename :
admin-options.js
back
Copy
// tabs jQuery(document).ready(function($) { if ( typeof $.fn.tabs === 'undefined') { return; } $('.mz-options-inner').tabs({ select: function(event, ui) { $(ui.panel).animate({opacity:0.1}); }, show: function(event, ui) { $(ui.panel).animate({opacity:1.0},2000); } }); $('a.mz-disable-tab').unbind('click'); }); // upload images var mz_upload_images = function($) { $('.upload-image-button').on('click', function() { upload_image_button = true; field_image_src = $(this).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() { mz_upload_images(jQuery); }); // preview fonts jQuery(document).ready(function($) { $('#mz-options-fonts select').on('change', function() { var font_family = $(this).parent().parent().find('.mz-font-family').val(); var font_size = $(this).parent().parent().find('.mz-font-size').val(); var font_weight = $(this).parent().parent().find('.mz-font-weight').val(); var font_preview = $(this).parent().parent().find('.mz-font-test'); font_preview.css('font-family', font_family); font_preview.css('font-size', parseInt(font_size)); font_preview.css('font-weight', font_weight); }); $('#mz-options-fonts select').change(); }); // ads options var mz_toggle_ad_content = function($) { $('.mz-toggle-ad-content').live('click', function() { $(this).find('.dashicons').toggleClass('dashicons-arrow-down-alt2').toggleClass('dashicons-arrow-up-alt2'); $(this).parents('.mz-ad-item-outer').find('.mz-options-ad-content, .mz-options-ad-footer').slideToggle(); }); } jQuery(document).ready(function() { mz_toggle_ad_content(jQuery); }); var mz_toggle_ad_fields = function($) { $('.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(); }); $('.mz-options-ad-header select').change(); }; jQuery(document).ready(function() { mz_toggle_ad_fields(jQuery); }); var mz_add_remove_add_button = function($) { $('#mz-admin-ads-container .mz-options-ad-header').prepend('<span class="mz-delete-ad"><span class="dashicons dashicons-dismiss"></span></span><span class="mz-move-ad"><span class="dashicons dashicons-menu"></span></span>'); } jQuery(document).ready(function() { mz_add_remove_add_button(jQuery); }); var mz_remove_ad = function($) { $('.mz-delete-ad').on('click', function() { $(this).parents('.mz-ad-item-outer').fadeOut(300, function() { $(this).remove(); }); }); }; jQuery(document).ready(function() { mz_remove_ad(jQuery); }); var mz_sort_ads = function($) { $('#mz-admin-ads-container').sortable({ handle: '.mz-move-ad', start: function(event, ui) { ui.item.find('.mz-ad-overlay').show(); } }); $('#mz-admin-ads-container').on('sortbeforestop', function(event, ui) { ui.item.find('.mz-ad-overlay').fadeOut(1000); }); } jQuery(document).ready(function() { mz_sort_ads(jQuery); }); var mz_last_ad_id = function($) { var largest_order = 0; var elements = $('#mz-admin-ads-container .mz-ad-item-outer').each(function() { var current_order = parseInt($(this).attr('data-order')); if ( current_order > largest_order ) { largest_order = current_order; } }); return largest_order; } var mz_add_ad = function($) { $('#mz-admin-ads-add-button a').on('click', function() { var i = parseInt(mz_last_ad_id(jQuery)); i++; var sample = $('#mz-admin-ad-sample .mz-ad-item-outer').clone(); //sample.find('.mz-options-ad-content, .mz-options-ad-footer').show(); sample.attr('data-order', i); sample.find('[id]').each(function() { $(this).attr('id', $(this).attr('id').replace('ad_', 'ad_' + i)); }); sample.find('[name]').each(function() { $(this).attr('name', $(this).attr('name').replace('ad_', 'ad_' + i)); }); sample.find('[for]').each(function() { $(this).attr('for', $(this).attr('for').replace('ad_', 'ad_' + i)); }); $('#mz-admin-ads-container').append(sample.fadeIn()); //mz_toggle_ad_content(jQuery); mz_toggle_ad_fields(jQuery); mz_add_remove_add_button(jQuery); mz_remove_ad(jQuery); mz_upload_images(jQuery); return false; }); }; jQuery(document).ready(function() { mz_add_ad(jQuery); }); // ajax save options jQuery(document).ready(function($) { if ( typeof $.fn.ajaxSubmit === 'undefined') { return; } var loading_placeholder = $('.mz-loading-placeholder'); var loading_img = $('.mz-loading-placeholder img'); var loading_success = $('.mz-loading-saved'); var loading_close = $('.mz-btn-close'); $('#a4h-form').submit(function() { loading_placeholder.fadeIn(); $(this).ajaxSubmit({ success: function(){ loading_img.animate({"opacity": 0}); loading_success.animate({"opacity": 1}); loading_close.animate({"opacity": 1}); }, timeout: 5000 }); return false; }); loading_close.on('click', function() { loading_placeholder.hide(); loading_img.animate({"opacity": 1}); loading_success.animate({"opacity": 0}); loading_close.animate({"opacity": 0}); return false; }); });