@@ -16,11 +16,13 @@ function clearState(key) {
16
16
}
17
17
18
18
function syncMessage ( key ) {
19
+ var el = document . getElementById ( key ) . getElementsByClassName ( "translation" ) ;
20
+ el [ 0 ] . innerHTML = getLoaderHTML ( ) ;
21
+
19
22
Sfjs . request (
20
23
translationSyncUrl ,
21
24
function ( xhr ) {
22
25
// Success
23
- var el = document . getElementById ( key ) . getElementsByClassName ( "translation" ) ;
24
26
el [ 0 ] . innerHTML = xhr . responseText ;
25
27
26
28
if ( xhr . responseText !== "" ) {
@@ -29,53 +31,58 @@ function syncMessage(key) {
29
31
} ,
30
32
function ( xhr ) {
31
33
// Error
32
- console . log ( " Syncing message "+ key + " - Error" ) ;
34
+ el [ 0 ] . innerHTML = "<span style='color:red;'>Error - Syncing message " + key + "</span>" ;
33
35
} ,
34
36
serializeQueryString ( { message_id : key } ) ,
35
37
{ method : 'POST' }
36
38
) ;
37
39
}
40
+
38
41
function syncAll ( ) {
42
+ var el = document . getElementById ( "top-result-area" ) ;
43
+ el [ 0 ] . innerHTML = getLoaderHTML ( ) ;
44
+
39
45
Sfjs . request (
40
46
translationSyncAllUrl ,
41
47
function ( xhr ) {
42
48
// Success
43
- var el = document . getElementById ( "top-result-area" ) ;
44
49
el . innerHTML = xhr . responseText ;
45
50
} ,
46
51
function ( xhr ) {
47
52
// Error
48
- console . log ( "Syncing message " + key + " - Error" ) ;
53
+ el [ 0 ] . innerHTML = "<span style='color:red;'>Error - Syncing all messages</span>" ;
49
54
} ,
50
55
{ } ,
51
56
{ method : 'POST' }
52
57
) ;
53
58
}
54
59
55
60
function getEditForm ( key ) {
61
+ var el = document . getElementById ( key ) . getElementsByClassName ( "translation" ) ;
62
+ el [ 0 ] . innerHTML = getLoaderHTML ( ) ;
56
63
57
64
Sfjs . request (
58
65
translationEditUrl + "?" + serializeQueryString ( { message_id : key } ) ,
59
66
function ( xhr ) {
60
67
// Success
61
- var el = document . getElementById ( key ) . getElementsByClassName ( "translation" ) ;
62
68
el [ 0 ] . innerHTML = xhr . responseText ;
63
69
} ,
64
70
function ( xhr ) {
65
71
// Error
66
- console . log ( " Getting edit form "+ key + " - Error" ) ;
72
+ el [ 0 ] . innerHTML = "<span style='color:red;'>Error - Getting edit form " + key + "</span>" ;
67
73
} ,
68
74
{ method : 'GET' }
69
75
) ;
70
76
}
71
77
72
78
function saveEditForm ( key , translation ) {
79
+ var el = document . getElementById ( key ) . getElementsByClassName ( "translation" ) ;
80
+ el [ 0 ] . innerHTML = getLoaderHTML ( ) ;
73
81
74
82
Sfjs . request (
75
83
translationEditUrl ,
76
84
function ( xhr ) {
77
85
// Success
78
- var el = document . getElementById ( key ) . getElementsByClassName ( "translation" ) ;
79
86
el [ 0 ] . innerHTML = xhr . responseText ;
80
87
81
88
if ( xhr . responseText !== "" ) {
@@ -84,7 +91,7 @@ function saveEditForm(key, translation) {
84
91
} ,
85
92
function ( xhr ) {
86
93
// Error
87
- console . log ( " Saving edit form "+ key + " - Error" ) ;
94
+ el [ 0 ] . innerHTML = "<span style='color:red;'>Error - Saving edit form " + key + "</span>" ;
88
95
} ,
89
96
serializeQueryString ( { message_id : key , translation :translation } ) ,
90
97
{ method : 'POST' }
@@ -98,6 +105,20 @@ function cancelEditForm(key, orgMessage) {
98
105
el [ 0 ] . innerHTML = orgMessage ;
99
106
}
100
107
108
+ function toggleCheckAll ( controller ) {
109
+ var checkboxes = document . querySelectorAll ( '.translation-key-checkbox' ) ;
110
+
111
+ for ( var i = 0 ; i < checkboxes . length ; i ++ ) {
112
+ checkboxes [ i ] . checked = controller . checked ;
113
+ }
114
+ }
115
+
116
+ function getLoaderHTML ( ) {
117
+ var loader = document . getElementById ( 'svg-loader' ) ;
118
+
119
+ return loader . outerHTML ;
120
+ }
121
+
101
122
var serializeQueryString = function ( obj , prefix ) {
102
123
var str = [ ] ;
103
124
for ( var p in obj ) {
@@ -122,11 +143,14 @@ var serializeQueryString = function(obj, prefix) {
122
143
123
144
var saveTranslations = function ( form ) {
124
145
"use strict" ;
146
+
125
147
if ( typeof ( form . translationKey ) === 'undefined' ) {
126
148
return false ;
127
149
}
150
+
128
151
var inputs = form . translationKey ;
129
152
var selected = [ ] ;
153
+
130
154
if ( ! inputs . value ) {
131
155
for ( var val in inputs ) {
132
156
if ( inputs . hasOwnProperty ( val ) && inputs [ val ] . value ) {
@@ -138,15 +162,26 @@ var saveTranslations = function(form) {
138
162
} else if ( inputs . checked ) {
139
163
selected . push ( inputs . value ) ;
140
164
}
165
+
166
+ var el = document . getElementById ( 'translationResult' ) ;
167
+ el . innerHTML = getLoaderHTML ( ) ;
168
+ el . classList . remove ( 'label' ) ;
169
+ el . classList . remove ( 'status-error' ) ;
170
+ el . classList . remove ( 'status-success' ) ;
171
+
141
172
Sfjs . request (
142
173
form . action ,
143
174
function ( xhr ) {
144
175
// Success
145
- document . getElementById ( 'translationResult' ) . innerHTML = xhr . responseText ;
176
+ el . classList . add ( 'label' ) ;
177
+ el . classList . add ( 'status-success' ) ;
178
+ el . innerHTML = xhr . responseText ;
146
179
} ,
147
180
function ( xhr ) {
148
181
// Error
149
- document . getElementById ( 'translationResult' ) . innerHTML = xhr . responseText ;
182
+ el . classList . add ( 'label' ) ;
183
+ el . classList . add ( 'status-error' ) ;
184
+ el . innerHTML = xhr . responseText ;
150
185
} ,
151
186
serializeQueryString ( { selected : selected } ) ,
152
187
{ method : 'POST' }
0 commit comments