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')) || (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')) {
// 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&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: 'jsonp',
data: request,
jsonp: 'callback'
});
}
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&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: 'jsonp',
data: request,
jsonp: 'callback'
});
}
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('');
}
});
}
}
// set regions that are on the page
regions = {};
var region = 0;
jQuery(document).ready(function($)
{
jQuery("#jform_region option").each(function()
{
var key = jQuery(this).val();
var text = jQuery(this).text();
regions[key] = text;
});
region = jQuery('#jform_region').val();
getRegion();
});
function getRegion_server(country){
var getUrl = "index.php?option=com_membersmanager&task=ajax.getRegion&format=json";
if(token.length > 0 && country > 0){
var request = 'token='+token+'&country='+country;
}
return jQuery.ajax({
type: 'GET',
url: getUrl,
dataType: 'jsonp',
data: request,
jsonp: 'callback'
});
}
function getRegion(){
jQuery("#loading").show();
// clear the selection
jQuery('#jform_region').find('option').remove().end();
jQuery('#jform_region').trigger('liszt:updated');
// get country value if set
var country = jQuery('#jform_country').val();
getRegion_server(country).done(function(result) {
setRegion(result);
jQuery("#loading").hide();
if (typeof regionButton !== 'undefined') {
// ensure button is correct
var region = jQuery('#jform_region').val();
regionButton(region);
}
});
}
function setRegion(array){
if (array) {
jQuery('#jform_region').append('
');
jQuery.each( array, function( i, id ) {
if (id in regions) {
jQuery('#jform_region').append('
');
}
if (id == region) {
jQuery('#jform_region').val(id);
}
});
} else {
jQuery('#jform_region').append('
');
}
jQuery('#jform_region').trigger('liszt:updated');
}