gathercontent-8.x-5.0/gathercontent_ui/js/gathercontent_ui.counter.js
gathercontent_ui/js/gathercontent_ui.counter.js
/**
* @file
*/
(function ($, Drupal, once) {
'use strict';
Drupal.behaviors.gatherContentCounter = {
attach: function (context) {
Drupal.gatherContent.counterUpdateSelectedMessage();
$(once('gather-content-counter', Drupal.gatherContent.counterCountedSelector)).on('change', Drupal.gatherContent.onCountedChanged);
}
};
Drupal.gatherContent = Drupal.gatherContent || {};
Drupal.gatherContent.counterCountedSelector = '.gather-content-counted';
Drupal.gatherContent.counterMessageWrapperSelector = '.gather-content-counter-message';
Drupal.gatherContent.onCountedChanged = function () {
Drupal.gatherContent.counterUpdateSelectedMessage();
};
Drupal.gatherContent.counterUpdateSelectedMessage = function () {
var count = $(Drupal.gatherContent.counterCountedSelector + ':checked').length;
var msg = Drupal.t('There is no selected template');
if (count !== 0) {
msg = Drupal.formatPlural(
count,
'1 template selected',
'@count templates selected'
);
}
$(Drupal.gatherContent.counterMessageWrapperSelector).text(msg);
};
})(jQuery, Drupal, once);
