This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
*

siken

  • ****
  • 138 posts
How can it be done so that when you enter the publication form, the choice of the type of publication that is displayed when you press the colored icons is automatically opened?

*

MB Themes

Re: When posting that directly shows the choice of the type of publication
« Reply #1 on: December 19, 2018, 11:10:38 PM »
Via jquery add click event on button.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

siken

  • ****
  • 138 posts
Re: When posting that directly shows the choice of the type of publication
« Reply #2 on: December 19, 2018, 11:39:19 PM »
Where I put this?:

Code: [Select]
jQuery(function(){
   jQuery().click();
});


For open it automatically when the user post an ad...


This is my script in item-post.php:

Code: [Select]
  <script type="text/javascript">
    // HIDE THEME EXTRA FIELDS (Transaction, Condition, Status) ON EXCLUDED CATEGORIES

    var catExtraVeronikaHide = new Array();
    <?php 
      $e_array 
veronika_extra_fields_hide();

      if(!empty(
$e_array) && count($e_array) > 0) {
        foreach(
$e_array as $e) {
          if(
is_numeric($e)) {
            echo 
'catExtraVeronikaHide[' $e '] = 1;';
          }
        }
      }
    
?>



    <?php if(osc_is_web_user_logged_in() ) { ?>
      // SET READONLY FOR EMAIL AND NAME FOR LOGGED IN USERS
      $('input[name="contactName"]').attr('readonly', true);
      $('input[name="contactEmail"]').attr('readonly', true);
    <?php ?>


    // LANGUAGE TABS
    tabberAutomatic();



    // JAVASCRIPT FOR PRICE ALTERNATIVES
    $(document).ready(function(){
      $('input#price').attr('autocomplete', 'off');         // Disable autocomplete for price field
      $('input#price').attr('placeholder', '<?php echo osc_esc_js(__('Price''veronika')); ?>');         

     
      $('body').on('click change', '.simple-price-type .option, .simple-price-type > select.text', function() {

        if( $('.simple-price-type > select.text').length ) {
          var type = $(this).val();
        } else {
          var type = $(this).attr('data-id');
        }

        if(type == 1 || type == 2) {
          $('.add_item .price-wrap .enter').addClass('disabled');
          $('.add_item .price-wrap .enter input#price').attr('readonly', true).attr('placeholder', '');;
          $('.add_item .price-wrap .enter .simple-select').addClass('disabled');

          if(type == 1) {
            $('input#price').val("0");
          } else {
            $('input#price').val("");
          }

        } else {
          $('.add_item .price-wrap .enter').removeClass('disabled');
          $('.add_item .price-wrap .enter input#price').attr('readonly', false).attr('placeholder', '<?php echo osc_esc_js(__('Price''veronika')); ?>');;
          $('.add_item .price-wrap .enter .simple-select').removeClass('disabled');
          $('input#price').val("");
        }
      });
    });


    // If no category loaded at start, hide hook section
    if( $('#catId').val() != "" && parseInt($('#catId').val()) > 0 ) {
      $('fieldset.hooks').show(0);
      $('span.total-steps').text('3');
    }


    // Trigger click when category selected via flat category select
    $('body').on('click change', 'input[name="catId"], select#catId', function() {
      var cat_id = $(this).val();
      var url = '<?php echo osc_base_url(); ?>index.php';
      var result = '';

      if(cat_id != '' && cat_id != 0) {
        if(catPriceEnabled[cat_id] == 1) {
          $(".add_item .price-wrap").fadeIn(200);
        } else {
          $(".add_item .price-wrap").fadeOut(200);
          $('#price').val('') ;
        }

        if(catExtraVeronikaHide[cat_id] == 1) {
          $(".add_item .status-wrap").fadeOut(200);
          $('input[name="sTransaction"], input[name="sCondition"]').val('');
          $('#sTransaction option, #sCondition option').prop('selected', function() {
            return this.defaultSelected;
          });

          $('.simple-transaction span.text span').text($('.simple-transaction .list .option.bold').text());
          $('.simple-condition span.text span').text($('.simple-condition .list .option.bold').text());
          $('.simple-transaction .list .option, .simple-condition .list .option').removeClass('selected');
          $('.simple-transaction .list .option.bold, .simple-condition .list .option.bold').addClass('selected');

        } else {
          $(".add_item .status-wrap").fadeIn(200);
        }


        $.ajax({
          type: "POST",
          url: url,
          data: 'page=ajax&action=runhook&hook=item_form&catId=' + cat_id,
          dataType: 'html',
          success: function(data){
            $("#plugin-hook").html(data);

            if (data.indexOf("input") >= 0 || data.indexOf("select") >= 0 || data.indexOf("textarea") >= 0) {

              // There are some plugins hooked
              $('fieldset.hooks').show(0);
              $('span.total-steps').text('3');

            } else {

              // There are no plugins hooked
              $('fieldset.hooks').hide(0);
              $('span.total-steps').text('2');

            }
          }
        });
      }
    });



    // ADD CAMERA ICON TO PICTURE BOX
    $(document).ready(function(){
      setInterval(function(){
        $('input[name="qqfile"]').prop('accept', 'image/*');
        $("img[src$='uploads/temp/']").closest('.qq-upload-success').remove();
       
        if( !$('#photos > .qq-upload-list > li').length ) {
          $('#photos > .qq-upload-list').remove();
          $('#photos > h3').remove();
        }
      }, 250);
     
      $('#photos .qq-upload-button > div').remove();
      $('#photos .qq-upload-button').append('<div class="sample-box-wrap"></div>');

      for(i = 0; i < 1; i++) { 
        $('#photos .qq-upload-button .sample-box-wrap').append('<div class="sample-box tr1"><div class="ins tr1"><i class="fa fa-camera tr1"></i></i></div></div>');
      }

      $('#photos .qq-upload-button .sample-box-wrap').live('click', function(){
        $('#photos .qq-upload-button input').click();
      });




      // 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(title_max + ' ' + '<?php echo osc_esc_js(__('more''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(title_remaining + ' ' + '<?php echo osc_esc_js(__('more''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(title_remaining + ' ' + '<?php echo osc_esc_js(__('more''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');
        }
      });



      // DESCRIPTION REMAINING CHARACTERS
      var desc_max = <?php echo osc_max_characters_per_description(); ?>;
      var check_textareas = $('');

      check_textareas.attr('maxlength', desc_max);
      check_textareas.after('<div class="desc-max-char max-char"></div>');
      $('.desc-max-char').html(desc_max + ' ' + '<?php echo osc_esc_js(__('more''veronika')); ?>');

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

        check_textareas.each(function(){
          if( $(this).val().length > desc_length ) {
            desc_length = $(this).val().length;
          }
        });

        var desc_remaining = desc_max - desc_length;

        $('.desc-max-char').html(desc_remaining + ' ' + '<?php echo osc_esc_js(__('more''veronika')); ?>');

        $('.desc-max-char').removeClass('orange').removeClass('red');

        if(desc_remaining/desc_length <= 0.3 && desc_remaining/desc_length > 0.15) {
          $('.desc-max-char').addClass('orange');
        } else if (desc_remaining/desc_length <= 0.15) {
          $('.desc-max-char').addClass('red');
        }
      });

      check_textareas.keyup(function() {
        var desc_length = $(this).val().length;
        var desc_remaining = desc_max - desc_length;

        $('.desc-max-char').html(desc_remaining + ' ' + '<?php echo osc_esc_js(__('more''veronika')); ?>');

        $('.desc-max-char').removeClass('orange').removeClass('red');
        if(desc_remaining/desc_length <= 0.3 && desc_remaining/desc_length > 0.15) {
          $('.desc-max-char').addClass('orange');
        } else if (desc_remaining/desc_length <= 0.15) {
          $('.desc-max-char').addClass('red');
        }
      });
    });


    // CATEGORY CHECK IF PARENT
    <?php if(!osc_selectable_parent_categories()) { ?>
      $(document).ready(function(){
        if(typeof window['categories_' + $('#catId').val()] !== 'undefined'){
          if(eval('categories_' + $('#catId').val()) != '') {
            $('#catId').val('');
          }
        }
      });

      $('#catId').live('change', function(){
        if(typeof window['categories_' + $(this).val()] !== 'undefined'){
          if(eval('categories_' + $(this).val()) != '') {
            $(this).val('');
          }
        }
      });
    <?php ?>



    // Set forms to active language
    $(document).ready(function(){

      var post_timer = setInterval(veronika_check_lang, 250);

      function veronika_check_lang() {
        if($('.tabbertab').length > 1 && $('.tabbertab.tabbertabhide').length) {
          var l_active = veronikaCurrentLocale;
          l_active = l_active.trim();

          $('.tabbernav > li > a:contains("' + l_active + '")').click();

          clearInterval(post_timer);
          return;
        }
      }



      // Code for form validation
      $("form[name=item]").validate({
        rules: {
          "title[<?php echo osc_current_user_locale(); ?>]": {
            required: true,
            minlength: 3
          },

          "description[<?php echo osc_current_user_locale(); ?>]": {
            required: false,
            minlength: 5
          },

          <?php if(strpos($required_fields'location') !== true) { ?>
          term: {
            required: true,
          },
          <?php ?>


          <?php if(strpos($required_fields'country') !== true) { ?>
          countryId: {
            required: true,
          },
          <?php ?>

          <?php if(strpos($required_fields'region') !== false) { ?>
          regionId: {
            required: false,
          },
          <?php ?>

          <?php if(strpos($required_fields'city') !== false) { ?>
          cityId: {
            required: false,
          },
          <?php ?>

          <?php if(function_exists('ir_get_min_img')) { ?>
          ir_image_check: {
            required: true,
            min: <?php echo ir_get_min_img(); ?>
          },
          <?php ?>

          catId: {
            required: false,
            digits: false
          },

          "photos[]": {
            accept: "png,gif,jpg,jpeg"
          },

          <?php if(strpos($required_fields'name') !== false) { ?>
          contactName: {
            required: false,
            minlength: 3
          },
          <?php ?>

          <?php if(strpos($required_fields'phone') !== false) { ?>
          sPhone: {
            required: false,
            minlength: 6,
            maxlength: 15
          },
          <?php ?>

          contactEmail: {
            required: true,
            email: true
          }
        },

        messages: {
          "title[<?php echo osc_current_user_locale(); ?>]": {
            required: '<?php echo osc_esc_js(__('Title: this field is required.''veronika')); ?>',
            minlength: '<?php echo osc_esc_js(__('Title: enter at least 3 characters.''veronika')); ?>'
          },

          "description[<?php echo osc_current_user_locale(); ?>]": {
            required: '<?php echo osc_esc_js(__('Description: this field is required.''veronika')); ?>',
            minlength: '<?php echo osc_esc_js(__('Description: enter at least 10 characters.''veronika')); ?>'
          },

          <?php if(strpos($required_fields'location') !== false) { ?>
          term: {
            required: '<?php echo osc_esc_js(__('Location: select country, region or city.''veronika')); ?>',
            minlength: '<?php echo osc_esc_js(__('Location: enter at least 3 characters to get list.''veronika')); ?>'
          },
          <?php ?>

          <?php if(strpos($required_fields'country') !== false) { ?>
          countryId: {
            required: '<?php echo osc_esc_js(__('Location: select country from location field.''veronika')); ?>'
          },
          <?php ?>

          <?php if(strpos($required_fields'region') !== false) { ?>
          regionId: {
            required: '<?php echo osc_esc_js(__('Location: select region from location field.''veronika')); ?>'
          },
          <?php ?>

          <?php if(strpos($required_fields'city') !== false) { ?>
          cityId: {
            required: '<?php echo osc_esc_js(__('Location: select city from location field.''veronika')); ?>'
          },
          <?php ?>

          <?php if(function_exists('ir_get_min_img')) { ?>
          ir_image_check: {
            required: '<?php echo osc_esc_js(__('Pictures: you need to upload pictures.''veronika')); ?>',
            min: '<?php echo osc_esc_js(__('Pictures: upload at least.') . ' ' ir_get_min_img() . ' ' __('picture(s).')); ?>'
          },
          <?php ?>

          catId: '<?php echo osc_esc_js(__('Category: this field is required.''veronika')); ?>',

          "photos[]": {
             accept: '<?php echo osc_esc_js(__('Photo: must be png,gif,jpg,jpeg.''veronika')); ?>'
          },

          <?php if(strpos($required_fields'phone') !== false) { ?>
          sPhone: {
            required: '<?php echo osc_esc_js(__('Phone: this field is required.''veronika')); ?>',
            minlength: "<?php echo osc_esc_js(__('Phone: enter at least 6 characters.')); ?>",
            maxlength: "<?php echo osc_esc_js(__('Phone: max 15 characters.')); ?>"
          },
          <?php ?>

          <?php if(strpos($required_fields'name') !== false) { ?>
          contactName: {
            required: '<?php echo osc_esc_js(__('Your Name: this field is required.''veronika')); ?>',
            minlength: '<?php echo osc_esc_js(__('Your Name: enter at least 3 characters.')); ?>'
          },
          <?php ?>

          contactEmail: {
            required: '<?php echo osc_esc_js(__('Email: this field is required.''veronika')); ?>',
            email: '<?php echo osc_esc_js(__('Email: invalid format of email address.''veronika')); ?>'
          }
        },

        ignore: ":disabled",
        ignoreTitle: false,
        errorLabelContainer: "#error_list",
        wrapper: "li",
        invalidHandler: function(form, validator) {
          $('html,body').animate({ scrollTop: $('h1').offset().top }, { duration: 250, easing: 'swing'});
        },
        submitHandler: function(form){
          $('button[type=submit], input[type=submit]').attr('disabled', 'disabled');
          form.submit();
        }
      });
    });
  </script>

« Last Edit: December 20, 2018, 12:51:44 AM by alexandromt »

*

siken

  • ****
  • 138 posts
Re: When posting that directly shows the choice of the type of publication
« Reply #3 on: December 20, 2018, 01:53:33 AM »
Via jquery add click event on button.



Maybe this:

      $('#catId').trigger('click');


inside the script in item-post.php or in global.js?
« Last Edit: December 20, 2018, 02:10:33 AM by alexandromt »

*

MB Themes

Re: When posting that directly shows the choice of the type of publication
« Reply #4 on: December 20, 2018, 08:38:05 AM »
 $('#catId').click();

Looks better and should be inside document ready function.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

siken

  • ****
  • 138 posts
Re: When posting that directly shows the choice of the type of publication
« Reply #5 on: December 20, 2018, 08:44:37 AM »
$('#catId').click();

Looks better and should be inside document ready function.

But this code inside the script in item-post.php or in global.js?

*

MB Themes

Re: When posting that directly shows the choice of the type of publication
« Reply #6 on: December 20, 2018, 09:07:31 AM »
Should not matter.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

siken

  • ****
  • 138 posts
Re: When posting that directly shows the choice of the type of publication
« Reply #7 on: December 20, 2018, 10:21:31 AM »
Should not matter.

Do I have to replace some line or put the code in some line?

this code...

$('#catId').click();{
}


I have put the code inside the script but it does not automatically open the categories of the icons when entering ad post.

It could be implemented in the theme configuration, because it is the first step and the user would click less

Marked as best answer by leales_org on December 20, 2018, 12:57:34 PM
*

MB Themes

Re: When posting that directly shows the choice of the type of publication
« Reply #8 on: December 20, 2018, 11:32:44 AM »
Code: [Select]
$(document).ready(function() {
  $('.category-box').click();
});
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

siken

  • ****
  • 138 posts
Re: When posting that directly shows the choice of the type of publication
« Reply #9 on: December 20, 2018, 12:57:56 PM »
Code: [Select]
$(document).ready(function() {
  $('.category-box').click();
});


Perfect, thank you, it works very well.

I recommend adding it in the settings of future versions of your themes, since it saves the user a click. Many users see a row of icons and some do not click them until they get the error of choosing the type of publication.

Regards

*

MB Themes

Re: When posting that directly shows the choice of the type of publication
« Reply #10 on: December 20, 2018, 01:59:04 PM »
Thanks for feedback.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots