From 32618817d15d4267e77e7a01ed31be510a33490a Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 12 Aug 2021 11:51:55 -0700 Subject: [PATCH] Character counting display added to meta description on admin News and Page inputs. --- e107_admin/cpage.php | 2 +- e107_admin/newspost.php | 2 +- e107_handlers/form_handler.php | 5 +++++ e107_languages/English/admin/lan_admin.php | 1 + e107_web/js/core/admin.jquery.js | 22 ++++++++++++++++++++++ 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/e107_admin/cpage.php b/e107_admin/cpage.php index 03a38787b..b7ac42473 100644 --- a/e107_admin/cpage.php +++ b/e107_admin/cpage.php @@ -600,7 +600,7 @@ class page_admin_ui extends e_admin_ui 'page_password' => array('title'=> LAN_PASSWORD, 'tab' => 1, 'type' => 'text', 'data'=>'str', 'width' => 'auto', 'writeParms'=>array('password'=>1, 'nomask'=>1, 'size' => 40, 'class' => 'tbox e-password', 'generate' => 1, 'strength' => 1, 'required'=>0)), 'page_sef' => array('title'=> LAN_SEFURL, 'tab' => 1, 'type' => 'text', 'batch'=>true, 'data'=>'str', 'inline'=>true, 'width' => 'auto', 'writeParms'=>'size=xxlarge&sef=page_title'), 'page_metakeys' => array('title'=> LAN_KEYWORDS, 'tab' => 1, 'type' => 'tags', 'data'=>'str', 'width' => 'auto'), - 'page_metadscr' => array('title'=> CUSLAN_11, 'tab' => 1, 'type' => 'text', 'data'=>'str', 'width' => 'auto', 'writeParms'=>'size=xxlarge'), + 'page_metadscr' => array('title'=> CUSLAN_11, 'tab' => 1, 'type' => 'textarea', 'data'=>'str', 'width' => 'auto', 'writeParms'=>array('size'=>'xxlarge', 'rows'=>2, 'maxlength'=>155)), 'page_metarobots' => array('title' => LAN_ROBOTS, 'tab'=>1, 'type' => 'dropdown', 'data'=>'safestr', 'batch'=>true, 'inline'=>true, 'readParms'=>array('type'=>'checkboxes'), 'width' => 'auto', 'thclass' => 'left', 'class' => 'left', 'nosort' => false, 'filter'=>true), 'page_order' => array('title'=> LAN_ORDER, 'tab' => 1, 'type' => 'number', 'width' => 'auto', 'inline'=>true), diff --git a/e107_admin/newspost.php b/e107_admin/newspost.php index 6f1155e4a..e23a767c2 100644 --- a/e107_admin/newspost.php +++ b/e107_admin/newspost.php @@ -454,7 +454,7 @@ class news_admin_ui extends e_admin_ui 'news_extended' => array('title' => "", 'type' => null, 'data'=>'str', 'tab'=>0, 'nolist'=>true, 'noedit'=>true, 'writeParms'=>'nolabel=1', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), 'news_meta_keywords' => array('title' => LAN_KEYWORDS, 'type' => 'tags', 'data'=>'safestr', 'filter'=>true, 'tab'=>1, 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), - 'news_meta_description' => array('title' => LAN_DESCRIPTION,'type' => 'textarea', 'data'=>'safestr','filter'=>true, 'tab'=>1, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'writeParms'=>array('size'=>'xxlarge')), + 'news_meta_description' => array('title' => LAN_DESCRIPTION,'type' => 'textarea', 'data'=>'safestr','filter'=>true, 'tab'=>1, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'writeParms'=>array('size'=>'xxlarge', 'maxlength'=>155, 'rows'=>2)), 'news_meta_robots' => array('title' => LAN_ROBOTS, 'type' => 'dropdown', 'data'=>'safestr', 'tab'=>1, 'inline'=>true, 'readParms'=>array('type'=>'checkboxes'), 'writeParms'=>array('multiple'=>1), 'width' => 'auto', 'thclass' => 'left', 'class' => 'left', 'nosort' => false, 'batch'=>true, 'filter'=>true), 'news_sef' => array('title' => LAN_SEFURL, 'type' => 'text', 'batch'=>1, 'data'=>'str', 'tab'=>1, 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'writeParms'=>array('size'=>'xxlarge', 'show'=>1, 'sef'=>'news_title')), diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index c3f18f514..02f6ee070 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -6327,6 +6327,11 @@ var_dump($select_options);*/ $parms['size'] = 'xxlarge'; } + if(!empty($parms['maxlength']) && empty($parms['post'])) + { + $charMsg = e107::getParser()->lanVars(defset('LAN_X_CHARS_REMAINING', '[x] chars remaining'),"".$parms['maxlength'].""); + $parms['post'] = ""; + } $text .= vartrue($parms['pre']).$this->textarea($key, $value, vartrue($parms['rows'], 5), vartrue($parms['cols'], 40), vartrue($parms['__options'],$parms), varset($parms['counter'], false)).vartrue($parms['post']); $ret = $text; diff --git a/e107_languages/English/admin/lan_admin.php b/e107_languages/English/admin/lan_admin.php index f4ab9d4ec..2e43cdd39 100644 --- a/e107_languages/English/admin/lan_admin.php +++ b/e107_languages/English/admin/lan_admin.php @@ -582,4 +582,5 @@ define("LAN_ROBOTS_NOIMAGE", "Prevent search engines from indexing images of thi define("LAN_NAVIGATION", "Navigation"); define("LAN_NAVIGATION_LINKS", "Navigation Links"); define("LAN_PAGINATION", "Pagination"); +define("LAN_X_CHARS_REMAINING", "[x] chars. remaining"); diff --git a/e107_web/js/core/admin.jquery.js b/e107_web/js/core/admin.jquery.js index 962357b06..a7279debd 100644 --- a/e107_web/js/core/admin.jquery.js +++ b/e107_web/js/core/admin.jquery.js @@ -183,6 +183,28 @@ $(document).ready(function() $(this).html(orig + spin); }); + $('textarea').on("input", function(){ + + if($(this).attr("maxlength") === undefined) + { + return; + } + + var maxlength = $(this).attr("maxlength"); + var currentLength = $(this).val().length; + var countID = $(this).attr('id') + '-char-count'; + + if( currentLength >= maxlength ) + { + $('#'+ countID + ' span').text('0'); + } + else + { + $('#'+ countID).show(); + $('#'+ countID + ' span').text(maxlength - currentLength); + } + }); + $('#e-modal-submit').click(function () {