first commit
@@ -0,0 +1,85 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
|
||||
/** Sub extensions will extend this class */
|
||||
require dirname(__FILE__) .'/includes/extends/population-method-interface.php';
|
||||
|
||||
class FW_Extension_Population_Method extends FW_Extension
|
||||
{
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function _init()
|
||||
{
|
||||
}
|
||||
|
||||
public function get_population_methods($media_types)
|
||||
{
|
||||
$collector = array();
|
||||
foreach ($this->get_children() as $instance) {
|
||||
$intersection = array_intersect($media_types, $instance->get_multimedia_types());
|
||||
|
||||
if (!empty($intersection)) {
|
||||
$collector = array_merge($collector, $instance->get_population_method());
|
||||
}
|
||||
}
|
||||
|
||||
return $collector;
|
||||
}
|
||||
|
||||
public function get_population_options($population_method, $multimedia_types = array(), $options = array())
|
||||
{
|
||||
$population_method_instance = $this->get_child('population-method-' . $population_method);
|
||||
|
||||
if (empty($population_method)) {
|
||||
FW_Flash_Messages::add(
|
||||
'fw-ext-'. $this->get_name() .'-wrong-method',
|
||||
sprintf(__('Specified population method does not exists: %s', 'fw'), $population_method),
|
||||
'error'
|
||||
);
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
return $population_method_instance->get_population_options($multimedia_types, $options);
|
||||
}
|
||||
|
||||
public function get_population_method($post_id)
|
||||
{
|
||||
$selected = fw_get_db_post_option($post_id, 'slider/selected');
|
||||
$population_method = fw_get_db_post_option($post_id, 'slider/'.$selected.'/population-method');
|
||||
$population_method_instance = $this->get_child('population-method-' . $population_method);
|
||||
|
||||
if ($population_method_instance) {
|
||||
return $population_method_instance->get_population_method();
|
||||
} else {
|
||||
return array('_unknown' => sprintf(__('Population method %s does not exist', 'fw'), $population_method));
|
||||
}
|
||||
}
|
||||
|
||||
public function get_number_of_images($post_id)
|
||||
{
|
||||
$selected = fw_get_db_post_option($post_id, 'slider/selected');
|
||||
$population_method = fw_get_db_post_option($post_id, 'slider/'.$selected.'/population-method');
|
||||
$population_method_instance = $this->get_child('population-method-' . $population_method);
|
||||
|
||||
if ($population_method_instance) {
|
||||
return $population_method_instance->get_number_of_images($post_id);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function get_frontend_data($post_id)
|
||||
{
|
||||
$selected = fw_get_db_post_option($post_id, 'slider/selected');
|
||||
$population_method = fw_get_db_post_option($post_id, 'slider/'.$selected.'/population-method');
|
||||
$population_method_instance = $this->get_child('population-method-' . $population_method);
|
||||
|
||||
if ($population_method_instance) {
|
||||
return $population_method_instance->get_frontend_data($post_id);
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
|
||||
class FW_Extension_Population_Method_Categories extends FW_Extension implements Population_Method_Interface
|
||||
{
|
||||
private $multimedia_types = array('image');
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function _init()
|
||||
{
|
||||
}
|
||||
|
||||
public function get_multimedia_types()
|
||||
{
|
||||
return $this->multimedia_types;
|
||||
}
|
||||
|
||||
public function get_population_method()
|
||||
{
|
||||
return array('categories' => __('Automatically, fetch images from categories', 'fw'));
|
||||
}
|
||||
|
||||
public function get_population_options($multimedia_types, $custom_options)
|
||||
{
|
||||
$population_options = array();
|
||||
$post_categories = $this->get_post_categories();
|
||||
if (empty($post_categories)) {
|
||||
$message = sprintf(__('%s extension needs configured categories in post types', 'fw'), ucwords(str_replace('-', ' ', $this->get_name())));
|
||||
wp_die($message);
|
||||
} else {
|
||||
$population_options = array(
|
||||
'wrapper-population-method-categories' => array(
|
||||
'title' => __('Categories Population Method', 'fw'),
|
||||
'type' => 'box',
|
||||
'options' => array(
|
||||
'categories' => array(
|
||||
'type' => 'multi-picker',
|
||||
'label' => false,
|
||||
'desc' => false,
|
||||
'show_borders'=>true,
|
||||
'picker' => array(
|
||||
'selected' => array(
|
||||
'label' => __('Choose Category', 'fw'),
|
||||
'type' => 'select',
|
||||
'choices' => $this->get_post_categories()
|
||||
)
|
||||
),
|
||||
'choices' => $this->get_post_categories_sets()
|
||||
),
|
||||
'number_of_images' => array(
|
||||
'type' => 'text',
|
||||
'label' => __('Number of Images in the slider', 'fw')
|
||||
)
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
return $population_options;
|
||||
}
|
||||
|
||||
public function get_post_categories()
|
||||
{
|
||||
$collector = array();
|
||||
$post_types = get_post_types(array('public' => true), 'objects');
|
||||
|
||||
foreach ($post_types as $key => $post_type) {
|
||||
|
||||
$have_terms = $this->get_terms($key);
|
||||
|
||||
if (!empty($have_terms)) {
|
||||
$collector[$key] = empty($post_type->labels->name) ? $post_type->label : $post_type->labels->name;
|
||||
}
|
||||
}
|
||||
|
||||
return $collector;
|
||||
}
|
||||
|
||||
private function get_terms($post_type)
|
||||
{
|
||||
$taxonomies = get_taxonomies(array('object_type' => array($post_type), 'hierarchical' => true));
|
||||
if (count($taxonomies)) {
|
||||
return get_terms($taxonomies);
|
||||
}
|
||||
return $taxonomies;
|
||||
}
|
||||
|
||||
private function get_post_categories_sets()
|
||||
{
|
||||
$post_types = get_post_types(array('public' => true));
|
||||
$terms_collector = array();
|
||||
|
||||
foreach ($post_types as $post_type) {
|
||||
|
||||
$terms = $this->get_terms($post_type);
|
||||
|
||||
if (!empty($terms) && !is_wp_error($terms)) {
|
||||
$terms_collector = array();
|
||||
foreach ($terms as $term) {
|
||||
$key = json_encode(array('term_id' => $term->term_id, 'taxonomy' => $term->taxonomy));
|
||||
$terms_collector[$key] = $term->name;
|
||||
}
|
||||
}
|
||||
|
||||
$collector[$post_type] = array(
|
||||
'terms' => array(
|
||||
'type' => 'select-multiple',
|
||||
'attr' => array('class' => 'selectize fw-selectize'),
|
||||
'label' => __('Select Specific Categories', 'fw'),
|
||||
'choices' => $terms_collector,
|
||||
)
|
||||
);
|
||||
}
|
||||
return $collector;
|
||||
}
|
||||
|
||||
public function get_number_of_images($post_id)
|
||||
{
|
||||
return (int)fw_get_db_post_option($post_id, 'number_of_images');
|
||||
}
|
||||
|
||||
public function get_frontend_data($post_id)
|
||||
{
|
||||
$collector = array();
|
||||
$meta = fw_get_db_post_option($post_id);
|
||||
$post_status = get_post_status($post_id);
|
||||
|
||||
if ('publish' === $post_status and isset($meta['populated'])) {
|
||||
|
||||
$slider_name = $meta['slider']['selected'];
|
||||
$population_method = $meta['slider'][$slider_name]['population-method'];
|
||||
$number_of_images = (int)$meta['number_of_images'];
|
||||
|
||||
$collector = array(
|
||||
'slides' => array(),
|
||||
'settings' => array(
|
||||
'title' => $meta['title'],
|
||||
'slider_type' => $slider_name,
|
||||
'population_method' => $population_method,
|
||||
'post_id' => $post_id,
|
||||
'extra' => isset($meta['custom-settings']) ? $meta['custom-settings'] : array(),
|
||||
)
|
||||
);
|
||||
|
||||
$query_data = array();
|
||||
$post_type = $meta['categories']['selected'];
|
||||
$terms = $meta['categories'][$post_type]['terms'];
|
||||
|
||||
$tax_query = array(
|
||||
'tax_query' => array(
|
||||
'relation' => 'OR'
|
||||
)
|
||||
);
|
||||
|
||||
foreach ($terms as $term) {
|
||||
$decoded_data = json_decode($term, true);
|
||||
$query_data[$decoded_data['taxonomy']][] = $decoded_data['term_id'];
|
||||
}
|
||||
|
||||
foreach ($query_data as $taxonomy => $terms) {
|
||||
$tax_query['tax_query'][] = array(
|
||||
'taxonomy' => $taxonomy,
|
||||
'field' => 'id',
|
||||
'terms' => $terms
|
||||
);
|
||||
}
|
||||
|
||||
$attachment_query = array(
|
||||
'post_status' => 'any',
|
||||
'numberposts' => -1,
|
||||
'post_parent' => null,
|
||||
'post_type' => $post_type,
|
||||
'post_mime_type'=>'image',
|
||||
|
||||
);
|
||||
|
||||
$regular_query = array(
|
||||
'numberposts' => -1,
|
||||
'post_status' => 'publish',
|
||||
'posts_per_page' => $number_of_images,
|
||||
'post_type' => $post_type,
|
||||
'meta_key' => '_thumbnail_id',
|
||||
);
|
||||
|
||||
$post_query = ($post_type === 'attachment') ? $attachment_query : $regular_query;
|
||||
$final_query = array_merge( $post_query, $tax_query );
|
||||
|
||||
global $post;
|
||||
$original_post = $post;
|
||||
|
||||
$the_query = new WP_Query($final_query);
|
||||
|
||||
while ($the_query->have_posts()) {
|
||||
$the_query->the_post();
|
||||
$post_id = get_the_ID();
|
||||
array_push($collector['slides'], array(
|
||||
'title' => get_the_title($post_id),
|
||||
'multimedia_type' => $this->multimedia_types[0],
|
||||
'src' => wp_get_attachment_url(get_post_thumbnail_id($post_id)),
|
||||
'desc' => get_the_excerpt(),
|
||||
'extra' => array(
|
||||
'post_id' => $post_id
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
wp_reset_postdata();
|
||||
|
||||
$post = $original_post;
|
||||
unset($original_post);
|
||||
}
|
||||
|
||||
return $collector;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
|
||||
$manifest['name'] = __( 'Population Method - Categories', 'fw' );
|
||||
$manifest['description'] = __( 'Population Method - Categories', 'fw' );
|
||||
|
||||
$manifest['version'] = '1.0.0';
|
||||
|
||||
$manifest['display'] = 'slider';
|
||||
@@ -0,0 +1,181 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
|
||||
class FW_Extension_Population_Method_Custom extends FW_Extension implements Population_Method_Interface
|
||||
{
|
||||
private $multimedia_types = array('image', 'video');
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function _init()
|
||||
{
|
||||
add_action('fw_option_types_init', array($this, '_action_option_types_init'));
|
||||
}
|
||||
|
||||
public function _action_option_types_init() {
|
||||
require dirname(__FILE__) .'/includes/slides/class-fw-option-type-slides.php';
|
||||
}
|
||||
|
||||
public function get_multimedia_types()
|
||||
{
|
||||
return $this->multimedia_types;
|
||||
}
|
||||
|
||||
|
||||
public function get_population_method()
|
||||
{
|
||||
return array('custom' => __('Manually, I\'ll upload the images myself'));
|
||||
}
|
||||
|
||||
public function get_population_options($multimedia_types, $custom_options)
|
||||
{
|
||||
$media_type_choices = $this->transform_multimedia_types_array($multimedia_types);
|
||||
$media_type_values = array_keys($media_type_choices);
|
||||
$media_type_values = array_shift($media_type_values);
|
||||
|
||||
$options = array(
|
||||
'wrapper-population-method-custom' => array(
|
||||
'title' => __('Click to edit / Drag to reorder', 'fw') . ' <span class="fw-slide-spinner spinner"></span>',
|
||||
'type' => 'box',
|
||||
'options' => array(
|
||||
'custom-slides' =>
|
||||
array(
|
||||
'label' => false,
|
||||
'desc' => false,
|
||||
'type' => 'slides',
|
||||
'multimedia_type' => array_keys($media_type_choices),
|
||||
'thumb_size' => array('height' => 75, 'width' => 138),
|
||||
'slides_options' => array(
|
||||
'multimedia' => array(
|
||||
'type' => 'multi-picker',
|
||||
'desc' => false,
|
||||
'label' => false,
|
||||
'hide_picker' => true,
|
||||
'show_borders'=>true,
|
||||
'picker' => array(
|
||||
'selected' => array(
|
||||
'type' => 'radio',
|
||||
'attr' => array('class' => 'multimedia-radio-controls'),
|
||||
'label' => __('Choose', 'fw'),
|
||||
'choices' => $media_type_choices,
|
||||
'value' => $media_type_values
|
||||
)),
|
||||
'choices' => $this->get_multimedia_types_sets($multimedia_types)
|
||||
),
|
||||
'title' => array(
|
||||
'type' => 'text',
|
||||
'label' => __('Title', 'fw'),
|
||||
),
|
||||
'desc' => array(
|
||||
'type' => 'textarea',
|
||||
'label' => __('Description', 'fw'),
|
||||
'value' => ''
|
||||
),
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if (!empty($custom_options)) {
|
||||
$options['wrapper-population-method-custom']['options']['custom-slides']['slides_options']['extra-options'] =
|
||||
array(
|
||||
'type' => 'multi',
|
||||
'attr' => array('class' => 'fw-no-border'),
|
||||
'label' => false,
|
||||
'desc' => false,
|
||||
'inner-options' => $custom_options,
|
||||
);
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
private function transform_multimedia_types_array($multimedia_types)
|
||||
{
|
||||
return array_combine(
|
||||
array_values($multimedia_types),
|
||||
array_map('ucfirst', $multimedia_types)
|
||||
);
|
||||
}
|
||||
|
||||
private function get_multimedia_types_sets($multimedia_types)
|
||||
{
|
||||
$options = array(
|
||||
'image' => array(
|
||||
'src' => array(
|
||||
'label' => __('Image', 'fw'),
|
||||
'type' => 'upload',
|
||||
)
|
||||
),
|
||||
'video' => array(
|
||||
'src' => array(
|
||||
'label' => __('Video', 'fw'),
|
||||
'type' => 'text'
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
$filtered_options = array();
|
||||
|
||||
$filtered_multimedia_types = array_intersect($this->multimedia_types, $multimedia_types);
|
||||
|
||||
foreach ($filtered_multimedia_types as $multimedia_type) {
|
||||
$filtered_options[$multimedia_type] = $options[$multimedia_type];
|
||||
}
|
||||
|
||||
return $filtered_options;
|
||||
}
|
||||
|
||||
public function get_number_of_images($post_id)
|
||||
{
|
||||
return count(fw_get_db_post_option($post_id, 'custom-slides', array()));
|
||||
}
|
||||
|
||||
public function get_frontend_data( $post_id ) {
|
||||
$meta = fw_get_db_post_option( $post_id );
|
||||
$post_status = get_post_status( $post_id );
|
||||
|
||||
$collector = array();
|
||||
|
||||
if ( 'publish' === $post_status and isset( $meta['populated'] ) ) {
|
||||
|
||||
$slider_name = $meta['slider']['selected'];
|
||||
$population_method = $meta['slider'][ $slider_name ]['population-method'];
|
||||
|
||||
$collector = array(
|
||||
'slides' => array(),
|
||||
'settings' => array(
|
||||
'title' => $meta['title'],
|
||||
'slider_type' => $slider_name,
|
||||
'population_method' => $population_method,
|
||||
'post_id' => $post_id,
|
||||
'extra' => isset( $meta['custom-settings'] ) ? $meta['custom-settings'] : array(),
|
||||
)
|
||||
);
|
||||
|
||||
foreach ( $meta['custom-slides'] as $slide ) {
|
||||
|
||||
$collector_slide = array(
|
||||
'title' => ! empty( $slide['title'] ) ? $slide['title'] : '',
|
||||
'multimedia_type' => $slide['multimedia']['selected'],
|
||||
'src' =>
|
||||
( $slide['multimedia']['selected'] === 'image' && ! empty( $slide['multimedia'][ $slide['multimedia']['selected'] ]['src']['url'] ) ) ?
|
||||
$slide['multimedia'][ $slide['multimedia']['selected'] ]['src']['url'] :
|
||||
$slide['multimedia'][ $slide['multimedia']['selected'] ]['src'],
|
||||
'attachment_id' =>
|
||||
( $slide['multimedia']['selected'] === 'image' && ! empty( $slide['multimedia'][ $slide['multimedia']['selected'] ]['src']['attachment_id'] ) ) ?
|
||||
$slide['multimedia'][ $slide['multimedia']['selected'] ]['src']['attachment_id'] :
|
||||
'',
|
||||
'desc' => ! empty( $slide['desc'] ) ? $slide['desc'] : '',
|
||||
'extra' => isset( $slide['extra-options'] ) ? $slide['extra-options'] : array()
|
||||
);
|
||||
|
||||
array_push( $collector['slides'], $collector_slide );
|
||||
}
|
||||
}
|
||||
|
||||
return $collector;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
|
||||
class FW_Option_Type_Slides extends FW_Option_Type
|
||||
{
|
||||
private $extension_name = 'population-method-custom';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function _init()
|
||||
{
|
||||
add_action('wp_ajax_cache_slide', array(__CLASS__, '_action_ajax_cache_slide'));
|
||||
add_action('wp_ajax_resize_slide', array(__CLASS__, '_action_ajax_resize_slide'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public static function _action_ajax_resize_slide()
|
||||
{
|
||||
$thumb_size = json_decode(FW_Request::POST('thumb_size'), true);
|
||||
wp_send_json(array('src' => fw_resize(FW_Request::POST('src'), $thumb_size['width'], $thumb_size['height'], true)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public static function _action_ajax_cache_slide()
|
||||
{
|
||||
$output = '';
|
||||
$attr_data = json_decode(FW_Request::POST('option'), true);
|
||||
|
||||
$option = $attr_data['option'];
|
||||
$id = $attr_data['id'];
|
||||
$data = $attr_data['data'];
|
||||
|
||||
parse_str(FW_Request::POST('values'), $values);
|
||||
|
||||
if (isset($values)) {
|
||||
$options_values_cache = $values['fw_options']['custom-slides'];
|
||||
$options_values = array_pop($options_values_cache);
|
||||
$valid_values = fw_get_options_values_from_input(
|
||||
$option['slides_options'],
|
||||
$options_values
|
||||
);
|
||||
|
||||
foreach ($values['fw_options']['custom-slides'] as $key => $value) {
|
||||
$output .= "<div class='fw-slide slide-" . $key . "' data-order='" . $key . "'>";
|
||||
|
||||
$output .= fw()->backend->render_options($option['slides_options'], $valid_values, array(
|
||||
'id_prefix' => $data['id_prefix'] . $id . '-' . $key . '-',
|
||||
'name_prefix' => $data['name_prefix'] . '[' . $id . '][' . $key . ']'
|
||||
));
|
||||
$output .= "</div>";
|
||||
}
|
||||
}
|
||||
|
||||
wp_send_json($output);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
protected function _get_defaults()
|
||||
{
|
||||
return array(
|
||||
'value' => array(),
|
||||
'thumb_size' => array(
|
||||
'width' => 150,
|
||||
'height' => 150
|
||||
),
|
||||
'slides_options' => array()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function _enqueue_static($id, $option, $data)
|
||||
{
|
||||
$ext = fw()->extensions->get($this->extension_name);
|
||||
$js_path = $ext->get_URI('/includes/slides/static/js/slides.js');
|
||||
$css_path = $ext->get_URI('/includes/slides/static/css/slides.css');
|
||||
|
||||
wp_enqueue_script(
|
||||
'fw-option-'. $this->get_type() .'-slides-js',
|
||||
$js_path,
|
||||
array('jquery-ui-sortable','qtip', 'fw'),
|
||||
fw()->manifest->get_version()
|
||||
);
|
||||
wp_enqueue_style(
|
||||
'fw-option-'. $this->get_type() .'-slides-css',
|
||||
$css_path,
|
||||
array('qtip'),
|
||||
fw()->manifest->get_version()
|
||||
);
|
||||
|
||||
fw()->backend->enqueue_options_static($option['slides_options']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate option's html from option array
|
||||
* @param string $id
|
||||
* @param array $option
|
||||
* @param array $data
|
||||
* @return string HTML
|
||||
* @internal
|
||||
*/
|
||||
protected function _render($id, $option, $data)
|
||||
{
|
||||
$ext = fw()->extensions->get($this->extension_name);
|
||||
|
||||
return fw_render_view(
|
||||
$ext->get_path('/includes/slides/views/slides.php'),
|
||||
array(
|
||||
'id' => $id,
|
||||
'option' => $option,
|
||||
'data' => $data,
|
||||
'thumb_size' => $option['thumb_size'],
|
||||
'values' => $data['value'],
|
||||
'slides_options' => $option['slides_options'],
|
||||
'multimedia_type' => (array)$option['multimedia_type'],
|
||||
'type' => $this->get_type(),
|
||||
'attr' => array(
|
||||
'data-js-tpl' => fw_render_view(
|
||||
$ext->get_path('/includes/slides/views/templates.php'),
|
||||
array(
|
||||
'id' => $id,
|
||||
'option' => $option,
|
||||
'data' => $data,
|
||||
'values' => $data['value'],
|
||||
'type' => $this->get_type(),
|
||||
'thumb_size' => $option['thumb_size'],
|
||||
'slides_options' => $option['slides_options'],
|
||||
)
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Option's unique type, used in option array in 'type' key
|
||||
* @return string
|
||||
*/
|
||||
public function get_type()
|
||||
{
|
||||
return 'slides';
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract correct value for $option['value'] from input array
|
||||
* If input value is empty, will be returned $option['value']
|
||||
* @param array $option
|
||||
* @param array|string|null $input_value
|
||||
* @return string|array|int|bool Correct value
|
||||
* @internal
|
||||
*/
|
||||
protected function _get_value_from_input($option, $input_value)
|
||||
{
|
||||
if (!is_array($input_value)) {
|
||||
return $option['value'];
|
||||
}
|
||||
|
||||
// unset the last slide that is default for add
|
||||
array_pop($input_value);
|
||||
|
||||
$value = array();
|
||||
|
||||
$slides_options = fw_extract_only_options($option['slides_options']);
|
||||
|
||||
foreach ($input_value as &$list_item_value) {
|
||||
$current_value = array();
|
||||
|
||||
foreach ($slides_options as $id => $input_option) {
|
||||
$current_value[$id] = fw()->backend->option_type($input_option['type'])->get_value_from_input(
|
||||
$input_option,
|
||||
isset($list_item_value[$id]) ? $list_item_value[$id] : null
|
||||
);
|
||||
$current_value['thumb'] = isset($list_item_value['thumb']) ? $list_item_value['thumb'] : null;
|
||||
}
|
||||
|
||||
$value[] = $current_value;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
FW_Option_Type::register('FW_Option_Type_Slides');
|
||||
@@ -0,0 +1,137 @@
|
||||
.thumbs-wrapper {
|
||||
margin: 20px auto;
|
||||
padding-left: 25px;
|
||||
padding-right: 25px;
|
||||
}
|
||||
.thumbs-wrapper .add-new-btn {
|
||||
padding: 2px;
|
||||
border: 3px solid transparent;
|
||||
}
|
||||
.thumbs-wrapper .add-new-btn div{
|
||||
width: 90px;
|
||||
height:75px;
|
||||
display: block;
|
||||
background-color:#f2f2f2;
|
||||
float:left;
|
||||
font-size: 0px;
|
||||
background-image: url(../images/icon.png);
|
||||
background-repeat: no-repeat;
|
||||
background-position: 50% 20px;
|
||||
}
|
||||
.thumbs-wrapper .add-new-btn p {
|
||||
margin-top: 45px;
|
||||
text-align: center;
|
||||
font-style: italic;
|
||||
}
|
||||
.thumbs-wrapper .delete-btn {
|
||||
display: none;
|
||||
z-index: 999;
|
||||
position: absolute;
|
||||
border-width: 0px;
|
||||
line-height: 0;
|
||||
right: -5px;
|
||||
top: -5px;
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
cursor: pointer;
|
||||
border-radius: 100%;
|
||||
background-color: #fff;
|
||||
}
|
||||
.thumbs-wrapper .delete-btn:hover {
|
||||
color: #db382f;
|
||||
}
|
||||
.thumbs-wrapper .delete-btn:before {
|
||||
content: '\f153';
|
||||
display: block !important;
|
||||
font: 400 18px/1 dashicons;
|
||||
}
|
||||
.fw-option-type-slides .buttons-wrapper{
|
||||
padding: 15px 25px;
|
||||
display : none;
|
||||
}
|
||||
.thumbs-wrapper li:hover .delete-btn {
|
||||
display: block;
|
||||
}
|
||||
.thumbs-wrapper li {
|
||||
margin-right: 4px;
|
||||
margin-bottom: 0px;
|
||||
position: relative;
|
||||
display: block;
|
||||
float: left;
|
||||
cursor: pointer;
|
||||
line-height: 0;
|
||||
padding: 2px;
|
||||
border-radius: 2px;
|
||||
border: 3px solid transparent;
|
||||
}
|
||||
.thumbs-wrapper li.selected {
|
||||
border: 3px solid #64bd1f;
|
||||
}
|
||||
.thumbs-wrapper li:hover{
|
||||
border: 3px solid #dddddd;
|
||||
}
|
||||
.thumbs-wrapper li.selected:hover{
|
||||
border: 3px solid #64bd1f;
|
||||
}
|
||||
|
||||
.thumbs-wrapper li.new-selected {
|
||||
border: 3px solid #64bd1f;
|
||||
margin-right: 40px;
|
||||
}
|
||||
.thumbs-wrapper li.selected:after, .thumbs-wrapper li.new-selected:after{
|
||||
content: "\f147";
|
||||
font-family: dashicons;
|
||||
background-color: #64bd1f;
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
bottom: 0px;
|
||||
border-top-left-radius: 2px;
|
||||
color: #fff;
|
||||
line-height: normal;
|
||||
font-size: 20px;
|
||||
}
|
||||
.fw-slides-wrapper .fw-slide {
|
||||
display :none;
|
||||
border-top: 1px solid #eeeeee;
|
||||
}
|
||||
.fw-slides-wrapper .fw-slide.default{
|
||||
display: block;
|
||||
}
|
||||
.fw-backend-option-type-slides > .fw-backend-option-input > .fw-inner {
|
||||
width: 100% !important;
|
||||
max-width: 100% !important;
|
||||
}
|
||||
.fw-backend-option-type-slides{
|
||||
padding: 0 !important;
|
||||
}
|
||||
.multimedia-radio-controls div {
|
||||
display: inline-block;
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
#fw-options-box-wrapper-population-method-custom .inside{
|
||||
margin-top: 0px !important;
|
||||
padding-bottom: 0px !important;
|
||||
}
|
||||
|
||||
/* qtip */
|
||||
|
||||
.qtip-fw-slides {
|
||||
padding: 5px 10px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.qtip-fw-slides .qtip-content {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* end: qtip */
|
||||
|
||||
.fw-slide-spinner.spinner {
|
||||
/*float: left;*/
|
||||
float: none;
|
||||
display: inline-block !important;
|
||||
margin-top: -3px;
|
||||
visibility: hidden;
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
After Width: | Height: | Size: 359 B |
|
After Width: | Height: | Size: 448 B |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
@@ -0,0 +1,420 @@
|
||||
/*
|
||||
* Dependency jQuery Sortable
|
||||
* */
|
||||
|
||||
(function ($) {
|
||||
|
||||
$.fn.slides = function (options) {
|
||||
var extensionPath = fw.FW_URI +'/extensions/media/extensions/population-method/extensions/population-method-custom/includes/slides/static/images/';
|
||||
var defaults = {
|
||||
'mediaImg': extensionPath+'no_video.jpg',
|
||||
'noDataImg': extensionPath+'no_img.jpg',
|
||||
'imageExtensions': ['jpeg', 'jpg', 'png', 'gif', 'bmp'],
|
||||
'addSlideSelector': 'fw-add-slide',
|
||||
'editSlideSelector': '.fw-edit-slide',
|
||||
'addSlideEvent': 'fw:add:new:slide',
|
||||
'editSlideEvent': 'fw:edit:slide'
|
||||
},
|
||||
settings = $.extend({}, defaults, options);
|
||||
|
||||
return this.each(function () {
|
||||
var $this = $(this),
|
||||
elements = {
|
||||
$optionWrappper: $this,
|
||||
$addButton: $this.find('.fw-add-slide'),
|
||||
$slidesWrapper: $this.find('.fw-slides-wrapper'),
|
||||
$spinner :$this.parents('.postbox').find('.fw-slide-spinner')
|
||||
},
|
||||
$template = $($this.attr('data-js-tpl')),
|
||||
templates = {
|
||||
settings: {
|
||||
evaluate: /\{\{([\s\S]+?)\}\}/g,
|
||||
interpolate: /\{\{=([\s\S]+?)\}\}/g,
|
||||
escape: /\{\{-([\s\S]+?)\}\}/g
|
||||
},
|
||||
thumb: $template.filter('.default-thumb').html(),
|
||||
slide: $template.filter('.default-slide').html()
|
||||
},
|
||||
utils = {
|
||||
getSlideElement: function (slideNumber) {
|
||||
return elements.$optionWrappper.find('.slide-' + slideNumber);
|
||||
},
|
||||
initQtip: function ($elements) {
|
||||
$elements.each(function () {
|
||||
$(this).qtip({
|
||||
content: {
|
||||
text :'Click to edit / Drag to reorder'
|
||||
},
|
||||
position: {
|
||||
at: 'top center',
|
||||
my: 'bottom center',
|
||||
viewport: jQuery('body')
|
||||
},
|
||||
style: {
|
||||
classes: 'qtip-fw qtip-fw-slides',
|
||||
tip: {
|
||||
width: 12,
|
||||
height: 5
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
appendDefaultSlide: function (slideNumber) {
|
||||
var $compiled = $(
|
||||
_.template(
|
||||
$.trim(templates.slide),
|
||||
undefined,
|
||||
templates.settings
|
||||
)({i: slideNumber})
|
||||
).hide();
|
||||
|
||||
var $default = elements.$slidesWrapper.find('.default');
|
||||
|
||||
if ($default.length > 0) {
|
||||
$default.slideUp(500, function () {
|
||||
elements.$slidesWrapper.children().removeClass('default').hide();
|
||||
elements.$slidesWrapper.append($compiled);
|
||||
fwEvents.trigger('fw:options:init', {$elements: $compiled});
|
||||
});
|
||||
} else {
|
||||
elements.$slidesWrapper.append($compiled);
|
||||
fwEvents.trigger('fw:options:init', {$elements: $compiled});
|
||||
}
|
||||
},
|
||||
revealSlide: function (slideNumber) {
|
||||
elements.$slidesWrapper.find('.fw-slide').hide();
|
||||
utils.getSlideElement(slideNumber).slideDown();//show();
|
||||
},
|
||||
replaceSlide: function (slideNumber) {
|
||||
var $cachedSlide = cache.getCachedSlide(slideNumber).clone();
|
||||
|
||||
elements.$slidesWrapper.find('.slide-' + slideNumber).remove();
|
||||
elements.$slidesWrapper.append($cachedSlide);
|
||||
fwEvents.trigger('fw:options:init', {$elements: $cachedSlide});
|
||||
},
|
||||
getDefaultThumb: function (data) {
|
||||
var $defaultThumb = $(
|
||||
_.template(
|
||||
$.trim(templates.thumb),
|
||||
undefined,
|
||||
{
|
||||
evaluate: /\{\{([\s\S]+?)\}\}/g,
|
||||
interpolate: /\{\{=([\s\S]+?)\}\}/g,
|
||||
escape: /\{\{-([\s\S]+?)\}\}/g
|
||||
}
|
||||
)({src: data['src'], i: data['order_id']})
|
||||
);
|
||||
utils.initQtip($defaultThumb);
|
||||
return $defaultThumb;
|
||||
},
|
||||
cancelEditMode: function () {
|
||||
this.hideControlButtons();
|
||||
this.deselectThumbs();
|
||||
this.deselectSlides();
|
||||
},
|
||||
hideControlButtons: function () {
|
||||
elements.$optionWrappper.find('.buttons-wrapper').hide();
|
||||
},
|
||||
showControlButtons: function () {
|
||||
var $buttonsWrapper = elements.$optionWrappper.find('.buttons-wrapper');
|
||||
if ($buttonsWrapper.is(':hidden')) {
|
||||
$buttonsWrapper.show();
|
||||
}
|
||||
},
|
||||
showEditButtons: function () {
|
||||
utils.showControlButtons();
|
||||
elements.$optionWrappper.find('.edit-buttons').show();
|
||||
elements.$addButton.hide();
|
||||
},
|
||||
showAddButton: function () {
|
||||
utils.showControlButtons();
|
||||
elements.$addButton.show();
|
||||
elements.$optionWrappper.find('.edit-buttons').hide();
|
||||
},
|
||||
deselectThumbs: function () {
|
||||
elements.$optionWrappper.find('li').removeClass('selected');
|
||||
elements.$optionWrappper.find('.add-new-btn').removeClass('new-selected');
|
||||
},
|
||||
deselectSlides: function () {
|
||||
elements.$optionWrappper.find('.fw-slide').hide();
|
||||
},
|
||||
getThumbSrcFromOption: function ($option) {
|
||||
|
||||
var $multimedia_type = $option.find('.picker-group :radio:checked').val(),
|
||||
$group = $option.find('.choice-group.chosen'),
|
||||
$inputValue = $group.find(':input').val(),
|
||||
$thumbSrc = $group.find('.thumb[data-attid="' + $inputValue + '"] img');
|
||||
|
||||
if ($thumbSrc.length === 0) {
|
||||
$thumbSrc = $inputValue;
|
||||
} else {
|
||||
$thumbSrc = $group.find('.thumb').attr('data-origsrc');
|
||||
}
|
||||
|
||||
return {'src': $thumbSrc, 'multimedia_type': $multimedia_type};
|
||||
},
|
||||
initSortable: function () {
|
||||
elements.$optionWrappper.find('.thumbs-wrapper').sortable({
|
||||
items: "li:not(.sortable-false)"
|
||||
});
|
||||
},
|
||||
initSlides: function () {
|
||||
utils.hideControlButtons();
|
||||
utils.appendDefaultSlide(slidesNumber);
|
||||
utils.initSortable();
|
||||
|
||||
var thumbs = elements.$optionWrappper.find('.thumbs-wrapper li:not(.sortable-false)');
|
||||
utils.initQtip(thumbs);
|
||||
$.each(thumbs, function () {
|
||||
var slideNumber = $(this).data('order');
|
||||
|
||||
cache.slides['slide-' + slideNumber] = $(
|
||||
'<div class="fw-slide slide-' + slideNumber + '" data-order="' + slideNumber + '">'
|
||||
+ elements.$slidesWrapper.find('.slide-' + slideNumber).data('default-html')
|
||||
+ '</div>'
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
validator = {
|
||||
parseValidUrl: function (src) {
|
||||
//REGEX FROM https://gist.github.com/dperini/729294
|
||||
return (
|
||||
/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/i
|
||||
).test(src);
|
||||
},
|
||||
parseYouTubeSrc: function (src) {
|
||||
// REGEX FROM http://stackoverflow.com/a/9102270
|
||||
var matches = src.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/);
|
||||
if (matches && matches[2].length == 11) {
|
||||
return matches[2];
|
||||
}
|
||||
return false;
|
||||
},
|
||||
getYoutubeImgSrc: function (youtubeId) {
|
||||
// http://stackoverflow.com/questions/2068344/how-do-i-get-a-youtube-video-thumbnail-from-the-youtube-api
|
||||
return 'https://img.youtube.com/vi/' + youtubeId + '/mqdefault.jpg';
|
||||
},
|
||||
parseImgSrc: function (src) {
|
||||
return (-1 !== $.inArray(src.split('.').pop().toLowerCase(), settings.imageExtensions));
|
||||
},
|
||||
parseVimeoSrc: function (src) {
|
||||
//REGEX FROM http://stackoverflow.com/a/2916654
|
||||
var matches = src.match(
|
||||
/https?:\/\/(?:www\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|)(\d+)(?:$|\/|\?)/
|
||||
);
|
||||
if (matches) {
|
||||
return matches[3];
|
||||
}
|
||||
return false;
|
||||
},
|
||||
getVimeoImgSrc: function (eventName, data) {
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: 'https://vimeo.com/api/v2/video/' + data['src'] + '.json',
|
||||
jsonp: 'callback',
|
||||
dataType: 'jsonp'
|
||||
}).done(function (response) {
|
||||
data['src'] = response[0].thumbnail_medium;
|
||||
validator.triggerEvent(eventName, data);
|
||||
}).fail(function () {
|
||||
data['src'] = settings.mediaImg;
|
||||
validator.triggerEvent(eventName, data);
|
||||
});
|
||||
},
|
||||
triggerEvent: function (event, data) {
|
||||
elements.$optionWrappper.trigger(event, data);
|
||||
},
|
||||
validateSrc: function (eventName, data) {
|
||||
var isMediaImg = true;
|
||||
var src = data['src'];
|
||||
if (data['multimedia_type'] === 'image' && data['src'] !== '') {
|
||||
|
||||
var thumbSize = JSON.stringify(elements.$optionWrappper.data('option').option.thumb_size);
|
||||
|
||||
$.ajax({
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'resize_slide',
|
||||
'src': data['src'],
|
||||
'thumb_size': thumbSize
|
||||
}
|
||||
}).done(function (response) {
|
||||
data['src'] = response.src;
|
||||
validator.triggerEvent(eventName, data);
|
||||
}).fail(function () {
|
||||
data['src'] = settings.mediaImg;
|
||||
validator.triggerEvent(eventName, data);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
if (data['src'] === '' || data['src'] === undefined) {
|
||||
data['src'] = data.multimedia_type === 'image' ? settings.noDataImg : settings.mediaImg;
|
||||
|
||||
this.triggerEvent(eventName, data);
|
||||
return;
|
||||
}
|
||||
if (this.parseValidUrl(src)) {
|
||||
if (this.parseYouTubeSrc(src) !== false) {
|
||||
isMediaImg = false;
|
||||
data['src'] = this.getYoutubeImgSrc(this.parseYouTubeSrc(data['src']));
|
||||
this.triggerEvent(eventName, data);
|
||||
}
|
||||
if (this.parseVimeoSrc(src) !== false) {
|
||||
isMediaImg = false;
|
||||
data['src'] = this.parseVimeoSrc(data['src']);
|
||||
this.getVimeoImgSrc(eventName, data);
|
||||
}
|
||||
|
||||
if (this.parseImgSrc(src)) {
|
||||
isMediaImg = false;
|
||||
this.triggerEvent(eventName, data);
|
||||
}
|
||||
|
||||
if (isMediaImg) {
|
||||
data['src'] = settings.mediaImg;
|
||||
this.triggerEvent(eventName, data);
|
||||
}
|
||||
|
||||
} else {
|
||||
data['src'] = settings.noDataImg;
|
||||
this.triggerEvent(eventName, data);
|
||||
}
|
||||
}
|
||||
},
|
||||
cache = {
|
||||
slides: {},
|
||||
cacheSlide: function (slideNumber) {
|
||||
|
||||
var serializedData = elements.$optionWrappper.find('.slide-' + slideNumber + ' :input').serialize();
|
||||
var optionSlides = JSON.stringify(elements.$optionWrappper.data('option'));
|
||||
|
||||
$.ajax({
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'cache_slide',
|
||||
'option': optionSlides,
|
||||
'values': serializedData
|
||||
}
|
||||
}).done(function (response) {
|
||||
cache.slides['slide-' + slideNumber] = $(response);
|
||||
});
|
||||
},
|
||||
getCachedSlide: function (slideNumber) {
|
||||
return this.slides['slide-' + slideNumber];
|
||||
}
|
||||
};
|
||||
|
||||
var slidesNumber = elements.$optionWrappper.find('.thumbs-wrapper li').length;
|
||||
|
||||
utils.initSlides();
|
||||
|
||||
elements.$addButton.on('click', function (e) {
|
||||
e.preventDefault();
|
||||
cache.cacheSlide(slidesNumber);
|
||||
elements.$spinner.css({'visibility' : 'visible'});
|
||||
var mediaSrc = utils.getThumbSrcFromOption(utils.getSlideElement(slidesNumber)),
|
||||
data = {src: mediaSrc['src'], order_id: slidesNumber, 'multimedia_type': mediaSrc['multimedia_type']};
|
||||
|
||||
slidesNumber++;
|
||||
utils.appendDefaultSlide(slidesNumber);
|
||||
utils.hideControlButtons();
|
||||
validator.validateSrc(settings.addSlideEvent, data);
|
||||
});
|
||||
|
||||
elements.$optionWrappper.on(settings.addSlideEvent, function (e, data) {
|
||||
elements.$optionWrappper.find('.thumbs-wrapper .add-new-btn').before(utils.getDefaultThumb(data));
|
||||
utils.deselectThumbs();
|
||||
elements.$spinner.css({visibility : 'hidden'});
|
||||
});
|
||||
|
||||
elements.$optionWrappper.on(settings.editSlideEvent, function (e, data) {
|
||||
elements.$optionWrappper.find('.thumbs-wrapper li[data-order="' + data['order_id'] + '"]').replaceWith(utils.getDefaultThumb(data));
|
||||
elements.$spinner.css({visibility : 'hidden'});
|
||||
});
|
||||
|
||||
elements.$optionWrappper.on('click', '.thumbs-wrapper li:not(.sortable-false)', function (e) {
|
||||
e.preventDefault();
|
||||
if (!$(this).hasClass('selected')) {
|
||||
var lastSelectedThumb = elements.$optionWrappper.find('.thumbs-wrapper li.selected');
|
||||
|
||||
if (lastSelectedThumb.length > 0) {
|
||||
utils.replaceSlide(lastSelectedThumb.data('order'));
|
||||
}
|
||||
|
||||
utils.deselectThumbs();
|
||||
utils.revealSlide($(this).data('order'));
|
||||
$(this).addClass('selected');
|
||||
utils.showEditButtons();
|
||||
}
|
||||
});
|
||||
|
||||
elements.$optionWrappper.on('click', '.fw-edit-slide', function (e) {
|
||||
e.preventDefault();
|
||||
var slideNumber = elements.$optionWrappper.find('.thumbs-wrapper li.selected').data('order'),
|
||||
mediaSrc = utils.getThumbSrcFromOption(utils.getSlideElement(slideNumber));
|
||||
|
||||
cache.cacheSlide(slideNumber);
|
||||
elements.$spinner.css({'visibility' : 'visible'});
|
||||
utils.getSlideElement(slideNumber).slideUp(500, function () {
|
||||
validator.validateSrc(settings.editSlideEvent, {'src': mediaSrc['src'], 'order_id': slideNumber, 'multimedia_type': mediaSrc['multimedia_type']});
|
||||
utils.cancelEditMode();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
elements.$optionWrappper.on('click', '.fw-cancel-edit', function (e) {
|
||||
e.preventDefault();
|
||||
var slideNumber = elements.$optionWrappper.find('.thumbs-wrapper li.selected').data('order');
|
||||
|
||||
utils.getSlideElement(slideNumber).slideUp(500, function () {
|
||||
utils.replaceSlide(slideNumber);
|
||||
utils.cancelEditMode();
|
||||
utils.hideControlButtons();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
elements.$optionWrappper.on('click', '.delete-btn', function (e) {
|
||||
var $selectedThumb = $(this).closest('li'),
|
||||
slideNumber = $selectedThumb.data('order');
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
utils.cancelEditMode();
|
||||
|
||||
$selectedThumb.qtip('destroy');
|
||||
$selectedThumb.remove();
|
||||
utils.getSlideElement(slideNumber).remove();
|
||||
});
|
||||
|
||||
elements.$optionWrappper.on('click', '.add-new-btn', function () {
|
||||
if (!$(this).hasClass('new-selected')) {
|
||||
utils.deselectSlides();
|
||||
elements.$optionWrappper.find('li').removeClass('selected');
|
||||
elements.$optionWrappper.find('.add-new-btn').addClass('new-selected');
|
||||
elements.$optionWrappper.find('.fw-slide.default').slideDown();
|
||||
utils.showAddButton();
|
||||
}
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
jQuery(document).ready(function () {
|
||||
fwEvents.on('fw:options:init', function (data) {
|
||||
data.$elements
|
||||
.find('.fw-option-type-slides:not(.fw-option-initialized)')
|
||||
.slides()
|
||||
.addClass('fw-option-initialized');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
/**
|
||||
* @var string $id
|
||||
* @var array $option
|
||||
* @var array $data
|
||||
* @var array $thumb_size
|
||||
* @var array $values
|
||||
* @var string $type
|
||||
* @var array $slides_options
|
||||
* @var array $multimedia_type
|
||||
* @var array $attr
|
||||
*/
|
||||
?>
|
||||
<div class="fw-option fw-option-type-<?php echo esc_attr($type); ?>" <?php echo fw_attr_to_html($attr); ?>
|
||||
data-option="<?php echo fw_htmlspecialchars(json_encode(array('option' => $option, 'data' => $data, 'id' => $id))) ?>">
|
||||
<ul class="thumbs-wrapper">
|
||||
<?php if (isset($values)): ?>
|
||||
<?php foreach ($values as $key => $value): ?>
|
||||
<?php if (in_array($value['multimedia']['selected'], $multimedia_type)): ?>
|
||||
<li data-order="<?php echo esc_attr($key) ?>">
|
||||
<div class="delete-btn"></div>
|
||||
<img src="<?php echo esc_attr($value['thumb']) ?>" height="<?php echo esc_attr($thumb_size['height']) ?>"
|
||||
width="<?php echo esc_attr($thumb_size['width']) ?>"/>
|
||||
<?php echo fw()->backend->option_type('hidden')->render('thumb', array('value' => $value['thumb']), array(
|
||||
'id_prefix' => $data['id_prefix'] . $id . '-' . $key . '-',
|
||||
'name_prefix' => $data['name_prefix'] . '[' . $id . '][' . $key . ']',
|
||||
));?>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<li class="sortable-false add-new-btn">
|
||||
<div>
|
||||
<p><?php _e('Add New', 'fw') ?></p>
|
||||
</div>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<div class="fw-clear"></div>
|
||||
</ul>
|
||||
<div class="fw-slides-options">
|
||||
<div class="fw-slides-wrapper">
|
||||
<?php if (isset($values)): ?>
|
||||
<?php foreach ($values as $key => $value): ?>
|
||||
<?php if (in_array($value['multimedia']['selected'], $multimedia_type)): ?>
|
||||
|
||||
<?php $options = fw()->backend->render_options($slides_options, $value, array(
|
||||
'id_prefix' => $data['id_prefix'] . $id . '-' . $key . '-',
|
||||
'name_prefix' => $data['name_prefix'] . '[' . $id . '][' . $key . ']',
|
||||
));?>
|
||||
<div class="fw-slide slide-<?php echo esc_attr($key) ?>" data-order="<?php echo esc_attr($key) ?>"
|
||||
data-default-html="<?php echo fw_htmlspecialchars($options) ?>">
|
||||
<?php echo $options; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class='buttons-wrapper'>
|
||||
<button class='fw-add-slide button-primary button-large'><?php _e('Add Slide', 'fw') ?></button>
|
||||
<button
|
||||
class='fw-edit-slide edit-buttons button-primary button-large'><?php _e('Save Changes', 'fw') ?></button>
|
||||
<button class='fw-cancel-edit edit-buttons button'><?php _e('Cancel', 'fw') ?></button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php if (!defined('FW')) die('Forbidden'); ?>
|
||||
<script class="default-slide" type="text/template">
|
||||
<div class="fw-slide default slide-{{=i}}" data-order="{{=i}}">
|
||||
<?php echo fw()->backend->render_options(
|
||||
$slides_options,
|
||||
$values,
|
||||
array(
|
||||
'id_prefix' => $data['id_prefix'] . $id . '-' . '{{=i}}' . '-',
|
||||
'name_prefix' => $data['name_prefix'] . '[' . $id . '][' . '{{=i}}' . ']',
|
||||
)
|
||||
); ?>
|
||||
</div>
|
||||
</script>
|
||||
<script class="default-thumb" type="text/template">
|
||||
<li data-order="{{=i}}">
|
||||
<div class="delete-btn"></div>
|
||||
<img src="{{=src}}" height="<?php echo esc_attr($thumb_size['height']) ?>" width="<?php echo esc_attr($thumb_size['width']) ?>"/>
|
||||
<?php echo fw()->backend->option_type('hidden')->render(
|
||||
'thumb',
|
||||
array('value' => '{{=src}}'),
|
||||
array(
|
||||
'id_prefix' => $data['id_prefix'] . $id . '-' . '{{=i}}' . '-',
|
||||
'name_prefix' => $data['name_prefix'] . '[' . $id . '][' . '{{=i}}' . ']',
|
||||
)
|
||||
); ?>
|
||||
</li>
|
||||
</script>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
|
||||
$manifest['name'] = __( 'Population Method - Custom', 'fw' );
|
||||
$manifest['description'] = __( 'Population Method - Custom', 'fw' );
|
||||
|
||||
$manifest['version'] = '1.0.0';
|
||||
|
||||
$manifest['display'] = 'slider';
|
||||
@@ -0,0 +1,174 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
|
||||
class FW_Extension_Population_Method_Posts extends FW_Extension implements Population_Method_Interface
|
||||
{
|
||||
private $multimedia_types = array('image');
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function _init()
|
||||
{
|
||||
}
|
||||
|
||||
public function get_multimedia_types()
|
||||
{
|
||||
return $this->multimedia_types;
|
||||
}
|
||||
|
||||
public function get_population_method()
|
||||
{
|
||||
return array('posts' => __('Automatically, fetch images from posts', 'fw'));
|
||||
}
|
||||
|
||||
public function get_population_options($multimedia_types, $custom_options)
|
||||
{
|
||||
$population_options = array();
|
||||
$post_categories = $this->get_post_categories();
|
||||
if (empty($post_categories)) {
|
||||
$message = sprintf(__('%s extension needs configured post categories in post types', 'fw'), ucwords(str_replace('-', ' ', $this->get_name())));
|
||||
wp_die($message);
|
||||
} else {
|
||||
$population_options = array(
|
||||
'wrapper-population-method-posts' => array(
|
||||
'title' => __('Posts Population Method', 'fw'),
|
||||
'type' => 'box',
|
||||
'options' => array(
|
||||
'post_types' => array(
|
||||
'type' => 'multi-picker',
|
||||
'show_borders'=>true,
|
||||
'label' => false,
|
||||
'desc' => false,
|
||||
'picker' => array(
|
||||
'selected' => array(
|
||||
'label' => __('Choose Tag', 'fw'),
|
||||
'type' => 'select',
|
||||
'choices' => $this->get_post_categories()
|
||||
)
|
||||
),
|
||||
'choices' => $this->get_posts_sets()
|
||||
),
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
return $population_options;
|
||||
}
|
||||
|
||||
public function get_post_categories()
|
||||
{
|
||||
$collector = array();
|
||||
$post_types = get_post_types(array('public' => true), 'objects');
|
||||
foreach ($post_types as $post_type => $post_type_obj) {
|
||||
$have_posts = $this->get_posts($post_type);
|
||||
if (!empty($have_posts)) {
|
||||
$collector[$post_type] = empty($post_type_obj->labels->name) ? $post_type_obj->label : $post_type_obj->labels->name;
|
||||
}
|
||||
}
|
||||
|
||||
return $collector;
|
||||
}
|
||||
|
||||
private function get_posts($post_type)
|
||||
{
|
||||
return get_posts(
|
||||
array(
|
||||
'post_type' => $post_type,
|
||||
'post_status' => 'publish',
|
||||
'meta_key' => '_thumbnail_id',
|
||||
'nopaging' => true
|
||||
));
|
||||
}
|
||||
|
||||
private function get_posts_sets()
|
||||
{
|
||||
$post_types = get_post_types(array('public' => true));
|
||||
$collector = array();
|
||||
|
||||
foreach ($post_types as $post_type) {
|
||||
$posts_collector = array();
|
||||
$posts = $this->get_posts($post_type);
|
||||
|
||||
if (!empty($posts)) {
|
||||
foreach ($posts as $post) {
|
||||
$posts_collector[$post->ID] = empty($post->post_title) ? __('(no title)', 'fw') : $post->post_title;
|
||||
}
|
||||
|
||||
$collector[$post_type] = array(
|
||||
'posts_id' => array(
|
||||
'type' => 'select-multiple',
|
||||
'attr' => array('class' => 'selectize fw-selectize'),
|
||||
'label' => __('Select Specific posts', 'fw'),
|
||||
'choices' => $posts_collector,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $collector;
|
||||
}
|
||||
|
||||
public function get_number_of_images($post_id)
|
||||
{
|
||||
return (int)fw_get_db_post_option($post_id, 'number_of_images');
|
||||
}
|
||||
|
||||
public function get_frontend_data($post_id)
|
||||
{
|
||||
$collector = array();
|
||||
$meta = fw_get_db_post_option($post_id);
|
||||
$post_status = get_post_status($post_id);
|
||||
|
||||
if ('publish' === $post_status and isset($meta['populated'])) {
|
||||
$slider_name = $meta['slider']['selected'];
|
||||
$population_method = $meta['slider'][$slider_name]['population-method'];
|
||||
$posts_id = $meta['post_types'][$meta['post_types']['selected']]['posts_id'];
|
||||
$post_type = $meta['post_types']['selected'];
|
||||
|
||||
$collector = array(
|
||||
'slides' => array(),
|
||||
'settings' => array(
|
||||
'title' => $meta['title'],
|
||||
'slider_type' => $slider_name,
|
||||
'population_method' => $population_method,
|
||||
'post_id' => $post_id,
|
||||
'extra' => isset($meta['custom-settings']) ? $meta['custom-settings'] : array(),
|
||||
)
|
||||
);
|
||||
|
||||
$posts = get_posts(array(
|
||||
'post__in' => $posts_id,
|
||||
'post_type' => $post_type,
|
||||
'numberposts' => -1
|
||||
));
|
||||
|
||||
foreach ($posts as $post) {
|
||||
setup_postdata($post);
|
||||
array_push($collector['slides'], array(
|
||||
'title' => get_the_title($post->ID),
|
||||
'multimedia_type' => $this->multimedia_types[0],
|
||||
'src' => wp_get_attachment_url(get_post_thumbnail_id($post->ID)),
|
||||
/**
|
||||
* Fixes https://github.com/ThemeFuse/Unyson/issues/1460
|
||||
* Prevent infinite recursion:
|
||||
* -> fw_get_db_post_option($post_id)
|
||||
* -> page-builder all shortcode options loaded for fw-storage param to be processed
|
||||
* -> slider shortcode options are loaded
|
||||
* -> get_the_excerpt()
|
||||
* -> FW_Extension_Page_Builder->_filter_prevent_autop()
|
||||
* -> fw_get_db_post_option($post_id, 'page-builder/builder_active')
|
||||
* -> page-builder all shortcode options loaded for fw-storage ... (recursion)
|
||||
*/
|
||||
//'desc' => get_the_excerpt(),
|
||||
'extra' => array(
|
||||
'post_id' => $post->ID
|
||||
)
|
||||
));
|
||||
}
|
||||
wp_reset_postdata();
|
||||
}
|
||||
|
||||
return $collector;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
|
||||
$manifest['name'] = __( 'Population Method - Posts', 'fw' );
|
||||
$manifest['description'] = __( 'Population Method - Posts', 'fw' );
|
||||
|
||||
$manifest['version'] = '1.0.0';
|
||||
|
||||
$manifest['display'] = 'slider';
|
||||
@@ -0,0 +1,204 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
|
||||
class FW_Extension_Population_Method_Tags extends FW_Extension implements Population_Method_Interface
|
||||
{
|
||||
private $multimedia_types = array('image');
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function _init()
|
||||
{
|
||||
}
|
||||
|
||||
public function get_multimedia_types()
|
||||
{
|
||||
return $this->multimedia_types;
|
||||
}
|
||||
|
||||
public function get_population_method()
|
||||
{
|
||||
return array('tags' => __('Automatically, fetch images from tags', 'fw'));
|
||||
}
|
||||
|
||||
public function get_population_options($multimedia_types, $custom_options)
|
||||
{
|
||||
$population_options = array();
|
||||
$post_categories = $this->get_post_categories();
|
||||
if (empty($post_categories)) {
|
||||
$message = sprintf(__('%s extension needs configured tags in post types', 'fw'), ucwords(str_replace('-', ' ', $this->get_name())));
|
||||
wp_die($message);
|
||||
} else {
|
||||
$population_options = array(
|
||||
'wrapper-population-method-tags' => array(
|
||||
'title' => __('Tags Population Method', 'fw'),
|
||||
'type' => 'box',
|
||||
'options' => array(
|
||||
'tags' => array(
|
||||
'type' => 'multi-picker',
|
||||
'show_borders'=>true,
|
||||
'label' => false,
|
||||
'desc' => false,
|
||||
'picker' => array(
|
||||
'selected' => array(
|
||||
'label' => __('Choose Tag', 'fw'),
|
||||
'type' => 'select',
|
||||
'choices' => $this->get_post_categories()
|
||||
)
|
||||
),
|
||||
'choices' => $this->get_post_tags_sets()
|
||||
),
|
||||
'number_of_images' => array(
|
||||
'type' => 'text',
|
||||
'label' => __('Number of Images in the slider', 'fw')
|
||||
)
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
return $population_options;
|
||||
}
|
||||
|
||||
public function get_post_categories()
|
||||
{
|
||||
$collector = array();
|
||||
$post_types = get_post_types(array('public' => true), 'objects');
|
||||
|
||||
foreach ($post_types as $key => $post_type) {
|
||||
|
||||
$have_terms = $this->get_terms($key);
|
||||
|
||||
if (!empty($have_terms)) {
|
||||
$collector[$key] = empty($post_type->labels->name) ? $post_type->label : $post_type->labels->name;
|
||||
}
|
||||
}
|
||||
|
||||
return $collector;
|
||||
}
|
||||
|
||||
private function get_terms($post_type)
|
||||
{
|
||||
$taxonomies = get_taxonomies(array('object_type' => array($post_type), 'hierarchical' => false));
|
||||
if (count($taxonomies)) {
|
||||
return get_terms($taxonomies);
|
||||
} else {
|
||||
return $taxonomies;
|
||||
}
|
||||
}
|
||||
|
||||
private function get_post_tags_sets()
|
||||
{
|
||||
$post_types = get_post_types(array('public' => true));
|
||||
$terms_collector = array();
|
||||
|
||||
foreach ($post_types as $post_type) {
|
||||
|
||||
$terms = $this->get_terms($post_type);
|
||||
|
||||
if (!empty($terms) && !is_wp_error($terms)) {
|
||||
$terms_collector = array();
|
||||
foreach ($terms as $term) {
|
||||
$key = json_encode(array('term_id' => $term->term_id, 'taxonomy' => $term->taxonomy));
|
||||
$terms_collector[$key] = $term->name;
|
||||
}
|
||||
}
|
||||
|
||||
$collector[$post_type] = array(
|
||||
'terms' => array(
|
||||
'type' => 'select-multiple',
|
||||
'attr' => array('class' => 'selectize fw-selectize'),
|
||||
'label' => __('Select Specific tags', 'fw'),
|
||||
'choices' => $terms_collector,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $collector;
|
||||
}
|
||||
|
||||
public function get_number_of_images($post_id)
|
||||
{
|
||||
return (int)fw_get_db_post_option($post_id, 'number_of_images');
|
||||
}
|
||||
|
||||
public function get_frontend_data($post_id)
|
||||
{
|
||||
$collector = array();
|
||||
$meta = fw_get_db_post_option($post_id);
|
||||
$post_status = get_post_status($post_id);
|
||||
|
||||
if ('publish' === $post_status and isset($meta['populated'])) {
|
||||
$slider_name = $meta['slider']['selected'];
|
||||
$population_method = $meta['slider'][$slider_name]['population-method'];
|
||||
$number_of_images = (int)$meta['number_of_images'];
|
||||
|
||||
$collector = array(
|
||||
'slides' => array(),
|
||||
'settings' => array(
|
||||
'title' => $meta['title'],
|
||||
'slider_type' => $slider_name,
|
||||
'population_method' => $population_method,
|
||||
'post_id' => $post_id,
|
||||
'extra' => isset($meta['custom-settings']) ? $meta['custom-settings'] : array(),
|
||||
)
|
||||
);
|
||||
|
||||
$query_data = array();
|
||||
$post_type = $meta['tags']['selected'];
|
||||
$terms = $meta['tags'][$post_type]['terms'];
|
||||
|
||||
$tax_query = array(
|
||||
'tax_query' => array(
|
||||
'relation' => 'OR'
|
||||
)
|
||||
);
|
||||
|
||||
foreach ($terms as $term) {
|
||||
$decoded_data = json_decode($term, true);
|
||||
$query_data[$decoded_data['taxonomy']][] = $decoded_data['term_id'];
|
||||
}
|
||||
|
||||
foreach ($query_data as $taxonomy => $terms) {
|
||||
$tax_query['tax_query'][] = array(
|
||||
'taxonomy' => $taxonomy,
|
||||
'field' => 'id',
|
||||
'terms' => $terms
|
||||
);
|
||||
}
|
||||
|
||||
$final_query = array_merge(array(
|
||||
'post_status' => 'publish',
|
||||
'posts_per_page' => $number_of_images,
|
||||
'post_type' => $post_type,
|
||||
'meta_key' => '_thumbnail_id',
|
||||
), $tax_query
|
||||
);
|
||||
|
||||
global $post;
|
||||
$original_post = $post;
|
||||
|
||||
$the_query = new WP_Query($final_query);
|
||||
|
||||
while ($the_query->have_posts()) {
|
||||
$the_query->the_post();
|
||||
|
||||
array_push($collector['slides'], array(
|
||||
'title' => get_the_title(),
|
||||
'multimedia_type' => $this->multimedia_types[0],
|
||||
'src' => wp_get_attachment_url(get_post_thumbnail_id(get_the_ID())),
|
||||
'desc' => get_the_excerpt(),
|
||||
'extra' => array(
|
||||
'post_id' => $post->ID
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
wp_reset_postdata();
|
||||
|
||||
$post = $original_post;
|
||||
unset($original_post);
|
||||
}
|
||||
|
||||
return $collector;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
|
||||
$manifest['name'] = __( 'Population Method - Tags', 'fw' );
|
||||
$manifest['description'] = __( 'Population Method - Tags', 'fw' );
|
||||
|
||||
$manifest['version'] = '1.0.0';
|
||||
|
||||
$manifest['display'] = 'slider';
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
|
||||
interface Population_Method_Interface
|
||||
{
|
||||
public function get_multimedia_types();
|
||||
public function get_population_method();
|
||||
public function get_number_of_images($post_id);
|
||||
public function get_population_options($multimedia_types, $custom_options);
|
||||
public function get_frontend_data($post_id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
|
||||
$manifest['name'] = __( 'Population Methods', 'fw' );
|
||||
$manifest['description'] = '';
|
||||
$manifest['version'] = '1.0.19';
|
||||
|
||||
$manifest['github_update'] = 'ThemeFuse/Unyson-PopulationMethods-Extension';
|
||||
@@ -0,0 +1,615 @@
|
||||
<?php if ( ! defined( 'FW' ) ) {
|
||||
die( 'Forbidden' );
|
||||
}
|
||||
require dirname( __FILE__ ) . '/includes/default/class-fw-extension-slider-default.php';
|
||||
|
||||
class FW_Extension_Slider extends FW_Extension {
|
||||
private $post_type = 'fw-slider';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function _init() {
|
||||
$this->add_admin_filters();
|
||||
$this->add_admin_actions();
|
||||
}
|
||||
|
||||
/**
|
||||
* new function that update merged values
|
||||
* @since 2.3.3 version of Unyson.
|
||||
*/
|
||||
public function _action_slider_post_update_merged_old_db_option_values( $post_id, $basekey, $subkey, $old_values ) {
|
||||
|
||||
if (
|
||||
get_post_type( $post_id ) !== $this->post_type
|
||||
||
|
||||
!fw_is_post_edit()
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
remove_action( 'fw_post_options_update', array(
|
||||
$this,
|
||||
'_action_slider_post_update_merged_old_db_option_values'
|
||||
), 11 );
|
||||
|
||||
fw_set_db_post_option(
|
||||
$post_id,
|
||||
null,
|
||||
array_merge( (array) $old_values, fw_get_db_post_option( $post_id ) )
|
||||
);
|
||||
|
||||
add_action( 'fw_post_options_update', array(
|
||||
$this,
|
||||
'_action_slider_post_update_merged_old_db_option_values'
|
||||
), 11, 4 );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Do manually array_merge($old_values, $new_values) on slider post save
|
||||
* because that feature was removed in https://github.com/ThemeFuse/Unyson/commit/e75ff06a2262e49576fac647e8d3651ab842b7b1
|
||||
* int $post_id
|
||||
* WP_Post $post
|
||||
* array $old_values
|
||||
*/
|
||||
public function _action_slider_post_merge_old_db_option_values( $post_id, $post, $old_values ) {
|
||||
|
||||
if ( $post->post_type !== $this->post_type ) {
|
||||
return;
|
||||
}
|
||||
|
||||
fw_set_db_post_option(
|
||||
$post_id,
|
||||
null,
|
||||
array_merge( $old_values, fw_get_db_post_option( $post_id ) )
|
||||
);
|
||||
}
|
||||
|
||||
private function add_admin_filters() {
|
||||
add_filter( 'fw_post_options', array( $this, '_admin_filter_load_options' ), 10, 2 );
|
||||
add_filter( 'wp_insert_post_data', array( $this, '_admin_filter_pre_save_slider_title' ), 99, 2 );
|
||||
add_filter( 'post_updated_messages', array( $this, '_admin_filter_change_updated_messages' ) );
|
||||
add_filter( 'manage_' . $this->get_post_type() . '_posts_columns', array( $this, '_admin_filter_add_columns' ),
|
||||
10, 1 );
|
||||
add_filter( 'post_row_actions', array( $this, '_admin_filter_post_row_actions' ), 10, 2 );
|
||||
add_filter( 'bulk_actions-edit-' . $this->get_post_type(),
|
||||
array( $this, '_admin_filter_customize_bulk_actions' ) );
|
||||
add_filter( 'parent_file', array( $this, '_set_active_submenu' ) );
|
||||
add_filter(
|
||||
'fw_get_db_post_option:fw-storage-enabled',
|
||||
array($this, '_filter_disable_post_options_fw_storage'),
|
||||
10, 2
|
||||
);
|
||||
}
|
||||
|
||||
public function get_post_type() {
|
||||
return $this->post_type;
|
||||
}
|
||||
|
||||
private function add_admin_actions() {
|
||||
add_action( 'admin_enqueue_scripts', array( $this, '_admin_action_enqueue_static' ) );
|
||||
add_action( 'admin_menu', array( $this, '_admin_action_replace_submit_meta_box' ) );
|
||||
add_action( 'manage_' . $this->get_post_type() . '_posts_custom_column',
|
||||
array( $this, '_admin_action_manage_custom_column' ), 10, 2 );
|
||||
|
||||
if ( version_compare( fw()->manifest->get_version(), '2.3.3', '>=' ) ) {
|
||||
// this action was added in Unyson 2.2.8
|
||||
add_action( 'fw_post_options_update', array(
|
||||
$this,
|
||||
'_action_slider_post_update_merged_old_db_option_values'
|
||||
), 11, 4 );
|
||||
} else {
|
||||
// @deprecated
|
||||
add_action( 'fw_save_post_options', array(
|
||||
$this,
|
||||
'_action_slider_post_merge_old_db_option_values'
|
||||
), 10, 3 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function _set_active_submenu( $parent_file ) {
|
||||
global $submenu_file, $current_screen;
|
||||
|
||||
// Set correct active/current submenu in the WordPress Admin menu
|
||||
if ( $current_screen->post_type == $this->post_type ) {
|
||||
$submenu_file = 'edit.php?post_type=' . $this->post_type;
|
||||
}
|
||||
|
||||
return $parent_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function _get_link() {
|
||||
return self_admin_url( 'edit.php?post_type=' . $this->post_type );
|
||||
}
|
||||
|
||||
/*Hide edit bulk action from table*/
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function _admin_action_manage_custom_column( $column, $post_id ) {
|
||||
switch ( $column ) {
|
||||
case 'slider_design' :
|
||||
$image = $this->get_slider_type( $post_id );
|
||||
$link = get_edit_post_link( $post_id );
|
||||
if ( ! empty( $image ) ) {
|
||||
echo '<a href="' . $link . '"><img height="100" src="' . $image['small']['src'] . '"/></a>';
|
||||
}
|
||||
break;
|
||||
case 'number_of_images' :
|
||||
echo fw()->extensions->get( 'population-method' )->get_number_of_images( $post_id );
|
||||
break;
|
||||
case 'population_method' :
|
||||
$population_method = fw()->extensions->get( 'population-method' )->get_population_method( $post_id );
|
||||
echo '<p><a>' . array_shift( $population_method ) . '</a></p>';
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*Hide actions from rows in table (Quick Edit and View)*/
|
||||
|
||||
private function get_slider_type( $post_id ) {
|
||||
$slider_name = fw_get_db_post_option( $post_id, $this->get_name() . '/selected' );
|
||||
$sliders_types = $this->get_sliders_types();
|
||||
|
||||
return isset( $sliders_types[ $slider_name ] ) ? $sliders_types[ $slider_name ] : array();
|
||||
}
|
||||
|
||||
//TODO must return to normal method
|
||||
private function get_sliders_types() {
|
||||
$choices = array();
|
||||
foreach ( $this->get_active_sliders() as $instance_name ) {
|
||||
$choices[ $instance_name ] = $this->get_child( $instance_name )->get_slider_type();
|
||||
}
|
||||
|
||||
return $choices;
|
||||
}
|
||||
|
||||
private function get_active_sliders() {
|
||||
$active_sliders = array();
|
||||
foreach ( $this->get_children() as $slider_instance ) {
|
||||
$slider_population_methods = $slider_instance->get_population_methods();
|
||||
if ( ! empty( $slider_population_methods ) ) {
|
||||
$active_sliders[] = $slider_instance->get_name();
|
||||
}
|
||||
}
|
||||
|
||||
$active_sliders = apply_filters( 'fw_ext_slider_activated', $active_sliders );
|
||||
|
||||
return $active_sliders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function _admin_filter_customize_bulk_actions( $actions ) {
|
||||
unset( $actions['edit'] );
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function _admin_filter_post_row_actions( $actions, $post ) {
|
||||
if ( $post->post_type === $this->get_post_type() ) {
|
||||
unset( $actions['inline hide-if-no-js'], $actions['view'] );
|
||||
}
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function _admin_filter_add_columns( $columns ) {
|
||||
return array(
|
||||
'cb' => $columns['cb'],
|
||||
'slider_design' => __( 'Slider Design', 'fw' ),
|
||||
'title' => $columns['title'],
|
||||
'number_of_images' => __( 'Number of Images', 'fw' ),
|
||||
'population_method' => __( 'Population Method', 'fw' ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function _admin_filter_change_updated_messages( $messages ) {
|
||||
global $post;
|
||||
$post_type = get_post_type( $post->ID );
|
||||
|
||||
if ( $post_type === $this->get_post_type() ) {
|
||||
$obj = get_post_type_object( $post_type );
|
||||
$singular = $obj->labels->singular_name;
|
||||
|
||||
$messages[ $post_type ] = array(
|
||||
0 => '', // Unused. Messages start at index 1.
|
||||
1 => sprintf( __( '%s updated.', 'fw' ), $singular ),
|
||||
2 => __( 'Custom field updated.', 'fw' ),
|
||||
3 => __( 'Custom field deleted.', 'fw' ),
|
||||
4 => sprintf( __( '%s updated.', 'fw' ), $singular ),
|
||||
5 => isset( $_GET['revision'] ) ? sprintf( __( '%s restored to revision from %s', 'fw' ), $singular,
|
||||
wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
|
||||
6 => sprintf( __( '%s published.', 'fw' ), $singular ),
|
||||
7 => __( 'Page saved.', 'fw' ),
|
||||
8 => sprintf( __( '%s submitted.', 'fw' ), $singular ),
|
||||
9 => sprintf( __( '%s scheduled for: %s.', 'fw' ), $singular,
|
||||
'<strong>' . date_i18n( 'M j, Y @ G:i' ) . '</strong>' ),
|
||||
10 => sprintf( __( '%s draft updated.', 'fw' ), $singular ),
|
||||
);
|
||||
}
|
||||
|
||||
return $messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function _admin_filter_pre_save_slider_title( $data, $postarr ) {
|
||||
if ( $data['post_type'] === $this->get_post_type() ) {
|
||||
if ( isset( $postarr['fw_options']['slider']['selected'] ) ) {
|
||||
$active_slider = $postarr['fw_options']['slider']['selected'];
|
||||
$data['post_title'] = $postarr['fw_options']['slider'][ $active_slider ]['title'];
|
||||
}
|
||||
|
||||
if ( isset( $postarr['fw_options']['title'] ) ) {
|
||||
$data['post_title'] = $postarr['fw_options']['title'];
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function _admin_action_replace_submit_meta_box() {
|
||||
remove_meta_box( 'submitdiv', $this->get_post_type(), 'core' );
|
||||
add_meta_box( 'submitdiv', __( 'Publish', 'fw' ), array( $this, 'render_submit_meta_box' ),
|
||||
$this->get_post_type(), 'side' );
|
||||
}
|
||||
|
||||
public function render_submit_meta_box( $post, $args = array() ) {
|
||||
// a modified version of post_submit_meta_box() (wp-admin/includes/meta-boxes.php, line 12)
|
||||
$post_type = $post->post_type;
|
||||
$post_type_object = get_post_type_object( $post_type );
|
||||
$can_publish = current_user_can( $post_type_object->cap->publish_posts );
|
||||
$meta = (array) fw_get_db_post_option( $post->ID );
|
||||
|
||||
if ( isset( $_GET['action'] ) && $_GET['action'] === 'edit' ) {
|
||||
if (
|
||||
array_key_exists( $this->get_name(), $meta )
|
||||
&&
|
||||
! is_null( $this->get_child( $meta['slider']['selected'] ) )
|
||||
) {
|
||||
$slider_name = $meta['slider']['selected'];
|
||||
$population_method = $this->get_child( $slider_name )->get_population_method( $meta['slider'][ $slider_name ]['population-method'] );
|
||||
$slider_type = $this->get_slider_type( $post->ID );
|
||||
echo $this->render_view( 'backend/submit-box-edit',
|
||||
compact( 'post', 'population_method', 'meta', 'post_type', 'post_type_object', 'can_publish',
|
||||
'slider_type' ) );
|
||||
} else {
|
||||
echo $this->render_view( 'backend/submit-box-error', compact( 'post' ) );
|
||||
}
|
||||
} else {
|
||||
echo $this->render_view( 'backend/submit-box-raw',
|
||||
compact( 'post', 'meta', 'post_type', 'post_type_object', 'can_publish' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function _admin_filter_load_options( $options, $post_type ) {
|
||||
if ( $post_type === $this->get_post_type() ) {
|
||||
if ( fw_is_post_edit() ) {
|
||||
return $this->load_post_edit_options();
|
||||
} else {
|
||||
return $this->load_post_new_options();
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function error_metabox( $message ) {
|
||||
return array(
|
||||
'slider-sidebar-errobox' => array(
|
||||
'title' => 'Error Message',
|
||||
'type' => 'box',
|
||||
'context' => 'normal',
|
||||
'options' => array(
|
||||
'error' => array(
|
||||
'label' => false,
|
||||
'type' => 'html-full',
|
||||
'html' => '<p style="color:#dd3d36; text-align:center;">' . $message . '</p>'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function load_post_edit_options() {
|
||||
global $post;
|
||||
|
||||
$selected = fw_get_db_post_option( $post->ID, $this->get_name() . '/selected' );
|
||||
$title_value = fw_get_db_post_option( $post->ID, $this->get_name() . '/' . $selected . '/title' );
|
||||
$child_extension = $this->get_child( $selected );
|
||||
|
||||
if (
|
||||
is_null( $child_extension ) or
|
||||
! in_array( $selected, $this->get_active_sliders() )
|
||||
) {
|
||||
$message = __( 'This slider was created correctly, but the code implementation was delete from source code or blocked from filter.Delete this post or recovery slider implementation',
|
||||
'fw' );
|
||||
|
||||
return $this->error_metabox( $message );
|
||||
}
|
||||
|
||||
$multimedia_types = $child_extension->get_multimedia_types();
|
||||
|
||||
if ( empty( $multimedia_types ) ) {
|
||||
$message = __( 'This slider was created correctly, but the multimedia_types from config.php file was deleted, please set multimedia_types for this slider type.',
|
||||
'fw' );
|
||||
|
||||
return $this->error_metabox( $message );
|
||||
}
|
||||
|
||||
$options = array_merge(
|
||||
array(
|
||||
'slider-sidebar-metabox' => array(
|
||||
'context' => 'side',
|
||||
'title' => __( 'Slider Configuration', 'fw' ),
|
||||
'type' => 'box',
|
||||
'options' => array(
|
||||
'populated' => array(
|
||||
'type' => 'hidden',
|
||||
'value' => true
|
||||
),
|
||||
'slider_type' => array(
|
||||
'type' => 'hidden',
|
||||
'value' => $selected,
|
||||
'fw-storage' => array(
|
||||
'type' => 'post-meta',
|
||||
'post-meta' => 'fw_option:slider_type',
|
||||
),
|
||||
),
|
||||
'title' => array(
|
||||
'type' => 'text',
|
||||
'label' => __( 'Slider Title', 'fw' ),
|
||||
'value' => $title_value,
|
||||
'desc' => __( 'Choose a title for your slider only for internal use: Ex: "Homepage".',
|
||||
'fw' )
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
$this->get_slider_population_method_options()
|
||||
);
|
||||
|
||||
$custom_settings = $this->get_slider_options();
|
||||
|
||||
if ( ! empty( $custom_settings ) ) {
|
||||
$selected = fw_get_db_post_option( $post->ID, $this->get_name() . '/selected' );
|
||||
$custom_settings_value = fw_get_db_post_option( $post->ID, $this->get_name() . '/' . $selected . '/custom-settings' );
|
||||
|
||||
$options['slider-sidebar-metabox']['options']['custom-settings'] = array(
|
||||
'label' => false,
|
||||
'desc' => false,
|
||||
'type' => 'multi',
|
||||
'value' => $custom_settings_value,
|
||||
'inner-options' => $this->get_slider_options()
|
||||
);
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
private function get_slider_population_method_options() {
|
||||
global $post;
|
||||
|
||||
$slider_name = fw_get_db_post_option( $post->ID, $this->get_name() . '/selected' );
|
||||
$population_method = fw_get_db_post_option( $post->ID,
|
||||
$this->get_name() . '/' . $slider_name . '/population-method' );
|
||||
$slider_instance = $this->get_child( $slider_name );
|
||||
$multimedia_types = $slider_instance->get_multimedia_types();
|
||||
$options = $slider_instance->get_population_method_options( $population_method );
|
||||
|
||||
return apply_filters( 'fw_ext_' . str_replace( '-', '_', $slider_name ) . '_population_method_' . $population_method . '_options',
|
||||
fw()->extensions->get( 'population-method' )->get_population_options(
|
||||
$population_method,
|
||||
$multimedia_types,
|
||||
$options )
|
||||
);
|
||||
}
|
||||
|
||||
private function get_slider_options() {
|
||||
global $post;
|
||||
|
||||
$slider_type = fw_get_db_post_option( $post->ID, $this->get_name() . '/selected' );
|
||||
|
||||
return $this->get_child( $slider_type )->get_slider_options();
|
||||
}
|
||||
|
||||
public function load_post_new_options() {
|
||||
return array(
|
||||
'general' => array(
|
||||
'title' => __( 'Slider Settings', 'fw' ),
|
||||
'type' => 'box',
|
||||
'options' => array(
|
||||
$this->get_name() => array(
|
||||
'type' => 'multi-picker',
|
||||
'value' => '',
|
||||
'show_borders' => true,
|
||||
'label' => false,
|
||||
'desc' => false,
|
||||
'picker' => array(
|
||||
'selected' => array(
|
||||
'label' => __( 'Type', 'fw' ),
|
||||
'type' => 'image-picker',
|
||||
'choices' => $this->get_sliders_types()
|
||||
)
|
||||
),
|
||||
'choices' => $this->get_sliders_sets_options()
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function get_sliders_sets_options() {
|
||||
$options = array();
|
||||
$active_sliders = $this->get_active_sliders();
|
||||
|
||||
if ( empty( $active_sliders ) ) {
|
||||
$message = __( "You don't have slider extensions, please create at least one extension for properly work",
|
||||
'fw' );
|
||||
wp_die( $message );
|
||||
}
|
||||
|
||||
foreach ( $active_sliders as $instance_name ) {
|
||||
|
||||
$slider_options = $this->get_child( $instance_name )->get_slider_options();
|
||||
$population_methods = $this->get_child( $instance_name )->get_population_methods();
|
||||
|
||||
$options[ $instance_name ] = array(
|
||||
'population-method' => array(
|
||||
'type' => 'select',
|
||||
'label' => __( 'Population Method', 'fw' ),
|
||||
'desc' => __( 'Choose the population method for your slider', 'fw' ),
|
||||
'value' => '',
|
||||
'choices' => $population_methods,
|
||||
),
|
||||
'title' => array(
|
||||
'type' => 'text',
|
||||
'label' => __( 'Title', 'fw' ),
|
||||
'value' => '',
|
||||
'desc' => 'Choose the ' . $this->get_name() . ' title (for internal use)'
|
||||
)
|
||||
);
|
||||
|
||||
if ( ! empty( $slider_options ) ) {
|
||||
$options[ $instance_name ]['custom-settings'] = array(
|
||||
'label' => false,
|
||||
'desc' => false,
|
||||
'type' => 'multi',
|
||||
'inner-options' => $slider_options
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function render_slider( $post_id, $dimensions, $extra_data = array() ) {
|
||||
$slider_name = fw_get_db_post_option( $post_id, $this->get_name() . '/selected' );
|
||||
|
||||
if ( ! is_null( $this->get_child( $slider_name ) ) ) {
|
||||
return $this->get_child( $slider_name )->render_slider( $post_id, $dimensions, $extra_data );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function _admin_action_enqueue_static() {
|
||||
$match_current_screen = fw_current_screen_match(
|
||||
array(
|
||||
'only' => array(
|
||||
array(
|
||||
'post_type' => $this->post_type,
|
||||
)
|
||||
)
|
||||
) );
|
||||
|
||||
if ( $match_current_screen ) {
|
||||
wp_enqueue_style(
|
||||
'fw-extension-' . $this->get_name() . '-css',
|
||||
$this->get_declared_URI( '/static/css/style.css' ),
|
||||
array(),
|
||||
fw()->manifest->get_version()
|
||||
);
|
||||
wp_enqueue_style( 'fw-selectize' );
|
||||
wp_enqueue_script(
|
||||
'fw-population-method-categories',
|
||||
$this->get_declared_URI( '/static/js/population-method.js' ),
|
||||
array( 'fw-selectize' ),
|
||||
fw()->manifest->get_version()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function get_populated_sliders_choices() {
|
||||
$choices = array();
|
||||
|
||||
foreach ( $this->get_populated_sliders() as $slider ) {
|
||||
|
||||
$choices[ $slider->ID ] = empty( $slider->post_title ) ? __( '(no title)', 'fw' ) : $slider->post_title;
|
||||
}
|
||||
|
||||
return $choices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get populated sliders.
|
||||
*
|
||||
* If want to get the sliders from a slider type, set the next array
|
||||
* array('slider_types' => array('slider_type_name'))
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_populated_sliders( $params = array() ) {
|
||||
|
||||
$params = (array) $params;
|
||||
$meta_query = array();
|
||||
|
||||
if ( array_key_exists( 'slider_types', $params ) && ! empty( $params['slider_types'] ) ) {
|
||||
$collector = array();
|
||||
array_push( $collector, array(
|
||||
'key' => 'fw_option:slider_type',
|
||||
'value' => $params['slider_types']
|
||||
) );
|
||||
|
||||
$meta_query = array(
|
||||
'meta_query' => $collector,
|
||||
);
|
||||
}
|
||||
|
||||
$posts = get_posts(
|
||||
array_merge(
|
||||
array(
|
||||
'post_type' => $this->post_type,
|
||||
'numberposts' => - 1
|
||||
),
|
||||
$meta_query
|
||||
)
|
||||
);
|
||||
|
||||
foreach ( $posts as $key => $post ) {
|
||||
$data = fw()->extensions->get( 'population-method' )->get_frontend_data( $post->ID );
|
||||
if ( empty( $data['slides'] ) ) {
|
||||
unset( $posts[ $key ] );
|
||||
}
|
||||
}
|
||||
|
||||
return $posts;
|
||||
}
|
||||
|
||||
public function _filter_disable_post_options_fw_storage($enabled, $post_type) {
|
||||
if ($this->get_post_type() === $post_type) {
|
||||
$enabled = false;
|
||||
}
|
||||
|
||||
return $enabled;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
$cfg['multimedia_types'] = array('image','video');
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
|
||||
$manifest = array();
|
||||
|
||||
$manifest['name'] = __( 'Bx-Slider', 'fw' );
|
||||
$manifest['description'] = __( 'Bx-Slider', 'fw' );
|
||||
$manifest['version'] = '1.0.0';
|
||||
$manifest['display'] = 'slider';
|
||||
$manifest['standalone'] = true;
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
$options = array(
|
||||
'test1' => array(
|
||||
'label' => __('Population Method Categories opt 1', 'fw'),
|
||||
'desc' => __('Option description', 'fw'),
|
||||
'type' => 'text',
|
||||
'value' => '',
|
||||
),
|
||||
'test2' => array(
|
||||
'label' => __('Population Method Categories opt 2', 'fw'),
|
||||
'desc' => __('Option description', 'fw'),
|
||||
'type' => 'text',
|
||||
'value' => '',
|
||||
),
|
||||
);
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php if ( ! defined( 'FW' ) ) {
|
||||
die( 'Forbidden' );
|
||||
}
|
||||
$options = array(
|
||||
'subtitle' => array(
|
||||
'type' => 'text',
|
||||
'label' => __( 'Subtitle', 'fw' ),
|
||||
'value' => '',
|
||||
'desc' => __( 'Choose a subtitle for your slide.', 'fw' )
|
||||
)
|
||||
);
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
|
||||
$options = array(
|
||||
'test1z' => array(
|
||||
'label' => __('Type of Transition', 'fw'),
|
||||
'desc' => __('Type of transition between slides', 'fw'),
|
||||
'type' => 'select',
|
||||
'choices' => array(
|
||||
'horizontal' => __('Horizontal', 'fw'),
|
||||
'vertical' => __('Vertical', 'fw'),
|
||||
'fade' => __('Fade', 'fw')
|
||||
),
|
||||
'value' => 'horizontal',
|
||||
)
|
||||
);
|
||||
|
After Width: | Height: | Size: 8.4 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
@@ -0,0 +1,213 @@
|
||||
/**
|
||||
* BxSlider v4.1.2 - Fully loaded, responsive content slider
|
||||
* http://bxslider.com
|
||||
*
|
||||
* Written by: Steven Wanderski, 2014
|
||||
* http://stevenwanderski.com
|
||||
* (while drinking Belgian ales and listening to jazz)
|
||||
*
|
||||
* CEO and founder of bxCreative, LTD
|
||||
* http://bxcreative.com
|
||||
*/
|
||||
|
||||
|
||||
/** RESET AND LAYOUT
|
||||
===================================*/
|
||||
|
||||
.bx-wrapper {
|
||||
position: relative;
|
||||
margin: 0 auto 60px;
|
||||
padding: 0;
|
||||
*zoom: 1;
|
||||
}
|
||||
|
||||
.bx-wrapper img {
|
||||
max-width: 100%;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/** THEME
|
||||
===================================*/
|
||||
|
||||
.bx-wrapper .bx-viewport {
|
||||
-moz-box-shadow: 0 0 5px #ccc;
|
||||
-webkit-box-shadow: 0 0 5px #ccc;
|
||||
box-shadow: 0 0 5px #ccc;
|
||||
border: 5px solid #fff;
|
||||
background: #fff;
|
||||
|
||||
/*fix other elements on the page moving (on Chrome)*/
|
||||
-webkit-transform: translatez(0);
|
||||
-moz-transform: translatez(0);
|
||||
-ms-transform: translatez(0);
|
||||
-o-transform: translatez(0);
|
||||
transform: translatez(0);
|
||||
}
|
||||
|
||||
.bx-wrapper .bx-pager,
|
||||
.bx-wrapper .bx-controls-auto {
|
||||
position: absolute;
|
||||
bottom: -30px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* LOADER */
|
||||
|
||||
.bx-wrapper .bx-loading {
|
||||
min-height: 50px;
|
||||
background: url(images/bx_loader.gif) center center no-repeat #fff;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 2000;
|
||||
}
|
||||
|
||||
/* PAGER */
|
||||
|
||||
.bx-wrapper .bx-pager {
|
||||
text-align: center;
|
||||
font-size: .85em;
|
||||
font-family: Arial;
|
||||
font-weight: bold;
|
||||
color: #666;
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
.bx-wrapper .bx-pager .bx-pager-item,
|
||||
.bx-wrapper .bx-controls-auto .bx-controls-auto-item {
|
||||
display: inline-block;
|
||||
*zoom: 1;
|
||||
*display: inline;
|
||||
}
|
||||
|
||||
.bx-wrapper .bx-pager.bx-default-pager a {
|
||||
background: #666;
|
||||
text-indent: -9999px;
|
||||
display: block;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
margin: 0 5px;
|
||||
outline: 0;
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.bx-wrapper .bx-pager.bx-default-pager a:hover,
|
||||
.bx-wrapper .bx-pager.bx-default-pager a.active {
|
||||
background: #000;
|
||||
}
|
||||
|
||||
/* DIRECTION CONTROLS (NEXT / PREV) */
|
||||
|
||||
.bx-wrapper .bx-prev {
|
||||
left: 10px;
|
||||
background: url(images/controls.png) no-repeat 0 -32px;
|
||||
}
|
||||
|
||||
.bx-wrapper .bx-next {
|
||||
right: 10px;
|
||||
background: url(images/controls.png) no-repeat -43px -32px;
|
||||
}
|
||||
|
||||
.bx-wrapper .bx-prev:hover {
|
||||
background-position: 0 0;
|
||||
}
|
||||
|
||||
.bx-wrapper .bx-next:hover {
|
||||
background-position: -43px 0;
|
||||
}
|
||||
|
||||
.bx-wrapper .bx-controls-direction a {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
margin-top: -16px;
|
||||
outline: 0;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
text-indent: -9999px;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.bx-wrapper .bx-controls-direction a.disabled {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* AUTO CONTROLS (START / STOP) */
|
||||
|
||||
.bx-wrapper .bx-controls-auto {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.bx-wrapper .bx-controls-auto .bx-start {
|
||||
display: block;
|
||||
text-indent: -9999px;
|
||||
width: 10px;
|
||||
height: 11px;
|
||||
outline: 0;
|
||||
background: url(images/controls.png) -86px -11px no-repeat;
|
||||
margin: 0 3px;
|
||||
}
|
||||
|
||||
.bx-wrapper .bx-controls-auto .bx-start:hover,
|
||||
.bx-wrapper .bx-controls-auto .bx-start.active {
|
||||
background-position: -86px 0;
|
||||
}
|
||||
|
||||
.bx-wrapper .bx-controls-auto .bx-stop {
|
||||
display: block;
|
||||
text-indent: -9999px;
|
||||
width: 9px;
|
||||
height: 11px;
|
||||
outline: 0;
|
||||
background: url(images/controls.png) -86px -44px no-repeat;
|
||||
margin: 0 3px;
|
||||
}
|
||||
|
||||
.bx-wrapper .bx-controls-auto .bx-stop:hover,
|
||||
.bx-wrapper .bx-controls-auto .bx-stop.active {
|
||||
background-position: -86px -33px;
|
||||
}
|
||||
|
||||
/* PAGER WITH AUTO-CONTROLS HYBRID LAYOUT */
|
||||
|
||||
.bx-wrapper .bx-controls.bx-has-controls-auto.bx-has-pager .bx-pager {
|
||||
text-align: left;
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
.bx-wrapper .bx-controls.bx-has-controls-auto.bx-has-pager .bx-controls-auto {
|
||||
right: 0;
|
||||
width: 35px;
|
||||
}
|
||||
|
||||
/* IMAGE CAPTIONS */
|
||||
|
||||
.bx-wrapper .bx-caption {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
background: #666\9;
|
||||
background: rgba(80, 80, 80, 0.75);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.bx-wrapper .bx-caption span {
|
||||
color: #fff;
|
||||
font-family: Arial;
|
||||
display: block;
|
||||
font-size: .85em;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.bx-wrapper ul{
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.bx-wrapper iframe{
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
float: left;
|
||||
}
|
||||
|
After Width: | Height: | Size: 77 KiB |
|
After Width: | Height: | Size: 21 KiB |
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
|
||||
*
|
||||
* Uses the built in easing capabilities added In jQuery 1.1
|
||||
* to offer multiple easing options
|
||||
*
|
||||
* TERMS OF USE - jQuery Easing
|
||||
*
|
||||
* Open source under the BSD License.
|
||||
*
|
||||
* Copyright © 2008 George McGinley Smith
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* Neither the name of the author nor the names of contributors may be used to endorse
|
||||
* or promote products derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// t: current time, b: begInnIng value, c: change In value, d: duration
|
||||
jQuery.easing['jswing'] = jQuery.easing['swing'];
|
||||
|
||||
jQuery.extend( jQuery.easing,
|
||||
{
|
||||
def: 'easeOutQuad',
|
||||
swing: function (x, t, b, c, d) {
|
||||
//alert(jQuery.easing.default);
|
||||
return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
|
||||
},
|
||||
easeInQuad: function (x, t, b, c, d) {
|
||||
return c*(t/=d)*t + b;
|
||||
},
|
||||
easeOutQuad: function (x, t, b, c, d) {
|
||||
return -c *(t/=d)*(t-2) + b;
|
||||
},
|
||||
easeInOutQuad: function (x, t, b, c, d) {
|
||||
if ((t/=d/2) < 1) return c/2*t*t + b;
|
||||
return -c/2 * ((--t)*(t-2) - 1) + b;
|
||||
},
|
||||
easeInCubic: function (x, t, b, c, d) {
|
||||
return c*(t/=d)*t*t + b;
|
||||
},
|
||||
easeOutCubic: function (x, t, b, c, d) {
|
||||
return c*((t=t/d-1)*t*t + 1) + b;
|
||||
},
|
||||
easeInOutCubic: function (x, t, b, c, d) {
|
||||
if ((t/=d/2) < 1) return c/2*t*t*t + b;
|
||||
return c/2*((t-=2)*t*t + 2) + b;
|
||||
},
|
||||
easeInQuart: function (x, t, b, c, d) {
|
||||
return c*(t/=d)*t*t*t + b;
|
||||
},
|
||||
easeOutQuart: function (x, t, b, c, d) {
|
||||
return -c * ((t=t/d-1)*t*t*t - 1) + b;
|
||||
},
|
||||
easeInOutQuart: function (x, t, b, c, d) {
|
||||
if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
|
||||
return -c/2 * ((t-=2)*t*t*t - 2) + b;
|
||||
},
|
||||
easeInQuint: function (x, t, b, c, d) {
|
||||
return c*(t/=d)*t*t*t*t + b;
|
||||
},
|
||||
easeOutQuint: function (x, t, b, c, d) {
|
||||
return c*((t=t/d-1)*t*t*t*t + 1) + b;
|
||||
},
|
||||
easeInOutQuint: function (x, t, b, c, d) {
|
||||
if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
|
||||
return c/2*((t-=2)*t*t*t*t + 2) + b;
|
||||
},
|
||||
easeInSine: function (x, t, b, c, d) {
|
||||
return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
|
||||
},
|
||||
easeOutSine: function (x, t, b, c, d) {
|
||||
return c * Math.sin(t/d * (Math.PI/2)) + b;
|
||||
},
|
||||
easeInOutSine: function (x, t, b, c, d) {
|
||||
return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
|
||||
},
|
||||
easeInExpo: function (x, t, b, c, d) {
|
||||
return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
|
||||
},
|
||||
easeOutExpo: function (x, t, b, c, d) {
|
||||
return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
|
||||
},
|
||||
easeInOutExpo: function (x, t, b, c, d) {
|
||||
if (t==0) return b;
|
||||
if (t==d) return b+c;
|
||||
if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
|
||||
return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
|
||||
},
|
||||
easeInCirc: function (x, t, b, c, d) {
|
||||
return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
|
||||
},
|
||||
easeOutCirc: function (x, t, b, c, d) {
|
||||
return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
|
||||
},
|
||||
easeInOutCirc: function (x, t, b, c, d) {
|
||||
if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
|
||||
return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
|
||||
},
|
||||
easeInElastic: function (x, t, b, c, d) {
|
||||
var s=1.70158;var p=0;var a=c;
|
||||
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
|
||||
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
||||
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
||||
return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
||||
},
|
||||
easeOutElastic: function (x, t, b, c, d) {
|
||||
var s=1.70158;var p=0;var a=c;
|
||||
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
|
||||
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
||||
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
||||
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
|
||||
},
|
||||
easeInOutElastic: function (x, t, b, c, d) {
|
||||
var s=1.70158;var p=0;var a=c;
|
||||
if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
|
||||
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
||||
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
||||
if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
||||
return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
|
||||
},
|
||||
easeInBack: function (x, t, b, c, d, s) {
|
||||
if (s == undefined) s = 1.70158;
|
||||
return c*(t/=d)*t*((s+1)*t - s) + b;
|
||||
},
|
||||
easeOutBack: function (x, t, b, c, d, s) {
|
||||
if (s == undefined) s = 1.70158;
|
||||
return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
|
||||
},
|
||||
easeInOutBack: function (x, t, b, c, d, s) {
|
||||
if (s == undefined) s = 1.70158;
|
||||
if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
|
||||
return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
|
||||
},
|
||||
easeInBounce: function (x, t, b, c, d) {
|
||||
return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
|
||||
},
|
||||
easeOutBounce: function (x, t, b, c, d) {
|
||||
if ((t/=d) < (1/2.75)) {
|
||||
return c*(7.5625*t*t) + b;
|
||||
} else if (t < (2/2.75)) {
|
||||
return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
|
||||
} else if (t < (2.5/2.75)) {
|
||||
return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
|
||||
} else {
|
||||
return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
|
||||
}
|
||||
},
|
||||
easeInOutBounce: function (x, t, b, c, d) {
|
||||
if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
|
||||
return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
*
|
||||
* TERMS OF USE - EASING EQUATIONS
|
||||
*
|
||||
* Open source under the BSD License.
|
||||
*
|
||||
* Copyright © 2001 Robert Penner
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* Neither the name of the author nor the names of contributors may be used to endorse
|
||||
* or promote products derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,80 @@
|
||||
/*global jQuery */
|
||||
/*jshint multistr:true browser:true */
|
||||
/*!
|
||||
* FitVids 1.0
|
||||
*
|
||||
* Copyright 2011, Chris Coyier - http://css-tricks.com + Dave Rupert - http://daverupert.com
|
||||
* Credit to Thierry Koblentz - http://www.alistapart.com/articles/creating-intrinsic-ratios-for-video/
|
||||
* Released under the WTFPL license - http://sam.zoy.org/wtfpl/
|
||||
*
|
||||
* Date: Thu Sept 01 18:00:00 2011 -0500
|
||||
*/
|
||||
|
||||
(function( $ ){
|
||||
|
||||
"use strict";
|
||||
|
||||
$.fn.fitVids = function( options ) {
|
||||
var settings = {
|
||||
customSelector: null
|
||||
};
|
||||
|
||||
var div = document.createElement('div'),
|
||||
ref = document.getElementsByTagName('base')[0] || document.getElementsByTagName('script')[0];
|
||||
|
||||
div.className = 'fit-vids-style';
|
||||
div.innerHTML = '­<style> \
|
||||
.fluid-width-video-wrapper { \
|
||||
width: 100%; \
|
||||
position: relative; \
|
||||
padding: 0; \
|
||||
} \
|
||||
\
|
||||
.fluid-width-video-wrapper iframe, \
|
||||
.fluid-width-video-wrapper object, \
|
||||
.fluid-width-video-wrapper embed { \
|
||||
position: absolute; \
|
||||
top: 0; \
|
||||
left: 0; \
|
||||
width: 100%; \
|
||||
height: 100%; \
|
||||
} \
|
||||
</style>';
|
||||
|
||||
ref.parentNode.insertBefore(div,ref);
|
||||
|
||||
if ( options ) {
|
||||
$.extend( settings, options );
|
||||
}
|
||||
|
||||
return this.each(function(){
|
||||
var selectors = [
|
||||
"iframe[src*='player.vimeo.com']",
|
||||
"iframe[src*='www.youtube.com']",
|
||||
"iframe[src*='www.kickstarter.com']",
|
||||
"object",
|
||||
"embed"
|
||||
];
|
||||
|
||||
if (settings.customSelector) {
|
||||
selectors.push(settings.customSelector);
|
||||
}
|
||||
|
||||
var $allVideos = $(this).find(selectors.join(','));
|
||||
|
||||
$allVideos.each(function(){
|
||||
var $this = $(this);
|
||||
if (this.tagName.toLowerCase() === 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { return; }
|
||||
var height = ( this.tagName.toLowerCase() === 'object' || ($this.attr('height') && !isNaN(parseInt($this.attr('height'), 10))) ) ? parseInt($this.attr('height'), 10) : $this.height(),
|
||||
width = !isNaN(parseInt($this.attr('width'), 10)) ? parseInt($this.attr('width'), 10) : $this.width(),
|
||||
aspectRatio = height / width;
|
||||
if(!$this.attr('id')){
|
||||
var videoID = 'fitvid' + Math.floor(Math.random()*999999);
|
||||
$this.attr('id', videoID);
|
||||
}
|
||||
$this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+"%");
|
||||
$this.removeAttr('height').removeAttr('width');
|
||||
});
|
||||
});
|
||||
};
|
||||
})( jQuery );
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php if (!defined('FW')) die('Forbidden'); ?>
|
||||
<?php if (isset($data['slides'])): ?>
|
||||
<script type="text/javascript">
|
||||
jQuery('document').ready(function () {
|
||||
jQuery('.bxslider').bxSlider();
|
||||
});
|
||||
</script>
|
||||
<ul class="bxslider">
|
||||
<?php foreach ($data['slides'] as $slide): ?>
|
||||
<li>
|
||||
<?php if ($slide['multimedia_type'] === 'video') : ?>
|
||||
<?php echo fw_oembed_get($slide['src'], $dimensions); ?>
|
||||
<?php else: ?>
|
||||
<img src="<?php echo esc_attr(fw_resize($slide['src'], $dimensions['width'], $dimensions['height'], true)); ?>"
|
||||
alt="<?php echo esc_attr($slide['title']) ?>" width="<?php echo esc_attr($dimensions['width']); ?>"
|
||||
height="<?php echo esc_attr($dimensions['height']); ?>"/>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
$cfg['population_methods'] = array('custom');
|
||||
$cfg['multimedia_types'] = array('image');
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
|
||||
$manifest = array();
|
||||
|
||||
$manifest['name'] = __( 'Nivo Slider', 'fw' );
|
||||
$manifest['description'] = __( 'Nivo Slider', 'fw' );
|
||||
$manifest['version'] = '1.0.0';
|
||||
$manifest['display'] = 'slider';
|
||||
$manifest['standalone'] = true;
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php if ( ! defined( 'FW' ) ) {
|
||||
die( 'Forbidden' );
|
||||
}
|
||||
|
||||
wp_enqueue_script('jquery');
|
||||
|
After Width: | Height: | Size: 824 B |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* jQuery Nivo Slider v3.2
|
||||
* http://nivo.dev7studios.com
|
||||
*
|
||||
* Copyright 2012, Dev7studios
|
||||
* Free to use and abuse under the MIT license.
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
/* The Nivo Slider styles */
|
||||
.nivoSlider {
|
||||
position:relative;
|
||||
width:100%;
|
||||
height:auto;
|
||||
overflow: hidden;
|
||||
}
|
||||
.nivoSlider img {
|
||||
position:absolute;
|
||||
top:0px;
|
||||
left:0px;
|
||||
max-width: none;
|
||||
}
|
||||
.nivo-main-image {
|
||||
display: block !important;
|
||||
position: relative !important;
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
/* If an image is wrapped in a link */
|
||||
.nivoSlider a.nivo-imageLink {
|
||||
position:absolute;
|
||||
top:0px;
|
||||
left:0px;
|
||||
width:100%;
|
||||
height:100%;
|
||||
border:0;
|
||||
padding:0;
|
||||
margin:0;
|
||||
z-index:6;
|
||||
display:none;
|
||||
background:white;
|
||||
filter:alpha(opacity=0);
|
||||
opacity:0;
|
||||
}
|
||||
/* The slices and boxes in the Slider */
|
||||
.nivo-slice {
|
||||
display:block;
|
||||
position:absolute;
|
||||
z-index:5;
|
||||
height:100%;
|
||||
top:0;
|
||||
}
|
||||
.nivo-box {
|
||||
display:block;
|
||||
position:absolute;
|
||||
z-index:5;
|
||||
overflow:hidden;
|
||||
}
|
||||
.nivo-box img { display:block; }
|
||||
|
||||
/* Caption styles */
|
||||
.nivo-caption {
|
||||
position:absolute;
|
||||
left:0px;
|
||||
bottom:0px;
|
||||
background:#000;
|
||||
color:#fff;
|
||||
width:100%;
|
||||
z-index:8;
|
||||
padding: 5px 10px;
|
||||
opacity: 0.8;
|
||||
overflow: hidden;
|
||||
display: none;
|
||||
-moz-opacity: 0.8;
|
||||
filter:alpha(opacity=8);
|
||||
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
|
||||
-moz-box-sizing: border-box; /* Firefox, other Gecko */
|
||||
box-sizing: border-box; /* Opera/IE 8+ */
|
||||
}
|
||||
.nivo-caption p {
|
||||
padding:5px;
|
||||
margin:0;
|
||||
}
|
||||
.nivo-caption a {
|
||||
display:inline !important;
|
||||
}
|
||||
.nivo-html-caption {
|
||||
display:none;
|
||||
}
|
||||
/* Direction nav styles (e.g. Next & Prev) */
|
||||
.nivo-directionNav a {
|
||||
position:absolute;
|
||||
top:45%;
|
||||
z-index:9;
|
||||
cursor:pointer;
|
||||
}
|
||||
.nivo-prevNav {
|
||||
left:0px;
|
||||
}
|
||||
.nivo-nextNav {
|
||||
right:0px;
|
||||
}
|
||||
/* Control nav styles (e.g. 1,2,3...) */
|
||||
.nivo-controlNav {
|
||||
text-align:center;
|
||||
padding: 15px 0;
|
||||
}
|
||||
.nivo-controlNav a {
|
||||
cursor:pointer;
|
||||
}
|
||||
.nivo-controlNav a.active {
|
||||
font-weight:bold;
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
Skin Name: Nivo Slider Default Theme
|
||||
Skin URI: http://nivo.dev7studios.com
|
||||
Description: The default skin for the Nivo Slider.
|
||||
Version: 1.3
|
||||
Author: Gilbert Pellegrom
|
||||
Author URI: http://dev7studios.com
|
||||
Supports Thumbs: true
|
||||
*/
|
||||
/* Changed css style */
|
||||
|
||||
.wrap-nivoslider.theme-default{
|
||||
position: relative;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.wrap-nivoslider .nivo-caption{
|
||||
font-style: italic;
|
||||
font-size: 16px;
|
||||
color: #fff;
|
||||
padding: 21px 130px 21px 35px;
|
||||
}
|
||||
|
||||
.wrap-nivoslider .nivoSlider .nivo-caption a{
|
||||
text-decoration: none;
|
||||
color: #55d727;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.wrap-nivoslider.theme-default .nivoSlider{
|
||||
box-shadow: none;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.wrap-nivoslider.theme-default .nivo-controlNav {
|
||||
text-align: center;
|
||||
padding: 0;
|
||||
position: absolute;
|
||||
right: 28px;
|
||||
bottom: 13px;
|
||||
z-index: 10;
|
||||
}
|
||||
.wrap-nivoslider.theme-default .nivo-html-caption{
|
||||
position: relative;
|
||||
}
|
||||
|
||||
|
||||
.wrap-nivoslider.theme-default .nivo-controlNav a{
|
||||
background: none;
|
||||
background-color: #fff;
|
||||
border-radius: 50%;
|
||||
opacity: 0.3;
|
||||
width: 9px;
|
||||
height: 9px;
|
||||
}
|
||||
|
||||
.wrap-nivoslider.theme-default .nivo-controlNav a.active{
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.wrap-nivoslider.theme-default .nivo-directionNav a{
|
||||
background: url(images/arrows2.png) no-repeat;
|
||||
width: 19px;
|
||||
height: 38px;
|
||||
margin-top: -15px;
|
||||
}
|
||||
|
||||
.wrap-nivoslider.theme-default a.nivo-nextNav{
|
||||
background-position: -21px 0;
|
||||
}
|
||||
/* Original css style */
|
||||
|
||||
.theme-default .nivoSlider {
|
||||
position:relative;
|
||||
background:#fff url(images/loading.gif) no-repeat 50% 50%;
|
||||
margin-bottom:10px;
|
||||
-webkit-box-shadow: 0px 1px 5px 0px #4a4a4a;
|
||||
-moz-box-shadow: 0px 1px 5px 0px #4a4a4a;
|
||||
box-shadow: 0px 1px 5px 0px #4a4a4a;
|
||||
}
|
||||
.theme-default .nivoSlider img {
|
||||
position:absolute;
|
||||
top:0px;
|
||||
left:0px;
|
||||
display:none;
|
||||
}
|
||||
.theme-default .nivoSlider a {
|
||||
border:0;
|
||||
display:block;
|
||||
}
|
||||
|
||||
.theme-default .nivo-controlNav {
|
||||
text-align: center;
|
||||
padding: 20px 0;
|
||||
}
|
||||
.theme-default .nivo-controlNav a {
|
||||
display:inline-block;
|
||||
width:22px;
|
||||
height:22px;
|
||||
background:url(images/bullets.png) no-repeat;
|
||||
text-indent:-9999px;
|
||||
border:0;
|
||||
margin: 0 2px;
|
||||
}
|
||||
.theme-default .nivo-controlNav a.active {
|
||||
background-position:0 -22px;
|
||||
}
|
||||
|
||||
.theme-default .nivo-directionNav a {
|
||||
display:block;
|
||||
width:30px;
|
||||
height:30px;
|
||||
background:url(images/arrows.png) no-repeat;
|
||||
text-indent:-9999px;
|
||||
border:0;
|
||||
opacity: 0;
|
||||
-webkit-transition: all 200ms ease-in-out;
|
||||
-moz-transition: all 200ms ease-in-out;
|
||||
-o-transition: all 200ms ease-in-out;
|
||||
transition: all 200ms ease-in-out;
|
||||
}
|
||||
.theme-default:hover .nivo-directionNav a { opacity: 1; }
|
||||
.theme-default a.nivo-nextNav {
|
||||
background-position:-30px 0;
|
||||
right:15px;
|
||||
}
|
||||
.theme-default a.nivo-prevNav {
|
||||
left:15px;
|
||||
}
|
||||
|
||||
.theme-default .nivo-caption {
|
||||
font-family: Helvetica, Arial, sans-serif;
|
||||
}
|
||||
.theme-default .nivo-caption a {
|
||||
color:#fff;
|
||||
border-bottom:1px dotted #fff;
|
||||
}
|
||||
.theme-default .nivo-caption a:hover {
|
||||
color:#fff;
|
||||
}
|
||||
|
||||
.theme-default .nivo-controlNav.nivo-thumbs-enabled {
|
||||
width: 100%;
|
||||
}
|
||||
.theme-default .nivo-controlNav.nivo-thumbs-enabled a {
|
||||
width: auto;
|
||||
height: auto;
|
||||
background: none;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.theme-default .nivo-controlNav.nivo-thumbs-enabled img {
|
||||
display: block;
|
||||
width: 120px;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 120 KiB |
|
After Width: | Height: | Size: 36 KiB |
@@ -0,0 +1,662 @@
|
||||
/*
|
||||
* jQuery Nivo Slider v3.2
|
||||
* http://nivo.dev7studios.com
|
||||
*
|
||||
* Copyright 2012, Dev7studios
|
||||
* Free to use and abuse under the MIT license.
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
var NivoSlider = function(element, options){
|
||||
// Defaults are below
|
||||
var settings = $.extend({}, $.fn.nivoSlider.defaults, options);
|
||||
|
||||
// Useful variables. Play carefully.
|
||||
var vars = {
|
||||
currentSlide: 0,
|
||||
currentImage: '',
|
||||
totalSlides: 0,
|
||||
running: false,
|
||||
paused: false,
|
||||
stop: false,
|
||||
controlNavEl: false
|
||||
};
|
||||
|
||||
// Get this slider
|
||||
var slider = $(element);
|
||||
slider.data('nivo:vars', vars).addClass('nivoSlider');
|
||||
|
||||
// Find our slider children
|
||||
var kids = slider.children();
|
||||
kids.each(function() {
|
||||
var child = $(this);
|
||||
var link = '';
|
||||
if(!child.is('img')){
|
||||
if(child.is('a')){
|
||||
child.addClass('nivo-imageLink');
|
||||
link = child;
|
||||
}
|
||||
child = child.find('img:first');
|
||||
}
|
||||
// Get img width & height
|
||||
var childWidth = (childWidth === 0) ? child.attr('width') : child.width(),
|
||||
childHeight = (childHeight === 0) ? child.attr('height') : child.height();
|
||||
|
||||
if(link !== ''){
|
||||
link.css('display','none');
|
||||
}
|
||||
child.css('display','none');
|
||||
vars.totalSlides++;
|
||||
});
|
||||
|
||||
// If randomStart
|
||||
if(settings.randomStart){
|
||||
settings.startSlide = Math.floor(Math.random() * vars.totalSlides);
|
||||
}
|
||||
|
||||
// Set startSlide
|
||||
if(settings.startSlide > 0){
|
||||
if(settings.startSlide >= vars.totalSlides) { settings.startSlide = vars.totalSlides - 1; }
|
||||
vars.currentSlide = settings.startSlide;
|
||||
}
|
||||
|
||||
// Get initial image
|
||||
if($(kids[vars.currentSlide]).is('img')){
|
||||
vars.currentImage = $(kids[vars.currentSlide]);
|
||||
} else {
|
||||
vars.currentImage = $(kids[vars.currentSlide]).find('img:first');
|
||||
}
|
||||
|
||||
// Show initial link
|
||||
if($(kids[vars.currentSlide]).is('a')){
|
||||
$(kids[vars.currentSlide]).css('display','block');
|
||||
}
|
||||
|
||||
// Set first background
|
||||
var sliderImg = $('<img/>').addClass('nivo-main-image');
|
||||
sliderImg.attr('src', vars.currentImage.attr('src')).show();
|
||||
slider.append(sliderImg);
|
||||
|
||||
// Detect Window Resize
|
||||
$(window).resize(function() {
|
||||
slider.children('img').width(slider.width());
|
||||
sliderImg.attr('src', vars.currentImage.attr('src'));
|
||||
sliderImg.stop().height('auto');
|
||||
$('.nivo-slice').remove();
|
||||
$('.nivo-box').remove();
|
||||
});
|
||||
|
||||
//Create caption
|
||||
slider.append($('<div class="nivo-caption"></div>'));
|
||||
|
||||
// Process caption function
|
||||
var processCaption = function(settings){
|
||||
var nivoCaption = $('.nivo-caption', slider);
|
||||
if(vars.currentImage.attr('title') != '' && vars.currentImage.attr('title') != undefined){
|
||||
var title = vars.currentImage.attr('title');
|
||||
if(title.substr(0,1) == '#') title = $(title).html();
|
||||
|
||||
if(nivoCaption.css('display') == 'block'){
|
||||
setTimeout(function(){
|
||||
nivoCaption.html(title);
|
||||
}, settings.animSpeed);
|
||||
} else {
|
||||
nivoCaption.html(title);
|
||||
nivoCaption.stop().fadeIn(settings.animSpeed);
|
||||
}
|
||||
} else {
|
||||
nivoCaption.stop().fadeOut(settings.animSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
//Process initial caption
|
||||
processCaption(settings);
|
||||
|
||||
// In the words of Super Mario "let's a go!"
|
||||
var timer = 0;
|
||||
if(!settings.manualAdvance && kids.length > 1){
|
||||
timer = setInterval(function(){ nivoRun(slider, kids, settings, false); }, settings.pauseTime);
|
||||
}
|
||||
|
||||
// Add Direction nav
|
||||
if(settings.directionNav){
|
||||
slider.append('<div class="nivo-directionNav"><a class="nivo-prevNav">'+ settings.prevText +'</a><a class="nivo-nextNav">'+ settings.nextText +'</a></div>');
|
||||
|
||||
$(slider).on('click', 'a.nivo-prevNav', function(){
|
||||
if(vars.running) { return false; }
|
||||
clearInterval(timer);
|
||||
timer = '';
|
||||
vars.currentSlide -= 2;
|
||||
nivoRun(slider, kids, settings, 'prev');
|
||||
});
|
||||
|
||||
$(slider).on('click', 'a.nivo-nextNav', function(){
|
||||
if(vars.running) { return false; }
|
||||
clearInterval(timer);
|
||||
timer = '';
|
||||
nivoRun(slider, kids, settings, 'next');
|
||||
});
|
||||
}
|
||||
|
||||
// Add Control nav
|
||||
if(settings.controlNav){
|
||||
vars.controlNavEl = $('<div class="nivo-controlNav"></div>');
|
||||
slider.after(vars.controlNavEl);
|
||||
for(var i = 0; i < kids.length; i++){
|
||||
if(settings.controlNavThumbs){
|
||||
vars.controlNavEl.addClass('nivo-thumbs-enabled');
|
||||
var child = kids.eq(i);
|
||||
if(!child.is('img')){
|
||||
child = child.find('img:first');
|
||||
}
|
||||
if(child.attr('data-thumb')) vars.controlNavEl.append('<a class="nivo-control" rel="'+ i +'"><img src="'+ child.attr('data-thumb') +'" alt="" /></a>');
|
||||
} else {
|
||||
vars.controlNavEl.append('<a class="nivo-control" rel="'+ i +'">'+ (i + 1) +'</a>');
|
||||
}
|
||||
}
|
||||
|
||||
//Set initial active link
|
||||
$('a:eq('+ vars.currentSlide +')', vars.controlNavEl).addClass('active');
|
||||
|
||||
$('a', vars.controlNavEl).bind('click', function(){
|
||||
if(vars.running) return false;
|
||||
if($(this).hasClass('active')) return false;
|
||||
clearInterval(timer);
|
||||
timer = '';
|
||||
sliderImg.attr('src', vars.currentImage.attr('src'));
|
||||
vars.currentSlide = $(this).attr('rel') - 1;
|
||||
nivoRun(slider, kids, settings, 'control');
|
||||
});
|
||||
}
|
||||
|
||||
//For pauseOnHover setting
|
||||
if(settings.pauseOnHover){
|
||||
slider.hover(function(){
|
||||
vars.paused = true;
|
||||
clearInterval(timer);
|
||||
timer = '';
|
||||
}, function(){
|
||||
vars.paused = false;
|
||||
// Restart the timer
|
||||
if(timer === '' && !settings.manualAdvance){
|
||||
timer = setInterval(function(){ nivoRun(slider, kids, settings, false); }, settings.pauseTime);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Event when Animation finishes
|
||||
slider.bind('nivo:animFinished', function(){
|
||||
sliderImg.attr('src', vars.currentImage.attr('src'));
|
||||
vars.running = false;
|
||||
// Hide child links
|
||||
$(kids).each(function(){
|
||||
if($(this).is('a')){
|
||||
$(this).css('display','none');
|
||||
}
|
||||
});
|
||||
// Show current link
|
||||
if($(kids[vars.currentSlide]).is('a')){
|
||||
$(kids[vars.currentSlide]).css('display','block');
|
||||
}
|
||||
// Restart the timer
|
||||
if(timer === '' && !vars.paused && !settings.manualAdvance){
|
||||
timer = setInterval(function(){ nivoRun(slider, kids, settings, false); }, settings.pauseTime);
|
||||
}
|
||||
// Trigger the afterChange callback
|
||||
settings.afterChange.call(this);
|
||||
});
|
||||
|
||||
// Add slices for slice animations
|
||||
var createSlices = function(slider, settings, vars) {
|
||||
if($(vars.currentImage).parent().is('a')) $(vars.currentImage).parent().css('display','block');
|
||||
$('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').width(slider.width()).css('visibility', 'hidden').show();
|
||||
var sliceHeight = ($('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').parent().is('a')) ? $('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').parent().height() : $('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').height();
|
||||
|
||||
for(var i = 0; i < settings.slices; i++){
|
||||
var sliceWidth = Math.round(slider.width()/settings.slices);
|
||||
|
||||
if(i === settings.slices-1){
|
||||
slider.append(
|
||||
$('<div class="nivo-slice" name="'+i+'"><img src="'+ vars.currentImage.attr('src') +'" style="position:absolute; width:'+ slider.width() +'px; height:auto; display:block !important; top:0; left:-'+ ((sliceWidth + (i * sliceWidth)) - sliceWidth) +'px;" /></div>').css({
|
||||
left:(sliceWidth*i)+'px',
|
||||
width:(slider.width()-(sliceWidth*i))+'px',
|
||||
height:sliceHeight+'px',
|
||||
opacity:'0',
|
||||
overflow:'hidden'
|
||||
})
|
||||
);
|
||||
} else {
|
||||
slider.append(
|
||||
$('<div class="nivo-slice" name="'+i+'"><img src="'+ vars.currentImage.attr('src') +'" style="position:absolute; width:'+ slider.width() +'px; height:auto; display:block !important; top:0; left:-'+ ((sliceWidth + (i * sliceWidth)) - sliceWidth) +'px;" /></div>').css({
|
||||
left:(sliceWidth*i)+'px',
|
||||
width:sliceWidth+'px',
|
||||
height:sliceHeight+'px',
|
||||
opacity:'0',
|
||||
overflow:'hidden'
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$('.nivo-slice', slider).height(sliceHeight);
|
||||
sliderImg.stop().animate({
|
||||
height: $(vars.currentImage).height()
|
||||
}, settings.animSpeed);
|
||||
};
|
||||
|
||||
// Add boxes for box animations
|
||||
var createBoxes = function(slider, settings, vars){
|
||||
if($(vars.currentImage).parent().is('a')) $(vars.currentImage).parent().css('display','block');
|
||||
$('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').width(slider.width()).css('visibility', 'hidden').show();
|
||||
var boxWidth = Math.round(slider.width()/settings.boxCols),
|
||||
boxHeight = Math.round($('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').height() / settings.boxRows);
|
||||
|
||||
|
||||
for(var rows = 0; rows < settings.boxRows; rows++){
|
||||
for(var cols = 0; cols < settings.boxCols; cols++){
|
||||
if(cols === settings.boxCols-1){
|
||||
slider.append(
|
||||
$('<div class="nivo-box" name="'+ cols +'" rel="'+ rows +'"><img src="'+ vars.currentImage.attr('src') +'" style="position:absolute; width:'+ slider.width() +'px; height:auto; display:block; top:-'+ (boxHeight*rows) +'px; left:-'+ (boxWidth*cols) +'px;" /></div>').css({
|
||||
opacity:0,
|
||||
left:(boxWidth*cols)+'px',
|
||||
top:(boxHeight*rows)+'px',
|
||||
width:(slider.width()-(boxWidth*cols))+'px'
|
||||
|
||||
})
|
||||
);
|
||||
$('.nivo-box[name="'+ cols +'"]', slider).height($('.nivo-box[name="'+ cols +'"] img', slider).height()+'px');
|
||||
} else {
|
||||
slider.append(
|
||||
$('<div class="nivo-box" name="'+ cols +'" rel="'+ rows +'"><img src="'+ vars.currentImage.attr('src') +'" style="position:absolute; width:'+ slider.width() +'px; height:auto; display:block; top:-'+ (boxHeight*rows) +'px; left:-'+ (boxWidth*cols) +'px;" /></div>').css({
|
||||
opacity:0,
|
||||
left:(boxWidth*cols)+'px',
|
||||
top:(boxHeight*rows)+'px',
|
||||
width:boxWidth+'px'
|
||||
})
|
||||
);
|
||||
$('.nivo-box[name="'+ cols +'"]', slider).height($('.nivo-box[name="'+ cols +'"] img', slider).height()+'px');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sliderImg.stop().animate({
|
||||
height: $(vars.currentImage).height()
|
||||
}, settings.animSpeed);
|
||||
};
|
||||
|
||||
// Private run method
|
||||
var nivoRun = function(slider, kids, settings, nudge){
|
||||
// Get our vars
|
||||
var vars = slider.data('nivo:vars');
|
||||
|
||||
// Trigger the lastSlide callback
|
||||
if(vars && (vars.currentSlide === vars.totalSlides - 1)){
|
||||
settings.lastSlide.call(this);
|
||||
}
|
||||
|
||||
// Stop
|
||||
if((!vars || vars.stop) && !nudge) { return false; }
|
||||
|
||||
// Trigger the beforeChange callback
|
||||
settings.beforeChange.call(this);
|
||||
|
||||
// Set current background before change
|
||||
if(!nudge){
|
||||
sliderImg.attr('src', vars.currentImage.attr('src'));
|
||||
} else {
|
||||
if(nudge === 'prev'){
|
||||
sliderImg.attr('src', vars.currentImage.attr('src'));
|
||||
}
|
||||
if(nudge === 'next'){
|
||||
sliderImg.attr('src', vars.currentImage.attr('src'));
|
||||
}
|
||||
}
|
||||
|
||||
vars.currentSlide++;
|
||||
// Trigger the slideshowEnd callback
|
||||
if(vars.currentSlide === vars.totalSlides){
|
||||
vars.currentSlide = 0;
|
||||
settings.slideshowEnd.call(this);
|
||||
}
|
||||
if(vars.currentSlide < 0) { vars.currentSlide = (vars.totalSlides - 1); }
|
||||
// Set vars.currentImage
|
||||
if($(kids[vars.currentSlide]).is('img')){
|
||||
vars.currentImage = $(kids[vars.currentSlide]);
|
||||
} else {
|
||||
vars.currentImage = $(kids[vars.currentSlide]).find('img:first');
|
||||
}
|
||||
|
||||
// Set active links
|
||||
if(settings.controlNav){
|
||||
$('a', vars.controlNavEl).removeClass('active');
|
||||
$('a:eq('+ vars.currentSlide +')', vars.controlNavEl).addClass('active');
|
||||
}
|
||||
|
||||
// Process caption
|
||||
processCaption(settings);
|
||||
|
||||
// Remove any slices from last transition
|
||||
$('.nivo-slice', slider).remove();
|
||||
|
||||
// Remove any boxes from last transition
|
||||
$('.nivo-box', slider).remove();
|
||||
|
||||
var currentEffect = settings.effect,
|
||||
anims = '';
|
||||
|
||||
// Generate random effect
|
||||
if(settings.effect === 'random'){
|
||||
anims = new Array('sliceDownRight','sliceDownLeft','sliceUpRight','sliceUpLeft','sliceUpDown','sliceUpDownLeft','fold','fade',
|
||||
'boxRandom','boxRain','boxRainReverse','boxRainGrow','boxRainGrowReverse');
|
||||
currentEffect = anims[Math.floor(Math.random()*(anims.length + 1))];
|
||||
if(currentEffect === undefined) { currentEffect = 'fade'; }
|
||||
}
|
||||
|
||||
// Run random effect from specified set (eg: effect:'fold,fade')
|
||||
if(settings.effect.indexOf(',') !== -1){
|
||||
anims = settings.effect.split(',');
|
||||
currentEffect = anims[Math.floor(Math.random()*(anims.length))];
|
||||
if(currentEffect === undefined) { currentEffect = 'fade'; }
|
||||
}
|
||||
|
||||
// Custom transition as defined by "data-transition" attribute
|
||||
if(vars.currentImage.attr('data-transition')){
|
||||
currentEffect = vars.currentImage.attr('data-transition');
|
||||
}
|
||||
|
||||
// Run effects
|
||||
vars.running = true;
|
||||
var timeBuff = 0,
|
||||
i = 0,
|
||||
slices = '',
|
||||
firstSlice = '',
|
||||
totalBoxes = '',
|
||||
boxes = '';
|
||||
|
||||
if(currentEffect === 'sliceDown' || currentEffect === 'sliceDownRight' || currentEffect === 'sliceDownLeft'){
|
||||
createSlices(slider, settings, vars);
|
||||
timeBuff = 0;
|
||||
i = 0;
|
||||
slices = $('.nivo-slice', slider);
|
||||
if(currentEffect === 'sliceDownLeft') { slices = $('.nivo-slice', slider)._reverse(); }
|
||||
|
||||
slices.each(function(){
|
||||
var slice = $(this);
|
||||
slice.css({ 'top': '0px' });
|
||||
if(i === settings.slices-1){
|
||||
setTimeout(function(){
|
||||
slice.animate({opacity:'1.0' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); });
|
||||
}, (100 + timeBuff));
|
||||
} else {
|
||||
setTimeout(function(){
|
||||
slice.animate({opacity:'1.0' }, settings.animSpeed);
|
||||
}, (100 + timeBuff));
|
||||
}
|
||||
timeBuff += 50;
|
||||
i++;
|
||||
});
|
||||
} else if(currentEffect === 'sliceUp' || currentEffect === 'sliceUpRight' || currentEffect === 'sliceUpLeft'){
|
||||
createSlices(slider, settings, vars);
|
||||
timeBuff = 0;
|
||||
i = 0;
|
||||
slices = $('.nivo-slice', slider);
|
||||
if(currentEffect === 'sliceUpLeft') { slices = $('.nivo-slice', slider)._reverse(); }
|
||||
|
||||
slices.each(function(){
|
||||
var slice = $(this);
|
||||
slice.css({ 'bottom': '0px' });
|
||||
if(i === settings.slices-1){
|
||||
setTimeout(function(){
|
||||
slice.animate({opacity:'1.0' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); });
|
||||
}, (100 + timeBuff));
|
||||
} else {
|
||||
setTimeout(function(){
|
||||
slice.animate({opacity:'1.0' }, settings.animSpeed);
|
||||
}, (100 + timeBuff));
|
||||
}
|
||||
timeBuff += 50;
|
||||
i++;
|
||||
});
|
||||
} else if(currentEffect === 'sliceUpDown' || currentEffect === 'sliceUpDownRight' || currentEffect === 'sliceUpDownLeft'){
|
||||
createSlices(slider, settings, vars);
|
||||
timeBuff = 0;
|
||||
i = 0;
|
||||
var v = 0;
|
||||
slices = $('.nivo-slice', slider);
|
||||
if(currentEffect === 'sliceUpDownLeft') { slices = $('.nivo-slice', slider)._reverse(); }
|
||||
|
||||
slices.each(function(){
|
||||
var slice = $(this);
|
||||
if(i === 0){
|
||||
slice.css('top','0px');
|
||||
i++;
|
||||
} else {
|
||||
slice.css('bottom','0px');
|
||||
i = 0;
|
||||
}
|
||||
|
||||
if(v === settings.slices-1){
|
||||
setTimeout(function(){
|
||||
slice.animate({opacity:'1.0' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); });
|
||||
}, (100 + timeBuff));
|
||||
} else {
|
||||
setTimeout(function(){
|
||||
slice.animate({opacity:'1.0' }, settings.animSpeed);
|
||||
}, (100 + timeBuff));
|
||||
}
|
||||
timeBuff += 50;
|
||||
v++;
|
||||
});
|
||||
} else if(currentEffect === 'fold'){
|
||||
createSlices(slider, settings, vars);
|
||||
timeBuff = 0;
|
||||
i = 0;
|
||||
|
||||
$('.nivo-slice', slider).each(function(){
|
||||
var slice = $(this);
|
||||
var origWidth = slice.width();
|
||||
slice.css({ top:'0px', width:'0px' });
|
||||
if(i === settings.slices-1){
|
||||
setTimeout(function(){
|
||||
slice.animate({ width:origWidth, opacity:'1.0' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); });
|
||||
}, (100 + timeBuff));
|
||||
} else {
|
||||
setTimeout(function(){
|
||||
slice.animate({ width:origWidth, opacity:'1.0' }, settings.animSpeed);
|
||||
}, (100 + timeBuff));
|
||||
}
|
||||
timeBuff += 50;
|
||||
i++;
|
||||
});
|
||||
} else if(currentEffect === 'fade'){
|
||||
createSlices(slider, settings, vars);
|
||||
|
||||
firstSlice = $('.nivo-slice:first', slider);
|
||||
firstSlice.css({
|
||||
'width': slider.width() + 'px'
|
||||
});
|
||||
|
||||
firstSlice.animate({ opacity:'1.0' }, (settings.animSpeed*2), '', function(){ slider.trigger('nivo:animFinished'); });
|
||||
} else if(currentEffect === 'slideInRight'){
|
||||
createSlices(slider, settings, vars);
|
||||
|
||||
firstSlice = $('.nivo-slice:first', slider);
|
||||
firstSlice.css({
|
||||
'width': '0px',
|
||||
'opacity': '1'
|
||||
});
|
||||
|
||||
firstSlice.animate({ width: slider.width() + 'px' }, (settings.animSpeed*2), '', function(){ slider.trigger('nivo:animFinished'); });
|
||||
} else if(currentEffect === 'slideInLeft'){
|
||||
createSlices(slider, settings, vars);
|
||||
|
||||
firstSlice = $('.nivo-slice:first', slider);
|
||||
firstSlice.css({
|
||||
'width': '0px',
|
||||
'opacity': '1',
|
||||
'left': '',
|
||||
'right': '0px'
|
||||
});
|
||||
|
||||
firstSlice.animate({ width: slider.width() + 'px' }, (settings.animSpeed*2), '', function(){
|
||||
// Reset positioning
|
||||
firstSlice.css({
|
||||
'left': '0px',
|
||||
'right': ''
|
||||
});
|
||||
slider.trigger('nivo:animFinished');
|
||||
});
|
||||
} else if(currentEffect === 'boxRandom'){
|
||||
createBoxes(slider, settings, vars);
|
||||
|
||||
totalBoxes = settings.boxCols * settings.boxRows;
|
||||
i = 0;
|
||||
timeBuff = 0;
|
||||
|
||||
boxes = shuffle($('.nivo-box', slider));
|
||||
boxes.each(function(){
|
||||
var box = $(this);
|
||||
if(i === totalBoxes-1){
|
||||
setTimeout(function(){
|
||||
box.animate({ opacity:'1' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); });
|
||||
}, (100 + timeBuff));
|
||||
} else {
|
||||
setTimeout(function(){
|
||||
box.animate({ opacity:'1' }, settings.animSpeed);
|
||||
}, (100 + timeBuff));
|
||||
}
|
||||
timeBuff += 20;
|
||||
i++;
|
||||
});
|
||||
} else if(currentEffect === 'boxRain' || currentEffect === 'boxRainReverse' || currentEffect === 'boxRainGrow' || currentEffect === 'boxRainGrowReverse'){
|
||||
createBoxes(slider, settings, vars);
|
||||
|
||||
totalBoxes = settings.boxCols * settings.boxRows;
|
||||
i = 0;
|
||||
timeBuff = 0;
|
||||
|
||||
// Split boxes into 2D array
|
||||
var rowIndex = 0;
|
||||
var colIndex = 0;
|
||||
var box2Darr = [];
|
||||
box2Darr[rowIndex] = [];
|
||||
boxes = $('.nivo-box', slider);
|
||||
if(currentEffect === 'boxRainReverse' || currentEffect === 'boxRainGrowReverse'){
|
||||
boxes = $('.nivo-box', slider)._reverse();
|
||||
}
|
||||
boxes.each(function(){
|
||||
box2Darr[rowIndex][colIndex] = $(this);
|
||||
colIndex++;
|
||||
if(colIndex === settings.boxCols){
|
||||
rowIndex++;
|
||||
colIndex = 0;
|
||||
box2Darr[rowIndex] = [];
|
||||
}
|
||||
});
|
||||
|
||||
// Run animation
|
||||
for(var cols = 0; cols < (settings.boxCols * 2); cols++){
|
||||
var prevCol = cols;
|
||||
for(var rows = 0; rows < settings.boxRows; rows++){
|
||||
if(prevCol >= 0 && prevCol < settings.boxCols){
|
||||
/* Due to some weird JS bug with loop vars
|
||||
being used in setTimeout, this is wrapped
|
||||
with an anonymous function call */
|
||||
(function(row, col, time, i, totalBoxes) {
|
||||
var box = $(box2Darr[row][col]);
|
||||
var w = box.width();
|
||||
var h = box.height();
|
||||
if(currentEffect === 'boxRainGrow' || currentEffect === 'boxRainGrowReverse'){
|
||||
box.width(0).height(0);
|
||||
}
|
||||
if(i === totalBoxes-1){
|
||||
setTimeout(function(){
|
||||
box.animate({ opacity:'1', width:w, height:h }, settings.animSpeed/1.3, '', function(){ slider.trigger('nivo:animFinished'); });
|
||||
}, (100 + time));
|
||||
} else {
|
||||
setTimeout(function(){
|
||||
box.animate({ opacity:'1', width:w, height:h }, settings.animSpeed/1.3);
|
||||
}, (100 + time));
|
||||
}
|
||||
})(rows, prevCol, timeBuff, i, totalBoxes);
|
||||
i++;
|
||||
}
|
||||
prevCol--;
|
||||
}
|
||||
timeBuff += 100;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Shuffle an array
|
||||
var shuffle = function(arr){
|
||||
for(var j, x, i = arr.length; i; j = parseInt(Math.random() * i, 10), x = arr[--i], arr[i] = arr[j], arr[j] = x);
|
||||
return arr;
|
||||
};
|
||||
|
||||
// For debugging
|
||||
var trace = function(msg){
|
||||
if(this.console && typeof console.log !== 'undefined') { console.log(msg); }
|
||||
};
|
||||
|
||||
// Start / Stop
|
||||
this.stop = function(){
|
||||
if(!$(element).data('nivo:vars').stop){
|
||||
$(element).data('nivo:vars').stop = true;
|
||||
trace('Stop Slider');
|
||||
}
|
||||
};
|
||||
|
||||
this.start = function(){
|
||||
if($(element).data('nivo:vars').stop){
|
||||
$(element).data('nivo:vars').stop = false;
|
||||
trace('Start Slider');
|
||||
}
|
||||
};
|
||||
|
||||
// Trigger the afterLoad callback
|
||||
settings.afterLoad.call(this);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
$.fn.nivoSlider = function(options) {
|
||||
return this.each(function(key, value){
|
||||
var element = $(this);
|
||||
// Return early if this element already has a plugin instance
|
||||
if (element.data('nivoslider')) { return element.data('nivoslider'); }
|
||||
// Pass options to plugin constructor
|
||||
var nivoslider = new NivoSlider(this, options);
|
||||
// Store plugin object in this element's data
|
||||
element.data('nivoslider', nivoslider);
|
||||
});
|
||||
};
|
||||
|
||||
//Default settings
|
||||
$.fn.nivoSlider.defaults = {
|
||||
effect: 'random',
|
||||
slices: 15,
|
||||
boxCols: 8,
|
||||
boxRows: 4,
|
||||
animSpeed: 500,
|
||||
pauseTime: 3000,
|
||||
startSlide: 0,
|
||||
directionNav: true,
|
||||
controlNav: true,
|
||||
controlNavThumbs: false,
|
||||
pauseOnHover: true,
|
||||
manualAdvance: false,
|
||||
prevText: 'Prev',
|
||||
nextText: 'Next',
|
||||
randomStart: false,
|
||||
beforeChange: function(){},
|
||||
afterChange: function(){},
|
||||
slideshowEnd: function(){},
|
||||
lastSlide: function(){},
|
||||
afterLoad: function(){}
|
||||
};
|
||||
|
||||
$.fn._reverse = [].reverse;
|
||||
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php if (!defined('FW')) die('Forbidden'); ?>
|
||||
|
||||
<?php if (isset($data['slides'])): ?>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($) {
|
||||
$('.nivoSlider').nivoSlider({effect:'fade'});
|
||||
});
|
||||
</script>
|
||||
<!--Slider-->
|
||||
<section class="wrap-nivoslider theme-default">
|
||||
<div class="nivoSlider">
|
||||
<?php foreach ($data['slides'] as $id => $slide): ?>
|
||||
<img width="<?php echo esc_attr($dimensions['width']); ?>"
|
||||
height="<?php echo esc_attr($dimensions['height']); ?>"
|
||||
src="<?php echo esc_attr(fw_resize($slide['src'], $dimensions['width'], $dimensions['height'], true)); ?>"
|
||||
alt="<?php echo esc_attr($slide['title']); ?>"
|
||||
title="#nivo-<?php echo esc_attr($id); ?>" />
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php foreach ($data['slides'] as $id => $slide): ?>
|
||||
<div id="nivo-<?php echo esc_attr($id) ?>" class="nivo-html-caption">
|
||||
<?php if (empty($slide['desc'])): ?>
|
||||
<span><?php echo $slide['title'] ?></span>
|
||||
<?php else: ?>
|
||||
<span><strong><?php echo $slide['title'] ?></strong> - <?php echo $slide['desc'] ?><span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</section>
|
||||
<!--/Slider-->
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
$cfg['multimedia_types'] = array('video');
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
|
||||
$manifest = array();
|
||||
|
||||
$manifest['name'] = __( 'Owl Slider', 'fw' );
|
||||
$manifest['description'] = __( 'Owl Slider', 'fw' );
|
||||
$manifest['version'] = '1.0.0';
|
||||
$manifest['display'] = 'slider';
|
||||
$manifest['standalone'] = true;
|
||||
@@ -0,0 +1 @@
|
||||
.owl-carousel .animated{-webkit-animation-duration:1000ms;animation-duration:1000ms;-webkit-animation-fill-mode:both;animation-fill-mode:both}.owl-carousel .owl-animated-in{z-index:0}.owl-carousel .owl-animated-out{z-index:1}.owl-carousel .fadeOut{-webkit-animation-name:fadeOut;animation-name:fadeOut}@-webkit-keyframes fadeOut{0%{opacity:1}100%{opacity:0}}@keyframes fadeOut{0%{opacity:1}100%{opacity:0}}.owl-height{-webkit-transition:height 500ms ease-in-out;-moz-transition:height 500ms ease-in-out;-ms-transition:height 500ms ease-in-out;-o-transition:height 500ms ease-in-out;transition:height 500ms ease-in-out}.owl-carousel{display:none;width:100%;-webkit-tap-highlight-color:transparent;position:relative;z-index:1}.owl-carousel .owl-stage{position:relative;-ms-touch-action:pan-Y}.owl-carousel .owl-stage:after{content:".";display:block;clear:both;visibility:hidden;line-height:0;height:0}.owl-carousel .owl-stage-outer{position:relative;overflow:hidden;-webkit-transform:translate3d(0px,0,0)}.owl-carousel .owl-item{position:relative;min-height:1px;float:left;-webkit-backface-visibility:hidden;-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none}.owl-carousel .owl-item img{display:block;width:100%;-webkit-transform-style:preserve-3d}.owl-carousel .owl-dots.disabled,.owl-carousel .owl-nav.disabled{display:none}.owl-carousel .owl-dot,.owl-carousel .owl-nav .owl-next,.owl-carousel .owl-nav .owl-prev{cursor:pointer;cursor:hand;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.owl-carousel.owl-loaded{display:block}.owl-carousel.owl-loading{opacity:0;display:block}.owl-carousel.owl-hidden{opacity:0}.owl-carousel.owl-refresh .owl-item{display:none}.owl-carousel.owl-drag .owl-item{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.owl-carousel.owl-grab{cursor:move;cursor:-webkit-grab;cursor:-o-grab;cursor:-ms-grab;cursor:grab}.owl-carousel.owl-rtl{direction:rtl}.owl-carousel.owl-rtl .owl-item{float:right}.no-js .owl-carousel{display:block}.owl-carousel .owl-item .owl-lazy{opacity:0;-webkit-transition:opacity 400ms ease;-moz-transition:opacity 400ms ease;-ms-transition:opacity 400ms ease;-o-transition:opacity 400ms ease;transition:opacity 400ms ease}.owl-carousel .owl-item img{transform-style:preserve-3d}.owl-carousel .owl-video-wrapper{position:relative;height:100%;background:#000}.owl-carousel .owl-video-play-icon{position:absolute;height:80px;width:80px;left:50%;top:50%;margin-left:-40px;margin-top:-40px;background:url(owl.video.play.png) no-repeat;cursor:pointer;z-index:1;-webkit-backface-visibility:hidden;-webkit-transition:scale 100ms ease;-moz-transition:scale 100ms ease;-ms-transition:scale 100ms ease;-o-transition:scale 100ms ease;transition:scale 100ms ease}.owl-carousel .owl-video-play-icon:hover{-webkit-transition:scale(1.3,1.3);-moz-transition:scale(1.3,1.3);-ms-transition:scale(1.3,1.3);-o-transition:scale(1.3,1.3);transition:scale(1.3,1.3)}.owl-carousel .owl-video-playing .owl-video-play-icon,.owl-carousel .owl-video-playing .owl-video-tn{display:none}.owl-carousel .owl-video-tn{opacity:0;height:100%;background-position:center center;background-repeat:no-repeat;-webkit-background-size:contain;-moz-background-size:contain;-o-background-size:contain;background-size:contain;-webkit-transition:opacity 400ms ease;-moz-transition:opacity 400ms ease;-ms-transition:opacity 400ms ease;-o-transition:opacity 400ms ease;transition:opacity 400ms ease}.owl-carousel .owl-video-frame{position:relative;z-index:1;height:100%;width:100%}
|
||||
@@ -0,0 +1 @@
|
||||
.owl-theme .owl-nav{margin-top:10px;text-align:center;-webkit-tap-highlight-color:transparent}.owl-theme .owl-nav [class*=owl-]{color:#FFF;font-size:14px;margin:5px;padding:4px 7px;background:#D6D6D6;display:inline-block;cursor:pointer;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.owl-theme .owl-nav [class*=owl-]:hover{background:#869791;color:#FFF;text-decoration:none}.owl-theme .owl-nav .disabled{opacity:.5;cursor:default}.owl-theme .owl-nav.disabled+.owl-dots{margin-top:10px}.owl-theme .owl-dots{text-align:center;-webkit-tap-highlight-color:transparent}.owl-theme .owl-dots .owl-dot{display:inline-block;zoom:1;*display:inline}.owl-theme .owl-dots .owl-dot span{width:10px;height:10px;margin:5px 7px;background:#D6D6D6;display:block;-webkit-backface-visibility:visible;-webkit-transition:opacity 200ms ease;-moz-transition:opacity 200ms ease;-ms-transition:opacity 200ms ease;-o-transition:opacity 200ms ease;transition:opacity 200ms ease;-webkit-border-radius:30px;-moz-border-radius:30px;border-radius:30px}.owl-theme .owl-dots .owl-dot.active span,.owl-theme .owl-dots .owl-dot:hover span{background:#869791}
|
||||
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 86 KiB |
|
After Width: | Height: | Size: 23 KiB |
@@ -0,0 +1,50 @@
|
||||
<?php if (!defined('FW')) die('Forbidden'); ?>
|
||||
|
||||
<?php if (isset($data['slides'])): ?>
|
||||
|
||||
<div class="owl-carousel owl-theme">
|
||||
<?php foreach ($data['slides'] as $slide): ?>
|
||||
<?php if ($slide['multimedia_type'] === 'video'): ?>
|
||||
<?php
|
||||
if (false === ($oembed = get_site_transient($transient = 'fw:oembed:'. md5($slide['src'])))) {
|
||||
// Cache wp_oembed_get() to prevent request on every render
|
||||
set_site_transient(
|
||||
$transient,
|
||||
// do strlen() because wp_oembed_get() can be false and it will mess the above `if`
|
||||
$oembed = strlen(wp_oembed_get($slide['src'])),
|
||||
MINUTE_IN_SECONDS
|
||||
);
|
||||
}
|
||||
?>
|
||||
<div class="item-video" style="height:<?php echo esc_attr($dimensions['height']); ?>px;">
|
||||
<?php if ($oembed): ?>
|
||||
<a class="owl-video" href="<?php echo esc_attr($slide['src']); ?>"></a>
|
||||
<?php else: // fixes https://github.com/ThemeFuse/Unyson/issues/2189 ?>
|
||||
<?php
|
||||
$video_type = parse_url($slide['src']);
|
||||
$video_type = explode('.', $video_type['path']);
|
||||
$video_type = array_pop($video_type);
|
||||
$video_type = strtolower($video_type);
|
||||
?>
|
||||
<video controls width="100%" height="100%">
|
||||
<source src="<?php echo esc_attr($slide['src']); ?>" type="video/<?php echo esc_attr($video_type); ?>" />
|
||||
<p class="vjs-no-js"><?php esc_html_e('Please enable JavaScript', 'fw') ?></p>
|
||||
</video>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function ($) {
|
||||
$('.owl-carousel').owlCarousel({
|
||||
items: 1,
|
||||
loop: true,
|
||||
margin: 10,
|
||||
video: true,
|
||||
center: true
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
|
||||
class FW_Slider extends FW_Extension
|
||||
{
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function _init()
|
||||
{
|
||||
}
|
||||
|
||||
public function get_slider_type()
|
||||
{
|
||||
return array(
|
||||
'label' => $this->get_name(),
|
||||
'small' => array(
|
||||
'height' => 100,
|
||||
'src' => $this->locate_URI('/static/images/thumb.jpg'),
|
||||
),
|
||||
'large' => array(
|
||||
'height' => 208,
|
||||
'src' => $this->locate_URI('/static/images/preview.jpg')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function get_multimedia_types()
|
||||
{
|
||||
return (array) $this->get_config('multimedia_types');
|
||||
}
|
||||
|
||||
public function get_population_methods()
|
||||
{
|
||||
$population_methods = fw()->extensions->get('population-method')->get_population_methods($this->get_multimedia_types());
|
||||
$config_population_methods = $this->get_config('population_methods');
|
||||
$final = is_null($config_population_methods) ? $population_methods : array_intersect_key($population_methods, array_flip($config_population_methods));
|
||||
return $final;
|
||||
|
||||
}
|
||||
|
||||
public function get_population_method($type){
|
||||
$population_methods = $this->get_population_methods();
|
||||
return isset($population_methods[$type]) ? $population_methods[$type] : array();
|
||||
}
|
||||
|
||||
private function get_frontend_data($post_id)
|
||||
{
|
||||
return fw()->extensions->get('population-method')->get_frontend_data($post_id);
|
||||
}
|
||||
|
||||
private function list_files($path, $ext){
|
||||
$suffix = '.'. trim($ext, '.');
|
||||
|
||||
if ($glob = glob($path .'/*'. $suffix)) {
|
||||
return array_map('basename', $glob, array_fill_keys($glob, $suffix));
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function add_static()
|
||||
{
|
||||
if ($js_path = $this->locate_path('/static/js')) {
|
||||
foreach($this->list_files($js_path, 'js') as $js){
|
||||
wp_enqueue_script(
|
||||
'fw-ext-'. $this->get_name() .'-'. $js,
|
||||
$this->locate_js_URI($js),
|
||||
array(),
|
||||
fw()->manifest->get_version()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($js_path = $this->locate_path('/static/css')) {
|
||||
foreach($this->list_files($js_path, 'css') as $css){
|
||||
wp_enqueue_style(
|
||||
'fw-ext-'. $this->get_name() .'-'. $css,
|
||||
$this->locate_css_URI($css),
|
||||
array(),
|
||||
fw()->manifest->get_version()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function render_slider($post_id, $dimensions, $extra_data = array())
|
||||
{
|
||||
$this->add_static();
|
||||
$data = $this->get_frontend_data($post_id);
|
||||
return $this->render_view($this->get_name(), compact('data', 'dimensions', 'extra_data'));
|
||||
}
|
||||
|
||||
public function get_slider_options()
|
||||
{
|
||||
return $this->get_options('options');
|
||||
}
|
||||
|
||||
public function get_population_method_options($population_method)
|
||||
{
|
||||
return $this->get_options($population_method);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
|
||||
require dirname(__FILE__) . '/base/class-fw-slider.php';
|
||||
|
||||
class FW_Extension_Slider_Default extends FW_Slider
|
||||
{
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function _init()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
|
||||
$manifest = array();
|
||||
|
||||
$manifest['name'] = __( 'Sliders', 'fw' );
|
||||
$manifest['description'] = __( "Adds the Sliders extension to your website. You'll be able to create different built in jQuery sliders for your homepage and all the other website pages.", 'fw' );
|
||||
$manifest['version'] = '1.1.19';
|
||||
$manifest['github_repo'] = 'https://github.com/ThemeFuse/Unyson-Sliders-Extension';
|
||||
$manifest['uri'] = 'http://manual.unyson.io/en/latest/extension/slider/index.html#content';
|
||||
$manifest['author'] = 'ThemeFuse';
|
||||
$manifest['author_uri'] = 'http://themefuse.com/';
|
||||
$manifest['display'] = true;
|
||||
$manifest['standalone'] = true;
|
||||
$manifest['requirements'] = array(
|
||||
'extensions' => array(
|
||||
'population-method' => array(),
|
||||
)
|
||||
);
|
||||
|
||||
$manifest['github_update'] = 'ThemeFuse/Unyson-Sliders-Extension';
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
|
||||
|
||||
register_post_type(fw()->extensions->get('slider')->get_post_type(), array(
|
||||
'labels' => array(
|
||||
'name' => __('Sliders', 'fw'),
|
||||
'singular_name' => __('Slider', 'fw'),
|
||||
'add_new' => __('Add New', 'fw'),
|
||||
'add_new_item' => __('Add New Slider', 'fw'),
|
||||
'edit_item' => __('Edit Slider', 'fw'),
|
||||
'new_item' => __('New Slider', 'fw'),
|
||||
'all_items' => __('Sliders', 'fw'),
|
||||
'view_item' => __('View Slider', 'fw'),
|
||||
'search_items' => __('Search Sliders', 'fw'),
|
||||
'not_found' => __('No Sliders found', 'fw'),
|
||||
'not_found_in_trash' => __('No Sliders found in Trash', 'fw'),
|
||||
'parent_item_colon' => '',
|
||||
'menu_name' => __('Sliders', 'fw')
|
||||
),
|
||||
'public' => false,
|
||||
'publicly_queryable' => true,
|
||||
'show_ui' => true,
|
||||
'show_in_nav_menus' => false,
|
||||
'query_var' => true,
|
||||
'rewrite' => array('slug' => fw()->extensions->get('slider')->get_post_type()),
|
||||
'has_archive' => true,
|
||||
'hierarchical' => false,
|
||||
'menu_position' => null,
|
||||
'supports' => array(''),
|
||||
'capabilities' => array(
|
||||
'edit_post' => 'edit_pages',
|
||||
'read_post' => 'edit_pages',
|
||||
'delete_post' => 'edit_pages',
|
||||
'edit_posts' => 'edit_pages',
|
||||
'edit_others_posts' => 'edit_pages',
|
||||
'publish_posts' => 'edit_pages',
|
||||
'read_private_posts'=> 'edit_pages',
|
||||
|
||||
'read' => 'edit_pages',
|
||||
'delete_posts' => 'edit_pages',
|
||||
'delete_private_posts' => 'edit_pages',
|
||||
'delete_published_posts'=> 'edit_pages',
|
||||
'delete_others_posts' => 'edit_pages',
|
||||
'edit_private_posts' => 'edit_pages',
|
||||
'edit_published_posts' => 'edit_pages',
|
||||
),
|
||||
/**
|
||||
* Show in menu only if user has access to the Appearance (Themes) menu
|
||||
* else, the Sliders menu will appear, but when clicked on it
|
||||
* users with smaller privileges that does not have access to Appearance menu (for e.g. 'edit_pages' capability)
|
||||
* will see Access denied page
|
||||
*/
|
||||
'show_in_menu' => current_user_can('switch_themes') ? 'themes.php' : null,
|
||||
));
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php if ( ! defined( 'FW' ) ) {
|
||||
die( 'Forbidden' );
|
||||
}
|
||||
|
||||
class FW_Shortcode_Slider extends FW_Shortcode {
|
||||
protected function _render( $atts, $content = null, $tag = '' ) {
|
||||
if ( ! empty( $atts['slider_id'] ) ) {
|
||||
return fw()->extensions->get( 'slider' )->render_slider( $atts['slider_id'],
|
||||
array(
|
||||
'width' => empty( $atts['width'] ) ? 300 : $atts['width'],
|
||||
'height' => empty( $atts['height'] ) ? 200 : $atts['height'],
|
||||
), apply_filters( 'fw_slider_add_shortcode_extra_data', array(), $atts ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php if ( ! defined( 'FW' ) ) {
|
||||
die( 'Forbidden' );
|
||||
}
|
||||
|
||||
$cfg = array();
|
||||
|
||||
$cfg['page_builder'] = array(
|
||||
'title' => __( 'Slider', 'fw' ),
|
||||
'description' => __( 'Add a Slider', 'fw' ),
|
||||
'tab' => __( 'Media Elements', 'fw' ),
|
||||
);
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||
|
||||
$choices = fw()->extensions->get('slider')->get_populated_sliders_choices();
|
||||
|
||||
if (!empty($choices)) {
|
||||
$options = array(
|
||||
'slider_id' => array(
|
||||
'type' => 'select',
|
||||
'label' => __('Select Slider', 'fw'),
|
||||
'choices' => fw()->extensions->get('slider')->get_populated_sliders_choices()
|
||||
),
|
||||
'width' => array(
|
||||
'type' => 'text',
|
||||
'label' => __('Set width', 'fw'),
|
||||
'value' => 300
|
||||
),
|
||||
'height' => array(
|
||||
'type' => 'text',
|
||||
'label' => __('Set height', 'fw'),
|
||||
'value' => 200
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$options = array(
|
||||
'slider_id' => array( // make sure it exists to prevent notices when try to get ['slider_id'] somewhere in the code
|
||||
'type' => 'hidden',
|
||||
),
|
||||
'no-forms' => array(
|
||||
'type' => 'html-full',
|
||||
'label' => false,
|
||||
'desc' => false,
|
||||
'html' =>
|
||||
'<div>'.
|
||||
'<h1 style="font-weight:100; text-align:center; margin-top:80px">'. __('No Sliders Available', 'fw') .'</h1>'.
|
||||
'<p style="text-align:center">'.
|
||||
'<em>'.
|
||||
str_replace(
|
||||
array(
|
||||
'{br}',
|
||||
'{add_slider_link}'
|
||||
),
|
||||
array(
|
||||
'<br/>',
|
||||
fw_html_tag('a', array(
|
||||
'href' => admin_url('post-new.php?post_type='. fw()->extensions->get('slider')->get_post_type()),
|
||||
'target' => '_blank',
|
||||
), __('create a new Slider', 'fw'))
|
||||
),
|
||||
__('No Sliders created yet. Please go to the {br}Sliders page and {add_slider_link}.', 'fw')
|
||||
).
|
||||
'</em>'.
|
||||
'</p>'.
|
||||
'</div>'
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
.fw-shortcode-no-sliders {
|
||||
margin: 0px auto;
|
||||
background-color:#1f6f93 ;
|
||||
}
|
||||
|
After Width: | Height: | Size: 15 KiB |
@@ -0,0 +1,32 @@
|
||||
/*.fw-option-type-image-picker ul.thumbnails.image_picker_selector li*/
|
||||
td.slider_design ul.thumbnails.image_picker_selector li {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
.inside .submitbox ul.thumbnails.image_picker_selector li {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
td.slider_design .fw-option-type-image-picker {
|
||||
margin-bottom: 10px !important;
|
||||
margin-top: 10px !important;
|
||||
}
|
||||
th.column-slider_design{
|
||||
width: 150px;
|
||||
}
|
||||
td.column-slider_design{
|
||||
line-height: 0 !important;
|
||||
}
|
||||
#submitdiv .inside{
|
||||
padding-bottom: 0px !important;
|
||||
}
|
||||
#submitdiv .fw-backend-options-last-border-hider{
|
||||
display: none;
|
||||
}
|
||||
#submitdiv #major-publishing-actions{
|
||||
border-top-width: 0px;
|
||||
}
|
||||
#submitdiv .fw-option-type-image-picker .thumbnail{
|
||||
cursor: auto;
|
||||
}
|
||||
#post-body-content {
|
||||
margin-bottom: 0px !important;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
jQuery(document).ready(function($){
|
||||
$('.selectize').selectize();
|
||||
});
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php if (!defined('FW')) die('Forbidden'); ?>
|
||||
<?php $options = array(
|
||||
'slider-type' =>
|
||||
array(
|
||||
'label' => 'Type',
|
||||
'desc' => false,
|
||||
'type' => 'html',
|
||||
'html' => '<img height="100" src="'.$slider_type['small']['src'].'"/>'
|
||||
),
|
||||
'population-method' => array(
|
||||
'label' => __('Population Method', 'fw'),
|
||||
'type' => 'html',
|
||||
'attr' => array('disabled' => 'disabled','class'=>'fw-no-border'),
|
||||
'html' => '<i>'.$population_method.'</i>',
|
||||
)
|
||||
);?>
|
||||
|
||||
<div class="submitbox" id="submitpost">
|
||||
<?php
|
||||
$out = '';
|
||||
foreach($options as $key=>$option){
|
||||
$out.=fw()->backend->render_option($key, $option);
|
||||
}
|
||||
echo $out;
|
||||
?>
|
||||
<div id="major-publishing-actions">
|
||||
<div id="delete-action">
|
||||
<?php
|
||||
if (current_user_can("delete_post", $post->ID)) {
|
||||
if (!EMPTY_TRASH_DAYS)
|
||||
$delete_text = __('Delete Permanently', 'fw');
|
||||
else
|
||||
$delete_text = __('Move to Trash', 'fw');
|
||||
?>
|
||||
<a class="submitdelete deletion"
|
||||
href="<?php echo esc_attr(get_delete_post_link($post->ID)); ?>"><?php echo $delete_text; ?></a><?php
|
||||
} ?>
|
||||
</div>
|
||||
|
||||
<div id="publishing-action">
|
||||
<span class="spinner"></span>
|
||||
<?php
|
||||
if (!in_array($post->post_status, array('publish', 'future', 'private')) || 0 == $post->ID) {
|
||||
if ($can_publish) :
|
||||
if (!empty($post->post_date_gmt) && time() < strtotime($post->post_date_gmt . ' +0000')) : ?>
|
||||
<input name="original_publish" type="hidden" id="original_publish"
|
||||
value="<?php esc_attr_e('Schedule') ?>"/>
|
||||
<?php submit_button(__('Schedule', 'fw'), 'primary button-large', 'publish', false, array('accesskey' => 'p')); ?>
|
||||
<?php else : ?>
|
||||
<input name="original_publish" type="hidden" id="original_publish"
|
||||
value="<?php esc_attr_e('Publish') ?>"/>
|
||||
<?php submit_button(__('Publish', 'fw'), 'primary button-large', 'publish', false, array('accesskey' => 'p')); ?>
|
||||
<?php endif;
|
||||
else : ?>
|
||||
<input name="original_publish" type="hidden" id="original_publish"
|
||||
value="<?php esc_attr_e('Submit for Review') ?>"/>
|
||||
<?php submit_button(__('Submit for Review', 'fw'), 'primary button-large', 'publish', false, array('accesskey' => 'p')); ?>
|
||||
<?php
|
||||
endif;
|
||||
} else {
|
||||
?>
|
||||
<input name="original_publish" type="hidden" id="original_publish"
|
||||
value="<?php esc_attr_e('Update', 'fw') ?>"/>
|
||||
<input name="save" type="submit" class="button button-primary button-large" id="publish"
|
||||
accesskey="p" value="<?php esc_attr_e('Save', 'fw') ?>"/>
|
||||
<?php
|
||||
} ?>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php if (!defined('FW')) die('Forbidden'); ?>
|
||||
<div class="submitbox" id="submitpost">
|
||||
<div id="major-publishing-actions">
|
||||
<div id="delete-action">
|
||||
<?php
|
||||
if (current_user_can("delete_post", $post->ID)) {
|
||||
if (!EMPTY_TRASH_DAYS)
|
||||
$delete_text = __('Delete Permanently', 'fw');
|
||||
else
|
||||
$delete_text = __('Move to Trash', 'fw');
|
||||
?>
|
||||
<a class="submitdelete deletion"
|
||||
href="<?php echo esc_attr(get_delete_post_link($post->ID)); ?>"><?php echo $delete_text; ?></a><?php
|
||||
} ?>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php if (!defined('FW')) die('Forbidden'); ?>
|
||||
<div class="submitbox" id="submitpost">
|
||||
<div class="misc-pub-section misc-pub-post-status">
|
||||
<p class="description">
|
||||
<?php _e('Note that the type and population can\'t be changed later. You\'ll need to create a new slider to have a different slider type or population method.','fw')?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div id="major-publishing-actions">
|
||||
<div id="delete-action">
|
||||
<?php
|
||||
if (current_user_can("delete_post", $post->ID)) {
|
||||
if (!EMPTY_TRASH_DAYS)
|
||||
$delete_text = __('Delete Permanently', 'fw');
|
||||
else
|
||||
$delete_text = __('Move to Trash', 'fw');
|
||||
?>
|
||||
<a class="submitdelete deletion"
|
||||
href="<?php echo esc_attr(get_delete_post_link($post->ID)); ?>"><?php echo $delete_text; ?></a><?php
|
||||
} ?>
|
||||
</div>
|
||||
|
||||
<div id="publishing-action">
|
||||
<span class="spinner"></span>
|
||||
<?php
|
||||
if (!in_array($post->post_status, array('publish', 'future', 'private')) || 0 == $post->ID) {
|
||||
if ($can_publish) :
|
||||
if (!empty($post->post_date_gmt) && time() < strtotime($post->post_date_gmt . ' +0000')) : ?>
|
||||
<input name="original_publish" type="hidden" id="original_publish"
|
||||
value="<?php esc_attr_e('Schedule') ?>"/>
|
||||
<?php submit_button(__('Schedule', 'fw'), 'primary button-large', 'publish', false, array('accesskey' => 'p')); ?>
|
||||
<?php else : ?>
|
||||
<input name="original_publish" type="hidden" id="original_publish"
|
||||
value="<?php esc_attr_e('Publish') ?>"/>
|
||||
<?php submit_button(__('Create', 'fw'), 'primary button-large', 'publish', false, array('accesskey' => 'p')); ?>
|
||||
<?php endif;
|
||||
else : ?>
|
||||
<input name="original_publish" type="hidden" id="original_publish"
|
||||
value="<?php esc_attr_e('Submit for Review') ?>"/>
|
||||
<?php submit_button(__('Submit for Review', 'fw'), 'primary button-large', 'publish', false, array('accesskey' => 'p')); ?>
|
||||
<?php
|
||||
endif;
|
||||
} else {
|
||||
?>
|
||||
<input name="original_publish" type="hidden" id="original_publish"
|
||||
value="<?php esc_attr_e('Update') ?>"/>
|
||||
<input name="save" type="submit" class="button button-primary button-large" id="publish"
|
||||
accesskey="p" value="<?php esc_attr_e('Update') ?>"/>
|
||||
<?php
|
||||
} ?>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1 @@
|
||||
<?php if (!defined('FW')) die('Forbidden');
|
||||