<div class="form-group spec4uploadOnly">
<label class="col-xs-2 col-sm-2 col-md-2 col-lg-2 control-label"></label>
<div class="col-xs-10 col-sm-10 col-md-10 col-lg-10">
<input type="file" id="uploadBtn1" style="display:none;"/>
<button type="button" style="z-index:0" class="btn btn-default green_btn col-xs-2 col-sm-2 col-md-2 col-lg-2 uploadBtn "><s:text name="coocUploadFile" /></button>
<button type="button" id="urlBtn" style="z-index:0" class="btn btn-default green_btn col-xs-2 col-sm-2 col-md-2 col-lg-2 uploadBtn "><s:text name="coocUrlAddr" /></button>
<div class="col-xs-8 col-sm-8 col-md-8 col-lg-8" style="display:none;margin-top:10px;" id="firstInputFile">
<input class="form-control">
</div>
<button type="button" class="btn btn-default blue_btn col-xs-1 col-sm-1 col-md-1 col-lg-1 deleteBtn" style="display:none;top:9px;"></button>
</div>
<div id='queuelist' style = "width:260px;position:relative;left:850px;top:-35px;margin-bottom:-50px;"></div> <!-- -->
</div>
<div class="form-group urlFile" style="display:none;">
<label class="col-sm-2 control-label"></label>
<div class="row col-sm-10">
<div class="col-sm-8"><input class="form-control" id="linkurl" placeholder="<s:text name="coocPleInputUrlAddr"/>"></div>
<button id="urlDelBtn" type="button" class="btn btn-default blue_btn col-sm-1 deleteBtn"></button>
</div>
</div>
$("#urlBtn").click(function(){
$("#urlBtn").css("outline","none");
$("div.urlFile").css("display","block");
$("#firstInputFile").css("display","none");
$("#firstInputFile").siblings("button.deleteBtn").css("display","none");
$("div.spec4upload").css("display","none");
$("#fileid").val("");
$("#arr").val("");
});
$("#urlBtn").mouseout(function(){
$("#urlBtn").css({background:"#9bbf62",color:"#fff",outline:"none"});
});
$("#urlBtn").mouseenter(function(){
$("#urlBtn").css({background:"#9bbf62",color:"#fff",outline:"none"});
});
$("#urlDelBtn").click(function(){
$("#linkurl").val("");
});
function uploadRender() {
$("#uploadBtn1").uploadify({
width : 130,
height : 35,
buttonText : '<s:text name="uploadMySource"/>',
swf : '<%=basePath%>resource/script/plugins/uploadify/uploadify.swf',
uploader : '<%=basePath%>upload',
fileSizeLimit : 1000*1024,
fileTypeExts : '*.gif;*.zip;*.jpg;*.jpeg;*.exe;*.bmp;*.exe;*.apk;*.png;*.doc;*.docx;*.ppt;*.pptx;*.pdf;*.mp4;*.flv;*.rm;*.rmvb;*.3gp;*.mkv;*.avi;*.wmv;*.mp3;*.txt;*.epub;*.xls;*.xlsx',
fileTypeDesc : 'select',
multi : true,
uploadLimit : 0,
queueID : 'queuelist',
onSelectError : function(file,errorCode,erorMsg){
switch(errorCode) {
case -100:
this.queueData.errorMsg ="<s:text name='errorMsg1'/>";
break;
case -110:
this.queueData.errorMsg ="<s:text name='errorMsg2'/>";
break;
case -120:
this.queueData.errorMsg ="<s:text name='errorMsg3'/>";
break;
}
},
onQueueComplete : function(queueData){
//$("#fileid").val(id); $("#arr").val(arr);
},
onUploadSuccess : function (event, ID, fileObj, response, data) {//当文件上传完成时触发
//id = id+ID+'|'; name = event.name; arr = arr + name + '|';
var elementId = ID.substring(0,ID.indexOf("."));
uploadFile.initData({id:elementId, name:event.name, rId:(ID+"|"), rName:(event.name+"|")});
uploadFile.add();
}
});
}
var uploadFile = {
param: {id:'',name:''},
initData : function(options) {
this.param = $.extend({},this.param,options);
},
html : '<div class="form-group spec4upload"><label class="col-sm-2 control-label"></label>'
+'<div class="row col-sm-10">'
+'<div class="col-sm-8"><input class="form-control"></div>'
+'<button type="button" class="btn btn-default blue_btn col-sm-1 deleteBtn"></button></div></div>',
add : function() {
var oid = $("div.spec4uploadOnly").find("input:not(input[type='file'])").attr("id"), p = this.param;
if(oid){
var temp = $(this.html);
temp.find("input").attr("id","filename_"+p.id).val(p.name);
temp.find("button.deleteBtn").attr("id","deleteBtn_"+p.id).click(function(){
uploadFile.remove(p.id);
uploadFile.reset("remove",p.rId,p.rName);});
var len = $("div.spec4uploadOnly").siblings(".spec4upload:last").length;
if(len>0){
$("div.spec4uploadOnly").siblings(".spec4upload:last").after(temp);
}else{
$("div.spec4uploadOnly").after(temp);
}
}else{
$("#firstInputFile").css("display","block");
$("#firstInputFile").siblings("button.deleteBtn").css("display","block");
$("div.spec4uploadOnly").find("input:not(input[type='file'])").attr("id","filename_"+p.id).val(p.name);
$("div.spec4uploadOnly").find("button.deleteBtn").attr("id","deleteBtn_"+p.id).click(function(){
uploadFile.remove(p.id);
uploadFile.reset("remove",p.rId,p.rName);});
}
$("div.urlFile").css("display","none");
uploadFile.reset("add",p.rId,p.rName);
},
remove : function(id) {
showConfirm('<s:text name="coocDelMessage1"/>',function(){
var clas = $("#deleteBtn_"+id).parent().parent().attr("class");
console.log(clas);
if(clas) {
if(clas.indexOf("spec4uploadOnly")>-1){
var len = $("div.spec4uploadOnly").siblings(".spec4upload:last").length;
if(len>0){
var last = $("div.spec4uploadOnly").siblings(".spec4upload:last");
var input = last.find("input"),btn = last.find("button.deleteBtn");
$("div.spec4uploadOnly").find("input").replaceWith(input);
$("div.spec4uploadOnly").find("button.deleteBtn").replaceWith(btn);
$("div.spec4uploadOnly").find("button.deleteBtn").css("top","9px");
last.remove();
}else{
var input = $("#filename_"+id),
delBtn = $("#deleteBtn_"+id);
input.val("");
input.attr("id","");
delBtn.attr("id","");
}
}else{
$("#deleteBtn_"+id).parent().parent().remove();
}
}
});
},
reset : function(flag,rId,rName) {
var id = $("#fileid").val(),
name = $("#arr").val();
if(flag=='add') {
id = id + rId;
name = name + rName;
} else if (flag=="remove"){
id = id.replace(rId,"");
name = name.replace(rName,"");
}
$("#fileid").val(id);
$("#arr").val(name);
//console.log($("#fileid").val() + "---" + $("#arr").val());
}
};