Issue #1877048 by nod_: Fixed Make Translation entity module JS follow newer core rules
parent
25ad0ea49b
commit
8c44d48f61
|
@ -25,9 +25,7 @@ function _translation_entity_form_language_content_settings_form_alter(array &$f
|
|||
}
|
||||
$form['entity_types']['#default_value'] = $default;
|
||||
|
||||
$path = drupal_get_path('module', 'translation_entity');
|
||||
$form['#attached']['css'][] = $path . '/translation_entity.admin.css';
|
||||
$form['#attached']['js'][] = $path . '/translation_entity.admin.js';
|
||||
$form['#attached']['library'][] = array('translation_entity', 'drupal.translation_entity.admin');
|
||||
|
||||
foreach ($form['#labels'] as $entity_type => $label) {
|
||||
foreach (entity_get_bundles($entity_type) as $bundle) {
|
||||
|
|
|
@ -7,28 +7,28 @@
|
|||
*/
|
||||
Drupal.behaviors.translationEntity = {
|
||||
attach: function (context) {
|
||||
var $context = $(context);
|
||||
// Initially hide all field rows for non translatable bundles.
|
||||
var $input = $('table .bundle-settings .translatable :input', context);
|
||||
$input.filter(':not(:checked)').once('translation-entity-admin-hide', function() {
|
||||
var $inputs = $context.find('table .bundle-settings .translatable :input');
|
||||
$inputs.filter(':not(:checked)').once('translation-entity-admin-hide', function () {
|
||||
$(this).closest('.bundle-settings').nextUntil('.bundle-settings').hide();
|
||||
});
|
||||
|
||||
// When a bundle is made translatable all of its field instances should
|
||||
// inherit this setting. Instead when it is made non translatable its field
|
||||
// instances are hidden, since their translatability no longer matters.
|
||||
$input.once('translation-entity-admin-bind', function() {
|
||||
var $bundleTranslatable = $(this).click(function() {
|
||||
var $bundleSettings = $bundleTranslatable.closest('.bundle-settings');
|
||||
var $fieldSettings = $bundleSettings.nextUntil('.bundle-settings');
|
||||
if ($bundleTranslatable.is(':checked')) {
|
||||
$bundleSettings.find('.operations :input[name$="[language_hidden]"]').attr('checked', false);
|
||||
$fieldSettings.find('.translatable :input').attr('checked', true);
|
||||
$fieldSettings.show();
|
||||
}
|
||||
else {
|
||||
$fieldSettings.hide();
|
||||
}
|
||||
});
|
||||
$('body').once('translation-entity-admin-bind').on('click', 'table .bundle-settings .translatable :input', function (e) {
|
||||
var $target = $(e.target);
|
||||
var $bundleSettings = $target.closest('.bundle-settings');
|
||||
var $fieldSettings = $bundleSettings.nextUntil('.bundle-settings');
|
||||
if ($target.is(':checked')) {
|
||||
$bundleSettings.find('.operations :input[name$="[language_hidden]"]').attr('checked', false);
|
||||
$fieldSettings.find('.translatable :input').attr('checked', true);
|
||||
$fieldSettings.show();
|
||||
}
|
||||
else {
|
||||
$fieldSettings.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -254,6 +254,30 @@ function translation_entity_add_access(EntityInterface $entity, Language $source
|
|||
return $source->langcode != $target->langcode && isset($languages[$source->langcode]) && isset($languages[$target->langcode]) && !isset($translations[$target->langcode]) && translation_entity_access($entity, $target->langcode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_library_info().
|
||||
*/
|
||||
function translation_entity_library_info() {
|
||||
$path = drupal_get_path('module', 'translation_entity');
|
||||
$libraries['drupal.translation_entity.admin'] = array(
|
||||
'title' => 'Translation entity UI',
|
||||
'version' => VERSION,
|
||||
'js' => array(
|
||||
$path . '/translation_entity.admin.js' => array(),
|
||||
),
|
||||
'css' => array(
|
||||
$path . '/translation_entity.admin.css' => array(),
|
||||
),
|
||||
'dependencies' => array(
|
||||
array('system', 'jquery'),
|
||||
array('system', 'drupal'),
|
||||
array('system', 'jquery.once'),
|
||||
),
|
||||
);
|
||||
|
||||
return $libraries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key name used to store the configuration item.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue