Browse Source

cleaned up locale; added all locals to example; set users local as default

codeClimate
Alexander Wunschik 8 years ago
parent
commit
f61c83ac6e
3 changed files with 37 additions and 18 deletions
  1. +13
    -9
      docs/network/index.html
  2. +24
    -3
      examples/network/other/manipulation.html
  3. +0
    -6
      lib/network/options.js

+ 13
- 9
docs/network/index.html View File

@ -328,19 +328,23 @@ network.setOptions(options);
<tr><td id="event_locale">locale</td>
<td>String</td>
<td><code>'en'</code></td>
<td>Select the locale. By default, the language is English. If you want to use another language, you
will
need to define your own locale and refer to it here.
<td>Select the locale. By default, the language is English.
</td>
</tr>
<tr><td id="event_locales">locales</td>
<td>Object</td>
<td>defaultLocales</td>
<td>Locales object. By default only <code>'en'</code>, <code>'de'</code>, <code>'es'</code>, <code>'it'</code> and <code>'nl'</code> are supported. Take a look
at
the <a href="#locales" data-scroll=""
data-options="{ &quot;easing&quot;: &quot;easeInCubic&quot; }">locales
section below</a> for more explaination on how to customize this.
<td>Locales object. By default
<code>'en'</code>,
<code>'de'</code>,
<code>'es'</code>,
<code>'it'</code>,
<code>'nl'</code>
<code>'pt-br'</code>,
<code>'ru'</code>
are supported. Take a look at the
<a href="#locales" data-scroll="" data-options="{ &quot;easing&quot;: &quot;easeInCubic&quot; }">locales section below</a>
for more explaination on how to customize this.
</td>
</tr>
<tr><td id="event_clickToUse">clickToUse</td>
@ -998,7 +1002,7 @@ function releaseFunction (clusterPosition, containedNodesPositions) {
</tr>
<tr class="collapsible toggle" onclick="toggleTable('methodTable','setSelection', this);">
<td colspan="2"><span parent="setSelection" class="right-caret" id="method_setSelection"></span> setSelection(
<code>Object selection</code>,
<code>Object selection</code>,
<code>[Object options]</code>)</td>
</tr>
<tr class="hidden" parent="setSelection">

+ 24
- 3
examples/network/other/manipulation.html View File

@ -1,6 +1,7 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Network | Manipulation</title>
<style type="text/css">
@ -64,6 +65,17 @@
var data = getScaleFreeNetwork(25);
var seed = 2;
function setDefaultLocale() {
var defaultLocal = navigator.language;
var select = document.getElementById('locale');
select.selectedIndex = 0; // set fallback value
for (var i = 0, j = select.options.length; i < j; ++i) {
if (select.options[i].getAttribute('value') === defaultLocal) {
select.selectedIndex = i;
break;
}
}
}
function destroy() {
if (network !== null) {
@ -135,11 +147,16 @@
callback(data);
}
function init() {
setDefaultLocale();
draw();
}
</script>
<script src="../../googleAnalytics.js"></script>
</head>
<body onload="draw();">
<body onload="init();">
<h2>Editing the nodes and edges (localized)</h2>
<p style="width: 700px; font-size:14px; text-align: justify;">
The localization is only relevant to the manipulation buttons.
@ -148,8 +165,13 @@
<p>
<label for="locale">Select a locale:</label>
<select id="locale" onchange="draw();">
<option value="en" selected>en</option>
<option value="en">en</option>
<option value="de">de</option>
<option value="es">es</option>
<option value="it">it</option>
<option value="nl">nl</option>
<option value="pt-br">pt</option>
<option value="ru">ru</option>
</select>
</p>
@ -169,4 +191,3 @@
</body>
</html>

+ 0
- 6
lib/network/options.js View File

@ -502,13 +502,7 @@ let configureOptions = {
solver: ['barnesHut', 'forceAtlas2Based', 'repulsion', 'hierarchicalRepulsion'],
timestep: [0.5, 0.01, 1, 0.01],
//adaptiveTimestep: true
},
global: {
locale: ['en', 'nl']
}
};
export {allOptions, configureOptions};

Loading…
Cancel
Save