]> _ Git - eif-extranet.git/commitdiff
wait #5482 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 30 Sep 2022 06:58:32 +0000 (08:58 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 30 Sep 2022 06:58:32 +0000 (08:58 +0200)
EIF-URW.zip
js/script.js

index 39ad302accc390a381c8fb52f9128e857a12d619..db8c43e2cda953d1ecbd894b97f4a26aae8e3fb3 100644 (file)
Binary files a/EIF-URW.zip and b/EIF-URW.zip differ
index 3c3a4d797363ef2e6749741ff490900af3e74186..c4e7475a96e39899763c301a3f44d4a5b635d0e3 100644 (file)
-$(function () {
+function _updateAfterDomChange() {
+    initTooltips();
+    updateTable();
+    updateIcons()
+    updateSwitchSelection()
+}
+
+// Tables (Selectionner les lignes dont la checkbox est cochée)
+function updateTable() {
+    $('table').each(function () {
+        $(this).find('td input[type=checkbox]').each(function () {
+            var checked = $(this).prop('checked');
+            var tr = $(this).closest('tr');
+            if (checked) {
+                $(tr).addClass('selected');
+            } else {
+                $(tr).removeClass('selected');
+            }
+        });
+    });
+}
+
+
+/**
+ * Ajouter les symboles SVG dans les élements ayant l'attribut data-icon
+ * Par défaut, l'icône est ajoutée à la fin de l'élement.
+ * Si l'attribut data-icon-prepend est présent, l'icône est ajoutée au début de l'élement.
+ */
+function updateIcons() {
+    $("[data-icon]").each(function () {
+        var iconId = 'eif-' + $(this).data('icon');
+        // L'icône est déjà en place
+        if ($(this).children('svg.' + iconId).length) {
+            return;
+        }
+        // Si une autre icône est présente, on la supprime
+        $(this).children('svg.svg-icon').remove();
+        // Puis on ajoute l'icône
+        var icon = getSpriteIcon(iconId);
+        if ($(this).is('[data-icon-prepend]')) {
+            $(this).prepend(icon);
+        } else {
+            $(this).append(icon);
+        }
+    });
+}
+
+// Générer le code qui affiche une icône du Sprite SVG
+function getSpriteIcon(icon, attrs) {
+    var a = [];
+    var iconSymbol = $('svg symbol[id="' + icon + '"]');
+    if (iconSymbol.length > 1) {
+        $('svg symbol[id="' + icon + '"]:not(:last)').remove();
+        iconSymbol = $('svg symbol[id="' + icon + '"]');
+    }
+
+    if (iconSymbol.length == 0) {
+        return ''; // Bail out because symbol doesn't exist
+    }
+
+    if (attrs == undefined) {
+        attrs = {};
+    }
+    if (attrs.viewBox == null) {
+        attrs.viewBox = iconSymbol.get(0).attributes.viewBox.value;
+    }
+
+    if (Modernizr.msie) {
+        var vb = attrs.viewBox.split(' ');
+        attrs.width = vb[2];
+        attrs.height = vb[3];
+    }
+
+    if (attrs.class == null) {
+        attrs.class = icon;
+    } else {
+        attrs.class += ' ' + icon;
+    }
+
+    attrs.class += ' nav-icon svg-icon'; // Common class for all icons
+
+    $.each(attrs, function (k, v) {
+        a.push(k + '="' + v + '"');
+    });
+    return '<svg ' + a.join(' ') + ' aria-hidden="true"><use xlink:href="#' + icon + '" /></svg>';
+}
+
+// Interrupteurs "Afficher tout / ma sélection
+function updateSwitchSelection() {
+    $('.switch label').each(function () {
+        if ($(this).find('input').prop('checked')) {
+            $(this).addClass('checked');
+        } else {
+            $(this).removeClass('checked');
+        }
+    });
+}
+
+// Initialisation des tooltips
+function initTooltips() {
     // Utilisation de tippy pour afficher les tooltips.
-    $('[data-tooltip]').each(function () {
+    $('[data-tooltip]:not([data-tooltip-done])').each(function () {
         tippy(this, {content: $(this).attr('data-tooltip')});
+        $(this).attr('data-tooltip-done', '1');
     });
 
     // Tooltip du menu (uniquement en mode compact)
-    $("#menu nav>ul>li>a").each(function () {
+    $("#menu nav>ul>li>a:not([data-tooltip-done])").each(function () {
         tippy(this, {content: $(this).find('span').text(), trigger: 'manual', theme: 'menu'});
+        $(this).attr('data-tooltip-done', '1');
     });
+}
+
+$(function () {
     $(document).on('mouseover', '.menu-compact #menu nav>ul>li>a', function () {
         this._tippy.show();
         clearTimeout(this._tippyHideTimeout);
@@ -18,32 +122,6 @@ $(function () {
         }, 50);
     });
 
-    /**
-     * Ajouter les symboles SVG dans les élements ayant l'attribut data-icon
-     * Par défaut, l'icône est ajoutée à la fin de l'élement.
-     * Si l'attribut data-icon-prepend est présent, l'icône est ajoutée au début de l'élement.
-     */
-    var updateIcons = function () {
-        $("[data-icon]").each(function () {
-            var iconId = 'eif-' + $(this).data('icon');
-            // L'icône est déjà en place
-            if ($(this).children('svg.' + iconId).length) {
-                return;
-            }
-            // Si une autre icône est présente, on la supprime
-            $(this).children('svg.svg-icon').remove();
-            // Puis on ajoute l'icône
-            var icon = getSpriteIcon(iconId);
-            if ($(this).is('[data-icon-prepend]')) {
-                $(this).prepend(icon);
-            } else {
-                $(this).append(icon);
-            }
-        });
-    };
-    updateIcons();
-
-
     // Menu : afficher le sous-menu au clic sur un élement
     $(document).on('click', '.open-submenu', function () {
         var li = $(this).closest('li');
@@ -55,35 +133,10 @@ $(function () {
         return false;
     });
 
-    // Interrupteurs "Afficher tout / ma sélection
-    var updateSwitchSelection = function () {
-        $('.switch label').each(function () {
-            if ($(this).find('input').prop('checked')) {
-                $(this).addClass('checked');
-            } else {
-                $(this).removeClass('checked');
-            }
-        });
-    };
     $(document).on('change', 'input', function () {
         updateSwitchSelection();
     });
-    updateSwitchSelection();
-
-    // Tables (Selectionner les lignes dont la checkbox est cochée)
-    var updateTable = function () {
-        $('table').each(function () {
-            $(this).find('td input[type=checkbox]').each(function () {
-                var checked = $(this).prop('checked');
-                var tr = $(this).closest('tr');
-                if (checked) {
-                    $(tr).addClass('selected');
-                } else {
-                    $(tr).removeClass('selected');
-                }
-            });
-        });
-    }
+
     $(document).on('change', 'input[type=checkbox]', function () {
         if ($(this).closest('th').length === 1) {
             var checked = $(this).prop('checked');
@@ -91,7 +144,6 @@ $(function () {
         }
         updateTable();
     });
-    updateTable();
 
     // Lignes cliquables
     $(document).on('click', 'tr[data-href] td:not(:first-child)', function () {
@@ -102,47 +154,8 @@ $(function () {
     // Menu : passer le menu en mode compact
     $(document).on('click', '.toggle-menu', function () {
         $('body').toggleClass('menu-compact');
-        resize();
         return false;
     });
-});
-
-// Générer le code qui affiche une icône du Sprite SVG
-function getSpriteIcon(icon, attrs) {
-    var a = [];
-    var iconSymbol = $('svg symbol[id="' + icon + '"]');
-    if (iconSymbol.length > 1) {
-        $('svg symbol[id="' + icon + '"]:not(:last)').remove();
-        iconSymbol = $('svg symbol[id="' + icon + '"]');
-    }
 
-    if (iconSymbol.length == 0) {
-        return ''; // Bail out because symbol doesn't exist
-    }
-
-    if (attrs == undefined) {
-        attrs = {};
-    }
-    if (attrs.viewBox == null) {
-        attrs.viewBox = iconSymbol.get(0).attributes.viewBox.value;
-    }
-
-    if (Modernizr.msie) {
-        var vb = attrs.viewBox.split(' ');
-        attrs.width = vb[2];
-        attrs.height = vb[3];
-    }
-
-    if (attrs.class == null) {
-        attrs.class = icon;
-    } else {
-        attrs.class += ' ' + icon;
-    }
-
-    attrs.class += ' nav-icon svg-icon'; // Common class for all icons
-
-    $.each(attrs, function (k, v) {
-        a.push(k + '="' + v + '"');
-    });
-    return '<svg ' + a.join(' ') + ' aria-hidden="true"><use xlink:href="#' + icon + '" /></svg>';
-}
\ No newline at end of file
+    _updateAfterDomChange();
+});