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

Commit ababd77

Browse files
author
Matthias Pfefferle
committed
unobtrusive javascript
1 parent cbe6a4d commit ababd77

File tree

4 files changed

+29
-14
lines changed

4 files changed

+29
-14
lines changed

css/semantic-linkbacks.css

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@
1313
display: none;
1414
}
1515

16+
.mention-list .toggle-additional-facepiles {
17+
display: inline-block;
18+
text-align: center;
19+
height: 64px;
20+
width: 64px;
21+
line-height: 1.5;
22+
font-size: 32px;
23+
cursor: pointer;
24+
}
25+
1626
.mention-list li img {
1727
height: 64px;
1828
width: 64px;
@@ -31,5 +41,5 @@ li.emoji-reaction {
3141
}
3242

3343
.reactions {
34-
clear: both;
44+
clear: both;
3545
}

includes/functions.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,7 @@ function list_linkbacks( $args, $comments ) {
135135

136136
foreach ( $comments as $i => $comment ) {
137137
if ( $fold_at && $i == $fold_at ) {
138-
$return .= sprintf( '<li id="%2$s" class="single-mention mention-ellipsis">
139-
<h3> &nbsp;
140-
<a href="" onclick="document.getElementById(\'%1$s\').style.display = \'inline\';
141-
document.getElementById(\'%2$s\').style.display = \'none\';
142-
return false;">...</a>
143-
</h3>
144-
</li>
145-
<span id="%1$s" style="display: none">',
146-
$fold_id, $ellipsis_id );
138+
$classes .= ' additional-facepile';
147139
}
148140

149141
// If it's an emoji reaction, overlay the emoji.
@@ -179,7 +171,7 @@ function list_linkbacks( $args, $comments ) {
179171
}
180172

181173
if ( $fold_at && count( $comments ) > $fold_at ) {
182-
$return .= '</span>';
174+
$return .= '<li class="toggle-additional-facepiles">&hellip;</li>';
183175
}
184176

185177
$return .= sprintf( '</%1$s>', $r['style'] );

js/semantic-linkbacks.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
jQuery( document ).ready( function() {
2+
jQuery( '.additional-facepile' ).hide();
3+
4+
jQuery( '.toggle-additional-facepiles' ).click( function() {
5+
jQuery( this ).parent( 'ul' ).find( '.additional-facepile' ).toggle();
6+
} );
7+
} );

semantic-linkbacks.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static function init() {
4242
require_once( dirname( __FILE__ ) . '/includes/class-linkbacks-mf2-handler.php' );
4343
add_action( 'init', array( 'Linkbacks_MF2_Handler', 'init' ) );
4444

45-
add_action( 'wp_enqueue_scripts', array( 'Semantic_Linkbacks_Plugin', 'style_load' ) );
45+
add_action( 'wp_enqueue_scripts', array( 'Semantic_Linkbacks_Plugin', 'enqueue_scripts' ) );
4646

4747
remove_filter( 'webmention_comment_data', array( 'Webmention_Receiver', 'default_title_filter' ), 21 );
4848
remove_filter( 'webmention_comment_data', array( 'Webmention_Receiver', 'default_content_filter' ), 22 );
@@ -125,8 +125,14 @@ public static function discussion_settings() {
125125
load_template( plugin_dir_path( __FILE__ ) . 'templates/discussion-settings.php' );
126126
}
127127

128-
129-
public static function style_load() {
128+
/**
129+
* Add CSS and JavaScript
130+
*/
131+
public static function enqueue_scripts() {
130132
wp_enqueue_style( 'semantic-linkbacks-css', plugin_dir_url( __FILE__ ) . 'css/semantic-linkbacks.css', array(), self::$version );
133+
134+
if ( is_singular() && 0 != get_option( 'semantic_linkbacks_facepiles_fold_limit', 8 ) ) {
135+
wp_enqueue_script( 'semantic-linkbacks', plugin_dir_url( __FILE__ ) . 'js/semantic-linkbacks.js', array( 'jquery' ), self::$version, true );
136+
}
131137
}
132138
}

0 commit comments

Comments
 (0)