(function($){
$.fn.extend({
select4:function(options){
var defaults = {
ajax_url:true
}
var options = $.extend(defaults, options);
return this.each(function(){
var mythis = $(this);
var mythis2 = $('.y_scriptm');
$(document).on("click",".select4_box li",function(){
mythis.val($(this).find('a span.y_left').attr('title'));
$(".select4_box").remove();
$('.y_scriptm').hide();
});
$(document).click(function(event) {
$(".select4_box").remove();
$('.y_scriptm').hide();
});
$(".select4_box").click(function(event) {
event.stopPropagation();
});
mythis.click(function(event) {
var val = $(this).val();
$.ajax({
url:options.ajax_url,
dataType:"json",
data:{title:val},
success:function(data){
mythis2.html('');
if(data.code == 200){
var html = '
';
var price = '待定';
var unit = '';
$.each(data.data,function(k,v){
if(v.sale_price != ''&&v.sale_price != null && v.sale_price !=0){
price = v.sale_price;
unit = v.price_unit;
}
var nemeleng=v.name;
if (nemeleng.length>8) {
var nametext=nemeleng.substring(0,8)+"...";
}else{
var nametext=nemeleng;
};
html += '- '+nametext+'('+v.city_name+') '+price+''+unit+'
';
});
html+='
'
$(".select4_box").remove();
mythis2.html(html);
$('.y_scriptm').show();
}
}
});
});
var u = navigator.userAgent;
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
console.log(isiOS);
if(isiOS){
mythis.bind('input propertychange',function(event) {
if(event.keyCode==40){
var index = $(".select4_box li.active").index()+1;
$(".select4_box li").eq(index).addClass('active').siblings().removeClass('active');
mythis.val($(".select4_box li.active span.y_left").attr('title'));
}else if(event.keyCode==38){
var index = $(".select4_box li.active").index()-1;
if(index<0){
index = $(".select4_box li").length-1;
}
$(".select4_box li").eq(index).addClass('active').siblings().removeClass('active');
mythis.val($(".select4_box li.active span.y_left").attr('title'));
}else if(event.keyCode==13){
event.stopPropagation();
mythis.val($(".select4_box li.active span.y_left").attr('title'));
return false;
}else{
mythis.trigger("click");
}
});
}else{
mythis.keyup(function(event) {
if(event.keyCode==40){
var index = $(".select4_box li.active").index()+1;
$(".select4_box li").eq(index).addClass('active').siblings().removeClass('active');
mythis.val($(".select4_box li.active span.y_left").attr('title'));
}else if(event.keyCode==38){
var index = $(".select4_box li.active").index()-1;
if(index<0){
index = $(".select4_box li").length-1;
}
$(".select4_box li").eq(index).addClass('active').siblings().removeClass('active');
mythis.val($(".select4_box li.active span.y_left").attr('title'));
}else if(event.keyCode==13){
event.stopPropagation();
mythis.val($(".select4_box li.active span.y_left").attr('title'));
return false;
}else{
mythis.trigger("click");
}
});
}
});
}
});
})(jQuery);
$(function(){
$(".y_headerscr").select4({"ajax_url":"/house/searchname"});
$('.back_search_m .form a.submit').on('click',function(){
var inptext=$('.y_headerscr').val();
window.location.href = '/house/search?name='+inptext;
})
$(document).keydown(function(event){
if(event.keyCode==13){
$(".y_lpsubmit").click();
}
});
// 输入清除显示与隐藏
$('.index_form input[type="search"]').on('keyup',function(){
var txt = $(this).val();
console.log(txt);
if(txt != ''){
$('.index_form .w_cls').show();
}else{
$('.index_form .w_cls').hide();
}
})
// 清除功能
$('.index_form .w_cls').on('click',function(){
$('.index_form input[type="search"]').val('');
$(this).hide();
})
});
function search(){
var inptext=$('.y_headerscr').val();
window.location.href = '/house/search?name='+inptext;
}
$(function(){
$('.y_publicright').on('click',function(){
var that = $(this);
if(that.hasClass('ion')){
that.removeClass('ion');
$('.y_sidebar').animate({left:"100%"});
}else{
that.addClass("ion");
$('.y_sidebar').animate({left:"0%"});
}
shanwutong(); //修改商务通层级 /js/nav.js
})
$('.y_sidebar_bg').on('click',function(){
$(this).parent().animate({left:"100%"});
if($('.y_publicright').hasClass('ion')){
$('.y_publicright').removeClass('ion');
}
})
setInterval(function(){
$('#LXB_CONTAINER_SHOW').css({"bottom":"63px","top":"auto","left":"0","right":"auto"});
},80);
})
function shanwutong(){
setTimeout(function(){
$('#LXB_CONTAINER_SHOW,#LRfloater3').css({'z-index':'5'});
},80);
}