Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cloud-quote
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
cloud-quote
Commits
d070594f
Commit
d070594f
authored
Mar 21, 2013
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made translate gadget autonomous, removed translate interactions
parent
686356ed
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
92 additions
and
154 deletions
+92
-154
gadgets/ad.html
gadgets/ad.html
+0
-5
gadgets/analysis.html
gadgets/analysis.html
+0
-5
gadgets/configure.html
gadgets/configure.html
+0
-5
gadgets/header.html
gadgets/header.html
+1
-8
gadgets/index_wrapper.html
gadgets/index_wrapper.html
+1
-10
gadgets/navigation.html
gadgets/navigation.html
+0
-5
gadgets/results_wrapper.html
gadgets/results_wrapper.html
+2
-11
gadgets/social.html
gadgets/social.html
+1
-4
gadgets/translate.html
gadgets/translate.html
+87
-66
js/controller.js
js/controller.js
+0
-35
No files found.
gadgets/ad.html
View file @
d070594f
...
...
@@ -11,11 +11,6 @@
$
(
document
).
ready
(
function
()
{
var
gadget
=
RenderJs
.
getSelfGadget
();
// interaction listener
gadget
.
translate
=
function
(){
$
.
fn
.
util
.
lang
(
gadget
.
dom
);
};
// trigger enhancement
$
(
this
).
trigger
(
"
render_enhance
"
,
{
gadget
:
gadget
.
dom
});
});
...
...
gadgets/analysis.html
View file @
d070594f
...
...
@@ -17,11 +17,6 @@
$
(
document
).
ready
(
function
()
{
var
gadget
=
RenderJs
.
getSelfGadget
();
// interaction listener
gadget
.
translate
=
function
(){
$
.
fn
.
util
.
lang
(
gadget
.
dom
);
};
// trigger enhancement
$
(
this
).
trigger
(
"
render_enhance
"
,
{
gadget
:
gadget
.
dom
});
});
...
...
gadgets/configure.html
View file @
d070594f
...
...
@@ -348,11 +348,6 @@
$
(
document
).
ready
(
function
()
{
var
gadget
=
RenderJs
.
getSelfGadget
();
// interaction listener
gadget
.
translate
=
function
(){
$
.
fn
.
util
.
lang
(
gadget
.
dom
);
};
// trigger enhancement
$
(
this
).
trigger
(
"
render_enhance
"
,
{
gadget
:
gadget
.
dom
});
});
...
...
gadgets/header.html
View file @
d070594f
...
...
@@ -17,9 +17,7 @@
<div
class=
"headWrapRight ui-btn-right"
>
<div
id=
"translator"
data-gadget=
"../gadgets/translate.html"
></div>
</div>
<div
data-gadget=
""
class=
"main-interactor"
data-gadget-connection=
"[
{"source": "translator.translate", "destination": "index_wrapper.translate"}
]"
>
<div
data-gadget=
""
class=
"main-interactor"
data-gadget-connection=
"[]"
>
</div>
</div>
...
...
@@ -58,11 +56,6 @@
}
}
// interactions
gadget
.
translate
=
function
(){
$
.
fn
.
util
.
lang
(
gadget
.
dom
);
};
$
(
document
).
ready
(
function
()
{
// trigger enhancement
$
(
this
).
trigger
(
"
render_enhance
"
,
{
gadget
:
gadget
.
dom
});
...
...
gadgets/index_wrapper.html
View file @
d070594f
...
...
@@ -11,21 +11,12 @@
<p
class=
"mini t"
data-i18n=
"gen.disclaimer"
></p>
<!-- interactions -->
<div
data-gadget=
""
class=
"main-interactor"
data-gadget-connection=
"[
{"source": "index_wrapper.route_translate", "destination": "index_configure.translate"}
, {"source": "index_wrapper.route_translate", "destination": "index_social.translate"}
, {"source": "index_wrapper.route_translate", "destination": "index_analysis.translate"}
, {"source": "index_wrapper.route_translate", "destination": "index_nav.translate"}
]"
>
data-gadget-connection=
"[]"
>
<script
type=
"text/javascript"
language=
"javascript"
>
//
<!
[
CDATA
[
$
(
document
).
ready
(
function
()
{
var
gadget
=
RenderJs
.
getSelfGadget
();
gadget
.
translate
=
function
(){
$
.
fn
.
util
.
lang
(
gadget
.
dom
);
gadget
.
dom
.
trigger
(
"
route_translate
"
);
};
});
//]]>
</script>
...
...
gadgets/navigation.html
View file @
d070594f
...
...
@@ -28,11 +28,6 @@
$
(
document
).
ready
(
function
()
{
var
gadget
=
RenderJs
.
getSelfGadget
();
// interaction listener
gadget
.
translate
=
function
(){
$
.
fn
.
util
.
lang
(
gadget
.
dom
);
};
// trigger enhancement
$
(
this
).
trigger
(
"
render_enhance
"
,
{
gadget
:
gadget
.
dom
});
});
...
...
gadgets/results_wrapper.html
View file @
d070594f
...
...
@@ -16,22 +16,13 @@
<p
class=
"mini t"
data-i18n=
"gen.disclaimer"
></p>
<!-- interactions -->
<div
data-gadget=
""
class=
"main-interactor"
data-gadget-connection=
"[
{"source": "results_wrapper.route_translate", "destination": "results_list.translate"}
, {"source": "results_wrapper.route_translate", "destination": "results_ad.translate"}
, {"source": "results_wrapper.route_translate", "destination": "results_social.translate"}
, {"source": "results_wrapper.route_translate", "destination": "results_analysis.translate"}
, {"source": "results_wrapper.route_translate", "destination": "results_nav.translate"}
]"
>
data-gadget-connection=
"[]"
>
<script
type=
"text/javascript"
language=
"javascript"
>
//
<!
[
CDATA
[
$
(
document
).
ready
(
function
()
{
var
gadget
=
RenderJs
.
getSelfGadget
();
gadget
.
translate
=
function
(){
$
.
fn
.
util
.
lang
(
gadget
.
dom
);
gadget
.
dom
.
trigger
(
"
route_translate
"
);
};
});
//]]>
</script>
...
...
gadgets/social.html
View file @
d070594f
...
...
@@ -22,10 +22,7 @@
//
<!
[
CDATA
[
$
(
document
).
ready
(
function
()
{
var
gadget
=
RenderJs
.
getSelfGadget
();
// interaction listener
gadget
.
translate
=
function
(){
$
.
fn
.
util
.
lang
(
gadget
.
dom
);
};
// trigger enhancement
$
(
this
).
trigger
(
"
render_enhance
"
,
{
gadget
:
gadget
.
dom
});
});
...
...
gadgets/translate.html
View file @
d070594f
...
...
@@ -63,31 +63,37 @@
<div
data-role=
"popup"
id=
""
class=
"all_popups"
>
<ul
data-role=
"listview"
data-inset=
"true"
data-divider-theme=
"f"
>
<li
data-role=
"list-divider"
class=
"t"
data-i18n=
"gen.language"
></li>
<li
data-icon=
"false"
><a
class=
"t change_language"
href=
"?lang=
FR-fr
"
data-i18n-target=
".ui-li-text"
data-i18n=
"[title]gen.language_info;[html]gen.lang.fr"
><span
class=
"ui-icon ui-fake-icon ui-li-icon ui-icon-lang ui-li-thumb FR"
>
</span><span
class=
"ui-li-text"
></span></a></li>
<li
data-icon=
"false"
><a
class=
"t change_language"
href=
"?lang=
DE-de
"
data-i18n-target=
".ui-li-text"
data-i18n=
"[title]gen.language_info;[html]gen.lang.de"
><span
class=
"ui-icon ui-fake-icon ui-li-icon ui-icon-lang ui-li-thumb DE"
>
</span><span
class=
"ui-li-text"
></span></a></li>
<li
data-icon=
"false"
><a
class=
"t change_language"
href=
"?lang=
EN-en
"
data-i18n-target=
".ui-li-text"
data-i18n=
"[title]gen.language_info;[html]gen.lang.en"
><span
class=
"ui-icon ui-fake-icon ui-li-icon ui-icon-lang ui-li-thumb EN"
>
</span><span
class=
"ui-li-text"
></span></a></li>
<li
data-icon=
"false"
><a
class=
"t change_language"
href=
"?lang=
fr-FR
"
data-i18n-target=
".ui-li-text"
data-i18n=
"[title]gen.language_info;[html]gen.lang.fr"
><span
class=
"ui-icon ui-fake-icon ui-li-icon ui-icon-lang ui-li-thumb FR"
>
</span><span
class=
"ui-li-text"
></span></a></li>
<li
data-icon=
"false"
><a
class=
"t change_language"
href=
"?lang=
de-DE
"
data-i18n-target=
".ui-li-text"
data-i18n=
"[title]gen.language_info;[html]gen.lang.de"
><span
class=
"ui-icon ui-fake-icon ui-li-icon ui-icon-lang ui-li-thumb DE"
>
</span><span
class=
"ui-li-text"
></span></a></li>
<li
data-icon=
"false"
><a
class=
"t change_language"
href=
"?lang=
en-EN
"
data-i18n-target=
".ui-li-text"
data-i18n=
"[title]gen.language_info;[html]gen.lang.en"
><span
class=
"ui-icon ui-fake-icon ui-li-icon ui-icon-lang ui-li-thumb EN"
>
</span><span
class=
"ui-li-text"
></span></a></li>
</ul>
</div>
<script
type=
"text/javascript"
language=
"javascript"
>
//
<!
[
CDATA
[
var
gadget
=
RenderJs
.
getSelfGadget
(),
i
,
list
=
RenderJs
.
GadgetIndex
.
getGadgetList
(),
current_gadget
,
recursive_gadgets
=
gadget
.
dom
.
find
(
"
[data-gadget]
"
).
not
(
"
.main-interactor
"
),
len
=
recursive_gadgets
.
length
,
lang
=
$
.
fn
.
fauna
.
i18n_current_lang
,
switchIcon
=
function
()
{
// this should be the callback after create, which sets the icon
// however setting elem here cannot access the JQM enhanced elements
// although the functions is called after JQM is done enhancing...
// var elem = gadget.dom.find(".setIcon .ui-icon");
// if (elem.length > 0) {
// elem.removeClass()
// .addClass('ui-icon ui-shadow ui-icon-lang '+set_icon);
// }
switchIcon
=
function
(
id
,
icon
)
{
var
current_gadget
,
elem
,
gadget_to_translate
;
// not possible without, because JQM will not be done enhancing
window
.
setTimeout
(
function
(){
current_gadget
=
RenderJs
.
GadgetIndex
.
getGadgetById
(
id
),
elem
=
current_gadget
.
dom
.
find
(
"
.setIcon .ui-icon
"
);
elem
=
$
(
"
.setIcon .ui-icon
"
)
if
(
elem
.
length
>
0
)
{
elem
.
removeClass
()
.
addClass
(
'
ui-icon ui-shadow ui-icon-lang
'
+
icon
);
}
},
50
);
},
// set
interactions
// set
language
set_lang
=
function
(
language
)
{
var
set_icon
,
elem
;
var
set_icon
,
elem
,
override
=
false
,
remote
;
switch
(
language
)
{
case
"
de-DE
"
:
...
...
@@ -101,26 +107,53 @@
break
;
};
$
.
fn
.
fauna
.
i18n_current_lang
=
language
;
// modfiy elements, trigger translation
gadget
.
dom
.
trigger
(
"
translate
"
);
// trigger create
if
(
gadget
.
isEnhanced
()
===
false
)
{
$
(
document
).
trigger
(
"
render_enhance
"
,
{
"
gadget
"
:
gadget
.
dom
,
"
callback
"
:
switchIcon
()});
gadget
.
setEnhanced
(
true
);
//$(document).trigger("render_enhance", {"gadget": gadget.dom, "callback":switchIcon(gadget.id, set_icon)});
$
(
document
).
trigger
(
"
render_enhance
"
,
{
"
gadget
"
:
gadget
.
dom
});
// no other way to translate popups, because the popup will be moved to the end of the DOM
remote
=
gadget
.
dom
.
find
(
"
a
"
).
attr
(
'
href
'
);
$
(
remote
+
'
-popup
'
).
find
(
"
.t
"
).
i18n
()
}
// NONO!
setTimeout
(
function
()
{
elem
=
gadget
.
dom
.
find
(
"
.setIcon .ui-icon
"
);
if
(
elem
.
length
>
0
)
{
elem
.
removeClass
()
.
addClass
(
'
ui-icon ui-shadow ui-icon-lang
'
+
set_icon
);
if
(
$
.
fn
.
fauna
.
i18n_current_lang
!==
language
)
{
override
=
true
;
}
// translate all gadgets in the gadget list (dom available)
for
(
i
=
0
;
i
<
list
.
length
;
i
+=
1
)
{
gadget_to_translate
=
list
[
i
];
if
(
gadget_to_translate
.
isEnhanced
()
===
false
||
override
)
{
gadget_to_translate
.
dom
.
find
(
"
.t
"
).
i18n
();
gadget_to_translate
.
setEnhanced
(
true
);
}
}
$
.
fn
.
fauna
.
i18n_current_lang
=
language
;
switchIcon
(
gadget
.
id
,
set_icon
);
},
// i18n handler
lang
=
function
(
lang
)
{
// init
if
(
$
.
fn
.
fauna
.
i18n_set
===
undefined
)
{
$
.
i18n
.
init
({
lng
:
'
en-EN
'
,
load
:
'
current
'
,
detectLngQS
:
'
lang
'
,
fallbackLng
:
false
,
resGetPath
:
'
../lang/__lng__/__ns__.json
'
,
ns
:
'
gen
'
// , debug: true,
// , useLocalStorage: true
// , localStorageExpirationTime: 86400000 // in ms, default 1 week
},
function
()
{
set_lang
(
$
.
i18n
.
lng
());
});
$
.
fn
.
fauna
.
i18n_set
=
true
;
}
else
{
set_lang
(
lang
);
}
},
50
);
};
// modify gadget
// customize gadget
if
(
gadget
.
self
!==
undefined
)
{
for
(
key
in
gadget
.
self
)
{
if
(
gadget
.
self
.
hasOwnProperty
(
key
))
{
...
...
@@ -142,39 +175,27 @@
// dynamic gadget-id
$
(
this
).
attr
(
'
id
'
,
new_id
);
// update interactions
string
=
gadget
.
dom
.
find
(
"
.main-interactor
"
).
attr
(
"
data-gadget-connection
"
);
new_string
=
string
.
replace
(
current_id
,
new_id
);
gadget
.
dom
.
find
(
"
.main-interactor
"
).
attr
(
"
data-gadget-connection
"
,
new_string
);
});
// initializing setter
$
(
document
).
on
(
'
i18n_ready
'
,
function
(
e
,
data
)
{
set_lang
(
data
.
lang
);
RenderJs
.
bindReady
(
function
()
{
var
current_lang
=
$
.
fn
.
fauna
.
i18n_current_lang
;
// also pass undefined on first run
lang
(
current_lang
);
});
$
(
document
).
ready
(
function
()
{
// regular page setter
if
(
lang
!==
undefined
)
{
set_lang
(
$
.
fn
.
fauna
.
i18n_current_lang
);
}
// switch language
// add switch language binding
$
(
this
)
.
filter
(
function
()
{
return
$
(
this
).
jqmData
(
"
i18n
"
)
!==
true
;
})
.
jqmData
(
'
i18n
'
,
true
)
.
on
(
'
click
'
,
'
.change_language
'
,
function
(
e
)
{
var
lang
=
$
(
this
).
attr
(
'
href
'
).
replace
(
'
?lang=
'
,
''
);
var
new_language
=
$
(
this
).
attr
(
'
href
'
).
replace
(
'
?lang=
'
,
''
);
e
.
preventDefault
();
$
(
'
.all_popups
'
).
popup
(
"
close
"
);
// switch to new language
$
.
i18n
.
setLng
(
lang
,
function
()
{
// translate everything in gadget
$
.
fn
.
util
.
lang
(
gadget
.
dom
);
// interaction! switch icon (triggers translate on all other gadgets
set_lang
(
$
.
i18n
.
lng
());
$
.
i18n
.
setLng
(
new_language
,
function
()
{
// switch to new language
lang
(
new_language
);
});
});
});
...
...
js/controller.js
View file @
d070594f
...
...
@@ -108,36 +108,6 @@ define([], function () {
$
(
this
).
appendTo
(
$
(
'
#configure tbody tr
'
).
eq
(
i
).
find
(
'
td
'
).
show
().
last
());
});
}
},
// languages i18n handler
lang
:
function
(
elem
)
{
var
translate
=
function
(
elem
)
{
elem
.
find
(
'
.t
'
).
i18n
();
};
// init
if
(
fauna
.
i18n_set
===
undefined
)
{
i18n
.
init
({
lng
:
'
en-EN
'
,
load
:
'
current
'
,
detectLngQS
:
'
lang
'
,
fallbackLng
:
false
,
resGetPath
:
'
../lang/__lng__/__ns__.json
'
,
ns
:
'
gen
'
// , debug: true,
// , useLocalStorage: true
// , localStorageExpirationTime: 86400000 // in ms, default 1 week
},
function
()
{
translate
(
elem
);
// set current language, trigger i18n_ready
fauna
.
i18n_current_lang
=
i18n
.
lng
();
$
(
document
).
trigger
(
'
i18n_ready
'
,{
lang
:
i18n
.
lng
()});
});
fauna
.
i18n_set
=
true
;
}
else
{
translate
(
elem
);
}
}
};
...
...
@@ -195,11 +165,6 @@ define([], function () {
// initialize renderjs
RenderJs
.
init
();
RenderJs
.
bindReady
(
function
()
{
var
elem
=
$
(
this
);
util
.
lang
(
elem
);
});
});
// reset gadgets on pages that are being removed
...
...
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