Skip to content

Commit e0c55ea

Browse files
committed
Merge branch 'master' into dev/4.0
2 parents 75b3a6c + f19a354 commit e0c55ea

File tree

6 files changed

+33
-42
lines changed

6 files changed

+33
-42
lines changed

event/listener.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ public static function getSubscribedEvents()
6262
'paybas.recenttopics.sql_pull_topics_data' => 'modify_sql_array',
6363
'paybas.recenttopics.modify_tpl_ary' => 'display_topic_previews',
6464

65+
// Custom events for integration with Recent Topics NG
66+
'imcger.recenttopicsng.sql_pull_topics_data'=> 'modify_sql_array',
67+
'imcger.recenttopicsng.modify_tpl_ary' => 'display_topic_previews',
68+
6569
// Custom events for integration with Top Five
6670
'rmcgirr83.topfive.sql_pull_topics_data' => 'modify_sql_array',
6771
'rmcgirr83.topfive.modify_tpl_ary' => 'display_topic_previews',

styles/all/template/event/overall_footer_after.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
delay: {{ TOPICPREVIEW_DELAY }},
99
width: {{ TOPICPREVIEW_WIDTH }},
1010
drift: {{ TOPICPREVIEW_DRIFT }},
11-
position: {left: 35, top: 25},
12-
noavatar: '{{ T_THEME_PATH }}/images/no_avatar.gif'
11+
position: {left: 35, top: 25}
1312
});
1413
});
1514
</script>
Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
11
{% import '@vse_topicpreview/topicpreview_macro.html' as macro %}
2-
3-
{# display topic preview in view forum #}
4-
{% if topicrow.TOPIC_PREVIEW_FIRST_POST %}
5-
{{ macro.renderTopicPreview(topicrow) }}
6-
{% endif %}
7-
8-
{# display topic preview in search results #}
9-
{% if searchresults.TOPIC_PREVIEW_FIRST_POST %}
10-
{{ macro.renderTopicPreview(searchresults) }}
11-
{% endif %}
12-
13-
{# display topic preview in Similar Topics extension #}
14-
{% if similar.TOPIC_PREVIEW_FIRST_POST %}
15-
{{ macro.renderTopicPreview(similar) }}
16-
{% endif %}
17-
18-
{# display topic preview in Recent Topics extension #}
19-
{% if recent_topics.TOPIC_PREVIEW_FIRST_POST %}
20-
{{ macro.renderTopicPreview(recent_topics) }}
21-
{% endif %}
22-
23-
{# DEPRECTATED: @v2.2.1 display topic preview in Top Five extension #}
24-
{% if top_five_topic.TOPIC_PREVIEW_FIRST_POST %}
25-
{{ macro.renderTopicPreview(top_five_topic) }}
26-
{% endif %}
2+
{# Context variables:
3+
tpl block purpose
4+
--------- -------
5+
topicrow display topic preview in view forum
6+
searchresults display topic preview in search results
7+
similar display topic preview in Similar Topics extension
8+
recent_topics display topic preview in Recent Topics extension
9+
rtng display topic preview in Recent Topics NG extension
10+
top_five_topic display topic preview in Top Five extension - deprecated @v2.2.1
11+
#}
12+
{% for context in [topicrow, searchresults, similar, recent_topics, rtng, top_five_topic] %}
13+
{% if context.TOPIC_PREVIEW_FIRST_POST %}
14+
{{ macro.renderTopicPreview(context) }}
15+
{% endif %}
16+
{% endfor %}

styles/all/template/topicpreview.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
previewTimeout,
2424
previewContainer = $('<div id="topic_preview" class="topic_preview_container"></div>').css('width', settings.width).appendTo('body');
2525

26-
// Do not allow delay times less than 300ms to prevent tooltip madness
26+
// Do not allow delay times less than 300 ms to prevent tooltip madness
2727
settings.delay = Math.max(settings.delay, 300);
2828

2929
$('.topic_preview_avatar')
3030
// Add rtl class for right-to-left languages to avatar images
3131
.toggleClass('rtl', (settings.dir === 'rtl'))
3232
.children('img')
33-
.brokenImage({ replacement: settings.noavatar })
33+
.brokenImage({})
3434
;
3535

3636
// Display the topic preview tooltip
@@ -67,7 +67,7 @@
6767
// Pointer offset
6868
var pointerOffset = 8;
6969

70-
// Window bottom edge detection, invert topic preview if needed
70+
// Window bottom-edge detection, invert topic preview if needed
7171
var previewTop = obj.offset().top + settings.position.top,
7272
previewBottom = previewTop + previewContainer.height() + pointerOffset;
7373
previewContainer.toggleClass('invert', edgeDetect(previewBottom));
@@ -112,7 +112,7 @@
112112
obj.restoreTitles('dt').restoreTitles('dl'); // reinstate original title attributes
113113
};
114114

115-
// Check if y coordinate is within 50 pixels of bottom edge of browser window
115+
// Check if y coordinate is within 50 pixels of the bottom edge of a browser window
116116
var edgeDetect = function(y) {
117117
return (y >= ($(window).scrollTop() + $(window).height() - 50));
118118
};
@@ -122,7 +122,7 @@
122122
.on('mouseenter', showTopicPreview)
123123
.on('mouseleave', hideTopicPreview)
124124
.on('click', function() {
125-
// Remove topic preview immediately on click as failsafe
125+
// Remove the topic preview immediately on click as failsafe
126126
previewContainer.hide();
127127
// clear any existing timeouts
128128
if (previewTimeout) {
@@ -157,20 +157,16 @@
157157
});
158158

159159
setTimeout(function() {
160-
var test = new Image(); // Virgin image with no styles to affect dimensions
161-
test.src = image.src;
162-
163-
if (test.height === 0) {
160+
// Check if the image failed to load with fallback for older browsers
161+
var isIncomplete = image.complete !== undefined ? !image.complete : false;
162+
var hasNoHeight = image.naturalHeight !== undefined ? image.naturalHeight === 0 : image.height === 0;
163+
if (isIncomplete || hasNoHeight) {
164164
insertPlaceholder();
165165
}
166166
}, options.timeout);
167167

168168
function insertPlaceholder() {
169-
if (options.replacement) {
170-
image.src = options.replacement;
171-
} else {
172-
$(image).css('visibility', 'hidden');
173-
}
169+
$(image).replaceWith('<div class="topic_preview_no_avatar"></div>');
174170
}
175171
});
176172
},

tests/core/display_topic_preview_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class display_topic_preview_test extends base
1717

1818
/** @var array Avatar data to use in tests below */
1919
protected static $avatar_data = array(
20-
'src' => 'avatar.jpg',
20+
'src' => 'some-avatar.jpg',
2121
'width' => '60',
2222
'height' => '60',
2323
);

tests/event/listener_test.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public function test_getSubscribedEvents()
5656
'vse.similartopics.modify_topicrow',
5757
'paybas.recenttopics.sql_pull_topics_data',
5858
'paybas.recenttopics.modify_tpl_ary',
59+
'imcger.recenttopicsng.sql_pull_topics_data',
60+
'imcger.recenttopicsng.modify_tpl_ary',
5961
'rmcgirr83.topfive.sql_pull_topics_data',
6062
'rmcgirr83.topfive.modify_tpl_ary',
6163
), array_keys(\vse\topicpreview\event\listener::getSubscribedEvents()));

0 commit comments

Comments
 (0)