Authored by biao

Merge branch 'release/1.0' of http://git.yoho.cn/fe/yoho-blk into release/1.0

... ... @@ -16,6 +16,8 @@ var $result,
$upload,
$filename;
var uping;
var num,
inter,
callback;
... ... @@ -26,42 +28,45 @@ $result = $('#yoho-upload-result');
$upload = $('#yoho-upload');
$filename = $upload.find('.file-name');
function up(opt) {
if (uping) {
return;
}
$filename.click();
if (opt && typeof opt.callback === 'function') {
callback = opt.callback;
} else {
callback = '';
}
}
function getResponse(cb) {
num = 0;
inter = setInterval(function() {
var res = $result[0].contentDocument.body.innerText || '';
if (res) {
if (num > 20 || res) {
uping = false;
clearInterval(inter);
}
num++;
if (res) {
clearInterval(inter);
$result[0].contentDocument.body.innerText = '';
if (cb) {
return cb($.parseJSON(res));
}
}
if (num > 20 || res) {
clearInterval(inter);
}
num++;
}, 500);
}
function up(opt) {
$filename.click();
if (opt) {
callback = null;
callback = opt.callback;
} else {
callback = '';
}
$filename.off('change').on('change', function() {
$upload.submit();
getResponse(callback);
});
}
$filename.change(function() {
uping = true;
$upload.submit();
getResponse(callback);
});
exports.up = up;
... ...