From b1e7313be141dd31c2f13bd199a05e0a9ef5553e Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Fri, 11 Nov 2016 14:39:46 +0000 Subject: [PATCH] git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/liferay62-plugins/d4science-responsive-theme@134092 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../WEB-INF/liferay-plugin-package.properties | 2 +- src/main/webapp/js/gcube-context-injection.js | 27 ----------- src/main/webapp/js/gcube-context.js | 47 +++++++++++++++++++ src/main/webapp/templates/portal_normal.vm | 23 ++++++++- 4 files changed, 69 insertions(+), 30 deletions(-) delete mode 100644 src/main/webapp/js/gcube-context-injection.js create mode 100644 src/main/webapp/js/gcube-context.js diff --git a/src/main/webapp/WEB-INF/liferay-plugin-package.properties b/src/main/webapp/WEB-INF/liferay-plugin-package.properties index a26d537..5fdd6b2 100644 --- a/src/main/webapp/WEB-INF/liferay-plugin-package.properties +++ b/src/main/webapp/WEB-INF/liferay-plugin-package.properties @@ -1,6 +1,6 @@ name=d4science-responsive-theme module-group-id=liferay -module-incremental-version=2 +module-incremental-version=3 tags= short-description= change-log= diff --git a/src/main/webapp/js/gcube-context-injection.js b/src/main/webapp/js/gcube-context-injection.js deleted file mode 100644 index d4ace78..0000000 --- a/src/main/webapp/js/gcube-context-injection.js +++ /dev/null @@ -1,27 +0,0 @@ -/* The following function simply injects the Liferay object fields userId and scopeGroupId in the XMLHttpRequest header. - * So that every ajax call performed in the page has those parameters set. - * Author: Massimiliano Assante, CNR-ISTI */ -function injectClientContext() { - if (Liferay != null) { - var userId; - var groupId; - if (Liferay.ThemeDisplay.isSignedIn()) { - userId = Liferay.ThemeDisplay.getUserId(); - groupId = Liferay.ThemeDisplay.getScopeGroupId(); - console.log('(d4science responsive) userId is = ' + userId); - console.log("groupId is = " + groupId); - } - else { - groupId = Liferay.ThemeDisplay.getScopeGroupId(); - //console.log('Not logged in, injecting groupId only'); - } - - XMLHttpRequest.prototype.realSend = XMLHttpRequest.prototype.send; - var newSend = function(vData) { - this.setRequestHeader("gcube-userId", userId); - this.setRequestHeader("gcube-vreid", groupId); - this.realSend(vData); - }; - XMLHttpRequest.prototype.send = newSend; - } -} \ No newline at end of file diff --git a/src/main/webapp/js/gcube-context.js b/src/main/webapp/js/gcube-context.js new file mode 100644 index 0000000..0c458d4 --- /dev/null +++ b/src/main/webapp/js/gcube-context.js @@ -0,0 +1,47 @@ +/* + * Author: Massimiliano Assante, CNR-ISTI + * */ + +/*The following function simply injects the Liferay object fields userId and scopeGroupId in the XMLHttpRequest header. + * So that every ajax call performed in the page has those parameters set.*/ +function injectClientContext() { + if (Liferay != null) { + var userId; + var groupId; + if (Liferay.ThemeDisplay.isSignedIn()) { + userId = Liferay.ThemeDisplay.getUserId(); + groupId = Liferay.ThemeDisplay.getScopeGroupId(); + console.log("D4S groupId is = " + groupId); + } + else { + groupId = Liferay.ThemeDisplay.getScopeGroupId(); + //console.log('Not logged in, injecting groupId only'); + } + + XMLHttpRequest.prototype.realSend = XMLHttpRequest.prototype.send; + var newSend = function(vData) { + this.setRequestHeader("gcube-userId", userId); + this.setRequestHeader("gcube-vreid", groupId); + this.realSend(vData); + }; + XMLHttpRequest.prototype.send = newSend; + } +} +/* + * Override the expire function of the Liferay.Session javascript object. It makes the default behaviour and then open a modal + * */ +$(function () { + AUI().use('liferay-session', function(A) { + console.log('Liferay session overrding'); + if(Liferay.Session) { + console.log('Liferay session overridden ON'); + Liferay.Session.expire = function() { + var instance = this; + instance.set('sessionState', 'expired', {}); + $("#expirationModal").css("display", "block"); + $("#expirationModal").modal({backdrop: 'static', keyboard: false},'show'); + $("body div.alert.alert-block.popup-alert-warning.alert-error").html("Due to inactivity your session has expired, please Refresh"); + }; + } + }); + }); diff --git a/src/main/webapp/templates/portal_normal.vm b/src/main/webapp/templates/portal_normal.vm index 8e19722..6a9168d 100644 --- a/src/main/webapp/templates/portal_normal.vm +++ b/src/main/webapp/templates/portal_normal.vm @@ -17,13 +17,32 @@ $theme.include($top_head_include) - + + + + #language ("skip-to-content") $theme.include($body_top_include)