// Init variables
var currentTabId = null;
-var errorDisplayed = false;
-var warningDisplayed = false;
var defaultTabId = null;
var footerElements = new Array();
var changedElements = new Array();
currentTabId = tabId;
}
+// Checks whether a given element is visible by checking 'display: none'
+function isElementVisible (prefix, element) {
+ // Get element
+ var el = document.getElementById(prefix + '_' + element);
+
+ // Is element set?
+ if (el == null || el == undefined) {
+ throw new '"' + prefix + '_' + element + '" does not exist.';
+ }
+
+ // Default is visible
+ var isVisible = ((el.style.display == undefined) || ((el.style.display != 'none') && (el.style.display != '')));
+
+ // Return status
+ return isVisible;
+}
+
// Marks a tab navigation entry
function markTabNavigation (prefix, tab) {
+ // Is process working?
+ if (isElementVisible(prefix, 'process')) {
+ // Then exit silently
+ return;
+ } // END - if
+
// Get all li-tags
var li = document.getElementsByTagName('li');
// Enables a given footer navigation element
function enableFooterNavigationPage (element) {
// Remove the 'disabled' class and attribute
- enableElement('input#' + element + '_page');
+ if (element == 'finish') {
+ enableElement('input#finish');
+ } else {
+ enableElement('input#' + element + '_page');
+ disableElement('input#finish');
+ }
}
// Resets footer navigation by adding CSS class 'disabled'
// Set AJAX reply and decode JSON if requested
function setAjaxReply (reply, isJson) {
- // Copy reply to local variable
- var localReply = reply;
-
// Is it JSON URL-encoded content?
if ((isJson != undefined) && (isJson == true)) {
- // Then decode it, replace '%20' with space before because '%20' breakes JSON content
- var obj = jQuery.parseJSON(reply.replace('%20', ' '));
+ // Decode URL-encoding (for some reason it must be here ...)
+ var localReply = decodeUrlEncoding(reply);
- // Is reply_content there
- if (obj.reply_content == undefined) {
- // Not defined
- throw new 'obj.reply_content not returned from ajax.php, please fix your scripts.';
- } // END - if
+ // Then decode it, replace '%20' with space before because '%20' breakes JSON content
+ var obj = jQuery.parseJSON(localReply.replace('%20', ' '));
// ... and set it
- setAjaxDecodedContent(obj.reply_content);
+ setAjaxContent(obj);
} else {
// Handle the content over to decode it
- setAjaxDecodedContent(localReply);
+ setAjaxDecodedContent(reply);
}
}
// Is ajax_content set?
if (ajax_content.reply_content == undefined) {
// This shall not happen
- throw new 'ajax_content.reply_content not returned from ajax.php, please fix your scripts.';
+ throw new 'ajax_content.reply_content not returned from ajax.php, please fix your scripts. (1)';
} else if (ajax_content.reply_content == null) {
// This shall not happen, too
- throw new 'ajax_content.reply_content=null from ajax.php, please fix your scripts.';
+ throw new 'ajax_content.reply_content=null from ajax.php, please fix your scripts. (2)';
}
// Set AJAX reply
error: function (ajax_content) {
// Is ajax_content set?
if (ajax_content.reply_content == undefined) {
- // This shall not happen
- throw new 'ajax_content.reply_content not returned from ajax.php, please fix your scripts.';
+ // Is 'responseText' there?
+ if (ajax_content.responseText != undefined) {
+ // Then parse it
+ var obj = jQuery.parseJSON(ajax_content.responseText.replace('%20', ' '));
+
+ // Is 'reply_content' set?
+ if (obj.reply_content == undefined) {
+ // This shall not happen
+ throw new 'obj.reply_content not returned from ajax.php, please fix your scripts. (3)';
+ } // END - if
+
+ // Set it
+ setAjaxReply(obj.reply_content, false);
+ return false;
+ } else {
+ // This shall not happen
+ throw new 'ajax_content.reply_content not returned from ajax.php, please fix your scripts. (4)';
+ }
} else if (ajax_content.reply_content == null) {
// This shall not happen, too
- throw new 'ajax_content.reply_content=null from ajax.php, please fix your scripts.';
+ throw new 'ajax_content.reply_content=null from ajax.php, please fix your scripts. (5)';
}
// Set AJAX reply
// Enables footer navigation buttons
function enableFooterNavigation (prefix, tabId) {
+ // Is process working?
+ if (isElementVisible(prefix, 'process')) {
+ // Then exit silently
+ return;
+ } // END - if
+
// Reset both footer navigation first
resetFooterNavigation();
// Requests an AJAX content
function requestAjaxContent (prefix, htmlId, tabId, footerNavigation) {
+ // Is process working?
+ if (isElementVisible(prefix, 'process')) {
+ // Then exit silently
+ return;
+ } // END - if
+
// Check if this request is disabled
if ($('#' + prefix + '_' + tabId).hasClass('tab_disabled')) {
// Clicked on a disabled tabId so blur it
// Fade the old content out
$('#' + htmlId).fadeOut('fast', function() {
// Send AJAX request
- if (sendAjaxRequest(prefix, 'request_content', '&tab=' + tabId, true) == true) {
+ if (sendAjaxRequest(prefix, 'request_content', '&tab=' + tabId, false) == true) {
// Add the HTML content
$('#' + htmlId).html(getAjaxContent());
});
// Request it from the AJAX backend
- if (sendAjaxRequest(prefix, 'test', '') == true) {
+ if (sendAjaxRequest(prefix, 'test', '', false) == true) {
// Transfer the returned content to the prefix_warning_content id
$('#' + prefix + '_warning_content').html(getAjaxContent());
// Enable element
enableElement(element);
});
-
- // Mark 'warning' as displayed
- warningDisplayed = true;
} else {
// Display error message
displayErrorWindow(prefix, getAjaxContent());
// Fade error out for eye-candy, if open
closeErrorWindow(prefix);
+ // Fade it out for eye-candy
+ closeProcessWindow(prefix);
+
// Abort here if warningDisplayed is still true
- if (warningDisplayed == true) {
+ if (isElementVisible(prefix, 'warning')) {
// Make sure this doesn't happen
return;
} // END - if
// Fade the warning in
$('#' + prefix + '_warning').fadeIn('slow', function() {
- // Mark warning as displayed
- warningDisplayed = true;
+ // Do nothing for now
});
} else {
// Display error message
// Fade it out for eye-candy
closeErrorWindow(prefix);
+ // Fade it out for eye-candy
+ closeProcessWindow(prefix);
+
// Abort here if errorDisplayed is still true
- if (errorDisplayed == true) {
+ if (isElementVisible(prefix, 'error')) {
// Make sure this doesn't happen
return;
} // END - if
// Fade the error in
$('#' + prefix + '_error').fadeIn('slow', function() {
- // Mark error as displayed
- errorDisplayed = true;
+ // Do nothing for now
});
}
+// Displays the process window for given prefix and content
+function displayProcessWindow (prefix, ajax_content) {
+ // Fade out warning window, if open
+ //* DEBUG: */ alert('displayProcessWindow(): prefix=' + prefix + ' - calling closeWarningWindow()');
+ closeWarningWindow(prefix);
+
+ // Fade it out for eye-candy
+ closeErrorWindow(prefix);
+
+ // Fade it out for eye-candy
+ closeProcessWindow(prefix);
+
+ // Abort here if processDisplayed is still true
+ if (isElementVisible(prefix, 'process')) {
+ // Make sure this doesn't happen
+ return;
+ } // END - if
+
+ // Copy the response text to the process variable
+ if (ajax_content.reply_content != undefined) {
+ // Set HTML content
+ setProcessContent(prefix, ajax_content.reply_content);
+ } else {
+ setProcessContent(prefix, ajax_content);
+ }
+
+ // Fade the process in
+ $('#' + prefix + '_process').fadeIn('slow', function() {
+ // Do nothing for now
+ });
+}
+
+// Sets "process content"
+function setProcessContent (prefix, content) {
+ // Set HTML content
+ $('#' + prefix + '_process_content').html(content);
+}
+
// Waits until the window has been closed
function closeErrorLocked () {
// Has all been loaded?
- if (errorDisplayed == false) {
+ if (!isElementVisible(prefix, 'error')) {
// Then release ready()
$.holdReady(false);
} else {
}
}
+// Waits until the window has been closed
+function closeProcessLocked () {
+ // Has all been loaded?
+ if (!isElementVisible(prefix, 'process')) {
+ // Then release ready()
+ $.holdReady(false);
+ } else {
+ // Recursive call again
+ window.setTimeout('closeProcessLocked()', 10);
+ }
+}
+
// Closes an error window
function closeErrorWindow (prefix, waitClose, resetCurrentTabId) {
// Is the error displayed?
- if (errorDisplayed == true) {
+ if (isElementVisible(prefix, 'error')) {
// Shall we wait ("sync") until the animation has completed?
if (waitClose == true) {
// Hold the ready status
if (resetCurrentTabId == true) {
setCurrentTabId(defaultTabId);
} // END - if
-
- // Mark it as closed
- errorDisplayed = false;
});
// Shall this animation be "synchronized"?
} // END - if
}
+// Closes an process window
+function closeProcessWindow (prefix, waitClose, resetCurrentTabId) {
+ // Is the process displayed?
+ if (isElementVisible(prefix, 'process')) {
+ // Shall we wait ("sync") until the animation has completed?
+ if (waitClose == true) {
+ // Hold the ready status
+ $.holdReady(true);
+ } // END - if
+
+ // Yes, then fade it out
+ $('#' + prefix + '_process').fadeOut('fast', function() {
+ // Set current tab id to default
+ if (resetCurrentTabId == true) {
+ setCurrentTabId(defaultTabId);
+ } // END - if
+ });
+
+ // Shall this animation be "synchronized"?
+ if (waitClose == true) {
+ // Wait for the window has been closed
+ closeProcessLocked();
+ } // END - if
+ } // END - if
+}
+
// Waits until the window has been closed
function closeWarningLocked () {
// Has all been loaded?
- if (warningDisplayed == false) {
+ if (!isElementVisible(prefix, 'warning')) {
// Then release ready()
$.holdReady(false);
} else {
function closeWarningWindow (prefix, waitClose, resetCurrentTabId) {
//* DEBUG: */ alert('prefix=' + prefix + ',waitClose=' + waitClose + ' - ENTERED!');
// Is the warning displayed?
- if (warningDisplayed == true) {
+ if (isElementVisible(prefix, 'warning')) {
// Shall we wait ("sync") until the animation has completed?
//* DEBUG: */ alert('prefix=' + prefix + ',waitClose=' + waitClose + ',warningDisplayed=true');
if (waitClose == true) {
// Yes, then fade it out
$('#' + prefix + '_warning').fadeOut('fast', function() {
// Set current tab id to default
- //* DEBUG: */ alert('closeWarningWindow(): prefix=' + prefix + ',waitClose=' + waitClose + ',defaultTab=' + defaultTabId + ' - Calling setCurrentTabId()');
if (resetCurrentTabId == true) {
setCurrentTabId(defaultTabId);
} // END - if
-
- // Mark it as closed
- warningDisplayed = false;
- //* DEBUG: */ alert('closeWarningWindow(): waitClose=' + waitClose + ',resetCurrentTabId=' + resetCurrentTabId + ',warningDisplayed=false');
});
// Shall this animation be "synchronized"?
return;
} // END - if
- // Do we have a 'next' entry?
+ // Is process working?
+ if (isElementVisible(prefix, 'process')) {
+ // Then exit silently
+ return;
+ } // END - if
+
+ // Is there a 'next' entry?
//* DEBUG: */ alert('doFooterPage(): button=' + button + ',currentTabId=' + currentTabId + ',nextPage[currentTabId]=' + nextPage[currentTabId]);
if ((button == 'next') && (nextPage[currentTabId] != null)) {
// Then call the AJAX requester
- requestAjaxContent(prefix, htmlId, nextPage[currentTabId]);
+ var page = nextPage[currentTabId];
} else if ((button == 'previous') && (previousPage[currentTabId] != null)) {
// Then call the AJAX requester
- requestAjaxContent(prefix, htmlId, previousPage[currentTabId]);
+ var page = previousPage[currentTabId];
}
+
+ // Request AJAX content
+ requestAjaxContent(prefix, htmlId, page);
+
+ // Change the footer navigation
+ enableFooterNavigation(prefix, page);
}
// Allows to save made changes (this will be called if the onchange event has been triggered)
// Saves changes by sending the data to the AJAX backend script
function saveChanges (prefix) {
+ // Is process working?
+ if (isElementVisible(prefix, 'process')) {
+ // Then exit silently
+ return;
+ } // END - if
+
// Mark all elements as unchanged
markAllElementsAsUnchanged();
- // Do we have changed elements
+ // Is there changed elements
if (changedElements.length == 0) {
// This should not happen
displayErrorWindow(prefix, '<div class="ajax_error_message">saveChanges() called with no changed elements.</div>');
// Reset form
resetMailerAjaxForm();
} else {
- // Do we have 'failed_fields' set?
+ // Is there 'failed_fields' set?
if ((ajax_content.failed_fields != undefined) && (ajax_content.message != undefined)) {
// Mark all fields as 'failed'
markFormFieldsFailed(ajax_content.failed_fields);
// Saves changed settings and continues with given tab
function doSaveChangesContinue (prefix, htmlId, tab) {
+ // Is process working?
+ if (isElementVisible(prefix, 'process')) {
+ // Then exit silently
+ return;
+ } // END - if
+
// Save the changes
saveChanges(prefix);