<?php  

class ControllerEventAddCodeInView extends Controller {
	public function before_view(&$route, &$data, &$output){
		 // echo "<pre>"; print_r($data); echo "</pre>";die;
		 switch ($route) {
		  	case 'common/footer':
		  		break;
		  	
		  	default:
		  		
		  		break;
		  } 
      // $route = str_replace('common/header', 'common/my_custom_header', $route);
		 // echo "<pre>"; print_r($route); echo "</pre>"; 
		 // echo "<pre>"; print_r($data); echo "</pre>"; 
		 // echo "<pre>"; print_r($output); echo "</pre>"; 
    }

    public function after_view(&$route, &$data, &$output){
    	$position = 'right';
    	$position = $this->config->get('module_social_position');
		$status = $this->config->get('module_social_module_status');
		$style = $this->config->get('module_social_style');
		$target = $this->config->get('module_social_target');
		$items = array();
		$html = '';
		$style_class = '';
		$style_class = $style == 1 ? 'icon-bar' : ($style == 2 ? 'icon-bar2' : ($style == 3 ? 'icon-bar3' : ''));
		$target_attr = $target != '' ? 'target="'.$target.'"' : '';
		
		if ($status) {
			if (!empty($this->config->get('module_social_item'))) {
				$items = $this->config->get('module_social_item');
				$html .= '<div class="social_sidebar '.$position.' '.$style_class.' ">';
				$check = false;
				foreach ($items as $key => $social_item) {
					if ($social_item['status'] && !empty($social_item['link'])) {
						$check = true;
						switch ($social_item['name']) {
							case 'Facebook':
								$html .= '<a class="facebook item" '.$target_attr.' href="'.$social_item['link'].'">
											<i class="fa fa-facebook" aria-hidden="true"></i>
										</a>';
								break;
							case 'Instagram':
								$html .= '<a class="instagram item" '.$target_attr.' href="'.$social_item['link'].'"><i class="fa fa-instagram" aria-hidden="true"></i></a>';
								break;
							case 'Twitter':
								$html .= '<a class="twitter item" '.$target_attr.' href="'.$social_item['link'].'"><i class="fa fa-twitter" aria-hidden="true"></i></a>';
								break;
							case 'Google+':
								$html .= '<a class="google item" '.$target_attr.' href="'.$social_item['link'].'"><i class="fa fa-google-plus" aria-hidden="true"></i></a>';
								break;
							case 'Youtube':
								$html .= '<a class="youtube item" '.$target_attr.' href="'.$social_item['link'].'"><i class="fa fa-youtube" aria-hidden="true"></i></a>';
								break;
							case 'Linkedin':
								$html .= '<a class="linkedin item" '.$target_attr.' href="'.$social_item['link'].'"><i class="fa fa-linkedin" aria-hidden="true"></i></a>';
								break;
							case 'Pintrest':
								$html .= '<a class="pintrest item" '.$target_attr.' href="'.$social_item['link'].'"><i class="fa fa-pinterest-p" aria-hidden="true"></i></a>';
								break;
							case 'TikTok':
								$html .= '<a class="tiktok item" '.$target_attr.' href="'.$social_item['link'].'">';
								// $html .= '<i class="fa fa-tiktok" aria-hidden="true"></i>';
								$html .= '<svg height="22px" width="22px" fill="white" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2859 3333" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" image-rendering="optimizeQuality" fill-rule="evenodd" clip-rule="evenodd"><path d="M2081 0c55 473 319 755 778 785v532c-266 26-499-61-770-225v995c0 1264-1378 1659-1932 753-356-583-138-1606 1004-1647v561c-87 14-180 36-265 65-254 86-398 247-358 531 77 544 1075 705 992-358V1h551z"/></svg>';
								$html .= '</a>';
								break;
							default:
								# code...
								break;
						}
					}
				}


				$html .= '</div>';

				$html .='<script type="text/javascript">
							$(".hide_show").on("click",function(e){
								if ($(this).hasClass("on")) {
									$(".social_sidebar .item").css({opacity: 1.0, visibility: "visible"}).animate({opacity: 0}, 320);
									setTimeout(function(){
										$(".social_sidebar .item").hide();
									}, 340);
									$(this).removeClass("on");
									$(this).addClass("off");
								}else{
									$(".social_sidebar .item").animate({opacity: 1}, 320);
									setTimeout(function(){
										$(".social_sidebar .item").show();
									}, 340);
									$(this).addClass("on");
									$(this).removeClass("off");
								}

								if ($(this).find("i").hasClass("fa-arrow-right")) {
									$(this).find("i").removeClass("fa-arrow-right");
									$(this).find("i").addClass("fa-arrow-left");
								}else if ($(this).find("i").hasClass("fa-arrow-left")) {
									$(this).find("i").removeClass("fa-arrow-left");
									$(this).find("i").addClass("fa-arrow-right");
								}else if ($(this).find("i").hasClass("fa-arrow-up")) {
									$(this).find("i").removeClass("fa-arrow-up");
									$(this).find("i").addClass("fa-arrow-down");
								}else if ($(this).find("i").hasClass("fa-arrow-down")) {
									$(this).find("i").removeClass("fa-arrow-down");
									$(this).find("i").addClass("fa-arrow-up");
								}
							});						
							</script>';

				$html .= '<style type="text/css">
							.social_sidebar{
								position: fixed;
								z-index:9999999;
							}

							.social_sidebar.left{
								position: fixed;
							  	top: 45%;
							  	left:0;
							  	-webkit-transform: translateY(-50%);
							  	-ms-transform: translateY(-50%);
							  	transform: translateY(-50%);
							}

							.social_sidebar.right{
								position: fixed;
							  	top: 45%;
							  	right:0;
							  	-webkit-transform: translateY(-50%);
							  	-ms-transform: translateY(-50%);
							  	transform: translateY(-50%);
							}

							.social_sidebar.top{
								position: fixed;
								top: 0;
								left: 50%;
								-webkit-transform: translateX(-50%);
							  	-ms-transform: translateX(-50%);
							  	transform: translateX(-50%);
							}

							.social_sidebar.bottom{
								position: fixed;
								bottom: 0;
								left: 50%;
								-webkit-transform: translateX(-50%);
							  	-ms-transform: translateX(-50%);
							  	transform: translateX(-50%);
							}

							.facebook {
							  background: #3B5998;
							  color: white;
							}

							.instagram {
								background: #f09433; 
								background: -moz-linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%); 
								background: -webkit-linear-gradient(45deg, #f09433 0%,#e6683c 25%,#dc2743 50%,#cc2366 75%,#bc1888 100%); 
								background: linear-gradient(45deg, #f09433 0%,#e6683c 25%,#dc2743 50%,#cc2366 75%,#bc1888 100%); 
								filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=\'#f09433\', endColorstr=\'#bc1888\',GradientType=1 );
							  color: white;
							}

							.twitter {
							  background: #55ACEE;
							  color: white;
							}

							.google {
							  background: #dd4b39;
							  color: white;
							}

							.linkedin {
							  background: #007bb5;
							  color: white;
							}

							.pintrest {
							  background: #EE1B22;
							  color: white;
							}

							.tiktok {
							  background: #000000;
							  color: white;
							}

							.youtube {
							  background: #bb0000;
							  color: white;
							}

							.hide_show {
							  background: #009985;
							  color: white;
							}

							.hide_show:hover {
							  background: #009985;
							  color: white;
							}
						
							// style1

							.icon-bar {
							}

							.icon-bar a {
							  display: block;
							  text-align: center;
							  padding: 16px;
							  transition: all 0.3s ease;
							  color: white;
							  font-size: 20px;
							}

							.icon-bar.bottom a,.icon-bar.top a  {
							  display: inline-block;
							  width:65px;
							  text-align: center;
							  padding: 16px;
							  transition: all 0.3s ease;
							  color: white;
							  font-size: 20px;
							}


							.icon-bar a:hover {
							  background-color: #000;
							}

							
							
							.social_sidebar a i{
								font-size:22px;
							}

							// style 2

							.icon-bar2 {
							  left:400px ;
							  width: 250px;
							  height: 220px;
							  position: fixed;
							  margin-top: 5px;
							  perspective: 1000px;
							}

							.icon-bar2 a {
							  display: block;
							  text-align: center;
							  padding: 16px;
							  transition: all 0.3s ease;
							  color: white;
							  font-size: 20px;
							}

							.icon-bar2.bottom a,.icon-bar2.top a  {
							  display: inline-block;
							  width:65px;
							  text-align: center;
							  padding: 16px;
							  transition: all 0.3s ease;
							  color: white;
							  font-size: 20px;
							}

							.icon-bar2 a {
							  background: #222;
							  border-right: 1px solid #333;
							  font: normal normal normal 16px/20px "FontAwesome", "Source Sans Pro", Helvetica, Arial, sans-serif;
							  color: #fff;
							  -webkit-font-smoothing: antialiased;
							  padding: 14px;
							  text-decoration: none;
							  text-align: center;
							  transition: background .5s ease .300ms
							}

							.icon-bar2.left a,.icon-bar2.right a{
							}

							.icon-bar2 a.facebook:hover { background: #3B5998 }
							.icon-bar2 a.instagram:hover { 							  background: #f09433; 
								background: -moz-linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%); 
								background: -webkit-linear-gradient(45deg, #f09433 0%,#e6683c 25%,#dc2743 50%,#cc2366 75%,#bc1888 100%); 
								background: linear-gradient(45deg, #f09433 0%,#e6683c 25%,#dc2743 50%,#cc2366 75%,#bc1888 100%); 
								filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=\'#f09433\', endColorstr=\'#bc1888\',GradientType=1 ); }
							.icon-bar2 a.twitter:hover { background: #55ACEE }
							.icon-bar2 a.google:hover { background: #dd4b39 }
							.icon-bar2 a.linkedin:hover { background: #007bb5 }
							.icon-bar2 a.pintrest:hover { background: #EE1B22 }
							.icon-bar2 a.tiktok:hover { background: #000000 }
							.icon-bar2 a.youtube:hover { background: #bb0000 }

							.icon-bar2.top a:first-child { border-radius: 0 0 0 5px }
							.icon-bar2.top a:last-child { border-radius: 0 0 5px 0 }

							.icon-bar2.bottom a:first-child { border-radius: 5px 0 0 0 }
							.icon-bar2.bottom a:last-child { border-radius: 0 5px 0 0 }

							.icon-bar2.left a:first-child { border-radius: 0 5px 0 0 }
							.icon-bar2.left a:last-child { border-radius: 0 0 5px 0 }	

							.icon-bar2.right a:first-child { border-radius: 5px 0 0 0 }
							.icon-bar2.right  a:last-child { border-radius: 0 0 0 5px }
							    
							.icon-bar2  a span {
							  width: 100px;
							  float: left;
							  text-align: center;
							  background: #222;
							  color: #fff;
							  margin-top: 20px;
							  margin-left: -45px;
							  padding: 8px;
							  transform-origin: 0;
							  visibility: hidden;
							  opacity: 0;
							  transform: rotateY(45deg);
							  border-radius: 5px;
							  transition: all .5s ease .300ms
							}

							.icon-bar2 span:after {
							  content: "";
							  display: block;
							  width: 0;
							  height: 0;
							  position: absolute;
							  left: 50px;
							  top: -20px;
							  border-left: 10px solid transparent;
							  border-bottom: 10px solid #222;
							  border-right: 10px solid transparent;
							  border-top: 10px solid transparent;
							}

							.icon-bar2  a:hover span {
							  visibility: visible;
							  opacity: 1;
							  transform: rotateY(0);
							}

							// style3

							.icon-bar3 {
							}

							.icon-bar3 a {
							  display: block;
							  text-align: center;
							  padding: 16px;
							  transition: all 0.3s ease;
							  color: white;
							  font-size: 20px;
							  
							}

							.icon-bar3.bottom a,.icon-bar3.top a  {
							  display: inline-block;
							  width:65px;
							  text-align: center;
							  padding: 16px;
							  transition: all 0.3s ease;
							  color: white;
							  font-size: 20px;
							}
							
							.icon-bar3.right a {
							  	width:50px;
							  	margin-left:auto;
							}

							.icon-bar3.left a{
							  	width:50px;
							  	margin-right:auto;
							}

							.icon-bar3.left a:hover,.icon-bar3.right a:hover {
							  	background-color: #000;
								width:70px;
							}

							.icon-bar3.top a,.icon-bar3.bottom a {
								height:54px;
							}

							.icon-bar3.top a:hover,.icon-bar3.bottom a:hover {
							  	background-color: #000;
								height:64px;
							}
							
							.social_sidebar a i{
								font-size:22px;
							}

							.icon-bar a i {
							    font-size: 22px;
							    filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.6));
							}
		
							.icon-bar2 a i {
							    font-size: 22px;
							    filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.6));
							}

							.icon-bar3 a i {
							    font-size: 22px;
							    filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.6));
							}

							@media screen and (max-width: 768px) {
							  	.social_sidebar.right a, .social_sidebar.left a {
								    padding: 12px;
								}

								.social_sidebar.right a i, .social_sidebar.left a i {
								    font-size: 19px;
								}

								.icon-bar3.left a:hover, .icon-bar3.right a:hover{
									width: 52px;
								}

								.social_sidebar.right a {
								    width: 46px;
								    margin-left: auto;
								    font-size: 18px;
								}

								.social_sidebar.left a {
								    width: 46px;
								    margin-left: auto;
								    font-size: 18px;
								}

								.social_sidebar a i{
									font-size: 18px;
								}

								.social_sidebar.bottom a, .social_sidebar.top a{
								    height: 44px;
								    width: 44px; 
								    padding: 11px;
								}

								.icon-bar3.top a:hover, .icon-bar3.bottom a:hover {
								    height: 50px;
								}

								.social_sidebar.top,.social_sidebar.bottom{
									width: 370px;
								}
							}

							@media screen and (max-width: 425px) {
							  	.social_sidebar.right a, .social_sidebar.left a {
								    padding: 12px;
								}

								.social_sidebar.right a i, .social_sidebar.left a i {
								    font-size: 19px;
								}

								.icon-bar3.left a:hover, .icon-bar3.right a:hover{
									width: 52px;
								}

								.social_sidebar.right a {
								    width: 46px;
								    margin-left: auto;
								    font-size: 18px;
								}

								.social_sidebar.left a {
								    width: 46px;
								    margin-left: auto;
								    font-size: 18px;
								}

								.social_sidebar a i{
									font-size: 18px;
								}

								.social_sidebar.bottom a, .social_sidebar.top a{
								    height: 44px;
								    width: 44px; 
								    padding: 11px;
								}

								.icon-bar3.top a:hover, .icon-bar3.bottom a:hover {
								    height: 52px;
								}

								.social_sidebar.top,.social_sidebar.bottom{
									width: 100%;
								}
							}

							@media screen and (max-width: 375px) {
						  	.social_sidebar.right a, .social_sidebar.left a {
							    padding: 12px;
							}

							.social_sidebar.right a i, .social_sidebar.left a i {
							    font-size: 19px;
							}

							.icon-bar3.left a:hover, .icon-bar3.right a:hover{
								width: 52px;
							}

							.social_sidebar.right a {
							    width: 46px;
							    margin-left: auto;
							    font-size: 18px;
							}

							.social_sidebar.left a {
							    width: 46px;
							    margin-left: auto;
							    font-size: 18px;
							}

							.social_sidebar a i{
								font-size: 18px;
							}

							.social_sidebar.bottom a, .social_sidebar.top a{
							    height: 40px;
							    width: 40px; 
							    padding: 11px;
							}

							.icon-bar3.top a:hover, .icon-bar3.bottom a:hover {
							    height: 50px;
							}

							.social_sidebar.top,.social_sidebar.bottom{
								width: 100%;
							}
						}

						@media screen and (max-width: 320px) {
						  	.social_sidebar.right a, .social_sidebar.left a {
							    padding: 10px;
							}

							.social_sidebar.right a i, .social_sidebar.left a i {
							    font-size: 18px;
							}

							.icon-bar3.left a:hover, .icon-bar3.right a:hover{
								width: 50px;
							}

							.social_sidebar.right a {
							    width: 44px;
							    margin-left: auto;
							    font-size: 18px;
							}

							.social_sidebar.left a {
							    width: 44px;
							    margin-left: auto;
							    font-size: 18px;
							}

							.social_sidebar a i{
								font-size: 16px;
							}

							.social_sidebar.bottom a, .social_sidebar.top a{
							    height: 40px;
							    width: 40px; 
							    padding: 11px;
							}

							.icon-bar3.top a:hover, .icon-bar3.bottom a:hover {
							    height: 50px;
							}

							.social_sidebar.top,.social_sidebar.bottom{
								width: 100%;
							}
						}
						</style>';
			}
		}

    	switch ($route) {
		  	case 'common/footer':
				$extra_data = $html;
				$output = $extra_data.$output;		  		
	  		break;
		  	
		  	default:
		  		
		  		break;
		  } 

      // $route = str_replace('common/header', 'common/my_custom_header', $route);
		 // echo "<pre>"; print_r($route); echo "</pre>"; 
		 // echo "<pre>"; print_r($data); echo "</pre>"; 
		 // echo "<pre>"; print_r($output); echo "</pre>"; 
    }
}