Advertisement
progreccor

show_block_img.php

Oct 29th, 2018
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.10 KB | None | 0 0
  1. <?php
  2. /**
  3.  * @package    HikaShop for Joomla!
  4.  * @version    2.5.0
  5.  * @author    hikashop.com
  6.  * @copyright    (C) 2010-2015 HIKARI SOFTWARE. All rights reserved.
  7.  * @license    GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
  8.  */
  9. defined('_JEXEC') or die('Restricted access');
  10. ?><?php
  11. $variant_name = '';
  12. $variant_main = '_main';
  13. $display_mode = '';
  14. if (!empty($this->variant_name)) {
  15.     $variant_name = $this->variant_name;
  16.     if (substr($variant_name, 0, 1) != '_')
  17.         $variant_name = '_' . $variant_name;
  18.     $variant_main = $variant_name;
  19.     $display_mode = 'display:none;';
  20. }
  21. ?>
  22.  
  23. <div class="uk-grid " >
  24.  
  25.     <div class="uk-width-medium-5-6 uk-push-1-6">
  26.  
  27.         <div id="hikashop_main_image_div<?php echo $variant_name; ?>" class="hikashop_main_image_div uk-panel">
  28.             <?php
  29.             if (!empty ($this->element->images)) {
  30.                 $image = reset($this->element->images);
  31.             }
  32.             $height = (int)$this->config->get('product_image_y');
  33.             $width = (int)$this->config->get('product_image_x');
  34.             if (empty($height)) $height = (int)$this->config->get('thumbnail_y');
  35.             if (empty($width)) $width = (int)$this->config->get('thumbnail_x');
  36.             $divWidth = $width;
  37.             $divHeight = $height;
  38.             $this->image->checkSize($divWidth, $divHeight, $image);
  39.  
  40.             if (!$this->config->get('thumbnail')) {
  41.                 if (!empty ($this->element->images)) {
  42.                     echo '<img src="' . $this->image->uploadFolder_url . $image->file_path . '" alt="' . $image->file_name . '" id="hikashop_main_image" style="margin-top:10px;margin-bottom:10px;display:inline-block;vertical-align:middle;" />';
  43.                 }
  44.             } else {
  45.                 $style = '';
  46.                 if (!empty ($this->element->images) && count($this->element->images) > 1) {
  47.                     if (!empty($height)) {
  48.                         $style = ' style="height:' . ($height + 20) . 'px;"';
  49.                     }
  50.                 }
  51.                 $variant_name = '';
  52.                 if (isset($this->variant_name)) {
  53.                     $variant_name = $this->variant_name;
  54.                 }
  55.  
  56.                 ?>
  57.  
  58.                 <div class="hikashop_product_main_image_thumb"
  59.                      id="hikashop_image_main_thumb_div<?php echo $variant_name; ?>"  >
  60.                     <div style="text-align:center;clear:both;" class="hikashop_product_main_image">
  61.                         <div  class="hikashop_product_main_image_subdiv">
  62.                             <?php
  63.                             if ($this->image->override) {
  64.                                 echo $this->image->display(@$image->file_path, true, @$image->file_name, 'id="hikashop_main_image' . $variant_name . '" style="margin-top:10px;margin-bottom:10px;display:inline-block;vertical-align:middle"', 'id="hikashop_main_image_link"', $width, $height);
  65.                             } else {
  66.                                 if (empty($this->popup))
  67.                                     $this->popup = hikashop_get('helper.popup');
  68.                                 $image_options = array('default' => true, 'forcesize' => $this->config->get('image_force_size', true), 'scale' => $this->config->get('image_scale_mode', 'inside'));
  69.                                 $img = $this->image->getThumbnail(@$image->file_path, array('width' => $width, 'height' => $height), $image_options);
  70.                                 if (@$img->success) {
  71.                                     $attr = 'title="' . $this->escape(@$image->file_description) . '"';
  72.                                     if (!empty ($this->element->images) && count($this->element->images) > 1) {
  73.                                         $attr .= 'onclick="return window.localPage.openImage(\'hikashop_main_image' . $variant_name . '\');"';
  74.                                     }
  75.                                     $html = '<img id="hikashop_main_image' . $variant_name . '" style="margin-top:10px;margin-bottom:10px;display:inline-block;vertical-align:middle;"  alt="' . $this->escape(@$image->file_name) . '" src="' . $img->url . '"/>';
  76.                                     if (!empty($this->element->badges))
  77.                                         $html .= $this->classbadge->placeBadges($this->image, $this->element->badges, '0', '0', false);
  78.  
  79.                                     echo $this->popup->image($html, $img->origin_url, null, $attr);
  80.                                 }
  81.                             }
  82.                             ?>
  83.                         </div>
  84.                     </div>
  85.                 </div>
  86.                 <?php
  87.             }
  88.             ?>
  89.         </div>
  90.     </div>
  91.     <div class="uk-width-medium-1-6 uk-pull-5-6 ">
  92.  
  93.         <div class="uk-vertical-align uk-panel uk-height-1-1">
  94.             <div id="hikashop_small_image_div<?php echo $variant_name; ?>"
  95.                  class="uk-vertical-align-middle hikashop_small_image_div uk-position-relative">
  96.                 <i class="uk-icon-chevron-down uk-slidenav-down"></i>
  97.                 <i class="uk-icon-chevron-up uk-slidenav-up"></i>
  98.  
  99.                 <div>
  100.                     <div style="top:0;">
  101.                         <?php
  102.                         if (!empty ($this->element->images) && count($this->element->images) > 1) {
  103.                             $firstThunb = true;
  104.                             $skipFirst = true;
  105.                             foreach ($this->element->images as $image) {
  106.                                 if (!$skipFirst) {
  107.                                     if ($this->image->override) {
  108.                                         echo $this->image->display($image->file_path, 'hikashop_main_image' . $variant_name, $image->file_name, 'class="hikashop_child_image"', '', $width, $height);
  109.                                     } else {
  110.                                         if (empty($this->popup))
  111.                                             $this->popup = hikashop_get('helper.popup');
  112.                                         $img = $this->image->getThumbnail(@$image->file_path, array('width' => $width, 'height' => $height), $image_options);
  113.                                         if (@$img->success) {
  114.                                             $id = null;
  115.                                             $classname = 'hikashop_child_image';
  116.                                             if ($firstThunb) {
  117.                                                 $id = 'hikashop_first_thumbnail' . $variant_name;
  118.                                                 $firstThunb = false;
  119.                                                 $classname .= ' hikashop_child_image_active';
  120.                                             }
  121.                                             $attr = 'title="' . $this->escape(@$image->file_description) . '" onmouseover="return window.localPage.changeImage(this, \'hikashop_main_image' . $variant_name . '\', \'' . $img->url . '\', ' . $img->width . ', ' . $img->height . ', \'' . str_replace("'", "\'", @$image->file_description) . '\', \'' . str_replace("'", "\'", @$image->file_name) . '\');"';
  122.                                             $html = '<img class="' . $classname . '" title="' . $this->escape(@$image->file_description) . '" alt="' . $this->escape(@$image->file_name) . '" src="' . $img->url . '"/>';
  123.                                             if (empty($variant_name)) {
  124.                                                 echo $this->popup->image($html, $img->origin_url, $id, $attr, array('gallery' => 'hikashop_main_image'));
  125.                                             } else {
  126.                                                 echo $this->popup->image($html, $img->origin_url, $id, $attr, array('gallery' => 'hikashop_main_image_VARIANT_NAME'));
  127.                                             }
  128.                                         }
  129.                                     }
  130.                                 } else {
  131.                                     $skipFirst = false;
  132.                                 }
  133.                             }
  134.                         }
  135.  
  136.                         ?>
  137.                     </div>
  138.                 </div>
  139.             </div>
  140.         </div>
  141.     </div>
  142.  
  143.  
  144. </div>
  145. <script type="text/javascript">
  146.     if (!window.localPage)
  147.         window.localPage = {};
  148.     if (!window.localPage.images)
  149.         window.localPage.images = {};
  150.     window.localPage.changeImage = function (el, id, url, width, height, title, alt) {
  151.         var d = document, target = d.getElementById(id), w = window, o = window.Oby;
  152.         if (!target) return false;
  153.         target.src = url;
  154.         target.width = width;
  155.         target.height = height;
  156.         target.title = title;
  157.         target.alt = alt;
  158.         var thumb_img = null, thumbs_div = d.getElementById('hikashop_small_image_div');
  159.         if (thumbs_div) {
  160.             thumbs_img = thumbs_div.getElementsByTagName('img');
  161.             if (thumbs_img) {
  162.                 for (var j = thumbs_img.length - 1; i >= 0; i--) {
  163.                     o.removeClass(thumbs_img[j], 'hikashop_child_image_active');
  164.                 }
  165.             }
  166.         }
  167.         thumb_img = el.getElementsByTagName('img');
  168.         if (thumb_img) {
  169.             for (var j = thumbs_img.length - 1; i >= 0; i--) {
  170.                 o.addClass(thumbs_img[j], 'hikashop_child_image_active');
  171.             }
  172.         }
  173.  
  174.         window.localPage.images[id] = el;
  175.         return false;
  176.     };
  177.     window.localPage.openImage = function (id) {
  178.         if (!window.localPage.images[id])
  179.             window.localPage.images[id] = document.getElementById('hikashop_first_thumbnail<?php echo $variant_name;?>');
  180.         window.localPage.images[id].click();
  181.         return false;
  182.     };
  183.  
  184.     var tmblock= 0,
  185.         razmer=jQuery("#hikashop_small_image_div .hikashop_child_image").outerHeight(true),
  186.         kolichestvo=jQuery("#hikashop_small_image_div .hikashop_child_image").length;
  187.     if (kolichestvo<5) {
  188.         jQuery(".uk-slidenav-down").css({display: 'none'});
  189.         jQuery(".uk-slidenav-up").css({display: 'none'});
  190.     }
  191.     jQuery( ".uk-slidenav-up" ).on( "click", function( event ) {
  192.         event.preventDefault();
  193.         if (tmblock) return;
  194.         tmblock=1;
  195.         setTimeout(function(){tmblock=0;},510);
  196.         jQuery("#hikashop_small_image_div>div>div").css("top", function (index, top) {
  197.             top=parseInt(top);
  198.             if((top+razmer)>0) return;
  199.             return top+razmer;
  200.         });
  201.     });
  202.  
  203.     jQuery( ".uk-slidenav-down" ).on( "click", function( event ) {
  204.         event.preventDefault();
  205.         if (tmblock) return;
  206.         tmblock = 1;
  207.         setTimeout(function () {
  208.             tmblock = 0;
  209.         }, 510);
  210.         jQuery("#hikashop_small_image_div>div>div").css("top", function (index, top) {
  211.             top=parseInt(top);
  212.             if((top-razmer)<(-(kolichestvo-4)*razmer)) return;
  213.             return top-razmer;
  214.         });
  215.  
  216.         if ((-(jQuery("#hikashop_small_image_div .hikashop_child_image").length - 3) * 340) < parseFloat(jQuery("#hikashop_small_image_div>div>div").css("top"))) {
  217.  
  218.  
  219.         }
  220.     });
  221.  
  222. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement