!
function(a, b) {
"function" == typeof define && define.amd ? define(["jquery", "underscore", "webuploader", "jquery.jplayer", "bootstrap", "filestyle"],
function(c, d, e) {
return a.fileUploader = b(c, d, e)
}) : "object" == typeof module && "object" == typeof module.exports ? module.exports = b(require("jquery"), require("underscore"), require("webuploader"), require("jquery.jplayer"), require("bootstrap"), require("filestyle")) : a.fileUploader = b(jQuery, underscore, WebUploader)
} (window,
function(a, b, c) {
var d = {
defaultoptions: {
direct: !1,
global: !1,
dest_dir: "",
callback: null,
type: "image",
mode: "",
multiple: !0,
allowUploadVideo: !0,
fileSizeLimit: !1,
uploader: {}
},
uploader: {},
show: function(a, b) {
return this.init(a, b)
},
init: function(b, c) {
var d = this;
if (d.options = a.extend({},
d.defaultoptions, c), d.options.callback = b, this.options.isWechat) {
if (c.account_error) return util.message("公众号号没有上传素材的权限", "", "info"),
!1
} else this.options.global ? this.options.global = "global": this.options.global = "",
document.cookie = "__fileupload_type=" + escape(this.options.type),
document.cookie = "__fileupload_dest_dir=" + escape(this.options.dest_dir),
document.cookie = "__fileupload_global=" + escape(this.options.global);
return a("#modal-webuploader").remove(),
0 == a("#modal-webuploader").length && a(document.body).append(d.buildHtml().mainDialog),
d.modalobj = a("#modal-webuploader"),
d.modalobj.modal("show"),
d.modalobj.on("shown.bs.modal",
function() {
if (!a(this).data("init")) {
switch (d.options.type) {
case "image":
case "thumb":
d.options.isWechat || d.initRemote(),
d.initLocal();
break;
case "audio":
d.initLocalAudio();
break;
case "voice":
d.initLocalVoice();
break;
case "video":
d.options.isWechat || d.initVideoRemote(),
d.options.allowUploadVideo && d.initLocalVideo()
}
d.options.allowUploadVideo && d["init" + d.options.type.substring(0, 1).toUpperCase() + d.options.type.substring(1) + "Uploader"]()
}
}),
d.modalobj
},
initUploader: function(b) {
function e(e) {
var f = a('
" + e.name + '
"),
g = a('删除
').appendTo(f),
h = f.find("p.progress span"),
i = f.find("p.imgWrap"),
j = a(''),
k = function(a) {
switch (a) {
case "exceed_size":
text = "文件大小超出";
break;
case "interrupt":
text = "上传暂停";
break;
default:
text = "上传失败,请重试"
}
j.text(text).appendTo(f)
};
"invalid" === e.getStatus() ? k(e.statusText) : ("image" == b ? (i.text("预览中"), d.makeThumb(e,
function(b, c) {
if (b) return void i.text("不能预览");
var d = a('
');
i.empty().append(d)
},
thumbnailWidth, thumbnailHeight)) : i.text(c.formatSize(e.size) + " kb"), percentages[e.id] = [e.size, 0], e.rotation = 0),
e.on("statuschange",
function(a, c) {
"progress" === c ? h.hide().width(0) : "queued" === c && (f.off("mouseenter mouseleave"), g.remove()),
"error" === a || "invalid" === a ? (k(e.statusText), percentages[e.id][1] = 1) : "interrupt" === a ? k("interrupt") : "queued" === a ? percentages[e.id][1] = 0 : "progress" === a && (j.remove(), "image" == b && h.css("display", "block")),
f.removeClass("state-" + c).addClass("state-" + a)
}),
f.on("mouseenter",
function() {
g.stop().animate({
height: 30
})
}),
f.on("mouseleave",
function() {
g.stop().animate({
height: 0
})
}),
g.on("click", "span",
function() {
var b, c = a(this).index();
switch (c) {
case 0:
return void d.removeFile(e);
case 1:
e.rotation += 90;
break;
case 2:
e.rotation -= 90
}
supportTransition ? (b = "rotate(" + e.rotation + "deg)", i.css({
"-webkit-transform": b,
"-mos-transform": b,
"-o-transform": b,
transform: b
})) : i.css("filter", "progid:DXImageTransform.Microsoft.BasicImage(rotation=" + ~~ (e.rotation / 90 % 4 + 4) % 4 + ")")
}),
p.options.multiple && r.find(".fileinput-button").show(),
f.insertBefore(r.find(".fileinput-button"))
}
function f(b) {
var c = a("#" + b.id);
delete percentages[b.id],
g(),
c.off().find(".file-panel").off().end().remove()
}
function g() {
var b, c = 0,
d = 0,
e = w.children();
a.each(percentages,
function(a, b) {
d += b[0],
c += b[0] * b[1]
}),
b = d ? c / d: 0,
e.eq(0).text(Math.round(100 * b) + "%"),
e.eq(1).css("width", Math.round(100 * b) + "%"),
h()
}
function h() {
var a, b = "";
if ("ready" === state) {
if (p.options.isWechat) {
if ("" == p.options.mode) var e = p.modalobj.find(".nav-pills li.active").attr("data-mode");
else var e = p.options.mode;
p.options.flag || (d.option("server", d.option("server") + "&mode=" + e + "&types=" + p.options.type), p.options.flag = 1)
}
b = "选中" + fileCount + typeUnit + j + ",共" + c.formatSize(fileSize) + "。"
} else "confirm" === state ? (a = d.getStats(), a.uploadFailNum && (b = "已上传" + a.successNum + typeUnit + j + "," + a.uploadFailNum + typeUnit + j + '上传失败,重新上传失败' + j + '或忽略')) : (a = d.getStats(), b = "共" + fileCount + typeUnit + "(" + c.formatSize(fileSize) + "),已上传" + a.successNum + typeUnit, a.uploadFailNum && (b += ",失败" + a.uploadFailNum + typeUnit));
t.html(b)
}
function i(b) {
var c;
if (b !== state) {
switch (u.removeClass("state-" + state), u.addClass("state-" + b), state = b, state) {
case "pedding":
v.removeClass("element-invisible"),
r.hide(),
d.refresh();
break;
case "ready":
v.addClass("element-invisible"),
p.options.isWechat && "video" == p.options.type && a("#upload form").removeClass("hide"),
r.show(),
d.refresh();
break;
case "uploading":
w.show(),
u.text("暂停上传");
break;
case "paused":
w.show(),
u.text("继续上传");
break;
case "confirm":
if (w.hide(), u.text("开始上传").addClass("disabled"), c = d.getStats(), c.successNum && !c.uploadFailNum) return void i("finish");
break;
case "finish":
if (u.removeClass("disabled"), c = d.getStats(), c.successNum) {
if (d.uploadedFiles.length > 0) return p.finish(d.uploadedFiles),
void d.resetUploader()
} else state = "done",
location.reload()
}
h()
}
}
var j, k, l, m, n, o, p = this;
switch (b) {
case "image":
j = "图片",
typeUnit = "张",
k = {
title: "Images",
extensions: "gif,jpg,jpeg,bmp,png,ico",
mimeTypes: "image/*"
},
l = 30,
m = 5242880,
n = l * m,
o = p.options.isWechat ? {
quality: 80,
preserveHeaders: !0,
noCompressIfLarger: !0,
compressSize: 1048576
}: !1;
break;
case "audio":
case "voice":
j = "音频",
typeUnit = "个",
k = {
title: "Audios",
extensions: "mp3,wma,wav,amr",
mimeTypes: "audio/*"
},
l = 30,
m = 6291456,
n = l * m,
o = !1,
p.options.isWechat && (l = 5, "temp" == p.options.mode ? (k.extensions = "mp3", m = 2097152, n = 10485760) : (m = 5242880, n = 26214400));
break;
case "video":
j = "视频",
typeUnit = "个",
k = {
title: "Video",
extensions: "mpeg,mp4",
mimeTypes: "video/*"
},
l = 30,
m = 20971520,
n = l * m,
o = !1,
p.options.isWechat && (l = 5, "temp" == p.options.mode ? (k.extensions = "mp4", m = 10485760, n = 52428800) : (m = 20971520, n = 104857600))
}
p.options.isWechat ? (p.options.flag = 0, p.modalobj.find("#li_upload_perm a").html("上传永久" + j), p.modalobj.find("#li_upload_temp a").html("上传临时" + j + "(保留3天)")) : p.modalobj.find("#li_upload a").html("上传" + j),
p.modalobj.find(".modal-body").append(this.buildHtml().uploaderDialog);
var q = a("#uploader"),
r = a('').appendTo(q.find(".queueList")),
s = q.find(".statusBar"),
t = s.find(".info"),
u = q.find(".uploadBtn"),
v = q.find(".placeholder"),
w = s.find(".progress").hide();
q.find(".btn-primary");
fileCount = 0,
fileSize = 0,
ratio = window.devicePixelRatio || 1,
thumbnailWidth = 110 * ratio,
thumbnailHeight = 110 * ratio,
state = "pedding",
percentages = {},
supportTransition = function() {
var a = document.createElement("p").style,
b = "transition" in a || "WebkitTransition" in a || "MozTransition" in a || "msTransition" in a || "OTransition" in a;
return a = null,
b
} (),
d;
var x = {
pick: {
id: "#filePicker",
label: "点击选择" + j,
multiple: !0
},
dnd: "#dndArea",
paste: "#uploader",
swf: "./resource/componets/webuploader/Uploader.swf",
server: p.options.isWechat ? "./index.php?c=utility&a=wechat_file&do=upload": "./index.php?c=utility&a=file&do=upload&upload_type=" + b,
compress: o,
accept: k,
fileNumLimit: l,
fileSizeLimit: n,
fileSingleSizeLimit: m,
threads:1
};
x = a.extend({},
x, p.options.uploader),
x.pick.multiple = p.options.multiple,
x.isWechat = p.options.isWechat,
x.type = p.options.type,
"audio" == b || "voice" == b ? p.options.isWechat ? a("#dndArea p").html("临时语音只支持amr/mp3格式,大小不超过为2M,长度不超过60秒
永久语音只支持mp3/wma/wav/amr格式,大小不超过为5M,长度不超过60秒") : a("#dndArea p").html("最大支持 " + c.formatSize(x.fileSingleSizeLimit) + " MB 以内的语音 (" + x.accept.extensions + " 格式)") : "video" == b && (p.options.isWechat ? a("#dndArea p").html("临时视频只支持mp4格式,大小不超过为10M
永久视频只支持rm/rmvb/wmv/avi/mpg/mpeg/mp4格式,大小不超过为20M") : a("#dndArea p").html("最大支持 " + c.formatSize(x.fileSingleSizeLimit) + " MB 以内的视频 (" + x.accept.extensions + " 格式)")),
p.options.fileSizeLimit && (x.fileSizeLimit = p.options.fileSizeLimit),
console.dir(x),
d = c.create(x),
d.uploadedFiles = [],
d.addButton({
id: "#filePicker2",
innerHTML:`+
`,
label: "+",
multiple: p.options.multiple
}),
k = 0,
d.resetUploader = function() {
if (fileCount = 0, fileSize = 0, k = 0, d.uploadedFiles = [], a.each(d.getFiles(),
function(a, b) {
f(b)
}), p.options.isWechat) {
p.options.video && (a("#upload :text[name='title']").val(""), a("#upload :text[name='introduction']").val("")),
g(),
d.reset(),
d.refresh(),
a("#dndArea").removeClass("element-invisible"),
a("#uploader").find(".filelist").empty(),
a("#filePicker").find(".webuploader-pick").next().css({
left: "190px"
});
var b = a("#uploader").find(".statusBar");
b.find(".info").empty(),
b.find(".accept").empty(),
b.hide()
} else d.refresh(),
d.reset(),
u.removeClass("disabled"),
i("pedding")
},
d.onUploadProgress = function(b, c) {
var d = a("#" + b.id),
e = d.find(".progress span");
e.css("width", 100 * c + "%"),
percentages[b.id][1] = c,
fileid = b.id,
g()
},
d.onFileQueued = function(a) {
fileCount++,
fileSize += a.size,
1 === fileCount && (v.addClass("element-invisible"), s.show()),
e(a),
i("ready"),
g()
},
d.onFileDequeued = function(a) {
fileCount--,
fileSize -= a.size,
fileCount || i("pedding"),
f(a),
g()
},
d.on("all",
function(a) {
switch (a) {
case "uploadFinished":
i("confirm");
break;
case "startUpload":
i("uploading");
break;
case "stopUpload":
i("paused")
}
}),
d.on("uploadSuccess",
function(b, c) {
return c.message ? (alert(c.message), void d.resetUploader()) : void((c.attachment || c.media_id) && (k++, d.uploadedFiles.push(c), a("#" + b.id).append('' + c.width + "x" + c.height + ""), a(".accept").text("成功上传 " + k + " " + typeUnit + j)))
}),
d.onError = function(a) {
return "Q_EXCEED_SIZE_LIMIT" == a ? void alert("错误信息: " + j + "大于 " + c.formatSize(x.fileSizeLimit) + " 无法上传.") : "F_DUPLICATE" == a ? void alert("错误信息: 不能重复上传" + j + ".") : void alert("Eroor: " + a)
},
u.on("click",
function() {
if (a(this).hasClass("disabled")) return ! 1;
if ("pedding" != state && d.options.isWechat && "video" == d.options.type) {
var b = a('#upload :text[name="title"]').val(),
c = a('#upload textarea[name="introduction"]').val();
if (!b) return util.message("视频标题不能为空"),
!1;
if (!c) return util.message("视频描述不能为空"),
!1;
d.option("formData", {
title: b,
introduction: c
})
}
"ready" === state ? d.upload() : "paused" === state ? d.upload() : "uploading" === state && d.stop()
}),
t.on("click", ".retry",
function() {
d.retry()
}),
t.on("click", ".ignore",
function() {}),
u.addClass("state-" + state),
g()
},
initImageUploader: function() {
this.initUploader("image")
},
initAudioUploader: function() {
this.initUploader("audio")
},
initVoiceUploader: function() {
this.initUploader("voice")
},
initVideoUploader: function() {
this.initUploader("video")
},
initRemote: function() {
var b = this;
b.modalobj.find("#li_network").removeClass("hide"),
b.modalobj.find(".modal-body").append(b.buildHtml().remoteDialog),
b.modalobj.find(".btn-primary").click(function() {
var c = b.modalobj.find("#networkurl").val();
c.length > 0 && "image" == b.options.type && a.getJSON("./index.php?c=utility&a=file&do=fetch", {
url: c
},
function(a) {
a.message && alert(a.message),
a && (b.finish([a]), a = {})
})
})
},
initVideoRemote: function() {
function b(b) {
if (b) {
var e = c(b);
e = d(e),
a("#preview").html('只支持 腾讯,优酷,土豆视频,如无法预览视频,请前往视频网址处的分享区域,复制通用地址到编辑器内部!
')
}
}
function c(a) {
if (!a) return "";
var b, c;
if (a.indexOf("v.qq.com") >= 0) {
if (b = a.match(/vid\=([^\&]*)($|\&)/), b ? c = "http://v.qq.com/iframe/player.html?vid=" + b[1] + "&tiny=0&auto=0": (b = a.match(/\/([0-9a-zA-Z]+).html/), b && (c = "http://v.qq.com/iframe/player.html?vid=" + b[1] + "&tiny=0&auto=0")), !b) return
} else if (a.indexOf("v.youku.com") >= 0) b = a.match(/id_(.*)\.html/),
c = "http://player.youku.com/embed/" + b[1];
else {
if (! (a.indexOf("tudou.com") >= 0)) return;
b = a.match(/\/([-\w]+)/g),
b = b[b.length - 1].substring(1),
c = "http://www.tudou.com/programs/view/html5embed.action?code=" + b
}
return c
}
function d(a, b) {
return a ? a.replace(b || /[<">']/g,
function(a) {
return {
"<": "<",
"&": "&",
'"': """,
">": ">",
"'": "'"
} [a]
}) : ""
}
var e = this;
e.modalobj.find("#li_network").removeClass("hide"),
e.modalobj.find(".modal-body").append(e.buildHtml().remoteVideoDialog),
e.modalobj.find("#networkurl").blur(function() {
var c = a(this).val();
c.length > 0 ? b(c) : a("#preview").html("")
}),
e.modalobj.find(".btn-primary").click(function() {
var a = e.modalobj.find("#networkurl").val();
if (a.length > 0 && "video" == e.options.type) {
var b = c(a);
b = d(b),
e.finish([{
url: b,
isRemote: !0
}])
}
})
},
initLocal: function() {
var a = this;
a.modalobj.find("#li_history_image").removeClass("hide"),
a.modalobj.find(".modal-body").append(this.buildHtml().localDialog),
a.localPage(1)
},
localPage: function(c) {
var d = this;
if (d.options.isWechat) var e = d.options.type,
f = d.options.mode,
g = "./index.php?c=utility&a=wechat_file&do=browser",
h = {
page: c,
type: e,
mode: f,
psize: 32
};
else var i = d.modalobj.find("#select-year .btn-info").data("id"),
j = d.modalobj.find("#select-month .btn-info").data("id"),
g = "./index.php?c=utility&a=file&do=image&local=local&group_id=-999",
h = {
page: c,
year: i,
month: j,
psize: 32
};
var k = d.modalobj.find("#history_image");
return a.getJSON(g, h,
function(c) {
c = c.message.message,
k.find(".history-content").css("text-align", "center").html(''),
k.find("#image-list-pager").html(""),
b.isEmpty(c.items) ? k.find(".history-content").css("text-align", "left").html(' 暂无数据') : (k.data("attachment", c.items),
k.find(".history-content").empty(),
k.find(".history-content").html(b.template(d.buildHtml().localDialogLi)(c)),
k.find("#image-list-pager").html(c.pager),
k.find(".pagination a").click(function() {
d.localPage(a(this).attr("page"))
}), k.find(".img-list li").click(function(b) {
d.selectImage(a(b.target).parents("li"))
}), d.options.isWechat ? d.weixinDeletefile() : d.deletefile())
}),
d.options.isWechat || d.modalobj.find(".btn-select").unbind("click").click(function() {
return a(this).hasClass("btn-info") ? !1 : ("month" == a(this).data("type") && a(this).data("id") > 0 && (d.modalobj.find("#select-year .btn-info").data("id") || (d.modalobj.find("#select-year .btn-select").removeClass("btn-info"), d.modalobj.find("#select-year .btn-select").eq(1).addClass("btn-info"))), a(this).siblings().removeClass("btn-info"), a(this).addClass("btn-info"), void d.localPage(1))
}),
k.find(".btn-primary").unbind("click").click(function() {
var b = [];
k.find(".img-item-selected").each(function() {
var dd = d.modalobj.find("#history_image").data("attachment");
for (cc in dd) {
if (dd[cc].id == a(this).attr("attachid")) {
var ee = dd[cc];
}
};
b.push(ee),
a(this).removeClass("img-item-selected")
}),
d.finish(b)
}),
!1
},
deletefile: function() {
var b = this;
b.modalobj.find("#history_image .img-list li .btnClose").unbind().click(function() {
var b = a(this),
c = a(this).data("id");
return c ? (a.post("./index.php?c=utility&a=file&do=delete", {
id: c
},
function(a) {
(b.parent().remove(), util.message("删除成功", "", "success"))
}), !1) : !1
})
},
weixinDeletefile: function() {
var b = this;
b.modalobj.find(".history .delete-file").off("click"),
b.modalobj.find(".history .delete-file").on("click",
function(b) {
var c = a(this);
if (confirm("确定要删除文件吗?")) {
var d = a(this).parent().attr("attachid"),
e = a(this).parent().attr("data-type");
a.post("./index.php?c=utility&a=wechat_file&do=delete", {
id: d
},
function(b) {
var b = a.parseJSON(b);
return b.error ? void("image" == e ? c.parent().remove() : "audio" != e && "voice" != e && "video" != e || c.parents("tr").remove()) : (util.message(b.message), !1)
})
}
b.stopPropagation()
})
},
selectImage: function(b) {
var c = this;
a(b).toggleClass("img-item-selected"),
c.options.isWechat ? c.options.direct && c.modalobj.find("#history_image").find(".btn-primary").trigger("click") : c.options.multiple || c.modalobj.find("#history_image").find(".btn-primary").trigger("click")
},
initLocalAudio: function() {
var a = this;
a.modalobj.find("#li_history_audio").removeClass("hide"),
a.modalobj.find(".modal-body").append(this.buildHtml().localAudioDialog),
a.localAudioPage(1)
},
localAudioPage: function(c) {
var d = this;
if (d.options.isWechat) var e = d.options.type,
f = d.options.mode,
g = "./index.php?c=utility&a=wechat_file&do=browser",
h = {
page: c,
type: e,
mode: f,
psize: 5
};
else var g = "./index.php?c=utility&a=file&do=local&type=audio&pagesize=5",
h = {
page: c
};
var i = d.modalobj.find("#history_audio");
return a.getJSON(g, h,
function(c) {
c = c.message,
i.find(".history-content").html(''),
b.isEmpty(c.items) ? i.find(".history-content").css("text-align", "center").html(' 暂无数据') : (i.data("attachment", c.items), i.find(".history-content").empty(), i.find(".history-content").html(b.template(d.buildHtml()[d.options.isWechat ? "weixin_localAudioDialogLi": "localAudioDialogLi"])(c)), i.find("#image-list-pager").html(c.page), i.find(".pagination a").click(function() {
d.localAudioPage(a(this).attr("page"))
}), i.find(".js-btn-select").click(function(b) {
a(b.target).toggleClass("btn-primary"),
d.options.isWechat ? d.options.direct && d.modalobj.find("#history_audio").find(".modal-footer .btn-primary").trigger("click") : d.options.multiple || d.modalobj.find("#history_audio").find(".modal-footer .btn-primary").trigger("click")
}), d.playAudio(), d.options.isWechat && d.weixinDeletefile())
}),
i.find(".modal-footer .btn-primary").unbind("click").click(function() {
var b = [];
i.find(".history-content .btn-primary").each(function() {
b.push(d.modalobj.find("#history_audio").data("attachment")[a(this).attr("attachid")]),
a(this).removeClass("btn-primary")
}),
d.finish(b)
}),
!1
},
playAudio: function() {
var b = this,
c = b.modalobj.find("#history_audio");
a(".audio-player-play").click(function() {
var b = a(this).attr("attach");
if (b) {
if (a("#player")[0]) var d = a("#player");
else {
var d = a('');
a(document.body).append(d)
}
d.data("control", a(this)),
d.jPlayer({
playing: function() {
a(this).data("control").find("p").removeClass("fa-play").addClass("fa-stop")
},
pause: function(b) {
a(this).data("control").find("p").removeClass("fa-stop").addClass("fa-play")
},
swfPath: "resource/components/jplayer",
supplied: "mp3,wma,wav,amr",
solution: "html, flash"
}),
d.jPlayer("setMedia", {
mp3: a(this).attr("attach")
}).jPlayer("play"),
a(this).find("p").hasClass("fa-stop") ? d.jPlayer("stop") : (c.find(".fa-stop").removeClass("fa-stop").addClass("fa-play"), d.jPlayer("setMedia", {
mp3: a(this).attr("attach")
}).jPlayer("play"))
}
})
},
initLocalVoice: function() {
this.initLocalAudio()
},
initLocalVideo: function() {
var a = this;
a.modalobj.find("#li_history_video").removeClass("hide"),
a.modalobj.find(".modal-body").append(this.buildHtml().localVideoDialog),
a.localVideoPage(1)
},
localVideoPage: function(c) {
var d = this;
if (d.options.isWechat) var e = d.options.type,
f = "./index.php?c=utility&a=wechat_file&do=browser",
g = {
page: c,
type: e,
psize: 5
};
else var f = "./index.php?c=utility&a=file&do=video&local=local&type=video&pagesize=5",
g = {
page: c
};
var h = d.modalobj.find("#history_video");
return a.getJSON(f, g,
function(c) {
c = c.message.message,
b.isEmpty(c.items) ? c : c.items = d.foritem(c.items),
h.find(".history-content").html(''),
b.isEmpty(c.items) ? h.find(".history-content").css("text-align", "left").html(' 暂无数据') : (h.data("attachment", c.items), h.find(".history-content").empty(), h.find(".history-content").html(b.template(d.buildHtml()[d.options.isWechat ? "weixin_localVideoDialogLi": "localVideoDialogLi"])(c)), h.find("#image-list-pager").html(c.page), h.find(".pagination a").click(function() {
d.localVideoPage(a(this).attr("pager"))
}), h.find(".js-btn-select").click(function(b) {
a(b.target).toggleClass("btn-primary"),
d.options.isWechat ? d.options.direct && d.modalobj.find("#history_video").find(".modal-footer .btn-primary").trigger("click") : d.options.multiple || d.modalobj.find("#history_video").find(".modal-footer .btn-primary").trigger("click")
}), d.deletevideofile())
}),
h.find(".modal-footer .btn-primary").unbind("click").click(function() {
var b = [];
h.find(".history-content .btn-primary").each(function() {
var dd = d.modalobj.find("#history_video").data("attachment");
for (cc in dd) {
if (dd[cc].id == a(this).attr("attachid")) {
var ee = dd[cc];
}
};
b.push(ee),
a(this).removeClass("btn-primary")
}),
d.finish(b)
}),
!1
},
deletevideofile: function() {
var b = this;
b.modalobj.find("#history_video .history-content td .delete-video-file").unbind().click(function() {
if (confirm("确定要删除文件吗?")) {
var b = a(this),
c = a(this).data("id");
return c ? (a.post("./index.php?c=utility&a=file&do=delete", {
id: c
},
function(a) {
(b.parents('tr').remove(), util.message("删除成功", "", "success"))
}), !1) : !1
}
})
},
finish: function(b) {
var c = this;
a.isFunction(c.options.callback) && (0 == c.options.multiple ? c.options.callback(b[0]) : c.options.callback(b), c.modalobj.modal("hide"))
},
foritem: function(items) {
var d = this;
for (obj in items) {
items[obj].createtime = d.getdate(items[obj].createtime)
}
return items
},
getdate: function(date) {
var now = new Date(date * 1000),
y = now.getFullYear(),
m = now.getMonth() + 1,
day = now.getDate();
return y + "-" + (m < 10 ? "0" + m : m) + "-" + (day < 10 ? "0" + day : day) + " " + now.toTimeString().substr(0, 8)
},
buildHtml: function() {
var a = {};
var myDate = new Date();
var abcd = '';
for (var i = myDate.getFullYear(); i > 2012; i--) {
abcd += '' + i + '年'
}
return a.mainDialog = '\n
\n
\n \n' + (this.options.isWechat ? "": '
') + '
\n
\n
\n
',
a.uploaderDialog = '\n' + (this.options.isWechat && "video" == this.options.type ? '
': "") + '
\n
\n
\n
xx
\n' + (this.options.multiple ? '
或将照片拖到这里,单次最多可选' + (this.options.isWechat ? 5 : 30) + "张
\n": '
或将照片拖到这里
\n') + '
\n
\n
\n
\n
',
a.remoteDialog = '',
a.remoteVideoDialog = '',
a.localDialog = '",
a.localDialogLi = '\n<%var items = _.sortBy(items, function(item) {return -item.id;});%><%_.each(items, function(item) {%> \n- \n \n \n
\n<%});%>\n
',
a.weixin_localDialogLi = '\n<%_.each(items, function(item) {%> \n- \n \n
\n<%});%>\n
',
a.localAudioDialog = '\n
\n
\n \n \n | 标题 | \n' + (this.options.isWechat ? ' 创建时间 | \n \n |
\n \n \n \n
\n \n
",
a.localAudioDialogLi = '<%var items = _.sortBy(items, function(item) {return -item.id;});%><%_.each(items, function(item) {%> \n\n | <%=item.filename%> | \n <%=item.createtime%> | \n \n \n \n \n \n | \n
\n<%});%>\n',
a.weixin_localAudioDialogLi = '<%var items = _.sortBy(items, function(item) {return -item.id;});%><%_.each(items, function(item) {%> \n\n | <%=item.filename%> | \n <%=item.createtime%> | \n \n \n \n \n \n \n | \n
\n<%});%>\n',
a.localVideoDialog = '",
a.localVideoDialogLi = '<%var items = _.sortBy(items, function(item) {return -item.id;});%><%_.each(items, function(item) {%> \n\n | <%=item.filename%> | \n <%=item.createtime%> | \n \n \n \n \n \n | \n
\n<%});%>\n',
a.weixin_localVideoDialogLi = '<%var items = _.sortBy(items, function(item) {return -item.id;});%><%_.each(items, function(item) {%> \n\n | <%=item.filename%> | \n <%=item.createtime%> | \n \n \n \n \n \n | \n
\n<%});%>\n',
a
}
};
return d
});