diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..b7e87e2d --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +*.DS_Store +composer.lock +/node_modules/ +/vendor/ +/logs/ +/reports/ diff --git a/404.php b/404.php index cdf2e4e4..2c7be533 100644 --- a/404.php +++ b/404.php @@ -1,12 +1,13 @@ __( 'Post Options', 'tm-beans' ) ) ); - } diff --git a/lib/admin/updater.php b/lib/admin/updater.php index ed21af1d..9b1b5fb6 100644 --- a/lib/admin/updater.php +++ b/lib/admin/updater.php @@ -2,26 +2,34 @@ /** * Handles Beans updates. * - * @package Beans - * @since 1.0.0 + * @package Beans\Framework\Admin + * + * @since 1.0.0 */ add_filter( 'site_transient_update_themes', 'beans_updater' ); /** - * Retrieve product data from Beans REST API. + * Retrieve product data from the Beans REST API. * - * Data are cached in a 24 hours transients and will be returned if found to avoid long loading time. + * Data is cached in a transient for 24 hours. Product data will only be retrieved + * if no transient is found to avoid long loading times. * + * @since 1.0.0 * @ignore + * @access private + * + * @param object $value Update check object. + * + * @return object Modified update check object. */ function beans_updater( $value ) { - // Stop here if the current user is not a super admin user. + // Stop here if the current user is not a super admin. if ( ! is_super_admin() ) { return; } - $data = get_site_transient( 'beans_updater' ); + $data = get_site_transient( 'beans_updater' ); $theme = wp_get_theme( 'tm-beans' ); if ( ! $theme->exists() ) { @@ -30,31 +38,24 @@ function beans_updater( $value ) { $current_version = $theme->get( 'Version' ); - // Query Beans REST API if the transient is expired. + // Query the Beans REST API if the transient is expired. if ( empty( $data ) ) { - - $response = wp_remote_get( 'http://www.getbeans.io/rest-api/', array( 'sslverify' => false ) ); + $response = wp_remote_get( 'https://www.getbeans.io/rest-api/' ); // Retrieve data from the body and decode json format. $data = json_decode( wp_remote_retrieve_body( $response ), true ); - // Stop here if the is an error. + // Stop here if there is an error, set a temporary transient and bail out. if ( is_wp_error( $response ) || isset( $data['error'] ) ) { - - // Set temporary transient. set_site_transient( 'beans_updater', array( 'version' => $current_version ), 30 * MINUTE_IN_SECONDS ); - return $value; - } set_site_transient( 'beans_updater', $data, 24 * HOUR_IN_SECONDS ); - } // Return data if Beans is not up to date. if ( version_compare( $current_version, beans_get( 'version', $data ), '<' ) ) { - $value->response[ $data['path'] ] = array( 'slug' => $data['slug'], 'name' => $data['name'], @@ -64,23 +65,22 @@ function beans_updater( $value ) { 'tested' => $data['tested'], 'requires' => $data['requires'], ); - return $value; - } return $value; - } add_action( 'load-update-core.php', 'beans_updater_clear_transient' ); /** * Clear updater transient. * + * @since 1.0.0 * @ignore + * @access private + * + * @return void */ function beans_updater_clear_transient() { - delete_site_transient( 'beans_updater' ); - } diff --git a/lib/admin/wp-customize.php b/lib/admin/wp-customize.php index 998d1afb..7cd1fba0 100644 --- a/lib/admin/wp-customize.php +++ b/lib/admin/wp-customize.php @@ -2,7 +2,9 @@ /** * Add Beans options to the WordPress Customizer. * - * @package Admin + * @package Beans\Framework\Admin + * + * @since 1.0.0 */ beans_add_smart_action( 'customize_preview_init', 'beans_do_enqueue_wp_customize_assets' ); @@ -10,11 +12,14 @@ * Enqueue Beans assets for the WordPress Customizer. * * @since 1.0.0 + * + * @return void */ function beans_do_enqueue_wp_customize_assets() { - - wp_enqueue_script( 'beans-wp-customize-preview', BEANS_ADMIN_JS_URL . 'wp-customize-preview.js', array( 'jquery', 'customize-preview' ), BEANS_VERSION, true ); - + wp_enqueue_script( 'beans-wp-customize-preview', BEANS_ADMIN_JS_URL . 'wp-customize-preview.js', array( + 'jquery', + 'customize-preview', + ), BEANS_VERSION, true ); } beans_add_smart_action( 'customize_register', 'beans_do_register_wp_customize_options' ); @@ -22,9 +27,10 @@ function beans_do_enqueue_wp_customize_assets() { * Add Beans options to the WordPress Customizer. * * @since 1.0.0 + * + * @return void */ function beans_do_register_wp_customize_options() { - $fields = array( array( 'id' => 'beans_logo_image', @@ -40,29 +46,37 @@ function beans_do_register_wp_customize_options() { // Only show the layout options if more than two layouts are registered. if ( count( $options ) > 2 ) { - $fields = array( array( - 'id' => 'beans_layout', - 'label' => __( 'Default Layout', 'tm-beans' ), - 'type' => 'radio', - 'default' => beans_get_default_layout(), - 'options' => $options, + 'id' => 'beans_layout', + 'label' => __( 'Default Layout', 'tm-beans' ), + 'type' => 'radio', + 'default' => beans_get_default_layout(), + 'options' => $options, ), ); - beans_register_wp_customize_options( $fields, 'beans_layout', array( 'title' => __( 'Default Layout', 'tm-beans' ), 'priority' => 1000 ) ); - + beans_register_wp_customize_options( + $fields, + 'beans_layout', + array( + 'title' => __( 'Default Layout', 'tm-beans' ), + 'priority' => 1000, + ) + ); } $fields = array( array( - 'id' => 'beans_viewport_width_group', - 'label' => __( 'Viewport Width', 'tm-beans' ), - 'type' => 'group', - 'fields' => array( + 'id' => 'beans_viewport_width_group', + 'label' => __( 'Viewport Width - for Previewing Only', 'tm-beans' ), + 'description' => __( 'Slide left or right to change the viewport width. Publishing will not change the width of your website.', 'tm-beans' ), + 'type' => 'group', + 'transport' => 'postMessage', + 'fields' => array( array( 'id' => 'beans_enable_viewport_width', + 'label' => __( 'Enable to change the viewport width.', 'tm-beans' ), 'type' => 'activation', 'default' => false, ), @@ -78,12 +92,15 @@ function beans_do_register_wp_customize_options() { ), ), array( - 'id' => 'beans_viewport_height_group', - 'label' => __( 'Viewport Height', 'tm-beans' ), - 'type' => 'group', - 'fields' => array( + 'id' => 'beans_viewport_height_group', + 'label' => __( 'Viewport Height - for Previewing Only', 'tm-beans' ), + 'description' => __( 'Slide left or right to change the viewport height. Publishing will not change the height of your website.', 'tm-beans' ), + 'type' => 'group', + 'transport' => 'postMessage', + 'fields' => array( array( 'id' => 'beans_enable_viewport_height', + 'label' => __( 'Enable to change the viewport height.', 'tm-beans' ), 'type' => 'activation', 'default' => false, ), @@ -100,6 +117,12 @@ function beans_do_register_wp_customize_options() { ), ); - beans_register_wp_customize_options( $fields, 'beans_preview', array( 'title' => __( 'Preview Tools', 'tm-beans' ), 'priority' => 1010 ) ); - + beans_register_wp_customize_options( + $fields, + 'beans_preview', + array( + 'title' => __( 'Preview Tools', 'tm-beans' ), + 'priority' => 1010, + ) + ); } diff --git a/lib/api/actions/class-beans-anonymous-action.php b/lib/api/actions/class-beans-anonymous-action.php new file mode 100644 index 00000000..25255e9b --- /dev/null +++ b/lib/api/actions/class-beans-anonymous-action.php @@ -0,0 +1,56 @@ +callback = $callback; + + add_action( $hook, array( $this, 'callback' ), $priority, $number_args ); + } + + /** + * Get action content and set it as the callback. + * + * @since 1.5.0 + * + * @return void + */ + public function callback() { + echo call_user_func_array( $this->callback[0], $this->callback[1] ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- The callback handles escaping its output, as Beans does not know what HTML or content will be passed back to it. + } +} diff --git a/lib/api/actions/class.php b/lib/api/actions/class.php deleted file mode 100644 index 4cab2c38..00000000 --- a/lib/api/actions/class.php +++ /dev/null @@ -1,49 +0,0 @@ -callback = $callback; - - add_action( $hook, array( $this, 'callback' ), $priority, $args ); - - } - - /** - * Get action content and set it as the callback. - */ - public function callback() { - - echo call_user_func_array( $this->callback[0], $this->callback[1] ); - - } -} diff --git a/lib/api/actions/functions.php b/lib/api/actions/functions.php index f66840ec..379ffd88 100644 --- a/lib/api/actions/functions.php +++ b/lib/api/actions/functions.php @@ -5,31 +5,33 @@ * While WordPress requires two or three arguments to remove an action, Beans * actions can be modified, replaced, removed or reset using only the ID as a reference. * - * @package API\Actions + * @package Beans\Framework\API\Actions + * + * @since 1.5.0 */ /** - * Hooks a function on to a specific action. + * Hooks a callback (function or method) to a specific action event. * - * This function is similar to {@link http://codex.wordpress.org/Function_Reference/add_action add_action()} - * with the exception of being registered by ID in order to be manipulated by the other Beans Actions functions. + * This function is similar to {@link https://codex.wordpress.org/Function_Reference/add_action add_action()} + * with the exception of being registered by ID within Beans in order to be manipulated by the other Beans + * Actions functions. * * @since 1.0.0 - * - * @param string $id A unique string used as a reference. - * @param string $hook The name of the action to which the $callback is hooked. - * @param callback $callback The name of the function you wish to be called. - * @param int $priority Optional. Used to specify the order in which the functions - * associated with a particular action are executed. Default 10. - * Lower numbers correspond with earlier execution, - * and functions with the same priority are executed - * in the order in which they were added to the action. - * @param int $args Optional. The number of arguments the function accepts. Default 1. - * - * @return bool Will always return true. + * @since 1.5.0 Returns false when action is not added via add_action. + * + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param string $hook The name of the action to which the `$callback` is hooked. + * @param callable $callback The name of the function|method you wish to be called when the action event fires. + * @param int $priority Optional. Used to specify the order in which the callbacks associated with a particular + * action are executed. Default is 10. + * Lower numbers correspond with earlier execution. Callbacks with the same priority + * are executed in the order in which they were added to the action. + * @param int $args Optional. The number of arguments the callback accepts. Default is 1. + * + * @return bool */ function beans_add_action( $id, $hook, $callback, $priority = 10, $args = 1 ) { - $action = array( 'hook' => $hook, 'callback' => $callback, @@ -37,301 +39,302 @@ function beans_add_action( $id, $hook, $callback, $priority = 10, $args = 1 ) { 'args' => $args, ); - // Replace original if set. - if ( $replaced = _beans_get_action( $id, 'replaced' ) ) { - $action = array_merge( $action, $replaced ); + $replaced_action = _beans_get_action( $id, 'replaced' ); + + // If the ID is set to be "replaced", then replace that(those) parameter(s). + if ( ! empty( $replaced_action ) ) { + $action = array_merge( $action, $replaced_action ); } $action = _beans_set_action( $id, $action, 'added', true ); - // Stop here if removed. + // If the ID is set to be "removed", then bail out. if ( _beans_get_action( $id, 'removed' ) ) { - return; + return false; } - // Merge modified. - if ( $modified = _beans_get_action( $id, 'modified' ) ) { - $action = array_merge( $action, $modified ); - } + $modified_action = _beans_get_action( $id, 'modified' ); - // Validate action arguments. - if ( count( $action ) == 4 ) { - add_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); + // If the ID is set to be "modified", then modify that(those) parameter(s). + if ( ! empty( $modified_action ) ) { + $action = array_merge( $action, $modified_action ); } - return true; - + return add_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); } /** * Set {@see beans_add_action()} using the callback argument as the action ID. * - * This function is a shortcut of {@see beans_add_action()}. It does't require an ID - * to be specified and uses the callback argument instead. + * This function is a shortcut of {@see beans_add_action()}. It does't require a Beans ID as it uses the + * callback argument instead. * * @since 1.0.0 + * @since 1.5.0 Returns false when action is not added via add_action. * - * @param string $hook The name of the action to which the $callback is hooked. - * @param callback $callback The name of the function you wish to be called. Used to set the action ID. - * @param int $priority Optional. Used to specify the order in which the functions - * associated with a particular action are executed. Default 10. - * Lower numbers correspond with earlier execution, - * and functions with the same priority are executed - * in the order in which they were added to the action. - * @param int $args Optional. The number of arguments the function accept. Default 1. + * @param string $hook The name of the action to which the `$callback` is hooked. + * @param callable $callback The name of the function|method you wish to be called when the action event fires. + * @param int $priority Optional. Used to specify the order in which the callbacks associated with a particular + * action are executed. Default is 10. + * Lower numbers correspond with earlier execution. Callbacks with the same priority + * are executed in the order in which they were added to the action. + * @param int $args Optional. The number of arguments the callback accepts. Default is 1. * - * @return bool Will always return true. + * @return bool */ function beans_add_smart_action( $hook, $callback, $priority = 10, $args = 1 ) { - return beans_add_action( $callback, $hook, $callback, $priority, $args ); - } /** - * Modify an action. + * Modify one or more of the arguments for the given action, i.e. referenced by its Bean's ID. * - * This function modifies an action registered using {@see beans_add_action()} or - * {@see beans_add_smart_action()}. Each optional argument must be set to NULL to keep the orginal value. + * This function modifies a registered action using {@see beans_add_action()} or + * {@see beans_add_smart_action()}. Each optional argument must be set to NULL to keep the original value. * * The original action can be reset using {@see beans_reset_action()}. * * @since 1.0.0 - * - * @param string $id The action ID. - * @param string $hook Optional. The name of the new action to which the $callback is hooked. - * Use NULL to keep the original value. - * @param callback $callback Optional. The name of the new function you wish to be called. - * Use NULL to keep the original value. - * @param int $priority Optional. The new priority. - * Use NULL to keep the original value. - * @param int $args Optional. The new number of arguments the function accept. - * Use NULL to keep the original value. - * - * @return bool Will always return true. + * @since 1.5.0 Improved action parameter filtering. + * + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param string|null $hook Optional. The new action's event name to which the $callback is hooked. + * Use NULL to keep the original value. + * @param callable|null $callback Optional. The new callback (function or method) you wish to be called. + * Use NULL to keep the original value. + * @param int|null $priority Optional. The new priority. + * Use NULL to keep the original value. + * @param int|null $args Optional. The new number of arguments the $callback accepts. + * Use NULL to keep the original value. + * + * @return bool */ function beans_modify_action( $id, $hook = null, $callback = null, $priority = null, $args = null ) { + $action = _beans_build_action_array( $hook, $callback, $priority, $args ); - // Remove action. - if ( $current = _beans_get_current_action( $id ) ) { - remove_action( $current['hook'], $current['callback'], $current['priority'], $current['args'] ); + // If no changes were passed in, there's nothing to modify. Bail out. + if ( empty( $action ) ) { + return false; } - $action = array_filter( array( - 'hook' => $hook, - 'callback' => $callback, - 'priority' => $priority, - 'args' => $args, - ) ); - - // Merge modified. - $action = _beans_merge_action( $id, $action, 'modified' ); - - // Replace if needed. - if ( $current ) { + $current_action = _beans_get_current_action( $id ); - $action = array_merge( $current, $action ); + // If the action is registered, let's remove it. + if ( ! empty( $current_action ) ) { + remove_action( $current_action['hook'], $current_action['callback'], $current_action['priority'] ); + } - add_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); + // Merge the modified parameters and register with Beans. + $action = _beans_merge_action( $id, $action, 'modified' ); + // If there is no action to modify, bail out. + if ( empty( $current_action ) ) { + return false; } - return true; + // Overwrite the modified parameters. + $action = array_merge( $current_action, $action ); + return add_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); } /** - * Modify an action hook. + * Modify one or more of the arguments for the given action, i.e. referenced by its Bean's ID. * * This function is a shortcut of {@see beans_modify_action()}. * * @since 1.0.0 + * @since 1.5.0 Return false if the hook is empty or not a string. * - * @param string $id The action ID. - * @param string $hook Optional. The name of the new action to which the $callback is hooked. Use NULL to - * keep the original value. + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param string $hook The new action's event name to which the callback is hooked. * - * @return bool Will always return true. + * @return bool */ function beans_modify_action_hook( $id, $hook ) { - return beans_modify_action( $id, $hook ); + if ( empty( $hook ) || ! is_string( $hook ) ) { + return false; + } + return beans_modify_action( $id, $hook ); } /** - * Modify an action callback. + * Modify the callback of the given action, i.e. referenced by its Bean's ID. * * This function is a shortcut of {@see beans_modify_action()}. * * @since 1.0.0 + * @since 1.5.0 Return false if the callback is empty. * - * @param string $id The action ID. - * @param string $callback Optional. The name of the new function you wish to be called. Use NULL to keep - * the original value. + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param callable $callback The new callback (function or method) you wish to be called. * - * @return bool Will always return true. + * @return bool */ function beans_modify_action_callback( $id, $callback ) { - return beans_modify_action( $id, null, $callback ); + if ( empty( $callback ) ) { + return false; + } + return beans_modify_action( $id, null, $callback ); } /** - * Modify an action priority. + * Modify the priority of the given action, i.e. referenced by its Bean's ID. * * This function is a shortcut of {@see beans_modify_action()}. * * @since 1.0.0 * - * @param string $id The action ID. - * @param int $priority Optional. The new priority. Use NULL to keep the original value. + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param int|string $priority The new priority. * - * @return bool Will always return true. + * @return bool */ -function beans_modify_action_priority( $id, $callback ) { - - return beans_modify_action( $id, null, null, $callback ); - +function beans_modify_action_priority( $id, $priority ) { + return beans_modify_action( $id, null, null, $priority ); } /** - * Modify an action arguments. + * Modify the number of arguments of the given action, i.e. referenced by its Bean's ID. * * This function is a shortcut of {@see beans_modify_action()}. * * @since 1.0.0 * - * @param string $id The action ID. - * @param int $args Optional. The new number of arguments the function accepts. Use NULL to keep the - * original value. + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param int|string $number_of_args The new number of arguments the $callback accepts. * - * @return bool Will always return true. + * @return bool */ -function beans_modify_action_arguments( $id, $args ) { - - return beans_modify_action( $id, null, null, null, $args ); - +function beans_modify_action_arguments( $id, $number_of_args ) { + return beans_modify_action( $id, null, null, null, $number_of_args ); } /** - * Replace an action. + * Replace one or more of the arguments for the given action, i.e. referenced by its Bean's ID. * * This function replaces an action registered using {@see beans_add_action()} or * {@see beans_add_smart_action()}. Each optional argument must be set to NULL to keep - * the orginal value. + * the original value. * - * While {@see beans_modify_action()} will keep the original value registered, this function - * will overwrite the original action. If the action is reset using {@see beans_reset_action()}, - * the replaced values will be used. + * This function is not resettable as it overwrites the original action's argument(s). + * That means using {@see beans_reset_action()} will not restore the original action. * * @since 1.0.0 - * - * @param string $id The action ID. - * @param string $hook Optional. The name of the new action to which the $callback is hooked. - * Use NULL to keep the original value. - * @param callback $callback Optional. The name of the new function you wish to be called. - * Use NULL to keep the original value. - * @param int $priority Optional. The new priority. - * Use NULL to keep the original value. - * @param int $args Optional. The new number of arguments the function accepts. - * Use NULL to keep the original value. - * - * @return bool Will always return true. + * @since 1.5.0 Returns false when no replacement arguments are passed. + * + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param string|null $hook Optional. The new action's event name to which the $callback is hooked. + * Use NULL to keep the original value. + * @param callable|null $callback Optional. The new callback (function or method) you wish to be called. + * Use NULL to keep the original value. + * @param int|null $priority Optional. The new priority. + * Use NULL to keep the original value. + * @param int|null $args Optional. The new number of arguments the $callback accepts. + * Use NULL to keep the original value. + * + * @return bool */ function beans_replace_action( $id, $hook = null, $callback = null, $priority = null, $args = null ) { + $action = _beans_build_action_array( $hook, $callback, $priority, $args ); - $action = array( - 'hook' => $hook, - 'callback' => $callback, - 'priority' => $priority, - 'args' => $args, - ); + // If no changes were passed in, there's nothing to modify. Bail out. + if ( empty( $action ) ) { + return false; + } - // Set and get the latest replaced. - $action = _beans_merge_action( $id, array_filter( $action ), 'replaced' ); + // Set and get the latest "replaced" action. + $action = _beans_merge_action( $id, $action, 'replaced' ); - // Set and get the latest added. - $action = _beans_merge_action( $id, $action, 'added' ); + // Modify the action. + $is_modified = beans_modify_action( $id, $hook, $callback, $priority, $args ); - return beans_modify_action( $id, $hook, $callback, $priority, $args ); + // If there's a current action, merge it with the replaced one; else, it will be replaced when the original is added. + if ( $is_modified ) { + _beans_merge_action( $id, $action, 'added' ); + } + return $is_modified; } /** - * Replace an action hook. + * Replace the action's event name (hook) for the given action, i.e. referenced by its Bean's ID. * * This function is a shortcut of {@see beans_replace_action()}. * * @since 1.0.0 + * @since 1.5.0 Return false if the hook is empty or not a string. * - * @param string $id The action ID. - * @param string $hook Optional. The name of the new action to which the $callback is hooked. Use NULL to keep - * the original value. + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param string $hook The new action's event name to which the callback is hooked. * - * @return bool Will always return true. + * @return bool */ function beans_replace_action_hook( $id, $hook ) { - return beans_replace_action( $id, $hook ); + if ( empty( $hook ) || ! is_string( $hook ) ) { + return false; + } + return beans_replace_action( $id, $hook ); } /** - * Replace an action callback. + * Replace the callback of the given action, i.e. referenced by its Bean's ID. * * This function is a shortcut of {@see beans_replace_action()}. * * @since 1.0.0 + * @since 1.5.0 Return false if the callback is empty. * - * @param string $id The action ID. - * @param string $callback Optional. The name of the new function you wish to be called. Use NULL to keep - * the original value. + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param string $callback The new callback (function or method) you wish to be called. * - * @return bool Will always return true. + * @return bool */ function beans_replace_action_callback( $id, $callback ) { - return beans_replace_action( $id, null, $callback ); + if ( empty( $callback ) ) { + return false; + } + return beans_replace_action( $id, null, $callback ); } /** - * Replace an action priority. + * Replace the priority of the given action, i.e. referenced by its Bean's ID. * * This function is a shortcut of {@see beans_replace_action()}. * * @since 1.0.0 * - * @param string $id The action ID. - * @param int $priority Optional. The new priority. Use NULL to keep the original value. + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param int $priority The new priority. * - * @return bool Will always return true. + * @return bool */ -function beans_replace_action_priority( $id, $callback ) { - +function beans_replace_action_priority( $id, $priority ) { return beans_replace_action( $id, null, null, $priority ); - } /** - * Replace an action argument. + * Replace the number of arguments of the given action, i.e. referenced by its Bean's ID. * * This function is a shortcut of {@see beans_replace_action()}. * * @since 1.0.0 * - * @param string $id The action ID. - * @param int $args Optional. The new number of arguments the function accepts. Use NULL to keep the original - * value. + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param int $args The new number of arguments the $callback accepts. * - * @return bool Will always return true. + * @return bool */ function beans_replace_action_arguments( $id, $args ) { - return beans_replace_action( $id, null, null, null, $args ); - } /** @@ -340,55 +343,73 @@ function beans_replace_action_arguments( $id, $args ) { * This function removes an action registered using {@see beans_add_action()} or * {@see beans_add_smart_action()}. The original action can be re-added using {@see beans_reset_action()}. * + * This function is "load order" agnostic, meaning that you can remove an action before it's added. + * * @since 1.0.0 + * @since 1.5.0 When no current action, sets "removed" to default configuration. * - * @param string $id The action ID. + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. * - * @return bool Will always return true. + * @return bool */ function beans_remove_action( $id ) { + $action = _beans_get_current_action( $id ); - // Remove. - if ( $action = _beans_get_current_action( $id ) ) { - remove_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); + // When there is a current action, remove it. + if ( ! empty( $action ) ) { + remove_action( $action['hook'], $action['callback'], $action['priority'] ); + } else { + // If the action is not registered yet, set it to a default configuration. + $action = array( + 'hook' => null, + 'callback' => null, + 'priority' => null, + 'args' => null, + ); } - // Register as removed. - _beans_set_action( $id, $action, 'removed' ); - - return true; - + // Store as "removed". + return _beans_set_action( $id, $action, 'removed' ); } /** * Reset an action. * * This function resets an action registered using {@see beans_add_action()} or - * {@see beans_add_smart_action()}. If the original values were replaced using - * {@see beans_replace_action()}, these values will be used. + * {@see beans_add_smart_action()}. + * + * If the original values were replaced using {@see beans_replace_action()}, these values will be used, as + * {@see beans_replace_action()} is not resettable. * * @since 1.0.0 + * @since 1.5.0 Bail out if the action does not need to be reset. * - * @param string $id The action ID. + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. * - * @return bool Will always return true. + * @return bool */ function beans_reset_action( $id ) { - _beans_unset_action( $id, 'modified' ); _beans_unset_action( $id, 'removed' ); $action = _beans_get_action( $id, 'added' ); - if ( $current = _beans_get_current_action( $id ) ) { + // If there is no "added" action, bail out. + if ( empty( $action ) ) { + return false; + } - remove_action( $current['hook'], $current['callback'], $current['priority'], $current['args'] ); - add_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); + $current = _beans_get_current_action( $id ); + // If there's no current action, return the "added" action. + if ( empty( $current ) ) { + return $action; } - return $action; + remove_action( $current['hook'], $current['callback'], $current['priority'] ); + add_action( $action['hook'], $action['callback'], $action['priority'], $action['args'] ); + return $action; } /** @@ -408,204 +429,327 @@ function beans_reset_action( $id ) { } /** - * Get action. + * Get the action's configuration for the given ID and status. Returns `false` if the action is not registered with + * Beans. * + * @since 1.0.0 * @ignore + * @access private + * + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param string $status Status for which to get the action. + * + * @return array|bool */ function _beans_get_action( $id, $status ) { - global $_beans_registered_actions; - $id = _beans_unique_action_id( $id ); + $registered_actions = beans_get( $status, $_beans_registered_actions ); - if ( ! $registered = beans_get( $status, $_beans_registered_actions ) ) { + // If the status is empty, return false, as no actions are registered. + if ( empty( $registered_actions ) ) { return false; } - if ( ! $action = beans_get( $id, $registered ) ) { + $id = _beans_unique_action_id( $id ); + $action = beans_get( $id, $registered_actions ); + + // If the action is empty, return false. + if ( empty( $action ) ) { return false; } - return (array) json_decode( $action ); - + return $action; } /** - * Set action. + * Store the action's configuration for the given ID and status. + * + * What happens if the action's configuration is already registered? If the `$overwrite` flag is set to `true`, + * then the new action's configuration is stored, overwriting the previous one. Else, the registered action's + * configuration is returned. * + * @since 1.0.0 * @ignore + * @access private + * + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param array|mixed $action The action configuration to store. + * @param string $status Status for which to store the action. + * @param bool $overwrite Optional. When set to `true`, the new action's configuration is stored, overwriting a + * previously stored configuration (if one exists). + * + * @return array|mixed */ function _beans_set_action( $id, $action, $status, $overwrite = false ) { - - global $_beans_registered_actions; - $id = _beans_unique_action_id( $id ); - // Return action which already exist unless overwrite is set to true. - if ( ! $overwrite && ( $_action = _beans_get_action( $id, $status ) ) ) { - return $_action; + // If not overwriting, return the registered action (if it's registered). + if ( ! $overwrite ) { + $registered_action = _beans_get_action( $id, $status ); + + if ( ! empty( $registered_action ) ) { + return $registered_action; + } } - $_beans_registered_actions[ $status ][ $id ] = json_encode( $action ); + if ( ! empty( $action ) || 'removed' === $status ) { + global $_beans_registered_actions; + $_beans_registered_actions[ $status ][ $id ] = $action; + } return $action; - } /** - * Unset action. + * Unset the action's configuration for the given ID and status. Returns `false` if there are is no action + * registered with Beans actions for the given ID and status. Else, returns true when complete. * + * @since 1.0.0 * @ignore + * @access private + * + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param string $status Status for which to get the action. + * + * @return bool */ function _beans_unset_action( $id, $status ) { - - global $_beans_registered_actions; - $id = _beans_unique_action_id( $id ); - // Stop here if the action doesn't exist. - if ( ! _beans_get_action( $id, $status ) ) { + // Bail out if the ID is not registered for the given status. + if ( false === _beans_get_action( $id, $status ) ) { return false; } + global $_beans_registered_actions; unset( $_beans_registered_actions[ $status ][ $id ] ); return true; - } /** - * Merge action. + * Merge the action's configuration and then store it for the given ID and status. + * + * If the action's configuration has not already been registered with Beans, just store it. * + * @since 1.0.0 * @ignore + * @access private + * + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * @param array $action The new action's configuration to merge and then store. + * @param string $status Status for which to merge/store this action. + * + * @return array */ -function _beans_merge_action( $id, $action, $status ) { +function _beans_merge_action( $id, array $action, $status ) { + $id = _beans_unique_action_id( $id ); + $registered_action = _beans_get_action( $id, $status ); - global $_beans_registered_actions; - - $id = _beans_unique_action_id( $id ); - - if ( $_action = _beans_get_action( $id, $status ) ) { - $action = array_merge( $_action, $action ); + // If the action's configuration is already registered with Beans, merge the new configuration with it. + if ( ! empty( $registered_action ) ) { + $action = array_merge( $registered_action, $action ); } + // Now store/register it. return _beans_set_action( $id, $action, $status, true ); - } /** - * Check all action status and return the current action. + * Get the current action, meaning get from the "added" and/or "modified" statuses. * + * @since 1.0.0 + * @since 1.5.0 Bails out if there is no "added" action registered. * @ignore + * @access private + * + * @param string $id The action's Beans ID, a unique ID tracked within Beans for this action. + * + * @return array|bool */ function _beans_get_current_action( $id ) { - $action = array(); - + // Bail out if the action is "removed". if ( _beans_get_action( $id, 'removed' ) ) { return false; } - if ( $added = _beans_get_action( $id, 'added' ) ) { - $action = $added; + $added = _beans_get_action( $id, 'added' ); + + // If there is no "added" action registered, bail out. + if ( empty( $added ) ) { + return false; } - if ( $modified = _beans_get_action( $id, 'modified' ) ) { - $action = array_merge( $action, $modified ); + $modified = _beans_get_action( $id, 'modified' ); + + // If the action is set to be modified, merge the changes and return the action. + if ( ! empty( $modified ) ) { + return array_merge( $added, $modified ); } - // Stop here if the action is invalid. - if ( 4 != count( $action ) ) { - return false; + return $added; +} + +/** + * Build the action's array for only the valid given arguments. + * + * @since 1.5.0 + * + * @param string|null $hook Optional. The action event's name to which the $callback is hooked. + * Valid when not falsey, + * i.e. (meaning not `null`, `false`, `0`, `0.0`, an empty string, or empty array). + * @param callable|null $callback Optional. The callback (function or method) you wish to be called when the event + * fires. Valid when not falsey, i.e. (meaning not `null`, `false`, `0`, `0.0`, an empty + * string, or empty array). + * @param int|null $priority Optional. Used to specify the order in which the functions associated with a + * particular action are executed. Valid when it's numeric, including 0. + * @param int|null $args Optional. The number of arguments the callback accepts. + * Valid when it's numeric, including 0. + * + * @return array + */ +function _beans_build_action_array( $hook = null, $callback = null, $priority = null, $args = null ) { + $action = array(); + + if ( ! empty( $hook ) ) { + $action['hook'] = $hook; } - return $action; + if ( ! empty( $callback ) ) { + $action['callback'] = $callback; + } + + foreach ( array( 'priority', 'args' ) as $arg_name ) { + $arg = ${$arg_name}; + + if ( is_numeric( $arg ) ) { + $action[ $arg_name ] = (int) $arg; + } + } + return $action; } /** * Add anonymous callback using a class since php 5.2 is still supported. * + * @since 1.5.0 * @ignore + * @access private + * + * @param string $hook The name of the action to which the $callback is hooked. + * @param array $callback The callback to register to the given $hook and arguments to pass. + * @param int $priority Optional. Used to specify the order in which the functions + * associated with a particular action are executed. Default 10. + * Lower numbers correspond with earlier execution, + * and functions with the same priority are executed + * in the order in which they were added to the action. + * @param int $number_args Optional. The number of arguments the function accepts. Default 1. + * + * @return _Beans_Anonymous_Action */ -function _beans_add_anonymous_action( $hook, $callback, $priority = 10, $args = 1 ) { - - require_once( BEANS_API_PATH . 'actions/class.php' ); - - new _Beans_Anonymous_Actions( $hook, $callback, $priority, $args ); +function _beans_add_anonymous_action( $hook, array $callback, $priority = 10, $number_args = 1 ) { + require_once BEANS_API_PATH . 'actions/class-beans-anonymous-action.php'; + return new _Beans_Anonymous_Action( $hook, $callback, $priority, $number_args ); } /** * Render action which can therefore be stored in a variable. * + * @since 1.5.0 * @ignore + * @access private + * + * @param mixed $hook Hook and possibly sub-hooks to be rendered. + * + * @return bool|null|string */ function _beans_render_action( $hook ) { - $args = func_get_args(); - // Return simple action if no sub-hook is set. - if ( ! preg_match_all( '#\[(.*?)\]#', $args[0], $matches ) ) { - - if ( has_filter( $args[0] ) ) { - return call_user_func_array( 'beans_render_function', array_merge( array( 'do_action' ), $args ) ); - } else { - return false; - } + // Return simple action if no sub-hook(s) is(are) set. + if ( ! preg_match_all( '#\[(.*?)\]#', $args[0], $sub_hooks ) ) { + return _beans_when_has_action_do_render( $args ); } - $output = null; - $prefix = current( explode( '[', $args[0] ) ); + $output = null; + $prefix = current( explode( '[', $args[0] ) ); $variable_prefix = $prefix; - $suffix = preg_replace( '/^.*\]\s*/', '', $args[0] ); + $suffix = preg_replace( '/^.*\]\s*/', '', $args[0] ); // Base hook. $args[0] = $prefix . $suffix; - if ( has_filter( $args[0] ) ) { - $output .= call_user_func_array( 'beans_render_function', array_merge( array( 'do_action' ), $args ) ); - } + // If the base hook is registered, render it. + _beans_when_has_action_do_render( $args, $output ); - foreach ( $matches[0] as $i => $subhook ) { + foreach ( (array) $sub_hooks[0] as $index => $sub_hook ) { + $variable_prefix .= $sub_hook; - $variable_prefix = $variable_prefix . $subhook; - $levels = array( $prefix . $subhook . $suffix ); + $levels = array( $prefix . $sub_hook . $suffix ); // Cascade sub-hooks. - if ( $i > 0 ) { - - $levels[] = str_replace( $subhook, '', $hook ); + if ( $index > 0 ) { $levels[] = $variable_prefix . $suffix; - } // Apply sub-hooks. foreach ( $levels as $level ) { - $args[0] = $level; - if ( has_filter( $args[0] ) ) { - $output .= call_user_func_array( 'beans_render_function', array_merge( array( 'do_action' ), $args ) ); - } + // If the level is registered, render it. + _beans_when_has_action_do_render( $args, $output ); - // Apply filter whithout square brackets for backwards compatibility. + // Apply filter without square brackets for backwards compatibility. $args[0] = preg_replace( '#(\[|\])#', '', $args[0] ); - if ( has_filter( $args[0] ) ) { - $output .= call_user_func_array( 'beans_render_function', array_merge( array( 'do_action' ), $args ) ); - } + // If the backwards compatible $args[0] is registered, render it. + _beans_when_has_action_do_render( $args, $output ); } } return $output; +} +/** + * Render all hooked action callbacks by firing {@see do_action()}. The output is captured in the buffer and then + * returned. + * + * @since 1.5.0 + * @ignore + * @access private + * + * @param array $args Array of arguments. + * @param string $output The output to be updated. + * + * @return string|bool + */ +function _beans_when_has_action_do_render( array $args, &$output = '' ) { + + if ( ! has_action( $args[0] ) ) { + return false; + } + + ob_start(); + call_user_func_array( 'do_action', $args ); + $output .= ob_get_clean(); + + return $output; } /** * Make sure the action ID is unique. * + * @since 1.5.0 * @ignore + * @access private + * + * @param mixed $callback Callback to convert into a unique ID. + * + * @return array|string */ function _beans_unique_action_id( $callback ) { @@ -627,13 +771,12 @@ function _beans_unique_action_id( $callback ) { } return get_class( $callback[0] ) . $callback[1]; + } - } elseif ( is_string( $callback[0] ) ) { // Treat static method. - + // Treat static method. + if ( is_string( $callback[0] ) ) { return $callback[0] . '::' . $callback[1]; - } return md5( $callback ); - } diff --git a/lib/api/admin-menu.php b/lib/api/admin-menu.php index 32262410..c14c38ad 100644 --- a/lib/api/admin-menu.php +++ b/lib/api/admin-menu.php @@ -1,8 +1,20 @@
-

+

'beans_dev_mode', - 'checkbox_label' => __( 'Enable development mode', 'tm-beans' ), + 'label' => __( 'Enable development mode', 'tm-beans' ), + 'checkbox_label' => __( 'Select to activate development mode.', 'tm-beans' ), 'type' => 'checkbox', 'description' => __( 'This option should be enabled while your website is in development.', 'tm-beans' ), ), ); - beans_register_options( $fields, 'beans_settings', 'mode_options', array( - 'title' => __( 'Mode options', 'tm-beans' ), - 'context' => beans_get( 'beans_settings', $wp_meta_boxes ) ? 'column' : 'normal', // Check for other beans boxes. - ) ); - + beans_register_options( + $fields, + 'beans_settings', + 'mode_options', + array( + 'title' => __( 'Mode options', 'tm-beans' ), + 'context' => beans_get( 'beans_settings', $wp_meta_boxes ) ? 'column' : 'normal', // Check for other beans boxes. + ) + ); } } diff --git a/lib/api/compiler/class-beans-compiler-options.php b/lib/api/compiler/class-beans-compiler-options.php new file mode 100644 index 00000000..b7584bf1 --- /dev/null +++ b/lib/api/compiler/class-beans-compiler-options.php @@ -0,0 +1,191 @@ +get_fields_to_register(), + 'beans_settings', + 'compiler_options', + array( + 'title' => __( 'Compiler options', 'tm-beans' ), + 'context' => 'normal', + ) + ); + } + + /** + * Get the fields to register. + * + * @since 1.5.0 + * + * @return array + */ + private function get_fields_to_register() { + $fields = require dirname( __FILE__ ) . '/config/fields.php'; + + // If not supported, remove the styles' fields. + if ( $this->is_not_supported( 'wp_styles_compiler' ) ) { + unset( $fields['beans_compile_all_styles'] ); + } + + // If not supported, remove the scripts' fields. + if ( $this->is_not_supported( 'wp_scripts_compiler' ) ) { + unset( $fields['beans_compile_all_scripts_group'] ); + } + + return $fields; + } + + /** + * Checks if the component is not supported. + * + * @since 1.5.0 + * + * @param string $component The component to check. + * + * @return bool + */ + private function is_not_supported( $component ) { + return ! beans_get_component_support( $component ); + } + + /** + * Flush the cached files. + * + * @since 1.0.0 + * + * @return void + */ + public function flush() { + + if ( ! beans_post( 'beans_flush_compiler_cache' ) ) { + return; + } + + beans_remove_dir( beans_get_compiler_dir() ); + } + + /** + * Renders the success notice. + * + * @since 1.0.0 + * + * @return void + */ + public function render_success_notice() { + + if ( ! beans_post( 'beans_flush_compiler_cache' ) ) { + return; + } + + include dirname( __FILE__ ) . '/views/flushed-notice.php'; + } + + /** + * Render the flush button, which is used to flush the cache. + * + * @since 1.0.0 + * + * @param array $field Registered options. + * + * @return void + */ + public function render_flush_button( $field ) { + + if ( 'beans_compiler_items' !== $field['id'] ) { + return; + } + + include dirname( __FILE__ ) . '/views/flush-button.php'; + } + + /** + * Render a notice when styles should not be compiled. + * + * @since 1.0.0 + * + * @return void + */ + public function render_styles_not_compiled_notice() { + + if ( ! _beans_is_compiler_dev_mode() ) { + return; + } + + if ( ! get_option( 'beans_compile_all_styles' ) ) { + return; + } + + $message = __( 'Styles are not compiled in development mode.', 'tm-beans' ); + + include dirname( __FILE__ ) . '/views/not-compiled-notice.php'; + } + + /** + * Maybe show disabled notice. + * + * @since 1.0.0 + * + * @return void + */ + public function render_scripts_not_compiled_notice() { + + if ( ! _beans_is_compiler_dev_mode() ) { + return; + } + + if ( ! get_option( 'beans_compile_all_scripts' ) ) { + return; + } + + $message = __( 'Scripts are not compiled in development mode.', 'tm-beans' ); + + include dirname( __FILE__ ) . '/views/not-compiled-notice.php'; + } +} diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php new file mode 100644 index 00000000..cb3a6d08 --- /dev/null +++ b/lib/api/compiler/class-beans-compiler.php @@ -0,0 +1,934 @@ +config = $this->init_config( $config ); + $this->dir = beans_get_compiler_dir( is_admin() ) . $this->config['id']; + $this->url = beans_get_compiler_url( is_admin() ) . $this->config['id']; + } + + /** + * Run the compiler. + * + * @since 1.5.0 + * + * @return void + */ + public function run_compiler() { + // Modify the WP Filesystem method. + add_filter( 'filesystem_method', array( $this, 'modify_filesystem_method' ) ); + + $this->set_fragments(); + $this->set_filename(); + + if ( ! $this->cache_file_exist() ) { + $this->filesystem(); + $this->maybe_make_dir(); + $this->combine_fragments(); + $this->cache_file(); + } + + $this->enqueue_file(); + + // Keep it safe and reset the WP Filesystem method. + remove_filter( 'filesystem_method', array( $this, 'modify_filesystem_method' ) ); + } + + /** + * Callback to set the WP Filesystem method. + * + * @since 1.0.0 + * + * @return string + */ + public function modify_filesystem_method() { + return 'direct'; + } + + /** + * Initialise the WP Filesystem. + * + * @since 1.0.0 + * + * @return bool|void + */ + public function filesystem() { + + // If the WP_Filesystem is not already loaded, load it. + if ( ! function_exists( 'WP_Filesystem' ) ) { + require_once ABSPATH . '/wp-admin/includes/file.php'; + } + + // If the WP_Filesystem is not initialized or is not set to WP_Filesystem_Direct, then initialize it. + if ( $this->is_wp_filesystem_direct() ) { + return true; + } + + // Initialize the filesystem. + $response = WP_Filesystem(); + + // If the filesystem did not initialize, then generate a report and exit. + if ( true !== $response || ! $this->is_wp_filesystem_direct() ) { + return $this->kill(); + } + + return true; + } + + /** + * Check if the filesystem is set to "direct". + * + * @since 1.5.0 + * + * @return bool + */ + private function is_wp_filesystem_direct() { + return isset( $GLOBALS['wp_filesystem'] ) && is_a( $GLOBALS['wp_filesystem'], 'WP_Filesystem_Direct' ); + } + + /** + * Make directory. + * + * @since 1.0.0 + * @since 1.5.0 Changed access to private. + * + * @return bool + */ + private function maybe_make_dir() { + + if ( ! @is_dir( $this->dir ) ) { // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- This is a valid use case. + wp_mkdir_p( $this->dir ); + } + + return is_writable( $this->dir ); + } + + /** + * Set class fragments. + * + * @since 1.0.0 + * + * @return void + */ + public function set_fragments() { + global $_beans_compiler_added_fragments; + + $added_fragments = beans_get( $this->config['id'], $_beans_compiler_added_fragments[ $this->config['format'] ] ); + + if ( $added_fragments ) { + $this->config['fragments'] = array_merge( $this->config['fragments'], $added_fragments ); + } + + /** + * Filter the compiler fragment files. + * + * The dynamic portion of the hook name, $this->config['id'], refers to the compiler id used as a reference. + * + * @since 1.0.0 + * + * @param array $fragments An array of fragment files. + */ + $this->config['fragments'] = apply_filters( 'beans_compiler_fragments_' . $this->config['id'], $this->config['fragments'] ); + } + + /** + * Set the filename for the compiled asset. + * + * @since 1.0.0 + * @since 1.5.0 Renamed method. Changed storage location to $filename property. + * + * @return void + */ + public function set_filename() { + $hash = $this->hash( $this->config ); + $fragments_filemtime = $this->get_fragments_filemtime(); + $hash = $this->get_new_hash( $hash, $fragments_filemtime ); + $this->filename = $hash . '.' . $this->get_extension(); + } + + /** + * Hash the given array. + * + * @since 1.5.0 + * + * @param array $given_array Given array to be hashed. + * + * @return string + */ + public function hash( array $given_array ) { + return substr( md5( @serialize( $given_array ) ), 0, 7 ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize -- Valid use case. + } + + /** + * Checks if the file exists on the filesystem, meaning it's been cached. + * + * @since 1.0.0 + * + * @return bool + */ + public function cache_file_exist() { + $filename = $this->get_filename(); + + if ( empty( $filename ) ) { + return false; + } + + return file_exists( $filename ); + } + + /** + * Get the absolute path of the cached and compiled file. + * + * @since 1.5.0 + * + * @return string + */ + public function get_filename() { + if ( isset( $this->filename ) ) { + return $this->dir . '/' . $this->filename; + } + + return ''; + } + + /** + * Create cached file. + * + * @since 1.0.0 + * + * @return bool + */ + public function cache_file() { + $filename = $this->get_filename(); + + if ( empty( $filename ) ) { + return false; + } + + // It is safe to access the filesystem because we made sure it was set. + return $GLOBALS['wp_filesystem']->put_contents( $filename, $this->compiled_content, FS_CHMOD_FILE ); + } + + /** + * Enqueue cached file. + * + * @since 1.0.0 + * @since 1.5.0 Changed access to private. + * + * @return void|bool + */ + private function enqueue_file() { + + // Enqueue CSS file. + if ( 'style' === $this->config['type'] ) { + return wp_enqueue_style( + $this->config['id'], + $this->get_url(), + $this->config['dependencies'], + $this->config['version'] + ); + } + + // Enqueue JS file. + if ( 'script' === $this->config['type'] ) { + return wp_enqueue_script( + $this->config['id'], + $this->get_url(), + $this->config['dependencies'], + $this->config['version'], + $this->config['in_footer'] + ); + } + + return false; + } + + /** + * Get cached file url. + * + * @since 1.0.0 + * + * @return string + */ + public function get_url() { + $url = trailingslashit( $this->url ) . $this->filename; + + if ( is_ssl() ) { + $url = str_replace( 'http://', 'https://', $url ); + } + + return $url; + } + + /** + * Get the file extension from the configured "type". + * + * @since 1.0.0 + * + * @return string|null + */ + public function get_extension() { + + if ( 'style' === $this->config['type'] ) { + return 'css'; + } + + if ( 'script' === $this->config['type'] ) { + return 'js'; + } + } + + /** + * Combine content of the fragments. + * + * @since 1.0.0 + * + * @return void + */ + public function combine_fragments() { + $content = ''; + + // Loop through fragments. + foreach ( $this->config['fragments'] as $fragment ) { + + // Stop here if the fragment is empty. + if ( empty( $fragment ) ) { + continue; + } + + $fragment_content = $this->get_content( $fragment ); + + // Stop here if no content or content is an html page. + if ( ! $fragment_content || preg_match( '#^\s*\<#', $fragment_content ) ) { + continue; + } + + // Continue processing style. + if ( 'style' === $this->config['type'] ) { + $fragment_content = $this->replace_css_url( $fragment_content ); + $fragment_content = $this->add_content_media_query( $fragment_content ); + } + + // If there's content, start a new line. + if ( $content ) { + $content .= "\n\n"; + } + + $content .= $fragment_content; + } + + $this->compiled_content = ! empty( $content ) ? $this->format_content( $content ) : ''; + } + + /** + * Get the fragment's content. + * + * @since 1.5.0 + * + * @param string|callable $fragment The given fragment from which to get the content. + * + * @return bool|string + */ + private function get_content( $fragment ) { + // Set the current fragment used by other functions. + $this->current_fragment = $fragment; + + // If the fragment is callable, call it to get the content. + if ( $this->is_function( $fragment ) ) { + return $this->get_function_content(); + } + + $content = $this->get_internal_content(); + + // Try remote content if the internal content returned false. + if ( empty( $content ) ) { + $content = $this->get_remote_content(); + } + + return $content; + } + + /** + * Get internal file content. + * + * @since 1.0.0 + * + * @return string|bool + */ + public function get_internal_content() { + $fragment = $this->current_fragment; + + if ( ! file_exists( $fragment ) ) { + + // Replace URL with path. + $fragment = beans_url_to_path( $fragment ); + + // Stop here if it isn't a valid file. + if ( ! file_exists( $fragment ) || 0 === @filesize( $fragment ) ) { // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + return false; + } + } + + // It is safe to access the filesystem because we made sure it was set. + return $GLOBALS['wp_filesystem']->get_contents( $fragment ); + } + + /** + * Get external file content. + * + * @since 1.0.0 + * + * @return string|bool + */ + public function get_remote_content() { + $fragment = $this->current_fragment; + + if ( empty( $fragment ) ) { + return false; + } + + // For a relative URL, add http: to it. + if ( substr( $fragment, 0, 2 ) === '//' ) { + $fragment = 'http:' . $fragment; + } elseif ( substr( $fragment, 0, 1 ) === '/' ) { // Add domain if it is local but could not be fetched as a file. + $fragment = site_url( $fragment ); + } + + $request = wp_remote_get( $fragment ); + + if ( is_wp_error( $request ) ) { + return ''; + } + + // If no content was received and the URL is not https, then convert the URL to SSL and retry. + if ( + ( ! isset( $request['body'] ) || 200 !== $request['response']['code'] ) && + ( substr( $fragment, 0, 8 ) !== 'https://' ) + ) { + $fragment = str_replace( 'http://', 'https://', $fragment ); + $request = wp_remote_get( $fragment ); + + if ( is_wp_error( $request ) ) { + return ''; + } + } + + if ( ( ! isset( $request['body'] ) || 200 !== $request['response']['code'] ) ) { + return false; + } + + return wp_remote_retrieve_body( $request ); + } + + /** + * Get function content. + * + * @since 1.0.0 + * + * @return string|bool + */ + public function get_function_content() { + + if ( ! is_callable( $this->current_fragment ) ) { + return false; + } + + return call_user_func( $this->current_fragment ); + } + + /** + * Wrap content in query. + * + * @since 1.0.0 + * + * @param string $content Given content to process. + * + * @return string + */ + public function add_content_media_query( $content ) { + + // Ignore if the fragment is a function. + if ( $this->is_function( $this->current_fragment ) ) { + return $content; + } + + $query = parse_url( $this->current_fragment, PHP_URL_QUERY ); + + // Bail out if there are no query args or no media query. + if ( empty( $query ) || false === stripos( $query, 'beans_compiler_media_query' ) ) { + return $content; + } + + // Wrap the content in the query. + return sprintf( + "@media %s {\n%s\n}\n", + beans_get( 'beans_compiler_media_query', wp_parse_args( $query ) ), + $content + ); + } + + /** + * Formal CSS, LESS and JS content. + * + * @since 1.0.0 + * + * @param string $content Given content to process. + * + * @return string + */ + public function format_content( $content ) { + + if ( 'style' === $this->config['type'] ) { + + if ( 'less' === $this->config['format'] ) { + + if ( ! class_exists( 'Beans_Lessc' ) ) { + require_once BEANS_API_PATH . 'compiler/vendors/lessc.php'; + } + + $less = new Beans_Lessc(); + $content = $less->compile( $content ); + } + + if ( ! _beans_is_compiler_dev_mode() ) { + return $this->strip_whitespace( $content ); + } + + return $content; + } + + if ( 'script' === $this->config['type'] && ! _beans_is_compiler_dev_mode() && $this->config['minify_js'] ) { + + if ( ! class_exists( 'JSMin' ) ) { + require_once BEANS_API_PATH . 'compiler/vendors/js-minifier.php'; + } + + $js_min = new JSMin( $content ); + + return $js_min->min(); + } + + return $content; + } + + /** + * Replace CSS URL shortcuts with a valid URL. + * + * @since 1.0.0 + * + * @param string $content Given content to process. + * + * @return string + */ + public function replace_css_url( $content ) { + return preg_replace_callback( + '#url\s*\(\s*[\'"]*?([^\'"\)]+)[\'"]*\s*\)#i', + array( $this, 'replace_css_url_callback' ), + $content + ); + } + + /** + * Convert any CSS URL relative paths to absolute URLs. + * + * @since 1.0.0 + * + * @param array $matches Matches to process, where 0 is the CSS' URL() and 1 is the URI. + * + * @return string + */ + public function replace_css_url_callback( $matches ) { + + // If the URI is absolute, bail out and return the CSS. + if ( _beans_is_uri( $matches[1] ) ) { + return $matches[0]; + } + + $base = $this->current_fragment; + + // Separate the placeholders and path. + $paths = explode( '../', $matches[1] ); + + /** + * Walk backwards through each of the the fragment's directories, one-by-one. The `foreach` loop + * provides us with a performant way to walk the fragment back to its base path based upon the + * number of placeholders. + */ + foreach ( $paths as $path ) { + $base = dirname( $base ); + } + + // Make sure it is a valid base. + if ( '.' === $base ) { + $base = ''; + } + + // Rebuild the URL and make sure it is valid using the beans_path_to_url function. + $url = beans_path_to_url( trailingslashit( $base ) . ltrim( end( $paths ), '/\\' ) ); + + // Return the rebuilt path converted to an URL. + return 'url("' . $url . '")'; + } + + /** + * Initialize the configuration. + * + * @since 1.5.0 + * + * @param array $config Runtime configuration parameters for the Compiler. + * + * @return array + */ + private function init_config( array $config ) { + // Fix dependencies, if "depedencies" is specified. + if ( isset( $config['depedencies'] ) ) { + $config['dependencies'] = $config['depedencies']; + unset( $config['depedencies'] ); + } + + $defaults = array( + 'id' => false, + 'type' => false, + 'format' => false, + 'fragments' => array(), + 'dependencies' => false, + 'in_footer' => false, + 'minify_js' => false, + 'version' => false, + ); + + return array_merge( $defaults, $config ); + } + + /** + * Get the fragments' modification times. + * + * @since 1.5.0 + * + * @return array + */ + private function get_fragments_filemtime() { + $fragments_filemtime = array(); + + foreach ( $this->config['fragments'] as $index => $fragment ) { + + // Skip this one if the fragment is a function. + if ( $this->is_function( $fragment ) ) { + continue; + } + + if ( file_exists( $fragment ) ) { + $fragments_filemtime[ $index ] = @filemtime( $fragment ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + } + } + + return $fragments_filemtime; + } + + /** + * Get the new hash for the given fragments' modification times. + * + * @since 1.5.0 + * + * @param string $hash The original hash to modify. + * @param array $fragments_filemtime Array of fragments' modification times. + * + * @return string + */ + private function get_new_hash( $hash, array $fragments_filemtime ) { + + if ( empty( $fragments_filemtime ) ) { + return $hash; + } + + // Set filemtime hash. + $_hash = $this->hash( $fragments_filemtime ); + + $this->remove_modified_files( $hash, $_hash ); + + // Set the new hash which will trigger a new compiling. + return $hash . '-' . $_hash; + } + + /** + * Remove any modified files. A file is considered modified when: + * + * 1. It has both a base hash and filemtime hash, separated by '-'. + * 2. Its base hash matches the given hash. + * 3. Its filemtime hash does not match the given filemtime hash. + * + * @since 1.5.0 + * + * @param string $hash Base hash. + * @param string $filemtime_hash The filemtime hash (from hashing the fragments). + * + * @return void + */ + private function remove_modified_files( $hash, $filemtime_hash ) { + $items = beans_scandir( $this->dir ); + + if ( empty( $items ) ) { + return; + } + + foreach ( $items as $item ) { + + // Skip this one if it's a directory. + if ( @is_dir( $item ) ) { // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + continue; + } + + // Skip this one if it's not the same type. + if ( pathinfo( $item, PATHINFO_EXTENSION ) !== $this->get_extension() ) { + continue; + } + + // Skip this one if it does not have a '-' in the filename. + if ( strpos( $item, '-' ) === false ) { + continue; + } + + $hash_parts = explode( '-', pathinfo( $item, PATHINFO_FILENAME ) ); + + // Skip this one if it does not match the given base hash. + if ( $hash_parts[0] !== $hash ) { + continue; + } + + // Skip this one if it does match the given filemtime's hash. + if ( $hash_parts[1] === $filemtime_hash ) { + continue; + } + + // Clean up other modified files. + @unlink( $this->dir . '/' . $item ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + } + } + + /** + * Minify the CSS. + * + * @since 1.0.0 + * @since 1.5.0 Changed access to private. + * + * @param string $content Given content to process. + * + * @return string + */ + private function strip_whitespace( $content ) { + $replace = array( + '#/\*.*?\*/#s' => '', // Strip comments. + '#\s\s+#' => ' ', // Strip excess whitespace. + ); + + $search = array_keys( $replace ); + $content = preg_replace( $search, $replace, $content ); + + // Strip all new lines and tabs. + $content = str_replace( array( "\r\n", "\r", "\n", "\t" ), '', $content ); + + $replace = array( + ': ' => ':', + '; ' => ';', + ' {' => '{', + ' }' => '}', + ', ' => ',', + '{ ' => '{', + ';}' => '}', // Strip optional semicolons. + ',\n' => ',', // Don't wrap multiple selectors. + '\n}' => '}', // Don't wrap closing braces. + '}' => "}\n", // Put each rule on it's own line. + '\n' => '', // Remove all line breaks. + "}\n " => "}\n", // Remove the whitespace at start of each new line. + ); + + $search = array_keys( $replace ); + + return trim( str_replace( $search, $replace, $content ) ); + } + + /** + * Check if the given fragment is a callable. + * + * @since 1.0.0 + * @since 1.5.0 Changed access to private. + * + * @param mixed $fragment Given fragment to check. + * + * @return bool + */ + private function is_function( $fragment ) { + return ( is_array( $fragment ) || is_callable( $fragment ) ); + } + + /** + * Kill it :( + * + * @since 1.0.0 + * @since 1.5.0 Changed access to private. + * + * @return void + */ + private function kill() { + + // Send report if set. + if ( beans_get( 'beans_send_compiler_report' ) ) { + $this->report(); + } + + $html = beans_output( 'beans_compiler_error_title_text', sprintf( + '

%s

', + __( 'Not cool, Beans cannot work its magic :(', 'tm-beans' ) + ) ); + + $html .= beans_output( 'beans_compiler_error_message_text', sprintf( + '

%s

', + __( 'Your current install or file permission prevents Beans from working its magic. Please get in touch with Beans support. We will gladly get you started within 24 - 48 hours (working days).', 'tm-beans' ) + ) ); + + $html .= beans_output( 'beans_compiler_error_contact_text', sprintf( + '%s', + __( 'Contact Beans Support', 'tm-beans' ) + ) ); + + $html .= beans_output( 'beans_compiler_error_report_text', sprintf( + '

%1$s. %2$s

', + __( 'Send us an automatic report', 'tm-beans' ), + __( 'We respect your time and understand you might not be able to contact us.', 'tm-beans' ) + ) ); + + wp_die( wp_kses_post( $html ) ); + } + + /** + * Send report. + * + * @since 1.0.0 + * @since 1.5.0 Changed access to private. + * + * @return void + */ + private function report() { + // Send report. + wp_mail( + 'hello@getbeans.io', + 'Compiler error', + 'Compiler error reported by ' . home_url(), + array( + 'MIME-Version: 1.0' . "\r\n", + 'Content-type: text/html; charset=utf-8' . "\r\n", + "X-Mailer: PHP \r\n", + 'From: ' . wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) . ' < ' . get_option( 'admin_email' ) . '>' . "\r\n", + 'Reply-To: ' . get_option( 'admin_email' ) . "\r\n", + ) + ); + + // Die and display message. + $message = beans_output( + 'beans_compiler_report_error_text', + sprintf( + '

%s

', + __( 'Thanks for your contribution by reporting this issue. We hope to hear from you again.', 'tm-beans' ) + ) + ); + + wp_die( wp_kses_post( $message ) ); + } + + /** + * Set the filename for the compiled asset. + * + * This method has been replaced with {@see set_filename()}. + * + * @since 1.0.0 + * @deprecated 1.5.0. + */ + public function set_filname() { + _deprecated_function( __METHOD__, '1.5.0', 'set_filename' ); + + $this->set_filename(); + } + + /** + * Get the property's value. + * + * @since 1.5.0 + * + * @param string $property Name of the property to get. + * + * @return mixed + */ + public function __get( $property ) { + + if ( property_exists( $this, $property ) ) { + return $this->{$property}; + } + } +} diff --git a/lib/api/compiler/class-beans-page-compiler.php b/lib/api/compiler/class-beans-page-compiler.php new file mode 100644 index 00000000..2ee3150b --- /dev/null +++ b/lib/api/compiler/class-beans-page-compiler.php @@ -0,0 +1,306 @@ +do_not_compile_styles() ) { + return; + } + + $this->processed_handles = array(); + $styles = $this->compile_enqueued( 'style' ); + + if ( empty( $styles ) ) { + return; + } + + beans_compile_css_fragments( 'beans', $styles, array( 'version' => null ) ); + } + + /** + * Checks if the page's styles should not be compiled. + * + * @since 1.5.0 + * + * @return bool + */ + private function do_not_compile_styles() { + return ! beans_get_component_support( 'wp_styles_compiler' ) || ! get_option( 'beans_compile_all_styles', false ) || _beans_is_compiler_dev_mode(); + } + + /** + * Enqueue the compiled WP scripts. + * + * @since 1.0.0 + * + * @return void + */ + public function compile_page_scripts() { + + if ( $this->do_not_compile_scripts() ) { + return; + } + + $this->processed_handles = array(); + $scripts = $this->compile_enqueued( 'script' ); + + if ( empty( $scripts ) ) { + return; + } + + $this->dequeued_scripts = $scripts; + add_action( 'wp_print_scripts', array( $this, 'dequeue_scripts' ), 9999 ); + + beans_compile_js_fragments( 'beans', $scripts, array( + 'in_footer' => 'aggressive' === get_option( 'beans_compile_all_scripts_mode', 'aggressive' ), + 'version' => null, + ) ); + } + + /** + * Checks if the page's scripts should not be compiled. + * + * @since 1.5.0 + * + * @return bool + */ + private function do_not_compile_scripts() { + return ! beans_get_component_support( 'wp_scripts_compiler' ) || ! get_option( 'beans_compile_all_scripts', false ) || _beans_is_compiler_dev_mode(); + } + + /** + * Compile all of the enqueued assets, i.e. all assets that are registered with WordPress. + * + * @since 1.0.0 + * @ignore + * @access private + * + * @param string $type Type of asset, e.g. style or script. + * @param string|array $dependencies Optional. The asset's dependency(ies). Default is an empty string. + * + * @return array + */ + private function compile_enqueued( $type, $dependencies = '' ) { + $assets = beans_get( "wp_{$type}s", $GLOBALS ); + + if ( ! $assets ) { + return array(); + } + + if ( ! $dependencies ) { + $dependencies = $assets->queue; + } + + $fragments = array(); + + foreach ( $dependencies as $handle ) { + + if ( $this->do_not_compile_asset( $handle ) ) { + continue; + } + + if ( $this->did_handle( $handle ) ) { + continue; + } + + $asset = beans_get( $handle, $assets->registered ); + + if ( ! $asset ) { + continue; + } + + $this->get_deps_to_be_compiled( $type, $asset, $fragments ); + + if ( empty( $asset->src ) ) { + continue; + } + + if ( 'style' === $type ) { + $this->maybe_add_media_query_to_src( $asset ); + + $assets->done[] = $handle; + } + + $fragments[ $handle ] = $asset->src; + } + + return $fragments; + } + + /** + * Checks if the handle has already been processed. If no, it stores the handle. + * + * Note: This check eliminates processing dependencies that are in more than one asset. For example, if more than + * one script requires 'jquery', then this check ensures we only process jquery's dependencies once. + * + * @since 1.5.0 + * + * @param string $handle The asset's handle. + * + * @return bool + */ + private function did_handle( $handle ) { + if ( in_array( $handle, $this->processed_handles, true ) ) { + return true; + } + + $this->processed_handles[] = $handle; + + return false; + } + + /** + * When the args are not set to "all," adds the media query to the asset's src. + * + * @since 1.5.0 + * + * @param _WP_Dependency $asset The given asset. + * + * @return void + */ + private function maybe_add_media_query_to_src( $asset ) { + // Add compiler media query if set. + if ( 'all' === $asset->args ) { + return; + } + + $asset->src = add_query_arg( array( 'beans_compiler_media_query' => $asset->args ), $asset->src ); + } + + /** + * Checks the given asset's handle to determine if it should not be compiled. + * + * @since 1.5.0 + * + * @param string $handle The asset handle to check. + * + * @return bool + */ + private function do_not_compile_asset( $handle ) { + return in_array( $handle, $this->handles_not_to_compile, true ); + } + + /** + * Get the asset's dependencies to be compiled. + * + * @since 1.5.0 + * + * @param string $type Type of asset. + * @param _WP_Dependency $asset Instance of the asset. + * @param array $srcs Array of compiled asset srcs to be compiled. Passed by reference. + * + * @return void + */ + private function get_deps_to_be_compiled( $type, $asset, array &$srcs ) { + + if ( empty( $asset->deps ) ) { + return; + } + + foreach ( $this->compile_enqueued( $type, $asset->deps, true ) as $dep_handle => $dep_src ) { + + if ( empty( $dep_src ) ) { + continue; + } + + $srcs[ $dep_handle ] = $dep_src; + } + } + + /** + * Dequeue scripts which have been compiled, grab localized + * data and add it inline. + * + * @since 1.0.0 + * + * @return void + */ + public function dequeue_scripts() { + + if ( empty( $this->dequeued_scripts ) ) { + return; + } + + global $wp_scripts; + $localized = ''; + + // Fetch the localized content and dequeue script. + foreach ( $this->dequeued_scripts as $handle => $src ) { + $script = beans_get( $handle, $wp_scripts->registered ); + + if ( ! $script ) { + continue; + } + + if ( isset( $script->extra['data'] ) ) { + $localized .= $script->extra['data'] . "\n"; + } + + $wp_scripts->done[] = $handle; + } + + if ( empty( $localized ) ) { + return; + } + + // Add localized content since it was removed with dequeue scripts. + require dirname( __FILE__ ) . '/views/localized-content.php'; + } +} diff --git a/lib/api/compiler/class-compiler.php b/lib/api/compiler/class-compiler.php deleted file mode 100644 index 8aaa19c9..00000000 --- a/lib/api/compiler/class-compiler.php +++ /dev/null @@ -1,617 +0,0 @@ - false, - 'type' => false, - 'format' => false, - 'fragments' => array(), - 'depedencies' => false, - 'in_footer' => false, - 'minify_js' => false, - 'version' => false, - ); - - $this->compiler = array_merge( $defaults, $args ); - $this->dir = beans_get_compiler_dir( is_admin() ) . $this->compiler['id']; - $this->url = beans_get_compiler_url( is_admin() ) . $this->compiler['id']; - - $this->set_fragments(); - $this->set_filname(); - - if ( ! $this->cache_file_exist() ) { - - $this->filesystem(); - $this->maybe_make_dir(); - $this->cache_file(); - - } - - $this->enqueue_file(); - - // Keep it safe and reset WP Filsystem method. - remove_filter( 'filesystem_method', array( $this, 'filesystem_method' ) ); - - } - - /** - * Set WP Filsystem method. - */ - public function filesystem_method() { - - return 'direct'; - - } - - /** - * Initialise WP Filsystem. - */ - public function filesystem() { - - // Initialize the WordPress Filsystem. - if ( ! isset( $GLOBALS['wp_filesystem'] ) || empty( $GLOBALS['wp_filesystem'] ) ) { - - require_once( ABSPATH . '/wp-admin/includes/file.php' ); - - if ( ! WP_Filesystem() ) { - return $this->kill(); - } - } - - return true; - - } - - /** - * Make directory. - */ - public function maybe_make_dir() { - - if ( ! @is_dir( $this->dir ) ) { - wp_mkdir_p( $this->dir ); - } - - if ( ! is_writable( $this->dir ) ) { - return false; - } - - return true; - - } - - /** - * Set class fragments. - */ - public function set_fragments() { - - global $_beans_compiler_added_fragments; - - if ( $added_fragments = beans_get( $this->compiler['id'], $_beans_compiler_added_fragments[ $this->compiler['format'] ] ) ) { - $this->compiler['fragments'] = array_merge( $this->compiler['fragments'], $added_fragments ); - } - - /** - * Filter the compiler fragment files. - * - * The dynamic portion of the hook name, $this->compiler['id'], refers to the compiler id used as a reference. - * - * @since 1.0.0 - * - * @param array $fragments An array of fragment files. - */ - $this->compiler['fragments'] = apply_filters( 'beans_compiler_fragments_' . $this->compiler['id'], $this->compiler['fragments'] ); - - } - - /** - * Set class filname. - */ - public function set_filname() { - - $hash = substr( md5( @serialize( $this->compiler ) ), 0, 7 ); - - // Stop here and return filename if not in dev mode or if not using filesystem. - if ( ! _beans_is_compiler_dev_mode() || ! @is_dir( $this->dir ) ) { - return $this->compiler['filename'] = $hash . '.' . $this->get_extension(); - } - - $fragments_filemtime = array(); - - // Check for internal file changes. - foreach ( $this->compiler['fragments'] as $id => $fragment ) { - - // Ignore if the fragment is a function. - if ( $this->is_function( $fragment ) ) { - continue; - } - - // Only check file time for internal files. - if ( false !== strpos( $fragment, $_SERVER['HTTP_HOST'] ) || true == preg_match( '#^\/[^\/]#', $fragment ) ) { - $fragments_filemtime[ $id ] = @filemtime( beans_url_to_path( $fragment ) ); - } - } - - if ( ! empty( $fragments_filemtime ) ) { - - // Set filemtime hash. - $_hash = substr( md5( @serialize( $fragments_filemtime ) ), 0, 7 ); - - $items = @scandir( $this->dir ); - unset( $items[0], $items[1] ); - - // Clean up other modified files. - foreach ( $items as $item ) { - - // Remove if it contains initial hash, is the same format and doesn't contain the filemtime hash. - if ( false !== stripos( $item, $hash ) && false !== stripos( $item, $this->get_extension() ) && false === stripos( $item, $_hash ) ) { - @unlink( $this->dir . '/' . $item ); - } - } - - // Set the new hash which will trigger to new compiling. - $hash = $hash . '-' . $_hash; - - } - - $this->compiler['filename'] = $hash . '.' . $this->get_extension(); - - } - - /** - * Check if cached file exists. - */ - public function cache_file_exist() { - - if ( ( $filname = beans_get( 'filename', $this->compiler ) ) && file_exists( $this->dir . '/' . $filname ) ) { - return true; - } - - return false; - - } - - /** - * Create cached file. - */ - public function cache_file() { - - $content = $this->combine_fragments(); - $filename = $this->dir . '/' . $this->compiler['filename']; - - // Safe to access filesystem since we made sure it was set. - if ( ! $GLOBALS['wp_filesystem']->put_contents( $filename, $content, FS_CHMOD_FILE ) ) { - return false; - } - - return true; - - } - - /** - * Enqueue cached file. - */ - public function enqueue_file() { - - // Enqueue css. - if ( 'style' == $this->compiler['type'] ) { - return wp_enqueue_style( $this->compiler['id'], $this->get_url(), $this->compiler['depedencies'], $this->compiler['version'] ); - } elseif ( 'script' == $this->compiler['type'] ) { // Enqueue js file. - return wp_enqueue_script( $this->compiler['id'], $this->get_url(), $this->compiler['depedencies'], $this->compiler['version'], $this->compiler['in_footer'] ); - } - - return false; - - } - - /** - * Get cached file url. - */ - public function get_url() { - - $url = trailingslashit( $this->url ) . beans_get( 'filename', $this->compiler ); - - if ( is_ssl() ) { - $url = str_replace( 'http://', 'https://', $url ); - } - - return $url; - - } - - /** - * Get file extension. - */ - public function get_extension() { - - if ( 'style' == $this->compiler['type'] ) { - return 'css'; - } elseif ( 'script' == $this->compiler['type'] ) { - return 'js'; - } - - } - - /** - * Combine fragments content. - */ - public function combine_fragments() { - - $content = ''; - - // Loop through fragments. - foreach ( $this->compiler['fragments'] as $fragment ) { - - // Stop here if the fragment is empty. - if ( empty( $fragment ) ) { - continue; - } - - // Set the current fragment used by other functions. - $this->current_fragment = $fragment; - - // Treat function. - if ( $this->is_function( $fragment ) ) { - - $get_content = $this->get_function_content(); - - } else { // Treat file. - - $get_content = $this->get_internal_content(); - - // Try remote content if the internal content returned false. - if ( ! $get_content ) { - $get_content = $this->get_remote_content(); - } - } - - // Stop here if no content or content is an html page. - if ( ! $get_content || preg_match( '#^\s*\<#', $get_content ) ) { - continue; - } - - // Add the content. - if ( 'style' == $this->compiler['type'] ) { - - $get_content = $this->replace_css_url( $get_content ); - $get_content = $this->add_content_media_query( $get_content ); - - } - - $content .= ( $content ? "\n\n" : '' ) . $get_content; - - } - - return $this->format_content( $content ); - - } - - /** - * Get internal file content. - */ - public function get_internal_content() { - - $fragment = $this->current_fragment; - - if ( ! file_exists( $fragment ) ) { - - // Replace url with path. - $fragment = beans_url_to_path( $fragment ); - - // Stop here if it isn't a valid file. - if ( ! file_exists( $fragment ) || 0 === @filesize( $fragment ) ) { - return false; - } - } - - // Safe to access filesystem since we made sure it was set. - return $GLOBALS['wp_filesystem']->get_contents( $fragment ); - - } - - /** - * Get external file content. - */ - public function get_remote_content() { - - $fragment = $this->current_fragment; - - // Replace double slaches by http. Mostly used for font referencing urls. - if ( true == preg_match( '#^\/\/#', $fragment ) ) { - $fragment = preg_replace( '#^\/\/#', 'http://', $fragment ); - } elseif ( true == preg_match( '#^\/#', $fragment ) ) { // Add domain if it is local but could not be fetched as a file. - $fragment = site_url( $fragment ); - } - - $request = wp_remote_get( $fragment ); - - // If failed to get content, try with ssl url, otherwise go to next fragment. - if ( ! is_wp_error( $request ) && ( ! isset( $request['body'] ) || 200 != $request['response']['code'] ) ) { - - $fragment = preg_replace( '#^http#', 'https', $fragment ); - $request = wp_remote_get( $fragment ); - - if ( ! is_wp_error( $request ) && ( ! isset( $request['body'] ) || 200 != $request['response']['code'] ) ) { - return false; - } - } - - return wp_remote_retrieve_body( $request ); - - } - - /** - * Get function content. - */ - public function get_function_content() { - - return call_user_func( $this->current_fragment ); - - } - - /** - * Wrap content in query. - */ - public function add_content_media_query( $content ) { - - // Ignore if the fragment is a function. - if ( $this->is_function( $this->current_fragment ) ) { - return $content; - } - - $parse_url = parse_url( $this->current_fragment ); - - // Return content if it no media query is set. - if ( ! ( $query = beans_get( 'query', $parse_url ) ) || false === stripos( $query, 'beans_compiler_media_query' ) ) { - return $content; - } - - // Wrap the content in the query. - $new_content = '@media ' . beans_get( 'beans_compiler_media_query', wp_parse_args( $query ) ) . ' {' . "\n"; - - $new_content .= $content . "\n"; - - $new_content .= '}' . "\n"; - - return $new_content; - - } - - /** - * Formal CSS, LESS and JS content. - */ - public function format_content( $content ) { - - if ( 'style' == $this->compiler['type'] ) { - - if ( 'less' == $this->compiler['format'] ) { - - if ( ! class_exists( 'Beans_Lessc' ) ) { - require_once( BEANS_API_PATH . 'compiler/vendors/lessc.php' ); - } - - $less = new Beans_Lessc(); - - $content = $less->compile( $content ); - - } - - if ( ! _beans_is_compiler_dev_mode() ) { - $content = $this->strip_whitespace( $content ); - } - } - - if ( 'script' == $this->compiler['type'] && ! _beans_is_compiler_dev_mode() && $this->compiler['minify_js'] ) { - - if ( ! class_exists( 'JSMin' ) ) { - require_once( BEANS_API_PATH . 'compiler/vendors/js-minifier.php' ); - } - - $js_min = new JSMin( $content ); - - $content = $js_min->min(); - - } - - return $content; - - } - - /** - * Replace CSS url shortcuts with a valid url. - */ - public function replace_css_url( $content ) { - - // Replace css path to urls. - return preg_replace_callback( '#url\s*\(\s*[\'"]*?([^\'"\)]+)[\'"]*\s*\)#i', array( $this, 'css_path_to_url' ) , $content ); - - } - - /** - * replace_css_url() callback. - */ - public function css_path_to_url( $matches, $base_is_path = false ) { - - $base = $this->current_fragment; - - // Stop here if it isn't a internal file or not a valid format. - if ( true == preg_match( '#^(http|https|\/\/|data)#', $matches[1] ) ) { - return $matches[0]; - } - - $explode_path = explode( '../', $matches[1] ); - - // Replace the base part according to the path "../". - foreach ( $explode_path as $value ) { - $base = dirname( $base ); - } - - // Rebuild path. - $replace = preg_replace( '#^\/#', '', $explode_path ); - $rebuilt_path = end( $replace ); - - // Make sure it is a valid base. - if ( '.' === $base ) { - $base = ''; - } - - // Rebuild url and make sure it is a valid one using the beans_path_to_url function. - $url = beans_path_to_url( trailingslashit( $base ) . $rebuilt_path ); - - // Return the rebuilt path converted to url. - return 'url("' . $url . '")'; - - } - - /** - * Minify CSS. - */ - public function strip_whitespace( $content ) { - - $replace = array( - '#/\*.*?\*/#s' => '', // Strip comments. - '#\s\s+#' => ' ', // Strip excess whitespace. - ); - - $search = array_keys( $replace ); - $content = preg_replace( $search, $replace, $content ); - - $replace = array( - ': ' => ':', - '; ' => ';', - ' {' => '{', - ' }' => '}', - ', ' => ',', - '{ ' => '{', - ';}' => '}', // Strip optional semicolons. - ',\n' => ',', // Don't wrap multiple selectors. - '\n}' => '}', // Don't wrap closing braces. - '} ' => "}\n", // Put each rule on it's own line. - '\n' => '', // Take out all line breaks - ); - - $search = array_keys( $replace ); - - return trim( str_replace( $search, $replace, $content ) ); - - } - - /** - * Is the fragement a function. - */ - public function is_function( $fragment ) { - - if ( is_array( $fragment ) || is_callable( $fragment ) ) { - return true; - } - - return false; - - } - - /** - * Kill it :( - */ - public function kill() { - - // Send report if set. - if ( beans_get( 'beans_send_compiler_report' ) ) { - $this->report(); - } - - $html = beans_output( 'beans_compiler_error_title_text', sprintf( - '

%s

', - __( 'Not cool, Beans cannot work its magic :(', 'tm-beans' ) - ) ); - - $html .= beans_output( 'beans_compiler_error_message_text', sprintf( - '

%s

', - __( 'Your current install or file permission prevents Beans from working its magic. Please get in touch with Beans support, we will gladly get you started within 24 - 48 hours (working days).', 'tm-beans' ) - ) ); - - $html .= beans_output( 'beans_compiler_error_contact_text', sprintf( - '%s', - __( 'Contact Beans Support', 'tm-beans' ) - ) ); - - $html .= beans_output( 'beans_compiler_error_report_text', sprintf( - '

%1$s. %2$s

', - __( 'Send us an automatic report', 'tm-beans' ), - __( 'We respect your time and understand you might not be able to contact us.', 'tm-beans' ) - ) ); - - wp_die( $html ); - - } - - /** - * Send report. - */ - public function report() { - - // Send report. - $send = wp_mail( - 'hello@getbeans.io', - 'Compiler error', - 'Compiler error reported by ' . home_url(), - array( - 'MIME-Version: 1.0' . "\r\n", - 'Content-type: text/html; charset=utf-8' . "\r\n", - "X-Mailer: PHP \r\n", - 'From: ' . wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) . ' < ' . get_option( 'admin_email' ) . '>' . "\r\n", - 'Reply-To: ' . get_option( 'admin_email' ) . "\r\n", - ) - ); - - // Die and display message. - wp_die( beans_output( 'beans_compiler_report_error_text', sprintf( - '

%s

', - __( 'Thanks for your contribution by reporting this issue. We hope to hear from you again.', 'tm-beans' ) - ) ) ); - - } -} diff --git a/lib/api/compiler/class-options.php b/lib/api/compiler/class-options.php deleted file mode 100644 index 7a04f9df..00000000 --- a/lib/api/compiler/class-options.php +++ /dev/null @@ -1,160 +0,0 @@ - 'beans_compiler_items', - 'type' => 'flush_cache', - 'description' => __( 'Clear CSS and Javascript cached files. New cached versions will be compiled on page load.', 'tm-beans' ), - ), - ); - - // Add styles compiler option only if supported - if ( beans_get_component_support( 'wp_styles_compiler' ) ) { - $fields = array_merge( $fields, array( - array( - 'id' => 'beans_compile_all_styles', - 'label' => false, - 'checkbox_label' => __( 'Compile all WordPress styles', 'tm-beans' ), - 'type' => 'checkbox', - 'default' => false, - 'description' => __( 'Compile and cache all the CSS files that have been enqueued to the WordPress head.', 'tm-beans' ), - ), - ) ); - } - - // Add scripts compiler option only if supported - if ( beans_get_component_support( 'wp_scripts_compiler' ) ) { - $fields = array_merge( $fields, array( - array( - 'id' => 'beans_compile_all_scripts_group', - 'label' => __( 'Compile all WordPress scripts', 'tm-beans' ), - 'type' => 'group', - 'fields' => array( - array( - 'id' => 'beans_compile_all_scripts', - 'type' => 'activation', - 'default' => false, - ), - array( - 'id' => 'beans_compile_all_scripts_mode', - 'type' => 'select', - 'default' => 'aggressive', - 'attributes' => array( 'style' => 'margin: -3px 0 0 -8px;' ), - 'options' => array( - 'aggressive' => __( 'Aggressive', 'tm-beans' ), - 'standard' => __( 'Standard', 'tm-beans' ), - ), - ), - ), - 'description' => __( 'Compile and cache all the Javascript files that have been enqueued to the WordPress head.JavaSript is outputted in the footer if the level is set to Aggressive and might conflict with some third party plugins which are not following WordPress standards.', 'tm-beans' ), - ), - ) ); - } - - beans_register_options( $fields, 'beans_settings', 'compiler_options', array( - 'title' => __( 'Compiler options', 'tm-beans' ), - 'context' => 'normal', - ) ); - - } - - /** - * Flush images for all folders set. - */ - public function flush() { - - if ( ! beans_post( 'beans_flush_compiler_cache' ) ) { - return; - } - - beans_remove_dir( beans_get_compiler_dir() ); - - } - - /** - * Cache cleaner notice. - */ - public function admin_notice() { - - if ( ! beans_post( 'beans_flush_compiler_cache' ) ) { - return; - } - - ?> -

- - - -
- - -
- - compile_enqueued( 'style' ) ) { - beans_compile_css_fragments( 'beans', $styles, array( 'version' => null ) ); - } - - } - - /** - * Enqueue compiled wp scripts. - */ - public function compile_page_scripts() { - - if ( ! beans_get_component_support( 'wp_scripts_compiler' ) || ! get_option( 'beans_compile_all_scripts', false ) || _beans_is_compiler_dev_mode() ) { - return; - } - - if ( $scripts = $this->compile_enqueued( 'script' ) ) { - beans_compile_js_fragments( 'beans', $scripts, array( - 'in_footer' => ( 'aggressive' === get_option( 'beans_compile_all_scripts_mode', 'aggressive' ) ) ? true : false, - 'version' => null, - ) ); - } - - } - - /** - * Compile all wp enqueued assets. - */ - private function compile_enqueued( $type, $depedencies = false ) { - - if ( ! $assets = beans_get( "wp_{$type}s", $GLOBALS ) ) { - return array(); - } - - if ( 'script' == $type ) { - add_action( 'wp_print_scripts', array( $this, 'dequeue_scripts' ), 9999 ); - } - - if ( ! $depedencies ) { - $depedencies = $assets->queue; - } - - $fragments = array(); - - foreach ( $depedencies as $id ) { - - // Don't compile admin bar assets. - if ( in_array( $id, array( 'admin-bar', 'open-sans', 'dashicons' ) ) ) { - continue; - } - - if ( ! $args = beans_get( $id, $assets->registered ) ) { - continue; - } - - if ( $args->deps ) { - - foreach ( $this->compile_enqueued( $type, $args->deps ) as $dep_id => $dep_src ) { - - if ( ! empty( $dep_src ) ) { - $fragments[ $dep_id ] = $dep_src; - } - } - } - - if ( 'style' == $type ) { - - // Add compiler media query if set. - if ( 'all' != $args->args ) { - $args->src = add_query_arg( array( 'beans_compiler_media_query' => $args->args ), $args->src ); - } - - $assets->done[] = $id; - - } elseif ( 'script' == $type ) { - - $this->dequeued_scripts[ $id ] = $args->src; - - } - - $fragments[ $id ] = $args->src; - - } - - return $fragments; - - } - - /** - * Dequeue scripts which have been compiled, grab localized - * data and add it inline. - */ - public function dequeue_scripts() { - - global $wp_scripts; - - if ( empty( $this->dequeued_scripts ) ) { - return; - } - - $localized = ''; - - // Fetch the localized content and dequeue script. - foreach ( $this->dequeued_scripts as $id => $src ) { - - if ( ! $args = beans_get( $id, $wp_scripts->registered ) ) { - continue; - } - - if ( isset( $args->extra['data'] ) ) { - $localized .= $args->extra['data'] . "\n"; - } - - $wp_scripts->done[] = $id; - - } - - // Stop here if there isn't any content to add. - if ( empty( $localized ) ) { - return; - } - - // Add localized content since it was removed with dequeue scripts. - printf( "\n", $localized ); - - } -} - -new _Beans_Page_Compiler(); diff --git a/lib/api/compiler/config/fields.php b/lib/api/compiler/config/fields.php new file mode 100644 index 00000000..ac029dee --- /dev/null +++ b/lib/api/compiler/config/fields.php @@ -0,0 +1,48 @@ + array( + 'id' => 'beans_compiler_items', + 'type' => 'flush_cache', + 'description' => __( 'Clear CSS and Javascript cached files. New cached versions will be compiled on page load.', 'tm-beans' ), + ), + 'beans_compile_all_styles' => array( + 'id' => 'beans_compile_all_styles', + 'label' => __( 'Compile all WordPress styles', 'tm-beans' ), + 'checkbox_label' => __( 'Select to compile styles.', 'tm-beans' ), + 'type' => 'checkbox', + 'default' => false, + 'description' => __( 'Compile and cache all the CSS files that have been enqueued to the WordPress head.', 'tm-beans' ), + ), + 'beans_compile_all_scripts_group' => array( + 'id' => 'beans_compile_all_scripts_group', + 'label' => __( 'Compile all WordPress scripts', 'tm-beans' ), + 'type' => 'group', + 'fields' => array( + array( + 'id' => 'beans_compile_all_scripts', + 'type' => 'activation', + 'label' => __( 'Select to compile scripts.', 'tm-beans' ), + 'default' => false, + ), + array( + 'id' => 'beans_compile_all_scripts_mode', + 'type' => 'select', + 'label' => __( 'Choose the level of compilation.', 'tm-beans' ), + 'default' => 'aggressive', + 'options' => array( + 'aggressive' => __( 'Aggressive', 'tm-beans' ), + 'standard' => __( 'Standard', 'tm-beans' ), + ), + ), + ), + 'description' => __( 'Compile and cache all the JavaScript files that have been enqueued to the WordPress head.
JavaScript is outputted in the footer if the level is set to Aggressive and might conflict with some third-party plugins which are not following WordPress standards.', 'tm-beans' ), + ), +); diff --git a/lib/api/compiler/functions.php b/lib/api/compiler/functions.php index 0ad4ca4e..9c3ffb27 100644 --- a/lib/api/compiler/functions.php +++ b/lib/api/compiler/functions.php @@ -2,11 +2,11 @@ /** * Compile and cache CSS, LESS and JS files. * - * The Beans Compiler is there to compile multiple internal or external CSS, LESS and JS files on a + * The Beans Compiler compiles multiple internal or external CSS, LESS and JS files on a * per page basis. LESS content will automatically be converted to CSS. * - * When development mode is enabled, internal files changes will automatically be detected. Third party enqueued - * styles and scripts can be compiled and cached into a single file. + * Internal file changes are automatically detected if development mode is enabled. + * Third party enqueued styles and scripts can be compiled and cached into a single file. * * @package API\Compiler */ @@ -15,20 +15,23 @@ * Compile CSS fragments and enqueue compiled file. * * This function should be used in a similar fashion to - * {@link http://codex.wordpress.org/Function_Reference/wp_enqueue_script wp_enqueue_script()}. + * {@link https://codex.wordpress.org/Function_Reference/wp_enqueue_script wp_enqueue_script()}. * * Fragments can be added to the compiler using {@see beans_compiler_add_fragment()}. * * @since 1.0.0 * - * @param string $id A unique string used as a reference. Similar to the WordPress scripts - * $handle argument. - * @param string|array $fragments File(s) absolute path. Internal or external file(s) url accepted but may increase compiling time. - * @param array $args { - * Optional. Array of arguments used by the compiler. + * @param string $id A unique string used as a reference. Similar to the WordPress scripts + * $handle argument. + * @param string|array $fragments File(s) absolute path. Internal or external file(s) url accepted but may increase + * compiling time. + * @param array $args { + * Optional. Array of arguments used by the compiler. * - * @type array $depedencies An array of registered handles this script depends on. Default false. + * @type array $dependencies An array of registered handles this script depends on. Default is an empty array. * } + * + * @return void|bool */ function beans_compile_css_fragments( $id, $fragments, $args = array() ) { @@ -36,34 +39,29 @@ function beans_compile_css_fragments( $id, $fragments, $args = array() ) { return false; } - $params = array( - 'id' => $id, - 'type' => 'style', - 'format' => 'css', - 'fragments' => (array) $fragments, - ); - - new _Beans_Compiler( $params + $args ); - + _beans_compile_fragments( $id, 'css', $fragments, $args ); } /** * Compile LESS fragments, convert to CSS and enqueue compiled file. * * This function should be used in a similar fashion to - * {@link http://codex.wordpress.org/Function_Reference/wp_enqueue_script wp_enqueue_script()}. + * {@link https://codex.wordpress.org/Function_Reference/wp_enqueue_script wp_enqueue_script()}. * * Fragments can be added to the compiler using {@see beans_compiler_add_fragment()}. * * @since 1.0.0 * - * @param string $id The compiler ID. Similar to the WordPress scripts $handle argument. - * @param string|array $fragments File(s) absolute path. Internal or external file(s) url accepted but may increase compiling time. - * @param array $args { - * Optional. Array of arguments used by the compiler. + * @param string $id The compiler ID. Similar to the WordPress scripts $handle argument. + * @param string|array $fragments File(s) absolute path. Internal or external file(s) url accepted but may increase + * compiling time. + * @param array $args { + * Optional. Array of arguments used by the compiler. * - * @type array $depedencies An array of registered handles this script depends on. Default false. + * @type array $dependencies An array of registered handles this script depends on. Default is an empty array. * } + * + * @return void|bool */ function beans_compile_less_fragments( $id, $fragments, $args = array() ) { @@ -71,38 +69,33 @@ function beans_compile_less_fragments( $id, $fragments, $args = array() ) { return false; } - $params = array( - 'id' => $id, - 'type' => 'style', - 'format' => 'less', - 'fragments' => (array) $fragments, - ); - - new _Beans_Compiler( $params + $args ); - + _beans_compile_fragments( $id, 'less', $fragments, $args ); } /** * Compile JS fragments and enqueue compiled file. * * This function should be used in a similar fashion to - * {@link http://codex.wordpress.org/Function_Reference/wp_enqueue_script wp_enqueue_script()}. + * {@link https://codex.wordpress.org/Function_Reference/wp_enqueue_script wp_enqueue_script()}. * * Fragments can be added to the compiler using {@see beans_compiler_add_fragment()}. * * @since 1.0.0 * - * @param string $id The compiler ID. Similar to the WordPress scripts $handle argument. - * @param string|array $fragments File(s) absolute path. Internal or external file(s) url accepted but may increase compiling time. - * @param array $args { - * Optional. Array of arguments used by the compiler. - * - * @type array $depedencies An array of registered handles this script depends on. Default false. - * @type bool $in_footer Whether to enqueue the script before or before . Default false. - * @type bool $minify_js Whether the JavaScript should be minified or not. Be aware that minifying - * the JavaScript can considerably slow down the process of compiling files. - * Default false. + * @param string $id The compiler ID. Similar to the WordPress scripts $handle argument. + * @param string|array $fragments File(s) absolute path. Internal or external file(s) URL accepted but may increase + * compiling time. + * @param array $args { + * Optional. Array of arguments used by the compiler. + * + * @type array $dependencies An array of registered handles this script depends on. Default false. + * @type bool $in_footer Whether to enqueue the script before or before . Default false. + * @type bool $minify_js Whether the JavaScript should be minified or not. Be aware that minifying + * the JavaScript can considerably slow down the process of compiling files. + * Default false. * } + * + * @return void|bool */ function beans_compile_js_fragments( $id, $fragments, $args = array() ) { @@ -110,29 +103,50 @@ function beans_compile_js_fragments( $id, $fragments, $args = array() ) { return false; } - $params = array( + _beans_compile_fragments( $id, 'js', $fragments, $args, true ); +} + +/** + * Compile the given fragments. + * + * @since 1.5.0 + * + * @param string $id The ID. + * @param string $format The format type. + * @param string|array $fragments File(s) absolute path. Internal or external file(s) URL accepted but may increase + * compiling time. + * @param array $args Optional. An array of arguments. + * @param bool $is_script Optional. When true, the fragment(s) is(are) script(s). + * + * @return void + */ +function _beans_compile_fragments( $id, $format, $fragments, array $args = array(), $is_script = false ) { + $config = array( 'id' => $id, - 'type' => 'script', - 'format' => 'js', + 'type' => $is_script ? 'script' : 'style', + 'format' => $format, 'fragments' => (array) $fragments, ); - new _Beans_Compiler( $params + $args ); - + $compiler = new _Beans_Compiler( $config + $args ); + $compiler->run_compiler(); } /** * Add CSS, LESS or JS fragments to a compiler. * * This function should be used in a similar fashion to - * {@link http://codex.wordpress.org/Function_Reference/wp_enqueue_script wp_enqueue_script()}. + * {@link https://codex.wordpress.org/Function_Reference/wp_enqueue_script wp_enqueue_script()}. * * @since 1.0.0 * * @param string $id The compiler ID. Similar to the WordPress scripts $handle argument. - * @param string|array $fragments File(s) absolute path. Internal or external file(s) url accepted but may increase compiling time. + * @param string|array $fragments File(s) absolute path. Internal or external file(s) url accepted but may increase + * compiling time. * @param string $format Compiler format the fragments should be added to. Accepts 'css', * 'less' or 'js'. + * + * @return void|bool */ function beans_compiler_add_fragment( $id, $fragments, $format ) { @@ -145,76 +159,67 @@ function beans_compiler_add_fragment( $id, $fragments, $format ) { foreach ( (array) $fragments as $key => $fragment ) { // Stop here if the format isn't valid. - if ( ! isset( $_beans_compiler_added_fragments[ $format ] ) ) : + if ( ! isset( $_beans_compiler_added_fragments[ $format ] ) ) { continue; + } - // Register new compiler id if it doesn't exist and add fragment. - elseif ( ! isset( $_beans_compiler_added_fragments[ $format ][ $id ] ) ) : + // Register a new compiler ID if it doesn't exist and add fragment. + if ( ! isset( $_beans_compiler_added_fragments[ $format ][ $id ] ) ) { $_beans_compiler_added_fragments[ $format ][ $id ] = array( $fragment ); - - // Add fragment to existing compiler. - else : + } else { // Add fragment to existing compiler. $_beans_compiler_added_fragments[ $format ][ $id ][] = $fragment; - - endif; - + } } - } /** * Flush cached compiler files. * - * Each compiler has its own folder which contains the cached CSS and JS files. Cached files format - * can be specified if needed. + * Each compiler has its own folder which contains the cached CSS and JS files. The file format + * of the cached file can be specified if needed. * * @since 1.0.0 * * @param string $id The compiler ID. Similar to the WordPress scripts $handle argument. - * @param string|bool $file_format Optional. Define which files format should be removed. Both CSS and JS + * @param string|bool $file_format Optional. Define which file format(s) should be removed. Both CSS and JS * files will be removed if set to false. Accepts 'false', 'css' or 'js'. * @param bool $admin Optional. Whether it is an admin compiler or not. + * + * @return void|bool */ function beans_flush_compiler( $id, $file_format = false, $admin = false ) { - static $beans_flushed = false; $cache_dir = beans_get_compiler_dir( $admin ); - // Always flush beans global chache. + // Always flush Beans' global cache. if ( ! $beans_flushed ) { - $beans_flushed = true; beans_flush_compiler( 'beans', $file_format, $admin ); - } - $dir = trailingslashit( $cache_dir ) . $id; + $dir = trailingslashit( $cache_dir ) . $id; // Stop here if directory doesn't exist. if ( ! is_dir( $dir ) ) { return; } - // Remove only specified format files. - if ( $file_format ) { + // Remove all file formats. + if ( ! $file_format ) { + beans_remove_dir( $dir ); - $items = scandir( $dir ); - unset( $items[0], $items[1] ); + return; + } - foreach ( $items as $item ) { + // Remove only the specified file format. + foreach ( beans_scandir( $dir ) as $item ) { - if ( false !== stripos( $item, '.' . $file_format ) ) { - @unlink( trailingslashit( $dir ) . $item ); - } + if ( beans_str_ends_with( $item, ".{$file_format}" ) ) { + @unlink( trailingslashit( $dir ) . $item ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. } - } else { // Remove all format files. - - beans_remove_dir( $dir ); - } - } /** @@ -225,61 +230,107 @@ function beans_flush_compiler( $id, $file_format = false, $admin = false ) { * @since 1.0.0 * * @param string $id The compiler ID. Similar to the WordPress scripts $handle argument. - * @param string|bool $file_format Optional. Define which files format should be removed. Both CSS and JS + * @param string|bool $file_format Optional. Define which file formats should be removed. Both CSS and JS * files will be removed if set to false. Accepts 'false', 'css' or 'js'. + * + * @return void */ function beans_flush_admin_compiler( $id, $file_format = false ) { - beans_flush_compiler( $id, $file_format, true ); - } /** - * Get beans compiler directory. + * Get absolute path to the Beans' compiler directory. * * @since 1.0.0 * - * @return string Compiler directory. + * @param bool $is_admin Optional. When true, gets the admin compiler directory. Default is false. + * + * @return string */ -function beans_get_compiler_dir( $admin = false ) { - +function beans_get_compiler_dir( $is_admin = false ) { $wp_upload_dir = wp_upload_dir(); - $suffix = $admin ? 'beans/admin-compiler/' : 'beans/compiler/'; + $suffix = $is_admin ? 'beans/admin-compiler/' : 'beans/compiler/'; /** - * Deprecated. Filter the beans compiler directory. + * Deprecated. Filter the Beans compiler directory. * * This filter is deprecated for security and compatibility purposes. * - * @since 1.0.0 + * @since 1.0.0 * @deprecated 1.3.0 */ - $deprecated = apply_filters( 'beans_compiler_dir', false, $admin ); + apply_filters( 'beans_compiler_dir', false, $is_admin ); return wp_normalize_path( trailingslashit( $wp_upload_dir['basedir'] ) . $suffix ); - } /** - * Get beans compiler url. + * Get absolute URL to the Beans' compiler directory. * * @since 1.3.0 * - * @return string Compiler directory. + * @param bool $is_admin Optional. When true, gets the admin compiler directory. Default is false. + * + * @return string */ -function beans_get_compiler_url( $admin = false ) { - +function beans_get_compiler_url( $is_admin = false ) { $wp_upload_dir = wp_upload_dir(); - $suffix = $admin ? 'beans/admin-compiler/' : 'beans/compiler/'; + $suffix = $is_admin ? 'beans/admin-compiler/' : 'beans/compiler/'; return trailingslashit( $wp_upload_dir['baseurl'] ) . $suffix; +} + +add_action( 'beans_loaded_api_component_compiler', 'beans_add_compiler_options_to_settings' ); +/** + * Add the "compiler options" to the Beans Settings page. + * + * @since 1.5.0 + * + * @return _Beans_Compiler_Options|void + */ +function beans_add_compiler_options_to_settings() { + if ( ! class_exists( '_Beans_Compiler_Options' ) ) { + return; + } + + $instance = new _Beans_Compiler_Options(); + $instance->init(); + + return $instance; +} + +add_action( 'beans_loaded_api_component_compiler', 'beans_add_page_assets_compiler' ); +/** + * Add the page assets' compiler. + * + * @since 1.5.0 + * + * @return _Beans_Page_Compiler|void + */ +function beans_add_page_assets_compiler() { + + if ( ! class_exists( '_Beans_Page_Compiler' ) ) { + return; + } + + $instance = new _Beans_Page_Compiler(); + $instance->init(); + + return $instance; } /** - * Check if development mode is enabled taking in consideration legacy constant. + * Check if development mode is enabled. + * + * Takes legacy constant into consideration. * + * @since 1.0.0 * @ignore + * @access private + * + * @return bool */ function _beans_is_compiler_dev_mode() { @@ -287,14 +338,15 @@ function _beans_is_compiler_dev_mode() { return BEANS_COMPILER_DEV_MODE; } - return get_option( 'beans_dev_mode', false ); - + return (bool) get_option( 'beans_dev_mode', false ); } /** * Initialize added fragments global. * + * @since 1.0.0 * @ignore + * @access private */ global $_beans_compiler_added_fragments; diff --git a/lib/api/compiler/vendors/lessc.php b/lib/api/compiler/vendors/lessc.php index 68ee6fd7..aac854b6 100644 --- a/lib/api/compiler/vendors/lessc.php +++ b/lib/api/compiler/vendors/lessc.php @@ -2509,7 +2509,7 @@ protected function expressionList(&$exps) { /** * Attempt to consume an expression. - * @link http://en.wikipedia.org/wiki/Operator-precedence_parser#Pseudo-code + * @link https://en.wikipedia.org/wiki/Operator-precedence_parser#Pseudo-code */ protected function expression(&$out) { if ($this->value($lhs)) { diff --git a/lib/api/compiler/views/flush-button.php b/lib/api/compiler/views/flush-button.php new file mode 100644 index 00000000..4f81b3bc --- /dev/null +++ b/lib/api/compiler/views/flush-button.php @@ -0,0 +1,12 @@ + + diff --git a/lib/api/compiler/views/flushed-notice.php b/lib/api/compiler/views/flushed-notice.php new file mode 100644 index 00000000..028a63d0 --- /dev/null +++ b/lib/api/compiler/views/flushed-notice.php @@ -0,0 +1,14 @@ + +
+

+
diff --git a/lib/api/compiler/views/localized-content.php b/lib/api/compiler/views/localized-content.php new file mode 100644 index 00000000..631272a4 --- /dev/null +++ b/lib/api/compiler/views/localized-content.php @@ -0,0 +1,15 @@ + + + diff --git a/lib/api/compiler/views/not-compiled-notice.php b/lib/api/compiler/views/not-compiled-notice.php new file mode 100644 index 00000000..91f3a0d7 --- /dev/null +++ b/lib/api/compiler/views/not-compiled-notice.php @@ -0,0 +1,13 @@ + +
+ diff --git a/lib/api/components.php b/lib/api/components.php index 4a541fc4..a52b1cb9 100644 --- a/lib/api/components.php +++ b/lib/api/components.php @@ -1,18 +1,20 @@ array( $root . 'html/functions.php', - $root . 'html/class.php', + $root . 'html/class-beans-attribute.php', + $root . 'html/accessibility.php', ), 'actions' => $root . 'actions/functions.php', 'filters' => $root . 'filters/functions.php', @@ -41,12 +43,12 @@ function beans_load_api_components( $components ) { 'image' => $root . 'image/functions.php', 'compiler' => array( $root . 'compiler/functions.php', - $root . 'compiler/class-compiler.php', - $root . 'compiler/class-page-compiler.php', + $root . 'compiler/class-beans-compiler.php', + $root . 'compiler/class-beans-page-compiler.php', ), 'uikit' => array( $root . 'uikit/functions.php', - $root . 'uikit/class.php', + $root . 'uikit/class-beans-uikit.php', ), 'layout' => $root . 'layout/functions.php', 'template' => $root . 'template/functions.php', @@ -59,8 +61,8 @@ function beans_load_api_components( $components ) { 'options' => $root . 'options/functions.php', 'post-meta' => $root . 'post-meta/functions-admin.php', 'term-meta' => $root . 'term-meta/functions-admin.php', - 'compiler' => $root . 'compiler/class-options.php', - 'image' => $root . 'image/class-options.php', + 'compiler' => $root . 'compiler/class-beans-compiler-options.php', + 'image' => $root . 'image/class-beans-image-options.php', '_admin_menu' => $root . 'admin-menu.php', // Internal use. ); } else { @@ -90,8 +92,8 @@ function beans_load_api_components( $components ) { foreach ( (array) $components as $component ) { - // Stop here if the component is already loaded or doesn't exists. - if ( in_array( $component, $loaded ) || ( ! isset( $common[ $component ] ) && ! isset( $admin[ $component ] ) ) ) { + // Stop here if the component is already loaded or doesn't exist. + if ( in_array( $component, $loaded, true ) || ( ! isset( $common[ $component ] ) && ! isset( $admin[ $component ] ) ) ) { continue; } @@ -116,8 +118,8 @@ function beans_load_api_components( $components ) { } // Load components. - foreach ( $_components as $component_path ) { - require_once( $component_path ); + foreach ( $_components as $component_path ) { + require_once $component_path; } /** @@ -128,11 +130,9 @@ function beans_load_api_components( $components ) { * @since 1.0.0 */ do_action( 'beans_loaded_api_component_' . $component ); - } return true; - } /** @@ -141,17 +141,15 @@ function beans_load_api_components( $components ) { * @since 1.0.0 * * @param string $feature The feature to register. - * @param mixed $var Additional variables passed to component support. * * @return bool Will always return true. */ function beans_add_api_component_support( $feature ) { - global $_beans_api_components_support; $args = func_get_args(); - if ( 1 == func_num_args() ) { + if ( 1 === func_num_args() ) { $args = true; } else { $args = array_slice( $args, 1 ); @@ -160,7 +158,6 @@ function beans_add_api_component_support( $feature ) { $_beans_api_components_support[ $feature ] = $args; return true; - } /** @@ -173,7 +170,6 @@ function beans_add_api_component_support( $feature ) { * @return mixed The argument(s) passed. */ function beans_get_component_support( $feature ) { - global $_beans_api_components_support; if ( ! isset( $_beans_api_components_support[ $feature ] ) ) { @@ -181,7 +177,6 @@ function beans_get_component_support( $feature ) { } return $_beans_api_components_support[ $feature ]; - } /** @@ -194,19 +189,16 @@ function beans_get_component_support( $feature ) { * @return bool Will always return true. */ function beans_remove_api_component_support( $feature ) { - global $_beans_api_components_support; - unset( $_beans_api_components_support[ $feature ] ); - return true; - } /** * Initialize API components support global. * * @ignore + * @access private */ global $_beans_api_components_support; diff --git a/lib/api/fields/assets/css/fields.css b/lib/api/fields/assets/css/fields.css index ea15f917..46e3ecdd 100644 --- a/lib/api/fields/assets/css/fields.css +++ b/lib/api/fields/assets/css/fields.css @@ -1,38 +1,41 @@ /* Fields ========================================================================== */ .bs-field-wrap { - width: 100%; display: inline-block; - border-top: 1px solid #e8e8e8; - padding: 20px 0; box-sizing: border-box; + width: 100%; + padding: 20px 0; + border-top: 1px solid #e8e8e8; } + .bs-field-wrap:first-of-type { - border-top: 0; padding-top: 10px; + border-top: 0; } + .bs-field-wrap:last-of-type { padding-bottom: 0; } + .bs-field-wrap a { - text-decoration: none; - outline: none; - box-shadow: none; } + .bs-field { display: block; + position: relative; width: 100%; min-width: 200px; - position: relative; padding: 0; } -.bs-field input[type='text'], + +.bs-field input[type="text"], .bs-field textarea { width: 100%; max-width: 100%; margin: 0; color: #666; } + .bs-field select { width: 100%; min-width: 200px; @@ -41,6 +44,10 @@ color: #666; } +p.bs-fields-header { + margin-top: 0; +} + /* Label */ .bs-field-wrap label { display: block; @@ -51,70 +58,94 @@ .bs-field-description { display: block; clear: both; - font-size: 11px; - color: #888; padding: 10px 0 0; + color: #333; + font-size: 12px; } + .bs-field-description .bs-read-more { - display: none; - text-decoration: none; - outline: none; } + .bs-field-description .bs-extended-content p { margin-top: 0; } + .js .bs-field-description a.bs-read-more { display: inline-block; } + .js .bs-field-description .bs-extended-content { - display: none; float: left; } /* Activation */ .bs-field.deactivated { - opacity: .5; + opacity: 0.5; } -/* Group fields */ -.bs-group .bs-field-inside { +/* Dashicons */ +.bs-field .button { display: inline-block; - margin: -10px 0 0 -10px; + padding: 0 4px 1px; + border-radius: 4px; + color: #555; + background-color: #fff; + text-align: center; + -moz-transition: background-color 0.1s ease-in 0; + -webkit-transition: background-color 0.1s ease-in 0; + transition: background-color 0.1s ease-in 0; } -.bs-group .bs-field-inside .bs-field { - display: inline-block; + +.bs-field .button:hover, +.bs-field .button:focus { + color: #fff; +} + +.bs-field .button.dashicons { width: auto; - min-width: 0; - max-width: 300px; - margin: 10px 0 0 10px; + font-size: 0; } -/* Dashicons */ -.bs-field a.dashicons { - display: inline-block; - margin-left: 5px; +.bs-field .bs-button-edit:before { + font-family: dashicons; + font-size: 22px; text-align: center; - background-color: #fff; - border-radius: 4px; - padding: 4px; - color: #555; - -moz-transition: background-color .1s ease-in 0; - -webkit-transition: background-color .1s ease-in 0; + content: "\f464"; } -.bs-field a.dashicons-edit { - font-size: 20px; + +.bs-field .bs-button-menu:before { + font-family: dashicons; + font-size: 22px; + text-align: center; + content: "\f333"; } -.bs-field a.dashicons:hover { - color: #fff; + +.bs-field .bs-button-trash { + margin-left: 5px; } -.bs-field a:hover.dashicons-edit { - background-color: #76B031; + +.bs-field .bs-button-trash:before { + font-family: dashicons; + font-size: 22px; + text-align: center; + content: "\f182"; } -.bs-field a:hover.dashicons-menu { - background-color: #2991C0; + +.bs-field .bs-button-edit:hover, +.bs-field .bs-button-edit:focus, +.bs-field .bs-add-image:hover, +.bs-field .bs-add-image:focus { + background-color: #76b031; +} + +.bs-field .bs-button-menu:hover, +.bs-field .bs-button-menu:focus { + background-color: #2991c0; cursor: move; } -.bs-field a:hover.dashicons-post-trash { + +.bs-field .bs-button-trash:hover, +.bs-field .bs-button-trash:focus { background-color: #dd4b39; } @@ -126,85 +157,124 @@ cursor: pointer; } +.bs-activation label { + display: inline-block; + margin-bottom: 5px; +} + /* Image */ .bs-field .bs-images-wrap { - margin-left:-10px; + margin-left: -10px; } + .bs-field .bs-image-wrap, .bs-field .bs-image-placeholder { - position: relative; display: inline-block; + position: relative; margin: 10px 0 0 10px; } + .bs-field .bs-images-wrap:not([data-multiple="1"]) .bs-image-wrap { margin-top: 0; } + .bs-field .bs-image-wrap { - border: 1px solid #ddd; - height: 110px; width: 110px; + height: 110px; + border: 1px solid #ddd; background: #eee; box-shadow: inset 0 0 0 3px #fff; text-align: center; } + .bs-field .bs-image-placeholder { border: 3px dashed #ddd; } + .bs-field .bs-image-wrap img { position: absolute; - margin: auto; top: 0; - left: 0; right: 0; bottom: 0; - max-height: 100%; + left: 0; + box-sizing: border-box; max-width: 100%; + max-height: 100%; + margin: auto; padding: 2px; - box-sizing: border-box; } + .bs-field .bs-image-template { display: none; } + .bs-field .bs-image-wrap .bs-toolbar { - width: 100%; - padding: 6px 0; - text-align: center; - box-sizing: border-box; position: absolute; right: 0; - top: 0; + bottom: 0; + box-sizing: border-box; + width: 100%; + padding: 3px 0; background-color: #e6e6e6; - display: none; + text-align: center; } + .bs-field .bs-image-wrap .bs-toolbar a { margin: 0 3px 0 1px; } -.bs-field .bs-image-wrap:hover .bs-toolbar { - display: block; + +.bs-field .bs-image-wrap:hover .bs-toolbar, +.bs-field .bs-image-wrap:focus .bs-toolbar { } +/* Group fields */ +.bs-group .bs-field-inside { + display: inline-block; + margin: -10px 0 0 -10px; +} -/* Radio/Imageradio */ -.bs-radio fieldset { - margin-left: -15px; +.bs-group .bs-field-inside .bs-field { + display: inline-block; + width: auto; + min-width: 0; + max-width: 300px; + margin: 10px 0 0 10px; +} + +.bs-group .bs-field-inside .bs-field:first-of-type { + margin-left: 3px; +} + +.bs-group .bs-field-fieldset { + margin: 10px; } -.bs-radio fieldset label { - padding-left: 15px; + +.bs-group .bs-select select { + margin-top: -8px; +} + +/* Radio/Image radio */ +.bs-radio .bs-field-legend { + margin-bottom: 15px; } + .bs-radio .bs-has-image { - width: auto; display: inline-block; + width: auto; + padding-right: 15px; line-height: 0; } + .bs-radio img { padding: 1px; border: 3px solid #eee; } + .bs-radio .selected img { border-color: #2ea2cc; } + .bs-radio .bs-has-image input { - display: none; } /* Textarea */ @@ -214,57 +284,60 @@ /* Slider */ .bs-field .bs-slider-wrap { - border-radius: 5px; - width: 180px; - height: 10px; - border: 1px solid #ccc; display: inline-block; - margin: 2px 0 0; position: relative; top: 2px; + width: 180px; + height: 10px; + margin: 2px 0 0; + border: 1px solid #ccc; + border-radius: 5px; } + .bs-field .ui-slider-range { - background: #ddd; height: 10px; border-radius: 4px; + background: #ddd; } + .bs-field .ui-slider-handle { - background: #bbb; - border-radius: 8px; display: block; - height: 16px; + position: absolute; width: 16px; + height: 16px; margin: -13px 0 0 -8px; - position: absolute; - cursor: pointer; + border-radius: 8px; + background: #bbb; box-shadow: none; - outline: 0; + cursor: pointer; } + .bs-field .ui-slider-handle.ui-state-active { background: #aaa; - outline: 0; } + .bs-field .bs-slider-value, .bs-field .bs-slider-unit { - font-size: 11px; display: inline-block; margin: 0; + font-size: 11px; } + .bs-field .bs-slider-value { margin-left: 5px; } - /* Options fields modifiers ========================================================================== */ .bs-options-form-actions { - padding: 0; - margin: 0; display: block; clear: both; width: 100%; + margin: 0; margin-top: 20px; + padding: 0; } + .bs-options-form-actions input { display: inline-block; margin-right: 10px; @@ -274,24 +347,29 @@ .bs-options .postbox-container { min-height: 100px; } + .bs-options .metabox-holder { margin: 0 0 0 -20px; padding: 0; } + .bs-options .meta-box-sortables { float: left; - padding-left: 20px; - margin: 0; -moz-box-sizing: border-box; box-sizing: border-box; width: 100%; min-height: 100px; min-height: 100px; + margin: 0; + padding-left: 20px; } + @media (min-width: 768px) { + .bs-options .metabox-holder .meta-box-sortables { width: 75%; - } + } + .bs-options .metabox-holder.column .meta-box-sortables { width: 50%; } @@ -302,24 +380,27 @@ .form-field .bs-field-wrap { padding: 0; } -.form-field .bs-field input[type='text'], + +.form-field .bs-field input[type="text"], .form-field .bs-field textarea { max-width: 95%; } + /* Radio/Imageradio */ .bs-field fieldset label:not(.bs-has-image) { display: block; } - /* WP customizer fields modifiers ========================================================================== */ #customize-controls .bs-field-wrap label { margin-bottom: 5px; } + #customize-controls .bs-field-wrap:first-of-type { padding-top: 5px; } + #customize-controls .bs-field-wrap { padding: 0; } @@ -330,16 +411,19 @@ font-size: 14px; font-weight: 600; } + #customize-controls .bs-radio fieldset { margin-left: -5px; } + #customize-controls .bs-radio fieldset label { - padding: 0 0 0 5px; margin-bottom: 0; + padding: 0 0 0 5px; } + #customize-controls .bs-radio .bs-has-image img { - border-width: 2px; width: 33px; height: 33px; margin-bottom: 0; + border-width: 2px; } diff --git a/lib/api/fields/assets/css/fields.min.css b/lib/api/fields/assets/css/fields.min.css index bc4d394d..8b5a1e13 100644 --- a/lib/api/fields/assets/css/fields.min.css +++ b/lib/api/fields/assets/css/fields.min.css @@ -1 +1 @@ -.bs-field-wrap{width:100%;display:inline-block;border-top:1px solid #e8e8e8;padding:20px 0;box-sizing:border-box}.bs-field-wrap:first-of-type{border-top:0;padding-top:10px}.bs-field-wrap:last-of-type{padding-bottom:0}.bs-field-wrap a{text-decoration:none;outline:0;box-shadow:none}.bs-field{display:block;width:100%;min-width:200px;position:relative;padding:0}.bs-field input[type='text'],.bs-field textarea{width:100%;max-width:100%;margin:0;color:#666}.bs-field select{width:100%;min-width:200px;max-width:280px;margin:0;color:#666}.bs-field-wrap label{display:block;margin-bottom:15px}.bs-field-description{display:block;clear:both;font-size:11px;color:#888;padding:10px 0 0}.bs-field-description .bs-read-more{display:none;text-decoration:none;outline:0}.bs-field-description .bs-extended-content p{margin-top:0}.js .bs-field-description a.bs-read-more{display:inline-block}.js .bs-field-description .bs-extended-content{display:none;float:left}.bs-field.deactivated{opacity:.5}.bs-group .bs-field-inside{display:inline-block;margin:-10px 0 0 -10px}.bs-group .bs-field-inside .bs-field{display:inline-block;width:auto;min-width:0;max-width:300px;margin:10px 0 0 10px}.bs-field a.dashicons{display:inline-block;margin-left:5px;text-align:center;background-color:#fff;border-radius:4px;padding:4px;color:#555;-moz-transition:background-color .1s ease-in 0;-webkit-transition:background-color .1s ease-in 0}.bs-field a.dashicons-edit{font-size:20px}.bs-field a.dashicons:hover{color:#fff}.bs-field a:hover.dashicons-edit{background-color:#76b031}.bs-field a:hover.dashicons-menu{background-color:#2991c0;cursor:move}.bs-field a:hover.dashicons-post-trash{background-color:#dd4b39}.bs-field .bs-checkbox-label{cursor:pointer}.bs-field .bs-images-wrap{margin-left:-10px}.bs-field .bs-image-wrap,.bs-field .bs-image-placeholder{position:relative;display:inline-block;margin:10px 0 0 10px}.bs-field .bs-images-wrap:not([data-multiple="1"]) .bs-image-wrap{margin-top:0}.bs-field .bs-image-wrap{border:1px solid #ddd;height:110px;width:110px;background:#eee;box-shadow:inset 0 0 0 3px #fff;text-align:center}.bs-field .bs-image-placeholder{border:3px dashed #ddd}.bs-field .bs-image-wrap img{position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;max-height:100%;max-width:100%;padding:2px;box-sizing:border-box}.bs-field .bs-image-template{display:none}.bs-field .bs-image-wrap .bs-toolbar{width:100%;padding:6px 0;text-align:center;box-sizing:border-box;position:absolute;right:0;top:0;background-color:#e6e6e6;display:none}.bs-field .bs-image-wrap .bs-toolbar a{margin:0 3px 0 1px}.bs-field .bs-image-wrap:hover .bs-toolbar{display:block}.bs-radio fieldset{margin-left:-15px}.bs-radio fieldset label{padding-left:15px}.bs-radio .bs-has-image{width:auto;display:inline-block;line-height:0}.bs-radio img{padding:1px;border:3px solid #eee}.bs-radio .selected img{border-color:#2ea2cc}.bs-radio .bs-has-image input{display:none}.bs-field textarea{height:70px}.bs-field .bs-slider-wrap{border-radius:5px;width:180px;height:10px;border:1px solid #ccc;display:inline-block;margin:2px 0 0;position:relative;top:2px}.bs-field .ui-slider-range{background:#ddd;height:10px;border-radius:4px}.bs-field .ui-slider-handle{background:#bbb;border-radius:8px;display:block;height:16px;width:16px;margin:-13px 0 0 -8px;position:absolute;cursor:pointer;box-shadow:none;outline:0}.bs-field .ui-slider-handle.ui-state-active{background:#aaa;outline:0}.bs-field .bs-slider-value,.bs-field .bs-slider-unit{font-size:11px;display:inline-block;margin:0}.bs-field .bs-slider-value{margin-left:5px}.bs-options-form-actions{padding:0;margin:0;display:block;clear:both;width:100%;margin-top:20px}.bs-options-form-actions input{display:inline-block;margin-right:10px}.bs-options .postbox-container{min-height:100px}.bs-options .metabox-holder{margin:0 0 0 -20px;padding:0}.bs-options .meta-box-sortables{float:left;padding-left:20px;margin:0;-moz-box-sizing:border-box;box-sizing:border-box;width:100%;min-height:100px;min-height:100px}@media(min-width:768px){.bs-options .metabox-holder .meta-box-sortables{width:75%}.bs-options .metabox-holder.column .meta-box-sortables{width:50%}}.form-field .bs-field-wrap{padding:0}.form-field .bs-field input[type='text'],.form-field .bs-field textarea{max-width:95%}.bs-field fieldset label:not(.bs-has-image){display:block}#customize-controls .bs-field-wrap label{margin-bottom:5px}#customize-controls .bs-field-wrap:first-of-type{padding-top:5px}#customize-controls .bs-field-wrap{padding:0}#customize-controls .bs-radio label{color:#555;font-size:14px;font-weight:600}#customize-controls .bs-radio fieldset{margin-left:-5px}#customize-controls .bs-radio fieldset label{padding:0 0 0 5px;margin-bottom:0}#customize-controls .bs-radio .bs-has-image img{border-width:2px;width:33px;height:33px;margin-bottom:0} \ No newline at end of file +.bs-field-wrap{display:inline-block;box-sizing:border-box;width:100%;padding:20px 0;border-top:1px solid #e8e8e8}.bs-field-wrap:first-of-type{padding-top:10px;border-top:0}.bs-field-wrap:last-of-type{padding-bottom:0}.bs-field{display:block;position:relative;width:100%;min-width:200px;padding:0}.bs-field input[type=text],.bs-field textarea{width:100%;max-width:100%;margin:0;color:#666}.bs-field select{width:100%;min-width:200px;max-width:280px;margin:0;color:#666}p.bs-fields-header{margin-top:0}.bs-field-wrap label{display:block;margin-bottom:15px}.bs-field-description{display:block;clear:both;padding:10px 0 0;color:#333;font-size:12px}.bs-field-description .bs-extended-content p{margin-top:0}.js .bs-field-description a.bs-read-more{display:inline-block}.js .bs-field-description .bs-extended-content{float:left}.bs-field.deactivated{opacity:.5}.bs-field .button{display:inline-block;padding:0 4px 1px;border-radius:4px;color:#555;background-color:#fff;text-align:center;transition:background-color .1s ease-in 0}.bs-field .button:focus,.bs-field .button:hover{color:#fff}.bs-field .button.dashicons{width:auto;font-size:0}.bs-field .bs-button-edit:before{font-family:dashicons;font-size:22px;text-align:center;content:"\f464"}.bs-field .bs-button-menu:before{font-family:dashicons;font-size:22px;text-align:center;content:"\f333"}.bs-field .bs-button-trash{margin-left:5px}.bs-field .bs-button-trash:before{font-family:dashicons;font-size:22px;text-align:center;content:"\f182"}.bs-field .bs-add-image:focus,.bs-field .bs-add-image:hover,.bs-field .bs-button-edit:focus,.bs-field .bs-button-edit:hover{background-color:#76b031}.bs-field .bs-button-menu:focus,.bs-field .bs-button-menu:hover{background-color:#2991c0;cursor:move}.bs-field .bs-button-trash:focus,.bs-field .bs-button-trash:hover{background-color:#dd4b39}.bs-field .bs-checkbox-label{cursor:pointer}.bs-activation label{display:inline-block;margin-bottom:5px}.bs-field .bs-images-wrap{margin-left:-10px}.bs-field .bs-image-placeholder,.bs-field .bs-image-wrap{display:inline-block;position:relative;margin:10px 0 0 10px}.bs-field .bs-images-wrap:not([data-multiple="1"]) .bs-image-wrap{margin-top:0}.bs-field .bs-image-wrap{width:110px;height:110px;border:1px solid #ddd;background:#eee;box-shadow:inset 0 0 0 3px #fff;text-align:center}.bs-field .bs-image-placeholder{border:3px dashed #ddd}.bs-field .bs-image-wrap img{position:absolute;top:0;right:0;bottom:0;left:0;box-sizing:border-box;max-width:100%;max-height:100%;margin:auto;padding:2px}.bs-field .bs-image-template{display:none}.bs-field .bs-image-wrap .bs-toolbar{position:absolute;right:0;bottom:0;box-sizing:border-box;width:100%;padding:3px 0;background-color:#e6e6e6;text-align:center}.bs-field .bs-image-wrap .bs-toolbar a{margin:0 3px 0 1px}.bs-group .bs-field-inside{display:inline-block;margin:-10px 0 0 -10px}.bs-group .bs-field-inside .bs-field{display:inline-block;width:auto;min-width:0;max-width:300px;margin:10px 0 0 10px}.bs-group .bs-field-inside .bs-field:first-of-type{margin-left:3px}.bs-group .bs-field-fieldset{margin:10px}.bs-group .bs-select select{margin-top:-8px}.bs-radio .bs-field-legend{margin-bottom:15px}.bs-radio .bs-has-image{display:inline-block;width:auto;padding-right:15px;line-height:0}.bs-radio img{padding:1px;border:3px solid #eee}.bs-radio .selected img{border-color:#2ea2cc}.bs-field textarea{height:70px}.bs-field .bs-slider-wrap{display:inline-block;position:relative;top:2px;width:180px;height:10px;margin:2px 0 0;border:1px solid #ccc;border-radius:5px}.bs-field .ui-slider-range{height:10px;border-radius:4px;background:#ddd}.bs-field .ui-slider-handle{display:block;position:absolute;width:16px;height:16px;margin:-13px 0 0 -8px;border-radius:8px;background:#bbb;box-shadow:none;cursor:pointer}.bs-field .ui-slider-handle.ui-state-active{background:#aaa}.bs-field .bs-slider-unit,.bs-field .bs-slider-value{display:inline-block;margin:0;font-size:11px}.bs-field .bs-slider-value{margin-left:5px}.bs-options-form-actions{display:block;clear:both;width:100%;margin:0;margin-top:20px;padding:0}.bs-options-form-actions input{display:inline-block;margin-right:10px}.bs-options .postbox-container{min-height:100px}.bs-options .metabox-holder{margin:0 0 0 -20px;padding:0}.bs-options .meta-box-sortables{float:left;box-sizing:border-box;width:100%;min-height:100px;margin:0;padding-left:20px}@media (min-width:768px){.bs-options .metabox-holder .meta-box-sortables{width:75%}.bs-options .metabox-holder.column .meta-box-sortables{width:50%}}.form-field .bs-field-wrap{padding:0}.form-field .bs-field input[type=text],.form-field .bs-field textarea{max-width:95%}.bs-field fieldset label:not(.bs-has-image){display:block}#customize-controls .bs-field-wrap label{margin-bottom:5px}#customize-controls .bs-field-wrap:first-of-type{padding-top:5px}#customize-controls .bs-field-wrap{padding:0}#customize-controls .bs-radio label{color:#555;font-size:14px;font-weight:600}#customize-controls .bs-radio fieldset{margin-left:-5px}#customize-controls .bs-radio fieldset label{margin-bottom:0;padding:0 0 0 5px}#customize-controls .bs-radio .bs-has-image img{width:33px;height:33px;margin-bottom:0;border-width:2px} \ No newline at end of file diff --git a/lib/api/fields/assets/js/fields.js b/lib/api/fields/assets/js/fields.js index 4e6c780a..c1302ef7 100644 --- a/lib/api/fields/assets/js/fields.js +++ b/lib/api/fields/assets/js/fields.js @@ -1,34 +1,25 @@ -!(function($) { - - "use strict"; +!(function( $ ) { + 'use strict'; var beansFields = function( element, options ) { - this.container = $( element ); this.init(); this.listen(); - } beansFields.prototype = { - constructor: beansFields, checkboxLabelToggle: function ( selector ) { - selector.parent().find( 'input[type="checkbox"]' ).click(); - }, imageradio: function( selector ) { - selector.closest( 'fieldset' ).find( 'label' ).removeClass( 'selected' ); selector.closest( 'label.bs-has-image' ).addClass( 'selected' ); - }, slider: function( selector ) { - var value = parseInt( selector.find( 'input[type=text]' ).val() ), min = parseInt( selector.attr( 'slider_min' ) ), max = parseInt( selector.attr( 'slider_max' ) ), @@ -41,41 +32,30 @@ max: max, step: interval, slide: function( event, ui ) { + // Update visible output. + $(this).parent().find( '.bs-slider-value' ).text( ui.value ); - // Update visible output. - $(this).parent().find( '.bs-slider-value' ).text( ui.value ); - - // Update hidden input. - $(this).find( 'input[type=text]' ) - .val( ui.value ) - .keyup(); - + // Update text hidden input. Then trigger the change. + var sliderField = $(this).find( 'input[type=text]' ); + sliderField.attr( 'value', ui.value ); + sliderField.trigger( 'change' ); } }); // Remove href attribute to keep status bar from showing. selector.find( '.ui-slider-handle' ).removeAttr( 'href' ); - }, activation: function( selector ) { if ( selector.is( ':checked' ) ) { - - selector.parent().next() - .removeClass( 'deactivated' ); - + selector.parent().next().removeClass( 'deactivated' ); } else { - - selector.parent().next() - .addClass( 'deactivated' ); - + selector.parent().next().addClass( 'deactivated' ); } - }, readmore: function( selector ) { - selector.parents( '.bs-field-description' ).find( '.bs-extended-content' ).slideToggle( 400, function() { if ( $( this ).is( ':visible' ) ) { @@ -83,29 +63,23 @@ } else { selector.text( 'More...' ); } - }); }, postbox: function( selector ) { - // Close postboxes that should be closed. $( '.if-js-closed' ).removeClass( 'if-js-closed' ).addClass( 'closed' ); postboxes.add_postbox_toggles( selector.data( 'page' ) ); - }, init: function() { - var that = this; // Fire ui slider. this.container.find( '.bs-slider-wrap' ).each( function() { - that.slider( $( this ) ); - }); // Add active imageradio. @@ -113,9 +87,7 @@ // Fire activation toggle. this.container.find( '.bs-field.bs-activation input[type="checkbox"]' ).each( function() { - that.activation( $( this ) ); - }); // Fire the postboxes. @@ -125,44 +97,33 @@ }, listen: function() { - var that = this; // Make checkbox legend toggling checkbox input on click. this.container.on( 'click', '.bs-checkbox-label', function( e ) { - that.checkboxLabelToggle( $( this ) ); - }); // Fire imageradio on click. this.container.on( 'click', '.bs-field.bs-radio label', function( e ) { - that.imageradio( $( this ) ); - }); // Fire activation toggle on click. this.container.on( 'click', '.bs-field.bs-activation input[type="checkbox"]', function() { - that.activation( $( this ) ); - }); // Fire readmore on click. this.container.on( 'click', '.bs-read-more', function( e ) { - e.preventDefault(); that.readmore( $( this ) ); - }); // Reset confirmation. this.container.on( 'click', '[name="beans_reset_options"]', function(e) { - return confirm( 'Are you sure you would like to reset?' ); - }); } @@ -176,26 +137,20 @@ if ( ! $.data( this, 'plugin_beansFields' ) ) { $.data( this, 'plugin_beansFields', new beansFields( this, options ) ); } - }); }; // Fire the plugin. $( document ).ready( function( $ ) { - $( '#edittag, #post-body, .bs-options' ).beansFields(); // Wait for the control to be loaded before initialising. if ( wp.customize !== undefined ) { wp.customize.bind( 'ready', function() { - $( '#customize-controls' ).beansFields(); - } ); - } - }); })( window.jQuery ); diff --git a/lib/api/fields/assets/js/fields.min.js b/lib/api/fields/assets/js/fields.min.js index f809b97d..eba06861 100644 --- a/lib/api/fields/assets/js/fields.min.js +++ b/lib/api/fields/assets/js/fields.min.js @@ -1 +1 @@ -!(function(b){var a=function(d,c){this.container=b(d);this.init();this.listen()};a.prototype={constructor:a,checkboxLabelToggle:function(c){c.parent().find('input[type="checkbox"]').click()},imageradio:function(c){c.closest("fieldset").find("label").removeClass("selected");c.closest("label.bs-has-image").addClass("selected")},slider:function(d){var g=parseInt(d.find("input[type=text]").val()),f=parseInt(d.attr("slider_min")),c=parseInt(d.attr("slider_max")),e=parseInt(d.attr("slider_interval"));d.slider({range:"min",value:g,min:f,max:c,step:e,slide:function(h,i){b(this).parent().find(".bs-slider-value").text(i.value);b(this).find("input[type=text]").val(i.value).keyup()}});d.find(".ui-slider-handle").removeAttr("href")},activation:function(c){if(c.is(":checked")){c.parent().next().removeClass("deactivated")}else{c.parent().next().addClass("deactivated")}},readmore:function(c){c.parents(".bs-field-description").find(".bs-extended-content").slideToggle(400,function(){if(b(this).is(":visible")){c.text("Less...")}else{c.text("More...")}})},postbox:function(c){b(".if-js-closed").removeClass("if-js-closed").addClass("closed");postboxes.add_postbox_toggles(c.data("page"))},init:function(){var c=this;this.container.find(".bs-slider-wrap").each(function(){c.slider(b(this))});this.container.find(".bs-field.bs-radio .bs-has-image input:checked:enabled").closest("label").addClass("selected");this.container.find('.bs-field.bs-activation input[type="checkbox"]').each(function(){c.activation(b(this))});if((typeof postboxes!="undefined")&&this.container.hasClass("bs-options")){this.postbox(this.container)}},listen:function(){var c=this;this.container.on("click",".bs-checkbox-label",function(d){c.checkboxLabelToggle(b(this))});this.container.on("click",".bs-field.bs-radio label",function(d){c.imageradio(b(this))});this.container.on("click",'.bs-field.bs-activation input[type="checkbox"]',function(){c.activation(b(this))});this.container.on("click",".bs-read-more",function(d){d.preventDefault();c.readmore(b(this))});this.container.on("click",'[name="beans_reset_options"]',function(d){return confirm("Are you sure you would like to reset?")})}};b.fn.beansFields=function(c){return this.each(function(){if(!b.data(this,"plugin_beansFields")){b.data(this,"plugin_beansFields",new a(this,c))}})};b(document).ready(function(c){c("#edittag, #post-body, .bs-options").beansFields();if(wp.customize!==undefined){wp.customize.bind("ready",function(){c("#customize-controls").beansFields()})}})})(window.jQuery); \ No newline at end of file +!function(a){"use strict";var t=function(e,t){this.container=a(e),this.init(),this.listen()};t.prototype={constructor:t,checkboxLabelToggle:function(e){e.parent().find('input[type="checkbox"]').click()},imageradio:function(e){e.closest("fieldset").find("label").removeClass("selected"),e.closest("label.bs-has-image").addClass("selected")},slider:function(e){var t=parseInt(e.find("input[type=text]").val()),i=parseInt(e.attr("slider_min")),n=parseInt(e.attr("slider_max")),s=parseInt(e.attr("slider_interval"));e.slider({range:"min",value:t,min:i,max:n,step:s,slide:function(e,t){a(this).parent().find(".bs-slider-value").text(t.value);var i=a(this).find("input[type=text]");i.attr("value",t.value),i.trigger("change")}}),e.find(".ui-slider-handle").removeAttr("href")},activation:function(e){e.is(":checked")?e.parent().next().removeClass("deactivated"):e.parent().next().addClass("deactivated")},readmore:function(e){e.parents(".bs-field-description").find(".bs-extended-content").slideToggle(400,function(){a(this).is(":visible")?e.text("Less..."):e.text("More...")})},postbox:function(e){a(".if-js-closed").removeClass("if-js-closed").addClass("closed"),postboxes.add_postbox_toggles(e.data("page"))},init:function(){var e=this;this.container.find(".bs-slider-wrap").each(function(){e.slider(a(this))}),this.container.find(".bs-field.bs-radio .bs-has-image input:checked:enabled").closest("label").addClass("selected"),this.container.find('.bs-field.bs-activation input[type="checkbox"]').each(function(){e.activation(a(this))}),"undefined"!=typeof postboxes&&this.container.hasClass("bs-options")&&this.postbox(this.container)},listen:function(){var t=this;this.container.on("click",".bs-checkbox-label",function(e){t.checkboxLabelToggle(a(this))}),this.container.on("click",".bs-field.bs-radio label",function(e){t.imageradio(a(this))}),this.container.on("click",'.bs-field.bs-activation input[type="checkbox"]',function(){t.activation(a(this))}),this.container.on("click",".bs-read-more",function(e){e.preventDefault(),t.readmore(a(this))}),this.container.on("click",'[name="beans_reset_options"]',function(e){return confirm("Are you sure you would like to reset?")})}},a.fn.beansFields=function(e){return this.each(function(){a.data(this,"plugin_beansFields")||a.data(this,"plugin_beansFields",new t(this,e))})},a(document).ready(function(e){e("#edittag, #post-body, .bs-options").beansFields(),void 0!==wp.customize&&wp.customize.bind("ready",function(){e("#customize-controls").beansFields()})})}(window.jQuery); \ No newline at end of file diff --git a/lib/api/fields/assets/js/media.js b/lib/api/fields/assets/js/media.js index f762b5fe..e5fd1329 100644 --- a/lib/api/fields/assets/js/media.js +++ b/lib/api/fields/assets/js/media.js @@ -1,17 +1,13 @@ (function($){ - "use strict"; var beansFieldImage = function( element, options ) { - this.container = $( element ); this.isMultiple = this.container.find( '.bs-images-wrap' ).data( 'multiple' ); this.init(); - } beansFieldImage.prototype = { - constructor: beansFieldImage, addImage: function( element ) { @@ -27,7 +23,6 @@ // Run a callback when an image is selected. media_iframe.on( 'select', function() { - var selection = media_iframe.state().get( 'selection' ); if ( ! selection ) { @@ -40,7 +35,6 @@ var newField = field.find( '.bs-image-wrap.bs-image-template' ) .clone() .removeClass( 'bs-image-template' ); - var updatedfield = $this.updateImage( newField, attachment ); // Finally append the field @@ -50,18 +44,14 @@ if ( ! $this.isMultiple ) { element.hide(); } - }); - }); // Open the iframe. media_iframe.open(); - }, editImage: function( element ) { - var $this = this, media_iframe, field = element.parents( '.bs-field-wrap' ); @@ -73,19 +63,16 @@ // Select image on edit. media_iframe.on( 'open', function() { - var selection = media_iframe.state().get( 'selection' ), id = element.parents( '.bs-image-wrap' ).find( 'input[type=hidden]' ).val(), attachment = wp.media.model.Attachment.get( id ); attachment.fetch(); selection.add( attachment ? [ attachment ] : [] ); - }); // Run a callback when an image is selected. media_iframe.on( 'select', function() { - var selection = media_iframe.state().get( 'selection' ); if ( ! selection ) { @@ -93,16 +80,13 @@ } selection.each( function( attachment ) { - $this.updateImage( element.parents( '.bs-image-wrap' ), attachment ); - }); }); // Open the iframe. media_iframe.open(); - }, updateImage: function( field, attachment ) { @@ -144,7 +128,7 @@ var $this = this; this.container.find( '.bs-images-wrap' ).sortable( { - handle: '.bs-toolbar .dashicons-menu', + handle: '.bs-toolbar .bs-button-menu', placeholder: "bs-image-placeholder", cursor: 'move', start: function( e, ui ){ @@ -156,36 +140,27 @@ }, init: function() { - this.sortable(); this.listen(); - }, listen: function() { - var $this = this; this.container.on( 'click', '.bs-add-image', function() { - $this.addImage( $(this) ); - }); - this.container.on( 'click', '.dashicons-post-trash', function( e ) { - + this.container.on( 'click', '.bs-button-trash', function( e ) { e.preventDefault(); $this.deleteImage( $(this) ); - }); - this.container.on( 'click', '.dashicons-edit', function( e ) { - + this.container.on( 'click', '.bs-button-edit', function( e ) { e.preventDefault(); $this.editImage( $(this) ); - }); } @@ -199,15 +174,12 @@ if ( ! $.data( this, 'plugin_beansFieldImages' ) ) { $.data( this, 'plugin_beansFieldImage', new beansFieldImage( this, options ) ); } - }); }; // Fire the plugin. $( document ).ready( function( $ ) { - $( '.bs-field.bs-image' ).beansFieldImage(); - }); })(jQuery); diff --git a/lib/api/fields/assets/js/media.min.js b/lib/api/fields/assets/js/media.min.js index e38c1c9d..673c1293 100644 --- a/lib/api/fields/assets/js/media.min.js +++ b/lib/api/fields/assets/js/media.min.js @@ -1 +1 @@ -(function(b){var a=function(d,c){this.container=b(d);this.isMultiple=this.container.find(".bs-images-wrap").data("multiple");this.init()};a.prototype={constructor:a,addImage:function(c){var f=this,e,d=c.parents(".bs-field-wrap");e=wp.media({multiple:f.isMultiple});e.on("select",function(){var g=e.state().get("selection");if(!g){return}g.each(function(j){var i=d.find(".bs-image-wrap.bs-image-template").clone().removeClass("bs-image-template");var h=f.updateImage(i,j);d.find(".bs-images-wrap").append(h);if(!f.isMultiple){c.hide()}})});e.open()},editImage:function(c){var f=this,e,d=c.parents(".bs-field-wrap");e=wp.media({multiple:false});e.on("open",function(){var g=e.state().get("selection"),i=c.parents(".bs-image-wrap").find("input[type=hidden]").val(),h=wp.media.model.Attachment.get(i);h.fetch();g.add(h?[h]:[])});e.on("select",function(){var g=e.state().get("selection");if(!g){return}g.each(function(h){f.updateImage(c.parents(".bs-image-wrap"),h)})});e.open()},updateImage:function(d,e){if("thumbnail" in e.attributes.sizes){var c=e.attributes.sizes.thumbnail.url}else{var c=e.attributes.url}d.find("input[type=hidden]").attr("value",e.id).removeAttr("disabled");d.find("img").attr("src",c);return d},deleteImage:function(c){c.closest(".bs-image-wrap").remove();if(!this.isMultiple){this.container.find(".bs-add-image").show()}},sortable:function(){if(!this.isMultiple){return}var c=this;this.container.find(".bs-images-wrap").sortable({handle:".bs-toolbar .dashicons-menu",placeholder:"bs-image-placeholder",cursor:"move",start:function(f,d){d.placeholder.height(c.container.find(".bs-image-wrap").outerHeight()-6);d.placeholder.width(c.container.find(" .bs-image-wrap").outerWidth()-6)}})},init:function(){this.sortable();this.listen()},listen:function(){var c=this;this.container.on("click",".bs-add-image",function(){c.addImage(b(this))});this.container.on("click",".dashicons-post-trash",function(d){d.preventDefault();c.deleteImage(b(this))});this.container.on("click",".dashicons-edit",function(d){d.preventDefault();c.editImage(b(this))})}};b.fn.beansFieldImage=function(c){return this.each(function(){if(!b.data(this,"plugin_beansFieldImages")){b.data(this,"plugin_beansFieldImage",new a(this,c))}})};b(document).ready(function(c){c(".bs-field.bs-image").beansFieldImage()})})(jQuery); \ No newline at end of file +!function(e){"use strict";var t=function(t,i){this.container=e(t),this.isMultiple=this.container.find(".bs-images-wrap").data("multiple"),this.init()};t.prototype={constructor:t,addImage:function(e){var t,i=this,a=e.parents(".bs-field-wrap");(t=wp.media({multiple:i.isMultiple})).on("select",function(){var n=t.state().get("selection");n&&n.each(function(t){var n=a.find(".bs-image-wrap.bs-image-template").clone().removeClass("bs-image-template"),s=i.updateImage(n,t);a.find(".bs-images-wrap").append(s),i.isMultiple||e.hide()})}),t.open()},editImage:function(e){var t,i=this;e.parents(".bs-field-wrap");(t=wp.media({multiple:!1})).on("open",function(){var i=t.state().get("selection"),a=e.parents(".bs-image-wrap").find("input[type=hidden]").val(),n=wp.media.model.Attachment.get(a);n.fetch(),i.add(n?[n]:[])}),t.on("select",function(){var a=t.state().get("selection");a&&a.each(function(t){i.updateImage(e.parents(".bs-image-wrap"),t)})}),t.open()},updateImage:function(e,t){if("thumbnail"in t.attributes.sizes)var i=t.attributes.sizes.thumbnail.url;else i=t.attributes.url;return e.find("input[type=hidden]").attr("value",t.id).removeAttr("disabled"),e.find("img").attr("src",i),e},deleteImage:function(e){e.closest(".bs-image-wrap").remove(),this.isMultiple||this.container.find(".bs-add-image").show()},sortable:function(){if(this.isMultiple){var e=this;this.container.find(".bs-images-wrap").sortable({handle:".bs-toolbar .bs-button-menu",placeholder:"bs-image-placeholder",cursor:"move",start:function(t,i){i.placeholder.height(e.container.find(".bs-image-wrap").outerHeight()-6),i.placeholder.width(e.container.find(" .bs-image-wrap").outerWidth()-6)}})}},init:function(){this.sortable(),this.listen()},listen:function(){var t=this;this.container.on("click",".bs-add-image",function(){t.addImage(e(this))}),this.container.on("click",".bs-button-trash",function(i){i.preventDefault(),t.deleteImage(e(this))}),this.container.on("click",".bs-button-edit",function(i){i.preventDefault(),t.editImage(e(this))})}},e.fn.beansFieldImage=function(i){return this.each(function(){e.data(this,"plugin_beansFieldImages")||e.data(this,"plugin_beansFieldImage",new t(this,i))})},e(document).ready(function(e){e(".bs-field.bs-image").beansFieldImage()})}(jQuery); \ No newline at end of file diff --git a/lib/api/fields/class-beans-fields.php b/lib/api/fields/class-beans-fields.php new file mode 100644 index 00000000..cedb6e17 --- /dev/null +++ b/lib/api/fields/class-beans-fields.php @@ -0,0 +1,337 @@ + array(), + 'post_meta' => array(), + 'term_meta' => array(), + 'wp_customize' => array(), + ); + + /** + * Register the given fields. + * + * @since 1.0.0 + * + * @param array $fields Array of fields to register. + * @param string $context The context in which the fields are used. 'option' for options/settings pages, + * 'post_meta' for post fields, 'term_meta' for taxonomies fields and 'wp_customize' for + * WP customizer fields. + * @param string $section A section ID to define the group of fields. + * + * @return bool + */ + public function register( array $fields, $context, $section ) { + $this->fields = $fields; + $this->context = $context; + $this->section = $section; + + $this->add(); + $this->do_once(); + $this->load_fields(); + + add_action( 'admin_enqueue_scripts', array( $this, 'load_fields_assets_hook' ) ); + add_action( 'customize_controls_enqueue_scripts', array( $this, 'load_fields_assets_hook' ) ); + + return true; + } + + /** + * Register the field. + * + * @since 1.0.0 + * + * @return void + */ + private function add() { + $fields = array(); + + foreach ( $this->fields as $field ) { + $fields[] = $this->standardize_field( $field ); + $this->set_type( $field ); + } + + // Register fields. + self::$registered[ $this->context ][ $this->section ] = $fields; + } + + /** + * Standardize the field to include the default configuration parameters and fetching the current value. + * + * @since 1.0.0 + * + * @param array $field The given field to be standardized. + * + * @return array + */ + private function standardize_field( array $field ) { + $field = array_merge( array( + 'label' => false, + 'description' => false, + 'default' => false, + 'context' => $this->context, + 'attributes' => array(), + 'db_group' => false, + ), $field ); + + // Set the field's name. + $field['name'] = 'wp_customize' === $this->context ? $field['id'] : 'beans_fields[' . $field['id'] . ']'; + + if ( 'group' === $field['type'] ) { + + foreach ( $field['fields'] as $index => $_field ) { + + if ( $field['db_group'] ) { + $_field['name'] = $field['name'] . '[' . $_field['id'] . ']'; + } + + $field['fields'][ $index ] = $this->standardize_field( $_field ); + } + } else { + // Add value after standardizing the field. + $field['value'] = $this->get_field_value( $field['id'], $field['context'], $field['default'] ); + } + + // Add required attributes for wp_customizer. + if ( 'wp_customize' === $this->context ) { + $field['attributes'] = array_merge( + $field['attributes'], + array( 'data-customize-setting-link' => $field['name'] ) + ); + } + + return $field; + } + + /** + * Set the type for the given field. + * + * @since 1.5.0 + * + * @param array $field The given field. + * + * @return void + */ + private function set_type( array $field ) { + + // Set the single field's type. + if ( 'group' !== $field['type'] ) { + $this->field_types[ $field['type'] ] = $field['type']; + return; + } + + foreach ( $field['fields'] as $_field ) { + $this->field_types[ $_field['type'] ] = $_field['type']; + } + } + + /** + * Trigger actions only once. + * + * @since 1.0.0 + * + * @return void + */ + private function do_once() { + static $once = false; + + if ( $once ) { + return; + } + + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_global_assets' ) ); + add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_global_assets' ) ); + + // Load the field label and description handler. + require_once BEANS_API_PATH . 'fields/types/field.php'; + + $once = true; + } + + /** + * Load the field type PHP file for each of the fields. + * + * @since 1.0.0 + * + * @return void + */ + private function load_fields() { + + foreach ( $this->field_types as $type ) { + + // Stop here if the field type has already been loaded. + if ( in_array( $type, self::$field_types_loaded, true ) ) { + continue; + } + + $path = BEANS_API_PATH . "fields/types/{$type}.php"; + + if ( file_exists( $path ) ) { + require_once $path; + } + + // Set a flag that the field is loaded. + self::$field_types_loaded[ $type ] = $type; + } + } + + /** + * Load the field's assets hook. This hook can then be used to load custom assets for the field. + * + * @since 1.0.0 + * + * @return void + */ + public function load_fields_assets_hook() { + + foreach ( $this->field_types as $type ) { + + // Stop here if the field type has already been loaded. + if ( in_array( $type, self::$field_assets_hook_loaded, true ) ) { + continue; + } + + do_action( "beans_field_enqueue_scripts_{$type}" ); + + // Set a flag that the field is loaded. + self::$field_assets_hook_loaded[ $type ] = $type; + } + } + + /** + * Enqueue the default assets for the fields. + * + * @since 1.0.0 + * + * @return void + */ + public function enqueue_global_assets() { + $css = BEANS_API_URL . 'fields/assets/css/fields' . BEANS_MIN_CSS . '.css'; + $js = BEANS_API_URL . 'fields/assets/js/fields' . BEANS_MIN_CSS . '.js'; + + wp_enqueue_style( 'beans-fields', $css, false, BEANS_VERSION ); + wp_enqueue_script( 'beans-fields', $js, array( 'jquery' ), BEANS_VERSION ); + + do_action( 'beans_field_enqueue_scripts' ); + } + + /** + * Get the field value. + * + * @since 1.0.0 + * @since 1.5.0 Return the default when the context is not pre-defined. + * + * @param string $field_id Field's ID. + * @param string $context The field's context, i.e. "option", "post_meta", "term_meta", or "wp_customize". + * @param mixed $default The field's default value. + * + * @return mixed|string|void + */ + private function get_field_value( $field_id, $context, $default ) { + + switch ( $context ) { + + case 'option': + return get_option( $field_id, $default ); + + case 'post_meta': + return beans_get_post_meta( $field_id, $default ); + + case 'term_meta': + return beans_get_term_meta( $field_id, $default ); + + case 'wp_customize': + return get_theme_mod( $field_id, $default ); + } + + return $default; + } + + /** + * Get the registered fields. + * + * @since 1.0.0 + * @since 1.5.0 Changed to static method. + * + * @param string $context The context in which the fields are used. 'option' for options/settings pages, + * 'post_meta' for post fields, 'term_meta' for taxonomies fields and 'wp_customize' for WP + * customizer fields. + * @param string $section Optional. A section ID to define a group of fields. This is mostly used for meta boxes + * and WP Customizer sections. + * + * @return array|bool Array of registered fields on success, false on failure. + */ + public static function get_fields( $context, $section ) { + $fields = beans_get( $section, self::$registered[ $context ] ); + + if ( ! $fields ) { + return false; + } + + return $fields; + } +} diff --git a/lib/api/fields/class.php b/lib/api/fields/class.php deleted file mode 100644 index 9645ad27..00000000 --- a/lib/api/fields/class.php +++ /dev/null @@ -1,327 +0,0 @@ - array(), - 'post_meta' => array(), - 'term_meta' => array(), - 'wp_customize' => array(), - ); - - /** - * Register fields. - */ - public function register( $fields, $context, $section ) { - - $this->fields = $fields; - $this->context = $context; - $this->section = $section; - - $this->add(); - $this->set_types(); - $this->do_once(); - $this->load_fields(); - - add_action( 'admin_enqueue_scripts', array( $this, 'load_fields_assets_hook' ) ); - add_action( 'customize_controls_enqueue_scripts', array( $this, 'load_fields_assets_hook' ) ); - - } - - /** - * Register field. - */ - private function add() { - - $fields = array(); - - foreach ( $this->fields as $field ) { - $fields[] = $this->standardize_field( $field ); - } - - // Register fields. - self::$registered[ $this->context ][ $this->section ] = $fields; - - } - - /** - * Standadrize field to beans format. - */ - private function standardize_field( $field ) { - - // Set defaults. - $defaults = array( - 'label' => false, - 'description' => false, - 'default' => false, - 'context' => $this->context, - 'attributes' => array(), - 'db_group' => false, - ); - - $field = array_merge( $defaults, $field ); - - // Set field name. - $field['name'] = 'wp_customize' == $this->context ? $field['id'] : 'beans_fields[' . $field['id'] . ']'; - - if ( 'group' === $field['type'] ) { - - foreach ( $field['fields'] as $index => $_field ) { - - if ( $field['db_group'] ) { - $_field['name'] = $field['name'] . '[' . $_field['id'] . ']'; - } - - $field['fields'][ $index ] = $this->standardize_field( $_field ); - - } - } else { - - // Add value after the standardizing the field. - $field['value'] = $this->get_field_value( $field['id'], $field['context'], $field['default'] ); - - } - - // Add required attributes for wp_customizer. - if ( 'wp_customize' == $this->context ) { - $field['attributes'] = array_merge( - $field['attributes'], - array( 'data-customize-setting-link' => $field['name'] ) - ); - } - - return $field; - - } - - /** - * Set the fields types used. - */ - private function set_types() { - - foreach ( $this->fields as $field ) { - - if ( 'group' == $field['type'] ) { - foreach ( $field['fields'] as $_field ) { - $this->field_types[ $_field['type'] ] = $_field['type']; - } - } else { - $this->field_types[ $field['type'] ] = $field['type']; - } - } - - } - - /** - * Trigger actions only once. - */ - private function do_once() { - - static $once = false; - - if ( ! $once ) { - - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_global_assets' ) ); - add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_global_assets' ) ); - - require_once( BEANS_API_PATH . 'fields/types/field.php' ); - - $once = true; - - } - - } - - /** - * Load the required core fields php files. - */ - private function load_fields() { - - foreach ( $this->field_types as $type ) { - - // Stop here if the field type has already been loaded. - if ( in_array( $type, self::$field_types_loaded ) ) { - continue; - } - - $path = BEANS_API_PATH . "fields/types/{$type}.php"; - - if ( file_exists( $path ) ) { - require_once( $path ); - } - - // Set flag that field is loaded. - self::$field_types_loaded[ $type ] = $type; - - } - - } - - /** - * Load the fields assets hooks. This hook can then be used to load custom fields assets. - */ - public function load_fields_assets_hook() { - - foreach ( $this->field_types as $type ) { - - // Stop here if the field type has already been loaded. - if ( in_array( $type, self::$field_assets_hook_loaded ) ) { - continue; - } - - do_action( "beans_field_enqueue_scripts_{$type}" ); - - // Set flag that field is loaded. - self::$field_assets_hook_loaded[ $type ] = $type; - - } - - } - - /** - * Enqueue default fields assets. - */ - public function enqueue_global_assets() { - - $css = BEANS_API_URL . 'fields/assets/css/fields' . BEANS_MIN_CSS . '.css'; - $js = BEANS_API_URL . 'fields/assets/js/fields' . BEANS_MIN_CSS . '.js'; - - wp_enqueue_style( 'beans-fields', $css, false, BEANS_VERSION ); - wp_enqueue_script( 'beans-fields', $js, array( 'jquery' ), BEANS_VERSION ); - - do_action( 'beans_field_enqueue_scripts' ); - - } - - /** - * Get the field value. - */ - private function get_field_value( $field_id, $context, $default ) { - - switch ( $context ) { - - case 'option': - return get_option( $field_id, $default ); - break; - - case 'post_meta': - return beans_get_post_meta( $field_id, $default ); - break; - - case 'term_meta': - return beans_get_term_meta( $field_id, $default ); - break; - - case 'wp_customize': - return get_theme_mod( $field_id, $default ); - break; - - } - - } - - /** - * Display the field content. - */ - public function field_content( $field ) { - - beans_open_markup_e( 'beans_field_wrap', 'div', array( - 'class' => 'bs-field-wrap bs-' . $field['type'] . ' ' . $field['context'], - ), $field ); - - // Set fields loop to cater for groups. - if ( 'group' === $field['type'] ) { - $fields = $field['fields']; - } else { - $fields = array( $field ); - } - - beans_open_markup_e( 'beans_field_inside', 'div', array( - 'class' => 'bs-field-inside', - ), $fields ); - - // Loop through fields. - foreach ( $fields as $single_field ) { - - beans_open_markup_e( 'beans_field[_' . $single_field['id'] . ']', 'div', array( - 'class' => 'bs-field bs-' . $single_field['type'], - ), $single_field ); - - do_action( 'beans_field_' . $single_field['type'], $single_field ); - - beans_close_markup_e( 'beans_field[_' . $single_field['id'] . ']', 'div', $single_field ); - - } - - beans_close_markup_e( 'beans_field_inside', 'div', $fields ); - - beans_close_markup_e( 'beans_field_wrap', 'div', $field ); - - } - - /** - * Get the registered fields. - */ - public function get_fields( $context, $section ) { - - if ( ! $fields = beans_get( $section, self::$registered[ $context ] ) ) { - return false; - } - - return $fields; - - } -} diff --git a/lib/api/fields/functions.php b/lib/api/fields/functions.php index 46c44335..1e23e5d3 100644 --- a/lib/api/fields/functions.php +++ b/lib/api/fields/functions.php @@ -2,42 +2,40 @@ /** * The Beans Fields component offers a range of fields which can be used in the WordPress admin. * - * Fields can be used as Options, Post Meta, Term Meta or WP - * Customizer Options. Custom fields can easily be added too. + * Fields can be used as Options, Post Meta, Term Meta or WP Customizer Options. Custom fields can easily be added, too. * - * @package API\Fields + * @package Beans\Framework\API\Fields */ /** - * Register fields. + * Register the given fields. * * This function should only be invoked through the 'admin_init' action. * * @since 1.0.0 * - * @param array $fields { + * @param array $fields { * Array of fields to register. * - * @type string $id A unique id used for the field. This id will also be used to save the value in - * the database. - * @type string $type The type of field to use. Please refer to the Beans core field types for more - * information. Custom field types are accepted here. - * @type string $label The field label. Default false. - * @type string $description The field description. The description can be truncated using - * as a delimiter. Default false. - * @type array $attributes An array of attributes to add to the field. The array key defines the - * attribute name and the array value defines the attribute value. Default array. - * @type mixed $default The default field value. Default false. - * @type array $fields Must only be used for 'group' field type. The array arguments are similar to the - * {@see beans_register_fields()} $fields arguments. - * @type bool $db_group Must only be used for 'group' field type. It defines whether the group of fields - * registered should be saved as a group in the database or as individual - * entries. Default false. + * @type string $id A unique id used for the field. This id will also be used to save the value in the + * database. + * @type string $type The type of field to use. Please refer to the Beans core field types for more + * information. Custom field types are accepted here. + * @type string $label The field label. Default false. + * @type string $description The field description. The description can be truncated using as a + * delimiter. Default false. + * @type array $attributes An array of attributes to add to the field. The array key defines the attribute name + * and the array value defines the attribute value. Default array. + * @type mixed $default The default field value. Default false. + * @type array $fields Must only be used for the 'group' field type. The array arguments are similar to the + * {@see beans_register_fields()} $fields arguments. + * @type bool $db_group Must only be used for the 'group' field type. It defines whether the group of fields + * should be saved as a group or as individual entries in the database. Default false. * } - * @param string $context The context in which the fields are used. 'option' for options/settings pages, 'post_meta' - * for post fields, 'term_meta' for taxonomies fields and 'wp_customize' for WP customizer - * fields. - * @param string $section A section id to define the group of fields. + * @param string $context The context in which the fields are used. 'option' for options/settings pages, + * 'post_meta' for post fields, 'term_meta' for taxonomies fields and 'wp_customize' for WP + * customizer fields. + * @param string $section A section ID to define the group of fields. * * @return bool True on success, false on failure. */ @@ -48,30 +46,27 @@ function beans_register_fields( array $fields, $context, $section ) { } // Load the class only if this function is called to prevent unnecessary memory usage. - require_once( BEANS_API_PATH . 'fields/class.php' ); + require_once BEANS_API_PATH . 'fields/class-beans-fields.php'; $class = new _Beans_Fields(); - $class->register( $fields, $context, $section ); - - return true; - + return $class->register( $fields, $context, $section ); } /** - * Get registered fields. + * Get the registered fields. * * This function is used to get the previously registered fields in order to display them using * {@see beans_field()}. * * @since 1.0.0 * - * @param string $context The context in which the fields are used. 'option' for options/settings pages, 'post_meta' - * for post fields, 'term_meta' for taxonomies fields and 'wp_customize' for WP customizer - * fields. - * @param string $section Optional. A section id to define a group of fields. This is mostly used for metaboxes - * and WP Customizer sections. + * @param string $context The context in which the fields are used. 'option' for options/settings pages, + * 'post_meta' for post fields, 'term_meta' for taxonomies fields and 'wp_customize' for WP + * customizer fields. + * @param string|bool $section Optional. A section ID to define a group of fields. This is mostly used for metaboxes + * and WP Customizer sections. * - * @return array|bool Array of register fields on success, false on failure. + * @return array|bool Array of registered fields on success, false on failure. */ function beans_get_fields( $context, $section = false ) { @@ -79,43 +74,107 @@ function beans_get_fields( $context, $section = false ) { return; } - $class = new _Beans_Fields(); - return $class->get_fields( $context, $section ); - + return _Beans_Fields::get_fields( $context, $section ); } /** - * Echo a field. + * Render (echo) a field. * * This function echos the field content. Must be used in the loop of fields obtained using * {@see beans_get_fields()}. * * @since 1.0.0 + * @since 1.5.0 Moved rendering code out of _Beans_Fields. + * + * @param array $field The given field to render, obtained using {@see beans_get_fields()}. * - * @param array $field Array of data obtained using {@see beans_get_fields()}. + * @return void */ -function beans_field( $field ) { +function beans_field( array $field ) { if ( ! class_exists( '_Beans_Fields' ) ) { return; } - $class = new _Beans_Fields(); - $class->field_content( $field ); + $group_field_type = 'group' === $field['type']; + + beans_open_markup_e( 'beans_field_wrap', 'div', array( + 'class' => 'bs-field-wrap bs-' . $field['type'] . ' ' . $field['context'], + ), $field ); + + // Set fields loop to cater for groups. + if ( $group_field_type ) { + $fields = $field['fields']; + } else { + $fields = array( $field ); + } + + beans_open_markup_e( 'beans_field_inside', 'div', array( + 'class' => 'bs-field-inside', + ), $fields ); + + if ( $group_field_type ) { + beans_open_markup_e( 'beans_field_group_fieldset', 'fieldset', array( + 'class' => 'bs-field-fieldset', + ), $field ); + beans_open_markup_e( 'beans_field_group_legend', 'legend', array( + 'class' => 'bs-field-legend', + ), $field ); + echo esc_html( $field['label'] ); + beans_close_markup_e( 'beans_field_group_legend', 'legend', $field ); + } + // Loop through fields. + foreach ( $fields as $single_field ) { + beans_open_markup_e( 'beans_field[_' . $single_field['id'] . ']', 'div', array( + 'class' => 'bs-field bs-' . $single_field['type'], + ), $single_field ); + + if ( $group_field_type ) { + /** + * Fires the "beans_field_group_label" event to render this field's label. + * + * @since 1.5.0 + * + * @param array $single_field The given single field. + */ + do_action( 'beans_field_group_label', $single_field ); + } + + /** + * Fires the "beans_field_{type}" event to render this single field. + * + * @since 1.5.0 + * + * @param array $single_field The given single field. + */ + do_action( 'beans_field_' . $single_field['type'], $single_field ); + + beans_close_markup_e( 'beans_field[_' . $single_field['id'] . ']', 'div', $single_field ); + } + + if ( $group_field_type ) { + beans_close_markup_e( 'beans_field_group_fieldset', 'fieldset', $field ); + } + beans_close_markup_e( 'beans_field_inside', 'div', $fields ); + beans_close_markup_e( 'beans_field_wrap', 'div', $field ); } /** - * Standardize fields. + * Pre-standardize the fields by keying each field by its ID. * + * @since 1.0.0 * @ignore + * @access private + * + * @param array $fields An array of fields to be standardized. + * + * @return array */ -function _beans_pre_standardize_fields( $fields ) { - +function _beans_pre_standardize_fields( array $fields ) { $_fields = array(); foreach ( $fields as $field ) { - $_fields[ $field['id'] ] = $field; if ( 'group' === beans_get( 'type', $field ) ) { @@ -124,5 +183,4 @@ function _beans_pre_standardize_fields( $fields ) { } return $_fields; - } diff --git a/lib/api/fields/types/activation.php b/lib/api/fields/types/activation.php index a3ce930f..4993bb0b 100644 --- a/lib/api/fields/types/activation.php +++ b/lib/api/fields/types/activation.php @@ -1,31 +1,26 @@ - * as a delimiter. Default false. - * @type mixed $value The field value. - * @type string $name The field name value. - * @type array $attributes An array of attributes to add to the field. The array key defines the - * attribute name and the array value defines the attribute value. Default array. - * @type mixed $default The default value. Default false. - * } + * @type mixed $value The field's current value. + * @type string $name The field's "name" value. + * @type array $attributes An array of attributes to add to the field. The array's key defines the attribute name + * and the array's value defines the attribute value. Default is an empty array. + * @type int $default The default value. */ -function beans_field_activation( $field ) { - - ?> - - /> - - - /> - - - $field['id'] ); + beans_open_markup_e( $id, $tag, $args ); + echo esc_html( $field['label'] ); + beans_close_markup_e( $id, $tag ); } beans_add_smart_action( 'beans_field_wrap_append_markup', 'beans_field_description' ); /** - * Echo field description. + * Render the field's description. * * @since 1.0.0 + * @since 1.5.0 Moved the HTML to a view file. * - * @param array $field { - * Array of data. + * @param array $field { + * Array of data. * - * @type string $description The field description. The description can be truncated using - * as a delimiter. Default false. + * @type string $description The field description. The description can be truncated using as a delimiter. + * Default false. * } */ -function beans_field_description( $field ) { +function beans_field_description( array $field ) { + $description = beans_get( 'description', $field ); - if ( ! $description = beans_get( 'description', $field ) ) { + if ( ! $description ) { return; } + // Escape the description here. + $description = wp_kses_post( $description ); - beans_open_markup_e( 'beans_field_description[_' . $field['id'] . ']', 'div', array( 'class' => 'bs-field-description' ) ); - - if ( preg_match( '##', $description, $matches ) ) { - list( $description, $extended ) = explode( $matches[0], $description, 2 ); - } - - echo $description; + // If the description has , split it. + if ( preg_match( '##', $description, $matches ) ) { + list( $description, $extended ) = explode( $matches[0], $description, 2 ); + } - if ( isset( $extended ) ) { + beans_open_markup_e( 'beans_field_description[_' . $field['id'] . ']', 'div', array( 'class' => 'bs-field-description' ) ); - ?> -
-
- - > - -
- 'image-id', + 'type' => 'hidden', + 'name' => $is_multiple ? $field['name'] . '[]' : $field['name'], // Return single value if not multiple. + 'value' => $id, + ), $field['attributes'] ); + + if ( 'placeholder' === $id ) { + $attributes = array_merge( + $attributes, + array( + 'disabled' => 'disabled', + 'value' => false, + ) + ); + } + + return $attributes; +} - $class = ''; - $img = wp_get_attachment_image_src( $id, 'thumbnail' ); +/** + * Get the image's URL. + * + * @since 1.5.0 + * + * @param mixed $image_id The image's attachment ID. + * + * @return string|void + */ +function _beans_get_image_url( $image_id ) { + $image_id = (int) $image_id; - $attributes = array_merge( array( - 'class' => 'image-id', - 'type' => 'hidden', - 'name' => $multiple ? $field['name'] . '[]' : $field['name'], // Return single value if not multiple. - 'value' => $id, - ), $field['attributes'] ); + // If this is not a valid image ID, bail out. + if ( $image_id < 1 ) { + return; + } - // Set placeholder. - if ( 'placeholder' == $id ) { + return beans_get( 0, wp_get_attachment_image_src( $image_id, 'thumbnail' ) ); +} - $class = 'bs-image-template'; - $attributes = array_merge( $attributes, array( 'disabled' => 'disabled', 'value' => false ) ); +/** + * Get the image's alt description. + * + * @since 1.5.0 + * + * @param mixed $image_id The image's attachment ID. + * + * @return string|void + */ +function _beans_get_image_alt( $image_id ) { + $image_id = (int) $image_id; - } + // If this is not a valid image ID, bail out. + if ( $image_id < 1 ) { + return; + } - ?> -
- /> - -
- - - - - -
-
+ $image_alt = get_post_meta( $image_id, '_wp_attachment_image_alt', true ); - -
- $radio, + 'alt' => "Option for {$value}", + 'screen_reader_text' => "Option for {$value}", + ); + } - ?> -
- $radio ) : + $radio = array_merge( array( + 'src' => '', + 'alt' => '', + 'screen_reader_text' => '', + ), $radio ); - $extensions = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico' ); - $has_image = in_array( beans_get( 'extension', pathinfo( $radio ) ), $extensions ) ? 'bs-has-image' : false; + if ( $radio['screen_reader_text'] && $radio['alt'] ) { + return $radio; + } - ?> - + // Use the "alt" attribute when the "screen_reader_text" is not set. + if ( ! $radio['screen_reader_text'] && $radio['alt'] ) { + $radio['screen_reader_text'] = $radio['alt']; + return $radio; + } - -
- - - 0, 'max' => 100, @@ -44,19 +44,7 @@ function beans_field_slider( $field ) { 'unit' => null, ); - $field = array_merge( $defaults, $field ); - - ?> -
- - - style="display: none;"/> - -
- - - - - - > - ', + esc_attr( $field['id'] ), + esc_attr( $field['name'] ), + esc_attr( $field['value'] ), + beans_esc_attributes( $field['attributes'] ) // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Escaping is handled in the function. + ); } diff --git a/lib/api/fields/types/textarea.php b/lib/api/fields/types/textarea.php index d7d4baad..b64966e5 100644 --- a/lib/api/fields/types/textarea.php +++ b/lib/api/fields/types/textarea.php @@ -1,28 +1,31 @@ - - %s', + esc_attr( $field['id'] ), + esc_attr( $field['name'] ), + beans_esc_attributes( $field['attributes'] ), // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Escaping is handled in the function. + esc_textarea( $field['value'] ) + ); } diff --git a/lib/api/fields/types/views/activation.php b/lib/api/fields/types/views/activation.php new file mode 100644 index 00000000..740a6833 --- /dev/null +++ b/lib/api/fields/types/views/activation.php @@ -0,0 +1,15 @@ + + + + /> + diff --git a/lib/api/fields/types/views/checkbox.php b/lib/api/fields/types/views/checkbox.php new file mode 100644 index 00000000..86a218d0 --- /dev/null +++ b/lib/api/fields/types/views/checkbox.php @@ -0,0 +1,20 @@ + + + + /> + + + + + +
+ diff --git a/lib/api/fields/types/views/image.php b/lib/api/fields/types/views/image.php new file mode 100644 index 00000000..af66576e --- /dev/null +++ b/lib/api/fields/types/views/image.php @@ -0,0 +1,55 @@ + + + + +
+ +
+ /> + <?php echo $image_alt ? esc_attr( $image_alt ) : ''; ?> +
+ + + + + + +
+
+ +
diff --git a/lib/api/fields/types/views/radio.php b/lib/api/fields/types/views/radio.php new file mode 100644 index 00000000..e60ee754 --- /dev/null +++ b/lib/api/fields/types/views/radio.php @@ -0,0 +1,47 @@ + + +
+ + $radio ) : + $is_image = _beans_is_radio_image( $radio ); + + // Clean the value here to avoid calling esc_attr() again and again for the same value. + $clean_value = esc_attr( $value ); + $clean_id = $id_prefix . $clean_value; +?> + + +
diff --git a/lib/api/fields/types/views/select.php b/lib/api/fields/types/views/select.php new file mode 100644 index 00000000..b9823296 --- /dev/null +++ b/lib/api/fields/types/views/select.php @@ -0,0 +1,19 @@ + + + diff --git a/lib/api/fields/types/views/slider.php b/lib/api/fields/types/views/slider.php new file mode 100644 index 00000000..7d221c3e --- /dev/null +++ b/lib/api/fields/types/views/slider.php @@ -0,0 +1,22 @@ + + +
+ /> +
+ + + + +value_to_return = $value_to_return; + + add_filter( $hook, array( $this, 'callback' ), $priority, $args ); + } + + /** + * Get filter content and set it as the callback. + * + * @since 1.0.0 + * + * @return array + */ + public function callback() { + return $this->value_to_return; + } +} diff --git a/lib/api/filters/class.php b/lib/api/filters/class.php deleted file mode 100644 index 44bf626e..00000000 --- a/lib/api/filters/class.php +++ /dev/null @@ -1,48 +0,0 @@ -callback = $callback; - - add_filter( $id, array( $this, 'callback' ), $priority, $args ); - - } - - /** - * Get filter content and set it as the callback. - */ - public function callback() { - - return $this->callback; - - } -} diff --git a/lib/api/filters/functions.php b/lib/api/filters/functions.php index 15b79649..c5ae6278 100644 --- a/lib/api/filters/functions.php +++ b/lib/api/filters/functions.php @@ -1,50 +1,52 @@ $id. + * * @since 1.0.0 * * @param string $id A unique string used as a reference. Sub-hook(s) must be set in square brackets. Each sub- @@ -56,136 +58,147 @@ function beans_add_filter( $id, $callback, $priority = 10, $args = 1 ) { * always run the parent filter first, so a filter set to the parent will apply * to all sub-hooks. Maximum 3 sub-hooks allowed. * @param mixed $value The value on which the filters hooked to $id are applied to it. - * @param mixed $var Additional variables passed to the functions hooked to $id. * * @return mixed The filtered value after all hooked functions are applied to it. */ function beans_apply_filters( $id, $value ) { - $args = func_get_args(); - // Return simple filter if no sub-hook is set. - if ( ! preg_match_all( '#\[(.*?)\]#', $args[0], $matches ) ) { + // Return simple filter if no sub-hook(s) is(are) set. + if ( ! preg_match_all( '#\[(.*?)\]#', $args[0], $sub_hooks ) ) { return call_user_func_array( 'apply_filters', $args ); } - $prefix = current( explode( '[', $args[0] ) ); + $prefix = current( explode( '[', $args[0] ) ); $variable_prefix = $prefix; - $suffix = preg_replace( '/^.*\]\s*/', '', $args[0] ); + $suffix = preg_replace( '/^.*\]\s*/', '', $args[0] ); // Base filter. $args[0] = $prefix . $suffix; - $value = call_user_func_array( 'apply_filters', $args ); - - foreach ( $matches[0] as $i => $subhook ) { + $value = call_user_func_array( 'apply_filters', $args ); - $variable_prefix = $variable_prefix . $subhook; - $levels = array( $prefix . $subhook . $suffix ); + foreach ( (array) $sub_hooks[0] as $index => $sub_hook ) { - // Cascade sub-hooks. - if ( $i > 0 ) { + // If there are more than 3 sub-hooks, stop processing. + if ( $index > 2 ) { + break; + } - if ( count( $matches[0] ) > 2 ) { - $levels[] = str_replace( $subhook, '', $id ); - } + $variable_prefix .= $sub_hook; + $levels = array( $prefix . $sub_hook . $suffix ); + // Cascade sub-hooks. + if ( $index > 0 ) { $levels[] = $variable_prefix . $suffix; - } // Apply sub-hooks. foreach ( $levels as $level ) { - $args[0] = $level; $args[1] = $value; - $value = call_user_func_array( 'apply_filters', $args ); + $value = call_user_func_array( 'apply_filters', $args ); - // Apply filter whithout square brackets for backwards compatibility. + // Apply filter without square brackets for backwards compatibility. $args[0] = preg_replace( '#(\[|\])#', '', $args[0] ); $args[1] = $value; - $value = call_user_func_array( 'apply_filters', $args ); - + $value = call_user_func_array( 'apply_filters', $args ); } } return $value; - } /** * Check if any filter has been registered for a hook. * - * This function is similar to {@link http://codex.wordpress.org/Function_Reference/has_filters has_filters()} + * This function is similar to {@link https://codex.wordpress.org/Function_Reference/has_filters has_filters()} * with the exception of checking sub-hooks if it is told to do so. * * @since 1.0.0 * - * @param string $id The filter ID. - * @param callback|bool $callback Optional. The callback to check for. Default false. + * @param string $id A unique string used as a reference. Sub-hook(s) must be set in square brackets. + * @param callable|bool $callback Optional. The callback to check for. Default false. * - * @return bool|int If $callback is omitted, returns boolean for whether the hook has - * anything registered. When checking a specific function, the priority of that - * hook is returned, or false if the function is not attached. When using the - * $callback argument, this function may return a non-boolean value - * that evaluates to false (e.g. 0), so use the === operator for testing the - * return value. + * @return bool|int If $callback is omitted, returns boolean for whether the hook has any callbacks registered. + * When checking a specific callback, returns the priority of that hook when a callback is registered; + * else, it returns false. When using the `$callback` argument, this function may return a non-boolean + * value that evaluates to false (e.g. 0). Make sure you use the === operator for testing the return + * value. */ function beans_has_filters( $id, $callback = false ) { - // Check simple filter if no subhook is set. - if ( ! preg_match_all( '#\[(.*?)\]#', $id, $matches ) ) { + // Check simple filter if no sub-hook is set. + if ( ! preg_match_all( '#\[(.*?)\]#', $id, $sub_hooks ) ) { return has_filter( $id, $callback ); } - $prefix = current( explode( '[', $id ) ); + $prefix = current( explode( '[', $id ) ); $variable_prefix = $prefix; - $suffix = preg_replace( '/^.*\]\s*/', '', $id ); + $suffix = preg_replace( '/^.*\]\s*/', '', $id ); // Check base filter. - if ( has_filter( $prefix . $suffix, $callback ) ) { - return true; + $priority_number = has_filter( $prefix . $suffix, $callback ); + + if ( false !== $priority_number ) { + return $priority_number; } - foreach ( $matches[0] as $i => $subhook ) { + foreach ( (array) $sub_hooks[0] as $index => $sub_hook ) { + + // If there are more than 3 sub-hooks, return false. + if ( $index > 2 ) { + return false; + } - $variable_prefix = $variable_prefix . $subhook; - $levels = array( $prefix . $subhook . $suffix ); + $variable_prefix .= $sub_hook; + $levels = array( $prefix . $sub_hook . $suffix ); // Cascade sub-hooks. - if ( $i > 0 ) { - - $levels[] = str_replace( $subhook, '', $id ); + if ( $index > 0 ) { $levels[] = $variable_prefix . $suffix; - } // Apply sub-hooks. foreach ( $levels as $level ) { + $priority_number = has_filter( $level, $callback ); - if ( has_filter( $level, $callback ) ) { - return true; + if ( false !== $priority_number ) { + return $priority_number; } - // Check filter whithout square brackets for backwards compatibility. - if ( has_filter( preg_replace( '#(\[|\])#', '', $level ), $callback ) ) { - return true; + // Check filter without square brackets for backwards compatibility. + $priority_number = has_filter( preg_replace( '#(\[|\])#', '', $level ), $callback ); + + if ( false !== $priority_number ) { + return $priority_number; } } } return false; - } /** * Add anonymous callback using a class since php 5.2 is still supported. * + * @since 1.0.0 + * @since 1.5.0 Returns the object. * @ignore + * @access private + * + * @param string $hook The name of the filter event to which the callback is hooked. + * @param mixed $value The value that will be returned when the anonymous callback runs. + * @param int $priority Optional. Used to specify the order in which the functions + * associated with a particular filter are executed. Default 10. + * Lower numbers correspond with earlier execution, + * and functions with the same priority are executed + * in the order in which they were added to the filter. + * @param int $args Optional. The number of arguments the function accepts. Default 1. + * + * @return _Beans_Anonymous_Filters */ -function _beans_add_anonymous_filter( $id, $callback, $priority = 10, $args = 1 ) { - - require_once( BEANS_API_PATH . 'filters/class.php' ); - - new _Beans_Anonymous_Filters( $id, $callback, $priority, $args ); +function _beans_add_anonymous_filter( $hook, $value, $priority = 10, $args = 1 ) { + require_once BEANS_API_PATH . 'filters/class-beans-anonymous-filters.php'; + return new _Beans_Anonymous_Filters( $hook, $value, $priority, $args ); } diff --git a/lib/api/html/accessibility.php b/lib/api/html/accessibility.php new file mode 100644 index 00000000..1cac514d --- /dev/null +++ b/lib/api/html/accessibility.php @@ -0,0 +1,100 @@ + 'beans-skip-links' ) ); + + foreach ( $skip_links as $link => $link_name ) { + beans_open_markup_e( 'beans_skip_links_item', 'li' ); + + beans_open_markup_e( + 'beans_skip_links_item_link', + 'a', + array( + 'href' => '#' . $link, + 'class' => 'screen-reader-shortcut', + ) + ); + + echo esc_html( $link_name ); + + beans_close_markup_e( 'beans_skip_links_item', 'a' ); + + beans_close_markup_e( 'beans_skip_links_item', 'li' ); + } + beans_close_markup_e( 'beans_skiplinks', 'ul' ); +} + + +beans_add_smart_action( 'beans_accessibility_enqueue_skip_link_fix', 'beans_accessibility_skip_link_fix' ); +/** + * Enqueue the JavaScript fix for Internet Explorer 11 + * + * @since 1.5.0 + * + * return void + */ +function beans_accessibility_skip_link_fix() { + $js = BEANS_API_URL . 'html/assets/js/skip-link-fix' . BEANS_MIN_JS . '.js'; + wp_enqueue_script( 'beans-skip-link-fix', $js, array(), BEANS_VERSION ); +} diff --git a/lib/api/html/assets/js/skip-link-fix.js b/lib/api/html/assets/js/skip-link-fix.js new file mode 100644 index 00000000..a40ebacf --- /dev/null +++ b/lib/api/html/assets/js/skip-link-fix.js @@ -0,0 +1,31 @@ +/** + * File skip-link-focus-fix.js. + * + * Helps with accessibility for keyboard only users. + * + * Learn more: https://git.io/vWdr2 + */ +(function() { + var isIe = /(trident|msie)/i.test( navigator.userAgent ); + + if ( isIe && document.getElementById && window.addEventListener ) { + window.addEventListener( 'hashchange', function() { + var id = location.hash.substring( 1 ), + element; + + if ( ! ( /^[A-z0-9_-]+$/.test( id ) ) ) { + return; + } + + element = document.getElementById( id ); + + if ( element ) { + if ( ! ( /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) ) { + element.tabIndex = -1; + } + + element.focus(); + } + }, false ); + } +})(); diff --git a/lib/api/html/class-beans-attribute.php b/lib/api/html/class-beans-attribute.php new file mode 100644 index 00000000..f62ceec9 --- /dev/null +++ b/lib/api/html/class-beans-attribute.php @@ -0,0 +1,184 @@ +id = $id; + $this->attribute = $attribute; + $this->value = $value; + $this->new_value = $new_value; + } + + /** + * Initialize by registering the attribute filter. + * + * @since 1.0.0 + * @since 1.5.0 Return self, for chaining and testing. + * + * @param array $method Method to register as the callback for this filter. + * + * @return void|self (for chaining) + */ + public function init( $method ) { + + if ( ! method_exists( $this, $method ) ) { + return; + } + + beans_add_filter( $this->id . '_attributes', array( $this, $method ) ); + + return $this; + } + + /** + * Add a value to an existing attribute or add a new attribute. + * + * @since 1.0.0 + * + * @param array $attributes Array of HTML markup attributes. + * + * @return array + */ + public function add( array $attributes ) { + + if ( $this->has_attribute( $attributes ) ) { + $attributes[ $this->attribute ] .= ' ' . $this->value; + } else { + $attributes[ $this->attribute ] = $this->value; + } + + return $attributes; + } + + /** + * Replace the attribute's value. If the attribute does not exist, it is added with the new value. + * + * @since 1.0.0 + * @since 1.5.0 Allows replacement of all values. + * + * @param array $attributes Array of HTML markup attributes. + * + * @return array + */ + public function replace( array $attributes ) { + + if ( $this->has_attribute( $attributes ) && ! empty( $this->value ) ) { + $attributes[ $this->attribute ] = $this->replace_value( $attributes[ $this->attribute ] ); + } else { + $attributes[ $this->attribute ] = $this->new_value; + } + + return $attributes; + } + + /** + * Remove a specific value from the attribute or remove the entire attribute. + * + * When the attribute value to remove is null, the attribute is removed; else, the value is removed. + * + * @since 1.0.0 + * + * @param array $attributes Array of HTML markup attributes. + * + * @return array + */ + public function remove( array $attributes ) { + + if ( empty( $attributes ) ) { + return $attributes; + } + + if ( ! $this->has_attribute( $attributes ) ) { + return $attributes; + } + + if ( is_null( $this->value ) ) { + unset( $attributes[ $this->attribute ] ); + } else { + $attributes[ $this->attribute ] = $this->replace_value( $attributes[ $this->attribute ] ); + } + + return $attributes; + } + + /** + * Checks if the attribute exists in the given attributes. + * + * @since 1.5.0 + * + * @param array $attributes Array of HTML markup attributes. + * + * @return bool + */ + private function has_attribute( array $attributes ) { + return isset( $attributes[ $this->attribute ] ); + } + + /** + * Replace the attribute's value. + * + * @since 1.5.0 + * + * @param string $value The current attribute's value. + * + * @return string + */ + private function replace_value( $value ) { + return str_replace( $this->value, $this->new_value, $value ); + } +} diff --git a/lib/api/html/class.php b/lib/api/html/class.php deleted file mode 100644 index 64fe5867..00000000 --- a/lib/api/html/class.php +++ /dev/null @@ -1,115 +0,0 @@ -id = $id; - $this->attribute = $attribute; - $this->value = $value; - $this->new_value = $new_value; - - } - - /** - * Initialize action. - */ - public function init( $action ) { - - beans_add_filter( $this->id . '_attributes', array( $this, $action ) ); - - } - - /** - * Add attribute. - */ - public function add( $attributes ) { - - if ( ! isset( $attributes[ $this->attribute ] ) ) { - $attributes[ $this->attribute ] = $this->value; - } else { - $attributes[ $this->attribute ] = $attributes[ $this->attribute ] . ' ' . $this->value; - } - - return $attributes; - - } - - /** - * Replace attribute. - */ - public function replace( $attributes ) { - - if ( $this->new_value ) { - - if ( isset( $attributes[ $this->attribute ] ) ) { - $attributes[ $this->attribute ] = str_replace( $this->value, $this->new_value, $attributes[ $this->attribute ] ); - } else { - $attributes[ $this->attribute ] = $this->new_value; - } - } else { - - $attributes[ $this->attribute ] = $this->value; - - } - - return $attributes; - - } - - /** - * Remove attribute. - */ - public function remove( $attributes ) { - - if ( ! isset( $attributes[ $this->attribute ] ) ) { - return $attributes; - } - - if ( is_null( $this->value ) ) { - unset( $attributes[ $this->attribute ] ); - } else { - $attributes[ $this->attribute ] = str_replace( $this->value, '', $attributes[ $this->attribute ] ); - } - - return $attributes; - - } -} diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index cc53e94f..50b3cd37 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -3,30 +3,33 @@ * The Beans HTML component contains a powerful set of functions to create flexible and easy overwritable HTML markup, * attributes and content. * - * @package API\HTML + * @package Beans\Framework\API\HTML + * + * @since 1.5.0 */ /** - * Register output by ID. + * Register the output for the given ID. This function enables the output to be: * - * The output can be modified using the available Beans HTML "output" functions. + * 1. modified by registering a callback to "{$id}_output" + * 2. removed by using {@see beans_remove_output()}. * - * HTML comments containing the ID are added before and after the output if the development mode is enabled. - * This makes it very easy to find a content ID when inspecting an element in your web browser. + * When in development mode, HTML comments containing the ID are added before and after the output, i.e. making it + * easier to identify the content ID when inspecting an element in your web browser. * - * Since this function uses {@see beans_apply_filters()}, the $id argument may contain sub-hook(s). + * Notes: + * 1. Since this function uses {@see beans_apply_filters()}, the $id argument may contain sub-hook(s). + * 2. You can pass additional arguments to the functions that are hooked to $id. * * @since 1.0.0 * * @param string $id A unique string used as a reference. The $id argument may contain sub-hook(s). - * @param string $output Content to output. - * @param mixed $var Additional variables passed to the functions hooked to $id. + * @param string $output The given content to output. * - * @return string The output. + * @return string|void */ function beans_output( $id, $output ) { - - $args = func_get_args(); + $args = func_get_args(); $args[0] = $id . '_output'; $output = call_user_func_array( 'beans_apply_filters', $args ); @@ -36,390 +39,339 @@ function beans_output( $id, $output ) { } if ( _beans_is_html_dev_mode() ) { + $id = esc_attr( $id ); $output = "" . $output . ""; } return $output; - } /** - * Echo output registered by ID. - * - * The output can be modified using the available Beans HTML "output" functions. - * - * HTML comments containing the ID are added before and after the output if the development mode is enabled. - * This makes it very easy to find a content ID when inspecting an element in your web browser. - * - * Since this function uses {@see beans_apply_filters()}, the $id argument may contain sub-hook(s). + * Register and then echo the output for the given ID. This function is a wrapper for {@see beans_output()}. See + * {@see beans_output()} for more details. * * @since 1.4.0 - * @uses beans_output() To register output by ID. + * @uses beans_output() To register output by ID. * * @param string $id A unique string used as a reference. The $id argument may contain sub-hook(s). - * @param string $output Content to output. - * @param mixed $var Additional variables passed to the functions hooked to $id. + * @param string $output The given content to output. */ function beans_output_e( $id, $output ) { - $args = func_get_args(); - - echo call_user_func_array( 'beans_output', $args ); - + echo call_user_func_array( 'beans_output', $args ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Escaped in beans_output. } /** - * Remove output. - * - * HTML comments containing the ID are added before and after the output if the development mode is enabled. - * This makes it very easy to find a content ID when inspecting an element in your web browser. + * Removes the HTML output for the given $id, meaning the output will not render. * * @since 1.0.0 * - * @param string $id The output ID. + * @param string $id The output's ID. * - * @return bool Will always return true. + * @return bool|_Beans_Anonymous_Filters */ function beans_remove_output( $id ) { - - return beans_add_filter( $id . '_output', false ); - + return beans_add_filter( $id . '_output', false, 99999999 ); } /** - * Register open markup and attributes by ID. + * Build the opening HTML element's markup. This function fires 3 separate hooks: * - * The Beans HTML "markups" and "attributes" functions make it really easy to modify, replace, extend, - * remove or hook into registered markup or attributes. + * 1. "{id}_before_markup" - which fires first before the element. + * 2. "{$id}_prepend_markup" - which fires after the element when the element is not self-closing. + * 3. "{$id}_after_markup" - which fires after the element when the element is self-closing. * - * The "data-markup-id" is added as a HTML attribute if the development mode is enabled. This makes it very - * easy to find the content ID when inspecting an element in a web browser. + * These 3 hooks along with the attributes make it really easy to modify, replace, extend, remove or hook the + * markup and/or attributes. * - * Since this function uses {@see beans_apply_filters()}, the $id argument may contain sub-hook(s). + * When in development mode, the "data-markup-id" attribute is added to the element, i.e. making it + * easier to identify the content ID when inspecting an element in your web browser. + * + * Notes: + * 1. Since this function uses {@see beans_apply_filters()}, the $id argument may contain sub-hook(s). + * 2. You can pass additional arguments to the functions that are hooked to $id. * * @since 1.0.0 * - * @param string $id A unique string used as a reference. The $id argument may contain sub-hooks(s). - * @param string|bool $tag The HTML tag. If set to False or empty, the markup HTML tag will be removed but - * the actions hook will be called. If set the Null, both markup HTML tag and actions - * hooks will be removed. + * @param string $id A unique string used as a reference. The $id argument may contain sub-hooks(s). + * @param string|bool $tag The HTML tag. When set to false or an empty string, the HTML markup tag will not be + * built, but both action hooks will fire. If set to null, the function bails out, i.e. + * the HTML markup tag will not be built and neither action hook fires. * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the - * attribute name and the array value defines the attribute value. Setting - * the array value to '' will display the attribute value as empty - * (e.g. class=""). Setting it to 'false' will only display - * the attribute name (e.g. data-example). Setting it to 'null' will not - * display anything. - * @param mixed $var Optional. Additional variables passed to the functions hooked to $id. + * attribute name and the array value defines the attribute value. * - * @return string The output. + * @return string|void */ function beans_open_markup( $id, $tag, $attributes = array() ) { - - global $_temp_beans_selfclose_markup; - - $args = func_get_args(); + $args = func_get_args(); $attributes_args = $args; // Set markup tag filter id. $args[0] = $id . '_markup'; - if ( isset( $args[2] ) ) { + // If there are attributes, remove them from $args. + if ( $attributes ) { unset( $args[2] ); } - // Remove function $tag argument. - unset( $attributes_args[1] ); + // Filter the tag. + $tag = call_user_func_array( 'beans_apply_filters', $args ); - // Stop here if the tag is set to false, the before and after actions won't run in this case. - if ( null === ( $tag = call_user_func_array( 'beans_apply_filters', $args ) ) ) { + // If the tag is set to null, bail out. + if ( null === $tag ) { return; } - // Remove function $tag argument. + global $_beans_is_selfclose_markup; + + // Remove the $tag argument. unset( $args[1] ); + unset( $attributes_args[1] ); - // Set before action id. + // Set and then fire the before action hook. $args[0] = $id . '_before_markup'; + $output = call_user_func_array( '_beans_render_action', $args ); - $output = call_user_func_array( '_beans_render_action', $args ); - - // Don't output the tag if empty, the before and after actions still run. - if ( $tag ) { - $output .= '<' . $tag . ' ' . call_user_func_array( 'beans_add_attributes', $attributes_args ) . ( _beans_is_html_dev_mode() ? ' data-markup-id="' . $id . '"' : null ) . ( $_temp_beans_selfclose_markup ? '/' : '' ) . '>'; - } - - // Set after action id. - $args[0] = $id . ( $_temp_beans_selfclose_markup ? '_after_markup' : '_prepend_markup' ); + // Build the opening tag when tag is available. + if ( $tag ) { + $output .= '<' . esc_attr( $tag ) . ' ' . call_user_func_array( 'beans_add_attributes', $attributes_args ) . ( _beans_is_html_dev_mode() ? ' data-markup-id="' . esc_attr( $id ) . '"' : null ) . ( $_beans_is_selfclose_markup ? '/' : '' ) . '>'; + } + // Set and then fire the after action hook. + $args[0] = $id . ( $_beans_is_selfclose_markup ? '_after_markup' : '_prepend_markup' ); $output .= call_user_func_array( '_beans_render_action', $args ); - // Reset temp selfclose global to reduce memory usage. - unset( $GLOBALS['_temp_beans_selfclose_markup'] ); + // Reset the global variable to reduce memory usage. + unset( $GLOBALS['_beans_is_selfclose_markup'] ); return $output; - } /** - * Echo open markup and attributes registered by ID. - * - * The Beans HTML "markups" and "attributes" functions make it really easy to modify, replace, extend, - * remove or hook into registered markup or attributes. - * - * The "data-markup-id" is added as a HTML attribute if the development mode is enabled. This makes it very - * easy to find the content ID when inspecting an element in a web browser. - * - * Since this function uses {@see beans_apply_filters()}, the $id argument may contain sub-hook(s). + * Echo the opening HTML tag's markup. This function is a wrapper for {@see beans_open_markup()}. See + * {@see beans_open_markup()} for more details. * * @since 1.4.0 * - * @param string $id A unique string used as a reference. The $id argument may contain sub-hooks(s). - * @param string|bool $tag The HTML tag. If set to False or empty, the markup HTML tag will be removed but - * the actions hook will be called. If set the Null, both markup HTML tag and actions - * hooks will be removed. + * @param string $id A unique string used as a reference. The $id argument may contain sub-hooks(s). + * @param string|bool $tag The HTML tag. When set to false or an empty string, the HTML markup tag will not be + * built, but both action hooks will fire. If set to null, the function bails out, i.e. + * the HTML markup tag will not be built and neither action hook fires. * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the - * attribute name and the array value defines the attribute value. Setting - * the array value to '' will display the attribute value as empty - * (e.g. class=""). Setting it to 'false' will only display - * the attribute name (e.g. data-example). Setting it to 'null' will not - * display anything. - * @param mixed $var Optional. Additional variables passed to the functions hooked to $id. + * attribute name and the array value defines the attribute value. + * + * @return void */ function beans_open_markup_e( $id, $tag, $attributes = array() ) { - $args = func_get_args(); - - echo call_user_func_array( 'beans_open_markup', $args ); - + echo call_user_func_array( 'beans_open_markup', $args ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Escaped in beans_open_markup(). } /** - * Register self-close markup and attributes by ID. + * Build the self-closing HTML element's markup. * - * This function is shortuct of {@see beans_open_markup()}. It should be used for self-closed HTML markup such as + * This function is shortcut of {@see beans_open_markup()}. It should be used for self-closing HTML markup such as * images or inputs. * + * Note: You can pass additional arguments to the functions that are hooked to $id. + * * @since 1.0.0 + * @since 1.5.0 Unsets the global variable. * - * @param string $id A unique string used as a reference. The $id argument may contain sub-hook(s). - * @param string|bool $tag The HTML self-close tag.If set to False or empty, the markup HTML tag will - * be removed but the actions hook will be called. If set the Null, both - * markup HTML tag and actions hooks will be removed. - * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the - * attribute name and the array value defines the attribute value. Setting - * the array value to '' will display the attribute value as empty - * (e.g. class=""). Setting it to 'false' will only display - * the attribute name (e.g. data-example). Setting it to 'null' will not - * display anything. - * @param mixed $var Optional. Additional variables passed to the functions hooked to $id. + * @global bool $_beans_is_selfclose_markup When true, indicates a self-closing element should be built. * - * @return string The output. + * @param string $id A unique string used as a reference. The $id argument may contain sub-hooks(s). + * @param string|bool $tag The self-closing HTML tag. When set to false or an empty string, the HTML markup tag + * will not be built, but both action hooks will fire. If set to null, the function + * bails out, i.e. the HTML markup tag will not be built and neither action hook fires. + * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the attribute + * name and the array value defines the attribute value. + * + * @return string|void */ function beans_selfclose_markup( $id, $tag, $attributes = array() ) { + global $_beans_is_selfclose_markup; - global $_temp_beans_selfclose_markup; + $_beans_is_selfclose_markup = true; - $_temp_beans_selfclose_markup = true; $args = func_get_args(); + $html = call_user_func_array( 'beans_open_markup', $args ); - return call_user_func_array( 'beans_open_markup', $args ); + // Reset the global variable to reduce memory usage. + unset( $GLOBALS['_beans_is_selfclose_markup'] ); + return $html; } /** - * Echo self-close markup and attributes registered by ID. - * - * This function is shortuct of {@see beans_open_markup()}. It should be used for self-closed HTML markup such as - * images or inputs. + * Echo the self-closing HTML element's markup. This function is a wrapper for {@see beans_selfclose_markup()}. See + * {@see beans_selfclose_markup()} for more details. * * @since 1.4.0 * - * @param string $id A unique string used as a reference. The $id argument may contain sub-hook(s). - * @param string|bool $tag The HTML self-close tag.If set to False or empty, the markup HTML tag will - * be removed but the actions hook will be called. If set the Null, both - * markup HTML tag and actions hooks will be removed. - * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the - * attribute name and the array value defines the attribute value. Setting - * the array value to '' will display the attribute value as empty - * (e.g. class=""). Setting it to 'false' will only display - * the attribute name (e.g. data-example). Setting it to 'null' will not - * display anything. - * @param mixed $var Optional. Additional variables passed to the functions hooked to $id. + * @param string $id A unique string used as a reference. The $id argument may contain sub-hooks(s). + * @param string|bool $tag The self-closing HTML tag. When set to false or an empty string, the HTML markup tag + * will not be built, but both action hooks will fire. If set to null, the function + * bails out, i.e. the HTML markup tag will not be built and neither action hook fires. + * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the attribute + * name and the array value defines the attribute value. + * + * @return void */ function beans_selfclose_markup_e( $id, $tag, $attributes = array() ) { - $args = func_get_args(); - - echo call_user_func_array( 'beans_selfclose_markup', $args ); - + echo call_user_func_array( 'beans_selfclose_markup', $args ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Escaped in beans_open_markup(). } /** - * Register close markup by ID. + * Build the closing HTML element's markup. This function fires 2 separate hooks: + * + * 1. "{id}_append_markup" - which fires first before the closing tag. + * 2. "{$id}_after_markup" - which fires after the closing tag. * - * This function is similar to {@see beans_open_markup()}, but does not accept HTML attributes. The $id - * argument must be the identical to the opening markup. + * Note: You can pass additional arguments to the functions that are hooked to $id. * * @since 1.0.0 * * @param string $id Identical to the opening markup ID. - * @param string $tag The HTML tag. - * @param mixed $var Additional variables passed to the functions hooked to $id. + * @param string $tag The HTML tag. When set to false or an empty string, the HTML markup tag will not be built, but + * both action hooks will fire. If set to null, the function bails out, i.e. the HTML markup + * tag will not be built and neither action hook fires. * - * @return string The output. + * @return string|void */ function beans_close_markup( $id, $tag ) { + // Filter the tag. + $tag = beans_apply_filters( $id . '_markup', $tag ); - // Stop here if the tag is set to false, the before and after actions won't run in this case. - if ( null === ( $tag = beans_apply_filters( $id . '_markup', $tag ) ) ) { + // If the tag is set to null, bail out. + if ( null === $tag ) { return; } $args = func_get_args(); - // Remove function $tag argument. + // Remove the $tag argument. unset( $args[1] ); - // Set before action id. + // Set and then fire the append action hook. $args[0] = $id . '_append_markup'; + $output = call_user_func_array( '_beans_render_action', $args ); - $output = call_user_func_array( '_beans_render_action', $args ); - - // Don't output the tag if empty, the before and after actions still run. - if ( $tag ) { - $output .= ''; - } + // Build the closing tag when tag is available. + if ( $tag ) { + $output .= ''; + } - // Set after action id. + // Set and then fire the after action hook. $args[0] = $id . '_after_markup'; - $output .= call_user_func_array( '_beans_render_action', $args ); return $output; - } /** - * Echo close markup registered by ID. - * - * This function is similar to {@see beans_open_markup()}, but does not accept HTML attributes. The $id - * argument must be the identical to the opening markup. + * Echo the closing HTML tag's markup. This function is a wrapper for {@see beans_close_markup()}. See + * {@see beans_close_markup()} for more details. * * @since 1.4.0 * * @param string $id Identical to the opening markup ID. - * @param string $tag The HTML tag. - * @param mixed $var Additional variables passed to the functions hooked to $id. + * @param string $tag The HTML tag. When set to false or an empty string, the HTML markup tag will not be built, but + * both action hooks will fire. If set to null, the function bails out, i.e. the HTML markup + * tag will not be built and neither action hook fires. + * + * @return void */ function beans_close_markup_e( $id, $tag ) { - $args = func_get_args(); - - echo call_user_func_array( 'beans_close_markup', $args ); - + echo call_user_func_array( 'beans_close_markup', $args ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Escaped in beans_close_markup(). } /** - * Modify opening and closing HTML tag. Also works for self-closed markup. - * - * This function will automatically modify the opening and the closing HTML tag. If the markup is self-closed, - * the HTML tag will be modified accordingly. - * - * The "data-markup-id" is added as a HTML attribute if the development mode is enabled. This makes it very - * easy to find the content ID when inspecting an element in a web browser. + * Modify the opening and closing or self-closing HTML tag. * * @since 1.0.0 * - * @param string $id The markup ID. - * @param string|callback $markup The replacment HTML tag. A callback is accepted if conditions needs - * to be applied. If arguments are available, they are passed to the callback. + * @param string $id The target markup's ID. + * @param string|callback $markup The replacement HTML tag. A callback is accepted if conditions need to be + * applied. If arguments are available, then they are passed to the callback. * @param int $priority Optional. Used to specify the order in which the functions - * associated with a particular action are executed. Default 10. - * Lower numbers correspond with earlier execution, - * and functions with the same priority are executed - * in the order in which they were added to the action. - * @param int $args Optional. The number of arguments the function accepts. Default 1. + * associated with a particular action are executed. Default is 10. + * @param int $args Optional. The number of arguments the callback accepts. Default is 1. * - * @return bool Will always return true. + * @return bool|_Beans_Anonymous_Filters */ function beans_modify_markup( $id, $markup, $priority = 10, $args = 1 ) { - return beans_add_filter( $id . '_markup', $markup, $priority, $args ); - } /** - * Remove markup. + * Remove the markup. * - * This function will automatically remove the opening and the closing HTML tag. If the markup is self-closed, + * This function will automatically remove the opening and the closing HTML tag. If the markup is self-closing, * the HTML tag will be removed accordingly. * - * The "data-markup-id" is added as a HTML attribute if the development mode is enabled. This makes it very - * easy to find the content ID when inspecting an element in a web browser. - * * @since 1.0.0 * - * @param string $id The markup ID. - * @param bool $remove_actions Optional. Whether elements attached to a markup should be removed or not. This must be used - * with absolute caution. + * @param string $id The target markup's ID. + * @param bool $remove_actions Optional. When true, the markup including the before and prepend/after hooks will be + * removed. When false, only the HTML element will be removed. * - * @return bool Will always return true. + * @return bool|_Beans_Anonymous_Filters */ function beans_remove_markup( $id, $remove_actions = false ) { - - if ( $remove_actions ) { - return beans_add_filter( $id . '_markup', null ); - } - - return beans_add_filter( $id . '_markup', false ); - + return beans_add_filter( $id . '_markup', $remove_actions ? null : false ); } /** - * Reset markup. - * - * This function will automatically reset the opening and the closing HTML tag to its original value. If the markup is self-closed, - * the HTML tag will be reset accordingly. - * - * The "data-markup-id" is added as a HTML attribute if the development mode is enabled. This makes it very - * easy to find the content ID when inspecting an element in a web browser. + * Reset the given markup's tag. This function will automatically reset the opening and closing HTML tag or + * self-closing tag to its original value. * * @since 1.3.1 * * @param string $id The markup ID. * - * @return bool Will always return true. + * @return void */ function beans_reset_markup( $id ) { - remove_all_filters( $id . '_markup' ); remove_all_filters( preg_replace( '#(\[|\])#', '', $id ) . '_markup' ); - } /** - * Wrap markup. + * Register the wrap markup with Beans using the given markup ID. + * + * This function registers an anonymous callback to the following action hooks: * - * This function calls {@see beans_open_markup()} before the opening markup and - * {@see beans_close_markup()} after the closing markup. + * 1. `$id_before_markup`: When this hook fires, {@see beans_open_markup()} is called to build the wrap's + * opening HTML markup. + * 2. `$id_after_markup`: When this hook fires, {@see beans_close_markup()} is called to build the wrap's + * closing HTML markup. + * + * Note: You can pass additional arguments to the functions that are hooked to $id. * * @since 1.0.0 + * @since 1.5.0 Bails out if an empty $tag is given. * - * @param string $id The markup ID. - * @param string $new_id A unique string used as a reference. The $id argument may contain sub-hook(s). - * @param string $tag The HTML wrap tag. + * @param string $id The wrap markup's ID. + * @param string $new_id A unique string used as a reference. The $id argument may contain sub-hook(s). + * @param string $tag The wrap's HTML tag. * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the * attribute name and the array value define the attribute value. Setting * the array value to '' will display the attribute value as empty * (e.g. class=""). Setting it to 'false' will only display * the attribute name (e.g. data-example). Setting it to 'null' will not * display anything. - * @param mixed $var Additional variables passed to the functions hooked to $id. * - * @return bool Will always return true. + * @return bool */ function beans_wrap_markup( $id, $new_id, $tag, $attributes = array() ) { + if ( ! $tag ) { + return false; + } + $args = func_get_args(); unset( $args[0] ); @@ -430,32 +382,41 @@ function beans_wrap_markup( $id, $new_id, $tag, $attributes = array() ) { _beans_add_anonymous_action( $id . '_after_markup', array( 'beans_close_markup', $args ), 1 ); return true; - } /** - * Wrap markup inner content. + * Register the wrap inner content's markup with Beans using the given markup ID. + * + * This function registers an anonymous callback to the following action hooks: + * + * 1. `$id_prepend_markup`: When this hook fires, {@see beans_open_markup()} is called to build the wrap inner + * content's HTML markup just after the wrap's opening tag. + * 2. `$id_append_markup`: When this hook fires, {@see beans_close_markup()} is called to build the wrap inner + * content's HTML markup just before the wrap's closing tag. * - * This function calls {@see beans_open_markup()} after the opening markup and - * {@see beans_close_markup()} before the closing markup. + * Note: You can pass additional arguments to the functions that are hooked to $id. * * @since 1.0.0 + * @since 1.5.0 Bails out if an empty $tag is given. * - * @param string $id The markup ID. - * @param string $new_id A unique string used as a reference. The $id argument may contain sub-hook(s). - * @param string $tag The HTML wrap tag. + * @param string $id The wrap markup's ID. + * @param string $new_id A unique string used as a reference. The $id argument may contain sub-hook(s). + * @param string $tag The wrap inner content's HTML tag. * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the * attribute name and the array value define the attribute value. Setting * the array value to '' will display the attribute value as empty * (e.g. class=""). Setting it to 'false' will only display * the attribute name (e.g. data-example). Setting it to 'null' will not * display anything. - * @param mixed $var Additional variables passed to the functions hooked to $id. * - * @return bool Will always return true. + * @return bool */ function beans_wrap_inner_markup( $id, $new_id, $tag, $attributes = array() ) { + if ( ! $tag ) { + return false; + } + $args = func_get_args(); unset( $args[0] ); @@ -466,36 +427,35 @@ function beans_wrap_inner_markup( $id, $new_id, $tag, $attributes = array() ) { _beans_add_anonymous_action( $id . '_append_markup', array( 'beans_close_markup', $args ), 9999 ); return true; - } /** - * Register attributes by ID. + * Convert an array of attributes into a properly formatted HTML string. * - * The Beans HTML "attributes" functions make it really easy to modify, replace, extend, - * remove or hook into registered attributes. + * The attributes are registered in Beans via the given ID. Using this ID, we can hook into the filter, i.e. + * "$id_attributes", to modify, replace, extend, or remove one or more of the registered attributes. * * Since this function uses {@see beans_apply_filters()}, the $id argument may contain sub-hook(s). * + * Note: You can pass additional arguments to the functions that are hooked to $id. + * * @since 1.0.0 * - * @param string $id A unique string used as a reference. The $id argument may contain sub-hook(s). + * @param string $id A unique string used as a reference. The $id argument may contain sub-hook(s). * @param string|array $attributes Optional. Query string or array of attributes. The array key defines the * attribute name and the array value define the attribute value. Setting * the array value to '' will display the attribute value as empty * (e.g. class=""). Setting it to 'false' will only display * the attribute name (e.g. data-example). Setting it to 'null' will not * display anything. - * @param mixed $var Additional variables passed to the functions hooked to $id. * * @return string The HTML attributes. */ function beans_add_attributes( $id, $attributes = array() ) { - - $args = func_get_args(); + $args = func_get_args(); $args[0] = $id . '_attributes'; - if ( ! isset( $args[1] ) ) { + if ( empty( $args[1] ) ) { $args[1] = array(); } @@ -504,7 +464,6 @@ function beans_add_attributes( $id, $attributes = array() ) { $attributes = call_user_func_array( 'beans_apply_filters', $args ); return beans_esc_attributes( $attributes ); - } /** @@ -520,17 +479,15 @@ function beans_add_attributes( $id, $attributes = array() ) { * * @param string $id The markup ID. * - * @return bool Will always return true. + * @return void */ function beans_reset_attributes( $id ) { - remove_all_filters( $id . '_attributes' ); remove_all_filters( preg_replace( '#(\[|\])#', '', $id ) . '_attributes' ); - } /** - * Add attribute to markup. + * Add a value to an existing attribute or add a new attribute. * * This function must be called before the targeted markup is called. * @@ -538,6 +495,7 @@ function beans_reset_attributes( $id ) { * easy to find the content ID when inspecting an element in a web browser. * * @since 1.0.0 + * @since 1.5.0 Return the object. * * @param string $id The markup ID. * @param string $attribute Name of the HTML attribute. @@ -545,18 +503,16 @@ function beans_reset_attributes( $id ) { * (e.g. class=""). Setting it to 'false' will only display the attribute name * (e.g. data-example). Setting it to 'null' will not display anything. * - * @return array All targeted markup attributes. + * @return _Beans_Attribute */ function beans_add_attribute( $id, $attribute, $value ) { + $attribute = new _Beans_Attribute( $id, $attribute, $value ); - $class = new _Beans_Attributes( $id, $attribute, $value ); - - return $class->init( 'add' ); - + return $attribute->init( 'add' ); } /** - * Replace attribute to markup. + * Replace the attribute's value. If the attribute does not exist, it is added with the new value. * * This function must be called before the targeted markup is called. * @@ -564,26 +520,27 @@ function beans_add_attribute( $id, $attribute, $value ) { * easy to find the content ID when inspecting an element in a web browser. * * @since 1.0.0 - * - * @param string $id The markup ID. - * @param string $attribute Name of the HTML attribute to target. - * @param string $value Value which should be replaced. - * @param string $new_value Optional. Replacement value. If set to '' will display the attribute value as empty - * (e.g. class=""). Setting it to 'false' will only display the attribute name - * (e.g. data-example). Setting it to 'null' will not display anything. - * - * @return array All targeted markup attributes. + * @since 1.5.0 Return the object. Allows replacement of all values. + * + * @param string $id The markup ID. + * @param string $attribute Name of the HTML attribute to target. + * @param string $value Value of the HTML attribute to be replaced. Setting it to an empty (i.e. empty string, + * false, or null) replaces all of the values for this attribute. + * @param string|null $new_value Optional. Replacement (new) value of the HTML attribute. Setting it to an empty string + * ('') or null will remove the $value (e.g. class=""). Setting it to 'false', the + * browser will display only the attribute name + * (e.g. data-example). + * + * @return _Beans_Attribute */ function beans_replace_attribute( $id, $attribute, $value, $new_value = null ) { + $attribute = new _Beans_Attribute( $id, $attribute, $value, $new_value ); - $class = new _Beans_Attributes( $id, $attribute, $value, $new_value ); - - return $class->init( 'replace' ); - + return $attribute->init( 'replace' ); } /** - * Remove markup attribute. + * Remove a specific value from the attribute or remove the entire attribute. * * This function must be called before the targeted markup is called. * @@ -591,32 +548,35 @@ function beans_replace_attribute( $id, $attribute, $value, $new_value = null ) { * easy to find the content ID when inspecting an element in a web browser. * * @since 1.0.0 + * @since 1.5.0 Return the object. * - * @param string $id The markup ID. - * @param string $attribute Name of the HTML attribute to target. - * @param string $value Optional. Name of the value to remove. Set it to 'false' to completely remove the attribute. + * @param string $id The markup ID. + * @param string $attribute Name of the HTML attribute to target. + * @param string|null $value Optional. The attribute value to remove. Set it to 'false' or null to completely + * remove the attribute. * - * @return array All targeted markup attributes remaining. + * @return _Beans_Attribute */ function beans_remove_attribute( $id, $attribute, $value = null ) { + $attribute = new _Beans_Attribute( $id, $attribute, $value, '' ); - $class = new _Beans_Attributes( $id, $attribute, $value ); - - return $class->init( 'remove' ); - + return $attribute->init( 'remove' ); } /** * Check if development mode is enabled taking in consideration legacy constant. * + * @since 1.5.0 * @ignore + * @access private + * + * @return bool */ function _beans_is_html_dev_mode() { if ( defined( 'BEANS_HTML_DEV_MODE' ) ) { - return BEANS_HTML_DEV_MODE; + return (bool) BEANS_HTML_DEV_MODE; } - return get_option( 'beans_dev_mode', false ); - + return (bool) get_option( 'beans_dev_mode', false ); } diff --git a/lib/api/image/class-beans-image-editor.php b/lib/api/image/class-beans-image-editor.php new file mode 100644 index 00000000..5a931356 --- /dev/null +++ b/lib/api/image/class-beans-image-editor.php @@ -0,0 +1,185 @@ +src ); + $this->src = file_exists( $local_source ) ? $local_source : $src; + $this->args = $args; + $this->output = $output; + $this->rebuilt_path = $this->rebuild_image_path(); + } + + /** + * Run the editor. + * + * @since 1.0.0 + * @since 1.5.0 Refactored. + * + * @return array|object|string + */ + public function run() { + + // Return the edited image's info packet when the file already exists or we successfully create it. + if ( $this->edited_image_exists() || $this->create_edited_image() ) { + return $this->get_image_info( beans_path_to_url( $this->rebuilt_path ), true ); + } + + return $this->get_image_info( $this->src ); + } + + /** + * Edit the image and then store it in the rebuilt path. + * + * @since 1.0.0 + * + * @return bool Returns true when successful; else false is returned. + */ + private function create_edited_image() { + $wp_editor = wp_get_image_editor( $this->src ); + + // If an error occurred, bail out. + if ( is_wp_error( $wp_editor ) ) { + return false; + } + + // Fire the editing task. + foreach ( $this->args as $method => $args ) { + + if ( is_callable( array( $wp_editor, $method ) ) ) { + call_user_func_array( array( $wp_editor, $method ), (array) $args ); + } + } + + // Save the "edited" image as a new image. + $wp_editor->save( $this->rebuilt_path ); + + return ! is_wp_error( $wp_editor ); + } + + /** + * Returns the image's information in the configured output format. + * + * @since 1.5.0 + * + * @param string $src Image's path or URL. + * @param bool $edited_image_exists When true, include the dimensions. + * + * @return array|object + */ + private function get_image_info( $src, $edited_image_exists = false ) { + + if ( 'STRING' === $this->output ) { + return $src; + } + + if ( $edited_image_exists ) { + list( $width, $height ) = @getimagesize( $this->rebuilt_path ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + } else { + $width = null; + $height = null; + } + + if ( 'ARRAY_N' === $this->output ) { + return array( $src, $width, $height ); + } + + $image_info = array( + 'src' => $src, + 'width' => $width, + 'height' => $height, + ); + + if ( 'OBJECT' === $this->output ) { + return (object) $image_info; + } + + return $image_info; + } + + /** + * Rebuild the image's path. + * + * @since 1.0.0 + * + * @return string + */ + private function rebuild_image_path() { + $upload_dir = beans_get_images_dir(); + $info = pathinfo( preg_replace( '#\?.*#', '', $this->src ) ); + $query = substr( md5( @serialize( $this->args ) ), 0, 7 ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize -- Valid use case. + $extension = $info['extension']; + $filename = str_replace( '.' . $extension, '', $info['basename'] ); + + return "{$upload_dir}{$filename}-{$query}.{$extension}"; + } + + /** + * Checks if the edited image exists. + * + * @since 1.5.0 + * + * @return bool + */ + private function edited_image_exists() { + return file_exists( $this->rebuilt_path ); + } +} diff --git a/lib/api/image/class-beans-image-options.php b/lib/api/image/class-beans-image-options.php new file mode 100644 index 00000000..ca2e97b4 --- /dev/null +++ b/lib/api/image/class-beans-image-options.php @@ -0,0 +1,128 @@ +get_fields_to_register(), + 'beans_settings', + 'images_options', array( + 'title' => __( 'Images options', 'tm-beans' ), + 'context' => $this->has_metaboxes() ? 'column' : 'normal', + ) + ); + } + + /** + * Get the fields to register. + * + * @since 1.5.0 + * + * @return array + */ + private function get_fields_to_register() { + return require dirname( __FILE__ ) . '/config/fields.php'; + } + + /** + * Checks if there are metaboxes registered already. + * + * @since 1.5.0 + * + * @return bool + */ + private function has_metaboxes() { + global $wp_meta_boxes; + + $metaboxes = beans_get( 'beans_settings', $wp_meta_boxes ); + return ! empty( $metaboxes ); + } + + /** + * Flush images from the Beans cached folder. + * + * @since 1.0.0 + * + * @return void + */ + public function flush() { + + if ( ! beans_post( 'beans_flush_edited_images' ) ) { + return; + } + + beans_remove_dir( beans_get_images_dir() ); + } + + /** + * Renders the success admin notice. + * + * @since 1.0.0 + * + * @return void + */ + public function render_success_notice() { + + if ( ! beans_post( 'beans_flush_edited_images' ) ) { + return; + } + + include dirname( __FILE__ ) . '/views/flushed-notice.php'; + } + + /** + * Render the flush button, which is used to flush the images' cache. + * + * @since 1.0.0 + * + * @param array $field Registered options. + * + * @return void + */ + public function render_flush_button( $field ) { + + if ( 'beans_edited_images_directories' !== $field['id'] ) { + return; + } + + include dirname( __FILE__ ) . '/views/flush-button.php'; + } +} diff --git a/lib/api/image/class-images.php b/lib/api/image/class-images.php deleted file mode 100644 index f3647bac..00000000 --- a/lib/api/image/class-images.php +++ /dev/null @@ -1,166 +0,0 @@ -src = $src; - $this->args = $args; - $this->output = $output; - $local_source = beans_url_to_path( $this->src ); - - // Treat internal files as such if possible. - if ( file_exists( $local_source ) ) { - $this->src = $local_source; - } - - } - - /** - * Initialize the editing. - */ - public function init() { - - $this->setup(); - - // Try to create image if it doesn't exist. - if ( ! file_exists( $this->rebuilt_path ) ) { - - // Return orginial image source if it can't be edited. - if ( ! $this->edit() ) { - - $array = array( - 'src' => $this->src, - 'width' => null, - 'height' => null, - ); - - switch ( $this->output ) { - - case 'STRING': - return $this->src; - break; - - case 'ARRAY_N': - return array_values( $array ); - break; - - case 'OBJECT': - return (object) $array; - break; - - } - } - } - - $src = beans_path_to_url( $this->rebuilt_path ); - - // Simply return the source if dimensions are not requested - if ( 'STRING' == $this->output ) { - return $src; - } - - // Get the new image dimensions - list( $width, $height ) = @getimagesize( $this->rebuilt_path ); - - $array = array( - 'src' => $src, - 'width' => $width, - 'height' => $height, - ); - - if ( 'ARRAY_N' == $this->output ) { - return array_values( $array ); - } elseif ( 'OBJECT' == $this->output ) { - return (object) $array; - } - - return $array; - - } - - /** - * Setup image data. - */ - private function setup() { - - $upload_dir = beans_get_images_dir(); - $info = pathinfo( preg_replace( '#\?.*#', '', $this->src ) ); - $query = substr( md5( @serialize( $this->args ) ), 0, 7 ); - $extension = $info['extension']; - $filename = str_replace( '.' . $extension, '', $info['basename'] ); - $this->rebuilt_path = "{$upload_dir}{$filename}-{$query}.{$extension}"; - - } - - /** - * Edit image. - */ - private function edit() { - - // Prepare editor. - $editor = wp_get_image_editor( $this->src ); - - // Stop here if there was an error. - if ( is_wp_error( $editor ) ) { - return false; - } - - // Fire image edit. - foreach ( $this->args as $function => $arguments ) { - - // Make sure it is callable - if ( is_callable( array( $editor, $function ) ) ) { - call_user_func_array( array( $editor, $function ), (array) $arguments ); - } - } - - // Save new image. - $editor->save( $this->rebuilt_path ); - - // Stop here if there was an error. - if ( is_wp_error( $editor ) ) { - return false; - } - - return true; - - } -} diff --git a/lib/api/image/class-options.php b/lib/api/image/class-options.php deleted file mode 100644 index 47dbaa3a..00000000 --- a/lib/api/image/class-options.php +++ /dev/null @@ -1,90 +0,0 @@ - 'beans_edited_images_directories', - 'type' => 'flush_edited_images', - 'description' => __( 'Clear all edited images. New images will be created on page load.', 'tm-beans' ), - ), - ); - - beans_register_options( $fields, 'beans_settings', 'images_options', array( - 'title' => __( 'Images options', 'tm-beans' ), - 'context' => beans_get( 'beans_settings', $wp_meta_boxes ) ? 'column' : 'normal', // Check of other beans boxes. - ) ); - - } - - /** - * Flush images for all folders set. - */ - public function flush() { - - if ( ! beans_post( 'beans_flush_edited_images' ) ) { - return; - } - - beans_remove_dir( beans_get_images_dir() ); - - } - - /** - * Image editor notice notice. - */ - public function admin_notice() { - - if ( ! beans_post( 'beans_flush_edited_images' ) ) { - return; - } - - ?> -

- - - array( + 'id' => 'beans_edited_images_directories', + 'type' => 'flush_edited_images', + 'description' => __( 'Clear all edited images. New images will be created on page load.', 'tm-beans' ), + ), +); diff --git a/lib/api/image/functions.php b/lib/api/image/functions.php index dc29e451..f9b5506c 100644 --- a/lib/api/image/functions.php +++ b/lib/api/image/functions.php @@ -2,10 +2,10 @@ /** * The Beans Image component contains a set of functions to edit images on the fly. * - * Edited images are duplicates of the orinigals. All modified images are stored in a shared folder, + * Edited images are duplicates of the originals. All modified images are stored in a shared folder, * which makes it easy to delete them without impacting the originals. * - * @package API\Image + * @package Beans\Framework\API\Image */ /** @@ -16,34 +16,21 @@ * * @since 1.0.0 * - * @param string $src The image source. - * @param array $args { - * Associative array of arguments used by the image editor. - * - * @type array $resize Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} resize - * function arguments. - * @type array $crop Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} crop - * function arguments. - * @type array $rotate Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} rotate - * function arguments. - * @type array $flip Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} flip - * function arguments. - * @type array $set_quality Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} set_quality - * function arguments. - * } - * @param string $output Optional. Returned format. Accepts STRING, OBJECT, ARRAY_A, or ARRAY_N. - * Default STRING. + * @param string $src The image source. + * @param array $args An array of editor arguments, where the key is the {@see WP_Image_Editor} method name + * and the value is a numeric array of arguments for the method. Make sure to specify + * all of the arguments the WordPress editor's method requires. Refer to + * {@link https://codex.wordpress.org/Class_Reference/WP_Image_Editor#Methods} for more + * information on the available methods and each method's arguments. + * @param string $output Optional. Returned format. Accepts STRING, OBJECT, ARRAY_A, or ARRAY_N. + * Default is STRING. * * @return string|array Image source if output set the STRING, image data otherwise. */ function beans_edit_image( $src, array $args, $output = 'STRING' ) { - - require_once( BEANS_API_PATH . 'image/class-images.php' ); - - $instance = new _Beans_Image_Editor( $src, $args, $output ); - - return $instance->init(); - + require_once BEANS_API_PATH . 'image/class-beans-image-editor.php'; + $editor = new _Beans_Image_Editor( $src, $args, $output ); + return $editor->run(); } /** @@ -60,47 +47,36 @@ function beans_edit_image( $src, array $args, $output = 'STRING' ) { * @return object Post attachment data. */ function beans_get_post_attachment( $post_id, $size = 'full' ) { - - $id = get_post_thumbnail_id( $post_id ); + $id = get_post_thumbnail_id( $post_id ); $post = get_post( $id ); - $src = wp_get_attachment_image_src( $id, $size ); - - $obj = new stdClass(); - $obj->id = $id; - $obj->src = $src[0]; - $obj->width = $src[1]; - $obj->height = $src[2]; - $obj->alt = trim( strip_tags( get_post_meta( $id, '_wp_attachment_image_alt', true ) ) ); - $obj->title = $post->post_title; - $obj->caption = $post->post_excerpt; + $src = wp_get_attachment_image_src( $id, $size ); + + $obj = new stdClass(); + $obj->id = $id; + $obj->src = $src[0]; + $obj->width = $src[1]; + $obj->height = $src[2]; + $obj->alt = trim( strip_tags( get_post_meta( $id, '_wp_attachment_image_alt', true ) ) ); + $obj->title = $post->post_title; + $obj->caption = $post->post_excerpt; $obj->description = $post->post_content; return $obj; - } /** * Edit post attachment. * - * This function is shortuct of {@see beans_edit_image()}. It should be used to edit a post attachment. + * This function is shortcut of {@see beans_edit_image()}. It should be used to edit a post attachment. * * @since 1.0.0 * - * @param string $post_id The post id. - * @param array $args { - * Array of arguments used by the image editor. - * - * @type array $resize Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} resize - * function arguments. - * @type array $crop Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} crop - * function arguments. - * @type array $rotate Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} rotate - * function arguments. - * @type array $flip Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} flip - * function arguments. - * @type array $set_quality Numeric array matching the {@link http://codex.wordpress.org/Class_Reference/WP_Image_Editor WP_Image_Editor} set_quality - * function arguments. - * } + * @param string $post_id The post id. + * @param array $args An array of editor arguments, where the key is the {@see WP_Image_Editor} method name + * and the value is a numeric array of arguments for the method. Make sure to specify + * all of the arguments the WordPress editor's method requires. Refer to + * {@link https://codex.wordpress.org/Class_Reference/WP_Image_Editor#Methods} for more + * information on the available methods and each method's arguments. * * @return object Edited post attachment data. */ @@ -111,34 +87,54 @@ function beans_edit_post_attachment( $post_id, $args = array() ) { } // Get full size image. - $attachement = beans_get_post_attachment( $post_id, 'full' ); + $attachment = beans_get_post_attachment( $post_id, 'full' ); + $edited = beans_edit_image( $attachment->src, $args, 'ARRAY_A' ); - if ( ! $edited = beans_edit_image( $attachement->src, $args, 'ARRAY_A' ) ) { - return $attachement; + if ( ! $edited ) { + return $attachment; } - return (object) array_merge( (array) $attachement, $edited ); - + return (object) array_merge( (array) $attachment, $edited ); } /** - * Get edited images directory. + * Get the "edited images" storage directory, i.e. where the "edited images" are/will be stored. * * @since 1.0.0 * - * @return string Edited images directory. + * @return string */ function beans_get_images_dir() { - $wp_upload_dir = wp_upload_dir(); /** * Filter the edited images directory. * * @since 1.0.0 + * + * @param string Default path to the Beans' edited images storage directory. */ $dir = apply_filters( 'beans_images_dir', trailingslashit( $wp_upload_dir['basedir'] ) . 'beans/images/' ); return wp_normalize_path( trailingslashit( $dir ) ); +} + +add_action( 'beans_loaded_api_component_image', 'beans_add_image_options_to_settings' ); +/** + * Add the "image options" to the Beans Settings page. + * + * @since 1.5.0 + * + * @return _Beans_Image_Options|void + */ +function beans_add_image_options_to_settings() { + + if ( ! class_exists( '_Beans_Image_Options' ) ) { + return; + } + + $instance = new _Beans_Image_Options(); + $instance->init(); + return $instance; } diff --git a/lib/api/image/views/flush-button.php b/lib/api/image/views/flush-button.php new file mode 100644 index 00000000..1e88b9dc --- /dev/null +++ b/lib/api/image/views/flush-button.php @@ -0,0 +1,12 @@ + + diff --git a/lib/api/image/views/flushed-notice.php b/lib/api/image/views/flushed-notice.php new file mode 100644 index 00000000..995e3da7 --- /dev/null +++ b/lib/api/image/views/flushed-notice.php @@ -0,0 +1,14 @@ + +
+

+
diff --git a/lib/api/init.php b/lib/api/init.php index 4c0e26a4..ac2d8236 100644 --- a/lib/api/init.php +++ b/lib/api/init.php @@ -1,11 +1,11 @@ 'medium', ) ); - $g = beans_get( 'grid', $args ); // $g stands for grid. - $c = $g; // $c stands for content. Same value as grid by default - $sp = beans_get( 'sidebar_primary', $args ); // $sp stands for sidebar primary. - $ss = beans_get( 'sidebar_secondary', $args ); // $ss stands for 'sidebar secondary. - $prefix = 'uk-width-' . beans_get( 'breakpoint', $args, 'medium' ); - - $classes = array(); - - switch ( $layout = beans_get_layout() ) { - - case 'c': - - $classes['content'] = "$prefix-$c-$g"; - - break; - - default: - - $classes['content'] = "$prefix-$c-$g"; - - } - - // Add sidebar primary layouts if the primary widget area is registered. - if ( $has_primary = beans_has_widget_area( 'sidebar_primary' ) ) { - - switch ( $layout ) { - - case 'c_sp': - - $c = $g - $sp; - - $classes['content'] = "$prefix-$c-$g"; - $classes['sidebar_primary'] = "$prefix-$sp-$g"; - - break; - - case 'sp_c': - - $c = $g - $sp; + /** + * Filter the layout class. + * + * The dynamic portion of the hook name refers to the searched layout section ID. + * + * @since 1.0.0 + * + * @param string $layout The layout class. + */ + return apply_filters( "beans_layout_class_{$id}", beans_get( $id, _beans_get_layout_classes( $args ) ) ); +} - $classes['content'] = "$prefix-$c-$g uk-push-$sp-$g"; - $classes['sidebar_primary'] = "$prefix-$sp-$g uk-pull-$c-$g"; +/** + * Get the layout's class attribute values. + * + * @since 1.5.0 + * @ignore + * @access private + * + * @param array $args Grid configuration. + * + * @return array + */ +function _beans_get_layout_classes( array $args ) { + $grid = beans_get( 'grid', $args ); + $c = $grid; // $c stands for "content". + $sp = beans_get( 'sidebar_primary', $args ); + $ss = beans_get( 'sidebar_secondary', $args ); + $prefix = 'uk-width-' . beans_get( 'breakpoint', $args, 'medium' ); - break; + $classes = array( + 'content' => "{$prefix}-{$c}-{$grid}", + ); - } + if ( ! beans_has_widget_area( 'sidebar_primary' ) ) { + return $classes; } - // Add sidebar secondary layouts if the primary and secondary widget area are registered. - if ( $has_primary && beans_has_widget_area( 'sidebar_secondary' ) ) { - - switch ( $layout ) { - - case 'c_ss': - - $c = $g - $sp; - - $classes['content'] = "$prefix-$c-$g"; - $classes['sidebar_secondary'] = "$prefix-$sp-$g"; - - break; - - case 'c_sp_ss': + $layout = beans_get_layout(); + $has_secondary = beans_has_widget_area( 'sidebar_secondary' ); + $c = $has_secondary && strlen( trim( $layout ) ) > 4 ? $grid - ( $sp + $ss ) : $grid - $sp; - $c = $g - ( $sp + $ss ); + switch ( $layout ) { - $classes['content'] = "$prefix-$c-$g"; - $classes['sidebar_primary'] = "$prefix-$sp-$g"; - $classes['sidebar_secondary'] = "$prefix-$ss-$g"; + case 'c_sp': + case 'c_sp_ss': + $classes['content'] = "{$prefix}-{$c}-{$grid}"; + $classes['sidebar_primary'] = "{$prefix}-{$sp}-{$grid}"; - break; - - case 'ss_c': - - $c = $g - $sp; - - $classes['content'] = "$prefix-$c-$g uk-push-$sp-$g"; - $classes['sidebar_secondary'] = "$prefix-$sp-$g uk-pull-$c-$g"; - - break; + if ( $has_secondary && 'c_sp_ss' === $layout ) { + $classes['sidebar_secondary'] = "{$prefix}-{$ss}-{$grid}"; + } + break; - case 'sp_ss_c': + case 'sp_c': + case 'sp_c_ss': + $classes['content'] = "{$prefix}-{$c}-{$grid} uk-push-{$sp}-{$grid}"; + $classes['sidebar_primary'] = "{$prefix}-{$sp}-{$grid} uk-pull-{$c}-{$grid}"; - $c = $g - ( $sp + $ss ); - $push_content = $sp + $ss; + if ( $has_secondary && 'sp_c_ss' === $layout ) { + $classes['sidebar_secondary'] = "{$prefix}-{$ss}-{$grid}"; + } + break; - $classes['content'] = "$prefix-$c-$g uk-push-$push_content-$g"; - $classes['sidebar_primary'] = "$prefix-$sp-$g uk-pull-$c-$g"; - $classes['sidebar_secondary'] = "$prefix-$ss-$g uk-pull-$c-$g"; + case 'c_ss': + // If we don't have a secondary sidebar, bail out. + if ( ! $has_secondary ) { + return $classes; + } - break; + $classes['content'] = "{$prefix}-{$c}-{$grid}"; + $classes['sidebar_secondary'] = "{$prefix}-{$ss}-{$grid}"; + break; - case 'sp_c_ss': + case 'ss_c': + // If we don't have a secondary sidebar, bail out. + if ( ! $has_secondary ) { + return $classes; + } - $c = $g - ( $sp + $ss ); + $classes['content'] = "{$prefix}-{$c}-{$grid} uk-push-{$ss}-{$grid}"; + $classes['sidebar_secondary'] = "{$prefix}-{$ss}-{$grid} uk-pull-{$c}-{$grid}"; + break; - $classes['content'] = "$prefix-$c-$g uk-push-$sp-$g"; - $classes['sidebar_primary'] = "$prefix-$sp-$g uk-pull-$c-$g"; - $classes['sidebar_secondary'] = "$prefix-$ss-$g"; + case 'sp_ss_c': + $push_content = $has_secondary ? $sp + $ss : $sp; + $classes['content'] = "{$prefix}-{$c}-{$grid} uk-push-{$push_content}-{$grid}"; + $classes['sidebar_primary'] = "{$prefix}-{$sp}-{$grid} uk-pull-{$c}-{$grid}"; - break; + if ( $has_secondary ) { + $classes['sidebar_secondary'] = "{$prefix}-{$ss}-{$grid} uk-pull-{$c}-{$grid}"; + } - } + break; } - /** - * Filter the layout class. - * - * The dynamic portion of the hook name refers to the searched layout section ID. - * - * @since 1.0.0 - * - * @param string $layout The layout class. - */ - return apply_filters( "beans_layout_class_$id", beans_get( $id, $classes ) ); - + return $classes; } /** @@ -233,28 +222,41 @@ function beans_get_layout_class( $id ) { * @return array Layouts ready for Beans 'imageradio' option type. */ function beans_get_layouts_for_options( $add_default = false ) { - - $base = BEANS_ADMIN_ASSETS_URL . 'images/layouts/'; - + $base = BEANS_ADMIN_ASSETS_URL . 'images/layouts/'; $layouts = array( - 'c' => $base . 'c.png', + 'c' => array( + 'src' => $base . 'c.png', + 'alt' => __( 'Full-Width Content Layout', 'tm-beans' ), + 'screen_reader_text' => __( 'Option for the Full-Width Content Layout.', 'tm-beans' ), + ), ); // Add sidebar primary layouts if the primary widget area is registered. - if ( $has_primary = beans_has_widget_area( 'sidebar_primary' ) ) { + $has_primary = beans_has_widget_area( 'sidebar_primary' ); - $layouts['c_sp'] = $base . 'cs.png'; - $layouts['sp_c'] = $base . 'sc.png'; + if ( $has_primary ) { + $layouts['c_sp']['src'] = $base . 'cs.png'; + $layouts['c_sp']['alt'] = __( 'Content and Primary Sidebar Layout', 'tm-beans' ); + $layouts['c_sp']['screen_reader_text'] = __( 'Option for the Content and Primary Sidebar Layout.', 'tm-beans' ); + $layouts['sp_c']['src'] = $base . 'sc.png'; + $layouts['sp_c']['alt'] = __( 'Primary Sidebar and Content Layout', 'tm-beans' ); + $layouts['sp_c']['screen_reader_text'] = __( 'Option for the Primary Sidebar and Content Layout.', 'tm-beans' ); } // Add sidebar secondary layouts if the primary and secondary widget area are registered. if ( $has_primary && beans_has_widget_area( 'sidebar_secondary' ) ) { + $layouts['c_sp_ss']['src'] = $base . 'css.png'; + $layouts['c_sp_ss']['alt'] = __( 'Content, Primary Sidebar and Secondary Sidebar Layout', 'tm-beans' ); + $layouts['c_sp_ss']['screen_reader_text'] = __( 'Option for the Content, Primary Sidebar and Secondary Sidebar Layout.', 'tm-beans' ); - $layouts['c_sp_ss'] = $base . 'css.png'; - $layouts['sp_ss_c'] = $base . 'ssc.png'; - $layouts['sp_c_ss'] = $base . 'scs.png'; + $layouts['sp_ss_c']['src'] = $base . 'ssc.png'; + $layouts['sp_ss_c']['alt'] = __( 'Primary Sidebar, Secondary Sidebar and Content Layout', 'tm-beans' ); + $layouts['sp_ss_c']['screen_reader_text'] = __( 'Option for the Primary Sidebar, Secondary Sidebar and Content Layout.', 'tm-beans' ); + $layouts['sp_c_ss']['src'] = $base . 'scs.png'; + $layouts['sp_c_ss']['alt'] = __( 'Primary Sidebar, Content and Secondary Sidebar Layout', 'tm-beans' ); + $layouts['sp_c_ss']['screen_reader_text'] = __( 'Option for the Primary Sidebar, Content and Secondary Sidebar Layout.', 'tm-beans' ); } /** @@ -270,15 +272,53 @@ function beans_get_layouts_for_options( $add_default = false ) { */ $layouts = apply_filters( 'beans_layouts', $layouts ); - if ( $add_default ) { - $layouts = array_merge( array( - 'default_fallback' => sprintf( - __( 'Use Default Layout (%s)', 'tm-beans' ), - '' . _x( 'Modify', 'Default layout', 'tm-beans' ) . '' - ), - ), $layouts ); + if ( ! $add_default ) { + return $layouts; } + $layouts = array_merge( array( + 'default_fallback' => sprintf( + // translators: The (%s) placeholder is for the "Modify" hyperlink. + __( 'Use Default Layout (%s)', 'tm-beans' ), + '' . _x( 'Modify', 'Default layout', 'tm-beans' ) . '' + ), + ), $layouts ); + return $layouts; +} + +/** + * Check if the given layout has a primary sidebar. + * + * @since 1.5.0 + * + * @param string $layout The layout to check. + * + * @return bool + */ +function beans_has_primary_sidebar( $layout ) { + + if ( ! in_array( $layout, array( 'c_sp', 'sp_c', 'c_sp_ss', 'sp_c_ss', 'sp_ss_c' ), true ) ) { + return false; + } + + return beans_is_active_widget_area( 'sidebar_primary' ); +} + +/** + * Check if the given layout has a secondary sidebar. + * + * @since 1.5.0 + * + * @param string $layout The layout to check. + * + * @return bool + */ +function beans_has_secondary_sidebar( $layout ) { + + if ( ! in_array( $layout, array( 'c_ss', 'ss_c', 'c_sp_ss', 'sp_c_ss', 'sp_ss_c' ), true ) ) { + return false; + } + return beans_is_active_widget_area( 'sidebar_secondary' ); } diff --git a/lib/api/options/class-beans-options.php b/lib/api/options/class-beans-options.php new file mode 100644 index 00000000..79723982 --- /dev/null +++ b/lib/api/options/class-beans-options.php @@ -0,0 +1,243 @@ + __( 'Undefined', 'tm-beans' ), + 'context' => 'normal', + ); + + $this->section = $section; + $this->args = array_merge( $defaults, $args ); + + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) ); + + $this->register_metabox(); + } + + /** + * Enqueue assets. + * + * @since 1.0.0 + * + * @return void + */ + public function enqueue_assets() { + wp_enqueue_script( 'postbox' ); + } + + /** + * Register the Metabox with WordPress. + * + * @since 1.0.0 + * + * @return void + */ + private function register_metabox() { + add_meta_box( + $this->section, + $this->args['title'], + array( $this, 'render_metabox' ), + beans_get( 'page' ), + $this->args['context'], + 'default' + ); + } + + /** + * Render the metabox's content. The callback is fired by WordPress. + * + * @since 1.0.0 + * + * @return void + */ + public function render_metabox() { + $fields = beans_get_fields( 'option', $this->section ); + + if ( empty( $fields ) ) { + return; + } + + foreach ( $fields as $field ) { + beans_field( $field ); + } + } + + /** + * Render the page's (screen's) content. + * + * @since 1.0.0 + * + * @param string|WP_Screen $page The given page. + * + * @return void + */ + public function render_page( $page ) { + global $wp_meta_boxes; + + $boxes = beans_get( $page, $wp_meta_boxes ); + + if ( ! $boxes ) { + return; + } + + // Only add a column class if there is more than 1 metabox. + $column_class = beans_get( 'column', $boxes, array() ) ? ' column' : false; + + include dirname( __FILE__ ) . '/views/page.php'; + } + + /** + * Process the form's actions. + * + * @since 1.0.0 + * + * @return void + */ + public function process_actions() { + + if ( beans_post( 'beans_save_options' ) ) { + $this->save(); + add_action( 'admin_notices', array( $this, 'render_save_notice' ) ); + } + + if ( beans_post( 'beans_reset_options' ) ) { + $this->reset(); + add_action( 'admin_notices', array( $this, 'render_reset_notice' ) ); + } + } + + /** + * Save options. + * + * @since 1.0.0 + * + * @return bool + */ + private function save() { + + if ( ! wp_verify_nonce( beans_post( 'beans_options_nonce' ), 'beans_options_nonce' ) ) { + return false; + } + + $fields = beans_post( 'beans_fields' ); + + if ( ! $fields ) { + return false; + } + + foreach ( $fields as $field => $value ) { + update_option( $field, stripslashes_deep( $value ) ); + } + + $this->success = true; + } + + /** + * Reset options. + * + * @since 1.0.0 + * + * @return bool + */ + private function reset() { + + if ( ! wp_verify_nonce( beans_post( 'beans_options_nonce' ), 'beans_options_nonce' ) ) { + return false; + } + + $fields = beans_post( 'beans_fields' ); + + if ( ! $fields ) { + return false; + } + + foreach ( $fields as $field => $value ) { + delete_option( $field ); + } + + $this->success = true; + } + + /** + * Render the save notice. + * + * @since 1.0.0 + * + * @return void + */ + public function render_save_notice() { + + if ( $this->success ) { + include dirname( __FILE__ ) . '/views/save-notice-success.php'; + return; + } + + include dirname( __FILE__ ) . '/views/save-notice-error.php'; + } + + /** + * Render the reset notice. + * + * @since 1.0.0 + * + * @return void + */ + public function render_reset_notice() { + + if ( $this->success ) { + include dirname( __FILE__ ) . '/views/reset-notice-success.php'; + return; + } + + include dirname( __FILE__ ) . '/views/reset-notice-error.php'; + } +} diff --git a/lib/api/options/class.php b/lib/api/options/class.php deleted file mode 100644 index de72a922..00000000 --- a/lib/api/options/class.php +++ /dev/null @@ -1,228 +0,0 @@ - __( 'Undefined', 'tm-beans' ), - 'context' => 'normal', - ); - - $this->section = $section; - $this->args = array_merge( $defaults, $args ); - - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) ); - - $this->register_metabox(); - - } - - /** - * Enqueue assets. - */ - public function enqueue_assets() { - - wp_enqueue_script( 'postbox' ); - - } - - /** - * Register the Metabox. - */ - private function register_metabox() { - - add_meta_box( - $this->section, - $this->args['title'], - array( $this, 'metabox_content' ), - beans_get( 'page' ), - $this->args['context'], - 'default' - ); - - } - - /** - * Metabox content. - */ - public function metabox_content() { - - foreach ( beans_get_fields( 'option', $this->section ) as $field ) { - beans_field( $field ); - } - - } - - /** - * Page content. - */ - public function page( $page ) { - - global $wp_meta_boxes; - - if ( ! $boxes = beans_get( $page, $wp_meta_boxes ) ) { - return; - } - - // Only add column class if there is more than 1 metaboxes. - $column_class = beans_get( 'column', $boxes, array() ) ? ' column' : false; - - // Set page data which will be used by the postbox. - ?> -
- - - -
- -
-

- - -

-
- save(); - add_action( 'admin_notices', array( $this, 'save_notices' ) ); - - } - - if ( beans_post( 'beans_reset_options' ) ) { - - $this->reset(); - add_action( 'admin_notices', array( $this, 'reset_notices' ) ); - - } - - } - - /** - * Save options. - */ - private function save() { - - if ( ! wp_verify_nonce( beans_post( 'beans_options_nonce' ), 'beans_options_nonce' ) ) { - return false; - } - - if ( ! ( $fields = beans_post( 'beans_fields' ) ) ) { - return false; - } - - foreach ( $fields as $field => $value ) { - update_option( $field, stripslashes_deep( $value ) ); - } - - $this->success = true; - - } - - /** - * Reset options. - */ - private function reset() { - - if ( ! wp_verify_nonce( beans_post( 'beans_options_nonce' ), 'beans_options_nonce' ) ) { - return false; - } - - if ( ! ( $fields = beans_post( 'beans_fields' ) ) ) { - return false; - } - - foreach ( $fields as $field => $value ) { - delete_option( $field ); - } - - $this->success = true; - - } - - /** - * Save notice content. - */ - public function save_notices() { - - if ( $this->success ) { - ?> -
-

-
- -
-

-
- success ) { - ?> -
-

-
- -
-

-
- - * as a delimiter. Default false. + * as a delimiter. Default false. * @type array $attributes An array of attributes to add to the field. The array key defines the - * attribute name and the array value defines the attribute value. Default array. + * attribute name and the array value defines the attribute value. Default array. * @type mixed $default The default field value. Default false. * @type array $fields Must only be used for 'group' field type. The array arguments are similar to the - * {@see beans_register_fields()} $fields arguments. + * {@see beans_register_fields()} $fields arguments. * @type bool $db_group Must only be used for 'group' field types. Defines whether the group of fields - * registered should be saved as a group in the database or as individual - * entries. Default false. + * registered should be saved as a group in the database or as individual + * entries. Default false. * } * @param string $menu_slug The menu slug used by fields. * @param string $section A section id to define the group of fields. * @param array $args { * Optional. Array of arguments used to register the fields. * - * @type string $title The metabox Title. Default 'Undefined'. - * @type string $context Where on the page where the metabox should be shown - * ('normal', 'column'). Default 'normal'. + * @type string $title The metabox Title. Default 'Undefined'. + * @type string $context Where on the page where the metabox should be shown + * ('normal', 'column'). Default 'normal'. * } * * @return bool True on success, false on failure. @@ -78,13 +80,12 @@ function beans_register_options( array $fields, $menu_slug, $section, $args = ar } // Load the class only if this function is called to prevent unnecessary memory usage. - require_once( BEANS_API_PATH . 'options/class.php' ); + require_once BEANS_API_PATH . 'options/class-beans-options.php'; $class = new _Beans_Options(); $class->register( $section, $args ); return true; - } /** @@ -95,6 +96,8 @@ function beans_register_options( array $fields, $menu_slug, $section, $args = ar * @since 1.0.0 * * @param array $menu_slug The menu slug used to register the options. + * + * @return bool */ function beans_options( $menu_slug ) { @@ -103,15 +106,18 @@ function beans_options( $menu_slug ) { } $class = new _Beans_Options(); - $class->page( $menu_slug ); - + $class->render_page( $menu_slug ); } add_action( 'wp_loaded', '_beans_options_page_actions' ); /** * Fires the options form actions. * + * @since 1.0.0 * @ignore + * @access private + * + * @return void */ function _beans_options_page_actions() { @@ -120,9 +126,8 @@ function _beans_options_page_actions() { } // Load the class only if this function is called to prevent unnecessary memory usage. - require_once( BEANS_API_PATH . 'options/class.php' ); + require_once BEANS_API_PATH . 'options/class-beans-options.php'; $class = new _Beans_Options(); - $class->actions(); - + $class->process_actions(); } diff --git a/lib/api/options/views/page.php b/lib/api/options/views/page.php new file mode 100644 index 00000000..e19dc583 --- /dev/null +++ b/lib/api/options/views/page.php @@ -0,0 +1,31 @@ + + +
+ + + +
+ +
+

+ + +

+
diff --git a/lib/api/options/views/reset-notice-error.php b/lib/api/options/views/reset-notice-error.php new file mode 100644 index 00000000..83459109 --- /dev/null +++ b/lib/api/options/views/reset-notice-error.php @@ -0,0 +1,16 @@ + + +
+

+
diff --git a/lib/api/options/views/reset-notice-success.php b/lib/api/options/views/reset-notice-success.php new file mode 100644 index 00000000..439b28e9 --- /dev/null +++ b/lib/api/options/views/reset-notice-success.php @@ -0,0 +1,16 @@ + + +
+

+
diff --git a/lib/api/options/views/save-notice-error.php b/lib/api/options/views/save-notice-error.php new file mode 100644 index 00000000..d39d2e79 --- /dev/null +++ b/lib/api/options/views/save-notice-error.php @@ -0,0 +1,16 @@ + + +
+

+
diff --git a/lib/api/options/views/save-notice-success.php b/lib/api/options/views/save-notice-success.php new file mode 100644 index 00000000..a5c29ec2 --- /dev/null +++ b/lib/api/options/views/save-notice-success.php @@ -0,0 +1,16 @@ + + +
+

+
diff --git a/lib/api/post-meta/class-beans-post-meta.php b/lib/api/post-meta/class-beans-post-meta.php new file mode 100644 index 00000000..f70fbab9 --- /dev/null +++ b/lib/api/post-meta/class-beans-post-meta.php @@ -0,0 +1,194 @@ + __( 'Undefined', 'tm-beans' ), + 'context' => 'normal', + 'priority' => 'high', + ); + + $this->section = $section; + $this->args = array_merge( $defaults, $args ); + $this->do_once(); + + add_action( 'add_meta_boxes', array( $this, 'register_metabox' ) ); + } + + /** + * Trigger actions only once. + * + * @since 1.0.0 + * + * @return void + */ + private function do_once() { + static $did_once = false; + + if ( $did_once ) { + return; + } + + add_action( 'edit_form_top', array( $this, 'render_nonce' ) ); + add_action( 'save_post', array( $this, 'save' ) ); + add_filter( 'attachment_fields_to_save', array( $this, 'save_attachment' ) ); + + $did_once = true; + } + + /** + * Render post meta nonce. + * + * @since 1.0.0 + * + * @return void + */ + public function render_nonce() { + include dirname( __FILE__ ) . '/views/nonce.php'; + } + + /** + * Add the Metabox. + * + * @since 1.0.0 + * + * @param string $post_type Name of the post type. + * + * @return void + */ + public function register_metabox( $post_type ) { + add_meta_box( + $this->section, + $this->args['title'], + array( $this, 'render_metabox_content' ), + $post_type, + $this->args['context'], + $this->args['priority'] + ); + } + + /** + * Render metabox content. + * + * @since 1.0.0 + * + * @return void + */ + public function render_metabox_content() { + + foreach ( beans_get_fields( 'post_meta', $this->section ) as $field ) { + beans_field( $field ); + } + } + + /** + * Save Post Meta. + * + * @since 1.0.0 + * + * @param int $post_id Post ID. + * + * @return mixed + */ + public function save( $post_id ) { + + if ( _beans_doing_autosave() ) { + return false; + } + + $fields = beans_post( 'beans_fields' ); + + if ( ! $this->ok_to_save( $post_id, $fields ) ) { + return $post_id; + } + + foreach ( $fields as $field => $value ) { + update_post_meta( $post_id, $field, $value ); + } + } + + /** + * Save Post Meta for attachment. + * + * @since 1.0.0 + * + * @param array $attachment Attachment data. + * + * @return mixed + */ + public function save_attachment( $attachment ) { + + if ( _beans_doing_autosave() ) { + return $attachment; + } + + $fields = beans_post( 'beans_fields' ); + + if ( ! $this->ok_to_save( $attachment['ID'], $fields ) ) { + return $attachment; + } + + foreach ( $fields as $field => $value ) { + update_post_meta( $attachment['ID'], $field, $value ); + } + + return $attachment; + } + + /** + * Check if all criteria are met to safely save post meta. + * + * @param int $id The Post Id. + * @param array $fields The array of fields to save. + * + * @return bool + */ + public function ok_to_save( $id, $fields ) { + if ( ! wp_verify_nonce( beans_post( 'beans_post_meta_nonce' ), 'beans_post_meta_nonce' ) ) { + return false; + } + + if ( ! current_user_can( 'edit_post', $id ) ) { + return false; + } + + return ! empty( $fields ); + } +} diff --git a/lib/api/post-meta/class.php b/lib/api/post-meta/class.php deleted file mode 100644 index 60bf31ff..00000000 --- a/lib/api/post-meta/class.php +++ /dev/null @@ -1,140 +0,0 @@ - __( 'Undefined', 'tm-beans' ), - 'context' => 'normal', - 'priority' => 'high', - ); - - $this->section = $section; - $this->args = array_merge( $defaults, $args ); - $this->do_once(); - - add_action( 'add_meta_boxes', array( $this, 'register_metabox' ) ); - - } - - /** - * Trigger actions only once. - */ - private function do_once() { - - static $once = false; - - if ( ! $once ) { - - add_action( 'edit_form_top', array( $this, 'nonce' ) ); - add_action( 'save_post', array( $this, 'save' ) ); - add_filter( 'attachment_fields_to_save', array( $this, 'save_attachment' ) ); - - $once = true; - - } - - } - - /** - * Post meta nonce. - */ - public function nonce() { - - ?> - - section, $this->args['title'], array( $this, 'metabox_content' ), $post_type, $this->args['context'], $this->args['priority'] ); - - } - - /** - * Metabox content. - */ - public function metabox_content( $post ) { - - foreach ( beans_get_fields( 'post_meta', $this->section ) as $field ) { - beans_field( $field ); - } - } - - /** - * Save Post Meta. - */ - public function save( $post_id ) { - - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { - return false; - } - - if ( ! wp_verify_nonce( beans_post( 'beans_post_meta_nonce' ), 'beans_post_meta_nonce' ) ) { - return $post_id; - } - - if ( ! $fields = beans_post( 'beans_fields' ) ) { - return $post_id; - } - - foreach ( $fields as $field => $value ) { - update_post_meta( $post_id, $field, $value ); - } - - } - - /** - * Save Post Meta for attachment. - */ - public function save_attachment( $attachment ) { - - if ( ! wp_verify_nonce( beans_post( 'beans_post_meta_nonce' ), 'beans_post_meta_nonce' ) ) { - return $post_id; - } - - if ( ! current_user_can( 'edit_post', $attachment['ID'] ) ) { - return $attachment; - } - - if ( ! $fields = beans_post( 'beans_fields' ) ) { - return $attachment; - } - - foreach ( $fields as $field => $value ) { - update_post_meta( $attachment['ID'], $field, $value ); - } - - return $attachment; - - } -} diff --git a/lib/api/post-meta/functions-admin.php b/lib/api/post-meta/functions-admin.php index a5b0a544..97a708b8 100644 --- a/lib/api/post-meta/functions-admin.php +++ b/lib/api/post-meta/functions-admin.php @@ -1,8 +1,10 @@ - * as a delimiter. Default false. - * @type array $attributes An array of attributes to add to the field. The array key defines the - * attribute name and the array value defines the attribute value. Default array. - * @type mixed $default The default field value. Default false. - * @type array $fields Must only be used for 'group' field type. The array arguments are similar to the - * {@see beans_register_fields()} $fields arguments. - * @type bool $db_group Must only be used for 'group' field type. Defines whether the group of fields - * registered should be saved as a group in the database or as individual - * entries. Default false. + * @type string $id A unique ID used for the field. This ID will also be used to save the value in + * the database. + * @type string $type The type of field to use. Please refer to the Beans core field types for more + * information. Custom field types are accepted here. + * @type string $label The field label. Default false. + * @type string $description The field description. The description can be truncated using + * as a delimiter. Default false. + * @type array $attributes An array of attributes to add to the field. The array key defines the + * attribute name and the array value defines the attribute value. Default array. + * @type mixed $default The default field value. Default false. + * @type array $fields Must only be used for the 'group' field type. The array arguments are similar to the + * {@see beans_register_fields()} $fields arguments. + * @type bool $db_group Must only be used for the 'group' field type. Defines whether the group of fields + * registered should be saved as a group in the database or as individual + * entries. Default false. * } - * @param string|array $conditions Array of 'post types id(s)', 'post id(s)' or 'page template slug(s)' for which the post meta should be registered. - * 'page template slug(s)' must include '.php' file extention. Set to true to display everywhere. - * @param string $section A section id to define the group of fields. - * @param array $args { - * Optional. Array of arguments used to register the fields. * - * @type string $title The metabox Title. Default 'Undefined'. - * @type string $context Where on the page the metabox should be shown - * ('normal', 'advanced', or 'side'). Default 'normal'. - * @type int $priority The priority within the context where the boxes should show - * ('high', 'core', 'default' or 'low'). Default 'high'. + * @param string|array $conditions Array of 'post type ID(s)', 'post ID(s)' or 'page template slug(s)' for which the post meta should be registered. + * 'page template slug(s)' must include the '.php' file extention. Set to true to display everywhere. + * @param string $section A section ID to define the group of fields. + * @param array $args { + * Optional. Array of arguments used to register the fields. + * + * @type string $title The metabox Title. Default 'Undefined'. + * @type string $context Where on the page the metabox should be shown + * ('normal', 'advanced', or 'side'). Default 'normal'. + * @type int $priority The priority within the context where the boxes should show + * ('high', 'core', 'default' or 'low'). Default 'high'. * } * * @return bool True on success, false on failure. */ function beans_register_post_meta( array $fields, $conditions, $section, $args = array() ) { - global $_beans_post_meta_conditions; + if ( empty( $fields ) ) { + return false; + } + /** * Filter the post meta fields. * - * The dynamic portion of the hook name, $section, refers to the section id which defines the group of fields. + * The dynamic portion of the hook name, $section, refers to the section ID which defines the group of fields. * * @since 1.0.0 * @@ -64,18 +70,19 @@ function beans_register_post_meta( array $fields, $conditions, $section, $args = /** * Filter the conditions used to define whether the fields set should be displayed or not. * - * The dynamic portion of the hook name, $section, refers to the section id which defines the group of fields. + * The dynamic portion of the hook name, $section, refers to the section ID which defines the group of fields. * * @since 1.0.0 * * @param string|array $conditions Conditions used to define whether the fields set should be displayed or not. */ $conditions = apply_filters( "beans_post_meta_post_types_{$section}", $conditions ); + $_beans_post_meta_conditions = array_merge( $_beans_post_meta_conditions, (array) $conditions ); // Stop here if the current page isn't concerned. if ( ! _beans_is_post_meta_conditions( $conditions ) || ! is_admin() ) { - return; + return false; } // Stop here if the field can't be registered. @@ -84,37 +91,53 @@ function beans_register_post_meta( array $fields, $conditions, $section, $args = } // Load the class only if this function is called to prevent unnecessary memory usage. - require_once( BEANS_API_PATH . 'post-meta/class.php' ); + require_once BEANS_API_PATH . 'post-meta/class-beans-post-meta.php'; new _Beans_Post_Meta( $section, $args ); + return true; } /** * Check the current screen conditions. * + * @since 1.0.0 * @ignore + * @access private + * + * @param array|bool $conditions Conditions to show a Post Meta box. + * + * @return bool */ function _beans_is_post_meta_conditions( $conditions ) { + // If user has designated boolean true, it's always true. Nothing more to do here. + if ( true === $conditions ) { + return true; + } + // Check if it is a new post and treat it as such. if ( false !== stripos( $_SERVER['REQUEST_URI'], 'post-new.php' ) ) { + $current_post_type = beans_get( 'post_type' ); - if ( ! $current_post_type = beans_get( 'post_type' ) ) { + if ( ! $current_post_type ) { - if ( in_array( 'post', (array) $conditions ) ) { + if ( in_array( 'post', (array) $conditions, true ) ) { return true; } else { return false; } } } else { - - // Try to get id from $_GET. - if ( $id = beans_get( 'post' ) ) { - $post_id = $id; - } elseif ( $id = beans_post( 'post_ID' ) ) { // Try to get id from $_POST. - $post_id = $id; + // Try to get ID from $_GET. + $id_get = beans_get( 'post' ); + // Try to get ID from $_POST. + $id_post = beans_post( 'post_ID' ); + + if ( $id_get ) { + $post_id = $id_get; + } elseif ( $id_post ) { + $post_id = $id_post; } if ( ! isset( $post_id ) ) { @@ -122,73 +145,49 @@ function _beans_is_post_meta_conditions( $conditions ) { } $current_post_type = get_post_type( $post_id ); - } $statements = array( - true === $conditions, - in_array( $current_post_type, (array) $conditions ), // Check post type. - isset( $post_id ) && in_array( $post_id, (array) $conditions ), // Check post id. - isset( $post_id ) && in_array( get_post_meta( $post_id, '_wp_page_template', true ), (array) $conditions ), // Check page template. + in_array( $current_post_type, (array) $conditions, true ), // Check post type. + isset( $post_id ) && in_array( $post_id, (array) $conditions, true ), // Check post ID. + isset( $post_id ) && in_array( get_post_meta( $post_id, '_wp_page_template', true ), (array) $conditions, true ), // Check page template. ); // Return true if any condition is met, otherwise false. - return in_array( true, $statements ); - + return in_array( true, $statements, true ); } add_action( 'admin_print_footer_scripts', '_beans_post_meta_page_template_reload' ); /** * Reload post edit screen on page template change. * + * @since 1.0.0 * @ignore + * @access private + * + * @return void */ function _beans_post_meta_page_template_reload() { - global $_beans_post_meta_conditions, $pagenow; // Stop here if not editing a post object. - if ( ! in_array( $pagenow, array( 'post-new.php', 'post.php' ) ) ) { + if ( ! in_array( $pagenow, array( 'post-new.php', 'post.php' ), true ) ) { return; } - // Stop here of there isn't any post meta assigned to page templates. + // Stop here if there is no post meta assigned to page templates. if ( false === stripos( wp_json_encode( $_beans_post_meta_conditions ), '.php' ) ) { return; } - ?> - - + diff --git a/lib/api/post-meta/views/script.php b/lib/api/post-meta/views/script.php new file mode 100644 index 00000000..e2a00fe4 --- /dev/null +++ b/lib/api/post-meta/views/script.php @@ -0,0 +1,35 @@ + + + diff --git a/lib/api/template/functions.php b/lib/api/template/functions.php index 1b0334d8..77f871d5 100644 --- a/lib/api/template/functions.php +++ b/lib/api/template/functions.php @@ -2,20 +2,27 @@ /** * The Beans Templates API allows to load Beans template files as well as loading the entire document. * - * @package API\Templates + * @package Beans\Framework\API\Template + * + * @since 1.0.0 */ /** - * Load the entire document. + * Load and render the entire document (web page). This function is the root of the Beans' framework hierarchy. + * Therefore, when calling it, Beans runs, building the web page's HTML markup and rendering it out to the + * browser. * - * This function is the root of Beans's framework hierarchy. It must be called from a primary template file - * (e.g. page.php) and must be the last function to be called. All modifications must be done before calling - * this function. This includes modifying markup, attributes, fragments, etc. + * Here are some guidelines for calling this function: + * + * - Call it from a primary template file, e.g. single.php, page.php, home.php, archive.php, etc. + * - Do all modifications and customizations before calling this function. + * - Put this function on the last line of code in the template file. * * @since 1.0.0 + * + * @return void */ function beans_load_document() { - /** * Fires before the document is loaded. * @@ -23,14 +30,14 @@ function beans_load_document() { */ do_action( 'beans_before_load_document' ); - /** - * Fires when the document loads. - * - * This hook is the root of Beans's framework hierarchy. It all starts here! - * - * @since 1.0.0 - */ - do_action( 'beans_load_document' ); + /** + * Fires when the document loads. + * + * This hook is the root of Beans's framework hierarchy. It all starts here! + * + * @since 1.0.0 + */ + do_action( 'beans_load_document' ); /** * Fires after the document is loaded. @@ -38,11 +45,10 @@ function beans_load_document() { * @since 1.0.0 */ do_action( 'beans_after_load_document' ); - } /** - * Load Beans secondary template file. + * Loads a secondary template file. * * This function loads Beans's default template file. It must be called from a secondary template file * (e.g. comments.php) and must be the last function to be called. All modifications must be done before calling @@ -55,84 +61,93 @@ function beans_load_document() { * * @param string $file The filename of the secondary template files. __FILE__ is usually to argument to pass. * - * @return bool False if file isn't found. + * @return bool True on success, false on failure. */ function beans_load_default_template( $file ) { - $file = BEANS_STRUCTURE_PATH . basename( $file ); if ( ! file_exists( $file ) ) { return false; } - require_once( $file ); + require_once $file; + return true; } /** - * Load fragment file. + * Load the fragment file. * - * This function can be short-circuited. + * This function can be short-circuited using the filter event "beans_pre_load_fragment_". * * @since 1.0.0 * - * @param string $slug The file name to include without extension. + * @param string $fragment The fragment to load. This is its filename without the extension. * * @return bool True on success, false on failure. */ -function beans_load_fragment_file( $slug ) { +function beans_load_fragment_file( $fragment ) { /** - * Filter whether to load a fragment or not. + * Filter to allow the child theme or plugin to short-circuit this function by passing back a `true` or + * truthy value. * - * The dynamic portion of the hook name, $slug, refers to the file name without extension. Passing a truthy - * value to the filter will short-circuit loading the fragment. + * The hook's name is "beans_pre_load_fragment_" + the fragment's filename (without its extension). For example, + * the header fragment's hook name is "beans_pre_load_fragment_header". * * @since 1.0.0 * - * @param bool $pre True to short-circuit, False to let the function run. + * @param bool Set to `true` to short-circuit this function. The default is `false`. */ - if ( apply_filters( 'beans_pre_load_fragment_' . $slug, false ) ) { + if ( apply_filters( 'beans_pre_load_fragment_' . $fragment, false ) ) { return false; } - // Stop here if fragment file doesn't exists. - if ( ! file_exists( BEANS_FRAGMENTS_PATH . $slug . '.php' ) ) { + // If fragment file does not exist, bail out. + if ( ! file_exists( BEANS_FRAGMENTS_PATH . $fragment . '.php' ) ) { return false; } - require_once( BEANS_FRAGMENTS_PATH . $slug . '.php' ); + require_once BEANS_FRAGMENTS_PATH . $fragment . '.php'; return true; - } /** - * wp_list_comments callback function. + * Render the current comment's HTML markup. * - * This function adds the hooks to which the comment template part is attached to. - * are attached. + * This function is a callback that is registered to {@see wp_list_comments()}. It adds the args and depth to the + * global comment, renders the opening
  • tag, and fires the "beans_comment" event to render the comment. * * @since 1.0.0 + * + * @see wp_list_comments() + * + * @param WP_Comment $comment Instance of the current comment, i.e. which is also the global comment. + * @param array $args Array of arguments. + * @param int $depth Depth of the comment in reference to its parents. + * + * @return void */ -function beans_comment_callback( $comment, $args, $depth ) { - +function beans_comment_callback( $comment, array $args, $depth ) { + // To give us access, add the args and depth as public properties on the comment's global instance. global $comment; - - // Add args and depth to comment global. - $comment->args = $args; + $comment->args = $args; $comment->depth = $depth; - // Don't allow overwrite. - ?>
  • > tag. + $comment_class = empty( $args['has_children'] ) ? '' : 'parent'; + printf( '
  • ', + (int) get_comment_ID(), + comment_class( $comment_class, $comment, null, false ) + ); - // Don't close
  • tag. + /** + * Render the comment's HTML markup. + * + * @since 1.0.0 + */ + do_action( 'beans_comment' ); + // The tag is intentionally omitted. } diff --git a/lib/api/term-meta/class-beans-term-meta.php b/lib/api/term-meta/class-beans-term-meta.php new file mode 100644 index 00000000..40947cb4 --- /dev/null +++ b/lib/api/term-meta/class-beans-term-meta.php @@ -0,0 +1,138 @@ +section = $section; + $this->do_once(); + add_action( beans_get( 'taxonomy' ) . '_edit_form_fields', array( $this, 'render_fields' ) ); + } + + /** + * Trigger actions only once. + * + * @since 1.0.0 + * + * @return void + */ + private function do_once() { + static $did_once = false; + + if ( $did_once ) { + return; + } + + add_action( beans_get( 'taxonomy' ) . '_edit_form', array( $this, 'render_nonce' ) ); + add_action( 'edit_term', array( $this, 'save' ) ); + add_action( 'delete_term', array( $this, 'delete' ), 10, 3 ); + + $did_once = true; + } + + /** + * Render term meta nonce. + * + * @since 1.0.0 + * + * @return void + */ + public function render_nonce() { + include dirname( __FILE__ ) . '/views/nonce.php'; + } + + /** + * Render fields content. + * + * @since 1.0.0 + * + * @return void + */ + public function render_fields() { + beans_remove_action( 'beans_field_label' ); + beans_modify_action_hook( 'beans_field_description', 'beans_field_wrap_after_markup' ); + beans_modify_markup( 'beans_field_description', 'p' ); + beans_add_attribute( 'beans_field_description', 'class', 'description' ); + + foreach ( beans_get_fields( 'term_meta', $this->section ) as $field ) { + include dirname( __FILE__ ) . '/views/term-meta-field.php'; + } + } + + /** + * Save Term Meta. + * + * @since 1.0.0 + * + * @param int $term_id Term ID. + * + * @return null|int Null on success or Term ID on fail. + */ + public function save( $term_id ) { + + if ( _beans_doing_ajax() ) { + return $term_id; + } + + if ( ! wp_verify_nonce( beans_post( 'beans_term_meta_nonce' ), 'beans_term_meta_nonce' ) ) { + return $term_id; + } + + $fields = beans_post( 'beans_fields' ); + + if ( ! $fields ) { + return $term_id; + } + + foreach ( $fields as $field => $value ) { + update_option( "beans_term_{$term_id}_{$field}", stripslashes_deep( $value ) ); + } + } + + /** + * Delete Term Meta. + * + * @since 1.0.0 + * + * @param int $term_id Term ID. + * + * @return void + */ + public function delete( $term_id ) { + global $wpdb; + + $wpdb->query( + $wpdb->prepare( + "DELETE FROM $wpdb->options WHERE option_name LIKE %s", + "beans_term_{$term_id}_%" + ) + ); + } +} diff --git a/lib/api/term-meta/class.php b/lib/api/term-meta/class.php deleted file mode 100644 index 88c62575..00000000 --- a/lib/api/term-meta/class.php +++ /dev/null @@ -1,122 +0,0 @@ -section = $section; - $this->do_once(); - - add_action( beans_get( 'taxonomy' ). '_edit_form_fields', array( $this, 'fields' ) ); - - } - - /** - * Trigger actions only once. - */ - private function do_once() { - - static $once = false; - - if ( ! $once ) { - - add_action( beans_get( 'taxonomy' ). '_edit_form', array( $this, 'nonce' ) ); - add_action( 'edit_term', array( $this, 'save' ) ); - add_action( 'delete_term', array( $this, 'delete' ), 10, 3 ); - - $once = true; - - } - - } - - /** - * Post meta nonce. - */ - public function nonce( $tag ) { - - ?> - section ) as $field ) { - - ?> - - - - - - - - - $value ) { - update_option( "beans_term_{$term_id}_{$field}", stripslashes_deep( $value ) ); - } - - } - - /** - * Delete Term Meta. - */ - public function delete( $term, $term_id, $taxonomy ) { - - global $wpdb; - - $wpdb->query( $wpdb->prepare( - "DELETE FROM $wpdb->options WHERE option_name LIKE %s", - "beans_term_{$term_id}_%" - ) ); - - } -} diff --git a/lib/api/term-meta/functions-admin.php b/lib/api/term-meta/functions-admin.php index 97c5a3b5..9f60e300 100644 --- a/lib/api/term-meta/functions-admin.php +++ b/lib/api/term-meta/functions-admin.php @@ -1,8 +1,10 @@ - * as a delimiter. Default false. + * as a delimiter. Default false. * @type array $attributes An array of attributes to add to the field. The array key defines the - * attribute name and the array value defines the attribute value. Default array. + * attribute name and the array value defines the attribute value. Default array. * @type mixed $default The default field value. Default false. * @type array $fields Must only be used for the 'group' field type. The array arguments are similar to the - * {@see beans_register_fields()} $fields arguments. + * {@see beans_register_fields()} $fields arguments. * @type bool $db_group Must only be used for 'group' field type. Defines whether the group of fields - * registered should be saved as a group in the database or as individual - * entries. Default false. + * registered should be saved as a group in the database or as individual + * entries. Default false. * } * @param string|array $taxonomies Array of taxonomies for which the term meta should be registered. * @param string $section A section id to define the group of fields. @@ -62,7 +64,7 @@ function beans_register_term_meta( array $fields, $taxonomies, $section ) { // Stop here if the current page isn't concerned. if ( ! _beans_is_admin_term( $taxonomies ) || ! is_admin() ) { - return; + return false; } // Stop here if the field can't be registered. @@ -71,31 +73,34 @@ function beans_register_term_meta( array $fields, $taxonomies, $section ) { } // Load the class only if this function is called to prevent unnecessary memory usage. - require_once( BEANS_API_PATH . 'term-meta/class.php' ); + require_once BEANS_API_PATH . 'term-meta/class-beans-term-meta.php'; new _Beans_Term_Meta( $section ); + return true; } /** * Check if the current screen is a given term. * + * @since 1.0.0 * @ignore + * @access private + * + * @param array|bool $taxonomies Array of taxonomies or true for all taxonomies. + * + * @return bool */ function _beans_is_admin_term( $taxonomies ) { - - if ( ! $taxonomy = beans_get_or_post( 'taxonomy' ) ) { - return false; - } - if ( true === $taxonomies ) { return true; } - if ( in_array( $taxonomy, (array) $taxonomies ) ) { - return true; - } + $taxonomy = beans_get_or_post( 'taxonomy' ); - return false; + if ( empty( $taxonomy ) ) { + return false; + } + return in_array( $taxonomy, (array) $taxonomies, true ); } diff --git a/lib/api/term-meta/functions.php b/lib/api/term-meta/functions.php index bc961a1e..291f07ce 100644 --- a/lib/api/term-meta/functions.php +++ b/lib/api/term-meta/functions.php @@ -1,6 +1,10 @@ + diff --git a/lib/api/term-meta/views/term-meta-field.php b/lib/api/term-meta/views/term-meta-field.php new file mode 100644 index 00000000..cba0aca1 --- /dev/null +++ b/lib/api/term-meta/views/term-meta-field.php @@ -0,0 +1,20 @@ + + + + + + + + + diff --git a/lib/api/uikit/class-beans-uikit.php b/lib/api/uikit/class-beans-uikit.php new file mode 100644 index 00000000..a8a389bb --- /dev/null +++ b/lib/api/uikit/class-beans-uikit.php @@ -0,0 +1,421 @@ +compile_styles(); + $this->compile_scripts(); + } + + /** + * Compile the styles. + * + * @since 1.5.0 + * + * @return void + */ + private function compile_styles() { + /** + * Filter UIkit enqueued style components. + * + * @since 1.0.0 + * + * @param array $components An array of UIkit style component files. + */ + $styles = apply_filters( 'beans_uikit_euqueued_styles', $this->register_less_components() ); + + // If there are no styles to compile, bail out. + if ( empty( $styles ) ) { + return; + } + + /** + * Filter UIkit style compiler arguments. + * + * @since 1.0.0 + * + * @param array $components An array of UIkit style compiler arguments. + */ + $args = apply_filters( 'beans_uikit_euqueued_styles_args', array() ); + + beans_compile_less_fragments( 'uikit', array_unique( $styles ), $args ); + } + + /** + * Compile the scripts. + * + * @since 1.5.0 + * + * @return void + */ + private function compile_scripts() { + /** + * Filter UIkit enqueued script components. + * + * @since 1.0.0 + * + * @param array $components An array of UIkit script component files. + */ + $scripts = apply_filters( 'beans_uikit_euqueued_scripts', $this->register_js_components() ); + + // If there are no scripts to compile, bail out. + if ( empty( $scripts ) ) { + return; + } + + /** + * Filter UIkit script compiler arguments. + * + * @since 1.0.0 + * + * @param array $components An array of UIkit script compiler arguments. + */ + $args = apply_filters( + 'beans_uikit_euqueued_scripts_args', + array( + 'dependencies' => array( 'jquery' ), + ) + ); + + beans_compile_js_fragments( 'uikit', array_unique( $scripts ), $args ); + } + + /** + * Register less components. + * + * @since 1.0.0 + * + * @return array + */ + public function register_less_components() { + $components = $this->get_registered_component_paths( array( 'variables' ) ); + + if ( empty( $components ) ) { + return array(); + } + + // Add fixes. + $components[] = BEANS_API_PATH . 'uikit/src/fixes.less'; + + return $components; + } + + /** + * Register JavaScript components. + * + * @since 1.0.0 + * + * @return array + */ + public function register_js_components() { + return $this->get_registered_component_paths( array( 'core', 'utility', 'touch' ), false ); + } + + /** + * Get an array of registered component paths, i.e. absolute path to each component file. + * + * @since 1.5.0 + * + * @param array $core_components Array of core components. + * @param bool $is_less Optional. When true, get the registered LESS components; else, get the + * registered JavaScript components. + * + * @return array + */ + private function get_registered_component_paths( array $core_components, $is_less = true ) { + global $_beans_uikit_enqueued_items; + + $components = array(); + + foreach ( $_beans_uikit_enqueued_items['components'] as $type => $items ) { + + // Add core before the components. + if ( 'core' === $type ) { + $items = array_merge( $core_components, $items ); + } + + // Fetch components from directories. + $component_directories = $this->get_components_from_directory( + $items, + $is_less ? $this->get_less_directories( $type ) : $this->get_js_directories( $type ), + $is_less ? 'styles' : 'scripts' + ); + beans_join_arrays( $components, $component_directories ); + } + + return $components; + } + + /** + * Get LESS directories. + * + * @since 1.0.0 + * + * @param string $type Type of the UIkit components. + * + * @return array + */ + public function get_less_directories( $type ) { + + if ( 'add-ons' === $type ) { + $type = 'components'; + } + + global $_beans_uikit_enqueued_items; + + // Define the UIkit src directory. + $directories = array( BEANS_API_PATH . 'uikit/src/less/' . $type ); + + // Add the registered theme directories. + foreach ( $_beans_uikit_enqueued_items['themes'] as $id => $directory ) { + $directories[] = wp_normalize_path( untrailingslashit( $directory ) ); + } + + return $directories; + } + + /** + * Get JavaScript directories. + * + * @since 1.0.0 + * + * @param string $type Type. + * + * @return array + */ + public function get_js_directories( $type ) { + + if ( 'add-ons' === $type ) { + $type = 'components'; + } + + // Define the UIkit src directory. + return array( BEANS_API_PATH . 'uikit/src/js/' . $type ); + } + + /** + * Get components from directories. + * + * @since 1.0.0 + * + * @param array $components Array of UIkit Components. + * @param array $directories Array of directories containing the UIkit Components. + * @param string $format File format. + * + * @return array + */ + public function get_components_from_directory( array $components, array $directories, $format ) { + + if ( empty( $components ) ) { + return array(); + } + + $extension = 'styles' === $format ? 'less' : 'min.js'; + + $return = array(); + + foreach ( $components as $component ) { + + // Fetch the components from all directories set. + foreach ( $directories as $directory ) { + $file = trailingslashit( $directory ) . $component . '.' . $extension; + + // Make sure the file exists. + if ( is_readable( $file ) ) { + $return[] = $file; + } + } + } + + return $return; + } + + /** + * Get all components. + * + * @since 1.0.0 + * + * @param string $type Type of UIkit components ('core' or 'add-ons'). + * + * @return array + */ + public function get_all_components( $type ) { + // Fetch all directories. + $directories = array_merge( $this->get_less_directories( $type ), $this->get_js_directories( $type ) ); + + $components = array(); + + foreach ( $directories as $dir_path ) { + + if ( ! is_dir( $dir_path ) ) { + continue; + } + + // Build an array of component names (i.e. filenames only). + $component_names = array_map( array( $this, 'to_filename' ), $this->get_all_files( $dir_path ) ); + + beans_join_arrays( $components, $component_names ); + } + + // Clean up by removing duplicates and empties. + return array_filter( beans_array_unique( $components ) ); + } + + /** + * Get all of the files and folders from the given directory. When on a Linux-based machine, + * removes the '.' and '..' files. + * + * @since 1.5.0 + * + * @param string $directory Absolute path to the source directory. + * + * @return array + */ + private function get_all_files( $directory ) { + return beans_scandir( $directory ); + } + + /** + * Get all of the required dependencies for the given components. + * + * @since 1.0.0 + * + * @param array $components The given components to search for dependencies. + * + * @return array + */ + public function get_autoload_components( array $components ) { + $dependencies = array( + 'core' => array(), + 'add-ons' => array(), + ); + + $this->init_component_dependencies(); + + // Build dependencies for each component. + foreach ( (array) $components as $component ) { + $component_dependencies = beans_get( $component, self::$configured_components_dependencies, array() ); + + foreach ( $component_dependencies as $type => $dependency ) { + $dependencies[ $type ] = array_merge( $dependencies[ $type ], $dependency ); + } + } + + return $this->remove_duplicate_values( $dependencies ); + } + + /** + * Removes duplicate values from the given source array. + * + * @since 1.5.0 + * + * @param array $source The given array to iterate and remove duplicate values. + * + * @return array + */ + private function remove_duplicate_values( array $source ) { + + foreach ( $source as $key => $value ) { + + if ( empty( $value ) || ! is_array( $value ) ) { + continue; + } + + $source[ $key ] = beans_array_unique( $value ); + } + + return $source; + } + + /** + * Initialize the components' dependencies, by loading from its configuration file when null. + * + * @since 1.5.0 + * + * @return void + */ + private function init_component_dependencies() { + + if ( ! is_null( self::$configured_components_dependencies ) ) { + return; + } + + self::$configured_components_dependencies = require dirname( __FILE__ ) . '/config/component-dependencies.php'; + } + + /** + * Convert component to a filename. + * + * @since 1.0.0 + * + * @param string $file File name. + * + * @return null|string + */ + public function to_filename( $file ) { + $pathinfo = pathinfo( $file ); + + // If the given file is not valid, bail out. + if ( ! isset( $pathinfo['filename'] ) ) { + return null; + } + + // Stop here if it isn't a valid file or if it should be ignored. + if ( $this->ignore_component( $pathinfo['filename'] ) ) { + return null; + } + + // Return the filename without the .min to avoid duplicates. + return str_replace( '.min', '', $pathinfo['filename'] ); + } + + /** + * Checks if the given component's filename should be ignored. + * + * @since 1.5.0 + * + * @param string $filename The filename to check against the ignored components. + * + * @return bool + */ + private function ignore_component( $filename ) { + return in_array( $filename, $this->ignored_components, true ); + } +} diff --git a/lib/api/uikit/class.php b/lib/api/uikit/class.php deleted file mode 100644 index 257fb688..00000000 --- a/lib/api/uikit/class.php +++ /dev/null @@ -1,354 +0,0 @@ -register_less_components() ); - - /** - * Filter UIkit enqueued script components. - * - * @since 1.0.0 - * - * @param array $components An array of UIkit script component files. - */ - $scripts = apply_filters( 'beans_uikit_euqueued_scripts', $this->register_js_components() ); - - /** - * Filter UIkit style compiler arguments. - * - * @since 1.0.0 - * - * @param array $components An array of UIkit style compiler arguments. - */ - $styles_args = apply_filters( 'beans_uikit_euqueued_styles_args', array() ); - - /** - * Filter UIkit script compiler arguments. - * - * @since 1.0.0 - * - * @param array $components An array of UIkit script compiler arguments. - */ - $scripts_args = apply_filters( 'beans_uikit_euqueued_scripts_args', array( - 'depedencies' => array( 'jquery' ), - ) ); - - // Compile less. - if ( $styles ) { - beans_compile_less_fragments( 'uikit', array_unique( $styles ), $styles_args ); - } - - // Compile js. - if ( $scripts ) { - beans_compile_js_fragments( 'uikit', array_unique( $scripts ), $scripts_args ); - } - - } - - /** - * Register less components. - */ - function register_less_components() { - - global $_beans_uikit_enqueued_items; - - $components = array(); - - foreach ( $_beans_uikit_enqueued_items['components'] as $type => $items ) { - - // Add core before the components. - if ( 'core' == $type ) { - $items = array_merge( array( 'variables' ), $items ); - } - - // Fetch components from directories. - $components = array_merge( $components, $this->get_components_from_directory( $items, $this->get_less_directories( $type ), 'styles' ) ); - - } - - // Add fixes. - if ( ! empty( $components ) ) { - $components = array_merge( $components, array( BEANS_API_PATH . 'uikit/src/fixes.less' ) ); - } - - return $components; - - } - - /** - * Register js components. - */ - function register_js_components() { - - global $_beans_uikit_enqueued_items; - - $components = array(); - - foreach ( $_beans_uikit_enqueued_items['components'] as $type => $items ) { - - // Add core before the components. - if ( 'core' == $type ) { - $items = array_merge( - array( - 'core', - 'component', - 'utility', - 'touch', - ), - $items - ); - } - - // Fetch components from directories. - $components = array_merge( $components, $this->get_components_from_directory( $items, $this->get_js_directories( $type ), 'scripts' ) ); - - } - - return $components; - - } - - /** - * Get LESS directories. - */ - function get_less_directories( $type ) { - - if ( 'add-ons' == $type ) { - $type = 'components'; - } - - global $_beans_uikit_enqueued_items; - - // Define uikit src directory. - $directories = array( BEANS_API_PATH . 'uikit/src/less/' . $type ); - - // Add the registered theme directories. - foreach ( $_beans_uikit_enqueued_items['themes'] as $id => $directory ) { - $directories[] = wp_normalize_path( untrailingslashit( $directory ) ); - } - - return $directories; - - } - - /** - * Get JS directories. - */ - function get_js_directories( $type ) { - - if ( 'add-ons' == $type ) { - $type = 'components'; - } - - // Define uikit src directory. - return array( BEANS_API_PATH . 'uikit/src/js/' . $type ); - - } - - /** - * Get components from directories. - */ - function get_components_from_directory( $components, $directories, $format ) { - - $extension = ( 'styles' == $format ) ? 'less' : 'min.js'; - - $return = array(); - - foreach ( $components as $component ) { - - // Fectch components from all directories set. - foreach ( $directories as $directory ) { - - $file = trailingslashit( $directory ) . $component . '.' . $extension; - - // Make sure the file exists. - if ( file_exists( $file ) ) { - $return[] = $file; - } - } - } - - return $return; - - } - - /** - * Get all components. - */ - function get_all_components( $type ) { - - // Fetch all directories. - $directories = array_merge( $this->get_less_directories( $type ), $this->get_js_directories( $type ) ); - - $components = array(); - - foreach ( $directories as $dir_path ) { - - if ( ! is_dir( $dir_path ) ) { - continue; - } - - $scandir = scandir( $dir_path ); - - // Unset scandir defaults. - unset( $scandir[0], $scandir[1] ); - - // Only return the filname and remove empty elements. - $components = array_merge( $components, array_filter( array_map( array( $this, 'to_filename' ), $scandir ) ) ); - - } - - return $components; - - } - - /** - * Auto detect components required. - */ - function get_autoload_components( $components ) { - - $autoload = array( - 'core' => array(), - 'add-ons' => array(), - ); - - $depedencies = array( - 'panel' => array( - 'core' => array( - 'badge', - ), - ), - 'cover' => array( - 'core' => array( - 'flex', - ), - ), - 'overlay' => array( - 'core' => array( - 'flex', - ), - ), - 'tab' => array( - 'core' => array( - 'switcher', - ), - ), - 'modal' => array( - 'core' => array( - 'close', - ), - ), - 'scrollspy' => array( - 'core' => array( - 'animation', - ), - ), - 'lightbox' => array( - 'core' => array( - 'animation', - 'flex', - 'close', - 'modal', - 'overlay', - ), - 'add-ons' => array( - 'slidenav', - ), - ), - 'slider' => array( - 'add-ons' => array( - 'slidenav', - ), - ), - 'slideset' => array( - 'core' => array( - 'animation', - 'flex', - ), - 'add-ons' => array( - 'dotnav', - 'slidenav', - ), - ), - 'slideshow' => array( - 'core' => array( - 'animation', - 'flex', - ), - 'add-ons' => array( - 'dotnav', - 'slidenav', - ), - ), - 'parallax' => array( - 'core' => array( - 'flex', - ), - ), - 'notify' => array( - 'core' => array( - 'close', - ), - ), - ); - - foreach ( (array) $components as $component ) { - - $this_depedencies = beans_get( $component, $depedencies, array() ); - - foreach ( $this_depedencies as $depedency ) { - $autoload['core'] = array_merge( $autoload['core'], array_flip( beans_get( 'core', $this_depedencies, array() ) ) ); - $autoload['add-ons'] = array_merge( $autoload['add-ons'], array_flip( beans_get( 'add-ons', $this_depedencies, array() ) ) ); - } - } - - // Format autoload back to associative key value array. - $autoload['core'] = array_flip( $autoload['core'] ); - $autoload['add-ons'] = array_flip( $autoload['add-ons'] ); - - return $autoload; - - } - - /** - * Convert component to a filename. - */ - function to_filename( $file ) { - - $pathinfo = pathinfo( $file ); - - $ignore = array( - 'uikit-customizer', - 'uikit', - ); - - // Stop here if it isn't a valid file or if it should be ignored. - if ( ! isset( $pathinfo['filename'] ) || in_array( $pathinfo['filename'], $ignore ) ) { - return null; - } - - // Return the filename without the .min to avoid duplicates. - return str_replace( '.min', '', $pathinfo['filename'] ); - - } -} diff --git a/lib/api/uikit/config/component-dependencies.php b/lib/api/uikit/config/component-dependencies.php new file mode 100644 index 00000000..e46c337e --- /dev/null +++ b/lib/api/uikit/config/component-dependencies.php @@ -0,0 +1,88 @@ + array( + 'core' => array( + 'flex', + ), + ), + 'lightbox' => array( + 'core' => array( + 'animation', + 'flex', + 'close', + 'modal', + 'overlay', + ), + 'add-ons' => array( + 'slidenav', + ), + ), + 'modal' => array( + 'core' => array( + 'close', + ), + ), + 'notify' => array( + 'core' => array( + 'close', + ), + ), + 'overlay' => array( + 'core' => array( + 'flex', + ), + ), + 'panel' => array( + 'core' => array( + 'badge', + ), + ), + 'parallax' => array( + 'core' => array( + 'flex', + ), + ), + 'scrollspy' => array( + 'core' => array( + 'animation', + ), + ), + 'slider' => array( + 'add-ons' => array( + 'slidenav', + ), + ), + 'slideset' => array( + 'core' => array( + 'animation', + 'flex', + ), + 'add-ons' => array( + 'dotnav', + 'slidenav', + ), + ), + 'slideshow' => array( + 'core' => array( + 'animation', + 'flex', + ), + 'add-ons' => array( + 'dotnav', + 'slidenav', + ), + ), + 'tab' => array( + 'core' => array( + 'switcher', + ), + ), +); diff --git a/lib/api/uikit/functions.php b/lib/api/uikit/functions.php index 888c7da0..f5d62d35 100644 --- a/lib/api/uikit/functions.php +++ b/lib/api/uikit/functions.php @@ -2,14 +2,16 @@ /** * The Beans UIkit component integrates the awesome {@link https://getuikit.com/v2/ UIkit 2 framework}. * - * Only the desired components are compiled into a single cached file and may be different on a per page basis. UIkit - * default or custom themes can be enqueued to the UIkit compiler. All UIkit LESS variables are accessible + * Only the selected components are compiled into a single cached file and can be different on a per page basis. + * UIkit default or custom themes can be enqueued to the UIkit compiler. All UIkit LESS variables are accessible * and overwritable via custom themes. * - * When development mode is enabled, files changes will automatically be detected. This makes it very easy + * When development mode is enabled, file changes will automatically be detected. This makes it very easy * to style UIkit themes using LESS. * - * @package API\UIkit + * @package Beans\Framework\API\UIkit + * + * @since 1.0.0 */ /** @@ -18,42 +20,33 @@ * Enqueued components will be compiled into a single file. Refer to * {@link https://getuikit.com/v2/ UIkit 2} to learn more about the available components. * - * When development mode is enabled, files changes will automatically be detected. This makes it very easy + * When development mode is enabled, file changes will automatically be detected. This makes it very easy * to style UIkit themes using LESS. * * This function must be called in the 'beans_uikit_enqueue_scripts' action hook. * * @since 1.0.0 * - * @param string|array $components Name of the component(s) to include as an indexed array. The name(s) must be - * the UIkit component filename without the extention (e.g. 'grid'). Set to true - * load all components. - * @param string $type Optional. Type of UIkit components ('core' or 'add-ons'). - * @param bool $autoload Optional. Automatically include components dependencies. + * @param string|array|bool $components Name of the component(s) to include as an indexed array. The name(s) must be + * the UIkit component filename without the extension (e.g. 'grid'). Set to true + * to load all components. + * @param string $type Optional. Type of UIkit components ('core' or 'add-ons'). + * @param bool $autoload Optional. Automatically include components dependencies. + * + * @return void */ function beans_uikit_enqueue_components( $components, $type = 'core', $autoload = true ) { - global $_beans_uikit_enqueued_items; // Get all uikit components. if ( true === $components ) { - - $uikit = new _Beans_Uikit; - $components = $uikit->get_all_components( $type ); - + $components = beans_uikit_get_all_components( $type ); } elseif ( $autoload ) { - - $uikit = new _Beans_Uikit; - $autoloads = $uikit->get_autoload_components( (array) $components ); - - foreach ( $autoloads as $autotype => $autoload ) { - beans_uikit_enqueue_components( $autoload, $autotype, false ); - } + _beans_uikit_autoload_dependencies( $components ); } - // Add components. - $_beans_uikit_enqueued_items['components'][ $type ] = array_merge( (array) $_beans_uikit_enqueued_items['components'][ $type ], (array) $components ); - + // Add components into the registry. + $_beans_uikit_enqueued_items['components'][ $type ] = beans_join_arrays_clean( (array) $_beans_uikit_enqueued_items['components'][ $type ], (array) $components ); } /** @@ -62,7 +55,7 @@ function beans_uikit_enqueue_components( $components, $type = 'core', $autoload * Dequeued components are removed from the UIkit compiler. Refer to * {@link https://getuikit.com/v2/ UIkit 2} to learn more about the available components. * - * When development mode is enabled, files changes will automatically be detected. This makes it very easy + * When development mode is enabled, file changes will automatically be detected. This makes it very easy * to style UIkit themes using LESS. * * This function must be called in the 'beans_uikit_enqueue_scripts' action hook. @@ -71,23 +64,23 @@ function beans_uikit_enqueue_components( $components, $type = 'core', $autoload * * @param string|array $components Name of the component(s) to exclude as an indexed array. The name(s) must be * the UIkit component filename without the extention (e.g. 'grid'). Set to true - * exclude all components. + * to exclude all components. * @param string $type Optional. Type of UIkit components ('core' or 'add-ons'). + * + * @return void */ function beans_uikit_dequeue_components( $components, $type = 'core' ) { - global $_beans_uikit_enqueued_items; + // When true, remove all of the components from the registry. if ( true === $components ) { + $_beans_uikit_enqueued_items['components'][ $type ] = array(); - $uikit = new _Beans_Uikit; - $components = $uikit->get_all_components( $type ); - + return; } // Remove components. $_beans_uikit_enqueued_items['components'][ $type ] = array_diff( (array) $_beans_uikit_enqueued_items['components'][ $type ], (array) $components ); - } /** @@ -106,7 +99,6 @@ function beans_uikit_dequeue_components( $components, $type = 'core' ) { * @return bool False on error or if already exists, true on success. */ function beans_uikit_register_theme( $id, $path ) { - global $_beans_uikit_registered_items; // Stop here if already registered. @@ -118,14 +110,13 @@ function beans_uikit_register_theme( $id, $path ) { return false; } - if ( false !== stripos( $path, 'http' ) ) { + if ( beans_str_starts_with( $path, 'http' ) ) { $path = beans_url_to_path( $path ); } $_beans_uikit_registered_items['themes'][ $id ] = trailingslashit( $path ); return true; - } /** @@ -155,7 +146,6 @@ function beans_uikit_enqueue_theme( $id, $path = false ) { $_beans_uikit_enqueued_items['themes'][ $id ] = _beans_uikit_get_registered_theme( $id ); return true; - } /** @@ -167,20 +157,68 @@ function beans_uikit_enqueue_theme( $id, $path = false ) { * * @param string $id The id of the theme to dequeue. * - * @return bool Will always return true. + * @return void */ function beans_uikit_dequeue_theme( $id ) { - global $_beans_uikit_enqueued_items; - unset( $_beans_uikit_enqueued_items['themes'][ $id ] ); +} +/** + * Get all of the UIkit components for the given type, i.e. for core or add-ons. + * + * @since 1.5.0 + * + * @param string $type Optional. Type of UIkit components ('core' or 'add-ons'). + * + * @return array + */ +function beans_uikit_get_all_components( $type = 'core' ) { + $uikit = new _Beans_Uikit(); + + return $uikit->get_all_components( $type ); +} + +/** + * Get all of the UIkit dependencies for the given component(s). + * + * @since 1.5.0 + * + * @param string|array $components Name of the component(s) to process. The name(s) must be + * the UIkit component filename without the extension (e.g. 'grid'). + * + * @return array + */ +function beans_uikit_get_all_dependencies( $components ) { + $uikit = new _Beans_Uikit(); + + return $uikit->get_autoload_components( (array) $components ); +} + +/** + * Autoload all the component dependencies. + * + * @since 1.5.0 + * @ignore + * @access private + * + * @param string|array $components Name of the component(s) to include as an indexed array. The name(s) must be + * the UIkit component filename without the extension (e.g. 'grid'). + * + * @return void + */ +function _beans_uikit_autoload_dependencies( $components ) { + + foreach ( beans_uikit_get_all_dependencies( $components ) as $type => $autoload ) { + beans_uikit_enqueue_components( $autoload, $type, false ); + } } /** * Initialize registered UIkit items global. * * @ignore + * @access private */ global $_beans_uikit_registered_items; @@ -199,6 +237,7 @@ function beans_uikit_dequeue_theme( $id ) { * Initialize enqueued UIkit items global. * * @ignore + * @access private */ global $_beans_uikit_enqueued_items; @@ -213,28 +252,31 @@ function beans_uikit_dequeue_theme( $id ) { } /** - * Get registered theme. + * Get the path for the given theme ID, if the theme is registered. * + * @since 1.0.0 * @ignore + * @access private + * + * @param string $id The theme ID to get. + * + * @return string|bool Returns false if the theme is not registered. */ function _beans_uikit_get_registered_theme( $id ) { - global $_beans_uikit_registered_items; - // Stop here if is already registered. - if ( $theme = beans_get( $id, $_beans_uikit_registered_items['themes'] ) ) { - return $theme; - } - - return false; - + return beans_get( $id, $_beans_uikit_registered_items['themes'], false ); } add_action( 'wp_enqueue_scripts', '_beans_uikit_enqueue_assets', 7 ); /** * Enqueue UIkit assets. * + * @since 1.0.0 * @ignore + * @access private + * + * @return void */ function _beans_uikit_enqueue_assets() { @@ -250,17 +292,19 @@ function _beans_uikit_enqueue_assets() { do_action( 'beans_uikit_enqueue_scripts' ); // Compile everything. - $uikit = new _Beans_Uikit; - + $uikit = new _Beans_Uikit(); $uikit->compile(); - } add_action( 'admin_enqueue_scripts', '_beans_uikit_enqueue_admin_assets', 7 ); /** * Enqueue UIkit admin assets. * + * @since 1.0.0 * @ignore + * @access private + * + * @return void */ function _beans_uikit_enqueue_admin_assets() { @@ -276,8 +320,6 @@ function _beans_uikit_enqueue_admin_assets() { do_action( 'beans_uikit_admin_enqueue_scripts' ); // Compile everything. - $uikit = new _Beans_Uikit; - + $uikit = new _Beans_Uikit(); $uikit->compile(); - } diff --git a/lib/api/uikit/src/fonts/FontAwesome.otf b/lib/api/uikit/src/fonts/FontAwesome.otf index f7f9eaef..401ec0f3 100755 Binary files a/lib/api/uikit/src/fonts/FontAwesome.otf and b/lib/api/uikit/src/fonts/FontAwesome.otf differ diff --git a/lib/api/uikit/src/fonts/fontawesome-webfont.ttf b/lib/api/uikit/src/fonts/fontawesome-webfont.ttf index cec09e00..35acda2f 100755 Binary files a/lib/api/uikit/src/fonts/fontawesome-webfont.ttf and b/lib/api/uikit/src/fonts/fontawesome-webfont.ttf differ diff --git a/lib/api/uikit/src/fonts/fontawesome-webfont.woff b/lib/api/uikit/src/fonts/fontawesome-webfont.woff index 52d81165..400014a4 100755 Binary files a/lib/api/uikit/src/fonts/fontawesome-webfont.woff and b/lib/api/uikit/src/fonts/fontawesome-webfont.woff differ diff --git a/lib/api/uikit/src/fonts/fontawesome-webfont.woff2 b/lib/api/uikit/src/fonts/fontawesome-webfont.woff2 index 65aeb01e..4d13fc60 100755 Binary files a/lib/api/uikit/src/fonts/fontawesome-webfont.woff2 and b/lib/api/uikit/src/fonts/fontawesome-webfont.woff2 differ diff --git a/lib/api/uikit/src/js/components/accordion.min.js b/lib/api/uikit/src/js/components/accordion.min.js index d953a084..42e57f96 100755 --- a/lib/api/uikit/src/js/components/accordion.min.js +++ b/lib/api/uikit/src/js/components/accordion.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var i;window.UIkit&&(i=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-accordion",["uikit"],function(){return i||t(UIkit)})}(function(t){"use strict";function i(i){var e=t.$(i),o="auto";if(e.is(":visible"))o=e.outerHeight();else{var a={position:e.css("position"),visibility:e.css("visibility"),display:e.css("display")};o=e.css({position:"absolute",visibility:"hidden",display:"block"}).outerHeight(),e.css(a)}return o}return t.component("accordion",{defaults:{showfirst:!0,collapse:!0,animate:!0,easing:"swing",duration:300,toggle:".uk-accordion-title",containers:".uk-accordion-content",clsactive:"uk-active"},boot:function(){t.ready(function(i){setTimeout(function(){t.$("[data-uk-accordion]",i).each(function(){var i=t.$(this);i.data("accordion")||t.accordion(i,t.Utils.options(i.attr("data-uk-accordion")))})},0)})},init:function(){var i=this;this.element.on("click.uk.accordion",this.options.toggle,function(e){e.preventDefault(),i.toggleItem(t.$(this).data("wrapper"),i.options.animate,i.options.collapse)}),this.update(!0),t.domObserve(this.element,function(){i.element.children(i.options.containers).length&&i.update()})},toggleItem:function(e,o,a){var n=this;e.data("toggle").toggleClass(this.options.clsactive),e.data("content").toggleClass(this.options.clsactive);var s=e.data("toggle").hasClass(this.options.clsactive);a&&(this.toggle.not(e.data("toggle")).removeClass(this.options.clsactive),this.content.not(e.data("content")).removeClass(this.options.clsactive).parent().stop().css("overflow","hidden").animate({height:0},{easing:this.options.easing,duration:o?this.options.duration:0}).attr("aria-expanded","false")),e.stop().css("overflow","hidden"),o?e.animate({height:s?i(e.data("content")):0},{easing:this.options.easing,duration:this.options.duration,complete:function(){s&&(e.css({overflow:"",height:"auto"}),t.Utils.checkDisplay(e.data("content"))),n.trigger("display.uk.check")}}):(e.height(s?"auto":0),s&&(e.css({overflow:""}),t.Utils.checkDisplay(e.data("content"))),this.trigger("display.uk.check")),e.attr("aria-expanded",s),this.element.trigger("toggle.uk.accordion",[s,e.data("toggle"),e.data("content")])},update:function(i){var e,o,a,n=this;this.toggle=this.find(this.options.toggle),this.content=this.find(this.options.containers),this.content.each(function(i){e=t.$(this),e.parent().data("wrapper")?o=e.parent():(o=t.$(this).wrap('
    ').parent(),o.attr("aria-expanded","false")),a=n.toggle.eq(i),o.data("toggle",a),o.data("content",e),a.data("wrapper",o),e.data("wrapper",o)}),this.element.trigger("update.uk.accordion",[this]),i&&this.options.showfirst&&this.toggleItem(this.toggle.eq(0).data("wrapper"),!1,!1)}}),t.accordion}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var i;window.UIkit2&&(i=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-accordion",["uikit"],function(){return i||t(UIkit2)})}(function(t){"use strict";function i(i){var e=t.$(i),o="auto";if(e.is(":visible"))o=e.outerHeight();else{var a={position:e.css("position"),visibility:e.css("visibility"),display:e.css("display")};o=e.css({position:"absolute",visibility:"hidden",display:"block"}).outerHeight(),e.css(a)}return o}return t.component("accordion",{defaults:{showfirst:!0,collapse:!0,animate:!0,easing:"swing",duration:300,toggle:".uk-accordion-title",containers:".uk-accordion-content",clsactive:"uk-active"},boot:function(){t.ready(function(i){setTimeout(function(){t.$("[data-uk-accordion]",i).each(function(){var i=t.$(this);i.data("accordion")||t.accordion(i,t.Utils.options(i.attr("data-uk-accordion")))})},0)})},init:function(){var i=this;this.element.on("click.uk.accordion",this.options.toggle,function(e){e.preventDefault(),i.toggleItem(t.$(this).data("wrapper"),i.options.animate,i.options.collapse)}),this.update(!0),t.domObserve(this.element,function(){i.element.children(i.options.containers).length&&i.update()})},toggleItem:function(e,o,a){var n=this;e.data("toggle").toggleClass(this.options.clsactive),e.data("content").toggleClass(this.options.clsactive);var s=e.data("toggle").hasClass(this.options.clsactive);a&&(this.toggle.not(e.data("toggle")).removeClass(this.options.clsactive),this.content.not(e.data("content")).removeClass(this.options.clsactive).parent().stop().css("overflow","hidden").animate({height:0},{easing:this.options.easing,duration:o?this.options.duration:0}).attr("aria-expanded","false")),e.stop().css("overflow","hidden"),o?e.animate({height:s?i(e.data("content")):0},{easing:this.options.easing,duration:this.options.duration,complete:function(){s&&(e.css({overflow:"",height:"auto"}),t.Utils.checkDisplay(e.data("content"))),n.trigger("display.uk.check")}}):(e.height(s?"auto":0),s&&(e.css({overflow:""}),t.Utils.checkDisplay(e.data("content"))),this.trigger("display.uk.check")),e.attr("aria-expanded",s),this.element.trigger("toggle.uk.accordion",[s,e.data("toggle"),e.data("content")])},update:function(i){var e,o,a,n=this;this.toggle=this.find(this.options.toggle),this.content=this.find(this.options.containers),this.content.each(function(i){e=t.$(this),e.parent().data("wrapper")?o=e.parent():(o=t.$(this).wrap('
    ').parent(),o.attr("aria-expanded","false")),a=n.toggle.eq(i),o.data("toggle",a),o.data("content",e),a.data("wrapper",o),e.data("wrapper",o)}),this.element.trigger("update.uk.accordion",[this]),i&&this.options.showfirst&&this.toggleItem(this.toggle.eq(0).data("wrapper"),!1,!1)}}),t.accordion}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/autocomplete.min.js b/lib/api/uikit/src/js/components/autocomplete.min.js index f89ff1f2..d35e7a0b 100755 --- a/lib/api/uikit/src/js/components/autocomplete.min.js +++ b/lib/api/uikit/src/js/components/autocomplete.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-autocomplete",["uikit"],function(){return e||t(UIkit)})}(function(t){"use strict";var e;return t.component("autocomplete",{defaults:{minLength:3,param:"search",method:"post",delay:300,loadingClass:"uk-loading",flipDropdown:!1,skipClass:"uk-skip",hoverClass:"uk-active",source:null,renderer:null,template:''},visible:!1,value:null,selected:null,boot:function(){t.$html.on("focus.autocomplete.uikit","[data-uk-autocomplete]",function(){var e=t.$(this);e.data("autocomplete")||t.autocomplete(e,t.Utils.options(e.attr("data-uk-autocomplete")))}),t.$html.on("click.autocomplete.uikit",function(t){e&&t.target!=e.input[0]&&e.hide()})},init:function(){var e=this,i=!1,s=t.Utils.debounce(function(){return i?i=!1:(e.handle(),void 0)},this.options.delay);this.dropdown=this.find(".uk-dropdown"),this.template=this.find('script[type="text/autocomplete"]').html(),this.template=t.Utils.template(this.template||this.options.template),this.input=this.find("input:first").attr("autocomplete","off"),this.dropdown.length||(this.dropdown=t.$('
    ').appendTo(this.element)),this.options.flipDropdown&&this.dropdown.addClass("uk-dropdown-flip"),this.dropdown.attr("aria-expanded","false"),this.input.on({keydown:function(t){if(t&&t.which&&!t.shiftKey&&e.visible)switch(t.which){case 13:i=!0,e.selected&&(t.preventDefault(),e.select());break;case 38:t.preventDefault(),e.pick("prev",!0);break;case 40:t.preventDefault(),e.pick("next",!0);break;case 27:case 9:e.hide()}},keyup:s}),this.dropdown.on("click",".uk-autocomplete-results > *",function(){e.select()}),this.dropdown.on("mouseover",".uk-autocomplete-results > *",function(){e.pick(t.$(this))}),this.triggercomplete=s},handle:function(){var t=this,e=this.value;return this.value=this.input.val(),this.value.lengtha-1?o.length-1:a-1)}else n=o["next"==e?"first":"last"]();n=t.$(n)}}else n=e;if(n&&n.length&&(this.selected=n,o.removeClass(this.options.hoverClass),this.selected.addClass(this.options.hoverClass),i)){var l=n.position().top,h=s.dropdown.scrollTop(),r=s.dropdown.height();(l>r||0>l)&&s.dropdown.scrollTop(h+l)}},select:function(){if(this.selected){var t=this.selected.data();this.trigger("selectitem.uk.autocomplete",[t,this]),t.value&&this.input.val(t.value).trigger("change"),this.hide()}},show:function(){return this.visible?void 0:(this.visible=!0,this.element.addClass("uk-open"),e&&e!==this&&e.hide(),e=this,this.dropdown.attr("aria-expanded","true"),this)},hide:function(){return this.visible?(this.visible=!1,this.element.removeClass("uk-open"),e===this&&(e=!1),this.dropdown.attr("aria-expanded","false"),this):void 0},request:function(){var e=this,i=function(t){t&&e.render(t),e.element.removeClass(e.options.loadingClass)};if(this.element.addClass(this.options.loadingClass),this.options.source){var s=this.options.source;switch(typeof this.options.source){case"function":this.options.source.apply(this,[i]);break;case"object":if(s.length){var o=[];s.forEach(function(t){t.value&&-1!=t.value.toLowerCase().indexOf(e.value.toLowerCase())&&o.push(t)}),i(o)}break;case"string":var n={};n[this.options.param]=this.value,t.$.ajax({url:this.options.source,data:n,type:this.options.method,dataType:"json"}).done(function(t){i(t||[])});break;default:i(null)}}else this.element.removeClass(e.options.loadingClass)},render:function(t){return this.dropdown.empty(),this.selected=!1,this.options.renderer?this.options.renderer.apply(this,[t]):t&&t.length&&(this.dropdown.append(this.template({items:t})),this.show(),this.trigger("show.uk.autocomplete")),this}}),t.autocomplete}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var e;window.UIkit2&&(e=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-autocomplete",["uikit"],function(){return e||t(UIkit2)})}(function(t){"use strict";var e;return t.component("autocomplete",{defaults:{minLength:3,param:"search",method:"post",delay:300,loadingClass:"uk-loading",flipDropdown:!1,skipClass:"uk-skip",hoverClass:"uk-active",source:null,renderer:null,template:''},visible:!1,value:null,selected:null,boot:function(){t.$html.on("focus.autocomplete.uikit","[data-uk-autocomplete]",function(){var e=t.$(this);e.data("autocomplete")||t.autocomplete(e,t.Utils.options(e.attr("data-uk-autocomplete")))}),t.$html.on("click.autocomplete.uikit",function(t){e&&t.target!=e.input[0]&&e.hide()})},init:function(){var e=this,i=!1,s=t.Utils.debounce(function(){return i?i=!1:(e.handle(),void 0)},this.options.delay);this.dropdown=this.find(".uk-dropdown"),this.template=this.find('script[type="text/autocomplete"]').html(),this.template=t.Utils.template(this.template||this.options.template),this.input=this.find("input:first").attr("autocomplete","off"),this.dropdown.length||(this.dropdown=t.$('
    ').appendTo(this.element)),this.options.flipDropdown&&this.dropdown.addClass("uk-dropdown-flip"),this.dropdown.attr("aria-expanded","false"),this.input.on({keydown:function(t){if(t&&t.which&&!t.shiftKey&&e.visible)switch(t.which){case 13:i=!0,e.selected&&(t.preventDefault(),e.select());break;case 38:t.preventDefault(),e.pick("prev",!0);break;case 40:t.preventDefault(),e.pick("next",!0);break;case 27:case 9:e.hide()}},keyup:s}),this.dropdown.on("click",".uk-autocomplete-results > *",function(){e.select()}),this.dropdown.on("mouseover",".uk-autocomplete-results > *",function(){e.pick(t.$(this))}),this.triggercomplete=s},handle:function(){var t=this,e=this.value;return this.value=this.input.val(),this.value.lengtha-1?o.length-1:a-1)}else n=o["next"==e?"first":"last"]();n=t.$(n)}}else n=e;if(n&&n.length&&(this.selected=n,o.removeClass(this.options.hoverClass),this.selected.addClass(this.options.hoverClass),i)){var l=n.position().top,h=s.dropdown.scrollTop(),r=s.dropdown.height();(l>r||0>l)&&s.dropdown.scrollTop(h+l)}},select:function(){if(this.selected){var t=this.selected.data();this.trigger("selectitem.uk.autocomplete",[t,this]),t.value&&this.input.val(t.value).trigger("change"),this.hide()}},show:function(){return this.visible?void 0:(this.visible=!0,this.element.addClass("uk-open"),e&&e!==this&&e.hide(),e=this,this.dropdown.attr("aria-expanded","true"),this)},hide:function(){return this.visible?(this.visible=!1,this.element.removeClass("uk-open"),e===this&&(e=!1),this.dropdown.attr("aria-expanded","false"),this):void 0},request:function(){var e=this,i=function(t){t&&e.render(t),e.element.removeClass(e.options.loadingClass)};if(this.element.addClass(this.options.loadingClass),this.options.source){var s=this.options.source;switch(typeof this.options.source){case"function":this.options.source.apply(this,[i]);break;case"object":if(s.length){var o=[];s.forEach(function(t){t.value&&-1!=t.value.toLowerCase().indexOf(e.value.toLowerCase())&&o.push(t)}),i(o)}break;case"string":var n={};n[this.options.param]=this.value,t.$.ajax({url:this.options.source,data:n,type:this.options.method,dataType:"json"}).done(function(t){i(t||[])});break;default:i(null)}}else this.element.removeClass(e.options.loadingClass)},render:function(t){return this.dropdown.empty(),this.selected=!1,this.options.renderer?this.options.renderer.apply(this,[t]):t&&t.length&&(this.dropdown.append(this.template({items:t})),this.show(),this.trigger("show.uk.autocomplete")),this}}),t.autocomplete}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/datepicker.min.js b/lib/api/uikit/src/js/components/datepicker.min.js index c84307b6..9df0b8a5 100755 --- a/lib/api/uikit/src/js/components/datepicker.min.js +++ b/lib/api/uikit/src/js/components/datepicker.min.js @@ -1,3 +1,3 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-datepicker",["uikit"],function(){return e||t(UIkit)})}(function(t){"use strict";var e,n,a=!1;return t.component("datepicker",{defaults:{mobile:!1,weekstart:1,i18n:{months:["January","February","March","April","May","June","July","August","September","October","November","December"],weekdays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},format:"YYYY-MM-DD",offsettop:5,maxDate:!1,minDate:!1,pos:"auto",template:function(e,n){var a,s="";if(s+='
    ',s+='',s+='',t.formSelect){var i,r,o,u,c=(new Date).getFullYear(),d=[];for(a=0;a'+n.i18n.months[a]+""):d.push('");for(i=''+n.i18n.months[e.month]+'",d=[],o=e.minDate?e.minDate.year():c-50,u=e.maxDate?e.maxDate.year():c+20,a=o;u>=a;a++)a==e.year?d.push('"):d.push('");r=''+e.year+'",s+='
    '+i+" "+r+"
    "}else s+='
    '+n.i18n.months[e.month]+" "+e.year+"
    ";for(s+="
    ",s+='',s+="",a=0;a"+e.weekdays[a]+"");for(s+="",s+="",a=0;a";for(var l=0;l'+h.day.format("D")+""}s+=""}return s+="",s+="
    "}},boot:function(){t.$win.on("resize orientationchange",function(){a&&a.hide()}),t.$html.on("focus.datepicker.uikit","[data-uk-datepicker]",function(e){var n=t.$(this);n.data("datepicker")||(e.preventDefault(),t.datepicker(n,t.Utils.options(n.attr("data-uk-datepicker"))),n.trigger("focus"))}),t.$html.on("click focus","*",function(n){var s=t.$(n.target);!a||s[0]==e[0]||s.data("datepicker")||s.parents(".uk-datepicker:first").length||a.hide()})},init:function(){if(!t.support.touch||"date"!=this.element.attr("type")||this.options.mobile){var s=this;this.current=this.element.val()?n(this.element.val(),this.options.format):n(),this.on("click focus",function(){a!==s&&s.pick(this.value?this.value:s.options.minDate?s.options.minDate:"")}).on("change",function(){s.element.val()&&!n(s.element.val(),s.options.format).isValid()&&s.element.val(n().format(s.options.format))}),e||(e=t.$('
    '),e.on("click",".uk-datepicker-next, .uk-datepicker-previous, [data-date]",function(e){e.stopPropagation(),e.preventDefault();var s=t.$(this);return s.hasClass("uk-datepicker-date-disabled")?!1:(s.is("[data-date]")?(a.current=n(s.data("date")),a.element.val(a.current.isValid()?a.current.format(a.options.format):null).trigger("change"),a.hide()):a.add(s.hasClass("uk-datepicker-next")?1:-1,"months"),void 0)}),e.on("change",".update-picker-month, .update-picker-year",function(){var e=t.$(this);a[e.is(".update-picker-year")?"setYear":"setMonth"](Number(e.val()))}),e.appendTo("body"))}},pick:function(s){var i=this.element.offset(),r={left:i.left,right:""};this.current=isNaN(s)?n(s,this.options.format):n(),this.initdate=this.current.format("YYYY-MM-DD"),this.update(),"right"==t.langdirection&&(r.right=window.innerWidth-(r.left+this.element.outerWidth()),r.left="");var o=i.top-this.element.outerHeight()+this.element.height()-this.options.offsettop-e.outerHeight(),u=i.top+this.element.outerHeight()+this.options.offsettop;r.top=u,"top"==this.options.pos?r.top=o:"auto"==this.options.pos&&window.innerHeight-u-e.outerHeight()<0&&o>=0&&(r.top=o),e.css(r).show(),this.trigger("show.uk.datepicker"),a=this},add:function(t,e){this.current.add(t,e),this.update()},setMonth:function(t){this.current.month(t),this.update()},setYear:function(t){this.current.year(t),this.update()},update:function(){var t=this.getRows(this.current.year(),this.current.month()),n=this.options.template(t,this.options);e.html(n),this.trigger("update.uk.datepicker")},getRows:function(t,e){var a=this.options,s=n().format("YYYY-MM-DD"),i=[31,t%4===0&&t%100!==0||t%400===0?29:28,31,30,31,30,31,31,30,31,30,31][e],r=new Date(t,e,1,12).getDay(),o={month:e,year:t,weekdays:[],days:[],maxDate:!1,minDate:!1},u=[];a.maxDate!==!1&&(o.maxDate=isNaN(a.maxDate)?n(a.maxDate,a.format).startOf("day").hours(12):n().add(a.maxDate,"days").startOf("day").hours(12)),a.minDate!==!1&&(o.minDate=isNaN(a.minDate)?n(a.minDate,a.format).startOf("day").hours(12):n().add(a.minDate-1,"days").startOf("day").hours(12)),o.weekdays=function(){for(var t=0,e=[];7>t;t++){for(var n=t+(a.weekstart||0);n>=7;)n-=7;e.push(a.i18n.weekdays[n])}return e}(),a.weekstart&&a.weekstart>0&&(r-=a.weekstart,0>r&&(r+=7));for(var c=i+r,d=c;d>7;)d-=7;c+=7-d;for(var l,h,f,m,_,p=0,y=0;c>p;p++)l=new Date(t,e,1+(p-r),12),h=o.minDate&&o.minDate>l||o.maxDate&&l>o.maxDate,_=!(r>p||p>=i+r),l=n(l),f=this.initdate==l.format("YYYY-MM-DD"),m=s==l.format("YYYY-MM-DD"),u.push({selected:f,today:m,disabled:h,day:l,inmonth:_}),7===++y&&(o.days.push(u),u=[],y=0);return o},hide:function(){a&&a===this&&(e.hide(),a=!1,this.trigger("hide.uk.datepicker"))}}),n=function(t){function e(t,e,n){switch(arguments.length){case 2:return null!=t?t:e;case 3:return null!=t?t:null!=e?e:n;default:throw new Error("Implement me")}}function n(t,e){return Ye.call(t,e)}function a(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}}function s(t){De.suppressDeprecationWarnings===!1&&"undefined"!=typeof console&&console.warn&&console.warn("Deprecation warning: "+t)}function i(t,e){var n=!0;return h(function(){return n&&(s(t),n=!1),e.apply(this,arguments)},e)}function r(t,e){mn[t]||(s(e),mn[t]=!0)}function o(t,e){return function(n){return _(t.call(this,n),e)}}function u(t,e){return function(n){return this.localeData().ordinal(t.call(this,n),e)}}function c(){}function d(t,e){e!==!1&&F(t),f(this,t),this._d=new Date(+t._d)}function l(t){var e=v(t),n=e.year||0,a=e.quarter||0,s=e.month||0,i=e.week||0,r=e.day||0,o=e.hour||0,u=e.minute||0,c=e.second||0,d=e.millisecond||0;this._milliseconds=+d+1e3*c+6e4*u+36e5*o,this._days=+r+7*i,this._months=+s+3*a+12*n,this._data={},this._locale=De.localeData(),this._bubble()}function h(t,e){for(var a in e)n(e,a)&&(t[a]=e[a]);return n(e,"toString")&&(t.toString=e.toString),n(e,"valueOf")&&(t.valueOf=e.valueOf),t}function f(t,e){var n,a,s;if("undefined"!=typeof e._isAMomentObject&&(t._isAMomentObject=e._isAMomentObject),"undefined"!=typeof e._i&&(t._i=e._i),"undefined"!=typeof e._f&&(t._f=e._f),"undefined"!=typeof e._l&&(t._l=e._l),"undefined"!=typeof e._strict&&(t._strict=e._strict),"undefined"!=typeof e._tzm&&(t._tzm=e._tzm),"undefined"!=typeof e._isUTC&&(t._isUTC=e._isUTC),"undefined"!=typeof e._offset&&(t._offset=e._offset),"undefined"!=typeof e._pf&&(t._pf=e._pf),"undefined"!=typeof e._locale&&(t._locale=e._locale),Fe.length>0)for(n in Fe)a=Fe[n],s=e[a],"undefined"!=typeof s&&(t[a]=s);return t}function m(t){return 0>t?Math.ceil(t):Math.floor(t)}function _(t,e,n){for(var a=""+Math.abs(t),s=t>=0;a.lengtha;a++)(n&&t[a]!==e[a]||!n&&S(t[a])!==S(e[a]))&&r++;return r+i}function w(t){if(t){var e=t.toLowerCase().replace(/(.)s$/,"$1");t=on[t]||un[e]||e}return t}function v(t){var e,a,s={};for(a in t)n(t,a)&&(e=w(a),e&&(s[e]=t[a]));return s}function b(e){var n,a;if(0===e.indexOf("week"))n=7,a="day";else{if(0!==e.indexOf("month"))return;n=12,a="month"}De[e]=function(s,i){var r,o,u=De._locale[e],c=[];if("number"==typeof s&&(i=s,s=t),o=function(t){var e=De().utc().set(a,t);return u.call(De._locale,e,s||"")},null!=i)return o(i);for(r=0;n>r;r++)c.push(o(r));return c}}function S(t){var e=+t,n=0;return 0!==e&&isFinite(e)&&(n=e>=0?Math.floor(e):Math.ceil(e)),n}function T(t,e){return new Date(Date.UTC(t,e+1,0)).getUTCDate()}function O(t,e,n){return oe(De([t,11,31+e-n]),e,n).week}function W(t){return U(t)?366:365}function U(t){return t%4===0&&t%100!==0||t%400===0}function F(t){var e;t._a&&-2===t._pf.overflow&&(e=t._a[ve]<0||t._a[ve]>11?ve:t._a[be]<1||t._a[be]>T(t._a[we],t._a[ve])?be:t._a[Se]<0||t._a[Se]>23?Se:t._a[Te]<0||t._a[Te]>59?Te:t._a[Oe]<0||t._a[Oe]>59?Oe:t._a[We]<0||t._a[We]>999?We:-1,t._pf._overflowDayOfYear&&(we>e||e>be)&&(e=be),t._pf.overflow=e)}function G(t){return null==t._isValid&&(t._isValid=!isNaN(t._d.getTime())&&t._pf.overflow<0&&!t._pf.empty&&!t._pf.invalidMonth&&!t._pf.nullInput&&!t._pf.invalidFormat&&!t._pf.userInvalidated,t._strict&&(t._isValid=t._isValid&&0===t._pf.charsLeftOver&&0===t._pf.unusedTokens.length)),t._isValid}function C(t){return t?t.toLowerCase().replace("_","-"):t}function z(t){for(var e,n,a,s,i=0;i0;){if(a=x(s.slice(0,e).join("-")))return a;if(n&&n.length>=e&&Y(s,n,!0)>=e-1)break;e--}i++}return null}function x(t){var e=null;if(!Ue[t]&&Ge)try{e=De.locale(),require("./locale/"+t),De.locale(e)}catch(n){}return Ue[t]}function I(t,e){return e._isUTC?De(t).zone(e._offset||0):De(t).local()}function H(t){return t.match(/\[[\s\S]/)?t.replace(/^\[|\]$/g,""):t.replace(/\\/g,"")}function L(t){var e,n,a=t.match(Ie);for(e=0,n=a.length;n>e;e++)a[e]=fn[a[e]]?fn[a[e]]:H(a[e]);return function(s){var i="";for(e=0;n>e;e++)i+=a[e]instanceof Function?a[e].call(s,t):a[e];return i}}function P(t,e){return t.isValid()?(e=A(e,t.localeData()),cn[e]||(cn[e]=L(e)),cn[e](t)):t.localeData().invalidDate()}function A(t,e){function n(t){return e.longDateFormat(t)||t}var a=5;for(He.lastIndex=0;a>=0&&He.test(t);)t=t.replace(He,n),He.lastIndex=0,a-=1;return t}function N(t,e){var n,a=e._strict;switch(t){case"Q":return qe;case"DDDD":return Re;case"YYYY":case"GGGG":case"gggg":return a?Xe:Ae;case"Y":case"G":case"g":return Ke;case"YYYYYY":case"YYYYY":case"GGGGG":case"ggggg":return a?Be:Ne;case"S":if(a)return qe;case"SS":if(a)return Qe;case"SSS":if(a)return Re;case"DDD":return Pe;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":return je;case"a":case"A":return e._locale._meridiemParse;case"X":return Ve;case"Z":case"ZZ":return Ee;case"T":return $e;case"SSSS":return Ze;case"MM":case"DD":case"YY":case"GG":case"gg":case"HH":case"hh":case"mm":case"ss":case"ww":case"WW":return a?Qe:Le;case"M":case"D":case"d":case"H":case"h":case"m":case"s":case"w":case"W":case"e":case"E":return Le;case"Do":return Je;default:return n=new RegExp(R(Q(t.replace("\\","")),"i"))}}function Z(t){t=t||"";var e=t.match(Ee)||[],n=e[e.length-1]||[],a=(n+"").match(sn)||["-",0,0],s=+(60*a[1])+S(a[2]);return"+"===a[0]?-s:s}function j(t,e,n){var a,s=n._a;switch(t){case"Q":null!=e&&(s[ve]=3*(S(e)-1));break;case"M":case"MM":null!=e&&(s[ve]=S(e)-1);break;case"MMM":case"MMMM":a=n._locale.monthsParse(e),null!=a?s[ve]=a:n._pf.invalidMonth=e;break;case"D":case"DD":null!=e&&(s[be]=S(e));break;case"Do":null!=e&&(s[be]=S(parseInt(e,10)));break;case"DDD":case"DDDD":null!=e&&(n._dayOfYear=S(e));break;case"YY":s[we]=De.parseTwoDigitYear(e);break;case"YYYY":case"YYYYY":case"YYYYYY":s[we]=S(e);break;case"a":case"A":n._isPm=n._locale.isPM(e);break;case"H":case"HH":case"h":case"hh":s[Se]=S(e);break;case"m":case"mm":s[Te]=S(e);break;case"s":case"ss":s[Oe]=S(e);break;case"S":case"SS":case"SSS":case"SSSS":s[We]=S(1e3*("0."+e));break;case"X":n._d=new Date(1e3*parseFloat(e));break;case"Z":case"ZZ":n._useUTC=!0,n._tzm=Z(e);break;case"dd":case"ddd":case"dddd":a=n._locale.weekdaysParse(e),null!=a?(n._w=n._w||{},n._w.d=a):n._pf.invalidWeekday=e;break;case"w":case"ww":case"W":case"WW":case"d":case"e":case"E":t=t.substr(0,1);case"gggg":case"GGGG":case"GGGGG":t=t.substr(0,2),e&&(n._w=n._w||{},n._w[t]=S(e));break;case"gg":case"GG":n._w=n._w||{},n._w[t]=De.parseTwoDigitYear(e)}}function E(t){var n,a,s,i,r,o,u;n=t._w,null!=n.GG||null!=n.W||null!=n.E?(r=1,o=4,a=e(n.GG,t._a[we],oe(De(),1,4).year),s=e(n.W,1),i=e(n.E,1)):(r=t._locale._week.dow,o=t._locale._week.doy,a=e(n.gg,t._a[we],oe(De(),r,o).year),s=e(n.w,1),null!=n.d?(i=n.d,r>i&&++s):i=null!=n.e?n.e+r:r),u=ue(a,s,i,o,r),t._a[we]=u.year,t._dayOfYear=u.dayOfYear}function $(t){var n,a,s,i,r=[];if(!t._d){for(s=J(t),t._w&&null==t._a[be]&&null==t._a[ve]&&E(t),t._dayOfYear&&(i=e(t._a[we],s[we]),t._dayOfYear>W(i)&&(t._pf._overflowDayOfYear=!0),a=ae(i,0,t._dayOfYear),t._a[ve]=a.getUTCMonth(),t._a[be]=a.getUTCDate()),n=0;3>n&&null==t._a[n];++n)t._a[n]=r[n]=s[n];for(;7>n;n++)t._a[n]=r[n]=null==t._a[n]?2===n?1:0:t._a[n];t._d=(t._useUTC?ae:ne).apply(null,r),null!=t._tzm&&t._d.setUTCMinutes(t._d.getUTCMinutes()+t._tzm)}}function V(t){var e;t._d||(e=v(t._i),t._a=[e.year,e.month,e.day,e.hour,e.minute,e.second,e.millisecond],$(t))}function J(t){var e=new Date;return t._useUTC?[e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()]:[e.getFullYear(),e.getMonth(),e.getDate()]}function q(t){if(t._f===De.ISO_8601)return B(t),void 0;t._a=[],t._pf.empty=!0;var e,n,a,s,i,r=""+t._i,o=r.length,u=0;for(a=A(t._f,t._locale).match(Ie)||[],e=0;e0&&t._pf.unusedInput.push(i),r=r.slice(r.indexOf(n)+n.length),u+=n.length),fn[s]?(n?t._pf.empty=!1:t._pf.unusedTokens.push(s),j(s,n,t)):t._strict&&!n&&t._pf.unusedTokens.push(s);t._pf.charsLeftOver=o-u,r.length>0&&t._pf.unusedInput.push(r),t._isPm&&t._a[Se]<12&&(t._a[Se]+=12),t._isPm===!1&&12===t._a[Se]&&(t._a[Se]=0),$(t),F(t)}function Q(t){return t.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(t,e,n,a,s){return e||n||a||s})}function R(t){return t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function X(t){var e,n,s,i,r;if(0===t._f.length)return t._pf.invalidFormat=!0,t._d=new Date(0/0),void 0;for(i=0;ir)&&(s=r,n=e));h(t,n||e)}function B(t){var e,n,a=t._i,s=tn.exec(a);if(s){for(t._pf.iso=!0,e=0,n=nn.length;n>e;e++)if(nn[e][1].exec(a)){t._f=nn[e][0]+(s[6]||" ");break}for(e=0,n=an.length;n>e;e++)if(an[e][1].exec(a)){t._f+=an[e][0];break}a.match(Ee)&&(t._f+="Z"),q(t)}else t._isValid=!1}function K(t){B(t),t._isValid===!1&&(delete t._isValid,De.createFromInputFallback(t))}function te(t,e){var n,a=[];for(n=0;nt&&o.setFullYear(t),o}function ae(t){var e=new Date(Date.UTC.apply(null,arguments));return 1970>t&&e.setUTCFullYear(t),e}function se(t,e){if("string"==typeof t)if(isNaN(t)){if(t=e.weekdaysParse(t),"number"!=typeof t)return null}else t=parseInt(t,10);return t}function ie(t,e,n,a,s){return s.relativeTime(e||1,!!n,t,a)}function re(t,e,n){var a=De.duration(t).abs(),s=Me(a.as("s")),i=Me(a.as("m")),r=Me(a.as("h")),o=Me(a.as("d")),u=Me(a.as("M")),c=Me(a.as("y")),d=s0,d[4]=n,ie.apply({},d)}function oe(t,e,n){var a,s=n-e,i=n-t.day();return i>s&&(i-=7),s-7>i&&(i+=7),a=De(t).add(i,"d"),{week:Math.ceil(a.dayOfYear()/7),year:a.year()}}function ue(t,e,n,a,s){var i,r,o=ae(t,0,1).getUTCDay();return o=0===o?7:o,n=null!=n?n:s,i=s-o+(o>a?7:0)-(s>o?7:0),r=7*(e-1)+(n-s)+i+1,{year:r>0?t:t-1,dayOfYear:r>0?r:W(t-1)+r}}function ce(e){var n=e._i,a=e._f;return e._locale=e._locale||De.localeData(e._l),null===n||a===t&&""===n?De.invalid({nullInput:!0}):("string"==typeof n&&(e._i=n=e._locale.preparse(n)),De.isMoment(n)?new d(n,!0):(a?k(a)?X(e):q(e):ee(e),new d(e)))}function de(t,e){var n,a;if(1===e.length&&k(e[0])&&(e=e[0]),!e.length)return De();for(n=e[0],a=1;a=0?"+":"-";return e+_(Math.abs(t),6)},gg:function(){return _(this.weekYear()%100,2)},gggg:function(){return _(this.weekYear(),4)},ggggg:function(){return _(this.weekYear(),5)},GG:function(){return _(this.isoWeekYear()%100,2)},GGGG:function(){return _(this.isoWeekYear(),4)},GGGGG:function(){return _(this.isoWeekYear(),5)},e:function(){return this.weekday()},E:function(){return this.isoWeekday()},a:function(){return this.localeData().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.localeData().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return S(this.milliseconds()/100)},SS:function(){return _(S(this.milliseconds()/10),2)},SSS:function(){return _(this.milliseconds(),3)},SSSS:function(){return _(this.milliseconds(),3)},Z:function(){var t=-this.zone(),e="+";return 0>t&&(t=-t,e="-"),e+_(S(t/60),2)+":"+_(S(t)%60,2)},ZZ:function(){var t=-this.zone(),e="+";return 0>t&&(t=-t,e="-"),e+_(S(t/60),2)+_(S(t)%60,2)},z:function(){return this.zoneAbbr()},zz:function(){return this.zoneName()},X:function(){return this.unix()},Q:function(){return this.quarter()}},mn={},_n=["months","monthsShort","weekdays","weekdaysShort","weekdaysMin"];ln.length;)ge=ln.pop(),fn[ge+"o"]=u(fn[ge],ge);for(;hn.length;)ge=hn.pop(),fn[ge+ge]=o(fn[ge],2);fn.DDDD=o(fn.DDD,3),h(c.prototype,{set:function(t){var e,n;for(n in t)e=t[n],"function"==typeof e?this[n]=e:this["_"+n]=e},_months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),months:function(t){return this._months[t.month()]},_monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),monthsShort:function(t){return this._monthsShort[t.month()]},monthsParse:function(t){var e,n,a;for(this._monthsParse||(this._monthsParse=[]),e=0;12>e;e++)if(this._monthsParse[e]||(n=De.utc([2e3,e]),a="^"+this.months(n,"")+"|^"+this.monthsShort(n,""),this._monthsParse[e]=new RegExp(a.replace(".",""),"i")),this._monthsParse[e].test(t))return e},_weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdays:function(t){return this._weekdays[t.day()]},_weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysShort:function(t){return this._weekdaysShort[t.day()]},_weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),weekdaysMin:function(t){return this._weekdaysMin[t.day()]},weekdaysParse:function(t){var e,n,a;for(this._weekdaysParse||(this._weekdaysParse=[]),e=0;7>e;e++)if(this._weekdaysParse[e]||(n=De([2e3,1]).day(e),a="^"+this.weekdays(n,"")+"|^"+this.weekdaysShort(n,"")+"|^"+this.weekdaysMin(n,""),this._weekdaysParse[e]=new RegExp(a.replace(".",""),"i")),this._weekdaysParse[e].test(t))return e},_longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY LT",LLLL:"dddd, MMMM D, YYYY LT"},longDateFormat:function(t){var e=this._longDateFormat[t];return!e&&this._longDateFormat[t.toUpperCase()]&&(e=this._longDateFormat[t.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(t){return t.slice(1)}),this._longDateFormat[t]=e),e},isPM:function(t){return"p"===(t+"").toLowerCase().charAt(0)},_meridiemParse:/[ap]\.?m?\.?/i,meridiem:function(t,e,n){return t>11?n?"pm":"PM":n?"am":"AM"},_calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},calendar:function(t,e){var n=this._calendar[t];return"function"==typeof n?n.apply(e):n},_relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},relativeTime:function(t,e,n,a){var s=this._relativeTime[n];return"function"==typeof s?s(t,e,n,a):s.replace(/%d/i,t)},pastFuture:function(t,e){var n=this._relativeTime[t>0?"future":"past"];return"function"==typeof n?n(e):n.replace(/%s/i,e)},ordinal:function(t){return this._ordinal.replace("%d",t)},_ordinal:"%d",preparse:function(t){return t},postformat:function(t){return t},week:function(t){return oe(t,this._week.dow,this._week.doy).week},_week:{dow:0,doy:6},_invalidDate:"Invalid date",invalidDate:function(){return this._invalidDate}}),De=function(e,n,s,i){var r;return"boolean"==typeof s&&(i=s,s=t),r={},r._isAMomentObject=!0,r._i=e,r._f=n,r._l=s,r._strict=i,r._isUTC=!1,r._pf=a(),ce(r)},De.suppressDeprecationWarnings=!1,De.createFromInputFallback=i("moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.",function(t){t._d=new Date(t._i)}),De.min=function(){var t=[].slice.call(arguments,0);return de("isBefore",t)},De.max=function(){var t=[].slice.call(arguments,0);return de("isAfter",t)},De.utc=function(e,n,s,i){var r;return"boolean"==typeof s&&(i=s,s=t),r={},r._isAMomentObject=!0,r._useUTC=!0,r._isUTC=!0,r._l=s,r._i=e,r._f=n,r._strict=i,r._pf=a(),ce(r).utc()},De.unix=function(t){return De(1e3*t)},De.duration=function(t,e){var a,s,i,r,o=t,u=null;return De.isDuration(t)?o={ms:t._milliseconds,d:t._days,M:t._months}:"number"==typeof t?(o={},e?o[e]=t:o.milliseconds=t):(u=ze.exec(t))?(a="-"===u[1]?-1:1,o={y:0,d:S(u[be])*a,h:S(u[Se])*a,m:S(u[Te])*a,s:S(u[Oe])*a,ms:S(u[We])*a}):(u=xe.exec(t))?(a="-"===u[1]?-1:1,i=function(t){var e=t&&parseFloat(t.replace(",","."));return(isNaN(e)?0:e)*a},o={y:i(u[2]),M:i(u[3]),d:i(u[4]),h:i(u[5]),m:i(u[6]),s:i(u[7]),w:i(u[8])}):"object"==typeof o&&("from"in o||"to"in o)&&(r=y(De(o.from),De(o.to)),o={},o.ms=r.milliseconds,o.M=r.months),s=new l(o),De.isDuration(t)&&n(t,"_locale")&&(s._locale=t._locale),s},De.version=ke,De.defaultFormat=en,De.ISO_8601=function(){},De.momentProperties=Fe,De.updateOffset=function(){},De.relativeTimeThreshold=function(e,n){return dn[e]===t?!1:n===t?dn[e]:(dn[e]=n,!0)},De.lang=i("moment.lang is deprecated. Use moment.locale instead.",function(t,e){return De.locale(t,e)}),De.locale=function(t,e){var n;return t&&(n="undefined"!=typeof e?De.defineLocale(t,e):De.localeData(t),n&&(De.duration._locale=De._locale=n)),De._locale._abbr},De.defineLocale=function(t,e){return null!==e?(e.abbr=t,Ue[t]||(Ue[t]=new c),Ue[t].set(e),De.locale(t),Ue[t]):(delete Ue[t],null)},De.langData=i("moment.langData is deprecated. Use moment.localeData instead.",function(t){return De.localeData(t)}),De.localeData=function(t){var e;if(t&&t._locale&&t._locale._abbr&&(t=t._locale._abbr),!t)return De._locale;if(!k(t)){if(e=x(t))return e;t=[t]}return z(t)},De.isMoment=function(t){return t instanceof d||null!=t&&n(t,"_isAMomentObject")},De.isDuration=function(t){return t instanceof l};for(ge=_n.length-1;ge>=0;--ge)b(_n[ge]);De.normalizeUnits=function(t){return w(t)},De.invalid=function(t){var e=De.utc(0/0);return null!=t?h(e._pf,t):e._pf.userInvalidated=!0,e},De.parseZone=function(){return De.apply(null,arguments).parseZone()},De.parseTwoDigitYear=function(t){return S(t)+(S(t)>68?1900:2e3)},h(De.fn=d.prototype,{clone:function(){return De(this)},valueOf:function(){return+this._d+6e4*(this._offset||0)},unix:function(){return Math.floor(+this/1e3)},toString:function(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},toDate:function(){return this._offset?new Date(+this):this._d},toISOString:function(){var t=De(this).utc();return 00:!1},parsingFlags:function(){return h({},this._pf)},invalidAt:function(){return this._pf.overflow},utc:function(t){return this.zone(0,t)},local:function(t){return this._isUTC&&(this.zone(0,t),this._isUTC=!1,t&&this.add(this._dateTzOffset(),"m")),this},format:function(t){var e=P(this,t||De.defaultFormat);return this.localeData().postformat(e)},add:D(1,"add"),subtract:D(-1,"subtract"),diff:function(t,e,n){var a,s,i,r=I(t,this),o=6e4*(this.zone()-r.zone());return e=w(e),"year"===e||"month"===e?(a=432e5*(this.daysInMonth()+r.daysInMonth()),s=12*(this.year()-r.year())+(this.month()-r.month()),i=this-De(this).startOf("month")-(r-De(r).startOf("month")),i-=6e4*(this.zone()-De(this).startOf("month").zone()-(r.zone()-De(r).startOf("month").zone())),s+=i/a,"year"===e&&(s/=12)):(a=this-r,s="second"===e?a/1e3:"minute"===e?a/6e4:"hour"===e?a/36e5:"day"===e?(a-o)/864e5:"week"===e?(a-o)/6048e5:a),n?s:m(s)},from:function(t,e){return De.duration({to:this,from:t}).locale(this.locale()).humanize(!e)},fromNow:function(t){return this.from(De(),t)},calendar:function(t){var e=t||De(),n=I(e,this).startOf("day"),a=this.diff(n,"days",!0),s=-6>a?"sameElse":-1>a?"lastWeek":0>a?"lastDay":1>a?"sameDay":2>a?"nextDay":7>a?"nextWeek":"sameElse";return this.format(this.localeData().calendar(s,this))},isLeapYear:function(){return U(this.year())},isDST:function(){return this.zone()+t):+this.clone().startOf(e)>+De(t).startOf(e)},isBefore:function(t,e){return e=w("undefined"!=typeof e?e:"millisecond"),"millisecond"===e?(t=De.isMoment(t)?t:De(t),+t>+this):+this.clone().startOf(e)<+De(t).startOf(e)},isSame:function(t,e){return e=w(e||"millisecond"),"millisecond"===e?(t=De.isMoment(t)?t:De(t),+this===+t):+this.clone().startOf(e)===+I(t,this).startOf(e)},min:i("moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548",function(t){return t=De.apply(null,arguments),this>t?this:t}),max:i("moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548",function(t){return t=De.apply(null,arguments),t>this?this:t}),zone:function(t,e){var n,a=this._offset||0;return null==t?this._isUTC?a:this._dateTzOffset():("string"==typeof t&&(t=Z(t)),Math.abs(t)<16&&(t=60*t),!this._isUTC&&e&&(n=this._dateTzOffset()),this._offset=t,this._isUTC=!0,null!=n&&this.subtract(n,"m"),a!==t&&(!e||this._changeInProgress?g(this,De.duration(a-t,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,De.updateOffset(this,!0),this._changeInProgress=null)),this)},zoneAbbr:function(){return this._isUTC?"UTC":"" +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var e;window.UIkit2&&(e=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-datepicker",["uikit"],function(){return e||t(UIkit2)})}(function(t){"use strict";var e,n,a=!1;return t.component("datepicker",{defaults:{mobile:!1,weekstart:1,i18n:{months:["January","February","March","April","May","June","July","August","September","October","November","December"],weekdays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},format:"YYYY-MM-DD",offsettop:5,maxDate:!1,minDate:!1,pos:"auto",container:"body",template:function(e,n){var a,s="";if(s+='
    ',s+='',s+='',t.formSelect){var i,r,o,u,c=(new Date).getFullYear(),d=[];for(a=0;a'+n.i18n.months[a]+""):d.push('");for(i=''+n.i18n.months[e.month]+'",d=[],o=e.minDate?e.minDate.year():c-50,u=e.maxDate?e.maxDate.year():c+20,a=o;u>=a;a++)a==e.year?d.push('"):d.push('");r=''+e.year+'",s+='
    '+i+" "+r+"
    "}else s+='
    '+n.i18n.months[e.month]+" "+e.year+"
    ";for(s+="
    ",s+='',s+="",a=0;a"+e.weekdays[a]+"");for(s+="",s+="",a=0;a";for(var l=0;l'+h.day.format("D")+""}s+=""}return s+="",s+="
    "}},boot:function(){t.$win.on("resize orientationchange",function(){a&&a.hide()}),t.$html.on("focus.datepicker.uikit","[data-uk-datepicker]",function(e){var n=t.$(this);n.data("datepicker")||(e.preventDefault(),t.datepicker(n,t.Utils.options(n.attr("data-uk-datepicker"))),n.trigger("focus"))}),t.$html.on("click focus","*",function(n){var s=t.$(n.target);!a||s[0]==e[0]||s.data("datepicker")||s.parents(".uk-datepicker:first").length||a.hide()})},init:function(){if(!t.support.touch||"date"!=this.element.attr("type")||this.options.mobile){var s=this;this.current=this.element.val()?n(this.element.val(),this.options.format):n(),this.on("click focus",function(){a!==s&&s.pick(this.value?this.value:"")}).on("change",function(){s.element.val()&&!n(s.element.val(),s.options.format).isValid()&&s.element.val(n().format(s.options.format))}),e||(e=t.$('
    '),e.on("click",".uk-datepicker-next, .uk-datepicker-previous, [data-date]",function(e){e.stopPropagation(),e.preventDefault();var s=t.$(this);return s.hasClass("uk-datepicker-date-disabled")?!1:(s.is("[data-date]")?(a.current=n(s.data("date")),a.element.val(a.current.isValid()?a.current.format(a.options.format):null).trigger("change"),a.hide()):a.add(s.hasClass("uk-datepicker-next")?1:-1,"months"),void 0)}),e.on("change",".update-picker-month, .update-picker-year",function(){var e=t.$(this);a[e.is(".update-picker-year")?"setYear":"setMonth"](Number(e.val()))}),e.appendTo(this.options.container))}},pick:function(s){var i=this.element.offset(),r={left:i.left,right:""};this.current=isNaN(s)?n(s,this.options.format):n(),this.initdate=this.current.format("YYYY-MM-DD"),this.update(),"right"==t.langdirection&&(r.right=window.innerWidth-(r.left+this.element.outerWidth()),r.left="");var o=i.top-this.element.outerHeight()+this.element.height()-this.options.offsettop-e.outerHeight(),u=i.top+this.element.outerHeight()+this.options.offsettop;r.top=u,"top"==this.options.pos?r.top=o:"auto"==this.options.pos&&window.innerHeight-u-e.outerHeight()<0&&o>=0&&(r.top=o),e.css(r).show(),this.trigger("show.uk.datepicker"),a=this},add:function(t,e){this.current.add(t,e),this.update()},setMonth:function(t){this.current.month(t),this.update()},setYear:function(t){this.current.year(t),this.update()},update:function(){var t=this.getRows(this.current.year(),this.current.month()),n=this.options.template(t,this.options);e.html(n),this.trigger("update.uk.datepicker")},getRows:function(t,e){var a=this.options,s=n().format("YYYY-MM-DD"),i=[31,t%4===0&&t%100!==0||t%400===0?29:28,31,30,31,30,31,31,30,31,30,31][e],r=new Date(t,e,1,12).getDay(),o={month:e,year:t,weekdays:[],days:[],maxDate:!1,minDate:!1},u=[];a.maxDate!==!1&&(o.maxDate=isNaN(a.maxDate)?n(a.maxDate,a.format).startOf("day").hours(12):n().add(a.maxDate,"days").startOf("day").hours(12)),a.minDate!==!1&&(o.minDate=isNaN(a.minDate)?n(a.minDate,a.format).startOf("day").hours(12):n().add(a.minDate-1,"days").startOf("day").hours(12)),o.weekdays=function(){for(var t=0,e=[];7>t;t++){for(var n=t+(a.weekstart||0);n>=7;)n-=7;e.push(a.i18n.weekdays[n])}return e}(),a.weekstart&&a.weekstart>0&&(r-=a.weekstart,0>r&&(r+=7));for(var c=i+r,d=c;d>7;)d-=7;c+=7-d;for(var l,h,f,m,_,p=0,y=0;c>p;p++)l=new Date(t,e,1+(p-r),12),h=o.minDate&&o.minDate>l||o.maxDate&&l>o.maxDate,_=!(r>p||p>=i+r),l=n(l),f=this.initdate==l.format("YYYY-MM-DD"),m=s==l.format("YYYY-MM-DD"),u.push({selected:f,today:m,disabled:h,day:l,inmonth:_}),7===++y&&(o.days.push(u),u=[],y=0);return o},hide:function(){a&&a===this&&(e.hide(),a=!1,this.trigger("hide.uk.datepicker"))}}),n=function(t){function e(t,e,n){switch(arguments.length){case 2:return null!=t?t:e;case 3:return null!=t?t:null!=e?e:n;default:throw new Error("Implement me")}}function n(t,e){return Ye.call(t,e)}function a(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}}function s(t){De.suppressDeprecationWarnings===!1&&"undefined"!=typeof console&&console.warn&&console.warn("Deprecation warning: "+t)}function i(t,e){var n=!0;return h(function(){return n&&(s(t),n=!1),e.apply(this,arguments)},e)}function r(t,e){mn[t]||(s(e),mn[t]=!0)}function o(t,e){return function(n){return _(t.call(this,n),e)}}function u(t,e){return function(n){return this.localeData().ordinal(t.call(this,n),e)}}function c(){}function d(t,e){e!==!1&&F(t),f(this,t),this._d=new Date(+t._d)}function l(t){var e=v(t),n=e.year||0,a=e.quarter||0,s=e.month||0,i=e.week||0,r=e.day||0,o=e.hour||0,u=e.minute||0,c=e.second||0,d=e.millisecond||0;this._milliseconds=+d+1e3*c+6e4*u+36e5*o,this._days=+r+7*i,this._months=+s+3*a+12*n,this._data={},this._locale=De.localeData(),this._bubble()}function h(t,e){for(var a in e)n(e,a)&&(t[a]=e[a]);return n(e,"toString")&&(t.toString=e.toString),n(e,"valueOf")&&(t.valueOf=e.valueOf),t}function f(t,e){var n,a,s;if("undefined"!=typeof e._isAMomentObject&&(t._isAMomentObject=e._isAMomentObject),"undefined"!=typeof e._i&&(t._i=e._i),"undefined"!=typeof e._f&&(t._f=e._f),"undefined"!=typeof e._l&&(t._l=e._l),"undefined"!=typeof e._strict&&(t._strict=e._strict),"undefined"!=typeof e._tzm&&(t._tzm=e._tzm),"undefined"!=typeof e._isUTC&&(t._isUTC=e._isUTC),"undefined"!=typeof e._offset&&(t._offset=e._offset),"undefined"!=typeof e._pf&&(t._pf=e._pf),"undefined"!=typeof e._locale&&(t._locale=e._locale),Fe.length>0)for(n in Fe)a=Fe[n],s=e[a],"undefined"!=typeof s&&(t[a]=s);return t}function m(t){return 0>t?Math.ceil(t):Math.floor(t)}function _(t,e,n){for(var a=""+Math.abs(t),s=t>=0;a.lengtha;a++)(n&&t[a]!==e[a]||!n&&S(t[a])!==S(e[a]))&&r++;return r+i}function w(t){if(t){var e=t.toLowerCase().replace(/(.)s$/,"$1");t=on[t]||un[e]||e}return t}function v(t){var e,a,s={};for(a in t)n(t,a)&&(e=w(a),e&&(s[e]=t[a]));return s}function b(e){var n,a;if(0===e.indexOf("week"))n=7,a="day";else{if(0!==e.indexOf("month"))return;n=12,a="month"}De[e]=function(s,i){var r,o,u=De._locale[e],c=[];if("number"==typeof s&&(i=s,s=t),o=function(t){var e=De().utc().set(a,t);return u.call(De._locale,e,s||"")},null!=i)return o(i);for(r=0;n>r;r++)c.push(o(r));return c}}function S(t){var e=+t,n=0;return 0!==e&&isFinite(e)&&(n=e>=0?Math.floor(e):Math.ceil(e)),n}function T(t,e){return new Date(Date.UTC(t,e+1,0)).getUTCDate()}function O(t,e,n){return oe(De([t,11,31+e-n]),e,n).week}function W(t){return U(t)?366:365}function U(t){return t%4===0&&t%100!==0||t%400===0}function F(t){var e;t._a&&-2===t._pf.overflow&&(e=t._a[ve]<0||t._a[ve]>11?ve:t._a[be]<1||t._a[be]>T(t._a[we],t._a[ve])?be:t._a[Se]<0||t._a[Se]>23?Se:t._a[Te]<0||t._a[Te]>59?Te:t._a[Oe]<0||t._a[Oe]>59?Oe:t._a[We]<0||t._a[We]>999?We:-1,t._pf._overflowDayOfYear&&(we>e||e>be)&&(e=be),t._pf.overflow=e)}function G(t){return null==t._isValid&&(t._isValid=!isNaN(t._d.getTime())&&t._pf.overflow<0&&!t._pf.empty&&!t._pf.invalidMonth&&!t._pf.nullInput&&!t._pf.invalidFormat&&!t._pf.userInvalidated,t._strict&&(t._isValid=t._isValid&&0===t._pf.charsLeftOver&&0===t._pf.unusedTokens.length)),t._isValid}function C(t){return t?t.toLowerCase().replace("_","-"):t}function z(t){for(var e,n,a,s,i=0;i0;){if(a=x(s.slice(0,e).join("-")))return a;if(n&&n.length>=e&&Y(s,n,!0)>=e-1)break;e--}i++}return null}function x(t){var e=null;if(!Ue[t]&&Ge)try{e=De.locale(),require("./locale/"+t),De.locale(e)}catch(n){}return Ue[t]}function I(t,e){return e._isUTC?De(t).zone(e._offset||0):De(t).local()}function H(t){return t.match(/\[[\s\S]/)?t.replace(/^\[|\]$/g,""):t.replace(/\\/g,"")}function L(t){var e,n,a=t.match(Ie);for(e=0,n=a.length;n>e;e++)a[e]=fn[a[e]]?fn[a[e]]:H(a[e]);return function(s){var i="";for(e=0;n>e;e++)i+=a[e]instanceof Function?a[e].call(s,t):a[e];return i}}function P(t,e){return t.isValid()?(e=A(e,t.localeData()),cn[e]||(cn[e]=L(e)),cn[e](t)):t.localeData().invalidDate()}function A(t,e){function n(t){return e.longDateFormat(t)||t}var a=5;for(He.lastIndex=0;a>=0&&He.test(t);)t=t.replace(He,n),He.lastIndex=0,a-=1;return t}function N(t,e){var n,a=e._strict;switch(t){case"Q":return qe;case"DDDD":return Re;case"YYYY":case"GGGG":case"gggg":return a?Xe:Ae;case"Y":case"G":case"g":return Ke;case"YYYYYY":case"YYYYY":case"GGGGG":case"ggggg":return a?Be:Ne;case"S":if(a)return qe;case"SS":if(a)return Qe;case"SSS":if(a)return Re;case"DDD":return Pe;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":return je;case"a":case"A":return e._locale._meridiemParse;case"X":return Ve;case"Z":case"ZZ":return Ee;case"T":return $e;case"SSSS":return Ze;case"MM":case"DD":case"YY":case"GG":case"gg":case"HH":case"hh":case"mm":case"ss":case"ww":case"WW":return a?Qe:Le;case"M":case"D":case"d":case"H":case"h":case"m":case"s":case"w":case"W":case"e":case"E":return Le;case"Do":return Je;default:return n=new RegExp(R(Q(t.replace("\\","")),"i"))}}function Z(t){t=t||"";var e=t.match(Ee)||[],n=e[e.length-1]||[],a=(n+"").match(sn)||["-",0,0],s=+(60*a[1])+S(a[2]);return"+"===a[0]?-s:s}function j(t,e,n){var a,s=n._a;switch(t){case"Q":null!=e&&(s[ve]=3*(S(e)-1));break;case"M":case"MM":null!=e&&(s[ve]=S(e)-1);break;case"MMM":case"MMMM":a=n._locale.monthsParse(e),null!=a?s[ve]=a:n._pf.invalidMonth=e;break;case"D":case"DD":null!=e&&(s[be]=S(e));break;case"Do":null!=e&&(s[be]=S(parseInt(e,10)));break;case"DDD":case"DDDD":null!=e&&(n._dayOfYear=S(e));break;case"YY":s[we]=De.parseTwoDigitYear(e);break;case"YYYY":case"YYYYY":case"YYYYYY":s[we]=S(e);break;case"a":case"A":n._isPm=n._locale.isPM(e);break;case"H":case"HH":case"h":case"hh":s[Se]=S(e);break;case"m":case"mm":s[Te]=S(e);break;case"s":case"ss":s[Oe]=S(e);break;case"S":case"SS":case"SSS":case"SSSS":s[We]=S(1e3*("0."+e));break;case"X":n._d=new Date(1e3*parseFloat(e));break;case"Z":case"ZZ":n._useUTC=!0,n._tzm=Z(e);break;case"dd":case"ddd":case"dddd":a=n._locale.weekdaysParse(e),null!=a?(n._w=n._w||{},n._w.d=a):n._pf.invalidWeekday=e;break;case"w":case"ww":case"W":case"WW":case"d":case"e":case"E":t=t.substr(0,1);case"gggg":case"GGGG":case"GGGGG":t=t.substr(0,2),e&&(n._w=n._w||{},n._w[t]=S(e));break;case"gg":case"GG":n._w=n._w||{},n._w[t]=De.parseTwoDigitYear(e)}}function E(t){var n,a,s,i,r,o,u;n=t._w,null!=n.GG||null!=n.W||null!=n.E?(r=1,o=4,a=e(n.GG,t._a[we],oe(De(),1,4).year),s=e(n.W,1),i=e(n.E,1)):(r=t._locale._week.dow,o=t._locale._week.doy,a=e(n.gg,t._a[we],oe(De(),r,o).year),s=e(n.w,1),null!=n.d?(i=n.d,r>i&&++s):i=null!=n.e?n.e+r:r),u=ue(a,s,i,o,r),t._a[we]=u.year,t._dayOfYear=u.dayOfYear}function $(t){var n,a,s,i,r=[];if(!t._d){for(s=J(t),t._w&&null==t._a[be]&&null==t._a[ve]&&E(t),t._dayOfYear&&(i=e(t._a[we],s[we]),t._dayOfYear>W(i)&&(t._pf._overflowDayOfYear=!0),a=ae(i,0,t._dayOfYear),t._a[ve]=a.getUTCMonth(),t._a[be]=a.getUTCDate()),n=0;3>n&&null==t._a[n];++n)t._a[n]=r[n]=s[n];for(;7>n;n++)t._a[n]=r[n]=null==t._a[n]?2===n?1:0:t._a[n];t._d=(t._useUTC?ae:ne).apply(null,r),null!=t._tzm&&t._d.setUTCMinutes(t._d.getUTCMinutes()+t._tzm)}}function V(t){var e;t._d||(e=v(t._i),t._a=[e.year,e.month,e.day,e.hour,e.minute,e.second,e.millisecond],$(t))}function J(t){var e=new Date;return t._useUTC?[e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()]:[e.getFullYear(),e.getMonth(),e.getDate()]}function q(t){if(t._f===De.ISO_8601)return B(t),void 0;t._a=[],t._pf.empty=!0;var e,n,a,s,i,r=""+t._i,o=r.length,u=0;for(a=A(t._f,t._locale).match(Ie)||[],e=0;e0&&t._pf.unusedInput.push(i),r=r.slice(r.indexOf(n)+n.length),u+=n.length),fn[s]?(n?t._pf.empty=!1:t._pf.unusedTokens.push(s),j(s,n,t)):t._strict&&!n&&t._pf.unusedTokens.push(s);t._pf.charsLeftOver=o-u,r.length>0&&t._pf.unusedInput.push(r),t._isPm&&t._a[Se]<12&&(t._a[Se]+=12),t._isPm===!1&&12===t._a[Se]&&(t._a[Se]=0),$(t),F(t)}function Q(t){return t.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(t,e,n,a,s){return e||n||a||s})}function R(t){return t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function X(t){var e,n,s,i,r;if(0===t._f.length)return t._pf.invalidFormat=!0,t._d=new Date(0/0),void 0;for(i=0;ir)&&(s=r,n=e));h(t,n||e)}function B(t){var e,n,a=t._i,s=tn.exec(a);if(s){for(t._pf.iso=!0,e=0,n=nn.length;n>e;e++)if(nn[e][1].exec(a)){t._f=nn[e][0]+(s[6]||" ");break}for(e=0,n=an.length;n>e;e++)if(an[e][1].exec(a)){t._f+=an[e][0];break}a.match(Ee)&&(t._f+="Z"),q(t)}else t._isValid=!1}function K(t){B(t),t._isValid===!1&&(delete t._isValid,De.createFromInputFallback(t))}function te(t,e){var n,a=[];for(n=0;nt&&o.setFullYear(t),o}function ae(t){var e=new Date(Date.UTC.apply(null,arguments));return 1970>t&&e.setUTCFullYear(t),e}function se(t,e){if("string"==typeof t)if(isNaN(t)){if(t=e.weekdaysParse(t),"number"!=typeof t)return null}else t=parseInt(t,10);return t}function ie(t,e,n,a,s){return s.relativeTime(e||1,!!n,t,a)}function re(t,e,n){var a=De.duration(t).abs(),s=Me(a.as("s")),i=Me(a.as("m")),r=Me(a.as("h")),o=Me(a.as("d")),u=Me(a.as("M")),c=Me(a.as("y")),d=s0,d[4]=n,ie.apply({},d)}function oe(t,e,n){var a,s=n-e,i=n-t.day();return i>s&&(i-=7),s-7>i&&(i+=7),a=De(t).add(i,"d"),{week:Math.ceil(a.dayOfYear()/7),year:a.year()}}function ue(t,e,n,a,s){var i,r,o=ae(t,0,1).getUTCDay();return o=0===o?7:o,n=null!=n?n:s,i=s-o+(o>a?7:0)-(s>o?7:0),r=7*(e-1)+(n-s)+i+1,{year:r>0?t:t-1,dayOfYear:r>0?r:W(t-1)+r}}function ce(e){var n=e._i,a=e._f;return e._locale=e._locale||De.localeData(e._l),null===n||a===t&&""===n?De.invalid({nullInput:!0}):("string"==typeof n&&(e._i=n=e._locale.preparse(n)),De.isMoment(n)?new d(n,!0):(a?k(a)?X(e):q(e):ee(e),new d(e)))}function de(t,e){var n,a;if(1===e.length&&k(e[0])&&(e=e[0]),!e.length)return De();for(n=e[0],a=1;a=0?"+":"-";return e+_(Math.abs(t),6)},gg:function(){return _(this.weekYear()%100,2)},gggg:function(){return _(this.weekYear(),4)},ggggg:function(){return _(this.weekYear(),5)},GG:function(){return _(this.isoWeekYear()%100,2)},GGGG:function(){return _(this.isoWeekYear(),4)},GGGGG:function(){return _(this.isoWeekYear(),5)},e:function(){return this.weekday()},E:function(){return this.isoWeekday()},a:function(){return this.localeData().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.localeData().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return S(this.milliseconds()/100)},SS:function(){return _(S(this.milliseconds()/10),2)},SSS:function(){return _(this.milliseconds(),3)},SSSS:function(){return _(this.milliseconds(),3)},Z:function(){var t=-this.zone(),e="+";return 0>t&&(t=-t,e="-"),e+_(S(t/60),2)+":"+_(S(t)%60,2)},ZZ:function(){var t=-this.zone(),e="+";return 0>t&&(t=-t,e="-"),e+_(S(t/60),2)+_(S(t)%60,2)},z:function(){return this.zoneAbbr()},zz:function(){return this.zoneName()},X:function(){return this.unix()},Q:function(){return this.quarter()}},mn={},_n=["months","monthsShort","weekdays","weekdaysShort","weekdaysMin"];ln.length;)ge=ln.pop(),fn[ge+"o"]=u(fn[ge],ge);for(;hn.length;)ge=hn.pop(),fn[ge+ge]=o(fn[ge],2);fn.DDDD=o(fn.DDD,3),h(c.prototype,{set:function(t){var e,n;for(n in t)e=t[n],"function"==typeof e?this[n]=e:this["_"+n]=e},_months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),months:function(t){return this._months[t.month()]},_monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),monthsShort:function(t){return this._monthsShort[t.month()]},monthsParse:function(t){var e,n,a;for(this._monthsParse||(this._monthsParse=[]),e=0;12>e;e++)if(this._monthsParse[e]||(n=De.utc([2e3,e]),a="^"+this.months(n,"")+"|^"+this.monthsShort(n,""),this._monthsParse[e]=new RegExp(a.replace(".",""),"i")),this._monthsParse[e].test(t))return e},_weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdays:function(t){return this._weekdays[t.day()]},_weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysShort:function(t){return this._weekdaysShort[t.day()]},_weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),weekdaysMin:function(t){return this._weekdaysMin[t.day()]},weekdaysParse:function(t){var e,n,a;for(this._weekdaysParse||(this._weekdaysParse=[]),e=0;7>e;e++)if(this._weekdaysParse[e]||(n=De([2e3,1]).day(e),a="^"+this.weekdays(n,"")+"|^"+this.weekdaysShort(n,"")+"|^"+this.weekdaysMin(n,""),this._weekdaysParse[e]=new RegExp(a.replace(".",""),"i")),this._weekdaysParse[e].test(t))return e},_longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY LT",LLLL:"dddd, MMMM D, YYYY LT"},longDateFormat:function(t){var e=this._longDateFormat[t];return!e&&this._longDateFormat[t.toUpperCase()]&&(e=this._longDateFormat[t.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(t){return t.slice(1)}),this._longDateFormat[t]=e),e},isPM:function(t){return"p"===(t+"").toLowerCase().charAt(0)},_meridiemParse:/[ap]\.?m?\.?/i,meridiem:function(t,e,n){return t>11?n?"pm":"PM":n?"am":"AM"},_calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},calendar:function(t,e){var n=this._calendar[t];return"function"==typeof n?n.apply(e):n},_relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},relativeTime:function(t,e,n,a){var s=this._relativeTime[n];return"function"==typeof s?s(t,e,n,a):s.replace(/%d/i,t)},pastFuture:function(t,e){var n=this._relativeTime[t>0?"future":"past"];return"function"==typeof n?n(e):n.replace(/%s/i,e)},ordinal:function(t){return this._ordinal.replace("%d",t)},_ordinal:"%d",preparse:function(t){return t},postformat:function(t){return t},week:function(t){return oe(t,this._week.dow,this._week.doy).week},_week:{dow:0,doy:6},_invalidDate:"Invalid date",invalidDate:function(){return this._invalidDate}}),De=function(e,n,s,i){var r;return"boolean"==typeof s&&(i=s,s=t),r={},r._isAMomentObject=!0,r._i=e,r._f=n,r._l=s,r._strict=i,r._isUTC=!1,r._pf=a(),ce(r)},De.suppressDeprecationWarnings=!1,De.createFromInputFallback=i("moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.",function(t){t._d=new Date(t._i)}),De.min=function(){var t=[].slice.call(arguments,0);return de("isBefore",t)},De.max=function(){var t=[].slice.call(arguments,0);return de("isAfter",t)},De.utc=function(e,n,s,i){var r;return"boolean"==typeof s&&(i=s,s=t),r={},r._isAMomentObject=!0,r._useUTC=!0,r._isUTC=!0,r._l=s,r._i=e,r._f=n,r._strict=i,r._pf=a(),ce(r).utc()},De.unix=function(t){return De(1e3*t)},De.duration=function(t,e){var a,s,i,r,o=t,u=null;return De.isDuration(t)?o={ms:t._milliseconds,d:t._days,M:t._months}:"number"==typeof t?(o={},e?o[e]=t:o.milliseconds=t):(u=ze.exec(t))?(a="-"===u[1]?-1:1,o={y:0,d:S(u[be])*a,h:S(u[Se])*a,m:S(u[Te])*a,s:S(u[Oe])*a,ms:S(u[We])*a}):(u=xe.exec(t))?(a="-"===u[1]?-1:1,i=function(t){var e=t&&parseFloat(t.replace(",","."));return(isNaN(e)?0:e)*a},o={y:i(u[2]),M:i(u[3]),d:i(u[4]),h:i(u[5]),m:i(u[6]),s:i(u[7]),w:i(u[8])}):"object"==typeof o&&("from"in o||"to"in o)&&(r=y(De(o.from),De(o.to)),o={},o.ms=r.milliseconds,o.M=r.months),s=new l(o),De.isDuration(t)&&n(t,"_locale")&&(s._locale=t._locale),s},De.version=ke,De.defaultFormat=en,De.ISO_8601=function(){},De.momentProperties=Fe,De.updateOffset=function(){},De.relativeTimeThreshold=function(e,n){return dn[e]===t?!1:n===t?dn[e]:(dn[e]=n,!0)},De.lang=i("moment.lang is deprecated. Use moment.locale instead.",function(t,e){return De.locale(t,e)}),De.locale=function(t,e){var n;return t&&(n="undefined"!=typeof e?De.defineLocale(t,e):De.localeData(t),n&&(De.duration._locale=De._locale=n)),De._locale._abbr},De.defineLocale=function(t,e){return null!==e?(e.abbr=t,Ue[t]||(Ue[t]=new c),Ue[t].set(e),De.locale(t),Ue[t]):(delete Ue[t],null)},De.langData=i("moment.langData is deprecated. Use moment.localeData instead.",function(t){return De.localeData(t)}),De.localeData=function(t){var e;if(t&&t._locale&&t._locale._abbr&&(t=t._locale._abbr),!t)return De._locale;if(!k(t)){if(e=x(t))return e;t=[t]}return z(t)},De.isMoment=function(t){return t instanceof d||null!=t&&n(t,"_isAMomentObject")},De.isDuration=function(t){return t instanceof l};for(ge=_n.length-1;ge>=0;--ge)b(_n[ge]);De.normalizeUnits=function(t){return w(t)},De.invalid=function(t){var e=De.utc(0/0);return null!=t?h(e._pf,t):e._pf.userInvalidated=!0,e},De.parseZone=function(){return De.apply(null,arguments).parseZone()},De.parseTwoDigitYear=function(t){return S(t)+(S(t)>68?1900:2e3)},h(De.fn=d.prototype,{clone:function(){return De(this)},valueOf:function(){return+this._d+6e4*(this._offset||0)},unix:function(){return Math.floor(+this/1e3)},toString:function(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},toDate:function(){return this._offset?new Date(+this):this._d},toISOString:function(){var t=De(this).utc();return 00:!1},parsingFlags:function(){return h({},this._pf)},invalidAt:function(){return this._pf.overflow},utc:function(t){return this.zone(0,t)},local:function(t){return this._isUTC&&(this.zone(0,t),this._isUTC=!1,t&&this.add(this._dateTzOffset(),"m")),this},format:function(t){var e=P(this,t||De.defaultFormat);return this.localeData().postformat(e)},add:D(1,"add"),subtract:D(-1,"subtract"),diff:function(t,e,n){var a,s,i,r=I(t,this),o=6e4*(this.zone()-r.zone());return e=w(e),"year"===e||"month"===e?(a=432e5*(this.daysInMonth()+r.daysInMonth()),s=12*(this.year()-r.year())+(this.month()-r.month()),i=this-De(this).startOf("month")-(r-De(r).startOf("month")),i-=6e4*(this.zone()-De(this).startOf("month").zone()-(r.zone()-De(r).startOf("month").zone())),s+=i/a,"year"===e&&(s/=12)):(a=this-r,s="second"===e?a/1e3:"minute"===e?a/6e4:"hour"===e?a/36e5:"day"===e?(a-o)/864e5:"week"===e?(a-o)/6048e5:a),n?s:m(s)},from:function(t,e){return De.duration({to:this,from:t}).locale(this.locale()).humanize(!e)},fromNow:function(t){return this.from(De(),t)},calendar:function(t){var e=t||De(),n=I(e,this).startOf("day"),a=this.diff(n,"days",!0),s=-6>a?"sameElse":-1>a?"lastWeek":0>a?"lastDay":1>a?"sameDay":2>a?"nextDay":7>a?"nextWeek":"sameElse";return this.format(this.localeData().calendar(s,this))},isLeapYear:function(){return U(this.year())},isDST:function(){return this.zone()+t):+this.clone().startOf(e)>+De(t).startOf(e)},isBefore:function(t,e){return e=w("undefined"!=typeof e?e:"millisecond"),"millisecond"===e?(t=De.isMoment(t)?t:De(t),+t>+this):+this.clone().startOf(e)<+De(t).startOf(e)},isSame:function(t,e){return e=w(e||"millisecond"),"millisecond"===e?(t=De.isMoment(t)?t:De(t),+this===+t):+this.clone().startOf(e)===+I(t,this).startOf(e)},min:i("moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548",function(t){return t=De.apply(null,arguments),this>t?this:t}),max:i("moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548",function(t){return t=De.apply(null,arguments),t>this?this:t}),zone:function(t,e){var n,a=this._offset||0;return null==t?this._isUTC?a:this._dateTzOffset():("string"==typeof t&&(t=Z(t)),Math.abs(t)<16&&(t=60*t),!this._isUTC&&e&&(n=this._dateTzOffset()),this._offset=t,this._isUTC=!0,null!=n&&this.subtract(n,"m"),a!==t&&(!e||this._changeInProgress?g(this,De.duration(a-t,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,De.updateOffset(this,!0),this._changeInProgress=null)),this)},zoneAbbr:function(){return this._isUTC?"UTC":"" },zoneName:function(){return this._isUTC?"Coordinated Universal Time":""},parseZone:function(){return this._tzm?this.zone(this._tzm):"string"==typeof this._i&&this.zone(this._i),this},hasAlignedHourOffset:function(t){return t=t?De(t).zone():0,(this.zone()-t)%60===0},daysInMonth:function(){return T(this.year(),this.month())},dayOfYear:function(t){var e=Me((De(this).startOf("day")-De(this).startOf("year"))/864e5)+1;return null==t?e:this.add(t-e,"d")},quarter:function(t){return null==t?Math.ceil((this.month()+1)/3):this.month(3*(t-1)+this.month()%3)},weekYear:function(t){var e=oe(this,this.localeData()._week.dow,this.localeData()._week.doy).year;return null==t?e:this.add(t-e,"y")},isoWeekYear:function(t){var e=oe(this,1,4).year;return null==t?e:this.add(t-e,"y")},week:function(t){var e=this.localeData().week(this);return null==t?e:this.add(7*(t-e),"d")},isoWeek:function(t){var e=oe(this,1,4).week;return null==t?e:this.add(7*(t-e),"d")},weekday:function(t){var e=(this.day()+7-this.localeData()._week.dow)%7;return null==t?e:this.add(t-e,"d")},isoWeekday:function(t){return null==t?this.day()||7:this.day(this.day()%7?t:t-7)},isoWeeksInYear:function(){return O(this.year(),1,4)},weeksInYear:function(){var t=this.localeData()._week;return O(this.year(),t.dow,t.doy)},get:function(t){return t=w(t),this[t]()},set:function(t,e){return t=w(t),"function"==typeof this[t]&&this[t](e),this},locale:function(e){var n;return e===t?this._locale._abbr:(n=De.localeData(e),null!=n&&(this._locale=n),this)},lang:i("moment().lang() is deprecated. Use moment().localeData() instead.",function(e){return e===t?this.localeData():this.locale(e)}),localeData:function(){return this._locale},_dateTzOffset:function(){return 15*Math.round(this._d.getTimezoneOffset()/15)}}),De.fn.millisecond=De.fn.milliseconds=me("Milliseconds",!1),De.fn.second=De.fn.seconds=me("Seconds",!1),De.fn.minute=De.fn.minutes=me("Minutes",!1),De.fn.hour=De.fn.hours=me("Hours",!0),De.fn.date=me("Date",!0),De.fn.dates=i("dates accessor is deprecated. Use date instead.",me("Date",!0)),De.fn.year=me("FullYear",!0),De.fn.years=i("years accessor is deprecated. Use year instead.",me("FullYear",!0)),De.fn.days=De.fn.day,De.fn.months=De.fn.month,De.fn.weeks=De.fn.week,De.fn.isoWeeks=De.fn.isoWeek,De.fn.quarters=De.fn.quarter,De.fn.toJSON=De.fn.toISOString,h(De.duration.fn=l.prototype,{_bubble:function(){var t,e,n,a=this._milliseconds,s=this._days,i=this._months,r=this._data,o=0;r.milliseconds=a%1e3,t=m(a/1e3),r.seconds=t%60,e=m(t/60),r.minutes=e%60,n=m(e/60),r.hours=n%24,s+=m(n/24),o=m(_e(s)),s-=m(pe(o)),i+=m(s/30),s%=30,o+=m(i/12),i%=12,r.days=s,r.months=i,r.years=o},abs:function(){return this._milliseconds=Math.abs(this._milliseconds),this._days=Math.abs(this._days),this._months=Math.abs(this._months),this._data.milliseconds=Math.abs(this._data.milliseconds),this._data.seconds=Math.abs(this._data.seconds),this._data.minutes=Math.abs(this._data.minutes),this._data.hours=Math.abs(this._data.hours),this._data.months=Math.abs(this._data.months),this._data.years=Math.abs(this._data.years),this},weeks:function(){return m(this.days()/7)},valueOf:function(){return this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*S(this._months/12)},humanize:function(t){var e=re(this,!t,this.localeData());return t&&(e=this.localeData().pastFuture(+this,e)),this.localeData().postformat(e)},add:function(t,e){var n=De.duration(t,e);return this._milliseconds+=n._milliseconds,this._days+=n._days,this._months+=n._months,this._bubble(),this},subtract:function(t,e){var n=De.duration(t,e);return this._milliseconds-=n._milliseconds,this._days-=n._days,this._months-=n._months,this._bubble(),this},get:function(t){return t=w(t),this[t.toLowerCase()+"s"]()},as:function(t){var e,n;if(t=w(t),"month"===t||"year"===t)return e=this._days+this._milliseconds/864e5,n=this._months+12*_e(e),"month"===t?n:n/12;switch(e=this._days+pe(this._months/12),t){case"week":return e/7+this._milliseconds/6048e5;case"day":return e+this._milliseconds/864e5;case"hour":return 24*e+this._milliseconds/36e5;case"minute":return 24*e*60+this._milliseconds/6e4;case"second":return 24*e*60*60+this._milliseconds/1e3;case"millisecond":return Math.floor(24*e*60*60*1e3)+this._milliseconds;default:throw new Error("Unknown unit "+t)}},lang:De.fn.lang,locale:De.fn.locale,toIsoString:i("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",function(){return this.toISOString()}),toISOString:function(){var t=Math.abs(this.years()),e=Math.abs(this.months()),n=Math.abs(this.days()),a=Math.abs(this.hours()),s=Math.abs(this.minutes()),i=Math.abs(this.seconds()+this.milliseconds()/1e3);return this.asSeconds()?(this.asSeconds()<0?"-":"")+"P"+(t?t+"Y":"")+(e?e+"M":"")+(n?n+"D":"")+(a||s||i?"T":"")+(a?a+"H":"")+(s?s+"M":"")+(i?i+"S":""):"P0D"},localeData:function(){return this._locale}}),De.duration.fn.toString=De.duration.fn.toISOString;for(ge in rn)n(rn,ge)&&ye(ge.toLowerCase());return De.duration.fn.asMilliseconds=function(){return this.as("ms")},De.duration.fn.asSeconds=function(){return this.as("s")},De.duration.fn.asMinutes=function(){return this.as("m")},De.duration.fn.asHours=function(){return this.as("h")},De.duration.fn.asDays=function(){return this.as("d")},De.duration.fn.asWeeks=function(){return this.as("weeks")},De.duration.fn.asMonths=function(){return this.as("M")},De.duration.fn.asYears=function(){return this.as("y")},De.locale("en",{ordinal:function(t){var e=t%10,n=1===S(t%100/10)?"th":1===e?"st":2===e?"nd":3===e?"rd":"th";return t+n}}),De}.call(this),t.Utils.moment=n,t.datepicker}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/form-password.min.js b/lib/api/uikit/src/js/components/form-password.min.js index c5f5f8a1..8201cb76 100755 --- a/lib/api/uikit/src/js/components/form-password.min.js +++ b/lib/api/uikit/src/js/components/form-password.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var i;window.UIkit&&(i=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-form-password",["uikit"],function(){return i||t(UIkit)})}(function(t){"use strict";return t.component("formPassword",{defaults:{lblShow:"Show",lblHide:"Hide"},boot:function(){t.$html.on("click.formpassword.uikit","[data-uk-form-password]",function(i){var e=t.$(this);e.data("formPassword")||(i.preventDefault(),t.formPassword(e,t.Utils.options(e.attr("data-uk-form-password"))),e.trigger("click"))})},init:function(){var t=this;this.on("click",function(i){if(i.preventDefault(),t.input.length){var e=t.input.attr("type");t.input.attr("type","text"==e?"password":"text"),t.element.html(t.options["text"==e?"lblShow":"lblHide"])}}),this.input=this.element.next("input").length?this.element.next("input"):this.element.prev("input"),this.element.html(this.options[this.input.is("[type='password']")?"lblShow":"lblHide"]),this.element.data("formPassword",this)}}),t.formPassword}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var i;window.UIkit2&&(i=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-form-password",["uikit"],function(){return i||t(UIkit2)})}(function(t){"use strict";return t.component("formPassword",{defaults:{lblShow:"Show",lblHide:"Hide"},boot:function(){t.$html.on("click.formpassword.uikit","[data-uk-form-password]",function(i){var e=t.$(this);e.data("formPassword")||(i.preventDefault(),t.formPassword(e,t.Utils.options(e.attr("data-uk-form-password"))),e.trigger("click"))})},init:function(){var t=this;this.on("click",function(i){if(i.preventDefault(),t.input.length){var e=t.input.attr("type");t.input.attr("type","text"==e?"password":"text"),t.element.html(t.options["text"==e?"lblShow":"lblHide"])}}),this.input=this.element.next("input").length?this.element.next("input"):this.element.prev("input"),this.element.html(this.options[this.input.is('[type="password"]')?"lblShow":"lblHide"]),this.element.data("formPassword",this)}}),t.formPassword}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/form-select.min.js b/lib/api/uikit/src/js/components/form-select.min.js index 1f6e3df5..fe1a750f 100755 --- a/lib/api/uikit/src/js/components/form-select.min.js +++ b/lib/api/uikit/src/js/components/form-select.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-form-select",["uikit"],function(){return e||t(UIkit)})}(function(t){"use strict";return t.component("formSelect",{defaults:{target:">span:first",activeClass:"uk-active"},boot:function(){t.ready(function(e){t.$("[data-uk-form-select]",e).each(function(){var e=t.$(this);e.data("formSelect")||t.formSelect(e,t.Utils.options(e.attr("data-uk-form-select")))})})},init:function(){var t=this;this.target=this.find(this.options.target),this.select=this.find("select"),this.select.on({change:function(){var e=t.select[0],n=function(){try{"input"===t.options.target?t.target.val(e.options[e.selectedIndex].text):t.target.text(e.options[e.selectedIndex].text)}catch(s){}return t.element[t.select.val()?"addClass":"removeClass"](t.options.activeClass),n};return n()}(),focus:function(){t.target.addClass("uk-focus")},blur:function(){t.target.removeClass("uk-focus")},mouseenter:function(){t.target.addClass("uk-hover")},mouseleave:function(){t.target.removeClass("uk-hover")}}),this.element.data("formSelect",this)}}),t.formSelect}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var e;window.UIkit2&&(e=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-form-select",["uikit"],function(){return e||t(UIkit2)})}(function(t){"use strict";return t.component("formSelect",{defaults:{target:">span:first",activeClass:"uk-active"},boot:function(){t.ready(function(e){t.$("[data-uk-form-select]",e).each(function(){var e=t.$(this);e.data("formSelect")||t.formSelect(e,t.Utils.options(e.attr("data-uk-form-select")))})})},init:function(){var t=this;this.target=this.find(this.options.target),this.select=this.find("select"),this.select.on({change:function(){var e=t.select[0],n=function(){try{"input"===t.options.target?t.target.val(e.options[e.selectedIndex].text):t.target.text(e.options[e.selectedIndex].text)}catch(s){}return t.element[t.select.val()?"addClass":"removeClass"](t.options.activeClass),n};return n()}(),focus:function(){t.target.addClass("uk-focus")},blur:function(){t.target.removeClass("uk-focus")},mouseenter:function(){t.target.addClass("uk-hover")},mouseleave:function(){t.target.removeClass("uk-hover")}}),this.element.data("formSelect",this)}}),t.formSelect}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/grid-parallax.min.js b/lib/api/uikit/src/js/components/grid-parallax.min.js index 5e08db77..0bc309f5 100755 --- a/lib/api/uikit/src/js/components/grid-parallax.min.js +++ b/lib/api/uikit/src/js/components/grid-parallax.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var n;window.UIkit&&(n=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-grid-parallax",["uikit"],function(){return n||t(UIkit)})}(function(t){function n(t){for(var n=t.children(),i=n.filter(":visible:first"),e=i[0].offsetTop+i.outerHeight(),o=0;o=e);o++);return o||1}function i(t){var n,i,e,o=t.offset().top,r=t.outerHeight(),s=UIkit.$win.scrollTop(),a=window.innerHeight;return o>s+a?e=0:s>o+r?e=1:(a>o+r?e=(a>s?s:s-a)/(o+r):(n=s+a-o,i=Math.round(n/((a+r)/100)),e=i/100),a>o&&(e=e*s/(o+r-a))),e>1?1:e}var e=[],o=function(){requestAnimationFrame(function(){for(var t=0;t1&&i.element.css("margin-bottom",i.options.translate+parseInt(i.element.css("margin-bottom")))};return t.$(function(){e()}),t.Utils.debounce(e,50)}())},initItems:function(){var n=this.options.smooth;return this.items=(this.options.target?this.element.find(this.options.target):this.element.children()).each(function(){t.$(this).css({transition:"transform "+n+"ms linear",transform:""})}),this},process:function(){var e=i(this.element),o=n(this.element),r=this.items,s=[o-1];if(1==o||!e)return r.css("transform",""),void 0;for(;s.length=e);o++);return o||1}function i(n){var i,e,o,r=n.offset().top,s=n.outerHeight(),a=t.$win.scrollTop(),l=window.innerHeight;return r>a+l?o=0:a>r+s?o=1:(l>r+s?o=(l>a?a:a-l)/(r+s):(i=a+l-r,e=Math.round(i/((l+s)/100)),o=e/100),l>r&&(o=o*a/(r+s-l))),o>1?1:o}var e=[],o=function(){requestAnimationFrame(function(){for(var t=0;t1&&i.element.css("margin-bottom",i.options.translate+parseInt(i.element.css("margin-bottom")))};return t.$(function(){e()}),t.Utils.debounce(e,50)}())},initItems:function(){var n=this.options.smooth;return this.items=(this.options.target?this.element.find(this.options.target):this.element.children()).each(function(){t.$(this).css({transition:"transform "+n+"ms linear",transform:""})}),this},process:function(){var e=i(this.element),o=n(this.element),r=this.items,s=[o-1];if(1==o||!e)return r.css("transform",""),void 0;for(;s.lengthe;e++)if(i=h[e]+t,"string"==typeof u[i])return i}}function i(t){var i=parseFloat(t),e=-1===t.indexOf("%")&&!isNaN(i);return e&&i}function e(){}function n(){for(var t={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},i=0,e=c.length;e>i;i++){var n=c[i];t[n]=0}return t}function r(){if(!f){f=!0;var e=window.getComputedStyle;if(s=function(){var t=e?function(t){return e(t,null)}:function(t){return t.currentStyle};return function(i){var e=t(i);return e||l("Style returned "+e+". Are you running this code in a hidden iframe on Firefox? See http://bit.ly/getsizebug1"),e}}(),a=t("boxSizing")){var n=document.createElement("div");n.style.width="200px",n.style.padding="1px 2px 3px 4px",n.style.borderStyle="solid",n.style.borderWidth="1px 2px 3px 4px",n.style[a]="border-box";var r=document.body||document.documentElement;r.appendChild(n);var o=s(n);d=200===i(o.width),r.removeChild(n)}}}function o(t){if(r(),"string"==typeof t&&(t=document.querySelector(t)),t&&"object"==typeof t&&t.nodeType){var e=s(t);if("none"===e.display)return n();var o={};o.width=t.offsetWidth,o.height=t.offsetHeight;for(var h=o.isBorderBox=!(!a||!e[a]||"border-box"!==e[a]),u=0,l=c.length;l>u;u++){var f=c[u],p=e[f],g=parseFloat(p);o[f]=isNaN(g)?0:g}var m=o.paddingLeft+o.paddingRight,v=o.paddingTop+o.paddingBottom,b=o.marginLeft+o.marginRight,y=o.marginTop+o.marginBottom,k=o.borderLeftWidth+o.borderRightWidth,w=o.borderTopWidth+o.borderBottomWidth,x=h&&d,W=i(e.width);W!==!1&&(o.width=W+(x?0:m+k));var $=i(e.height);return $!==!1&&(o.height=$+(x?0:v+w)),o.innerWidth=o.width-(m+k),o.innerHeight=o.height-(v+w),o.outerWidth=o.width+b,o.outerHeight=o.height+y,o}}var s,a,d,h="Webkit Moz ms Ms O".split(" "),u=document.documentElement.style,l="undefined"==typeof console?e:function(t){console.error(t)},c=["paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"],f=!1;return o}function e(t){return i()(t)}t.component("grid",{defaults:{colwidth:"auto",animation:!0,duration:300,gutter:0,controls:!1,filter:!1,origin:t.langdirection},boot:function(){t.ready(function(i){t.$("[data-uk-grid]",i).each(function(){var i=t.$(this);i.data("grid")||t.grid(i,t.Utils.options(i.attr("data-uk-grid")))})})},init:function(){var i=this,e=String(this.options.gutter).trim().split(" ");this.gutterv=parseInt(e[0],10),this.gutterh=parseInt(e[1]||e[0],10),this.element.css({position:"relative"}),this.controls=null,this.origin=this.options.origin,this.options.controls&&(this.controls=t.$(this.options.controls),this.controls.on("click","[data-uk-filter]",function(e){e.preventDefault(),i.filter(t.$(this).attr("data-uk-filter"))}),this.controls.on("click","[data-uk-sort]",function(e){e.preventDefault();var n=t.$(this).attr("data-uk-sort").split(":");i.sort(n[0],n[1])})),t.$win.on("load resize orientationchange",t.Utils.debounce(function(){i.currentfilter?i.filter(i.currentfilter):this.update()}.bind(this),100)),this.on("display.uk.check",function(){i.element.is(":visible")&&i.update()}),t.domObserve(this.element,function(){i.update()}),this.options.filter!==!1?this.filter(this.options.filter):this.update()},_prepareElements:function(){var t,i=this.element.children(":not([data-grid-prepared])");i.length&&(t={position:"absolute","box-sizing":"border-box",width:"auto"==this.options.colwidth?"":this.options.colwidth},this.options.gutter&&(t["padding-"+this.origin]=this.gutterh,t["padding-bottom"]=this.gutterv,this.element.css("margin-"+this.origin,-1*this.gutterh)),i.attr("data-grid-prepared","true").css(t))},update:function(i){var n=this;this._prepareElements(),i=i||this.element.children(":visible");var r,o,s,a,d,h,u,l,c,f=i,p=this.element.width()+2*this.gutterh+2,g=0,m=0,v=[];this.trigger("beforeupdate.uk.grid",[f]),f.each(function(){for(c=e(this),r=t.$(this),o=c.outerWidth,s=c.outerHeight,g=0,m=0,h=0,l=v.length;l>h;h++)a=v[h],g<=a.aX&&(g=a.aX),g+o>p&&(g=0),m<=a.aY&&(m=a.aY);d={ele:r,top:m,width:o,height:s,aY:m+s,aX:g+o},d[n.origin]=g,v.push(d)});var b,y,k=0;for(h=0,l=v.length;l>h;h++){for(a=v[h],m=0,u=0;h>u;u++)b=v[u],a[this.origin]-1&&(o=!0)})),r[o?"visible":"hidden"].push(e)}),r.hidden=t.$(r.hidden).map(function(){return this[0]}),r.visible=t.$(r.visible).map(function(){return this[0]}),r.hidden.attr("aria-hidden","true").filter(":visible").fadeOut(this.options.duration),r.visible.attr("aria-hidden","false").filter(":hidden").css("opacity",0).show(),e.update(r.visible),this.controls&&this.controls.length&&this.controls.find("[data-uk-filter]").removeClass("uk-active").filter('[data-uk-filter="'+i+'"]').addClass("uk-active")},sort:function(i,e){e=e||1,"string"==typeof e&&(e="desc"==e.toLowerCase()?-1:1);var n=this.element.children();n.sort(function(n,r){return n=t.$(n),r=t.$(r),(r.data(i)||"")<(n.data(i)||"")?e:-1*e}).appendTo(this.element),this.update(n.filter(":visible")),this.controls&&this.controls.length&&this.controls.find("[data-uk-sort]").removeClass("uk-active").filter('[data-uk-sort="'+i+":"+(-1==e?"desc":"asc")+'"]').addClass("uk-active")}})}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var i;window.UIkit2&&(i=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-grid",["uikit"],function(){return i||t(UIkit2)})}(function(t){"use strict";t.component("grid",{defaults:{colwidth:"auto",animation:!0,duration:300,gutter:0,controls:!1,filter:!1,origin:t.langdirection},boot:function(){t.ready(function(i){t.$("[data-uk-grid]",i).each(function(){var i=t.$(this);i.data("grid")||t.grid(i,t.Utils.options(i.attr("data-uk-grid")))})})},init:function(){var i=this,e=String(this.options.gutter).trim().split(" ");this.gutterv=parseInt(e[0],10),this.gutterh=parseInt(e[1]||e[0],10),this.element.css({position:"relative"}),this.controls=null,this.origin=this.options.origin,this.options.controls&&(this.controls=t.$(this.options.controls),this.controls.on("click","[data-uk-filter]",function(e){e.preventDefault(),i.filter(t.$(this).attr("data-uk-filter"))}),this.controls.on("click","[data-uk-sort]",function(e){e.preventDefault();var n=t.$(this).attr("data-uk-sort").split(":");i.sort(n[0],n[1])})),t.$win.on("load resize orientationchange",t.Utils.debounce(function(){i.currentfilter?i.filter(i.currentfilter):this.update()}.bind(this),100)),this.on("display.uk.check",function(){i.element.is(":visible")&&i.update()}),t.domObserve(this.element,function(){i.update()}),this.options.filter!==!1?this.filter(this.options.filter):this.update()},_prepareElements:function(){var t,i=this.element.children().not("[data-grid-prepared]");i.length&&(t={position:"absolute",boxSizing:"border-box",width:"auto"==this.options.colwidth?"":this.options.colwidth},this.options.gutter&&(t["padding-"+this.origin]=this.gutterh,t["padding-bottom"]=this.gutterv,this.element.css("margin-"+this.origin,-1*this.gutterh)),i.attr("data-grid-prepared","true").css(t))},update:function(i){var e=this;this._prepareElements(),i=i||this.element.children(":visible");var n,o,s,r,a,h,d,l,u,c=i,f=this.element.width()+2*this.gutterh+2,p=0,g=0,m=[];this.trigger("beforeupdate.uk.grid",[c]),c.each(function(){for(n=t.$(this),u=this.getBoundingClientRect(),o=u.width,s=u.height,p=0,g=0,h=0,l=m.length;l>h;h++)r=m[h],p<=r.aX&&(p=r.aX),p+o>f&&(p=0),g<=r.aY&&(g=r.aY);a={ele:n,top:g,width:o,height:s,aY:g+s,aX:p+o},a[e.origin]=p,m.push(a)});var v,k,b=0;for(h=0,l=m.length;l>h;h++){for(r=m[h],g=0,d=0;h>d;d++)v=m[d],r[this.origin]-1&&(s=!0)})),o[s?"visible":"hidden"].push(e)}),o.hidden=t.$(o.hidden).map(function(){return this[0]}),o.visible=t.$(o.visible).map(function(){return this[0]}),o.hidden.attr("aria-hidden","true").filter(":visible").fadeOut(this.options.duration),o.visible.attr("aria-hidden","false").filter(":hidden").css("opacity",0).show(),e.update(o.visible),this.controls&&this.controls.length&&this.controls.find("[data-uk-filter]").removeClass("uk-active").filter('[data-uk-filter="'+i+'"]').addClass("uk-active")},sort:function(i,e){e=e||1,"string"==typeof e&&(e="desc"==e.toLowerCase()?-1:1);var n=this.element.children();n.sort(function(n,o){return n=t.$(n),o=t.$(o),(o.data(i)||"")<(n.data(i)||"")?e:-1*e}).appendTo(this.element),this.update(n.filter(":visible")),this.controls&&this.controls.length&&this.controls.find("[data-uk-sort]").removeClass("uk-active").filter('[data-uk-sort="'+i+":"+(-1==e?"desc":"asc")+'"]').addClass("uk-active")}})}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/htmleditor.min.js b/lib/api/uikit/src/js/components/htmleditor.min.js index 38105854..14d99ebb 100755 --- a/lib/api/uikit/src/js/components/htmleditor.min.js +++ b/lib/api/uikit/src/js/components/htmleditor.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-htmleditor",["uikit"],function(){return e||t(UIkit)})}(function(t){"use strict";var e=[];return t.component("htmleditor",{defaults:{iframe:!1,mode:"split",markdown:!1,autocomplete:!0,enablescripts:!1,height:500,maxsplitsize:1e3,codemirror:{mode:"htmlmixed",lineWrapping:!0,dragDrop:!1,autoCloseTags:!0,matchTags:!0,autoCloseBrackets:!0,matchBrackets:!0,indentUnit:4,indentWithTabs:!1,tabSize:4,hintOptions:{completionSingle:!1}},toolbar:["bold","italic","strike","link","image","blockquote","listUl","listOl"],lblPreview:"Preview",lblCodeview:"HTML",lblMarkedview:"Markdown"},boot:function(){t.ready(function(e){t.$("textarea[data-uk-htmleditor]",e).each(function(){var e=t.$(this);e.data("htmleditor")||t.htmleditor(e,t.Utils.options(e.attr("data-uk-htmleditor")))})})},init:function(){var i=this,o=t.components.htmleditor.template;this.CodeMirror=this.options.CodeMirror||CodeMirror,this.buttons={},o=o.replace(/\{:lblPreview}/g,this.options.lblPreview),o=o.replace(/\{:lblCodeview}/g,this.options.lblCodeview),this.htmleditor=t.$(o),this.content=this.htmleditor.find(".uk-htmleditor-content"),this.toolbar=this.htmleditor.find(".uk-htmleditor-toolbar"),this.preview=this.htmleditor.find(".uk-htmleditor-preview").children().eq(0),this.code=this.htmleditor.find(".uk-htmleditor-code"),this.element.before(this.htmleditor).appendTo(this.code),this.editor=this.CodeMirror.fromTextArea(this.element[0],this.options.codemirror),this.editor.htmleditor=this,this.editor.on("change",t.Utils.debounce(function(){i.render()},150)),this.editor.on("change",function(){i.editor.save(),i.element.trigger("input")}),this.code.find(".CodeMirror").css("height",this.options.height),this.options.iframe?(this.iframe=t.$(''),this.preview.append(this.iframe),this.iframe[0].contentWindow.document.open(),this.iframe[0].contentWindow.document.close(),this.preview.container=t.$(this.iframe[0].contentWindow.document).find("body"),"string"==typeof this.options.iframe&&this.preview.container.parent().append('')):this.preview.container=this.preview,t.$win.on("resize load",t.Utils.debounce(function(){i.fit()},200));var n=this.iframe?this.preview.container:i.preview.parent(),r=this.code.find(".CodeMirror-sizer"),l=this.code.find(".CodeMirror-scroll").on("scroll",t.Utils.debounce(function(){if("tab"!=i.htmleditor.attr("data-mode")){var t=r.height()-l.height(),e=n[0].scrollHeight-(i.iframe?i.iframe.height():n.height()),o=e/t,s=l.scrollTop()*o;n.scrollTop(s)}},10));this.htmleditor.on("click",".uk-htmleditor-button-code, .uk-htmleditor-button-preview",function(e){e.preventDefault(),"tab"==i.htmleditor.attr("data-mode")&&(i.htmleditor.find(".uk-htmleditor-button-code, .uk-htmleditor-button-preview").removeClass("uk-active").filter(this).addClass("uk-active"),i.activetab=t.$(this).hasClass("uk-htmleditor-button-code")?"code":"preview",i.htmleditor.attr("data-active-tab",i.activetab),i.editor.refresh())}),this.htmleditor.on("click","a[data-htmleditor-button]",function(){i.code.is(":visible")&&i.trigger("action."+t.$(this).data("htmleditor-button"),[i.editor])}),this.preview.parent().css("height",this.code.height()),this.options.autocomplete&&this.CodeMirror.showHint&&this.CodeMirror.hint&&this.CodeMirror.hint.html&&this.editor.on("inputRead",t.Utils.debounce(function(){var t=i.editor.getDoc(),e=t.getCursor(),o=i.CodeMirror.innerMode(i.editor.getMode(),i.editor.getTokenAt(e).state).mode.name;if("xml"==o){var n=i.editor.getCursor(),r=i.editor.getTokenAt(n);("<"==r.string.charAt(0)||"attribute"==r.type)&&i.CodeMirror.showHint(i.editor,i.CodeMirror.hint.html,{completeSingle:!1})}},100)),this.debouncedRedraw=t.Utils.debounce(function(){i.redraw()},5),this.on("init.uk.component",function(){i.debouncedRedraw()}),this.element.attr("data-uk-check-display",1).on("display.uk.check",function(){this.htmleditor.is(":visible")&&this.fit()}.bind(this)),e.push(this)},addButton:function(t,e){this.buttons[t]=e},addButtons:function(e){t.$.extend(this.buttons,e)},replaceInPreview:function(t,e){function i(t){var e=o.getValue().substring(0,t).split("\n");return{line:e.length-1,ch:e[e.length-1].length}}var o=this.editor,n=[],r=o.getValue(),l=-1,s=0;return this.currentvalue=this.currentvalue.replace(t,function(){l=r.indexOf(arguments[0],++l);var t={matches:arguments,from:i(l),to:i(l+arguments[0].length),replace:function(e){o.replaceRange(e,t.from,t.to)},inRange:function(e){return e.line===t.from.line&&e.line===t.to.line?e.ch>=t.from.ch&&e.ch=t.from.ch||e.line>t.from.line&&e.line'+t.buttons[i].label+"")}}),this.toolbar.html(e.join("\n"))}},fit:function(){var t=this.options.mode;"split"==t&&this.htmleditor.width())<[^<]*)*<\/(script|style)>/gim,"")),this.currentvalue?(this.trigger("render",[this]),this.trigger("renderLate",[this]),this.preview.container.html(this.currentvalue),void 0):(this.element.val(""),this.preview.container.html(""),void 0)},addShortcut:function(e,i){var o={};return t.$.isArray(e)||(e=[e]),e.forEach(function(t){o[t]=i}),this.editor.addKeyMap(o),o},addShortcutAction:function(t,e){var i=this;this.addShortcut(e,function(){i.element.trigger("action."+t,[i.editor])})},replaceSelection:function(t){var e=this.editor.getSelection();if(!e.length){for(var i=this.editor.getCursor(),o=this.editor.getLine(i.line),n=i.ch,r=n;r','
    ','
      ','
      ','","
      ","
      ",'
      ','
      ','
      ',"
      ",""].join(""),t.plugin("htmleditor","base",{init:function(e){function i(t,i,o){e.on("action."+t,function(){"html"==e.getCursorMode()&&e["replaceLine"==o?"replaceLine":"replaceSelection"](i)})}e.addButtons({fullscreen:{title:"Fullscreen",label:''},bold:{title:"Bold",label:''},italic:{title:"Italic",label:''},strike:{title:"Strikethrough",label:''},blockquote:{title:"Blockquote",label:''},link:{title:"Link",label:''},image:{title:"Image",label:''},listUl:{title:"Unordered List",label:''},listOl:{title:"Ordered List",label:''}}),i("bold","$1"),i("italic","$1"),i("strike","$1"),i("blockquote","

      $1

      ","replaceLine"),i("link",'$1'),i("image",'$1');var o=function(t){if("html"==e.getCursorMode()){t=t||"ul";for(var i=e.editor,o=i.getDoc(),n=o.getCursor(!0),r=o.getCursor(!1),l=CodeMirror.innerMode(i.getMode(),i.getTokenAt(i.getCursor()).state),s=l&&l.state&&l.state.context&&-1!=["ul","ol"].indexOf(l.state.context.tagName),a=n.line;a"+i.getLine(a)+"",{line:a,ch:0},{line:a,ch:i.getLine(a).length});s?i.setCursor({line:r.line,ch:i.getLine(r.line).length}):(i.replaceRange("<"+t+">\n"+i.getLine(n.line),{line:n.line,ch:0},{line:n.line,ch:i.getLine(n.line).length}),i.replaceRange(i.getLine(r.line+1)+"\n",{line:r.line+1,ch:0},{line:r.line+1,ch:i.getLine(r.line+1).length}),i.setCursor({line:r.line+1,ch:i.getLine(r.line+1).length})),i.focus()}};e.on("action.listUl",function(){o("ul")}),e.on("action.listOl",function(){o("ol")}),e.htmleditor.on("click",'a[data-htmleditor-button="fullscreen"]',function(){e.htmleditor.toggleClass("uk-htmleditor-fullscreen");var i=e.editor.getWrapperElement();if(e.htmleditor.hasClass("uk-htmleditor-fullscreen")){var o=!1,n=e.htmleditor.parents().each(function(){"fixed"!=t.$(this).css("position")||t.$(this).is("html")||(o=t.$(this))});if(e.htmleditor.data("fixedParents",!1),o){var r=[];o=o.parent().find(n).each(function(){"none"!=t.$(this).css("transform")&&r.push(t.$(this).data("transform-reset",{transform:this.style.transform,"-webkit-transform":this.style.webkitTransform,"-webkit-transition":this.style.webkitTransition,transition:this.style.transition}).css({transform:"none","-webkit-transform":"none","-webkit-transition":"none",transition:"none"}))}),e.htmleditor.data("fixedParents",r)}e.editor.state.fullScreenRestore={scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,width:i.style.width,height:i.style.height},i.style.width="",i.style.height=e.content.height()+"px",document.documentElement.style.overflow="hidden"}else{document.documentElement.style.overflow="";var l=e.editor.state.fullScreenRestore;i.style.width=l.width,i.style.height=l.height,window.scrollTo(l.scrollLeft,l.scrollTop),e.htmleditor.data("fixedParents")&&e.htmleditor.data("fixedParents").forEach(function(t){t.css(t.data("transform-reset"))})}setTimeout(function(){e.fit(),t.$win.trigger("resize")},50)}),e.addShortcut(["Ctrl-S","Cmd-S"],function(){e.element.trigger("htmleditor-save",[e])}),e.addShortcutAction("bold",["Ctrl-B","Cmd-B"])}}),t.plugin("htmleditor","markdown",{init:function(e){function i(){e.editor.setOption("mode","gfm"),e.htmleditor.find(".uk-htmleditor-button-code a").html(e.options.lblMarkedview)}function o(t,i,o){e.on("action."+t,function(){"markdown"==e.getCursorMode()&&e["replaceLine"==o?"replaceLine":"replaceSelection"](i)})}var n=e.options.mdparser||window.marked||null;n&&(e.options.markdown&&i(),o("bold","**$1**"),o("italic","*$1*"),o("strike","~~$1~~"),o("blockquote","> $1","replaceLine"),o("link","[$1](http://)"),o("image","![$1](http://)"),e.on("action.listUl",function(){if("markdown"==e.getCursorMode()){for(var t=e.editor,i=t.getDoc().getCursor(!0),o=t.getDoc().getCursor(!1),n=i.line;n0){var r,l=t.getLine(i.line-1);(r=l.match(/^(\d+)\./))&&(n=Number(r[1])+1)}for(var s=i.line;s'),this.preview.append(this.iframe),this.iframe[0].contentWindow.document.open(),this.iframe[0].contentWindow.document.close(),this.preview.container=t.$(this.iframe[0].contentWindow.document).find("body"),"string"==typeof this.options.iframe&&this.preview.container.parent().append('')):this.preview.container=this.preview,t.$win.on("resize load",t.Utils.debounce(function(){i.fit()},200));var n=this.iframe?this.preview.container:i.preview.parent(),r=this.code.find(".CodeMirror-sizer"),l=this.code.find(".CodeMirror-scroll").on("scroll",t.Utils.debounce(function(){if("tab"!=i.htmleditor.attr("data-mode")){var t=r.height()-l.height(),e=n[0].scrollHeight-(i.iframe?i.iframe.height():n.height()),o=e/t,s=l.scrollTop()*o;n.scrollTop(s)}},10));this.htmleditor.on("click",".uk-htmleditor-button-code, .uk-htmleditor-button-preview",function(e){e.preventDefault(),"tab"==i.htmleditor.attr("data-mode")&&(i.htmleditor.find(".uk-htmleditor-button-code, .uk-htmleditor-button-preview").removeClass("uk-active").filter(this).addClass("uk-active"),i.activetab=t.$(this).hasClass("uk-htmleditor-button-code")?"code":"preview",i.htmleditor.attr("data-active-tab",i.activetab),i.editor.refresh())}),this.htmleditor.on("click","a[data-htmleditor-button]",function(){i.code.is(":visible")&&i.trigger("action."+t.$(this).data("htmleditor-button"),[i.editor])}),this.preview.parent().css("height",this.code.height()),this.options.autocomplete&&this.CodeMirror.showHint&&this.CodeMirror.hint&&this.CodeMirror.hint.html&&this.editor.on("inputRead",t.Utils.debounce(function(){var t=i.editor.getDoc(),e=t.getCursor(),o=i.CodeMirror.innerMode(i.editor.getMode(),i.editor.getTokenAt(e).state).mode.name;if("xml"==o){var n=i.editor.getCursor(),r=i.editor.getTokenAt(n);("<"==r.string.charAt(0)||"attribute"==r.type)&&i.CodeMirror.showHint(i.editor,i.CodeMirror.hint.html,{completeSingle:!1})}},100)),this.debouncedRedraw=t.Utils.debounce(function(){i.redraw()},5),this.on("init.uk.component",function(){i.debouncedRedraw()}),this.element.attr("data-uk-check-display",1).on("display.uk.check",function(){this.htmleditor.is(":visible")&&this.fit()}.bind(this)),e.push(this)},addButton:function(t,e){this.buttons[t]=e},addButtons:function(e){t.$.extend(this.buttons,e)},replaceInPreview:function(t,e){function i(t){var e=o.getValue().substring(0,t).split("\n");return{line:e.length-1,ch:e[e.length-1].length}}var o=this.editor,n=[],r=o.getValue(),l=-1,s=0;return this.currentvalue=this.currentvalue.replace(t,function(){l=r.indexOf(arguments[0],++l);var t={matches:arguments,from:i(l),to:i(l+arguments[0].length),replace:function(e){o.replaceRange(e,t.from,t.to)},inRange:function(e){return e.line===t.from.line&&e.line===t.to.line?e.ch>=t.from.ch&&e.ch=t.from.ch||e.line>t.from.line&&e.line'+t.buttons[i].label+"")}}),this.toolbar.html(e.join("\n"))}},fit:function(){var t=this.options.mode;"split"==t&&this.htmleditor.width())<[^<]*)*<\/(script|style)>/gim,"")),this.currentvalue?(this.trigger("render",[this]),this.trigger("renderLate",[this]),this.preview.container.html(this.currentvalue),void 0):(this.element.val(""),this.preview.container.html(""),void 0)},addShortcut:function(e,i){var o={};return t.$.isArray(e)||(e=[e]),e.forEach(function(t){o[t]=i}),this.editor.addKeyMap(o),o},addShortcutAction:function(t,e){var i=this;this.addShortcut(e,function(){i.element.trigger("action."+t,[i.editor])})},replaceSelection:function(t){var e=this.editor.getSelection();if(!e.length){for(var i=this.editor.getCursor(),o=this.editor.getLine(i.line),n=i.ch,r=n;r','
      ','
        ','
        ','","
        ","
        ",'
        ','
        ','
        ',"
        ",""].join(""),t.plugin("htmleditor","base",{init:function(e){function i(t,i,o){e.on("action."+t,function(){"html"==e.getCursorMode()&&e["replaceLine"==o?"replaceLine":"replaceSelection"](i)})}e.addButtons({fullscreen:{title:"Fullscreen",label:''},bold:{title:"Bold",label:''},italic:{title:"Italic",label:''},strike:{title:"Strikethrough",label:''},blockquote:{title:"Blockquote",label:''},link:{title:"Link",label:''},image:{title:"Image",label:''},listUl:{title:"Unordered List",label:''},listOl:{title:"Ordered List",label:''}}),i("bold","$1"),i("italic","$1"),i("strike","$1"),i("blockquote","

        $1

        ","replaceLine"),i("link",'$1'),i("image",'$1');var o=function(t){if("html"==e.getCursorMode()){t=t||"ul";for(var i=e.editor,o=i.getDoc(),n=o.getCursor(!0),r=o.getCursor(!1),l=CodeMirror.innerMode(i.getMode(),i.getTokenAt(i.getCursor()).state),s=l&&l.state&&l.state.context&&-1!=["ul","ol"].indexOf(l.state.context.tagName),a=n.line;a"+i.getLine(a)+"",{line:a,ch:0},{line:a,ch:i.getLine(a).length});s?i.setCursor({line:r.line,ch:i.getLine(r.line).length}):(i.replaceRange("<"+t+">\n"+i.getLine(n.line),{line:n.line,ch:0},{line:n.line,ch:i.getLine(n.line).length}),i.replaceRange(i.getLine(r.line+1)+"\n",{line:r.line+1,ch:0},{line:r.line+1,ch:i.getLine(r.line+1).length}),i.setCursor({line:r.line+1,ch:i.getLine(r.line+1).length})),i.focus()}};e.on("action.listUl",function(){o("ul")}),e.on("action.listOl",function(){o("ol")}),e.htmleditor.on("click",'a[data-htmleditor-button="fullscreen"]',function(){e.htmleditor.toggleClass("uk-htmleditor-fullscreen");var i=e.editor.getWrapperElement();if(e.htmleditor.hasClass("uk-htmleditor-fullscreen")){var o=!1,n=e.htmleditor.parents().each(function(){"fixed"!=t.$(this).css("position")||t.$(this).is("html")||(o=t.$(this))});if(e.htmleditor.data("fixedParents",!1),o){var r=[];o=o.parent().find(n).each(function(){"none"!=t.$(this).css("transform")&&r.push(t.$(this).data("transform-reset",{transform:this.style.transform,"-webkit-transform":this.style.webkitTransform,"-webkit-transition":this.style.webkitTransition,transition:this.style.transition}).css({transform:"none","-webkit-transform":"none","-webkit-transition":"none",transition:"none"}))}),e.htmleditor.data("fixedParents",r)}e.editor.state.fullScreenRestore={scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,width:i.style.width,height:i.style.height},i.style.width="",i.style.height=e.content.height()+"px",document.documentElement.style.overflow="hidden"}else{document.documentElement.style.overflow="";var l=e.editor.state.fullScreenRestore;i.style.width=l.width,i.style.height=l.height,window.scrollTo(l.scrollLeft,l.scrollTop),e.htmleditor.data("fixedParents")&&e.htmleditor.data("fixedParents").forEach(function(t){t.css(t.data("transform-reset"))})}setTimeout(function(){e.fit(),t.$win.trigger("resize")},50)}),e.addShortcut(["Ctrl-S","Cmd-S"],function(){e.element.trigger("htmleditor-save",[e])}),e.addShortcutAction("bold",["Ctrl-B","Cmd-B"])}}),t.plugin("htmleditor","markdown",{init:function(e){function i(){e.editor.setOption("mode","gfm"),e.htmleditor.find(".uk-htmleditor-button-code a").html(e.options.lblMarkedview)}function o(t,i,o){e.on("action."+t,function(){"markdown"==e.getCursorMode()&&e["replaceLine"==o?"replaceLine":"replaceSelection"](i)})}var n=e.options.mdparser||window.marked||null;n&&(e.options.markdown&&i(),o("bold","**$1**"),o("italic","*$1*"),o("strike","~~$1~~"),o("blockquote","> $1","replaceLine"),o("link","[$1](http://)"),o("image","![$1](http://)"),e.on("action.listUl",function(){if("markdown"==e.getCursorMode()){for(var t=e.editor,i=t.getDoc().getCursor(!0),o=t.getDoc().getCursor(!1),n=i.line;n0){var r,l=t.getLine(i.line-1);(r=l.match(/^(\d+)\./))&&(n=Number(r[1])+1)}for(var s=i.line;s','
        ','','
        ','
        ',"
        ",""].join("")).appendTo("body"),e.dialog=e.find(".uk-modal-dialog:first"),e.content=e.find(".uk-lightbox-content:first"),e.loader=e.find(".uk-modal-spinner:first"),e.closer=e.find(".uk-close.uk-close-alt"),e.modal=i.modal(e,{modal:!1}),e.on("swipeRight swipeLeft",function(i){e.lightbox["swipeLeft"==i.type?"next":"previous"]()}).on("click","[data-lightbox-previous], [data-lightbox-next]",function(t){t.preventDefault(),e.lightbox[i.$(this).is("[data-lightbox-next]")?"next":"previous"]()}),e.on("hide.uk.modal",function(){e.content.html("")});var o={w:window.innerWidth,h:window.innerHeight};return i.$win.on("load resize orientationchange",i.Utils.debounce(function(){o.w!==window.innerWidth&&e.is(":visible")&&!i.Utils.isFullscreen()&&e.lightbox.fitSize(),o={w:window.innerWidth,h:window.innerHeight}},100)),e.lightbox=t,e}var e,o={};return i.component("lightbox",{defaults:{allowfullscreen:!0,duration:400,group:!1,keyboard:!0},index:0,items:!1,boot:function(){i.$html.on("click","[data-uk-lightbox]",function(t){t.preventDefault();var e=i.$(this);e.data("lightbox")||i.lightbox(e,i.Utils.options(e.attr("data-uk-lightbox"))),e.data("lightbox").show(e)}),i.$doc.on("keyup",function(i){if(e&&e.is(":visible")&&e.lightbox.options.keyboard)switch(i.preventDefault(),i.keyCode){case 37:e.lightbox.previous();break;case 39:e.lightbox.next()}})},init:function(){var t=[];if(this.index=0,this.siblings=[],this.element&&this.element.length){var e=this.options.group?i.$(['[data-uk-lightbox*="'+this.options.group+'"]',"[data-uk-lightbox*='"+this.options.group+"']"].join(",")):this.element;e.each(function(){var e=i.$(this);t.push({source:e.attr("href"),title:e.attr("data-title")||e.attr("title"),type:e.attr("data-lightbox-type")||"auto",link:e})}),this.index=e.index(this.element),this.siblings=t}else this.options.group&&this.options.group.length&&(this.siblings=this.options.group);this.trigger("lightbox-init",[this])},show:function(e){this.modal=t(this),this.modal.dialog.stop(),this.modal.content.stop();var o,n,s=this,h=i.$.Deferred();e=e||0,"object"==typeof e&&this.siblings.forEach(function(i,t){e[0]===i.link[0]&&(e=t)}),0>e?e=this.siblings.length-e:this.siblings[e]||(e=0),n=this.siblings[e],o={lightbox:s,source:n.source,type:n.type,index:e,promise:h,title:n.title,item:n,meta:{content:"",width:null,height:null}},this.index=e,this.modal.content.empty(),this.modal.is(":visible")||(this.modal.content.css({width:"",height:""}).empty(),this.modal.modal.show()),this.modal.loader.removeClass("uk-hidden"),h.promise().done(function(){s.data=o,s.fitSize(o)}).fail(function(){o.meta.content='
        Loading resource failed!
        ',o.meta.width=400,o.meta.height=300,s.data=o,s.fitSize(o)}),s.trigger("showitem.uk.lightbox",[o])},fitSize:function(){var t=this,e=this.data,o=this.modal.dialog.outerWidth()-this.modal.dialog.width(),n=parseInt(this.modal.dialog.css("margin-top"),10),s=parseInt(this.modal.dialog.css("margin-bottom"),10),h=n+s,a=e.meta.content,l=t.options.duration;this.siblings.length>1&&(a=[a,'',''].join(""));var d,r,u=i.$("
         
        ").css({opacity:0,position:"absolute",top:0,left:0,width:"100%","max-width":t.modal.dialog.css("max-width"),padding:t.modal.dialog.css("padding"),margin:t.modal.dialog.css("margin")}),c=e.meta.width,g=e.meta.height;u.appendTo("body").width(),d=u.width(),r=window.innerHeight-h,u.remove(),this.modal.dialog.find(".uk-modal-caption").remove(),e.title&&(this.modal.dialog.append('
        '+e.title+"
        "),r-=this.modal.dialog.find(".uk-modal-caption").outerHeight()),dr&&(g=Math.floor(r),c=Math.ceil(e.meta.width*(r/e.meta.height))),this.modal.content.css("opacity",0).width(c).html(a),"iframe"==e.type&&this.modal.content.find("iframe:first").height(g);var m=g+o,p=Math.floor(window.innerHeight/2-m/2)-h;0>p&&(p=0),this.modal.closer.addClass("uk-hidden"),t.modal.data("mwidth")==c&&t.modal.data("mheight")==g&&(l=0),this.modal.dialog.animate({width:c+o,height:g+o,top:p},l,"swing",function(){t.modal.loader.addClass("uk-hidden"),t.modal.content.css({width:""}).animate({opacity:1},function(){t.modal.closer.removeClass("uk-hidden")}),t.modal.data({mwidth:c,mheight:g})})},next:function(){this.show(this.siblings[this.index+1]?this.index+1:0)},previous:function(){this.show(this.siblings[this.index-1]?this.index-1:this.siblings.length-1)}}),i.plugin("lightbox","image",{init:function(i){i.on("showitem.uk.lightbox",function(i,t){if("image"==t.type||t.source&&t.source.match(/\.(jpg|jpeg|png|gif|svg)$/i)){var e=function(i,e,o){t.meta={content:'',width:e,height:o},t.type="image",t.promise.resolve()};if(o[t.source])e(t.source,o[t.source].width,o[t.source].height);else{var n=new Image;n.onerror=function(){t.promise.reject("Loading image failed")},n.onload=function(){o[t.source]={width:n.width,height:n.height},e(t.source,o[t.source].width,o[t.source].height)},n.src=t.source}}})}}),i.plugin("lightbox","youtube",{init:function(i){var t=/(\/\/.*?youtube\.[a-z]+)\/watch\?v=([^&]+)&?(.*)/,n=/youtu\.be\/(.*)/;i.on("showitem.uk.lightbox",function(i,s){var h,a,l=function(i,t,o){s.meta={content:'",width:t,height:o},s.type="iframe",s.promise.resolve()};if((a=s.source.match(t))&&(h=a[2]),(a=s.source.match(n))&&(h=a[1]),h){if(o[h])l(h,o[h].width,o[h].height);else{var d=new Image,r=!1;d.onerror=function(){o[h]={width:640,height:320},l(h,o[h].width,o[h].height)},d.onload=function(){120==d.width&&90==d.height?r?(o[h]={width:640,height:320},l(h,o[h].width,o[h].height)):(r=!0,d.src="//img.youtube.com/vi/"+h+"/0.jpg"):(o[h]={width:d.width,height:d.height},l(h,d.width,d.height))},d.src="//img.youtube.com/vi/"+h+"/maxresdefault.jpg"}i.stopImmediatePropagation()}})}}),i.plugin("lightbox","vimeo",{init:function(t){var n,s=/(\/\/.*?)vimeo\.[a-z]+\/([0-9]+).*?/;t.on("showitem.uk.lightbox",function(t,h){var a,l=function(i,t,o){h.meta={content:'",width:t,height:o},h.type="iframe",h.promise.resolve()};(n=h.source.match(s))&&(a=n[2],o[a]?l(a,o[a].width,o[a].height):i.$.ajax({type:"GET",url:"//vimeo.com/api/oembed.json?url="+encodeURI(h.source),jsonp:"callback",dataType:"jsonp",success:function(i){o[a]={width:i.width,height:i.height},l(a,o[a].width,o[a].height)}}),t.stopImmediatePropagation())})}}),i.plugin("lightbox","video",{init:function(t){t.on("showitem.uk.lightbox",function(t,e){var n=function(i,t,o){e.meta={content:'',width:t,height:o},e.type="video",e.promise.resolve()};if("video"==e.type||e.source.match(/\.(mp4|webm|ogv)$/i))if(o[e.source])n(e.source,o[e.source].width,o[e.source].height);else var s=i.$('').attr("src",e.source).appendTo("body"),h=setInterval(function(){s[0].videoWidth&&(clearInterval(h),o[e.source]={width:s[0].videoWidth,height:s[0].videoHeight},n(e.source,o[e.source].width,o[e.source].height),s.remove())},20)})}}),UIkit.plugin("lightbox","iframe",{init:function(i){i.on("showitem.uk.lightbox",function(t,o){var n=function(i,t,n){o.meta={content:'",width:t,height:n},o.type="iframe",o.promise.resolve()};("iframe"===o.type||o.source.match(/\.(html|php)$/))&&n(o.source,i.options.width||800,i.options.height||600)})}}),i.lightbox.create=function(t,e){if(t){var o,n=[];return t.forEach(function(t){n.push(i.$.extend({source:"",title:"",type:"auto",link:!1},"string"==typeof t?{source:t}:t))}),o=i.lightbox(i.$.extend({},e,{group:n}))}},i.lightbox}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(i){var t;window.UIkit2&&(t=i(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-lightbox",["uikit"],function(){return t||i(UIkit2)})}(function(i){"use strict";function t(t){if(e)return e.lightbox=t,e;e=i.$(['
        ','
        ','','
        ','
        ',"
        ","
        "].join("")).appendTo("body"),e.dialog=e.find(".uk-modal-dialog:first"),e.content=e.find(".uk-lightbox-content:first"),e.loader=e.find(".uk-modal-spinner:first"),e.closer=e.find(".uk-close.uk-close-alt"),e.modal=i.modal(e,{modal:!1}),e.on("swipeRight swipeLeft",function(i){e.lightbox["swipeLeft"==i.type?"next":"previous"]()}).on("click","[data-lightbox-previous], [data-lightbox-next]",function(t){t.preventDefault(),e.lightbox[i.$(this).is("[data-lightbox-next]")?"next":"previous"]()}),e.on("hide.uk.modal",function(){e.content.html("")});var o={w:window.innerWidth,h:window.innerHeight};return i.$win.on("load resize orientationchange",i.Utils.debounce(function(){o.w!==window.innerWidth&&e.is(":visible")&&!i.Utils.isFullscreen()&&e.lightbox.fitSize(),o={w:window.innerWidth,h:window.innerHeight}},100)),e.lightbox=t,e}var e,o={};return i.component("lightbox",{defaults:{allowfullscreen:!0,duration:400,group:!1,keyboard:!0},index:0,items:!1,boot:function(){i.$html.on("click","[data-uk-lightbox]",function(t){t.preventDefault();var e=i.$(this);e.data("lightbox")||i.lightbox(e,i.Utils.options(e.attr("data-uk-lightbox"))),e.data("lightbox").show(e)}),i.$doc.on("keyup",function(i){if(e&&e.is(":visible")&&e.lightbox.options.keyboard)switch(i.preventDefault(),i.keyCode){case 37:e.lightbox.previous();break;case 39:e.lightbox.next()}})},init:function(){var t=[];if(this.index=0,this.siblings=[],this.element&&this.element.length){var e=this.options.group?i.$('[data-uk-lightbox*="'+this.options.group+'"]'):this.element;e.each(function(){var e=i.$(this);t.push({source:e.attr("href"),title:e.attr("data-title")||e.attr("title"),type:e.attr("data-lightbox-type")||"auto",link:e})}),this.index=e.index(this.element),this.siblings=t}else this.options.group&&this.options.group.length&&(this.siblings=this.options.group);this.trigger("lightbox-init",[this])},show:function(e){this.modal=t(this),this.modal.dialog.stop(),this.modal.content.stop();var o,n,s=this,h=i.$.Deferred();e=e||0,"object"==typeof e&&this.siblings.forEach(function(i,t){e[0]===i.link[0]&&(e=t)}),0>e?e=this.siblings.length-e:this.siblings[e]||(e=0),n=this.siblings[e],o={lightbox:s,source:n.source,type:n.type,index:e,promise:h,title:n.title,item:n,meta:{content:"",width:null,height:null}},this.index=e,this.modal.content.empty(),this.modal.is(":visible")||(this.modal.content.css({width:"",height:""}).empty(),this.modal.modal.show()),this.modal.loader.removeClass("uk-hidden"),h.promise().done(function(){s.data=o,s.fitSize(o)}).fail(function(){o.meta.content='
        Loading resource failed!
        ',o.meta.width=400,o.meta.height=300,s.data=o,s.fitSize(o)}),s.trigger("showitem.uk.lightbox",[o])},fitSize:function(){var t=this,e=this.data,o=this.modal.dialog.outerWidth()-this.modal.dialog.width(),n=parseInt(this.modal.dialog.css("margin-top"),10),s=parseInt(this.modal.dialog.css("margin-bottom"),10),h=n+s,a=e.meta.content,l=t.options.duration;this.siblings.length>1&&(a=[a,'',''].join(""));var d,r,u=i.$("
         
        ").css({opacity:0,position:"absolute",top:0,left:0,width:"100%",maxWidth:t.modal.dialog.css("max-width"),padding:t.modal.dialog.css("padding"),margin:t.modal.dialog.css("margin")}),c=e.meta.width,g=e.meta.height;u.appendTo("body").width(),d=u.width(),r=window.innerHeight-h,u.remove(),this.modal.dialog.find(".uk-modal-caption").remove(),e.title&&(this.modal.dialog.append('
        '+e.title+"
        "),r-=this.modal.dialog.find(".uk-modal-caption").outerHeight()),dr&&(g=Math.floor(r),c=Math.ceil(e.meta.width*(r/e.meta.height))),this.modal.content.css("opacity",0).width(c).html(a),"iframe"==e.type&&this.modal.content.find("iframe:first").height(g);var m=g+o,p=Math.floor(window.innerHeight/2-m/2)-h;0>p&&(p=0),this.modal.closer.addClass("uk-hidden"),t.modal.data("mwidth")==c&&t.modal.data("mheight")==g&&(l=0),this.modal.dialog.animate({width:c+o,height:g+o,top:p},l,"swing",function(){t.modal.loader.addClass("uk-hidden"),t.modal.content.css({width:""}).animate({opacity:1},function(){t.modal.closer.removeClass("uk-hidden")}),t.modal.data({mwidth:c,mheight:g})})},next:function(){this.show(this.siblings[this.index+1]?this.index+1:0)},previous:function(){this.show(this.siblings[this.index-1]?this.index-1:this.siblings.length-1)}}),i.plugin("lightbox","image",{init:function(i){i.on("showitem.uk.lightbox",function(i,t){if("image"==t.type||t.source&&t.source.match(/\.(jpg|jpeg|png|gif|svg)$/i)){var e=function(i,e,o){t.meta={content:'',width:e,height:o},t.type="image",t.promise.resolve()};if(o[t.source])e(t.source,o[t.source].width,o[t.source].height);else{var n=new Image;n.onerror=function(){t.promise.reject("Loading image failed")},n.onload=function(){o[t.source]={width:n.width,height:n.height},e(t.source,o[t.source].width,o[t.source].height)},n.src=t.source}}})}}),i.plugin("lightbox","youtube",{init:function(i){var t=/(\/\/.*?youtube\.[a-z]+)\/watch\?v=([^&]+)&?(.*)/,n=/youtu\.be\/(.*)/;i.on("showitem.uk.lightbox",function(i,s){var h,a,l=function(i,t,o){s.meta={content:'",width:t,height:o},s.type="iframe",s.promise.resolve()};if((a=s.source.match(t))&&(h=a[2]),(a=s.source.match(n))&&(h=a[1]),h){if(o[h])l(h,o[h].width,o[h].height);else{var d=new Image,r=!1;d.onerror=function(){o[h]={width:640,height:320},l(h,o[h].width,o[h].height)},d.onload=function(){120==d.width&&90==d.height?r?(o[h]={width:640,height:320},l(h,o[h].width,o[h].height)):(r=!0,d.src="//img.youtube.com/vi/"+h+"/0.jpg"):(o[h]={width:d.width,height:d.height},l(h,d.width,d.height))},d.src="//img.youtube.com/vi/"+h+"/maxresdefault.jpg"}i.stopImmediatePropagation()}})}}),i.plugin("lightbox","vimeo",{init:function(t){var n,s=/(\/\/.*?)vimeo\.[a-z]+\/([0-9]+).*?/;t.on("showitem.uk.lightbox",function(t,h){var a,l=function(i,t,o){h.meta={content:'",width:t,height:o},h.type="iframe",h.promise.resolve()};(n=h.source.match(s))&&(a=n[2],o[a]?l(a,o[a].width,o[a].height):i.$.ajax({type:"GET",url:"//vimeo.com/api/oembed.json?url="+encodeURI(h.source),jsonp:"callback",dataType:"jsonp",success:function(i){o[a]={width:i.width,height:i.height},l(a,o[a].width,o[a].height)}}),t.stopImmediatePropagation())})}}),i.plugin("lightbox","video",{init:function(t){t.on("showitem.uk.lightbox",function(t,e){var n=function(i,t,o){e.meta={content:'',width:t,height:o},e.type="video",e.promise.resolve()};if("video"==e.type||e.source.match(/\.(mp4|webm|ogv)$/i))if(o[e.source])n(e.source,o[e.source].width,o[e.source].height);else var s=i.$('').attr("src",e.source).appendTo("body"),h=setInterval(function(){s[0].videoWidth&&(clearInterval(h),o[e.source]={width:s[0].videoWidth,height:s[0].videoHeight},n(e.source,o[e.source].width,o[e.source].height),s.remove())},20)})}}),i.plugin("lightbox","iframe",{init:function(i){i.on("showitem.uk.lightbox",function(t,o){var n=function(i,t,n){o.meta={content:'",width:t,height:n},o.type="iframe",o.promise.resolve()};("iframe"===o.type||o.source.match(/\.(html|php)$/))&&n(o.source,i.options.width||800,i.options.height||600)})}}),i.lightbox.create=function(t,e){if(t){var o,n=[];return t.forEach(function(t){n.push(i.$.extend({source:"",title:"",type:"auto",link:!1},"string"==typeof t?{source:t}:t))}),o=i.lightbox(i.$.extend({},e,{group:n}))}},i.lightbox}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/nestable.min.js b/lib/api/uikit/src/js/components/nestable.min.js index f6151412..b22bf131 100755 --- a/lib/api/uikit/src/js/components/nestable.min.js +++ b/lib/api/uikit/src/js/components/nestable.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var s;window.UIkit&&(s=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-nestable",["uikit"],function(){return s||t(UIkit)})}(function(t){"use strict";var s,e="ontouchstart"in window,i=t.$html,l=[],a=t.$win,n=e?"touchstart":"mousedown",o=e?"touchmove":"mousemove",h=e?"touchend":"mouseup",r=e?"touchcancel":"mouseup";return t.component("nestable",{defaults:{listBaseClass:"uk-nestable",listClass:"uk-nestable-list",listItemClass:"uk-nestable-item",dragClass:"uk-nestable-dragged",movingClass:"uk-nestable-moving",noChildrenClass:"uk-nestable-nochildren",emptyClass:"uk-nestable-empty",handleClass:"",collapsedClass:"uk-collapsed",placeholderClass:"uk-nestable-placeholder",noDragClass:"uk-nestable-nodrag",group:!1,maxDepth:10,threshold:20,idlethreshold:10},boot:function(){t.$html.on("mousemove touchmove",function(){if(s){var e=s.offset().top;ewindow.innerHeight+t.$win.scrollTop()&&t.$win.scrollTop(t.$win.scrollTop()+Math.ceil(s.height()/2))}}),t.ready(function(s){t.$("[data-uk-nestable]",s).each(function(){var s=t.$(this);s.data("nestable")||t.nestable(s,t.Utils.options(s.attr("data-uk-nestable")))})})},init:function(){var i=this;Object.keys(this.options).forEach(function(t){-1!=String(t).indexOf("Class")&&(i.options["_"+t]="."+i.options[t])}),this.find(this.options._listItemClass).find(">ul").addClass(this.options.listClass),this.checkEmptyList(),this.reset(),this.element.data("nestable-group",this.options.group||t.Utils.uid("nestable-group")),this.find(this.options._listItemClass).each(function(){i.setParent(t.$(this))}),this.on("click","[data-nestable-action]",function(s){if(!i.dragEl&&(e||0===s.button)){s.preventDefault();var l=t.$(s.currentTarget),a=l.data("nestableAction"),n=l.closest(i.options._listItemClass);"collapse"===a&&i.collapseItem(n),"expand"===a&&i.expandItem(n),"toggle"===a&&i.toggleItem(n)}});var l=function(s){var l=t.$(s.target),a=l.is("a[href]")?l:l.parents("a[href]");s.target!==i.element[0]&&(l.is(i.options._noDragClass)||l.closest(i.options._noDragClass).length||l.is("[data-nestable-action]")||l.closest("[data-nestable-action]").length||(i.options.handleClass&&!l.hasClass(i.options.handleClass)&&i.options.handleClass&&(l=l.closest(i.options._handleClass)),!l.length||i.dragEl||!e&&0!==s.button||e&&1!==s.touches.length||(s.originalEvent&&s.originalEvent.touches&&(s=evt.originalEvent.touches[0]),i.delayMove=function(t){a=!1,t.preventDefault(),i.dragStart(s),i.trigger("start.uk.nestable",[i]),i.delayMove=!1},i.delayMove.x=parseInt(s.pageX,10),i.delayMove.y=parseInt(s.pageY,10),i.delayMove.threshold=i.options.idlethreshold,a.length&&"touchend"==h&&i.one(h,function(){a&&a.attr("href").trim()&&(location.href=a.attr("href"))}),s.preventDefault())))},d=function(t){t.originalEvent&&t.originalEvent.touches&&(t=t.originalEvent.touches[0]),i.delayMove&&(Math.abs(t.pageX-i.delayMove.x)>i.delayMove.threshold||Math.abs(t.pageY-i.delayMove.y)>i.delayMove.threshold)&&(window.getSelection().toString()?i.delayMove=!1:i.delayMove(t)),i.dragEl&&(t.preventDefault(),i.dragMove(t),i.trigger("move.uk.nestable",[i]))},p=function(t){i.dragEl&&(t.preventDefault(),i.dragStop(e?t.touches[0]:t)),s=!1,i.delayMove=!1};e?(this.element[0].addEventListener(n,l,!1),window.addEventListener(o,d,!1),window.addEventListener(h,p,!1),window.addEventListener(r,p,!1)):(this.on(n,l),a.on(o,d),a.on(h,p))},serialize:function(){var s,e=0,i=this,l=function(s,e){var a=[],n=s.children(i.options._listItemClass);return n.each(function(){for(var s,n,o,h=t.$(this),r={},d=h.children(i.options._listClass),p=0;p").addClass(this.options.listClass+" "+this.options.dragClass).append(n.clone()),this.dragEl.css("width",n.width()),this.placeEl.addClass(this.options.placeholderClass),s=this.dragEl,this.tmpDragOnSiblings=[n[0].previousSibling,n[0].nextSibling],t.$body.append(this.dragEl),this.dragEl.css({left:o.left,top:o.top});var h,r,d=this.dragEl.find(this.options._listItemClass);for(h=0;hthis.dragDepth&&(this.dragDepth=r);i.addClass(this.options.movingClass)},dragStop:function(){var s=t.$(this.placeEl),e=this.placeEl.parents(this.options._listBaseClass+":first");this.placeEl.removeClass(this.options.placeholderClass),this.dragEl.remove(),this.element[0]!==e[0]?(e.trigger("change.uk.nestable",[e.data("nestable"),s,"added"]),this.element.trigger("change.uk.nestable",[this,s,"removed"])):this.element.trigger("change.uk.nestable",[this,s,"moved"]),this.trigger("stop.uk.nestable",[this,s]),this.reset(),i.removeClass(this.options.movingClass)},dragMove:function(s){var e,i,a,n,o,h=this.options,r=this.mouse,d=this.dragRootEl?this.dragRootEl.data("nestable").options.maxDepth:h.maxDepth;this.dragEl.css({left:s.pageX-r.offsetX,top:s.pageY-r.offsetY}),r.lastX=r.nowX,r.lastY=r.nowY,r.nowX=s.pageX,r.nowY=s.pageY,r.distX=r.nowX-r.lastX,r.distY=r.nowY-r.lastY,r.lastDirX=r.dirX,r.lastDirY=r.dirY,r.dirX=0===r.distX?0:r.distX>0?1:-1,r.dirY=0===r.distY?0:r.distY>0?1:-1;var p=Math.abs(r.distX)>Math.abs(r.distY)?1:0;if(!r.moving)return r.dirAx=p,r.moving=!0,void 0;if(r.dirAx!==p?(r.distAxX=0,r.distAxY=0):(r.distAxX+=Math.abs(r.distX),0!==r.dirX&&r.dirX!==r.lastDirX&&(r.distAxX=0),r.distAxY+=Math.abs(r.distY),0!==r.dirY&&r.dirY!==r.lastDirY&&(r.distAxY=0)),r.dirAx=p,r.dirAx&&r.distAxX>=h.threshold&&(r.distAxX=0,a=this.placeEl.prev("li"),r.distX>0&&a.length&&!a.hasClass(h.collapsedClass)&&!a.hasClass(h.noChildrenClass)&&(e=a.find(h._listClass).last(),o=this.placeEl.parents(h._listClass+","+h._listBaseClass).length,o+this.dragDepth<=d&&(e.length?(e=a.children(h._listClass).last(),e.append(this.placeEl)):(e=t.$("
          ").addClass(h.listClass),e.append(this.placeEl),a.append(e),this.setParent(a)))),r.distX<0&&(n=this.placeEl.next(h._listItemClass),!n.length))){var c=this.placeEl.closest([h._listBaseClass,h._listClass].join(",")),g=c.closest(h._listItemClass);g.length&&(g.after(this.placeEl),c.children().length||this.unsetParent(g))}var u=!1,f=s.pageX-(window.pageXOffset||document.scrollLeft||0),m=s.pageY-(window.pageYOffset||document.documentElement.scrollTop);if(this.pointEl=t.$(document.elementFromPoint(f,m)),h.handleClass&&this.pointEl.hasClass(h.handleClass))this.pointEl=this.pointEl.closest(h._listItemClass);else{var C=this.pointEl.closest(h._listItemClass);C.length&&(this.pointEl=C)}if(!this.placeEl.find(this.pointEl).length){if(this.pointEl.data("nestable")&&!this.pointEl.children().length)u=!0,this.checkEmptyList(this.pointEl);else if(!this.pointEl.length||!this.pointEl.hasClass(h.listItemClass))return;var v=this.element,E=this.pointEl.closest(this.options._listBaseClass),b=v[0]!=E[0];if(!r.dirAx||b||u){if(b&&h.group!==E.data("nestable-group"))return;if(l.push(v),o=this.dragDepth-1+this.pointEl.parents(h._listClass+","+h._listBaseClass).length,o>d)return;var X=s.pageYwindow.innerHeight+t.$win.scrollTop()&&t.$win.scrollTop(t.$win.scrollTop()+Math.ceil(s.height()/2))}}),t.ready(function(s){t.$("[data-uk-nestable]",s).each(function(){var s=t.$(this);s.data("nestable")||t.nestable(s,t.Utils.options(s.attr("data-uk-nestable")))})})},init:function(){var i=this;Object.keys(this.options).forEach(function(t){-1!=String(t).indexOf("Class")&&(i.options["_"+t]="."+i.options[t])}),this.find(this.options._listItemClass).find(">ul").addClass(this.options.listClass),this.checkEmptyList(),this.reset(),this.element.data("nestable-group",this.options.group||t.Utils.uid("nestable-group")),this.find(this.options._listItemClass).each(function(){i.setParent(t.$(this))}),this.on("click","[data-nestable-action]",function(s){if(!i.dragEl&&(e||0===s.button)){s.preventDefault();var l=t.$(s.currentTarget),a=l.data("nestableAction"),n=l.closest(i.options._listItemClass);"collapse"===a&&i.collapseItem(n),"expand"===a&&i.expandItem(n),"toggle"===a&&i.toggleItem(n)}});var l=function(s){var l=t.$(s.target),a=l.is("a[href]")?l:l.parents("a[href]");s.target!==i.element[0]&&(l.is(i.options._noDragClass)||l.closest(i.options._noDragClass).length||l.is("[data-nestable-action]")||l.closest("[data-nestable-action]").length||(i.options.handleClass&&!l.hasClass(i.options.handleClass)&&i.options.handleClass&&(l=l.closest(i.options._handleClass)),!l.length||i.dragEl||!e&&0!==s.button||e&&s.touches&&1!==s.touches.length||(s.originalEvent&&s.originalEvent.touches&&(s=evt.originalEvent.touches[0]),i.delayMove=function(t){a=!1,t.preventDefault(),i.dragStart(s),i.trigger("start.uk.nestable",[i]),i.delayMove=!1},i.delayMove.x=parseInt(s.pageX,10),i.delayMove.y=parseInt(s.pageY,10),i.delayMove.threshold=i.options.idlethreshold,a.length&&"touchend"==h&&i.one(h,function(){a&&a.attr("href").trim()&&(location.href=a.attr("href"))}),s.preventDefault())))},d=function(t){t.originalEvent&&t.originalEvent.touches&&(t=t.originalEvent.touches[0]),i.delayMove&&(Math.abs(t.pageX-i.delayMove.x)>i.delayMove.threshold||Math.abs(t.pageY-i.delayMove.y)>i.delayMove.threshold)&&(window.getSelection().toString()?i.delayMove=!1:i.delayMove(t)),i.dragEl&&(t.preventDefault(),i.dragMove(t),i.trigger("move.uk.nestable",[i]))},p=function(t){i.dragEl&&(t.preventDefault(),i.dragStop(e&&t.touches?t.touches[0]:t)),s=!1,i.delayMove=!1};e?(this.element[0].addEventListener(n,l,!1),window.addEventListener(o,d,!1),window.addEventListener(h,p,!1),window.addEventListener(r,p,!1)):(this.on(n,l),a.on(o,d),a.on(h,p))},serialize:function(){var s,e=0,i=this,l=function(s,e){var a=[],n=s.children(i.options._listItemClass);return n.each(function(){for(var s,n,o,h=t.$(this),r={},d=h.children(i.options._listClass),p=0;p
        ").addClass(this.options.listClass+" "+this.options.dragClass).append(n.clone()),this.dragEl.css("width",n.width()),this.placeEl.addClass(this.options.placeholderClass),s=this.dragEl,this.tmpDragOnSiblings=[n[0].previousSibling,n[0].nextSibling],t.$body.append(this.dragEl),this.dragEl.css({left:o.left,top:o.top});var h,r,d=this.dragEl.find(this.options._listItemClass);for(h=0;hthis.dragDepth&&(this.dragDepth=r);i.addClass(this.options.movingClass)},dragStop:function(){var s=t.$(this.placeEl),e=this.placeEl.parents(this.options._listBaseClass+":first");this.placeEl.removeClass(this.options.placeholderClass),this.dragEl.remove(),this.element[0]!==e[0]?(e.trigger("change.uk.nestable",[e.data("nestable"),s,"added"]),this.element.trigger("change.uk.nestable",[this,s,"removed"])):this.element.trigger("change.uk.nestable",[this,s,"moved"]),this.trigger("stop.uk.nestable",[this,s]),this.reset(),i.removeClass(this.options.movingClass)},dragMove:function(s){var e,i,a,n,o,h=this.options,r=this.mouse,d=this.dragRootEl?this.dragRootEl.data("nestable").options.maxDepth:h.maxDepth;this.dragEl.css({left:s.pageX-r.offsetX,top:s.pageY-r.offsetY}),r.lastX=r.nowX,r.lastY=r.nowY,r.nowX=s.pageX,r.nowY=s.pageY,r.distX=r.nowX-r.lastX,r.distY=r.nowY-r.lastY,r.lastDirX=r.dirX,r.lastDirY=r.dirY,r.dirX=0===r.distX?0:r.distX>0?1:-1,r.dirY=0===r.distY?0:r.distY>0?1:-1;var p=Math.abs(r.distX)>Math.abs(r.distY)?1:0;if(!r.moving)return r.dirAx=p,r.moving=!0,void 0;if(r.dirAx!==p?(r.distAxX=0,r.distAxY=0):(r.distAxX+=Math.abs(r.distX),0!==r.dirX&&r.dirX!==r.lastDirX&&(r.distAxX=0),r.distAxY+=Math.abs(r.distY),0!==r.dirY&&r.dirY!==r.lastDirY&&(r.distAxY=0)),r.dirAx=p,r.dirAx&&r.distAxX>=h.threshold&&(r.distAxX=0,a=this.placeEl.prev("li"),r.distX>0&&a.length&&!a.hasClass(h.collapsedClass)&&!a.hasClass(h.noChildrenClass)&&(e=a.find(h._listClass).last(),o=this.placeEl.parents(h._listClass+","+h._listBaseClass).length,o+this.dragDepth<=d&&(e.length?(e=a.children(h._listClass).last(),e.append(this.placeEl)):(e=t.$("
          ").addClass(h.listClass),e.append(this.placeEl),a.append(e),this.setParent(a)))),r.distX<0&&(n=this.placeEl.next(h._listItemClass),!n.length))){var c=this.placeEl.closest([h._listBaseClass,h._listClass].join(",")),u=c.closest(h._listItemClass);u.length&&(u.after(this.placeEl),c.children().length||this.unsetParent(u))}var g=!1,f=s.pageX-(window.pageXOffset||document.scrollLeft||0),m=s.pageY-(window.pageYOffset||document.documentElement.scrollTop);if(this.pointEl=t.$(document.elementFromPoint(f,m)),h.handleClass&&this.pointEl.hasClass(h.handleClass))this.pointEl=this.pointEl.closest(h._listItemClass);else{var v=this.pointEl.closest(h._listItemClass);v.length&&(this.pointEl=v)}if(!this.placeEl.find(this.pointEl).length){if(this.pointEl.data("nestable")&&!this.pointEl.children().length)g=!0,this.checkEmptyList(this.pointEl);else if(!this.pointEl.length||!this.pointEl.hasClass(h.listItemClass))return;var C=this.element,E=this.pointEl.closest(this.options._listBaseClass),w=C[0]!=E[0];if(!r.dirAx||w||g){if(w&&h.group!==E.data("nestable-group"))return;if(l.push(C),o=this.dragDepth-1+this.pointEl.parents(h._listClass+","+h._listBaseClass).length,o>d)return;var b=s.pageY','',"
          ",""].join("")).data("notifyMessage",this),this.content(this.options.message),this.options.status&&(this.element.addClass("uk-notify-message-"+this.options.status),this.currentstatus=this.options.status),this.group=this.options.group,i[this.uuid]=this,e[this.options.pos]||(e[this.options.pos]=t.$('
          ').appendTo("body").on("click",".uk-notify-message",function(){var e=t.$(this).data("notifyMessage");e.element.trigger("manualclose.uk.notify",[e]),e.close()}))};return t.$.extend(n.prototype,{uuid:!1,element:!1,timout:!1,currentstatus:"",group:!1,show:function(){if(!this.element.is(":visible")){var t=this;e[this.options.pos].show().prepend(this.element);var i=parseInt(this.element.css("margin-bottom"),10);return this.element.css({opacity:0,"margin-top":-1*this.element.outerHeight(),"margin-bottom":0}).animate({opacity:1,"margin-top":0,"margin-bottom":i},function(){if(t.options.timeout){var e=function(){t.close()};t.timeout=setTimeout(e,t.options.timeout),t.element.hover(function(){clearTimeout(t.timeout)},function(){t.timeout=setTimeout(e,t.options.timeout)})}}),this}},close:function(t){var s=this,o=function(){s.element.remove(),e[s.options.pos].children().length||e[s.options.pos].hide(),s.options.onClose.apply(s,[]),s.element.trigger("close.uk.notify",[s]),delete i[s.uuid]};this.timeout&&clearTimeout(this.timeout),t?o():this.element.animate({opacity:0,"margin-top":-1*this.element.outerHeight(),"margin-bottom":0},function(){o()})},content:function(t){var e=this.element.find(">div");return t?(e.html(t),this):e.html()},status:function(t){return t?(this.element.removeClass("uk-notify-message-"+this.currentstatus).addClass("uk-notify-message-"+t),this.currentstatus=t,this):this.currentstatus}}),n.defaults={message:"",status:"",timeout:5e3,group:null,pos:"top-center",onClose:function(){}},t.notify=s,t.notify.message=n,t.notify.closeAll=o,s}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var e;window.UIkit2&&(e=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-notify",["uikit"],function(){return e||t(UIkit2)})}(function(t){"use strict";var e={},i={},s=function(e){return"string"==t.$.type(e)&&(e={message:e}),arguments[1]&&(e=t.$.extend(e,"string"==t.$.type(arguments[1])?{status:arguments[1]}:arguments[1])),new n(e).show()},o=function(t,e){var s;if(t)for(s in i)t===i[s].group&&i[s].close(e);else for(s in i)i[s].close(e)},n=function(s){this.options=t.$.extend({},n.defaults,s),this.uuid=t.Utils.uid("notifymsg"),this.element=t.$(['
          ','',"
          ","
          "].join("")).data("notifyMessage",this),this.content(this.options.message),this.options.status&&(this.element.addClass("uk-notify-message-"+this.options.status),this.currentstatus=this.options.status),this.group=this.options.group,i[this.uuid]=this,e[this.options.pos]||(e[this.options.pos]=t.$('
          ').appendTo("body").on("click",".uk-notify-message",function(){var e=t.$(this).data("notifyMessage");e.element.trigger("manualclose.uk.notify",[e]),e.close()}))};return t.$.extend(n.prototype,{uuid:!1,element:!1,timout:!1,currentstatus:"",group:!1,show:function(){if(!this.element.is(":visible")){var t=this;e[this.options.pos].show().prepend(this.element);var i=parseInt(this.element.css("margin-bottom"),10);return this.element.css({opacity:0,marginTop:-1*this.element.outerHeight(),marginBottom:0}).animate({opacity:1,marginTop:0,marginBottom:i},function(){if(t.options.timeout){var e=function(){t.close()};t.timeout=setTimeout(e,t.options.timeout),t.element.hover(function(){clearTimeout(t.timeout)},function(){t.timeout=setTimeout(e,t.options.timeout)})}}),this}},close:function(t){var s=this,o=function(){s.element.remove(),e[s.options.pos].children().length||e[s.options.pos].hide(),s.options.onClose.apply(s,[]),s.element.trigger("close.uk.notify",[s]),delete i[s.uuid]};this.timeout&&clearTimeout(this.timeout),t?o():this.element.animate({opacity:0,marginTop:-1*this.element.outerHeight(),marginBottom:0},function(){o()})},content:function(t){var e=this.element.find(">div");return t?(e.html(t),this):e.html()},status:function(t){return t?(this.element.removeClass("uk-notify-message-"+this.currentstatus).addClass("uk-notify-message-"+t),this.currentstatus=t,this):this.currentstatus}}),n.defaults={message:"",status:"",timeout:5e3,group:null,pos:"top-center",onClose:function(){}},t.notify=s,t.notify.message=n,t.notify.closeAll=o,s}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/pagination.min.js b/lib/api/uikit/src/js/components/pagination.min.js index 9a0c5778..10ad7139 100755 --- a/lib/api/uikit/src/js/components/pagination.min.js +++ b/lib/api/uikit/src/js/components/pagination.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-pagination",["uikit"],function(){return e||t(UIkit)})}(function(t){"use strict";return t.component("pagination",{defaults:{items:1,itemsOnPage:1,pages:0,displayedPages:7,edges:1,currentPage:0,lblPrev:!1,lblNext:!1,onSelectPage:function(){}},boot:function(){t.ready(function(e){t.$("[data-uk-pagination]",e).each(function(){var e=t.$(this);e.data("pagination")||t.pagination(e,t.Utils.options(e.attr("data-uk-pagination")))})})},init:function(){var e=this;this.pages=this.options.pages?this.options.pages:Math.ceil(this.options.items/this.options.itemsOnPage)?Math.ceil(this.options.items/this.options.itemsOnPage):1,this.currentPage=this.options.currentPage,this.halfDisplayed=this.options.displayedPages/2,this.on("click","a[data-page]",function(i){i.preventDefault(),e.selectPage(t.$(this).data("page"))}),this._render()},_getInterval:function(){return{start:Math.ceil(this.currentPage>this.halfDisplayed?Math.max(Math.min(this.currentPage-this.halfDisplayed,this.pages-this.options.displayedPages),0):0),end:Math.ceil(this.currentPage>this.halfDisplayed?Math.min(this.currentPage+this.halfDisplayed,this.pages):Math.min(this.options.displayedPages,this.pages))}},render:function(t){this.pages=t?t:this.pages,this._render()},selectPage:function(t,e){this.currentPage=t,this.render(e),this.options.onSelectPage.apply(this,[t]),this.trigger("select.uk.pagination",[t,this])},_render:function(){var t,e=this.options,i=this._getInterval();if(this.element.empty(),e.lblPrev&&this._append(this.currentPage-1,{text:e.lblPrev}),i.start>0&&e.edges>0){var s=Math.min(e.edges,i.start);for(t=0;s>t;t++)this._append(t);e.edges..."):i.start-e.edges==1&&this._append(e.edges)}for(t=i.start;t0){this.pages-e.edges>i.end&&this.pages-e.edges-i.end!=1?this.element.append("
        • ...
        • "):this.pages-e.edges-i.end==1&&this._append(i.end++);var a=Math.max(this.pages-e.edges,i.end);for(t=a;te?0:e'+a.text+"":'
        • '+a.text+"
        • ",this.element.append(s)}}),t.pagination}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var e;window.UIkit2&&(e=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-pagination",["uikit"],function(){return e||t(UIkit2)})}(function(t){"use strict";return t.component("pagination",{defaults:{items:1,itemsOnPage:1,pages:0,displayedPages:7,edges:1,currentPage:0,lblPrev:!1,lblNext:!1,onSelectPage:function(){}},boot:function(){t.ready(function(e){t.$("[data-uk-pagination]",e).each(function(){var e=t.$(this);e.data("pagination")||t.pagination(e,t.Utils.options(e.attr("data-uk-pagination")))})})},init:function(){var e=this;this.pages=this.options.pages?this.options.pages:Math.ceil(this.options.items/this.options.itemsOnPage)?Math.ceil(this.options.items/this.options.itemsOnPage):1,this.currentPage=this.options.currentPage,this.halfDisplayed=this.options.displayedPages/2,this.on("click","a[data-page]",function(i){i.preventDefault(),e.selectPage(t.$(this).data("page"))}),this._render()},_getInterval:function(){return{start:Math.ceil(this.currentPage>this.halfDisplayed?Math.max(Math.min(this.currentPage-this.halfDisplayed,this.pages-this.options.displayedPages),0):0),end:Math.ceil(this.currentPage>this.halfDisplayed?Math.min(this.currentPage+this.halfDisplayed,this.pages):Math.min(this.options.displayedPages,this.pages))}},render:function(t){this.pages=t?t:this.pages,this._render()},selectPage:function(t,e){this.currentPage=t,this.render(e),this.options.onSelectPage.apply(this,[t]),this.trigger("select.uk.pagination",[t,this])},_render:function(){var t,e=this.options,i=this._getInterval();if(this.element.empty(),e.lblPrev&&this._append(this.currentPage-1,{text:e.lblPrev}),i.start>0&&e.edges>0){var s=Math.min(e.edges,i.start);for(t=0;s>t;t++)this._append(t);e.edges..."):i.start-e.edges==1&&this._append(e.edges)}for(t=i.start;t0){this.pages-e.edges>i.end&&this.pages-e.edges-i.end!=1?this.element.append("
        • ...
        • "):this.pages-e.edges-i.end==1&&this._append(i.end++);var a=Math.max(this.pages-e.edges,i.end);for(t=a;te?0:e'+a.text+"":'
        • '+a.text+"
        • ",this.element.append(s)}}),t.pagination}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/parallax.min.js b/lib/api/uikit/src/js/components/parallax.min.js index 36180dce..a3cc3fa9 100755 --- a/lib/api/uikit/src/js/components/parallax.min.js +++ b/lib/api/uikit/src/js/components/parallax.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(e){var t;window.UIkit&&(t=e(UIkit)),"function"==typeof define&&define.amd&&define("uikit-parallax",["uikit"],function(){return t||e(UIkit)})}(function(e){"use strict";function t(t,a,r){var i,n,s,o,c,l,p,f=new Image;return n=t.element.css({"background-size":"cover","background-repeat":"no-repeat"}),i=n.css("background-image").replace(/^url\(/g,"").replace(/\)$/g,"").replace(/("|')/g,""),o=function(){var e=n.innerWidth(),i=n.innerHeight(),o="bg"==a?r.diff:r.diff/100*i;return i+=o,e+=Math.ceil(o*c),e-oe/c?(l=Math.ceil(i*c),p=i,i>window.innerHeight&&(l=1.2*l,p=1.2*p)):(l=e,p=Math.ceil(e/c)),n.css({"background-size":l+"px "+p+"px"}).data("bgsize",{w:l,h:p}),void 0)},f.onerror=function(){},f.onload=function(){s={w:f.width,h:f.height},c=f.width/f.height,e.$win.on("load resize orientationchange",e.Utils.debounce(function(){o()},50)),o()},f.src=i,!0}function a(e,t,a){return e=i(e),t=i(t),a=a||0,r(e,t,a)}function r(e,t,a){var r="rgba("+parseInt(e[0]+a*(t[0]-e[0]),10)+","+parseInt(e[1]+a*(t[1]-e[1]),10)+","+parseInt(e[2]+a*(t[2]-e[2]),10)+","+(e&&t?parseFloat(e[3]+a*(t[3]-e[3])):1);return r+=")"}function i(e){var t,a;return a=(t=/#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/.exec(e))?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16),1]:(t=/#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/.exec(e))?[17*parseInt(t[1],16),17*parseInt(t[2],16),17*parseInt(t[3],16),1]:(t=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(e))?[parseInt(t[1]),parseInt(t[2]),parseInt(t[3]),1]:(t=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9\.]*)\s*\)/.exec(e))?[parseInt(t[1],10),parseInt(t[2],10),parseInt(t[3],10),parseFloat(t[4])]:p[e]||[255,255,255,0]}var n=[],s=!1,o=0,c=window.innerHeight,l=function(){o=e.$win.scrollTop(),window.requestAnimationFrame(function(){for(var e=0;e0&&"none"!==e}(),e.$doc.on("scrolling.uk.document",l),e.$win.on("load resize orientationchange",e.Utils.debounce(function(){c=window.innerHeight,l()},50)),e.ready(function(t){e.$("[data-uk-parallax]",t).each(function(){var t=e.$(this);t.data("parallax")||e.parallax(t,e.Utils.options(t.attr("data-uk-parallax")))})})},init:function(){this.base=this.options.target?e.$(this.options.target):this.element,this.props={},this.velocity=this.options.velocity||1;var t=["target","velocity","viewport","plugins","media"];Object.keys(this.options).forEach(function(e){if(-1===t.indexOf(e)){var a,r,i,n,s=String(this.options[e]).split(",");e.match(/color/i)?(a=s[1]?s[0]:this._getStartValue(e),r=s[1]?s[1]:s[0],a||(a="rgba(255,255,255,0)")):(a=parseFloat(s[1]?s[0]:this._getStartValue(e)),r=parseFloat(s[1]?s[1]:s[0]),n=r>a?r-a:a-r,i=r>a?1:-1),this.props[e]={start:a,end:r,dir:i,diff:n}}}.bind(this)),n.push(this)},process:function(){if(this.options.media)switch(typeof this.options.media){case"number":if(window.innerWidtho+c?a=0:o>r+i?a=1:c>r+i?a=(c>o?o:o-c)/(r+i):(e=o+c-r,t=Math.round(e/((c+i)/100)),a=t/100),a},update:function(e){var r,i,n={transform:"",filter:""},o=e*(1-(this.velocity-this.velocity*e));0>o&&(o=0),o>1&&(o=1),(void 0===this._percent||this._percent!=o)&&(Object.keys(this.props).forEach(function(c){switch(r=this.props[c],0===e?i=r.start:1===e?i=r.end:void 0!==r.diff&&(i=r.start+r.diff*o*r.dir),"bg"!=c&&"bgp"!=c||this._bgcover||(this._bgcover=t(this,c,r)),c){case"x":n.transform+=s?" translate3d("+i+"px, 0, 0)":" translateX("+i+"px)";break;case"xp":n.transform+=s?" translate3d("+i+"%, 0, 0)":" translateX("+i+"%)";break;case"y":n.transform+=s?" translate3d(0, "+i+"px, 0)":" translateY("+i+"px)";break;case"yp":n.transform+=s?" translate3d(0, "+i+"%, 0)":" translateY("+i+"%)";break;case"rotate":n.transform+=" rotate("+i+"deg)";break;case"scale":n.transform+=" scale("+i+")";break;case"bg":n["background-position"]="50% "+i+"px";break;case"bgp":n["background-position"]="50% "+i+"%";break;case"color":case"background-color":case"border-color":n[c]=a(r.start,r.end,o);break;case"blur":n.filter+=" blur("+i+"px)";break;case"hue":n.filter+=" hue-rotate("+i+"deg)";break;case"grayscale":n.filter+=" grayscale("+i+"%)";break;case"invert":n.filter+=" invert("+i+"%)";break;case"fopacity":n.filter+=" opacity("+i+"%)";break;case"saturate":n.filter+=" saturate("+i+"%)";break;case"sepia":n.filter+=" sepia("+i+"%)";break;default:n[c]=i}}.bind(this)),n.filter&&(n["-webkit-filter"]=n.filter),this.element.css(n),this._percent=o)},_getStartValue:function(e){var t=0;switch(e){case"scale":t=1;break;default:t=this.element.css(e)}return t||0}});var p={black:[0,0,0,1],blue:[0,0,255,1],brown:[165,42,42,1],cyan:[0,255,255,1],fuchsia:[255,0,255,1],gold:[255,215,0,1],green:[0,128,0,1],indigo:[75,0,130,1],khaki:[240,230,140,1],lime:[0,255,0,1],magenta:[255,0,255,1],maroon:[128,0,0,1],navy:[0,0,128,1],olive:[128,128,0,1],orange:[255,165,0,1],pink:[255,192,203,1],purple:[128,0,128,1],violet:[128,0,128,1],red:[255,0,0,1],silver:[192,192,192,1],white:[255,255,255,1],yellow:[255,255,0,1],transparent:[255,255,255,0]};return e.parallax}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(e){var t;window.UIkit2&&(t=e(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-parallax",["uikit"],function(){return t||e(UIkit2)})}(function(e){"use strict";function t(t,a,r){var i,n,s,o,c,l,p,f=new Image;return n=t.element.css({backgroundSize:"cover",backgroundRepeat:"no-repeat"}),i=n.css("background-image").replace(/^url\(/g,"").replace(/\)$/g,"").replace(/("|')/g,""),o=function(){var e=n.innerWidth(),i=n.innerHeight(),o="bg"==a?r.diff:r.diff/100*i;return i+=o,e+=Math.ceil(o*c),e-oe/c?(l=Math.ceil(i*c),p=i,i>window.innerHeight&&(l=1.2*l,p=1.2*p)):(l=e,p=Math.ceil(e/c)),n.css({backgroundSize:l+"px "+p+"px"}).data("bgsize",{w:l,h:p}),void 0)},f.onerror=function(){},f.onload=function(){s={w:f.width,h:f.height},c=f.width/f.height,e.$win.on("load resize orientationchange",e.Utils.debounce(function(){o()},50)),o()},f.src=i,!0}function a(e,t,a){return e=i(e),t=i(t),a=a||0,r(e,t,a)}function r(e,t,a){var r="rgba("+parseInt(e[0]+a*(t[0]-e[0]),10)+","+parseInt(e[1]+a*(t[1]-e[1]),10)+","+parseInt(e[2]+a*(t[2]-e[2]),10)+","+(e&&t?parseFloat(e[3]+a*(t[3]-e[3])):1);return r+=")"}function i(e){var t,a;return a=(t=/#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/.exec(e))?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16),1]:(t=/#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/.exec(e))?[17*parseInt(t[1],16),17*parseInt(t[2],16),17*parseInt(t[3],16),1]:(t=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(e))?[parseInt(t[1]),parseInt(t[2]),parseInt(t[3]),1]:(t=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9\.]*)\s*\)/.exec(e))?[parseInt(t[1],10),parseInt(t[2],10),parseInt(t[3],10),parseFloat(t[4])]:p[e]||[255,255,255,0]}var n=[],s=!1,o=0,c=window.innerHeight,l=function(){o=e.$win.scrollTop(),window.requestAnimationFrame(function(){for(var e=0;e0&&"none"!==e}(),e.$doc.on("scrolling.uk.document",l),e.$win.on("load resize orientationchange",e.Utils.debounce(function(){c=window.innerHeight,l()},50)),e.ready(function(t){e.$("[data-uk-parallax]",t).each(function(){var t=e.$(this);t.data("parallax")||e.parallax(t,e.Utils.options(t.attr("data-uk-parallax")))})})},init:function(){this.base=this.options.target?e.$(this.options.target):this.element,this.props={},this.velocity=this.options.velocity||1;var t=["target","velocity","viewport","plugins","media"];Object.keys(this.options).forEach(function(e){if(-1===t.indexOf(e)){var a,r,i,n,s=String(this.options[e]).split(",");e.match(/color/i)?(a=s[1]?s[0]:this._getStartValue(e),r=s[1]?s[1]:s[0],a||(a="rgba(255,255,255,0)")):(a=parseFloat(s[1]?s[0]:this._getStartValue(e)),r=parseFloat(s[1]?s[1]:s[0]),n=r>a?r-a:a-r,i=r>a?1:-1),this.props[e]={start:a,end:r,dir:i,diff:n}}}.bind(this)),n.push(this)},process:function(){if(this.options.media)switch(typeof this.options.media){case"number":if(window.innerWidtho+c?a=0:o>r+i?a=1:c>r+i?a=(c>o?o:o-c)/(r+i):(e=o+c-r,t=Math.round(e/((c+i)/100)),a=t/100),a},update:function(e){var r,i,n={transform:"",filter:""},o=e*(1-(this.velocity-this.velocity*e));0>o&&(o=0),o>1&&(o=1),(void 0===this._percent||this._percent!=o)&&(Object.keys(this.props).forEach(function(c){switch(r=this.props[c],0===e?i=r.start:1===e?i=r.end:void 0!==r.diff&&(i=r.start+r.diff*o*r.dir),"bg"!=c&&"bgp"!=c||this._bgcover||(this._bgcover=t(this,c,r)),c){case"x":n.transform+=s?" translate3d("+i+"px, 0, 0)":" translateX("+i+"px)";break;case"xp":n.transform+=s?" translate3d("+i+"%, 0, 0)":" translateX("+i+"%)";break;case"y":n.transform+=s?" translate3d(0, "+i+"px, 0)":" translateY("+i+"px)";break;case"yp":n.transform+=s?" translate3d(0, "+i+"%, 0)":" translateY("+i+"%)";break;case"rotate":n.transform+=" rotate("+i+"deg)";break;case"scale":n.transform+=" scale("+i+")";break;case"bg":n["background-position"]="50% "+i+"px";break;case"bgp":n["background-position"]="50% "+i+"%";break;case"color":case"background-color":case"border-color":n[c]=a(r.start,r.end,o);break;case"blur":n.filter+=" blur("+i+"px)";break;case"hue":n.filter+=" hue-rotate("+i+"deg)";break;case"grayscale":n.filter+=" grayscale("+i+"%)";break;case"invert":n.filter+=" invert("+i+"%)";break;case"fopacity":n.filter+=" opacity("+i+"%)";break;case"saturate":n.filter+=" saturate("+i+"%)";break;case"sepia":n.filter+=" sepia("+i+"%)";break;default:n[c]=i}}.bind(this)),n.filter&&(n["-webkit-filter"]=n.filter),this.element.css(n),this._percent=o)},_getStartValue:function(e){var t=0;switch(e){case"scale":t=1;break;default:t=this.element.css(e)}return t||0}});var p={black:[0,0,0,1],blue:[0,0,255,1],brown:[165,42,42,1],cyan:[0,255,255,1],fuchsia:[255,0,255,1],gold:[255,215,0,1],green:[0,128,0,1],indigo:[75,0,130,1],khaki:[240,230,140,1],lime:[0,255,0,1],magenta:[255,0,255,1],maroon:[128,0,0,1],navy:[0,0,128,1],olive:[128,128,0,1],orange:[255,165,0,1],pink:[255,192,203,1],purple:[128,0,128,1],violet:[128,0,128,1],red:[255,0,0,1],silver:[192,192,192,1],white:[255,255,255,1],yellow:[255,255,0,1],transparent:[255,255,255,0]};return e.parallax}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/search.min.js b/lib/api/uikit/src/js/components/search.min.js index 700f8502..b6e7e7a8 100755 --- a/lib/api/uikit/src/js/components/search.min.js +++ b/lib/api/uikit/src/js/components/search.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(e){var s;window.UIkit&&(s=e(UIkit)),"function"==typeof define&&define.amd&&define("uikit-search",["uikit"],function(){return s||e(UIkit)})}(function(e){"use strict";e.component("search",{defaults:{msgResultsHeader:"Search Results",msgMoreResults:"More Results",msgNoResults:"No results found",template:'',renderer:function(e){var s=this.options;this.dropdown.append(this.template({items:e.results||[],msgResultsHeader:s.msgResultsHeader,msgMoreResults:s.msgMoreResults,msgNoResults:s.msgNoResults})),this.show()}},boot:function(){e.$html.on("focus.search.uikit","[data-uk-search]",function(){var s=e.$(this);s.data("search")||e.search(s,e.Utils.options(s.attr("data-uk-search")))})},init:function(){var s=this;this.autocomplete=e.autocomplete(this.element,this.options),this.autocomplete.dropdown.addClass("uk-dropdown-search"),this.autocomplete.input.on("keyup",function(){s.element[s.autocomplete.input.val()?"addClass":"removeClass"]("uk-active")}).closest("form").on("reset",function(){s.value="",s.element.removeClass("uk-active")}),this.on("selectitem.uk.autocomplete",function(e,t){t.url?location.href=t.url:t.moreresults&&s.autocomplete.input.closest("form").submit()}),this.element.data("search",this)}})}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(e){var s;window.UIkit2&&(s=e(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-search",["uikit"],function(){return s||e(UIkit2)})}(function(e){"use strict";e.component("search",{defaults:{msgResultsHeader:"Search Results",msgMoreResults:"More Results",msgNoResults:"No results found",template:'',renderer:function(e){var s=this.options;this.dropdown.append(this.template({items:e.results||[],msgResultsHeader:s.msgResultsHeader,msgMoreResults:s.msgMoreResults,msgNoResults:s.msgNoResults})),this.show()}},boot:function(){e.$html.on("focus.search.uikit","[data-uk-search]",function(){var s=e.$(this);s.data("search")||e.search(s,e.Utils.options(s.attr("data-uk-search")))})},init:function(){var s=this;this.autocomplete=e.autocomplete(this.element,this.options),this.autocomplete.dropdown.addClass("uk-dropdown-search"),this.autocomplete.input.on("keyup",function(){s.element[s.autocomplete.input.val()?"addClass":"removeClass"]("uk-active")}).closest("form").on("reset",function(){s.value="",s.element.removeClass("uk-active")}),this.on("selectitem.uk.autocomplete",function(e,t){t.url?location.href=t.url:t.moreresults&&s.autocomplete.input.closest("form").submit()}),this.element.data("search",this)}})}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/slider.min.js b/lib/api/uikit/src/js/components/slider.min.js index 9f6ca6a8..d9435396 100755 --- a/lib/api/uikit/src/js/components/slider.min.js +++ b/lib/api/uikit/src/js/components/slider.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-slider",["uikit"],function(){return e||t(UIkit)})}(function(t){"use strict";var e,i,s,n,a={};return t.component("slider",{defaults:{center:!1,threshold:10,infinite:!0,autoplay:!1,autoplayInterval:7e3,pauseOnHover:!0,activecls:"uk-active"},boot:function(){t.ready(function(e){setTimeout(function(){t.$("[data-uk-slider]",e).each(function(){var e=t.$(this);e.data("slider")||t.slider(e,t.Utils.options(e.attr("data-uk-slider")))})},0)})},init:function(){var o=this;this.container=this.element.find(".uk-slider"),this.focus=0,t.$win.on("resize load",t.Utils.debounce(function(){o.update(!0)},100)),this.on("click.uk.slider","[data-uk-slider-item]",function(e){e.preventDefault();var i=t.$(this).attr("data-uk-slider-item");if(o.focus!=i)switch(o.stop(),i){case"next":case"previous":o["next"==i?"next":"previous"]();break;default:o.updateFocus(parseInt(i,10))}}),this.container.on({"touchstart mousedown":function(h){h.originalEvent&&h.originalEvent.touches&&(h=h.originalEvent.touches[0]),h.button&&2==h.button||!o.active||(o.stop(),s=t.$(h.target).is("a")?t.$(h.target):t.$(h.target).parents("a:first"),n=!1,s.length&&s.one("click",function(t){n&&t.preventDefault()}),i=function(t){n=!0,e=o,a={touchx:parseInt(t.pageX,10),dir:1,focus:o.focus,base:o.options.center?"center":"area"},t.originalEvent&&t.originalEvent.touches&&(t=t.originalEvent.touches[0]),e.element.data({"pointer-start":{x:parseInt(t.pageX,10),y:parseInt(t.pageY,10)},"pointer-pos-start":o.pos}),o.container.addClass("uk-drag"),i=!1},i.x=parseInt(h.pageX,10),i.threshold=o.options.threshold)},mouseenter:function(){o.options.pauseOnHover&&(o.hovering=!0)},mouseleave:function(){o.hovering=!1}}),this.update(!0),this.on("display.uk.check",function(){o.element.is(":visible")&&o.update(!0)}),this.element.find("a,img").attr("draggable","false"),this.options.autoplay&&this.start(),t.domObserve(this.element,function(){o.element.children(":not([data-slide])").length&&o.update(!0)})},update:function(e){var i,s,n,a,o=this,h=0,r=0;return this.items=this.container.children().filter(":visible"),this.vp=this.element[0].getBoundingClientRect().width,this.container.css({"min-width":"","min-height":""}),this.items.each(function(e){i=t.$(this).attr("data-slide",e),a=i.css({left:"",width:""})[0].getBoundingClientRect(),s=a.width,n=i.width(),r=Math.max(r,a.height),i.css({left:h,width:s}).data({idx:e,left:h,width:s,cwidth:n,area:h+s,center:h-(o.vp/2-n/2)}),h+=s}),this.container.css({"min-width":h,"min-height":r}),this.options.infinite&&(h<=2*this.vp||this.items.length<5)&&!this.itemsResized?(this.container.children().each(function(t){o.container.append(o.items.eq(t).clone(!0).attr("id",""))}).each(function(t){o.container.append(o.items.eq(t).clone(!0).attr("id",""))}),this.itemsResized=!0,this.update()):(this.cw=h,this.pos=0,this.active=h>=this.vp,this.container.css({"-ms-transform":"","-webkit-transform":"",transform:""}),e&&this.updateFocus(this.focus),void 0)},updatePos:function(t){this.pos=t,this.container.css({"-ms-transform":"translateX("+t+"px)","-webkit-transform":"translateX("+t+"px)",transform:"translateX("+t+"px)"})},updateFocus:function(e,i){if(this.active){i=i||(e>this.focus?1:-1);var s,n,a=this.items.eq(e);if(this.options.infinite&&this.infinite(e,i),this.options.center)this.updatePos(-1*a.data("center")),this.items.filter("."+this.options.activecls).removeClass(this.options.activecls),a.addClass(this.options.activecls);else if(this.options.infinite)this.updatePos(-1*a.data("left"));else{for(s=0,n=e;nthis.vp)this.updatePos(-1*a.data("left"));else if(1==i){for(s=0,n=this.items.length-1;n>=0;n--){if(s+=this.items.eq(n).data("width"),s==this.vp){e=n;break}if(s>this.vp){e=nthis.vp?this.updatePos(-1*(this.container.width()-this.vp)):this.updatePos(-1*this.items.eq(e).data("left"))}}var o=this.items.eq(e).data("left");this.items.removeClass("uk-slide-before uk-slide-after").each(function(i){i!==e&&t.$(this).addClass(t.$(this).data("left")this.vp));i++)a=a+1==this.items.length?0:a+1;o.length&&o.forEach(function(t){var e=n.data("area");t.css({left:e}).data({left:e,area:e+t.data("width"),center:e-(s.vp/2-t.data("cwidth")/2)}),n=t})}else{for(i=this.items.length-1;i>-1&&(h+=this.items.eq(a).data("width"),a!=t&&o.push(this.items.eq(a)),!(h>this.vp));i--)a=a-1==-1?this.items.length-1:a-1;o.length&&o.forEach(function(t){var e=n.data("left")-t.data("width");t.css({left:e}).data({left:e,area:e+t.data("width"),center:e-(s.vp/2-t.data("cwidth")/2)}),n=t})}}}),t.$doc.on("mousemove.uk.slider touchmove.uk.slider",function(t){if(t.originalEvent&&t.originalEvent.touches&&(t=t.originalEvent.touches[0]),i&&Math.abs(t.pageX-i.x)>i.threshold&&(window.getSelection().toString()?e=i=!1:i(t)),e){var s,n,o,h,r,c,d,u,f,l;if(t.clientX||t.clientY?s=t.clientX:(t.pageX||t.pageY)&&(s=t.pageX-document.body.scrollLeft-document.documentElement.scrollLeft),r=a.focus,n=s-e.element.data("pointer-start").x,o=e.element.data("pointer-pos-start")+n,h=s>e.element.data("pointer-start").x?-1:1,c=e.items.eq(a.focus),1==h)for(d=c.data("left")+Math.abs(n),u=0,f=a.focus;ud){r=f;break}f=f+1==e.items.length?0:f+1}else for(d=c.data("left")-Math.abs(n),u=0,f=a.focus;ua.diff){o=n;break}n=n+1==e.items.length?0:n+1}e.options.infinite||o||(o=e.items.length)}else{for(s=0,n=a.focus;s=this.vp,this.container.css({"-ms-transform":"","-webkit-transform":"",transform:""}),e&&this.updateFocus(this.focus),void 0)},updatePos:function(t){this.pos=t,this.container.css({"-ms-transform":"translateX("+t+"px)","-webkit-transform":"translateX("+t+"px)",transform:"translateX("+t+"px)"})},updateFocus:function(e,i){if(this.active){i=i||(e>this.focus?1:-1);var s,n,a=this.items.eq(e);if(this.options.infinite&&this.infinite(e,i),this.options.center)this.updatePos(-1*a.data("center")),this.items.filter("."+this.options.activecls).removeClass(this.options.activecls),a.addClass(this.options.activecls);else if(this.options.infinite)this.updatePos(-1*a.data("left"));else{for(s=0,n=e;nthis.vp)this.updatePos(-1*a.data("left"));else if(1==i){for(s=0,n=this.items.length-1;n>=0;n--){if(s+=this.items.eq(n).data("width"),s==this.vp){e=n;break}if(s>this.vp){e=nthis.vp?this.updatePos(-1*(this.container.width()-this.vp)):this.updatePos(-1*this.items.eq(e).data("left"))}}var o=this.items.eq(e).data("left");this.items.removeClass("uk-slide-before uk-slide-after").each(function(i){i!==e&&t.$(this).addClass(t.$(this).data("left")this.vp));i++)a=a+1==this.items.length?0:a+1;o.length&&o.forEach(function(t){var e=n.data("area");t.css({left:e}).data({left:e,area:e+t.data("width"),center:e-(s.vp/2-t.data("cwidth")/2)}),n=t})}else{for(i=this.items.length-1;i>-1&&(h+=this.items.eq(a).data("width"),a!=t&&o.push(this.items.eq(a)),!(h>this.vp));i--)a=a-1==-1?this.items.length-1:a-1;o.length&&o.forEach(function(t){var e=n.data("left")-t.data("width");t.css({left:e}).data({left:e,area:e+t.data("width"),center:e-(s.vp/2-t.data("cwidth")/2)}),n=t})}}}),t.$doc.on("mousemove.uk.slider touchmove.uk.slider",function(t){if(t.originalEvent&&t.originalEvent.touches&&(t=t.originalEvent.touches[0]),i&&Math.abs(t.pageX-i.x)>i.threshold&&(window.getSelection().toString()?e=i=!1:i(t)),e){var s,n,o,h,r,c,d,u,f,l;if(t.clientX||t.clientY?s=t.clientX:(t.pageX||t.pageY)&&(s=t.pageX-document.body.scrollLeft-document.documentElement.scrollLeft),r=a.focus,n=s-e.element.data("pointer-start").x,o=e.element.data("pointer-pos-start")+n,h=s>e.element.data("pointer-start").x?-1:1,c=e.items.eq(a.focus),1==h)for(d=c.data("left")+Math.abs(n),u=0,f=a.focus;ud){r=f;break}f=f+1==e.items.length?0:f+1}else for(d=c.data("left")-Math.abs(n),u=0,f=a.focus;ua.diff){o=n;break}n=n+1==e.items.length?0:n+1}e.options.infinite||o||(o=e.items.length)}else{for(s=0,n=a.focus;si)return null;for(;a>n;)e=n%i,e?o[s][e]=t[n]:o[++s]=[t[n]],n++;for(n=0,a=o.length;a>n;)o[n]=jQuery(o[n]),n++;return o}var n;t.component("slideset",{defaults:{"default":1,animation:"fade",duration:200,filter:"",delay:!1,controls:!1,autoplay:!1,autoplayInterval:7e3,pauseOnHover:!0},sets:[],boot:function(){t.ready(function(i){t.$("[data-uk-slideset]",i).each(function(){var i=t.$(this);i.data("slideset")||t.slideset(i,t.Utils.options(i.attr("data-uk-slideset")))})})},init:function(){var i=this;this.activeSet=!1,this.list=this.element.find(".uk-slideset"),this.nav=this.element.find(".uk-slideset-nav"),this.controls=this.options.controls?t.$(this.options.controls):this.element,t.$win.on("resize load",t.Utils.debounce(function(){i.update()},100)),i.list.addClass("uk-grid-width-1-"+i.options.default),["xlarge","large","medium","small"].forEach(function(t){i.options[t]&&i.list.addClass("uk-grid-width-"+t+"-1-"+i.options[t])}),this.on("click.uk.slideset","[data-uk-slideset-item]",function(e){if(e.preventDefault(),!i.animating){var n=t.$(this).attr("data-uk-slideset-item");if(i.activeSet!==n)switch(n){case"next":case"previous":i["next"==n?"next":"previous"]();break;default:i.show(parseInt(n,10))}}}),this.controls.on("click.uk.slideset","[data-uk-filter]",function(e){var n=t.$(this);n.parent().hasClass("uk-slideset")||(e.preventDefault(),i.animating||i.currentFilter==n.attr("data-uk-filter")||(i.updateFilter(n.attr("data-uk-filter")),i._hide().then(function(){i.update(!0,!0)})))}),this.on("swipeRight swipeLeft",function(t){i["swipeLeft"==t.type?"next":"previous"]()}),this.updateFilter(this.options.filter),this.update(),this.element.on({mouseenter:function(){i.options.pauseOnHover&&(i.hovering=!0)},mouseleave:function(){i.hovering=!1}}),this.options.autoplay&&this.start(),t.domObserve(this.list,function(){i.list.children(":visible:not(.uk-active)").length&&i.update(!1,!0)})},update:function(t,i){var n,s=this.visible;if(this.visible=this.getVisibleOnCurrenBreakpoint(),s!=this.visible||i){for(this.children=this.list.children().hide(),this.items=this.getItems(),this.sets=e(this.items,this.visible),n=0;n');this.nav[1==this.nav.children().length?"addClass":"removeClass"]("uk-invisible")}this.activeSet=!1,this.show(0,!t)}},updateFilter:function(i){var e,n=this;this.currentFilter=i,this.controls.find("[data-uk-filter]").each(function(){e=t.$(this),e.parent().hasClass("uk-slideset")||(e.attr("data-uk-filter")==n.currentFilter?e.addClass("uk-active"):e.removeClass("uk-active"))})},getVisibleOnCurrenBreakpoint:function(){var i=null,e=t.$('
          ').appendTo("body"),n=e.children().eq(0),s=this.options;return["xlarge","large","medium","small"].forEach(function(t){s[t]&&!i&&(e.attr("class","uk-grid-width-"+t+"-1-2").width(),50==n.width()&&(i=t))}),e.remove(),this.options[i]||this.options["default"]},getItems:function(){var i,e=[];return this.currentFilter?(i=this.currentFilter||[],"string"==typeof i&&(i=i.split(/,/).map(function(t){return t.trim()})),this.children.each(function(){var n=t.$(this),s=n.attr("data-uk-filter"),a=i.length?!1:!0;s&&(s=s.split(/,/).map(function(t){return t.trim()}),i.forEach(function(t){s.indexOf(t)>-1&&(a=!0)})),a&&e.push(n[0])}),e=t.$(e)):e=this.list.children(),e},show:function(i,e,s){var a=this;if(this.activeSet!==i&&!this.animating){s=s||(ii)return null;for(;a>n;)e=n%i,e?o[s][e]=t[n]:o[++s]=[t[n]],n++;for(n=0,a=o.length;a>n;)o[n]=jQuery(o[n]),n++;return o}var n;t.component("slideset",{defaults:{"default":1,animation:"fade",duration:200,filter:"",delay:!1,controls:!1,autoplay:!1,autoplayInterval:7e3,pauseOnHover:!0},sets:[],boot:function(){t.ready(function(i){t.$("[data-uk-slideset]",i).each(function(){var i=t.$(this);i.data("slideset")||t.slideset(i,t.Utils.options(i.attr("data-uk-slideset")))})})},init:function(){var i=this;this.activeSet=!1,this.list=this.element.find(".uk-slideset"),this.nav=this.element.find(".uk-slideset-nav"),this.controls=this.options.controls?t.$(this.options.controls):this.element,t.$win.on("resize load",t.Utils.debounce(function(){i.update()},100)),i.list.addClass("uk-grid-width-1-"+i.options.default),["xlarge","large","medium","small"].forEach(function(t){i.options[t]&&i.list.addClass("uk-grid-width-"+t+"-1-"+i.options[t])}),this.on("click.uk.slideset","[data-uk-slideset-item]",function(e){if(e.preventDefault(),!i.animating){var n=t.$(this).attr("data-uk-slideset-item");if(i.activeSet!==n)switch(n){case"next":case"previous":i["next"==n?"next":"previous"]();break;default:i.show(parseInt(n,10))}}}),this.controls.on("click.uk.slideset","[data-uk-filter]",function(e){var n=t.$(this);n.parent().hasClass("uk-slideset")||(e.preventDefault(),i.animating||i.currentFilter==n.attr("data-uk-filter")||(i.updateFilter(n.attr("data-uk-filter")),i._hide().then(function(){i.update(!0,!0)})))}),this.on("swipeRight swipeLeft",function(t){i["swipeLeft"==t.type?"next":"previous"]()}),this.updateFilter(this.options.filter),this.update(),this.element.on({mouseenter:function(){i.options.pauseOnHover&&(i.hovering=!0)},mouseleave:function(){i.hovering=!1}}),this.options.autoplay&&this.start(),t.domObserve(this.list,function(){i.list.children(":visible:not(.uk-active)").length&&i.update(!1,!0)})},update:function(t,i){var n,s=this.visible;if(this.visible=this.getVisibleOnCurrenBreakpoint(),s!=this.visible||i){for(this.children=this.list.children().hide(),this.items=this.getItems(),this.sets=e(this.items,this.visible),n=0;n');this.nav[1==this.nav.children().length?"addClass":"removeClass"]("uk-invisible")}this.activeSet=!1,this.show(0,!t)}},updateFilter:function(i){var e,n=this;this.currentFilter=i,this.controls.find("[data-uk-filter]").each(function(){e=t.$(this),e.parent().hasClass("uk-slideset")||(e.attr("data-uk-filter")==n.currentFilter?e.addClass("uk-active"):e.removeClass("uk-active"))})},getVisibleOnCurrenBreakpoint:function(){var i=null,e=t.$('
          ').appendTo("body"),n=e.children().eq(0),s=this.options;return["xlarge","large","medium","small"].forEach(function(t){s[t]&&!i&&(e.attr("class","uk-grid-width-"+t+"-1-2").width(),50==n.width()&&(i=t))}),e.remove(),this.options[i]||this.options["default"]},getItems:function(){var i,e=[];return this.currentFilter?(i=this.currentFilter||[],"string"==typeof i&&(i=i.split(/,/).map(function(t){return t.trim()})),this.children.each(function(){var n=t.$(this),s=n.attr("data-uk-filter"),a=i.length?!1:!0;s&&(s=s.split(/,/).map(function(t){return t.trim()}),i.forEach(function(t){s.indexOf(t)>-1&&(a=!0)})),a&&e.push(n[0])}),e=t.$(e)):e=this.list.children(),e},show:function(i,e,s){var a=this;if(this.activeSet!==i&&!this.animating){s=s||(i").css({top:0,left:0,width:this.container.width(),height:this.container.height(),opacity:1,zIndex:15}),p=h.width(),l=h.height(),u="slice-up"==o?l:"0",f=0;f').css({position:"absolute",top:0,left:0,width:p,height:l,"background-image":d,clip:m,opacity:0,transition:"all "+this.options.duration+"ms ease-in-out "+60*f+"ms","-webkit-transition":"all "+this.options.duration+"ms ease-in-out "+60*f+"ms"}).data("clip",v),h.append(r)}return this.container.append(h),h.children().last().on(i.support.transition.end,function(){setTimeout(h.remove.bind(h),0),a.resolve()}),h.width(),h.children().each(function(){var t=i.$(this);t.css({clip:t.data("clip"),opacity:1})}),a.promise()},"slice-up":function(i,e,s){return t.slice.apply(this,[i,e,s,"slice-up"])},"slice-down":function(i,e,s){return t.slice.apply(this,[i,e,s,"slice-down"])},"slice-up-down":function(i,e,s){return t.slice.apply(this,[i,e,s,"slice-up-down"])},fold:function(e,s){if(!s.data("cover"))return t.fade.apply(this,arguments);for(var n,o=i.$.Deferred(),r=Math.ceil(this.element.width()/this.options.slices),a=s.data("cover").css("background-image"),c=i.$("
        • ").css({width:s.width(),height:s.height(),opacity:1,zIndex:15}),d=s.width(),h=s.height(),p=0;p').css({position:"absolute",top:0,left:0,width:d,height:h,"background-image":a,"transform-origin":r*p+"px 0 0",clip:"rect(0px, "+r*(p+1)+"px, "+h+"px, "+r*p+"px)",opacity:0,transform:"scaleX(0.000001)",transition:"all "+this.options.duration+"ms ease-in-out "+(100+60*p)+"ms","-webkit-transition":"all "+this.options.duration+"ms ease-in-out "+(100+60*p)+"ms"}),c.prepend(n);return this.container.append(c),c.width(),c.children().first().on(i.support.transition.end,function(){setTimeout(c.remove.bind(c),0),o.resolve()}).end().css({transform:"scaleX(1)",opacity:1}),o.promise()},puzzle:function(s,n){if(!n.data("cover"))return t.fade.apply(this,arguments);for(var o,r,a,c=i.$.Deferred(),d=this,h=Math.round(this.options.slices/2),p=Math.round(n.width()/h),l=Math.round(n.height()/p),u=Math.round(n.height()/l)+1,f=n.data("cover").css("background-image"),m=i.$("
        • ").css({width:this.container.width(),height:this.container.height(),opacity:1,zIndex:15}),x=this.container.width(),v=this.container.height(),g=0;l>g;g++)for(var w=0;h>w;w++)a=w==h-1?p+2:p,r=[u*g+"px",a*(w+1)+"px",u*(g+1)+"px",p*w+"px"],o=i.$('
          ').css({position:"absolute",top:0,left:0,opacity:0,width:x,height:v,"background-image":f,clip:"rect("+r.join(",")+")","-webkit-transform":"translateZ(0)",transform:"translateZ(0)"}),m.append(o);this.container.append(m);var b=e(m.children());return b.each(function(t){i.$(this).css({transition:"all "+d.options.duration+"ms ease-in-out "+(50+25*t)+"ms","-webkit-transition":"all "+d.options.duration+"ms ease-in-out "+(50+25*t)+"ms"})}).last().on(i.support.transition.end,function(){setTimeout(m.remove.bind(m),0),c.resolve()}),m.width(),b.css({opacity:1}),c.promise()},boxes:function(e,s,n,o){if(!s.data("cover"))return t.fade.apply(this,arguments);for(var r,a,c,d,h=i.$.Deferred(),p=Math.round(this.options.slices/2),l=Math.round(s.width()/p),u=Math.round(s.height()/l),f=Math.round(s.height()/u)+1,m=s.data("cover").css("background-image"),x=i.$("
        • ").css({width:s.width(),height:s.height(),opacity:1,zIndex:15}),v=s.width(),g=s.height(),w=0;u>w;w++)for(d=0;p>d;d++)c=d==p-1?l+2:l,a=[f*w+"px",c*(d+1)+"px",f*(w+1)+"px",l*d+"px"],r=i.$('
          ').css({position:"absolute",top:0,left:0,opacity:1,width:v,height:g,"background-image":m,"transform-origin":a[3]+" "+a[0]+" 0",clip:"rect("+a.join(",")+")","-webkit-transform":"scale(0.0000000000000001)",transform:"scale(0.0000000000000001)"}),x.append(r);this.container.append(x);var b,k=0,y=0,$=0,I=[[]],M=x.children();for("boxes-reverse"==o&&(M=[].reverse.apply(M)),M.each(function(){I[k][y]=i.$(this),y++,y==p&&(k++,y=0,I[k]=[])}),d=0,b=0;p*u>d;d++){b=d;for(var z=0;u>z;z++)b>=0&&p>b&&I[z][b].css({transition:"all "+this.options.duration+"ms linear "+(50+$)+"ms","-webkit-transition":"all "+this.options.duration+"ms linear "+(50+$)+"ms"}),b--;$+=100}return M.last().on(i.support.transition.end,function(){setTimeout(x.remove.bind(x),0),h.resolve()}),x.width(),M.css({"-webkit-transform":"scale(1)",transform:"scale(1)"}),h.promise()},"boxes-reverse":function(i,e,s){return t.boxes.apply(this,[i,e,s,"boxes-reverse"])},"random-fx":function(){var i=["slice-up","fold","puzzle","slice-down","boxes","slice-up-down","boxes-reverse"];return this.fxIndex=(void 0===this.fxIndex?-1:this.fxIndex)+1,i[this.fxIndex]||(this.fxIndex=0),t[i[this.fxIndex]].apply(this,arguments)}});var e=function(i){for(var t,e,s=i.length;s;t=parseInt(Math.random()*s),e=i[--s],i[s]=i[t],i[t]=e);return i};return i.slideshow.animations}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(i){var t;window.UIkit2&&(t=i(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-slideshow-fx",["uikit"],function(){return t||i(UIkit2)})}(function(i){"use strict";var t=i.slideshow.animations;i.$.extend(i.slideshow.animations,{slice:function(e,s,n,o){if(!e.data("cover"))return t.fade.apply(this,arguments);for(var r,a=i.$.Deferred(),c=Math.ceil(this.element.width()/this.options.slices),h=s.data("cover").css("background-image"),d=i.$('
        • ').css({top:0,left:0,width:this.container.width(),height:this.container.height(),opacity:1,zIndex:15}),p=d.width(),l=d.height(),u="slice-up"==o?l:"0",f=0;f').css({position:"absolute",top:0,left:0,width:p,height:l,"background-image":h,clip:m,opacity:0,transition:"all "+this.options.duration+"ms ease-in-out "+60*f+"ms","-webkit-transition":"all "+this.options.duration+"ms ease-in-out "+60*f+"ms"}).data("clip",x),d.append(r)}return this.container.append(d),d.children().last().on(i.support.transition.end,function(){setTimeout(function(){d.remove(),a.resolve()},0)}),d.width(),d.children().each(function(){r=i.$(this),r.css({clip:r.data("clip"),opacity:1})}),a.promise()},"slice-up":function(i,e,s){return t.slice.apply(this,[i,e,s,"slice-up"])},"slice-down":function(i,e,s){return t.slice.apply(this,[i,e,s,"slice-down"])},"slice-up-down":function(i,e,s){return t.slice.apply(this,[i,e,s,"slice-up-down"])},fold:function(e,s){if(!s.data("cover"))return t.fade.apply(this,arguments);for(var n,o=i.$.Deferred(),r=Math.ceil(this.element.width()/this.options.slices),a=s.data("cover").css("background-image"),c=i.$('
        • ').css({width:s.width(),height:s.height(),opacity:1,zIndex:15}),h=s.width(),d=s.height(),p=0;p').css({position:"absolute",top:0,left:0,width:h,height:d,"background-image":a,"transform-origin":r*p+"px 0 0",clip:"rect(0px, "+r*(p+1)+"px, "+d+"px, "+r*p+"px)",opacity:0,transform:"scaleX(0.000001)",transition:"all "+this.options.duration+"ms ease-in-out "+(100+60*p)+"ms","-webkit-transition":"all "+this.options.duration+"ms ease-in-out "+(100+60*p)+"ms"}),c.prepend(n);return this.container.append(c),c.width(),c.children().first().on(i.support.transition.end,function(){setTimeout(function(){c.remove(),o.resolve()},0)}).end().css({transform:"scaleX(1)",opacity:1}),o.promise()},puzzle:function(s,n){if(!n.data("cover"))return t.fade.apply(this,arguments);for(var o,r,a,c=i.$.Deferred(),h=this,d=Math.round(this.options.slices/2),p=Math.round(n.width()/d),l=Math.round(n.height()/p),u=Math.round(n.height()/l)+1,f=n.data("cover").css("background-image"),m=i.$('
        • ').css({width:this.container.width(),height:this.container.height(),opacity:1,zIndex:15}),g=this.container.width(),x=this.container.height(),w=0;l>w;w++)for(var v=0;d>v;v++)a=v==d-1?p+2:p,r=[u*w+"px",a*(v+1)+"px",u*(w+1)+"px",p*v+"px"],o=i.$('
          ').css({position:"absolute",top:0,left:0,opacity:0,width:g,height:x,"background-image":f,clip:"rect("+r.join(",")+")","-webkit-transform":"translateZ(0)",transform:"translateZ(0)"}),m.append(o);this.container.append(m);var k=e(m.children());return k.each(function(t){i.$(this).css({transition:"all "+h.options.duration+"ms ease-in-out "+(50+25*t)+"ms","-webkit-transition":"all "+h.options.duration+"ms ease-in-out "+(50+25*t)+"ms"})}).last().on(i.support.transition.end,function(){setTimeout(function(){m.remove(),c.resolve()},0)}),m.width(),k.css({opacity:1}),c.promise()},boxes:function(e,s,n,o){if(!s.data("cover"))return t.fade.apply(this,arguments);for(var r,a,c,h,d=i.$.Deferred(),p=Math.round(this.options.slices/2),l=Math.round(s.width()/p),u=Math.round(s.height()/l),f=Math.round(s.height()/u)+1,m=s.data("cover").css("background-image"),g=i.$('
        • ').css({width:s.width(),height:s.height(),opacity:1,zIndex:15}),x=s.width(),w=s.height(),v=0;u>v;v++)for(h=0;p>h;h++)c=h==p-1?l+2:l,a=[f*v+"px",c*(h+1)+"px",f*(v+1)+"px",l*h+"px"],r=i.$('
          ').css({position:"absolute",top:0,left:0,opacity:1,width:x,height:w,"background-image":m,"transform-origin":a[3]+" "+a[0]+" 0",clip:"rect("+a.join(",")+")","-webkit-transform":"scale(0.0000000000000001)",transform:"scale(0.0000000000000001)"}),g.append(r);this.container.append(g);var k,b=0,y=0,$=0,I=[[]],M=g.children();for("boxes-reverse"==o&&(M=[].reverse.apply(M)),M.each(function(){I[b][y]=i.$(this),y++,y==p&&(b++,y=0,I[b]=[])}),h=0,k=0;p*u>h;h++){k=h;for(var z=0;u>z;z++)k>=0&&p>k&&I[z][k].css({transition:"all "+this.options.duration+"ms linear "+(50+$)+"ms","-webkit-transition":"all "+this.options.duration+"ms linear "+(50+$)+"ms"}),k--;$+=100}return M.last().on(i.support.transition.end,function(){setTimeout(function(){g.remove(),d.resolve()},0)}),g.width(),M.css({"-webkit-transform":"scale(1)",transform:"scale(1)"}),d.promise()},"boxes-reverse":function(i,e,s){return t.boxes.apply(this,[i,e,s,"boxes-reverse"])},"random-fx":function(){var i=["slice-up","fold","puzzle","slice-down","boxes","slice-up-down","boxes-reverse"];return this.fxIndex=(void 0===this.fxIndex?-1:this.fxIndex)+1,i[this.fxIndex]||(this.fxIndex=0),t[i[this.fxIndex]].apply(this,arguments)}});var e=function(i){for(var t,e,s=i.length;s;t=parseInt(Math.random()*s),e=i[--s],i[s]=i[t],i[t]=e);return i};return i.slideshow.animations}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/slideshow.min.js b/lib/api/uikit/src/js/components/slideshow.min.js index 09d22955..8fe8ced4 100755 --- a/lib/api/uikit/src/js/components/slideshow.min.js +++ b/lib/api/uikit/src/js/components/slideshow.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(i){var t;window.UIkit&&(t=i(UIkit)),"function"==typeof define&&define.amd&&define("uikit-slideshow",["uikit"],function(){return t||i(UIkit)})}(function(i){"use strict";var t,s=0;i.component("slideshow",{defaults:{animation:"fade",duration:500,height:"auto",start:0,autoplay:!1,autoplayInterval:7e3,videoautoplay:!0,videomute:!0,slices:15,pauseOnHover:!0,kenburns:!1,kenburnsanimations:["uk-animation-middle-left","uk-animation-top-right","uk-animation-bottom-left","uk-animation-top-center","","uk-animation-bottom-right"]},current:!1,interval:null,hovering:!1,boot:function(){i.ready(function(t){i.$("[data-uk-slideshow]",t).each(function(){var t=i.$(this);t.data("slideshow")||i.slideshow(t,i.Utils.options(t.attr("data-uk-slideshow")))})})},init:function(){var t=this;this.container=this.element.hasClass("uk-slideshow")?this.element:i.$(this.find(".uk-slideshow:first")),this.current=this.options.start,this.animating=!1,this.fixFullscreen=navigator.userAgent.match(/(iPad|iPhone|iPod)/g)&&this.container.hasClass("uk-slideshow-fullscreen"),this.options.kenburns&&(this.kbanimduration=this.options.kenburns===!0?"15s":this.options.kenburns,String(this.kbanimduration).match(/(ms|s)$/)||(this.kbanimduration+="ms"),"string"==typeof this.options.kenburnsanimations&&(this.options.kenburnsanimations=this.options.kenburnsanimations.split(","))),this.update(),this.on("click.uk.slideshow","[data-uk-slideshow-item]",function(s){s.preventDefault();var e=i.$(this).attr("data-uk-slideshow-item");if(t.current!=e){switch(e){case"next":case"previous":t["next"==e?"next":"previous"]();break;default:t.show(parseInt(e,10))}t.stop()}}),i.$win.on("resize load",i.Utils.debounce(function(){t.resize(),t.fixFullscreen&&(t.container.css("height",window.innerHeight),t.slides.css("height",window.innerHeight))},100)),setTimeout(function(){t.resize()},80),this.options.autoplay&&this.start(),this.options.videoautoplay&&this.slides.eq(this.current).data("media")&&this.playmedia(this.slides.eq(this.current).data("media")),this.options.kenburns&&this.applyKenBurns(this.slides.eq(this.current)),this.container.on({mouseenter:function(){t.options.pauseOnHover&&(t.hovering=!0)},mouseleave:function(){t.hovering=!1}}),this.on("swipeRight swipeLeft",function(i){t["swipeLeft"==i.type?"next":"previous"]()}),this.on("display.uk.check",function(){t.element.is(":visible")&&(t.resize(),t.fixFullscreen&&(t.container.css("height",window.innerHeight),t.slides.css("height",window.innerHeight)))}),i.domObserve(this.element,function(){t.container.children(":not([data-slide])").length&&t.update(!0)})},update:function(t){var e,a=this,n=0;this.slides=this.container.children(),this.slidesCount=this.slides.length,this.slides.eq(this.current).length||(this.current=0),this.slides.each(function(t){var o=i.$(this);if(!o.data("processed")){var r=o.children("img,video,iframe").eq(0),d="html";if(o.data("media",r),o.data("sizer",r),r.length){var u;switch(d=r[0].nodeName.toLowerCase(),r[0].nodeName){case"IMG":var h=i.$('
          ').css({"background-image":"url("+r.attr("src")+")"});r.attr("width")&&r.attr("height")&&(u=i.$("").attr({width:r.attr("width"),height:r.attr("height")}),r.replaceWith(u),r=u,u=void 0),r.css({width:"100%",height:"auto",opacity:0}),o.prepend(h).data("cover",h);break;case"IFRAME":var c=r[0].src,l="sw-"+ ++s;r.attr("src","").on("load",function(){if((t!==a.current||t==a.current&&!a.options.videoautoplay)&&a.pausemedia(r),a.options.videomute){a.mutemedia(r);var i=setInterval(function(t){return function(){a.mutemedia(r),++t>=4&&clearInterval(i)}}(0),250)}}).data("slideshow",a).attr("data-player-id",l).attr("src",[c,c.indexOf("?")>-1?"&":"?","enablejsapi=1&api=1&player_id="+l].join("")).addClass("uk-position-absolute"),i.support.touch||r.css("pointer-events","none"),u=!0,i.cover&&(i.cover(r),r.attr("data-uk-cover","{}"));break;case"VIDEO":r.addClass("uk-cover-object uk-position-absolute"),u=!0,a.options.videomute&&a.mutemedia(r)}if(u){e=i.$("").attr({width:r[0].width,height:r[0].height});var p=i.$('').attr("src",e[0].toDataURL());o.prepend(p),o.data("sizer",p)}}else o.data("sizer",o);a.hasKenBurns(o)&&o.data("cover").css({"-webkit-animation-duration":a.kbanimduration,"animation-duration":a.kbanimduration}),o.data("processed",++n),o.attr("data-slide",d)}}),n&&(this.triggers=this.find("[data-uk-slideshow-item]"),this.slides.attr("aria-hidden","true").removeClass("uk-active").eq(this.current).addClass("uk-active").attr("aria-hidden","false"),this.triggers.filter('[data-uk-slideshow-item="'+this.current+'"]').addClass("uk-active")),t&&n&&this.resize()},resize:function(){if(!this.container.hasClass("uk-slideshow-fullscreen")){var t=this.options.height;"auto"===this.options.height&&(t=0,this.slides.css("height","").each(function(){t=Math.max(t,i.$(this).height())})),this.container.css("height",t),this.slides.css("height",t)}},show:function(s,e){if(!this.animating&&this.current!=s){this.animating=!0;var a=this,n=this.slides.eq(this.current),o=this.slides.eq(s),r=e?e:this.current-1&&"ready"==e.event&&e.player_id&&(s=i.$('[data-player-id="'+e.player_id+'"]'),s.length&&s.data("slideshow").mutemedia(s))},!1)}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(i){var t;window.UIkit2&&(t=i(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-slideshow",["uikit"],function(){return t||i(UIkit2)})}(function(i){"use strict";var t,s=0;i.component("slideshow",{defaults:{animation:"fade",duration:500,height:"auto",start:0,autoplay:!1,autoplayInterval:7e3,videoautoplay:!0,videomute:!0,slices:15,pauseOnHover:!0,kenburns:!1,kenburnsanimations:["uk-animation-middle-left","uk-animation-top-right","uk-animation-bottom-left","uk-animation-top-center","","uk-animation-bottom-right"]},current:!1,interval:null,hovering:!1,boot:function(){i.ready(function(t){i.$("[data-uk-slideshow]",t).each(function(){var t=i.$(this);t.data("slideshow")||i.slideshow(t,i.Utils.options(t.attr("data-uk-slideshow")))})})},init:function(){var t=this;this.container=this.element.hasClass("uk-slideshow")?this.element:i.$(this.find(".uk-slideshow:first")),this.current=this.options.start,this.animating=!1,this.fixFullscreen=navigator.userAgent.match(/(iPad|iPhone|iPod)/g)&&this.container.hasClass("uk-slideshow-fullscreen"),this.options.kenburns&&(this.kbanimduration=this.options.kenburns===!0?"15s":this.options.kenburns,String(this.kbanimduration).match(/(ms|s)$/)||(this.kbanimduration+="ms"),"string"==typeof this.options.kenburnsanimations&&(this.options.kenburnsanimations=this.options.kenburnsanimations.split(","))),this.update(),this.on("click.uk.slideshow","[data-uk-slideshow-item]",function(s){s.preventDefault();var e=i.$(this).attr("data-uk-slideshow-item");if(t.current!=e){switch(e){case"next":case"previous":t["next"==e?"next":"previous"]();break;default:t.show(parseInt(e,10))}t.stop()}}),i.$win.on("resize load",i.Utils.debounce(function(){t.resize(),t.fixFullscreen&&(t.container.css("height",window.innerHeight),t.slides.css("height",window.innerHeight))},100)),setTimeout(function(){t.resize()},80),this.options.autoplay&&this.start(),this.options.videoautoplay&&this.slides.eq(this.current).data("media")&&this.playmedia(this.slides.eq(this.current).data("media")),this.options.kenburns&&this.applyKenBurns(this.slides.eq(this.current)),this.container.on({mouseenter:function(){t.options.pauseOnHover&&(t.hovering=!0)},mouseleave:function(){t.hovering=!1}}),this.on("swipeRight swipeLeft",function(i){t["swipeLeft"==i.type?"next":"previous"]()}),this.on("display.uk.check",function(){t.element.is(":visible")&&(t.resize(),t.fixFullscreen&&(t.container.css("height",window.innerHeight),t.slides.css("height",window.innerHeight)))}),i.domObserve(this.element,function(){t.container.children(":not([data-slideshow-slide])").not(".uk-slideshow-ghost").length&&t.update(!0)})},update:function(t){var e,a=this,n=0;this.slides=this.container.children(),this.slidesCount=this.slides.length,this.slides.eq(this.current).length||(this.current=0),this.slides.each(function(t){var o=i.$(this);if(!o.data("processed")){var r=o.children("img,video,iframe").eq(0),d="html";if(o.data("media",r),o.data("sizer",r),r.length){var u;switch(d=r[0].nodeName.toLowerCase(),r[0].nodeName){case"IMG":var h=i.$('
          ').css({"background-image":"url("+r.attr("src")+")"});r.attr("width")&&r.attr("height")&&(u=i.$("").attr({width:r.attr("width"),height:r.attr("height")}),r.replaceWith(u),r=u,u=void 0),r.css({width:"100%",height:"auto",opacity:0}),o.prepend(h).data("cover",h);break;case"IFRAME":var c=r[0].src,l="sw-"+ ++s;r.attr("src","").on("load",function(){if((t!==a.current||t==a.current&&!a.options.videoautoplay)&&a.pausemedia(r),a.options.videomute){a.mutemedia(r);var i=setInterval(function(t){return function(){a.mutemedia(r),++t>=4&&clearInterval(i)}}(0),250)}}).data("slideshow",a).attr("data-player-id",l).attr("src",[c,c.indexOf("?")>-1?"&":"?","enablejsapi=1&api=1&player_id="+l].join("")).addClass("uk-position-absolute"),i.support.touch||r.css("pointer-events","none"),u=!0,i.cover&&(i.cover(r),r.attr("data-uk-cover","{}"));break;case"VIDEO":r.addClass("uk-cover-object uk-position-absolute"),u=!0,a.options.videomute&&a.mutemedia(r)}if(u){e=i.$("").attr({width:r[0].width,height:r[0].height});var p=i.$('').attr("src",e[0].toDataURL());o.prepend(p),o.data("sizer",p)}}else o.data("sizer",o);a.hasKenBurns(o)&&o.data("cover").css({"-webkit-animation-duration":a.kbanimduration,"animation-duration":a.kbanimduration}),o.data("processed",++n),o.attr("data-slideshow-slide",d)}}),n&&(this.triggers=this.find("[data-uk-slideshow-item]"),this.slides.attr("aria-hidden","true").removeClass("uk-active").eq(this.current).addClass("uk-active").attr("aria-hidden","false"),this.triggers.filter('[data-uk-slideshow-item="'+this.current+'"]').addClass("uk-active")),t&&n&&this.resize()},resize:function(){if(!this.container.hasClass("uk-slideshow-fullscreen")){var t=this.options.height;"auto"===this.options.height&&(t=0,this.slides.css("height","").each(function(){t=Math.max(t,i.$(this).height())})),this.container.css("height",t),this.slides.css("height",t)}},show:function(s,e){if(!this.animating&&this.current!=s){this.animating=!0;var a=this,n=this.slides.eq(this.current),o=this.slides.eq(s),r=e?e:this.current-1&&"ready"==e.event&&e.player_id&&(s=i.$('[data-player-id="'+e.player_id+'"]'),s.length&&s.data("slideshow").mutemedia(s))},!1)}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/sortable.min.js b/lib/api/uikit/src/js/components/sortable.min.js index cd66f57c..e083d2d8 100755 --- a/lib/api/uikit/src/js/components/sortable.min.js +++ b/lib/api/uikit/src/js/components/sortable.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-sortable",["uikit"],function(){return e||t(UIkit)})}(function(t){"use strict";function e(e){e=t.$(e);do{if(e.data("sortable"))return e;e=t.$(e).parent()}while(e.length);return e}function o(t,e){var o=t.parentNode;if(e.parentNode!=o)return!1;for(var n=t.previousSibling;n&&9!==n.nodeType;){if(n===e)return!0;n=n.previousSibling}return!1}function n(t,e){var o=e;if(o==t)return null;for(;o;){if(o.parentNode===t)return o;if(o=o.parentNode,!o||!o.ownerDocument||11===o.nodeType)break}return null}function s(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault(),t.returnValue=!1}var a,r,i,l,d,h,u,p,c,g,f,m="ontouchstart"in window||"MSGesture"in window||window.DocumentTouch&&document instanceof DocumentTouch,v=m?"MSGesture"in window?"pointerdown":"touchstart":"mousedown",b=m?"MSGesture"in window?"pointermove":"touchmove":"mousemove",C=m?"MSGesture"in window?"pointerup":"touchend":"mouseup";return t.component("sortable",{defaults:{animation:150,threshold:10,childClass:"uk-sortable-item",placeholderClass:"uk-sortable-placeholder",overClass:"uk-sortable-over",draggingClass:"uk-sortable-dragged",dragMovingClass:"uk-sortable-moving",baseClass:"uk-sortable",noDragClass:"uk-sortable-nodrag",emptyClass:"uk-sortable-empty",dragCustomClass:"",handleClass:!1,group:!1,stop:function(){},start:function(){},change:function(){}},boot:function(){t.ready(function(e){t.$("[data-uk-sortable]",e).each(function(){var e=t.$(this);e.data("sortable")||t.sortable(e,t.Utils.options(e.attr("data-uk-sortable")))})}),t.$html.on(b,function(e){if(u){var o=e.originalEvent.targetTouches?e.originalEvent.targetTouches[0]:e;(Math.abs(o.pageX-u.pos.x)>u.threshold||Math.abs(o.pageY-u.pos.y)>u.threshold)&&u.apply(o)}if(a){d||(d=!0,a.show(),a.$current.addClass(a.$sortable.options.placeholderClass),a.$sortable.element.children().addClass(a.$sortable.options.childClass),t.$html.addClass(a.$sortable.options.dragMovingClass));var n=a.data("mouse-offset"),s=e.originalEvent.touches&&e.originalEvent.touches[0]||e.originalEvent,r=parseInt(s.pageX,10)+n.left,i=parseInt(s.pageY,10)+n.top;if(a.css({left:r,top:i}),i+a.height()/3>document.body.offsetHeight)return;iwindow.innerHeight+t.$win.scrollTop()&&t.$win.scrollTop(t.$win.scrollTop()+Math.ceil(a.height()/3))}}),t.$html.on(C,function(t){if(u=h=!1,!r||!a)return r=a=null,void 0;var o=e(r),n=a.$sortable,s={type:t.type};o[0]&&n.dragDrop(s,n.element),n.dragEnd(s,n.element)})},init:function(){function e(){m&&f.touches&&f.touches.length?h.addEventListener(b,y,!1):(h.addEventListener("mouseover",$,!1),h.addEventListener("mouseout",w,!1))}function o(){m&&f.touches&&f.touches.length?h.removeEventListener(b,y,!1):(h.removeEventListener("mouseover",$,!1),h.removeEventListener("mouseout",w,!1))}function a(t){r&&d.dragMove(t,d)}function l(e){return function(o){var s,a,r;f=o,o&&(s=o.touches&&o.touches[0]||o,a=s.target||o.target,m&&document.elementFromPoint&&(a=document.elementFromPoint(s.pageX-document.body.scrollLeft,s.pageY-document.body.scrollTop)),g=t.$(a)),t.$(a).hasClass("."+d.options.childClass)?e.apply(a,[o]):a!==h&&(r=n(h,a),r&&e.apply(r,[o]))}}var d=this,h=this.element[0];p=[],this.checkEmptyList(),this.element.data("sortable-group",this.options.group?this.options.group:t.Utils.uid("sortable-group"));var u=l(function(e){if(!e.data||!e.data.sortable){var o=t.$(e.target),n=o.is("a[href]")?o:o.parents("a[href]");if(!o.is(":input")){if(d.options.handleClass){var s=o.hasClass(d.options.handleClass)?o:o.closest("."+d.options.handleClass,d.element);if(!s.length)return}return e.preventDefault(),n.length&&n.one("click",function(t){t.preventDefault()}).one(C,function(){c||(n.trigger("click"),m&&n.attr("href").trim()&&(location.href=n.attr("href")))}),e.data=e.data||{},e.data.sortable=h,d.dragStart(e,this)}}}),$=l(t.Utils.debounce(function(t){return d.dragEnter(t,this)}),40),w=l(function(){var e=d.dragenterData(this);d.dragenterData(this,e-1),d.dragenterData(this)||(t.$(this).removeClass(d.options.overClass),d.dragenterData(this,!1))}),y=l(function(t){return r&&r!==this&&i!==this?(d.element.children().removeClass(d.options.overClass),i=this,d.moveElementNextTo(r,this),s(t)):!0});this.addDragHandlers=e,this.removeDragHandlers=o,window.addEventListener(b,a,!1),h.addEventListener(v,u,!1)},dragStart:function(e,o){c=!1,d=!1,l=!1;var n=this,s=t.$(e.target);if(!(!m&&2==e.button||s.is("."+n.options.noDragClass)||s.closest("."+n.options.noDragClass).length||s.is(":input"))){r=o,a&&a.remove();var i=t.$(r),h=i.offset(),p=e.touches&&e.touches[0]||e;u={pos:{x:p.pageX,y:p.pageY},threshold:n.options.handleClass?1:n.options.threshold,apply:function(){a=t.$('
          ').css({display:"none",top:h.top,left:h.left,width:i.width(),height:i.height(),padding:i.css("padding")}).data({"mouse-offset":{left:h.left-parseInt(p.pageX,10),top:h.top-parseInt(p.pageY,10)},origin:n.element,index:i.index()}).append(i.html()).appendTo("body"),a.$current=i,a.$sortable=n,i.data({"start-list":i.parent(),"start-index":i.index(),"sortable-group":n.options.group}),n.addDragHandlers(),n.options.start(this,r),n.trigger("start.uk.sortable",[n,r,a]),c=!0,u=!1}}}},dragMove:function(e){g=t.$(document.elementFromPoint(e.pageX-(document.body.scrollLeft||document.scrollLeft||0),e.pageY-(document.body.scrollTop||document.documentElement.scrollTop||0)));var o,n=g.closest("."+this.options.baseClass),s=n.data("sortable-group"),a=t.$(r),i=a.parent(),l=a.data("sortable-group");n[0]!==i[0]&&void 0!==l&&s===l&&(n.data("sortable").addDragHandlers(),p.push(n),n.children().addClass(this.options.childClass),n.children().length>0?(o=g.closest("."+this.options.childClass),o.length?o.before(a):n.append(a)):g.append(a),UIkit.$doc.trigger("mouseover")),this.checkEmptyList(),this.checkEmptyList(i)},dragEnter:function(e,o){if(!r||r===o)return!0;var n=this.dragenterData(o);if(this.dragenterData(o,n+1),0===n){var s=t.$(o).parent(),a=t.$(r).data("start-list");if(s[0]!==a[0]){var i=s.data("sortable-group"),l=t.$(r).data("sortable-group");if((i||l)&&i!=l)return!1}t.$(o).addClass(this.options.overClass),this.moveElementNextTo(r,o)}return!1},dragEnd:function(e,o){var n=this;r&&(this.options.stop(o),this.trigger("stop.uk.sortable",[this])),r=null,i=null,p.push(this.element),p.forEach(function(e){t.$(e).children().each(function(){1===this.nodeType&&(t.$(this).removeClass(n.options.overClass).removeClass(n.options.placeholderClass).removeClass(n.options.childClass),n.dragenterData(this,!1))})}),p=[],t.$html.removeClass(this.options.dragMovingClass),this.removeDragHandlers(),a&&(a.remove(),a=null)},dragDrop:function(t){"drop"===t.type&&(t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()),this.triggerChangeEvents()},triggerChangeEvents:function(){if(r){var e=t.$(r),o=a.data("origin"),n=e.closest("."+this.options.baseClass),s=[],i=t.$(r);o[0]===n[0]&&a.data("index")!=e.index()?s.push({sortable:this,mode:"moved"}):o[0]!=n[0]&&s.push({sortable:t.$(n).data("sortable"),mode:"added"},{sortable:t.$(o).data("sortable"),mode:"removed"}),s.forEach(function(t){t.sortable&&t.sortable.element.trigger("change.uk.sortable",[t.sortable,i,t.mode])})}},dragenterData:function(e,o){return e=t.$(e),1==arguments.length?parseInt(e.data("child-dragenter"),10)||0:(o?e.data("child-dragenter",Math.max(0,o)):e.removeData("child-dragenter"),void 0)},moveElementNextTo:function(e,n){l=!0;var s=this,a=t.$(e).parent().css("min-height",""),r=o(e,n)?n:n.nextSibling,i=a.children(),d=i.length;return s.options.animation?(a.css("min-height",a.height()),i.stop().each(function(){var e=t.$(this),o=e.position();o.width=e.width(),e.data("offset-before",o)}),n.parentNode.insertBefore(e,r),t.Utils.checkDisplay(s.element.parent()),i=a.children().each(function(){var e=t.$(this);e.data("offset-after",e.position())}).each(function(){var e=t.$(this),o=e.data("offset-before");e.css({position:"absolute",top:o.top,left:o.left,"min-width":o.width})}),i.each(function(){var e=t.$(this),o=(e.data("offset-before"),e.data("offset-after"));e.css("pointer-events","none").width(),setTimeout(function(){e.animate({top:o.top,left:o.left},s.options.animation,function(){e.css({position:"",top:"",left:"","min-width":"","pointer-events":""}).removeClass(s.options.overClass).removeData("child-dragenter"),d--,d||(a.css("min-height",""),t.Utils.checkDisplay(s.element.parent()))})},0)}),void 0):(n.parentNode.insertBefore(e,r),t.Utils.checkDisplay(s.element.parent()),void 0)},serialize:function(){var e,o,n=[];return this.element.children().each(function(s,a){e={};for(var r,i,l=0;lu.threshold||Math.abs(o.pageY-u.pos.y)>u.threshold)&&u.apply(o)}if(s){d||(d=!0,s.show(),s.$current.addClass(s.$sortable.options.placeholderClass),s.$sortable.element.children().addClass(s.$sortable.options.childClass),t.$html.addClass(s.$sortable.options.dragMovingClass));var n=s.data("mouse-offset"),a=e.originalEvent.touches&&e.originalEvent.touches[0]||e.originalEvent,r=parseInt(a.pageX,10)+n.left,i=parseInt(a.pageY,10)+n.top;if(s.css({left:r,top:i}),i+s.height()/3>document.body.offsetHeight)return;iwindow.innerHeight+t.$win.scrollTop()&&t.$win.scrollTop(t.$win.scrollTop()+Math.ceil(s.height()/3))}}),t.$html.on(C,function(t){if(u=h=!1,!r||!s)return r=s=null,void 0;var o=e(r),n=s.$sortable,a={type:t.type};o[0]&&n.dragDrop(a,n.element),n.dragEnd(a,n.element)})},init:function(){function e(){m&&g.touches&&g.touches.length?h.addEventListener(b,y,!1):(h.addEventListener("mouseover",$,!1),h.addEventListener("mouseout",w,!1))}function o(){m&&g.touches&&g.touches.length?h.removeEventListener(b,y,!1):(h.removeEventListener("mouseover",$,!1),h.removeEventListener("mouseout",w,!1))}function s(t){r&&d.dragMove(t,d)}function l(e){return function(o){var a,s,r;if(g=o,o){if(a=o.touches&&o.touches[0]||o,s=a.target||o.target,m&&document.elementFromPoint){var i=document.elementFromPoint(a.pageX-document.body.scrollLeft,a.pageY-document.body.scrollTop);i&&(s=i)}f=t.$(s)}t.$(s).hasClass("."+d.options.childClass)?e.apply(s,[o]):s!==h&&(r=n(h,s),r&&e.apply(r,[o]))}}var d=this,h=this.element[0];p=[],this.checkEmptyList(),this.element.data("sortable-group",this.options.group?this.options.group:t.Utils.uid("sortable-group"));var u=l(function(e){if(!e.data||!e.data.sortable){var o=t.$(e.target),n=o.is("a[href]")?o:o.parents("a[href]");if(!o.is(":input")){if(d.options.handleClass){var a=o.hasClass(d.options.handleClass)?o:o.closest("."+d.options.handleClass,d.element);if(!a.length)return}return e.preventDefault(),n.length&&n.one("click",function(t){t.preventDefault()}).one(C,function(){c||(n.trigger("click"),m&&n.attr("href").trim()&&(location.href=n.attr("href")))}),e.data=e.data||{},e.data.sortable=h,d.dragStart(e,this)}}}),$=l(t.Utils.debounce(function(t){return d.dragEnter(t,this)}),40),w=l(function(){var e=d.dragenterData(this);d.dragenterData(this,e-1),d.dragenterData(this)||(t.$(this).removeClass(d.options.overClass),d.dragenterData(this,!1))}),y=l(function(t){return r&&r!==this&&i!==this?(d.element.children().removeClass(d.options.overClass),i=this,d.moveElementNextTo(r,this),a(t)):!0});this.addDragHandlers=e,this.removeDragHandlers=o,window.addEventListener(b,s,!1),h.addEventListener(v,u,!1)},dragStart:function(e,o){c=!1,d=!1,l=!1;var n=this,a=t.$(e.target);if((m||2!=e.button)&&!a.is("."+n.options.noDragClass)){var i=a.closest("."+n.options.noDragClass);if(!(i.length&&this.element.find(i[0]).length||a.is(":input"))){r=o,s&&s.remove();var h=t.$(r),p=h.offset(),f=e.touches&&e.touches[0]||e;u={pos:{x:f.pageX,y:f.pageY},threshold:n.options.handleClass?1:n.options.threshold,apply:function(){s=t.$('
          ').css({display:"none",top:p.top,left:p.left,width:h.width(),height:h.height(),padding:h.css("padding")}).data({"mouse-offset":{left:p.left-parseInt(f.pageX,10),top:p.top-parseInt(f.pageY,10)},origin:n.element,index:h.index()}).append(h.html()).appendTo("body"),s.$current=h,s.$sortable=n,h.data({"start-list":h.parent(),"start-index":h.index(),"sortable-group":n.options.group}),n.addDragHandlers(),n.options.start(this,r),n.trigger("start.uk.sortable",[n,r,s]),c=!0,u=!1}}}}},dragMove:function(e){f=t.$(document.elementFromPoint(e.pageX-(document.body.scrollLeft||document.scrollLeft||0),e.pageY-(document.body.scrollTop||document.documentElement.scrollTop||0)));var o,n=f.closest("."+this.options.baseClass),a=n.data("sortable-group"),s=t.$(r),i=s.parent(),l=s.data("sortable-group");n[0]!==i[0]&&void 0!==l&&a===l&&(n.data("sortable").addDragHandlers(),p.push(n),n.children().addClass(this.options.childClass),n.children().length>0?(o=f.closest("."+this.options.childClass),o.length?o.before(s):n.append(s)):f.append(s),t.$doc.trigger("mouseover")),this.checkEmptyList(),this.checkEmptyList(i)},dragEnter:function(e,o){if(!r||r===o)return!0;var n=this.dragenterData(o);if(this.dragenterData(o,n+1),0===n){var a=t.$(o).parent(),s=t.$(r).data("start-list");if(a[0]!==s[0]){var i=a.data("sortable-group"),l=t.$(r).data("sortable-group");if((i||l)&&i!=l)return!1}t.$(o).addClass(this.options.overClass),this.moveElementNextTo(r,o)}return!1},dragEnd:function(e,o){var n=this;r&&(this.options.stop(o),this.trigger("stop.uk.sortable",[this])),r=null,i=null,p.push(this.element),p.forEach(function(e){t.$(e).children().each(function(){1===this.nodeType&&(t.$(this).removeClass(n.options.overClass).removeClass(n.options.placeholderClass).removeClass(n.options.childClass),n.dragenterData(this,!1))})}),p=[],t.$html.removeClass(this.options.dragMovingClass),this.removeDragHandlers(),s&&(s.remove(),s=null)},dragDrop:function(t){"drop"===t.type&&(t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()),this.triggerChangeEvents()},triggerChangeEvents:function(){if(r){var e=t.$(r),o=s.data("origin"),n=e.closest("."+this.options.baseClass),a=[],i=t.$(r);o[0]===n[0]&&s.data("index")!=e.index()?a.push({sortable:this,mode:"moved"}):o[0]!=n[0]&&a.push({sortable:t.$(n).data("sortable"),mode:"added"},{sortable:t.$(o).data("sortable"),mode:"removed"}),a.forEach(function(t){t.sortable&&t.sortable.element.trigger("change.uk.sortable",[t.sortable,i,t.mode])})}},dragenterData:function(e,o){return e=t.$(e),1==arguments.length?parseInt(e.data("child-dragenter"),10)||0:(o?e.data("child-dragenter",Math.max(0,o)):e.removeData("child-dragenter"),void 0)},moveElementNextTo:function(e,n){l=!0;var a=this,s=t.$(e).parent().css("min-height",""),r=o(e,n)?n:n.nextSibling,i=s.children(),d=i.length;return a.options.animation?(s.css("min-height",s.height()),i.stop().each(function(){var e=t.$(this),o=e.position();o.width=e.width(),e.data("offset-before",o)}),n.parentNode.insertBefore(e,r),t.Utils.checkDisplay(a.element.parent()),i=s.children().each(function(){var e=t.$(this);e.data("offset-after",e.position())}).each(function(){var e=t.$(this),o=e.data("offset-before");e.css({position:"absolute",top:o.top,left:o.left,minWidth:o.width})}),i.each(function(){var e=t.$(this),o=(e.data("offset-before"),e.data("offset-after"));e.css("pointer-events","none").width(),setTimeout(function(){e.animate({top:o.top,left:o.left},a.options.animation,function(){e.css({position:"",top:"",left:"",minWidth:"","pointer-events":""}).removeClass(a.options.overClass).removeData("child-dragenter"),d--,d||(s.css("min-height",""),t.Utils.checkDisplay(a.element.parent()))})},0)}),void 0):(n.parentNode.insertBefore(e,r),t.Utils.checkDisplay(a.element.parent()),void 0)},serialize:function(){var e,o,n=[];return this.element.children().each(function(a,s){e={};for(var r,i,l=0;lm?m-p:0,u=0;uo?o+h.top:h.top),h.boundary&&h.boundary.length){var f=h.boundary.offset().top;a=h.boundtoparent?c-(f+h.boundary.outerHeight())+parseInt(h.boundary.css("padding-bottom")):c-f,o=p+r>c-a-(h.top<0?0:h.top)?c-a-(p+r):o}if(h.currentTop!=o){if(h.element.css({position:"fixed",top:o,width:h.getWidthFrom.length?h.getWidthFrom.width():h.element.width()}),!h.init&&(h.element.addClass(h.options.clsinit),location.hash&&p>0&&h.options.target)){var g=t.$(location.hash);g.length&&setTimeout(function(t,i){return function(){i.element.width();var e=t.offset(),s=e.top+t.outerHeight(),n=i.element.offset(),o=i.element.outerHeight(),a=n.top+o;n.top').parent(),this.computeWrapper(),this.wrapper.css({"margin-top":this.element.css("margin-top"),"margin-bottom":this.element.css("margin-bottom"),"margin-left":this.element.css("margin-left"),"margin-right":this.element.css("margin-right")}),this.element.css("margin",0),a&&(a===!0||"!"===a[0]?(a=a===!0?this.wrapper.parent():this.wrapper.closest(a.substr(1)),i=!0):"string"==typeof a&&(a=t.$(a))),this.sticky={self:this,options:this.options,element:this.element,currentTop:null,wrapper:this.wrapper,init:!1,getWidthFrom:t.$(this.options.getWidthFrom||this.wrapper),boundary:a,boundtoparent:i,top:0,calcTop:function(){var i=this.options.top;if(this.options.top&&"string"==typeof this.options.top)if(this.options.top.match(/^(-|)(\d+)vh$/))i=window.innerHeight*parseInt(this.options.top,10)/100;else{var e=t.$(this.options.top).first();e.length&&e.is(":visible")&&(i=-1*(e.offset().top+e.outerHeight()-this.wrapper.offset().top))}this.top=i},reset:function(i){this.calcTop();var e=function(){this.element.css({position:"",top:"",width:"",left:"",margin:"0"}),this.element.removeClass([this.options.animation,"uk-animation-reverse",this.options.clsactive].join(" ")),this.element.addClass(this.options.clsinactive),this.element.trigger("inactive.uk.sticky"),this.currentTop=null,this.animate=!1}.bind(this);!i&&this.options.animation&&t.support.animation&&!t.Utils.isInView(this.wrapper)?(this.animate=!0,this.element.removeClass(this.options.animation).one(t.support.animation.end,function(){e()}).width(),this.element.addClass(this.options.animation+" uk-animation-reverse")):e()},check:function(){if(this.options.disabled)return!1;if(this.options.media)switch(typeof this.options.media){case"number":if(window.innerWidtha?a-i:0,h=this.wrapper.offset().top,p=h-this.top-r,c=i>=p;return c&&this.options.showup&&(1==o&&(c=!1),-1==o&&!this.element.hasClass(this.options.clsactive)&&t.Utils.isInView(this.wrapper)&&(c=!1)),c}},this.sticky.calcTop(),n.push(this.sticky)},update:function(){i(this.sticky)},enable:function(){this.options.disabled=!1,this.update()},disable:function(t){this.options.disabled=!0,this.sticky.reset(t)},computeWrapper:function(){this.wrapper.css({height:-1==["absolute","fixed"].indexOf(this.element.css("position"))?this.element.outerHeight():"","float":"none"!=this.element.css("float")?this.element.css("float"):""}),"fixed"==this.element.css("position")&&this.element.css({width:this.sticky.getWidthFrom.length?this.sticky.getWidthFrom.width():this.element.width()})}}),t.sticky}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var i;window.UIkit2&&(i=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-sticky",["uikit"],function(){return i||t(UIkit2)})}(function(t){"use strict";function i(){var i=arguments.length?arguments:n;if(i.length&&!(e.scrollTop()<0))for(var o,a,r,h,p=e.scrollTop(),c=s.height(),l=e.height(),m=c-l,d=p>m?m-p:0,u=0;uo?o+h.top:h.top),h.boundary&&h.boundary.length){var f=h.boundary.offset().top;a=h.boundtoparent?c-(f+h.boundary.outerHeight())+parseInt(h.boundary.css("padding-bottom")):c-f,o=p+r>c-a-(h.top<0?0:h.top)?c-a-(p+r):o}if(h.currentTop!=o){if(h.element.css({position:"fixed",top:o,width:h.getWidthFrom.length?h.getWidthFrom.width():h.element.width()}),!h.init&&(h.element.addClass(h.options.clsinit),location.hash&&p>0&&h.options.target)){var g=t.$(location.hash);g.length&&setTimeout(function(t,i){return function(){i.element.width();var e=t.offset(),s=e.top+t.outerHeight(),n=i.element.offset(),o=i.element.outerHeight(),a=n.top+o;n.top').parent(),this.computeWrapper(),this.wrapper.css({"margin-top":this.element.css("margin-top"),"margin-bottom":this.element.css("margin-bottom"),"margin-left":this.element.css("margin-left"),"margin-right":this.element.css("margin-right")}),this.element.css("margin",0),a&&(a===!0||"!"===a[0]?(a=a===!0?this.wrapper.parent():this.wrapper.closest(a.substr(1)),i=!0):"string"==typeof a&&(a=t.$(a))),this.sticky={self:this,options:this.options,element:this.element,currentTop:null,wrapper:this.wrapper,init:!1,getWidthFrom:t.$(this.options.getWidthFrom||this.wrapper),boundary:a,boundtoparent:i,top:0,calcTop:function(){var i=this.options.top;if(this.options.top&&"string"==typeof this.options.top)if(this.options.top.match(/^(-|)(\d+)vh$/))i=window.innerHeight*parseInt(this.options.top,10)/100;else{var e=t.$(this.options.top).first();e.length&&e.is(":visible")&&(i=-1*(e.offset().top+e.outerHeight()-this.wrapper.offset().top))}this.top=i},reset:function(i){this.calcTop();var e=function(){this.element.css({position:"",top:"",width:"",left:"",margin:"0"}),this.element.removeClass([this.options.animation,"uk-animation-reverse",this.options.clsactive].join(" ")),this.element.addClass(this.options.clsinactive),this.element.trigger("inactive.uk.sticky"),this.currentTop=null,this.animate=!1}.bind(this);!i&&this.options.animation&&t.support.animation&&!t.Utils.isInView(this.wrapper)?(this.animate=!0,this.element.removeClass(this.options.animation).one(t.support.animation.end,function(){e()}).width(),this.element.addClass(this.options.animation+" uk-animation-reverse")):e()},check:function(){if(this.options.disabled)return!1;if(this.options.media)switch(typeof this.options.media){case"number":if(window.innerWidtha?a-i:0,h=this.wrapper.offset().top,p=h-this.top-r,c=i>=p;return c&&this.options.showup&&(1==o&&(c=!1),-1==o&&!this.element.hasClass(this.options.clsactive)&&t.Utils.isInView(this.wrapper)&&(c=!1)),c}},this.sticky.calcTop(),n.push(this.sticky)},update:function(){i(this.sticky)},enable:function(){this.options.disabled=!1,this.update()},disable:function(t){this.options.disabled=!0,this.sticky.reset(t)},computeWrapper:function(){this.wrapper.css({height:-1==["absolute","fixed"].indexOf(this.element.css("position"))?this.element.outerHeight():"","float":"none"!=this.element.css("float")?this.element.css("float"):""}),"fixed"==this.element.css("position")&&this.element.css({width:this.sticky.getWidthFrom.length?this.sticky.getWidthFrom.width():this.element.width()})}}),t.sticky}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/timepicker.min.js b/lib/api/uikit/src/js/components/timepicker.min.js index ae8c9f8d..cf8dee4c 100755 --- a/lib/api/uikit/src/js/components/timepicker.min.js +++ b/lib/api/uikit/src/js/components/timepicker.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-timepicker",["uikit"],function(){return e||t(UIkit)})}(function(t){"use strict";function e(t,e){t=t||0,e=e||24;var i,o,a={"12h":[],"24h":[]};for(i=t,o="";e>i;i++)o=""+i,10>i&&(o="0"+o),a["24h"].push({value:o+":00"}),a["24h"].push({value:o+":30"}),0===i&&(o=12,a["12h"].push({value:o+":00 AM"}),a["12h"].push({value:o+":30 AM"})),i>0&&13>i&&12!==i&&(a["12h"].push({value:o+":00 AM"}),a["12h"].push({value:o+":30 AM"})),i>=12&&(o-=12,0===o&&(o=12),10>o&&(o="0"+String(o)),a["12h"].push({value:o+":00 PM"}),a["12h"].push({value:o+":30 PM"}));return a}t.component("timepicker",{defaults:{format:"24h",delay:0,start:0,end:24},boot:function(){t.$html.on("focus.timepicker.uikit","[data-uk-timepicker]",function(){var e=t.$(this);if(!e.data("timepicker")){var i=t.timepicker(e,t.Utils.options(e.attr("data-uk-timepicker")));setTimeout(function(){i.autocomplete.input.focus()},40)}})},init:function(){var i,o=this,a=e(this.options.start,this.options.end);this.options.minLength=0,this.options.template='',this.options.source=function(t){t(a[o.options.format]||a["12h"])},this.element.is("input")?(this.element.wrap('
          '),i=this.element.parent()):i=this.element.addClass("uk-autocomplete"),this.autocomplete=t.autocomplete(i,this.options),this.autocomplete.dropdown.addClass("uk-dropdown-small uk-dropdown-scrollable"),this.autocomplete.on("show.uk.autocomplete",function(){var t=o.autocomplete.dropdown.find('[data-value="'+o.autocomplete.input.val()+'"]');setTimeout(function(){o.autocomplete.pick(t,!0)},10)}),this.autocomplete.input.on("focus",function(){o.autocomplete.value=Math.random(),o.autocomplete.triggercomplete()}).on("blur",t.Utils.debounce(function(){o.checkTime()},100)),this.element.data("timepicker",this)},checkTime:function(){var t,e,i,o,a="AM",u=this.autocomplete.input.val();"12h"==this.options.format?(t=u.split(" "),e=t[0].split(":"),a=t[1]):e=u.split(":"),i=parseInt(e[0],10),o=parseInt(e[1],10),isNaN(i)&&(i=0),isNaN(o)&&(o=0),"12h"==this.options.format?(i>12?i=12:0>i&&(i=12),"am"===a||"a"===a?a="AM":("pm"===a||"p"===a)&&(a="PM"),"AM"!==a&&"PM"!==a&&(a="AM")):i>=24?i=23:0>i&&(i=0),0>o?o=0:o>=60&&(o=0),this.autocomplete.input.val(this.formatTime(i,o,a)).trigger("change")},formatTime:function(t,e,i){return t=10>t?"0"+t:t,e=10>e?"0"+e:e,t+":"+e+("12h"==this.options.format?" "+i:"")}})}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var e;window.UIkit2&&(e=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-timepicker",["uikit"],function(){return e||t(UIkit2)})}(function(t){"use strict";function e(t,e){t=t||0,e=e||24;var i,o,a={"12h":[],"24h":[]};for(i=t,o="";e>i;i++)o=""+i,10>i&&(o="0"+o),a["24h"].push({value:o+":00"}),a["24h"].push({value:o+":30"}),0===i&&(o=12,a["12h"].push({value:o+":00 AM"}),a["12h"].push({value:o+":30 AM"})),i>0&&13>i&&12!==i&&(a["12h"].push({value:o+":00 AM"}),a["12h"].push({value:o+":30 AM"})),i>=12&&(o-=12,0===o&&(o=12),10>o&&(o="0"+String(o)),a["12h"].push({value:o+":00 PM"}),a["12h"].push({value:o+":30 PM"}));return a}t.component("timepicker",{defaults:{format:"24h",delay:0,start:0,end:24},boot:function(){t.$html.on("focus.timepicker.uikit","[data-uk-timepicker]",function(){var e=t.$(this);if(!e.data("timepicker")){var i=t.timepicker(e,t.Utils.options(e.attr("data-uk-timepicker")));setTimeout(function(){i.autocomplete.input.focus()},40)}})},init:function(){var i,o=this,a=e(this.options.start,this.options.end);this.options.minLength=0,this.options.template='',this.options.source=function(t){t(a[o.options.format]||a["12h"])},this.element.is("input")?(this.element.wrap('
          '),i=this.element.parent()):i=this.element.addClass("uk-autocomplete"),this.autocomplete=t.autocomplete(i,this.options),this.autocomplete.dropdown.addClass("uk-dropdown-small uk-dropdown-scrollable"),this.autocomplete.on("show.uk.autocomplete",function(){var t=o.autocomplete.dropdown.find('[data-value="'+o.autocomplete.input.val()+'"]');setTimeout(function(){o.autocomplete.pick(t,!0)},10)}),this.autocomplete.input.on("focus",function(){o.autocomplete.value=Math.random(),o.autocomplete.triggercomplete()}).on("blur",t.Utils.debounce(function(){o.checkTime()},100)),this.element.data("timepicker",this)},checkTime:function(){var t,e,i,o,a="AM",u=this.autocomplete.input.val();"12h"==this.options.format?(t=u.split(" "),e=t[0].split(":"),a=t[1]):e=u.split(":"),i=parseInt(e[0],10),o=parseInt(e[1],10),isNaN(i)&&(i=0),isNaN(o)&&(o=0),"12h"==this.options.format?(i>12?i=12:0>i&&(i=12),"am"===a||"a"===a?a="AM":("pm"===a||"p"===a)&&(a="PM"),"AM"!==a&&"PM"!==a&&(a="AM")):i>=24?i=23:0>i&&(i=0),0>o?o=0:o>=60&&(o=0),this.autocomplete.input.val(this.formatTime(i,o,a)).trigger("change")},formatTime:function(t,e,i){return t=10>t?"0"+t:t,e=10>e?"0"+e:e,t+":"+e+("12h"==this.options.format?" "+i:"")}})}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/tooltip.min.js b/lib/api/uikit/src/js/components/tooltip.min.js index 31eda9ab..a47d6524 100755 --- a/lib/api/uikit/src/js/components/tooltip.min.js +++ b/lib/api/uikit/src/js/components/tooltip.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){var i;window.UIkit&&(i=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-tooltip",["uikit"],function(){return i||t(UIkit)})}(function(t){"use strict";var i,o,e;return t.component("tooltip",{defaults:{offset:5,pos:"top",animation:!1,delay:0,cls:"",activeClass:"uk-active",src:function(t){var i=t.attr("title");return void 0!==i&&t.data("cached-title",i).removeAttr("title"),t.data("cached-title")}},tip:"",boot:function(){t.$html.on("mouseenter.tooltip.uikit focus.tooltip.uikit","[data-uk-tooltip]",function(){var i=t.$(this);i.data("tooltip")||(t.tooltip(i,t.Utils.options(i.attr("data-uk-tooltip"))),i.trigger("mouseenter"))})},init:function(){var o=this;i||(i=t.$('
          ').appendTo("body")),this.on({focus:function(){o.show()},blur:function(){o.hide()},mouseenter:function(){o.show()},mouseleave:function(){o.hide()}})},show:function(){if(this.tip="function"==typeof this.options.src?this.options.src(this.element):this.options.src,o&&clearTimeout(o),e&&clearTimeout(e),"string"==typeof this.tip?this.tip.length:0){i.stop().css({top:-2e3,visibility:"hidden"}).removeClass(this.options.activeClass).show(),i.html('
          '+this.tip+"
          ");var s=this,n=t.$.extend({},this.element.offset(),{width:this.element[0].offsetWidth,height:this.element[0].offsetHeight}),l=i[0].offsetWidth,f=i[0].offsetHeight,p="function"==typeof this.options.offset?this.options.offset.call(this.element):this.options.offset,a="function"==typeof this.options.pos?this.options.pos.call(this.element):this.options.pos,h=a.split("-"),c={display:"none",visibility:"visible",top:n.top+n.height+f,left:n.left};if("fixed"==t.$html.css("position")||"fixed"==t.$body.css("position")){var r=t.$("body").offset(),d=t.$("html").offset(),u={top:d.top+r.top,left:d.left+r.left};n.left-=u.left,n.top-=u.top}"left"!=h[0]&&"right"!=h[0]||"right"!=t.langdirection||(h[0]="left"==h[0]?"right":"left");var m={bottom:{top:n.top+n.height+p,left:n.left+n.width/2-l/2},top:{top:n.top-f-p,left:n.left+n.width/2-l/2},left:{top:n.top+n.height/2-f/2,left:n.left-l-p},right:{top:n.top+n.height/2-f/2,left:n.left+n.width+p}};t.$.extend(c,m[h[0]]),2==h.length&&(c.left="left"==h[1]?n.left:n.left+n.width-l);var v=this.checkBoundary(c.left,c.top,l,f);if(v){switch(v){case"x":a=2==h.length?h[0]+"-"+(c.left<0?"left":"right"):c.left<0?"right":"left";break;case"y":a=2==h.length?(c.top<0?"bottom":"top")+"-"+h[1]:c.top<0?"bottom":"top";break;case"xy":a=2==h.length?(c.top<0?"bottom":"top")+"-"+(c.left<0?"left":"right"):c.left<0?"right":"left"}h=a.split("-"),t.$.extend(c,m[h[0]]),2==h.length&&(c.left="left"==h[1]?n.left:n.left+n.width-l)}c.left-=t.$body.position().left,o=setTimeout(function(){i.css(c).attr("class",["uk-tooltip","uk-tooltip-"+a,s.options.cls].join(" ")),s.options.animation?i.css({opacity:0,display:"block"}).addClass(s.options.activeClass).animate({opacity:1},parseInt(s.options.animation,10)||400):i.show().addClass(s.options.activeClass),o=!1,e=setInterval(function(){s.element.is(":visible")||s.hide()},150)},parseInt(this.options.delay,10)||0)}},hide:function(){if(!this.element.is("input")||this.element[0]!==document.activeElement)if(o&&clearTimeout(o),e&&clearTimeout(e),i.stop(),this.options.animation){var t=this;i.fadeOut(parseInt(this.options.animation,10)||400,function(){i.removeClass(t.options.activeClass)})}else i.hide().removeClass(this.options.activeClass)},content:function(){return this.tip},checkBoundary:function(i,o,e,s){var n="";return(0>i||i-t.$win.scrollLeft()+e>window.innerWidth)&&(n+="x"),(0>o||o-t.$win.scrollTop()+s>window.innerHeight)&&(n+="y"),n}}),t.tooltip}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var i;window.UIkit2&&(i=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-tooltip",["uikit"],function(){return i||t(UIkit2)})}(function(t){"use strict";var i,o,e;return t.component("tooltip",{defaults:{offset:5,pos:"top",animation:!1,delay:0,cls:"",activeClass:"uk-active",src:function(t){var i=t.attr("title");return void 0!==i&&t.data("cached-title",i).removeAttr("title"),t.data("cached-title")}},tip:"",boot:function(){t.$html.on("mouseenter.tooltip.uikit focus.tooltip.uikit","[data-uk-tooltip]",function(){var i=t.$(this);i.data("tooltip")||(t.tooltip(i,t.Utils.options(i.attr("data-uk-tooltip"))),i.trigger("mouseenter"))})},init:function(){var o=this;i||(i=t.$('
          ').appendTo("body")),this.on({focus:function(){o.show()},blur:function(){o.hide()},mouseenter:function(){o.show()},mouseleave:function(){o.hide()}})},show:function(){if(this.tip="function"==typeof this.options.src?this.options.src(this.element):this.options.src,o&&clearTimeout(o),e&&clearInterval(e),"string"==typeof this.tip?this.tip.length:0){i.stop().css({top:-2e3,visibility:"hidden"}).removeClass(this.options.activeClass).show(),i.html('
          '+this.tip+"
          ");var s=this,n=t.$.extend({},this.element.offset(),{width:this.element[0].offsetWidth,height:this.element[0].offsetHeight}),l=i[0].offsetWidth,f=i[0].offsetHeight,a="function"==typeof this.options.offset?this.options.offset.call(this.element):this.options.offset,p="function"==typeof this.options.pos?this.options.pos.call(this.element):this.options.pos,h=p.split("-"),c={display:"none",visibility:"visible",top:n.top+n.height+f,left:n.left};if("fixed"==t.$html.css("position")||"fixed"==t.$body.css("position")){var r=t.$("body").offset(),d=t.$("html").offset(),u={top:d.top+r.top,left:d.left+r.left};n.left-=u.left,n.top-=u.top}"left"!=h[0]&&"right"!=h[0]||"right"!=t.langdirection||(h[0]="left"==h[0]?"right":"left");var m={bottom:{top:n.top+n.height+a,left:n.left+n.width/2-l/2},top:{top:n.top-f-a,left:n.left+n.width/2-l/2},left:{top:n.top+n.height/2-f/2,left:n.left-l-a},right:{top:n.top+n.height/2-f/2,left:n.left+n.width+a}};t.$.extend(c,m[h[0]]),2==h.length&&(c.left="left"==h[1]?n.left:n.left+n.width-l);var v=this.checkBoundary(c.left,c.top,l,f);if(v){switch(v){case"x":p=2==h.length?h[0]+"-"+(c.left<0?"left":"right"):c.left<0?"right":"left";break;case"y":p=2==h.length?(c.top<0?"bottom":"top")+"-"+h[1]:c.top<0?"bottom":"top";break;case"xy":p=2==h.length?(c.top<0?"bottom":"top")+"-"+(c.left<0?"left":"right"):c.left<0?"right":"left"}h=p.split("-"),t.$.extend(c,m[h[0]]),2==h.length&&(c.left="left"==h[1]?n.left:n.left+n.width-l)}c.left-=t.$body.position().left,o=setTimeout(function(){i.css(c).attr("class",["uk-tooltip","uk-tooltip-"+p,s.options.cls].join(" ")),s.options.animation?i.css({opacity:0,display:"block"}).addClass(s.options.activeClass).animate({opacity:1},parseInt(s.options.animation,10)||400):i.show().addClass(s.options.activeClass),o=!1,e=setInterval(function(){s.element.is(":visible")||s.hide()},150)},parseInt(this.options.delay,10)||0)}},hide:function(){if(!this.element.is("input")||this.element[0]!==document.activeElement)if(o&&clearTimeout(o),e&&clearInterval(e),i.stop(),this.options.animation){var t=this;i.fadeOut(parseInt(this.options.animation,10)||400,function(){i.removeClass(t.options.activeClass)})}else i.hide().removeClass(this.options.activeClass)},content:function(){return this.tip},checkBoundary:function(i,o,e,s){var n="";return(0>i||i-t.$win.scrollLeft()+e>window.innerWidth)&&(n+="x"),(0>o||o-t.$win.scrollTop()+s>window.innerHeight)&&(n+="y"),n}}),t.tooltip}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/components/upload.min.js b/lib/api/uikit/src/js/components/upload.min.js index 2f7f3c61..31fe9d43 100755 --- a/lib/api/uikit/src/js/components/upload.min.js +++ b/lib/api/uikit/src/js/components/upload.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(e){var t;window.UIkit&&(t=e(UIkit)),"function"==typeof define&&define.amd&&define("uikit-upload",["uikit"],function(){return t||e(UIkit)})}(function(e){"use strict";function t(o,a){function r(t,n){var o=new FormData,a=new XMLHttpRequest;if(n.before(n,t)!==!1){for(var r,i=0;r=t[i];i++)o.append(n.param,r);for(var l in n.params)o.append(l,n.params[l]);a.upload.addEventListener("progress",function(e){var t=e.loaded/e.total*100;n.progress(t,e)},!1),a.addEventListener("loadstart",function(e){n.loadstart(e)},!1),a.addEventListener("load",function(e){n.load(e)},!1),a.addEventListener("loadend",function(e){n.loadend(e)},!1),a.addEventListener("error",function(e){n.error(e)},!1),a.addEventListener("abort",function(e){n.abort(e)},!1),a.open(n.method,n.action,!0),"json"==n.type&&a.setRequestHeader("Accept","application/json");for(var s in n.headers)a.setRequestHeader(s,n.headers[s]);a.onreadystatechange=function(){if(n.readystatechange(a),4==a.readyState){var t=a.responseText;if("json"==n.type)try{t=e.$.parseJSON(t)}catch(o){t=!1}n.complete(t,a)}},n.beforeSend(a),a.send(o)}}if(!e.support.ajaxupload)return this;if(a=e.$.extend({},t.defaults,a),o.length){if("*.*"!==a.allow)for(var i,l=0;i=o[l];l++)if(!n(a.allow,i.name))return"string"==typeof a.notallowed?alert(a.notallowed):a.notallowed(i,a),void 0;var s=a.complete;if(a.single){var d=o.length,f=0,p=!0;a.beforeAll(o),a.complete=function(e,t){f+=1,s(e,t),a.filelimit&&f>=a.filelimit&&(p=!1),p&&d>f?r([o[f]],a):a.allcomplete(e,t)},r([o[0]],a)}else a.complete=function(e,t){s(e,t),a.allcomplete(e,t)},r(o,a)}}function n(e,t){var n="^"+e.replace(/\//g,"\\/").replace(/\*\*/g,"(\\/[^\\/]+)*").replace(/\*/g,"[^\\/]+").replace(/((?!\\))\?/g,"$1.")+"$";return n="^"+n+"$",null!==t.match(new RegExp(n,"i"))}return e.component("uploadSelect",{init:function(){var e=this;this.on("change",function(){t(e.element[0].files,e.options);var n=e.element.clone(!0).data("uploadSelect",e);e.element.replaceWith(n),e.element=n})}}),e.component("uploadDrop",{defaults:{dragoverClass:"uk-dragover"},init:function(){var e=this,n=!1;this.on("drop",function(n){n.originalEvent.dataTransfer&&n.originalEvent.dataTransfer.files&&(n.stopPropagation(),n.preventDefault(),e.element.removeClass(e.options.dragoverClass),e.element.trigger("dropped.uk.upload",[n.originalEvent.dataTransfer.files]),t(n.originalEvent.dataTransfer.files,e.options))}).on("dragenter",function(e){e.stopPropagation(),e.preventDefault()}).on("dragover",function(t){t.stopPropagation(),t.preventDefault(),n||(e.element.addClass(e.options.dragoverClass),n=!0)}).on("dragleave",function(t){t.stopPropagation(),t.preventDefault(),e.element.removeClass(e.options.dragoverClass),n=!1})}}),e.support.ajaxupload=function(){function e(){var e=document.createElement("INPUT");return e.type="file","files"in e}function t(){var e=new XMLHttpRequest;return!!(e&&"upload"in e&&"onprogress"in e.upload)}function n(){return!!window.FormData}return e()&&t()&&n()}(),t.defaults={action:"",single:!0,method:"POST",param:"files[]",params:{},allow:"*.*",type:"text",filelimit:!1,headers:{},before:function(){},beforeSend:function(){},beforeAll:function(){},loadstart:function(){},load:function(){},loadend:function(){},error:function(){},abort:function(){},progress:function(){},complete:function(){},allcomplete:function(){},readystatechange:function(){},notallowed:function(e,t){alert("Only the following file types are allowed: "+t.allow)}},e.Utils.xhrupload=t,t}); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(e){var t;window.UIkit2&&(t=e(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-upload",["uikit"],function(){return t||e(UIkit2)})}(function(e){"use strict";function t(o,a){function r(t,n){var o=new FormData,a=new XMLHttpRequest;if(n.before(n,t)!==!1){for(var r,i=0;r=t[i];i++)o.append(n.param,r);for(var l in n.params)o.append(l,n.params[l]);a.upload.addEventListener("progress",function(e){var t=e.loaded/e.total*100;n.progress(t,e)},!1),a.addEventListener("loadstart",function(e){n.loadstart(e)},!1),a.addEventListener("load",function(e){n.load(e)},!1),a.addEventListener("loadend",function(e){n.loadend(e)},!1),a.addEventListener("error",function(e){n.error(e)},!1),a.addEventListener("abort",function(e){n.abort(e)},!1),a.open(n.method,n.action,!0),"json"==n.type&&a.setRequestHeader("Accept","application/json");for(var s in n.headers)a.setRequestHeader(s,n.headers[s]);a.onreadystatechange=function(){if(n.readystatechange(a),4==a.readyState){var t=a.responseText;if("json"==n.type)try{t=e.$.parseJSON(t)}catch(o){t=!1}n.complete(t,a)}},n.beforeSend(a),a.send(o)}}if(!e.support.ajaxupload)return this;if(a=e.$.extend({},t.defaults,a),o.length){if("*.*"!==a.allow)for(var i,l=0;i=o[l];l++)if(!n(a.allow,i.name))return"string"==typeof a.notallowed?alert(a.notallowed):a.notallowed(i,a),void 0;var s=a.complete;if(a.single){var d=o.length,f=0,p=!0;a.beforeAll(o),a.complete=function(e,t){f+=1,s(e,t),a.filelimit&&f>=a.filelimit&&(p=!1),p&&d>f?r([o[f]],a):a.allcomplete(e,t)},r([o[0]],a)}else a.complete=function(e,t){s(e,t),a.allcomplete(e,t)},r(o,a)}}function n(e,t){var n="^"+e.replace(/\//g,"\\/").replace(/\*\*/g,"(\\/[^\\/]+)*").replace(/\*/g,"[^\\/]+").replace(/((?!\\))\?/g,"$1.")+"$";return n="^"+n+"$",null!==t.match(new RegExp(n,"i"))}return e.component("uploadSelect",{init:function(){var e=this;this.on("change",function(){t(e.element[0].files,e.options);var n=e.element.clone(!0).data("uploadSelect",e);e.element.replaceWith(n),e.element=n})}}),e.component("uploadDrop",{defaults:{dragoverClass:"uk-dragover"},init:function(){var e=this,n=!1;this.on("drop",function(n){n.originalEvent.dataTransfer&&n.originalEvent.dataTransfer.files&&(n.stopPropagation(),n.preventDefault(),e.element.removeClass(e.options.dragoverClass),e.element.trigger("dropped.uk.upload",[n.originalEvent.dataTransfer.files]),t(n.originalEvent.dataTransfer.files,e.options))}).on("dragenter",function(e){e.stopPropagation(),e.preventDefault()}).on("dragover",function(t){t.stopPropagation(),t.preventDefault(),n||(e.element.addClass(e.options.dragoverClass),n=!0)}).on("dragleave",function(t){t.stopPropagation(),t.preventDefault(),e.element.removeClass(e.options.dragoverClass),n=!1})}}),e.support.ajaxupload=function(){function e(){var e=document.createElement("INPUT");return e.type="file","files"in e}function t(){var e=new XMLHttpRequest;return!!(e&&"upload"in e&&"onprogress"in e.upload)}function n(){return!!window.FormData}return e()&&t()&&n()}(),t.defaults={action:"",single:!0,method:"POST",param:"files[]",params:{},allow:"*.*",type:"text",filelimit:!1,headers:{},before:function(){},beforeSend:function(){},beforeAll:function(){},loadstart:function(){},load:function(){},loadend:function(){},error:function(){},abort:function(){},progress:function(){},complete:function(){},allcomplete:function(){},readystatechange:function(){},notallowed:function(e,t){alert("Only the following file types are allowed: "+t.allow)}},e.Utils.xhrupload=t,t}); \ No newline at end of file diff --git a/lib/api/uikit/src/js/core/alert.min.js b/lib/api/uikit/src/js/core/alert.min.js index e33d27ff..165c3d8b 100755 --- a/lib/api/uikit/src/js/core/alert.min.js +++ b/lib/api/uikit/src/js/core/alert.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){"use strict";t.component("alert",{defaults:{fade:!0,duration:200,trigger:".uk-alert-close"},boot:function(){t.$html.on("click.alert.uikit","[data-uk-alert]",function(i){var o=t.$(this);if(!o.data("alert")){var e=t.alert(o,t.Utils.options(o.attr("data-uk-alert")));t.$(i.target).is(e.options.trigger)&&(i.preventDefault(),e.close())}})},init:function(){var t=this;this.on("click",this.options.trigger,function(i){i.preventDefault(),t.close()})},close:function(){var t=this.trigger("close.uk.alert"),i=function(){this.trigger("closed.uk.alert").remove()}.bind(this);this.options.fade?t.css("overflow","hidden").css("max-height",t.height()).animate({height:0,opacity:0,"padding-top":0,"padding-bottom":0,"margin-top":0,"margin-bottom":0},this.options.duration,i):i()}})}(UIkit); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";t.component("alert",{defaults:{fade:!0,duration:200,trigger:".uk-alert-close"},boot:function(){t.$html.on("click.alert.uikit","[data-uk-alert]",function(i){var o=t.$(this);if(!o.data("alert")){var e=t.alert(o,t.Utils.options(o.attr("data-uk-alert")));t.$(i.target).is(e.options.trigger)&&(i.preventDefault(),e.close())}})},init:function(){var t=this;this.on("click",this.options.trigger,function(i){i.preventDefault(),t.close()})},close:function(){var t=this.trigger("close.uk.alert"),i=function(){this.trigger("closed.uk.alert").remove()}.bind(this);this.options.fade?t.css("overflow","hidden").css("max-height",t.height()).animate({height:0,opacity:0,paddingTop:0,paddingBottom:0,marginTop:0,marginBottom:0},this.options.duration,i):i()}})}(UIkit2); \ No newline at end of file diff --git a/lib/api/uikit/src/js/core/button.min.js b/lib/api/uikit/src/js/core/button.min.js index c1bd2e09..28e6b514 100755 --- a/lib/api/uikit/src/js/core/button.min.js +++ b/lib/api/uikit/src/js/core/button.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){"use strict";t.component("buttonRadio",{defaults:{activeClass:"uk-active",target:".uk-button"},boot:function(){t.$html.on("click.buttonradio.uikit","[data-uk-button-radio]",function(i){var a=t.$(this);if(!a.data("buttonRadio")){var e=t.buttonRadio(a,t.Utils.options(a.attr("data-uk-button-radio"))),o=t.$(i.target);o.is(e.options.target)&&o.trigger("click")}})},init:function(){var i=this;this.find(i.options.target).attr("aria-checked","false").filter("."+i.options.activeClass).attr("aria-checked","true"),this.on("click",this.options.target,function(a){var e=t.$(this);e.is('a[href="#"]')&&a.preventDefault(),i.find(i.options.target).not(e).removeClass(i.options.activeClass).blur(),e.addClass(i.options.activeClass),i.find(i.options.target).not(e).attr("aria-checked","false"),e.attr("aria-checked","true"),i.trigger("change.uk.button",[e])})},getSelected:function(){return this.find("."+this.options.activeClass)}}),t.component("buttonCheckbox",{defaults:{activeClass:"uk-active",target:".uk-button"},boot:function(){t.$html.on("click.buttoncheckbox.uikit","[data-uk-button-checkbox]",function(i){var a=t.$(this);if(!a.data("buttonCheckbox")){var e=t.buttonCheckbox(a,t.Utils.options(a.attr("data-uk-button-checkbox"))),o=t.$(i.target);o.is(e.options.target)&&o.trigger("click")}})},init:function(){var i=this;this.find(i.options.target).attr("aria-checked","false").filter("."+i.options.activeClass).attr("aria-checked","true"),this.on("click",this.options.target,function(a){var e=t.$(this);e.is('a[href="#"]')&&a.preventDefault(),e.toggleClass(i.options.activeClass).blur(),e.attr("aria-checked",e.hasClass(i.options.activeClass)),i.trigger("change.uk.button",[e])})},getSelected:function(){return this.find("."+this.options.activeClass)}}),t.component("button",{defaults:{},boot:function(){t.$html.on("click.button.uikit","[data-uk-button]",function(){var i=t.$(this);if(!i.data("button")){{t.button(i,t.Utils.options(i.attr("data-uk-button")))}i.trigger("click")}})},init:function(){var t=this;this.element.attr("aria-pressed",this.element.hasClass("uk-active")),this.on("click",function(i){t.element.is('a[href="#"]')&&i.preventDefault(),t.toggle(),t.trigger("change.uk.button",[t.element.blur().hasClass("uk-active")])})},toggle:function(){this.element.toggleClass("uk-active"),this.element.attr("aria-pressed",this.element.hasClass("uk-active"))}})}(UIkit); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";t.component("buttonRadio",{defaults:{activeClass:"uk-active",target:".uk-button"},boot:function(){t.$html.on("click.buttonradio.uikit","[data-uk-button-radio]",function(i){var a=t.$(this);if(!a.data("buttonRadio")){var e=t.buttonRadio(a,t.Utils.options(a.attr("data-uk-button-radio"))),o=t.$(i.target);o.is(e.options.target)&&o.trigger("click")}})},init:function(){var i=this;this.find(i.options.target).attr("aria-checked","false").filter("."+i.options.activeClass).attr("aria-checked","true"),this.on("click",this.options.target,function(a){var e=t.$(this);e.is('a[href="#"]')&&a.preventDefault(),i.find(i.options.target).not(e).removeClass(i.options.activeClass).blur(),e.addClass(i.options.activeClass),i.find(i.options.target).not(e).attr("aria-checked","false"),e.attr("aria-checked","true"),i.trigger("change.uk.button",[e])})},getSelected:function(){return this.find("."+this.options.activeClass)}}),t.component("buttonCheckbox",{defaults:{activeClass:"uk-active",target:".uk-button"},boot:function(){t.$html.on("click.buttoncheckbox.uikit","[data-uk-button-checkbox]",function(i){var a=t.$(this);if(!a.data("buttonCheckbox")){var e=t.buttonCheckbox(a,t.Utils.options(a.attr("data-uk-button-checkbox"))),o=t.$(i.target);o.is(e.options.target)&&o.trigger("click")}})},init:function(){var i=this;this.find(i.options.target).attr("aria-checked","false").filter("."+i.options.activeClass).attr("aria-checked","true"),this.on("click",this.options.target,function(a){var e=t.$(this);e.is('a[href="#"]')&&a.preventDefault(),e.toggleClass(i.options.activeClass).blur(),e.attr("aria-checked",e.hasClass(i.options.activeClass)),i.trigger("change.uk.button",[e])})},getSelected:function(){return this.find("."+this.options.activeClass)}}),t.component("button",{defaults:{},boot:function(){t.$html.on("click.button.uikit","[data-uk-button]",function(){var i=t.$(this);if(!i.data("button")){{t.button(i,t.Utils.options(i.attr("data-uk-button")))}i.trigger("click")}})},init:function(){var t=this;this.element.attr("aria-pressed",this.element.hasClass("uk-active")),this.on("click",function(i){t.element.is('a[href="#"]')&&i.preventDefault(),t.toggle(),t.trigger("change.uk.button",[t.element.blur().hasClass("uk-active")])})},toggle:function(){this.element.toggleClass("uk-active"),this.element.attr("aria-pressed",this.element.hasClass("uk-active"))}})}(UIkit2); \ No newline at end of file diff --git a/lib/api/uikit/src/js/core/core.min.js b/lib/api/uikit/src/js/core/core.min.js index 04735e65..0419371a 100755 --- a/lib/api/uikit/src/js/core/core.min.js +++ b/lib/api/uikit/src/js/core/core.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){if("function"==typeof define&&define.amd&&define("uikit",function(){var n=window.UIkit||t(window,window.jQuery,window.document);return n.load=function(t,e,o,i){var r,a=t.split(","),s=[],u=(i.config&&i.config.uikit&&i.config.uikit.base?i.config.uikit.base:"").replace(/\/+$/g,"");if(!u)throw new Error("Please define base path to UIkit in the requirejs config.");for(r=0;r0||t.navigator.pointerEnabled&&t.navigator.maxTouchPoints>0||!1,o.support.mutationobserver=t.MutationObserver||t.WebKitMutationObserver||null,o.Utils={},o.Utils.isFullscreen=function(){return document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.fullscreenElement||!1},o.Utils.str2json=function(t,n){try{return n?JSON.parse(t.replace(/([\$\w]+)\s*:/g,function(t,n){return'"'+n+'":'}).replace(/'([^']+)'/g,function(t,n){return'"'+n+'"'})):new Function("","var json = "+t+"; return JSON.parse(JSON.stringify(json));")()}catch(e){return!1}},o.Utils.debounce=function(t,n,e){var o;return function(){var i=this,r=arguments,a=function(){o=null,e||t.apply(i,r)},s=e&&!o;clearTimeout(o),o=setTimeout(a,n),s&&t.apply(i,r)}},o.Utils.throttle=function(t,n){var e=!1;return function(){e||(t.call(),e=!0,setTimeout(function(){e=!1},n))}},o.Utils.removeCssRules=function(t){var n,e,o,i,r,a,s,u,c,d;t&&setTimeout(function(){try{for(d=document.styleSheets,i=0,s=d.length;s>i;i++){for(o=d[i],e=[],o.cssRules=o.cssRules,n=r=0,u=o.cssRules.length;u>r;n=++r)o.cssRules[n].type===CSSRule.STYLE_RULE&&t.test(o.cssRules[n].selectorText)&&e.unshift(n);for(a=0,c=e.length;c>a;a++)o.deleteRule(e[a])}}catch(l){}},0)},o.Utils.isInView=function(t,e){var i=n(t);if(!i.is(":visible"))return!1;var r=o.$win.scrollLeft(),a=o.$win.scrollTop(),s=i.offset(),u=s.left,c=s.top;return e=n.extend({topoffset:0,leftoffset:0},e),c+i.height()>=a&&c-e.topoffset<=a+o.$win.height()&&u+i.width()>=r&&u-e.leftoffset<=r+o.$win.width()?!0:!1},o.Utils.checkDisplay=function(t,e){var i=o.$("[data-uk-margin], [data-uk-grid-match], [data-uk-grid-margin], [data-uk-check-display]",t||document);return t&&!i.length&&(i=n(t)),i.trigger("display.uk.check"),e&&("string"!=typeof e&&(e='[class*="uk-animation-"]'),i.find(e).each(function(){var t=o.$(this),n=t.attr("class"),e=n.match(/uk-animation-(.+)/);t.removeClass(e[0]).width(),t.addClass(e[0])})),i},o.Utils.options=function(t){if("string"!=n.type(t))return t;-1!=t.indexOf(":")&&"}"!=t.trim().substr(-1)&&(t="{"+t+"}");var e=t?t.indexOf("{"):-1,i={};if(-1!=e)try{i=o.Utils.str2json(t.substr(e))}catch(r){}return i},o.Utils.animate=function(t,e){var i=n.Deferred();return t=o.$(t),t.css("display","none").addClass(e).one(o.support.animation.end,function(){t.removeClass(e),i.resolve()}),t.css("display",""),i.promise()},o.Utils.uid=function(t){return(t||"id")+(new Date).getTime()+"RAND"+Math.ceil(1e5*Math.random())},o.Utils.template=function(t,n){for(var e,o,i,r,a=t.replace(/\n/g,"\\n").replace(/\{\{\{\s*(.+?)\s*\}\}\}/g,"{{!$1}}").split(/(\{\{\s*(.+?)\s*\}\})/g),s=0,u=[],c=0;s/g, '>');}"].join("\n")),n?r(n):r},o.Utils.focus=function(t,e){t=n(t);var o,i=t.find("[autofocus]:first");return i.length?i.focus():(i=t.find(":input"+(e&&","+e||"")).first(),i.length?i.focus():(t.attr("tabindex")||(o=1e3,t.attr("tabindex",o)),t[0].focus(),o&&t.attr("tabindex",""),t))},o.Utils.events={},o.Utils.events.click=o.support.touch?"tap":"click",t.UIkit=o,o.fn=function(t,e){var i=arguments,r=t.match(/^([a-z\-]+)(?:\.([a-z]+))?/i),a=r[1],s=r[2];return o[a]?this.each(function(){var t=n(this),r=t.data(a);r||t.data(a,r=o[a](this,s?void 0:e)),s&&r[s].apply(r,Array.prototype.slice.call(i,1))}):(n.error("UIkit component ["+a+"] does not exist."),this)},n.UIkit=o,n.fn.uk=o.fn,o.langdirection="rtl"==o.$html.attr("dir")?"right":"left",o.components={},o.component=function(t,e){var i=function(e,r){var a=this;return this.UIkit=o,this.element=e?o.$(e):null,this.options=n.extend(!0,{},this.defaults,r),this.plugins={},this.element&&this.element.data(t,this),this.init(),(this.options.plugins.length?this.options.plugins:Object.keys(i.plugins)).forEach(function(t){i.plugins[t].init&&(i.plugins[t].init(a),a.plugins[t]=!0)}),this.trigger("init.uk.component",[t,this]),this};return i.plugins={},n.extend(!0,i.prototype,{defaults:{plugins:[]},boot:function(){},init:function(){},on:function(t,n,e){return o.$(this.element||this).on(t,n,e)},one:function(t,n,e){return o.$(this.element||this).one(t,n,e)},off:function(t){return o.$(this.element||this).off(t)},trigger:function(t,n){return o.$(this.element||this).trigger(t,n)},find:function(t){return o.$(this.element?this.element:[]).find(t)},proxy:function(t,n){var e=this;n.split(" ").forEach(function(n){e[n]||(e[n]=function(){return t[n].apply(t,arguments)})})},mixin:function(t,n){var e=this;n.split(" ").forEach(function(n){e[n]||(e[n]=t[n].bind(e))})},option:function(){return 1==arguments.length?this.options[arguments[0]]||void 0:(2==arguments.length&&(this.options[arguments[0]]=arguments[1]),void 0)}},e),this.components[t]=i,this[t]=function(){var e,i;if(arguments.length)switch(arguments.length){case 1:"string"==typeof arguments[0]||arguments[0].nodeType||arguments[0]instanceof jQuery?e=n(arguments[0]):i=arguments[0];break;case 2:e=n(arguments[0]),i=arguments[1]}return e&&e.data(t)?e.data(t):new o.components[t](e,i)},o.domready&&o.component.boot(t),i},o.plugin=function(t,n,e){this.components[t].plugins[n]=e},o.component.boot=function(t){o.components[t].prototype&&o.components[t].prototype.boot&&!o.components[t].booted&&(o.components[t].prototype.boot.apply(o,[]),o.components[t].booted=!0)},o.component.bootComponents=function(){for(var t in o.components)o.component.boot(t)},o.domObservers=[],o.domready=!1,o.ready=function(t){o.domObservers.push(t),o.domready&&t(document)},o.on=function(t,n,e){return t&&t.indexOf("ready.uk.dom")>-1&&o.domready&&n.apply(o.$doc),o.$doc.on(t,n,e)},o.one=function(t,n,e){return t&&t.indexOf("ready.uk.dom")>-1&&o.domready?(n.apply(o.$doc),o.$doc):o.$doc.one(t,n,e)},o.trigger=function(t,n){return o.$doc.trigger(t,n)},o.domObserve=function(t,n){o.support.mutationobserver&&(n=n||function(){},o.$(t).each(function(){var t=this,e=o.$(t);if(!e.data("observer"))try{var i=new o.support.mutationobserver(o.Utils.debounce(function(){n.apply(t,[e]),e.trigger("changed.uk.dom")},50),{childList:!0,subtree:!0});i.observe(t,{childList:!0,subtree:!0}),e.data("observer",i)}catch(r){}}))},o.init=function(t){t=t||document,o.domObservers.forEach(function(n){n(t)})},o.on("domready.uk.dom",function(){o.init(),o.domready&&o.Utils.checkDisplay()}),document.addEventListener("DOMContentLoaded",function(){var t=function(){o.$body=o.$("body"),o.trigger("beforeready.uk.dom"),o.component.bootComponents();var t=requestAnimationFrame(function(){var n={dir:{x:0,y:0},x:window.pageXOffset,y:window.pageYOffset},e=function(){var i=window.pageXOffset,r=window.pageYOffset;(n.x!=i||n.y!=r)&&(n.dir.x=i!=n.x?i>n.x?1:-1:0,n.dir.y=r!=n.y?r>n.y?1:-1:0,n.x=i,n.y=r,o.$doc.trigger("scrolling.uk.document",[{dir:{x:n.dir.x,y:n.dir.y},x:i,y:r}])),cancelAnimationFrame(t),t=requestAnimationFrame(e)};return o.support.touch&&o.$html.on("touchmove touchend MSPointerMove MSPointerUp pointermove pointerup",e),(n.x||n.y)&&e(),e}());if(o.trigger("domready.uk.dom"),o.support.touch&&navigator.userAgent.match(/(iPad|iPhone|iPod)/g)&&o.$win.on("load orientationchange resize",o.Utils.debounce(function(){var t=function(){return n(".uk-height-viewport").css("height",window.innerHeight),t};return t()}(),100)),o.trigger("afterready.uk.dom"),o.domready=!0,o.support.mutationobserver){var e=o.Utils.debounce(function(){requestAnimationFrame(function(){o.init(document.body)})},10);new o.support.mutationobserver(function(t){var n=!1;t.every(function(t){if("childList"!=t.type)return!0;for(var e,o=0;o0||window.navigator.pointerEnabled&&window.navigator.maxTouchPoints>0||!1,n.support.mutationobserver=window.MutationObserver||window.WebKitMutationObserver||null,n.Utils={},n.Utils.isFullscreen=function(){return document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.fullscreenElement||!1},n.Utils.str2json=function(t,n){try{return n?JSON.parse(t.replace(/([\$\w]+)\s*:/g,function(t,n){return'"'+n+'":'}).replace(/'([^']+)'/g,function(t,n){return'"'+n+'"'})):new Function("","var json = "+t+"; return JSON.parse(JSON.stringify(json));")()}catch(e){return!1}},n.Utils.debounce=function(t,n,e){var o;return function(){var i=this,r=arguments,a=function(){o=null,e||t.apply(i,r)},s=e&&!o;clearTimeout(o),o=setTimeout(a,n),s&&t.apply(i,r)}},n.Utils.throttle=function(t,n){var e=!1;return function(){e||(t.call(),e=!0,setTimeout(function(){e=!1},n))}},n.Utils.removeCssRules=function(t){var n,e,o,i,r,a,s,u,c,d;t&&setTimeout(function(){try{for(d=document.styleSheets,i=0,s=d.length;s>i;i++){for(o=d[i],e=[],o.cssRules=o.cssRules,n=r=0,u=o.cssRules.length;u>r;n=++r)o.cssRules[n].type===CSSRule.STYLE_RULE&&t.test(o.cssRules[n].selectorText)&&e.unshift(n);for(a=0,c=e.length;c>a;a++)o.deleteRule(e[a])}}catch(l){}},0)},n.Utils.isInView=function(e,o){var i=t(e);if(!i.is(":visible"))return!1;var r=n.$win.scrollLeft(),a=n.$win.scrollTop(),s=i.offset(),u=s.left,c=s.top;return o=t.extend({topoffset:0,leftoffset:0},o),c+i.height()>=a&&c-o.topoffset<=a+n.$win.height()&&u+i.width()>=r&&u-o.leftoffset<=r+n.$win.width()?!0:!1},n.Utils.checkDisplay=function(e,o){var i=n.$("[data-uk-margin], [data-uk-grid-match], [data-uk-grid-margin], [data-uk-check-display]",e||document);return e&&!i.length&&(i=t(e)),i.trigger("display.uk.check"),o&&("string"!=typeof o&&(o='[class*="uk-animation-"]'),i.find(o).each(function(){var t=n.$(this),e=t.attr("class"),o=e.match(/uk-animation-(.+)/);t.removeClass(o[0]).width(),t.addClass(o[0])})),i},n.Utils.options=function(e){if("string"!=t.type(e))return e;-1!=e.indexOf(":")&&"}"!=e.trim().substr(-1)&&(e="{"+e+"}");var o=e?e.indexOf("{"):-1,i={};if(-1!=o)try{i=n.Utils.str2json(e.substr(o))}catch(r){}return i},n.Utils.animate=function(e,o){var i=t.Deferred();return e=n.$(e),e.css("display","none").addClass(o).one(n.support.animation.end,function(){e.removeClass(o),i.resolve()}),e.css("display",""),i.promise()},n.Utils.uid=function(t){return(t||"id")+(new Date).getTime()+"RAND"+Math.ceil(1e5*Math.random())},n.Utils.template=function(t,n){for(var e,o,i,r,a=t.replace(/\n/g,"\\n").replace(/\{\{\{\s*(.+?)\s*\}\}\}/g,"{{!$1}}").split(/(\{\{\s*(.+?)\s*\}\})/g),s=0,u=[],c=0;s/g, '>');}"].join("\n")),n?r(n):r},n.Utils.focus=function(n,e){if(n=t(n),!n.length)return n;var o,i=n.find("[autofocus]:first");return i.length?i.focus():(i=n.find(":input"+(e&&","+e||"")).first(),i.length?i.focus():(n.attr("tabindex")||(o=1e3,n.attr("tabindex",o)),n[0].focus(),o&&n.attr("tabindex",""),n))},n.Utils.events={},n.Utils.events.click=n.support.touch?"tap":"click",n.fn=function(e,o){var i=arguments,r=e.match(/^([a-z\-]+)(?:\.([a-z]+))?/i),a=r[1],s=r[2];return n[a]?this.each(function(){var e=t(this),r=e.data(a);r||e.data(a,r=n[a](this,s?void 0:o)),s&&r[s].apply(r,Array.prototype.slice.call(i,1))}):(t.error("UIkit component ["+a+"] does not exist."),this)},t.UIkit=n,t.fn.uk=n.fn,n.langdirection="rtl"==n.$html.attr("dir")?"right":"left",n.components={},n.component=function(e,o,i){if(n.components[e]&&!i)return n.components[e];var r=function(o,i){var a=this;return this.UIkit=n,this.element=o?n.$(o):null,this.options=t.extend(!0,{},this.defaults,i),this.plugins={},this.element&&this.element.data(e,this),this.init(),(this.options.plugins.length?this.options.plugins:Object.keys(r.plugins)).forEach(function(t){r.plugins[t].init&&(r.plugins[t].init(a),a.plugins[t]=!0)}),this.trigger("init.uk.component",[e,this]),this};return r.plugins={},t.extend(!0,r.prototype,{defaults:{plugins:[]},boot:function(){},init:function(){},on:function(t,e,o){return n.$(this.element||this).on(t,e,o)},one:function(t,e,o){return n.$(this.element||this).one(t,e,o)},off:function(t){return n.$(this.element||this).off(t)},trigger:function(t,e){return n.$(this.element||this).trigger(t,e)},find:function(t){return n.$(this.element?this.element:[]).find(t)},proxy:function(t,n){var e=this;n.split(" ").forEach(function(n){e[n]||(e[n]=function(){return t[n].apply(t,arguments)})})},mixin:function(t,n){var e=this;n.split(" ").forEach(function(n){e[n]||(e[n]=t[n].bind(e))})},option:function(){return 1==arguments.length?this.options[arguments[0]]||void 0:(2==arguments.length&&(this.options[arguments[0]]=arguments[1]),void 0)}},o),this.components[e]=r,this[e]=function(){var o,i;if(arguments.length)switch(arguments.length){case 1:"string"==typeof arguments[0]||arguments[0].nodeType||arguments[0]instanceof jQuery?o=t(arguments[0]):i=arguments[0];break;case 2:o=t(arguments[0]),i=arguments[1]}return o&&o.data(e)?o.data(e):new n.components[e](o,i)},n.domready&&n.component.boot(e),r},n.plugin=function(t,n,e){this.components[t].plugins[n]=e},n.component.boot=function(t){n.components[t].prototype&&n.components[t].prototype.boot&&!n.components[t].booted&&(n.components[t].prototype.boot.apply(n,[]),n.components[t].booted=!0)},n.component.bootComponents=function(){for(var t in n.components)n.component.boot(t)},n.domObservers=[],n.domready=!1,n.ready=function(t){n.domObservers.push(t),n.domready&&t(document)},n.on=function(t,e,o){return t&&t.indexOf("ready.uk.dom")>-1&&n.domready&&e.apply(n.$doc),n.$doc.on(t,e,o)},n.one=function(t,e,o){return t&&t.indexOf("ready.uk.dom")>-1&&n.domready?(e.apply(n.$doc),n.$doc):n.$doc.one(t,e,o)},n.trigger=function(t,e){return n.$doc.trigger(t,e)},n.domObserve=function(t,e){n.support.mutationobserver&&(e=e||function(){},n.$(t).each(function(){var t=this,o=n.$(t);if(!o.data("observer"))try{var i=new n.support.mutationobserver(n.Utils.debounce(function(){e.apply(t,[o]),o.trigger("changed.uk.dom")},50),{childList:!0,subtree:!0});i.observe(t,{childList:!0,subtree:!0}),o.data("observer",i)}catch(r){}}))},n.init=function(t){t=t||document,n.domObservers.forEach(function(n){n(t)})},n.on("domready.uk.dom",function(){n.init(),n.domready&&n.Utils.checkDisplay()}),document.addEventListener("DOMContentLoaded",function(){var e=function(){n.$body=n.$("body"),n.trigger("beforeready.uk.dom"),n.component.bootComponents();var e=requestAnimationFrame(function(){var t={dir:{x:0,y:0},x:window.pageXOffset,y:window.pageYOffset},o=function(){var i=window.pageXOffset,r=window.pageYOffset;(t.x!=i||t.y!=r)&&(t.dir.x=i!=t.x?i>t.x?1:-1:0,t.dir.y=r!=t.y?r>t.y?1:-1:0,t.x=i,t.y=r,n.$doc.trigger("scrolling.uk.document",[{dir:{x:t.dir.x,y:t.dir.y},x:i,y:r}])),cancelAnimationFrame(e),e=requestAnimationFrame(o)};return n.support.touch&&n.$html.on("touchmove touchend MSPointerMove MSPointerUp pointermove pointerup",o),(t.x||t.y)&&o(),o}());if(n.trigger("domready.uk.dom"),n.support.touch&&navigator.userAgent.match(/(iPad|iPhone|iPod)/g)&&n.$win.on("load orientationchange resize",n.Utils.debounce(function(){var n=function(){return t(".uk-height-viewport").css("height",window.innerHeight),n};return n()}(),100)),n.trigger("afterready.uk.dom"),n.domready=!0,n.support.mutationobserver){var o=n.Utils.debounce(function(){requestAnimationFrame(function(){n.init(document.body)})},10);new n.support.mutationobserver(function(t){var n=!1;t.every(function(t){if("childList"!=t.type)return!0;for(var e,o=0;o-1?"&":"?","enablejsapi=1&api=1"].join(""))}},check:function(){this.element.css({width:"",height:""}),this.dimension={w:this.element.width(),h:this.element.height()},this.element.attr("width")&&!isNaN(this.element.attr("width"))&&(this.dimension.w=this.element.attr("width")),this.element.attr("height")&&!isNaN(this.element.attr("height"))&&(this.dimension.h=this.element.attr("height")),this.ratio=this.dimension.w/this.dimension.h;var t,i,e=this.parent.width(),n=this.parent.height();e/this.ratio-1?"&":"?","enablejsapi=1&api=1"].join(""))}},check:function(){this.element.css({width:"",height:""}),this.dimension={w:this.element.width(),h:this.element.height()},this.element.attr("width")&&!isNaN(this.element.attr("width"))&&(this.dimension.w=this.element.attr("width")),this.element.attr("height")&&!isNaN(this.element.attr("height"))&&(this.dimension.h=this.element.attr("height")),this.ratio=this.dimension.w/this.dimension.h;var t,i,e=this.parent.width(),n=this.parent.height();e/this.ratiol&&(s.addClass("uk-dropdown-stack"),this.trigger("stack.uk.dropdown",[this])),s.css(f).css("display","").addClass("uk-dropdown-"+e[0])}},checkBoundary:function(o,e,i,n,r){var s="";return(0>o||o-t.$win.scrollLeft()+i>r)&&(s+="x"),(e-t.$win.scrollTop()<0||e-t.$win.scrollTop()+n>window.innerHeight)&&(s+="y"),s}}),t.component("dropdownOverlay",{defaults:{justify:!1,cls:"",duration:200},boot:function(){t.ready(function(o){t.$("[data-uk-dropdown-overlay]",o).each(function(){var o=t.$(this);o.data("dropdownOverlay")||t.dropdownOverlay(o,t.Utils.options(o.attr("data-uk-dropdown-overlay")))})})},init:function(){var e=this;this.justified=this.options.justify?t.$(this.options.justify):!1,this.overlay=this.element.find("uk-dropdown-overlay"),this.overlay.length||(this.overlay=t.$('
          ').appendTo(this.element)),this.overlay.addClass(this.options.cls),this.on({"beforeshow.uk.dropdown":function(t,i){e.dropdown=i,e.justified&&e.justified.length&&o(e.overlay.css({display:"block","margin-left":"","margin-right":""}),e.justified,e.justified.outerWidth())},"show.uk.dropdown":function(){var o=e.dropdown.dropdown.outerHeight(!0);e.dropdown.element.removeClass("uk-open"),e.overlay.stop().css("display","block").animate({height:o},e.options.duration,function(){e.dropdown.dropdown.css("visibility",""),e.dropdown.element.addClass("uk-open"),t.Utils.checkDisplay(e.dropdown.dropdown,!0)}),e.pointerleave=!1},"hide.uk.dropdown":function(){e.overlay.stop().animate({height:0},e.options.duration)},"pointerenter.uk.dropdown":function(){clearTimeout(e.remainIdle)},"pointerleave.uk.dropdown":function(){e.pointerleave=!0}}),this.overlay.on({mouseenter:function(){e.remainIdle&&(clearTimeout(e.dropdown.remainIdle),clearTimeout(e.remainIdle))},mouseleave:function(){e.pointerleave&&i&&(e.remainIdle=setTimeout(function(){i&&i.hide()},i.options.remaintime))}})}})}(UIkit); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";function o(o,e,i,n){if(o=t.$(o),e=t.$(e),i=i||window.innerWidth,n=n||o.offset(),e.length){var r=e.outerWidth();if(o.css("min-width",r),"right"==t.langdirection){var s=i-(e.offset().left+r),d=i-(o.offset().left+o.outerWidth());o.css("margin-right",s-d)}else o.css("margin-left",e.offset().left-n.left)}}var e,i=!1,n={x:{"bottom-left":"bottom-right","bottom-right":"bottom-left","bottom-center":"bottom-center","top-left":"top-right","top-right":"top-left","top-center":"top-center","left-top":"right-top","left-bottom":"right-bottom","left-center":"right-center","right-top":"left-top","right-bottom":"left-bottom","right-center":"left-center"},y:{"bottom-left":"top-left","bottom-right":"top-right","bottom-center":"top-center","top-left":"bottom-left","top-right":"bottom-right","top-center":"bottom-center","left-top":"left-bottom","left-bottom":"left-top","left-center":"left-center","right-top":"right-bottom","right-bottom":"right-top","right-center":"right-center"},xy:{"bottom-left":"top-right","bottom-right":"top-left","bottom-center":"top-center","top-left":"bottom-right","top-right":"bottom-left","top-center":"bottom-center","left-top":"right-bottom","left-bottom":"right-top","left-center":"right-center","right-top":"left-bottom","right-bottom":"left-top","right-center":"left-center"}};t.component("dropdown",{defaults:{mode:"hover",pos:"bottom-left",offset:0,remaintime:800,justify:!1,boundary:t.$win,delay:0,dropdownSelector:".uk-dropdown,.uk-dropdown-blank",hoverDelayIdle:250,preventflip:!1},remainIdle:!1,boot:function(){var o=t.support.touch?"click":"mouseenter";t.$html.on(o+".dropdown.uikit focus pointerdown","[data-uk-dropdown]",function(e){var i=t.$(this);if(!i.data("dropdown")){var n=t.dropdown(i,t.Utils.options(i.attr("data-uk-dropdown")));("click"==e.type||"mouseenter"==e.type&&"hover"==n.options.mode)&&n.element.trigger(o),n.dropdown.length&&e.preventDefault()}})},init:function(){var o=this;this.dropdown=this.find(this.options.dropdownSelector),this.offsetParent=this.dropdown.parents().filter(function(){return-1!==t.$.inArray(t.$(this).css("position"),["relative","fixed","absolute"])}).slice(0,1),this.offsetParent.length||(this.offsetParent=this.element),this.centered=this.dropdown.hasClass("uk-dropdown-center"),this.justified=this.options.justify?t.$(this.options.justify):!1,this.boundary=t.$(this.options.boundary),this.boundary.length||(this.boundary=t.$win),this.dropdown.hasClass("uk-dropdown-up")&&(this.options.pos="top-left"),this.dropdown.hasClass("uk-dropdown-flip")&&(this.options.pos=this.options.pos.replace("left","right")),this.dropdown.hasClass("uk-dropdown-center")&&(this.options.pos=this.options.pos.replace(/(left|right)/,"center")),this.element.attr("aria-haspopup","true"),this.element.attr("aria-expanded",this.element.hasClass("uk-open")),this.dropdown.attr("aria-hidden","true"),"click"==this.options.mode||t.support.touch?this.on("click.uk.dropdown",function(e){var i=t.$(e.target);i.parents(o.options.dropdownSelector).length||((i.is("a[href='#']")||i.parent().is("a[href='#']")||o.dropdown.length&&!o.dropdown.is(":visible"))&&e.preventDefault(),i.blur()),o.element.hasClass("uk-open")?(!o.dropdown.find(e.target).length||i.is(".uk-dropdown-close")||i.parents(".uk-dropdown-close").length)&&o.hide():o.show()}):this.on("mouseenter",function(){o.trigger("pointerenter.uk.dropdown",[o]),o.remainIdle&&clearTimeout(o.remainIdle),e&&clearTimeout(e),i&&i==o||(e=i&&i!=o?setTimeout(function(){e=setTimeout(o.show.bind(o),o.options.delay)},o.options.hoverDelayIdle):setTimeout(o.show.bind(o),o.options.delay))}).on("mouseleave",function(){e&&clearTimeout(e),o.remainIdle=setTimeout(function(){i&&i==o&&o.hide()},o.options.remaintime),o.trigger("pointerleave.uk.dropdown",[o])}).on("click",function(e){var n=t.$(e.target);return o.remainIdle&&clearTimeout(o.remainIdle),i&&i==o?((!o.dropdown.find(e.target).length||n.is(".uk-dropdown-close")||n.parents(".uk-dropdown-close").length)&&o.hide(),void 0):((n.is("a[href='#']")||n.parent().is("a[href='#']"))&&e.preventDefault(),o.show(),void 0)})},show:function(){t.$html.off("click.outer.dropdown"),i&&i!=this&&i.hide(!0),e&&clearTimeout(e),this.trigger("beforeshow.uk.dropdown",[this]),this.checkDimensions(),this.element.addClass("uk-open"),this.element.attr("aria-expanded","true"),this.dropdown.attr("aria-hidden","false"),this.trigger("show.uk.dropdown",[this]),t.Utils.checkDisplay(this.dropdown,!0),t.Utils.focus(this.dropdown),i=this,this.registerOuterClick()},hide:function(t){this.trigger("beforehide.uk.dropdown",[this,t]),this.element.removeClass("uk-open"),this.remainIdle&&clearTimeout(this.remainIdle),this.remainIdle=!1,this.element.attr("aria-expanded","false"),this.dropdown.attr("aria-hidden","true"),this.trigger("hide.uk.dropdown",[this,t]),i==this&&(i=!1)},registerOuterClick:function(){var o=this;t.$html.off("click.outer.dropdown"),setTimeout(function(){t.$html.on("click.outer.dropdown",function(n){e&&clearTimeout(e);t.$(n.target);i!=o||o.element.find(n.target).length||(o.hide(!0),t.$html.off("click.outer.dropdown"))})},10)},checkDimensions:function(){if(this.dropdown.length){this.dropdown.removeClass("uk-dropdown-top uk-dropdown-bottom uk-dropdown-left uk-dropdown-right uk-dropdown-stack uk-dropdown-autoflip").css({topLeft:"",left:"",marginLeft:"",marginRight:""}),this.justified&&this.justified.length&&this.dropdown.css("min-width","");var e,i=t.$.extend({},this.offsetParent.offset(),{width:this.offsetParent[0].offsetWidth,height:this.offsetParent[0].offsetHeight}),r=this.options.offset,s=this.dropdown,d=(s.show().offset()||{left:0,top:0},s.outerWidth()),h=s.outerHeight(),p=this.boundary.width(),l=(this.boundary[0]!==window&&this.boundary.offset()?this.boundary.offset():{top:0,left:0},this.options.pos),a={"bottom-left":{top:0+i.height+r,left:0},"bottom-right":{top:0+i.height+r,left:0+i.width-d},"bottom-center":{top:0+i.height+r,left:0+i.width/2-d/2},"top-left":{top:0-h-r,left:0},"top-right":{top:0-h-r,left:0+i.width-d},"top-center":{top:0-h-r,left:0+i.width/2-d/2},"left-top":{top:0,left:0-d-r},"left-bottom":{top:0+i.height-h,left:0-d-r},"left-center":{top:0+i.height/2-h/2,left:0-d-r},"right-top":{top:0,left:0+i.width+r},"right-bottom":{top:0+i.height-h,left:0+i.width+r},"right-center":{top:0+i.height/2-h/2,left:0+i.width+r}},f={};if(e=l.split("-"),f=a[l]?a[l]:a["bottom-left"],this.justified&&this.justified.length)o(s.css({left:0}),this.justified,p);else if(this.options.preventflip!==!0){var u;switch(this.checkBoundary(i.left+f.left,i.top+f.top,d,h,p)){case"x":"x"!==this.options.preventflip&&(u=n.x[l]||"right-top");break;case"y":"y"!==this.options.preventflip&&(u=n.y[l]||"top-left");break;case"xy":this.options.preventflip||(u=n.xy[l]||"right-bottom")}u&&(e=u.split("-"),f=a[u]?a[u]:a["bottom-left"],s.addClass("uk-dropdown-autoflip"),this.checkBoundary(i.left+f.left,i.top+f.top,d,h,p)&&(e=l.split("-"),f=a[l]?a[l]:a["bottom-left"]))}d>p&&(s.addClass("uk-dropdown-stack"),this.trigger("stack.uk.dropdown",[this])),s.css(f).css("display","").addClass("uk-dropdown-"+e[0])}},checkBoundary:function(o,e,i,n,r){var s="";return(0>o||o-t.$win.scrollLeft()+i>r)&&(s+="x"),(e-t.$win.scrollTop()<0||e-t.$win.scrollTop()+n>window.innerHeight)&&(s+="y"),s}}),t.component("dropdownOverlay",{defaults:{justify:!1,cls:"",duration:200},boot:function(){t.ready(function(o){t.$("[data-uk-dropdown-overlay]",o).each(function(){var o=t.$(this);o.data("dropdownOverlay")||t.dropdownOverlay(o,t.Utils.options(o.attr("data-uk-dropdown-overlay")))})})},init:function(){var e=this;this.justified=this.options.justify?t.$(this.options.justify):!1,this.overlay=this.element.find("uk-dropdown-overlay"),this.overlay.length||(this.overlay=t.$('
          ').appendTo(this.element)),this.overlay.addClass(this.options.cls),this.on({"beforeshow.uk.dropdown":function(t,i){e.dropdown=i,e.justified&&e.justified.length&&o(e.overlay.css({display:"block",marginLeft:"",marginRight:""}),e.justified,e.justified.outerWidth())},"show.uk.dropdown":function(){var o=e.dropdown.dropdown.outerHeight(!0);e.dropdown.element.removeClass("uk-open"),e.overlay.stop().css("display","block").animate({height:o},e.options.duration,function(){e.dropdown.dropdown.css("visibility",""),e.dropdown.element.addClass("uk-open"),t.Utils.checkDisplay(e.dropdown.dropdown,!0)}),e.pointerleave=!1},"hide.uk.dropdown":function(){e.overlay.stop().animate({height:0},e.options.duration)},"pointerenter.uk.dropdown":function(){clearTimeout(e.remainIdle)},"pointerleave.uk.dropdown":function(){e.pointerleave=!0}}),this.overlay.on({mouseenter:function(){e.remainIdle&&(clearTimeout(e.dropdown.remainIdle),clearTimeout(e.remainIdle))},mouseleave:function(){e.pointerleave&&i&&(e.remainIdle=setTimeout(function(){i&&i.hide()},i.options.remaintime))}})}})}(UIkit2); \ No newline at end of file diff --git a/lib/api/uikit/src/js/core/grid.min.js b/lib/api/uikit/src/js/core/grid.min.js index cb967d62..dde71152 100755 --- a/lib/api/uikit/src/js/core/grid.min.js +++ b/lib/api/uikit/src/js/core/grid.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){"use strict";var i=[];t.component("gridMatchHeight",{defaults:{target:!1,row:!0,ignorestacked:!1,observe:!1},boot:function(){t.ready(function(i){t.$("[data-uk-grid-match]",i).each(function(){var i,n=t.$(this);n.data("gridMatchHeight")||(i=t.gridMatchHeight(n,t.Utils.options(n.attr("data-uk-grid-match"))))})})},init:function(){var n=this;this.columns=this.element.children(),this.elements=this.options.target?this.find(this.options.target):this.columns,this.columns.length&&(t.$win.on("load resize orientationchange",function(){var i=function(){n.element.is(":visible")&&n.match()};return t.$(function(){i()}),t.Utils.debounce(i,50)}()),this.options.observe&&t.domObserve(this.element,function(){n.element.is(":visible")&&n.match()}),this.on("display.uk.check",function(){this.element.is(":visible")&&this.match()}.bind(this)),i.push(this))},match:function(){var i=this.columns.filter(":visible:first");if(i.length){var n=Math.ceil(100*parseFloat(i.css("width"))/parseFloat(i.parent().css("width")))>=100;return n&&!this.options.ignorestacked?this.revert():t.Utils.matchHeights(this.elements,this.options),this}},revert:function(){return this.elements.css("min-height",""),this}}),t.component("gridMargin",{defaults:{cls:"uk-grid-margin",rowfirst:"uk-row-first"},boot:function(){t.ready(function(i){t.$("[data-uk-grid-margin]",i).each(function(){var i,n=t.$(this);n.data("gridMargin")||(i=t.gridMargin(n,t.Utils.options(n.attr("data-uk-grid-margin"))))})})},init:function(){t.stackMargin(this.element,this.options)}})}(UIkit); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";var i=[];t.component("gridMatchHeight",{defaults:{target:!1,row:!0,ignorestacked:!1,observe:!1},boot:function(){t.ready(function(i){t.$("[data-uk-grid-match]",i).each(function(){var i,n=t.$(this);n.data("gridMatchHeight")||(i=t.gridMatchHeight(n,t.Utils.options(n.attr("data-uk-grid-match"))))})})},init:function(){var n=this;this.columns=this.element.children(),this.elements=this.options.target?this.find(this.options.target):this.columns,this.columns.length&&(t.$win.on("load resize orientationchange",function(){var i=function(){n.element.is(":visible")&&n.match()};return t.$(function(){i()}),t.Utils.debounce(i,50)}()),this.options.observe&&t.domObserve(this.element,function(){n.element.is(":visible")&&n.match()}),this.on("display.uk.check",function(){this.element.is(":visible")&&this.match()}.bind(this)),i.push(this))},match:function(){var i=this.columns.filter(":visible:first");if(i.length){var n=Math.ceil(100*parseFloat(i.css("width"))/parseFloat(i.parent().css("width")))>=100;return n&&!this.options.ignorestacked?this.revert():t.Utils.matchHeights(this.elements,this.options),this}},revert:function(){return this.elements.css("min-height",""),this}}),t.component("gridMargin",{defaults:{cls:"uk-grid-margin",rowfirst:"uk-row-first"},boot:function(){t.ready(function(i){t.$("[data-uk-grid-margin]",i).each(function(){var i,n=t.$(this);n.data("gridMargin")||(i=t.gridMargin(n,t.Utils.options(n.attr("data-uk-grid-margin"))))})})},init:function(){t.stackMargin(this.element,this.options)}})}(UIkit2); \ No newline at end of file diff --git a/lib/api/uikit/src/js/core/modal.min.js b/lib/api/uikit/src/js/core/modal.min.js index 25da8e26..ce9e9739 100755 --- a/lib/api/uikit/src/js/core/modal.min.js +++ b/lib/api/uikit/src/js/core/modal.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){"use strict";function i(i,e){return e?("object"==typeof i?(i=i instanceof jQuery?i:t.$(i),i.parent().length&&(e.persist=i,e.persist.data("modalPersistParent",i.parent()))):i="string"==typeof i||"number"==typeof i?t.$("
          ").html(i):t.$("
          ").html("UIkit.modal Error: Unsupported data type: "+typeof i),i.appendTo(e.element.find(".uk-modal-dialog")),e):void 0}var e,o=!1,n=0,s=t.$html;t.$win.on("resize orientationchange",t.Utils.debounce(function(){t.$(".uk-modal.uk-open").each(function(){return t.$(this).data("modal")&&t.$(this).data("modal").resize()})},150)),t.component("modal",{defaults:{keyboard:!0,bgclose:!0,minScrollHeight:150,center:!1,modal:!0},scrollable:!1,transition:!1,hasTransitioned:!0,init:function(){if(e||(e=t.$("body")),this.element.length){var i=this;this.paddingdir="padding-"+("left"==t.langdirection?"right":"left"),this.dialog=this.find(".uk-modal-dialog"),this.active=!1,this.element.attr("aria-hidden",this.element.hasClass("uk-open")),this.on("click",".uk-modal-close",function(t){t.preventDefault(),i.hide()}).on("click",function(e){var o=t.$(e.target);o[0]==i.element[0]&&i.options.bgclose&&i.hide()}),t.domObserve(this.element,function(){i.resize()})}},toggle:function(){return this[this.isActive()?"hide":"show"]()},show:function(){if(this.element.length){var i=this;if(!this.isActive())return this.options.modal&&o&&o.hide(!0),this.element.removeClass("uk-open").show(),this.resize(!0),this.options.modal&&(o=this),this.active=!0,n++,t.support.transition?(this.hasTransitioned=!1,this.element.one(t.support.transition.end,function(){i.hasTransitioned=!0,t.Utils.focus(i.dialog,"a[href]")}).addClass("uk-open")):(this.element.addClass("uk-open"),t.Utils.focus(this.dialog,"a[href]")),s.addClass("uk-modal-page").height(),this.element.attr("aria-hidden","false"),this.element.trigger("show.uk.modal"),t.Utils.checkDisplay(this.dialog,!0),this}},hide:function(i){if(!i&&t.support.transition&&this.hasTransitioned){var e=this;this.one(t.support.transition.end,function(){e._hide()}).removeClass("uk-open")}else this._hide();return this},resize:function(t){if(this.isActive()||t){var i=e.width();if(this.scrollbarwidth=window.innerWidth-i,e.css(this.paddingdir,this.scrollbarwidth),this.element.css("overflow-y",this.scrollbarwidth?"scroll":"auto"),!this.updateScrollable()&&this.options.center){var o=this.dialog.outerHeight(),n=parseInt(this.dialog.css("margin-top"),10)+parseInt(this.dialog.css("margin-bottom"),10);o+ni?20:i)-e;return t.css({"max-height":n0?n--:n=0,this.element.hide().removeClass("uk-open"),this.element.attr("aria-hidden","true"),n||(s.removeClass("uk-modal-page"),e.css(this.paddingdir,"")),o===this&&(o=!1),this.trigger("hide.uk.modal")},isActive:function(){return this.element.hasClass("uk-open")}}),t.component("modalTrigger",{boot:function(){t.$html.on("click.modal.uikit","[data-uk-modal]",function(i){var e=t.$(this);if(e.is("a")&&i.preventDefault(),!e.data("modalTrigger")){var o=t.modalTrigger(e,t.Utils.options(e.attr("data-uk-modal")));o.show()}}),t.$html.on("keydown.modal.uikit",function(t){o&&27===t.keyCode&&o.options.keyboard&&(t.preventDefault(),o.hide())})},init:function(){var i=this;this.options=t.$.extend({target:i.element.is("a")?i.element.attr("href"):!1},this.options),this.modal=t.modal(this.options.target,this.options),this.on("click",function(t){t.preventDefault(),i.show()}),this.proxy(this.modal,"show hide isActive")}}),t.modal.dialog=function(e,o){var n=t.modal(t.$(t.modal.dialog.template).appendTo("body"),o);return n.on("hide.uk.modal",function(){n.persist&&(n.persist.appendTo(n.persist.data("modalPersistParent")),n.persist=!1),n.element.remove()}),i(e,n),n},t.modal.dialog.template='
          ',t.modal.alert=function(i,e){e=t.$.extend(!0,{bgclose:!1,keyboard:!1,modal:!1,labels:t.modal.labels},e);var o=t.modal.dialog(['
          '+String(i)+"
          ",'"].join(""),e);return o.on("show.uk.modal",function(){setTimeout(function(){o.element.find("button:first").focus()},50)}),o.show()},t.modal.confirm=function(i,e,o){var n=arguments.length>1&&arguments[arguments.length-1]?arguments[arguments.length-1]:{};e=t.$.isFunction(e)?e:function(){},o=t.$.isFunction(o)?o:function(){},n=t.$.extend(!0,{bgclose:!1,keyboard:!1,modal:!1,labels:t.modal.labels},t.$.isFunction(n)?{}:n);var s=t.modal.dialog(['
          '+String(i)+"
          ",'"].join(""),n);return s.element.find(".js-modal-confirm, .js-modal-confirm-cancel").on("click",function(){t.$(this).is(".js-modal-confirm")?e():o(),s.hide()}),s.on("show.uk.modal",function(){setTimeout(function(){s.element.find(".js-modal-confirm").focus()},50)}),s.show()},t.modal.prompt=function(i,e,o,n){o=t.$.isFunction(o)?o:function(){},n=t.$.extend(!0,{bgclose:!1,keyboard:!1,modal:!1,labels:t.modal.labels},n);var s=t.modal.dialog([i?'
          '+String(i)+"
          ":"",'

          ','"].join(""),n),a=s.element.find("input[type='text']").val(e||"").on("keyup",function(t){13==t.keyCode&&s.element.find(".js-modal-ok").trigger("click")});return s.element.find(".js-modal-ok").on("click",function(){o(a.val())!==!1&&s.hide()}),s.show()},t.modal.blockUI=function(i,e){var o=t.modal.dialog(['
          '+String(i||'
          ...
          ')+"
          "].join(""),t.$.extend({bgclose:!1,keyboard:!1,modal:!1},e));return o.content=o.element.find(".uk-modal-content:first"),o.show()},t.modal.labels={Ok:"Ok",Cancel:"Cancel"}}(UIkit); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";function i(i,e){return e?("object"==typeof i?(i=i instanceof jQuery?i:t.$(i),i.parent().length&&(e.persist=i,e.persist.data("modalPersistParent",i.parent()))):i="string"==typeof i||"number"==typeof i?t.$("
          ").html(i):t.$("
          ").html("UIkit2.modal Error: Unsupported data type: "+typeof i),i.appendTo(e.element.find(".uk-modal-dialog")),e):void 0}var e,o=!1,n=0,s=t.$html;t.$win.on("resize orientationchange",t.Utils.debounce(function(){t.$(".uk-modal.uk-open").each(function(){return t.$(this).data("modal")&&t.$(this).data("modal").resize()})},150)),t.component("modal",{defaults:{keyboard:!0,bgclose:!0,minScrollHeight:150,center:!1,modal:!0},scrollable:!1,transition:!1,hasTransitioned:!0,init:function(){if(e||(e=t.$("body")),this.element.length){var i=this;this.paddingdir="padding-"+("left"==t.langdirection?"right":"left"),this.dialog=this.find(".uk-modal-dialog"),this.active=!1,this.element.attr("aria-hidden",this.element.hasClass("uk-open")),this.on("click",".uk-modal-close",function(e){e.preventDefault();var o=t.$(e.target).closest(".uk-modal");o[0]===i.element[0]&&i.hide()}).on("click",function(e){var o=t.$(e.target);o[0]==i.element[0]&&i.options.bgclose&&i.hide()}),t.domObserve(this.element,function(){i.resize()})}},toggle:function(){return this[this.isActive()?"hide":"show"]()},show:function(){if(this.element.length){var i=this;if(!this.isActive())return this.options.modal&&o&&o.hide(!0),this.element.removeClass("uk-open").show(),this.resize(!0),this.options.modal&&(o=this),this.active=!0,n++,t.support.transition?(this.hasTransitioned=!1,this.element.one(t.support.transition.end,function(){i.hasTransitioned=!0,t.Utils.focus(i.dialog,"a[href]")}).addClass("uk-open")):(this.element.addClass("uk-open"),t.Utils.focus(this.dialog,"a[href]")),s.addClass("uk-modal-page").height(),this.element.attr("aria-hidden","false"),this.element.trigger("show.uk.modal"),t.Utils.checkDisplay(this.dialog,!0),this}},hide:function(i){if(!i&&t.support.transition&&this.hasTransitioned){var e=this;this.one(t.support.transition.end,function(){e._hide()}).removeClass("uk-open")}else this._hide();return this},resize:function(t){if(this.isActive()||t){var i=e.width();if(this.scrollbarwidth=window.innerWidth-i,e.css(this.paddingdir,this.scrollbarwidth),this.element.css("overflow-y",this.scrollbarwidth?"scroll":"auto"),!this.updateScrollable()&&this.options.center){var o=this.dialog.outerHeight(),n=parseInt(this.dialog.css("margin-top"),10)+parseInt(this.dialog.css("margin-bottom"),10);o+ni?20:i)-e;return t.css({maxHeight:n0?n--:n=0,this.element.hide().removeClass("uk-open"),this.element.attr("aria-hidden","true"),n||(s.removeClass("uk-modal-page"),e.css(this.paddingdir,"")),o===this&&(o=!1),this.trigger("hide.uk.modal")},isActive:function(){return this.element.hasClass("uk-open")}}),t.component("modalTrigger",{boot:function(){t.$html.on("click.modal.uikit","[data-uk-modal]",function(i){var e=t.$(this);if(e.is("a")&&i.preventDefault(),!e.data("modalTrigger")){var o=t.modalTrigger(e,t.Utils.options(e.attr("data-uk-modal")));o.show()}}),t.$html.on("keydown.modal.uikit",function(t){o&&27===t.keyCode&&o.options.keyboard&&(t.preventDefault(),o.hide())})},init:function(){var i=this;this.options=t.$.extend({target:i.element.is("a")?i.element.attr("href"):!1},this.options),this.modal=t.modal(this.options.target,this.options),this.on("click",function(t){t.preventDefault(),i.show()}),this.proxy(this.modal,"show hide isActive")}}),t.modal.dialog=function(e,o){var n=t.modal(t.$(t.modal.dialog.template).appendTo("body"),o);return n.on("hide.uk.modal",function(){n.persist&&(n.persist.appendTo(n.persist.data("modalPersistParent")),n.persist=!1),n.element.remove()}),i(e,n),n},t.modal.dialog.template='
          ',t.modal.alert=function(i,e){e=t.$.extend(!0,{bgclose:!1,keyboard:!1,modal:!1,labels:t.modal.labels},e);var o=t.modal.dialog(['
          '+String(i)+"
          ",'"].join(""),e);return o.on("show.uk.modal",function(){setTimeout(function(){o.element.find("button:first").focus()},50)}),o.show()},t.modal.confirm=function(i,e,o){var n=arguments.length>1&&arguments[arguments.length-1]?arguments[arguments.length-1]:{};e=t.$.isFunction(e)?e:function(){},o=t.$.isFunction(o)?o:function(){},n=t.$.extend(!0,{bgclose:!1,keyboard:!1,modal:!1,labels:t.modal.labels},t.$.isFunction(n)?{}:n);var s=t.modal.dialog(['
          '+String(i)+"
          ",'"].join(""),n);return s.element.find(".js-modal-confirm, .js-modal-confirm-cancel").on("click",function(){t.$(this).is(".js-modal-confirm")?e():o(),s.hide()}),s.on("show.uk.modal",function(){setTimeout(function(){s.element.find(".js-modal-confirm").focus()},50)}),s.show()},t.modal.prompt=function(i,e,o,n){o=t.$.isFunction(o)?o:function(){},n=t.$.extend(!0,{bgclose:!1,keyboard:!1,modal:!1,labels:t.modal.labels},n);var s=t.modal.dialog([i?'
          '+String(i)+"
          ":"",'

          ','"].join(""),n),a=s.element.find("input[type='text']").val(e||"").on("keyup",function(t){13==t.keyCode&&s.element.find(".js-modal-ok").trigger("click")});return s.element.find(".js-modal-ok").on("click",function(){o(a.val())!==!1&&s.hide()}),s.show()},t.modal.blockUI=function(i,e){var o=t.modal.dialog(['
          '+String(i||'
          ...
          ')+"
          "].join(""),t.$.extend({bgclose:!1,keyboard:!1,modal:!1},e));return o.content=o.element.find(".uk-modal-content:first"),o.show()},t.modal.labels={Ok:"Ok",Cancel:"Cancel"}}(UIkit2); \ No newline at end of file diff --git a/lib/api/uikit/src/js/core/nav.min.js b/lib/api/uikit/src/js/core/nav.min.js index 25e43ab2..88e6fec0 100755 --- a/lib/api/uikit/src/js/core/nav.min.js +++ b/lib/api/uikit/src/js/core/nav.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){"use strict";function i(i){var s=t.$(i),e="auto";if(s.is(":visible"))e=s.outerHeight();else{var a={position:s.css("position"),visibility:s.css("visibility"),display:s.css("display")};e=s.css({position:"absolute",visibility:"hidden",display:"block"}).outerHeight(),s.css(a)}return e}t.component("nav",{defaults:{toggle:">li.uk-parent > a[href='#']",lists:">li.uk-parent > ul",multiple:!1},boot:function(){t.ready(function(i){t.$("[data-uk-nav]",i).each(function(){var i=t.$(this);if(!i.data("nav")){t.nav(i,t.Utils.options(i.attr("data-uk-nav")))}})})},init:function(){var i=this;this.on("click.uk.nav",this.options.toggle,function(s){s.preventDefault();var e=t.$(this);i.open(e.parent()[0]==i.element[0]?e:e.parent("li"))}),this.update(!0),t.domObserve(this.element,function(){i.element.find(this.options.lists).not("[role]").length&&i.update()})},update:function(){var i=this;this.find(this.options.lists).each(function(){var s=t.$(this).attr("role","menu"),e=s.closest("li"),a=e.hasClass("uk-active");e.data("list-container")||(s.wrap('
          '),e.data("list-container",s.parent()[a?"removeClass":"addClass"]("uk-hidden"))),e.attr("aria-expanded",e.hasClass("uk-open")),a&&i.open(e,!0)})},open:function(s,e){var a=this,n=this.element,o=t.$(s),l=o.data("list-container");this.options.multiple||n.children(".uk-open").not(s).each(function(){var i=t.$(this);i.data("list-container")&&i.data("list-container").stop().animate({height:0},function(){t.$(this).parent().removeClass("uk-open").end().addClass("uk-hidden")})}),o.toggleClass("uk-open"),o.attr("aria-expanded",o.hasClass("uk-open")),l&&(o.hasClass("uk-open")&&l.removeClass("uk-hidden"),e?(l.stop().height(o.hasClass("uk-open")?"auto":0),o.hasClass("uk-open")||l.addClass("uk-hidden"),this.trigger("display.uk.check")):l.stop().animate({height:o.hasClass("uk-open")?i(l.find("ul:first")):0},function(){o.hasClass("uk-open")?l.css("height",""):l.addClass("uk-hidden"),a.trigger("display.uk.check")}))}})}(UIkit); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";function i(i){var s=t.$(i),e="auto";if(s.is(":visible"))e=s.outerHeight();else{var a={position:s.css("position"),visibility:s.css("visibility"),display:s.css("display")};e=s.css({position:"absolute",visibility:"hidden",display:"block"}).outerHeight(),s.css(a)}return e}t.component("nav",{defaults:{toggle:'>li.uk-parent > a[href="#"]',lists:">li.uk-parent > ul",multiple:!1},boot:function(){t.ready(function(i){t.$("[data-uk-nav]",i).each(function(){var i=t.$(this);if(!i.data("nav")){t.nav(i,t.Utils.options(i.attr("data-uk-nav")))}})})},init:function(){var i=this;this.on("click.uk.nav",this.options.toggle,function(s){s.preventDefault();var e=t.$(this);i.open(e.parent()[0]==i.element[0]?e:e.parent("li"))}),this.update(),t.domObserve(this.element,function(){i.element.find(i.options.lists).not("[role]").length&&i.update()})},update:function(){var i=this;this.find(this.options.lists).each(function(){var s=t.$(this).attr("role","menu"),e=s.closest("li"),a=e.hasClass("uk-active");e.data("list-container")||(s.wrap('
          '),e.data("list-container",s.parent()[a?"removeClass":"addClass"]("uk-hidden"))),e.attr("aria-expanded",e.hasClass("uk-open")),a&&i.open(e,!0)})},open:function(s,e){var a=this,n=this.element,o=t.$(s),l=o.data("list-container");this.options.multiple||n.children(".uk-open").not(s).each(function(){var i=t.$(this);i.data("list-container")&&i.data("list-container").stop().animate({height:0},function(){t.$(this).parent().removeClass("uk-open").end().addClass("uk-hidden")})}),o.toggleClass("uk-open"),o.attr("aria-expanded",o.hasClass("uk-open")),l&&(o.hasClass("uk-open")&&l.removeClass("uk-hidden"),e?(l.stop().height(o.hasClass("uk-open")?"auto":0),o.hasClass("uk-open")||l.addClass("uk-hidden"),this.trigger("display.uk.check")):l.stop().animate({height:o.hasClass("uk-open")?i(l.find("ul:first")):0},function(){o.hasClass("uk-open")?l.css("height",""):l.addClass("uk-hidden"),a.trigger("display.uk.check")}))}})}(UIkit2); \ No newline at end of file diff --git a/lib/api/uikit/src/js/core/offcanvas.min.js b/lib/api/uikit/src/js/core/offcanvas.min.js index ea104ecd..7ee78a05 100755 --- a/lib/api/uikit/src/js/core/offcanvas.min.js +++ b/lib/api/uikit/src/js/core/offcanvas.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(a){"use strict";var t={x:window.scrollX,y:window.scrollY},n=(a.$win,a.$doc,a.$html),i={show:function(i,o){if(i=a.$(i),i.length){o=a.$.extend({mode:"push"},o);var e=a.$("body"),s=i.find(".uk-offcanvas-bar:first"),r="right"==a.langdirection,f=s.hasClass("uk-offcanvas-bar-flip")?-1:1,c=f*(r?-1:1),h=window.innerWidth-e.width();t={x:window.pageXOffset,y:window.pageYOffset},s.attr("mode",o.mode),i.addClass("uk-active"),e.css({width:window.innerWidth-h,height:window.innerHeight}).addClass("uk-offcanvas-page"),("push"==o.mode||"reveal"==o.mode)&&e.css(r?"margin-right":"margin-left",(r?-1:1)*s.outerWidth()*c),"reveal"==o.mode&&s.css("clip","rect(0, "+s.outerWidth()+"px, 100vh, 0)"),n.css("margin-top",-1*t.y).width(),s.addClass("uk-offcanvas-bar-show"),this._initElement(i),s.trigger("show.uk.offcanvas",[i,s]),i.attr("aria-hidden","false")}},hide:function(i){var o=a.$("body"),e=a.$(".uk-offcanvas.uk-active"),s="right"==a.langdirection,r=e.find(".uk-offcanvas-bar:first"),f=function(){o.removeClass("uk-offcanvas-page").css({width:"",height:"","margin-left":"","margin-right":""}),e.removeClass("uk-active"),r.removeClass("uk-offcanvas-bar-show"),n.css("margin-top",""),window.scrollTo(t.x,t.y),r.trigger("hide.uk.offcanvas",[e,r]),e.attr("aria-hidden","true")};e.length&&("none"==r.attr("mode")&&(i=!0),a.support.transition&&!i?(o.one(a.support.transition.end,function(){f()}).css(s?"margin-right":"margin-left",""),"reveal"==r.attr("mode")&&r.css("clip",""),setTimeout(function(){r.removeClass("uk-offcanvas-bar-show")},0)):f())},_initElement:function(t){t.data("OffcanvasInit")||(t.on("click.uk.offcanvas swipeRight.uk.offcanvas swipeLeft.uk.offcanvas",function(t){var n=a.$(t.target);if(!t.type.match(/swipe/)&&!n.hasClass("uk-offcanvas-close")){if(n.hasClass("uk-offcanvas-bar"))return;if(n.parents(".uk-offcanvas-bar:first").length)return}t.stopImmediatePropagation(),i.hide()}),t.on("click","a[href*='#']",function(){var t=a.$(this),n=t.attr("href");"#"!=n&&(a.$doc.one("hide.uk.offcanvas",function(){var i;try{i=a.$(t[0].hash)}catch(o){i=""}i.length||(i=a.$('[name="'+t[0].hash.replace("#","")+'"]')),i.length&&a.Utils.scrollToElement?a.Utils.scrollToElement(i,a.Utils.options(t.attr("data-uk-smooth-scroll")||"{}")):window.location.href=n}),i.hide())}),t.data("OffcanvasInit",!0))}};a.component("offcanvasTrigger",{boot:function(){n.on("click.offcanvas.uikit","[data-uk-offcanvas]",function(t){t.preventDefault();var n=a.$(this);if(!n.data("offcanvasTrigger")){{a.offcanvasTrigger(n,a.Utils.options(n.attr("data-uk-offcanvas")))}n.trigger("click")}}),n.on("keydown.uk.offcanvas",function(a){27===a.keyCode&&i.hide()})},init:function(){var t=this;this.options=a.$.extend({target:t.element.is("a")?t.element.attr("href"):!1,mode:"push"},this.options),this.on("click",function(a){a.preventDefault(),i.show(t.options.target,t.options)})}}),a.offcanvas=i}(UIkit); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(a){"use strict";var t={x:window.scrollX,y:window.scrollY},n=(a.$win,a.$doc,a.$html),i={show:function(i,e){if(i=a.$(i),i.length){e=a.$.extend({mode:"push"},e);var o=a.$("body"),s=i.find(".uk-offcanvas-bar:first"),r="right"==a.langdirection,f=s.hasClass("uk-offcanvas-bar-flip")?-1:1,c=f*(r?-1:1),h=window.innerWidth-o.width();t={x:window.pageXOffset,y:window.pageYOffset},s.attr("mode",e.mode),i.addClass("uk-active"),o.css({width:window.innerWidth-h,height:window.innerHeight}).addClass("uk-offcanvas-page"),("push"==e.mode||"reveal"==e.mode)&&o.css(r?"margin-right":"margin-left",(r?-1:1)*s.outerWidth()*c),"reveal"==e.mode&&s.css("clip","rect(0, "+s.outerWidth()+"px, 100vh, 0)"),n.css("margin-top",-1*t.y).width(),s.addClass("uk-offcanvas-bar-show"),this._initElement(i),s.trigger("show.uk.offcanvas",[i,s]),i.attr("aria-hidden","false")}},hide:function(i){var e=a.$("body"),o=a.$(".uk-offcanvas.uk-active"),s="right"==a.langdirection,r=o.find(".uk-offcanvas-bar:first"),f=function(){e.removeClass("uk-offcanvas-page").css({width:"",height:"",marginLeft:"",marginRight:""}),o.removeClass("uk-active"),r.removeClass("uk-offcanvas-bar-show"),n.css("margin-top",""),window.scrollTo(t.x,t.y),r.trigger("hide.uk.offcanvas",[o,r]),o.attr("aria-hidden","true")};o.length&&("none"==r.attr("mode")&&(i=!0),a.support.transition&&!i?(e.one(a.support.transition.end,function(){f()}).css(s?"margin-right":"margin-left",""),"reveal"==r.attr("mode")&&r.css("clip",""),setTimeout(function(){r.removeClass("uk-offcanvas-bar-show")},0)):f())},_initElement:function(t){t.data("OffcanvasInit")||(t.on("click.uk.offcanvas swipeRight.uk.offcanvas swipeLeft.uk.offcanvas",function(t){var n=a.$(t.target);if(t.type.match(/swipe/)){if(n.parents(".uk-offcanvas-bar:first").length)return}else if(!n.hasClass("uk-offcanvas-close")){if(n.hasClass("uk-offcanvas-bar"))return;if(n.parents(".uk-offcanvas-bar:first").length)return}t.stopImmediatePropagation(),i.hide()}),t.on("click",'a[href*="#"]',function(){var t=a.$(this),n=t.attr("href");"#"!=n&&(a.$doc.one("hide.uk.offcanvas",function(){var i;try{i=a.$(t[0].hash)}catch(e){i=""}i.length||(i=a.$('[name="'+t[0].hash.replace("#","")+'"]')),i.length&&a.Utils.scrollToElement?a.Utils.scrollToElement(i,a.Utils.options(t.attr("data-uk-smooth-scroll")||"{}")):window.location.href=n}),i.hide())}),t.data("OffcanvasInit",!0))}};a.component("offcanvasTrigger",{boot:function(){n.on("click.offcanvas.uikit","[data-uk-offcanvas]",function(t){t.preventDefault();var n=a.$(this);if(!n.data("offcanvasTrigger")){{a.offcanvasTrigger(n,a.Utils.options(n.attr("data-uk-offcanvas")))}n.trigger("click")}}),n.on("keydown.uk.offcanvas",function(a){27===a.keyCode&&i.hide()})},init:function(){var t=this;this.options=a.$.extend({target:t.element.is("a")?t.element.attr("href"):!1,mode:"push"},this.options),this.on("click",function(a){a.preventDefault(),i.show(t.options.target,t.options)})}}),a.offcanvas=i}(UIkit2); \ No newline at end of file diff --git a/lib/api/uikit/src/js/core/scrollspy.min.js b/lib/api/uikit/src/js/core/scrollspy.min.js index 39453724..74c7d801 100755 --- a/lib/api/uikit/src/js/core/scrollspy.min.js +++ b/lib/api/uikit/src/js/core/scrollspy.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){"use strict";var s=t.$win,o=t.$doc,i=[],e=function(){for(var t=0;t=p)return o[t]}();if(!f)return;c.options.closest?(e.blur().closest(r).removeClass(a),l=e.filter("a[href='#"+f.attr("id")+"']").closest(r).addClass(a)):l=e.removeClass(a).filter("a[href='#"+f.attr("id")+"']").addClass(a),c.element.trigger("inview.uk.scrollspynav",[f,l])}};this.options.smoothscroll&&t.smoothScroll&&e.each(function(){t.smoothScroll(this,c.options.smoothscroll)}),p(),this.element.data("scrollspynav",this),this.check=p,l.push(this)}})}(UIkit); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";var s=t.$win,o=t.$doc,i=[],e=function(){for(var t=0;t=p)return o[t]}();if(!f)return;c.options.closest?(e.blur().closest(r).removeClass(a),l=e.filter("a[href='#"+f.attr("id")+"']").closest(r).addClass(a)):l=e.removeClass(a).filter("a[href='#"+f.attr("id")+"']").addClass(a),c.element.trigger("inview.uk.scrollspynav",[f,l])}};this.options.smoothscroll&&t.smoothScroll&&e.each(function(){t.smoothScroll(this,c.options.smoothscroll)}),p(),this.element.data("scrollspynav",this),this.check=p,l.push(this)}})}(UIkit2); \ No newline at end of file diff --git a/lib/api/uikit/src/js/core/smooth-scroll.min.js b/lib/api/uikit/src/js/core/smooth-scroll.min.js index 2eb43f56..9a35beca 100755 --- a/lib/api/uikit/src/js/core/smooth-scroll.min.js +++ b/lib/api/uikit/src/js/core/smooth-scroll.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){"use strict";function o(o,i){i=t.$.extend({duration:1e3,transition:"easeOutExpo",offset:0,complete:function(){}},i);var n=o.offset().top-i.offset,s=t.$doc.height(),e=window.innerHeight;n+e>s&&(n=s-e),t.$("html,body").stop().animate({scrollTop:n},i.duration,i.transition).promise().done(i.complete)}t.component("smoothScroll",{boot:function(){t.$html.on("click.smooth-scroll.uikit","[data-uk-smooth-scroll]",function(){var o=t.$(this);if(!o.data("smoothScroll")){{t.smoothScroll(o,t.Utils.options(o.attr("data-uk-smooth-scroll")))}o.trigger("click")}return!1})},init:function(){var i=this;this.on("click",function(n){n.preventDefault(),o(t.$(this.hash).length?t.$(this.hash):t.$("body"),i.options)})}}),t.Utils.scrollToElement=o,t.$.easing.easeOutExpo||(t.$.easing.easeOutExpo=function(t,o,i,n,s){return o==s?i+n:n*(-Math.pow(2,-10*o/s)+1)+i})}(UIkit); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";function o(o,i){i=t.$.extend({duration:1e3,transition:"easeOutExpo",offset:0,complete:function(){}},i);var n=o.offset().top-i.offset,s=t.$doc.height(),e=window.innerHeight;n+e>s&&(n=s-e),t.$("html,body").stop().animate({scrollTop:n},i.duration,i.transition).promise().done(i.complete)}t.component("smoothScroll",{boot:function(){t.$html.on("click.smooth-scroll.uikit","[data-uk-smooth-scroll]",function(){var o=t.$(this);if(!o.data("smoothScroll")){{t.smoothScroll(o,t.Utils.options(o.attr("data-uk-smooth-scroll")))}o.trigger("click")}return!1})},init:function(){var i=this;this.on("click",function(n){n.preventDefault(),o(t.$(this.hash).length?t.$(this.hash):t.$("body"),i.options)})}}),t.Utils.scrollToElement=o,t.$.easing.easeOutExpo||(t.$.easing.easeOutExpo=function(t,o,i,n,s){return o==s?i+n:n*(-Math.pow(2,-10*o/s)+1)+i})}(UIkit2); \ No newline at end of file diff --git a/lib/api/uikit/src/js/core/switcher.min.js b/lib/api/uikit/src/js/core/switcher.min.js index 2a041ad2..f7149bbc 100755 --- a/lib/api/uikit/src/js/core/switcher.min.js +++ b/lib/api/uikit/src/js/core/switcher.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){"use strict";function i(i,n,e){var s,a=t.$.Deferred(),o=i,r=i;return e[0]===n[0]?(a.resolve(),a.promise()):("object"==typeof i&&(o=i[0],r=i[1]||i[0]),t.$body.css("overflow-x","hidden"),s=function(){n&&n.hide().removeClass("uk-active "+r+" uk-animation-reverse"),e.addClass(o).one(t.support.animation.end,function(){setTimeout(function(){e.removeClass(""+o).css({opacity:"",display:""})},0),a.resolve(),t.$body.css("overflow-x",""),n&&n.css({opacity:"",display:""})}.bind(this)).show()},e.css("animation-duration",this.options.duration+"ms"),n&&n.length?(n.css("animation-duration",this.options.duration+"ms"),n.css("display","none").addClass(r+" uk-animation-reverse").one(t.support.animation.end,function(){s()}.bind(this)).css("display","")):(e.addClass("uk-active"),s()),a.promise())}var n;t.component("switcher",{defaults:{connect:!1,toggle:">*",active:0,animation:!1,duration:200,swiping:!0},animating:!1,boot:function(){t.ready(function(i){t.$("[data-uk-switcher]",i).each(function(){var i=t.$(this);if(!i.data("switcher")){t.switcher(i,t.Utils.options(i.attr("data-uk-switcher")))}})})},init:function(){var i=this;this.on("click.uk.switcher",this.options.toggle,function(t){t.preventDefault(),i.show(this)}),this.options.connect&&(this.connect=t.$(this.options.connect),this.connect.length&&(this.connect.on("click.uk.switcher","[data-uk-switcher-item]",function(n){n.preventDefault();var e=t.$(this).attr("data-uk-switcher-item");if(i.index!=e)switch(e){case"next":case"previous":i.show(i.index+("next"==e?1:-1));break;default:i.show(parseInt(e,10))}}),this.options.swiping&&this.connect.on("swipeRight swipeLeft",function(t){t.preventDefault(),window.getSelection().toString()||i.show(i.index+("swipeLeft"==t.type?1:-1))}),this.update()))},update:function(){this.connect.children().removeClass("uk-active").attr("aria-hidden","true");var t=this.find(this.options.toggle),i=t.filter(".uk-active");if(i.length)this.show(i,!1);else{if(this.options.active===!1)return;i=t.eq(this.options.active),this.show(i.length?i:t.eq(0),!1)}t.not(i).attr("aria-expanded","false"),i.attr("aria-expanded","true")},show:function(e,s){if(!this.animating){if(isNaN(e))e=t.$(e);else{var a=this.find(this.options.toggle);e=0>e?a.length-1:e,e=a.eq(a[e]?e:0)}var o=this,a=this.find(this.options.toggle),r=t.$(e),c=n[this.options.animation]||function(t,e){if(!o.options.animation)return n.none.apply(o);var s=o.options.animation.split(",");return 1==s.length&&(s[1]=s[0]),s[0]=s[0].trim(),s[1]=s[1].trim(),i.apply(o,[s,t,e])};s!==!1&&t.support.animation||(c=n.none),r.hasClass("uk-disabled")||(a.attr("aria-expanded","false"),r.attr("aria-expanded","true"),a.filter(".uk-active").removeClass("uk-active"),r.addClass("uk-active"),this.options.connect&&this.connect.length&&(this.index=this.find(this.options.toggle).index(r),-1==this.index&&(this.index=0),this.connect.each(function(){var i=t.$(this),n=t.$(i.children()),e=t.$(n.filter(".uk-active")),s=t.$(n.eq(o.index));o.animating=!0,c.apply(o,[e,s]).then(function(){e.removeClass("uk-active"),s.addClass("uk-active"),e.attr("aria-hidden","true"),s.attr("aria-hidden","false"),t.Utils.checkDisplay(s,!0),o.animating=!1})})),this.trigger("show.uk.switcher",[r]))}}}),n={none:function(){var i=t.$.Deferred();return i.resolve(),i.promise()},fade:function(t,n){return i.apply(this,["uk-animation-fade",t,n])},"slide-bottom":function(t,n){return i.apply(this,["uk-animation-slide-bottom",t,n])},"slide-top":function(t,n){return i.apply(this,["uk-animation-slide-top",t,n])},"slide-vertical":function(t,n){var e=["uk-animation-slide-top","uk-animation-slide-bottom"];return t&&t.index()>n.index()&&e.reverse(),i.apply(this,[e,t,n])},"slide-left":function(t,n){return i.apply(this,["uk-animation-slide-left",t,n])},"slide-right":function(t,n){return i.apply(this,["uk-animation-slide-right",t,n])},"slide-horizontal":function(t,n){var e=["uk-animation-slide-right","uk-animation-slide-left"];return t&&t.index()>n.index()&&e.reverse(),i.apply(this,[e,t,n])},scale:function(t,n){return i.apply(this,["uk-animation-scale-up",t,n])}},t.switcher.animations=n}(UIkit); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";function i(i,n,e){var s,a=t.$.Deferred(),o=i,r=i;return e[0]===n[0]?(a.resolve(),a.promise()):("object"==typeof i&&(o=i[0],r=i[1]||i[0]),t.$body.css("overflow-x","hidden"),s=function(){n&&n.hide().removeClass("uk-active "+r+" uk-animation-reverse"),e.addClass(o).one(t.support.animation.end,function(){setTimeout(function(){e.removeClass(""+o).css({opacity:"",display:""})},0),a.resolve(),t.$body.css("overflow-x",""),n&&n.css({opacity:"",display:""})}.bind(this)).show()},e.css("animation-duration",this.options.duration+"ms"),n&&n.length?(n.css("animation-duration",this.options.duration+"ms"),n.css("display","none").addClass(r+" uk-animation-reverse").one(t.support.animation.end,function(){s()}.bind(this)).css("display","")):(e.addClass("uk-active"),s()),a.promise())}var n;t.component("switcher",{defaults:{connect:!1,toggle:">*",active:0,animation:!1,duration:200,swiping:!0},animating:!1,boot:function(){t.ready(function(i){t.$("[data-uk-switcher]",i).each(function(){var i=t.$(this);if(!i.data("switcher")){t.switcher(i,t.Utils.options(i.attr("data-uk-switcher")))}})})},init:function(){var i=this;this.on("click.uk.switcher",this.options.toggle,function(t){t.preventDefault(),i.show(this)}),this.options.connect&&(this.connect=t.$(this.options.connect),this.connect.length&&(this.connect.on("click.uk.switcher","[data-uk-switcher-item]",function(n){n.preventDefault();var e=t.$(this).attr("data-uk-switcher-item");if(i.index!=e)switch(e){case"next":case"previous":i.show(i.index+("next"==e?1:-1));break;default:i.show(parseInt(e,10))}}),this.options.swiping&&this.connect.on("swipeRight swipeLeft",function(t){t.preventDefault(),window.getSelection().toString()||i.show(i.index+("swipeLeft"==t.type?1:-1))}),this.update()))},update:function(){this.connect.children().removeClass("uk-active").attr("aria-hidden","true");var t=this.find(this.options.toggle),i=t.filter(".uk-active");if(i.length)this.show(i,!1);else{if(this.options.active===!1)return;i=t.eq(this.options.active),this.show(i.length?i:t.eq(0),!1)}t.not(i).attr("aria-expanded","false"),i.attr("aria-expanded","true")},show:function(e,s){if(!this.animating){var a=this.find(this.options.toggle);isNaN(e)?e=t.$(e):(e=0>e?a.length-1:e,e=a.eq(a[e]?e:0));var o=this,r=t.$(e),c=n[this.options.animation]||function(t,e){if(!o.options.animation)return n.none.apply(o);var s=o.options.animation.split(",");return 1==s.length&&(s[1]=s[0]),s[0]=s[0].trim(),s[1]=s[1].trim(),i.apply(o,[s,t,e])};s!==!1&&t.support.animation||(c=n.none),r.hasClass("uk-disabled")||(a.attr("aria-expanded","false"),r.attr("aria-expanded","true"),a.filter(".uk-active").removeClass("uk-active"),r.addClass("uk-active"),this.options.connect&&this.connect.length&&(this.index=this.find(this.options.toggle).index(r),-1==this.index&&(this.index=0),this.connect.each(function(){var i=t.$(this),n=t.$(i.children()),e=t.$(n.filter(".uk-active")),s=t.$(n.eq(o.index));o.animating=!0,c.apply(o,[e,s]).then(function(){e.removeClass("uk-active"),s.addClass("uk-active"),e.attr("aria-hidden","true"),s.attr("aria-hidden","false"),t.Utils.checkDisplay(s,!0),o.animating=!1})})),this.trigger("show.uk.switcher",[r]))}}}),n={none:function(){var i=t.$.Deferred();return i.resolve(),i.promise()},fade:function(t,n){return i.apply(this,["uk-animation-fade",t,n])},"slide-bottom":function(t,n){return i.apply(this,["uk-animation-slide-bottom",t,n])},"slide-top":function(t,n){return i.apply(this,["uk-animation-slide-top",t,n])},"slide-vertical":function(t,n){var e=["uk-animation-slide-top","uk-animation-slide-bottom"];return t&&t.index()>n.index()&&e.reverse(),i.apply(this,[e,t,n])},"slide-left":function(t,n){return i.apply(this,["uk-animation-slide-left",t,n])},"slide-right":function(t,n){return i.apply(this,["uk-animation-slide-right",t,n])},"slide-horizontal":function(t,n){var e=["uk-animation-slide-right","uk-animation-slide-left"];return t&&t.index()>n.index()&&e.reverse(),i.apply(this,[e,t,n])},scale:function(t,n){return i.apply(this,["uk-animation-scale-up",t,n])}},t.switcher.animations=n}(UIkit2); \ No newline at end of file diff --git a/lib/api/uikit/src/js/core/tab.min.js b/lib/api/uikit/src/js/core/tab.min.js index 517cc4db..7650c1bf 100755 --- a/lib/api/uikit/src/js/core/tab.min.js +++ b/lib/api/uikit/src/js/core/tab.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){"use strict";t.component("tab",{defaults:{target:">li:not(.uk-tab-responsive, .uk-disabled)",connect:!1,active:0,animation:!1,duration:200,swiping:!0},boot:function(){t.ready(function(i){t.$("[data-uk-tab]",i).each(function(){var i=t.$(this);if(!i.data("tab")){t.tab(i,t.Utils.options(i.attr("data-uk-tab")))}})})},init:function(){var i=this;this.current=!1,this.on("click.uk.tab",this.options.target,function(e){if(e.preventDefault(),!i.switcher||!i.switcher.animating){var s=i.find(i.options.target).not(this);s.removeClass("uk-active").blur(),i.trigger("change.uk.tab",[t.$(this).addClass("uk-active"),i.current]),i.current=t.$(this),i.options.connect||(s.attr("aria-expanded","false"),t.$(this).attr("aria-expanded","true"))}}),this.options.connect&&(this.connect=t.$(this.options.connect)),this.responsivetab=t.$('
        • ').append('
            '),this.responsivetab.dropdown=this.responsivetab.find(".uk-dropdown"),this.responsivetab.lst=this.responsivetab.dropdown.find("ul"),this.responsivetab.caption=this.responsivetab.find("a:first"),this.element.hasClass("uk-tab-bottom")&&this.responsivetab.dropdown.addClass("uk-dropdown-up"),this.responsivetab.lst.on("click.uk.tab","a",function(e){e.preventDefault(),e.stopPropagation();var s=t.$(this);i.element.children("li:not(.uk-tab-responsive)").eq(s.data("index")).trigger("click")}),this.on("show.uk.switcher change.uk.tab",function(t,e){i.responsivetab.caption.html(e.text())}),this.element.append(this.responsivetab),this.options.connect&&(this.switcher=t.switcher(this.element,{toggle:">li:not(.uk-tab-responsive)",connect:this.options.connect,active:this.options.active,animation:this.options.animation,duration:this.options.duration,swiping:this.options.swiping})),t.dropdown(this.responsivetab,{mode:"click",preventflip:"y"}),i.trigger("change.uk.tab",[this.element.find(this.options.target).not(".uk-tab-responsive").filter(".uk-active")]),this.check(),t.$win.on("resize orientationchange",t.Utils.debounce(function(){i.element.is(":visible")&&i.check()},100)),this.on("display.uk.check",function(){i.element.is(":visible")&&i.check()})},check:function(){var i=this.element.children("li:not(.uk-tab-responsive)").removeClass("uk-hidden");if(!i.length)return this.responsivetab.addClass("uk-hidden"),void 0;var e,s,n,a=i.eq(0).offset().top+Math.ceil(i.eq(0).height()/2),o=!1;if(this.responsivetab.lst.empty(),i.each(function(){t.$(this).offset().top>a&&(o=!0)}),o)for(var r=0;rli:not(.uk-tab-responsive, .uk-disabled)",connect:!1,active:0,animation:!1,duration:200,swiping:!0},boot:function(){t.ready(function(i){t.$("[data-uk-tab]",i).each(function(){var i=t.$(this);if(!i.data("tab")){t.tab(i,t.Utils.options(i.attr("data-uk-tab")))}})})},init:function(){var i=this;this.current=!1,this.on("click.uk.tab",this.options.target,function(e){if(e.preventDefault(),!i.switcher||!i.switcher.animating){var n=i.find(i.options.target).not(this);n.removeClass("uk-active").blur(),i.trigger("change.uk.tab",[t.$(this).addClass("uk-active"),i.current]),i.current=t.$(this),i.options.connect||(n.attr("aria-expanded","false"),t.$(this).attr("aria-expanded","true"))}}),this.options.connect&&(this.connect=t.$(this.options.connect)),this.responsivetab=t.$('
          • ').append('
              '),this.responsivetab.dropdown=this.responsivetab.find(".uk-dropdown"),this.responsivetab.lst=this.responsivetab.dropdown.find("ul"),this.responsivetab.caption=this.responsivetab.find("a:first"),this.element.hasClass("uk-tab-bottom")&&this.responsivetab.dropdown.addClass("uk-dropdown-up"),this.responsivetab.lst.on("click.uk.tab","a",function(e){e.preventDefault(),e.stopPropagation();var n=t.$(this);i.element.children("li:not(.uk-tab-responsive)").eq(n.data("index")).trigger("click")}),this.on("show.uk.switcher change.uk.tab",function(t,e){i.responsivetab.caption.html(e.text())}),this.element.append(this.responsivetab),this.options.connect&&(this.switcher=t.switcher(this.element,{toggle:">li:not(.uk-tab-responsive)",connect:this.options.connect,active:this.options.active,animation:this.options.animation,duration:this.options.duration,swiping:this.options.swiping})),t.dropdown(this.responsivetab,{mode:"click",preventflip:"y"}),i.trigger("change.uk.tab",[this.element.find(this.options.target).not(".uk-tab-responsive").filter(".uk-active")]),this.check(),t.$win.on("resize orientationchange",t.Utils.debounce(function(){i.element.is(":visible")&&i.check()},100)),this.on("display.uk.check",function(){i.element.is(":visible")&&i.check()})},check:function(){var i=this.element.children("li:not(.uk-tab-responsive)").removeClass("uk-hidden");if(!i.length)return this.responsivetab.addClass("uk-hidden"),void 0;var e,n,s,a=i.eq(0).offset().top+Math.ceil(i.eq(0).height()/2),o=!1;if(this.responsivetab.lst.empty(),i.each(function(){t.$(this).offset().top>a&&(o=!0)}),o)for(var r=0;r=Math.abs(n-o)?e-t>0?"Left":"Right":n-o>0?"Up":"Down"}function n(){p=null,g.last&&(void 0!==g.el&&g.el.trigger("longTap"),g={})}function o(){p&&clearTimeout(p),p=null}function i(){a&&clearTimeout(a),l&&clearTimeout(l),u&&clearTimeout(u),p&&clearTimeout(p),a=l=u=p=null,g={}}function r(e){return e.pointerType==e.MSPOINTER_TYPE_TOUCH&&e.isPrimary}if(!e.fn.swipeLeft){var a,l,u,p,c,g={},s=750;e(function(){var v,y,w,f=0,d=0;"MSGesture"in window&&(c=new MSGesture,c.target=document.body),e(document).on("MSGestureEnd gestureend",function(e){var t=e.originalEvent.velocityX>1?"Right":e.originalEvent.velocityX<-1?"Left":e.originalEvent.velocityY>1?"Down":e.originalEvent.velocityY<-1?"Up":null;t&&void 0!==g.el&&(g.el.trigger("swipe"),g.el.trigger("swipe"+t))}).on("touchstart MSPointerDown pointerdown",function(t){("MSPointerDown"!=t.type||r(t.originalEvent))&&(w="MSPointerDown"==t.type||"pointerdown"==t.type?t:t.originalEvent.touches[0],v=Date.now(),y=v-(g.last||v),g.el=e("tagName"in w.target?w.target:w.target.parentNode),a&&clearTimeout(a),g.x1=w.pageX,g.y1=w.pageY,y>0&&250>=y&&(g.isDoubleTap=!0),g.last=v,p=setTimeout(n,s),!c||"MSPointerDown"!=t.type&&"pointerdown"!=t.type&&"touchstart"!=t.type||c.addPointer(t.originalEvent.pointerId))}).on("touchmove MSPointerMove pointermove",function(e){("MSPointerMove"!=e.type||r(e.originalEvent))&&(w="MSPointerMove"==e.type||"pointermove"==e.type?e:e.originalEvent.touches[0],o(),g.x2=w.pageX,g.y2=w.pageY,f+=Math.abs(g.x1-g.x2),d+=Math.abs(g.y1-g.y2))}).on("touchend MSPointerUp pointerup",function(n){("MSPointerUp"!=n.type||r(n.originalEvent))&&(o(),g.x2&&Math.abs(g.x1-g.x2)>30||g.y2&&Math.abs(g.y1-g.y2)>30?u=setTimeout(function(){void 0!==g.el&&(g.el.trigger("swipe"),g.el.trigger("swipe"+t(g.x1,g.x2,g.y1,g.y2))),g={}},0):"last"in g&&(isNaN(f)||30>f&&30>d?l=setTimeout(function(){var t=e.Event("tap");t.cancelTouch=i,void 0!==g.el&&g.el.trigger(t),g.isDoubleTap?(void 0!==g.el&&g.el.trigger("doubleTap"),g={}):a=setTimeout(function(){a=null,void 0!==g.el&&g.el.trigger("singleTap"),g={}},250)},0):g={},f=d=0))}).on("touchcancel MSPointerCancel pointercancel",i),e(window).on("scroll",i)}),["swipe","swipeLeft","swipeRight","swipeUp","swipeDown","doubleTap","tap","singleTap","longTap"].forEach(function(t){e.fn[t]=function(n){return e(this).on(t,n)}})}}(jQuery); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(e){function t(e,t,n,o){return Math.abs(e-t)>=Math.abs(n-o)?e-t>0?"Left":"Right":n-o>0?"Up":"Down"}function n(){c=null,g.last&&(void 0!==g.el&&g.el.trigger("longTap"),g={})}function o(){c&&clearTimeout(c),c=null}function i(){a&&clearTimeout(a),l&&clearTimeout(l),u&&clearTimeout(u),c&&clearTimeout(c),a=l=u=c=null,g={}}function r(e){return e.pointerType==e.MSPOINTER_TYPE_TOUCH&&e.isPrimary}if(!e.fn.swipeLeft){var a,l,u,c,p,g={},s=750,v="ontouchstart"in window,w=window.PointerEvent,d=v||window.DocumentTouch&&document instanceof DocumentTouch||navigator.msPointerEnabled&&navigator.msMaxTouchPoints>0||navigator.pointerEnabled&&navigator.maxTouchPoints>0;e(function(){var y,T,f,h=0,M=0;"MSGesture"in window&&(p=new MSGesture,p.target=document.body),e(document).on("MSGestureEnd gestureend",function(e){var t=e.originalEvent.velocityX>1?"Right":e.originalEvent.velocityX<-1?"Left":e.originalEvent.velocityY>1?"Down":e.originalEvent.velocityY<-1?"Up":null;t&&void 0!==g.el&&(g.el.trigger("swipe"),g.el.trigger("swipe"+t))}).on("touchstart MSPointerDown pointerdown",function(t){("MSPointerDown"!=t.type||r(t.originalEvent))&&(f="MSPointerDown"==t.type||"pointerdown"==t.type?t:t.originalEvent.touches[0],y=Date.now(),T=y-(g.last||y),g.el=e("tagName"in f.target?f.target:f.target.parentNode),a&&clearTimeout(a),g.x1=f.pageX,g.y1=f.pageY,T>0&&250>=T&&(g.isDoubleTap=!0),g.last=y,c=setTimeout(n,s),t.originalEvent&&t.originalEvent.pointerId&&p&&("MSPointerDown"==t.type||"pointerdown"==t.type||"touchstart"==t.type)&&p.addPointer(t.originalEvent.pointerId))}).on("touchmove MSPointerMove pointermove",function(e){("MSPointerMove"!=e.type||r(e.originalEvent))&&(f="MSPointerMove"==e.type||"pointermove"==e.type?e:e.originalEvent.touches[0],o(),g.x2=f.pageX,g.y2=f.pageY,h+=Math.abs(g.x1-g.x2),M+=Math.abs(g.y1-g.y2))}).on("touchend MSPointerUp pointerup",function(n){("MSPointerUp"!=n.type||r(n.originalEvent))&&(o(),g.x2&&Math.abs(g.x1-g.x2)>30||g.y2&&Math.abs(g.y1-g.y2)>30?u=setTimeout(function(){void 0!==g.el&&(g.el.trigger("swipe"),g.el.trigger("swipe"+t(g.x1,g.x2,g.y1,g.y2))),g={}},0):"last"in g&&(isNaN(h)||30>h&&30>M?l=setTimeout(function(){var t=e.Event("tap");t.cancelTouch=i,void 0!==g.el&&g.el.trigger(t),g.isDoubleTap?(void 0!==g.el&&g.el.trigger("doubleTap"),g={}):a=setTimeout(function(){a=null,void 0!==g.el&&g.el.trigger("singleTap"),g={}},250)},0):g={},h=M=0))}).on("touchcancel MSPointerCancel pointercancel",function(e){("touchcancel"==e.type&&v&&d||!v&&"pointercancel"==e.type&&w)&&i()}),e(window).on("scroll",i)}),["swipe","swipeLeft","swipeRight","swipeUp","swipeDown","doubleTap","tap","singleTap","longTap"].forEach(function(t){e.fn[t]=function(n){return e(this).on(t,n)}})}}(jQuery); \ No newline at end of file diff --git a/lib/api/uikit/src/js/core/utility.min.js b/lib/api/uikit/src/js/core/utility.min.js index 5c06efd6..de5581d3 100755 --- a/lib/api/uikit/src/js/core/utility.min.js +++ b/lib/api/uikit/src/js/core/utility.min.js @@ -1,2 +1,2 @@ -/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ -!function(t){"use strict";var i=[];t.component("stackMargin",{defaults:{cls:"uk-margin-small-top",rowfirst:!1,observe:!1},boot:function(){t.ready(function(i){t.$("[data-uk-margin]",i).each(function(){var i=t.$(this);i.data("stackMargin")||t.stackMargin(i,t.Utils.options(i.attr("data-uk-margin")))})})},init:function(){var e=this;t.$win.on("resize orientationchange",function(){var i=function(){e.process()};return t.$(function(){i(),t.$win.on("load",i)}),t.Utils.debounce(i,20)}()),this.on("display.uk.check",function(){this.element.is(":visible")&&this.process()}.bind(this)),this.options.observe&&t.domObserve(this.element,function(){e.element.is(":visible")&&e.process()}),i.push(this)},process:function(){var i=this.element.children();if(t.Utils.stackMargin(i,this.options),!this.options.rowfirst||!i.length)return this;var e={},n=!1;return i.removeClass(this.options.rowfirst).each(function(i,s){s=t.$(this),"none"!=this.style.display&&(i=s.offset().left,((e[i]=e[i]||[])&&e[i]).push(this),n=n===!1?i:Math.min(n,i))}),t.$(e[n]).addClass(this.options.rowfirst),this}}),function(){var i=[],e=function(t){if(t.is(":visible")){var i=t.parent().width(),e=t.data("width"),n=i/e,s=Math.floor(n*t.data("height"));t.css({height:e>i?s:t.data("height")})}};t.component("responsiveElement",{defaults:{},boot:function(){t.ready(function(i){t.$("iframe.uk-responsive-width, [data-uk-responsive]",i).each(function(){var i,e=t.$(this);e.data("responsiveElement")||(i=t.responsiveElement(e,{}))})})},init:function(){var t=this.element;t.attr("width")&&t.attr("height")&&(t.data({width:t.attr("width"),height:t.attr("height")}).on("display.uk.check",function(){e(t)}),e(t),i.push(t))}}),t.$win.on("resize load",t.Utils.debounce(function(){i.forEach(function(t){e(t)})},15))}(),t.Utils.stackMargin=function(i,e){e=t.$.extend({cls:"uk-margin-small-top"},e),i=t.$(i).removeClass(e.cls);var n=!1;i.each(function(i,e,s,a){a=t.$(this),"none"!=a.css("display")&&(i=a.offset(),e=a.outerHeight(),s=i.top+e,a.data({ukMarginPos:s,ukMarginTop:i.top}),(n===!1||i.topn.top&&i.data("ukMarginPos")>n.pos&&i.addClass(e.cls)})},t.Utils.matchHeights=function(i,e){i=t.$(i).css("min-height",""),e=t.$.extend({row:!0},e);var n=function(i){if(!(i.length<2)){var e=0;i.each(function(){e=Math.max(e,t.$(this).outerHeight())}).each(function(){var i=t.$(this),n=e-("border-box"==i.css("box-sizing")?0:i.outerHeight()-i.height());i.css("min-height",n+"px")})}};e.row?(i.first().width(),setTimeout(function(){var e=!1,s=[];i.each(function(){var i=t.$(this),a=i.offset().top;a!=e&&s.length&&(n(t.$(s)),s=[],a=i.offset().top),s.push(i),e=a}),s.length&&n(t.$(s))},0)):n(i)},function(i){t.Utils.inlineSvg=function(e,n){t.$(e||'img[src$=".svg"]',n||document).each(function(){var e=t.$(this),n=e.attr("src");if(!i[n]){var s=t.$.Deferred();t.$.get(n,{nc:Math.random()},function(i){s.resolve(t.$(i).find("svg"))}),i[n]=s.promise()}i[n].then(function(i){var n=t.$(i).clone();e.attr("id")&&n.attr("id",e.attr("id")),e.attr("class")&&n.attr("class",e.attr("class")),e.attr("style")&&n.attr("style",e.attr("style")),e.attr("width")&&(n.attr("width",e.attr("width")),e.attr("height")||n.removeAttr("height")),e.attr("height")&&(n.attr("height",e.attr("height")),e.attr("width")||n.removeAttr("width")),e.replaceWith(n)})})},t.ready(function(i){t.Utils.inlineSvg("[data-uk-svg]",i)})}({}),t.Utils.getCssVar=function(t){var i,e=document.documentElement,n=e.appendChild(document.createElement("div"));n.classList.add("var-"+t);try{i=JSON.parse(i=getComputedStyle(n,":before").content.replace(/^["'](.*)["']$/,"$1"))}catch(s){i=void 0}return e.removeChild(n),i}}(UIkit); \ No newline at end of file +/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";var i=[];t.component("stackMargin",{defaults:{cls:"uk-margin-small-top",rowfirst:!1,observe:!1},boot:function(){t.ready(function(i){t.$("[data-uk-margin]",i).each(function(){var i=t.$(this);i.data("stackMargin")||t.stackMargin(i,t.Utils.options(i.attr("data-uk-margin")))})})},init:function(){var e=this;t.$win.on("resize orientationchange",function(){var i=function(){e.process()};return t.$(function(){i(),t.$win.on("load",i)}),t.Utils.debounce(i,20)}()),this.on("display.uk.check",function(){this.element.is(":visible")&&this.process()}.bind(this)),this.options.observe&&t.domObserve(this.element,function(){e.element.is(":visible")&&e.process()}),i.push(this)},process:function(){var i=this.element.children();if(t.Utils.stackMargin(i,this.options),!this.options.rowfirst||!i.length)return this;var e={},n=!1;return i.removeClass(this.options.rowfirst).each(function(i,s){s=t.$(this),"none"!=this.style.display&&(i=s.offset().left,((e[i]=e[i]||[])&&e[i]).push(this),n=n===!1?i:Math.min(n,i))}),t.$(e[n]).addClass(this.options.rowfirst),this}}),function(){var i=[],e=function(t){if(t.is(":visible")){var i=t.parent().width(),e=t.data("width"),n=i/e,s=Math.floor(n*t.data("height"));t.css({height:e>i?s:t.data("height")})}};t.component("responsiveElement",{defaults:{},boot:function(){t.ready(function(i){t.$("iframe.uk-responsive-width, [data-uk-responsive]",i).each(function(){var i,e=t.$(this);e.data("responsiveElement")||(i=t.responsiveElement(e,{}))})})},init:function(){var t=this.element;t.attr("width")&&t.attr("height")&&(t.data({width:t.attr("width"),height:t.attr("height")}).on("display.uk.check",function(){e(t)}),e(t),i.push(t))}}),t.$win.on("resize load",t.Utils.debounce(function(){i.forEach(function(t){e(t)})},15))}(),t.Utils.stackMargin=function(i,e){e=t.$.extend({cls:"uk-margin-small-top"},e),i=t.$(i).removeClass(e.cls);var n=!1;i.each(function(i,e,s,a){a=t.$(this),"none"!=a.css("display")&&(i=a.offset(),e=a.outerHeight(),s=i.top+e,a.data({ukMarginPos:s,ukMarginTop:i.top}),(n===!1||i.topn.top&&i.data("ukMarginPos")>n.pos&&i.addClass(e.cls)})},t.Utils.matchHeights=function(i,e){i=t.$(i).css("min-height",""),e=t.$.extend({row:!0},e);var n=function(i){if(!(i.length<2)){var e=0;i.each(function(){e=Math.max(e,t.$(this).outerHeight())}).each(function(){var i=t.$(this),n=e-("border-box"==i.css("box-sizing")?0:i.outerHeight()-i.height());i.css("min-height",n+"px")})}};e.row?(i.first().width(),setTimeout(function(){var e=!1,s=[];i.each(function(){var i=t.$(this),a=i.offset().top;a!=e&&s.length&&(n(t.$(s)),s=[],a=i.offset().top),s.push(i),e=a}),s.length&&n(t.$(s))},0)):n(i)},function(i){t.Utils.inlineSvg=function(e,n){t.$(e||'img[src$=".svg"]',n||document).each(function(){var e=t.$(this),n=e.attr("src");if(!i[n]){var s=t.$.Deferred();t.$.get(n,{nc:Math.random()},function(i){s.resolve(t.$(i).find("svg"))}),i[n]=s.promise()}i[n].then(function(i){var n=t.$(i).clone();e.attr("id")&&n.attr("id",e.attr("id")),e.attr("class")&&n.attr("class",e.attr("class")),e.attr("style")&&n.attr("style",e.attr("style")),e.attr("width")&&(n.attr("width",e.attr("width")),e.attr("height")||n.removeAttr("height")),e.attr("height")&&(n.attr("height",e.attr("height")),e.attr("width")||n.removeAttr("width")),e.replaceWith(n)})})},t.ready(function(i){t.Utils.inlineSvg("[data-uk-svg]",i)})}({}),t.Utils.getCssVar=function(t){var i,e=document.documentElement,n=e.appendChild(document.createElement("div"));n.classList.add("var-"+t);try{i=JSON.parse(i=getComputedStyle(n,":before").content.replace(/^["'](.*)["']$/,"$1"))}catch(s){i=void 0}return e.removeChild(n),i}}(UIkit2); \ No newline at end of file diff --git a/lib/api/uikit/src/less/components/accordion.less b/lib/api/uikit/src/less/components/accordion.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/components/datepicker.less b/lib/api/uikit/src/less/components/datepicker.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/components/dotnav.less b/lib/api/uikit/src/less/components/dotnav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/components/form-advanced.less b/lib/api/uikit/src/less/components/form-advanced.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/components/form-file.less b/lib/api/uikit/src/less/components/form-file.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/components/form-password.less b/lib/api/uikit/src/less/components/form-password.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/components/form-select.less b/lib/api/uikit/src/less/components/form-select.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/components/htmleditor.less b/lib/api/uikit/src/less/components/htmleditor.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/components/notify.less b/lib/api/uikit/src/less/components/notify.less old mode 100644 new mode 100755 index 44a13067..991ba59c --- a/lib/api/uikit/src/less/components/notify.less +++ b/lib/api/uikit/src/less/components/notify.less @@ -136,7 +136,7 @@ .uk-notify-message:hover > .uk-close { visibility: visible; } -/* Modifier: `uk-alert-info` +/* Modifier: `uk-notify-message-primary` ========================================================================== */ .uk-notify-message-primary { @@ -146,7 +146,7 @@ } -/* Modifier: `uk-alert-success` +/* Modifier: `uk-notify-message-success` ========================================================================== */ .uk-notify-message-success { diff --git a/lib/api/uikit/src/less/components/placeholder.less b/lib/api/uikit/src/less/components/placeholder.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/components/progress.less b/lib/api/uikit/src/less/components/progress.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/components/slidenav.less b/lib/api/uikit/src/less/components/slidenav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/components/tooltip.less b/lib/api/uikit/src/less/components/tooltip.less old mode 100644 new mode 100755 index d162e37a..3e2b76fc --- a/lib/api/uikit/src/less/components/tooltip.less +++ b/lib/api/uikit/src/less/components/tooltip.less @@ -174,4 +174,4 @@ .hook-tooltip-misc; .hook-tooltip() {} -.hook-tooltip-misc() {} \ No newline at end of file +.hook-tooltip-misc() {} diff --git a/lib/api/uikit/src/less/components/upload.less b/lib/api/uikit/src/less/components/upload.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/alert.less b/lib/api/uikit/src/less/core/alert.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/animation.less b/lib/api/uikit/src/less/core/animation.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/article.less b/lib/api/uikit/src/less/core/article.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/badge.less b/lib/api/uikit/src/less/core/badge.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/breadcrumb.less b/lib/api/uikit/src/less/core/breadcrumb.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/button.less b/lib/api/uikit/src/less/core/button.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/close.less b/lib/api/uikit/src/less/core/close.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/column.less b/lib/api/uikit/src/less/core/column.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/comment.less b/lib/api/uikit/src/less/core/comment.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/cover.less b/lib/api/uikit/src/less/core/cover.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/description-list.less b/lib/api/uikit/src/less/core/description-list.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/dropdown.less b/lib/api/uikit/src/less/core/dropdown.less old mode 100644 new mode 100755 index e8042c02..008e15b5 --- a/lib/api/uikit/src/less/core/dropdown.less +++ b/lib/api/uikit/src/less/core/dropdown.less @@ -95,6 +95,9 @@ .hook-dropdown; } +/* Focus */ +.uk-dropdown:focus { outline: none; } + /* * 1. Show dropdown * 2. Set animation diff --git a/lib/api/uikit/src/less/core/flex.less b/lib/api/uikit/src/less/core/flex.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/icon.less b/lib/api/uikit/src/less/core/icon.less index 8f4ab723..89976a3e 100755 --- a/lib/api/uikit/src/less/core/icon.less +++ b/lib/api/uikit/src/less/core/icon.less @@ -916,6 +916,65 @@ .uk-icon-wpforms:before { content: "\f298"; } .uk-icon-yoast:before { content: "\f2b1"; } +// added 4.7.0 +.uk-icon-adress-book:before { content: "\f2b9"; } +.uk-icon-adress-book-o:before { content: "\f2ba"; } +.uk-icon-adress-card:before { content: "\f2bb"; } +.uk-icon-adress-card-o:before { content: "\f2bc"; } +.uk-icon-bandcamp:before { content: "\f2d5"; } +.uk-icon-bath:before { content: "\f2cd"; } +.uk-icon-bathub:before { content: "\f2cd"; } +.uk-icon-drivers-license:before { content: "\f2c2"; } +.uk-icon-drivers-license-o:before { content: "\f2c3"; } +.uk-icon-eercast:before { content: "\f2da"; } +.uk-icon-envelope-open:before { content: "\f2b6"; } +.uk-icon-envelope-open-o:before { content: "\f2b7"; } +.uk-icon-etsy:before { content: "\f2d7"; } +.uk-icon-free-code-camp:before { content: "\f2c5"; } +.uk-icon-grav:before { content: "\f2d6"; } +.uk-icon-handshake-o:before { content: "\f2b5"; } +.uk-icon-id-badge:before { content: "\f2c1"; } +.uk-icon-id-card:before { content: "\f2c2"; } +.uk-icon-id-card-o:before { content: "\f2c3"; } +.uk-icon-imdb:before { content: "\f2d8"; } +.uk-icon-linode:before { content: "\f2b8"; } +.uk-icon-meetup:before { content: "\f2e0"; } +.uk-icon-microchip:before { content: "\f2db"; } +.uk-icon-podcast:before { content: "\f2ce"; } +.uk-icon-quora:before { content: "\f2c4"; } +.uk-icon-ravelry:before { content: "\f2d9"; } +.uk-icon-s15:before { content: "\f2cd"; } +.uk-icon-shower:before { content: "\f2cc"; } +.uk-icon-snowflake-o:before { content: "\f2dc"; } +.uk-icon-superpowers:before { content: "\f2dd"; } +.uk-icon-telegram:before { content: "\f2c6"; } +.uk-icon-thermometer:before { content: "\f2c7"; } +.uk-icon-thermometer-0:before { content: "\f2cb"; } +.uk-icon-thermometer-1:before { content: "\f2ca"; } +.uk-icon-thermometer-2:before { content: "\f2c9"; } +.uk-icon-thermometer-3:before { content: "\f2c8"; } +.uk-icon-thermometer-4:before { content: "\f2c7"; } +.uk-icon-thermometer-empty:before { content: "\f2cb"; } +.uk-icon-thermometer-full:before { content: "\f2c7"; } +.uk-icon-thermometer-half:before { content: "\f2c9"; } +.uk-icon-thermometer-quarter:before { content: "\f2ca"; } +.uk-icon-thermometer-three-quarters:before { content: "\f2c8"; } +.uk-icon-times-rectangle:before { content: "\f2d3"; } +.uk-icon-times-rectangle-o:before { content: "\f2d4"; } +.uk-icon-user-circle:before { content: "\f2bd"; } +.uk-icon-user-circle-o:before { content: "\f2be"; } +.uk-icon-user-o:before { content: "\f2c0"; } +.uk-icon-vcard:before { content: "\f2bb"; } +.uk-icon-vcard-o:before { content: "\f2bc"; } +.uk-icon-widow-close:before { content: "\f2d3"; } +.uk-icon-widow-close-o:before { content: "\f2d4"; } +.uk-icon-window-maximize:before { content: "\f2d0"; } +.uk-icon-window-minimize:before { content: "\f2d1"; } +.uk-icon-window-restore:before { content: "\f2d2"; } +.uk-icon-wpexplorer:before { content: "\f2de"; } + + + // Hooks // ======================================================================== diff --git a/lib/api/uikit/src/less/core/list.less b/lib/api/uikit/src/less/core/list.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/nav.less b/lib/api/uikit/src/less/core/nav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/navbar.less b/lib/api/uikit/src/less/core/navbar.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/pagination.less b/lib/api/uikit/src/less/core/pagination.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/subnav.less b/lib/api/uikit/src/less/core/subnav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/switcher.less b/lib/api/uikit/src/less/core/switcher.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/tab.less b/lib/api/uikit/src/less/core/tab.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/table.less b/lib/api/uikit/src/less/core/table.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/thumbnail.less b/lib/api/uikit/src/less/core/thumbnail.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/thumbnav.less b/lib/api/uikit/src/less/core/thumbnav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/less/core/variables.less b/lib/api/uikit/src/less/core/variables.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/accordion.less b/lib/api/uikit/src/themes/almost-flat/accordion.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/alert.less b/lib/api/uikit/src/themes/almost-flat/alert.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/article.less b/lib/api/uikit/src/themes/almost-flat/article.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/autocomplete.less b/lib/api/uikit/src/themes/almost-flat/autocomplete.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/badge.less b/lib/api/uikit/src/themes/almost-flat/badge.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/block.less b/lib/api/uikit/src/themes/almost-flat/block.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/breadcrumb.less b/lib/api/uikit/src/themes/almost-flat/breadcrumb.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/close.less b/lib/api/uikit/src/themes/almost-flat/close.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/column.less b/lib/api/uikit/src/themes/almost-flat/column.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/comment.less b/lib/api/uikit/src/themes/almost-flat/comment.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/customizer.json b/lib/api/uikit/src/themes/almost-flat/customizer.json old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/datepicker.less b/lib/api/uikit/src/themes/almost-flat/datepicker.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/description-list.less b/lib/api/uikit/src/themes/almost-flat/description-list.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/dotnav.less b/lib/api/uikit/src/themes/almost-flat/dotnav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/dropdown.less b/lib/api/uikit/src/themes/almost-flat/dropdown.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/form-advanced.less b/lib/api/uikit/src/themes/almost-flat/form-advanced.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/form-password.less b/lib/api/uikit/src/themes/almost-flat/form-password.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/form.less b/lib/api/uikit/src/themes/almost-flat/form.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/htmleditor.less b/lib/api/uikit/src/themes/almost-flat/htmleditor.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/icon.less b/lib/api/uikit/src/themes/almost-flat/icon.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/list.less b/lib/api/uikit/src/themes/almost-flat/list.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/modal.less b/lib/api/uikit/src/themes/almost-flat/modal.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/nav.less b/lib/api/uikit/src/themes/almost-flat/nav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/navbar.less b/lib/api/uikit/src/themes/almost-flat/navbar.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/nestable.less b/lib/api/uikit/src/themes/almost-flat/nestable.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/notify.less b/lib/api/uikit/src/themes/almost-flat/notify.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/offcanvas.less b/lib/api/uikit/src/themes/almost-flat/offcanvas.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/overlay.less b/lib/api/uikit/src/themes/almost-flat/overlay.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/pagination.less b/lib/api/uikit/src/themes/almost-flat/pagination.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/panel.less b/lib/api/uikit/src/themes/almost-flat/panel.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/placeholder.less b/lib/api/uikit/src/themes/almost-flat/placeholder.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/progress.less b/lib/api/uikit/src/themes/almost-flat/progress.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/search.less b/lib/api/uikit/src/themes/almost-flat/search.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/slidenav.less b/lib/api/uikit/src/themes/almost-flat/slidenav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/sortable.less b/lib/api/uikit/src/themes/almost-flat/sortable.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/sticky.less b/lib/api/uikit/src/themes/almost-flat/sticky.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/subnav.less b/lib/api/uikit/src/themes/almost-flat/subnav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/tab.less b/lib/api/uikit/src/themes/almost-flat/tab.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/table.less b/lib/api/uikit/src/themes/almost-flat/table.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/text.less b/lib/api/uikit/src/themes/almost-flat/text.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/thumbnail.less b/lib/api/uikit/src/themes/almost-flat/thumbnail.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/thumbnav.less b/lib/api/uikit/src/themes/almost-flat/thumbnav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/tooltip.less b/lib/api/uikit/src/themes/almost-flat/tooltip.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/uikit.less b/lib/api/uikit/src/themes/almost-flat/uikit.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/almost-flat/utility.less b/lib/api/uikit/src/themes/almost-flat/utility.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/accordion.less b/lib/api/uikit/src/themes/default/accordion.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/alert.less b/lib/api/uikit/src/themes/default/alert.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/article.less b/lib/api/uikit/src/themes/default/article.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/autocomplete.less b/lib/api/uikit/src/themes/default/autocomplete.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/badge.less b/lib/api/uikit/src/themes/default/badge.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/block.less b/lib/api/uikit/src/themes/default/block.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/breadcrumb.less b/lib/api/uikit/src/themes/default/breadcrumb.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/button.less b/lib/api/uikit/src/themes/default/button.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/close.less b/lib/api/uikit/src/themes/default/close.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/column.less b/lib/api/uikit/src/themes/default/column.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/comment.less b/lib/api/uikit/src/themes/default/comment.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/customizer.json b/lib/api/uikit/src/themes/default/customizer.json old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/datepicker.less b/lib/api/uikit/src/themes/default/datepicker.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/description-list.less b/lib/api/uikit/src/themes/default/description-list.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/dotnav.less b/lib/api/uikit/src/themes/default/dotnav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/dropdown.less b/lib/api/uikit/src/themes/default/dropdown.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/form-advanced.less b/lib/api/uikit/src/themes/default/form-advanced.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/form-password.less b/lib/api/uikit/src/themes/default/form-password.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/form.less b/lib/api/uikit/src/themes/default/form.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/htmleditor.less b/lib/api/uikit/src/themes/default/htmleditor.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/icon.less b/lib/api/uikit/src/themes/default/icon.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/list.less b/lib/api/uikit/src/themes/default/list.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/modal.less b/lib/api/uikit/src/themes/default/modal.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/nav.less b/lib/api/uikit/src/themes/default/nav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/navbar.less b/lib/api/uikit/src/themes/default/navbar.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/nestable.less b/lib/api/uikit/src/themes/default/nestable.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/notify.less b/lib/api/uikit/src/themes/default/notify.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/offcanvas.less b/lib/api/uikit/src/themes/default/offcanvas.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/overlay.less b/lib/api/uikit/src/themes/default/overlay.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/pagination.less b/lib/api/uikit/src/themes/default/pagination.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/panel.less b/lib/api/uikit/src/themes/default/panel.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/placeholder.less b/lib/api/uikit/src/themes/default/placeholder.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/progress.less b/lib/api/uikit/src/themes/default/progress.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/search.less b/lib/api/uikit/src/themes/default/search.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/slidenav.less b/lib/api/uikit/src/themes/default/slidenav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/sortable.less b/lib/api/uikit/src/themes/default/sortable.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/sticky.less b/lib/api/uikit/src/themes/default/sticky.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/subnav.less b/lib/api/uikit/src/themes/default/subnav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/tab.less b/lib/api/uikit/src/themes/default/tab.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/table.less b/lib/api/uikit/src/themes/default/table.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/text.less b/lib/api/uikit/src/themes/default/text.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/thumbnail.less b/lib/api/uikit/src/themes/default/thumbnail.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/thumbnav.less b/lib/api/uikit/src/themes/default/thumbnav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/tooltip.less b/lib/api/uikit/src/themes/default/tooltip.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/uikit.less b/lib/api/uikit/src/themes/default/uikit.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/default/utility.less b/lib/api/uikit/src/themes/default/utility.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/accordion.less b/lib/api/uikit/src/themes/gradient/accordion.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/alert.less b/lib/api/uikit/src/themes/gradient/alert.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/article.less b/lib/api/uikit/src/themes/gradient/article.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/autocomplete.less b/lib/api/uikit/src/themes/gradient/autocomplete.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/badge.less b/lib/api/uikit/src/themes/gradient/badge.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/block.less b/lib/api/uikit/src/themes/gradient/block.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/breadcrumb.less b/lib/api/uikit/src/themes/gradient/breadcrumb.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/button.less b/lib/api/uikit/src/themes/gradient/button.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/close.less b/lib/api/uikit/src/themes/gradient/close.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/column.less b/lib/api/uikit/src/themes/gradient/column.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/comment.less b/lib/api/uikit/src/themes/gradient/comment.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/customizer.json b/lib/api/uikit/src/themes/gradient/customizer.json old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/datepicker.less b/lib/api/uikit/src/themes/gradient/datepicker.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/description-list.less b/lib/api/uikit/src/themes/gradient/description-list.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/dotnav.less b/lib/api/uikit/src/themes/gradient/dotnav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/dropdown.less b/lib/api/uikit/src/themes/gradient/dropdown.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/form-advanced.less b/lib/api/uikit/src/themes/gradient/form-advanced.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/form-password.less b/lib/api/uikit/src/themes/gradient/form-password.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/form.less b/lib/api/uikit/src/themes/gradient/form.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/htmleditor.less b/lib/api/uikit/src/themes/gradient/htmleditor.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/icon.less b/lib/api/uikit/src/themes/gradient/icon.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/list.less b/lib/api/uikit/src/themes/gradient/list.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/modal.less b/lib/api/uikit/src/themes/gradient/modal.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/nav.less b/lib/api/uikit/src/themes/gradient/nav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/navbar.less b/lib/api/uikit/src/themes/gradient/navbar.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/nestable.less b/lib/api/uikit/src/themes/gradient/nestable.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/notify.less b/lib/api/uikit/src/themes/gradient/notify.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/offcanvas.less b/lib/api/uikit/src/themes/gradient/offcanvas.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/overlay.less b/lib/api/uikit/src/themes/gradient/overlay.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/pagination.less b/lib/api/uikit/src/themes/gradient/pagination.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/panel.less b/lib/api/uikit/src/themes/gradient/panel.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/placeholder.less b/lib/api/uikit/src/themes/gradient/placeholder.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/progress.less b/lib/api/uikit/src/themes/gradient/progress.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/search.less b/lib/api/uikit/src/themes/gradient/search.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/slidenav.less b/lib/api/uikit/src/themes/gradient/slidenav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/sortable.less b/lib/api/uikit/src/themes/gradient/sortable.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/sticky.less b/lib/api/uikit/src/themes/gradient/sticky.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/subnav.less b/lib/api/uikit/src/themes/gradient/subnav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/tab.less b/lib/api/uikit/src/themes/gradient/tab.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/table.less b/lib/api/uikit/src/themes/gradient/table.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/text.less b/lib/api/uikit/src/themes/gradient/text.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/thumbnail.less b/lib/api/uikit/src/themes/gradient/thumbnail.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/thumbnav.less b/lib/api/uikit/src/themes/gradient/thumbnav.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/tooltip.less b/lib/api/uikit/src/themes/gradient/tooltip.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/uikit.less b/lib/api/uikit/src/themes/gradient/uikit.less old mode 100644 new mode 100755 diff --git a/lib/api/uikit/src/themes/gradient/utility.less b/lib/api/uikit/src/themes/gradient/utility.less old mode 100644 new mode 100755 diff --git a/lib/api/utilities/deprecated.php b/lib/api/utilities/deprecated.php index f763ed77..2319efd6 100644 --- a/lib/api/utilities/deprecated.php +++ b/lib/api/utilities/deprecated.php @@ -2,7 +2,7 @@ /** * Deprecated utility functions. * - * @package API\Utilities + * @package Beans\Framework\API\Utilities */ /** @@ -19,9 +19,50 @@ * @return string The sanitized attributes. */ function beans_sanatize_attributes( $attributes ) { - _deprecated_function( __FUNCTION__, '1.3.1', 'beans_esc_attributes()' ); return beans_esc_attributes( $attributes ); +} + +/** + * Deprecated. Count recursive array. + * + * This function is unused in Beans. + * + * @since 1.0.0 + * @deprecated 1.5.0 + * + * @param string $array The array. + * @param int|bool $depth Optional. Depth until which the entries should be counted. + * @param bool $count_parent Optional. Whether the parent should be counted or not. + * + * @return int Number of entries found. + */ +function beans_count_recursive( $array, $depth = false, $count_parent = true ) { + _deprecated_function( __FUNCTION__, '1.5.0', 'beans_count_recursive()' ); + + if ( ! is_array( $array ) ) { + return 0; + } + + if ( 1 === $depth ) { + return count( $array ); + } + + if ( ! is_numeric( $depth ) ) { + return count( $array, COUNT_RECURSIVE ); + } + + $count = $count_parent ? count( $array ) : 0; + + foreach ( $array as $_array ) { + + if ( is_array( $_array ) ) { + $count += beans_count_recursive( $_array, $depth - 1, $count_parent ); + } else { + $count ++; + } + } + return $count; } diff --git a/lib/api/utilities/functions.php b/lib/api/utilities/functions.php index a4d51400..3a1644ea 100644 --- a/lib/api/utilities/functions.php +++ b/lib/api/utilities/functions.php @@ -5,7 +5,9 @@ * Since these functions are used throughout the Beans framework and are therefore required, they are * loaded automatically when the Beans framework is included. * - * @package API\Utilities + * @package Beans\Framework\API\Utilities + * + * @since 1.5.0 */ /** @@ -15,8 +17,8 @@ * * @since 1.0.0 * - * @param callback $callback The callback to be called. - * @param mixed $var Additional parameters to be passed to the callback. + * @param Callable $callback The callback to be called. + * @param mixed $args,... Optional. Additional parameters to be passed to the callback. * * @return string The callback content. */ @@ -30,10 +32,9 @@ function beans_render_function( $callback ) { ob_start(); - call_user_func_array( $callback, array_slice( $args, 1 ) ); + call_user_func_array( $callback, array_slice( $args, 1 ) ); return ob_get_clean(); - } /** @@ -43,7 +44,7 @@ function beans_render_function( $callback ) { * * @since 1.0.0 * - * @param callback $callback The callback to be called. + * @param Callable $callback The callback to be called. * @param array $params Optional. The parameters to be passed to the callback, as an indexed array. * * @return string The callback content. @@ -56,10 +57,9 @@ function beans_render_function_array( $callback, $params = array() ) { ob_start(); - call_user_func_array( $callback, $params ); + call_user_func_array( $callback, $params ); return ob_get_clean(); - } /** @@ -69,7 +69,7 @@ function beans_render_function_array( $callback, $params = array() ) { * * @param string $dir_path Path to directory to remove. * - * @return bool Will always return true. + * @return bool Returns true if the directory was removed; else, return false. */ function beans_remove_dir( $dir_path ) { @@ -77,27 +77,100 @@ function beans_remove_dir( $dir_path ) { return false; } - $items = scandir( $dir_path ); - unset( $items[0], $items[1] ); - - foreach ( $items as $needle => $item ) { - + foreach ( beans_scandir( $dir_path ) as $needle => $item ) { $path = $dir_path . '/' . $item; - if ( 'dir' === filetype( $dir_path . '/' . $item ) ) { + if ( is_dir( $path ) ) { beans_remove_dir( $path ); } else { - @unlink( $path ); + @unlink( $path ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. } + } + + return @rmdir( $dir_path ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. +} + +/** + * List files and directories inside of the specified path. + * + * @since 1.5.0 + * + * @param string $dir_path Path to the directory to scan. + * + * @return array|bool Returns false upon error. + */ +function beans_scandir( $dir_path ) { + $items = @scandir( $dir_path ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + + if ( ! $items ) { + return false; + } + + // Get rid of dot files when present. + if ( '.' === $items[0] ) { + unset( $items[0], $items[1] ); + } + + return $items; +} - unset( $items[ $needle ] ); +/** + * Check if the given string ends with the given substring(s). + * + * When passing an array of needles, the first needle match returns `true`. Therefore, only one word in the array + * needs to match. + * + * @since 1.5.0 + * + * @param string $haystack The given string to check. + * @param string|array $needles The substring(s) to check for at the end of the given string. + * + * @return bool + */ +function beans_str_ends_with( $haystack, $needles ) { + $haystack = (string) $haystack; + foreach ( (array) $needles as $needle ) { + $substring = mb_substr( $haystack, -mb_strlen( $needle ) ); + + if ( $substring === (string) $needle ) { + return true; + } } - @rmdir( $dir_path ); + return false; +} + +/** + * Check if the given string starts with the given substring(s). + * + * When passing an array of needles, the first needle match returns `true`. Therefore, only one word in the array + * needs to match. + * + * @since 1.5.0 + * + * @param string $haystack The given string to check. + * @param string|array $needles The substring(s) to check for at the beginning of the given string. + * + * @return bool + */ +function beans_str_starts_with( $haystack, $needles ) { + $haystack = (string) $haystack; + + foreach ( (array) $needles as $needle ) { + + if ( '' === $needle ) { + continue; + } + + $substring = mb_substr( $haystack, 0, mb_strlen( $needle ) ); - return true; + if ( $substring === (string) $needle ) { + return true; + } + } + return false; } /** @@ -105,18 +178,18 @@ function beans_remove_dir( $dir_path ) { * * This function must only be used with internal paths. * - * @since 1.0.0 + * @since 1.5.0 * - * @param string $path Path to be converted. Accepts absolute and relative internal paths. + * @param string $path Path to be converted. Accepts absolute and relative internal paths. + * @param bool $force_rebuild Optional. Forces the rebuild of the root url and path. * * @return string Url. */ -function beans_path_to_url( $path ) { - - static $root, $host; +function beans_path_to_url( $path, $force_rebuild = false ) { + static $root_path, $root_url; // Stop here if it is already a url or data format. - if ( true == preg_match( '#^(http|https|\/\/|data)#', $path ) ) { + if ( _beans_is_uri( $path ) ) { return $path; } @@ -124,43 +197,46 @@ function beans_path_to_url( $path ) { $path = wp_normalize_path( $path ); // Set root and host if it isn't cached. - if ( ! $root ) { + if ( ! $root_path || true === $force_rebuild ) { // Standardize backslashes set host. - $root = wp_normalize_path( untrailingslashit( ABSPATH ) ); - $host = untrailingslashit( site_url() ); + $root_path = wp_normalize_path( untrailingslashit( ABSPATH ) ); + $root_url = untrailingslashit( site_url() ); // Remove subfolder if necessary. - if ( '' !== ( $subfolder = parse_url( $host, PHP_URL_PATH ) ) ) { + $subfolder = parse_url( $root_url, PHP_URL_PATH ); - $root = preg_replace( '#' . untrailingslashit( preg_quote( $subfolder ) ) . '$#', '', $root ); - $host = preg_replace( '#' . untrailingslashit( preg_quote( $subfolder ) ) . '$#', '', $host ); + if ( $subfolder && '/' !== $subfolder ) { + $pattern = '#' . untrailingslashit( preg_quote( $subfolder ) ) . '$#'; + $root_path = preg_replace( $pattern, '', $root_path ); + $root_url = preg_replace( $pattern, '', $root_url ); + } - // Add the blog path for multsites. - if ( ! is_main_site() && ( $blogdetails = get_blog_details( get_current_blog_id() ) ) ) { - if ( ! ( defined( 'WP_SITEURL' ) ) || ( defined( 'WP_SITEURL' ) && WP_SITEURL == site_url() ) ) { - $host = untrailingslashit( $host ) . $blogdetails->path; - } + // If it's a multisite and not the main site, then add the site's path. + if ( ! is_main_site() ) { + $blogdetails = get_blog_details( get_current_blog_id() ); + + if ( $blogdetails && ( ! defined( 'WP_SITEURL' ) || ( defined( 'WP_SITEURL' ) && WP_SITEURL === site_url() ) ) ) { + $root_url = untrailingslashit( $root_url ) . $blogdetails->path; } } - $explode = beans_get( 0, explode( '/' , trailingslashit( ltrim( $subfolder, '/' ) ) ) ); - // Maybe re-add tilde from host. - if ( false !== stripos( $explode, '~' ) ) { - $host = trailingslashit( $host ) . $explode; + $maybe_tilde = beans_get( 0, explode( '/', trailingslashit( ltrim( $subfolder, '/' ) ) ) ); + + if ( false !== stripos( $maybe_tilde, '~' ) ) { + $root_url = trailingslashit( $root_url ) . $maybe_tilde; } } // Remove root if necessary. - if ( false !== stripos( $path, $root ) ) { - $path = str_replace( $root, '', $path ); + if ( false !== stripos( $path, $root_path ) ) { + $path = str_replace( $root_path, '', $path ); } elseif ( false !== stripos( $path, beans_get( 'DOCUMENT_ROOT', $_SERVER ) ) ) { $path = str_replace( beans_get( 'DOCUMENT_ROOT', $_SERVER ), '', $path ); } - return trailingslashit( $host ) . ltrim( $path, '/' ); - + return trailingslashit( $root_url ) . ltrim( $path, '/' ); } /** @@ -168,85 +244,98 @@ function beans_path_to_url( $path ) { * * This function must only be used with internal urls. * - * @since 1.0.0 + * @since 1.5.0 * - * @param string $url Url to be converted. Accepts only internal urls. + * @param string $url Url to be converted. Accepts only internal urls. + * @param bool $force_rebuild Optional. Forces the rebuild of the root url and path. * * @return string Absolute path. */ -function beans_url_to_path( $url ) { +function beans_url_to_path( $url, $force_rebuild = false ) { + static $root_path, $blogdetails; + $site_url = site_url(); - static $root, $blogdetails; + if ( true === $force_rebuild ) { + $root_path = ''; + $blogdetails = ''; + } - // Stop here if it is not an internal url. - if ( false === stripos( $url, parse_url( site_url(), PHP_URL_HOST ) ) ) { - return beans_sanitize_path( $url ); + // Fix protocol. It isn't needed to set SSL as it is only used to parse the URL. + if ( ! parse_url( $url, PHP_URL_SCHEME ) ) { + $original_url = $url; + $url = 'http://' . ltrim( $url, '/' ); } - // Fix protocole. It isn't needed to set SSL as it is only used to parse the URL. - if ( preg_match( '#^(\/\/)#', $url ) ) { - $url = 'http:' . $url; + // It's not an internal URL. Bail out. + if ( false === stripos( parse_url( $url, PHP_URL_HOST ), parse_url( $site_url, PHP_URL_HOST ) ) ) { + return isset( $original_url ) ? $original_url : $url; } // Parse url and standardize backslashes. - $url = parse_url( $url, PHP_URL_PATH ); + $url = parse_url( $url, PHP_URL_PATH ); $path = wp_normalize_path( $url ); - $explode = beans_get( 0, explode( '/' , trailingslashit( ltrim( $path, '/' ) ) ) ); // Maybe remove tilde from path. - if ( false !== stripos( $explode, '~' ) ) { - $path = preg_replace( '#\~[^/]*\/#', '', $path ); + $trimmed_path = trailingslashit( ltrim( $path, '/' ) ); + $maybe_tilde = beans_get( 0, explode( '/', $trimmed_path ) ); + + if ( false !== stripos( $maybe_tilde, '~' ) ) { + $ends_with_slash = substr( $path, - 1 ) === '/'; + $path = preg_replace( '#\~[^/]*\/#', '', $trimmed_path ); + + if ( $path && ! $ends_with_slash ) { + $path = rtrim( $path, '/' ); + } } // Set root if it isn't cached yet. - if ( ! $root ) { - + if ( ! $root_path ) { // Standardize backslashes and remove windows drive for local installs. - $root = wp_normalize_path( untrailingslashit( ABSPATH ) ); - $set_root = true; - + $root_path = wp_normalize_path( untrailingslashit( ABSPATH ) ); + $set_root = true; } - // Remove subfolder if necessary. - if ( '' !== ( $subfolder = parse_url( site_url(), PHP_URL_PATH ) ) ) { + /* + * If the subfolder exists for the root URL, then strip it off of the root path. + * Why? We don't want a double subfolder in the final path. + */ + $subfolder = parse_url( $site_url, PHP_URL_PATH ); - // Set root if it isn't cached. - if ( isset( $set_root ) ) { + if ( isset( $set_root ) && $subfolder && '/' !== $subfolder ) { + $root_path = preg_replace( '#' . untrailingslashit( preg_quote( $subfolder ) ) . '$#', '', $root_path ); - // Remove subfolder. - $root = preg_replace( '#' . untrailingslashit( preg_quote( $subfolder ) ) . '$#', '', $root ); + // Add an extra step which is only used for extremely rare case. + if ( defined( 'WP_SITEURL' ) ) { + $subfolder = parse_url( WP_SITEURL, PHP_URL_PATH ); - // Add an extra step which is only used for extremely rare case. - if ( defined( 'WP_SITEURL' ) && '' !== ( $subfolder = parse_url( WP_SITEURL, PHP_URL_PATH ) ) ) { - $root = preg_replace( '#' . untrailingslashit( preg_quote( $subfolder ) ) . '$#', '', $root ); + if ( '' !== $subfolder ) { + $root_path = preg_replace( '#' . untrailingslashit( preg_quote( $subfolder ) ) . '$#', '', $root_path ); } } + } - // Remove the blog path for multsites. - if ( ! is_main_site() ) { - - // Set blogdetails if it isn't cached. - if ( ! $blogdetails ) { - $blogdetails = get_blog_details( get_current_blog_id() ); - } - - $path = preg_replace( '#^(\/?)' . trailingslashit( preg_quote( ltrim( $blogdetails->path, '/' ) ) ) . '#', '', $path ); + // Remove the blog path for multisites. + if ( ! is_main_site() ) { + // Set blogdetails if it isn't cached. + if ( ! $blogdetails ) { + $blogdetails = get_blog_details( get_current_blog_id() ); } + + $path = preg_replace( '#^(\/?)' . trailingslashit( preg_quote( ltrim( $blogdetails->path, '/' ) ) ) . '#', '', $path ); } // Remove Windows drive for local installs if the root isn't cached yet. if ( isset( $set_root ) ) { - $root = beans_sanitize_path( $root ); + $root_path = beans_sanitize_path( $root_path ); } // Add root of it doesn't exist. - if ( false === strpos( $path, $root ) ) { - $path = trailingslashit( $root ) . ltrim( $path, '/' ); + if ( false === strpos( $path, $root_path ) ) { + $path = trailingslashit( $root_path ) . ltrim( $path, '/' ); } return beans_sanitize_path( $path ); - } /** @@ -269,7 +358,6 @@ function beans_sanitize_path( $path ) { $path = preg_replace( '#^[A-Z]\:#i', '', $path ); return wp_normalize_path( $path ); - } /** @@ -278,15 +366,15 @@ function beans_sanitize_path( $path ) { * @since 1.0.0 * * @param string $needle Name of the searched key. - * @param string $haystack Optional. Associative array. If false, $_GET is set to be the $haystack. - * @param mixed $default Optional. Value returned if the searched key isn't found. + * @param mixed $haystack Optional. The target to search. If false, $_GET is set to be the $haystack. + * @param mixed $default Optional. Value to return if the needle isn't found. * - * @return string Value if found, $default otherwise. + * @return string Returns the value if found; else $default is returned. */ function beans_get( $needle, $haystack = false, $default = null ) { if ( false === $haystack ) { - $haystack = $_GET; + $haystack = $_GET; // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification -- The nonce verification check should be at the form processing level. } $haystack = (array) $haystack; @@ -296,7 +384,6 @@ function beans_get( $needle, $haystack = false, $default = null ) { } return $default; - } /** @@ -305,14 +392,12 @@ function beans_get( $needle, $haystack = false, $default = null ) { * @since 1.0.0 * * @param string $needle Name of the searched key. - * @param mixed $default Optional. Value returned if the searched key isn't found. + * @param mixed $default Optional. Value to return if the needle isn't found. * - * @return string Value if found, $default otherwise. + * @return string Returns the value if found; else $default is returned. */ function beans_post( $needle, $default = null ) { - - return beans_get( $needle, $_POST, $default ); - + return beans_get( $needle, $_POST, $default ); // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification -- The nonce verification check should be at the form processing level. } /** @@ -321,66 +406,24 @@ function beans_post( $needle, $default = null ) { * @since 1.0.0 * * @param string $needle Name of the searched key. - * @param mixed $default Optional. Value returned if the searched key isn't found. + * @param mixed $default Optional. Value to return if the needle isn't found. * - * @return string Value if found, $default otherwise. + * @return string Returns the value if found; else $default is returned. */ function beans_get_or_post( $needle, $default = null ) { + $get = beans_get( $needle ); - if ( $get = beans_get( $needle ) ) { + if ( $get ) { return $get; } - if ( $post = beans_post( $needle ) ) { + $post = beans_post( $needle ); + + if ( $post ) { return $post; } return $default; - -} - -/** - * Count recursive array. - * - * This function is able to count a recursive array. The depth can be defined as well as if the parent should be - * counted. For instance, if $depth is defined and $count_parent is set to false, only the level of the - * defined depth will be counted. - * - * @since 1.0.0 - * - * @param string $array The array. - * @param int|bool $depth Optional. Depth until which the entries should be counted. - * @param bool $count_parent Optional. Whether the parent should be counted or not. - * - * @return int Number of entries found. - */ -function beans_count_recursive( $array, $depth = false, $count_parent = true ) { - - if ( ! is_array( $array ) ) { - return 0; - } - - if ( 1 === $depth ) { - return count( $array ); - } - - if ( ! is_numeric( $depth ) ) { - return count( $array, COUNT_RECURSIVE ); - } - - $count = $count_parent ? count( $array ) : 0; - - foreach ( $array as $_array ) { - - if ( is_array( $_array ) ) { - $count += beans_count_recursive( $_array, $depth - 1, $count_parent ); - } else { - $count += 1; - } - } - - return $count; - } /** @@ -393,48 +436,48 @@ function beans_count_recursive( $array, $depth = false, $count_parent = true ) { * @param bool $strict If the third parameter strict is set to true, the beans_in_multi_array() * function will also check the types of the needle in the haystack. * - * @return bool True if needle is found in the array, false otherwise. + * @return bool Returns true if needle is found in the array; else, false is returned. */ function beans_in_multi_array( $needle, $haystack, $strict = false ) { - if ( in_array( $needle, $haystack, $strict ) ) { + if ( in_array( $needle, $haystack, $strict ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict -- The rule does not account for when we are passing a boolean within a variable as the 3rd argument. return true; } foreach ( (array) $haystack as $value ) { - if ( is_array( $value ) && beans_in_multi_array( $needle , $value ) ) { + + if ( is_array( $value ) && beans_in_multi_array( $needle, $value ) ) { return true; } } return false; - } /** * Checks if a key or index exists in a multi-dimensional array. * - * @since 1.0.0 + * @since 1.5.0 * - * @param string $needle The searched value. - * @param array $haystack The multi-dimensional array. + * @param string $needle The key to search for within the haystack. + * @param array $haystack The array to be searched. * - * @return bool True if needle is found in the array, False otherwise. + * @return bool Returns true if needle is found in the array; else, false is returned. */ -function beans_multi_array_key_exists( $needle, $haystack ) { +function beans_multi_array_key_exists( $needle, array $haystack ) { if ( array_key_exists( $needle, $haystack ) ) { return true; } foreach ( $haystack as $value ) { - if ( is_array( $value ) && beans_multi_array_key_exists( $needle , $value ) ) { + + if ( is_array( $value ) && beans_multi_array_key_exists( $needle, $value ) ) { return true; } } return false; - } /** @@ -444,10 +487,10 @@ function beans_multi_array_key_exists( $needle, $haystack ) { * * @since 1.0.0 * - * @param string $content Content containing the shortcode(s) delimited with curly brackets (e.g. {key}). + * @param string $content Content containing the shortcode(s) delimited with curly brackets (e.g. {key}). * Shortcode(s) correspond to the searched array key and will be replaced by the array * value if found. - * @param array $haystack The associative array used to replace shortcode(s). + * @param array $haystack The associative array used to replace shortcode(s). * * @return string Content with shortcodes filtered out. */ @@ -456,15 +499,12 @@ function beans_array_shortcodes( $content, $haystack ) { if ( preg_match_all( '#{(.*?)}#', $content, $matches ) ) { foreach ( $matches[1] as $needle ) { - $sub_keys = explode( '.', $needle ); - $value = false; + $value = false; foreach ( $sub_keys as $sub_key ) { - $search = $value ? $value : $haystack; - $value = beans_get( $sub_key, $search ); - + $value = beans_get( $sub_key, $search ); } if ( $value ) { @@ -474,7 +514,6 @@ function beans_array_shortcodes( $content, $haystack ) { } return $content; - } /** @@ -484,12 +523,13 @@ function beans_array_shortcodes( $content, $haystack ) { * * @since 1.0.0 * + * @global $menu + * * @param int $position The desired position. * - * @return bool Valid postition. + * @return bool Valid position. */ function beans_admin_menu_position( $position ) { - global $menu; if ( ! is_array( $position ) ) { @@ -501,7 +541,6 @@ function beans_admin_menu_position( $position ) { } return $position; - } /** @@ -520,7 +559,7 @@ function beans_esc_attributes( $attributes ) { * Filter attributes escaping methods. * * For all unspecified selectors, values are automatically escaped using - * {@link http://codex.wordpress.org/Function_Reference/esc_attr esc_attr()}. + * {@link https://codex.wordpress.org/Function_Reference/esc_attr esc_attr()}. * * @since 1.3.1 * @@ -537,46 +576,130 @@ function beans_esc_attributes( $attributes ) { foreach ( (array) $attributes as $attribute => $value ) { - if ( null !== $value ) { - - if ( $method = beans_get( $attribute, $methods ) ) { - $value = call_user_func( $method, $value ); - } else { - $value = esc_attr( $value ); - } + if ( null === $value ) { + continue; + } - $string .= $attribute . '="' . $value . '" '; + $method = beans_get( $attribute, $methods ); + if ( $method ) { + $value = call_user_func( $method, $value ); + } else { + $value = esc_attr( $value ); } + + $string .= $attribute . '="' . $value . '" '; } return trim( $string ); - } -if ( ! function_exists( 'array_replace_recursive' ) ) { +/** + * Maybe joins two arrays together without requiring an additional variable assignment upon return. + * + * @since 1.5.0 + * + * @param array $array1 Initial array (passed by reference), which becomes the final array. + * @param array $array2 The array to merge into $array1. + * + * @return void Nothing is returned. + */ +function beans_join_arrays( array &$array1, array $array2 ) { - /** - * PHP 5.2 fallback. - * - * @ignore - */ - function array_replace_recursive( $base, $replacements ) { + // Bail out if the 2nd array is empty, as there's no work to do. + if ( empty( $array2 ) ) { + return; + } - if ( ! is_array( $base ) || ! is_array( $replacements ) ) { - return $base; - } + // If the 1st array is empty, set it to the 2nd array. Then bail out as we're done. + if ( empty( $array1 ) ) { + $array1 = $array2; - foreach ( $replacements as $key => $value ) { + return; + } - if ( is_array( $value ) && is_array( $from_base = beans_get( $key, $base ) ) ) { - $base[ $key ] = array_replace_recursive( $from_base, $value ); - } else { - $base[ $key ] = $value; - } - } + // Both arrays have elements. Let's join them together. + $array1 = array_merge( $array1, $array2 ); +} - return $base; +/** + * Remove duplicate values from the given array and re-indexes to start at element 0. Keys are not preserved. + * + * @since 1.5.0 + * + * @param array $array The given array to filter. + * + * @return array + */ +function beans_array_unique( array $array ) { + return array_values( array_unique( $array ) ); +} + +/** + * Join the given arrays and clean the merged array by removing duplicates and empties. By default, the clean joined + * array is re-indexed; however, setting the third parameter to `false` will preserve the keys. + * + * @since 1.5.0 + * + * @param array $array1 Initial array to join. + * @param array $array2 The array to merge into $array1. + * @param bool $reindex When true, re-indexes the clean array; else, preserves the keys. + * + * @return array + */ +function beans_join_arrays_clean( array $array1, array $array2, $reindex = true ) { + beans_join_arrays( $array1, $array2 ); + if ( empty( $array1 ) ) { + return $array1; } + + $array1 = array_filter( array_unique( $array1 ) ); + + return $reindex ? array_values( $array1 ) : $array1; +} + +/** + * Checks if the given input is a URL or data URI. It checks that the given input begins with: + * - http + * - https + * - // + * - data + * + * @since 1.5.0 + * @ignore + * @access private + * + * @param string $maybe_uri The given input to check. + * + * @return bool + */ +function _beans_is_uri( $maybe_uri ) { + return ( 1 === preg_match( '#^(http|https|\/\/|data)#', $maybe_uri ) ); +} + +/** + * Checks if WP is doing ajax. + * + * @since 1.5.0 + * @ignore + * @access private + * + * @return bool + */ +function _beans_doing_ajax() { + return defined( 'DOING_AJAX' ) && DOING_AJAX; +} + +/** + * Checks if WP is doing an autosave. + * + * @since 1.5.0 + * @ignore + * @access private + * + * @return bool + */ +function _beans_doing_autosave() { + return defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE; } diff --git a/lib/api/utilities/polyfills.php b/lib/api/utilities/polyfills.php new file mode 100644 index 00000000..00d78dba --- /dev/null +++ b/lib/api/utilities/polyfills.php @@ -0,0 +1,53 @@ + $value ) { + $from_base = beans_get( $key, $array1 ); + + if ( is_array( $value ) && is_array( $from_base ) ) { + $array1[ $key ] = array_replace_recursive( $from_base, $value ); // phpcs:ignore PHPCompatibility.PHP.NewFunctions.array_replace_recursiveFound -- This polyfill provides the construct for PHP 5.2. + } else { + $array1[ $key ] = $value; + } + } + + return $array1; + } +} diff --git a/lib/api/widget/deprecated.php b/lib/api/widget/deprecated.php new file mode 100644 index 00000000..e12bf7bd --- /dev/null +++ b/lib/api/widget/deprecated.php @@ -0,0 +1,25 @@ + '', - 'after_widget' => '', - 'before_title' => '', - 'after_title' => '', - ) ); + $wp_registered_sidebars[ $id ] = array_merge( // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Valid use case. + $wp_registered_sidebars[ $id ], + array( + 'before_widget' => '', + 'after_widget' => '', + 'before_title' => '', + 'after_title' => '', + ) + ); // Start building widget area global before dynamic_sidebar is called. $_beans_widget_area = $wp_registered_sidebars[ $id ]; @@ -363,30 +365,32 @@ function _beans_setup_widget_area( $id ) { // Prepare widgets count. preg_match_all( '##', $sidebar, $counter ); - // Continue building widget area global with the splited sidebar elements. - $_beans_widget_area['widgets_count'] = count( $counter[0] ); + // Continue building widget area global with the split sidebar elements. + $_beans_widget_area['widgets_count'] = count( $counter[0] ); $_beans_widget_area['current_widget'] = 0; // Only add widgets if exists. - if ( 3 == count( $splited_sidebar ) ) { - + if ( 3 === count( $splited_sidebar ) ) { $_beans_widget_area['before_widgets'] = $splited_sidebar[0]; - $_beans_widget_area['widgets'] = _beans_setup_widgets( $splited_sidebar[1] ); - $_beans_widget_area['after_widgets'] = $splited_sidebar[2]; - + $_beans_widget_area['widgets'] = _beans_setup_widgets( $splited_sidebar[1] ); + $_beans_widget_area['after_widgets'] = $splited_sidebar[2]; } return true; - } /** * Setup widget area global widgets data. * + * @since 1.0.0 * @ignore + * @access private + * + * @param string $widget_area_content Content of the widget area. + * + * @return array */ function _beans_setup_widgets( $widget_area_content ) { - global $wp_registered_widgets, $_beans_widget_area; $_beans_widgets = array(); @@ -401,7 +405,9 @@ function _beans_setup_widgets( $widget_area_content ) { $id = $matches[1]; // Stop here if the widget can't be found. - if ( ! $data = beans_get( $id, $wp_registered_widgets ) ) { + $data = beans_get( $id, $wp_registered_widgets ); + + if ( ! $data ) { continue; } @@ -410,8 +416,8 @@ function _beans_setup_widgets( $widget_area_content ) { // Set defaults. $widget['options'] = array(); - $widget['type'] = null; - $widget['title'] = ''; + $widget['type'] = null; + $widget['title'] = ''; // Add total count. $widget['count'] = $_beans_widget_area['widgets_count']; @@ -421,15 +427,15 @@ function _beans_setup_widgets( $widget_area_content ) { $widget[ $var ] = isset( $data[ $var ] ) ? $data[ $var ] : null; } - // Add type and options - if ( isset( $data['callback'] ) && is_array( $data['callback'] ) && ( $object = current( $data['callback'] ) ) ) { + // Add type and options. + $object = current( $data['callback'] ); - if ( is_a( $object, 'WP_Widget' ) ) { + if ( isset( $data['callback'] ) && is_array( $data['callback'] ) && $object ) { + if ( is_a( $object, 'WP_Widget' ) ) { $widget['type'] = $object->id_base; if ( isset( $data['params'][0]['number'] ) ) { - $number = $data['params'][0]['number']; $params = get_option( $object->option_name ); @@ -442,10 +448,8 @@ function _beans_setup_widgets( $widget_area_content ) { } } } - } elseif ( 'nav_menu-0' == $id ) { // Widget type fallback. - + } elseif ( 'nav_menu-0' === $id ) { // Widget type fallback. $widget['type'] = 'nav_menu'; - } // Widget fallback name. @@ -454,7 +458,7 @@ function _beans_setup_widgets( $widget_area_content ) { } // Extract and add title. - if ( preg_match( '#(.*)#s' , $content, $matches ) ) { + if ( preg_match( '#(.*)#s', $content, $matches ) ) { $widget['title'] = strip_tags( $matches[1] ); } @@ -472,71 +476,80 @@ function _beans_setup_widgets( $widget_area_content ) { 'badge' => $_beans_widget_area['beans_show_widget_badge'], 'badge_content' => $_beans_widget_area['beans_widget_badge_content'], ) ); - } return $_beans_widgets; - } /** * Setup widget global data. * + * @since 1.0.0 * @ignore + * @access private + * + * @param string $id Widget ID. + * + * @return void */ -function _beans_setup_widget( $id ) { - +function _beans_prepare_widget_data( $id ) { global $_beans_widget; - - $widgets = beans_get_widget_area( 'widgets' ); - + $widgets = beans_get_widget_area( 'widgets' ); $_beans_widget = $widgets[ $id ]; - } /** * Reset widget area global data. * + * @since 1.0.0 * @ignore + * @access private + * + * @return void */ function _beans_reset_widget_area() { - unset( $GLOBALS['_beans_widget_area'] ); - } /** * Reset widget global data. * + * @since 1.0.0 * @ignore + * @access private + * + * @return void */ function _beans_reset_widget() { - unset( $GLOBALS['_beans_widget'] ); - } /** - * Build widget area subfilters. + * Build widget area sub-filters. * + * @since 1.0.0 * @ignore + * @access private + * + * @return string */ function _beans_widget_area_subfilters() { - global $_beans_widget_area; // Add sidebar id. return '[_' . $_beans_widget_area['id'] . ']'; - } /** - * Build widget subfilters. + * Build widget sub-filters. * + * @since 1.0.0 * @ignore + * @access private + * + * @return string */ function _beans_widget_subfilters() { - global $_beans_widget_area, $_beans_widget; $subfilters = array( @@ -546,17 +559,23 @@ function _beans_widget_subfilters() { ); return '[_' . implode( '][_', $subfilters ) . ']'; - } add_action( 'the_widget', '_beans_force_the_widget', 10, 3 ); /** * Force atypical widget added using the_widget() to have a correctly registered id. * + * @since 1.0.0 * @ignore + * @access private + * + * @param string $widget The widget's PHP class name (see class-wp-widget.php). + * @param array $instance Optional. The widget's instance settings. Default empty array. + * @param array $args Array of arguments to configure the display of the widget. + * + * @return void */ function _beans_force_the_widget( $widget, $instance, $args ) { - global $wp_widget_factory; $widget_obj = $wp_widget_factory->widgets[ $widget ]; @@ -565,11 +584,10 @@ function _beans_force_the_widget( $widget, $instance, $args ) { return; } - // Stop here if the widget correctly contain an id. - if ( false !== stripos( $widget_obj->id, beans_get( 'before_widget', $args ) ) ) { + // Stop here if the widget correctly contains an id. + if ( false !== stripos( beans_get( 'before_widget', $args ), $widget_obj->id ) ) { return; } - printf( '', $widget_obj->id ); - + printf( '', esc_attr( $widget_obj->id ) ); } diff --git a/lib/api/wp-customize/class-beans-wp-customize-control.php b/lib/api/wp-customize/class-beans-wp-customize-control.php new file mode 100644 index 00000000..13bcb2b7 --- /dev/null +++ b/lib/api/wp-customize/class-beans-wp-customize-control.php @@ -0,0 +1,52 @@ +beans_field = end( $args ); + } + + /** + * Field content. + * + * @since 1.0.0 + * + * @return void + */ + public function render_content() { + beans_field( $this->beans_field ); + } +} diff --git a/lib/api/wp-customize/class-beans-wp-customize.php b/lib/api/wp-customize/class-beans-wp-customize.php new file mode 100644 index 00000000..2fa9a15d --- /dev/null +++ b/lib/api/wp-customize/class-beans-wp-customize.php @@ -0,0 +1,214 @@ + __( 'Undefined', 'tm-beans' ), + 'priority' => 30, + 'description' => false, + ); + + $this->section = $section; + $this->args = array_merge( $defaults, $args ); + + // Add section, settings and controls. + $this->add(); + + beans_add_attribute( 'beans_field_label', 'class', 'customize-control-title' ); + } + + /** + * Add section, settings and controls. + * + * @since 1.0.0 + * @ignore + * + * @return void + */ + private function add() { + global $wp_customize; + $this->add_section( $wp_customize ); + $fields = beans_get_fields( 'wp_customize', $this->section ); + + foreach ( $fields as $field ) { + $this->add_group_setting( $wp_customize, $field ); + $this->add_setting( $wp_customize, $field ); + $this->add_control( $wp_customize, $field ); + } + } + + /** + * Add Section. + * + * @since 1.0.0 + * @ignore + * + * @param WP_Customize_Manager $wp_customize WP Customizer Manager object. + * + * @return void + */ + private function add_section( WP_Customize_Manager $wp_customize ) { + + if ( $wp_customize->get_section( $this->section ) ) { + return; + } + + $wp_customize->add_section( + $this->section, + array( + 'title' => $this->args['title'], + 'priority' => $this->args['priority'], + 'description' => $this->args['description'], + ) + ); + } + + /** + * Add Group setting. + * + * @since 1.5.0 + * @ignore + * + * @param WP_Customize_Manager $wp_customize WP Customizer Manager object. + * @param array $field Metabox settings. + * + * @return void + */ + private function add_group_setting( WP_Customize_Manager $wp_customize, array $field ) { + + if ( 'group' !== $field['type'] ) { + return; + } + + foreach ( $field['fields'] as $_field ) { + $this->add_setting( $wp_customize, $_field ); + } + } + + /** + * Add setting. + * + * @since 1.0.0 + * @ignore + * + * @param WP_Customize_Manager $wp_customize WP Customizer Manager object. + * @param array $field { + * Array of Metabox settings. + * + * @type string $db_type Optional. Defines how the setting will be saved. Defaults to 'theme_mod'. + * @type string $capability Optional. Defines the user's permission level needed to see the setting. Defaults to 'edit_theme_options'. + * @type string $transport Optional. Defines how the live preview is updated. Defaults to 'refresh'. + * } + * + * @return void + */ + private function add_setting( WP_Customize_Manager $wp_customize, array $field ) { + $defaults = array( + 'db_type' => 'theme_mod', + 'capability' => 'edit_theme_options', + 'transport' => 'refresh', + ); + + $field = array_merge( $defaults, $field ); + + $wp_customize->add_setting( + $field['name'], + array( + 'default' => beans_get( 'default', $field ), + 'type' => $field['db_type'], + 'capability' => $field['capability'], + 'transport' => $field['transport'], + 'sanitize_callback' => array( $this, 'sanitize' ), + ) + ); + } + + /** + * Add Control. + * + * @since 1.0.0 + * @ignore + * + * @param WP_Customize_Manager $wp_customize WP Customizer Manager object. + * @param array $field { + * Metabox settings. + * + * @type string $type Field type or WP_Customize control class. + * @type string $name Name of the control. + * @type string $label Label of the control. + * } + * + * @return void + */ + private function add_control( WP_Customize_Manager $wp_customize, array $field ) { + require_once 'class-beans-wp-customize-control.php'; + + $class = '_Beans_WP_Customize_Control'; + + if ( $field['type'] !== $class && class_exists( $field['type'] ) ) { + $class = $field['type']; + } + + $wp_customize->add_control( + new $class( + $wp_customize, + $field['name'], + array( + 'label' => $field['label'], + 'section' => $this->section, + ), + $field + ) + ); + } + + /** + * Sanitize the value. + * + * @since 1.0.0 + * + * @param mixed $value Value. + * + * @return mixed + */ + public function sanitize( $value ) { + return $value; + } +} diff --git a/lib/api/wp-customize/class.php b/lib/api/wp-customize/class.php deleted file mode 100644 index fb40913f..00000000 --- a/lib/api/wp-customize/class.php +++ /dev/null @@ -1,185 +0,0 @@ - __( 'Undefined', 'tm-beans' ), - 'priority' => 30, - 'description' => false, - ); - - $this->section = $section; - $this->args = array_merge( $defaults, $args ); - - // Add section, settings and controls. - $this->add(); - - beans_add_attribute( 'beans_field_label', 'class', 'customize-control-title' ); - - } - - /** - * Add section, settings and controls. - */ - private function add() { - - global $wp_customize; - - $this->add_section( $wp_customize ); - - $fields = beans_get_fields( 'wp_customize', $this->section ); - - foreach ( $fields as $field ) { - - if ( 'group' === $field['type'] ) { - foreach ( $field['fields'] as $_field ) { - $this->add_setting( $wp_customize, $_field ); - } - } - - $this->add_setting( $wp_customize, $field ); - $this->add_control( $wp_customize, $field ); - - } - - } - - /** - * Add Section. - */ - private function add_section( $wp_customize ) { - - if ( $wp_customize->get_section( $this->section ) ) { - return; - } - - $wp_customize->add_section( - $this->section, - array( - 'title' => $this->args['title'], - 'priority' => $this->args['priority'], - 'description' => $this->args['description'], - ) - ); - - } - - /** - * Add setting. - */ - private function add_setting( $wp_customize, $field ) { - - $defaults = array( - 'db_type' => 'theme_mod', - 'capability' => 'edit_theme_options', - 'transport' => 'refresh', - ); - - $field = array_merge( $defaults, $field ); - - $wp_customize->add_setting( - $field['name'], - array( - 'default' => beans_get( 'default', $field ), - 'type' => $field['db_type'], - 'capability' => $field['capability'], - 'transport' => $field['transport'], - 'sanitize_callback' => array( $this, 'sanitize' ), - ) - ); - - } - - /** - * Add Control. - */ - private function add_control( $wp_customize, $field ) { - - $class = '_Beans_WP_Customize_Control'; - - if ( $field['type'] !== $class && class_exists( $field['type'] ) ) { - $class = $field['type']; - } - - $wp_customize->add_control( - new $class( - $wp_customize, - $field['name'], - array( - 'label' => $field['label'], - 'section' => $this->section, - ), - $field - ) - ); - - } - - /** - * Sanatize value. - */ - public function sanitize( $value ) { - - return $value; - - } -} - -if ( class_exists( 'WP_Customize_Control' ) ) : - - /** - * Render Beans fields content for WP Customize. - * - * @ignore - */ - class _Beans_WP_Customize_Control extends WP_Customize_Control { - - /** - * Field data. - * - * @type string - */ - private $beans_field; - - /** - * Constructor. - */ - public function __construct() { - - $args = func_get_args(); - - call_user_func_array( array( 'parent', '__construct' ), $args ); - - $this->beans_field = end( $args ); - - } - - /** - * Field content. - */ - public function render_content() { - - beans_field( $this->beans_field ); - - } - } - -endif; diff --git a/lib/api/wp-customize/functions.php b/lib/api/wp-customize/functions.php index caa126eb..173c497f 100644 --- a/lib/api/wp-customize/functions.php +++ b/lib/api/wp-customize/functions.php @@ -1,50 +1,52 @@ - * as a delimiter. Default false. + * as a delimiter. Default false. * @type array $attributes An array of attributes to add to the field. The array key defines the - * attribute name and the array value defines the attribute value. Default array. + * attribute name and the array value defines the attribute value. Default array. * @type mixed $default The default field value. Default false. - * @type array $fields Must only be used for 'group' field type. The array arguments are similary to the - * {@see beans_register_fields()} $fields arguments. - * @type bool $db_group Must only be used for 'group' field type. It defines whether the group of fields - * registered should be saved as a group in the database or as individual - * entries. Default false. + * @type array $fields Must only be used for the 'group' field type. The array arguments are similar to the + * {@see beans_register_fields()} $fields arguments. + * @type bool $db_group Must only be used for the 'group' field type. It defines whether the group of fields + * registered should be saved as a group in the database or as individual + * entries. Default false. * } * @param string $section The WP customize section to which the fields should be added. Add a unique id * to create a new section. * @param array $args { * Optional. Array of arguments used to register the fields. * - * @type string $title The visible name of a controller section. - * @type int $priority This controls the order in which this section appears - * in the Theme Customizer sidebar. Default 30. - * @type string $description This optional argument can add additional descriptive - * text to the section. Default false. + * @type string $title The visible name of a controller section. + * @type int $priority This controls the order in which this section appears + * in the Theme Customizer sidebar. Default 30. + * @type string $description This optional argument can add additional descriptive + * text to the section. Default false. * } * - * @return bool True on success, false on failure. + * @return _Beans_WP_Customize|bool False on failure. */ function beans_register_wp_customize_options( array $fields, $section, $args = array() ) { @@ -61,7 +63,7 @@ function beans_register_wp_customize_options( array $fields, $section, $args = a // Stop here if the current page isn't concerned. if ( ! is_customize_preview() ) { - return; + return false; } // Stop here if the field can't be registered. @@ -70,8 +72,7 @@ function beans_register_wp_customize_options( array $fields, $section, $args = a } // Load the class only if this function is called to prevent unnecessary memory usage. - require_once( BEANS_API_PATH . 'wp-customize/class.php' ); - - new _Beans_WP_Customize( $section, $args ); + require_once BEANS_API_PATH . 'wp-customize/class-beans-wp-customize.php'; + return new _Beans_WP_Customize( $section, $args ); } diff --git a/lib/assets/assets.php b/lib/assets/assets.php index 5dba1bb5..e0cd9704 100644 --- a/lib/assets/assets.php +++ b/lib/assets/assets.php @@ -2,19 +2,22 @@ /** * Add Beans assets. * - * @package Assets + * @package Beans\Framework\Assets + * + * @since 1.0.0 */ beans_add_smart_action( 'beans_uikit_enqueue_scripts', 'beans_enqueue_uikit_components', 5 ); /** - * Enqueue UIKit components and Beans style. + * Enqueue UIkit components and Beans style. * * Beans style is enqueued with the UIKit components to have access to UIKit LESS variables. * * @since 1.0.0 + * + * @return void */ function beans_enqueue_uikit_components() { - $core = array( 'base', 'block', @@ -42,20 +45,19 @@ function beans_enqueue_uikit_components() { beans_uikit_enqueue_components( $core, 'core', false ); - // Include uikit default theme. + // Include UIkit default theme. beans_uikit_enqueue_theme( 'default' ); - // Enqueue uikit overwrite theme folder. + // Enqueue UIkit overwrite theme folder. beans_uikit_enqueue_theme( 'beans', BEANS_ASSETS_PATH . 'less/uikit-overwrite' ); - // Add the theme style as a uikit fragment to have access to all the variables. + // Add the theme style as a UIkit fragment to have access to all the variables. beans_compiler_add_fragment( 'uikit', BEANS_ASSETS_PATH . 'less/style.less', 'less' ); - // Add the theme default style as a uikit fragment only if the theme supports it. + // Add the theme default style as a UIkit fragment only if the theme supports it. if ( current_theme_supports( 'beans-default-styling' ) ) { beans_compiler_add_fragment( 'uikit', BEANS_ASSETS_PATH . 'less/default.less', 'less' ); } - } beans_add_smart_action( 'wp_enqueue_scripts', 'beans_enqueue_assets', 5 ); @@ -63,13 +65,14 @@ function beans_enqueue_uikit_components() { * Enqueue Beans assets. * * @since 1.0.0 + * + * @return void */ function beans_enqueue_assets() { if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } - } beans_add_smart_action( 'after_setup_theme', 'beans_add_editor_assets' ); @@ -77,9 +80,9 @@ function beans_enqueue_assets() { * Add Beans editor assets. * * @since 1.2.5 + * + * @return void */ function beans_add_editor_assets() { - add_editor_style( BEANS_ASSETS_URL . 'css/editor' . BEANS_MIN_CSS . '.css' ); - } diff --git a/lib/assets/less/style.less b/lib/assets/less/style.less index 74c4232a..a22a7d8c 100644 --- a/lib/assets/less/style.less +++ b/lib/assets/less/style.less @@ -80,6 +80,14 @@ article header > .tm-article-image:first-child { margin-top: @grid-gutter-vertical; } +.comment-respond fieldset { + margin-bottom: @grid-gutter-vertical; +} + +.comment-form-cookies-consent input { + margin-right: 15px; +} + .comment-reply-title > small a { margin-top: -3px; } @@ -142,18 +150,26 @@ article header > .tm-article-image:first-child { margin: 3px 0; } -.screen-reader-text { - clip: rect(1px, 1px, 1px, 1px); - position: absolute !important; - height: 1px; - width: 1px; - overflow: hidden; +/* Hide visually but not from screen readers */ +.screen-reader-text, +.screen-reader-text span { + border: 0; + clip: rect(1px, 1px, 1px, 1px); + -webkit-clip-path: inset(50%); + clip-path: inset(50%); + height: 1px; + margin: -1px; + overflow: hidden; + padding: 0; + position: absolute; + width: 1px; + word-wrap: normal !important; /* many screen reader and browser combinations announce broken words as they would appear visually */ } .screen-reader-text:focus { background-color: #f1f1f1; border-radius: 3px; - box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6); + box-shadow: 0 0 2px 2px rgba(12, 4, 4, 0.6); clip: auto !important; color: #21759b; display: block; @@ -169,3 +185,51 @@ article header > .tm-article-image:first-child { width: auto; z-index: 100000; } + +.screen-reader-shortcut { + position: absolute; + top: -1000em; +} + +.screen-reader-shortcut:focus { + left: 6px; + top: 15px; + height: auto; + width: auto; + display: block; + font-size: 14px; + font-weight: 600; + padding: 15px 23px 14px; + background: #f1f1f1; + color: #0073aa; + z-index: 100000; + line-height: normal; + box-shadow: 0 0 2px 2px rgba(0,0,0,.6); + text-decoration: none; + outline: none; +} + +.beans-skip-links { + background-color: #f1f1f1; + box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.2); + color: #21759b; + display: block; + left: -9999em; + outline: none; + text-decoration: none; + text-transform: none; + top: -9999em; + margin: 0; +} + +.beans-skip-links li { + height: 0; + width: 0; + list-style: none; +} + +/* Display outline on focus */ +:focus { + color: #333; + outline: 1px #ccc solid; +} diff --git a/lib/init.php b/lib/init.php index 0c4111b2..80aa26bc 100644 --- a/lib/init.php +++ b/lib/init.php @@ -2,19 +2,23 @@ /** * Prepare and initialize the Beans framework. * - * @package Initialize + * @package Beans\Framework + * + * @since 1.0.0 */ add_action( 'beans_init', 'beans_define_constants', -1 ); /** * Define constants. * + * @since 1.0.0 * @ignore + * + * @return void */ function beans_define_constants() { - // Define version. - define( 'BEANS_VERSION', '1.4.1' ); + define( 'BEANS_VERSION', '1.5.0' ); // Define paths. if ( ! defined( 'BEANS_THEME_PATH' ) ) { @@ -49,18 +53,19 @@ function beans_define_constants() { define( 'BEANS_ADMIN_URL', BEANS_URL . 'admin/' ); define( 'BEANS_ADMIN_ASSETS_URL', BEANS_ADMIN_URL . 'assets/' ); define( 'BEANS_ADMIN_JS_URL', BEANS_ADMIN_ASSETS_URL . 'js/' ); - } add_action( 'beans_init', 'beans_load_dependencies', -1 ); /** * Load dependencies. * + * @since 1.0.0 * @ignore + * + * @return void */ function beans_load_dependencies() { - - require_once( BEANS_API_PATH . 'init.php' ); + require_once BEANS_API_PATH . 'init.php'; // Load the necessary Beans components. beans_load_api_components( array( @@ -87,17 +92,18 @@ function beans_load_dependencies() { * @since 1.0.0 */ do_action( 'beans_after_load_api' ); - } add_action( 'beans_init', 'beans_add_theme_support' ); /** * Add theme support. * + * @since 1.0.0 * @ignore + * + * @return void */ function beans_add_theme_support() { - add_theme_support( 'title-tag' ); add_theme_support( 'custom-background' ); add_theme_support( 'menus' ); @@ -115,52 +121,52 @@ function beans_add_theme_support() { // Beans specific. add_theme_support( 'offcanvas-menu' ); add_theme_support( 'beans-default-styling' ); - } add_action( 'beans_init', 'beans_includes' ); /** * Include framework files. * + * @since 1.0.0 * @ignore + * + * @return void */ function beans_includes() { // Include admin. if ( is_admin() ) { - - require_once( BEANS_ADMIN_PATH . 'options.php' ); - require_once( BEANS_ADMIN_PATH . 'updater.php' ); - + require_once BEANS_ADMIN_PATH . 'options.php'; + require_once BEANS_ADMIN_PATH . 'updater.php'; } // Include assets. - require_once( BEANS_ASSETS_PATH . 'assets.php' ); + require_once BEANS_ASSETS_PATH . 'assets.php'; // Include customizer. if ( is_customize_preview() ) { - require_once( BEANS_ADMIN_PATH . 'wp-customize.php' ); + require_once BEANS_ADMIN_PATH . 'wp-customize.php'; } // Include renderers. - require_once( BEANS_RENDER_PATH . 'template-parts.php' ); - require_once( BEANS_RENDER_PATH . 'fragments.php' ); - require_once( BEANS_RENDER_PATH . 'widget-area.php' ); - require_once( BEANS_RENDER_PATH . 'walker.php' ); - require_once( BEANS_RENDER_PATH . 'menu.php' ); - + require_once BEANS_RENDER_PATH . 'template-parts.php'; + require_once BEANS_RENDER_PATH . 'fragments.php'; + require_once BEANS_RENDER_PATH . 'widget-area.php'; + require_once BEANS_RENDER_PATH . 'walker.php'; + require_once BEANS_RENDER_PATH . 'menu.php'; } add_action( 'beans_init', 'beans_load_textdomain' ); /** * Load text domain. * + * @since 1.0.0 * @ignore + * + * @return void */ function beans_load_textdomain() { - load_theme_textdomain( 'tm-beans', BEANS_LANGUAGES_PATH ); - } /** diff --git a/lib/languages/tm-beans.pot b/lib/languages/tm-beans.pot index f63935b8..e1b09a10 100644 --- a/lib/languages/tm-beans.pot +++ b/lib/languages/tm-beans.pot @@ -2,16 +2,17 @@ msgid "" msgstr "" "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" -"Project-Id-Version: Beans\n" -"POT-Creation-Date: 2015-11-28 12:29+0200\n" -"PO-Revision-Date: 2015-11-28 12:29+0200\n" +"Project-Id-Version: Beans v.1.5.0\n" +"POT-Creation-Date: 2018-06-20 20:46-0500\n" +"PO-Revision-Date: 2018-06-20 08:10-0500\n" "Last-Translator: \n" -"Language-Team: \n" +"Language-Team: Beans Team\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 1.8.4\n" +"X-Generator: Poedit 2.0.8\n" "X-Poedit-Basepath: ../..\n" +"X-Poedit-Flags-xgettext: --add-comments=translators:\n" "X-Poedit-WPHeader: style.css\n" "X-Poedit-SourceCharset: UTF-8\n" "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;" @@ -19,394 +20,601 @@ msgstr "" "_nx_noop:3c,1,2;__ngettext_noop:1,2\n" "X-Poedit-SearchPath-0: .\n" "X-Poedit-SearchPathExcluded-0: *.js\n" +"X-Poedit-SearchPathExcluded-1: bin\n" +"X-Poedit-SearchPathExcluded-2: tests\n" +"X-Poedit-SearchPathExcluded-3: vendor\n" -#: lib/admin/options.php:27 +#: lib/admin/options.php:30 msgctxt "term meta" msgid "Layout" msgstr "" -#: lib/admin/options.php:58 +#: lib/admin/options.php:60 msgctxt "post meta" msgid "Layout" msgstr "" -#: lib/admin/options.php:65 +#: lib/admin/options.php:67 msgid "Post Options" msgstr "" -#: lib/admin/wp-customize.php:34 +#: lib/admin/wp-customize.php:37 msgid "Logo Image" msgstr "" -#: lib/admin/wp-customize.php:40 +#: lib/admin/wp-customize.php:42 msgid "Branding" msgstr "" -#: lib/admin/wp-customize.php:51 lib/admin/wp-customize.php:59 +#: lib/admin/wp-customize.php:52 lib/admin/wp-customize.php:63 msgid "Default Layout" msgstr "" -#: lib/admin/wp-customize.php:66 -msgid "Viewport Width" +#: lib/admin/wp-customize.php:72 +msgid "Viewport Width - for Previewing Only" msgstr "" -#: lib/admin/wp-customize.php:87 -msgid "Viewport Height" +#: lib/admin/wp-customize.php:73 +msgid "" +"Slide left or right to change the viewport width. Publishing will not change " +"the width of your website." +msgstr "" + +#: lib/admin/wp-customize.php:78 +msgid "Enable to change the viewport width." +msgstr "" + +#: lib/admin/wp-customize.php:95 +msgid "Viewport Height - for Previewing Only" +msgstr "" + +#: lib/admin/wp-customize.php:96 +msgid "" +"Slide left or right to change the viewport height. Publishing will not " +"change the height of your website." +msgstr "" + +#: lib/admin/wp-customize.php:101 +msgid "Enable to change the viewport height." msgstr "" -#: lib/admin/wp-customize.php:108 +#: lib/admin/wp-customize.php:122 msgid "Preview Tools" msgstr "" -#: lib/api/admin-menu.php:25 +#: lib/api/admin-menu.php:37 msgid "Settings" msgstr "" -#: lib/api/admin-menu.php:37 +#: lib/api/admin-menu.php:50 msgid "Beans Settings" msgstr "" -#: lib/api/admin-menu.php:37 +#: lib/api/admin-menu.php:50 msgid "Version " msgstr "" -#: lib/api/admin-menu.php:56 +#: lib/api/admin-menu.php:69 msgid "Enable development mode" msgstr "" -#: lib/api/admin-menu.php:58 +#: lib/api/admin-menu.php:70 +msgid "Select to activate development mode." +msgstr "" + +#: lib/api/admin-menu.php:72 msgid "This option should be enabled while your website is in development." msgstr "" -#: lib/api/admin-menu.php:63 +#: lib/api/admin-menu.php:81 msgid "Mode options" msgstr "" -#: lib/api/compiler/class-options.php:35 +#: lib/api/compiler/class-beans-compiler-options.php:56 +msgid "Compiler options" +msgstr "" + +#: lib/api/compiler/class-beans-compiler-options.php:165 +msgid "Styles are not compiled in development mode." +msgstr "" + +#: lib/api/compiler/class-beans-compiler-options.php:187 +msgid "Scripts are not compiled in development mode." +msgstr "" + +#: lib/api/compiler/class-beans-compiler.php:848 +msgid "Not cool, Beans cannot work its magic :(" +msgstr "" + +#: lib/api/compiler/class-beans-compiler.php:853 +msgid "" +"Your current install or file permission prevents Beans from working its " +"magic. Please get in touch with Beans support. We will gladly get you " +"started within 24 - 48 hours (working days)." +msgstr "" + +#: lib/api/compiler/class-beans-compiler.php:858 +msgid "Contact Beans Support" +msgstr "" + +#: lib/api/compiler/class-beans-compiler.php:863 +msgid "Send us an automatic report" +msgstr "" + +#: lib/api/compiler/class-beans-compiler.php:864 +msgid "" +"We respect your time and understand you might not be able to contact us." +msgstr "" + +#: lib/api/compiler/class-beans-compiler.php:898 +msgid "" +"Thanks for your contribution by reporting this issue. We hope to hear from " +"you again." +msgstr "" + +#: lib/api/compiler/config/fields.php:14 msgid "" "Clear CSS and Javascript cached files. New cached versions will be compiled " "on page load." msgstr "" -#: lib/api/compiler/class-options.php:45 +#: lib/api/compiler/config/fields.php:18 msgid "Compile all WordPress styles" msgstr "" -#: lib/api/compiler/class-options.php:48 +#: lib/api/compiler/config/fields.php:19 +msgid "Select to compile styles." +msgstr "" + +#: lib/api/compiler/config/fields.php:22 msgid "" "Compile and cache all the CSS files that have been enqueued to the WordPress " "head." msgstr "" -#: lib/api/compiler/class-options.php:58 +#: lib/api/compiler/config/fields.php:26 msgid "Compile all WordPress scripts" msgstr "" -#: lib/api/compiler/class-options.php:61 -msgid "" -"Compile and cache all the Javascript files that have been enqueued to the " -"WordPress head." +#: lib/api/compiler/config/fields.php:32 +msgid "Select to compile scripts." msgstr "" -#: lib/api/compiler/class-options.php:66 -msgid "Compiler options" +#: lib/api/compiler/config/fields.php:38 +msgid "Choose the level of compilation." msgstr "" -#: lib/api/compiler/class-options.php:94 -msgid "Cache flushed successfully!" +#: lib/api/compiler/config/fields.php:41 +msgid "Aggressive" msgstr "" -#: lib/api/compiler/class-options.php:107 -msgid "Flush assets cache" +#: lib/api/compiler/config/fields.php:42 +msgid "Standard" msgstr "" -#: lib/api/compiler/class-options.php:118 -msgid "Styles are not compiled in development mode." +#: lib/api/compiler/config/fields.php:46 +msgid "" +"Compile and cache all the JavaScript files that have been enqueued to the " +"WordPress head.
              JavaScript is outputted in the footer if the level is " +"set to Aggressive and might conflict with some third-party " +"plugins which are not following WordPress standards." msgstr "" -#: lib/api/compiler/class-options.php:128 -msgid "Scripts are not compiled in development mode." +#: lib/api/compiler/views/flush-button.php:12 +msgid "Flush assets cache" msgstr "" -#: lib/api/fields/types/field.php:61 -msgid "More..." +#: lib/api/compiler/views/flushed-notice.php:13 +msgid "Cache flushed successfully!" +msgstr "" + +#: lib/api/fields/types/checkbox.php:27 +msgid "Enable" msgstr "" -#: lib/api/fields/types/image.php:52 +#: lib/api/fields/types/image.php:43 msgid "Add Image" msgid_plural "Add Images" msgstr[0] "" msgstr[1] "" -#: lib/api/image/class-options.php:36 -msgid "Clear all edited images. New images will be created on page load." +#: lib/api/fields/types/image.php:127 +msgid "Sorry, no description was given for this image." +msgstr "" + +#: lib/api/fields/types/views/field-description.php:13 +msgid "More..." +msgstr "" + +#: lib/api/fields/types/views/image.php:48 +msgid "Manage Images" +msgstr "" + +#: lib/api/fields/types/views/image.php:50 +msgid "Edit Image" +msgstr "" + +#: lib/api/fields/types/views/image.php:51 +msgid "Delete Image" +msgstr "" + +#: lib/api/html/accessibility.php:22 +msgid "Skip to the primary navigation." +msgstr "" + +#: lib/api/html/accessibility.php:25 +msgid "Skip to the content." +msgstr "" + +#: lib/api/html/accessibility.php:30 +msgid "Skip to the primary sidebar." msgstr "" -#: lib/api/image/class-options.php:41 +#: lib/api/html/accessibility.php:34 +msgid "Skip to the secondary sidebar." +msgstr "" + +#: lib/api/image/class-beans-image-options.php:48 msgid "Images options" msgstr "" -#: lib/api/image/class-options.php:69 -msgid "Images flushed successfully!" +#: lib/api/image/config/fields.php:14 +msgid "Clear all edited images. New images will be created on page load." msgstr "" -#: lib/api/image/class-options.php:82 +#: lib/api/image/views/flush-button.php:12 msgid "Flush images" msgstr "" -#: lib/api/layout/functions.php:276 +#: lib/api/image/views/flushed-notice.php:13 +msgid "Images flushed successfully!" +msgstr "" + +#: lib/api/layout/functions.php:229 +msgid "Full-Width Content Layout" +msgstr "" + +#: lib/api/layout/functions.php:230 +msgid "Option for the Full-Width Content Layout." +msgstr "" + +#: lib/api/layout/functions.php:239 +msgid "Content and Primary Sidebar Layout" +msgstr "" + +#: lib/api/layout/functions.php:240 +msgid "Option for the Content and Primary Sidebar Layout." +msgstr "" + +#: lib/api/layout/functions.php:243 +msgid "Primary Sidebar and Content Layout" +msgstr "" + +#: lib/api/layout/functions.php:244 +msgid "Option for the Primary Sidebar and Content Layout." +msgstr "" + +#: lib/api/layout/functions.php:250 +msgid "Content, Primary Sidebar and Secondary Sidebar Layout" +msgstr "" + +#: lib/api/layout/functions.php:251 +msgid "Option for the Content, Primary Sidebar and Secondary Sidebar Layout." +msgstr "" + +#: lib/api/layout/functions.php:254 +msgid "Primary Sidebar, Secondary Sidebar and Content Layout" +msgstr "" + +#: lib/api/layout/functions.php:255 +msgid "Option for the Primary Sidebar, Secondary Sidebar and Content Layout." +msgstr "" + +#: lib/api/layout/functions.php:258 +msgid "Primary Sidebar, Content and Secondary Sidebar Layout" +msgstr "" + +#: lib/api/layout/functions.php:259 +msgid "Option for the Primary Sidebar, Content and Secondary Sidebar Layout." +msgstr "" + +#. translators: The (%s) placeholder is for the "Modify" hyperlink. +#: lib/api/layout/functions.php:282 #, php-format msgid "Use Default Layout (%s)" msgstr "" -#: lib/api/layout/functions.php:277 +#: lib/api/layout/functions.php:283 msgctxt "Default layout" msgid "Modify" msgstr "" -#: lib/api/options/class.php:39 lib/api/post-meta/class.php:32 -#: lib/api/wp-customize/class.php:25 +#: lib/api/options/class-beans-options.php:54 +#: lib/api/post-meta/class-beans-post-meta.php:43 +#: lib/api/wp-customize/class-beans-wp-customize.php:43 msgid "Undefined" msgstr "" -#: lib/api/options/class.php:196 -msgid "Settings saved successfully!" +#: lib/api/options/views/page.php:28 +msgid "Save" msgstr "" -#: lib/api/options/class.php:198 -msgid "Settings could not be saved, please try again." +#: lib/api/options/views/page.php:29 +msgid "Reset" msgstr "" -#: lib/api/options/class.php:210 +#: lib/api/options/views/reset-notice-error.php:15 +msgid "Settings could not be reset, please try again." +msgstr "" + +#: lib/api/options/views/reset-notice-success.php:15 msgid "Settings reset successfully!" msgstr "" -#: lib/api/options/class.php:212 -msgid "Settings could not be reset, please try again." +#: lib/api/options/views/save-notice-error.php:15 +msgid "Settings could not be saved, please try again." msgstr "" -#: lib/api/widget/functions.php:57 +#: lib/api/options/views/save-notice-success.php:15 +msgid "Settings saved successfully!" +msgstr "" + +#: lib/api/widget/functions.php:62 msgid "Hello" msgstr "" -#: lib/render/menu.php:23 +#: lib/render/menu.php:25 msgid "Navigation" msgstr "" -#: lib/render/menu.php:26 lib/templates/fragments/breadcrumb.php:25 +#: lib/render/menu.php:33 lib/templates/fragments/breadcrumb.php:30 msgid "Home" msgstr "" -#: lib/render/menu.php:46 +#: lib/render/menu.php:52 msgid "Primary Menu" msgstr "" -#: lib/render/widget-area.php:19 +#: lib/render/widget-area.php:21 msgid "Sidebar Primary" msgstr "" -#: lib/render/widget-area.php:24 +#: lib/render/widget-area.php:26 msgid "Sidebar Secondary" msgstr "" -#: lib/render/widget-area.php:30 +#: lib/render/widget-area.php:32 msgid "Off-Canvas Menu" msgstr "" -#: lib/templates/fragments/breadcrumb.php:83 +#: lib/templates/fragments/breadcrumb.php:80 msgid "Results:" msgstr "" -#: lib/templates/fragments/breadcrumb.php:92 +#: lib/templates/fragments/breadcrumb.php:83 msgid "Author Archives:" msgstr "" -#: lib/templates/fragments/breadcrumb.php:99 +#: lib/templates/fragments/breadcrumb.php:85 msgid "Tag Archives:" msgstr "" -#: lib/templates/fragments/breadcrumb.php:106 +#: lib/templates/fragments/breadcrumb.php:87 msgid "Archives:" msgstr "" -#: lib/templates/fragments/breadcrumb.php:113 +#: lib/templates/fragments/breadcrumb.php:89 msgid "404" msgstr "" -#: lib/templates/fragments/comments.php:20 +#. translators: Number of comments, one or many. +#: lib/templates/fragments/comments.php:25 #, php-format msgid "%s Comment" msgid_plural "%s Comments" msgstr[0] "" msgstr[1] "" -#: lib/templates/fragments/comments.php:92 +#: lib/templates/fragments/comments.php:98 msgid "Trackback" msgstr "" -#: lib/templates/fragments/comments.php:103 +#: lib/templates/fragments/comments.php:107 msgid "Pingback" msgstr "" -#: lib/templates/fragments/comments.php:115 +#: lib/templates/fragments/comments.php:116 msgid "Awaiting Moderation" msgstr "" -#: lib/templates/fragments/comments.php:127 +#: lib/templates/fragments/comments.php:125 msgid "Moderator" msgstr "" +#. translators: Date of the comment, time of the comment. #: lib/templates/fragments/comments.php:154 #, php-format msgctxt "1: date, 2: time" msgid "%1$s at %2$s" msgstr "" -#: lib/templates/fragments/comments.php:211 +#: lib/templates/fragments/comments.php:215 msgid "Edit" msgstr "" -#: lib/templates/fragments/comments.php:226 +#: lib/templates/fragments/comments.php:233 msgid "Link" msgstr "" -#: lib/templates/fragments/comments.php:248 +#: lib/templates/fragments/comments.php:253 msgid "No comment yet, add your voice below!" msgstr "" -#: lib/templates/fragments/comments.php:266 +#: lib/templates/fragments/comments.php:269 msgid "Comments are closed for this article!" msgstr "" -#: lib/templates/fragments/comments.php:301 -#: lib/templates/fragments/post.php:435 lib/templates/fragments/post.php:504 -msgid "Previous" +#: lib/templates/fragments/comments.php:295 +msgid "Comments Pagination Navigation" msgstr "" -#: lib/templates/fragments/comments.php:319 -#: lib/templates/fragments/post.php:446 lib/templates/fragments/post.php:590 -msgid "Next" +#: lib/templates/fragments/comments.php:322 +msgid "Previous Comments" msgstr "" -#: lib/templates/fragments/comments.php:361 +#: lib/templates/fragments/comments.php:343 +msgid "Next Comments " +msgstr "" + +#: lib/templates/fragments/comments.php:377 msgid "Add a Comment" msgstr "" -#: lib/templates/fragments/comments.php:368 +#: lib/templates/fragments/comments.php:390 msgid "Post Comment" msgstr "" -#: lib/templates/fragments/comments.php:435 -msgid "Name" +#: lib/templates/fragments/comments.php:458 +msgid "Comment *" +msgstr "" + +#: lib/templates/fragments/comments.php:533 +msgid "Name *" msgstr "" -#: lib/templates/fragments/comments.php:463 +#. translators: Whether or not submitting an email address is required. +#: lib/templates/fragments/comments.php:568 #, php-format msgid "Email %s" msgstr "" -#: lib/templates/fragments/comments.php:492 +#: lib/templates/fragments/comments.php:602 msgid "Website" msgstr "" -#: lib/templates/fragments/comments.php:542 -msgid "Comment *" -msgstr "" - -#: lib/templates/fragments/deprecated.php:57 +#. translators: Page number. +#: lib/templates/fragments/deprecated.php:59 #, php-format msgid "Page %s" msgstr "" -#: lib/templates/fragments/footer.php:24 +#. translators: Footer credits. Date followed by the name of the website. +#: lib/templates/fragments/footer.php:27 #, php-format msgid "© %1$s - %2$s. All rights reserved." msgstr "" -#: lib/templates/fragments/footer.php:45 +#. translators: Link to the Beans website. +#: lib/templates/fragments/footer.php:54 #, php-format msgid "%1$s theme for WordPress." msgstr "" -#: lib/templates/fragments/menu.php:67 +#: lib/templates/fragments/menu.php:31 +msgid "Primary Navigation Menu" +msgstr "" + +#: lib/templates/fragments/menu.php:96 msgid "Menu" msgstr "" -#: lib/templates/fragments/menu.php:115 +#: lib/templates/fragments/menu.php:121 +msgid "Off-Canvas Primary Navigation Menu" +msgstr "" + +#: lib/templates/fragments/menu.php:158 msgid "Whoops, your site does not have a menu!" msgstr "" -#: lib/templates/fragments/post-shortcodes.php:17 +#: lib/templates/fragments/post-shortcodes.php:19 msgid "Posted on " msgstr "" -#: lib/templates/fragments/post-shortcodes.php:40 +#: lib/templates/fragments/post-shortcodes.php:44 msgid "By " msgstr "" -#: lib/templates/fragments/post-shortcodes.php:73 +#: lib/templates/fragments/post-shortcodes.php:90 msgid "Leave a comment" msgstr "" -#: lib/templates/fragments/post-shortcodes.php:75 +#: lib/templates/fragments/post-shortcodes.php:92 msgid "1 comment" msgstr "" -#: lib/templates/fragments/post-shortcodes.php:77 +#. translators: Number of comments. Plural. +#: lib/templates/fragments/post-shortcodes.php:97 #, php-format msgid "%s comments" msgstr "" -#: lib/templates/fragments/post-shortcodes.php:104 +#: lib/templates/fragments/post-shortcodes.php:124 msgid "Tagged with: " msgstr "" -#: lib/templates/fragments/post-shortcodes.php:124 +#: lib/templates/fragments/post-shortcodes.php:142 msgid "Filed under: " msgstr "" -#: lib/templates/fragments/post.php:67 +#: lib/templates/fragments/post.php:74 msgid "Search results for: " msgstr "" -#: lib/templates/fragments/post.php:254 +#: lib/templates/fragments/post.php:339 msgid "Continue reading" msgstr "" -#: lib/templates/fragments/post.php:278 +#: lib/templates/fragments/post.php:367 msgid "Pages:" msgstr "" -#: lib/templates/fragments/post.php:624 +#: lib/templates/fragments/post.php:543 +msgid "Pagination Navigation" +msgstr "" + +#: lib/templates/fragments/post.php:561 lib/templates/fragments/post.php:655 +msgid "Previous Page" +msgstr "" + +#: lib/templates/fragments/post.php:573 lib/templates/fragments/post.php:744 +msgid "Next Page" +msgstr "" + +#: lib/templates/fragments/post.php:619 +msgid "Posts Pagination Navigation" +msgstr "" + +#: lib/templates/fragments/post.php:782 msgid "Whoops, no result found!" msgstr "" -#: lib/templates/fragments/post.php:636 +#: lib/templates/fragments/post.php:794 msgid "It looks like nothing was found at this location. Maybe try a search?" msgstr "" -#: lib/templates/fragments/post.php:670 +#: lib/templates/fragments/post.php:824 msgid "This post is protected. To view it, enter the password below!" msgstr "" -#: lib/templates/fragments/post.php:684 +#: lib/templates/fragments/post.php:845 msgid "Password" msgstr "" -#: lib/templates/fragments/post.php:692 +#: lib/templates/fragments/post.php:857 msgid "Submit" msgstr "" -#: lib/templates/fragments/searchform.php:30 +#: lib/templates/fragments/searchform.php:37 msgid "Search" msgstr "" -#: lib/templates/fragments/widget.php:83 +#. translators: Name of the widget area. +#: lib/templates/fragments/widget.php:89 #, php-format msgid "%s does not have any widget assigned!" msgstr "" -#: lib/templates/fragments/widget.php:103 +#: lib/templates/fragments/widget.php:107 msgid "Read feed" msgstr "" @@ -416,11 +624,14 @@ msgid "Beans" msgstr "" #. Theme URI of the plugin/theme -#. Author URI of the plugin/theme -msgid "http://www.getbeans.io" +msgid "https://www.getbeans.io/themes/beans/" msgstr "" #. Description of the plugin/theme msgid "" "The most innovative theme for WordPress. The real magic is under the hood." msgstr "" + +#. Author URI of the plugin/theme +msgid "https://www.getbeans.io" +msgstr "" diff --git a/lib/render/fragments.php b/lib/render/fragments.php index 70f98c7d..b4024fff 100644 --- a/lib/render/fragments.php +++ b/lib/render/fragments.php @@ -2,7 +2,9 @@ /** * Loads Beans fragments. * - * @package Render\Fragments + * @package Beans\Framework\Render + * + * @since 1.0.0 */ // Filter. @@ -12,12 +14,9 @@ * * @since 1.0.0 * - * @param string $template The template filename. - * - * @return string The template filename. + * @return void */ function beans_load_global_fragments() { - beans_load_fragment_file( 'breadcrumb' ); beans_load_fragment_file( 'footer' ); beans_load_fragment_file( 'header' ); @@ -27,7 +26,6 @@ function beans_load_global_fragments() { beans_load_fragment_file( 'widget-area' ); beans_load_fragment_file( 'embed' ); beans_load_fragment_file( 'deprecated' ); - } // Filter. @@ -52,7 +50,6 @@ function beans_load_comments_fragment( $template ) { beans_load_fragment_file( 'comments' ); return $template; - } beans_add_smart_action( 'dynamic_sidebar_before', 'beans_load_widget_fragment', -1 ); @@ -66,9 +63,7 @@ function beans_load_comments_fragment( $template ) { * @return bool True on success, false on failure. */ function beans_load_widget_fragment() { - return beans_load_fragment_file( 'widget' ); - } beans_add_smart_action( 'pre_get_search_form', 'beans_load_search_form_fragment' ); @@ -82,7 +77,5 @@ function beans_load_widget_fragment() { * @return bool True on success, false on failure. */ function beans_load_search_form_fragment() { - return beans_load_fragment_file( 'searchform' ); - } diff --git a/lib/render/menu.php b/lib/render/menu.php index f1b82f87..d013212c 100644 --- a/lib/render/menu.php +++ b/lib/render/menu.php @@ -1,8 +1,10 @@ __( 'Primary Menu', 'tm-beans' ), ) ); - } // Filter. @@ -55,7 +58,7 @@ function beans_do_register_nav_menus() { /** * Modify wp_nav_menu arguments. * - * This function converts the wp_nav_menu to UIKit format. It uses Beans custom walker and also makes + * This function converts the wp_nav_menu to UIkit format. It uses the Beans custom walker and also makes * use of the Beans HTML API. * * @since 1.0.0 @@ -65,16 +68,17 @@ function beans_do_register_nav_menus() { * @return array The modified wp_nav_menu arguments. */ function beans_modify_menu_args( $args ) { - // Get type. $type = beans_get( 'beans_type', $args ); // Check if the menu is in a widget area and set the type accordingly if it is defined. - if ( $widget_area_type = beans_get_widget_area( 'beans_type' ) ) { - $type = ( 'stack' == $widget_area_type ) ? 'sidenav' : $widget_area_type; + $widget_area_type = beans_get_widget_area( 'beans_type' ); + + if ( $widget_area_type ) { + $type = 'stack' === $widget_area_type ? 'sidenav' : $widget_area_type; } - // Stop if it isn't a beans menu. + // Stop if it isn't a Beans menu. if ( ! $type ) { return $args; } @@ -85,38 +89,36 @@ function beans_modify_menu_args( $args ) { 'class' => array( beans_get( 'menu_class', $args ) ), ); - // Add UIKit navbar item wrap attributes. - if ( 'navbar' == $type ) { + // Add UIkit navbar item wrap attributes. + if ( 'navbar' === $type ) { $attr['class'][] = 'uk-navbar-nav'; } - // Add UIKit sidenav item wrap attributes. - if ( 'sidenav' == $type ) { - - $attr['class'][] = 'uk-nav uk-nav-parent-icon uk-nav-side'; + // Add UIkit sidenav item wrap attributes. + if ( 'sidenav' === $type ) { + $attr['class'][] = 'uk-nav uk-nav-parent-icon uk-nav-side'; $attr['data-uk-nav'] = '{multiple:true}'; - } - // Add UIKit offcanvas item wrap attributes. - if ( 'offcanvas' == $type ) { - - $attr['class'][] = 'uk-nav uk-nav-parent-icon uk-nav-offcanvas'; + // Add UIkit offcanvas item wrap attributes. + if ( 'offcanvas' === $type ) { + $attr['class'][] = 'uk-nav uk-nav-parent-icon uk-nav-offcanvas'; $attr['data-uk-nav'] = '{multiple:true}'; - } // Implode to avoid empty spaces. $attr['class'] = implode( ' ', array_filter( $attr['class'] ) ); - // Set to null if empty to avoid outputing empty class html attribute. + // Set to null if empty to avoid outputing an empty HTML class attribute. if ( ! $attr['class'] ) { $attr['class'] = null; } - $location_subfilter = ( $location = beans_get( 'theme_location', $args ) ) ? "[_{$location}]" : null; + $location = beans_get( 'theme_location', $args ); - // Force beans menu arguments. + $location_subfilter = $location ? "[_{$location}]" : null; + + // Force Beans menu arguments. $force = array( 'beans_type' => $type, 'items_wrap' => beans_open_markup( "beans_menu[_{$type}]{$location_subfilter}", 'ul', $attr, $args ) . '%3$s' . beans_close_markup( "beans_menu[_{$type}]{$location_subfilter}", 'ul', $args ), @@ -124,12 +126,13 @@ function beans_modify_menu_args( $args ) { // Allow walker overwrite. if ( ! beans_get( 'walker', $args ) ) { - $args['walker'] = new _Beans_Walker_Nav_Menu; + $args['walker'] = new _Beans_Walker_Nav_Menu(); } // Adapt level to walker depth. - $force['beans_start_level'] = ( $level = beans_get( 'beans_start_level', $args ) ) ? ( $level - 1 ) : 0; + $level = beans_get( 'beans_start_level', $args ); - return array_merge( $args, $force ); + $force['beans_start_level'] = $level ? $level - 1 : 0; + return array_merge( $args, $force ); } diff --git a/lib/render/template-parts.php b/lib/render/template-parts.php index f225cf46..67ed3f5a 100644 --- a/lib/render/template-parts.php +++ b/lib/render/template-parts.php @@ -1,10 +1,12 @@ beans_start_level ) { return; } - $type = beans_get( 'beans_type', $args ); - $location_subfilter = ( $location = beans_get( 'theme_location', $args ) ) ? "[_{$location}]" : null; + $type = beans_get( 'beans_type', $args ); + $location = beans_get( 'theme_location', $args ); + $location_subfilter = $location ? "[_{$location}]" : null; // Default attributes. $attr = array( 'class' => array( 'sub-menu' ), ); - // Add UIKit sidenav and offcanvas class. - if ( $depth > 0 || in_array( $type, array( 'sidenav', 'offcanvas' ) ) ) { + // Add UIkit sidenav and offcanvas class. + if ( $depth > 0 || in_array( $type, array( 'sidenav', 'offcanvas' ), true ) ) { $attr['class'][] = 'uk-nav-sub'; } - // Add UIKit navbar stuff. + // Add UIkit navbar stuff. if ( 'navbar' === $type && $args->beans_start_level === $depth ) { - // Add UIKit navbar attributes. - $attr['class'][] = 'uk-nav uk-nav-parent-icon uk-nav-dropdown'; + // Add UIkit navbar attributes. + $attr['class'][] = 'uk-nav uk-nav-parent-icon uk-nav-dropdown'; $attr['data-uk-nav'] = '{multiple:true}'; // Open sub_menu wrap. $output .= beans_open_markup( "beans_sub_menu_wrap[_{$type}]{$location_subfilter}", 'div', 'class=uk-dropdown uk-dropdown-navbar', $depth, $args ); - } // Implode to avoid empty spaces. @@ -61,23 +75,31 @@ function start_lvl( &$output, $depth = 0, $args = array() ) { // Open sub_menu. $output .= beans_open_markup( "beans_sub_menu[_{$type}]{$location_subfilter}", 'ul', $attr, $depth, $args ); - } /** * Extend WordPress end first menu level. * + * @since 1.0.0 * @ignore + * @access private + * + * @param string $output Used to append additional content (passed by reference). + * @param int $depth Depth of menu item. Used for padding. + * @param stdClass $args An object of wp_nav_menu() arguments. + * + * @return void */ - function end_lvl( &$output, $depth = 0, $args = array() ) { + public function end_lvl( &$output, $depth = 0, $args = array() ) { // Stop here if the depth is smaller than starting depth. if ( $depth < $args->beans_start_level ) { return; } - $type = beans_get( 'beans_type', $args ); - $location_subfilter = ( $location = beans_get( 'theme_location', $args ) ) ? "[_{$location}]" : null; + $type = beans_get( 'beans_type', $args ); + $location = beans_get( 'theme_location', $args ); + $location_subfilter = $location ? "[_{$location}]" : null; // Close sub_menu. $output .= beans_close_markup( "beans_sub_menu[_{$type}]{$location_subfilter}", 'ul' ); @@ -86,15 +108,24 @@ function end_lvl( &$output, $depth = 0, $args = array() ) { if ( 'navbar' === $type && $args->beans_start_level === $depth ) { $output .= beans_close_markup( "beans_sub_menu_wrap[_{$type}]{$location_subfilter}", 'div', $depth, $args ); } - } /** * Extend WordPress start menu elements. * + * @since 1.0.0 * @ignore + * @access private + * + * @param string $output Used to append additional content (passed by reference). + * @param WP_Post $item Menu item data object. + * @param int $depth Depth of menu item. Used for padding. + * @param stdClass $args An object of wp_nav_menu() arguments. + * @param int $id Current item ID. + * + * @return void */ - function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { + public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { // Stop here if the depth is smaller than starting depth. if ( $depth < $args->beans_start_level ) { @@ -103,12 +134,12 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { $item_id = $item->ID; - // Wp item attributes. - $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args ); - $classes = empty( $item->classes ) ? array() : (array) $item->classes; + // WP item attributes. + $id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args ); //phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Used inside method scope. + $classes = empty( $item->classes ) ? array() : (array) $item->classes; $classes[] = 'menu-item-' . $item->ID; - $_classes = join( ' ', (array) apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) ); + $_classes = join( ' ', (array) apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Used inside method scope. // WP link attributes. $_link_attr = array( @@ -126,29 +157,26 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { } } - $link_attr = apply_filters( 'nav_menu_link_attributes', $_link_attr, $item, $args ); + $link_attr = apply_filters( 'nav_menu_link_attributes', $_link_attr, $item, $args ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Used inside method scope. - // Set wp item attributes as defaults. + // Set WP item attributes as defaults. $item_attr = array( 'class' => array( $_classes ), 'itemprop' => 'name', ); - // Add UIKit active class. - if ( in_array( 'current-menu-item', $classes ) ) { + // Add UIkit active class. + if ( in_array( 'current-menu-item', $classes, true ) ) { $item_attr['class'][] = 'uk-active'; } - // Add UIKit parent attributes. - if ( $args->beans_start_level == $depth && in_array( 'menu-item-has-children', $classes ) ) { - + // Add UIkit parent attributes. + if ( $args->beans_start_level === $depth && in_array( 'menu-item-has-children', $classes, true ) ) { $item_attr['class'][] = 'uk-parent'; - if ( beans_get( 'beans_type', $args ) == 'navbar' ) { - + if ( beans_get( 'beans_type', $args ) === 'navbar' ) { $item_attr['data-uk-dropdown'] = ''; - $child_indicator = true; - + $child_indicator = true; } } @@ -166,29 +194,35 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { $item_output .= beans_open_markup( "beans_menu_item_link[_{$item_id}]", 'a', $link_attr, $item, $depth, $args ); - $item_output .= beans_output( "beans_menu_item_text[_{$item_id}]", $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after ); - - if ( isset( $child_indicator ) ) { + $item_output .= beans_output( "beans_menu_item_text[_{$item_id}]", $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Used inside method scope. - $item_output .= beans_open_markup( "beans_menu_item_child_indicator[_{$item_id}]", 'i', array( 'class' => 'uk-icon-caret-down uk-margin-small-left' ), $item, $depth, $args ); - $item_output .= beans_close_markup( "beans_menu_item_child_indicator[_{$item_id}]", 'i', $item, $depth, $args ); - - } + if ( isset( $child_indicator ) ) { + $item_output .= beans_open_markup( "beans_menu_item_child_indicator[_{$item_id}]", 'i', array( 'class' => 'uk-icon-caret-down uk-margin-small-left' ), $item, $depth, $args ); + $item_output .= beans_close_markup( "beans_menu_item_child_indicator[_{$item_id}]", 'i', $item, $depth, $args ); + } $item_output .= beans_close_markup( "beans_menu_item_link[_{$item_id}]", 'a', $link_attr, $item, $depth, $args ); $item_output .= $args->after; - $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); - + $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Used inside method scope. } /** * Extend WordPress end menu elements. * + * @since 1.0.0 * @ignore + * @access private + * + * @param string $output Used to append additional content (passed by reference). + * @param WP_Post $item Page data object. Not used. + * @param int $depth Depth of page. Not Used. + * @param stdClass $args An object of wp_nav_menu() arguments. + * + * @return void */ - function end_el( &$output, $item, $depth = 0, $args = array() ) { + public function end_el( &$output, $item, $depth = 0, $args = array() ) { // Stop here if the depth is smaller than starting depth. if ( $depth < $args->beans_start_level ) { @@ -196,8 +230,6 @@ function end_el( &$output, $item, $depth = 0, $args = array() ) { } $item_id = $item->ID; - $output .= beans_close_markup( "beans_menu_item[_{$item_id}]", 'li', $item, $depth, $args ); - } } diff --git a/lib/render/widget-area.php b/lib/render/widget-area.php index 23540b28..27f44536 100644 --- a/lib/render/widget-area.php +++ b/lib/render/widget-area.php @@ -1,8 +1,10 @@ __( 'Sidebar Primary', 'tm-beans' ), @@ -31,17 +34,16 @@ function beans_do_register_widget_areas() { 'beans_type' => 'offcanvas', ) ); } - } /** * Call register sidebar. * - * Because WordPress.org checker don't understand that we are using register_sidebar properly, + * Because the WordPress.org checker doesn't understand that we are using register_sidebar properly, * we have to add this useless call which only has to be declared once. * * @since 1.0.0 - * * @ignore + * @access private */ add_action( 'widgets_init', 'beans_register_widget_area' ); diff --git a/lib/templates/fragments/breadcrumb.php b/lib/templates/fragments/breadcrumb.php index 15a0e5a6..f2387b3c 100644 --- a/lib/templates/fragments/breadcrumb.php +++ b/lib/templates/fragments/breadcrumb.php @@ -2,7 +2,9 @@ /** * Echo breadcrumb fragment. * - * @package Fragments\Breadcrumb + * @package Beans\Framework\Templates\Fragments + * + * @since 1.0.0 */ beans_add_smart_action( 'beans_main_grid_before_markup', 'beans_breadcrumb' ); @@ -10,6 +12,8 @@ * Echo the breadcrumb. * * @since 1.0.0 + * + * @return void */ function beans_breadcrumb() { @@ -17,33 +21,33 @@ function beans_breadcrumb() { return; } - wp_reset_query(); + wp_reset_query(); // phpcs:ignore WordPress.WP.DiscouragedFunctions.wp_reset_query_wp_reset_query -- Ensure the main query has been reset to the original main query. global $post; - $post_type = get_post_type(); - $breadcrumbs = array(); + $post_type = get_post_type(); + $breadcrumbs = array(); $breadcrumbs[ home_url() ] = __( 'Home', 'tm-beans' ); // Custom post type. - if ( ! in_array( $post_type, array( 'page', 'attachment', 'post' ) ) && ! is_404() ) { + if ( ! in_array( $post_type, array( 'page', 'attachment', 'post' ), true ) && ! is_404() ) { - if ( $post_type_object = get_post_type_object( $post_type ) ) { + $post_type_object = get_post_type_object( $post_type ); + + if ( $post_type_object ) { $breadcrumbs[ get_post_type_archive_link( $post_type ) ] = $post_type_object->labels->name; } } // Single posts. - if ( is_single() && 'post' == $post_type ) { + if ( is_single() && 'post' === $post_type ) { foreach ( get_the_category( $post->ID ) as $category ) { $breadcrumbs[ get_category_link( $category->term_id ) ] = $category->name; } $breadcrumbs[] = get_the_title(); - } elseif ( is_singular() && ! is_home() && ! is_front_page() ) { // Pages/custom post type. - $current_page = array( $post ); // Get the parent pages of the current page if they exist. @@ -58,11 +62,8 @@ function beans_breadcrumb() { $breadcrumbs[ get_page_link( $page->ID ) ] = $page->post_title; } } elseif ( is_category() ) { // Categories. - $breadcrumbs[] = single_cat_title( '', false ); - } elseif ( is_tax() ) { // Taxonomies. - $current_term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); $ancestors = array_reverse( get_ancestors( $current_term->term_id, get_query_var( 'taxonomy' ) ) ); @@ -72,76 +73,55 @@ function beans_breadcrumb() { $ancestor = get_term( $ancestor, get_query_var( 'taxonomy' ) ); $breadcrumbs[ get_term_link( $ancestor->slug, get_query_var( 'taxonomy' ) ) ] = $ancestor->name; - } $breadcrumbs[] = $current_term->name; - } elseif ( is_search() ) { // Searches. - $breadcrumbs[] = __( 'Results:', 'tm-beans' ) . ' ' . get_search_query(); - } elseif ( is_author() ) { // Author archives. - - $author = get_queried_object(); + $author = get_queried_object(); $breadcrumbs[] = __( 'Author Archives:', 'tm-beans' ) . ' ' . $author->display_name; - } elseif ( is_tag() ) {// Tag archives. - $breadcrumbs[] = __( 'Tag Archives:', 'tm-beans' ) . ' ' . single_tag_title( '', false ); - } elseif ( is_date() ) { // Date archives. - $breadcrumbs[] = __( 'Archives:', 'tm-beans' ) . ' ' . get_the_time( 'F Y' ); - } elseif ( is_404() ) { // 404. - $breadcrumbs[] = __( '404', 'tm-beans' ); - } // Open breadcrumb. beans_open_markup_e( 'beans_breadcrumb', 'ul', array( 'class' => 'uk-breadcrumb uk-width-1-1' ) ); - $i = 0; - foreach ( $breadcrumbs as $breadcrumb_url => $breadcrumb ) { - - // Breadcrumb items. - if ( count( $breadcrumbs ) - 1 != $i ) { - - beans_open_markup_e( 'beans_breadcrumb_item', 'li' ); - - beans_open_markup_e( 'beans_breadcrumb_item_link', 'a', array( - 'href' => $breadcrumb_url, // Automatically escaped. - ) ); + foreach ( $breadcrumbs as $breadcrumb_url => $breadcrumb ) { - // Used for mobile devices. - beans_open_markup_e( 'beans_breadcrumb_item_link_inner', 'span' ); + // Breadcrumb items. + if ( count( $breadcrumbs ) - 1 !== $i ) { + beans_open_markup_e( 'beans_breadcrumb_item', 'li' ); - beans_output_e( 'beans_breadcrumb_item_text', $breadcrumb );; + beans_open_markup_e( 'beans_breadcrumb_item_link', 'a', array( 'href' => $breadcrumb_url ) ); // Automatically escaped. - beans_close_markup_e( 'beans_breadcrumb_item_link_inner', 'span' ); + // Used for mobile devices. + beans_open_markup_e( 'beans_breadcrumb_item_link_inner', 'span' ); - beans_close_markup_e( 'beans_breadcrumb_item_link', 'a' ); + beans_output_e( 'beans_breadcrumb_item_text', $breadcrumb ); - beans_close_markup_e( 'beans_breadcrumb_item', 'li' ); + beans_close_markup_e( 'beans_breadcrumb_item_link_inner', 'span' ); - } else { // Active. + beans_close_markup_e( 'beans_breadcrumb_item_link', 'a' ); - beans_open_markup_e( 'beans_breadcrumb_item[_active]', 'li', array( 'class' => 'uk-active uk-text-muted' ) ); + beans_close_markup_e( 'beans_breadcrumb_item', 'li' ); + } else { // Active. + beans_open_markup_e( 'beans_breadcrumb_item[_active]', 'li', array( 'class' => 'uk-active uk-text-muted' ) ); - beans_output_e( 'beans_breadcrumb_item[_active]_text', $breadcrumb ); - - beans_close_markup_e( 'beans_breadcrumb_item[_active]', 'li' ); - - } - - $i++; + beans_output_e( 'beans_breadcrumb_item[_active]_text', $breadcrumb ); + beans_close_markup_e( 'beans_breadcrumb_item[_active]', 'li' ); } + $i++; + } + // Close breadcrumb. beans_close_markup_e( 'beans_breadcrumb', 'ul' ); - } diff --git a/lib/templates/fragments/comments.php b/lib/templates/fragments/comments.php index d320ba3b..22019660 100644 --- a/lib/templates/fragments/comments.php +++ b/lib/templates/fragments/comments.php @@ -2,7 +2,9 @@ /** * Echo comments fragments. * - * @package Fragments\Comments + * @package Beans\Framework\Templates\Fragments + * + * @since 1.0.0 */ beans_add_smart_action( 'beans_comments_list_before_markup', 'beans_comments_title' ); @@ -10,18 +12,22 @@ * Echo the comments title. * * @since 1.0.0 + * + * @return void */ function beans_comments_title() { beans_open_markup_e( 'beans_comments_title', 'h2' ); - beans_output_e( 'beans_comments_title_text', sprintf( - _n( '%s Comment', '%s Comments', get_comments_number(), 'tm-beans' ), - number_format_i18n( get_comments_number() ) - ) ); + beans_output_e( + 'beans_comments_title_text', sprintf( + // translators: Number of comments, one or many. + _n( '%s Comment', '%s Comments', get_comments_number(), 'tm-beans' ), + number_format_i18n( get_comments_number() ) + ) + ); beans_close_markup_e( 'beans_comments_title', 'h2' ); - } beans_add_smart_action( 'beans_comment_header', 'beans_comment_avatar', 5 ); @@ -29,22 +35,24 @@ function beans_comments_title() { * Echo the comment avatar. * * @since 1.0.0 + * + * @return void */ function beans_comment_avatar() { - global $comment; // Stop here if no avatar. - if ( ! $avatar = get_avatar( $comment, $comment->args['avatar_size'] ) ) { + $avatar = get_avatar( $comment, $comment->args['avatar_size'] ); + + if ( ! $avatar ) { return; } beans_open_markup_e( 'beans_comment_avatar', 'div', array( 'class' => 'uk-comment-avatar' ) ); - echo $avatar; + echo $avatar; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes get_avatar(). beans_close_markup_e( 'beans_comment_avatar', 'div' ); - } beans_add_smart_action( 'beans_comment_header', 'beans_comment_author' ); @@ -52,20 +60,24 @@ function beans_comment_avatar() { * Echo the comment author title. * * @since 1.0.0 + * + * @return void */ function beans_comment_author() { - - beans_open_markup_e( 'beans_comment_title', 'div', array( - 'class' => 'uk-comment-title', - 'itemprop' => 'author', - 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/Person', - ) ); + beans_open_markup_e( + 'beans_comment_title', + 'div', + array( + 'class' => 'uk-comment-title', + 'itemprop' => 'author', + 'itemscope' => 'itemscope', + 'itemtype' => 'https://schema.org/Person', + ) + ); echo get_comment_author_link(); beans_close_markup_e( 'beans_comment_title', 'div' ); - } beans_add_smart_action( 'beans_comment_title_append_markup', 'beans_comment_badges' ); @@ -73,55 +85,47 @@ function beans_comment_author() { * Echo the comment badges. * * @since 1.0.0 + * + * @return void */ function beans_comment_badges() { - global $comment; // Trackback badge. - if ( 'trackback' == $comment->comment_type ) { - + if ( 'trackback' === $comment->comment_type ) { beans_open_markup_e( 'beans_trackback_badge', 'span', array( 'class' => 'uk-badge uk-margin-small-left' ) ); - beans_output_e( 'beans_trackback_text', __( 'Trackback', 'tm-beans' ) ); + beans_output_e( 'beans_trackback_text', esc_html__( 'Trackback', 'tm-beans' ) ); beans_close_markup_e( 'beans_trackback_badge', 'span' ); - } // Pindback badge. - if ( 'pingback' == $comment->comment_type ) { - + if ( 'pingback' === $comment->comment_type ) { beans_open_markup_e( 'beans_pingback_badge', 'span', array( 'class' => 'uk-badge uk-margin-small-left' ) ); - beans_output_e( 'beans_pingback_text', __( 'Pingback', 'tm-beans' ) ); + beans_output_e( 'beans_pingback_text', esc_html__( 'Pingback', 'tm-beans' ) ); beans_close_markup_e( 'beans_pingback_badge', 'span' ); - } // Moderation badge. - if ( '0' == $comment->comment_approved ) { - + if ( '0' === $comment->comment_approved ) { beans_open_markup_e( 'beans_moderation_badge', 'span', array( 'class' => 'uk-badge uk-margin-small-left uk-badge-warning' ) ); - beans_output_e( 'beans_moderation_text', __( 'Awaiting Moderation', 'tm-beans' ) ); + beans_output_e( 'beans_moderation_text', esc_html__( 'Awaiting Moderation', 'tm-beans' ) ); beans_close_markup_e( 'beans_moderation_badge', 'span' ); - } // Moderator badge. if ( user_can( $comment->user_id, 'moderate_comments' ) ) { - beans_open_markup_e( 'beans_moderator_badge', 'span', array( 'class' => 'uk-badge uk-margin-small-left' ) ); - beans_output_e( 'beans_moderator_text', __( 'Moderator', 'tm-beans' ) ); + beans_output_e( 'beans_moderator_text', esc_html__( 'Moderator', 'tm-beans' ) ); beans_close_markup_e( 'beans_moderator_badge', 'span' ); - } - } beans_add_smart_action( 'beans_comment_header', 'beans_comment_metadata', 15 ); @@ -129,26 +133,33 @@ function beans_comment_badges() { * Echo the comment metadata. * * @since 1.0.0 + * + * @return void */ function beans_comment_metadata() { - beans_open_markup_e( 'beans_comment_meta', 'div', array( 'class' => 'uk-comment-meta' ) ); - beans_open_markup_e( 'beans_comment_time', 'time', array( - 'datetime' => get_comment_time( 'c' ), - 'itemprop' => 'datePublished', - ) ); - - beans_output_e( 'beans_comment_time_text', sprintf( - _x( '%1$s at %2$s', '1: date, 2: time', 'tm-beans' ), - get_comment_date(), - get_comment_time() - ) ); + beans_open_markup_e( + 'beans_comment_time', + 'time', + array( + 'datetime' => get_comment_time( 'c' ), + 'itemprop' => 'datePublished', + ) + ); + + beans_output_e( + 'beans_comment_time_text', sprintf( + // translators: Date of the comment, time of the comment. + _x( '%1$s at %2$s', '1: date, 2: time', 'tm-beans' ), + get_comment_date(), + get_comment_time() + ) + ); beans_close_markup_e( 'beans_comment_time', 'time' ); beans_close_markup_e( 'beans_comment_meta', 'div' ); - } beans_add_smart_action( 'beans_comment_content', 'beans_comment_content' ); @@ -156,11 +167,11 @@ function beans_comment_metadata() { * Echo the comment content. * * @since 1.0.0 + * + * @return void */ function beans_comment_content() { - beans_output_e( 'beans_comment_content', beans_render_function( 'comment_text' ) ); - } beans_add_smart_action( 'beans_comment_content', 'beans_comment_links', 15 ); @@ -168,54 +179,64 @@ function beans_comment_content() { * Echo the comment links. * * @since 1.0.0 + * + * @return void */ function beans_comment_links() { - global $comment; beans_open_markup_e( 'beans_comment_links', 'ul', array( 'class' => 'tm-comment-links uk-subnav uk-subnav-line' ) ); // Reply. - echo get_comment_reply_link( array_merge( $comment->args, array( - 'add_below' => 'comment-content', - 'depth' => $comment->depth, - 'max_depth' => $comment->args['max_depth'], - 'before' => beans_open_markup( 'beans_comment_item[_reply]', 'li' ), - 'after' => beans_close_markup( 'beans_comment_item[_reply]', 'li' ), - ) ) ); + echo get_comment_reply_link( // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. + array_merge( + $comment->args, array( + 'add_below' => 'comment-content', + 'depth' => $comment->depth, + 'max_depth' => $comment->args['max_depth'], + 'before' => beans_open_markup( 'beans_comment_item[_reply]', 'li' ), + 'after' => beans_close_markup( 'beans_comment_item[_reply]', 'li' ), + ) + ) + ); // Edit. - if ( current_user_can( 'moderate_comments' ) ) : - - beans_open_markup_e( 'beans_comment_item[_edit]', 'li' ); + if ( current_user_can( 'moderate_comments' ) ) : + beans_open_markup_e( 'beans_comment_item[_edit]', 'li' ); - beans_open_markup_e( 'beans_comment_item_link[_edit]', 'a', array( + beans_open_markup_e( + 'beans_comment_item_link[_edit]', + 'a', + array( 'href' => get_edit_comment_link( $comment->comment_ID ), // Automatically escaped. - ) ); + ) + ); - beans_output_e( 'beans_comment_edit_text', __( 'Edit', 'tm-beans' ) ); + beans_output_e( 'beans_comment_edit_text', esc_html__( 'Edit', 'tm-beans' ) ); - beans_close_markup_e( 'beans_comment_item_link[_edit]', 'a' ); + beans_close_markup_e( 'beans_comment_item_link[_edit]', 'a' ); - beans_close_markup_e( 'beans_comment_item[_edit]', 'li' ); - - endif; + beans_close_markup_e( 'beans_comment_item[_edit]', 'li' ); +endif; // Link. beans_open_markup_e( 'beans_comment_item[_link]', 'li' ); - beans_open_markup_e( 'beans_comment_item_link[_link]', 'a', array( - 'href' => get_comment_link( $comment->comment_ID ), // Automatically escaped. - ) ); + beans_open_markup_e( + 'beans_comment_item_link[_link]', + 'a', + array( + 'href' => get_comment_link( $comment->comment_ID ), // Automatically escaped. + ) + ); - beans_output_e( 'beans_comment_link_text', __( 'Link', 'tm-beans' ) ); + beans_output_e( 'beans_comment_link_text', esc_html__( 'Link', 'tm-beans' ) ); beans_close_markup_e( 'beans_comment_item_link[_link]', 'a' ); beans_close_markup_e( 'beans_comment_item[_link]', 'li' ); beans_close_markup_e( 'beans_comment_links', 'ul' ); - } beans_add_smart_action( 'beans_no_comment', 'beans_no_comment' ); @@ -223,15 +244,15 @@ function beans_comment_links() { * Echo no comment content. * * @since 1.0.0 + * + * @return void */ function beans_no_comment() { - beans_open_markup_e( 'beans_no_comment', 'p', 'class=uk-text-muted' ); - beans_output_e( 'beans_no_comment_text', __( 'No comment yet, add your voice below!', 'tm-beans' ) ); + beans_output_e( 'beans_no_comment_text', esc_html__( 'No comment yet, add your voice below!', 'tm-beans' ) ); beans_close_markup_e( 'beans_no_comment', 'p' ); - } beans_add_smart_action( 'beans_comments_closed', 'beans_comments_closed' ); @@ -239,15 +260,15 @@ function beans_no_comment() { * Echo closed comments content. * * @since 1.0.0 + * + * @return void */ function beans_comments_closed() { - beans_open_markup_e( 'beans_comments_closed', 'p', array( 'class' => 'uk-alert uk-alert-warning uk-margin-bottom-remove' ) ); - beans_output_e( 'beans_comments_closed_text', __( 'Comments are closed for this article!', 'tm-beans' ) ); + beans_output_e( 'beans_comments_closed_text', esc_html__( 'Comments are closed for this article!', 'tm-beans' ) ); beans_close_markup_e( 'beans_comments_closed', 'p' ); - } beans_add_smart_action( 'beans_comments_list_after_markup', 'beans_comments_navigation' ); @@ -255,6 +276,10 @@ function beans_comments_closed() { * Echo comments navigation. * * @since 1.0.0 + * + * @return void + * + * phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact -- Layout mirrors HTML markup. */ function beans_comments_navigation() { @@ -262,49 +287,68 @@ function beans_comments_navigation() { return; } - beans_open_markup_e( 'beans_comments_navigation', 'ul', array( - 'class' => 'uk-pagination', - 'role' => 'navigation', - ) ); + beans_open_markup_e( + 'beans_comments_navigation_nav_container', + 'nav', + array( + 'role' => 'navigation', + 'aria-label' => esc_attr__( 'Comments Pagination Navigation', 'tm-beans' ), + ) + ); + + beans_open_markup_e( + 'beans_comments_navigation', + 'ul', + array( + 'class' => 'uk-pagination', + ) + ); // Previous. if ( get_previous_comments_link() ) { - beans_open_markup_e( 'beans_comments_navigation_item[_previous]', 'li', array( 'class' => 'uk-pagination-previous' ) ); - $previous_icon = beans_open_markup( 'beans_previous_icon[_comments_navigation]', 'i', array( - 'class' => 'uk-icon-angle-double-left uk-margin-small-right', - ) ); - $previous_icon .= beans_close_markup( 'beans_previous_icon[_comments_navigation]', 'i' ); + $previous_icon = beans_open_markup( + 'beans_previous_icon[_comments_navigation]', + 'span', + array( + 'class' => 'uk-icon-angle-double-left uk-margin-small-right', + 'aria-hidden' => 'true', + ) + ); + $previous_icon .= beans_close_markup( 'beans_previous_icon[_comments_navigation]', 'span' ); - echo get_previous_comments_link( - $previous_icon . beans_output( 'beans_previous_text[_comments_navigation]', __( 'Previous', 'tm-beans' ) ) + echo get_previous_comments_link( // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. + $previous_icon . beans_output( 'beans_previous_text[_comments_navigation]', __( 'Previous Comments', 'tm-beans' ) ) ); beans_close_markup_e( 'beans_comments_navigation_item[_previous]', 'li' ); - } // Next. if ( get_next_comments_link() ) { - beans_open_markup_e( 'beans_comments_navigation_item[_next]', 'li', array( 'class' => 'uk-pagination-next' ) ); - $next_icon = beans_open_markup( 'beans_next_icon[_comments_navigation]', 'i', array( - 'class' => 'uk-icon-angle-double-right uk-margin-small-right', - ) ); - $next_icon .= beans_close_markup( 'beans_previous_icon[_comments_navigation]', 'i' ); + $next_icon = beans_open_markup( + 'beans_next_icon[_comments_navigation]', + 'span', + array( + 'class' => 'uk-icon-angle-double-right uk-margin-small-right', + 'aria-hidden' => 'true', + ) + ); + $next_icon .= beans_close_markup( 'beans_next_icon[_comments_navigation]', 'span' ); - echo get_next_comments_link( - beans_output( 'beans_next_text[_comments_navigation]', __( 'Next', 'tm-beans' ) ) . $next_icon + echo get_next_comments_link( // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. + beans_output( 'beans_next_text[_comments_navigation]', __( 'Next Comments ', 'tm-beans' ) ) . $next_icon ); beans_close_markup_e( 'beans_comments_navigation_item_[_next]', 'li' ); - } - beans_close_markup_e( 'beans_comments_navigation', 'ul' ); + beans_close_markup_e( 'beans_comments_navigation', 'ul' ); + beans_close_markup_e( 'beans_comments_navigation_nav_container', 'nav' ); } beans_add_smart_action( 'beans_after_open_comments', 'beans_comment_form_divider' ); @@ -312,11 +356,11 @@ function beans_comments_navigation() { * Echo comment divider. * * @since 1.0.0 + * + * @return void */ function beans_comment_form_divider() { - beans_selfclose_markup_e( 'beans_comment_form_divider', 'hr', array( 'class' => 'uk-article-divider' ) ); - } beans_add_smart_action( 'beans_after_open_comments', 'beans_comment_form' ); @@ -324,56 +368,68 @@ function beans_comment_form_divider() { * Echo comment navigation. * * @since 1.0.0 + * + * @return void */ function beans_comment_form() { - $output = beans_open_markup( 'beans_comment_form_wrap', 'div', array( 'class' => 'uk-form tm-comment-form-wrap' ) ); - $output .= beans_render_function( 'comment_form', array( - 'title_reply' => beans_output( 'beans_comment_form_title_text', __( 'Add a Comment', 'tm-beans' ) ), - ) ); + $output .= beans_render_function( 'comment_form', array( 'title_reply' => beans_output( 'beans_comment_form_title_text', __( 'Add a Comment', 'tm-beans' ) ) ) ); $output .= beans_close_markup( 'beans_comment_form_wrap', 'div' ); - $submit = beans_open_markup( 'beans_comment_form_submit', 'button', array( - 'class' => 'uk-button uk-button-primary', - 'type' => 'submit', - ) ); + $submit = beans_open_markup( + 'beans_comment_form_submit', + 'button', + array( + 'class' => 'uk-button uk-button-primary', + 'type' => 'submit', + ) + ); - $submit .= beans_output( 'beans_comment_form_submit_text', __( 'Post Comment', 'tm-beans' ) ); + $submit .= beans_output( 'beans_comment_form_submit_text', esc_html__( 'Post Comment', 'tm-beans' ) ); $submit .= beans_close_markup( 'beans_comment_form_submit', 'button' ); // WordPress, please make it easier for us. - echo preg_replace( '#]+type="submit"[^>]+>#', $submit, $output ); - + echo preg_replace( '#]+type="submit"[^>]+>#', $submit, $output ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Escaped above or as an attribute. } // Filter. -beans_add_smart_action( 'cancel_comment_reply_link', 'beans_comment_cancel_reply_link', 10 , 3 ); +beans_add_smart_action( 'cancel_comment_reply_link', 'beans_comment_cancel_reply_link', 10, 3 ); /** * Echo comment cancel reply link. * * This function replaces the default WordPress comment cancel reply link. * * @since 1.0.0 + * + * @param string $html HTML. + * @param string $link Cancel reply link. + * @param string $text Text to output. + * + * @return string */ function beans_comment_cancel_reply_link( $html, $link, $text ) { - $output = beans_open_markup( 'beans_comment_cancel_reply_link', 'a', array( - 'rel' => 'nofollow', - 'id' => 'cancel-comment-reply-link', - 'class' => 'uk-button uk-button-small uk-button-danger uk-margin-small-right', - 'style' => isset( $_GET['replytocom'] ) ? '' : 'display:none;', - 'href' => $link, // Automatically escaped. - ) ); + $output = beans_open_markup( + 'beans_comment_cancel_reply_link', + 'a', + array( + 'rel' => 'nofollow', + 'id' => 'cancel-comment-reply-link', + 'class' => 'uk-button uk-button-small uk-button-danger uk-margin-small-right', + // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification -- Used to determine inline style. + 'style' => isset( $_GET['replytocom'] ) ? '' : 'display:none;', + 'href' => $link, // Automatically escaped. + ) + ); $output .= beans_output( 'beans_comment_cancel_reply_link_text', $text ); $output .= beans_close_markup( 'beans_comment_cancel_reply_link', 'a' ); return $output; - } // Filter. @@ -384,40 +440,41 @@ function beans_comment_cancel_reply_link( $html, $link, $text ) { * This function replaces the default WordPress comment textarea field. * * @since 1.0.0 + * + * @return string */ function beans_comment_form_comment() { - - $output = beans_open_markup( 'beans_comment_form[_comment]', 'p', array( 'class' => 'uk-margin-top' ) ); + $output = beans_open_markup( 'beans_comment_form[_comment]', 'fieldset', array( 'class' => 'uk-margin-top' ) ); /** * Filter whether the comment form textarea legend should load or not. * * @since 1.0.0 */ - if ( beans_apply_filters( 'beans_comment_form_legend[_comment]', true ) ) { - - $output .= beans_open_markup( 'beans_comment_form_legend[_comment]', 'legend' ); + if ( beans_apply_filters( 'beans_comment_form_legend[_comment]', true ) ) { - $output .= beans_output( 'beans_comment_form_legend_text[_comment]', __( 'Comment *', 'tm-beans' ) ); + $output .= beans_open_markup( 'beans_comment_form_legend[_comment]', 'legend' ); - $output .= beans_close_markup( 'beans_comment_form_legend[_comment]', 'legend' ); + $output .= beans_output( 'beans_comment_form_legend_text[_comment]', esc_html__( 'Comment *', 'tm-beans' ) ); - } + $output .= beans_close_markup( 'beans_comment_form_legend[_comment]', 'legend' ); + } - $output .= beans_open_markup( 'beans_comment_form_field[_comment]', 'textarea', array( - 'id' => 'comment', - 'class' => 'uk-width-1-1', - 'name' => 'comment', - 'required' => '', - 'rows' => 8, - ) ); + $output .= beans_open_markup( + 'beans_comment_form_field[_comment]', 'textarea', array( + 'id' => 'comment', + 'class' => 'uk-width-1-1', + 'name' => 'comment', + 'required' => '', + 'rows' => 8, + ) + ); $output .= beans_close_markup( 'beans_comment_form_field[_comment]', 'textarea' ); - $output .= beans_close_markup( 'beans_comment_form[_comment]', 'p' ); + $output .= beans_close_markup( 'beans_comment_form[_comment]', 'fieldset' ); return $output; - } beans_add_smart_action( 'comment_form_before_fields', 'beans_comment_before_fields', 9999 ); @@ -428,16 +485,18 @@ function beans_comment_form_comment() { * the user is not logged in. * * @since 1.0.0 + * + * @return void */ function beans_comment_before_fields() { - beans_open_markup_e( 'beans_comment_fields_wrap', 'div', array( 'class' => 'uk-width-medium-1-1' ) ); - beans_open_markup_e( 'beans_comment_fields_inner_wrap', 'div', array( - 'class' => 'uk-grid uk-grid-small', - 'data-uk-grid-margin' => '', - ) ); - + beans_open_markup_e( + 'beans_comment_fields_inner_wrap', 'div', array( + 'class' => 'uk-grid uk-grid-small', + 'data-uk-grid-margin' => '', + ) + ); } // Filter. @@ -456,7 +515,7 @@ function beans_comment_before_fields() { function beans_comment_form_fields( $fields ) { $commenter = wp_get_current_commenter(); - $grid = count( (array) $fields ); + $grid = count( (array) $fields ); // Author. if ( isset( $fields['author'] ) ) { @@ -468,34 +527,32 @@ function beans_comment_form_fields( $fields ) { * * @since 1.0.0 */ - if ( beans_apply_filters( 'beans_comment_form_legend[_name]', true ) ) { - - $author .= beans_open_markup( 'beans_comment_form_legend[_name]', 'legend' ); - - $author .= beans_output( 'beans_comment_form_legend_text[_name]', __( 'Name *', 'tm-beans' ) ); + if ( beans_apply_filters( 'beans_comment_form_legend[_name]', true ) ) { + $author .= beans_open_markup( 'beans_comment_form_legend[_name]', 'legend' ); - $author .= beans_close_markup( 'beans_comment_form_legend[_name]', 'legend' ); + $author .= beans_output( 'beans_comment_form_legend_text[_name]', esc_html__( 'Name *', 'tm-beans' ) ); - } + $author .= beans_close_markup( 'beans_comment_form_legend[_name]', 'legend' ); + } - $author .= beans_selfclose_markup( 'beans_comment_form_field[_name]', 'input', array( - 'id' => 'author', - 'class' => 'uk-width-1-1', - 'type' => 'text', - 'value' => $commenter['comment_author'], // Automatically escaped. - 'name' => 'author', - 'required' => 'required', - ) ); + $author .= beans_selfclose_markup( + 'beans_comment_form_field[_name]', 'input', array( + 'id' => 'author', + 'class' => 'uk-width-1-1', + 'type' => 'text', + 'value' => $commenter['comment_author'], // Automatically escaped. + 'name' => 'author', + 'required' => 'required', + ) + ); $author .= beans_close_markup( 'beans_comment_form[_name]', 'div' ); $fields['author'] = $author; - } // Email. if ( isset( $fields['email'] ) ) { - $email = beans_open_markup( 'beans_comment_form[_email]', 'div', array( 'class' => "uk-width-medium-1-$grid" ) ); /** @@ -503,34 +560,35 @@ function beans_comment_form_fields( $fields ) { * * @since 1.0.0 */ - if ( beans_apply_filters( 'beans_comment_form_legend[_email]', true ) ) { - - $email .= beans_open_markup( 'beans_comment_form_legend[_email]', 'legend' ); + if ( beans_apply_filters( 'beans_comment_form_legend[_email]', true ) ) { + $email .= beans_open_markup( 'beans_comment_form_legend[_email]', 'legend' ); - $email .= beans_output( 'beans_comment_form_legend_text[_email]', sprintf( __( 'Email %s', 'tm-beans' ), ( get_option( 'require_name_email' ) ? ' *' : '' ) ) ); + $email .= beans_output( 'beans_comment_form_legend_text[_email]', + // translators: Whether or not submitting an email address is required. + sprintf( __( 'Email %s', 'tm-beans' ), ( get_option( 'require_name_email' ) ? ' *' : '' ) ) + ); - $email .= beans_close_markup( 'beans_comment_form_legend[_email]', 'legend' ); + $email .= beans_close_markup( 'beans_comment_form_legend[_email]', 'legend' ); + } - } - - $email .= beans_selfclose_markup( 'beans_comment_form_field[_email]', 'input', array( - 'id' => 'email', - 'class' => 'uk-width-1-1', - 'type' => 'text', - 'value' => $commenter['comment_author_email'], // Automatically escaped. - 'name' => 'email', - 'required' => get_option( 'require_name_email' ) ? 'required' : null, - ) ); + $email .= beans_selfclose_markup( + 'beans_comment_form_field[_email]', 'input', array( + 'id' => 'email', + 'class' => 'uk-width-1-1', + 'type' => 'text', + 'value' => $commenter['comment_author_email'], // Automatically escaped. + 'name' => 'email', + 'required' => get_option( 'require_name_email' ) ? 'required' : null, + ) + ); $email .= beans_close_markup( 'beans_comment_form[_email]', 'div' ); $fields['email'] = $email; - } // Url. if ( isset( $fields['url'] ) ) { - $url = beans_open_markup( 'beans_comment_form[_website]', 'div', array( 'class' => "uk-width-medium-1-$grid" ) ); /** @@ -538,28 +596,27 @@ function beans_comment_form_fields( $fields ) { * * @since 1.0.0 */ - if ( beans_apply_filters( 'beans_comment_form_legend[_url]', true ) ) { - - $url .= beans_open_markup( 'beans_comment_form_legend', 'legend' ); - - $url .= beans_output( 'beans_comment_form_legend_text[_url]', __( 'Website', 'tm-beans' ) ); + if ( beans_apply_filters( 'beans_comment_form_legend[_url]', true ) ) { + $url .= beans_open_markup( 'beans_comment_form_legend', 'legend' ); - $url .= beans_close_markup( 'beans_comment_form_legend[_url]', 'legend' ); + $url .= beans_output( 'beans_comment_form_legend_text[_url]', esc_html__( 'Website', 'tm-beans' ) ); - } + $url .= beans_close_markup( 'beans_comment_form_legend[_url]', 'legend' ); + } - $url .= beans_selfclose_markup( 'beans_comment_form_field[_url]', 'input', array( - 'id' => 'url', - 'class' => 'uk-width-1-1', - 'type' => 'text', - 'value' => $commenter['comment_author_url'], // Automatically escaped. - 'name' => 'url', - ) ); + $url .= beans_selfclose_markup( + 'beans_comment_form_field[_url]', 'input', array( + 'id' => 'url', + 'class' => 'uk-width-1-1', + 'type' => 'text', + 'value' => $commenter['comment_author_url'], // Automatically escaped. + 'name' => 'url', + ) + ); $url .= beans_close_markup( 'beans_comment_form[_website]', 'div' ); $fields['url'] = $url; - } return $fields; @@ -573,11 +630,11 @@ function beans_comment_form_fields( $fields ) { * the user is not logged in. * * @since 1.0.0 + * + * @return void */ function beans_comment_form_after_fields() { - beans_close_markup_e( 'beans_comment_fields_inner_wrap', 'div' ); beans_close_markup_e( 'beans_comment_fields_wrap', 'div' ); - } diff --git a/lib/templates/fragments/deprecated.php b/lib/templates/fragments/deprecated.php index ed077bc8..bb7ea560 100644 --- a/lib/templates/fragments/deprecated.php +++ b/lib/templates/fragments/deprecated.php @@ -2,7 +2,9 @@ /** * Deprecated fragments. * - * @package Fragments\Deprecated + * @package Beans\Framework\Templates\Fragments + * + * @since 1.0.0 */ /** @@ -12,13 +14,12 @@ * * @since 1.0.0 * @deprecated 1.2.0 + * + * @return void */ function beans_head_title() { - _deprecated_function( __FUNCTION__, '1.2.0', 'wp_title()' ); - wp_title( '|', true, 'right' ); - } /** @@ -35,9 +36,7 @@ function beans_head_title() { * @return string The modified title. */ function beans_wp_title( $title, $sep ) { - _deprecated_function( __FUNCTION__, '1.2.0', 'wp_title()' ); - global $page, $paged; if ( is_feed() ) { @@ -48,34 +47,40 @@ function beans_wp_title( $title, $sep ) { $title .= get_bloginfo( 'name' ); // Add the blog description for the home/front page. - if ( ( $site_description = get_bloginfo( 'description', 'display' ) ) && ( is_home() || is_front_page() ) ) { + $site_description = get_bloginfo( 'description', 'display' ); + + if ( $site_desciption && ( is_home() || is_front_page() ) ) { $title .= " $sep $site_description"; } // Add a page number if necessary. if ( $paged >= 2 || $page >= 2 ) { + // translators: Page number. $title .= " $sep " . sprintf( __( 'Page %s', 'tm-beans' ), max( $paged, $page ) ); } return $title; - } /** * Deprecated shortcodes. * - * We declare the shortcodes for backward compatibility purposes but it shouldn't be used for further development. + * We declare the shortcodes for backward compatibility purposes but they shouldn't be used for further development. * * @deprecated 1.2.0 * * @ignore + * + * @return void */ global $shortcode_tags; -$shortcode_tags = array_merge( $shortcode_tags, array( - 'beans_post_meta_date' => 'beans_post_meta_date_shortcode', - 'beans_post_meta_author' => 'beans_post_meta_author_shortcode', - 'beans_post_meta_comments' => 'beans_post_meta_comments_shortcode', - 'beans_post_meta_tags' => 'beans_post_meta_tags_shortcode', - 'beans_post_meta_categories' => 'beans_post_meta_categories_shortcode', -) ); +$shortcode_tags = array_merge( // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Deprecated function. + $shortcode_tags, array( + 'beans_post_meta_date' => 'beans_post_meta_date_shortcode', + 'beans_post_meta_author' => 'beans_post_meta_author_shortcode', + 'beans_post_meta_comments' => 'beans_post_meta_comments_shortcode', + 'beans_post_meta_tags' => 'beans_post_meta_tags_shortcode', + 'beans_post_meta_categories' => 'beans_post_meta_categories_shortcode', + ) +); diff --git a/lib/templates/fragments/embed.php b/lib/templates/fragments/embed.php index 11954761..10a92c1f 100644 --- a/lib/templates/fragments/embed.php +++ b/lib/templates/fragments/embed.php @@ -2,7 +2,9 @@ /** * Extends WordPress Embed. * - * @package Fragments\Embed + * @package Beans\Framework\Templates\Fragments + * + * @since 1.0.0 */ // Filter. @@ -17,7 +19,6 @@ * @return string The modified embed HTML. */ function beans_embed_oembed( $html ) { - $output = beans_open_markup( 'beans_embed_oembed', 'div', 'class=tm-oembed' ); $output .= $html; @@ -25,5 +26,4 @@ function beans_embed_oembed( $html ) { $output .= beans_close_markup( 'beans_embed_oembed', 'div' ); return $output; - } diff --git a/lib/templates/fragments/footer.php b/lib/templates/fragments/footer.php index 33164413..11685252 100644 --- a/lib/templates/fragments/footer.php +++ b/lib/templates/fragments/footer.php @@ -2,7 +2,9 @@ /** * Echo footer fragments. * - * @package Fragments\Footer + * @package Beans\Framework\Templates\Fragments + * + * @since 1.0.0 */ beans_add_smart_action( 'beans_footer', 'beans_footer_content' ); @@ -10,45 +12,53 @@ * Echo the footer content. * * @since 1.0.0 + * + * @return void */ function beans_footer_content() { - beans_open_markup_e( 'beans_footer_credit', 'div', array( 'class' => 'uk-clearfix uk-text-small uk-text-muted' ) ); - beans_open_markup_e( 'beans_footer_credit_left', 'span', array( - 'class' => 'uk-align-medium-left uk-margin-small-bottom', - ) ); + beans_open_markup_e( 'beans_footer_credit_left', 'span', array( 'class' => 'uk-align-medium-left uk-margin-small-bottom' ) ); - beans_output_e( 'beans_footer_credit_text', sprintf( - __( '© %1$s - %2$s. All rights reserved.', 'tm-beans' ), - date( 'Y' ), - get_bloginfo( 'name' ) - ) ); + beans_output_e( + 'beans_footer_credit_text', + sprintf( + // translators: Footer credits. Date followed by the name of the website. + __( '© %1$s - %2$s. All rights reserved.', 'tm-beans' ), + date( 'Y' ), + get_bloginfo( 'name' ) + ) + ); beans_close_markup_e( 'beans_footer_credit_left', 'span' ); - $framework_link = beans_open_markup( 'beans_footer_credit_framework_link', 'a', array( - 'href' => 'http://www.getbeans.io', // Automatically escaped. - 'rel' => 'designer', - ) ); + $framework_link = beans_open_markup( + 'beans_footer_credit_framework_link', + 'a', + array( + 'href' => 'https://www.getbeans.io', // Automatically escaped. + 'rel' => 'nofollow', + ) + ); $framework_link .= beans_output( 'beans_footer_credit_framework_link_text', 'Beans' ); $framework_link .= beans_close_markup( 'beans_footer_credit_framework_link', 'a' ); - beans_open_markup_e( 'beans_footer_credit_right', 'span', array( - 'class' => 'uk-align-medium-right uk-margin-bottom-remove', - ) ); + beans_open_markup_e( 'beans_footer_credit_right', 'span', array( 'class' => 'uk-align-medium-right uk-margin-bottom-remove' ) ); - beans_output_e( 'beans_footer_credit_right_text', sprintf( - __( '%1$s theme for WordPress.', 'tm-beans' ), - $framework_link - ) ); + beans_output_e( + 'beans_footer_credit_right_text', + sprintf( + // translators: Link to the Beans website. + __( '%1$s theme for WordPress.', 'tm-beans' ), + $framework_link + ) + ); beans_close_markup_e( 'beans_footer_credit_right', 'span' ); beans_close_markup_e( 'beans_footer_credit', 'div' ); - } beans_add_smart_action( 'wp_footer', 'beans_replace_nojs_class' ); @@ -56,13 +66,14 @@ function beans_footer_content() { * Print inline JavaScript in the footer to replace the 'no-js' class with 'js'. * * @since 1.0.0 + * + * @return void */ function beans_replace_nojs_class() { - ?> + - + + + 'Shortcut Icon', - 'href' => $url, // Automatically escaped. - 'type' => 'image/x-icon', - ) ); - + beans_selfclose_markup_e( + 'beans_favicon', + 'link', + array( + 'rel' => 'Shortcut Icon', + 'href' => $url, // Automatically escaped. + 'type' => 'image/x-icon', + ) + ); } beans_add_smart_action( 'wp_head', 'beans_header_image' ); @@ -60,22 +69,26 @@ function beans_favicon() { * Print the header image css inline in the header. * * @since 1.0.0 + * + * @return void */ function beans_header_image() { + $header_image = get_header_image(); - if ( ! current_theme_supports( 'custom-header' ) || ! ( $header_image = get_header_image() ) || empty( $header_image ) ) { + if ( ! current_theme_supports( 'custom-header' ) || ! $header_image || empty( $header_image ) ) { return; } - ?> + 'tm-site-branding uk-float-left' . ( ! get_bloginfo( 'description' ) ? ' uk-margin-small-top' : null ), - ) ); - - beans_open_markup_e( 'beans_site_title_link', 'a', array( - 'href' => home_url(), // Automatically escaped. - 'rel' => 'home', - 'itemprop' => 'headline', - ) ); - - if ( $logo = get_theme_mod( 'beans_logo_image', false ) ) { - beans_selfclose_markup_e( 'beans_logo_image', 'img', array( - 'class' => 'tm-logo', - 'src' => $logo, // Automatically escaped. - 'alt' => get_bloginfo( 'name' ), // Automatically escaped. - ) ); + beans_open_markup_e( + 'beans_site_branding', + 'div', + array( + 'class' => 'tm-site-branding uk-float-left' . ( ! get_bloginfo( 'description' ) ? ' uk-margin-small-top' : null ), + ) + ); + + beans_open_markup_e( + 'beans_site_title_link', + 'a', + array( + 'href' => home_url(), // Automatically escaped. + 'rel' => 'home', + 'itemprop' => 'headline', + ) + ); + + $logo = get_theme_mod( 'beans_logo_image', false ); + + // phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact -- Code structure mimics HTML markup. + if ( $logo ) { + beans_selfclose_markup_e( + 'beans_logo_image', + 'img', + array( + 'class' => 'tm-logo', + 'src' => $logo, // Automatically escaped. + 'alt' => get_bloginfo( 'name' ), // Automatically escaped. + ) + ); } else { beans_output_e( 'beans_site_title_text', get_bloginfo( 'name' ) ); } + // phpcs:enable Generic.WhiteSpace.ScopeIndent.IncorrectExact -- Code structure mimics HTML markup. beans_close_markup_e( 'beans_site_title_link', 'a' ); beans_close_markup_e( 'beans_site_branding', 'div' ); - } beans_add_smart_action( 'beans_site_branding_append_markup', 'beans_site_title_tag' ); @@ -117,21 +146,27 @@ function beans_site_branding() { * Echo header site title tag. * * @since 1.0.0 + * + * @return void */ function beans_site_title_tag() { - // Stop here if there isn't a description. - if ( ! $description = get_bloginfo( 'description' ) ) { + $description = get_bloginfo( 'description' ); + + if ( ! $description ) { return; } - beans_open_markup_e( 'beans_site_title_tag', 'span', array( - 'class' => 'tm-site-title-tag uk-text-small uk-text-muted uk-display-block', - 'itemprop' => 'description', - ) ); + beans_open_markup_e( + 'beans_site_title_tag', + 'span', + array( + 'class' => 'tm-site-title-tag uk-text-small uk-text-muted uk-display-block', + 'itemprop' => 'description', + ) + ); beans_output_e( 'beans_site_title_tag_text', $description ); beans_close_markup_e( 'beans_site_title_tag', 'span' ); - } diff --git a/lib/templates/fragments/menu.php b/lib/templates/fragments/menu.php index 27c2aa28..1c49b17e 100644 --- a/lib/templates/fragments/menu.php +++ b/lib/templates/fragments/menu.php @@ -2,7 +2,9 @@ /** * Echo menu fragments. * - * @package Fragments\Menu + * @package Beans\Framework\Templates\Fragments + * + * @since 1.0.0 */ beans_add_smart_action( 'beans_header', 'beans_primary_menu', 15 ); @@ -10,17 +12,26 @@ * Echo primary menu. * * @since 1.0.0 + * @since 1.5.0 Added ID and tabindex for skip links. + * + * @return void */ function beans_primary_menu() { - $nav_visibility = current_theme_supports( 'offcanvas-menu' ) ? 'uk-visible-large' : ''; - beans_open_markup_e( 'beans_primary_menu', 'nav', array( - 'class' => 'tm-primary-menu uk-float-right uk-navbar', - 'role' => 'navigation', - 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/SiteNavigationElement', - ) ); + beans_open_markup_e( + 'beans_primary_menu', + 'nav', + array( + 'class' => 'tm-primary-menu uk-float-right uk-navbar', + 'id' => 'beans-primary-navigation', + 'role' => 'navigation', + 'itemscope' => 'itemscope', + 'itemtype' => 'https://schema.org/SiteNavigationElement', + 'aria-label' => esc_attr__( 'Primary Navigation Menu', 'tm-beans' ), + 'tabindex' => '-1', + ) + ); /** * Filter the primary menu arguments. @@ -29,20 +40,22 @@ function beans_primary_menu() { * * @param array $args Nav menu arguments. */ - $args = apply_filters( 'beans_primary_menu_args', array( - 'theme_location' => has_nav_menu( 'primary' ) ? 'primary' : '', - 'fallback_cb' => 'beans_no_menu_notice', - 'container' => '', - 'menu_class' => $nav_visibility, // Automatically escaped. - 'echo' => false, - 'beans_type' => 'navbar', - ) ); + $args = apply_filters( + 'beans_primary_menu_args', + array( + 'theme_location' => has_nav_menu( 'primary' ) ? 'primary' : '', + 'fallback_cb' => 'beans_no_menu_notice', + 'container' => '', + 'menu_class' => $nav_visibility, // Automatically escaped. + 'echo' => false, + 'beans_type' => 'navbar', + ) + ); // Navigation. beans_output_e( 'beans_primary_menu', wp_nav_menu( $args ) ); beans_close_markup_e( 'beans_primary_menu', 'nav' ); - } beans_add_smart_action( 'beans_primary_menu_append_markup', 'beans_primary_menu_offcanvas_button', 5 ); @@ -50,6 +63,8 @@ function beans_primary_menu() { * Echo primary menu offcanvas button. * * @since 1.0.0 + * + * @return void */ function beans_primary_menu_offcanvas_button() { @@ -57,22 +72,30 @@ function beans_primary_menu_offcanvas_button() { return; } - beans_open_markup_e( 'beans_primary_menu_offcanvas_button', 'a', array( - 'href' => '#offcanvas_menu', - 'class' => 'uk-button uk-hidden-large', - 'data-uk-offcanvas' => '', - ) ); - - beans_open_markup_e( 'beans_primary_menu_offcanvas_button_icon', 'i', array( - 'class' => 'uk-icon-navicon uk-margin-small-right', - ) ); - - beans_close_markup_e( 'beans_primary_menu_offcanvas_button_icon', 'i' ); - - beans_output_e( 'beans_offcanvas_menu_button', __( 'Menu', 'tm-beans' ) ); + beans_open_markup_e( + 'beans_primary_menu_offcanvas_button', + 'a', + array( + 'href' => '#offcanvas_menu', + 'class' => 'uk-button uk-hidden-large', + 'data-uk-offcanvas' => '', + ) + ); + + beans_open_markup_e( + 'beans_primary_menu_offcanvas_button_icon', + 'span', + array( + 'class' => 'uk-icon-navicon uk-margin-small-right', + 'aria-hidden' => 'true', + ) + ); + + beans_close_markup_e( 'beans_primary_menu_offcanvas_button_icon', 'span' ); + + beans_output_e( 'beans_offcanvas_menu_button', esc_html__( 'Menu', 'tm-beans' ) ); beans_close_markup_e( 'beans_primary_menu_offcanvas_button', 'a' ); - } beans_add_smart_action( 'beans_widget_area_offcanvas_bar_offcanvas_menu_prepend_markup', 'beans_primary_offcanvas_menu' ); @@ -80,6 +103,8 @@ function beans_primary_menu_offcanvas_button() { * Echo off-canvas primary menu. * * @since 1.0.0 + * + * @return void */ function beans_primary_offcanvas_menu() { @@ -87,10 +112,15 @@ function beans_primary_offcanvas_menu() { return; } - beans_open_markup_e( 'beans_primary_offcanvas_menu', 'nav', array( - 'class' => 'tm-primary-offcanvas-menu uk-margin uk-margin-top', - 'role' => 'navigation', - ) ); + beans_open_markup_e( + 'beans_primary_offcanvas_menu', + 'nav', + array( + 'class' => 'tm-primary-offcanvas-menu uk-margin uk-margin-top', + 'role' => 'navigation', + 'aria-label' => esc_attr__( 'Off-Canvas Primary Navigation Menu', 'tm-beans' ), + ) + ); /** * Filter the off-canvas primary menu arguments. @@ -99,31 +129,33 @@ function beans_primary_offcanvas_menu() { * * @param array $args Off-canvas nav menu arguments. */ - $args = apply_filters( 'beans_primary_offcanvas_menu_args', array( - 'theme_location' => has_nav_menu( 'primary' ) ? 'primary' : '', - 'fallback_cb' => 'beans_no_menu_notice', - 'container' => '', - 'echo' => false, - 'beans_type' => 'offcanvas', - ) ); + $args = apply_filters( + 'beans_primary_offcanvas_menu_args', + array( + 'theme_location' => has_nav_menu( 'primary' ) ? 'primary' : '', + 'fallback_cb' => 'beans_no_menu_notice', + 'container' => '', + 'echo' => false, + 'beans_type' => 'offcanvas', + ) + ); beans_output_e( 'beans_primary_offcanvas_menu', wp_nav_menu( $args ) ); beans_close_markup_e( 'beans_primary_offcanvas_menu', 'nav' ); - } /** * Echo no menu notice. * * @since 1.0.0 + * + * @return void */ function beans_no_menu_notice() { - beans_open_markup_e( 'beans_no_menu_notice', 'p', array( 'class' => 'uk-alert uk-alert-warning' ) ); - beans_output_e( 'beans_no_menu_notice_text', __( 'Whoops, your site does not have a menu!', 'tm-beans' ) ); + beans_output_e( 'beans_no_menu_notice_text', esc_html__( 'Whoops, your site does not have a menu!', 'tm-beans' ) ); beans_close_markup_e( 'beans_no_menu_notice', 'p' ); - } diff --git a/lib/templates/fragments/post-shortcodes.php b/lib/templates/fragments/post-shortcodes.php index 758773b0..20ab6fa7 100644 --- a/lib/templates/fragments/post-shortcodes.php +++ b/lib/templates/fragments/post-shortcodes.php @@ -2,7 +2,9 @@ /** * Add post shortcodes. * - * @package Fragments\Post_Shortcodes + * @package Beans\Framework\Templates\Fragments + * + * @since 1.0.0 */ beans_add_smart_action( 'beans_post_meta_date', 'beans_post_meta_date_shortcode' ); @@ -10,20 +12,24 @@ * Echo post meta date shortcode. * * @since 1.0.0 + * + * @return void */ function beans_post_meta_date_shortcode() { + beans_output_e( 'beans_post_meta_date_prefix', esc_html__( 'Posted on ', 'tm-beans' ) ); - beans_output_e( 'beans_post_meta_date_prefix', __( 'Posted on ', 'tm-beans' ) ); - - beans_open_markup_e( 'beans_post_meta_date', 'time', array( - 'datetime' => get_the_time( 'c' ), - 'itemprop' => 'datePublished', - ) ); + beans_open_markup_e( + 'beans_post_meta_date', + 'time', + array( + 'datetime' => get_the_time( 'c' ), + 'itemprop' => 'datePublished', + ) + ); beans_output_e( 'beans_post_meta_date_text', get_the_time( get_option( 'date_format' ) ) ); beans_close_markup_e( 'beans_post_meta_date', 'time' ); - } beans_add_smart_action( 'beans_post_meta_author', 'beans_post_meta_author_shortcode' ); @@ -31,28 +37,36 @@ function beans_post_meta_date_shortcode() { * Echo post meta author shortcode. * * @since 1.0.0 + * + * @return void */ function beans_post_meta_author_shortcode() { - - beans_output_e( 'beans_post_meta_author_prefix', __( 'By ', 'tm-beans' ) ); - - beans_open_markup_e( 'beans_post_meta_author', 'a', array( - 'href' => get_author_posts_url( get_the_author_meta( 'ID' ) ), // Automatically escaped. - 'rel' => 'author', - 'itemprop' => 'author', - 'itemscope' => '', - 'itemtype' => 'http://schema.org/Person', - ) ); + beans_output_e( 'beans_post_meta_author_prefix', esc_html__( 'By ', 'tm-beans' ) ); + + beans_open_markup_e( + 'beans_post_meta_author', + 'a', + array( + 'href' => get_author_posts_url( get_the_author_meta( 'ID' ) ), // Automatically escaped. + 'rel' => 'author', + 'itemprop' => 'author', + 'itemscope' => '', + 'itemtype' => 'https://schema.org/Person', + ) + ); beans_output_e( 'beans_post_meta_author_text', get_the_author() ); - beans_selfclose_markup_e( 'beans_post_meta_author_name_meta', 'meta', array( - 'itemprop' => 'name', - 'content' => get_the_author(), // Automatically escaped. - ) ); + beans_selfclose_markup_e( + 'beans_post_meta_author_name_meta', + 'meta', + array( + 'itemprop' => 'name', + 'content' => get_the_author(), // Automatically escaped. + ) + ); beans_close_markup_e( 'beans_post_meta_author', 'a' ); - } beans_add_smart_action( 'beans_post_meta_comments', 'beans_post_meta_comments_shortcode' ); @@ -60,33 +74,35 @@ function beans_post_meta_author_shortcode() { * Echo post meta comments shortcode. * * @since 1.0.0 + * + * @return void */ function beans_post_meta_comments_shortcode() { - global $post; - if ( post_password_required() || ! comments_open() ) { return; } + global $post; $comments_number = (int) get_comments_number( $post->ID ); if ( $comments_number < 1 ) { - $comment_text = beans_output( 'beans_post_meta_empty_comment_text', __( 'Leave a comment', 'tm-beans' ) ); + $comment_text = beans_output( 'beans_post_meta_empty_comment_text', esc_html__( 'Leave a comment', 'tm-beans' ) ); } elseif ( 1 === $comments_number ) { - $comment_text = beans_output( 'beans_post_meta_comments_text_singular', __( '1 comment', 'tm-beans' ) ); + $comment_text = beans_output( 'beans_post_meta_comments_text_singular', esc_html__( '1 comment', 'tm-beans' ) ); } else { - $comment_text = beans_output( 'beans_post_meta_comments_text_plurial', __( '%s comments', 'tm-beans' ) ); + $comment_text = beans_output( + 'beans_post_meta_comments_text_plural', + // translators: %s: Number of comments. Plural. + esc_html__( '%s comments', 'tm-beans' ) + ); } - beans_open_markup_e( 'beans_post_meta_comments', 'a', array( - 'href' => get_comments_link(), // Automatically escaped. - ) ); + beans_open_markup_e( 'beans_post_meta_comments', 'a', array( 'href' => get_comments_link() ) ); // Automatically escaped. - printf( $comment_text, (int) get_comments_number( $post->ID ) ); + printf( $comment_text, (int) get_comments_number( $post->ID ) ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Escaping handled prior to this printf. beans_close_markup_e( 'beans_post_meta_comments', 'a' ); - } beans_add_smart_action( 'beans_post_meta_tags', 'beans_post_meta_tags_shortcode' ); @@ -94,17 +110,17 @@ function beans_post_meta_comments_shortcode() { * Echo post meta tags shortcode. * * @since 1.0.0 + * + * @return void */ function beans_post_meta_tags_shortcode() { - $tags = get_the_tag_list( null, ', ' ); if ( ! $tags || is_wp_error( $tags ) ) { return; } - printf( '%1$s%2$s', beans_output( 'beans_post_meta_tags_prefix', __( 'Tagged with: ', 'tm-beans' ) ), $tags ); - + printf( '%1$s%2$s', beans_output( 'beans_post_meta_tags_prefix', esc_html__( 'Tagged with: ', 'tm-beans' ) ), $tags ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Tags are escaped by WordPress. } beans_add_smart_action( 'beans_post_meta_categories', 'beans_post_meta_categories_shortcode' ); @@ -112,15 +128,15 @@ function beans_post_meta_tags_shortcode() { * Echo post meta categories shortcode. * * @since 1.0.0 + * + * @return void */ function beans_post_meta_categories_shortcode() { - $categories = get_the_category_list( ', ' ); if ( ! $categories || is_wp_error( $categories ) ) { return; } - printf( '%1$s%2$s', beans_output( 'beans_post_meta_categories_prefix', __( 'Filed under: ', 'tm-beans' ) ), $categories ); - + printf( '%1$s%2$s', beans_output( 'beans_post_meta_categories_prefix', esc_html__( 'Filed under: ', 'tm-beans' ) ), $categories ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Categories are escaped by WordPress. } diff --git a/lib/templates/fragments/post.php b/lib/templates/fragments/post.php index 02cbf5d4..1dfe5447 100644 --- a/lib/templates/fragments/post.php +++ b/lib/templates/fragments/post.php @@ -2,7 +2,9 @@ /** * Echo post fragments. * - * @package Fragments\Post + * @package Beans\Framework\Templates\Fragments + * + * @since 1.0.0 */ beans_add_smart_action( 'beans_post_header', 'beans_post_title' ); @@ -10,10 +12,11 @@ * Echo post title. * * @since 1.0.0 + * + * @return void */ function beans_post_title() { - - $title = beans_output( 'beans_post_title_text', get_the_title() ); + $title = beans_output( 'beans_post_title_text', get_the_title() ); $title_tag = 'h1'; if ( empty( $title ) ) { @@ -21,31 +24,35 @@ function beans_post_title() { } if ( ! is_singular() ) { + $title_link = beans_open_markup( + 'beans_post_title_link', + 'a', + array( + 'href' => get_permalink(), // Automatically escaped. + 'title' => the_title_attribute( 'echo=0' ), + 'rel' => 'bookmark', + ) + ); - $title_link = beans_open_markup( 'beans_post_title_link', 'a', array( - 'href' => get_permalink(), // Automatically escaped. - 'title' => the_title_attribute( 'echo=0' ), - 'rel' => 'bookmark', - ) ); - - $title_link .= $title; - + $title_link .= $title; $title_link .= beans_close_markup( 'beans_post_title_link', 'a' ); - $title = $title_link; + $title = $title_link; $title_tag = 'h2'; - } - beans_open_markup_e( 'beans_post_title', $title_tag, array( - 'class' => 'uk-article-title', - 'itemprop' => 'headline', - ) ); + beans_open_markup_e( + 'beans_post_title', + $title_tag, + array( + 'class' => 'uk-article-title', + 'itemprop' => 'headline', + ) + ); - echo $title; + echo $title; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. beans_close_markup_e( 'beans_post_title', $title_tag ); - } beans_add_smart_action( 'beans_before_loop', 'beans_post_search_title' ); @@ -53,6 +60,8 @@ function beans_post_title() { * Echo search post title. * * @since 1.0.0 + * + * @return void */ function beans_post_search_title() { @@ -62,10 +71,9 @@ function beans_post_search_title() { beans_open_markup_e( 'beans_search_title', 'h1', array( 'class' => 'uk-article-title' ) ); - printf( '%1$s%2$s', beans_output( 'beans_search_title_text', __( 'Search results for: ', 'tm-beans' ) ), get_search_query() ); + printf( '%1$s%2$s', beans_output( 'beans_search_title_text', esc_html__( 'Search results for: ', 'tm-beans' ) ), get_search_query() ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Each placeholder is escaped. beans_close_markup_e( 'beans_search_title', 'h1' ); - } @@ -74,6 +82,8 @@ function beans_post_search_title() { * Echo archive post title. * * @since 1.4.0 + * + * @return void */ function beans_post_archive_title() { @@ -86,7 +96,6 @@ function beans_post_archive_title() { beans_output_e( 'beans_archive_title_text', get_the_archive_title() ); beans_close_markup_e( 'beans_archive_title', 'h1' ); - } beans_add_smart_action( 'beans_post_header', 'beans_post_meta', 15 ); @@ -94,6 +103,8 @@ function beans_post_archive_title() { * Echo post meta. * * @since 1.0.0 + * + * @return void */ function beans_post_meta() { @@ -104,7 +115,7 @@ function beans_post_meta() { * * @param bool $pre True to short-circuit, False to let the function run. */ - if ( apply_filters( 'beans_pre_post_meta', 'post' != get_post_type() ) ) { + if ( apply_filters( 'beans_pre_post_meta', 'post' !== get_post_type() ) ) { return; } @@ -120,30 +131,33 @@ function beans_post_meta() { * * @param array $fragments An array of fragment files. */ - $meta_items = apply_filters( 'beans_post_meta_items', array( - 'date' => 10, - 'author' => 20, - 'comments' => 30, - ) ); + $meta_items = apply_filters( + 'beans_post_meta_items', + array( + 'date' => 10, + 'author' => 20, + 'comments' => 30, + ) + ); asort( $meta_items ); - foreach ( $meta_items as $meta => $priority ) { + foreach ( $meta_items as $meta => $priority ) { - if ( ! $content = beans_render_function( 'do_action', "beans_post_meta_$meta" ) ) { - continue; - } + $content = beans_render_function( 'do_action', "beans_post_meta_$meta" ); - beans_open_markup_e( "beans_post_meta_item[_{$meta}]", 'li' ); + if ( ! $content ) { + continue; + } - beans_output_e( "beans_post_meta_item_{$meta}_text", $content ); + beans_open_markup_e( "beans_post_meta_item[_{$meta}]", 'li' ); - beans_close_markup_e( "beans_post_meta_item[_{$meta}]", 'li' ); + beans_output_e( "beans_post_meta_item_{$meta}_text", $content ); - } + beans_close_markup_e( "beans_post_meta_item[_{$meta}]", 'li' ); + } beans_close_markup_e( 'beans_post_meta', 'ul' ); - } beans_add_smart_action( 'beans_post_body', 'beans_post_image', 5 ); @@ -151,6 +165,8 @@ function beans_post_meta() { * Echo post image. * * @since 1.0.0 + * + * @return bool */ function beans_post_image() { @@ -165,7 +181,7 @@ function beans_post_image() { * * @since 1.2.5 * - * @param bool $edit True to use Beans Image API to handle the image edition (resize), false to let {@link http://codex.wordpress.org/Function_Reference/the_post_thumbnail the_post_thumbnail()} taking care of it. Default true. + * @param bool $edit True to use Beans Image API to handle the image edition (resize), false to let {@link https://codex.wordpress.org/Function_Reference/the_post_thumbnail the_post_thumbnail()} taking care of it. Default true. */ $edit = apply_filters( 'beans_post_image_edit', true ); @@ -179,9 +195,12 @@ function beans_post_image() { * @param bool|array $edit_args Arguments used by {@see beans_edit_image()}. Set to false to use WordPress * large size. */ - $edit_args = apply_filters( 'beans_edit_post_image_args', array( - 'resize' => array( 800, false ), - ) ); + $edit_args = apply_filters( + 'beans_edit_post_image_args', + array( + 'resize' => array( 800, false ), + ) + ); if ( empty( $edit_args ) ) { $image = beans_get_post_attachment( $post->ID, 'large' ); @@ -199,9 +218,12 @@ function beans_post_image() { * @param bool|array $edit_args Arguments used by {@see beans_edit_image()}. Set to false to use WordPress * small size. */ - $edit_small_args = apply_filters( 'beans_edit_post_image_small_args', array( - 'resize' => array( 480, false ), - ) ); + $edit_small_args = apply_filters( + 'beans_edit_post_image_small_args', + array( + 'resize' => array( 480, false ), + ) + ); if ( empty( $edit_small_args ) ) { $image_small = beans_get_post_attachment( $post->ID, 'thumbnail' ); @@ -212,45 +234,54 @@ function beans_post_image() { beans_open_markup_e( 'beans_post_image', 'div', array( 'class' => 'tm-article-image' ) ); - if ( ! is_singular() ) { - beans_open_markup_e( 'beans_post_image_link', 'a', array( + if ( ! is_singular() ) { + beans_open_markup_e( + 'beans_post_image_link', + 'a', + array( 'href' => get_permalink(), // Automatically escaped. 'title' => the_title_attribute( 'echo=0' ), - ) ); - } + ) + ); + } beans_open_markup_e( 'beans_post_image_item_wrap', 'picture' ); - if ( $edit ) { - - beans_selfclose_markup_e( 'beans_post_image_small_item', 'source', array( - 'media' => '(max-width: ' . $image_small->width . 'px)', - 'srcset' => esc_url( $image_small->src ), - ), $image_small ); - - beans_selfclose_markup_e( 'beans_post_image_item', 'img', array( - 'width' => $image->width, - 'height' => $image->height, - 'src' => $image->src, // Automatically escaped. - 'alt' => $image->alt, // Automatically escaped. - 'itemprop' => 'image', - ), $image ); - - } else { - - // Beans API isn't available, use wp_get_attachment_image_attributes filter instead. - the_post_thumbnail(); - - } + if ( $edit ) { + beans_selfclose_markup_e( + 'beans_post_image_small_item', + 'source', + array( + 'media' => '(max-width: ' . $image_small->width . 'px)', + 'srcset' => esc_url( $image_small->src ), + ), + $image_small + ); + + beans_selfclose_markup_e( + 'beans_post_image_item', + 'img', + array( + 'width' => $image->width, + 'height' => $image->height, + 'src' => $image->src, // Automatically escaped. + 'alt' => $image->alt, // Automatically escaped. + 'itemprop' => 'image', + ), + $image + ); + } else { + // Beans API isn't available, use wp_get_attachment_image_attributes filter instead. + the_post_thumbnail(); + } beans_close_markup_e( 'beans_post_image_item_wrap', 'picture' ); - if ( ! is_singular() ) { - beans_close_markup_e( 'beans_post_image_link', 'a' ); - } + if ( ! is_singular() ) { + beans_close_markup_e( 'beans_post_image_link', 'a' ); + } beans_close_markup_e( 'beans_post_image', 'div' ); - } beans_add_smart_action( 'beans_post_body', 'beans_post_content' ); @@ -258,28 +289,30 @@ function beans_post_image() { * Echo post content. * * @since 1.0.0 + * + * @return void */ function beans_post_content() { - global $post; - beans_open_markup_e( 'beans_post_content', 'div', array( - 'class' => 'tm-article-content', - 'itemprop' => 'text', - ) ); + beans_open_markup_e( + 'beans_post_content', + 'div', + array( + 'class' => 'tm-article-content', + 'itemprop' => 'text', + ) + ); the_content(); - if ( is_singular() && 'open' === get_option( 'default_ping_status' ) && post_type_supports( $post->post_type, 'trackbacks' ) ) { - - echo '' . "\n"; - - } + if ( is_singular() && 'open' === get_option( 'default_ping_status' ) && post_type_supports( $post->post_type, 'trackbacks' ) ) { + echo '' . "\n"; + } beans_close_markup_e( 'beans_post_content', 'div' ); - } // Filter. @@ -292,25 +325,32 @@ function beans_post_content() { * @return string The modified "more link". */ function beans_post_more_link() { - global $post; - $output = beans_open_markup( 'beans_post_more_link', 'a', array( - 'href' => get_permalink(), // Automatically escaped. - 'class' => 'more-link', - ) ); + $output = beans_open_markup( + 'beans_post_more_link', + 'a', + array( + 'href' => get_permalink(), // Automatically escaped. + 'class' => 'more-link', + ) + ); - $output .= beans_output( 'beans_post_more_link_text', __( 'Continue reading', 'tm-beans' ) ); + $output .= beans_output( 'beans_post_more_link_text', esc_html__( 'Continue reading', 'tm-beans' ) ); - $output .= beans_open_markup( 'beans_next_icon[_more_link]', 'i', array( - 'class' => 'uk-icon-angle-double-right uk-margin-small-left', - ) ); - $output .= beans_close_markup( 'beans_previous_icon[_more_link]', 'i' ); + $output .= beans_open_markup( + 'beans_next_icon[_more_link]', + 'span', + array( + 'class' => 'uk-icon-angle-double-right uk-margin-small-left', + 'aria-hidden' => 'true', + ) + ); + $output .= beans_close_markup( 'beans_next_icon[_more_link]', 'span' ); $output .= beans_close_markup( 'beans_post_more_link', 'a' ); return $output; - } beans_add_smart_action( 'beans_post_body', 'beans_post_content_navigation', 20 ); @@ -318,15 +358,17 @@ function beans_post_more_link() { * Echo post content navigation. * * @since 1.0.0 + * + * @return void */ function beans_post_content_navigation() { - - echo wp_link_pages( array( - 'before' => beans_open_markup( 'beans_post_content_navigation', 'p', array( 'class' => 'uk-text-bold' ) ) . beans_output( 'beans_post_content_navigation_text', __( 'Pages:', 'tm-beans' ) ), - 'after' => beans_close_markup( 'beans_post_content_navigation', 'p' ), - 'echo' => false, - ) ); - + echo wp_link_pages( + array( + 'before' => beans_open_markup( 'beans_post_content_navigation', 'p', array( 'class' => 'uk-text-bold' ) ) . beans_output( 'beans_post_content_navigation_text', __( 'Pages:', 'tm-beans' ) ), + 'after' => beans_close_markup( 'beans_post_content_navigation', 'p' ), + 'echo' => false, + ) + ); } beans_add_smart_action( 'beans_post_body', 'beans_post_meta_categories', 25 ); @@ -334,19 +376,21 @@ function beans_post_content_navigation() { * Echo post meta categories. * * @since 1.0.0 + * + * @return void */ function beans_post_meta_categories() { + $categories = beans_render_function( 'do_shortcode', '[beans_post_meta_categories]' ); - if ( ! $categories = beans_render_function( 'do_shortcode', '[beans_post_meta_categories]' ) ) { + if ( ! $categories ) { return; } beans_open_markup_e( 'beans_post_meta_categories', 'span', array( 'class' => 'uk-text-small uk-text-muted uk-clearfix' ) ); - echo $categories; + echo $categories; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Shortcode's callback handles the escaping. See beans_post_meta_categories_shortcode(). beans_close_markup_e( 'beans_post_meta_categories', 'span' ); - } beans_add_smart_action( 'beans_post_body', 'beans_post_meta_tags', 30 ); @@ -356,17 +400,17 @@ function beans_post_meta_categories() { * @since 1.0.0 */ function beans_post_meta_tags() { + $tags = beans_render_function( 'do_shortcode', '[beans_post_meta_tags]' ); - if ( ! $tags = beans_render_function( 'do_shortcode', '[beans_post_meta_tags]' ) ) { + if ( ! $tags ) { return; } beans_open_markup_e( 'beans_post_meta_tags', 'span', array( 'class' => 'uk-text-small uk-text-muted uk-clearfix' ) ); - echo $tags; + echo $tags; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Shortcode's callback handles the escaping. See beans_post_meta_tags_shortcode(). beans_close_markup_e( 'beans_post_meta_tags', 'span' ); - } // Filter. @@ -376,31 +420,43 @@ function beans_post_meta_tags() { * * @since 1.0.0 * + * @param string $output "Next link" output. + * @param string $format Link output format. + * @param string $link Link permalink format. + * @param int $post Post ID. + * @return string The modified "previous link". */ function beans_previous_post_link( $output, $format, $link, $post ) { - // Using $link won't apply wp filters, so rather strip tags the $output. $text = strip_tags( $output ); - $output = beans_open_markup( 'beans_previous_link[_post_navigation]', 'a', array( - 'href' => get_permalink( $post ), // Automatically escaped. - 'rel' => 'previous', - 'title' => $post->post_title, // Automatically escaped. - ) ); + $output = beans_open_markup( + 'beans_previous_link[_post_navigation]', + 'a', + array( + 'href' => get_permalink( $post ), // Automatically escaped. + 'rel' => 'previous', + 'title' => $post->post_title, // Automatically escaped. + ) + ); - $output .= beans_open_markup( 'beans_previous_icon[_post_navigation]', 'i', array( - 'class' => 'uk-icon-angle-double-left uk-margin-small-right', - ) ); + $output .= beans_open_markup( + 'beans_previous_icon[_post_navigation]', + 'span', + array( + 'class' => 'uk-icon-angle-double-left uk-margin-small-right', + 'aria-hidden' => 'true', + ) + ); - $output .= beans_close_markup( 'beans_previous_icon[_post_navigation]', 'i' ); + $output .= beans_close_markup( 'beans_previous_icon[_post_navigation]', 'span' ); $output .= beans_output( 'beans_previous_text[_post_navigation]', $text ); $output .= beans_close_markup( 'beans_previous_link[_post_navigation]', 'a' ); return $output; - } // Filter. @@ -410,31 +466,43 @@ function beans_previous_post_link( $output, $format, $link, $post ) { * * @since 1.0.0 * + * @param string $output "Next link" output. + * @param string $format Link output format. + * @param string $link Link permalink format. + * @param int $post Post ID. + * * @return string The modified "next link". */ function beans_next_post_link( $output, $format, $link, $post ) { - - // Using $link won't apply wp filters, so rather strip tags the $output. + // Using $link won't apply WP filters, so rather strip tags the $output. $text = strip_tags( $output ); - $output = beans_open_markup( 'beans_next_link[_post_navigation]', 'a', array( - 'href' => get_permalink( $post ), // Automatically escaped. - 'rel' => 'next', - 'title' => $post->post_title, // Automatically escaped. - ) ); + $output = beans_open_markup( + 'beans_next_link[_post_navigation]', + 'a', + array( + 'href' => get_permalink( $post ), // Automatically escaped. + 'rel' => 'next', + 'title' => $post->post_title, // Automatically escaped. + ) + ); $output .= beans_output( 'beans_next_text[_post_navigation]', $text ); - $output .= beans_open_markup( 'beans_next_icon[_post_navigation]', 'i', array( - 'class' => 'uk-icon-angle-double-right uk-margin-small-left', - ) ); + $output .= beans_open_markup( + 'beans_next_icon[_post_navigation]', + 'span', + array( + 'class' => 'uk-icon-angle-double-right uk-margin-small-left', + 'aria-hidden' => 'true', + ) + ); - $output .= beans_close_markup( 'beans_previous_icon[_post_navigation]', 'i' ); + $output .= beans_close_markup( 'beans_next_icon[_post_navigation]', 'span' ); $output .= beans_close_markup( 'beans_next_link[_post_navigation]', 'a' ); return $output; - } beans_add_smart_action( 'beans_post_after_markup', 'beans_post_navigation' ); @@ -442,6 +510,10 @@ function beans_next_post_link( $output, $format, $link, $post ) { * Echo post navigation. * * @since 1.0.0 + * + * @return void + * + * phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact -- Layout mirrors HTML markup */ function beans_post_navigation() { @@ -456,42 +528,57 @@ function beans_post_navigation() { return; } - $previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true ); - $next = get_adjacent_post( false, '', false ); + $previous = is_attachment() ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true ); + $next = get_adjacent_post( false, '', false ); if ( ! $next && ! $previous ) { return; } - beans_open_markup_e( 'beans_post_navigation', 'ul', array( - 'class' => 'uk-pagination', - 'role' => 'navigation', - ) ); + beans_open_markup_e( + 'beans_post_navigation_nav_container', + 'nav', + array( + 'role' => 'navigation', + 'aria-label' => __( 'Pagination Navigation', 'tm-beans' ), // Attributes are automatically escaped. + ) + ); - if ( $previous ) { + beans_open_markup_e( + 'beans_post_navigation', + 'ul', + array( + 'class' => 'uk-pagination', + ) + ); - // Previous. + if ( $previous ) { beans_open_markup_e( 'beans_post_navigation_item[_previous]', 'li', array( 'class' => 'uk-pagination-previous' ) ); - echo get_previous_post_link( '%link', __( 'Previous', 'tm-beans' ) ); + // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. + echo get_previous_post_link( + '%link', + beans_output( 'beans_previous_text[_post_navigation_item]', __( 'Previous Page', 'tm-beans' ) ) + ); beans_close_markup_e( 'beans_post_navigation_item[_previous]', 'li' ); - } if ( $next ) { - - // Next. beans_open_markup_e( 'beans_post_navigation_item[_next]', 'li', array( 'class' => 'uk-pagination-next' ) ); - echo get_next_post_link( '%link', __( 'Next', 'tm-beans' ) ); + // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. + echo get_next_post_link( + '%link', + beans_output( 'beans_next_text[_post_navigation_item]', __( 'Next Page', 'tm-beans' ) ) + ); beans_close_markup_e( 'beans_post_navigation_item[_next]', 'li' ); - } - beans_close_markup_e( 'beans_post_navigation', 'ul' ); + beans_close_markup_e( 'beans_post_navigation', 'ul' ); + beans_close_markup_e( 'beans_post_navigation_nav_container', 'nav' ); } beans_add_smart_action( 'beans_after_posts_loop', 'beans_posts_pagination' ); @@ -499,6 +586,8 @@ function beans_post_navigation() { * Echo posts pagination. * * @since 1.0.0 + * + * @return void */ function beans_posts_pagination() { @@ -520,59 +609,78 @@ function beans_posts_pagination() { } $current = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1; - $count = intval( $wp_query->max_num_pages ); + $count = intval( $wp_query->max_num_pages ); + + beans_open_markup_e( + 'beans_posts_pagination_nav_container', + 'nav', + array( + 'role' => 'navigation', + 'aria-label' => __( 'Posts Pagination Navigation', 'tm-beans' ), // Attributes are automatically escaped. + ) + ); - beans_open_markup_e( 'beans_posts_pagination', 'ul', array( - 'class' => 'uk-pagination uk-grid-margin', - 'role' => 'navigation', - ) ); + beans_open_markup_e( + 'beans_posts_pagination', + 'ul', + array( + 'class' => 'uk-pagination uk-grid-margin', + ) + ); // Previous. if ( get_previous_posts_link() ) { - beans_open_markup_e( 'beans_posts_pagination_item[_previous]', 'li' ); - beans_open_markup_e( 'beans_previous_link[_posts_pagination]', 'a', array( - 'href' => previous_posts( false ), // Automatically escaped. - ), $current ); + beans_open_markup_e( + 'beans_previous_link[_posts_pagination]', + 'a', + array( + 'href' => previous_posts( false ), // Attributes are automatically escaped. + ), + $current + ); - beans_open_markup_e( 'beans_previous_icon[_posts_pagination]', 'i', array( - 'class' => 'uk-icon-angle-double-left uk-margin-small-right', - ) ); + beans_open_markup_e( + 'beans_previous_icon[_posts_pagination]', + 'span', + array( + 'class' => 'uk-icon-angle-double-left uk-margin-small-right', + 'aria-hidden' => 'true', + ) + ); - beans_close_markup_e( 'beans_previous_icon[_posts_pagination]', 'i' ); + beans_close_markup_e( 'beans_previous_icon[_posts_pagination]', 'span' ); - beans_output_e( 'beans_previous_text[_posts_pagination]', __( 'Previous', 'tm-beans' ) ); + beans_output_e( 'beans_previous_text[_posts_pagination]', esc_html__( 'Previous Page', 'tm-beans' ) ); beans_close_markup_e( 'beans_previous_link[_posts_pagination]', 'a' ); beans_close_markup_e( 'beans_posts_pagination_item[_previous]', 'li' ); - } // Links. - foreach ( range( 1, $wp_query->max_num_pages ) as $link ) { + foreach ( range( 1, (int) $wp_query->max_num_pages ) as $link ) { // Skip if next is set. - if ( isset( $next ) && $link != $next ) { + if ( isset( $next ) && $link !== $next ) { continue; } else { $next = $link + 1; } $is_separator = array( - 1 != $link, // Not first. - 1 == $current && 3 == $link ? false : true, // Force first 3 items. + 1 !== $link, // Not first. + 1 === $current && 3 === $link ? false : true, // Force first 3 items. $count > 3, // More. - $count != $link, // Not last. - ( $current - 1 ) != $link, // Not previous. - $current != $link, // Not current. - ( $current + 1 ) != $link, // Not next. + $count !== $link, // Not last. + ( $current - 1 ) !== $link, // Not previous. + $current !== $link, // Not current. + ( $current + 1 ) !== $link, // Not next. ); // Separator. - if ( ! in_array( false, $is_separator ) ) { - + if ( ! in_array( false, $is_separator, true ) ) { beans_open_markup_e( 'beans_posts_pagination_item[_separator]', 'li' ); beans_output_e( 'beans_posts_pagination_item_separator_text', '...' ); @@ -587,12 +695,10 @@ function beans_posts_pagination() { } continue; - } // Integer. - if ( $link == $current ) { - + if ( $link === $current ) { beans_open_markup_e( 'beans_posts_pagination_item[_active]', 'li', array( 'class' => 'uk-active' ) ); beans_open_markup_e( 'beans_posts_pagination_item[_active]_wrap', 'span' ); @@ -602,49 +708,60 @@ function beans_posts_pagination() { beans_close_markup_e( 'beans_posts_pagination_item[_active]_wrap', 'span' ); beans_close_markup_e( 'beans_posts_pagination_item[_active]', 'li' ); - } else { - beans_open_markup_e( 'beans_posts_pagination_item', 'li' ); - beans_open_markup_e( 'beans_posts_pagination_item_link', 'a', array( - 'href' => get_pagenum_link( $link ), // Automatically escaped. - ), $link ); + beans_open_markup_e( + 'beans_posts_pagination_item_link', + 'a', + array( + 'href' => get_pagenum_link( $link ), // Attributes are automatically escaped. + ), + $link + ); beans_output_e( 'beans_posts_pagination_item_link_text', $link ); beans_close_markup_e( 'beans_posts_pagination_item_link', 'a' ); beans_close_markup_e( 'beans_posts_pagination_item', 'li' ); - } } // Next. if ( get_next_posts_link() ) { - beans_open_markup_e( 'beans_posts_pagination_item[_next]', 'li' ); - beans_open_markup_e( 'beans_next_link[_posts_pagination]', 'a', array( - 'href' => next_posts( $count, false ), // Automatically escaped. - ), $current ); + beans_open_markup_e( + 'beans_next_link[_posts_pagination]', + 'a', + array( + 'href' => next_posts( $count, false ), // Attributes are automatically escaped. + ), + $current + ); - beans_output_e( 'beans_next_text[_posts_pagination]', __( 'Next', 'tm-beans' ) ); + beans_output_e( 'beans_next_text[_posts_pagination]', esc_html__( 'Next Page', 'tm-beans' ) ); - beans_open_markup_e( 'beans_next_icon[_posts_pagination]', 'i', array( - 'class' => 'uk-icon-angle-double-right uk-margin-small-left', - ) ); + beans_open_markup_e( + 'beans_next_icon[_posts_pagination]', + 'span', + array( + 'class' => 'uk-icon-angle-double-right uk-margin-small-left', + 'aria-hidden' => 'true', + ) + ); - beans_close_markup_e( 'beans_next_icon[_posts_pagination]', 'i' ); + beans_close_markup_e( 'beans_next_icon[_posts_pagination]', 'span' ); beans_close_markup_e( 'beans_next_link[_posts_pagination]', 'a' ); beans_close_markup_e( 'beans_posts_pagination_item[_next]', 'li' ); - } - beans_close_markup_e( 'beans_posts_pagination', 'ul' ); + beans_close_markup_e( 'beans_posts_pagination', 'ul' ); + beans_close_markup_e( 'beans_posts_pagination_nav_container', 'nav' ); } beans_add_smart_action( 'beans_no_post', 'beans_no_post' ); @@ -652,16 +769,17 @@ function beans_posts_pagination() { * Echo no post content. * * @since 1.0.0 + * + * @return void */ function beans_no_post() { - beans_open_markup_e( 'beans_post', 'article', array( 'class' => 'tm-no-article uk-article' . ( current_theme_supports( 'beans-default-styling' ) ? ' uk-panel-box' : null ) ) ); beans_open_markup_e( 'beans_post_header', 'header' ); beans_open_markup_e( 'beans_post_title', 'h1', array( 'class' => 'uk-article-title' ) ); - beans_output_e( 'beans_no_post_article_title_text', __( 'Whoops, no result found!', 'tm-beans' ) ); + beans_output_e( 'beans_no_post_article_title_text', esc_html__( 'Whoops, no result found!', 'tm-beans' ) ); beans_close_markup_e( 'beans_post_title', 'h1' ); @@ -673,7 +791,7 @@ function beans_no_post() { beans_open_markup_e( 'beans_no_post_article_content', 'p', array( 'class' => 'uk-alert uk-alert-warning' ) ); - beans_output_e( 'beans_no_post_article_content_text', __( 'It looks like nothing was found at this location. Maybe try a search?', 'tm-beans' ) ); + beans_output_e( 'beans_no_post_article_content_text', esc_html__( 'It looks like nothing was found at this location. Maybe try a search?', 'tm-beans' ) ); beans_close_markup_e( 'beans_no_post_article_content', 'p' ); @@ -684,7 +802,6 @@ function beans_no_post() { beans_close_markup_e( 'beans_post_body', 'div' ); beans_close_markup_e( 'beans_post', 'article' ); - } // Filter. @@ -697,7 +814,6 @@ function beans_no_post() { * @return string The form. */ function beans_post_password_form() { - global $post; $label = 'pwbox-' . ( empty( $post->ID ) ? rand() : $post->ID ); @@ -705,35 +821,46 @@ function beans_post_password_form() { // Notice. $output = beans_open_markup( 'beans_password_form_notice', 'p', array( 'class' => 'uk-alert uk-alert-warning' ) ); - $output .= beans_output( 'beans_password_form_notice_text', __( 'This post is protected. To view it, enter the password below!', 'tm-beans' ) ); + $output .= beans_output( 'beans_password_form_notice_text', esc_html__( 'This post is protected. To view it, enter the password below!', 'tm-beans' ) ); $output .= beans_close_markup( 'beans_password_form_notice', 'p' ); // Form. - $output .= beans_open_markup( 'beans_password_form', 'form', array( - 'class' => 'uk-form uk-margin-bottom', - 'method' => 'post', - 'action' => site_url( 'wp-login.php?action=postpass', 'login_post' ), // Automatically escaped. - ) ); - - $output .= beans_selfclose_markup( 'beans_password_form_input', 'input', array( - 'class' => 'uk-margin-small-top uk-margin-small-right', - 'type' => 'password', - 'placeholder' => apply_filters( 'beans_password_form_input_placeholder', __( 'Password', 'tm-beans' ) ), // Automatically escaped. - 'name' => 'post_password', - ) ); - - $output .= beans_selfclose_markup( 'beans_password_form_submit', 'input', array( - 'class' => 'uk-button uk-margin-small-top', - 'type' => 'submit', - 'name' => 'submit', - 'value' => esc_attr( apply_filters( 'beans_password_form_submit_text', __( 'Submit', 'tm-beans' ) ) ), - ) ); + $output .= beans_open_markup( + 'beans_password_form', + 'form', + array( + 'class' => 'uk-form uk-margin-bottom', + 'method' => 'post', + 'action' => site_url( 'wp-login.php?action=postpass', 'login_post' ), // Attributes are automatically escaped. + ) + ); + + $output .= beans_selfclose_markup( + 'beans_password_form_input', + 'input', + array( + 'class' => 'uk-margin-small-top uk-margin-small-right', + 'type' => 'password', + 'placeholder' => apply_filters( 'beans_password_form_input_placeholder', __( 'Password', 'tm-beans' ) ), // Attributes are automatically escaped. + 'name' => 'post_password', + ) + ); + + $output .= beans_selfclose_markup( + 'beans_password_form_submit', + 'input', + array( + 'class' => 'uk-button uk-margin-small-top', + 'type' => 'submit', + 'name' => 'submit', + 'value' => apply_filters( 'beans_password_form_submit_text', __( 'Submit', 'tm-beans' ) ), // Attributes are automatically escaped. + ) + ); $output .= beans_close_markup( 'beans_password_form', 'form' ); return $output; - } // Filter. @@ -752,9 +879,8 @@ function beans_post_password_form() { * @return string HTML content to display gallery. */ function beans_post_gallery( $output, $attr, $instance ) { - - $post = get_post(); - $html5 = current_theme_supports( 'html5', 'gallery' ); + $post = get_post(); + $html5 = current_theme_supports( 'html5', 'gallery' ); $defaults = array( 'order' => 'ASC', 'orderby' => 'menu_order ID', @@ -768,20 +894,21 @@ function beans_post_gallery( $output, $attr, $instance ) { 'exclude' => '', 'link' => '', ); - $atts = shortcode_atts( $defaults, $attr, 'gallery' ); - $id = intval( $atts['id'] ); + $atts = shortcode_atts( $defaults, $attr, 'gallery' ); + $id = intval( $atts['id'] ); - // Set attachements. + // Set attachments. if ( ! empty( $atts['include'] ) ) { - - $_attachments = get_posts( array( - 'include' => $atts['include'], - 'post_status' => 'inherit', - 'post_type' => 'attachment', - 'post_mime_type' => 'image', - 'order' => $atts['order'], - 'orderby' => $atts['orderby'], - ) ); + $_attachments = get_posts( + array( + 'include' => $atts['include'], + 'post_status' => 'inherit', + 'post_type' => 'attachment', + 'post_mime_type' => 'image', + 'order' => $atts['order'], + 'orderby' => $atts['orderby'], + ) + ); $attachments = array(); @@ -789,28 +916,28 @@ function beans_post_gallery( $output, $attr, $instance ) { $attachments[ $val->ID ] = $_attachments[ $key ]; } } elseif ( ! empty( $atts['exclude'] ) ) { - - $attachments = get_children( array( - 'post_parent' => $id, - 'exclude' => $atts['exclude'], - 'post_status' => 'inherit', - 'post_type' => 'attachment', - 'post_mime_type' => 'image', - 'order' => $atts['order'], - 'orderby' => $atts['orderby'], - ) ); - + $attachments = get_children( + array( + 'post_parent' => $id, + 'exclude' => $atts['exclude'], + 'post_status' => 'inherit', + 'post_type' => 'attachment', + 'post_mime_type' => 'image', + 'order' => $atts['order'], + 'orderby' => $atts['orderby'], + ) + ); } else { - - $attachments = get_children( array( - 'post_parent' => $id, - 'post_status' => 'inherit', - 'post_type' => 'attachment', - 'post_mime_type' => 'image', - 'order' => $atts['order'], - 'orderby' => $atts['orderby'], - ) ); - + $attachments = get_children( + array( + 'post_parent' => $id, + 'post_status' => 'inherit', + 'post_type' => 'attachment', + 'post_mime_type' => 'image', + 'order' => $atts['order'], + 'orderby' => $atts['orderby'], + ) + ); } // Stop here if no attachment. @@ -819,7 +946,6 @@ function beans_post_gallery( $output, $attr, $instance ) { } if ( is_feed() ) { - $output = "\n"; foreach ( $attachments as $att_id => $attachment ) { @@ -827,12 +953,11 @@ function beans_post_gallery( $output, $attr, $instance ) { } return $output; - } // Valid tags. $valid_tags = wp_kses_allowed_html( 'post' ); - $validate = array( + $validate = array( 'itemtag', 'captiontag', 'icontag', @@ -846,14 +971,20 @@ function beans_post_gallery( $output, $attr, $instance ) { } // Set variables used in the output. - $columns = intval( $atts['columns'] ); + $columns = intval( $atts['columns'] ); $size_class = sanitize_html_class( $atts['size'] ); - // WP adds the opening div in the gallery_style filter (weird), so we follow it as don't want to break people's site. - $gallery_div = beans_open_markup( "beans_post_gallery[_{$id}]", 'div', array( - 'class' => "uk-grid uk-grid-width-small-1-{$columns} gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}", // Automatically escaped. - 'data-uk-grid-margin' => false, - ), $id, $columns ); + // WP adds the opening div in the gallery_style filter (weird), so we follow it as we don't want to break people's site. + $gallery_div = beans_open_markup( + "beans_post_gallery[_{$id}]", + 'div', + array( + 'class' => "uk-grid uk-grid-width-small-1-{$columns} gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}", // Attributes are automatically escaped. + 'data-uk-grid-margin' => false, + ), + $id, + $columns + ); /** * Apply WP core filter. Filter the default gallery shortcode CSS styles. @@ -862,49 +993,45 @@ function beans_post_gallery( $output, $attr, $instance ) { * * @ignore */ - $output = apply_filters( 'gallery_style', $gallery_div ); + $output = apply_filters( 'gallery_style', $gallery_div ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Used in function scope. $i = 0; foreach ( $attachments as $attachment_id => $attachment ) { - $attr = ( trim( $attachment->post_excerpt ) ) ? array( 'aria-describedby' => "gallery-{$instance}-{$id}" ) : ''; - $image_meta = wp_get_attachment_metadata( $attachment_id ); + $attr = ( trim( $attachment->post_excerpt ) ) ? array( 'aria-describedby' => "gallery-{$instance}-{$id}" ) : ''; + $image_meta = wp_get_attachment_metadata( $attachment_id ); $orientation = ''; - if ( isset( $image_meta['height'], $image_meta['width'] ) ) { - $orientation = ( $image_meta['height'] > $image_meta['width'] ) ? 'portrait' : 'landscape'; - } + if ( isset( $image_meta['height'], $image_meta['width'] ) ) { + $orientation = ( $image_meta['height'] > $image_meta['width'] ) ? 'portrait' : 'landscape'; + } - // Set the image output. - if ( 'none' === $atts['link'] ) { - $image_output = wp_get_attachment_image( $attachment_id, $atts['size'], false, $attr ); - } else { - $image_output = wp_get_attachment_link( $attachment_id, $atts['size'], ( 'file' !== $atts['link'] ), false, false, $attr ); - } + // Set the image output. + if ( 'none' === $atts['link'] ) { + $image_output = wp_get_attachment_image( $attachment_id, $atts['size'], false, $attr ); + } else { + $image_output = wp_get_attachment_link( $attachment_id, $atts['size'], ( 'file' !== $atts['link'] ), false, false, $attr ); + } $output .= beans_open_markup( "beans_post_gallery_item[_{$attachment_id}]", $atts['itemtag'], array( 'class' => 'gallery-item' ) ); - $output .= beans_open_markup( "beans_post_gallery_icon[_{$attachment_id}]", $atts['icontag'], array( 'class' => "gallery-icon {$orientation}" ) ); // Automatically escaped. + $output .= beans_open_markup( "beans_post_gallery_icon[_{$attachment_id}]", $atts['icontag'], array( 'class' => "gallery-icon {$orientation}" ) ); // Attributes are automatically escaped. $output .= beans_output( "beans_post_gallery_icon[_{$attachment_id}]", $image_output, $attachment_id, $atts ); $output .= beans_close_markup( "beans_post_gallery_icon[_{$attachment_id}]", $atts['icontag'] ); - if ( $atts['captiontag'] && trim( $attachment->post_excerpt ) ) { - - $output .= beans_open_markup( "beans_post_gallery_caption[_{$attachment_id}]", $atts['captiontag'], array( 'class' => 'wp-caption-text gallery-caption' ) ); + if ( $atts['captiontag'] && trim( $attachment->post_excerpt ) ) { + $output .= beans_open_markup( "beans_post_gallery_caption[_{$attachment_id}]", $atts['captiontag'], array( 'class' => 'wp-caption-text gallery-caption' ) ); - $output .= beans_output( "beans_post_gallery_caption_text[_{$attachment_id}]", wptexturize( $attachment->post_excerpt ) ); + $output .= beans_output( "beans_post_gallery_caption_text[_{$attachment_id}]", wptexturize( $attachment->post_excerpt ) ); - $output .= beans_close_markup( "beans_post_gallery_caption[_{$attachment_id}]", $atts['captiontag'] ); - - } + $output .= beans_close_markup( "beans_post_gallery_caption[_{$attachment_id}]", $atts['captiontag'] ); + } $output .= beans_close_markup( "beans_post_gallery_item[_{$attachment_id}]", $atts['itemtag'] ); - } - $output .= beans_close_markup( "beans_post_gallery[_{$id}]", 'div' ); - - return $output; + $output .= beans_close_markup( "beans_post_gallery[_{$id}]", 'div' ); + return $output; } diff --git a/lib/templates/fragments/searchform.php b/lib/templates/fragments/searchform.php index aded642d..883a3fdd 100644 --- a/lib/templates/fragments/searchform.php +++ b/lib/templates/fragments/searchform.php @@ -2,7 +2,9 @@ /** * Modify the search from. * - * @package Fragments\Search_Form + * @package Beans\Framework\Templates\Fragments + * + * @since 1.0.0 */ // Filter. @@ -15,28 +17,41 @@ * @return string The form. */ function beans_search_form() { - - $output = beans_open_markup( 'beans_search_form', 'form', array( - 'class' => 'uk-form uk-form-icon uk-form-icon-flip uk-width-1-1', - 'method' => 'get', - 'action' => esc_url( home_url( '/' ) ), - 'role' => 'search', - ) ); - - $output .= beans_selfclose_markup( 'beans_search_form_input', 'input', array( - 'class' => 'uk-width-1-1', - 'type' => 'search', - 'placeholder' => __( 'Search', 'tm-beans' ), // Automatically escaped. - 'value' => esc_attr( get_search_query() ), - 'name' => 's', - ) ); - - $output .= beans_open_markup( 'beans_search_form_input_icon', 'i', 'class=uk-icon-search' ); - - $output .= beans_close_markup( 'beans_search_form_input_icon', 'i' ); + $output = beans_open_markup( + 'beans_search_form', + 'form', + array( + 'class' => 'uk-form uk-form-icon uk-form-icon-flip uk-width-1-1', + 'method' => 'get', + 'action' => esc_url( home_url( '/' ) ), + 'role' => 'search', + ) + ); + + $output .= beans_selfclose_markup( + 'beans_search_form_input', + 'input', + array( + 'class' => 'uk-width-1-1', + 'type' => 'search', + 'placeholder' => __( 'Search', 'tm-beans' ), // Automatically escaped. + 'value' => esc_attr( get_search_query() ), + 'name' => 's', + ) + ); + + $output .= beans_open_markup( + 'beans_search_form_input_icon', + 'span', + array( + 'class' => 'uk-icon-search', + 'aria-hidden' => 'true', + ) + ); + + $output .= beans_close_markup( 'beans_search_form_input_icon', 'span' ); $output .= beans_close_markup( 'beans_search_form', 'form' ); return $output; - } diff --git a/lib/templates/fragments/widget-area.php b/lib/templates/fragments/widget-area.php index 7332d9f2..5c1a41df 100644 --- a/lib/templates/fragments/widget-area.php +++ b/lib/templates/fragments/widget-area.php @@ -2,7 +2,9 @@ /** * Echo widget areas. * - * @package Fragments\Widget_Area + * @package Beans\Framework\Templates\Fragments + * + * @since 1.0.0 */ beans_add_smart_action( 'beans_sidebar_primary', 'beans_widget_area_sidebar_primary' ); @@ -10,11 +12,11 @@ * Echo primary sidebar widget area. * * @since 1.0.0 + * + * @return void */ function beans_widget_area_sidebar_primary() { - - echo beans_widget_area( 'sidebar_primary' ); - + echo beans_get_widget_area_output( 'sidebar_primary' ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. } beans_add_smart_action( 'beans_sidebar_secondary', 'beans_widget_area_sidebar_secondary' ); @@ -22,11 +24,11 @@ function beans_widget_area_sidebar_primary() { * Echo secondary sidebar widget area. * * @since 1.0.0 + * + * @return void */ function beans_widget_area_sidebar_secondary() { - - echo beans_widget_area( 'sidebar_secondary' ); - + echo beans_get_widget_area_output( 'sidebar_secondary' ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. } beans_add_smart_action( 'beans_site_after_markup', 'beans_widget_area_offcanvas_menu' ); @@ -34,6 +36,8 @@ function beans_widget_area_sidebar_secondary() { * Echo off-canvas widget area. * * @since 1.0.0 + * + * @return void */ function beans_widget_area_offcanvas_menu() { @@ -41,6 +45,5 @@ function beans_widget_area_offcanvas_menu() { return; } - echo beans_widget_area( 'offcanvas_menu' ); - + echo beans_get_widget_area_output( 'offcanvas_menu' ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. } diff --git a/lib/templates/fragments/widget.php b/lib/templates/fragments/widget.php index e4b78390..61daaf03 100644 --- a/lib/templates/fragments/widget.php +++ b/lib/templates/fragments/widget.php @@ -2,7 +2,9 @@ /** * Echo widget fragments. * - * @package Fragments\Widget + * @package Beans\Framework\Templates\Fragments + * + * @since 1.0.0 */ beans_add_smart_action( 'beans_widget', 'beans_widget_badge', 5 ); @@ -10,6 +12,8 @@ * Echo widget badge. * * @since 1.0.0 + * + * @return void */ function beans_widget_badge() { @@ -19,10 +23,9 @@ function beans_widget_badge() { beans_open_markup_e( 'beans_widget_badge' . _beans_widget_subfilters(), 'div', 'class=uk-panel-badge uk-badge' ); - echo beans_widget_shortcodes( beans_get_widget( 'badge_content' ) ); + echo beans_widget_shortcodes( beans_get_widget( 'badge_content' ) ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Echoes HTML output. beans_close_markup_e( 'beans_widget_badge' . _beans_widget_subfilters(), 'div' ); - } beans_add_smart_action( 'beans_widget', 'beans_widget_title' ); @@ -30,10 +33,13 @@ function beans_widget_badge() { * Echo widget title. * * @since 1.0.0 + * + * @return void */ function beans_widget_title() { + $title = beans_get_widget( 'title' ); - if ( ! ( $title = beans_get_widget( 'title' ) ) || ! beans_get_widget( 'show_title' ) ) { + if ( ! $title || ! beans_get_widget( 'show_title' ) ) { return; } @@ -42,7 +48,6 @@ function beans_widget_title() { beans_output_e( 'beans_widget_title_text', $title ); beans_close_markup_e( 'beans_widget_title' . _beans_widget_subfilters(), 'h3' ); - } beans_add_smart_action( 'beans_widget', 'beans_widget_content', 15 ); @@ -50,15 +55,15 @@ function beans_widget_title() { * Echo widget content. * * @since 1.0.0 + * + * @return void */ function beans_widget_content() { - beans_open_markup_e( 'beans_widget_content' . _beans_widget_subfilters(), 'div' ); beans_output_e( 'beans_widget_content' . _beans_widget_subfilters(), beans_get_widget( 'content' ) ); beans_close_markup_e( 'beans_widget_content' . _beans_widget_subfilters(), 'div' ); - } beans_add_smart_action( 'beans_no_widget', 'beans_no_widget' ); @@ -66,20 +71,25 @@ function beans_widget_content() { * Echo no widget content. * * @since 1.0.0 + * + * @return void */ function beans_no_widget() { // Only apply this notice to sidebar_primary and sidebar_secondary. - if ( ! in_array( beans_get_widget_area( 'id' ), array( 'sidebar_primary', 'sidebar_secondary' ) ) ) { + if ( ! in_array( beans_get_widget_area( 'id' ), array( 'sidebar_primary', 'sidebar_secondary' ), true ) ) { return; } beans_open_markup_e( 'beans_no_widget_notice', 'p', array( 'class' => 'uk-alert uk-alert-warning' ) ); - beans_output_e( 'beans_no_widget_notice_text', sprintf( __( '%s does not have any widget assigned!', 'tm-beans' ), beans_get_widget_area( 'name' ) ) ); + beans_output_e( + 'beans_no_widget_notice_text', + // translators: Name of the widget area. + sprintf( esc_html__( '%s does not have any widget assigned!', 'tm-beans' ), beans_get_widget_area( 'name' ) ) + ); beans_close_markup_e( 'beans_no_widget_notice', 'p' ); - } beans_add_filter( 'beans_widget_content_rss_output', 'beans_widget_rss_content' ); @@ -88,14 +98,12 @@ function beans_no_widget() { * * @since 1.0.0 * - * @return The RSS widget content. + * @return string The RSS widget content. */ function beans_widget_rss_content() { - $options = beans_get_widget( 'options' ); - return '

              ' . __( 'Read feed', 'tm-beans' ) . '

              '; - + return '

              ' . esc_html__( 'Read feed', 'tm-beans' ) . '

              '; } beans_add_filter( 'beans_widget_content_attributes', 'beans_modify_widget_content_attributes' ); @@ -109,7 +117,6 @@ function beans_widget_rss_content() { * @return array The modified widget attributes. */ function beans_modify_widget_content_attributes( $attributes ) { - $type = beans_get_widget( 'type' ); $target = array( @@ -124,16 +131,15 @@ function beans_modify_widget_content_attributes( $attributes ) { $current_class = isset( $attributes['class'] ) ? $attributes['class'] . ' ' : ''; - if ( in_array( beans_get_widget( 'type' ), $target ) ) { + if ( in_array( beans_get_widget( 'type' ), $target, true ) ) { $attributes['class'] = $current_class . 'uk-list'; // Automatically escaped. } - if ( 'calendar' == $type ) { + if ( 'calendar' === $type ) { $attributes['class'] = $current_class . 'uk-table uk-table-condensed'; // Automatically escaped. } return $attributes; - } beans_add_filter( 'beans_widget_content_categories_output', 'beans_modify_widget_count' ); @@ -148,26 +154,18 @@ function beans_modify_widget_content_attributes( $attributes ) { * @return string The modified widget content. */ function beans_modify_widget_count( $content ) { - $count = beans_output( 'beans_widget_count', '$1' ); - if ( true == beans_get( 'dropdown', beans_get_widget( 'options' ) ) ) { - + if ( true === beans_get( 'dropdown', beans_get_widget( 'options' ) ) ) { $output = $count; - } else { - - $output = beans_open_markup( 'beans_widget_count', 'span', 'class=tm-count' ); - - $output .= $count; - + $output = beans_open_markup( 'beans_widget_count', 'span', 'class=tm-count' ); + $output .= $count; $output .= beans_close_markup( 'beans_widget_count', 'span' ); - } // Keep closing tag to avoid overwriting the inline JavaScript. return preg_replace( '#>((\s| )\((.*)\))#', '>' . $output, $content ); - } beans_add_filter( 'beans_widget_content_categories_output', 'beans_remove_widget_dropdown_label' ); @@ -182,7 +180,5 @@ function beans_modify_widget_count( $content ) { * @return string The modified widget content. */ function beans_remove_widget_dropdown_label( $content ) { - return preg_replace( '#]*)class="screen-reader-text"(.*?)>(.*?)#', '', $content ); - } diff --git a/lib/templates/structure/comment.php b/lib/templates/structure/comment.php index e34d0451..c4c4d388 100644 --- a/lib/templates/structure/comment.php +++ b/lib/templates/structure/comment.php @@ -2,16 +2,22 @@ /** * Echo the structural markup for each comment. It also calls the comment action hooks. * - * @package Structure\Comment + * @package Beans\Framework\Templates\Structure + * + * @since 1.0.0 */ -beans_open_markup_e( 'beans_comment', 'article', array( - 'id' => 'div-comment-' . get_comment_ID(), // Automatically escaped. - 'class' => 'uk-comment', - 'itemprop' => 'comment', - 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/Comment', -) ); +beans_open_markup_e( + 'beans_comment', + 'article', + array( + 'id' => 'div-comment-' . get_comment_ID(), // Automatically escaped. + 'class' => 'uk-comment', + 'itemprop' => 'comment', + 'itemscope' => 'itemscope', + 'itemtype' => 'https://schema.org/Comment', + ) +); beans_open_markup_e( 'beans_comment_header', 'header', array( 'class' => 'uk-comment-header' ) ); @@ -24,10 +30,14 @@ beans_close_markup_e( 'beans_comment_header', 'header' ); - beans_open_markup_e( 'beans_comment_body', 'div', array( - 'class' => 'uk-comment-body', - 'itemprop' => 'text', - ) ); + beans_open_markup_e( + 'beans_comment_body', + 'div', + array( + 'class' => 'uk-comment-body', + 'itemprop' => 'text', + ) + ); /** * Fires in the comment body. @@ -38,4 +48,4 @@ beans_close_markup_e( 'beans_comment_body', 'div' ); -beans_close_markup_e( 'beans_comment', 'article' ); +beans_close_markup_e( 'beans_comment', 'article' ); // phpcs:ignore Generic.WhiteSpace.ScopeIndent.Incorrect -- Code structure mirrors HTML markup. diff --git a/lib/templates/structure/comments.php b/lib/templates/structure/comments.php index 4dd335f1..56f2ef29 100644 --- a/lib/templates/structure/comments.php +++ b/lib/templates/structure/comments.php @@ -4,7 +4,9 @@ * * This template will return empty if the post which is called is password protected. * - * @package Structure\Comments + * @package Beans\Framework\Templates\Structure + * + * @since 1.0.0 */ // Stop here if the post is password protected. @@ -12,21 +14,28 @@ return; } -beans_open_markup_e( 'beans_comments', 'div', array( 'id' => 'comments', 'class' => 'tm-comments' . ( current_theme_supports( 'beans-default-styling' ) ? ' uk-panel-box' : null ) ) ); - +beans_open_markup_e( + 'beans_comments', + 'div', + array( + 'id' => 'comments', + 'class' => 'tm-comments' . ( current_theme_supports( 'beans-default-styling' ) ? ' uk-panel-box' : null ), + ) +); + // phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact -- Code structure mirrors HTML markup. if ( comments_open() || get_comments_number() ) : if ( have_comments() ) : - beans_open_markup_e( 'beans_comments_list', 'ol', array( 'class' => 'uk-comment-list' ) ); - wp_list_comments( array( - 'avatar_size' => 50, - 'callback' => 'beans_comment_callback', - ) ); + wp_list_comments( + array( + 'avatar_size' => 50, + 'callback' => 'beans_comment_callback', + ) + ); beans_close_markup_e( 'beans_comments_list', 'ol' ); - else : /** @@ -37,7 +46,6 @@ * @since 1.0.0 */ do_action( 'beans_no_comment' ); - endif; /** @@ -48,7 +56,6 @@ * @since 1.0.0 */ do_action( 'beans_after_open_comments' ); - endif; if ( ! comments_open() ) : @@ -59,7 +66,7 @@ * @since 1.0.0 */ do_action( 'beans_comments_closed' ); - endif; beans_close_markup_e( 'beans_comments', 'div' ); +//phpcs:enable Generic.WhiteSpace.ScopeIndent.IncorrectExact -- Code structure mirrors HTML markup. diff --git a/lib/templates/structure/content.php b/lib/templates/structure/content.php index 556994a7..10fc575a 100644 --- a/lib/templates/structure/content.php +++ b/lib/templates/structure/content.php @@ -2,20 +2,26 @@ /** * Echo the structural markup for the main content. It also calls the content action hooks. * - * @package Structure\Content + * @package Beans\Framework\Templates\Structure + * + * @since 1.0.0 + * @since 1.5.0 Added ID and tabindex for skip links. */ +// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Variable called in a function scope. $content_attributes = array( 'class' => 'tm-content', + 'id' => 'beans-content', 'role' => 'main', 'itemprop' => 'mainEntityOfPage', + 'tabindex' => '-1', ); // Blog specific attributes. if ( is_home() || is_page_template( 'page_blog.php' ) || is_singular( 'post' ) || is_archive() ) { $content_attributes['itemscope'] = 'itemscope'; // Automatically escaped. - $content_attributes['itemtype'] = 'http://schema.org/Blog'; // Automatically escaped. + $content_attributes['itemtype'] = 'https://schema.org/Blog'; // Automatically escaped. } @@ -23,9 +29,10 @@ if ( is_search() ) { $content_attributes['itemscope'] = 'itemscope'; // Automatically escaped. - $content_attributes['itemtype'] = 'http://schema.org/SearchResultsPage'; // Automatically escaped. + $content_attributes['itemtype'] = 'https://schema.org/SearchResultsPage'; // Automatically escaped. } +// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound beans_open_markup_e( 'beans_content', 'div', $content_attributes ); diff --git a/lib/templates/structure/footer-partial.php b/lib/templates/structure/footer-partial.php index 4a3a9138..67a31b8f 100644 --- a/lib/templates/structure/footer-partial.php +++ b/lib/templates/structure/footer-partial.php @@ -2,15 +2,21 @@ /** * Since WordPress force us to use the footer.php name to close the document, we add a footer-partial.php template for the actual footer. * - * @package Structure\Footer + * @package Beans\Framework\Templates\Structure + * + * @since 1.0.0 */ -beans_open_markup_e( 'beans_footer', 'footer', array( - 'class' => 'tm-footer uk-block', - 'role' => 'contentinfo', - 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/WPFooter', -) ); +beans_open_markup_e( + 'beans_footer', + 'footer', + array( + 'class' => 'tm-footer uk-block', + 'role' => 'contentinfo', + 'itemscope' => 'itemscope', + 'itemtype' => 'https://schema.org/WPFooter', + ) +); beans_open_markup_e( 'beans_fixed_wrap[_footer]', 'div', 'class=uk-container uk-container-center' ); diff --git a/lib/templates/structure/footer.php b/lib/templates/structure/footer.php index fa4395ba..e4d745c4 100644 --- a/lib/templates/structure/footer.php +++ b/lib/templates/structure/footer.php @@ -4,7 +4,9 @@ * * This template must be called using get_footer(). * - * @package Structure\Footer + * @package Beans\Framework\Templates\Structure + * + * @since 1.0.0 */ beans_close_markup_e( 'beans_primary', 'div' ); diff --git a/lib/templates/structure/header-partial.php b/lib/templates/structure/header-partial.php index f5d3d2c9..cfa3793d 100644 --- a/lib/templates/structure/header-partial.php +++ b/lib/templates/structure/header-partial.php @@ -2,15 +2,21 @@ /** * Since WordPress force us to use the header.php name to open the document, we add a header-partial.php template for the actual header. * - * @package Structure\Header + * @package Beans\Framework\Templates\Structure + * + * @since 1.0.0 */ -beans_open_markup_e( 'beans_header', 'header', array( - 'class' => 'tm-header uk-block', - 'role' => 'banner', - 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/WPHeader', -) ); +beans_open_markup_e( + 'beans_header', + 'header', + array( + 'class' => 'tm-header uk-block', + 'role' => 'banner', + 'itemscope' => 'itemscope', + 'itemtype' => 'https://schema.org/WPHeader', + ) +); beans_open_markup_e( 'beans_fixed_wrap[_header]', 'div', 'class=uk-container uk-container-center' ); diff --git a/lib/templates/structure/header.php b/lib/templates/structure/header.php index ed46e0cf..3027ced5 100644 --- a/lib/templates/structure/header.php +++ b/lib/templates/structure/header.php @@ -4,7 +4,9 @@ * * This template must be called using get_header(). * - * @package Structure\Header + * @package Beans\Framework\Templates\Structure + * + * @since 1.0.0 */ beans_output_e( 'beans_doctype', '' ); @@ -25,13 +27,17 @@ wp_head(); beans_close_markup_e( 'beans_head', 'head' ); - - beans_open_markup_e( 'beans_body', 'body', array( - 'class' => implode( ' ', get_body_class( 'uk-form no-js' ) ), - 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/WebPage', - - ) ); + beans_build_skip_links(); + beans_open_markup_e( + 'beans_body', + 'body', + array( + 'class' => implode( ' ', get_body_class( 'uk-form no-js' ) ), + 'itemscope' => 'itemscope', + 'itemtype' => 'https://schema.org/WebPage', + + ) + ); beans_open_markup_e( 'beans_site', 'div', array( 'class' => 'tm-site' ) ); @@ -39,8 +45,13 @@ beans_open_markup_e( 'beans_fixed_wrap[_main]', 'div', 'class=uk-container uk-container-center' ); - beans_open_markup_e( 'beans_main_grid', 'div', array( 'class' => 'uk-grid', 'data-uk-grid-margin' => '' ) ); + beans_open_markup_e( + 'beans_main_grid', + 'div', + array( + 'class' => 'uk-grid', + 'data-uk-grid-margin' => '', + ) + ); - beans_open_markup_e( 'beans_primary', 'div', array( - 'class' => 'tm-primary ' . beans_get_layout_class( 'content' ), - ) ); + beans_open_markup_e( 'beans_primary', 'div', array( 'class' => 'tm-primary ' . beans_get_layout_class( 'content' ) ) ); diff --git a/lib/templates/structure/loop.php b/lib/templates/structure/loop.php index 37d85632..aed3aa32 100644 --- a/lib/templates/structure/loop.php +++ b/lib/templates/structure/loop.php @@ -2,7 +2,9 @@ /** * Echo the posts loop structural markup. It also calls the loop action hooks. * - * @package Structure\Loop + * @package Beans\Framework\Templates\Structure + * + * @since 1.0.0 */ /** @@ -13,7 +15,7 @@ * @since 1.0.0 */ do_action( 'beans_before_loop' ); - + // phpcs:disable Generic.WhiteSpace.ScopeIndent -- Code structure mirrors HTML markup. if ( have_posts() && ! is_404() ) : /** @@ -25,25 +27,28 @@ */ do_action( 'beans_before_posts_loop' ); - while ( have_posts() ) : the_post(); + while ( have_posts() ) : + the_post(); + // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Variable called in a function scope. $article_attributes = array( 'id' => get_the_ID(), // Automatically escaped. 'class' => implode( ' ', get_post_class( array( 'uk-article', ( current_theme_supports( 'beans-default-styling' ) ? 'uk-panel-box' : null ) ) ) ), // Automatically escaped. 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/CreativeWork', + 'itemtype' => 'https://schema.org/CreativeWork', ); // Blog specifc attributes. if ( 'post' === get_post_type() ) { - $article_attributes['itemtype'] = 'http://schema.org/BlogPosting'; + $article_attributes['itemtype'] = 'https://schema.org/BlogPosting'; - // Only add to blogPost attribute to the main query, + // Only add to blogPost attribute to the main query. if ( is_main_query() && ! is_search() ) { - $article_attributes['itemprop'] = 'blogPost'; + $article_attributes['itemprop'] = 'blogPost'; } } + // phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound beans_open_markup_e( 'beans_post', 'article', $article_attributes ); @@ -70,7 +75,6 @@ beans_close_markup_e( 'beans_post_body', 'div' ); beans_close_markup_e( 'beans_post', 'article' ); - endwhile; /** @@ -81,16 +85,14 @@ * @since 1.0.0 */ do_action( 'beans_after_posts_loop' ); - else : - /** - * Fires if no posts exist. - * - * @since 1.0.0 - */ - do_action( 'beans_no_post' ); - + /** + * Fires if no posts exist. + * + * @since 1.0.0 + */ + do_action( 'beans_no_post' ); endif; /** @@ -100,4 +102,5 @@ * * @since 1.0.0 */ -do_action( 'beans_after_loop' ); + do_action( 'beans_after_loop' ); +// phpcs:enable Generic.WhiteSpace.ScopeIndent -- Code structure mirrors HTML markup. diff --git a/lib/templates/structure/sidebar-primary.php b/lib/templates/structure/sidebar-primary.php index 69180913..c7acb251 100644 --- a/lib/templates/structure/sidebar-primary.php +++ b/lib/templates/structure/sidebar-primary.php @@ -2,15 +2,24 @@ /** * Echo the primary sidebar structural markup. It also calls the primary sidebar action hooks. * - * @package Structure\Primary_Sidebar + * @package Beans\Framework\Templates\Structure + * + * @since 1.0.0 + * @since 1.5.0 Added ID and tabindex for skip links. */ -beans_open_markup_e( 'beans_sidebar_primary', 'aside', array( - 'class' => 'tm-secondary ' . beans_get_layout_class( 'sidebar_primary' ), // Automatically escaped. - 'role' => 'complementary', - 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/WPSideBar', -) ); +beans_open_markup_e( + 'beans_sidebar_primary', + 'aside', + array( + 'class' => 'tm-secondary ' . beans_get_layout_class( 'sidebar_primary' ), // Automatically escaped. + 'id' => 'beans-primary-sidebar', + 'role' => 'complementary', + 'itemscope' => 'itemscope', + 'itemtype' => 'https://schema.org/WPSideBar', + 'tabindex' => '-1', + ) +); /** * Fires in the primary sidebar. diff --git a/lib/templates/structure/sidebar-secondary.php b/lib/templates/structure/sidebar-secondary.php index 34485059..118ca771 100644 --- a/lib/templates/structure/sidebar-secondary.php +++ b/lib/templates/structure/sidebar-secondary.php @@ -2,15 +2,24 @@ /** * Echo the secondary sidebar structural markup. It also calls the secondary sidebar action hooks. * - * @package Structure\Secondary_Sidebar + * @package Beans\Framework\Templates\Structure + * + * @since 1.0.0 + * @since 1.5.0 Added ID and tabindex for skip links. */ -beans_open_markup_e( 'beans_sidebar_secondary', 'aside', array( - 'class' => 'tm-tertiary ' . beans_get_layout_class( 'sidebar_secondary' ), // Automatically escaped. - 'role' => 'complementary', - 'itemscope' => 'itemscope', - 'itemtype' => 'http://schema.org/WPSideBar', -) ); +beans_open_markup_e( + 'beans_sidebar_secondary', + 'aside', + array( + 'class' => 'tm-tertiary ' . beans_get_layout_class( 'sidebar_secondary' ), // Automatically escaped. + 'id' => 'beans-secondary-sidebar', + 'role' => 'complementary', + 'itemscope' => 'itemscope', + 'itemtype' => 'https://schema.org/WPSideBar', + 'tabindex' => '-1', + ) +); /** * Fires in the secondary sidebar. diff --git a/lib/templates/structure/widget-area.php b/lib/templates/structure/widget-area.php index f71e3363..51b8a55a 100644 --- a/lib/templates/structure/widget-area.php +++ b/lib/templates/structure/widget-area.php @@ -3,25 +3,38 @@ * Echo the widget area and widget loop structural markup. It also calls the widget area and widget loop * action hooks. * - * @package Structure\Widget_Area + * @package Beans\Framework\Templates\Structure + * + * @since 1.0.0 */ // This includes everything added to wp hooks before the widgets. -echo beans_get_widget_area( 'before_widgets' ); - - if ( 'grid' == beans_get_widget_area( 'beans_type' ) ) { - beans_open_markup_e( 'beans_widget_area_grid' . _beans_widget_area_subfilters(), 'div', array( 'class' => 'uk-grid', 'data-uk-grid-margin' => '' ) ); +echo beans_get_widget_area( 'before_widgets' ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Widget area has to be echoed. + + // phpcs:disable Generic.WhiteSpace.ScopeIndent -- Code structure mirrors HTML markup. + if ( 'grid' === beans_get_widget_area( 'beans_type' ) ) { + beans_open_markup_e( + 'beans_widget_area_grid' . _beans_widget_area_subfilters(), + 'div', + array( + 'class' => 'uk-grid', + 'data-uk-grid-margin' => '', + ) + ); } - if ( 'offcanvas' == beans_get_widget_area( 'beans_type' ) ) { + if ( 'offcanvas' === beans_get_widget_area( 'beans_type' ) ) { - beans_open_markup_e( 'beans_widget_area_offcanvas_wrap' . _beans_widget_area_subfilters(), 'div', array( - 'id' => beans_get_widget_area( 'id' ), // Automatically escaped. - 'class' => 'uk-offcanvas', - ) ); + beans_open_markup_e( + 'beans_widget_area_offcanvas_wrap' . _beans_widget_area_subfilters(), + 'div', + array( + 'id' => beans_get_widget_area( 'id' ), // Automatically escaped. + 'class' => 'uk-offcanvas', + ) + ); beans_open_markup_e( 'beans_widget_area_offcanvas_bar' . _beans_widget_area_subfilters(), 'div', array( 'class' => 'uk-offcanvas-bar' ) ); - } // Widgets. @@ -36,9 +49,10 @@ */ do_action( 'beans_before_widgets_loop' ); - while ( beans_have_widgets() ) : beans_setup_widget(); + while ( beans_have_widgets() ) : + beans_setup_widget(); - if ( 'grid' == beans_get_widget_area( 'beans_type' ) ) { + if ( 'grid' === beans_get_widget_area( 'beans_type' ) ) { beans_open_markup_e( 'beans_widget_grid' . _beans_widget_subfilters(), 'div', beans_widget_shortcodes( 'class=uk-width-medium-1-{count}' ) ); } @@ -53,10 +67,9 @@ beans_close_markup_e( 'beans_widget_panel' . _beans_widget_subfilters(), 'div' ); - if ( 'grid' == beans_get_widget_area( 'beans_type' ) ) { + if ( 'grid' === beans_get_widget_area( 'beans_type' ) ) { beans_close_markup_e( 'beans_widget_grid' . _beans_widget_subfilters(), 'div' ); } - endwhile; /** @@ -67,7 +80,6 @@ * @since 1.0.0 */ do_action( 'beans_after_widgets_loop' ); - else : /** @@ -76,20 +88,20 @@ * @since 1.0.0 */ do_action( 'beans_no_widget' ); - endif; - if ( 'offcanvas' == beans_get_widget_area( 'beans_type' ) ) { + if ( 'offcanvas' === beans_get_widget_area( 'beans_type' ) ) { beans_close_markup_e( 'beans_widget_area_offcanvas_bar' . _beans_widget_area_subfilters(), 'div' ); beans_close_markup_e( 'beans_widget_area_offcanvas_wrap' . _beans_widget_area_subfilters(), 'div' ); - } - if ( 'grid' == beans_get_widget_area( 'beans_type' ) ) { + if ( 'grid' === beans_get_widget_area( 'beans_type' ) ) { beans_close_markup_e( 'beans_widget_area_grid' . _beans_widget_area_subfilters(), 'div' ); } // This includes everything added to wp hooks after the widgets. -echo beans_get_widget_area( 'after_widgets' ); +echo beans_get_widget_area( 'after_widgets' ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped -- Widget area has to be echoed. + +// phpcs:enable Generic.WhiteSpace.ScopeIndent -- Code structure mirrors HTML markup. diff --git a/license.txt b/license.txt index 08f48fa6..c4fc4947 100644 --- a/license.txt +++ b/license.txt @@ -1,703 +1,703 @@ -Beans - Theme Framework for WordPress - -Copyright 2016 by the contributors - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -This program incorporates work covered by the following copyright and -permission notices: - - Beans - Theme Framework for WordPress - - Beans is Copyright (c) 2016 BeansPress - - Beans is released under the GPL - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright © 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright © - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright © - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read +Beans - Theme Framework for WordPress + +Copyright 2016 by the contributors + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +This program incorporates work covered by the following copyright and +permission notices: + + Beans - Theme Framework for WordPress + + Beans is Copyright (c) 2016 BeansPress + + Beans is released under the GPL + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright © 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright © + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright © + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read . \ No newline at end of file diff --git a/page.php b/page.php index cdf2e4e4..2c7be533 100644 --- a/page.php +++ b/page.php @@ -1,12 +1,13 @@