Commit 4d5b82b0 authored by c24b's avatar c24b

Load lang

parent 6a5e707e
...@@ -148,36 +148,38 @@ help = {"#project":{ ...@@ -148,36 +148,38 @@ help = {"#project":{
}; };
//define lang //define lang
lang = $("a#lang").data("lang") lang = $("a#lang").data("lang")
//change lang
loadHelp(lang)
//change lang
$("a.new_lang").on("click", function(){ $("a.new_lang").on("click", function(){
new_lang = $(this).data("lang")
//new_lang.setAttr("data-lang", lang)
loadHelp(new_lang);
new_lang = $(this).data("lang")) console.log("AJAX")
// $.ajax({ $.ajax({
// url: '/api/users?lang='+new_lang, url: '/api/users/?'+jQuery.param({"default_language":new_lang}),
// type: 'PUT', type: 'PUT',
// beforeSend: function(xhr) { beforeSend: function(xhr) {
// xhr.setRequestHeader("X-CSRFToken", getCookie("csrftoken")); xhr.setRequestHeader("X-CSRFToken", getCookie("csrftoken"));
// }, },
// success: function(response) { success: function(response) {
// console.log(response); console.log(response);
// console.log("EDIT SUCCESS!"); console.log("EDIT SUCCESS!");
// //addFormStatus("success", "div#editForm-"+id, response["detail"]);
// window.location.reload() //window.location.reload()
// }, },
// error: function(xhr) { error: function(xhr) {
// console.log("EDIT FAIL!") console.log("EDIT FAIL!")
// var status = xhr.status;
// var info = xhr.responseJSON["detail"]; },
// var msg = "<strong>ERROR ["+status+"]:</strong>"+ "<p>"+info+"</p>" });
// addFormStatus("error", "div#editForm-"+id, msg);
// },
// });
// };
});
});
$( ".help" ).each(function(i, el) { function loadHelp(lang){
$("span.help-btn").remove()
$( ".help" ).each(function(i, el) {
console.log("This", el); console.log("This", el);
id = el.id id = el.id
div_id = "#"+id div_id = "#"+id
...@@ -192,7 +194,7 @@ $( ".help" ).each(function(i, el) { ...@@ -192,7 +194,7 @@ $( ".help" ).each(function(i, el) {
info = help[div_id] info = help[div_id]
console.log(lang) console.log(lang)
console.log(info[lang]["content"]) console.log(info[lang]["content"])
help_btn = '<span class="glyphicon glyphicon-question-sign" tab-index=0 data-toggle="popover" data-placement="'+info[lang]["placement"]+'" title="'+info[lang]["title"]+'" data-content="'+info[lang]["content"]+'"></span>' help_btn = '<span class="glyphicon glyphicon-question-sign help-btn" tab-index=0 data-toggle="popover" data-placement="'+info[lang]["placement"]+'" title="'+info[lang]["title"]+'" data-content="'+info[lang]["content"]+'"></span>'
if (info["position"] == "inside"){ if (info["position"] == "inside"){
...@@ -217,8 +219,8 @@ $( ".help" ).each(function(i, el) { ...@@ -217,8 +219,8 @@ $( ".help" ).each(function(i, el) {
//$(help_btn).insertBefore(el); //$(help_btn).insertBefore(el);
} }
}); });
}
$(document).on('click', function (e) { $(document).on('click', function (e) {
$('[data-toggle="popover"],[data-original-title]').each(function () { $('[data-toggle="popover"],[data-original-title]').each(function () {
//the 'is' for buttons that trigger popups //the 'is' for buttons that trigger popups
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment