annotate core/modules/locale/locale.admin.js @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 4c8ae668cc8c
children
rev   line source
Chris@0 1 /**
Chris@0 2 * DO NOT EDIT THIS FILE.
Chris@0 3 * See the following change record for more information,
Chris@0 4 * https://www.drupal.org/node/2815083
Chris@0 5 * @preserve
Chris@0 6 **/
Chris@0 7
Chris@0 8 (function ($, Drupal) {
Chris@0 9 Drupal.behaviors.localeTranslateDirty = {
Chris@0 10 attach: function attach() {
Chris@0 11 var $form = $('#locale-translate-edit-form').once('localetranslatedirty');
Chris@0 12 if ($form.length) {
Chris@0 13 $form.one('formUpdated.localeTranslateDirty', 'table', function () {
Chris@0 14 var $marker = $(Drupal.theme('localeTranslateChangedWarning')).hide();
Chris@0 15 $(this).addClass('changed').before($marker);
Chris@0 16 $marker.fadeIn('slow');
Chris@0 17 });
Chris@0 18
Chris@0 19 $form.on('formUpdated.localeTranslateDirty', 'tr', function () {
Chris@0 20 var $row = $(this);
Chris@0 21 var $rowToMark = $row.once('localemark');
Chris@0 22 var marker = Drupal.theme('localeTranslateChangedMarker');
Chris@0 23
Chris@0 24 $row.addClass('changed');
Chris@0 25
Chris@0 26 if ($rowToMark.length) {
Chris@0 27 $rowToMark.find('td:first-child .js-form-item').append(marker);
Chris@0 28 }
Chris@0 29 });
Chris@0 30 }
Chris@0 31 },
Chris@0 32 detach: function detach(context, settings, trigger) {
Chris@0 33 if (trigger === 'unload') {
Chris@0 34 var $form = $('#locale-translate-edit-form').removeOnce('localetranslatedirty');
Chris@0 35 if ($form.length) {
Chris@0 36 $form.off('formUpdated.localeTranslateDirty');
Chris@0 37 }
Chris@0 38 }
Chris@0 39 }
Chris@0 40 };
Chris@0 41
Chris@0 42 Drupal.behaviors.hideUpdateInformation = {
Chris@0 43 attach: function attach(context, settings) {
Chris@0 44 var $table = $('#locale-translation-status-form').once('expand-updates');
Chris@0 45 if ($table.length) {
Chris@0 46 var $tbodies = $table.find('tbody');
Chris@0 47
Chris@0 48 $tbodies.on('click keydown', '.description', function (e) {
Chris@0 49 if (e.keyCode && e.keyCode !== 13 && e.keyCode !== 32) {
Chris@0 50 return;
Chris@0 51 }
Chris@0 52 e.preventDefault();
Chris@0 53 var $tr = $(this).closest('tr');
Chris@0 54
Chris@0 55 $tr.toggleClass('expanded');
Chris@0 56
Chris@0 57 $tr.find('.locale-translation-update__prefix').text(function () {
Chris@0 58 if ($tr.hasClass('expanded')) {
Chris@0 59 return Drupal.t('Hide description');
Chris@0 60 }
Chris@0 61
Chris@0 62 return Drupal.t('Show description');
Chris@0 63 });
Chris@0 64 });
Chris@0 65 $table.find('.requirements, .links').hide();
Chris@0 66 }
Chris@0 67 }
Chris@0 68 };
Chris@0 69
Chris@0 70 $.extend(Drupal.theme, {
Chris@0 71 localeTranslateChangedMarker: function localeTranslateChangedMarker() {
Chris@0 72 return '<abbr class="warning ajax-changed" title="' + Drupal.t('Changed') + '">*</abbr>';
Chris@0 73 },
Chris@0 74 localeTranslateChangedWarning: function localeTranslateChangedWarning() {
Chris@0 75 return '<div class="clearfix messages messages--warning">' + Drupal.theme('localeTranslateChangedMarker') + ' ' + Drupal.t('Changes made in this table will not be saved until the form is submitted.') + '</div>';
Chris@0 76 }
Chris@0 77 });
Chris@0 78 })(jQuery, Drupal);