/**
*
* @param pickbtn 选取按钮
* @param showlist
* @param filesinglesizelimit 文件大小,int
* @param filenumlimit 文件数量
* @param extensions 扩展名,gif,jpg
* @param mimetypes 类型,image/gif
* @type 文件类型
* @return
*/
function initfileuploader(pickbtn, showlist, filesinglesizelimit, filenumlimit, extensions, mimetypes, type,obj) {
var base_url = "/jslib/webuploader";
var $list = $("#" + showlist);
var state = "pending";
var datas = {types: ""+type+"",obj: ""+obj+""};
var uploader = webuploader.create({
auto: true,
swf: base_url + '/uploader.swf',
server: '/uploadm/manage',
pick: '#' + pickbtn,
resize: false,
formdata: datas,
fileval: "file",
filenumlimit: filenumlimit,
filesinglesizelimit: filesinglesizelimit,
compress: false,
accept: {
title: 'file',
extensions: extensions,
mimetypes: mimetypes
}
});
// 当有文件被添加进队列的时候
uploader.on( 'filequeued', function( file ) {
$list.append(
'
' +
'' +
'删除' +
'
' +
'' +
'' + file.name + '
' +
'等待上传...
' +
''
);
$img = $list.find('img');
if(type=="annex" || type == 'word'){
$img.attr("src","/jslib/admin/images/annex.png");
}
if(type=="music"){
$img.attr("src","/jslib/admin/images/video.png");
}
});
// 文件上传过程中创建进度条实时显示。
uploader.on( 'uploadprogress', function( file, percentage ) {
var $li = $( '#'+file.id ),
$percent = $li.find('.progress .progress-bar');
// 避免重复创建
if ( !$percent.length ) {
$percent = $('').appendto( $li ).find('.progress-bar');
}
var fs=(percentage * 100).tofixed(2);
$li.find('div.state').text('上传中'+fs+ '%');
//$li.find('div.state').text('上传中');
$percent.css( 'width', percentage * 100 + '%' );
});
uploader.on( 'uploadsuccess', function( file, response ) {
$( '#'+file.id ).find('div.state').text('已上传');
$( '#'+file.id ).append("");
settimeout(function () {
$('#'+file.id ).find('div.state').fadeout();
}, 500);
$img = $list.find('img');
if(type=="video"){
$img.attr("src","/jslib/admin/images/video.png");
}
});
/*uploader.on( 'uploadsuccess', function( file, response ) {
$( '#'+file.id ).append("");
});*/
uploader.on( 'uploaderror', function( file ) {
$( '#'+file.id ).find('div.error').text('上传出错');
});
uploader.on( 'uploadcomplete', function( file ) {
$( '#'+file.id ).find('.progress').fadeout();
});
/* uploader.on( 'uploadcomplete', function( file ) {
$( '#'+file.id ).find('.progress').fadeout();
});*/
uploader.on( 'error', function( type ) {
if (type == "q_exceed_num_limit") {
alert("上传的文件数量不能超过" + filenumlimit);
} else if (type == "q_exceed_size_limit") {
alert("上传的文件大小不能超过" + filesinglesizelimit + "字节");
} else if (type == "q_type_denied") {
alert("不支持这种文件类型");
} else if (type == "f_exceed_size") {
alert("上传的文件大小不能超过" + filesinglesizelimit + "字节");
} else if (type == "f_duplicate") {
alert("已经上传过了");
} else {
alert(type);
}
});
$("body").on("click",".removefilelistener", function(){
removeuploadfile(uploader, $(this));
});
// 为dd添加hover效果 显示功能按钮
$(".file-item").live("mouseenter", function(){
$(this).find(".file-panel").slidedown()
$(this).find(".info").slidedown()
});
$(".file-item").live("mouseleave", function(){
$(this).find(".file-panel").slideup()
$(this).find(".info").slideup()
});
}
/**
* 特殊定制的方法 用在word上传生成内容 word上传后默认调取了生成方法
* @param pickbtn
* @param showlist
* @param filesinglesizelimit
* @param filenumlimit
* @param extensions
* @param mimetypes
* @param type
* @param obj
*/
function initfileuploader_word(pickbtn, showlist, filesinglesizelimit, filenumlimit, extensions, mimetypes, type,obj) {
var base_url = "/jslib/webuploader";
var $list = $("#" + showlist);
var state = "pending";
var datas = {types: ""+type+"",obj: ""+obj+""};
var uploader = webuploader.create({
auto: true,
swf: base_url + '/uploader.swf',
server: '/uploadm/manage',
pick: '#' + pickbtn,
resize: false,
formdata: datas,
fileval: "file",
filenumlimit: filenumlimit,
filesinglesizelimit: filesinglesizelimit,
compress: false,
accept: {
title: 'file',
extensions: extensions,
mimetypes: mimetypes
}
});
// 当有文件被添加进队列的时候
uploader.on( 'filequeued', function( file ) {
$list.append(
'' +
'' +
'删除' +
'
' +
'' +
'' + file.name + '
' +
'等待上传...
' +
''
);
$img = $list.find('img');
if(type=="annex" || type == 'word'){
$img.attr("src","/jslib/admin/images/annex.png");
}
if(type=="music"){
$img.attr("src","/jslib/admin/images/video.png");
}
});
// 文件上传过程中创建进度条实时显示。
uploader.on( 'uploadprogress', function( file, percentage ) {
var $li = $( '#'+file.id ),
$percent = $li.find('.progress .progress-bar');
// 避免重复创建
if ( !$percent.length ) {
$percent = $('').appendto( $li ).find('.progress-bar');
}
var fs=(percentage * 100).tofixed(2);
$li.find('div.state').text('上传中'+fs+ '%');
//$li.find('div.state').text('上传中');
$percent.css( 'width', percentage * 100 + '%' );
});
uploader.on( 'uploadsuccess', function( file, response ) {
$( '#'+file.id ).find('div.state').text('已上传');
$( '#'+file.id ).append("");
settimeout(function () {
$('#'+file.id ).find('div.state').fadeout();
}, 500);
$img = $list.find('img');
if(type=="video"){
$img.attr("src","/jslib/admin/images/video.png");
}
$(".createarticlebydoclistener").click();//默认调取生成功能
});
/*uploader.on( 'uploadsuccess', function( file, response ) {
$( '#'+file.id ).append("");
});*/
uploader.on( 'uploaderror', function( file ) {
$( '#'+file.id ).find('div.error').text('上传出错');
});
uploader.on( 'uploadcomplete', function( file ) {
$( '#'+file.id ).find('.progress').fadeout();
});
/* uploader.on( 'uploadcomplete', function( file ) {
$( '#'+file.id ).find('.progress').fadeout();
});*/
uploader.on( 'error', function( type ) {
if (type == "q_exceed_num_limit") {
alert("上传的文件数量不能超过" + filenumlimit);
} else if (type == "q_exceed_size_limit") {
alert("上传的文件大小不能超过" + filesinglesizelimit + "字节");
} else if (type == "q_type_denied") {
alert("不支持这种文件类型");
} else if (type == "f_exceed_size") {
alert("上传的文件大小不能超过" + filesinglesizelimit + "字节");
} else if (type == "f_duplicate") {
alert("已经上传过了");
} else {
alert(type);
}
});
$(".removefilelistener").live("click", function(){
removeuploadfile(uploader, $(this));
});
// 为dd添加hover效果 显示功能按钮
$(".file-item").live("mouseenter", function(){
$(this).find(".file-panel").slidedown()
$(this).find(".info").slidedown()
});
$(".file-item").live("mouseleave", function(){
$(this).find(".file-panel").slideup()
$(this).find(".info").slideup()
});
}
/**
*
* @param pickbtn 选取按钮
* @param showlist
* @param filesinglesizelimit 文件大小,int
* @param filenumlimit 文件数量
* @param extensions 扩展名,gif,jpg
* @param mimetypes 类型,image/gif
* @type 文件类型
* @return
*/
function initfileuploader2(pickbtn, showlist, filesinglesizelimit, filenumlimit, extensions, mimetypes, type,obj) {
var base_url = "/jslib/webuploader";
var $list = $("#" + showlist);
var state = "pending";
var datas = {types: ""+type+"",obj: ""+obj+""};
var uploader = webuploader.create({
auto: true,
swf: base_url + '/uploader.swf',
server: '/uploadm/manage',
pick: '#' + pickbtn,
resize: false,
formdata: datas,
fileval: "file",
filenumlimit: filenumlimit,
filesinglesizelimit: filesinglesizelimit,
compress: false,
accept: {
title: 'file',
extensions: extensions,
mimetypes: mimetypes
}
});
// 当有文件被添加进队列的时候
uploader.on( 'filequeued', function( file ) {
$list.append(
''+ file.name +''
/*'' +
'删除
' +
'' + file.name +"("+ math.round(file.size / 1024) +"kb) -100%"+ '
' +
'等待上传...
' +
''*/
);
});
// 文件上传过程中创建进度条实时显示。
uploader.on( 'uploadprogress', function( file, percentage ) {
var $li = $( '#'+file.id ),
$percent = $li.find('.progress .progress-bar');
// 避免重复创建
if ( !$percent.length ) {
$percent = $('').appendto( $li ).find('.progress-bar');
}
$li.find('div.state').text('上传中');
$percent.css( 'width', percentage * 100 + '%' );
});
uploader.on( 'uploadsuccess', function( file, response ) {
$( '#'+file.id ).find('div.state').text('已上传');
//$( '#'+file.id ).append('');
/*var infoobj = eval("("+response._raw+")");
if (infoobj.info.indexof("$$") >= 0) {
alert(infoobj.info.substring(2, infoobj.info.indexof("|")));
return false;
}
*/ $( '#'+file.id ).append("");
settimeout(function () {
$('#'+file.id ).find('div.state').fadeout();
}, 500);
});
uploader.on( 'uploaderror', function( file ) {
$( '#'+file.id ).find('div.error').text('上传出错');
});
uploader.on( 'uploadcomplete', function( file ) {
$( '#'+file.id ).find('.progress').fadeout();
});
uploader.on( 'error', function( type ) {
if (type == "q_exceed_num_limit") {
alert("上传的文件数量不能超过" + filenumlimit);
} else if (type == "q_exceed_size_limit") {
alert("上传的文件大小不能超过" + filesinglesizelimit + "字节");
} else if (type == "q_type_denied") {
alert("不支持这种文件类型");
} else if (type == "f_exceed_size") {
alert("上传的文件大小不能超过" + filesinglesizelimit + "字节");
} else if (type == "f_duplicate") {
alert("已经上传过了");
} else {
alert(type);
}
});
$(".removefilelistener").live("click", function(){
removeuploadfile(uploader, $(this));
});
}
/**
*
* @param pickbtn 选取按钮
* @param showlist
* @param filesinglesizelimit 文件大小,int
* @param filenumlimit 文件数量
* @param extensions 扩展名,gif,jpg
* @param mimetypes 类型,image/gif
* @type 文件类型
* @return
*/
function initfileuploader3(pickbtn, showlist, filesinglesizelimit, filenumlimit, extensions, mimetypes, type,obj) {
var base_url = "/jslib/webuploader";
var $list = $("#" + showlist);
var state = "pending";
var datas = {types: ""+type+"",obj: ""+obj+""};
var uploader = webuploader.create({
auto: true,
swf: base_url + '/uploader.swf',
server: '/uploadm/manage',
pick: '#' + pickbtn,
resize: false,
formdata: datas,
fileval: "file",
filenumlimit: filenumlimit,
filesinglesizelimit: filesinglesizelimit,
compress: false,
accept: {
title: 'file',
extensions: extensions,
mimetypes: mimetypes
}
});
// 当有文件被添加进队列的时候
uploader.on( 'filequeued', function( file ) {
$list.append(
'' +
'删除
' +
'' + file.name +"("+ math.round(file.size / 1024) +"kb) -100%"+ '
' +
'等待上传...
' +
''
);
});
// 文件上传过程中创建进度条实时显示。
uploader.on( 'uploadprogress', function( file, percentage ) {
var $li = $( '#'+file.id ),
/*$percent = $li.find('.progress .progress-bar');*/
$percent=$("#"+showlist);
// 避免重复创建
/* if ( !$percent.length ) {*/
/* $percent = $('').appendto( $li ).find('.progress-bar');*/
/* }*/
$percent.css("width","0%")
$("#easypushpickersp").find('span').text('上传中-'+percentage.tofixed(2) * 100 + '%');
$percent.css( 'width', percentage * 100 + '%' );
});
uploader.on( 'uploadsuccess', function( file, response ) {
$("#easypushpickersp").find('span').text('已上传-100%');
$("#easypushpickersp").attr("style","display:none");
$("#fx_delete").attr("style","display:");
$("#fx_delete").find('span').text('已上传-100%');
$( '#'+file.id ).find('div.state').text('已上传');
//$( '#'+file.id ).append('');
/*var infoobj = eval("("+response._raw+")");
if (infoobj.info.indexof("$$") >= 0) {
alert(infoobj.info.substring(2, infoobj.info.indexof("|")));
return false;
}
*/ $( '#'+file.id ).append("");
settimeout(function () {
$("#"+showlist).fadeout();
$('#'+file.id ).find('div.state').fadeout();
}, 500);
});
uploader.on( 'uploaderror', function( file ) {
$("#easypushpickersp").find('span').text('上传出错');
$( '#'+file.id ).find('div.error').text('上传出错');
});
uploader.on( 'uploadcomplete', function( file ) {
$( '#'+file.id).find('.progress').fadeout();
});
uploader.on( 'error', function( type ) {
if (type == "q_exceed_num_limit") {
alert("上传的文件数量不能超过" + filenumlimit);
} else if (type == "q_exceed_size_limit") {
alert("上传的文件大小不能超过" + filesinglesizelimit + "字节");
} else if (type == "q_type_denied") {
alert("不支持这种文件类型");
} else if (type == "f_exceed_size") {
alert("上传的文件大小不能超过" + filesinglesizelimit + "字节");
}else {
alert(type);
}
});
$(".removefilelistener").live("click", function(){
removeuploadfile(uploader, $(this));
$("#easypushpickersp").attr("style","display:");
$("#easypushpickersp").find("span").text("点击添加视频");
$("#"+showlist).css( 'width','0%' );
$("#fx_delete").attr("style","display:none");
$("#fx_delete").find('span').text('');
});
}
/**
*
* @param pickbtn 选取按钮
* @param uploadbtn 上传按钮
* @param showlist
* @param filesinglesizelimit 文件大小,int
* @param filenumlimit 文件数量
* @param extensions 扩展名,gif,jpg
* @param mimetypes 类型,image/gif
* @param type 文件类型
* @return
*/
function initimageuploader(pickbtn, showlist, filesinglesizelimit, filenumlimit, extensions, mimetypes, type,obj) {
var base_url = "/jslib/webuploader";
var $list = $("#" + showlist);
var state = "pending";
var thumbnailwidth = 120;
var thumbnailheight = 120;
var datas = {types: ""+type+"",obj: ""+obj+""};
$list.addclass("uploader-img-list");
var uploader = webuploader.create({
auto: true,
swf: base_url + '/uploader.swf',
server: '/uploadm/manage',
pick: '#' + pickbtn,
resize: false,
formdata: datas,
fileval: "file",
filenumlimit: filenumlimit,
filesinglesizelimit: filesinglesizelimit,
compress: false,
accept: {
title: 'file',
extensions: extensions,
mimetypes: mimetypes
}
});
// 当有文件被添加进队列的时候
uploader.on( 'filequeued', function( file ) {
//file = eval('('+file+')');
var $li = $(
'' +
'' +
'删除' +
'
' +
'' +
'' + file.name + '
' +
''
),
$img = $li.find('img');
// $list为容器jquery实例
$list.append( $li );
// 创建缩略图
// 如果为非图片文件,可以不用调用此方法。
// thumbnailwidth x thumbnailheight 为 100 x 100
uploader.makethumb( file, function( error, src ) {
if ( error ) {
$img.replacewith('不能预览');
return;
}
$img.attr( 'src', src );
}, thumbnailwidth, thumbnailheight );
});
// 文件上传过程中创建进度条实时显示。
uploader.on( 'uploadprogress', function( file, percentage ) {
var $li = $( '#'+file.id ),
$percent = $li.find('.progress span');
// 避免重复创建
if ( !$percent.length ) {
$percent = $('
')
.appendto( $li )
.find('span');
}
$percent.css( 'width', percentage * 100 + '%' );
});
uploader.on( 'uploadsuccess', function( file, response ) {
$( '#'+file.id ).addclass('upload-state-done');
var infoobj = eval("("+response.message+")");
$( '#'+file.id ).append("");
});
uploader.on( 'uploaderror', function( file ) {
var $li = $( '#'+file.id ),
$error = $li.find('div.error');
// 避免重复创建
if ( !$error.length ) {
$error = $('').appendto( $li );
}
//$error.text('上传失败');
});
uploader.on( 'uploadcomplete', function( file ) {
$( '#'+file.id ).find('.progress').remove();
});
uploader.on( 'error', function( type ) {
if (type == "q_exceed_num_limit") {
alert("上传的文件数量不能超过" + filenumlimit);
} else if (type == "q_exceed_size_limit") {
alert("上传的文件大小不能超过" + filesinglesizelimit + "字节");
} else if (type == "q_type_denied") {
alert("不支持这种文件类型");
} else if (type == "f_exceed_size") {
alert("上传的文件大小不能超过" + filesinglesizelimit + "字节");
} else if (type == "f_duplicate") {
alert("已经上传过了");
} else {
alert(type);
}
});
$(".removefilelistener").live("click", function(){
removeuploadfile(uploader, $(this));
});
// 为dd添加hover效果 显示功能按钮
$(".file-item").live("mouseenter", function(){
$(this).find(".file-panel").slidedown()
$(this).find(".info").slidedown()
});
$(".file-item").live("mouseleave", function(){
$(this).find(".file-panel").slideup()
$(this).find(".info").slideup()
});
}
/**
* 图片上传,根据图片水印设置进行处理
* @param pickbtn 选取按钮
* @param uploadbtn 上传按钮
* @param showlist
* @param filesinglesizelimit 文件大小,int
* @param filenumlimit 文件数量
* @param extensions 扩展名,gif,jpg
* @param mimetypes 类型,image/gif
* @param type 文件类型
* @return
*/
function initimageuploader_sy(pickbtn, showlist, filesinglesizelimit, filenumlimit, extensions, mimetypes, type,obj) {
var base_url = "/jslib/webuploader";
var $list = $("#" + showlist);
var state = "pending";
var thumbnailwidth = 120;
var thumbnailheight = 120;
var datas = {types: ""+type+"",obj: ""+obj+""};
var uploader = webuploader.create({
auto: true,
swf: base_url + '/uploader.swf',
server: '/uploadm/manage1',
pick: '#' + pickbtn,
resize: false,
formdata: datas,
fileval: "file",
filenumlimit: filenumlimit,
filesinglesizelimit: filesinglesizelimit,
compress: false,
accept: {
title: 'file',
extensions: extensions,
mimetypes: mimetypes
}
});
uploader.on( 'uploadbeforesend', function( block, data ) {
delete data.id;
//是否使用水印
var isused=$('.personalsy input:radio[name="isused"]:checked').val();
if(isused!=null && isused!=undefined && isused!=""){
data.isused=isused;
var obj=$('#picturewatermarkform').serializejson();
for(var key in obj){
if(obj.hasownproperty(key)){
data[key]=obj[key];
}
}
}
});
// 当有文件被添加进队列的时候
uploader.on( 'filequeued', function( file ) {
var $li = $(
'' +
'' +
'删除' +
'
' +
'' +
'' + file.name + '
' +
''
),
$img = $li.find('img');
// $list为容器jquery实例
$list.append( $li );
// 创建缩略图
// 如果为非图片文件,可以不用调用此方法。
// thumbnailwidth x thumbnailheight 为 100 x 100
uploader.makethumb( file, function( error, src ) {
if ( error ) {
$img.replacewith('不能预览');
return;
}
$img.attr( 'src', src );
}, thumbnailwidth, thumbnailheight );
});
// 文件上传过程中创建进度条实时显示。
uploader.on( 'uploadprogress', function( file, percentage ) {
var $li = $( '#'+file.id ),
$percent = $li.find('.progress span');
// 避免重复创建
if ( !$percent.length ) {
$percent = $('
')
.appendto( $li )
.find('span');
}
$percent.css( 'width', percentage * 100 + '%' );
});
uploader.on( 'uploadsuccess', function( file, response ) {
$( '#'+file.id ).addclass('upload-state-done');
var infoobj = eval("("+response.message+")");
debugger;
$( '#'+file.id ).append("");
//替换图片的src
var data=eval("("+response.cc+")");
$( '#'+file.id+' img' ).attr( 'src', data.path );
});
uploader.on( 'uploaderror', function( file ) {
var $li = $( '#'+file.id ),
$error = $li.find('div.error');
// 避免重复创建
if ( !$error.length ) {
$error = $('').appendto( $li );
}
//$error.text('上传失败');
});
uploader.on( 'uploadcomplete', function( file ) {
$( '#'+file.id ).find('.progress').remove();
});
uploader.on( 'error', function( type ) {
if (type == "q_exceed_num_limit") {
alert("上传的文件数量不能超过" + filenumlimit);
} else if (type == "q_exceed_size_limit") {
alert("上传的文件大小不能超过" + filesinglesizelimit + "字节");
} else if (type == "q_type_denied") {
alert("不支持这种文件类型");
} else if (type == "f_exceed_size") {
alert("上传的文件大小不能超过" + filesinglesizelimit + "字节");
} else if (type == "f_duplicate") {
alert("已经上传过了");
} else {
alert(type);
}
});
$(".removefilelistener").live("click", function(){
removeuploadfile(uploader, $(this));
});
// 为dd添加hover效果 显示功能按钮
$(".file-item").live("mouseenter", function(){
$(this).find(".file-panel").slidedown()
$(this).find(".info").slidedown()
});
$(".file-item").live("mouseleave", function(){
$(this).find(".file-panel").slideup()
$(this).find(".info").slideup()
});
}
/**
* 图片上传,不根据图片水印设置进行处理
* @param pickbtn 选取按钮
* @param uploadbtn 上传按钮
* @param showlist
* @param filesinglesizelimit 文件大小,int
* @param filenumlimit 文件数量
* @param extensions 扩展名,gif,jpg
* @param mimetypes 类型,image/gif
* @param type 文件类型
* @return
*/
function initimageuploader2(pickbtn, showlist, filesinglesizelimit, filenumlimit, extensions, mimetypes, type,obj) {
var base_url = "/jslib/webuploader";
var $list = $("#" + showlist);
var state = "pending";
var thumbnailwidth = 120;
var thumbnailheight = 120;
var datas = {types: ""+type+"",obj: ""+obj+""};
var uploader = webuploader.create({
auto: true,
swf: base_url + '/uploader.swf',
server: '/uploadm/manage2',
pick: '#' + pickbtn,
resize: false,
formdata: datas,
fileval: "file",
filenumlimit: filenumlimit,
filesinglesizelimit: filesinglesizelimit,
compress: false,
accept: {
title: 'file',
extensions: extensions,
mimetypes: mimetypes
}
});
// 当有文件被添加进队列的时候
uploader.on( 'filequeued', function( file ) {
//file = eval('('+file+')');
var $li = $(
'' +
'' +
'删除' +
'
' +
'' +
'' + file.name + '
' +
''
),
$img = $li.find('img');
// $list为容器jquery实例
$list.append( $li );
// 创建缩略图
// 如果为非图片文件,可以不用调用此方法。
// thumbnailwidth x thumbnailheight 为 100 x 100
uploader.makethumb( file, function( error, src ) {
if ( error ) {
$img.replacewith('不能预览');
return;
}
$img.attr( 'src', src );
}, thumbnailwidth, thumbnailheight );
});
// 文件上传过程中创建进度条实时显示。
uploader.on( 'uploadprogress', function( file, percentage ) {
var $li = $( '#'+file.id+'_sy' ),
$percent = $li.find('.progress span');
// 避免重复创建
if ( !$percent.length ) {
$percent = $('
')
.appendto( $li )
.find('span');
}
$percent.css( 'width', percentage * 100 + '%' );
});
uploader.on( 'uploadsuccess', function( file, response ) {
$( '#'+file.id+'_sy' ).addclass('upload-state-done');
var infoobj = eval("("+response.message+")");
$( '#'+file.id+'_sy' ).append("");
});
uploader.on( 'uploaderror', function( file ) {
var $li = $( '#'+file.id+'_sy' ),
$error = $li.find('div.error');
// 避免重复创建
if ( !$error.length ) {
$error = $('').appendto( $li );
}
//$error.text('上传失败');
});
uploader.on( 'uploadcomplete', function( file ) {
$( '#'+file.id+'_sy' ).find('.progress').remove();
});
uploader.on( 'error', function( type ) {
if (type == "q_exceed_num_limit") {
alert("上传的文件数量不能超过" + filenumlimit);
} else if (type == "q_exceed_size_limit") {
alert("上传的文件大小不能超过" + filesinglesizelimit + "字节");
} else if (type == "q_type_denied") {
alert("不支持这种文件类型");
} else if (type == "f_exceed_size") {
alert("上传的文件大小不能超过" + filesinglesizelimit + "字节");
} else if (type == "f_duplicate") {
alert("已经上传过了");
} else {
alert(type);
}
});
$(".removefilelistener").live("click", function(){
removeuploadfile(uploader, $(this));
});
// 为dd添加hover效果 显示功能按钮
$(".file-item").live("mouseenter", function(){
$(this).find(".file-panel").slidedown()
$(this).find(".info").slidedown()
});
$(".file-item").live("mouseleave", function(){
$(this).find(".file-panel").slideup()
$(this).find(".info").slideup()
});
}
/**
*
* @param pickbtn 选取按钮
* @param uploadbtn 上传按钮
* @param showlist
* @param filesinglesizelimit 文件大小,int
* @param filenumlimit 文件数量
* @param extensions 扩展名,gif,jpg
* @param mimetypes 类型,image/gif
* @param type 文件类型
* @return
*/
function initimageuploader3(pickbtn, showlist, filesinglesizelimit, filenumlimit, extensions, mimetypes, type,obj) {
var base_url = "/jslib/webuploader";
var $list = $("#" + showlist);
var state = "pending";
var thumbnailwidth = 640;
var thumbnailheight =1000;
var datas = {types: ""+type+"",obj: ""+obj+""};
var uploader = webuploader.create({
auto: true,
swf: base_url + '/uploader.swf',
server: '/uploadm/manage',
pick: '#' + pickbtn,
resize: false,
formdata: datas,
fileval: "file",
filenumlimit: filenumlimit,
filesinglesizelimit: filesinglesizelimit,
compress: false,
accept: {
title: 'file',
extensions: extensions,
mimetypes: mimetypes
}
});
// 当有文件被添加进队列的时候
uploader.on( 'filequeued', function( file ) {
//file = eval('('+file+')');
var txt=''
var pc;
if(showlist=="uploadfm"){
pc="fm";
}else{
if(showlist=="uploadlistmore"){
pc=$("#alllist").children().length+1;
}
}
var $li=$(
'' +
'' +
'
'
);
if(showlist=="uploadfm"){
// $list为容器jquery实例
$list.append( $li );
}else{
if(showlist=="uploadlistmore"){
$("#alllist").append(txt);
$("#alllist").children("div:last-child").attr("id","fx_excreatbtnnr"+pc);
$("#alllist").children("div:last-child").find("dl").append($li);
}
}
// 创建缩略图
// 如果为非图片文件,可以不用调用此方法。
// thumbnailwidth x thumbnailheight 为 100 x 100
uploader.makethumb( file, function( error, src ) {
if ( error ) {
$img.replacewith('不能预览');
return;
}
if(showlist=="uploadfm"){
$("#fx_excreatbtnfm").css({'background':'url('+src+')','background-size':'cover'});
/* $(".fx_excreatbtnc1box").attr("style","display:none");*/
}else{
if(showlist=="uploadlistmore"){
$("#alllist").children("div:last-child").find("img").attr('src',src);
}
}
}, thumbnailwidth, thumbnailheight );
});
// 文件上传过程中创建进度条实时显示。
uploader.on( 'uploadprogress', function( file, percentage ) {
var $li = $( '#'+file.id ),
$percent = $li.find('.progress span');
// 避免重复创建
if ( !$percent.length ) {
$percent = $('
')
.appendto( $li )
.find('span');
}
$percent.css( 'width', percentage * 100 + '%' );
});
uploader.on( 'uploadsuccess', function( file, response ) {
$( '#'+file.id ).addclass('upload-state-done');
//$( '#'+file.id ).append('');
var infoobj = eval("("+response.message+")");
if(showlist=="uploadfm"){
$list.find("dd").append("");
}else{
if(showlist=="uploadlistmore"){
$("#alllist").children("div:last-child").find("dl").find("dd").append("");
/*}else{
$list.find("dd").append("");
}*/
}
}
});
uploader.on( 'uploaderror', function( file ) {
var $li = $( '#'+file.id ),
$error = $li.find('div.error');
// 避免重复创建
if ( !$error.length ) {
$error = $('').appendto( $li );
}
//$error.text('上传失败');
});
uploader.on( 'uploadcomplete', function( file ) {
$( '#'+file.id ).find('.progress').remove();
});
uploader.on( 'error', function( type ) {
if (type == "q_exceed_num_limit") {
alert("上传的文件数量不能超过" + filenumlimit);
} else if (type == "q_exceed_size_limit") {
alert("上传的文件大小不能超过" + filesinglesizelimit + "字节");
} else if (type == "q_type_denied") {
alert("不支持这种文件类型");
} else if (type == "f_exceed_size") {
alert("上传的文件大小不能超过" + filesinglesizelimit + "字节");
} else {
alert(type);
}
});
$(".removefilelistener").live("click", function(){
removeuploadfile(uploader, $(this));
if($(this).parent().attr("id")=="fm"){
$("#fx_excreatbtnfm").css( 'background','url(/subsitesrc/mobile/images/extend/bg1.jpg)');
$(".fx_excreatbtnc1box").attr("style","display:block;");
}else{
$("#fx_excreatbtnnr"+$(this).parent().attr("id")).remove();
}
/*if(showlist=="uploadlistmore"){
if($("#alllist div").length>1){
$("#alllist div").eq($("#alllist div").length-1).css( 'background','url('+src+')');
}else{
$("#fx_excreatbtnnr").css( 'background','url('+src+')');
}
}else{*/
/*$(this).parent().remove();*/
/* } */
});
// 为dd添加hover效果 显示功能按钮
$(".file-item").live("mouseenter", function(){
$(this).find(".file-panel").slidedown()
$(this).find(".info").slidedown()
});
$(".file-item").live("mouseleave", function(){
$(this).find(".file-panel").slideup()
$(this).find(".info").slideup()
});
}
/*function removeuploadfile(uploader, obj) {
var parentobj = obj.parents("dd").eq(0);
var id = parentobj.attr("id");
if(isnan(id)) id = 0;
try {
//被上传控件托管,还没有进入annex,直接删除文件即可
uploader.removefile(id, true);
//物理删除
var filepath = parentobj.find("input").val();
filepath = filepath.substring(0, filepath.indexof("|"));
jquery.ajax({
type:'post',
datatype:'text',
url:'/uploadm/remove',
data: 'filepath=' + filepath + '&t=' + myjs.randomnumber,
success:function(data){
}
});
} catch (e){
//不在上传控件中托管,已进入annex,需要删除annex
jquery.ajax({
type:'post',
datatype:'text',
url:'/uploadm/remove',
data: 'annexid=' + id + '&t=' + myjs.randomnumber,
success:function(data){
}
});
}
parentobj.remove();
}*/
/**
* 视频上传附件
* @param pickbtn 选取按钮
* @param showlist
* @param filesinglesizelimit 文件大小,int
* @param filenumlimit 文件数量
* @param extensions 扩展名,gif,jpg
* @param mimetypes 类型,image/gif
* @type 文件类型
* @return
*/
function initfileuploader4(pickbtn, showlist, filesinglesizelimit, filenumlimit, extensions, mimetypes, type,obj) {
var base_url = "/jslib/webuploader";
var $list = $("#" + showlist);
var state = "pending";
var datas = {types: ""+type+"",obj: ""+obj+""};
var uploader = webuploader.create({
auto: true,
swf: base_url + '/uploader.swf',
server: '/uploadm/manage',
pick: '#' + pickbtn,
resize: false,
formdata: datas,
fileval: "file",
filenumlimit: filenumlimit,
filesinglesizelimit: filesinglesizelimit,
compress: false,
accept: {
title: 'file',
extensions: extensions,
mimetypes: mimetypes
}
});
// 当有文件被添加进队列的时候
uploader.on( 'filequeued', function( file ) {
$list.append(
'' +
'' +
'删除' +
'
' +
'' +
'' + file.name + '
' +
'等待上传...
' +
''
);
/*$img = $list.find('img');
if(type=="video"){
$img.attr("src","/jslib/admin/images/video.png");
}*/
});
// 文件上传过程中创建进度条实时显示。
uploader.on( 'uploadprogress', function( file, percentage ) {
var $li = $( '#'+file.id ),
$percent = $li.find('.progress .progress-bar');
// 避免重复创建
if ( !$percent.length ) {
$percent = $('').appendto( $li ).find('.progress-bar');
}
var fs=(percentage * 100).tofixed(2);
$li.find('div.state').text('上传中'+fs+ '%');
$percent.css( 'width', percentage * 100 + '%' );
});
uploader.on( 'uploadsuccess', function( file, response ) {
$( '#'+file.id ).find('div.state').text('已上传');
$( '#'+file.id ).append("");
settimeout(function () {
$('#'+file.id ).find('div.state').fadeout();
}, 500);
$img = $list.find('img');
if(type=="video"){
$img.attr("src","/jslib/admin/images/video.png");
}
});
uploader.on( 'uploaderror', function( file ) {
$( '#'+file.id ).find('div.error').text('上传出错');
});
uploader.on( 'uploadcomplete', function( file ) {
$( '#'+file.id ).find('.progress').fadeout();
});
uploader.on( 'error', function( type ) {
alert(type)
if (type == "q_exceed_num_limit") {
alert("上传的文件数量不能超过" + filenumlimit);
} else if (type == "q_exceed_size_limit") {
alert("上传的文件大小不能超过" + filesinglesizelimit + "字节");
} else if (type == "q_type_denied") {
alert("不支持这种文件类型");
} else if (type == "f_exceed_size") {
alert("上传的文件大小不能超过" + filesinglesizelimit + "字节");
} else {
alert(type);
}
});
$(".removefilelistener").live("click", function(){
removeuploadfile(uploader, $(this));
});
// 为dd添加hover效果 显示功能按钮
$(".file-item").live("mouseenter", function(){
$(this).find(".file-panel").slidedown()
$(this).find(".info").slidedown()
});
$(".file-item").live("mouseleave", function(){
$(this).find(".file-panel").slideup()
$(this).find(".info").slideup()
});
}
function removeuploadfile(uploader,obj) {
var parentobj = obj.parent().parent();
var id = parentobj.attr("id");
if(isnan(id)){
//被上传控件托管,还没有进入annex,直接删除文件即可
try {
uploader.removefile(id, true);
} catch (e) {
// todo: handle exception
}
}else{
//物理删除
var filepath = parentobj.find("input").val();
filepath = filepath.substring(0, filepath.indexof("|"));
jquery.ajax({
type:'post',
datatype:'text',
url:'/uploadm/deletefile',
data: 'annexid='+id,
success:function(data){
}
});
}
parentobj.remove();
}
/**
* 单独处理给图片添加水印
* @param pickbtn 选取按钮
* @param uploadbtn 上传按钮
* @param showlist
* @param filesinglesizelimit 文件大小,int
* @param filenumlimit 文件数量
* @param extensions 扩展名,gif,jpg
* @param mimetypes 类型,image/gif
* @param type 文件类型
* @return
*/
function initimageuploaderone(pickbtn, showlist, filesinglesizelimit, filenumlimit, extensions, mimetypes, type,obj) {
var base_url = "/jslib/webuploader";
var $list = $("#" + showlist);
var state = "pending";
var thumbnailwidth = 120;
var thumbnailheight = 120;
var datas = {types: ""+type+"",obj: ""+obj+""};
$list.addclass("uploader-img-list");
var uploader = webuploader.create({
auto: true,
swf: base_url + '/uploader.swf',
server: '/uploadm/manage',
pick: '#' + pickbtn,
resize: false,
formdata: datas,
fileval: "file",
filenumlimit: filenumlimit,
filesinglesizelimit: filesinglesizelimit,
compress: false,
accept: {
title: 'file',
extensions: extensions,
mimetypes: mimetypes
}
});
// 当有文件被添加进队列的时候
uploader.on( 'filequeued', function( file ) {
//file = eval('('+file+')');
var $li = $(
'' +
'' +
'删除' +
'
' +
'' +
'' + file.name + '
' +
''
),
$img = $li.find('img');
// $list为容器jquery实例
$list.append( $li );
// 创建缩略图
// 如果为非图片文件,可以不用调用此方法。
// thumbnailwidth x thumbnailheight 为 100 x 100
uploader.makethumb( file, function( error, src ) {
if ( error ) {
$img.replacewith('不能预览');
return;
}
$img.attr( 'src', src );
}, thumbnailwidth, thumbnailheight );
});
// 文件上传过程中创建进度条实时显示。
uploader.on( 'uploadprogress', function( file, percentage ) {
var $li = $( '#'+file.id ),
$percent = $li.find('.progress span');
// 避免重复创建
if ( !$percent.length ) {
$percent = $('
')
.appendto( $li )
.find('span');
}
$percent.css( 'width', percentage * 100 + '%' );
});
uploader.on( 'uploadsuccess', function( file, response ) {
$( '#'+file.id ).addclass('upload-state-done');
var infoobj = eval("("+response.message+")");
$( '#'+file.id ).append("");
var data = eval("("+response.cc+")");
var img = new image();
img.src = data.path;
img.onload = function(){
var width=img.width;
var height=img.height;
if(width>450||height>450){
rw=width/450;
rh=height/450;
if(rw>rh){
height=height/rw;
width=450;
}else{
width=width/rh;
height=450;
}
}
img.height=height;
img.width=width;
$(".watershow").css("width",width);
$(".watershow").css("height",height);
$(".watershow").css({"background":"#f5f5f5 url("+data.path+")","background-size":"contain"});
//$("#sourceimgurl").val(data.path);
/*canvas*/
/*var c=document.getelementbyid("mycanvas");
c.width=img.width;
c.height=img.height;
ctx=c.getcontext("2d");
ctx.drawimage(img,0,0);*/
//drawpic();
};
});
uploader.on( 'uploaderror', function( file ) {
var $li = $( '#'+file.id ),
$error = $li.find('div.error');
// 避免重复创建
if ( !$error.length ) {
$error = $('').appendto( $li );
}
//$error.text('上传失败');
});
uploader.on( 'uploadcomplete', function( file ) {
$( '#'+file.id ).find('.progress').remove();
});
uploader.on( 'error', function( type ) {
if (type == "q_exceed_num_limit") {
alert("上传的文件数量不能超过" + filenumlimit);
} else if (type == "q_exceed_size_limit") {
alert("上传的文件大小不能超过" + filesinglesizelimit + "字节");
} else if (type == "q_type_denied") {
alert("不支持这种文件类型");
} else if (type == "f_exceed_size") {
alert("上传的文件大小不能超过" + filesinglesizelimit + "字节");
} else if (type == "f_duplicate") {
alert("已经上传过了");
} else {
alert(type);
}
});
$(".removefilelistener").live("click", function(){
removeuploadfile(uploader, $(this));
});
// 为dd添加hover效果 显示功能按钮
$(".file-item").live("mouseenter", function(){
$(this).find(".file-panel").slidedown()
$(this).find(".info").slidedown()
});
$(".file-item").live("mouseleave", function(){
$(this).find(".file-panel").slideup()
$(this).find(".info").slideup()
});
}
function reloadpage(){
$("#picturelistsy .removefilelistener").click();
$("ul.accordion li a.hover").click();
}
/**
* 单独处理给图片添加水印图片
* @param pickbtn 选取按钮
* @param uploadbtn 上传按钮
* @param showlist
* @param filesinglesizelimit 文件大小,int
* @param filenumlimit 文件数量
* @param extensions 扩展名,gif,jpg
* @param mimetypes 类型,image/gif
* @param type 文件类型
* @return
*/
function initimageuploaderonesylogo(pickbtn, showlist, filesinglesizelimit, filenumlimit, extensions, mimetypes, type,obj) {
var base_url = "/jslib/webuploader";
var $list = $("#" + showlist);
var state = "pending";
var thumbnailwidth = 120;
var thumbnailheight = 120;
var datas = {types: ""+type+"",obj: ""+obj+""};
$list.addclass("uploader-img-list");
var uploader = webuploader.create({
auto: true,
swf: base_url + '/uploader.swf',
server: '/uploadm/manage',
pick: '#' + pickbtn,
resize: false,
formdata: datas,
fileval: "file",
filenumlimit: filenumlimit,
filesinglesizelimit: filesinglesizelimit,
compress: false,
accept: {
title: 'file',
extensions: extensions,
mimetypes: mimetypes
}
});
// 当有文件被添加进队列的时候
uploader.on( 'filequeued', function( file ) {
//file = eval('('+file+')');
var $li = $(
'' +
'' +
'删除' +
'
' +
'' +
'' + file.name + '
' +
''
),
$img = $li.find('img');
// $list为容器jquery实例
$list.append( $li );
// 创建缩略图
// 如果为非图片文件,可以不用调用此方法。
// thumbnailwidth x thumbnailheight 为 100 x 100
uploader.makethumb( file, function( error, src ) {
if ( error ) {
$img.replacewith('不能预览');
return;
}
$img.attr( 'src', src );
}, thumbnailwidth, thumbnailheight );
});
// 文件上传过程中创建进度条实时显示。
uploader.on( 'uploadprogress', function( file, percentage ) {
var $li = $( '#'+file.id ),
$percent = $li.find('.progress span');
// 避免重复创建
if ( !$percent.length ) {
$percent = $('
')
.appendto( $li )
.find('span');
}
$percent.css( 'width', percentage * 100 + '%' );
});
uploader.on( 'uploadsuccess', function( file, response ) {
$( '#'+file.id ).addclass('upload-state-done');
var infoobj = eval("("+response.message+")");
$( '#'+file.id ).append("");
var data = eval("("+response.cc+")");
var img = new image();
img.src = data.path;
img.onload = function(){
$("#sylogo").attr("src",data.path);
$("#sylogo").css('width','');
$("#sylogo").css('height','');
var height=img.height;
var defaultb = 30/height;
var tdefault = math.round(($('#picsizethumb').parent().width() - $('#picsizethumb').outerwidth())*defaultb/5);
$('#picsizethumb').css("left",tdefault+"px");
$("#watermarksize").val(defaultb);
};
});
uploader.on( 'uploaderror', function( file ) {
var $li = $( '#'+file.id ),
$error = $li.find('div.error');
// 避免重复创建
if ( !$error.length ) {
$error = $('').appendto( $li );
}
//$error.text('上传失败');
});
uploader.on( 'uploadcomplete', function( file ) {
$( '#'+file.id ).find('.progress').remove();
});
uploader.on( 'error', function( type ) {
if (type == "q_exceed_num_limit") {
alert("上传的文件数量不能超过" + filenumlimit);
} else if (type == "q_exceed_size_limit") {
alert("上传的文件大小不能超过" + filesinglesizelimit + "字节");
} else if (type == "q_type_denied") {
alert("不支持这种文件类型");
} else if (type == "f_exceed_size") {
alert("上传的文件大小不能超过" + filesinglesizelimit + "字节");
} else if (type == "f_duplicate") {
alert("已经上传过了");
} else {
alert(type);
}
});
$(".removefilelistener").live("click", function(){
removeuploadfile(uploader, $(this));
});
// 为dd添加hover效果 显示功能按钮
$(".file-item").live("mouseenter", function(){
$(this).find(".file-panel").slidedown()
$(this).find(".info").slidedown()
});
$(".file-item").live("mouseleave", function(){
$(this).find(".file-panel").slideup()
$(this).find(".info").slideup()
});
}
/*删除水印logo*/
function delsylogo(){
$("#sylogo").attr("src",'http://www.aykj.net/subsitesrc/aykjnet/images/logo.svg');
$("#sylogo").css('width','');
$("#sylogo").css('height','');
}