2015-08-18 00:00:26 +00:00
/ * *
2018-11-23 12:29:20 +00:00
* DO NOT EDIT THIS FILE .
* See the following change record for more information ,
* https : //www.drupal.org/node/2815083
* @ preserve
* * /
2015-08-18 00:00:26 +00:00
( function ( $ , Drupal ) {
Drupal . behaviors . localeTranslateDirty = {
2018-11-23 12:29:20 +00:00
attach : function attach ( ) {
2015-10-22 04:44:50 +00:00
var $form = $ ( '#locale-translate-edit-form' ) . once ( 'localetranslatedirty' ) ;
2015-08-18 00:00:26 +00:00
if ( $form . length ) {
$form . one ( 'formUpdated.localeTranslateDirty' , 'table' , function ( ) {
var $marker = $ ( Drupal . theme ( 'localeTranslateChangedWarning' ) ) . hide ( ) ;
$ ( this ) . addClass ( 'changed' ) . before ( $marker ) ;
$marker . fadeIn ( 'slow' ) ;
} ) ;
2018-11-23 12:29:20 +00:00
2015-08-18 00:00:26 +00:00
$form . on ( 'formUpdated.localeTranslateDirty' , 'tr' , function ( ) {
var $row = $ ( this ) ;
var $rowToMark = $row . once ( 'localemark' ) ;
var marker = Drupal . theme ( 'localeTranslateChangedMarker' ) ;
$row . addClass ( 'changed' ) ;
2018-11-23 12:29:20 +00:00
2015-08-18 00:00:26 +00:00
if ( $rowToMark . length ) {
2015-10-08 18:40:12 +00:00
$rowToMark . find ( 'td:first-child .js-form-item' ) . append ( marker ) ;
2015-08-18 00:00:26 +00:00
}
} ) ;
}
} ,
2018-11-23 12:29:20 +00:00
detach : function detach ( context , settings , trigger ) {
2015-08-18 00:00:26 +00:00
if ( trigger === 'unload' ) {
2015-10-22 04:44:50 +00:00
var $form = $ ( '#locale-translate-edit-form' ) . removeOnce ( 'localetranslatedirty' ) ;
2015-08-18 00:00:26 +00:00
if ( $form . length ) {
$form . off ( 'formUpdated.localeTranslateDirty' ) ;
}
}
}
} ;
Drupal . behaviors . hideUpdateInformation = {
2018-11-23 12:29:20 +00:00
attach : function attach ( context , settings ) {
2015-08-18 00:00:26 +00:00
var $table = $ ( '#locale-translation-status-form' ) . once ( 'expand-updates' ) ;
if ( $table . length ) {
var $tbodies = $table . find ( 'tbody' ) ;
$tbodies . on ( 'click keydown' , '.description' , function ( e ) {
2018-11-23 12:29:20 +00:00
if ( e . keyCode && e . keyCode !== 13 && e . keyCode !== 32 ) {
2015-08-18 00:00:26 +00:00
return ;
}
e . preventDefault ( ) ;
var $tr = $ ( this ) . closest ( 'tr' ) ;
$tr . toggleClass ( 'expanded' ) ;
$tr . find ( '.locale-translation-update__prefix' ) . text ( function ( ) {
if ( $tr . hasClass ( 'expanded' ) ) {
return Drupal . t ( 'Hide description' ) ;
}
2018-11-23 12:29:20 +00:00
return Drupal . t ( 'Show description' ) ;
2015-08-18 00:00:26 +00:00
} ) ;
} ) ;
$table . find ( '.requirements, .links' ) . hide ( ) ;
}
}
} ;
2018-11-23 12:29:20 +00:00
$ . extend ( Drupal . theme , {
localeTranslateChangedMarker : function localeTranslateChangedMarker ( ) {
2015-08-18 00:00:26 +00:00
return '<abbr class="warning ajax-changed" title="' + Drupal . t ( 'Changed' ) + '">*</abbr>' ;
} ,
2018-11-23 12:29:20 +00:00
localeTranslateChangedWarning : function localeTranslateChangedWarning ( ) {
2015-08-18 00:00:26 +00:00
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>' ;
}
} ) ;
2018-11-23 12:29:20 +00:00
} ) ( jQuery , Drupal ) ;