Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
5a52303f
Commit
5a52303f
authored
Mar 09, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show information about loading
parent
08299365
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
1 deletion
+25
-1
html/translate.html
html/translate.html
+1
-1
media/js/loader.js
media/js/loader.js
+24
-0
media/loading.gif
media/loading.gif
+0
-0
No files found.
html/translate.html
View file @
5a52303f
...
...
@@ -56,7 +56,7 @@
{% endif %}
<tr>
<td></td>
<td
class=
"toolbar"
><a
href=
"#"
id=
"copy-text"
>
{% trans "Copy" %}
</a></td>
<td
class=
"toolbar"
><a
href=
"#"
id=
"copy-text"
>
{% trans "Copy" %}
</a><
img
src=
"/media/loading.gif"
id=
"loading"
style=
"display: none"
/><
/td>
</tr>
<tr>
<th>
{% if unit.is_plural %}{% trans "Translations" %}{% else %}{% trans "Translation" %}{% endif %}
</th>
...
...
media/js/loader.js
View file @
5a52303f
...
...
@@ -2,9 +2,27 @@ function text_change(e) {
$
(
'
#id_fuzzy
'
).
attr
(
'
checked
'
,
false
);
}
var
loading
=
0
;
function
inc_loading
()
{
if
(
loading
==
0
)
{
$
(
'
#loading
'
).
show
();
}
loading
++
;
}
function
dec_loading
()
{
loading
--
;
if
(
loading
==
0
)
{
$
(
'
#loading
'
).
hide
();
}
}
function
get_source_string
(
callback
)
{
inc_loading
();
$
.
get
(
"
/js/get/
"
+
$
(
'
#id_checksum
'
).
attr
(
'
value
'
)
+
'
/
'
,
function
(
data
)
{
callback
(
data
);
dec_loading
();
});
}
...
...
@@ -17,10 +35,12 @@ function load_translate_apis() {
if
(
typeof
(
apertium
)
!=
'
undefined
'
&&
apertium
.
isTranslatablePair
(
'
en
'
,
target_language
))
{
add_translate_button
(
'
apertium
'
,
gettext
(
'
Translate using Apertium
'
),
function
()
{
get_source_string
(
function
(
data
)
{
inc_loading
();
apertium
.
translate
(
data
,
'
en
'
,
target_language
,
function
(
ret
)
{
if
(
!
ret
.
error
)
{
$
(
'
#id_target
'
).
text
(
ret
.
translation
);
}
dec_loading
();
});
});
return
false
;
...
...
@@ -31,8 +51,10 @@ function load_translate_apis() {
if
(
langs
.
indexOf
(
target_language
)
!=
-
1
)
{
add_translate_button
(
'
microsoft
'
,
gettext
(
'
Translate using Microsoft Translator
'
),
function
()
{
get_source_string
(
function
(
data
)
{
inc_loading
();
Microsoft
.
Translator
.
translate
(
data
,
'
en
'
,
target_language
,
function
(
ret
)
{
$
(
'
#id_target
'
).
text
(
ret
);
dec_loading
();
});
});
return
false
;
...
...
@@ -41,10 +63,12 @@ function load_translate_apis() {
}
add_translate_button
(
'
mymemory
'
,
gettext
(
'
Translate using MyMemory
'
),
function
()
{
get_source_string
(
function
(
data
)
{
inc_loading
();
$
.
getJSON
(
"
http://mymemory.translated.net/api/get?q=
"
+
data
+
"
&langpair=en|
"
+
target_language
,
function
(
data
)
{
if
(
data
.
responseData
!=
''
)
{
$
(
'
#id_target
'
).
text
(
data
.
responseData
.
translatedText
);
}
dec_loading
();
});
});
});
...
...
media/loading.gif
0 → 100644
View file @
5a52303f
1.8 KB
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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