- AjaxLib.css: better veil

- AjaxLib.js:
	- Renamed object FHC_Ajax_Client to FHC_AjaxClient
	- Removed REMOTE_CONTROLLER property from object data used as ajax call parameter
- Adapted FilterWidget.js to use AjaxLib.js
- Adapted NavigationWidget.js to use AjaxLib.js
- Introduced fhc_controller_id in method _printNavItem of NavigationWidget.js
- Adapted infocenterDetails.js and infocenterPersonDataset.js to use changed libraries
This commit is contained in:
Paolo
2018-05-22 18:08:54 +02:00
parent 4b1eacff21
commit 3c7fc4bdbd
6 changed files with 856 additions and 820 deletions
+5 -6
View File
@@ -1,14 +1,13 @@
.veil {
position: absolute;
z-index: 9999;
top: 0;
left: 0;
height: 98%;
width: 99%;
height: 100%;
width: 100%;
background-color: white;
border-width: 1px;
border-style: solid;
border-color: black;
background-image: url("/public/imgages/loader.gif");
border-width: 0px;
background-image: url("../images/loader.gif");
background-repeat: no-repeat;
background-position: center;
}
+32 -33
View File
@@ -37,9 +37,9 @@ const REMOTE_CONTROLLER = "remoteController";
const FHC_CONTROLLER_ID = "fhc_controller_id";
/**
* Definition and initialization of object FHC_Ajax_Client
* Definition and initialization of object FHC_AjaxClient
*/
var FHC_Ajax_Client = {
var FHC_AjaxClient = {
//------------------------------------------------------------------------------------------------------------------
// Properties
@@ -54,7 +54,7 @@ var FHC_Ajax_Client = {
* ajaxCallParameters is an object
*/
ajaxCallGet: function(remoteController, controllerParameters, ajaxCallParameters) {
FHC_Ajax_Client._ajaxCall(remoteController, controllerParameters, HTTP_GET_METHOD, ajaxCallParameters);
FHC_AjaxClient._ajaxCall(remoteController, controllerParameters, HTTP_GET_METHOD, ajaxCallParameters);
},
/**
@@ -63,7 +63,7 @@ var FHC_Ajax_Client = {
* ajaxCallParameters is an object
*/
ajaxCallPost: function(remoteController, controllerParameters, ajaxCallParameters) {
FHC_Ajax_Client._ajaxCall(remoteController, controllerParameters, HTTP_POST_METHOD, ajaxCallParameters);
FHC_AjaxClient._ajaxCall(remoteController, controllerParameters, HTTP_POST_METHOD, ajaxCallParameters);
},
/**
@@ -87,7 +87,7 @@ var FHC_Ajax_Client = {
* Checks if the response is an error
*/
isError: function(response) {
return !FHC_Ajax_Client.isSuccess(response);
return !FHC_AjaxClient.isSuccess(response);
},
/**
@@ -96,7 +96,7 @@ var FHC_Ajax_Client = {
hasData: function(response) {
var hasData = false;
if (FHC_Ajax_Client.isSuccess(response))
if (FHC_AjaxClient.isSuccess(response))
{
if ((jQuery.type(response.retval) == "object" && !jQuery.isEmptyObject(response.retval))
|| (jQuery.isArray(response.retval) && response.retval.length > 0)
@@ -116,7 +116,7 @@ var FHC_Ajax_Client = {
getData: function(response) {
var data = null;
if (FHC_Ajax_Client.hasData(response))
if (FHC_AjaxClient.hasData(response))
{
data = response.retval;
}
@@ -147,20 +147,20 @@ var FHC_Ajax_Client = {
showVeil: function(veilTimeout) {
if (typeof veilTimeout == "number")
{
FHC_Ajax_Client._veilTimeout = veilTimeout;
FHC_AjaxClient._veilTimeout = veilTimeout;
}
else
{
FHC_Ajax_Client._veilTimeout = VEIL_TIMEOUT;
FHC_AjaxClient._veilTimeout = VEIL_TIMEOUT;
}
FHC_Ajax_Client._showVeil();
FHC_AjaxClient._showVeil();
},
/**
* Hide a veil that was shown before
*/
hideVeil: function() {
FHC_Ajax_Client._hideVeil();
FHC_AjaxClient._hideVeil();
},
//------------------------------------------------------------------------------------------------------------------
@@ -212,10 +212,10 @@ var FHC_Ajax_Client = {
*/
_onSuccess: function(response, textStatus, jqXHR) {
FHC_Ajax_Client._printDebug(this._data, response); // debug time!
FHC_AjaxClient._printDebug(this._data, response); // debug time!
// Call the success callback saved in _successCallback property
// NOTE: this is not referred to FHC_Ajax_Client but to the ajax object
// NOTE: this is not referred to FHC_AjaxClient but to the ajax object
this._successCallback(response);
},
@@ -224,10 +224,10 @@ var FHC_Ajax_Client = {
*/
_onError: function(jqXHR, textStatus, errorThrown) {
FHC_Ajax_Client._printDebug(this._data, null, errorThrown); // debug time!
FHC_AjaxClient._printDebug(this._data, null, errorThrown); // debug time!
// Call the error callback saved in _errorCallback property
// NOTE: this is not referred to FHC_Ajax_Client but to the ajax object
// NOTE: this is not referred to FHC_AjaxClient but to the ajax object
this._errorCallback(jqXHR, textStatus, errorThrown);
},
@@ -249,12 +249,12 @@ var FHC_Ajax_Client = {
* Method to show the veil
*/
_showVeil: function() {
if (FHC_Ajax_Client._veilCallersCounter == 0)
if (FHC_AjaxClient._veilCallersCounter == 0)
{
$("<div class=\"veil\"></div>").appendTo('body');
}
FHC_Ajax_Client._veilCallersCounter++;
FHC_AjaxClient._veilCallersCounter++;
},
/**
@@ -262,14 +262,14 @@ var FHC_Ajax_Client = {
*/
_hideVeil: function() {
window.setTimeout(function() {
if (FHC_Ajax_Client._veilCallersCounter >= 0)
if (FHC_AjaxClient._veilCallersCounter >= 0)
{
if (FHC_Ajax_Client._veilCallersCounter > 0)
if (FHC_AjaxClient._veilCallersCounter > 0)
{
FHC_Ajax_Client._veilCallersCounter--;
FHC_AjaxClient._veilCallersCounter--;
}
if (FHC_Ajax_Client._veilCallersCounter == 0)
if (FHC_AjaxClient._veilCallersCounter == 0)
{
$(".veil").remove();
}
@@ -319,7 +319,7 @@ var FHC_Ajax_Client = {
if (typeof remoteController == "string" && remoteController.trim() != "")
{
// Is it possible to generate the URL
if ((url = FHC_Ajax_Client._generateRouterURI(remoteController)) != null)
if ((url = FHC_AjaxClient._generateRouterURI(remoteController)) != null)
{
ajaxParameters.url = url;
}
@@ -339,11 +339,10 @@ var FHC_Ajax_Client = {
if (typeof controllerParameters == "object")
{
// Copy the properties of controllerParameters into a new object
var data = FHC_Ajax_Client._cpObjProps(controllerParameters);
// Remote controller
data[REMOTE_CONTROLLER] = remoteController;
var data = FHC_AjaxClient._cpObjProps(controllerParameters);
// fhc_controller_id is given if present
data[FHC_CONTROLLER_ID] = FHC_Ajax_Client.getUrlParameter(FHC_CONTROLLER_ID);
data[FHC_CONTROLLER_ID] = FHC_AjaxClient.getUrlParameter(FHC_CONTROLLER_ID);
// Stores them into ajaxParameters
// NOTE: property data is not possible to get later,
@@ -367,7 +366,7 @@ var FHC_Ajax_Client = {
if (typeof ajaxCallParameters.errorCallback == "function")
{
ajaxParameters._errorCallback = ajaxCallParameters.errorCallback; // save as property the callback error
ajaxParameters.error = FHC_Ajax_Client._onError; // function to call if an error occurred
ajaxParameters.error = FHC_AjaxClient._onError; // function to call if an error occurred
}
else
{
@@ -382,7 +381,7 @@ var FHC_Ajax_Client = {
if (typeof ajaxCallParameters.successCallback == "function")
{
ajaxParameters._successCallback = ajaxCallParameters.successCallback; // save as property the callback success
ajaxParameters.success = FHC_Ajax_Client._onSuccess; // function to call if succeeded
ajaxParameters.success = FHC_AjaxClient._onSuccess; // function to call if succeeded
}
else
{
@@ -397,8 +396,8 @@ var FHC_Ajax_Client = {
if (ajaxCallParameters.veilTimeout > 0 && ajaxCallParameters.veilTimeout < 60000)
{
ajaxParameters._veilTimeout = ajaxCallParameters.veilTimeout;
ajaxParameters.beforeSend = FHC_Ajax_Client._showVeil;
ajaxParameters.complete = FHC_Ajax_Client._hideVeil;
ajaxParameters.beforeSend = FHC_AjaxClient._showVeil;
ajaxParameters.complete = FHC_AjaxClient._hideVeil;
}
else if(ajaxCallParameters.veilTimeout == 0)
{
@@ -413,8 +412,8 @@ var FHC_Ajax_Client = {
else // is not present or the value is invalid
{
ajaxParameters._veilTimeout = VEIL_TIMEOUT;
ajaxParameters.beforeSend = FHC_Ajax_Client._showVeil;
ajaxParameters.complete = FHC_Ajax_Client._hideVeil;
ajaxParameters.beforeSend = FHC_AjaxClient._showVeil;
ajaxParameters.complete = FHC_AjaxClient._hideVeil;
}
}
@@ -438,7 +437,7 @@ var FHC_Ajax_Client = {
*/
_ajaxCall: function(remoteController, controllerParameters, type, ajaxCallParameters) {
// Retrives the parameters for the ajax call
var ajaxParameters = FHC_Ajax_Client._checkAndGenerateAjaxParams(remoteController, controllerParameters, type, ajaxCallParameters);
var ajaxParameters = FHC_AjaxClient._checkAndGenerateAjaxParams(remoteController, controllerParameters, type, ajaxCallParameters);
// Checks the given parameters if they are present and are valid
if (ajaxParameters != null)
+641 -630
View File
File diff suppressed because it is too large Load Diff
+176 -149
View File
@@ -1,171 +1,198 @@
/**
* Used by the NavigationWidget
*/
var fhc_controller_id = FHC_Ajax_Client.getUrlParameter('fhc_controller_id');
/**
* FH-Complete
*
* @package
* @author
* @copyright Copyright (c) 2016 fhcomplete.org
* @license GPLv3
* @link https://fhcomplete.org
* @since Version 1.0.0
*/
function printNavItem(item, depth = 1)
{
strMenu = "";
var expanded = typeof item['expand'] != 'undefined' && item['expand'] === true ? ' active' : '';
strMenu += '<li class="' + expanded + '">';
/**
* FHC_NavigationWidget
*/
var FHC_NavigationWidget = {
//------------------------------------------------------------------------------------------------------------------
// Public methods
if (typeof item['subscriptLinkClass'] != 'undefined' && typeof item['subscriptDescription'] != 'undefined')
{
strMenu += '<span>';
}
/**
* Renders the header menu (top horizontal menu)
*/
renderHeaderMenu: function() {
//
FHC_AjaxClient.ajaxCallGet(
'system/Navigation/header',
{
navigation_widget_called: FHC_NavigationWidget._getNavigationWidgetCalled()
},
{
successCallback: function(data, textStatus, jqXHR) {
if (data != null)
{
jQuery.each(data, function(i, e) {
$(".menu-header-items").append('<a class="navbar-brand" href="' + e + '">' + i + '</a>');
});
}
}
}
);
},
// Handle fhc_controller_id
if (fhc_controller_id != null && fhc_controller_id != '' && item['link'] != '#')
{
if (item['link'].indexOf('?') != -1)
{
item['link'] += '&';
}
else
{
item['link'] += '?';
}
/**
* Renders the side left menu
*/
renderSideMenu: function() {
//
FHC_AjaxClient.ajaxCallGet(
'system/Navigation/menu',
{
navigation_widget_called: FHC_NavigationWidget._getNavigationWidgetCalled()
},
{
successCallback: function(data, textStatus, jqXHR) {
if (data != null)
{
var strMenu = '';
item['link'] += 'fhc_controller_id=' + fhc_controller_id;
}
FHC_NavigationWidget._printCollapseIcon();
strMenu += '<a href="' + item['link'] + '"' + expanded + '>';
jQuery.each(data, function(i, e) {
strMenu += FHC_NavigationWidget._printNavItem(e);
});
if (item['icon'] != 'undefined')
{
strMenu += '<i class="fa fa-' + item['icon'] + ' fa-fw"></i> ';
}
$("#side-menu").html(strMenu);
$("#side-menu").metisMenu();
}
strMenu += item['description'];
if (typeof sideMenuHook == 'function')
{
sideMenuHook();
}
}
}
);
},
if (typeof item['children'] != 'undefined' && Object.keys(item['children']).length > 0)
{
strMenu += '<span class="fa arrow"></span>';
}
//------------------------------------------------------------------------------------------------------------------
// Private methods
strMenu += '</a>';
/**
*
*/
_printCollapseIcon: function() {
// Hiding/showing navigation menu - works only with sb admin 2 template!!
if(!$("#collapseicon").length)
$("#side-menu").parent().append('<div id="collapseicon" title="hide Menu" class="text-right" style="cursor: pointer; color: #337ab7"><i class="fa fa-angle-double-left fa-fw"></i></div>');
if (typeof item['subscriptLinkClass'] != 'undefined' && typeof item['subscriptDescription'] != 'undefined')
{
strMenu += '<a class="' + item['subscriptLinkClass'] + ' menuSubscriptLink" value="' + item['subscriptLinkValue'] + '" href="#"> (' + item['subscriptDescription'] + ')</a>';
strMenu += '</span>';
}
if (typeof item['children'] != 'undefined' && Object.keys(item['children']).length > 0)
{
var level = '';
if (depth === 1)
{
level = 'second';
}
else if (depth > 1)
{
level = 'third';
}
strMenu += '<ul class="nav nav-' + level + '-level" ' + expanded + '>';
jQuery.each(item['children'], function(i, e) {
strMenu += printNavItem(e, ++depth);
$("#collapseicon").click(function() {
$("#page-wrapper").css('margin-left', '0px');
$("#side-menu").hide();
$("#collapseicon").hide();
$("#collapseinicon").show();
});
strMenu += '</ul>';
$("#collapseinicon").click(function() {
$("#page-wrapper").css('margin-left', '250px');
$("#side-menu").show();
$("#collapseicon").show();
$("#collapseinicon").hide();
});
},
/**
*
*/
_printNavItem: function(item, depth = 1) {
strMenu = "";
var expanded = typeof item['expand'] != 'undefined' && item['expand'] === true ? ' active' : '';
strMenu += '<li class="' + expanded + '">';
if (typeof item['subscriptLinkClass'] != 'undefined' && typeof item['subscriptDescription'] != 'undefined')
{
strMenu += '<span>';
}
// Handle fhc_controller_id
var fhc_controller_id = FHC_AjaxClient.getUrlParameter('fhc_controller_id');
if (fhc_controller_id != null && fhc_controller_id != '' && item['link'] != '#')
{
if (item['link'].indexOf('?') != -1)
{
item['link'] += '&';
}
else
{
item['link'] += '?';
}
item['link'] += 'fhc_controller_id=' + fhc_controller_id;
}
strMenu += '<a href="' + item['link'] + '"' + expanded + '>';
if (item['icon'] != 'undefined')
{
strMenu += '<i class="fa fa-' + item['icon'] + ' fa-fw"></i> ';
}
strMenu += item['description'];
if (typeof item['children'] != 'undefined' && Object.keys(item['children']).length > 0)
{
strMenu += '<span class="fa arrow"></span>';
}
strMenu += '</a>';
if (typeof item['subscriptLinkClass'] != 'undefined' && typeof item['subscriptDescription'] != 'undefined')
{
strMenu += '<a class="' + item['subscriptLinkClass'] + ' menuSubscriptLink" value="' + item['subscriptLinkValue'] + '" href="#"> (' + item['subscriptDescription'] + ')</a>';
strMenu += '</span>';
}
if (typeof item['children'] != 'undefined' && Object.keys(item['children']).length > 0)
{
var level = '';
if (depth === 1)
{
level = 'second';
}
else if (depth > 1)
{
level = 'third';
}
strMenu += '<ul class="nav nav-' + level + '-level" ' + expanded + '>';
jQuery.each(item['children'], function(i, e) {
strMenu += FHC_NavigationWidget._printNavItem(e, ++depth);
});
strMenu += '</ul>';
}
strMenu += '</li>';
return strMenu;
},
/**
* Returns the URI of the caller
*/
_getNavigationWidgetCalled: function() {
return FHC_JS_DATA_STORAGE_OBJECT.called_path + "/" + FHC_JS_DATA_STORAGE_OBJECT.called_method;
}
};
strMenu += '</li>';
return strMenu;
}
function renderSideMenu()
{
$.ajax({
url: FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/" + 'system/Navigation/menu',
method: "GET",
data: {
navigation_widget_called: FHC_JS_DATA_STORAGE_OBJECT.called_path + "/" + FHC_JS_DATA_STORAGE_OBJECT.called_method
}
})
.done(function(data, textStatus, jqXHR) {
if (data != null)
{
var strMenu = '';
printCollapseIcon();
jQuery.each(data, function(i, e) {
strMenu += printNavItem(e);
});
$("#side-menu").html(strMenu);
$("#side-menu").metisMenu();
}
if (typeof sideMenuHook == 'function')
{
sideMenuHook();
}
}).fail(function(jqXHR, textStatus, errorThrown) {
// alert(textStatus);
});
}
function printCollapseIcon()
{
// Hiding/showing navigation menu - works only with sb admin 2 template!!
if(!$("#collapseicon").length)
$("#side-menu").parent().append('<div id="collapseicon" title="hide Menu" class="text-right" style="cursor: pointer; color: #337ab7"><i class="fa fa-angle-double-left fa-fw"></i></div>');
$("#collapseicon").click(function() {
$("#page-wrapper").css('margin-left', '0px');
$("#side-menu").hide();
$("#collapseicon").hide();
$("#collapseinicon").show();
});
$("#collapseinicon").click(function() {
$("#page-wrapper").css('margin-left', '250px');
$("#side-menu").show();
$("#collapseicon").show();
$("#collapseinicon").hide();
});
}
function renderHeaderMenu()
{
$.ajax({
url: FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/" + 'system/Navigation/header',
method: "GET",
data: {
navigation_widget_called: FHC_JS_DATA_STORAGE_OBJECT.called_path + "/" + FHC_JS_DATA_STORAGE_OBJECT.called_method
}
})
.done(function(data, textStatus, jqXHR) {
if (data != null)
{
jQuery.each(data, function(i, e) {
$(".menu-header-items").append('<a class="navbar-brand" href="' + e + '">' + i + '</a>');
});
}
}).fail(function(jqXHR, textStatus, errorThrown) {
// alert(textStatus);
});
}
/**
* When JQuery is up
*/
$(document).ready(function() {
renderHeaderMenu();
FHC_NavigationWidget.renderHeaderMenu();
renderSideMenu();
FHC_NavigationWidget.renderSideMenu();
});
+1 -1
View File
@@ -1,5 +1,5 @@
var fhc_controller_id = FHC_Ajax_Client.getUrlParameter('fhc_controller_id');
var fhc_controller_id = FHC_AjaxClient.getUrlParameter('fhc_controller_id');
const CONTROLLER_URL = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/"+FHC_JS_DATA_STORAGE_OBJECT.called_path;
/**
@@ -145,7 +145,7 @@ function refreshSideMenu()
})
.done(function(data, textStatus, jqXHR) {
renderSideMenu();
FHC_NavigationWidget.renderSideMenu();
}).fail(function(jqXHR, textStatus, errorThrown) {
alert(textStatus);