Update content of files

This commit is contained in:
GitHub Action 2023-06-08 16:36:32 +00:00
parent 5bff5d2eb0
commit a4943559fd
5 changed files with 1624 additions and 348 deletions

View file

@ -440,7 +440,7 @@
isFocused = true;
var value = $field.value();
if (curValue != value ||
options.searchEnabled() && options.getData() === false) {
options.searchEnabled() && options.getData(value) === false) {
valueChange();
}
open();
@ -462,7 +462,7 @@
curValue = value;
console.log('valueChange', options.searchEnabled());
if (options.searchEnabled()) {
var data = options.getData();
var data = options.getData(value);
if (data === false) {
if (!dataWaiting) {
dataWaiting = true;
@ -700,6 +700,7 @@
$select.data('value', selValue);
$select.data('valueFull', selValueFull);
options.onChange && options.onChange(selValue, selValueFull);
$field.trigger('valuechange', [selValue, selValueFull]);
}
function toggleDD(open) {
@ -762,6 +763,7 @@
$('.selected-item', $selected).remove();
$selected.prepend(html);
options.onUpdate && options.onUpdate(getValue(), getValue(true));
$field.trigger('valueupdate', [getValue(), getValue(true)]);
}
var initTextarea = null;
@ -796,8 +798,8 @@
toggleDD(false);
}
}, options, {
getData: function() {
var data = options.getData();
getData: function(value) {
var data = options.getData(value);
if (data === false) {
return false;
}
@ -846,7 +848,7 @@
var defValue = $select.defaultValue();
var defSelected = defValue.length ? defValue.split(';') : [], dataMap = {};
if (defSelected.length) {
var data = options.getData();
var data = options.getData('');
if (data !== false) {
for (var i = 0; i < data.length; i++) {
var val = (data[i].prefix || '') + data[i].val;
@ -1078,6 +1080,22 @@
}
}).get() || [];
};
$.fn.cssProp = function(prop, val) {
if (typeof val !== 'undefined') {
return this.each(function() {
if (this.style && this.style.setProperty) {
this.style.setProperty(prop, val);
}
});
}
return this.first().map(function() {
if (this.style && this.style.getPropertyValue) {
return this.style.getPropertyValue(prop);
} else {
return '';
}
}).get(0) || '';
};
$.fn.initTextarea = function(options) {
options = options || {};

File diff suppressed because it is too large Load diff

View file

@ -440,7 +440,7 @@
isFocused = true;
var value = $field.value();
if (curValue != value ||
options.searchEnabled() && options.getData() === false) {
options.searchEnabled() && options.getData(value) === false) {
valueChange();
}
open();
@ -462,7 +462,7 @@
curValue = value;
console.log('valueChange', options.searchEnabled());
if (options.searchEnabled()) {
var data = options.getData();
var data = options.getData(value);
if (data === false) {
if (!dataWaiting) {
dataWaiting = true;
@ -700,6 +700,7 @@
$select.data('value', selValue);
$select.data('valueFull', selValueFull);
options.onChange && options.onChange(selValue, selValueFull);
$field.trigger('valuechange', [selValue, selValueFull]);
}
function toggleDD(open) {
@ -762,6 +763,7 @@
$('.selected-item', $selected).remove();
$selected.prepend(html);
options.onUpdate && options.onUpdate(getValue(), getValue(true));
$field.trigger('valueupdate', [getValue(), getValue(true)]);
}
var initTextarea = null;
@ -796,8 +798,8 @@
toggleDD(false);
}
}, options, {
getData: function() {
var data = options.getData();
getData: function(value) {
var data = options.getData(value);
if (data === false) {
return false;
}
@ -846,7 +848,7 @@
var defValue = $select.defaultValue();
var defSelected = defValue.length ? defValue.split(';') : [], dataMap = {};
if (defSelected.length) {
var data = options.getData();
var data = options.getData('');
if (data !== false) {
for (var i = 0; i < data.length; i++) {
var val = (data[i].prefix || '') + data[i].val;
@ -1078,6 +1080,22 @@
}
}).get() || [];
};
$.fn.cssProp = function(prop, val) {
if (typeof val !== 'undefined') {
return this.each(function() {
if (this.style && this.style.setProperty) {
this.style.setProperty(prop, val);
}
});
}
return this.first().map(function() {
if (this.style && this.style.getPropertyValue) {
return this.style.getPropertyValue(prop);
} else {
return '';
}
}).get(0) || '';
};
$.fn.initTextarea = function(options) {
options = options || {};

File diff suppressed because it is too large Load diff

View file

@ -64,6 +64,7 @@ function ajInit(options) {
setLayerLocation: setLayerLocation,
reload: reload,
apiRequest: apiRequest,
uploadRequest: uploadRequest,
needAuth: needAuth,
ajContainer: ajContainer,
state: options.state || {},
@ -124,13 +125,58 @@ function ajInit(options) {
// was aborted
} else if (xhr.status == 401) {
location.href = '/auth';
} else {
} else if (xhr.readyState > 0) {
location.reload();
}
}
});
}
function uploadRequest(method, file, params, onSuccess, onProgress) {
var data = new FormData();
data.append('file', file, file.name);
data.append('method', method);
for (var key in params) {
data.append(key, params[key]);
}
return $.ajax(Aj.apiUrl, {
type: 'POST',
data: data,
cache: false,
dataType: 'json',
processData: false,
contentType: false,
xhrFields: {
withCredentials: true
},
xhr: function() {
var xhr = new XMLHttpRequest();
xhr.upload.addEventListener('progress', function(event) {
if (event.lengthComputable) {
onProgress && onProgress(event.loaded, event.total);
}
});
return xhr;
},
beforeSend: function(xhr) {
onProgress && onProgress(0, 1);
},
success: function(result) {
if (result._dlog) {
$('#dlog').append(result._dlog);
}
onSuccess && onSuccess(result);
},
error: function(xhr) {
if (xhr.status == 401) {
location.href = '/auth';
} else if (xhr.readyState > 0) {
onSuccess && onSuccess({error: 'Network error'});
}
}
});
}
function loc(href) {
var url = document.createElement('a');
url.href = href;