Skip to content

Commit

Permalink
template: remove inline JavaScript
Browse files Browse the repository at this point in the history
Signed-off-by: Diego Rodriguez <diego.rodriguez@cern.ch>
  • Loading branch information
Diego Rodriguez authored and drjova committed Aug 3, 2017
1 parent 21c27e5 commit 32325f0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/app.py
Expand Up @@ -53,8 +53,8 @@
from __future__ import absolute_import, print_function

from flask import Flask, render_template

from flask_babelex import lazy_gettext as _

from invenio_i18n import InvenioI18N

# Create Flask application
Expand Down
8 changes: 7 additions & 1 deletion invenio_i18n/static/js/invenio_i18n/angularLangSelector.js
@@ -1,7 +1,7 @@
/* -*- coding: utf-8 -*-
*
* This file is part of Invenio.
* Copyright (C) 2016 CERN.
* Copyright (C) 2016, 2017 CERN.
*
* Invenio is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public License as
Expand All @@ -25,6 +25,7 @@

require([
"node_modules/angular/angular",
"node_modules/jquery/jquery.js",
"node_modules/angular-gettext/dist/angular-gettext"
], function() {
angular.module("langSelector", ["gettext"])
Expand All @@ -33,4 +34,9 @@ require([
gettextCatalog.setCurrentLanguage(lang);
}
}]);
$(document).ready(function() {
$('#lang-code').on('change', function() {
$('#language-code-form').submit();
});
});
});
Expand Up @@ -37,12 +37,12 @@
{% endmacro %}

{% macro language_selector_dropdown() %}
<form class="form form-inline lang-select"
<form id="language-code-form" class="form form-inline lang-select"
action="{{ url_for('invenio_i18n.set_lang')}}"
method="POST">
<div class="form-group">
<p class="form-control-static">{{ _('Language:') }}</p>
<select name="lang_code" onchange="this.form.submit()">
<select id="lang-code" name="lang_code">
{% for l in current_i18n.get_locales() %}
<option {% if current_i18n.language == l.language %}selected {% endif %}value="{{ l.language }}">{{ l.get_display_name() }}</option>
{% endfor %}
Expand Down

0 comments on commit 32325f0

Please sign in to comment.