<?php

class Intense_Counter extends Intense_Shortcode {

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

		global $intense_visions_options;

		$this->title = __( 'Counter', 'intense' );
		$this->description = __('Add a numerical counter to your WordPress site using the counter shortcode. The counter can count up or down and in set increments. Control the speed and styling of the text. You can also increment by less than one. When the number is less than one and/or over 1000, you can control the character used for the decimal place and thousands separator.', 'intense');
		$this->category = __( 'Elements', 'intense' );		
		$this->show_preview = true;
	}

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

		intense_add_script( 'jquery.appear' );
		intense_add_script( 'accounting.js' );
		intense_add_script( 'intense.counter' );

		$font_color = intense_get_plugin_color( $font_color );

		if ( $font_color == '' ) {
			$style = "";
		} else {
			$style = "color: " . $font_color . ";";
		}

		if ( isset( $border_radius ) ) {
			$style .= ' border-radius:' . $border_radius . ';';
		}

		$background_color = intense_get_plugin_color( $background_color );

		if ( isset( $background_color ) ) {
			$style .= ' background-color:' . $background_color . ';';
		}

		$id = ( !empty ( $id ) ) ? ' id="' . $id . '"' : '';

		return '<div' . $id . ' class="intense counter' . ( !empty( $class ) ? ' ' . $class : '' ) . '" style="display: inline-block; min-width: 5px;' . $style . '" data-text="' . $text . '" data-start="' . $start . '" data-end="' . $end . '" data-speed="' . $speed . '" data-decimal-places="' . $decimal_places . '" data-thousands-separator="' . $thousands_separator . '" data-decimal-point="' . $decimal_point . '" data-increment="' . $increment . '"></div>';
	}
}
