From af2c8e860051744e56129716d9f80631c9a9f781 Mon Sep 17 00:00:00 2001 From: Amauri CHAMPEAUX Date: Tue, 10 Mar 2015 01:45:20 +0100 Subject: [PATCH] Close all tooltip before open a new one --- tarteaucitron.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/tarteaucitron.js b/tarteaucitron.js index 531589e..175350d 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -10,7 +10,7 @@ var scripts = document.getElementsByTagName('script'), tarteaucitronNoAdBlocker = false; var tarteaucitron = { - "version": 201, + "version": 201.1, "cdn": cdn, "user": {}, "lang": {}, @@ -162,7 +162,7 @@ var tarteaucitron = { html += '
'; html += '
'; html += '
'; - html += ' ' + tarteaucitron.lang.all + ''; + html += ' ' + tarteaucitron.lang.all + ''; html += '
'; html += '
'; html += '
'; @@ -173,7 +173,7 @@ var tarteaucitron = { html += '
'; html += '
'; html += '
'; - html += '
'; + html += '
'; html += ' ' + tarteaucitron.lang.disclaimer; if (defaults.removeCredit === false) { html += '

'; @@ -185,9 +185,9 @@ var tarteaucitron = { for (i = 0; i < cat.length; i += 1) { html += '
'; html += '
'; - html += ' ' + tarteaucitron.lang[cat[i]].title; + html += ' ' + tarteaucitron.lang[cat[i]].title; html += '
'; - html += '
'; + html += '
'; html += ' ' + tarteaucitron.lang[cat[i]].details; html += '
'; html += '
'; @@ -598,7 +598,7 @@ var tarteaucitron = { tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none'); } }, - "toggle": function (id) { + "toggle": function (id, closeClass) { "use strict"; var div = document.getElementById(id); @@ -606,6 +606,12 @@ var tarteaucitron = { return; } + if (closeClass !== undefined) { + tarteaucitron.fallback([closeClass], function (elem) { + elem.style.display = 'none'; + }, true); + } + if (div.style.display !== 'block') { div.style.display = 'block'; } else { @@ -985,7 +991,7 @@ var tarteaucitron = { } } }, - "fallback": function (matchClass, content) { + "fallback": function (matchClass, content, noInner) { "use strict"; var elems = document.getElementsByTagName('*'), i, @@ -997,7 +1003,11 @@ var tarteaucitron = { if ((' ' + elems[i].className + ' ') .indexOf(' ' + matchClass[index] + ' ') > -1) { if (typeof content === 'function') { - elems[i].innerHTML = content(elems[i]); + if (noInner === true) { + content(elems[i]); + } else { + elems[i].innerHTML = content(elems[i]); + } } else { elems[i].innerHTML = content; }