function create_customizer_options() { $titan = TitanFramework::getInstance('thim'); TitanFrameworkOptionFontColor::$webSafeFonts = array('aileron' => 'Aileron', 'Arial, Helvetica, sans-serif' => 'Arial', '"Arial Black", Gadget, sans-serif' => 'Arial Black', '"Comic Sans MS", cursive, sans-serif' => 'Comic Sans', '"Courier New", Courier, monospace' => 'Courier New', 'Georgia, serif' => 'Geogia', 'Impact, Charcoal, sans-serif' => 'Impact', '"Lucida Console", Monaco, monospace' => 'Lucida Console', '"Lucida Sans Unicode", "Lucida Grande", sans-serif' => 'Lucida Sans', '"Palatino Linotype", "Book Antiqua", Palatino, serif' => 'Palatino', 'Tahoma, Geneva, sans-serif' => 'Tahoma', '"Times New Roman", Times, serif' => 'Times New Roman', '"Trebuchet MS", Helvetica, sans-serif' => 'Trebuchet', 'Verdana, Geneva, sans-serif' => 'Verdana'); /* Register Customizer Sections */ //include heading include TP_THEME_DIR . "/inc/admin/customizer-sections/logo.php"; include TP_THEME_DIR . "/inc/admin/customizer-sections/header.php"; include TP_THEME_DIR . "/inc/admin/customizer-sections/header-mainmenu.php"; include TP_THEME_DIR . "/inc/admin/customizer-sections/header-mobile.php"; // include TP_THEME_DIR . "/inc/admin/customizer-sections/header-offcanvas.php"; include TP_THEME_DIR . "/inc/admin/customizer-sections/header-submenu.php"; include TP_THEME_DIR . "/inc/admin/customizer-sections/header-stickymenu.php"; // include TP_THEME_DIR . "/inc/admin/customizer-sections/header-topdrawer.php"; //include styling include TP_THEME_DIR . "/inc/admin/customizer-sections/styling.php"; include TP_THEME_DIR . "/inc/admin/customizer-sections/styling-color.php"; include TP_THEME_DIR . "/inc/admin/customizer-sections/styling-layout.php"; include TP_THEME_DIR . "/inc/admin/customizer-sections/styling-pattern.php"; include TP_THEME_DIR . "/inc/admin/customizer-sections/styling-rtl.php"; //include display setting include TP_THEME_DIR . "/inc/admin/customizer-sections/display.php"; include TP_THEME_DIR . "/inc/admin/customizer-sections/display-archive.php"; include TP_THEME_DIR . "/inc/admin/customizer-sections/display-frontpage.php"; include TP_THEME_DIR . "/inc/admin/customizer-sections/display-postpage.php"; include TP_THEME_DIR . "/inc/admin/customizer-sections/display-404.php"; include TP_THEME_DIR . "/inc/admin/customizer-sections/display-sharing.php"; include TP_THEME_DIR . "/inc/admin/customizer-sections/display-loading.php"; //include woocommerce if (class_exists('WooCommerce')) { include TP_THEME_DIR . "/inc/admin/customizer-sections/woocommerce.php"; include TP_THEME_DIR . "/inc/admin/customizer-sections/woocommerce-archive.php"; include TP_THEME_DIR . "/inc/admin/customizer-sections/woocommerce-setting.php"; include TP_THEME_DIR . "/inc/admin/customizer-sections/woocommerce-sharing.php"; include TP_THEME_DIR . "/inc/admin/customizer-sections/woocommerce-single.php"; include TP_THEME_DIR . "/inc/admin/customizer-sections/woocommerce-badges.php"; } //include typography include TP_THEME_DIR . "/inc/admin/customizer-sections/typography.php"; //include footer include TP_THEME_DIR . "/inc/admin/customizer-sections/footer.php"; include TP_THEME_DIR . "/inc/admin/customizer-sections/footer-copyright.php"; include TP_THEME_DIR . "/inc/admin/customizer-sections/footer-options.php"; //include Custom Css include TP_THEME_DIR . "/inc/admin/customizer-sections/custom-css.php"; //include Import/Export include TP_THEME_DIR . "/inc/admin/customizer-sections/import-export.php"; //Page Event include TP_THEME_DIR . "/inc/admin/metabox-sections/event.php"; // One Page include TP_THEME_DIR . "/inc/admin/metabox-sections/onepage.php"; //include Document if (class_exists('wpdoc')) { include TP_THEME_DIR . "/inc/admin/customizer-sections/display-document.php"; } // Job if (class_exists('WP_Job_Manager')) { include TP_THEME_DIR . "/inc/admin/customizer-sections/display-job.php"; } }
/** * Creates the Javascript for running the font option * * @return void * @since 1.4 */ public static function createFontScript() { if (!self::$firstLoad) { return; } self::$firstLoad = false; ?> <script> jQuery(document).ready(function($) { "use strict"; var _tf_select_font_throttle = null; // Initialize color pickers Color.prototype.toString = function(remove_alpha) { if (remove_alpha == 'no-alpha') { return this.toCSS('rgba', '1').replace(/\s+/g, ''); } if (this._alpha < 1) { return this.toCSS('rgba', this._alpha).replace(/\s+/g, ''); } var hex = parseInt(this._color, 10).toString(16); if (this.error) return ''; if (hex.length < 6) { for (var i = 6 - hex.length - 1; i >= 0; i--) { hex = '0' + hex; } } return '#' + hex; }; jQuery('.color-picker-hex').each(function() { var $control = jQuery(this), value = $control.val().replace(/\s+/g, ''); // Manage Palettes var palette_input = $control.attr('data-palette'); if (palette_input == 'false' || palette_input == false) { var palette = false; } else if (palette_input == 'true' || palette_input == true) { var palette = true; } else { var palette = true; var palette = <?php global $primary_color; echo $primary_color ? $primary_color : "true"; ?> ; } $control.wpColorPicker({ // change some things with the color picker clear: function(event, ui) { // TODO reset Alpha Slider to 100 }, change: function(event, ui) { if (!$control.hasClass("tf-font-sel-color")) { // send ajax request to wp.customizer to enable Save & Publish button var _new_value = ui.color.toString(); var key = $control.attr('data-customize-setting-link'); try { wp.customize(key, function(obj) { //console.log(_new_value+ " - " +ui.color); obj.set(_new_value); }); } catch(err) { console.log(err); } }else { // update the preview, but throttle it to prevent fast loading if (_tf_select_font_throttle != null) { clearTimeout(_tf_select_font_throttle); _tf_select_font_throttle = null; } var $this = $(this); _tf_select_font_throttle = setTimeout(function () { tf_select_font_update_preview($this.parents('.tf-font:eq(0)'), true); }, 300); } // change the background color of our transparency container whenever a color is updated var $transparency = $control.parents('.wp-picker-container:first').find('.transparency'); // we only want to show the color at 100% alpha $transparency.css('backgroundColor', ui.color.toString('no-alpha')); }, palettes: palette // remove the color palettes }); jQuery('<div class="thim-alpha-container"><div class="slider-alpha"></div><div class="transparency"></div></div>').appendTo($control.parents('.wp-picker-container').find(".wp-picker-holder")); var $alpha_slider = $control.parents('.wp-picker-container:first').find('.slider-alpha'); // if in format RGBA - grab A channel value if (value.match(/rgba\(\d+\,\d+\,\d+\,([^\)]+)\)/)) { var alpha_val = parseFloat(value.match(/rgba\(\d+\,\d+\,\d+\,([^\)]+)\)/)[1]) * 100; var alpha_val = parseInt(alpha_val); } else { var alpha_val = 100; } $alpha_slider.slider({ slide: function(event, ui) { jQuery(this).find('.ui-slider-handle').text(ui.value); // show value on slider handle // send ajax request to wp.customizer to enable Save & Publish button var _new_value = $control.val(); var key = $control.attr('data-customize-setting-link'); try { wp.customize(key, function(obj) { obj.set(_new_value); }); } catch(err) { console.log(err); } }, create: function(event, ui) { var v = jQuery(this).slider('value'); jQuery(this).find('.ui-slider-handle').text(v); }, value: alpha_val, range: "max", step: 1, min: 0, max: 100 }); // slider $alpha_slider.slider().on('slidechange', function(event, ui) { var new_alpha_val = parseFloat(ui.value), iris = $control.data('a8cIris'), color_picker = $control.data('wpWpColorPicker'); iris._color._alpha = new_alpha_val / 100.0; $control.val(iris._color.toString()); color_picker.toggler.css({ backgroundColor: $control.val() }); // fix relationship between alpha slider and the 'side slider not updating. var get_val = $control.val(); jQuery($control).wpColorPicker('color', get_val); }); }); // each // Initialize the option $('.tf-font').each(function() { // Update save field on change $(this).find('select,.tf-font-sel-dark').change(function() { tf_select_font_update_preview( $(this).parents('.tf-font:eq(0)'), true ); }); // Trigger for toggling light/dark preview backgrounds $(this).find('.btn-dark').click(function() { var darkInput = $(this).parent().find('.tf-font-sel-dark'); if ( darkInput.val() == '' ) { darkInput.val('dark').trigger('change'); } else { darkInput.val('').trigger('change'); } }) // initialize preview tf_select_font_update_preview( $(this), true ); // We have to do this after 1ms for the theme customizer, or else the field's value // gets changed to a weird value var $this = $(this); setTimeout( function() { tf_select_font_update_preview( $this, false ) }, 1 ); }); $('body.wp-customizer').on('click', function(e) { $('.tf-font .wp-color-result').each(function() { if ( $(this).hasClass('wp-picker-open') ) { $(this).parents('label:eq(0)').addClass('tf-picker-open'); } else { if ( $(this).parents('label:eq(0)').hasClass('tf-picker-open') ) { $(this).parents('label:eq(0)').removeClass('tf-picker-open'); } } }); }); // chosen font $(".chosen-select").chosen({ allow_single_deselect: true, width: '60%' }); }); // Updates the option elements function tf_select_font_update_preview( $container, doTrigger ) { "use strict"; var $ = jQuery; // Show / hide shadow fields if ( $container.find(".tf-font-sel-location").val() == 'none' || $container.find('.tf-font-sel-location').parents('label:eq(0)').attr('data-visible') == 'false' ) { $container.find(".tf-font-sel-distance").parents('label:eq(0)').fadeOut(); $container.find(".tf-font-sel-blur").parents('label:eq(0)').fadeOut(); $container.find(".tf-font-sel-shadow-color").parents('label:eq(0)').fadeOut(); $container.find(".tf-font-sel-opacity").parents('label:eq(0)').fadeOut(); } else { $container.find(".tf-font-sel-distance").parents('label:eq(0)').fadeIn(); $container.find(".tf-font-sel-blur").parents('label:eq(0)').fadeIn(); $container.find(".tf-font-sel-shadow-color").parents('label:eq(0)').fadeIn(); $container.find(".tf-font-sel-opacity").parents('label:eq(0)').fadeIn(); } var family = $container.find('.tf-font-sel-family').val(); // These are all our parameters var params = { 'font-family': family, 'font-type': $container.find(".tf-font-sel-family option[value='" + family + "']").parent().attr('class'), 'color-opacity': $container.find(".tf-font-sel-color").val(), 'font-size': $container.find(".tf-font-sel-size").val(), 'font-weight': $container.find(".tf-font-sel-weight").val(), 'font-style': $container.find(".tf-font-sel-style").val(), 'line-height': $container.find(".tf-font-sel-height").val(), 'letter-spacing': $container.find(".tf-font-sel-spacing").val(), 'text-transform': $container.find(".tf-font-sel-transform").val(), 'font-variant': $container.find(".tf-font-sel-variant").val(), 'text-shadow-location': $container.find(".tf-font-sel-location").val(), 'text-shadow-distance': $container.find(".tf-font-sel-distance").val(), 'text-shadow-blur': $container.find(".tf-font-sel-blur").val(), 'text-shadow-color': $container.find(".tf-font-sel-shadow-color").val(), 'text-shadow-opacity': $container.find(".tf-font-sel-opacity").val(), 'dark': $container.find(".tf-font-sel-dark").val(), 'text': $container.find("iframe").attr('data-preview-text') } // Update preview if ( $container.find('iframe').is(':not([data-visible=false])') ) { $container.find('iframe').attr('src', '<?php echo TitanFramework::getURL('iframe-font-preview.php?', __FILE__); ?> ' + $.param(params) ); } // Update hidden save field $container.find('.tf-for-saving').val(serialize(params)); if ( doTrigger ) { $container.find('.tf-for-saving').trigger('change'); } } </script> <?php }