Рабочий поиск на ajax

Модули и плагины для vii (студяги)!
Ответить
Аватара пользователя
glGizma
Site Admin
Сообщения: 214
Зарегистрирован: Ср сен 27, 2017 2:20 pm

Рабочий поиск на ajax

Сообщение glGizma » Сб фев 01, 2020 8:24 am

В файле profile.js ищем

Код: Выделить всё

//SEARCH
function CheckRequestSearch(request){
var pattern = new RegExp(/search/i);
  return pattern.test(request);
}
var gSearch = {
open_types: function(id){
  $(id).show();
},
select_type: function(type, text){
  $('#se_type').val(type);
  $('#search_selected_text').text(text);
  $('.search_type_selected').removeClass();
  $('#'+type).addClass('search_type_selected');
  $('#sel_types').hide();
  $('#query').focus();
},
go: function(){
  var query = $('#query').val();
  var type = $('#se_type').val();
  if(query == 'Поиск' || !query)
   var query = $('#fast_search_txt').text();

  //Если открыта страница поиска
  if(CheckRequestSearch(location.href)){
   query = $('#query_full').val();
   sex = $('#sex').val();
   day = $('#day').val();
   month = $('#month').val();
   year = $('#year').val();
   country = $('#country').val();
   city = $('#select_city').val();
   type = $('#se_type_full').val();
   online = $('#online').val();
   user_photo = $('#user_photo').val();
  }
  if(query == 'Поиск' || query == 'Начните вводить любое слово или имя'){
   query = '';
  }

  //if(query != 0 && query != 'Поиск' && query != 'Начните вводить любое слово или имя'){
   if(CheckRequestSearch(location.href) && type == 1){
        if(sex != 0) all_queryeis_sex = '&sex='+sex;
        else all_queryeis_sex = '';
        if(day != 0) all_queryeis_day = '&day='+day;
        else all_queryeis_day = '';
        if(month != 0) all_queryeis_month = '&month='+month;
        else all_queryeis_month = '';
        if(year != 0) all_queryeis_year = '&year='+year;
        else all_queryeis_year = '';
        if(country != 0) all_queryeis_country = '&country='+country;
        else all_queryeis_country = '';
        if(city != 0) all_queryeis_city = '&city='+city;
        else all_queryeis_city = '';
        if(online != 0) all_queryeis_online = '&online='+online;
        else all_queryeis_online = '';
        if(user_photo != 0) all_queryeis_user_photo = '&user_photo='+user_photo;
        else all_queryeis_user_photo = '';
        res_sort_query = all_queryeis_sex+all_queryeis_day+all_queryeis_month+all_queryeis_year+all_queryeis_country+all_queryeis_city+all_queryeis_online+all_queryeis_user_photo;
   } else
        res_sort_query = '';
  
   lnk = '/?go=search&query='+encodeURIComponent(query)+'&type='+type+res_sort_query;
   Page.Loading('start');
   $.post(lnk, {ajax: 'yes'}, function(data){
        Page.Loading('stop');
        history.pushState({link:lnk}, null, lnk);
        $('#page').html(data);
        //Прокручиваем страницу в самый верх
        $('html, body').scrollTop(0);
        //Удаляем кеш фоток и видео
        $('.photo_view, .box_pos, .box_info, .video_view').remove();
        //Возвращаем scroll
        $('html, body').css('overflow-y', 'auto');
        $('#query').val('Поиск').css('color', '#c1cad0');
        $('#query_full').focus();
        $('#sel_types, .fast_search_bg').hide();
   });
  /*} else {
   $('#query, #query_full').val('');
   $('#query, #query_full').focus();
  }*/
}
}
Заменяем на

Код: Выделить всё

