var hxupload_desc_clickadd = function(){}; hxupload_desc_clickadd.prototype.init = function(){ var descriptions_to_add = $("#se3").children(); var huxing_desc = $("#huxing_desc"); $.each(descriptions_to_add,function(index,desc_toadd){ desc_toadd = $(desc_toadd); desc_toadd.click(function(){ var description_now = huxing_desc.val(); var description_tobe = description_now + desc_toadd.text()+';'; huxing_desc.val(description_tobe); huxing_desc.focus(); desc_toadd.hide(); }); }); }; var class_comm_check_form = function(){ this.setting_init = function(){ this.check_module = {};//todo this.base_name = '';//名称 this.check_result = 0;//检查结果 //this.all_mycheck = {}; }; this.setting_add = function(){ if(typeof(this.base_node_id)==='undefined'){ this.base_node = $("#"+this.base_name);} if(typeof(this.right_id)==='undefined'){ this.right = $("#"+this.base_name+"_right");} if(typeof(this.wrong_id)==='undefined'){ this.wrong = $("#"+this.base_name+"_wrong");} if(typeof(this.wrong_tips_id)==='undefined'){ this.wrong_tips = $("#"+this.base_name+"_tips");} if(typeof(this.progress_node_id)==='undefined'){ this.progress_node = $("#"+this.pre+"progress");} }; //全局设置 this.g_set = function(gseting){ this.pre = ''; this.inputcount = 0;//表单数 this.inputed = [];//已填数 this.progress = 0;//进度 var that = this; var index; for(index in gseting){ if(!gseting.hasOwnProperty(index)){ continue; } that[index] = gseting[index]; } this.submit_node = $("#"+this.pre+"submit");//提交按钮 }; //设置 this.setting = function(mysetting){ this.setting_init(); var index; var that = this; var copy_mysetting = this.myclone(mysetting); for(index in copy_mysetting){ if(copy_mysetting.hasOwnProperty(index)){ that[index] = copy_mysetting[index]; } } this.setting_add(); this.checkval = {}; this.checkvalue(); }; //销毁设置 this.setting_destruct = function(mysetting){ var index; var that = this; for(index in mysetting){ if(mysetting.hasOwnProperty(index)){ delete that[index]; } } }; //trim this.trim = function(str){ str = str.replace(/^(\s|\u00A0)+/,''); for(var i=str.length-1; i>=0; i--){ if(/\S/.test(str.charAt(i))){ str = str.substring(0, i+1); break; } } return str; }; //克隆 this.myclone = function(myObj){ if(typeof(myObj) !== 'object'){ return myObj; } if(myObj === null){ return myObj; } var myNewObj; if(myObj.constructor == Array){ myNewObj = []; }else{ myNewObj = {}; } var i; for(i in myObj){ if(!myObj.hasOwnProperty(i)){ continue;} myNewObj[i] = this.myclone(myObj[i]); } return myNewObj; }; //重新设置 this.out_set = function(g_set,live_set){ this.g_set(g_set); this.all_mycheck = live_set; this.json_deal.call(this.all_mycheck); }; }; //检查input class_comm_check_form.prototype.checkinput = function(){ if(this.check_result===1){ this.inputed[this.base_name] = 1; this.right.show(); this.wrong.hide(); this.wrong_tips.hide(); }else if(this.check_result===0){ this.inputed[this.base_name] = 0; this.right.hide(); this.wrong.show(); this.wrong_tips.show(); } this.setprogress(); this.progress_node.css({'width':this.progress+'%'}); this.progress_node.find("span").text(this.progress+'%'); this.progress_node.find("span").css({'position':'relative'}); }; //设置进度 class_comm_check_form.prototype.setprogress = function(){ var myinputed = 0; var index; for(index in this.inputed){ if(!this.inputed.hasOwnProperty(index)){ continue; } myinputed += this.inputed[index]; } this.progress = myinputed/this.inputcount*100; if(this.progress===100){ var submitfunc = this.submit_node.attr('data_func'); this.submit_node.click(function(){ window[submitfunc](); }); }else{ //alert(11); } }; //检查长度 class_comm_check_form.prototype.checkvalue = function(){ var that = this; this.checkval.check_len = function(){ var myval = that.trim(that.base_node.val()); var len = myval.length; if(typeof(that.min_len)==='undefined'){ that.min_len = 0; } if(typeof(that.max_len)==='undefined'){ that.max_len = 0; } if(len>that.min_len){ if(that.max_len===0){ that.check_result = 1; }else if(len已选择:"); $("#step2_g").val("");$("#step2_n").val(""); var step2_g; var step2_n; $(".hxpop_contentSearchCondition").find("a").each(function() { if(index>12){ return; } var data_num = $(this).attr("data-number"); if($(this).html() !== ""){ if($(this).hasClass("btn-red")){ $(".hxpop_contentSearch-keywordsWrapper").append("
"+$(this).text()+"
"); $(".hxpop_contentSearch-keywordsWrapper").find("#del_"+data_num).click(function(){ var todel = $("#filter_contener_huixing").find("a").filter(".btn-red").filter("[data-number='"+data_num+"']"); todel.removeClass("btn-red"); var the_right = todel.parent().find("img"); if(the_right.size()===0){ the_right = todel.parent().parent().find("img"); } if(todel.parent().find(".btn-red").size()===0){ the_right.hide(); } $(this).parent().remove(); }); if($(this).parent().attr("id")==="hxpop_fileType"){ step2_g = $("#step2_g").val(); $("#step2_g").val(step2_g+"["+data_num+"]").trigger("change"); }else{ step2_n = $("#step2_n").val(); $("#step2_n").val(step2_n+"["+data_num+"]").trigger("change"); } index++; } } }); }; class_filter_component.prototype.running = function(){ var index; var that = this; for(index in this.filter_module.click_ids){ if(!this.filter_module.click_ids.hasOwnProperty(index)){ continue; } this.filter_module.click_ids[index].pid = index; $("#"+index).find("a").click({'setting':this.filter_module.click_ids[index]}, function (the_event){ var setting = the_event.data.setting; setting.node_clicked = this; if(typeof(setting.add)!=='undefined'){ var setting_add = that.filter_module.condition(setting.pid,this); var index_add; for(index_add in setting_add){ if(!setting_add.hasOwnProperty(index_add)){ continue; } setting[index_add] = setting_add[index_add]; } //console.log(setting); } that.setting(setting); that.inactive_hide_sons(); that.topshowselected_activethis(); that.show_son(); }); } }; var huxing_filters_module = {}; huxing_filters_module.click_ids={ "hxpop_fileType" : { 'line_selected':'#step2_g_right','mult_select':'m' }, "hxpop_contentClude" : {'line_selected':'#step2_n_right','add':1, 'node_sons':['#hxpop_valliDetail','#hxpop_houseDetail','#hxpop_multifloorsDetail','#multifloorsDetail1','#hxpop_doublefloorsDetail','#hxpop_triplefloorsDetail', '#hxpop_forthfloorsDetail','#hxpop_valliDetail','#hxpop_valliDetail1','#hxpop_valliDetail2']}, "hxpop_houseDetail" : {'line_selected':'#da2','add':1}, "hxpop_valliDetail" : {'line_selected':'#da3','node_sons':["#hxpop_valliDetail1","#hxpop_valliDetail2"],'node_son':["#hxpop_valliDetail1","#hxpop_valliDetail2"]}, "hxpop_valliDetail1" : {'line_selected':'#dad8','add':1}, "hxpop_valliDetail2" : {'line_selected':'#da9'}, "hxpop_multifloorsDetail" : {'line_selected':'#da4','add':1, 'node_sons':['#hxpop_doublefloorsDetail','#hxpop_triplefloorsDetail','#hxpop_forthfloorsDetail']} , "hxpop_doublefloorsDetail" : {'line_selected':'#da5'}, "hxpop_triplefloorsDetail" : {'line_selected':'#da6'}, "hxpop_forthfloorsDetail" : {'line_selected':'#da7'} }; huxing_filters_module.condition = function(index,node_clicked){ var the_topicid = parseInt($(node_clicked).attr('data-number')); var the_id = $(node_clicked).attr('id'); var node_son =[]; var node_sons =[]; switch(index){ case "hxpop_contentClude": if(the_topicid===118){ node_son.push("#hxpop_houseDetail"); }else if(the_topicid===130){ node_son.push("#hxpop_valliDetail"); } return {'node_son':node_son}; case "hxpop_houseDetail": if(the_id==="gaoceng"){ node_son.push("#multifloorsDetail1"); }else{ node_son.push("#hxpop_multifloorsDetail"); } if(the_topicid===270 || the_topicid===271){ node_sons.push('#hxpop_multifloorsDetail'); }else{ node_sons.push('#hxpop_multifloorsDetail','#multifloorsDetail1'); } return {'node_son':node_son,'node_sons':node_sons}; case "hxpop_multifloorsDetail" : if(the_topicid === 195){ node_son = '#hxpop_doublefloorsDetail'; }else if(the_topicid === 196){ node_son = '#hxpop_triplefloorsDetail'; }else if(the_topicid === 197){ node_son = '#hxpop_forthfloorsDetail'; } return {'node_son':node_son}; case "hxpop_valliDetail1": var mult_select = 'm'; var parent_active = $("#hxpop_valliDetail").find("a").filter(".btn-red"); if(parent_active.size()===1){ var parent_topicid = parent_active.attr("data-number"); //console.log(parent_topicid); if(parent_topicid===126||parent_topicid===127){ mult_select = 1; } } return {'mult_select':mult_select}; case "default": } }; //webgl文件上传 function upload_process_file(){ this.myset = function(setting){ var index,that,i; that = this; if(typeof this.i==='undefined'){ this.i=0; } this.i++; if(setting.pre===1){ this.prop_pre = 'a'+String(i); }else{ this.prop_pre = ''; } for(index in setting){ if(!setting.hasOwnProperty(index)){ continue; } if(setting.skip!==1){ if(typeof that[this.prop_pre+index]!=='undefined'){ delete that[this.prop_pre+index]; } } that[this.prop_pre+index] = setting[index]; } //console.log(that[that.prop_pre+'clickable']);console.log(that[that.prop_pre+'dropezoneid']); }; this.myattrval = function(nodeid,valtoadd){ var mynode = $("#"+nodeid); var oldval = mynode.val();//trim(); if(oldval!=="" && typeof oldval!=="undefined"){ oldval += ','; } mynode.val(oldval+valtoadd); }; } upload_process_file.prototype.webgl_init = function(){ this.popup = $("#upload_webgl_obj"); this.myform = this.popup.find("#form_upload_webglobj"); this.filehash = this.myform.find("input[name='filehash']"); this.filesize = this.myform.find("input[name='filesize']"); this.filemimetype = this.myform.find("input[name='filemimetype']"); this.org_name = this.myform.find("input[name='org_name']"); this.fileurl = this.myform.find("input[name='fileurl']"); this.submitbtn = this.popup.find("#uploadpop_submit"); this.submitbtn.click({that:this},function(e){ var that = e.data.that; var data = that.myform.serializeArray(); var postdata = {}; var lowcase; $.each(data,function(i,field){ postdata[field.name] = field.value; }); postdata.mid = phpvar.mid; $.ajax({url:G_BASE_URL + "/materials/ajax/addwebgl/",type:'POST',data:postdata,dataType:'text',success:function(redata){ $('.alert-box').modal('hide'); //window.location.href = window.location.href; //console.log(redata); }}); }); }; upload_process_file.prototype.webgl_on_success = function(){ var mytrim = function(myinput){ return rtrim(myinput.val(),',');}; this.filehash.val(mytrim(this.filehash)+','+this.responseText.hash); this.filesize.val(mytrim(this.filesize)+','+this.file.size); this.filemimetype.val(mytrim(this.filemimetype)+','+this.responseText.mimeType); this.org_name.val(mytrim(this.org_name)+','+this.file.name); this.fileurl.val(mytrim(this.fileurl)+','+this.responseText.qiniu_thumbUrl); }; upload_process_file.prototype.webgl_remove = function(haystack,needle,contener){ haystack = ','+trim(haystack,this.separator)+','; contener.val(haystack.replace(','+needle+',',',')); }; upload_process_file.prototype.webgl_on_removedfile = function(){ //console.log(this); this.separator = ','; this.webgl_remove(this.filehash.val(),this.responseText.hash,this.filehash); this.webgl_remove(this.filesize.val(),this.file.size,this.filesize); this.webgl_remove(this.filemimetype.val(),this.responseText.mimeType,this.filemimetype); this.webgl_remove(this.org_name.val(),this.file.name,this.org_name); this.webgl_remove(this.fileurl.val(),this.responseText.qiniu_thumbUrl,this.fileurl); }; upload_process_file.prototype.initdropzonepic = function(){ var that = this; var mydropezoneid = that[that.prop_pre+'dropezoneid']; var new_bim_thumb = document.querySelector("#"+mydropezoneid); var myDropzone = new Dropzone(new_bim_thumb, { init: function () { var preid = that[that.prop_pre+'preid']; var revmove_diy = $("#"+mydropezoneid).parent().next('#'+preid+'_remove'); //console.log(revmove_diy); this.on("success", function (file, responseText) { that.myattrval(preid,responseText.qiniu_thumbUrl); that.myattrval(preid+'image_area',responseText.w+','+responseText.h); that.myattrval(preid+'imageave',responseText.imageave.RGB); that.myattrval(preid+'filesize',responseText.size); that.myattrval(preid+'mimetype',responseText.mimeType); that.myattrval(preid+'hash',responseText.hash); $("#"+mydropezoneid).css({display:'none'}); if(phpvar.app == 'manufacturer' && phpvar.act == 'info'){ if(phpvar.is_mobile == '1'){ var url = qnurl(responseText.qiniu_thumbUrl,291,195,'c5'); }else{ var url = qnurl(responseText.qiniu_thumbUrl,466,466,'c5'); } }else{ var url = qnurl(responseText.qiniu_thumbUrl,736,736,'c5'); } $("#"+mydropezoneid).parent().append(''); if($(revmove_diy).length){ $(revmove_diy).css({'display':'block'}); $(revmove_diy).on('click',function(){ $("#"+mydropezoneid).parent().find('img:last').remove(); $(revmove_diy).css({'display':'none'}); }) } }); this.on("removedfile",function(file, responseText){ //todo }); if($(revmove_diy).length){ $(revmove_diy).on('click',function(){ $('#'+preid).val(''); $('#'+preid+'image_area').val(''); $('#'+preid+'imageave').val(''); $('#'+preid+'filesize').val(''); $('#'+preid+'mimetype').val(''); $('#'+preid+'hash').val(''); $("#"+mydropezoneid).css({display:'block'}); }); } }, autoQueue: true, acceptedFiles: '.JPG,.JPEG,.PNG,.GIF,.BMP', clickable: "#"+that[that.prop_pre+'clickable'], previewTemplate: "
"+"
", maxFilesize:'10' }); }; upload_process_file.prototype.initdropzoneattr = function(){ var that = this; var preid = that[that.prop_pre+'preid']; var inputid = that.prop_pre+'inputid'; var myinput = that[inputid]; var myattr = document.querySelector("#"+preid+'_form'); if(typeof myinput==='undefined'){ myinput = preid; } var myDropzone = new Dropzone(myattr, { init: function () { this.on("success", function (file, responseText) { that.myattrval(preid+'_input',file.name); $('#'+preid+'_checkbox').attr('checked','checked'); that.myattrval(myinput+'_name',file.name); that.myattrval(myinput+'_type',$('#'+preid+'_checkbox').val()); that.myattrval('form_'+myinput,responseText.qiniu_thumbUrl); that.myattrval(myinput+'filesize',responseText.size); that.myattrval(myinput+'mimetype',responseText.mimeType); that.myattrval(myinput+'hash',responseText.hash); }); this.on("removedfile",function(file, responseText){ //todo }); }, autoQueue: true, maxFilesize:'99', acceptedFiles: that[that.prop_pre+'filetype'], previewTemplate: "
"+ "
", clickable: "#"+preid+"_button" }); var total_progress = 'total-progress'+String(that[that.prop_pre+'num']); myDropzone.on("totaluploadprogress", function(progress) { document.querySelector("#"+total_progress+" .progress-bar").style.width = progress + "%"; if(progress===100){ setTimeout(function(){ document.querySelector("#"+total_progress).style.display = 'none'; },800); }else if(progress > 0){ document.querySelector("#"+total_progress).style.display = ''; } }); myDropzone.on("sending", function() { document.querySelector("#"+total_progress).style.opacity = "20"; }); myDropzone.on("queuecomplete", function() { document.querySelector("#"+total_progress).style.opacity = "20"; }); }; $(function(){ $('#bim_upload_file').click(function(){ var myform = $('#myForm'); var ids_mustinsert = ['mid1','hidden_sktopic_top','board_id','mtitle','huxing_desc']; var ids_mustinsert_lan = {mid1:'图片',hidden_sktopic_top:'领域',board_id:'资料集',mtitle:'标题',huxing_desc:'标签'}; var ids_oneinsert = ['form_archicad','form_reivt','form_u3ds','form_ifc','form_skp','form_fujia','form_pdf']; var checklen = function(myval,min_len,max_len){ var len = myval.length; var check_result=0; if(len>min_len){ if(max_len===0){ check_result = 1; }else if(len0){ window.location.href = G_BASE_URL+ "/materials/"+umid; }else{ console.log(umid); } }); }else{ alert(toalert); } }); });