changeset 28:30a1edf90fae

move the language selector to the main menu
author souliane <souliane@mailoo.org>
date Wed, 21 Jan 2015 20:08:26 +0100
parents eda4deefecd1
children b45621706d83
files static/css/sat_website.css templates/sat_website/base.html templates/sat_website/menu.html
diffstat 3 files changed, 28 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/static/css/sat_website.css	Wed Jan 21 20:07:20 2015 +0100
+++ b/static/css/sat_website.css	Wed Jan 21 20:08:26 2015 +0100
@@ -116,3 +116,8 @@
 	font-size: 14px;
 	margin-bottom: 30px;
 }
+
+#language_form {
+    padding-top: 12px;
+    padding-bottom: 12px;
+}
--- a/templates/sat_website/base.html	Wed Jan 21 20:07:20 2015 +0100
+++ b/templates/sat_website/base.html	Wed Jan 21 20:08:26 2015 +0100
@@ -50,29 +50,20 @@
             </div>
             <div id="navbar" class="collapse navbar-collapse">
                 {% include "sat_website/menu.html" with style="nav navbar-nav" categories=categories %}
-                {% include "sat_website/menu.html" with style="nav navbar-nav pull-right" categories=categories_right %}
+                {% include "sat_website/menu.html" with style="nav navbar-nav pull-right" categories=categories_right language_select=True %}
             </div>
         </div>
     </nav>
 
     {% block content %}{% endblock %}
-
-    <div class="container">
-        <div class="row" id="language">
-            <form class="well form-inline" action="{% url 'set_language' %}" method="post">
-                {% csrf_token %}
-                <input name="next" type="hidden" value="{{ redirect_to }}" />
-                <select name="language">
-                    {% get_language_info_list for available_languages as languages %}
-                    {% for language in languages %}
-                        <option value="{{ language.code }}"{% if language.code == LANGUAGE_CODE %} selected="selected"{% endif %}>{{ language.name_local }} ({{ language.code }})</option>
-                    {% endfor %}
-                </select>
-                <input type="submit" value="{% trans "Change language" %}" />
-            </form>
-        </div>
-    </div>
     <script src="{% static "js/jquery.min.js" %}"></script>
     <script src="{% static "bootstrap/js/bootstrap.min.js" %}"></script>
+    <script type="text/javascript">
+		$(document).ready(function() {
+		    $('#language_select').change(function() {
+			    $('#language_form').submit();
+			});
+		});
+    </script>
 </body>
 </html>
--- a/templates/sat_website/menu.html	Wed Jan 21 20:07:20 2015 +0100
+++ b/templates/sat_website/menu.html	Wed Jan 21 20:08:26 2015 +0100
@@ -18,6 +18,7 @@
 along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
 {% endcomment %}
 
+{% load i18n %}
 {% load utils %}
 
 <ul class="{{ style }}">
@@ -38,4 +39,18 @@
             <li><a href="{{ cat_url }}.html"><strong>{{ item }}</strong></a></li>
         {% endif %}
     {% endfor %}
+    {% if language_select %}
+        <li>
+            <form id="language_form" class="form-inline" action="{% url 'set_language' %}" method="post">
+                {% csrf_token %}
+                <input name="next" type="hidden" value="{{ redirect_to }}" />
+                <select id="language_select" name="language">
+                    {% get_language_info_list for available_languages as languages %}
+                    {% for language in languages %}
+                        <option value="{{ language.code }}"{% if language.code == LANGUAGE_CODE %} selected="selected"{% endif %}>{{ language.name_local }} ({{ language.code }})</option>
+                    {% endfor %}
+                </select>
+            </form>
+        </li>
+    {% endif %}
 </ul>