Unverified Commit 8c62a32c authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3239123 by hooroomoo, bnjmnm, nod_: Refactor (if feasible) uses of the...

Issue #3239123 by hooroomoo, bnjmnm, nod_: Refactor (if feasible) uses of the jQuery text function to use vanillaJS
parent 6b8783b2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@
    "jquery/no-sizzle": 0,
    "jquery/no-slide": 0,
    "jquery/no-submit": 2,
    "jquery/no-text": 0,
    "jquery/no-text": 2,
    "jquery/no-toggle": 0,
    "jquery/no-trigger": 0,
    "jquery/no-trim": 2,
+8 −4
Original line number Diff line number Diff line
@@ -108,13 +108,15 @@
        // If the table has hidden columns, associate an action link with the
        // table to show the columns.
        if (hiddenLength > 0) {
          this.$link.show().text(this.showText);
          this.$link.show();
          this.$link[0].textContent = this.showText;
        }
        // When the toggle is pegged, its presence is maintained because the user
        // has interacted with it. This is necessary to keep the link visible if
        // the user adjusts screen size and changes the visibility of columns.
        if (!pegged && hiddenLength === 0) {
          this.$link.hide().text(this.hideText);
          this.$link.hide();
          this.$link[0].textContent = this.hideText;
        }
      },

@@ -148,7 +150,8 @@
            // Keep track of the revealed headers, so they can be hidden later.
            self.$revealedCells = $().add(self.$revealedCells).add($header);
          });
          this.$link.text(this.hideText).data('pegged', 1);
          this.$link[0].textContent = this.hideText;
          this.$link.data('pegged', 1);
        }
        // Hide revealed columns.
        else {
@@ -177,7 +180,8 @@
            // Return the rest of the style attribute values to the element.
            $cell.attr('style', newProps.join(';'));
          });
          this.$link.text(this.showText).data('pegged', 0);
          this.$link[0].textContent = this.showText;
          this.$link.data('pegged', 0);
          // Refresh the toggle link.
          $(window).trigger('resize.tableresponsive');
        }
+8 −4
Original line number Diff line number Diff line
@@ -34,11 +34,13 @@
      const hiddenLength = this.$headers.filter('.priority-medium:hidden, .priority-low:hidden').length;

      if (hiddenLength > 0) {
        this.$link.show().text(this.showText);
        this.$link.show();
        this.$link[0].textContent = this.showText;
      }

      if (!pegged && hiddenLength === 0) {
        this.$link.hide().text(this.hideText);
        this.$link.hide();
        this.$link[0].textContent = this.hideText;
      }
    },

@@ -60,7 +62,8 @@
          $header.show();
          self.$revealedCells = $().add(self.$revealedCells).add($header);
        });
        this.$link.text(this.hideText).data('pegged', 1);
        this.$link[0].textContent = this.hideText;
        this.$link.data('pegged', 1);
      } else {
        this.$revealedCells.hide();
        this.$revealedCells.each(function (index, element) {
@@ -83,7 +86,8 @@

          $cell.attr('style', newProps.join(';'));
        });
        this.$link.text(this.showText).data('pegged', 0);
        this.$link[0].textContent = this.showText;
        this.$link.data('pegged', 0);
        $(window).trigger('resize.tableresponsive');
      }
    }
+5 −6
Original line number Diff line number Diff line
@@ -84,8 +84,9 @@
          // Transform each details into a tab.
          $details.each(function () {
            const $that = $(this);
            const $summary = $that.find('> summary');
            const verticalTab = new Drupal.verticalTab({
              title: $that.find('> summary').text(),
              title: $summary.length ? $summary[0].textContent : '',
              details: $that,
            });
            tabList.append(verticalTab.item);
@@ -281,15 +282,13 @@
   */
  Drupal.theme.verticalTab = function (settings) {
    const tab = {};
    tab.title = $('<strong class="vertical-tabs__menu-item-title"></strong>');
    tab.title[0].textContent = settings.title;
    tab.item = $(
      '<li class="vertical-tabs__menu-item" tabindex="-1"></li>',
    ).append(
      (tab.link = $('<a href="#"></a>')
        .append(
          (tab.title = $(
            '<strong class="vertical-tabs__menu-item-title"></strong>',
          ).text(settings.title)),
        )
        .append(tab.title)
        .append(
          (tab.summary = $(
            '<span class="vertical-tabs__menu-item-summary"></span>',
+5 −2
Original line number Diff line number Diff line
@@ -36,8 +36,9 @@
        $this.wrap('<div class="vertical-tabs clearfix"></div>').before(tabList);
        $details.each(function () {
          const $that = $(this);
          const $summary = $that.find('> summary');
          const verticalTab = new Drupal.verticalTab({
            title: $that.find('> summary').text(),
            title: $summary.length ? $summary[0].textContent : '',
            details: $that
          });
          tabList.append(verticalTab.item);
@@ -132,7 +133,9 @@

  Drupal.theme.verticalTab = function (settings) {
    const tab = {};
    tab.item = $('<li class="vertical-tabs__menu-item" tabindex="-1"></li>').append(tab.link = $('<a href="#"></a>').append(tab.title = $('<strong class="vertical-tabs__menu-item-title"></strong>').text(settings.title)).append(tab.summary = $('<span class="vertical-tabs__menu-item-summary"></span>')));
    tab.title = $('<strong class="vertical-tabs__menu-item-title"></strong>');
    tab.title[0].textContent = settings.title;
    tab.item = $('<li class="vertical-tabs__menu-item" tabindex="-1"></li>').append(tab.link = $('<a href="#"></a>').append(tab.title).append(tab.summary = $('<span class="vertical-tabs__menu-item-summary"></span>')));
    return tab;
  };
})(jQuery, Drupal, drupalSettings);
 No newline at end of file
Loading