xsgl.js 4.2 KB

1
  1. $(function(){$(".table1 th").click(function(){var c=$(this).find(".updown");0!=c.length&&($(this).siblings().find(".updown").html("\u2191").addClass("auto"),c.hasClass("auto")?(c.removeClass("auto"),sort($(this).index(),1)):"\u2191"==c.html()?(c.html("\u2193"),sort($(this).index(),-1)):(c.html("\u2191"),sort($(this).index(),1)))});$(".tablecj").click(function(){return!1}).change(function(){var c=$(".table1 tr:gt(0)"),b=this.value;c.each(function(){"-1"==b?$(this).show():$(this).find("td").eq(2).html()==b?$(this).show():$(this).hide()})})});function sort(c,b){var a=$(".table1 tr:gt(0)"),a=a.sort(function(a,f){var e=$(a).find("td").eq(c).text(),g=$(f).find("td").eq(c).text();if(1==b)return e>g;if(-1==b)return e<g});$(".table1").append(a)}$(function(){function c(){this.init.apply(this,arguments)}c.prototype={init:function(b){this.setOpts(b);this.o=this.getByClass(this.opt.TTContainer,document,"div");this.b=this.getByClass(this.opt.TTDiy_select_btn);this.t=this.getByClass(this.opt.TTDiy_select_txt);this.l=this.getByClass(this.opt.TTDiv_select_list);this.ipt=this.getByClass(this.opt.TTDiy_select_input);this.lengths=this.o.length;this.showSelect()},addClass:function(b,a){b.className=b.className?b.className+" "+a:a},removeClass:function(b,a){var d=new RegExp("\\b"+a+"\\b");b.className=b.className?b.className.replace(d,""):""},addEvent:function(b,a,d){return b.addEventListener?b.addEventListener(a,d,!1):b.attachEvent("on"+a,d)},showSelect:function(){var b=this;this.addEvent(document,"click",function(){for(var a=0;a<b.lengths;a++)b.l[a].style.display="none";$(".ttt").each(function(){$(this).is(":hidden")?$(this).children("input").attr("disabled","disabled"):$(this).children("input").removeAttr("disabled")})});for(var a=0;a<this.lengths;a++)this.l[a].index=this.b[a].index=this.t[a].index=a,this.t[a].onclick=this.b[a].onclick=function(a){a=window.event||a;var c=this.index;b.item=b.l[c].getElementsByTagName("li");b.l[c].style.display="block"==b.l[c].style.display?"none":"block";for(var e=0;e<b.lengths;e++)e!=c&&(b.l[e].style.display="none");b.addClick(b.item);a.stopPropagation?a.stopPropagation():a.cancelBubble=!0}},addClick:function(b){if(0<b.length)for(var a=this,c=0;c<b.length;c++)b[c].onmouseover=function(){a.addClass(this,a.opt.TTFcous)},b[c].onmouseout=function(){a.removeClass(this,a.opt.TTFcous)},b[c].onclick=function(){var b=this.parentNode.index;a.t[b].innerHTML=this.innerHTML.replace(/^\s+/,"").replace(/\s+&/,"");a.ipt[b].value=this.getAttribute("val").replace(/^\s+/,"").replace(/\s+&/,"");if(this.getAttribute("material")){for(var c=document.getElementsByClassName("jfcheckAll"),d=0;d<c.length;d++)c[d].checked=!1;c=document.getElementsByClassName("ttt");for(d=0;d<c.length;d++)c[d].style.display="none";document.getElementById("m"+this.getAttribute("val")).style.display="block"}this.getAttribute("price")&&(document.getElementById("pay_cost").value=this.getAttribute("price"),document.getElementById("pay_name").value=this.getAttribute("pname"));this.getAttribute("copyClass")&&chageClass(this.getAttribute("val"));a.l[b].style.display="none"}},getByClass:function(b,a,c){b=new RegExp("\\b"+b+"\\b");var f=[];a=(a||document).getElementsByTagName(c||"*");for(c=0;c<a.length;c++)b.test(a[c].className)&&f.push(a[c]);return f},setOpts:function(b){this.opt={TTContainer:"diy_select",TTDiy_select_input:"diy_select_input",TTDiy_select_txt:"diy_select_txt",TTDiy_select_btn:"diy_select_btn",TTDiv_select_list:"diy_select_list",TTFcous:"focus"};for(var a in b)this.opt[a]=b[a]?b[a]:this.opt[a]}};new c({TTContainer:"diy_select",TTDiy_select_input:"diy_select_input",TTDiy_select_txt:"diy_select_txt",TTDiy_select_btn:"diy_select_btn",TTDiv_select_list:"diy_select_list",TTFcous:"focus"});new c({TTContainer:"diy_select1",TTDiy_select_input:"diy_select_input1",TTDiy_select_txt:"diy_select_txt1",TTDiy_select_btn:"diy_select_btn1",TTDiv_select_list:"diy_select_list1",TTFcous:"focus"});new c({TTContainer:"diy_select2",TTDiy_select_input:"diy_select_input2",TTDiy_select_txt:"diy_select_txt2",TTDiy_select_btn:"diy_select_btn2",TTDiv_select_list:"diy_select_list2",TTFcous:"focus"});new c({TTContainer:"diy_select3",TTDiy_select_input:"diy_select_input3",TTDiy_select_txt:"diy_select_txt3",TTDiy_select_btn:"diy_select_btn3",TTDiv_select_list:"diy_select_list3",TTFcous:"focus"})});