lvtip.js 2.3 KB

1
  1. UI.extend.lvtip=function(option){var opt={msg:"11",left:0,width:"auto",top:0,templete:$([]),auto:false,align:"left",mul:false};opt=$.extend(opt,option);var str='<div class="lvtip '+opt.align+'" id="lvtip_pop" style="display:none;"><b class="b1">◆</b><b class="b2">◆</b><label>'+opt.msg+"</label></div>";var me=this;if($(me).find(".edui-default").length>0&&opt.auto==false){var id=$(this).find("textarea").attr("id");var ue=UE.getEditor(id);ue.addListener("click",function(){if(!getCookie("lvtip")){$("#lvtip_pop").remove();$("body").append(str);var p=$(me).offset();$("#lvtip_pop").css({left:p.left+$(me).outerWidth()+opt.left,top:p.top+opt.top,width:opt.width}).fadeIn(200);if(opt.templete.attr("templete")==3){var s=opt.templete.find(".pad_tb20px");var pdtTip=$('<div class="lvtip" id="lvtip_pdt" style="display:none;"><b class="b1">◆</b><b class="b2">◆</b><label>直接点选答案</label></div>');$("body").append(pdtTip);pdtTip.css({top:s.offset().top+15,left:s.offset().left+180}).fadeIn(200)}}});ue.addListener("blur",function(){$("#lvtip_pop").hide();$("#lvtip_pdt").remove()})}else if($(me).is(".answer_list")&&opt.auto==false){$(this).focusin(function(e,isTrigger){if(!isTrigger){if(!getCookie("lvtip")){$("#lvtip_pop").remove();$("body").append(str);var p=$(this).offset();$("#lvtip_pop").css({left:p.left+$(me).outerWidth()+opt.left,top:p.top+opt.top,width:opt.width}).fadeIn(200);if(opt.templete.attr("templete")==1||opt.templete.attr("templete")==2){var s=$(this).parents(".answer_box:first").children().first();var pdtTip=$('<div class="lvtip right" id="lvtip_pop_dx" style="display:none;"><b class="b1">◆</b><b class="b2">◆</b><label>直接点选答案</label></div>');$("body").append(pdtTip);pdtTip.css({top:s.offset().top+5,left:s.offset().left-125}).show()}}}})}else{if(opt.auto){if(!opt.mul){$("#lvtip_pop").remove()}var obj=$(str);$("body").append(obj);var p=$(this).offset();obj.css({left:p.left+$(me).outerWidth()+opt.left,top:p.top+opt.top,width:opt.width}).fadeIn(200)}else{$(this).focusin(function(){if(!getCookie("lvtip")&&$("div.validate:visible").length==0){$("#lvtip_pop").remove();$("body").append(str);var p=$(this).offset();$("#lvtip_pop").css({left:p.left+$(me).outerWidth()+opt.left,top:p.top+opt.top,width:opt.width}).fadeIn(200)}}).focusout(function(){$("#lvtip_pop").hide()})}}};