Skip to content
This repository was archived by the owner on Apr 24, 2024. It is now read-only.

Commit ed96e3d

Browse files
authored
playable event preview image, fixes fluxapps#19 (fluxapps#47)
1 parent e3f56bb commit ed96e3d

File tree

7 files changed

+42
-7
lines changed

7 files changed

+42
-7
lines changed

classes/Event/class.xoctEventRenderer.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,27 @@ public function insert(&$tpl, $variable, $value, $block_title = '') {
9191
*
9292
* @throws xoctException
9393
*/
94-
public function insertThumbnail(&$tpl, $block_title = 'thumbnail', $variable = 'THUMBNAIL') {
95-
$this->insert($tpl, $variable, $this->getThumbnailHTML(), $block_title);
94+
public function insertPreviewImage(&$tpl, $block_title = 'preview_image', $variable = 'PREVIEW_IMAGE') {
95+
$this->insert($tpl, $variable, $this->getPreviewImageHTML(), $block_title);
9696
}
9797

98+
/**
99+
* @return string
100+
* @throws xoctException
101+
*/
102+
public function getPreviewImageHTML() {
103+
$preview_image_tpl = self::plugin()->template('default/tpl.event_preview_image.html');
104+
$preview_image_tpl->setVariable('ID', $this->event->getIdentifier());
105+
$preview_image_tpl->setVariable('THUMBNAIL', $this->getThumbnailHTML());
106+
return $preview_image_tpl->get();
107+
}
108+
109+
/**
110+
* @return string
111+
*/
112+
public function getPreviewLink() {
113+
return 'data-preview_link="' . $this->event->getIdentifier() . '"';
114+
}
98115

99116
/**
100117
* @return string
@@ -135,6 +152,7 @@ public function getPlayerLinkHTML($button_type = 'btn-info') {
135152
$link_tpl = self::plugin()->template('default/tpl.player_link.html');
136153
$link_tpl->setVariable('LINK_TEXT', self::plugin()->translate($this->event->isLiveEvent() ? 'player_live' : 'player', self::LANG_MODULE));
137154
$link_tpl->setVariable('BUTTON_TYPE', $button_type);
155+
$link_tpl->setVariable('PREVIEW_LINK', $this->getPreviewLink());
138156
$link_tpl->setVariable('TARGET', '_blank');
139157
if (PluginConfig::getConfig(PluginConfig::F_USE_MODALS)) {
140158
$modal = $this->getPlayerModal();

classes/Event/class.xoctEventTableGUI.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public function fillRow($a_set)
145145
$event = $a_set['object'] ?: $this->event_repository->find($a_set['identifier']);
146146
$renderer = new xoctEventRenderer($event, $this->objectSettings);
147147

148-
$renderer->insertThumbnail($this->tpl, null);
148+
$renderer->insertPreviewImage($this->tpl, null);
149149
$renderer->insertPlayerLink($this->tpl);
150150

151151
if (!$this->objectSettings->getStreamingOnly()) {

templates/default/events.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
margin: auto;
1010
width: 100%;
1111
height: 100%;
12+
cursor: pointer;
1213
}
1314

1415
.tblrow1.xoct-state-running td {

templates/default/events.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,20 @@ var xoctEvent = {
3232
outFunc: function(element) {
3333
var tooltip = $(element).find('span.xoct_tooltiptext')[0];
3434
tooltip.innerHTML = this.lang['tooltip_copy_link'];
35+
},
36+
37+
previewPlay: function(element, event) {
38+
event.preventDefault();
39+
var play_link_obj = $('a[data-preview_link="' + $(element).data('id') + '"]');
40+
if (play_link_obj.length) {
41+
var play_link = play_link_obj[0];
42+
var href = $(play_link).attr('href');
43+
if (href && href != '#') {
44+
var target = $(play_link).attr('target') ? $(play_link).attr('target') : '_blank';
45+
window.open(href, target);
46+
} else {
47+
$(play_link).click();
48+
}
49+
}
3550
}
3651
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="xoct_preview_image" onclick="xoctEvent.previewPlay(this, event)" data-id="{ID}">
2+
{THUMBNAIL}
3+
</div>

templates/default/tpl.events.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<tr class="{CSS_ROW} {ADDITIONAL_CSS}">
22
<td class="std small">
3-
<div class="xoct_preview_image">
4-
{THUMBNAIL}
5-
</div>
3+
{PREVIEW_IMAGE}
64
</td>
75
<td class="std small">
86
<div class="btn-group-vertical" role="group" >
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<a href="{LINK_URL}" target="{TARGET}" class="btn {BUTTON_TYPE}" {MODAL_LINK}>{LINK_TEXT}</a>{MODAL}
1+
<a href="{LINK_URL}" target="{TARGET}" class="btn {BUTTON_TYPE}" {PREVIEW_LINK} {MODAL_LINK}>{LINK_TEXT}</a>{MODAL}

0 commit comments

Comments
 (0)