Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
8c44d48f
Commit
8c44d48f
authored
Jan 02, 2013
by
Angie Byron
Browse files
Issue
#1877048
by nod_: Fixed Make Translation entity module JS follow newer core rules
parent
25ad0ea4
Changes
3
Hide whitespace changes
Inline
Side-by-side
core/modules/translation_entity/translation_entity.admin.inc
View file @
8c44d48f
...
...
@@ -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
)
{
...
...
core/modules/translation_entity/translation_entity.admin.js
View file @
8c44d48f
...
...
@@ -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
$input
s
=
$
context
.
find
(
'
table .bundle-settings .translatable :input
'
);
$input
s
.
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
();
}
});
}
};
...
...
core/modules/translation_entity/translation_entity.module
View file @
8c44d48f
...
...
@@ -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.
*
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment