@@ -13,28 +13,30 @@ function makeEditable(datatableApi) {
1313}
1414
1515function add ( ) {
16+ $ ( "#modalTitle" ) . html ( i18n [ "addTitle" ] ) ;
1617 form . find ( ":input" ) . val ( "" ) ;
1718 $ ( "#editRow" ) . modal ( ) ;
1819}
1920
2021function updateRow ( id ) {
2122 form . find ( ":input" ) . val ( "" ) ;
23+ $ ( "#modalTitle" ) . html ( i18n [ "editTitle" ] ) ;
2224 $ . get ( ctx . ajaxUrl + id , function ( data ) {
2325 $ . each ( data , function ( key , value ) {
24- form . find ( " input[name='" + key + "']" ) . val ( value ) ;
26+ form . find ( ` input[name='${ key } ']` ) . val ( value ) ;
2527 } ) ;
2628 $ ( '#editRow' ) . modal ( ) ;
2729 } ) ;
2830}
2931
3032function deleteRow ( id ) {
31- if ( confirm ( 'Are you sure?' ) ) {
33+ if ( confirm ( i18n [ 'common.confirm' ] ) ) {
3234 $ . ajax ( {
3335 url : ctx . ajaxUrl + id ,
3436 type : "DELETE"
3537 } ) . done ( function ( ) {
3638 ctx . updateTable ( ) ;
37- successNoty ( "Deleted " ) ;
39+ successNoty ( "common.deleted " ) ;
3840 } ) ;
3941 }
4042}
@@ -51,7 +53,7 @@ function save() {
5153 } ) . done ( function ( ) {
5254 $ ( "#editRow" ) . modal ( "hide" ) ;
5355 ctx . updateTable ( ) ;
54- successNoty ( "Saved " ) ;
56+ successNoty ( "common.saved " ) ;
5557 } ) ;
5658}
5759
@@ -64,10 +66,10 @@ function closeNoty() {
6466 }
6567}
6668
67- function successNoty ( text ) {
69+ function successNoty ( key ) {
6870 closeNoty ( ) ;
6971 new Noty ( {
70- text : " <span class='fa fa-lg fa-check'></span> " + text ,
72+ text : ` <span class='fa fa-lg fa-check'></span> ${ i18n [ key ] } ` ,
7173 type : 'success' ,
7274 layout : "bottomRight" ,
7375 timeout : 1000
@@ -76,20 +78,20 @@ function successNoty(text) {
7678
7779function renderEditBtn ( data , type , row ) {
7880 if ( type === "display" ) {
79- return " <a onclick='updateRow(" + row . id + " );'><span class='fa fa-pencil'></span></a>" ;
81+ return ` <a onclick='updateRow(${ row . id } );'><span class='fa fa-pencil'></span></a>` ;
8082 }
8183}
8284
8385function renderDeleteBtn ( data , type , row ) {
8486 if ( type === "display" ) {
85- return " <a onclick='deleteRow(" + row . id + " );'><span class='fa fa-remove'></span></a>" ;
87+ return ` <a onclick='deleteRow(${ row . id } );'><span class='fa fa-remove'></span></a>` ;
8688 }
8789}
8890
8991function failNoty ( jqXHR ) {
9092 closeNoty ( ) ;
9193 failedNote = new Noty ( {
92- text : " <span class='fa fa-lg fa-exclamation-circle'></span> Error status: " + jqXHR . status + ( jqXHR . responseJSON ? " <br>" + jqXHR . responseJSON : "" ) ,
94+ text : ` <span class='fa fa-lg fa-exclamation-circle'></span> ${ i18n [ 'common.errorStatus' ] } : ${ jqXHR . status } ${ jqXHR . responseJSON ? ' <br>' + jqXHR . responseJSON : '' } ` ,
9395 type : "error" ,
9496 layout : "bottomRight"
9597 } ) ;
0 commit comments