$(function(){ if($("html").html().indexOf('colorbox-min')==-1){ $("html").append(''); } //表单初始化插入 var obj=$("[data-elementtype=form]"); if(!obj.length)return; obj.attr("eleid",obj.parent().parent().attr("id")); obj.children().css("overflow",'visible').children().css("overflow",'visible'); obj.each(function(n,ele){ //obj.parents(".yzmoveContent ").append(obj.eq(n).css({"zIndex":450,'top':obj.eq(n).offset().top,'left':obj.eq(n).offset().left})); }); //文本域初始化可操作 $("[data-elementtype=formTextarea]").find('textarea').removeAttr('readonly disabled').val(""); $("[data-elementtype=formInput], [data-elementtype=formDate]").find('input').removeAttr('readonly disabled'); $("[data-elementtype=formSelect]").each(function(n,ele){ $("[data-elementtype=formSelect]").eq(n).attr("zindexn",$("[data-elementtype=formSelect]").eq(n).css("zIndex")); }); $("[data-elementtype=formDate]").each(function(n,ele){ $("[data-elementtype=formDate]").eq(n).attr("zindexn",$("[data-elementtype=formDate]").eq(n).css("zIndex")); }); $("[data-elementtype=formButton]").css("cursor",'pointer'); //默认时间 var oDate=new Date(); $(".wqd-form-element.formDate.wqdControlFormEl6 input[type=text]").val(oDate.getFullYear()+"-"+(oDate.getMonth()+1)+"-"+oDate.getDate()); //默认下拉框选项 var obj=$(".wqd-form-element.formSelect.wqdControlFormEl5 p span"); if(obj.html()=="下拉框"){ obj.html(obj.parent().next().find("li span").eq(0).html()); } //单选 $(".wqd-form.wqdControlForm .wqdControlFormEl3").on("click",function(){ if($(this).find("i").hasClass("on")) return; var name=$(this).find("input").attr("name"); $("[name="+name+"]").removeAttr("checked").prev().removeClass("on"); $(this).find("i").addClass("on").next("input").attr("checked","checked"); }); //多选 $(".wqd-form.wqdControlForm .wqdControlFormEl4").on("click",function(){ if($(this).find("i").hasClass("on")) $(this).find("i").removeClass("on").next("input").removeAttr("checked"); else $(this).find("i").addClass("on").next("input").attr("checked","checked"); }); //模拟下拉框 $(".wqd-form-element.formSelect.wqdControlFormEl5 p").on("click",function(){ if($(this).hasClass("on")) { $(this).removeClass("on").parent().removeClass("on"); $(this).parents('section.sectionV2').css({'zIndex':5,'overflow':'hidden'}); } else { $(this).addClass("on").parent().addClass("on"); $(this).parents('section.sectionV2').css({'zIndex':6,'overflow':'visible'}); } $(this).parents("[data-elementtype=formSelect]").css("zIndex",403); }); $(".wqd-form-element.formSelect.wqdControlFormEl5 ul li").on("mousedown",function(){ $(this).parents('section.sectionV2').css({'zIndex':5,'overflow':'visible'}); if(!$(this).hasClass("on")) $(this).addClass("on").siblings().removeClass("on"); $(this).parent().siblings("p").children("span").html($(this).children("span").html()); $(this).parent().siblings("p").removeClass("on").parent().removeClass("on"); $(this).parents("[data-elementtype=formSelect]").css("zIndex",$(this).parents("[data-elementtype=formSelect]").attr("zindexn")); }); $('.wqdNavLi').hover(function(){ $('section.sectionV2').css({'zIndex':5}); },function(){ $('section.sectionV2').css({'zIndex':5}); }); $("body").not(".wqd-form-element.formSelect.wqdControlFormEl5").on("mouseup",function(){ if($(".wqd-form-element.formSelect.wqdControlFormEl5").hasClass("on")){ $(this).parents('section.sectionV2').css({'zIndex':5,'overflow':'visible'}); $(".wqd-form-element.formSelect.wqdControlFormEl5").removeClass("on").children("p").removeClass("on"); //$("[data-elementtype=formSelect]").css("zIndex",400); $("[data-elementtype=formSelect]").each(function(n,ele){ $("[data-elementtype=formSelect]").eq(n).css("zIndex",$("[data-elementtype=formSelect]").eq(n).attr("zindexn")); }); } }); function isAttr(obj,title){ obj.each(function(n,ele){ obj.eq(n).attr("wqdformtitle")?obj.eq(n).attr("wqdformtitle"):obj.eq(n).attr("wqdformtitle",title); }); }; //表单默认字段 isAttr($("[data-elementtype=formInput]"),"姓名");//文本框 isAttr($("[data-elementtype=formTextarea]"),"详情");//文本域 isAttr($("[data-elementtype=formRadio]"),"单选");//单选框 isAttr($("[data-elementtype=formCheckbox]"),"多选");//复选框 isAttr($("[data-elementtype=formSelect]"),"学历");//下拉框 isAttr($("[data-elementtype=formDate]"),"日期");//日历 //表单提交 var json={}; function setCookie(cookieName,elementid){//设置cookie var gettime=new Date(); //cookie生命周期 var nDate=new Date(); nDate.setTime(nDate.getTime()+1000*60*60*24); document.cookie=(cookieName+elementid)+"="+gettime.getTime()+";expires="+nDate.toGMTString(); document.cookie=('clickn'+elementid)+'='+1+";expires="+nDate.toGMTString(); } function getCookie(cookieName,elementid){//获取cookie var allCookie=document.cookie; if(allCookie.indexOf(cookieName+elementid)==-1){ return true; }else{ return false; } } var bool=true; function colorbox(html){ $.colorbox({ transition: "none", opacity: 0.5, html:html, fixed: true, closeButton: false, onOpen: function() { window.scroll_top = $(document).scrollTop(); }, onComplete: function() { setTimeout(function(){ bool=true; $("#colorbox,#cboxOverlay").remove(); },1000); }, onClosed: function() { window.scrollTo(0, window.scroll_top); } }); }; var json={},arr=[]; function formclass(obj,fn){fn(obj.length)}; //checked添加name $("[data-elementtype=formRadio],[data-elementtype=formCheckbox]").each(function(n,ele){ if(!$(this).find('input').attr('name')){ $(this).find('input').attr('name',$(this).attr('elementid')); } }); $(".wqdControlFormEl7 a").on("click",function(){ //模版和案例预览时 return if(window.parent != window.self) return; var html,elementid=$(this).parents(".wqdelementEdit.elementsContainer").attr("elementid"); if(getCookie("getCookie",elementid)){ html="

提交成功!

"; if(bool){ bool=false; colorbox(html); } setCookie("getCookie",elementid); }else{ if(parseInt(document.cookie.split(('clickn'+elementid)+'=')[1].split(';')[0])<10){ document.cookie=('clickn'+elementid)+'='+(parseInt(document.cookie.split('clickn'+elementid+'=')[1].split(';')[0])+1); html="

提交成功!

"; if(bool){ bool=false; colorbox(html); } }else{ html="

提交失败!

每天最多提交10次

"; if(bool){ bool=false; colorbox(html); } window.location.reload(); return; } } var obj=$(this); var form=obj.parents('[data-elementtype=formButton]').parent(); if(obj.children().html()=='提交成功') return false; formclass(form.find("[data-elementtype=formInput]"),//文本框 function(n){ for(var i=0;i