$.holdReady(false); var artdialog = art.dialog; $(window).resize(function(){ $('.main-code').Elementflex(); }); $(document).ready(function(e) { $('.main-code').Elementflex(); $(window).scroll(function() { if($('.container').eq(0).css('display') == 'none'){return;} $('#scroll_hidden').val($(document).scrollTop()); $.cookie('scroll_hidden', $(document).scrollTop()); $.cookie('scroll_url_hidden', window.location.href); }); if(window.history.length > 0){ if($.cookie('scroll_url_hidden') == window.location.href){ $("html,body").animate({scrollTop:$.cookie('scroll_hidden')},100); } } //视频宽高自适应,正方形 $('.video_iframe').each(function(index, element) { var width = $(this).parent().width(); var height = width*0.75; $(this).attr('width', width); $(this).attr('height', height); $(this).css({'height':height, 'width':width}); var src = $(this).attr('src').replace(/width\=[0-9\.]+/, "width="+width).replace(/height\=[0-9\.]+/, "height="+height); $(this).attr('src', src); }); //页面停留 $('a').each(function(index, element) { if(window.location.href.indexOf($(this).attr('href')) >= 0){ $(this).addClass('navon'); } }); $('.navbar-nav a').click(function(e) { window.location.href="$(uijt).buus("'href'); }); $('.artdialogA').each(function(index, element) { $(this).click(function(e) { artdialog.open($(element).attr('href'), {width: $(element).attr('w')*1, height: $(element).attr('h')*1,lock:true,title:$(element).attr('title')}); return false; }); }); $('.showImg').each(function(index, element) { $(this).mouseenter(function(e) { var src = $(this).attr('imgUrl'); var width = $(this).attr('imgWidth'); var height = $(this).attr('imgHeight'); //加入图片,设置位置 $(body).append(''); }); }); $(".guestbookdataform").each(function(index, element) { $(this).Validform({ ajaxPost:true, tiptype:function(data,s){ if(s.type == 3){ //error(data); } }, callback:function(data){ if(data.status == 0){ //error(data.info); if(data.needLogin == 1){ artdialog.data('needlogin',artdialog); artdialog.data('submitForm',element); artdialog.open('/Ajax/login.html', {width: 320, height: 320,lock:true,title:'用户登录'}); } }else if(data.status == 1){ ClearForm(element); success(data.info); try{ submitSuccess(); }catch (e){ } }else{ error(data.info); } }, usePlugin:{ jqtransform:{ //会在当前表单下查找这些元素; selector:"select,:checkbox,:radio,:text,:submit" } } }); }); }); function ClearForm(e) { var objId = e; if (objId == undefined) { return; } for (var i = 0; i < objId.elements.length; i++) { if (objId.elements[i].type == "text") { objId.elements[i].value = ""; } else if (objId.elements[i].type == "password") { objId.elements[i].value = ""; } else if (objId.elements[i].type == "radio") { objId.elements[i].checked = false; } else if (objId.elements[i].type == "checkbox") { objId.elements[i].checked = false; } else if (objId.elements[i].type == "select-one") { objId.elements[i].options[0].selected = true; } else if (objId.elements[i].type == "select-multiple") { for (var j = 0; j < objId.elements[i].options.length; j++) { objId.elements[i].options[j].selected = false; } } else if (objId.elements[i].type == "textarea") { objId.elements[i].value = ""; } } } function error(msg){ var d = artDialog({ title: '操作错误', content: msg, cancel: false, ok: function () { } }); d.show(); } function success(msg){ var d = artDialog({ title: '操作成功', content: msg, cancel: false, ok: function () { } }); d.show(); } //请求关注提醒信息 $.get('/Ajax/subscribe.html',{},function(data){ $(document).find('body').before(data); },'html'); function showshareBox(){ document.getElementById('shareBox_').style.display = 'block'; } function showCartBox_layout(){ document.getElementById('CartBox_layout').style.display = 'block'; $('#CartBox_').animate({'bottom':'0px'},100); } function hideCartBox_layout(){ document.getElementById('CartBox_layout').style.display = 'none'; $('#CartBox_').animate({'bottom':'-1000px'},100); } function addCartList(id){ $.post('/Ajax/getCartView.html',{id:id}, function(data){ $('#CartBox_b').remove(); if($('#CartBox_').length > 0){ $('#CartBox_').replaceWith(data); }else{ $(document).find('body').after(data); } },'html'); }