';
} else {
if (type === 'images' || type === 'image') {
var icon = 'uk-icon-file-image-o';
} else {
var icon = 'uk-icon-file';
}
var thenotice = '
Your '+target+' '+type+' '+isAre+' set
';
}
var thefile = getFile(filename, fileFormat, target, type);
jQuery("."+target+"_"+type+"_uploader").append(thenotice+thefile);
// all is done
return true;
}
function removeFileCheck(clearServer, target, type, uiVer){
if (3 == uiVer) {
UIkit.modal.confirm('Are you sure you want to delete this '+target+'?').then(function(){ removeFile(clearServer, target, 1, type); });
} else {
UIkit2.modal.confirm('Are you sure you want to delete this '+target+'?', function(){ removeFile(clearServer, target, 1, type); });
}
}
function removeFile(clearServer, target, flush, type){
if ((clearServer.length > 20 && (type === 'image' || type === 'document' || type === 'file')) || (clearServer.length > 1 && (type === 'images' || type === 'documents' || type === 'media'))){
// remove file from server
removeFile_server(clearServer, target, flush, type);
}
jQuery(".success-"+target+"-"+type+"-8768").remove();
// remove locally
if (clearServer.length > 20 && (type === 'image' || type === 'document' || type === 'file')) {
// remove the file
jQuery("#jform_"+target+"_"+type).val('');
} else if (clearServer.length > 20 && (type === 'images' || type === 'documents' || type === 'media')) {
// get the old values
var filenames = jQuery("#jform_"+target+"_"+type).val();
if (isJsonString(filenames)) {
filenames = jQuery.parseJSON(filenames);
// remove the current file from those values
filenames = jQuery.grep(filenames, function(value) {
return value != clearServer;
});
if (typeof filenames == 'object' && !jQuery.isEmptyObject(filenames)) {
// set the new values
var filename = JSON.stringify(filenames);
jQuery("#jform_"+target+"_"+type).val(filename);
setFile(filename, 0, target, type);
} else {
jQuery("#jform_"+target+"_"+type).val('');
}
} else {
jQuery("#jform_"+target+"_"+type).val('');
}
}
}
function removeFile_server(currentFileName, target, flush, type){
var getUrl = JRouter("index.php?option=com_membersmanager&task=ajax.removeFile&format=json&raw=true&vdm="+vastDevMod);
if(token.length > 0 && target.length > 0 && type.length > 0){
var request = 'token='+token+'&filename='+currentFileName+'&target='+target+'&flush='+flush+'&type='+type;
}
return jQuery.ajax({
type: 'GET',
url: getUrl,
dataType: 'json',
data: request,
jsonp: false
});
}
function isJsonString(str) {
if (typeof str != 'string') {
str = JSON.stringify(str);
}
try {
var json = jQuery.parseJSON(str);
} catch(err) {
return false;
}
if (typeof json == 'object' && isEmpty(json)) {
return false;
} else if(typeof json == 'object') {
return true;
}
return false;
}
function isEmpty(obj) {
for(var prop in obj) {
if(obj.hasOwnProperty(prop))
return false;
}
return true;
}
function checkUnique_server(value, field){
var getUrl = JRouter("index.php?option=com_membersmanager&task=ajax.checkUnique&format=json&raw=true&vdm="+vastDevMod);
if(token.length > 0 && value.length > 0 && field.length > 0){
var request = 'token='+token+'&value='+value+'&field='+field;
}
return jQuery.ajax({
type: 'GET',
url: getUrl,
dataType: 'json',
data: request,
jsonp: false
});
}
function checkUnique(value, field, show){
// check that we have a value
if (value.length > 1) {
checkUnique_server(value, field).done(function(result) {
if(result.value && result.message){
// show notice that functioName is okay
if (show) {
UIkit2.notify({message: result.message, timeout: 5000, status: result.status, pos: 'top-right'});
}
jQuery('#jform_'+field).val(result.value);
} else if(result.message){
// show notice that functionName is not okay
if (show) {
UIkit2.notify({message: result.message, timeout: 5000, status: result.status, pos: 'top-right'});
}
jQuery('#jform_'+field).val('');
} else {
// set an error that message was not send
if (show) {
UIkit2.notify({message: Joomla.JText._('COM_MEMBERSMANAGER_VALUE_ALREADY_TAKEN_PLEASE_TRY_AGAIN'), timeout: 5000, status: 'danger', pos: 'top-right'});
}
jQuery('#jform_'+field).val('');
}
});
}
}