main.js
1.29 KB
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
39
40
41
42
var gamificationPlugin = {
displayNotification: function(html) {
var n = noty({
text: html,
type: 'success',
layout: 'center',
modal: 'true',
theme: 'relax',
closeWith: ['click', 'backdrop'],
animation: {
open : 'animated bounceInLeft',
close : 'animated bounceOutLeft',
easing: 'swing',
speed : 500
}
});
},
displayUserInfo: function(gamificationPlugin) {
var info = jQuery('.gamification-plugin.user-info-template').clone();
info.find('.badges .value').text(gamificationPlugin.badges.length);
info.find('.points .value').text(gamificationPlugin.points);
info.find('.level .value').text(gamificationPlugin.level);
info.insertAfter('#user .logged-in #homepage-link');
info.show();
},
displayLevelChart: function() {
var chart = $('.gamification .pie-chart');
var size = 60;
chart.easyPieChart({lineWidth: 10, scaleColor: false, size: size, barColor: '#1EA5C5', trackColor: '#C0EEFF'});
chart.width(size);
chart.find('span').css('line-height', size+'px');
}
}
jQuery(window).bind("userDataLoaded", function(event, data) {
gamificationPlugin.displayUserInfo(data.gamification_plugin);
});
jQuery(document).ready(function($) {
gamificationPlugin.displayLevelChart();
});