| 1 | <?php use_helper('I18N') ?> |
|---|
| 2 | <?php if ($options['arrows'] && (count($items) > 1)): ?> |
|---|
| 3 | <ul id="a-slideshow-controls-<?php echo $id ?>" class="a-slideshow-controls"> |
|---|
| 4 | <li class="a-arrow-btn icon a-arrow-left"><?php echo __('Previous', null, 'apostrophe') ?></li> |
|---|
| 5 | <?php if ($options['position']): ?> |
|---|
| 6 | <li class="a-slideshow-position"> |
|---|
| 7 | <span class="head"></span>/<span class="total"><?php echo count($items); ?></span> |
|---|
| 8 | </li> |
|---|
| 9 | <?php endif ?> |
|---|
| 10 | <li class="a-arrow-btn icon a-arrow-right"><?php echo __('Next', null, 'apostrophe') ?></li> |
|---|
| 11 | </ul> |
|---|
| 12 | <?php endif ?> |
|---|
| 13 | |
|---|
| 14 | <?php if (count($items)): ?> |
|---|
| 15 | <ul id="a-slideshow-<?php echo $id ?>" class="a-slideshow"> |
|---|
| 16 | <?php $first = true; $n=0; foreach ($items as $item): ?> |
|---|
| 17 | <?php $dimensions = aDimensions::constrain( |
|---|
| 18 | $item->width, |
|---|
| 19 | $item->height, |
|---|
| 20 | $item->format, |
|---|
| 21 | array("width" => $options['width'], |
|---|
| 22 | "height" => $options['flexHeight'] ? false : $options['height'], |
|---|
| 23 | "resizeType" => $options['resizeType'])) ?> |
|---|
| 24 | <?php $embed = str_replace( |
|---|
| 25 | array("_WIDTH_", "_HEIGHT_", "_c-OR-s_", "_FORMAT_"), |
|---|
| 26 | array($dimensions['width'], |
|---|
| 27 | $dimensions['height'], |
|---|
| 28 | $dimensions['resizeType'], |
|---|
| 29 | $dimensions['format']), |
|---|
| 30 | $item->getEmbedCode('_WIDTH_', '_HEIGHT_', '_c-OR-s_', '_FORMAT_', false)) ?> |
|---|
| 31 | |
|---|
| 32 | <li class="a-slideshow-item" id="a-slideshow-item-<?php echo $id ?>-<?php echo $n ?>" <?php echo ($first)? 'style="display:list-item;"':''; ?>> |
|---|
| 33 | <?php include_partial('aSlideshowSlot/'.$options['itemTemplate'], array('item' => $item, 'id' => $id, 'embed' => $embed, 'n' => $n, 'options' => $options)) ?> |
|---|
| 34 | </li> |
|---|
| 35 | <?php $first = false; $n++; endforeach ?> |
|---|
| 36 | </ul> |
|---|
| 37 | <?php endif ?> |
|---|
| 38 | |
|---|
| 39 | <?php if (count($items) > 1): ?> |
|---|
| 40 | <script type="text/javascript" charset="utf-8"> |
|---|
| 41 | //<![CDATA[ |
|---|
| 42 | $(document).ready(function() { |
|---|
| 43 | |
|---|
| 44 | <?php // Clear any interval timer left running by a previous slot variant ?> |
|---|
| 45 | if (window.aSlideshowIntervalTimeouts !== undefined) |
|---|
| 46 | { |
|---|
| 47 | if (window.aSlideshowIntervalTimeouts['<?php echo "a-$id" ?>']) |
|---|
| 48 | { |
|---|
| 49 | clearTimeout(window.aSlideshowIntervalTimeouts['<?php echo "a-$id" ?>']); |
|---|
| 50 | } |
|---|
| 51 | } |
|---|
| 52 | else |
|---|
| 53 | { |
|---|
| 54 | window.aSlideshowIntervalTimeouts = {}; |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | var position = 0; |
|---|
| 58 | var img_count = <?php echo count($items)-1 ?>; |
|---|
| 59 | var slideshowItems = $('#a-slideshow-<?php echo $id ?> .a-slideshow-item'); |
|---|
| 60 | $('.a-context-media-show-item').hide(); |
|---|
| 61 | $('#a-slideshow-item-<?php echo $id ?>-'+position).show(); |
|---|
| 62 | |
|---|
| 63 | <?php if ($options['position']): ?> |
|---|
| 64 | var positionHead = $('#a-slideshow-controls-<?php echo $id ?> li.a-slideshow-position span.head'); |
|---|
| 65 | setHead(position); |
|---|
| 66 | |
|---|
| 67 | function setHead(current_position) |
|---|
| 68 | { |
|---|
| 69 | positionHead.text(current_position+1); |
|---|
| 70 | } |
|---|
| 71 | <?php endif ?> |
|---|
| 72 | |
|---|
| 73 | var intervalEnabled = <?php echo ($options['interval'])? 1:0; ?>; |
|---|
| 74 | slideshowItems.attr('title', <?php echo json_encode(__('Click For Next Image', null, 'apostrophe')) ?>); |
|---|
| 75 | |
|---|
| 76 | $('#a-slideshow-<?php echo $id ?>').bind('showImage', function(e, num){ |
|---|
| 77 | position = num; |
|---|
| 78 | slideshowItems.hide(); |
|---|
| 79 | $('#a-slideshow-item-<?php echo $id ?>-'+position).fadeIn('slow'); |
|---|
| 80 | }); |
|---|
| 81 | |
|---|
| 82 | slideshowItems.find('.a-slideshow-image').click(function(event) { |
|---|
| 83 | event.preventDefault(); |
|---|
| 84 | next(); |
|---|
| 85 | }); |
|---|
| 86 | |
|---|
| 87 | $('#a-slideshow-controls-<?php echo $id ?> .a-arrow-left').click(function(event){ |
|---|
| 88 | event.preventDefault(); |
|---|
| 89 | intervalEnabled = false; |
|---|
| 90 | previous(); |
|---|
| 91 | }); |
|---|
| 92 | |
|---|
| 93 | $('#a-slideshow-controls-<?php echo $id ?> .a-arrow-right').click(function(event){ |
|---|
| 94 | event.preventDefault(); |
|---|
| 95 | intervalEnabled = false; |
|---|
| 96 | next(); |
|---|
| 97 | }); |
|---|
| 98 | |
|---|
| 99 | $('.a-slideshow-controls li').hover(function(){ |
|---|
| 100 | $(this).addClass('over'); |
|---|
| 101 | },function(){ |
|---|
| 102 | $(this).removeClass('over'); |
|---|
| 103 | }); |
|---|
| 104 | |
|---|
| 105 | function previous() |
|---|
| 106 | { |
|---|
| 107 | var oldItem = $('#a-slideshow-item-<?php echo $id ?>-'+position); |
|---|
| 108 | |
|---|
| 109 | if (position >= 0) |
|---|
| 110 | { |
|---|
| 111 | position--; |
|---|
| 112 | if ( position < 0 ) { position = img_count; } |
|---|
| 113 | |
|---|
| 114 | var newItem = $('#a-slideshow-item-<?php echo $id ?>-'+position); |
|---|
| 115 | newItem.parents('.a-slideshow').css('height',newItem.height()); |
|---|
| 116 | newItem.fadeIn('slow'); |
|---|
| 117 | oldItem.hide(); |
|---|
| 118 | <?php if ($options['position']): ?> |
|---|
| 119 | setHead(position); |
|---|
| 120 | <?php endif ?> |
|---|
| 121 | } |
|---|
| 122 | interval(); |
|---|
| 123 | } |
|---|
| 124 | |
|---|
| 125 | function next() |
|---|
| 126 | { |
|---|
| 127 | var oldItem = $('#a-slideshow-item-<?php echo $id ?>-'+position); |
|---|
| 128 | |
|---|
| 129 | if (position <= img_count) |
|---|
| 130 | { |
|---|
| 131 | position++; |
|---|
| 132 | if ( position == img_count+1 ) { position = 0; } |
|---|
| 133 | |
|---|
| 134 | var newItem = $('#a-slideshow-item-<?php echo $id ?>-'+position); |
|---|
| 135 | newItem.parents('.a-slideshow').css('height',newItem.height()); |
|---|
| 136 | newItem.fadeIn('slow'); |
|---|
| 137 | oldItem.hide(); |
|---|
| 138 | <?php if ($options['position']): ?> |
|---|
| 139 | setHead(position); |
|---|
| 140 | <?php endif ?> |
|---|
| 141 | } |
|---|
| 142 | interval(); |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | var intervalTimeout = null; |
|---|
| 146 | function interval() |
|---|
| 147 | { |
|---|
| 148 | if (intervalTimeout) |
|---|
| 149 | { |
|---|
| 150 | clearTimeout(intervalTimeout); |
|---|
| 151 | } |
|---|
| 152 | if (intervalEnabled) |
|---|
| 153 | { |
|---|
| 154 | intervalTimeout = setTimeout(next, <?php echo $options['interval'] ?> * 1000); |
|---|
| 155 | window.aSlideshowIntervalTimeouts['<?php echo "a-$id" ?>'] = intervalTimeout; |
|---|
| 156 | } |
|---|
| 157 | } |
|---|
| 158 | interval(); |
|---|
| 159 | |
|---|
| 160 | }); |
|---|
| 161 | //]]> |
|---|
| 162 | </script> |
|---|
| 163 | <?php elseif (count($items) == 1): ?> |
|---|
| 164 | <script type="text/javascript" charset="utf-8"> |
|---|
| 165 | <?php // Make sure a single-image slideshow is not hidden entirely ?> |
|---|
| 166 | $(document).ready(function() { |
|---|
| 167 | $('#a-slideshow-item-<?php echo $id ?>-0').show().parents(".aSlideshow").addClass("single-image"); |
|---|
| 168 | }); |
|---|
| 169 | </script> |
|---|
| 170 | <?php endif ?> |
|---|