From c94b15da20b8c0da726eb481537dc9214c2358d5 Mon Sep 17 00:00:00 2001 From: alexh58 Date: Fri, 1 Mar 2013 17:44:39 -0500 Subject: [PATCH] JS to make title and alt fields checked if the file itself is translatable See #1920888 --- .../translation_entity.admin.inc | 3 +++ .../translation_entity/translation_entity.admin.js | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/core/modules/translation_entity/translation_entity.admin.inc b/core/modules/translation_entity/translation_entity.admin.inc index 0e2316b..648ce21 100644 --- a/core/modules/translation_entity/translation_entity.admin.inc +++ b/core/modules/translation_entity/translation_entity.admin.inc @@ -36,6 +36,9 @@ function translation_entity_field_sync_widget(array $field, FieldInstance $insta '#title' => t('Translatable elements'), '#options' => $options, '#default_value' => !empty($instance['settings']['translation_sync']) ? $instance['settings']['translation_sync'] : $default, + '#attached' => array( + 'js' => array(drupal_get_path('module', 'translation_entity') . '/translation_entity.admin.js'), + ), ); } diff --git a/core/modules/translation_entity/translation_entity.admin.js b/core/modules/translation_entity/translation_entity.admin.js index bf253a1..167d110 100644 --- a/core/modules/translation_entity/translation_entity.admin.js +++ b/core/modules/translation_entity/translation_entity.admin.js @@ -3,6 +3,26 @@ "use strict"; /** + * Forces all options to be marked as translatable if the file itself is translatable. + */ +Drupal.behaviors.translationEntityFileOptions = { + attach: function (context) { + var $collection = $(context).find('.form-item-instance-settings-translation-sync'); + var $checkboxes = $collection.find(':input'); + + // Watch changes on all of these checkboxes + $checkboxes.change(function() { + if ($collection.find('input[value="file"]').is(':checked')) { + $checkboxes.prop('checked', true).not($(this)).prop('disabled', true); + } else { + $checkboxes.prop('disabled', false); + } + }); + } +}; + + +/** * Makes field translatability inherit bundle translatability. */ Drupal.behaviors.translationEntity = { -- 1.7.10.2 (Apple Git-33)