locale.admin.js 2.6 KB

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