//SEARCH
var selenter = false;
$('#search_types, #search_tab, #se_link').live('mouseenter', function() {
        selenter = true;
});
$('#search_types, #search_tab, #se_link').live('mouseleave', function() {
        selenter = false;
});
$(document).click(function() {
if(!selenter){
  $('#sel_types, #search_tab, .fast_search_bg').hide();
  $('#query').val('');
}
});
function CheckRequestSearch(request){
var pattern = new RegExp(/search/i);
  return pattern.test(request);
}
var gSearch = {
open_tab: function(){
  $('#search_tab').fadeIn('fast');
  $('#query').focus();
  if($('#fast_search_txt').text())
   $('.fast_search_bg').fadeIn('fast');
},
open_types: function(id){
  $(id).show();
},
select_type: function(type, text){
  $('#se_type').val(type);
  $('#search_selected_text').text(text);
  $('.search_type_selected').removeClass();
  $('#'+type).addClass('search_type_selected');
  $('#sel_types').hide();
  $('#query').focus();
},
go: function(){
  var query = $('#query').val();
  var type = $('#se_type').val();
  if(query == 'Поиск' || !query)
   var query = $('#fast_search_txt').text();

  //Если открыта страница поиска
  if(CheckRequestSearch(location.href)){
   query = $('#query_full').val();
   sex = $('#sex').val();
   day = $('#day').val();
   month = $('#month').val();
   year = $('#year').val();
   country = $('#country').val();
   city = $('#select_city').val();
   type = $('#se_type_full').val();
   online = $('#online').val();
   user_photo = $('#user_photo').val();
  }
  if(query == 'Поиск' || query == 'Начните вводить любое слово или имя'){
   query = '';
  }

  //if(query != 0 && query != 'Поиск' && query != 'Начните вводить любое слово или имя'){
   if(CheckRequestSearch(location.href) && type == 1){
        if(sex != 0) all_queryeis_sex = '&sex='+sex;
        else all_queryeis_sex = '';
        if(day != 0) all_queryeis_day = '&day='+day;
        else all_queryeis_day = '';
        if(month != 0) all_queryeis_month = '&month='+month;
        else all_queryeis_month = '';
        if(year != 0) all_queryeis_year = '&year='+year;
        else all_queryeis_year = '';
        if(country != 0) all_queryeis_country = '&country='+country;
        else all_queryeis_country = '';
        if(city != 0) all_queryeis_city = '&city='+city;
        else all_queryeis_city = '';
        if(online != 0) all_queryeis_online = '&online='+online;
        else all_queryeis_online = '';
        if(user_photo != 0) all_queryeis_user_photo = '&user_photo='+user_photo;
        else all_queryeis_user_photo = '';
        res_sort_query = all_queryeis_sex+all_queryeis_day+all_queryeis_month+all_queryeis_year+all_queryeis_country+all_queryeis_city+all_queryeis_online+all_queryeis_user_photo;
   } else
        res_sort_query = '';
  
   lnk = '/?go=search&query='+encodeURIComponent(query)+'&type='+type+res_sort_query;
   Page.Loading('start');
   $.post(lnk, {ajax: 'yes'}, function(data){
        Page.Loading('stop');
        history.pushState({link:lnk}, null, lnk);
        $('#page').html(data);
        //Прокручиваем страницу в самый верх
        $('html, body').scrollTop(0);
        //Удаляем кеш фоток и видео
        $('.photo_view, .box_pos, .box_info, .video_view').remove();
        //Возвращаем scroll
        $('html, body').css('overflow-y', 'auto');
        $('#sel_types, #search_tab, .fast_search_bg').hide();
        $('#query').val('');
   });
  /*} else {
   $('#query, #query_full').val('');
   $('#query, #query_full').focus();
  }*/
}
}
далее вносим изменения в файл style.css

Находим

Код: Выделить всё

/* HEAD MENU */
.headmenu{float:right;margin-right:3px;height:50px;overflow:hidden;position:relative;bottom:50px}
.headmenu a:hover{text-decoration:none}
.headm_posic{text-align:center;font-size:10px;color:#fff;text-decoration:none;padding:6px 4px 6px 5px;float:left}
.headm_posic:hover{background:url("../images/head_m_hover.png") repeat-x}
Заменяем все на

Код: Выделить всё

/* HEAD MENU */
.headmenu{float:right;margin-right:3px;height:50px;overflow:hidden}
.headmenu a:hover{text-decoration:none}
.headm_posic{text-align:center;font-size:10px;color:#fff;text-decoration:none;padding:6px 4px 6px 4px;float:left}
.headm_posic:hover{background:url("../images/head_m_hover2.png") repeat-x}
Вложения
(106).JPG
(106).JPG (427.28 КБ) 11751 просмотр

Ответить