-
Notifications
You must be signed in to change notification settings - Fork 39
/
edit_source.html
91 lines (82 loc) · 2.59 KB
/
edit_source.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<form style="display: inline" method="GET" action="/translator/edit/{{ lang }}">
<div style="float: right; margin-top: -5px">
<select name="source" onchange="this.form.elements['contains'].value = ''; this.form.submit ()">
<option value="">- {"Limit to source file"} -</option>
{% foreach sources %}
<option value="{{ loop_value }}"{% if loop_value === $data->source %} selected{% end %}>{{ loop_value }}</option>
{% end %}
</select>
- {"or"} -
<input type="text" name="contains" placeholder="{"Contains text..."}" size="30" />
<input type="submit" value="{"Go"}" />
<a href="/translator/edit/{{ lang }}">{"Clear"}</a>
</div>
</form>
<p><a href="/translator/index">{"Done editing"}</a></p>
<p>
<table width="100%">
<tr>
<th width="48%">{"Original text"}</th>
<th width="52%">
<span style="float: right">
{% if empty %}
<a href="/translator/edit/{{ lang }}?source={{ source|urlencode }}">{"Show all fields"}</a>
{% else %}
<a href="/translator/edit/{{ lang }}?source={{ source|urlencode }}&empty=1">{"Show empty fields"}</a>
{% end %}
</span>
{{ name }}
</th>
</tr>
{% foreach items %}
{% if empty === false || $data->loop_value['trans'] === '' %}
<tr id="tr-{{ loop_index|translator_field_id }}">
<td class="original" title="{"Source"}: {{ loop_value[src] }}">{{ loop_index }}</td>
<td class="translate">
<textarea
rows="1" style="float:left; width: 85%; height: 100%"
data-orig="{{ loop_index }}"
data-id="{{ loop_index|translator_field_id }}"
id="textarea-{{ loop_index|translator_field_id }}"
onblur="$.save_element (this)"
{% if empty ($data->loop_value[trans]) %} class="empty"{% end %}
>{{ loop_value[trans] }}</textarea>
<span id="saving-{{ loop_index|translator_field_id }}" class="notice" style="float: left; margin-left: 7px">{"Saving..."}</span>
</td>
</tr>
{% end %}
{% end %}
</table>
</p>
<script>
$(function () {
$('textarea')[0].focus ();
$('textarea').keyup (function (evt) {
if ($(this).val ().length > 0) {
$(this).removeClass ('empty');
} else {
$(this).addClass ('empty');
}
});
});
$.save_element = function (el) {
var id = $(el).data ('id'),
orig = $(el).data ('orig'),
val = $(el).val ();
if (val.length === 0) {
$(el).addClass ('empty');
return;
}
$(el).removeClass ('empty');
$('#saving-' + id).html ('{"Saving..."}').show ();
$.post ('/translator/api/save', {lang: '{{ lang }}', orig: orig, value: val}, function (res) {
// Todo: error checking
$('#saving-' + id).html ('{"Saved!"}').delay (1000).fadeOut ();
});
};
</script>
<style>
.empty {
background: #ffd;
}
</style>