*

siken

  • ****
  • 136 posts
Limit of characters in the title of itempost
« on: March 05, 2019, 01:50:11 PM »
In veronika theme when you put the title of the publication, there was a counter of the characters that you had left.

In alpha theme when you exceed 40 characters, it lets you keep writing but gives an error in the publication because it has exceeded 40 characters.

You have to put a limit or a counter in the title, as in the other themes. This is basic, because people can not be in contact with the characters that are left to put in the title ...

*

MB Themes

Re: Limit of characters in the title of itempost
« Reply #1 on: March 05, 2019, 03:26:53 PM »
@alexandromt
We does not have to, but we will look if there is simple solution or not.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Marked as best answer by leales_org on March 06, 2019, 12:50:35 AM
*

siken

  • ****
  • 136 posts
Re: Limit of characters in the title of itempost
« Reply #2 on: March 06, 2019, 12:50:28 AM »
solved: insert this code into the itempost script...


Code: [Select]
      // TITLE REMAINING CHARACTERS
      var title_max = <?php echo osc_max_characters_per_title(); ?>;
      var check_inputs = $('.add_item .title input');

      check_inputs.attr('maxlength', title_max);
      check_inputs.after('<div class="title-max-char max-char"></div>');
      $('.title-max-char').html('&nbsp;»&nbsp;máximo:&nbsp;' + title_max + ' ' + '<?php echo osc_esc_js(__('caracteres...''veronika')); ?>');

      $('ul.tabbernav li a').live('click', function(){
        var title_length = 0;

        check_inputs.each(function(){
          if( $(this).val().length > title_length ) {
            title_length = $(this).val().length;
          }
        });

        var title_remaining = title_max - title_length;

        $('.title-max-char').html('&nbsp;»&nbsp;máximo:&nbsp;' + title_remaining + ' ' + '<?php echo osc_esc_js(__('caracteres...''veronika')); ?>');

        $('.title-max-char').removeClass('orange').removeClass('red');
        if(title_remaining/title_length <= 0.2 && title_remaining/title_length > 0.1) {
          $('.title-max-char').addClass('orange');
        } else if (title_remaining/title_length <= 0.1) {
          $('.title-max-char').addClass('red');
        }
      });

      check_inputs.keyup(function() {
        var title_length = $(this).val().length;
        var title_remaining = title_max - title_length;

        $('.title-max-char').html('<?php echo osc_esc_js(__('&nbsp;...quedan&nbsp;''alpha')); ?>' + title_remaining + ' ' + '<?php echo osc_esc_js(__('&nbsp;''alpha')); ?>');

        $('.title-max-char').removeClass('orange').removeClass('red');
        if(title_remaining/title_length <= 0.2 && title_remaining/title_length > 0.1) {
          $('.title-max-char').addClass('orange');
        } else if (title_remaining/title_length <= 0.1) {
          $('.title-max-char').addClass('red');
        }
      });

*

gnoe

  • **
  • 20 posts
Re: Limit of characters in the title of itempost
« Reply #3 on: March 07, 2019, 09:29:34 AM »
That code should be better added in a future theme update so we don't have to copy-paste on each theme update.
It would be helpful.
Aristotle: We are what we repeatedly do. Excellence, then, is not an act, but a habit.

*

piter

  • ****
  • 104 posts
Re: Limit of characters in the title of itempost
« Reply #4 on: March 07, 2019, 10:26:34 AM »

+1 for this to be added