mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 23:27:26 +01:00
@@ -186,9 +186,9 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
|||||||
}
|
}
|
||||||
|
|
||||||
$rootScope.charts = {};
|
$rootScope.charts = {};
|
||||||
$rootScope.resizeCharts = {};
|
var resizeChartFunctions = {};
|
||||||
$rootScope.toggleChart = function(id, task) {
|
$rootScope.toggleChart = function(id, task) {
|
||||||
var history = [], matrix, data, options, container;
|
var history = [], matrix, data;
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 'exp':
|
case 'exp':
|
||||||
history = User.user.history.exp;
|
history = User.user.history.exp;
|
||||||
@@ -204,13 +204,12 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
|||||||
if (task && task._editing) task._editing = false;
|
if (task && task._editing) task._editing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($rootScope.charts[id]) {
|
if ($rootScope.charts[id] && !resizeChartFunctions[id]) {
|
||||||
var handleResize = _.debounce(function() {
|
resizeChartFunctions[id] = function() {
|
||||||
drawChart(id, data);
|
drawChart(id, data);
|
||||||
}, 300);
|
};
|
||||||
|
} else if (!$rootScope.charts[id]) {
|
||||||
$rootScope.resizeCharts[id] = $rootScope.resizeCharts[id] || _.once(function() { $(window).resize(handleResize) });
|
delete resizeChartFunctions[id];
|
||||||
$rootScope.resizeCharts[id]();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
matrix = [[env.t('date'), env.t('score')]];
|
matrix = [[env.t('date'), env.t('score')]];
|
||||||
@@ -222,15 +221,15 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
|||||||
drawChart(id, data);
|
drawChart(id, data);
|
||||||
};
|
};
|
||||||
|
|
||||||
function drawChart(id, data, options) {
|
function drawChart(id, data) {
|
||||||
var chart, width;
|
var chart, width, options;
|
||||||
|
|
||||||
if(id === "exp") {
|
if (id === 'exp') {
|
||||||
width = $(".row").width() - 20;
|
width = $('.row').width() - 20;
|
||||||
} else if(id === "todos") {
|
} else if (id === 'todos') {
|
||||||
width = $(".task-column.todos").width();
|
width = $('.task-column.todos').width();
|
||||||
} else {
|
} else {
|
||||||
width = $(".task-text").width() - 15;
|
width = $('.task-text').width() - 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
@@ -430,5 +429,12 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
|||||||
$scope.ctrlPressed = false;
|
$scope.ctrlPressed = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var resizeAllCharts = _.debounce(function () {
|
||||||
|
_.each(resizeChartFunctions, function (fn) {
|
||||||
|
fn();
|
||||||
|
});
|
||||||
|
}, 100);
|
||||||
|
$(window).resize(resizeAllCharts);
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|||||||
Reference in New Issue
Block a user