xsgl.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. $(function(){
  2. //表格排序
  3. $(".table1 th").click(function(){
  4. var updown = $(this).find(".updown");
  5. if(updown.length==0){
  6. return;
  7. }
  8. $(this).siblings().find(".updown").html("↑").addClass("auto");
  9. if(updown.hasClass("auto")){
  10. updown.removeClass("auto");
  11. sort($(this).index(),1);
  12. return;
  13. }
  14. if(updown.html()=="↑"){
  15. updown.html("↓");
  16. sort($(this).index(),-1);
  17. }else{
  18. updown.html("↑");
  19. sort($(this).index(),1);
  20. }
  21. });
  22. $(".tablecj").click(function(){
  23. return false;
  24. }).change(function(){
  25. var arr = $(".table1 tr:gt(0)");
  26. var key = this.value;
  27. arr.each(function(){
  28. if(key=="-1"){
  29. $(this).show();
  30. return;
  31. }
  32. if($(this).find("td").eq(2).html()==key){
  33. $(this).show();
  34. }else{
  35. $(this).hide();
  36. }
  37. });
  38. });
  39. });
  40. function checklink(url){
  41. if(window.confirm('你确定要取消吗?')){
  42. window.location.href=url
  43. }
  44. }
  45. //排序函数
  46. function sort(index,type){
  47. var arr = $(".table1 tr:gt(0)");
  48. arr = arr.sort(function(a,b){
  49. var val1 = $(a).find("td").eq(index).text();
  50. var val2 = $(b).find("td").eq(index).text();
  51. if(type==1){
  52. return val1>val2;
  53. }else if(type==-1){
  54. return val1<val2;
  55. }
  56. });
  57. $(".table1").append(arr);
  58. }
  59. //select
  60. $(function(){
  61. function diy_select(){this.init.apply(this,arguments)};
  62. diy_select.prototype={
  63. init:function(opt)
  64. {
  65. this.setOpts(opt);
  66. this.o=this.getByClass(this.opt.TTContainer,document,'div');//容器
  67. this.b=this.getByClass(this.opt.TTDiy_select_btn);//按钮
  68. this.t=this.getByClass(this.opt.TTDiy_select_txt);//显示
  69. this.l=this.getByClass(this.opt.TTDiv_select_list);//列表容器
  70. this.ipt=this.getByClass(this.opt.TTDiy_select_input);//列表容器
  71. this.lengths=this.o.length;
  72. this.showSelect();
  73. },
  74. addClass:function(o,s)//添加class
  75. {
  76. o.className = o.className ? o.className+' '+s:s;
  77. },
  78. removeClass:function(o,st)//删除class
  79. {
  80. var reg=new RegExp('\\b'+st+'\\b');
  81. o.className=o.className ? o.className.replace(reg,''):'';
  82. },
  83. addEvent:function(o,t,fn)//注册事件
  84. {
  85. return o.addEventListener ? o.addEventListener(t,fn,false):o.attachEvent('on'+t,fn);
  86. },
  87. showSelect:function()//显示下拉框列表
  88. {
  89. var This=this;
  90. var iNow=0;
  91. this.addEvent(document,'click',function(){
  92. for(var i=0;i<This.lengths;i++)
  93. {
  94. This.l[i].style.display='none';
  95. }
  96. $('.ttt').each(function(){//input隐藏添加disabled,显示去掉
  97. if($(this).is(":hidden")){
  98. $(this).children('input').attr("disabled","disabled");
  99. }else{
  100. $(this).children('input').removeAttr("disabled");
  101. }
  102. });
  103. })
  104. for(var i=0;i<this.lengths;i++)
  105. {
  106. this.l[i].index=this.b[i].index=this.t[i].index=i;
  107. this.t[i].onclick=this.b[i].onclick=function(ev)
  108. {
  109. var e=window.event || ev;
  110. var index=this.index;
  111. This.item=This.l[index].getElementsByTagName('li');
  112. This.l[index].style.display= This.l[index].style.display=='block' ? 'none' :'block';
  113. for(var j=0;j<This.lengths;j++)
  114. {
  115. if(j!=index)
  116. {
  117. This.l[j].style.display='none';
  118. }
  119. }
  120. This.addClick(This.item);
  121. e.stopPropagation ? e.stopPropagation() : (e.cancelBubble=true); //阻止冒泡
  122. }
  123. }
  124. },
  125. addClick:function(o)//点击回调函数
  126. {
  127. if(o.length>0)
  128. {
  129. var This=this;
  130. for(var i=0;i<o.length;i++)
  131. {
  132. o[i].onmouseover=function()
  133. {
  134. This.addClass(this,This.opt.TTFcous);
  135. }
  136. o[i].onmouseout=function()
  137. {
  138. This.removeClass(this,This.opt.TTFcous);
  139. }
  140. o[i].onclick=function()
  141. {
  142. var index=this.parentNode.index;//获得列表
  143. This.t[index].innerHTML=this.innerHTML.replace(/^\s+/,'').replace(/\s+&/,'');
  144. This.ipt[index].value=this.getAttribute("val").replace(/^\s+/,'').replace(/\s+&/,'');
  145. //This.t[index].innerHTML=This.ipt[index].value=this.innerHTML.replace(/^\s+/,'').replace(/\s+&/,'');
  146. // 特殊处理教材模块显示
  147. if (this.getAttribute("material")) {
  148. var jf_obj = document.getElementsByClassName('jfcheckAll');
  149. for(var i=0;i<jf_obj.length;i++) {
  150. jf_obj[i].checked=false;
  151. }
  152. var listr = document.getElementsByClassName('ttt');
  153. for(var i=0;i<listr.length;i++){
  154. listr[i].style.display="none";
  155. }
  156. document.getElementById('m'+this.getAttribute("val")).style.display = "block";
  157. }
  158. // 缴费设置特殊处理
  159. if (this.getAttribute("price")){
  160. document.getElementById('pay_cost').value = this.getAttribute("price");
  161. document.getElementById('pay_name').value = this.getAttribute("pname");
  162. }
  163. // 特殊处理学生转班
  164. if (this.getAttribute("copyClass")) {
  165. chageClass(this.getAttribute("val"));
  166. }
  167. This.l[index].style.display='none';
  168. }
  169. }
  170. }
  171. },
  172. getByClass:function(s,p,t)//使用class获取元素
  173. {
  174. var reg=new RegExp('\\b'+s+'\\b');
  175. var aResult=[];
  176. var aElement=(p||document).getElementsByTagName(t || '*');
  177. for(var i=0;i<aElement.length;i++)
  178. {
  179. if(reg.test(aElement[i].className))
  180. {
  181. aResult.push(aElement[i])
  182. }
  183. }
  184. return aResult;
  185. },
  186. setOpts:function(opt) //以下参数可以不设置 //设置参数
  187. {
  188. this.opt={
  189. TTContainer:'diy_select',//控件的class
  190. TTDiy_select_input:'diy_select_input',//用于提交表单的class
  191. TTDiy_select_txt:'diy_select_txt',//diy_select用于显示当前选中内容的容器class
  192. TTDiy_select_btn:'diy_select_btn',//diy_select的打开按钮
  193. TTDiv_select_list:'diy_select_list',//要显示的下拉框内容列表class
  194. TTFcous:'focus'//得到焦点时的class
  195. }
  196. for(var a in opt) //赋值 ,请保持正确,没有准确判断的
  197. {
  198. this.opt[a]=opt[a] ? opt[a]:this.opt[a];
  199. }
  200. }
  201. }
  202. var TTDiy_select=new diy_select({ //参数可选
  203. TTContainer:'diy_select',//控件的class
  204. TTDiy_select_input:'diy_select_input',//用于提交表单的class
  205. TTDiy_select_txt:'diy_select_txt',//diy_select用于显示当前选中内容的容器class
  206. TTDiy_select_btn:'diy_select_btn',//diy_select的打开按钮
  207. TTDiv_select_list:'diy_select_list',//要显示的下拉框内容列表class
  208. TTFcous:'focus'//得到焦点时的class
  209. });//如同时使用多个时请保持各class一致.
  210. var TTDiy_select1=new diy_select({ //参数可选
  211. TTContainer:'diy_select1',//控件的class
  212. TTDiy_select_input:'diy_select_input1',//用于提交表单的class
  213. TTDiy_select_txt:'diy_select_txt1',//diy_select用于显示当前选中内容的容器class
  214. TTDiy_select_btn:'diy_select_btn1',//diy_select的打开按钮
  215. TTDiv_select_list:'diy_select_list1',//要显示的下拉框内容列表class
  216. TTFcous:'focus'//得到焦点时的class
  217. });//如同时使用多个时请保持各class一致.
  218. var TTDiy_select2=new diy_select({ //参数可选
  219. TTContainer:'diy_select2',//控件的class
  220. TTDiy_select_input:'diy_select_input2',//用于提交表单的class
  221. TTDiy_select_txt:'diy_select_txt2',//diy_select用于显示当前选中内容的容器class
  222. TTDiy_select_btn:'diy_select_btn2',//diy_select的打开按钮
  223. TTDiv_select_list:'diy_select_list2',//要显示的下拉框内容列表class
  224. TTFcous:'focus'//得到焦点时的class
  225. });//如同时使用多个时请保持各class一致.
  226. var TTDiy_select3=new diy_select({ //参数可选
  227. TTContainer:'diy_select3',//控件的class
  228. TTDiy_select_input:'diy_select_input3',//用于提交表单的class
  229. TTDiy_select_txt:'diy_select_txt3',//diy_select用于显示当前选中内容的容器class
  230. TTDiy_select_btn:'diy_select_btn3',//diy_select的打开按钮
  231. TTDiv_select_list:'diy_select_list3',//要显示的下拉框内容列表class
  232. TTFcous:'focus'//得到焦点时的class
  233. });//如同时使用多个时请保持各class一致.
  234. var TTDiy_select4=new diy_select({ //参数可选
  235. TTContainer:'diy_select4',//控件的class
  236. TTDiy_select_input:'diy_select_input4',//用于提交表单的class
  237. TTDiy_select_txt:'diy_select_txt4',//diy_select用于显示当前选中内容的容器class
  238. TTDiy_select_btn:'diy_select_btn4',//diy_select的打开按钮
  239. TTDiv_select_list:'diy_select_list4',//要显示的下拉框内容列表class
  240. TTFcous:'focus'//得到焦点时的class
  241. });//如同时使用多个时请保持各class一致.
  242. var TTDiy_select5=new diy_select({ //参数可选
  243. TTContainer:'diy_select5',//控件的class
  244. TTDiy_select_input:'diy_select_input5',//用于提交表单的class
  245. TTDiy_select_txt:'diy_select_txt5',//diy_select用于显示当前选中内容的容器class
  246. TTDiy_select_btn:'diy_select_btn5',//diy_select的打开按钮
  247. TTDiv_select_list:'diy_select_list5',//要显示的下拉框内容列表class
  248. TTFcous:'focus'//得到焦点时的class
  249. });//如同时使用多个时请保持各class一致.
  250. });