Вход Регистрация
Файл: touchSpace/js/search_suggests.js
Строк: 107
<?php
!function(){function e(e){if(_[n]){var t=$(_[n]);e.length>0?t.show():t.hide()}}function t(){i.after('<input type="hidden" name="cfms" value="1" />')}var s,i,a,o,n="default",r="neoapi",_={service:"#form-item_years, #form-item_rank, #form-item_description",career:"#form-item_years, #form-item_position, #form-item_description"};$("body").on("focus",".search_suggest",function(){function e(){var e,t,s,_=i.val();o!=_&&(o=_,""!=_?(e="search.getSuggestions",s={},s.q=_,"career"==n?(e="services.searchEmployer",t={prefix:r},s.C=$("#s-city__hidden-city").val()):"service"==n&&(e="services.searchMilUnit",t={prefix:r},s.C=$("#s-city__hidden-country").val()),Spaces.api(e,s,function(e){var t,s,i,o;if(e.code==Codes.COMMON.SUCCESS)if(i="","default"==n?t=e.result:"career"==n?t=e.employers:"service"==n&&(t=e.mil_units),s=t.length,s>0){for(o=0;s>o;o++)i+='<div class="suggest__item">'+t[o]+"</div>";a.html(i),a.hasClass("suggest__list_on")||a.addClass("suggest__list_on")}else a.html("").removeClass("suggest__list_on")},t)):a.html("").removeClass("suggest__list_on"))}function _(e){var t,s,n,r,_,u=a.find(".suggest__item"),l=u.length;l>0&&(t=u.is(".suggest__item_active"),0==t?(s=40==e?u.first():u.last(),s.addClass("suggest__item_active"),o=s.text(),i.val(o)):l>1&&(n=$(".suggest__item_active"),r=n.index(),40==e?_=l>r+1?r+1:0:38==e&&(_=r-1>=0?r-1:l-1),u.addClass(function(e){return e==_?(n.removeClass("suggest__item_active"),o=$(this).text(),i.val(o),"suggest__item_active"):void 0})))}i=$(this),a=i.parents(".suggest_parent").find(".suggest__list"),console.log(i.data("type")),i.data("type")&&(n=i.data("type")),o=i.val(),"touch"==Device.type&&window.scrollTo(0,i.offset().top),s=setInterval(e,300),"desktop"==Device.type?i.on("keydown.suggest",function(e){var s=e.keyCode;38==s||40==s?(e.preventDefault(),_(s)):(13==s||27==s)&&(13==s&&("default"==n?t():("career"==n||"service"==n)&&e.preventDefault()),a.html("").removeClass("suggest__list_on"))}):"touch"==Device.type&&i.on("keydown.suggest",function(e){var s=e.keyCode;(13==s||27==s)&&(13==s&&("default"==n?t():("career"==n||"service"==n)&&e.preventDefault()),a.html("").removeClass("suggest__list_on"))})}).on("blur",".search_suggest",function(){setTimeout(function(){a.html("").removeClass("suggest__list_on"),a="",i=""},300),o="",i.off("keydown.suggest"),clearInterval(s)}),$("body").on("click",".suggest__item",function(){if("default"==n&&t(),"touch"==Device.type){var s=$(this);o=s.text(),i.val(o),e(o),"default"==n&&i.parent("form").delay(500).submit()}else"default"==n&&i.parent("form").submit();a.html("").removeClass("suggest__list_on")}),"desktop"==Device.type&&$("body").on("mouseenter",".suggest__item",function(){var t=$(this);$(".suggest__item_active").removeClass("suggest__item_active"),t.addClass("suggest__item_active"),o=t.text(),i.val(o),e(o)}).on("mouseleave",".suggest__item",function(){$(this).removeClass("suggest__item_active")}),$("body").on("keyup",".search_suggest",function(){e(i.val())})}();
?>
Онлайн: 0
Реклама