????

Your IP : 216.73.216.152


Current Path : /home2/morganrand/www/wp-content/themes/wanderfuls-2/framework/classes/assets/
Upload File :
Current File : /home2/morganrand/www/wp-content/themes/wanderfuls-2/framework/classes/assets/tb-metabox.js

( function( $ ) {
	"use strict";

	$( document ).on( 'ready', function() {

		// Tabs
		$( 'div#tb-metabox ul.wp-tab-bar a').click( function() {
			var lis = $( '#tb-metabox ul.wp-tab-bar li' ),
				data = $( this ).data( 'tab' ),
				tabs = $( '#tb-metabox div.wp-tab-panel');
			$( lis ).removeClass( 'wp-tab-active' );
			$( tabs ).hide();
			$( data ).show();
			$( this ).parent( 'li' ).addClass( 'wp-tab-active' );
			return false;
		} );

		// Color picker
		$('div#tb-metabox .tb-mb-color-field').wpColorPicker();

		// Media uploader
		var _custom_media = true,
		_orig_send_attachment = wp.media.editor.send.attachment;

		$('div#tb-metabox .tb-mb-uploader').click(function(e) {
			var send_attachment_bkp	= wp.media.editor.send.attachment,
				button = $(this),
				id = button.prev();
			wp.media.editor.send.attachment = function(props, attachment){
				if ( _custom_media ) {
					$( id ).val( attachment.id );
				} else {
					return _orig_send_attachment.apply( this, [props, attachment] );
				};
			}
			wp.media.editor.open( button );
			return false;
		} );

		$( 'div#tb-metabox .add_media' ).on('click', function() {
			_custom_media = false;
		} );

		// Reset
		$( 'div#tb-metabox div.tb-mb-reset a.tb-reset-btn' ).click( function() {
			var confirm = $( 'div.tb-mb-reset div.tb-reset-checkbox' ),
				txt = confirm.is(':visible') ? "<?php echo __(  'Reset Settings', 'tb' ); ?>" : "<?php echo __(  'Cancel Reset', 'tb' ); ?>";
			$( this ).text( txt );
			$( 'div.tb-mb-reset div.tb-reset-checkbox input' ).attr('checked', false);
			confirm.toggle();
		});

		// Show hide title options
		var titleField = $( 'div#tb-metabox select#tb_disable_title' ),
			titleMainSettings = $( '#tb_disable_header_margin_tr, #tb_post_subheading_tr,#tb_post_title_style_tr'),
			titleStyleField = $( 'div#tb-metabox select#tb_post_title_style' ),
			titleStyleFieldVal = titleStyleField.val(),
			pageTitleBgSettings = $( '#tb_post_title_background_color_tr, #tb_post_title_background_redux_tr,#tb_post_title_height_tr,#tb_post_title_background_overlay_tr,#tb_post_title_background_overlay_opacity_tr'),
			solidColorElements = $( '#tb_post_title_background_color_tr');

		if ( titleField.val() === 'on' ) {
			titleMainSettings.hide();
			pageTitleBgSettings.hide();
		} else {
			titleMainSettings.show();
		}

		if ( titleStyleFieldVal === 'background-image' ) {
			pageTitleBgSettings.show();
		} else if ( titleStyleFieldVal === 'solid-color' ) {
			solidColorElements.show();
		}

		titleField.change(function () {
			if ( $(this).val() === 'on' ) {
				titleMainSettings.hide();
				pageTitleBgSettings.hide();
			} else {
				titleMainSettings.show();
				var titleStyleFieldVal = titleStyleField.val();
				if ( titleStyleFieldVal === 'background-image' ) {
					pageTitleBgSettings.show();
				} else if ( titleStyleFieldVal === 'solid-color' ) {
					solidColorElements.show();
				}
			}
		} );

		titleStyleField.change(function () {
			pageTitleBgSettings.hide();
			if ( $(this).val() == 'background-image' ) {
				pageTitleBgSettings.show();
			}
			else if ( $(this).val() === 'solid-color' ) {
				solidColorElements.show();
			}
		} );

		// Show hide Overlay options
		var overlayField = $( 'div#tb-metabox select#tb_overlay_header' ),
			overlayFieldDependents = $( '#tb_overlay_header_style_tr, #tb_overlay_header_font_size_tr,#tb_overlay_header_logo_tr,#tb_overlay_header_logo_retina_tr,#tb_overlay_header_logo_retina_height_tr');
		if ( overlayField.val() === 'on' ) {
			overlayFieldDependents.show();
		} else {
			overlayFieldDependents.hide();
		}
		overlayField.change(function () {
			if ( $(this).val() === 'on' ) {
				overlayFieldDependents.show();
			} else {
				overlayFieldDependents.hide();
			}
		} );


	} );

} ) ( jQuery );