forked from speced/respec
-
Notifications
You must be signed in to change notification settings - Fork 1
/
chart_title.js
38 lines (34 loc) · 1.21 KB
/
chart_title.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function chart_title(args) {
//is chart title different than existing, if so, clear the fine
//gentleman, otherwise, move along
'use strict';
var currentTitle = $(args.target).find('h2.chart_title');
if(args.title && args.title !== currentTitle.text())
currentTitle.remove();
else
return;
if (args.target && args.title) {
var newTitle;
//only show question mark if there's a description
var optional_question_mark = (args.description)
? '<i class="fa fa-question-circle fa-inverse"></i>'
: '';
$(args.target).prepend('<h2 class="chart_title">'
+ args.title + optional_question_mark + '</h2>');
//activate the question mark if we have a description
if (args.description){
newTitle = $(args.target).find('h2.chart_title');
newTitle.popover({
html: true,
animation: false,
content: args.description,
trigger: 'hover',
placement: 'top',
container: newTitle
});
}
}
if(args.error) {
error(args);
}
}