Add a character counter for meta descriptions

3 years 2 weeks ago - 2 years 11 months ago #57501 by iamrobert
Do you wish your metadescription box had a countdown area? So it counts down how many characters you can add.





Add the following code to your administrator template:
//metadescription counter
jQuery(function($) {
$( "textarea#jform_metadesc" ).after( "<span id=\"summarychrs\">0</span>" );

function countChar(inobj, maxl, outobj) {
var isTextCounter = $('#jform_metadesc');
if (isTextCounter.length > 0) {
    var len = inobj.value.length;
    var msg = ' characters left';
    if (len >= maxl) {
        inobj.value = inobj.value.substring(0, maxl);
        $(outobj).text(0 + msg);
    } else {
        $(outobj).text(maxl - len + msg);
    }
}

}

$(document).ready(function(){

    //set up summary field character count
    countChar($('#jform_metadesc').get(0),160, '#summarychrs'); //show inital value on page load
    $('#jform_metadesc').keyup(function() {
        countChar(this, 160, '#summarychrs'); //set up on keyup event function
    });

});

});
//metadescription counter

Its still a WIP
Attachments:

Please Log in or Create an account to join the conversation.

3 years 2 weeks ago #57506 by micker
good idea !!!
maybe we can add same to description field

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

Please Log in or Create an account to join the conversation.

3 years 2 weeks ago #57507 by ggppdk
Hello

we can add this to description field and to textarea fields when HTML editor is not used


-- FLEXIcontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

3 years 2 weeks ago #57508 by iamrobert
Great!

However - I would keep it optional and not by default.

Please Log in or Create an account to join the conversation.

3 years 2 weeks ago #57524 by ggppdk
Hello

optional, but if a max-length is given and HTML editor is disabled, then i think
- it can be the default behaviour of the new parameter to display it, and optionally turn it off


-- FLEXIcontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
© 2018 Flexicontent. All Rights Reserved.