修复了一些问题
This commit is contained in:
1 parent
c484ee6ef3
commit
e877ceb560
28 files changed
+565
-535
No files matched your search
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
function miniupload() {
|
||||
var _body = $('body');
|
||||
var _body = jQuery('body');
|
||||
var input_selector = '[aksrtupload="image_upload"]';
|
||||
var submit_selector = '[aksrtupload="submit"]';
|
||||
var form_selector = '.form-upload,.mini-upload,form';
|
||||
@@ -13,9 +13,9 @@ function miniupload() {
|
||||
var pre_html;
|
||||
|
||||
_body.on('change', input_selector, function (e) {
|
||||
var _this = $(this);
|
||||
var _this = jQuery(this);
|
||||
var files = this.files || e.dataTransfer.files;
|
||||
var form = $(_this.parents(form_selector)[0]);
|
||||
var form = jQuery(_this.parents(form_selector)[0]);
|
||||
|
||||
var size_max = _this.attr('size_max') || Number(_win.upload_img_size) || 3;
|
||||
|
||||
@@ -46,7 +46,7 @@ function miniupload() {
|
||||
mini_file[upload_id] = [];
|
||||
}
|
||||
|
||||
$.each(files, function (key, val) {
|
||||
jQuery.each(files, function (key, val) {
|
||||
var name = val.name;
|
||||
if (accept_yanz && -1 == val.type.indexOf(accept_yanz)) {
|
||||
//如果限制文件格式
|
||||
@@ -64,7 +64,7 @@ function miniupload() {
|
||||
|
||||
var ii = 1;
|
||||
var empty = false;
|
||||
$.each(mini_file[upload_id], function (key, val) {
|
||||
jQuery.each(mini_file[upload_id], function (key, val) {
|
||||
if (multiple_max && multiple_max < ii) {
|
||||
//限制文件数量
|
||||
notyf(aksrt_sprintf('upload_count_exceeded', multiple_max), 'danger');
|
||||
@@ -79,7 +79,7 @@ function miniupload() {
|
||||
pre.html('');
|
||||
empty = true;
|
||||
}
|
||||
var cloce = '<div class="preview-remove" upload-id="' + upload_id + '" file-key="' + $.inArray(val, a_file) + '"><svg class="ic-close" aria-hidden="true"><use xlink:href="#icon-close"></use></svg></div>';
|
||||
var cloce = '<div class="preview-remove" upload-id="' + upload_id + '" file-key="' + jQuery.inArray(val, a_file) + '"><svg class="ic-close" aria-hidden="true"><use xlink:href="#icon-close"></use></svg></div>';
|
||||
img = '<div class="preview-item">' + img + cloce + '</div>';
|
||||
pre.append(img).find(add_selector).remove();
|
||||
if (multiple_max && multiple_max >= ii) {
|
||||
@@ -96,7 +96,7 @@ function miniupload() {
|
||||
});
|
||||
|
||||
_body.on('click', '.preview-remove', function () {
|
||||
var _this = $(this);
|
||||
var _this = jQuery(this);
|
||||
var file_key = _this.attr('file-key');
|
||||
var upload_id = _this.attr('upload-id');
|
||||
_this.parent().animate(
|
||||
@@ -106,8 +106,8 @@ function miniupload() {
|
||||
200,
|
||||
'swing',
|
||||
function () {
|
||||
var pre = $(this).parent();
|
||||
$(this).remove();
|
||||
var pre = jQuery(this).parent();
|
||||
jQuery(this).remove();
|
||||
mini_file[upload_id].splice(file_key, 1);
|
||||
if (!pre.find(add_selector).length) {
|
||||
pre.append(add_html);
|
||||
@@ -118,14 +118,14 @@ function miniupload() {
|
||||
});
|
||||
|
||||
_body.on('click', '.preview ' + add_selector, function () {
|
||||
var _this = $(this);
|
||||
var form = $(_this.parents(form_selector)[0]);
|
||||
var _this = jQuery(this);
|
||||
var form = jQuery(_this.parents(form_selector)[0]);
|
||||
form.find(input_selector).click();
|
||||
});
|
||||
|
||||
//提交表单
|
||||
_body.on('click', submit_selector, function (e) {
|
||||
var _this = $(this);
|
||||
var _this = jQuery(this);
|
||||
if (_this.attr('disabled')) {
|
||||
return false;
|
||||
}
|
||||
@@ -134,7 +134,7 @@ function miniupload() {
|
||||
else e.returnValue = false;
|
||||
|
||||
var _text = _this.html();
|
||||
var form = $(_this.parents(form_selector)[0]);
|
||||
var form = jQuery(_this.parents(form_selector)[0]);
|
||||
var _input = form.find(input_selector);
|
||||
var formData = new FormData();
|
||||
|
||||
@@ -142,12 +142,12 @@ function miniupload() {
|
||||
var is_files = _this.attr('aksrtupload-nomust');
|
||||
|
||||
_input.each(function () {
|
||||
var _this = $(this);
|
||||
var _this = jQuery(this);
|
||||
var upload_id = _this.attr('upload_id');
|
||||
if (upload_id && mini_file[upload_id]) {
|
||||
var ii = 0;
|
||||
var tag = _this.attr('data-tag') || 'file';
|
||||
$.each(mini_file[upload_id], function (key, val) {
|
||||
jQuery.each(mini_file[upload_id], function (key, val) {
|
||||
var append_tag = ii ? tag + '_' + ii : tag;
|
||||
formData.append(append_tag, val, val.name);
|
||||
ii++;
|
||||
@@ -164,13 +164,13 @@ function miniupload() {
|
||||
|
||||
//添加其它数据
|
||||
var serializeObject = form.serializeObject();
|
||||
$.each(serializeObject, function (key, val) {
|
||||
jQuery.each(serializeObject, function (key, val) {
|
||||
formData.append(key, val);
|
||||
});
|
||||
|
||||
//循环插入_POST内容
|
||||
form.find('[data-name]').each(function () {
|
||||
var _th = $(this);
|
||||
var _th = jQuery(this);
|
||||
var n = _th.attr('data-name');
|
||||
var v = _th.val() || _th.attr('data-value');
|
||||
if (v === undefined) {
|
||||
@@ -209,7 +209,7 @@ function miniupload() {
|
||||
.attr('disabled', false)
|
||||
.val('')
|
||||
.each(function () {
|
||||
var _this = $(this);
|
||||
var _this = jQuery(this);
|
||||
var upload_id = _this.attr('upload_id');
|
||||
if (upload_id && mini_file[upload_id]) {
|
||||
mini_file[upload_id] = [];
|
||||
@@ -225,7 +225,7 @@ function miniupload() {
|
||||
_this.attr('disabled', true).html('<span class="miniupload-ing"><i class="loading mr3 c-white"></i><span class="loading-text c-white">' + aksrt__('uploading') + '<count class="px12 ml3"></count></span><div class="progress progress-striped active"><div class="progress-bar progress-bar-success" role="progressbar" style="width:0;"></div></div></span>');
|
||||
_input.attr('disabled', true);
|
||||
|
||||
$.ajax({
|
||||
jQuery.ajax({
|
||||
url: _win.ajax_url,
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
@@ -257,10 +257,10 @@ function miniupload() {
|
||||
notyf(n.msg || aksrt__('operation_success'), ys, '', notyf_id);
|
||||
miniuploaded(n.no_preview_reset);
|
||||
if (n.hide_modal) {
|
||||
$(_this.parents('.modal')[0]).modal('hide');
|
||||
jQuery(_this.parents('.modal')[0]).modal('hide');
|
||||
}
|
||||
if (n.url && n.replace_img) {
|
||||
$('img' + n.replace_img).attr('src', n.url);
|
||||
jQuery('img' + n.replace_img).attr('src', n.url);
|
||||
}
|
||||
if (n.reload) {
|
||||
if (n.goto) {
|
||||
@@ -290,8 +290,8 @@ function miniupload() {
|
||||
jqXhr.onprogress = fun;
|
||||
//使用闭包实现监听绑
|
||||
return function () {
|
||||
//通过$.ajaxSettings.xhr();获得XMLHttpRequest对象
|
||||
var xhr = $.ajaxSettings.xhr();
|
||||
//通过jQuery.ajaxSettings.xhr();获得XMLHttpRequest对象
|
||||
var xhr = jQuery.ajaxSettings.xhr();
|
||||
//判断监听函数是否为函数
|
||||
if (typeof jqXhr.onprogress !== 'function') return xhr;
|
||||
//如果有监听函数并且xhr对象支持绑定时就把监听函数绑定上去
|
||||
|
||||
Reference in new issue
Block a user