Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
7a8e8629
Commit
7a8e8629
authored
Oct 27, 2016
by
c24b
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Load lang
parent
3ad41a84
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
62 deletions
+64
-62
help.js
static/lib/gargantext/help.js
+64
-62
No files found.
static/lib/gargantext/help.js
View file @
7a8e8629
...
...
@@ -148,77 +148,79 @@ help = {"#project":{
};
//define lang
lang
=
$
(
"a#lang"
).
data
(
"lang"
)
//change lang
loadHelp
(
lang
)
//change lang
$
(
"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"
))
// $.ajax({
// url: '/api/users?lang='+new_lang,
// type: 'PUT',
// beforeSend: function(xhr) {
// xhr.setRequestHeader("X-CSRFToken", getCookie("csrftoken"));
// },
// success: function(response) {
// console.log(response);
// console.log("EDIT SUCCESS!");
// //addFormStatus("success", "div#editForm-"+id, response["detail"]);
// window.location.reload()
// },
// error: function(xhr) {
// 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);
// },
// });
// };
});
console
.
log
(
"AJAX"
)
$
.
ajax
({
url
:
'/api/users/?'
+
jQuery
.
param
({
"default_language"
:
new_lang
}),
type
:
'PUT'
,
beforeSend
:
function
(
xhr
)
{
xhr
.
setRequestHeader
(
"X-CSRFToken"
,
getCookie
(
"csrftoken"
));
},
success
:
function
(
response
)
{
console
.
log
(
response
);
console
.
log
(
"EDIT SUCCESS!"
);
//window.location.reload()
},
error
:
function
(
xhr
)
{
console
.
log
(
"EDIT FAIL!"
)
},
});
$
(
".help"
).
each
(
function
(
i
,
el
)
{
console
.
log
(
"This"
,
el
);
id
=
el
.
id
div_id
=
"#"
+
id
help_steps
=
Object
.
keys
(
help
)
//console.log(help_steps)
//console.log("div help:", div_id)
if
(
help_steps
.
includes
(
div_id
)
==
false
){
console
.
log
(
"Step #"
,
id
,
"class='help' not described in help"
)
return
}
btn
=
id
+
"-help"
info
=
help
[
div_id
]
console
.
log
(
lang
)
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>'
});
function
loadHelp
(
lang
){
$
(
"span.help-btn"
).
remove
()
$
(
".help"
).
each
(
function
(
i
,
el
)
{
console
.
log
(
"This"
,
el
);
id
=
el
.
id
div_id
=
"#"
+
id
help_steps
=
Object
.
keys
(
help
)
//console.log(help_steps)
//console.log("div help:", div_id)
if
(
help_steps
.
includes
(
div_id
)
==
false
){
console
.
log
(
"Step #"
,
id
,
"class='help' not described in help"
)
return
}
btn
=
id
+
"-help"
info
=
help
[
div_id
]
console
.
log
(
lang
)
console
.
log
(
info
[
lang
][
"content"
])
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"
){
$
(
help_btn
).
appendTo
(
el
);
}
else
if
(
info
[
"position"
]
==
"after"
){
$
(
help_btn
).
insertAfter
(
el
);
}
else
if
(
info
[
"position"
]
==
"before"
){
$
(
help_btn
).
insertBefore
(
el
);
}
else
if
(
info
[
"position"
]
==
"dup_child"
){
//copy the first child inside the element and create a custom one with btn
console
.
log
(
el
.
children
())
}
else
if
(
info
[
"position"
]
==
"dup_parent"
){
//copy the element and create a copy with btn
console
.
log
(
el
.
parent
())
}
else
{
//duplicate element and insert the button
//$(help_btn).insertBefore(el);
}
});
if
(
info
[
"position"
]
==
"inside"
){
$
(
help_btn
).
appendTo
(
el
);
}
else
if
(
info
[
"position"
]
==
"after"
){
$
(
help_btn
).
insertAfter
(
el
);
}
else
if
(
info
[
"position"
]
==
"before"
){
$
(
help_btn
).
insertBefore
(
el
);
}
else
if
(
info
[
"position"
]
==
"dup_child"
){
//copy the first child inside the element and create a custom one with btn
console
.
log
(
el
.
children
())
}
else
if
(
info
[
"position"
]
==
"dup_parent"
){
//copy the element and create a copy with btn
console
.
log
(
el
.
parent
())
}
else
{
//duplicate element and insert the button
//$(help_btn).insertBefore(el);
}
});
}
$
(
document
).
on
(
'click'
,
function
(
e
)
{
$
(
'[data-toggle="popover"],[data-original-title]'
).
each
(
function
()
{
//the 'is' for buttons that trigger popups
...
...
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