group-8.x-1.x-dev/js/block.js

js/block.js
/**
 * @file
 * Block behaviors.
 */

(function ($, window) {

    'use strict';

    /**
     * Provide the summary information for the block settings vertical tabs.
     *
     * @type {Drupal~behavior}
     *
     * @prop {Drupal~behaviorAttach} attach
     *   Attaches the behavior for the block settings summaries.
     */
    Drupal.behaviors.blockSettingsSummaryGroup = {
        attach: function () {
            // The drupalSetSummary method required for this behavior is not available
            // on the Blocks administration page, so we need to make sure this
            // behavior is processed only if drupalSetSummary is defined.
            if (typeof jQuery.fn.drupalSetSummary === 'undefined') {
                return;
            }

            /**
             * Create a summary for checkboxes in the provided context.
             *
             * @param {HTMLDocument|HTMLElement} context
             *   A context where one would find checkboxes to summarize.
             *
             * @return {string}
             *   A string with the summary.
             */
            function checkboxesSummary(context) {
                var values = [];
                var $checkboxes = $(context).find('input[type="checkbox"]:checked + label');
                var il = $checkboxes.length;
                for (var i = 0; i < il; i++) {
                    values.push($($checkboxes[i]).html());
                }
                if (!values.length) {
                    values.push(Drupal.t('Not restricted'));
                }
                return values.join(', ');
            }

            $('[data-drupal-selector="edit-visibility-group-type"]').drupalSetSummary(checkboxesSummary);
        }
    };

})(jQuery, window);

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc