// javascript document $(function(){ selectdown();//jq模拟下拉选择 inputplaceholder();//处理input的placeholder messagetips();//信息浏览器右侧底部弹 }); function addcookie() { // 加入收藏 if (document.all) { window.external.addfavorite('http://www.sc.cc/', '实创装饰-让家居生活更幸福!'); } else if (window.sidebar) { window.sidebar.addpanel('实创装饰-让家居生活更幸福!', 'http://www.sc.cc', ""); } }; //tab 切换 function tabdemo(demtabn,demtabbody){ var $demtabname=$(demtabn); var $demtabbody=$(demtabn).parents('.demo-tabname').nextall('.demo-tabwrap'); $demtabname.addclass('t-active').siblings().removeclass('t-active'); $demtabbody.children('.demo-tabbody').eq($demtabname.index()).show().siblings().hide(); }; //******************扩展插件******************// $.fn.extend({ poupdailog : function(obj){ var $this=$(this); var objid=$(obj).attr('id'); $this.on('click',function(){ pouppos();//弹出框定位计算 $('#'+objid).fadein(); }); } }); //弹框效果封装 结束 function pouppos(){ var $poupcontent=$('.poup-content'), $poupmark=$('.poup-mark'), poupcontentw=$poupcontent.width()/2, poupcontenth=$poupcontent.height()/2; $poupcontent.css({'margin-left':-poupcontentw,'margin-top':-poupcontenth,'top':'50%','left':'50%'}); $poupmark.fadein(); // $poupmark.on('click',function(){ // $('.poup-content').fadeout(); // $(this).fadeout(); // }); }; function closedailog(){ $('.poup-mark').fadeout(); $('.poup-content').fadeout(); } //******************扩展插件 结束******************// //jq模拟下拉选择 function selectdown(){ var $selectinput=$('.select-input,.choose-down'); var $selectdownlist=$('.select-down-list'); var $selectdownlistietm=$selectdownlist.find('span'); var downlistmaxheight=$selectdownlistietm.eq(1).height(); $selectinput.on('click',function(){ var selectlenght=$(this).next('.select-down-list').children().length; var selectinputwidth=$(this).width()+parseint($(this).css('margin-left'))+parseint($(this).css('padding-left')); $(this).nextall('.select-down-list').width(selectinputwidth); //$(this).nextall('.select-down-list').css({left:$selectinput.position().left}); if(selectlenght>5){ $selectdownlist.css({'height':downlistmaxheight*5+'px','overflow-y':'auto'}); };//处理最大高度 $selectdownlist.hide(); $(this).parent().find($selectdownlist).show(200); $selectdownlistietm.on('click',function(){ $(this).parent().parent().find($selectinput).val($(this).html()); }); }); $selectdownlist.on('mouseleave',function(){ $(this).hide(); }); //jq模拟下拉选择 结束 }; //处理input的placeholder function inputplaceholder(){ $('input:text').each(function(){ var txt = $(this).val(); $(this).focus(function(){ if(txt === $(this).val()) $(this).val(""); }).blur(function(){ if($(this).val() == "") $(this).val(txt); }); }); }; //处理input的placeholder //信息浏览器右侧底部弹框 function messagetips(){ var messagebox=$('.message-tipx-layout'), closemessage=$('.close-m'); var messagestate=true; if(messagestate){ messagebox.animate({bottom:0},1000); }else{ messagebox.animate({bottom:-110}); }; //点击关闭 closemessage.on('click',function(){ messagebox.animate({bottom:-110}); }); }