From 34952e82588da3ce4596282942d33a1f86efbaf9 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 3 Sep 2014 22:34:15 +0200 Subject: [PATCH] Replace setTimeout with timeout function. Timeout function is much friendly with coffeescript and code that uses it looks better. --- app/coffee/modules/backlog/main.coffee | 5 ++--- app/coffee/modules/common/loader.coffee | 9 ++++----- app/coffee/modules/nav.coffee | 8 ++++---- app/coffee/modules/taskboard/charts.coffee | 7 +++---- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/app/coffee/modules/backlog/main.coffee b/app/coffee/modules/backlog/main.coffee index 94e85059..e6b12d85 100644 --- a/app/coffee/modules/backlog/main.coffee +++ b/app/coffee/modules/backlog/main.coffee @@ -26,6 +26,7 @@ toggleText = @.taiga.toggleText scopeDefer = @.taiga.scopeDefer bindOnce = @.taiga.bindOnce groupBy = @.taiga.groupBy +timeout = @.taiga.timeout module = angular.module("taigaBacklog") @@ -519,10 +520,9 @@ BacklogDirective = ($repo, $rootscope) -> showHideFilter = ($scope, $el, $ctrl) -> sidebar = $el.find("sidebar.filters-bar") sidebar.one "transitionend", () -> - setTimeout ( -> + timeout 150, -> $rootscope.$broadcast("resize") $('.burndown').css("visibility", "visible") - ), 150 target = angular.element("#show-filters-button") $('.burndown').css("visibility", "hidden") @@ -542,7 +542,6 @@ BacklogDirective = ($repo, $rootscope) -> event.preventDefault() showHideFilter($scope, $el, $ctrl) - link = ($scope, $el, $attrs, $rootscope) -> $ctrl = $el.controller() diff --git a/app/coffee/modules/common/loader.coffee b/app/coffee/modules/common/loader.coffee index f0266360..fdabe995 100644 --- a/app/coffee/modules/common/loader.coffee +++ b/app/coffee/modules/common/loader.coffee @@ -26,6 +26,7 @@ taiga = @.taiga sizeFormat = @.taiga.sizeFormat +timeout = @.taiga.timeout module = angular.module("taigaCommon") @@ -90,18 +91,16 @@ Loader = () -> pageLoaded = (force = false) -> if startLoadTime - timeout = 0 + timeoutValue = 0 if !force endTime = new Date().getTime() diff = endTime - startLoadTime if diff < config.minTime - timeout = config.minTime - diff + timeoutValue = config.minTime - diff - setTimeout ( -> - $rootscope.$broadcast("loader:end") - ), timeout + timeout(timeoutValue, -> $rootscope.$broadcast("loader:end")) return { reset: () -> diff --git a/app/coffee/modules/nav.coffee b/app/coffee/modules/nav.coffee index bb7ef375..dd4a961d 100644 --- a/app/coffee/modules/nav.coffee +++ b/app/coffee/modules/nav.coffee @@ -22,6 +22,7 @@ taiga = @.taiga groupBy = @.taiga.groupBy bindOnce = @.taiga.bindOnce +timeout = @.taiga.timeout module = angular.module("taigaNavMenu", []) @@ -113,12 +114,12 @@ ProjectsNavigationDirective = ($rootscope, animationFrame, $timeout, tgLoader, $ hideMenu = () -> if overlay.is(':visible') difftime = new Date().getTime() - loadingStart - timeout = 0 + timeoutValue = 0 if (difftime < 1000) - timeout = 1000 - timeout + timeoutValue = 1000 - timeoutValue - setTimeout ( -> + timeout timeoutValue, -> overlay.one 'transitionend', () -> overlay.hide() @@ -127,7 +128,6 @@ ProjectsNavigationDirective = ($rootscope, animationFrame, $timeout, tgLoader, $ .addClass("closed-projects-nav") tgLoader.disablePreventLoading() - ), timeout renderProjects = ($el, projects) -> html = projectsTemplate({projects: projects}) diff --git a/app/coffee/modules/taskboard/charts.coffee b/app/coffee/modules/taskboard/charts.coffee index f1a4db65..002fbfde 100644 --- a/app/coffee/modules/taskboard/charts.coffee +++ b/app/coffee/modules/taskboard/charts.coffee @@ -26,6 +26,7 @@ toggleText = @.taiga.toggleText scopeDefer = @.taiga.scopeDefer bindOnce = @.taiga.bindOnce groupBy = @.taiga.groupBy +timeout = @.taiga.timeout module = angular.module("taigaTaskboard") @@ -96,10 +97,8 @@ SprintGraphDirective = -> $scope.$on "taskboard:graph:toggle-visibility", -> $el.parent().toggleClass('open') - #fix chart overflow - setTimeout ( -> - redrawChart(element, $scope.stats.days) - ), 100 + # fix chart overflow + timeout(100, -> redrawChart(element, $scope.stats.days)) $scope.$on "$destroy", -> $el.off()