From cbcad078af4f3f083b111b5c6149bb0688d79305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=B3na=20Lore?= Date: Sun, 14 Feb 2016 20:55:27 +0100 Subject: [PATCH] Issue #369: Plugin Manager: Plugin Description is corrupted if there's a long discription and you click 'More' --- e107_handlers/form_handler.php | 21 ++--- e107_languages/English/English.php | 1 + e107_web/js/core/all.jquery.js | 121 ++++++++++++++++++----------- 3 files changed, 84 insertions(+), 59 deletions(-) diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 5a0fecf45..e7f11b8c4 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -3477,9 +3477,9 @@ class e_form { return $this->renderInline($field,$id,$attributes['title'],$value,substr($value,0,50)."...",'textarea'); //FIXME. } - - - $expand = '...'; + + + $expand = '...'; $toexpand = false; if($attributes['type'] == 'bbarea' && !isset($parms['bb'])) $parms['bb'] = true; //force bb parsing for bbareas $elid = trim(str_replace('_', '-', $field)).'-'.$id; @@ -3489,17 +3489,11 @@ class e_form $ttl = vartrue($parms['expand']); if($ttl == 1) { - $ttl = $expand.""; - $ttl1 = ""; - } - else - { - $ttl1 = null; + $dataAttr = "data-text-more='" . LAN_MORE . "' data-text-less='" . LAN_LESS . "'"; + $ttl = $expand.""; } $expands = ''.defset($ttl, $ttl).""; - $contracts = ''.defset($ttl1, $ttl1).""; - } $oldval = $value; @@ -3517,9 +3511,8 @@ class e_form if($toexpand) { // force hide! TODO - core style .expand-c (expand container) - // TODO: Hide 'More..' button when text fully displayed. - $value .= ''; - $value .= $expands; // 'More..' button. Keep it at the bottom so it does't cut the sentence. + $value .= ''; + $value .= varset($expands); // 'More..' button. Keep it at the bottom so it does't cut the sentence. } diff --git a/e107_languages/English/English.php b/e107_languages/English/English.php index b73c98257..c067b6117 100644 --- a/e107_languages/English/English.php +++ b/e107_languages/English/English.php @@ -50,6 +50,7 @@ define("LAN_EDIT","Edit"); define("LAN_DELETE","Delete"); define("LAN_DEFAULT","Default"); define("LAN_MORE", "More.."); +define("LAN_LESS", "..Less"); define("LAN_READ_MORE", "Read more.."); define("LAN_GOPAGE", "Go to page"); define("LAN_GOTOPAGEX", "Go to page [x]"); diff --git a/e107_web/js/core/all.jquery.js b/e107_web/js/core/all.jquery.js index d2dfc0bd9..434101af6 100644 --- a/e107_web/js/core/all.jquery.js +++ b/e107_web/js/core/all.jquery.js @@ -326,6 +326,82 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}}; } }; + /** + * Behavior to attach a click event to elements with .e-expandit class. + * + * @type {{attach: Function}} + */ + e107.behaviors.eExpandIt = { + attach: function (context, settings) + { + $(context).find('.e-expandit').once('e-expandit').each(function () + { + // default 'toggle'. + $(this).click(function () + { + var $this = $(this); + var href = ($this.is("a")) ? $this.attr("href") : ''; + var $button = $this.find('button'); + + if($button.length > 0) + { + var textMore = $button.attr('data-text-more'); + var textLess = $button.attr('data-text-less'); + + if(textLess && textMore) + { + if($button.html() == textMore) + { + $this.find('.e-expandit-ellipsis').hide(); + $button.html(textLess); + } + else + { + $this.find('.e-expandit-ellipsis').show(); + $button.html(textMore); + } + } + } + + if((href === "#" || href == "") && $this.attr("data-target")) + { + var select = $this.attr("data-target").split(','); // support multiple targets (comma separated) + + $(select).each(function () + { + $('#' + this).slideToggle("slow"); + }); + + if($this.attr("data-return") === 'true') + { + return true; + } + + return false; + } + + + if(href === "#" || href == "") + { + var idt = $(this).nextAll("div"); + $(idt).slideToggle("slow"); + return true; + } + + $(href).slideToggle('slow', function () + { + if($(this).is(':visible')) + { + $(this).css('display', 'initial'); + } + }); + + return false; + }); + }); + } + }; + /** * Dynamic next/prev. * @@ -439,52 +515,7 @@ $(document).ready(function() }); } }); - - - // default 'toggle'. - $(".e-expandit").click(function () { - - var href = ($(this).is("a")) ? $(this).attr("href") : ''; - - if((href === "#" || href == "") && $(this).attr("data-target")) - { - select = $(this).attr("data-target").split(','); // support multiple targets (comma separated) - - $(select).each( function() { - - $('#'+ this).slideToggle("slow"); - }); - if($(this).attr("data-return")==='true') - { - return true; - } - - - return false; - } - - - - if(href === "#" || href == "") - { - idt = $(this).nextAll("div"); - $(idt).slideToggle("slow"); - return true; - } - - - //var id = $(this).attr("href"); - $(href).slideToggle("slow"); - - return false; - }); - - - - - - // On $(".e-expandit-on").click(function () {