Where I put this?:
jQuery(function(){
jQuery().click();
});
For open it automatically when the user post an ad...
This is my script in item-post.php:
<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>