/** * Enqueues the jQuery UI scripts * * @return void * @since 1.4 */ public function enqueueDatepicker() { wp_enqueue_script('jquery-ui-core'); wp_enqueue_script('jquery-ui-slider'); wp_enqueue_script('jquery-ui-datepicker'); wp_enqueue_script('tf-jquery-ui-timepicker-addon', ParadoxTitanFramework::getURL('../js/min/jquery-ui-timepicker-addon-min.js', __FILE__), array('jquery-ui-datepicker', 'jquery-ui-slider')); }
public static function factory($settings, $owner) { $settings = array_merge(self::$defaultSettings, $settings); $className = 'ParadoxTitanFrameworkOption' . str_replace(' ', '', ucwords(str_replace('-', ' ', $settings['type']))); // assume all the classes are already required if (!class_exists($className) && !class_exists($settings['type'])) { ParadoxTitanFramework::displayFrameworkError(sprintf(__('Option type or extended class %s does not exist.', PARADOX_TF_I18NDOMAIN), '<code>' . $settings['type'] . '</code>', $settings), $settings); return null; } if (class_exists($className)) { $obj = new $className($settings, $owner); return $obj; } $className = $settings['type']; $obj = new $className($settings, $owner); return $obj; }
public function loadUploaderScript() { wp_enqueue_media(); wp_enqueue_script('tf-theme-customizer-serialize', ParadoxTitanFramework::getURL('../js/min/serialize-min.js', __FILE__)); wp_enqueue_style('tf-admin-theme-customizer-styles', ParadoxTitanFramework::getURL('../css/admin-theme-customizer-styles.css', __FILE__)); }
/** * Attaches Titan Framework to the Paradox */ public function attachTitanFramework() { // If Titan Framework does not exists, quit if (!class_exists('ParadoxTitanFramework')) { return; } // Instantialize our less handler in this object $this->options = ParadoxTitanFramework::getInstance($this->id, array('css' => $this->config['frontendCSS'], 'multisite' => $this->config['multisite'])); // Call out adminPages function $this->adminPages(); }
/** * Loads all the admin scripts used by Titan Framework * * @since 1.0 * * @param string $hook The slug of admin page that called the enqueue. * * @return void */ public function loadAdminScripts($hook) { // Get all options panel IDs. $panel_ids = array(); if (!empty($this->mainContainers['admin-page'])) { foreach ($this->mainContainers['admin-page'] as $admin_panel) { $panel_ids[] = $admin_panel->panelID; } } // Only enqueue scripts if we're on a Titan options page. if (in_array($hook, $panel_ids) || !empty($this->mainContainers['meta-box'])) { wp_enqueue_media(); wp_enqueue_script('tf-serialize', ParadoxTitanFramework::getURL('../js/min/serialize-min.js', __FILE__)); wp_enqueue_script('tf-styling', ParadoxTitanFramework::getURL('../js/min/admin-styling-min.js', __FILE__)); wp_enqueue_style('tf-admin-styles', ParadoxTitanFramework::getURL('../css/admin-styles.css', __FILE__)); } }
/** * Enqueue the colorpicker scripts * * @since 1.9 * * @return void */ public function enqueueColorPickerScript() { wp_enqueue_script('wp-color-picker'); wp_enqueue_style('wp-color-picker'); wp_enqueue_script('wp-color-picker-alpha', ParadoxTitanFramework::getURL('../js/min/wp-color-picker-alpha-min.js', __FILE__), array('wp-color-picker'), PARADOX_TF_VERSION); }
/** * Loads the ACE library for displaying our syntax highlighted code editor * * @return void * @since 1.3 */ public function loadAdminScripts() { wp_enqueue_script('tf-ace', ParadoxTitanFramework::getURL('../js/ace-min-noconflict/ace.js', __FILE__)); wp_enqueue_script('tf-ace-theme-' . $this->settings['theme'], ParadoxTitanFramework::getURL('../js/ace-min-noconflict/theme-' . $this->settings['theme'] . '.js', __FILE__)); wp_enqueue_script('tf-ace-mode-' . $this->settings['lang'], ParadoxTitanFramework::getURL('../js/ace-min-noconflict/mode-' . $this->settings['lang'] . '.js', __FILE__)); }
/** * Creates the Javascript for running the font option * * @return void * @since 1.4 */ public static function createFontScript() { ?> <script> jQuery(document).ready(function($) { "use strict"; var _tf_select_font_throttle = null; // Initialize color pickers $('.tf-font .tf-font-sel-color, .tf-font .tf-font-sel-shadow-color').wpColorPicker({ change: function ( event, ui ) { // 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 ); } }); // 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 ); }); /** * Theme Customizer scripts */ // Check for font selector clicks, we need to adjust styles to make it look nice $('body.wp-customizer .tf-font').on('mouseup', function(e) { if ( $(e.target).is('.wp-color-result') ) { if ( ! $(e.target).is('.wp-picker-open') ) { $(e.target).parents('label:eq(0)').addClass('tf-picker-open'); } else { $(e.target).parents('label:eq(0)').removeClass('tf-picker-open'); } } }); // Check for close clicks (clicking outside while the picker is open) $('body.wp-customizer').on('mouseup', '*', function(e) { var $target = $(e.target); if ( $target.is('.wp-color-result, .wp-color-picker, .wp-picker-default') ) { return; } if ( $target.parents('.wp-picker-holder').length > 0 ) { return; } if ( $('.tf-picker-open').length > 0 ) { $('.tf-picker-open').removeClass('tf-picker-open'); } }); }); // 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': $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 ParadoxTitanFramework::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 }