theme rorschach
This commit is contained in:
@@ -0,0 +1,278 @@
|
||||
/**
|
||||
* @file
|
||||
* External links js file.
|
||||
*/
|
||||
|
||||
(function ($, Drupal, drupalSettings) {
|
||||
|
||||
'use strict';
|
||||
|
||||
Drupal.extlink = Drupal.extlink || {};
|
||||
|
||||
Drupal.extlink.attach = function (context, drupalSettings) {
|
||||
if (typeof drupalSettings.data === 'undefined' || !drupalSettings.data.hasOwnProperty('extlink')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Define the jQuery method (either 'append' or 'prepend') of placing the
|
||||
// icon, defaults to 'append'.
|
||||
var extIconPlacement = 'append';
|
||||
if (drupalSettings.data.extlink.extIconPlacement && drupalSettings.data.extlink.extIconPlacement != '0') {
|
||||
extIconPlacement = drupalSettings.data.extlink.extIconPlacement;
|
||||
}
|
||||
|
||||
// Strip the host name down, removing ports, subdomains, or www.
|
||||
var pattern = /^(([^\/:]+?\.)*)([^\.:]{1,})((\.[a-z0-9]{1,253})*)(:[0-9]{1,5})?$/;
|
||||
var host = window.location.host.replace(pattern, '$2$3$6');
|
||||
var subdomain = window.location.host.replace(host, '');
|
||||
|
||||
// Determine what subdomains are considered internal.
|
||||
var subdomains;
|
||||
if (drupalSettings.data.extlink.extSubdomains) {
|
||||
subdomains = '([^/]*\\.)?';
|
||||
}
|
||||
else if (subdomain === 'www.' || subdomain === '') {
|
||||
subdomains = '(www\\.)?';
|
||||
}
|
||||
else {
|
||||
subdomains = subdomain.replace('.', '\\.');
|
||||
}
|
||||
|
||||
// Whitelisted domains.
|
||||
var whitelistedDomains = false;
|
||||
if (drupalSettings.data.extlink.whitelistedDomains) {
|
||||
whitelistedDomains = [];
|
||||
for (var i = 0; i < drupalSettings.data.extlink.whitelistedDomains.length; i++) {
|
||||
whitelistedDomains.push(new RegExp('^https?:\\/\\/' + drupalSettings.data.extlink.whitelistedDomains[i].replace(/(\r\n|\n|\r)/gm,'') + '.*$', 'i'));
|
||||
}
|
||||
}
|
||||
|
||||
// Build regular expressions that define an internal link.
|
||||
var internal_link = new RegExp('^https?://([^@]*@)?' + subdomains + host, 'i');
|
||||
|
||||
// Extra internal link matching.
|
||||
var extInclude = false;
|
||||
if (drupalSettings.data.extlink.extInclude) {
|
||||
extInclude = new RegExp(drupalSettings.data.extlink.extInclude.replace(/\\/, '\\'), 'i');
|
||||
}
|
||||
|
||||
// Extra external link matching.
|
||||
var extExclude = false;
|
||||
if (drupalSettings.data.extlink.extExclude) {
|
||||
extExclude = new RegExp(drupalSettings.data.extlink.extExclude.replace(/\\/, '\\'), 'i');
|
||||
}
|
||||
|
||||
// Extra external link CSS selector exclusion.
|
||||
var extCssExclude = false;
|
||||
if (drupalSettings.data.extlink.extCssExclude) {
|
||||
extCssExclude = drupalSettings.data.extlink.extCssExclude;
|
||||
}
|
||||
|
||||
// Extra external link CSS selector explicit.
|
||||
var extCssExplicit = false;
|
||||
if (drupalSettings.data.extlink.extCssExplicit) {
|
||||
extCssExplicit = drupalSettings.data.extlink.extCssExplicit;
|
||||
}
|
||||
|
||||
// Find all links which are NOT internal and begin with http as opposed
|
||||
// to ftp://, javascript:, etc. other kinds of links.
|
||||
// When operating on the 'this' variable, the host has been appended to
|
||||
// all links by the browser, even local ones.
|
||||
// In jQuery 1.1 and higher, we'd use a filter method here, but it is not
|
||||
// available in jQuery 1.0 (Drupal 5 default).
|
||||
var external_links = [];
|
||||
var mailto_links = [];
|
||||
$('a:not([data-extlink]), area:not([data-extlink])', context).each(function (el) {
|
||||
try {
|
||||
var url = '';
|
||||
if (typeof this.href == 'string') {
|
||||
url = this.href.toLowerCase();
|
||||
}
|
||||
// Handle SVG links (xlink:href).
|
||||
else if (typeof this.href == 'object') {
|
||||
url = this.href.baseVal;
|
||||
}
|
||||
if (url.indexOf('http') === 0
|
||||
&& ((!internal_link.test(url) && !(extExclude && extExclude.test(url))) || (extInclude && extInclude.test(url)))
|
||||
&& !(extCssExclude && $(this).is(extCssExclude))
|
||||
&& !(extCssExclude && $(this).parents(extCssExclude).length > 0)
|
||||
&& !(extCssExplicit && $(this).parents(extCssExplicit).length < 1)) {
|
||||
var match = false;
|
||||
if (whitelistedDomains) {
|
||||
for (var i = 0; i < whitelistedDomains.length; i++) {
|
||||
if (whitelistedDomains[i].test(url)) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!match) {
|
||||
external_links.push(this);
|
||||
}
|
||||
}
|
||||
// Do not include area tags with begin with mailto: (this prohibits
|
||||
// icons from being added to image-maps).
|
||||
else if (this.tagName !== 'AREA'
|
||||
&& url.indexOf('mailto:') === 0
|
||||
&& !(extCssExclude && $(this).parents(extCssExclude).length > 0)
|
||||
&& !(extCssExplicit && $(this).parents(extCssExplicit).length < 1)) {
|
||||
mailto_links.push(this);
|
||||
}
|
||||
}
|
||||
// IE7 throws errors often when dealing with irregular links, such as:
|
||||
// <a href="node/10"></a> Empty tags.
|
||||
// <a href="http://user:pass@example.com">example</a> User:pass syntax.
|
||||
catch (error) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (drupalSettings.data.extlink.extClass !== '0' && drupalSettings.data.extlink.extClass !== '') {
|
||||
Drupal.extlink.applyClassAndSpan(external_links, drupalSettings.data.extlink.extClass, extIconPlacement);
|
||||
}
|
||||
|
||||
if (drupalSettings.data.extlink.mailtoClass !== '0' && drupalSettings.data.extlink.mailtoClass !== '') {
|
||||
Drupal.extlink.applyClassAndSpan(mailto_links, drupalSettings.data.extlink.mailtoClass, extIconPlacement);
|
||||
}
|
||||
|
||||
if (drupalSettings.data.extlink.extTarget) {
|
||||
// Apply the target attribute to all links.
|
||||
$(external_links).filter(function () {
|
||||
// Filter out links with target set if option specified.
|
||||
return !(drupalSettings.data.extlink.extTargetNoOverride && $(this).is('a[target]'));
|
||||
}).attr({target: '_blank'});
|
||||
|
||||
// Add noopener rel attribute to combat phishing.
|
||||
$(external_links).attr('rel', function (i, val) {
|
||||
// If no rel attribute is present, create one with the value noopener.
|
||||
if (val === null || typeof val === 'undefined') {
|
||||
return 'noopener';
|
||||
}
|
||||
// Check to see if rel contains noopener. Add what doesn't exist.
|
||||
if (val.indexOf('noopener') > -1) {
|
||||
if (val.indexOf('noopener') === -1) {
|
||||
return val + ' noopener';
|
||||
}
|
||||
// Noopener exists. Nothing needs to be added.
|
||||
else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
// Else, append noopener to val.
|
||||
else {
|
||||
return val + ' noopener';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (drupalSettings.data.extlink.extNofollow) {
|
||||
$(external_links).attr('rel', function (i, val) {
|
||||
// When the link does not have a rel attribute set it to 'nofollow'.
|
||||
if (val === null || typeof val === 'undefined') {
|
||||
return 'nofollow';
|
||||
}
|
||||
var target = 'nofollow';
|
||||
// Change the target, if not overriding follow.
|
||||
if (drupalSettings.data.extlink.extFollowNoOverride) {
|
||||
target = 'follow';
|
||||
}
|
||||
if (val.indexOf(target) === -1) {
|
||||
return val + ' nofollow';
|
||||
}
|
||||
return val;
|
||||
});
|
||||
}
|
||||
|
||||
if (drupalSettings.data.extlink.extNoreferrer) {
|
||||
$(external_links).attr('rel', function (i, val) {
|
||||
// When the link does not have a rel attribute set it to 'noreferrer'.
|
||||
if (val === null || typeof val === 'undefined') {
|
||||
return 'noreferrer';
|
||||
}
|
||||
if (val.indexOf('noreferrer') === -1) {
|
||||
return val + ' noreferrer';
|
||||
}
|
||||
return val;
|
||||
});
|
||||
}
|
||||
|
||||
Drupal.extlink = Drupal.extlink || {};
|
||||
|
||||
// Set up default click function for the external links popup. This should be
|
||||
// overridden by modules wanting to alter the popup.
|
||||
Drupal.extlink.popupClickHandler = Drupal.extlink.popupClickHandler || function () {
|
||||
if (drupalSettings.data.extlink.extAlert) {
|
||||
return confirm(drupalSettings.data.extlink.extAlertText);
|
||||
}
|
||||
};
|
||||
|
||||
$(external_links).off("click.extlink");
|
||||
$(external_links).on("click.extlink", function (e) {
|
||||
return Drupal.extlink.popupClickHandler(e, this);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Apply a class and a trailing <span> to all links not containing images.
|
||||
*
|
||||
* @param {object[]} links
|
||||
* An array of DOM elements representing the links.
|
||||
* @param {string} class_name
|
||||
* The class to apply to the links.
|
||||
* @param {string} icon_placement
|
||||
* 'append' or 'prepend' the icon to the link.
|
||||
*/
|
||||
Drupal.extlink.applyClassAndSpan = function (links, class_name, icon_placement) {
|
||||
var $links_to_process;
|
||||
if (drupalSettings.data.extlink.extImgClass) {
|
||||
$links_to_process = $(links);
|
||||
}
|
||||
else {
|
||||
var links_with_images = $(links).find('img, svg').parents('a');
|
||||
$links_to_process = $(links).not(links_with_images);
|
||||
}
|
||||
|
||||
if (class_name !== '0') {
|
||||
$links_to_process.addClass(class_name);
|
||||
}
|
||||
|
||||
// Add data-extlink attribute.
|
||||
$links_to_process.attr('data-extlink', '');
|
||||
|
||||
var i;
|
||||
var length = $links_to_process.length;
|
||||
for (i = 0; i < length; i++) {
|
||||
var $link = $($links_to_process[i]);
|
||||
if (drupalSettings.data.extlink.extUseFontAwesome) {
|
||||
if (class_name === drupalSettings.data.extlink.mailtoClass) {
|
||||
$link[icon_placement]('<span class="fa-' + class_name + ' extlink"><span class="' + drupalSettings.data.extlink.extFaMailtoClasses + '" aria-label="' + drupalSettings.data.extlink.mailtoLabel + '"></span></span>');
|
||||
}
|
||||
else {
|
||||
$link[icon_placement]('<span class="fa-' + class_name + ' extlink"><span class="' + drupalSettings.data.extlink.extFaLinkClasses + '" aria-label="' + drupalSettings.data.extlink.extLabel + '"></span></span>');
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (class_name === drupalSettings.data.extlink.mailtoClass) {
|
||||
$link[icon_placement]('<svg focusable="false" class="' + class_name + '" role="img" aria-label="' + drupalSettings.data.extlink.mailtoLabel + '" xmlns="http://www.w3.org/2000/svg" viewBox="0 10 70 20"><metadata><sfw xmlns="http://ns.adobe.com/SaveForWeb/1.0/"><sliceSourceBounds y="-8160" x="-8165" width="16389" height="16384" bottomLeftOrigin="true"/><optimizationSettings><targetSettings targetSettingsID="0" fileFormat="PNG24Format"><PNG24Format transparency="true" filtered="false" interlaced="false" noMatteColor="false" matteColor="#FFFFFF"/></targetSettings></optimizationSettings></sfw></metadata><title>' + drupalSettings.data.extlink.mailtoLabel + '</title><path d="M56 14H8c-1.1 0-2 0.9-2 2v32c0 1.1 0.9 2 2 2h48c1.1 0 2-0.9 2-2V16C58 14.9 57.1 14 56 14zM50.5 18L32 33.4 13.5 18H50.5zM10 46V20.3l20.7 17.3C31.1 37.8 31.5 38 32 38s0.9-0.2 1.3-0.5L54 20.3V46H10z"/></svg>');
|
||||
}
|
||||
else {
|
||||
$link[icon_placement]('<svg focusable="false" class="' + class_name + '" role="img" aria-label="' + drupalSettings.data.extlink.extLabel + '" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 80 40"><metadata><sfw xmlns="http://ns.adobe.com/SaveForWeb/1.0/"><sliceSourceBounds y="-8160" x="-8165" width="16389" height="16384" bottomLeftOrigin="true"/><optimizationSettings><targetSettings targetSettingsID="0" fileFormat="PNG24Format"><PNG24Format transparency="true" filtered="false" interlaced="false" noMatteColor="false" matteColor="#FFFFFF"/></targetSettings></optimizationSettings></sfw></metadata><title>' + drupalSettings.data.extlink.extLabel + '</title><path d="M48 26c-1.1 0-2 0.9-2 2v26H10V18h26c1.1 0 2-0.9 2-2s-0.9-2-2-2H8c-1.1 0-2 0.9-2 2v40c0 1.1 0.9 2 2 2h40c1.1 0 2-0.9 2-2V28C50 26.9 49.1 26 48 26z"/><path d="M56 6H44c-1.1 0-2 0.9-2 2s0.9 2 2 2h7.2L30.6 30.6c-0.8 0.8-0.8 2 0 2.8C31 33.8 31.5 34 32 34s1-0.2 1.4-0.6L54 12.8V20c0 1.1 0.9 2 2 2s2-0.9 2-2V8C58 6.9 57.1 6 56 6z"/></svg>');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.extlink = Drupal.behaviors.extlink || {};
|
||||
Drupal.behaviors.extlink.attach = function (context, drupalSettings) {
|
||||
// Backwards compatibility, for the benefit of modules overriding extlink
|
||||
// functionality by defining an "extlinkAttach" global function.
|
||||
if (typeof extlinkAttach === 'function') {
|
||||
extlinkAttach(context);
|
||||
}
|
||||
else {
|
||||
Drupal.extlink.attach(context, drupalSettings);
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery, Drupal, drupalSettings);
|
||||
|
||||
@@ -0,0 +1,233 @@
|
||||
console.log('salut');
|
||||
// menu burger open
|
||||
|
||||
var burger = document.getElementById("block-burger");
|
||||
var burgertitle = document.getElementById("block-burger-menu");
|
||||
|
||||
|
||||
burgertitle.addEventListener("click", toggleMenu);
|
||||
|
||||
function toggleMenu(event) {
|
||||
// console.log(event);
|
||||
burger.classList.toggle('opened');
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
// faq reponse open
|
||||
|
||||
var answers = document.getElementsByClassName("field--name-field-reponse");
|
||||
var fichiers = document.getElementsByClassName("field--name-field-fichiers");
|
||||
var questions = document.getElementsByClassName("field--name-field-question");
|
||||
|
||||
for (let i = 0; i < questions.length; i++) {
|
||||
const question = questions[i]
|
||||
question.addEventListener("click", toggleFaq);
|
||||
}
|
||||
function toggleFaq(event) {
|
||||
// console.log(event, this);
|
||||
// fermé tout
|
||||
for (let i = 0; i < answers.length; i++) {
|
||||
answers[i].classList.remove('opened');
|
||||
}
|
||||
// la réponse correspndante a la question clické
|
||||
// | this c'est l'élément sur le quel on a clické
|
||||
// | |le parent |la réponse dans le parent
|
||||
let answer = this.parentNode.querySelector('.field--name-field-reponse');
|
||||
// console.log(answer);
|
||||
answer.classList.add('opened');
|
||||
|
||||
}
|
||||
///// répète fonction pour les fichiers, les liens et ressources
|
||||
//// il faudrait créer un tableau d'objet ?
|
||||
|
||||
var fichiers = document.getElementsByClassName("field--name-field-fichiers");
|
||||
var questions = document.getElementsByClassName("field--name-field-question");
|
||||
|
||||
for (let i = 0; i < questions.length; i++) {
|
||||
const question = questions[i]
|
||||
question.addEventListener("click", toggleFaqFichiers);
|
||||
}
|
||||
function toggleFaqFichiers(event) {
|
||||
// console.log(event, this);
|
||||
for (let i = 0; i < fichiers.length; i++) {
|
||||
fichiers[i].classList.remove('opened');
|
||||
}
|
||||
let fichier = this.parentNode.querySelector('.field--name-field-fichiers');
|
||||
|
||||
fichier.classList.add('opened');
|
||||
}
|
||||
|
||||
|
||||
////////////////////////
|
||||
var liens = document.getElementsByClassName("field--name-field-liens");
|
||||
var questions = document.getElementsByClassName("field--name-field-question");
|
||||
|
||||
for (let i = 0; i < questions.length; i++) {
|
||||
const question = questions[i]
|
||||
question.addEventListener("click", toggleFaqLiens);
|
||||
}
|
||||
function toggleFaqLiens(event) {
|
||||
// console.log(event, this);
|
||||
for (let i = 0; i < liens.length; i++) {
|
||||
liens[i].classList.remove('opened');
|
||||
}
|
||||
let lien = this.parentNode.querySelector('.field--name-field-liens');
|
||||
|
||||
lien.classList.add('opened');
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
var ressources = document.getElementsByClassName("field--name-field-ress");
|
||||
var questions = document.getElementsByClassName("field--name-field-question");
|
||||
|
||||
for (let i = 0; i < questions.length; i++) {
|
||||
const question = questions[i]
|
||||
question.addEventListener("click", toggleFaqRessources);
|
||||
}
|
||||
function toggleFaqRessources(event) {
|
||||
// console.log(event, this);
|
||||
for (let i = 0; i < resources.length; i++) {
|
||||
ressources[i].classList.remove('opened');
|
||||
}
|
||||
let ressource = this.parentNode.querySelector('.field--name-field-ress');
|
||||
|
||||
ressource.classList.add('opened');
|
||||
}
|
||||
|
||||
///////////////////////////////
|
||||
////////////////////////////////
|
||||
// fleche qui tourne faq
|
||||
|
||||
// var questions = document.getElementsByClassName("field--name-field-question");
|
||||
// var paragraph = document.querySelector('.field--name-field-question p::after');
|
||||
// console.log(paragraph)
|
||||
// var styles = window.getComputedStyle(element,':after')
|
||||
// console.log(styles)
|
||||
// var content = styles['content']
|
||||
// console.log(content)
|
||||
|
||||
|
||||
// for (let i = 0; i < questions.length; i++) {
|
||||
// const question = questions[i]
|
||||
// question.addEventListener("click", rotateFleche);
|
||||
// }
|
||||
// function rotateFleche(event) {
|
||||
// console.log(event, this);
|
||||
// // for (let i = 0; i < answers.length; i++) {
|
||||
// // answers[i].classList.remove('opened');
|
||||
// // }
|
||||
// }
|
||||
|
||||
//////////////////////////////////////////
|
||||
// block collection reste bleu quand actif
|
||||
|
||||
jQuery(function($) {
|
||||
var path = window.location.href; // because the 'href' property of the DOM element is the absolute path
|
||||
console.log(path);
|
||||
$(".view-id-collections .view-content .views-row a").each(function() {
|
||||
if (this.href === path) {
|
||||
$(this).parent().closest('.views-row').addClass('active');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// /////////////////
|
||||
//// ancre dans texte au click parragraphe correspondant arrive en dessous du header
|
||||
|
||||
|
||||
(function($, window) {
|
||||
var adjustAnchor = function() {
|
||||
var $anchor = $('.block-entity-fieldnodefield-textes'),
|
||||
fixedElementHeight = 350;
|
||||
if ($anchor.length > 0) {
|
||||
$('html, body').stop().animate({scrollTop: $anchor.offset().top - fixedElementHeight}, 250);
|
||||
}
|
||||
};
|
||||
|
||||
$(window).on('hashchange load', function() {
|
||||
adjustAnchor();
|
||||
});
|
||||
|
||||
})(jQuery, window);
|
||||
|
||||
|
||||
// ///////////////////////////////
|
||||
// (function(document, history, location) {
|
||||
// var HISTORY_SUPPORT = !!(history && history.pushState);
|
||||
|
||||
// var anchorScrolls = {
|
||||
// ANCHOR_REGEX: /^#[^ ]+$/,
|
||||
// OFFSET_HEIGHT_PX: 50,
|
||||
|
||||
// /**
|
||||
// * Establish events, and fix initial scroll position if a hash is provided.
|
||||
// */
|
||||
// init: function() {
|
||||
// this.scrollToCurrent();
|
||||
// $(window).on('hashchange', $.proxy(this, 'scrollToCurrent'));
|
||||
// $('body').on('click', 'a', $.proxy(this, 'delegateAnchors'));
|
||||
// },
|
||||
|
||||
// /**
|
||||
// * Return the offset amount to deduct from the normal scroll position.
|
||||
// * Modify as appropriate to allow for dynamic calculations
|
||||
// */
|
||||
// getFixedOffset: function() {
|
||||
// return this.OFFSET_HEIGHT_PX;
|
||||
// },
|
||||
|
||||
// /**
|
||||
// * If the provided href is an anchor which resolves to an element on the
|
||||
// * page, scroll to it.
|
||||
// * @param {String} href
|
||||
// * @return {Boolean} - Was the href an anchor.
|
||||
// */
|
||||
// scrollIfAnchor: function(href, pushToHistory) {
|
||||
// var match, anchorOffset;
|
||||
|
||||
// if(!this.ANCHOR_REGEX.test(href)) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// match = document.getElementById(href.slice(1));
|
||||
|
||||
// if(match) {
|
||||
// anchorOffset = $(match).offset().top - this.getFixedOffset();
|
||||
// $('html, body').animate({ scrollTop: anchorOffset});
|
||||
|
||||
// // Add the state to history as-per normal anchor links
|
||||
// if(HISTORY_SUPPORT && pushToHistory) {
|
||||
// history.pushState({}, document.title, location.pathname + href);
|
||||
// }
|
||||
// }
|
||||
|
||||
// return !!match;
|
||||
// },
|
||||
|
||||
// /**
|
||||
// * Attempt to scroll to the current location's hash.
|
||||
// */
|
||||
// scrollToCurrent: function(e) {
|
||||
// if(this.scrollIfAnchor(window.location.hash) && e) {
|
||||
// e.preventDefault();
|
||||
// }
|
||||
// },
|
||||
|
||||
// /**
|
||||
// * If the click event's target was an anchor, fix the scroll position.
|
||||
// */
|
||||
// delegateAnchors: function(e) {
|
||||
// var elem = e.target;
|
||||
|
||||
// if(this.scrollIfAnchor(elem.getAttribute('href'), true)) {
|
||||
// e.preventDefault();
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
|
||||
// $(document).ready($.proxy(anchorScrolls, 'init'));
|
||||
// })(window.document, window.history, window.location);
|
||||
|
||||
Reference in New Issue
Block a user