<?php

class Intense_Animated_Scroll extends Intense_Shortcode {

	function __construct() {
        parent::__construct();

		global $intense_visions_options;

		$this->title = __( 'Animated Scroll', 'intense' );
		$this->description = __( 'The animated scroll shortcode adds animated scroll effects to items of your choice. You will need to have a good understanding of <a href="https://github.com/Prinzhorn/skrollr#absolute-vs-relative-mode" target="_blank">Skrollr</a> to use this shortcode.', 'intense' );
		$this->category = __( 'Elements', 'intense' );
		$this->show_preview = true;		
	    $this->preview_content = __( "Animated Scroll Content", 'intense' );
	    $this->is_container = true;
	}

	function shortcode( $atts, $content = null ) {
		global $intense_visions_options;
		extract( shortcode_atts( $this->get_shortcode_defaults( null, $atts ), $atts ) );

		$output = "";
		$code = "";
		$target = "";

    	intense_add_script( 'intense.animatedscroll' );
		intense_add_script( "skrollr" );

		if ( !empty( $target_id ) ) {
			$target = 'data-anchor-target="#' . $target_id . '"';
		}

		if ( $effect == 'fadein' ) {
			$code = $effect_code . ' class="animated-scroll skrollable skrollable-after ' . $class . '"';
		} else if ( $effect == 'fadeout' ) {
			$code = $effect_code . ' class="animated-scroll skrollable skrollable-after ' . $class . '"';
		} else if ( $effect == 'fadeinout' || $effect == 'rotateupleft' || $effect == 'rotateupright' ) {
			$code = $effect_code . ' class="animated-scroll skrollable skrollable-between ' . $class . '"';
		} else if ( $effect == 'fadeoutscale' ) {
			$code = $effect_code . ' class="animated-scroll skrollable skrollable-before ' . $class . '"';
		//} else if ( $effect == 'gradient' ) {
		//	$code = $effect_code . ' class="skrollable skrollable-between ' . $class . '"' . ' style="padding:0;margin:0;width:100%;height:100%;background-attachment:fixed;"';
		// } else if ( $effect == 'fixed' ) {
		// 	$code = $effect_code . ' class="skrollable skrollable-between ' . $class . '" style="opacity: 0.712; position: fixed; top: 206px; width: 100%; left: 0px;"';
		// } else if ( $effect == 'speedup' ) {
		// 	$code = $effect_code . ' class="skrollable skrollable-before ' . $class . '"';
		// } else if ( $effect == 'easeleft' ) {
		// 	$code = $effect_code . ' class="skrollable skrollable-after ' . $class . '"';
		// } else if ( $effect == 'easeright' ) {
		// 	$code = $effect_code . ' class="skrollable skrollable-after ' . $class . '"';
		//} else if ( $effect == 'curtain' ) {
		//	$code = 'data-bottom-top="opacity: 0" data-106-top="height: 1%; opacity: 0; top: -10%;" data-center="height: 100%; opacity: 0.5; top: 0%;" class="curtain skrollable skrollable-after ' . $class . '"';
		} else if ( $effect == 'custom' ) {
			$code = $effect_code . ' class="animated-scroll skrollable skrollable-between ' . $class . '"';
		}

		$output = '<div ' . $code . '>' . do_shortcode( $content ) . '</div>';

		return $output;
	}
}
