Commit e0a62ab1 by doszhang

dos

parent 4f5a8ac3
node_modules node_modules
/.idea /.idea
.sass-cache/ .sass-cache/
.DS_Store .DS_Store
*.css.map *.css.map
Thumbs.db Thumbs.db
.phpstorm.meta.php .phpstorm.meta.php
# Application/Common/Conf # Application/Common/Conf
\ No newline at end of file
...@@ -9,9 +9,9 @@ return array( ...@@ -9,9 +9,9 @@ return array(
// 微信授权,通过key、token调用智达接口并验证智达返回数据 // 微信授权,通过key、token调用智达接口并验证智达返回数据
'AUTH_SUPPORT_FAKE_OPENID' => true, 'AUTH_SUPPORT_FAKE_OPENID' => true,
'AUTH_APP_ID' => 'wx3d1fe32645ff9e8d', 'AUTH_APP_ID' => 'wx7d067764769a7738',
'AUTH_CLIENT_ID' => 'zhida_app', 'AUTH_CLIENT_ID' => 'third',
'AUTH_CLIENT_PASSWORD' => 'izhida', 'AUTH_CLIENT_PASSWORD' => 'zhida_third_oauth',
/* CDN路径配置。配置之后可以在模版文件中使用__CDN__ */ /* CDN路径配置。配置之后可以在模版文件中使用__CDN__ */
// '__CDN__' => 'https://static3.izhida.cn/cdn1/samsung-christmas/v1.0.7', // '__CDN__' => 'https://static3.izhida.cn/cdn1/samsung-christmas/v1.0.7',
'__CDN__' => '/Public/static', // @readme <-- 上线时修改这里 '__CDN__' => '/Public/static', // @readme <-- 上线时修改这里
......
...@@ -4,7 +4,8 @@ vendor('tencentsdk.TCloudAutoLoader'); ...@@ -4,7 +4,8 @@ vendor('tencentsdk.TCloudAutoLoader');
use Think\Controller; use Think\Controller;
use SignedCookie; use SignedCookie;
use Zhida\OAuthHelperV3; // use Zhida\OAuthHelperV3;
use Common\Common\OAuthHelperV3;
use Think\Upload\Driver\Qiniu\QiniuStorage; use Think\Upload\Driver\Qiniu\QiniuStorage;
use Think\Log; use Think\Log;
......
/*global plupload */ /*global plupload */
/*global qiniu */ /*global qiniu */
function FileProgress(file, targetID) { function FileProgress(file, targetID) {
this.fileProgressID = file.id; this.fileProgressID = file.id;
this.file = file; this.file = file;
this.opacity = 100; this.opacity = 100;
this.height = 0; this.height = 0;
this.fileProgressWrapper = $('#' + this.fileProgressID); this.fileProgressWrapper = $('#' + this.fileProgressID);
if (!this.fileProgressWrapper.length) { if (!this.fileProgressWrapper.length) {
// <div class="progress"> // <div class="progress">
// <div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: 20%"> // <div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: 20%">
// <span class="sr-only">20% Complete</span> // <span class="sr-only">20% Complete</span>
// </div> // </div>
// </div> // </div>
this.fileProgressWrapper = $('<tr></tr>'); this.fileProgressWrapper = $('<tr></tr>');
var Wrappeer = this.fileProgressWrapper; var Wrappeer = this.fileProgressWrapper;
Wrappeer.attr('id', this.fileProgressID).addClass('progressContainer'); Wrappeer.attr('id', this.fileProgressID).addClass('progressContainer');
var progressText = $("<td/>"); var progressText = $("<td/>");
progressText.addClass('progressName').text(file.name); progressText.addClass('progressName').text(file.name);
var fileSize = plupload.formatSize(file.size).toUpperCase(); var fileSize = plupload.formatSize(file.size).toUpperCase();
var progressSize = $("<td/>"); var progressSize = $("<td/>");
progressSize.addClass("progressFileSize").text(fileSize); progressSize.addClass("progressFileSize").text(fileSize);
var progressBarTd = $("<td/>"); var progressBarTd = $("<td/>");
var progressBarBox = $("<div/>"); var progressBarBox = $("<div/>");
progressBarBox.addClass('info'); progressBarBox.addClass('info');
var progressBarWrapper = $("<div/>"); var progressBarWrapper = $("<div/>");
progressBarWrapper.addClass("progress progress-striped"); progressBarWrapper.addClass("progress progress-striped");
var progressBar = $("<div/>"); var progressBar = $("<div/>");
progressBar.addClass("progress-bar progress-bar-info") progressBar.addClass("progress-bar progress-bar-info")
.attr('role', 'progressbar') .attr('role', 'progressbar')
.attr('aria-valuemax', 100) .attr('aria-valuemax', 100)
.attr('aria-valuenow', 0) .attr('aria-valuenow', 0)
.attr('aria-valuein', 0) .attr('aria-valuein', 0)
.width('0%'); .width('0%');
var progressBarPercent = $('<span class=sr-only />'); var progressBarPercent = $('<span class=sr-only />');
progressBarPercent.text(fileSize); progressBarPercent.text(fileSize);
var progressCancel = $('<a href=javascript:; />'); var progressCancel = $('<a href=javascript:; />');
progressCancel.show().addClass('progressCancel').text('×'); progressCancel.show().addClass('progressCancel').text('×');
progressBar.append(progressBarPercent); progressBar.append(progressBarPercent);
progressBarWrapper.append(progressBar); progressBarWrapper.append(progressBar);
progressBarBox.append(progressBarWrapper); progressBarBox.append(progressBarWrapper);
progressBarBox.append(progressCancel); progressBarBox.append(progressCancel);
var progressBarStatus = $('<div class="status text-center"/>'); var progressBarStatus = $('<div class="status text-center"/>');
progressBarBox.append(progressBarStatus); progressBarBox.append(progressBarStatus);
progressBarTd.append(progressBarBox); progressBarTd.append(progressBarBox);
Wrappeer.append(progressText); Wrappeer.append(progressText);
Wrappeer.append(progressSize); Wrappeer.append(progressSize);
Wrappeer.append(progressBarTd); Wrappeer.append(progressBarTd);
$('#' + targetID).append(Wrappeer); $('#' + targetID).append(Wrappeer);
} else { } else {
this.reset(); this.reset();
} }
this.height = this.fileProgressWrapper.offset().top; this.height = this.fileProgressWrapper.offset().top;
this.setTimer(null); this.setTimer(null);
} }
FileProgress.prototype.setTimer = function(timer) { FileProgress.prototype.setTimer = function(timer) {
this.fileProgressWrapper.FP_TIMER = timer; this.fileProgressWrapper.FP_TIMER = timer;
}; };
FileProgress.prototype.getTimer = function(timer) { FileProgress.prototype.getTimer = function(timer) {
return this.fileProgressWrapper.FP_TIMER || null; return this.fileProgressWrapper.FP_TIMER || null;
}; };
FileProgress.prototype.reset = function() { FileProgress.prototype.reset = function() {
this.fileProgressWrapper.attr('class', "progressContainer"); this.fileProgressWrapper.attr('class', "progressContainer");
this.fileProgressWrapper.find('td .progress .progress-bar-info').attr('aria-valuenow', 0).width('0%').find('span').text(''); this.fileProgressWrapper.find('td .progress .progress-bar-info').attr('aria-valuenow', 0).width('0%').find('span').text('');
this.appear(); this.appear();
}; };
FileProgress.prototype.setChunkProgess = function(chunk_size) { FileProgress.prototype.setChunkProgess = function(chunk_size) {
var chunk_amount = Math.ceil(this.file.size / chunk_size); var chunk_amount = Math.ceil(this.file.size / chunk_size);
if (chunk_amount === 1) { if (chunk_amount === 1) {
return false; return false;
} }
var viewProgess = $('<button class="btn btn-default">查看分块上传进度</button>'); var viewProgess = $('<button class="btn btn-default">查看分块上传进度</button>');
var progressBarChunkTr = $('<tr class="chunk-status-tr"><td colspan=3></td></tr>'); var progressBarChunkTr = $('<tr class="chunk-status-tr"><td colspan=3></td></tr>');
var progressBarChunk = $('<div/>'); var progressBarChunk = $('<div/>');
for (var i = 1; i <= chunk_amount; i++) { for (var i = 1; i <= chunk_amount; i++) {
var col = $('<div class="col-md-2"/>'); var col = $('<div class="col-md-2"/>');
var progressBarWrapper = $('<div class="progress progress-striped"></div'); var progressBarWrapper = $('<div class="progress progress-striped"></div');
var progressBar = $("<div/>"); var progressBar = $("<div/>");
progressBar.addClass("progress-bar progress-bar-info text-left") progressBar.addClass("progress-bar progress-bar-info text-left")
.attr('role', 'progressbar') .attr('role', 'progressbar')
.attr('aria-valuemax', 100) .attr('aria-valuemax', 100)
.attr('aria-valuenow', 0) .attr('aria-valuenow', 0)
.attr('aria-valuein', 0) .attr('aria-valuein', 0)
.width('0%') .width('0%')
.attr('id', this.file.id + '_' + i) .attr('id', this.file.id + '_' + i)
.text(''); .text('');
var progressBarStatus = $('<span/>'); var progressBarStatus = $('<span/>');
progressBarStatus.addClass('chunk-status').text(); progressBarStatus.addClass('chunk-status').text();
progressBarWrapper.append(progressBar); progressBarWrapper.append(progressBar);
progressBarWrapper.append(progressBarStatus); progressBarWrapper.append(progressBarStatus);
col.append(progressBarWrapper); col.append(progressBarWrapper);
progressBarChunk.append(col); progressBarChunk.append(col);
} }
if(!this.fileProgressWrapper.find('td:eq(2) .btn-default').length){ if(!this.fileProgressWrapper.find('td:eq(2) .btn-default').length){
this.fileProgressWrapper.find('td>div').append(viewProgess); this.fileProgressWrapper.find('td>div').append(viewProgess);
} }
progressBarChunkTr.hide().find('td').append(progressBarChunk); progressBarChunkTr.hide().find('td').append(progressBarChunk);
progressBarChunkTr.insertAfter(this.fileProgressWrapper); progressBarChunkTr.insertAfter(this.fileProgressWrapper);
}; };
FileProgress.prototype.setProgress = function(percentage, speed, chunk_size) { FileProgress.prototype.setProgress = function(percentage, speed, chunk_size) {
this.fileProgressWrapper.attr('class', "progressContainer green"); this.fileProgressWrapper.attr('class', "progressContainer green");
var file = this.file; var file = this.file;
var uploaded = file.loaded; var uploaded = file.loaded;
var size = plupload.formatSize(uploaded).toUpperCase(); var size = plupload.formatSize(uploaded).toUpperCase();
var formatSpeed = plupload.formatSize(speed).toUpperCase(); var formatSpeed = plupload.formatSize(speed).toUpperCase();
var progressbar = this.fileProgressWrapper.find('td .progress').find('.progress-bar-info'); var progressbar = this.fileProgressWrapper.find('td .progress').find('.progress-bar-info');
if (this.fileProgressWrapper.find('.status').text() === '取消上传'){ if (this.fileProgressWrapper.find('.status').text() === '取消上传'){
return; return;
} }
this.fileProgressWrapper.find('.status').text("已上传: " + size + " 上传速度: " + formatSpeed + "/s"); this.fileProgressWrapper.find('.status').text("已上传: " + size + " 上传速度: " + formatSpeed + "/s");
percentage = parseInt(percentage, 10); percentage = parseInt(percentage, 10);
if (file.status !== plupload.DONE && percentage === 100) { if (file.status !== plupload.DONE && percentage === 100) {
percentage = 99; percentage = 99;
} }
progressbar.attr('aria-valuenow', percentage).css('width', percentage + '%'); progressbar.attr('aria-valuenow', percentage).css('width', percentage + '%');
if (chunk_size) { if (chunk_size) {
var chunk_amount = Math.ceil(file.size / chunk_size); var chunk_amount = Math.ceil(file.size / chunk_size);
if (chunk_amount === 1) { if (chunk_amount === 1) {
return false; return false;
} }
var current_uploading_chunk = Math.ceil(uploaded / chunk_size); var current_uploading_chunk = Math.ceil(uploaded / chunk_size);
var pre_chunk, text; var pre_chunk, text;
for (var index = 0; index < current_uploading_chunk; index++) { for (var index = 0; index < current_uploading_chunk; index++) {
pre_chunk = $('#' + file.id + "_" + index); pre_chunk = $('#' + file.id + "_" + index);
pre_chunk.width('100%').removeClass().addClass('alert-success').attr('aria-valuenow', 100); pre_chunk.width('100%').removeClass().addClass('alert-success').attr('aria-valuenow', 100);
text = "块" + index + "上传进度100%"; text = "块" + index + "上传进度100%";
pre_chunk.next().html(text); pre_chunk.next().html(text);
} }
var currentProgessBar = $('#' + file.id + "_" + current_uploading_chunk); var currentProgessBar = $('#' + file.id + "_" + current_uploading_chunk);
var current_chunk_percent; var current_chunk_percent;
if (current_uploading_chunk < chunk_amount) { if (current_uploading_chunk < chunk_amount) {
if (uploaded % chunk_size) { if (uploaded % chunk_size) {
current_chunk_percent = ((uploaded % chunk_size) / chunk_size * 100).toFixed(2); current_chunk_percent = ((uploaded % chunk_size) / chunk_size * 100).toFixed(2);
} else { } else {
current_chunk_percent = 100; current_chunk_percent = 100;
currentProgessBar.removeClass().addClass('alert-success'); currentProgessBar.removeClass().addClass('alert-success');
} }
} else { } else {
var last_chunk_size = file.size - chunk_size * (chunk_amount - 1); var last_chunk_size = file.size - chunk_size * (chunk_amount - 1);
var left_file_size = file.size - uploaded; var left_file_size = file.size - uploaded;
if (left_file_size % last_chunk_size) { if (left_file_size % last_chunk_size) {
current_chunk_percent = ((uploaded % chunk_size) / last_chunk_size * 100).toFixed(2); current_chunk_percent = ((uploaded % chunk_size) / last_chunk_size * 100).toFixed(2);
} else { } else {
current_chunk_percent = 100; current_chunk_percent = 100;
currentProgessBar.removeClass().addClass('alert-success'); currentProgessBar.removeClass().addClass('alert-success');
} }
} }
currentProgessBar.width(current_chunk_percent + '%'); currentProgessBar.width(current_chunk_percent + '%');
currentProgessBar.attr('aria-valuenow', current_chunk_percent); currentProgessBar.attr('aria-valuenow', current_chunk_percent);
text = "块" + current_uploading_chunk + "上传进度" + current_chunk_percent + '%'; text = "块" + current_uploading_chunk + "上传进度" + current_chunk_percent + '%';
currentProgessBar.next().html(text); currentProgessBar.next().html(text);
} }
this.appear(); this.appear();
}; };
FileProgress.prototype.setComplete = function(up, info) { FileProgress.prototype.setComplete = function(up, info) {
var td = this.fileProgressWrapper.find('td:eq(2)'), var td = this.fileProgressWrapper.find('td:eq(2)'),
tdProgress = td.find('.progress'); tdProgress = td.find('.progress');
var res = $.parseJSON(info); var res = $.parseJSON(info);
var url; var url;
if (res.url) { if (res.url) {
url = res.url; url = res.url;
str = "<div><strong>Link:</strong><a href=" + res.url + " target='_blank' > " + res.url + "</a></div>" + str = "<div><strong>Link:</strong><a href=" + res.url + " target='_blank' > " + res.url + "</a></div>" +
"<div class=hash><strong>Hash:</strong>" + res.hash + "</div>"; "<div class=hash><strong>Hash:</strong>" + res.hash + "</div>";
} else { } else {
var domain = up.getOption('domain'); var domain = up.getOption('domain');
url = domain + encodeURI(res.key); url = domain + encodeURI(res.key);
var link = domain + res.key; var link = domain + res.key;
str = "<div><strong>Link:</strong><a href=" + url + " target='_blank' > " + link + "</a></div>" + str = "<div><strong>Link:</strong><a href=" + url + " target='_blank' > " + link + "</a></div>" +
"<div class=hash><strong>Hash:</strong>" + res.hash + "</div>"; "<div class=hash><strong>Hash:</strong>" + res.hash + "</div>";
} }
tdProgress.html(str).removeClass().next().next('.status').hide(); tdProgress.html(str).removeClass().next().next('.status').hide();
td.find('.progressCancel').hide(); td.find('.progressCancel').hide();
var progressNameTd = this.fileProgressWrapper.find('.progressName'); var progressNameTd = this.fileProgressWrapper.find('.progressName');
var imageView = '?imageView2/1/w/100/h/100'; var imageView = '?imageView2/1/w/100/h/100';
var isImage = function(url) { var isImage = function(url) {
var res, suffix = ""; var res, suffix = "";
var imageSuffixes = ["png", "jpg", "jpeg", "gif", "bmp"]; var imageSuffixes = ["png", "jpg", "jpeg", "gif", "bmp"];
var suffixMatch = /\.([a-zA-Z0-9]+)(\?|\@|$)/; var suffixMatch = /\.([a-zA-Z0-9]+)(\?|\@|$)/;
if (!url || !suffixMatch.test(url)) { if (!url || !suffixMatch.test(url)) {
return false; return false;
} }
res = suffixMatch.exec(url); res = suffixMatch.exec(url);
suffix = res[1].toLowerCase(); suffix = res[1].toLowerCase();
for (var i = 0, l = imageSuffixes.length; i < l; i++) { for (var i = 0, l = imageSuffixes.length; i < l; i++) {
if (suffix === imageSuffixes[i]) { if (suffix === imageSuffixes[i]) {
return true; return true;
} }
} }
return false; return false;
}; };
var isImg = isImage(url); var isImg = isImage(url);
var Wrapper = $('<div class="Wrapper"/>'); var Wrapper = $('<div class="Wrapper"/>');
var imgWrapper = $('<div class="imgWrapper col-md-3"/>'); var imgWrapper = $('<div class="imgWrapper col-md-3"/>');
var linkWrapper = $('<a class="linkWrapper" target="_blank"/>'); var linkWrapper = $('<a class="linkWrapper" target="_blank"/>');
var showImg = $('<img src="images/loading.gif"/>'); var showImg = $('<img src="images/loading.gif"/>');
progressNameTd.append(Wrapper); progressNameTd.append(Wrapper);
if (!isImg) { if (!isImg) {
showImg.attr('src', 'images/default.png'); showImg.attr('src', 'images/default.png');
Wrapper.addClass('default'); Wrapper.addClass('default');
imgWrapper.append(showImg); imgWrapper.append(showImg);
Wrapper.append(imgWrapper); Wrapper.append(imgWrapper);
} else { } else {
linkWrapper.append(showImg); linkWrapper.append(showImg);
imgWrapper.append(linkWrapper); imgWrapper.append(linkWrapper);
Wrapper.append(imgWrapper); Wrapper.append(imgWrapper);
var img = new Image(); var img = new Image();
if (!/imageView/.test(url)) { if (!/imageView/.test(url)) {
url += imageView url += imageView
} }
$(img).attr('src', url); $(img).attr('src', url);
var height_space = 340; var height_space = 340;
$(img).on('load', function() { $(img).on('load', function() {
showImg.attr('src', url); showImg.attr('src', url);
linkWrapper.attr('href', url).attr('title', '查看原图'); linkWrapper.attr('href', url).attr('title', '查看原图');
function initImg(url, key, height) { function initImg(url, key, height) {
$('#myModal-img').modal(); $('#myModal-img').modal();
var modalBody = $('#myModal-img').find('.modal-body'); var modalBody = $('#myModal-img').find('.modal-body');
if (height <= 300) { if (height <= 300) {
$('#myModal-img').find('.text-warning').show(); $('#myModal-img').find('.text-warning').show();
} }
var newImg = new Image(); var newImg = new Image();
modalBody.find('img').attr('src', 'images/loading.gif'); modalBody.find('img').attr('src', 'images/loading.gif');
newImg.onload = function() { newImg.onload = function() {
modalBody.find('img').attr('src', url).data('key', key).data('h', height); modalBody.find('img').attr('src', url).data('key', key).data('h', height);
modalBody.find('.modal-body-wrapper').find('a').attr('href', url); modalBody.find('.modal-body-wrapper').find('a').attr('href', url);
}; };
newImg.src = url; newImg.src = url;
} }
var infoWrapper = $('<div class="infoWrapper col-md-6"></div>'); var infoWrapper = $('<div class="infoWrapper col-md-6"></div>');
var fopLink = $('<a class="fopLink"/>'); var fopLink = $('<a class="fopLink"/>');
fopLink.attr('data-key', res.key).text('查看处理效果'); fopLink.attr('data-key', res.key).text('查看处理效果');
infoWrapper.append(fopLink); infoWrapper.append(fopLink);
fopLink.on('click', function() { fopLink.on('click', function() {
var key = $(this).data('key'); var key = $(this).data('key');
var height = parseInt($(this).parents('.Wrapper').find('.origin-height').text(), 10); var height = parseInt($(this).parents('.Wrapper').find('.origin-height').text(), 10);
if (height > $(window).height() - height_space) { if (height > $(window).height() - height_space) {
height = parseInt($(window).height() - height_space, 10); height = parseInt($(window).height() - height_space, 10);
} else { } else {
height = parseInt(height, 10) || 300; height = parseInt(height, 10) || 300;
//set a default height 300 for ie9- //set a default height 300 for ie9-
} }
var fopArr = []; var fopArr = [];
fopArr.push({ fopArr.push({
fop: 'imageView2', fop: 'imageView2',
mode: 3, mode: 3,
h: height, h: height,
q: 100, q: 100,
format: 'png' format: 'png'
}); });
fopArr.push({ fopArr.push({
fop: 'watermark', fop: 'watermark',
mode: 1, mode: 1,
image: 'https://www.b1.qiniudn.com/images/logo-2.png', image: 'https://www.b1.qiniudn.com/images/logo-2.png',
dissolve: 100, dissolve: 100,
gravity: 'SouthEast', gravity: 'SouthEast',
dx: 100, dx: 100,
dy: 100 dy: 100
}); });
var url = Qiniu.pipeline(fopArr, key); var url = Qiniu.pipeline(fopArr, key);
$('#myModal-img').on('hide.bs.modal', function() { $('#myModal-img').on('hide.bs.modal', function() {
$('#myModal-img').find('.btn-default').removeClass('disabled'); $('#myModal-img').find('.btn-default').removeClass('disabled');
$('#myModal-img').find('.text-warning').hide(); $('#myModal-img').find('.text-warning').hide();
}).on('show.bs.modal', function() { }).on('show.bs.modal', function() {
$('#myModal-img').find('.imageView').find('a:eq(0)').addClass('disabled'); $('#myModal-img').find('.imageView').find('a:eq(0)').addClass('disabled');
$('#myModal-img').find('.watermark').find('a:eq(3)').addClass('disabled'); $('#myModal-img').find('.watermark').find('a:eq(3)').addClass('disabled');
$('#myModal-img').find('.text-warning').hide(); $('#myModal-img').find('.text-warning').hide();
}); });
initImg(url, key, height); initImg(url, key, height);
return false; return false;
}); });
var ie = Qiniu.detectIEVersion(); var ie = Qiniu.detectIEVersion();
if (!(ie && ie <= 9)) { if (!(ie && ie <= 9)) {
var exif = Qiniu.exif(res.key); var exif = Qiniu.exif(res.key);
if (exif) { if (exif) {
var exifLink = $('<a href="" target="_blank">查看exif</a>'); var exifLink = $('<a href="" target="_blank">查看exif</a>');
exifLink.attr('href', url + '?exif'); exifLink.attr('href', url + '?exif');
infoWrapper.append(exifLink); infoWrapper.append(exifLink);
} }
var imageInfo = Qiniu.imageInfo(res.key); var imageInfo = Qiniu.imageInfo(res.key);
var infoArea = $('<div/>'); var infoArea = $('<div/>');
var infoInner = '<div>格式:<span class="origin-format">' + imageInfo.format + '</span></div>' + var infoInner = '<div>格式:<span class="origin-format">' + imageInfo.format + '</span></div>' +
'<div>宽度:<span class="orgin-width">' + imageInfo.width + 'px</span></div>' + '<div>宽度:<span class="orgin-width">' + imageInfo.width + 'px</span></div>' +
'<div>高度:<span class="origin-height">' + imageInfo.height + 'px</span></div>'; '<div>高度:<span class="origin-height">' + imageInfo.height + 'px</span></div>';
infoArea.html(infoInner); infoArea.html(infoInner);
infoWrapper.append(infoArea); infoWrapper.append(infoArea);
} }
Wrapper.append(infoWrapper); Wrapper.append(infoWrapper);
}).on('error', function() { }).on('error', function() {
showImg.attr('src', 'default.png'); showImg.attr('src', 'default.png');
Wrapper.addClass('default'); Wrapper.addClass('default');
}); });
} }
}; };
FileProgress.prototype.setError = function() { FileProgress.prototype.setError = function() {
this.fileProgressWrapper.find('td:eq(2)').attr('class', 'text-warning'); this.fileProgressWrapper.find('td:eq(2)').attr('class', 'text-warning');
this.fileProgressWrapper.find('td:eq(2) .progress').css('width', 0).hide(); this.fileProgressWrapper.find('td:eq(2) .progress').css('width', 0).hide();
this.fileProgressWrapper.find('button').hide(); this.fileProgressWrapper.find('button').hide();
this.fileProgressWrapper.next('.chunk-status-tr').hide(); this.fileProgressWrapper.next('.chunk-status-tr').hide();
}; };
FileProgress.prototype.setCancelled = function(manual) { FileProgress.prototype.setCancelled = function(manual) {
var progressContainer = 'progressContainer'; var progressContainer = 'progressContainer';
if (!manual) { if (!manual) {
progressContainer += ' red'; progressContainer += ' red';
} }
this.fileProgressWrapper.attr('class', progressContainer); this.fileProgressWrapper.attr('class', progressContainer);
this.fileProgressWrapper.find('td .progress').remove(); this.fileProgressWrapper.find('td .progress').remove();
this.fileProgressWrapper.find('td:eq(2) .btn-default').hide(); this.fileProgressWrapper.find('td:eq(2) .btn-default').hide();
this.fileProgressWrapper.find('td:eq(2) .progressCancel').hide(); this.fileProgressWrapper.find('td:eq(2) .progressCancel').hide();
}; };
FileProgress.prototype.setStatus = function(status, isUploading) { FileProgress.prototype.setStatus = function(status, isUploading) {
if (!isUploading) { if (!isUploading) {
this.fileProgressWrapper.find('.status').text(status).attr('class', 'status text-left'); this.fileProgressWrapper.find('.status').text(status).attr('class', 'status text-left');
} }
}; };
// 绑定取消上传事件 // 绑定取消上传事件
FileProgress.prototype.bindUploadCancel = function(up) { FileProgress.prototype.bindUploadCancel = function(up) {
var self = this; var self = this;
if (up) { if (up) {
self.fileProgressWrapper.find('td:eq(2) .progressCancel').on('click', function(){ self.fileProgressWrapper.find('td:eq(2) .progressCancel').on('click', function(){
self.setCancelled(false); self.setCancelled(false);
self.setStatus("取消上传"); self.setStatus("取消上传");
self.fileProgressWrapper.find('.status').css('left', '0'); self.fileProgressWrapper.find('.status').css('left', '0');
up.removeFile(self.file); up.removeFile(self.file);
}); });
} }
}; };
FileProgress.prototype.appear = function() { FileProgress.prototype.appear = function() {
if (this.getTimer() !== null) { if (this.getTimer() !== null) {
clearTimeout(this.getTimer()); clearTimeout(this.getTimer());
this.setTimer(null); this.setTimer(null);
} }
if (this.fileProgressWrapper[0].filters) { if (this.fileProgressWrapper[0].filters) {
try { try {
this.fileProgressWrapper[0].filters.item("DXImageTransform.Microsoft.Alpha").opacity = 100; this.fileProgressWrapper[0].filters.item("DXImageTransform.Microsoft.Alpha").opacity = 100;
} catch (e) { } catch (e) {
// If it is not set initially, the browser will throw an error. This will set it if it is not set yet. // If it is not set initially, the browser will throw an error. This will set it if it is not set yet.
this.fileProgressWrapper.css('filter', "progid:DXImageTransform.Microsoft.Alpha(opacity=100)"); this.fileProgressWrapper.css('filter', "progid:DXImageTransform.Microsoft.Alpha(opacity=100)");
} }
} else { } else {
this.fileProgressWrapper.css('opacity', 1); this.fileProgressWrapper.css('opacity', 1);
} }
this.fileProgressWrapper.css('height', ''); this.fileProgressWrapper.css('height', '');
this.height = this.fileProgressWrapper.offset().top; this.height = this.fileProgressWrapper.offset().top;
this.opacity = 100; this.opacity = 100;
this.fileProgressWrapper.show(); this.fileProgressWrapper.show();
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment