diff --git a/app/assets/images/logo_mini_FC.png b/app/assets/images/logo_mini_FC.png new file mode 100644 index 000000000..f2c46cf0b Binary files /dev/null and b/app/assets/images/logo_mini_FC.png differ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 9b52ffa7a..31ae83487 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -26,6 +26,7 @@ //= require leaflet.freedraw //= require smart_listing //= require turf +//= require franceconnect $(document).ready(function() { $('.js-scrollTo').on('click', function() { // Au clic sur un élément diff --git a/app/assets/javascripts/franceconnect_kit.js b/app/assets/javascripts/franceconnect_kit.js index f641881c3..29b4b5f37 100644 --- a/app/assets/javascripts/franceconnect_kit.js +++ b/app/assets/javascripts/franceconnect_kit.js @@ -2,6 +2,6 @@ $(document).on('page:load', franceconnect_kit); $(document).ready(franceconnect_kit); function franceconnect_kit() { - + franceConnectKit.init() } diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 9a439eed5..14c1f936e 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -17,6 +17,7 @@ *= require bootstrap-datepicker3 *= require leaflet *= require font-awesome + *= require franceconnect */ @import "bootstrap-sprockets"; @import "bootstrap"; diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index f673a845e..38ac3a218 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -4,7 +4,6 @@ %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/ %title TPS - Téléprocédures simplifiées %meta{'http-equiv' => "X-UA-Compatible", :content => "IE=edge"} - %script{src: 'http://fcp.integ01.dev-franceconnect.fr/js/franceconnect.js'} = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true = javascript_include_tag 'application', 'data-turbolinks-track' => true diff --git a/vendor/assets/javascripts/franceconnect.js b/vendor/assets/javascripts/franceconnect.js new file mode 100644 index 000000000..01ab3c453 --- /dev/null +++ b/vendor/assets/javascripts/franceconnect.js @@ -0,0 +1,147 @@ +var franceConnectKit = {}; + +(function (window) { + var fconnect = { + tracesUrl: '/traces', + aboutUrl: '' + }; + + franceConnectKit.init = function() { + //initCurrentHostnameSource(); + //includeFCCss(); + + fconnect.currentHost = 'fcp.integ01.dev-franceconnect.fr' + + var fconnectProfile = document.getElementById('fconnect-profile'); + if (fconnectProfile) { + var linkAccess = document.querySelector('#fconnect-profile > a'); + var fcLogoutUrl = fconnectProfile.getAttribute('data-fc-logout-url'); + var access = createFCAccessElement(fcLogoutUrl); + fconnectProfile.appendChild(access); + linkAccess.onclick = toggleElement.bind(access); + } + }; + + var document = window.document; + + document.addEventListener('DOMContentLoaded', function () { + franceConnectKit.init(); + }); + + function initCurrentHostnameSource() { + var currentScript = document.querySelector('script[src^="/assets/franceconnect"]').getAttribute('src'); + var parseUrl = currentScript.split('/'); + fconnect.currentHost = parseUrl[2]; + } + + function includeFCCss() { + var ss = document.styleSheets; + for (var i = 0, max = ss.length; i < max; i++) { + if (ss[i].href == 'http://' + fconnect.currentHost + '/stylesheets/franceconnect.css' || ss[i].href == 'https://' + fconnect.currentHost + '/stylesheets/franceconnect.css') + return; + } + + var linkCss = document.createElement('link'); + linkCss.rel = 'stylesheet'; + linkCss.href = '//' + fconnect.currentHost + '/stylesheets/franceconnect.css'; + linkCss.type = 'text/css'; + linkCss.media = 'screen'; + + document.getElementsByTagName('head')[0].appendChild(linkCss); + } + + function toggleElement(event) { + event.preventDefault(); + if (this.style.display === "block") { + this.style.display = "none"; + } else { + this.style.display = "block"; + } + } + + function closeFCPopin(event) { + event.preventDefault(); + fconnect.popin.className = 'fade-out'; + setTimeout(function () { + document.body.removeChild(fconnect.popin); + }, 200); + } + + function openFCPopin() { + fconnect.popin = document.createElement('div'); + fconnect.popin.id = 'fc-background'; + + var iframe = createFCIframe(); + + document.body.appendChild(fconnect.popin); + + fconnect.popin.appendChild(iframe); + + setTimeout(function () { + fconnect.popin.className = 'fade-in'; + }, 200); + } + + function createFCIframe() { + var iframe = document.createElement("iframe"); + iframe.setAttribute('id', 'fconnect-iframe'); + iframe.frameBorder = 0; + iframe.name = 'fconnect-iframe'; + return iframe; + } + + function createFCAccessElement(logoutUrl) { + var access = document.createElement('div'); + access.id = 'fconnect-access'; + access.innerHTML = '