diff --git a/class/init.php b/class/init.php index 61c0845..2eb6ff4 100644 --- a/class/init.php +++ b/class/init.php @@ -21,7 +21,7 @@ * @since 2.5.5 Update: Stylesheets: increase speed and energy efficiency by tailoring stylesheets to the needs of the instance, thanks to @docteurfitness design contribution. * @since 2.5.5 Bugfix: Stylesheets: minify to shrink the carbon footprint, increase speed and implement best practice, thanks to @docteurfitness issue report. * @since 2.5.5 Bugfix: Libraries: optimize processes by loading external and internal scripts only if needed, thanks to @docteurfitness issue report. - * @since 2.5.6 Bugfix: Reference container: optional alternative expanding and collapsing without jQuery for use with hard links, thanks to @hopper87it issue report. + * @since 2.5.6 Bugfix: Reference container: optional alternative expanding and collapsing without jQuery for use with hard links, thanks to @hopper87it @pkverma99 issue reports. */ /** @@ -189,7 +189,7 @@ class MCI_Footnotes { /** * Enqueues the jQuery library registered by WordPress. * - * - Bugfix: Reference container: optional alternative expanding and collapsing without jQuery for use with hard links, thanks to @hopper87it issue report. + * - Bugfix: Reference container: optional alternative expanding and collapsing without jQuery for use with hard links, thanks to @hopper87it @pkverma99 issue reports. * * @since 2.5.6 * diff --git a/class/settings.php b/class/settings.php index 2856623..562e946 100644 --- a/class/settings.php +++ b/class/settings.php @@ -791,7 +791,7 @@ class MCI_Footnotes_Settings { /** * Settings container key to select the script mode for the reference container. * - * - Bugfix: Reference container: optional alternative expanding and collapsing without jQuery for use with hard links, thanks to @hopper87it issue report. + * - Bugfix: Reference container: optional alternative expanding and collapsing without jQuery for use with hard links, thanks to @hopper87it @pkverma99 issue reports. * * @since 2.5.6 * diff --git a/class/task.php b/class/task.php index 21acd02..4fae34f 100644 --- a/class/task.php +++ b/class/task.php @@ -7,7 +7,7 @@ * @since 1.5.0 * * - * @lastmodified 2021-02-19T2030+0100 + * @lastmodified 2021-02-20T0438+0100 * * @since 2.0.0 Bugfix: various. * @since 2.0.4 Bugfix: Referrers and backlinks: remove hard links to streamline browsing history, thanks to @theroninjedi47 bug report. @@ -79,7 +79,7 @@ * @since 2.5.4 Update: Reference container: Hard backlinks (optional): optional configurable tooltip hinting to use the backbutton instead, thanks to @theroninjedi47 bug report. * @since 2.5.4 Bugfix: Tooltips: fix display in Popup Maker popups by correcting a coding error. * @since 2.5.5 Bugfix: Process: fix numbering bug impacting footnote #2 with footnote #1 close to start, thanks to @rumperuu bug report, thanks to @lolzim code contribution. - * @since 2.5.6 Bugfix: Reference container: optional alternative expanding and collapsing without jQuery for use with hard links, thanks to @hopper87it issue report. + * @since 2.5.6 Bugfix: Reference container: optional alternative expanding and collapsing without jQuery for use with hard links, thanks to @hopper87it @pkverma99 issue reports. */ // If called directly, abort: @@ -828,7 +828,7 @@ class MCI_Footnotes_Task { * @since 2.2.5 * @date 2020-12-18T1113+0100 */ - // alternative tooltips: + // jQuery tooltips: if ( ! self::$a_bool_AlternativeTooltipsEnabled) { // tooltip position: @@ -838,13 +838,18 @@ class MCI_Footnotes_Task { } echo "}\r\n"; + // alternative tooltips: } else { echo "}\r\n"; - // position: + // dimensions: + $l_int_AlternativeTooltipWidth = intval( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_WIDTH ) ); echo ".footnote_tooltip.position {"; - echo " width: " . intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_WIDTH)) . 'px;'; + echo " width: " . $l_int_AlternativeTooltipWidth . 'px;'; + // set also as max-width wrt short tooltip shrinking: + echo " max-width: " . $l_int_AlternativeTooltipWidth . 'px;'; + // position: $l_str_AlternativePosition = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_POSITION); $l_int_OffsetX = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_X)); @@ -1650,6 +1655,21 @@ class MCI_Footnotes_Task { } else { $l_str_TooltipContent = ''; } + + /** + * Determine shrink width if alternative tooltips are enabled. + * + * @since 2.5.6 + */ + $l_str_TooltipStyle = ''; + if ( self::$a_bool_AlternativeTooltipsEnabled && self::$a_bool_TooltipsEnabled ) { + $l_int_TooltipLength = strlen( strip_tags( $l_str_TooltipContent ) ); + if ( $l_int_TooltipLength < 70 ) { + $l_str_TooltipStyle = ' style="width: '; + $l_str_TooltipStyle .= ( $l_int_TooltipLength * .7 ); + $l_str_TooltipStyle .= 'em;"'; + } + } // fill in 'templates/public/footnote.html': $l_obj_Template->replace( @@ -1664,6 +1684,7 @@ class MCI_Footnotes_Task { "index" => $l_int_Index, "after" => MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_AFTER), "anchor-element" => $l_str_ReferrerAnchorElement, + "style" => $l_str_TooltipStyle, "text" => $l_str_TooltipContent, ) ); @@ -2267,12 +2288,15 @@ class MCI_Footnotes_Task { /** * Select the reference container template according to the script mode. * - * - Bugfix: Reference container: optional alternative expanding and collapsing without jQuery for use with hard links, thanks to @hopper87it issue report. + * - Bugfix: Reference container: optional alternative expanding and collapsing without jQuery for use with hard links, thanks to @hopper87it @pkverma99 issue reports. * * @since 2.5.6 * * @reporter @hopper87it * @link https://wordpress.org/support/topic/footnotes-wp-rocket/ + * + * @reporter @pkverma99 + * @link https://wordpress.org/support/topic/footnotes-wp-rocket/#post-14076188 */ $l_str_ScriptMode = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE); diff --git a/footnotes.php b/footnotes.php index bfa5ac8..ef4848f 100755 --- a/footnotes.php +++ b/footnotes.php @@ -4,7 +4,7 @@ Plugin URI: https://wordpress.org/plugins/footnotes/ Description: time to bring footnotes to your website! footnotes are known from offline publishing and everybody takes them for granted when reading a magazine. Author: Mark Cheret - Version: 2.5.6d3 + Version: 2.5.6d4 Author URI: http://cheret.de/plugins/footnotes-2/ Text Domain: footnotes Domain Path: /languages @@ -18,10 +18,10 @@ * @since 2.1.4 * @since 2.5.3 (Hungarian) * @var str - * @lastmodified 2021-02-19T2055+0100 + * @lastmodified 2021-02-20T0438+0100 * @committer @pewgeuges */ -define( 'C_STR_FOOTNOTES_VERSION', '2.5.6d3' ); +define( 'C_STR_FOOTNOTES_VERSION', '2.5.6d4' ); /* LICENSE NOTICE diff --git a/readme.txt b/readme.txt index d5e79f1..d5ff8ee 100755 --- a/readme.txt +++ b/readme.txt @@ -78,7 +78,8 @@ Visit this swift write-up from a **footnotes** user by the name of **Southwest** == Changelog == = 2.5.6 = -- Bugfix: Reference container: optional alternative expanding and collapsing without jQuery for use with hard links, thanks to @hopper87it issue report. +- Bugfix: Reference container: optional alternative expanding and collapsing without jQuery for use with hard links, thanks to @hopper87it @pkverma99 issue reports. +- Bugfix: Alternative tooltips: shrink width to short content. - Update: Documentation: slightly revise / update the plugin’s welcome page on WordPress.org. = 2.5.5 = diff --git a/templates/public/footnote-alternative.html b/templates/public/footnote-alternative.html index 5eb081b..50c5c2b 100644 --- a/templates/public/footnote-alternative.html +++ b/templates/public/footnote-alternative.html @@ -18,6 +18,7 @@ id="footnote_plugin_tooltip_text_[[post_id]]_[[container_id]]_[[note_id]]" class="footnote_tooltip position hidden" onmouseout="footnoteTooltipHide('footnote_plugin_tooltip_text_[[post_id]]_[[container_id]]_[[note_id]]')" + [[style]] >[[text]] diff --git a/templates/public/js-reference-container.html b/templates/public/js-reference-container.html index dd5f274..d1ec848 100644 --- a/templates/public/js-reference-container.html +++ b/templates/public/js-reference-container.html @@ -4,14 +4,17 @@ * * @since 2.5.6 * @type object - * @lastmodified 2021-02-19T1545+0100 + * @lastmodified 2021-02-20T0252+0100 * - * - Bugfix: Reference container: optional alternative expanding and collapsing without jQuery for use with hard links, thanks to @hopper87it issue report. + * - Bugfix: Reference container: optional alternative expanding and collapsing without jQuery for use with hard links, thanks to @hopper87it @pkverma99 issue reports. * * @since 2.5.6 * * @reporter @hopper87it * @link https://wordpress.org/support/topic/footnotes-wp-rocket/ + * + * @reporter @pkverma99 + * @link https://wordpress.org/support/topic/footnotes-wp-rocket/#post-14076188 * * The heavy jQuery Core library from WordPress must not be deferred for * the jQuery reference container to work, and is detrimental to page speed.