123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420 |
- //首页
- $(function(){
- $(".lblRect").click(function(){
- $(this).addClass("active").siblings('.active').removeClass('active');
- });
-
- //最新动态删除
- $('.fcha').click(function(){
- $(this).parents('li').remove();
- });
- });
- $(function(){
- $('.jam').click(function(){
- $(this).parents('.tix').remove();
- });
- });
- $(function(){
- $(".vanish").click(function(){
- $(this).parents(".popup").fadeOut();
- });
- });
- $(function(){
- $change_li = $(".jlist li");
- $change_li.each(function(i){
- $(this).click(function(){
- $(this).addClass("active").siblings('.active').removeClass("active");
- $(".choice .volume").eq(i).show().siblings(".volume").hide();
- });
- });
- });
- /* 输入框输入文字限制 */
- $(function () {
- //匹配包含给定属性的元素,keyup在按键释放时发生
- $("#caseContent").keyup(function () {
- var area = $(this);
- //parseInt 方法返回与保存在 numString 中的数字值相等的整数。如果 numString 的前缀不能解释为整数,则返回 NaN(而不是数字)。
- var max = parseInt(area.attr("maxlength"), 10); //获取maxlength的值 转化为10进制,将输入到textarea的文本长度
- //这个判断可知max得到的是不是数字,设定的大小是多少
- if (max > 0) {
- if (area.val().length > max) { //textarea的文本长度大于maxlength
- area.val(area.val().substr(0, max)); //截断textarea的文本重新赋值
- }
- var yishu = area.val().length;
- var sheng = max - area.val().length;
- $("#lyishu").html(yishu);
- $("#lsheng").html(sheng);
- }
- });
- $("#caseContent").blur(function () {
- var area = $(this);
- var max = parseInt(area.attr("maxlength"), 10); //获取maxlength的值
- if (max > 0) {
- if (area.val().length > max) { //textarea的文本长度大于maxlength
- area.val(area.val().substr(0, max)); //截断textarea的文本重新赋值
- }
- var yishu = area.val().length;
- var sheng = max - area.val().length;
- $("#lyishu").html(yishu);
- $("#lsheng").html(sheng);
- }
- });
- });
-
- function changeCreateType(type) {
- var grade = parseInt($("input[name='grade']").val());
-
- if ( ! isNaN(grade) && grade >= 1 && grade <= 3) {
- $.get('/exams/ajaxChangeCreateType', {
- type: type,
- grade: grade
- }, function(result){
- if (result.status == 0) {
- $.alert(result.error);
- $("#classes").html("");
- return;
- }
-
- var html = '';
-
- for (var i in result) {
- html += '<label class="cur ml10"><input type="checkbox" name="classId[]" value="'+ result[i].class_id +'" style="vertical-align:calc();" /> '+ result[i].class_name +'</label>';
- }
-
- $("input[name='classIds']").val("");
- $("#classes").html(html);
-
- if (result.length > 0) {
- $("#checkClasses").show();
-
- // $("input#checkAll").click();
- $("input#checkAll").prop("checked", true);
- $("input[name='classId[]']").prop("checked", true);
- } else {
- $("#checkClasses").hide();
- }
- });
- } else {
- $.alert('请选择年级!');
- }
- }
-
- function changeGrade(grade) {
- var type = parseInt($("input[name='createType']").val());
-
- if ( ! isNaN(grade) && grade >= 0 && grade <= 3) {
- $.get('/exams/ajaxChangeCreateType', {
- type: type,
- grade: grade
- }, function(result){
- if (result.status == 0) {
- $.alert(result.error);
- $("#classes").html("");
- return;
- }
-
- var html = '';
-
- for (var i in result) {
- html += '<label class="cur ml10"><input type="checkbox" name="classId[]" value="'+ result[i].class_id +'" style="vertical-align:calc();" /> '+ result[i].class_name +'</label>';
- }
-
- $("input[name='classIds']").val("");
- $("#classes").html(html);
-
- if (result.length > 0) {
- $("#checkClasses").show();
-
- // $("input#checkAll").click();
- $("input#checkAll").prop("checked", true);
- $("input[name='classId[]']").prop("checked", true);
- } else {
- $("#checkClasses").hide();
- }
- });
- } else {
- $.alert('请选择生成方式!');
- }
- }
-
- //下拉框
- $(function () {
- function diy_select(){this.init.apply(this,arguments)};
- diy_select.prototype={
- init:function(opt)
- {
- this.setOpts(opt);
- 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(o,s)//添加class
- {
- o.className = o.className ? o.className+' '+s:s;
- },
- removeClass:function(o,st)//删除class
- {
- var reg=new RegExp('\\b'+st+'\\b');
- o.className=o.className ? o.className.replace(reg,''):'';
- },
- addEvent:function(o,t,fn)//注册事件
- {
- return o.addEventListener ? o.addEventListener(t,fn,false):o.attachEvent('on'+t,fn);
- },
- showSelect:function()//显示下拉框列表
- {
- var This=this;
- var iNow=0;
- this.addEvent(document,'click',function(){
- for(var i=0;i<This.lengths;i++)
- {
- This.l[i].style.display='none';
- }
- })
- for(var i=0;i<this.lengths;i++)
- {
- this.l[i].index=this.b[i].index=this.t[i].index=i;
- this.t[i].onclick=this.b[i].onclick=function(ev)
- {
- var e=window.event || ev;
- var index=this.index;
- This.item=This.l[index].getElementsByTagName('li');
- This.l[index].style.display= This.l[index].style.display=='block' ? 'none' :'block';
- for(var j=0;j<This.lengths;j++)
- {
- if(j!=index)
- {
- This.l[j].style.display='none';
- }
- }
- This.addClick(This.item);
- e.stopPropagation ? e.stopPropagation() : (e.cancelBubble=true); //阻止冒泡
- }
- }
- },
- addClick:function(o)//点击回调函数
- {
- if(o.length>0)
- {
- var This=this;
- for(var i=0;i<o.length;i++)
- {
- o[i].onmouseover=function()
- {
- This.addClass(this,This.opt.TTFcous);
- }
- o[i].onmouseout=function()
- {
- This.removeClass(this,This.opt.TTFcous);
- }
- o[i].onclick=function()
- {
- var index = this.parentNode.index;//获得列表
- var type = $(this).attr("type");
- var name = $(this).attr("name");
- var examName = this.innerHTML.replace(/^\s+/,'').replace(/\s+&/,'');
-
- // This.t[index].innerHTML=This.ipt[index].value=this.innerHTML.replace(/^\s+/,'').replace(/\s+&/,'');
- This.t[index].innerHTML = examName;
- $("input[name='examName']").val(examName);
- // $("#checkClasses").show();
- $("#createTypeName").html(name);
- This.ipt[index].value = type;
- This.l[index].style.display='none';
-
- changeCreateType(type);
- }
- }
- }
- },
- getByClass:function(s,p,t)//使用class获取元素
- {
- var reg=new RegExp('\\b'+s+'\\b');
- var aResult=[];
- var aElement=(p||document).getElementsByTagName(t || '*');
- for(var i=0;i<aElement.length;i++)
- {
- if(reg.test(aElement[i].className))
- {
- aResult.push(aElement[i])
- }
- }
- return aResult;
- },
- setOpts:function(opt) //以下参数可以不设置 //设置参数
- {
- this.opt={
- TTContainer:'diy_select',//控件的class
- TTDiy_select_input:'diy_select_input',//用于提交表单的class
- TTDiy_select_txt:'diy_select_txt',//diy_select用于显示当前选中内容的容器class
- TTDiy_select_btn:'diy_select_btn',//diy_select的打开按钮
- TTDiv_select_list:'diy_select_list',//要显示的下拉框内容列表class
- TTFcous:'focus'//得到焦点时的class
- }
- for(var a in opt) //赋值 ,请保持正确,没有准确判断的
- {
- this.opt[a]=opt[a] ? opt[a]:this.opt[a];
- }
- }
- }
- var TTDiy_select=new diy_select({ //参数可选
- TTContainer:'diy_select',//控件的class
- TTDiy_select_input:'diy_select_input',//用于提交表单的class
- TTDiy_select_txt:'diy_select_txt',//diy_select用于显示当前选中内容的容器class
- TTDiy_select_btn:'diy_select_btn',//diy_select的打开按钮
- TTDiv_select_list:'diy_select_list',//要显示的下拉框内容列表class
- TTFcous:'focus'//得到焦点时的class
- });//如同时使用多个时请保持各class一致.
- });
- //下拉框
- $(function () {
- function diy_select2(){this.init.apply(this,arguments)};
- diy_select2.prototype={
- init:function(opt)
- {
- this.setOpts(opt);
- 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(o,s)//添加class
- {
- o.className = o.className ? o.className+' '+s:s;
- },
- removeClass:function(o,st)//删除class
- {
- var reg=new RegExp('\\b'+st+'\\b');
- o.className=o.className ? o.className.replace(reg,''):'';
- },
- addEvent:function(o,t,fn)//注册事件
- {
- return o.addEventListener ? o.addEventListener(t,fn,false):o.attachEvent('on'+t,fn);
- },
- showSelect:function()//显示下拉框列表
- {
- var This=this;
- var iNow=0;
- this.addEvent(document,'click',function(){
- for(var i=0;i<This.lengths;i++)
- {
- This.l[i].style.display='none';
- }
- })
- for(var i=0;i<this.lengths;i++)
- {
- this.l[i].index=this.b[i].index=this.t[i].index=i;
- this.t[i].onclick=this.b[i].onclick=function(ev)
- {
- var e=window.event || ev;
- var index=this.index;
- This.item=This.l[index].getElementsByTagName('li');
- This.l[index].style.display= This.l[index].style.display=='block' ? 'none' :'block';
- for(var j=0;j<This.lengths;j++)
- {
- if(j!=index)
- {
- This.l[j].style.display='none';
- }
- }
- This.addClick(This.item);
- e.stopPropagation ? e.stopPropagation() : (e.cancelBubble=true); //阻止冒泡
- }
- }
- },
- addClick:function(o)//点击回调函数
- {
- if(o.length>0)
- {
- var This=this;
- for(var i=0;i<o.length;i++)
- {
- o[i].onmouseover=function()
- {
- This.addClass(this,This.opt.TTFcous);
- }
- o[i].onmouseout=function()
- {
- This.removeClass(this,This.opt.TTFcous);
- }
- o[i].onclick=function()
- {
- var index = this.parentNode.index;//获得列表
- var value = $(this).attr("value");
- var name = $(this).attr("name");
- var examName = this.innerHTML.replace(/^\s+/,'').replace(/\s+&/,'');
-
- // This.t[index].innerHTML=This.ipt[index].value=this.innerHTML.replace(/^\s+/,'').replace(/\s+&/,'');
- This.t[index].innerHTML = examName;
- // $("#checkClasses").show();
- This.ipt[index].value = value;
- This.l[index].style.display='none';
-
- changeGrade(value);
- }
- }
- }
- },
- getByClass:function(s,p,t)//使用class获取元素
- {
- var reg=new RegExp('\\b'+s+'\\b');
- var aResult=[];
- var aElement=(p||document).getElementsByTagName(t || '*');
- for(var i=0;i<aElement.length;i++)
- {
- if(reg.test(aElement[i].className))
- {
- aResult.push(aElement[i])
- }
- }
- return aResult;
- },
- setOpts:function(opt) //以下参数可以不设置 //设置参数
- {
- this.opt={
- TTContainer:'diy_select2',//控件的class
- TTDiy_select_input:'diy_select_input2',//用于提交表单的class
- TTDiy_select_txt:'diy_select_txt2',//diy_select用于显示当前选中内容的容器class
- TTDiy_select_btn:'diy_select_btn2',//diy_select的打开按钮
- TTDiv_select_list:'diy_select_list2',//要显示的下拉框内容列表class
- TTFcous:'focus'//得到焦点时的class
- }
- for(var a in opt) //赋值 ,请保持正确,没有准确判断的
- {
- this.opt[a]=opt[a] ? opt[a]:this.opt[a];
- }
- }
- }
- var TTDiy_select2=new diy_select2({ //参数可选
- TTContainer:'diy_select2',//控件的class
- TTDiy_select_input:'diy_select_input2',//用于提交表单的class
- TTDiy_select_txt:'diy_select_txt2',//diy_select用于显示当前选中内容的容器class
- TTDiy_select_btn:'diy_select_btn2',//diy_select的打开按钮
- TTDiv_select_list:'diy_select_list2',//要显示的下拉框内容列表class
- TTFcous:'focus'//得到焦点时的class
- });//如同时使用多个时请保持各class一致.
- });
|