\");\n templateFn = function() {\n var publicRegisterEnabled;\n publicRegisterEnabled = $config.get(\"publicRegisterEnabled\");\n if (!publicRegisterEnabled) {\n return \"\";\n }\n return template({\n url: $navUrls.resolve(\"register\")\n });\n };\n return {\n restrict: \"AE\",\n scope: {},\n template: templateFn\n };\n };\n\n module.directive(\"tgPublicRegisterMessage\", [\"$tgConfig\", \"$tgNavUrls\", PublicRegisterMessageDirective]);\n\n LoginDirective = function($auth, $confirm, $location, $config, $routeParams, $navUrls, $events) {\n var link;\n link = function($scope, $el, $attrs) {\n var onError, onSuccess, submit;\n onSuccess = function(response) {\n var nextUrl;\n if ($routeParams['next'] && $routeParams['next'] !== $navUrls.resolve(\"login\")) {\n nextUrl = $routeParams['next'];\n } else {\n nextUrl = $navUrls.resolve(\"home\");\n }\n $events.setupConnection();\n return $location.path(nextUrl);\n };\n onError = function(response) {\n return $confirm.notify(\"light-error\", \"According to our Oompa Loompas, your username/email or password are incorrect.\");\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var data, form, promise;\n event.preventDefault();\n form = new checksley.Form($el.find(\"form.login-form\"));\n if (!form.validate()) {\n return;\n }\n data = {\n \"username\": $el.find(\"form.login-form input[name=username]\").val(),\n \"password\": $el.find(\"form.login-form input[name=password]\").val()\n };\n promise = $auth.login(data);\n return promise.then(onSuccess, onError);\n };\n })(this));\n $el.on(\"submit\", \"form\", submit);\n return $el.on(\"click\", \".submit-button\", submit);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLogin\", [\"$tgAuth\", \"$tgConfirm\", \"$tgLocation\", \"$tgConfig\", \"$routeParams\", \"$tgNavUrls\", \"$tgEvents\", LoginDirective]);\n\n RegisterDirective = function($auth, $confirm, $location, $navUrls, $config, $analytics) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, onErrorSubmit, onSuccessSubmit, submit;\n if (!$config.get(\"publicRegisterEnabled\")) {\n $location.path($navUrls.resolve(\"not-found\"));\n $location.replace();\n }\n $scope.data = {};\n form = $el.find(\"form\").checksley({\n onlyOneErrorElement: true\n });\n onSuccessSubmit = function(response) {\n $analytics.trackEvent(\"auth\", \"register\", \"user registration\", 1);\n $confirm.notify(\"success\", \"Our Oompa Loompas are happy, welcome to Taiga.\");\n return $location.path($navUrls.resolve(\"home\"));\n };\n onErrorSubmit = function(response) {\n if (response.data._error_message != null) {\n $confirm.notify(\"light-error\", \"According to our Oompa Loompas there was an error. \" + response.data._error_message);\n }\n return form.setErrors(response.data);\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n promise = $auth.register($scope.data);\n return promise.then(onSuccessSubmit, onErrorSubmit);\n };\n })(this));\n $el.on(\"submit\", \"form\", submit);\n return $el.on(\"click\", \".submit-button\", submit);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgRegister\", [\"$tgAuth\", \"$tgConfirm\", \"$tgLocation\", \"$tgNavUrls\", \"$tgConfig\", \"$tgAnalytics\", RegisterDirective]);\n\n ForgotPasswordDirective = function($auth, $confirm, $location, $navUrls) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, onErrorSubmit, onSuccessSubmit, submit;\n $scope.data = {};\n form = $el.find(\"form\").checksley();\n onSuccessSubmit = function(response) {\n $location.path($navUrls.resolve(\"login\"));\n return $confirm.success(\"Check your inbox! We have sent a mail to \" + response.data.email + \" with the instructions to set a new password\");\n };\n onErrorSubmit = function(response) {\n return $confirm.notify(\"light-error\", \"According to our Oompa Loompas, your are not registered yet.\");\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n promise = $auth.forgotPassword($scope.data);\n return promise.then(onSuccessSubmit, onErrorSubmit);\n };\n })(this));\n $el.on(\"submit\", \"form\", submit);\n return $el.on(\"click\", \".submit-button\", submit);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgForgotPassword\", [\"$tgAuth\", \"$tgConfirm\", \"$tgLocation\", \"$tgNavUrls\", ForgotPasswordDirective]);\n\n ChangePasswordFromRecoveryDirective = function($auth, $confirm, $location, $params, $navUrls) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, onErrorSubmit, onSuccessSubmit, submit;\n $scope.data = {};\n if ($params.token != null) {\n $scope.tokenInParams = true;\n $scope.data.token = $params.token;\n } else {\n $scope.tokenInParams = false;\n }\n form = $el.find(\"form\").checksley();\n onSuccessSubmit = function(response) {\n $location.path($navUrls.resolve(\"login\"));\n return $confirm.success(\"Our Oompa Loompas saved your new password. Try to sign in with it.\");\n };\n onErrorSubmit = function(response) {\n return $confirm.notify(\"light-error\", \"One of our Oompa Loompas say '\" + response.data._error_message + \"'.\");\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n promise = $auth.changePasswordFromRecovery($scope.data);\n return promise.then(onSuccessSubmit, onErrorSubmit);\n };\n })(this));\n $el.on(\"submit\", \"form\", submit);\n return $el.on(\"click\", \".submit-button\", submit);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgChangePasswordFromRecovery\", [\"$tgAuth\", \"$tgConfirm\", \"$tgLocation\", \"$routeParams\", \"$tgNavUrls\", ChangePasswordFromRecoveryDirective]);\n\n InvitationDirective = function($auth, $confirm, $location, $params, $navUrls, $analytics) {\n var link;\n link = function($scope, $el, $attrs) {\n var loginForm, onErrorSubmitLogin, onErrorSubmitRegister, onSuccessSubmitLogin, onSuccessSubmitRegister, promise, registerForm, submitLogin, submitRegister, token;\n token = $params.token;\n promise = $auth.getInvitation(token);\n promise.then(function(invitation) {\n return $scope.invitation = invitation;\n });\n promise.then(null, function(response) {\n $location.path($navUrls.resolve(\"login\"));\n return $confirm.success(\"Ooops, we have a problem Our Oompa Loompas can't find your invitation.\");\n });\n $scope.dataLogin = {\n token: token\n };\n loginForm = $el.find(\"form.login-form\").checksley({\n onlyOneErrorElement: true\n });\n onSuccessSubmitLogin = function(response) {\n $analytics.trackEvent(\"auth\", \"invitationAccept\", \"invitation accept with existing user\", 1);\n $location.path($navUrls.resolve(\"project\", {\n project: $scope.invitation.project_slug\n }));\n return $confirm.notify(\"success\", \"You've successfully joined this project\", \"Welcome to \" + (_.escape($scope.invitation.project_name)));\n };\n onErrorSubmitLogin = function(response) {\n return $confirm.notify(\"light-error\", \"According to our Oompa Loompas, your are not registered yet or typed an invalid password.\");\n };\n submitLogin = debounce(2000, (function(_this) {\n return function(event) {\n event.preventDefault();\n if (!loginForm.validate()) {\n return;\n }\n promise = $auth.acceptInvitiationWithExistingUser($scope.dataLogin);\n return promise.then(onSuccessSubmitLogin, onErrorSubmitLogin);\n };\n })(this));\n $el.on(\"submit\", \"form.login-form\", submitLogin);\n $el.on(\"click\", \".button-login\", submitLogin);\n $scope.dataRegister = {\n token: token\n };\n registerForm = $el.find(\"form.register-form\").checksley();\n onSuccessSubmitRegister = function(response) {\n $analytics.trackEvent(\"auth\", \"invitationAccept\", \"invitation accept with new user\", 1);\n $location.path($navUrls.resolve(\"project\", {\n project: $scope.invitation.project_slug\n }));\n return $confirm.notify(\"success\", \"You've successfully joined this project\", \"Welcome to \" + (_.escape($scope.invitation.project_name)));\n };\n onErrorSubmitRegister = function(response) {\n return $confirm.notify(\"light-error\", \"According to our Oompa Loompas, that username or email is already in use.\");\n };\n submitRegister = debounce(2000, (function(_this) {\n return function(event) {\n event.preventDefault();\n if (!registerForm.validate()) {\n return;\n }\n promise = $auth.acceptInvitiationWithNewUser($scope.dataRegister);\n return promise.then(onSuccessSubmitRegister, onErrorSubmitRegister);\n };\n })(this));\n $el.on(\"submit\", \"form.register-form\", submitRegister);\n return $el.on(\"click\", \".button-register\", submitRegister);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgInvitation\", [\"$tgAuth\", \"$tgConfirm\", \"$tgLocation\", \"$routeParams\", \"$tgNavUrls\", \"$tgAnalytics\", InvitationDirective]);\n\n ChangeEmailDirective = function($repo, $model, $auth, $confirm, $location, $params, $navUrls) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, onErrorSubmit, onSuccessSubmit, submit;\n $scope.data = {};\n $scope.data.email_token = $params.email_token;\n form = $el.find(\"form\").checksley();\n onSuccessSubmit = function(response) {\n return $repo.queryOne(\"users\", $auth.getUser().id).then((function(_this) {\n return function(data) {\n $auth.setUser(data);\n $location.path($navUrls.resolve(\"home\"));\n return $confirm.success(\"Our Oompa Loompas updated your email\");\n };\n })(this));\n };\n onErrorSubmit = function(response) {\n return $confirm.notify(\"error\", \"One of our Oompa Loompas says '\" + response.data._error_message + \"'.\");\n };\n submit = function() {\n var promise;\n if (!form.validate()) {\n return;\n }\n promise = $auth.changeEmail($scope.data);\n return promise.then(onSuccessSubmit, onErrorSubmit);\n };\n $el.on(\"submit\", function(event) {\n event.preventDefault();\n return submit();\n });\n return $el.on(\"click\", \"a.button-change-email\", function(event) {\n event.preventDefault();\n return submit();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgChangeEmail\", [\"$tgRepo\", \"$tgModel\", \"$tgAuth\", \"$tgConfirm\", \"$tgLocation\", \"$routeParams\", \"$tgNavUrls\", ChangeEmailDirective]);\n\n CancelAccountDirective = function($repo, $model, $auth, $confirm, $location, $params, $navUrls) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, onErrorSubmit, onSuccessSubmit, submit;\n $scope.data = {};\n $scope.data.cancel_token = $params.cancel_token;\n form = $el.find(\"form\").checksley();\n onSuccessSubmit = function(response) {\n $auth.logout();\n $location.path($navUrls.resolve(\"home\"));\n return $confirm.success(\"Our Oompa Loompas removed your account\");\n };\n onErrorSubmit = function(response) {\n return $confirm.notify(\"error\", \"One of our Oompa Loompas says '\" + response.data._error_message + \"'.\");\n };\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n promise = $auth.cancelAccount($scope.data);\n return promise.then(onSuccessSubmit, onErrorSubmit);\n };\n })(this));\n $el.on(\"submit\", \"form\", submit);\n return $el.on(\"click\", \".submit-button\", submit);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgCancelAccount\", [\"$tgRepo\", \"$tgModel\", \"$tgAuth\", \"$tgConfirm\", \"$tgLocation\", \"$routeParams\", \"$tgNavUrls\", CancelAccountDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/backlog.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaBacklog\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base.coffee\n */\n\n(function() {\n var TaigaMainDirective, bindOnce, groupBy, init, module, taiga, urls;\n\n taiga = this.taiga;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n module = angular.module(\"taigaBase\", [\"taigaLocales\"]);\n\n TaigaMainDirective = function($rootscope, $window) {\n var link;\n link = function($scope, $el, $attrs) {\n return $window.onresize = function() {\n return $rootscope.$broadcast(\"resize\");\n };\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgMain\", [\"$rootScope\", \"$window\", TaigaMainDirective]);\n\n urls = {\n \"home\": \"/\",\n \"error\": \"/error\",\n \"not-found\": \"/not-found\",\n \"permission-denied\": \"/permission-denied\",\n \"login\": \"/login\",\n \"forgot-password\": \"/forgot-password\",\n \"change-password\": \"/change-password/:token\",\n \"change-email\": \"/change-email/:token\",\n \"cancel-account\": \"/cancel-account/:token\",\n \"register\": \"/register\",\n \"invitation\": \"/invitation/:token\",\n \"create-project\": \"/create-project\",\n \"profile\": \"/:user\",\n \"project\": \"/project/:project\",\n \"project-backlog\": \"/project/:project/backlog\",\n \"project-taskboard\": \"/project/:project/taskboard/:sprint\",\n \"project-kanban\": \"/project/:project/kanban\",\n \"project-issues\": \"/project/:project/issues\",\n \"project-search\": \"/project/:project/search\",\n \"project-userstories-detail\": \"/project/:project/us/:ref\",\n \"project-tasks-detail\": \"/project/:project/task/:ref\",\n \"project-issues-detail\": \"/project/:project/issue/:ref\",\n \"project-wiki\": \"/project/:project/wiki\",\n \"project-wiki-page\": \"/project/:project/wiki/:slug\",\n \"project-team\": \"/project/:project/team\",\n \"project-admin-home\": \"/project/:project/admin/project-profile/details\",\n \"project-admin-project-profile-details\": \"/project/:project/admin/project-profile/details\",\n \"project-admin-project-profile-default-values\": \"/project/:project/admin/project-profile/default-values\",\n \"project-admin-project-profile-modules\": \"/project/:project/admin/project-profile/modules\",\n \"project-admin-project-values-us-status\": \"/project/:project/admin/project-values/us-status\",\n \"project-admin-project-values-us-points\": \"/project/:project/admin/project-values/us-points\",\n \"project-admin-project-values-task-status\": \"/project/:project/admin/project-values/task-status\",\n \"project-admin-project-values-issue-status\": \"/project/:project/admin/project-values/issue-status\",\n \"project-admin-project-values-issue-types\": \"/project/:project/admin/project-values/issue-types\",\n \"project-admin-project-values-issue-priorities\": \"/project/:project/admin/project-values/issue-priorities\",\n \"project-admin-project-values-issue-severities\": \"/project/:project/admin/project-values/issue-severities\",\n \"project-admin-memberships\": \"/project/:project/admin/memberships\",\n \"project-admin-roles\": \"/project/:project/admin/roles\",\n \"project-admin-third-parties-github\": \"/project/:project/admin/third-parties/github\",\n \"project-admin-third-parties-gitlab\": \"/project/:project/admin/third-parties/gitlab\",\n \"project-admin-third-parties-bitbucket\": \"/project/:project/admin/third-parties/bitbucket\",\n \"user-settings-user-profile\": \"/project/:project/user-settings/user-profile\",\n \"user-settings-user-change-password\": \"/project/:project/user-settings/user-change-password\",\n \"user-settings-user-avatar\": \"/project/:project/user-settings/user-avatar\",\n \"user-settings-mail-notifications\": \"/project/:project/user-settings/mail-notifications\"\n };\n\n init = function($log, $navurls) {\n $log.debug(\"Initialize navigation urls\");\n return $navurls.update(urls);\n };\n\n module.run([\"$log\", \"$tgNavUrls\", init]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common.coffee\n */\n\n(function() {\n var AnimationFrame, AppTitle, CheckPermissionDirective, LimitLineLengthDirective, ProjectUrl, Qqueue, SelectedText, ToggleCommentDirective, module, taiga,\n __slice = [].slice;\n\n taiga = this.taiga;\n\n module = angular.module(\"taigaCommon\", []);\n\n SelectedText = function($window, $document) {\n var get;\n get = function() {\n if ($window.getSelection) {\n return $window.getSelection().toString();\n } else if ($document.selection) {\n return $document.selection.createRange().text;\n }\n return \"\";\n };\n return {\n get: get\n };\n };\n\n module.factory(\"$selectedText\", [\"$window\", \"$document\", SelectedText]);\n\n CheckPermissionDirective = function() {\n var link, render;\n render = function($el, project, permission) {\n if (project.my_permissions.indexOf(permission) > -1) {\n return $el.removeClass('hidden');\n }\n };\n link = function($scope, $el, $attrs) {\n var permission;\n $el.addClass('hidden');\n permission = $attrs.tgCheckPermission;\n $scope.$watch(\"project\", function(project) {\n if (project != null) {\n return render($el, project, permission);\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgCheckPermission\", CheckPermissionDirective);\n\n AnimationFrame = function() {\n var add, animationFrame, performAnimation, tail;\n animationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;\n performAnimation = (function(_this) {\n return function(time) {\n var fn;\n fn = tail.shift();\n fn();\n if (tail.length) {\n return animationFrame(performAnimation);\n }\n };\n })(this);\n tail = [];\n add = function() {\n var fn, _i, _len, _results;\n _results = [];\n for (_i = 0, _len = arguments.length; _i < _len; _i++) {\n fn = arguments[_i];\n tail.push(fn);\n if (tail.length === 1) {\n _results.push(animationFrame(performAnimation));\n } else {\n _results.push(void 0);\n }\n }\n return _results;\n };\n return {\n add: add\n };\n };\n\n module.factory(\"animationFrame\", AnimationFrame);\n\n ToggleCommentDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return $el.find(\"textarea\").on(\"focus\", function() {\n return $el.addClass(\"active\");\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgToggleComment\", ToggleCommentDirective);\n\n AppTitle = function() {\n var set;\n set = function(text) {\n return $(\"title\").text(text);\n };\n return {\n set: set\n };\n };\n\n module.factory(\"$appTitle\", AppTitle);\n\n ProjectUrl = function($navurls) {\n var get;\n get = function(project) {\n var ctx;\n ctx = {\n project: project.slug\n };\n if (project.is_backlog_activated && project.my_permissions.indexOf(\"view_us\") > -1) {\n return $navurls.resolve(\"project-backlog\", ctx);\n }\n if (project.is_kanban_activated && project.my_permissions.indexOf(\"view_us\") > -1) {\n return $navurls.resolve(\"project-kanban\", ctx);\n }\n if (project.is_wiki_activated && project.my_permissions.indexOf(\"view_wiki_pages\") > -1) {\n return $navurls.resolve(\"project-wiki\", ctx);\n }\n if (project.is_issues_activated && project.my_permissions.indexOf(\"view_issues\") > -1) {\n return $navurls.resolve(\"project-issues\", ctx);\n }\n return $navurls.resolve(\"project\", ctx);\n };\n return {\n get: get\n };\n };\n\n module.factory(\"$projectUrl\", [\"$tgNavUrls\", ProjectUrl]);\n\n LimitLineLengthDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n var maxColsPerLine;\n maxColsPerLine = parseInt($el.attr(\"cols\"));\n return $el.on(\"keyup\", function(event) {\n var code, lines;\n code = event.keyCode;\n lines = $el.val().split(\"\\n\");\n _.each(lines, function(line, index) {\n return lines[index] = line.substring(0, maxColsPerLine - 2);\n });\n return $el.val(lines.join(\"\\n\"));\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLimitLineLength\", LimitLineLengthDirective);\n\n Qqueue = function($q) {\n var deferred, lastPromise, qqueue;\n deferred = $q.defer();\n deferred.resolve();\n lastPromise = deferred.promise;\n qqueue = {\n bindAdd: (function(_this) {\n return function(fn) {\n return function() {\n var args;\n args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];\n return lastPromise = lastPromise.then(function() {\n return fn.apply(_this, args);\n });\n };\n return qqueue;\n };\n })(this),\n add: (function(_this) {\n return function(fn) {\n if (!lastPromise) {\n lastPromise = fn();\n } else {\n lastPromise = lastPromise.then(fn);\n }\n return qqueue;\n };\n })(this)\n };\n return qqueue;\n };\n\n module.factory(\"$tgQqueue\", [\"$q\", Qqueue]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/events.coffee\n */\n\n(function() {\n var EventsProvider, EventsService, bindMethods, module, startswith, taiga;\n\n taiga = this.taiga;\n\n startswith = this.taiga.startswith;\n\n bindMethods = this.taiga.bindMethods;\n\n module = angular.module(\"taigaEvents\", []);\n\n EventsService = (function() {\n function EventsService(win, log, config, auth) {\n this.win = win;\n this.log = log;\n this.config = config;\n this.auth = auth;\n bindMethods(this);\n }\n\n EventsService.prototype.initialize = function(sessionId) {\n this.sessionId = sessionId;\n this.subscriptions = {};\n this.connected = false;\n this.error = false;\n this.pendingMessages = [];\n if (this.win.WebSocket === void 0) {\n return this.log.info(\"WebSockets not supported on your browser\");\n }\n };\n\n EventsService.prototype.setupConnection = function() {\n var loc, path, scheme, url;\n this.stopExistingConnection();\n url = this.config.get(\"eventsUrl\");\n if (!url) {\n return;\n }\n if (!startswith(url, \"ws:\") && !startswith(url, \"wss:\")) {\n loc = this.win.location;\n scheme = loc.protocol === \"https:\" ? \"wss:\" : \"ws:\";\n path = _.str.ltrim(url, \"/\");\n url = \"\" + scheme + \"//\" + loc.host + \"/\" + path;\n }\n this.ws = new this.win.WebSocket(url);\n this.ws.addEventListener(\"open\", this.onOpen);\n this.ws.addEventListener(\"message\", this.onMessage);\n this.ws.addEventListener(\"error\", this.onError);\n return this.ws.addEventListener(\"close\", this.onClose);\n };\n\n EventsService.prototype.stopExistingConnection = function() {\n if (this.ws === void 0) {\n return;\n }\n this.ws.removeEventListener(\"open\", this.onOpen);\n this.ws.removeEventListener(\"close\", this.onClose);\n this.ws.removeEventListener(\"error\", this.onError);\n this.ws.removeEventListener(\"message\", this.onMessage);\n this.ws.close();\n return delete this.ws;\n };\n\n EventsService.prototype.serialize = function(message) {\n if (_.isObject(message)) {\n return JSON.stringify(message);\n }\n return message;\n };\n\n EventsService.prototype.sendMessage = function(message) {\n var messages, msg, _i, _len, _results;\n this.pendingMessages.push(message);\n if (!this.connected) {\n return;\n }\n messages = _.map(this.pendingMessages, this.serialize);\n this.pendingMessages = [];\n _results = [];\n for (_i = 0, _len = messages.length; _i < _len; _i++) {\n msg = messages[_i];\n _results.push(this.ws.send(msg));\n }\n return _results;\n };\n\n EventsService.prototype.subscribe = function(scope, routingKey, callback) {\n var message, subscription;\n if (this.error) {\n return;\n }\n this.log.debug(\"Subscribe to: \" + routingKey);\n subscription = {\n scope: scope,\n routingKey: routingKey,\n callback: _.debounce(callback, 500, {\n \"leading\": true,\n \"trailing\": false\n })\n };\n message = {\n \"cmd\": \"subscribe\",\n \"routing_key\": routingKey\n };\n this.subscriptions[routingKey] = subscription;\n this.sendMessage(message);\n return scope.$on(\"$destroy\", (function(_this) {\n return function() {\n return _this.unsubscribe(routingKey);\n };\n })(this));\n };\n\n EventsService.prototype.unsubscribe = function(routingKey) {\n var message;\n if (this.error) {\n return;\n }\n this.log.debug(\"Unsubscribe from: \" + routingKey);\n message = {\n \"cmd\": \"unsubscribe\",\n \"routing_key\": routingKey\n };\n return this.sendMessage(message);\n };\n\n EventsService.prototype.onOpen = function() {\n var message, token;\n this.connected = true;\n this.log.debug(\"WebSocket connection opened\");\n token = this.auth.getToken();\n message = {\n cmd: \"auth\",\n data: {\n token: token,\n sessionId: this.sessionId\n }\n };\n return this.sendMessage(message);\n };\n\n EventsService.prototype.onMessage = function(event) {\n var data, routingKey, subscription;\n this.log.debug(\"WebSocket message received: \" + event.data);\n data = JSON.parse(event.data);\n routingKey = data.routing_key;\n if (this.subscriptions[routingKey] == null) {\n return;\n }\n subscription = this.subscriptions[routingKey];\n return subscription.scope.$apply(function() {\n return subscription.callback(data.data);\n });\n };\n\n EventsService.prototype.onError = function(error) {\n this.log.error(\"WebSocket error: \" + error);\n return this.error = true;\n };\n\n EventsService.prototype.onClose = function() {\n this.log.debug(\"WebSocket closed.\");\n return this.connected = false;\n };\n\n return EventsService;\n\n })();\n\n EventsProvider = (function() {\n function EventsProvider() {}\n\n EventsProvider.prototype.setSessionId = function(sessionId) {\n return this.sessionId = sessionId;\n };\n\n EventsProvider.prototype.$get = function($win, $log, $conf, $auth) {\n var service;\n service = new EventsService($win, $log, $conf, $auth);\n service.initialize(this.sessionId);\n return service;\n };\n\n EventsProvider.prototype.$get.$inject = [\"$window\", \"$log\", \"$tgConfig\", \"$tgAuth\"];\n\n return EventsProvider;\n\n })();\n\n module.provider(\"$tgEvents\", EventsProvider);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/feedback.coffee\n */\n\n(function() {\n var FeedbackDirective, bindOnce, debounce, groupBy, mixOf, module, taiga, trim;\n\n taiga = this.taiga;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n mixOf = this.taiga.mixOf;\n\n debounce = this.taiga.debounce;\n\n trim = this.taiga.trim;\n\n module = angular.module(\"taigaFeedback\", []);\n\n FeedbackDirective = function($lightboxService, $repo, $confirm, $loading) {\n var link;\n link = function($scope, $el, $attrs) {\n var form, submit, submitButton;\n form = $el.find(\"form\").checksley();\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var promise;\n event.preventDefault();\n if (!form.validate()) {\n return;\n }\n $loading.start(submitButton);\n promise = $repo.create(\"feedback\", $scope.feedback);\n promise.then(function(data) {\n $loading.finish(submitButton);\n $lightboxService.close($el);\n return $confirm.notify(\"success\", \"\\\\o/ we'll be happy to read your\");\n });\n return promise.then(null, function() {\n $loading.finish(submitButton);\n return $confirm.notify(\"error\");\n });\n };\n })(this));\n submitButton = $el.find(\".submit-button\");\n $el.on(\"submit\", \"form\", submit);\n $el.on(\"click\", \".submit-button\", submit);\n $scope.$on(\"feedback:show\", function() {\n $scope.$apply(function() {\n return $scope.feedback = {};\n });\n $lightboxService.open($el);\n return $el.find(\"textarea\").focus();\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgLbFeedback\", [\"lightboxService\", \"$tgRepo\", \"$tgConfirm\", \"$tgLoading\", FeedbackDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/integrations.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaIntegrations\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/issues.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaIssues\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/kanban.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaKanban\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/locales.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaLocales\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/nav.coffee\n */\n\n(function() {\n var ProjectMenuDirective, ProjectsNavigationController, ProjectsNavigationDirective, bindOnce, groupBy, module, taiga, timeout,\n __hasProp = {}.hasOwnProperty,\n __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };\n\n taiga = this.taiga;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n timeout = this.taiga.timeout;\n\n module = angular.module(\"taigaNavMenu\", []);\n\n ProjectsNavigationController = (function(_super) {\n __extends(ProjectsNavigationController, _super);\n\n ProjectsNavigationController.$inject = [\"$scope\", \"$rootScope\", \"$tgResources\", \"$tgNavUrls\", \"$projectUrl\"];\n\n function ProjectsNavigationController(scope, rootscope, rs, navurls, projectUrl) {\n var promise;\n this.scope = scope;\n this.rootscope = rootscope;\n this.rs = rs;\n this.navurls = navurls;\n this.projectUrl = projectUrl;\n promise = this.loadInitialData();\n promise.then(null, function() {\n return console.log(\"FAIL\");\n });\n this.scope.$on(\"projects:reload\", (function(_this) {\n return function() {\n return _this.loadInitialData();\n };\n })(this));\n this.scope.$on(\"project:loaded\", (function(_this) {\n return function(ctx, project) {\n return _this.loadInitialData();\n };\n })(this));\n }\n\n ProjectsNavigationController.prototype.loadInitialData = function() {\n return this.rs.projects.list().then((function(_this) {\n return function(projects) {\n var project, _i, _len;\n for (_i = 0, _len = projects.length; _i < _len; _i++) {\n project = projects[_i];\n project.url = _this.projectUrl.get(project);\n }\n _this.scope.projects = projects;\n _this.scope.filteredProjects = projects;\n _this.scope.filterText = \"\";\n return projects;\n };\n })(this));\n };\n\n ProjectsNavigationController.prototype.newProject = function() {\n return this.scope.$apply((function(_this) {\n return function() {\n return _this.rootscope.$broadcast(\"projects:create\");\n };\n })(this));\n };\n\n ProjectsNavigationController.prototype.filterProjects = function(text) {\n this.scope.filteredProjects = _.filter(this.scope.projects, function(project) {\n return project.name.toLowerCase().indexOf(text) > -1;\n });\n this.scope.filterText = text;\n return this.rootscope.$broadcast(\"projects:filtered\");\n };\n\n return ProjectsNavigationController;\n\n })(taiga.Controller);\n\n module.controller(\"ProjectsNavigationController\", ProjectsNavigationController);\n\n ProjectsNavigationDirective = function($rootscope, animationFrame, $timeout, tgLoader, $location, $compile) {\n var baseTemplate, hideMenu, link, loadingStart, overlay, projectsTemplate;\n baseTemplate = _.template(\"
\\n\");\n getSectionName = function($el, sectionName, project) {\n var oldSectionName, _ref;\n oldSectionName = (_ref = $el.find(\"a.active\").parent().attr(\"id\")) != null ? _ref.replace(\"nav-\", \"\") : void 0;\n if (sectionName === \"backlog-kanban\") {\n if (oldSectionName === \"backlog\" || oldSectionName === \"kanban\") {\n sectionName = oldSectionName;\n } else if (project.is_backlog_activated && !project.is_kanban_activated) {\n sectionName = \"backlog\";\n } else if (!project.is_backlog_activated && project.is_kanban_activated) {\n sectionName = \"kanban\";\n }\n }\n return sectionName;\n };\n renderMainMenu = function($el) {\n var html;\n html = mainTemplate({});\n return $el.html(html);\n };\n renderMenuEntries = function($el, targetScope, project) {\n var container, ctx, dom, sectionName;\n if (project == null) {\n project = {};\n }\n container = $el.find(\".menu-container\");\n sectionName = getSectionName($el, targetScope.section, project);\n ctx = {\n user: $auth.getUser(),\n project: project,\n feedbackEnabled: $config.get(\"feedbackEnabled\")\n };\n dom = $compile(menuEntriesTemplate(ctx))(targetScope);\n dom.find(\"a.active\").removeClass(\"active\");\n dom.find(\"#nav-\" + sectionName + \" > a\").addClass(\"active\");\n return container.replaceWith(dom);\n };\n videoConferenceUrl = function(project) {\n var baseUrl, url;\n if (project.videoconferences === \"appear-in\") {\n baseUrl = \"https://appear.in/\";\n } else if (project.videoconferences === \"talky\") {\n baseUrl = \"https://talky.io/\";\n } else {\n return \"\";\n }\n if (project.videoconferences_salt) {\n url = \"\" + project.slug + \"-\" + project.videoconferences_salt;\n } else {\n url = \"\" + project.slug;\n }\n return baseUrl + url;\n };\n link = function($scope, $el, $attrs, $ctrl) {\n var project;\n renderMainMenu($el);\n project = null;\n $el.on(\"click\", \".logo\", function(event) {\n var target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n return $rootscope.$broadcast(\"nav:projects-list:open\");\n });\n $el.on(\"click\", \".user-settings .avatar\", function(event) {\n event.preventDefault();\n return $el.find(\".user-settings .popover\").popover().open();\n });\n $el.on(\"click\", \".logout\", function(event) {\n event.preventDefault();\n $auth.logout();\n return $scope.$apply(function() {\n return $location.path($navUrls.resolve(\"login\"));\n });\n });\n $el.on(\"click\", \"#nav-search > a\", function(event) {\n event.preventDefault();\n return $rootscope.$broadcast(\"search-box:show\", project);\n });\n $el.on(\"click\", \".feedback\", function(event) {\n event.preventDefault();\n return $rootscope.$broadcast(\"feedback:show\");\n });\n $scope.$on(\"projects:loaded\", function(listener) {\n $el.addClass(\"hidden\");\n return listener.stopPropagation();\n });\n return $scope.$on(\"project:loaded\", function(ctx, newProject) {\n project = newProject;\n if ($el.hasClass(\"hidden\")) {\n $el.removeClass(\"hidden\");\n }\n project.videoconferenceUrl = videoConferenceUrl(project);\n return renderMenuEntries($el, ctx.targetScope, project);\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgProjectMenu\", [\"$log\", \"$compile\", \"$tgAuth\", \"$rootScope\", \"$tgAuth\", \"$tgLocation\", \"$tgNavUrls\", \"$tgConfig\", ProjectMenuDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/projects.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaProject\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/related-tasks.coffee\n */\n\n(function() {\n var RelatedTaskAssignedToInlineEditionDirective, RelatedTaskCreateButtonDirective, RelatedTaskCreateFormDirective, RelatedTaskRowDirective, RelatedTasksDirective, debounce, module, taiga, trim;\n\n taiga = this.taiga;\n\n trim = this.taiga.trim;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaRelatedTasks\", []);\n\n RelatedTaskRowDirective = function($repo, $compile, $confirm, $rootscope, $loading) {\n var link, templateEdit, templateView;\n templateView = _.template(\"
\");\n newTask = {\n subject: \"\",\n assigned_to: null\n };\n link = function($scope, $el, $attrs) {\n var createTask, render;\n createTask = debounce(2000, function(task) {\n var promise;\n task.subject = $el.find('input').val();\n task.assigned_to = $scope.newTask.assigned_to;\n task.status = $scope.newTask.status;\n $scope.newTask.status = $scope.project.default_task_status;\n $scope.newTask.assigned_to = null;\n $loading.start($el.find('.task-name'));\n promise = $repo.create(\"tasks\", task);\n promise.then(function() {\n $analytics.trackEvent(\"task\", \"create\", \"create task on userstory\", 1);\n $loading.finish($el.find('.task-name'));\n $scope.$emit(\"related-tasks:add\");\n return $confirm.notify(\"success\");\n });\n promise.then(null, function() {\n $el.find('input').val(task.subject);\n $loading.finish($el.find('.task-name'));\n return $confirm.notify(\"error\");\n });\n return promise;\n });\n render = function() {\n $el.off();\n $el.html($compile(template())($scope));\n $el.find('input').focus().select();\n $el.addClass('active');\n $el.on(\"keyup\", \"input\", function(event) {\n if (event.keyCode === 13) {\n return createTask(newTask).then(function() {\n return render();\n });\n } else if (event.keyCode === 27) {\n return $el.html(\"\");\n }\n });\n $el.on(\"click\", \".icon-delete\", function(event) {\n return $el.html(\"\");\n });\n return $el.on(\"click\", \".icon-floppy\", function(event) {\n return createTask(newTask).then(function() {\n return $el.html(\"\");\n });\n });\n };\n taiga.bindOnce($scope, \"us\", function(val) {\n newTask[\"status\"] = $scope.project.default_task_status;\n newTask[\"project\"] = $scope.project.id;\n newTask[\"user_story\"] = $scope.us.id;\n $scope.newTask = $tgmodel.make_model(\"tasks\", newTask);\n return $el.html(\"\");\n });\n $scope.$on(\"related-tasks:show-form\", function() {\n return render();\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgRelatedTaskCreateForm\", [\"$tgRepo\", \"$compile\", \"$tgConfirm\", \"$tgModel\", \"$tgLoading\", \"$tgAnalytics\", RelatedTaskCreateFormDirective]);\n\n RelatedTaskCreateButtonDirective = function($repo, $compile, $confirm, $tgmodel) {\n var link, template;\n template = _.template(\"\");\n link = function($scope, $el, $attrs) {\n $scope.$watch(\"project\", function(val) {\n if (!val) {\n return;\n }\n $el.off();\n if ($scope.project.my_permissions.indexOf(\"add_task\") !== -1) {\n $el.html(template());\n } else {\n $el.html(\"\");\n }\n return $el.on(\"click\", \".icon\", function(event) {\n return $scope.$emit(\"related-tasks:add-new-clicked\");\n });\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgRelatedTaskCreateButton\", [\"$tgRepo\", \"$compile\", \"$tgConfirm\", \"$tgModel\", RelatedTaskCreateButtonDirective]);\n\n RelatedTasksDirective = function($repo, $rs, $rootscope) {\n var link;\n link = function($scope, $el, $attrs) {\n var loadTasks;\n loadTasks = function() {\n return $rs.tasks.list($scope.projectId, null, $scope.usId).then((function(_this) {\n return function(tasks) {\n $scope.tasks = tasks;\n return tasks;\n };\n })(this));\n };\n $scope.$on(\"related-tasks:add\", function() {\n return loadTasks().then(function() {\n return $rootscope.$broadcast(\"related-tasks:update\");\n });\n });\n $scope.$on(\"related-tasks:delete\", function() {\n return loadTasks().then(function() {\n return $rootscope.$broadcast(\"related-tasks:update\");\n });\n });\n $scope.$on(\"related-tasks:add-new-clicked\", function() {\n return $scope.$broadcast(\"related-tasks:show-form\");\n });\n taiga.bindOnce($scope, \"us\", function(val) {\n return loadTasks();\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgRelatedTasks\", [\"$tgRepo\", \"$tgResources\", \"$rootScope\", RelatedTasksDirective]);\n\n RelatedTaskAssignedToInlineEditionDirective = function($repo, $rootscope, popoverService) {\n var link, template;\n template = _.template(\"\\\" alt=\\\"<%- name %>\\\"/>\\n<%- name %>\");\n link = function($scope, $el, $attrs) {\n var $ctrl, autoSave, notAutoSave, task, updateRelatedTask;\n updateRelatedTask = function(task) {\n var ctx, member;\n ctx = {\n name: \"Unassigned\",\n imgurl: \"/images/unnamed.png\"\n };\n member = $scope.usersById[task.assigned_to];\n if (member) {\n ctx.imgurl = member.photo;\n ctx.name = member.full_name_display;\n }\n $el.find(\".avatar\").html(template(ctx));\n return $el.find(\".task-assignedto\").attr('title', ctx.name);\n };\n $ctrl = $el.controller();\n task = $scope.$eval($attrs.tgRelatedTaskAssignedToInlineEdition);\n notAutoSave = $scope.$eval($attrs.notAutoSave);\n autoSave = !notAutoSave;\n updateRelatedTask(task);\n $el.on(\"click\", \".task-assignedto\", function(event) {\n return $rootscope.$broadcast(\"assigned-to:add\", task);\n });\n taiga.bindOnce($scope, \"project\", function(project) {\n if (project.my_permissions.indexOf(\"modify_task\") === -1) {\n $el.unbind(\"click\");\n return $el.find(\"a\").addClass(\"not-clickable\");\n }\n });\n $scope.$on(\"assigned-to:added\", debounce(2000, (function(_this) {\n return function(ctx, userId, updatedRelatedTask) {\n if (updatedRelatedTask.id === task.id) {\n updatedRelatedTask.assigned_to = userId;\n if (autoSave) {\n $repo.save(updatedRelatedTask).then(function() {\n return $scope.$emit(\"related-tasks:assigned-to-changed\");\n });\n }\n return updateRelatedTask(updatedRelatedTask);\n }\n };\n })(this)));\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgRelatedTaskAssignedToInlineEdition\", [\"$tgRepo\", \"$rootScope\", RelatedTaskAssignedToInlineEditionDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources.coffee\n */\n\n(function() {\n var ResourcesService, initResources, initUrls, module, taiga, urls,\n __hasProp = {}.hasOwnProperty,\n __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };\n\n taiga = this.taiga;\n\n ResourcesService = (function(_super) {\n __extends(ResourcesService, _super);\n\n function ResourcesService() {\n return ResourcesService.__super__.constructor.apply(this, arguments);\n }\n\n return ResourcesService;\n\n })(taiga.Service);\n\n urls = {\n \"auth\": \"/auth\",\n \"auth-register\": \"/auth/register\",\n \"invitations\": \"/invitations\",\n \"permissions\": \"/permissions\",\n \"roles\": \"/roles\",\n \"projects\": \"/projects\",\n \"memberships\": \"/memberships\",\n \"notify-policies\": \"/notify-policies\",\n \"bulk-create-memberships\": \"/memberships/bulk_create\",\n \"milestones\": \"/milestones\",\n \"userstories\": \"/userstories\",\n \"bulk-create-us\": \"/userstories/bulk_create\",\n \"bulk-update-us-backlog-order\": \"/userstories/bulk_update_backlog_order\",\n \"bulk-update-us-sprint-order\": \"/userstories/bulk_update_sprint_order\",\n \"bulk-update-us-kanban-order\": \"/userstories/bulk_update_kanban_order\",\n \"userstories-restore\": \"/userstories/%s/restore\",\n \"tasks\": \"/tasks\",\n \"bulk-create-tasks\": \"/tasks/bulk_create\",\n \"bulk-update-task-taskboard-order\": \"/tasks/bulk_update_taskboard_order\",\n \"tasks-restore\": \"/tasks/%s/restore\",\n \"issues\": \"/issues\",\n \"bulk-create-issues\": \"/issues/bulk_create\",\n \"issues-restore\": \"/issues/%s/restore\",\n \"wiki\": \"/wiki\",\n \"wiki-restore\": \"/wiki/%s/restore\",\n \"wiki-links\": \"/wiki-links\",\n \"choices/userstory-statuses\": \"/userstory-statuses\",\n \"choices/userstory-statuses/bulk-update-order\": \"/userstory-statuses/bulk_update_order\",\n \"choices/points\": \"/points\",\n \"choices/points/bulk-update-order\": \"/points/bulk_update_order\",\n \"choices/task-statuses\": \"/task-statuses\",\n \"choices/task-statuses/bulk-update-order\": \"/task-statuses/bulk_update_order\",\n \"choices/issue-statuses\": \"/issue-statuses\",\n \"choices/issue-statuses/bulk-update-order\": \"/issue-statuses/bulk_update_order\",\n \"choices/issue-types\": \"/issue-types\",\n \"choices/issue-types/bulk-update-order\": \"/issue-types/bulk_update_order\",\n \"choices/priorities\": \"/priorities\",\n \"choices/priorities/bulk-update-order\": \"/priorities/bulk_update_order\",\n \"choices/severities\": \"/severities\",\n \"choices/severities/bulk-update-order\": \"/severities/bulk_update_order\",\n \"search\": \"/search\",\n \"sites\": \"/sites\",\n \"project-templates\": \"/project-templates\",\n \"site-members\": \"/site-members\",\n \"site-projects\": \"/site-projects\",\n \"users\": \"/users\",\n \"users-password-recovery\": \"/users/password_recovery\",\n \"users-change-password-from-recovery\": \"/users/change_password_from_recovery\",\n \"users-change-password\": \"/users/change_password\",\n \"users-change-email\": \"/users/change_email\",\n \"users-cancel-account\": \"/users/cancel\",\n \"user-storage\": \"/user-storage\",\n \"resolver\": \"/resolver\",\n \"userstory-statuses\": \"/userstory-statuses\",\n \"points\": \"/points\",\n \"task-statuses\": \"/task-statuses\",\n \"issue-statuses\": \"/issue-statuses\",\n \"issue-types\": \"/issue-types\",\n \"priorities\": \"/priorities\",\n \"severities\": \"/severities\",\n \"project-modules\": \"/projects/%s/modules\",\n \"history/us\": \"/history/userstory\",\n \"history/issue\": \"/history/issue\",\n \"history/task\": \"/history/task\",\n \"history/wiki\": \"/history/wiki\",\n \"attachments/us\": \"/userstories/attachments\",\n \"attachments/issue\": \"/issues/attachments\",\n \"attachments/task\": \"/tasks/attachments\",\n \"attachments/wiki_page\": \"/wiki/attachments\",\n \"feedback\": \"/feedback\"\n };\n\n initUrls = function($log, $urls) {\n $log.debug(\"Initialize api urls\");\n return $urls.update(urls);\n };\n\n initResources = function($log, $rs) {\n var provider, providers, _i, _len, _results;\n $log.debug(\"Initialize resources\");\n providers = _.toArray(arguments).slice(2);\n _results = [];\n for (_i = 0, _len = providers.length; _i < _len; _i++) {\n provider = providers[_i];\n _results.push(provider($rs));\n }\n return _results;\n };\n\n module = angular.module(\"taigaResources\", [\"taigaBase\"]);\n\n module.service(\"$tgResources\", ResourcesService);\n\n module.run([\"$log\", \"$tgUrls\", initUrls]);\n\n module.run([\"$log\", \"$tgResources\", \"$tgProjectsResourcesProvider\", \"$tgMembershipsResourcesProvider\", \"$tgNotifyPoliciesResourcesProvider\", \"$tgInvitationsResourcesProvider\", \"$tgRolesResourcesProvider\", \"$tgUserSettingsResourcesProvider\", \"$tgSprintsResourcesProvider\", \"$tgUserstoriesResourcesProvider\", \"$tgTasksResourcesProvider\", \"$tgIssuesResourcesProvider\", \"$tgWikiResourcesProvider\", \"$tgSearchResourcesProvider\", \"$tgAttachmentsResourcesProvider\", \"$tgMdRenderResourcesProvider\", \"$tgHistoryResourcesProvider\", \"$tgKanbanResourcesProvider\", \"$tgModulesResourcesProvider\", initResources]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/search.coffee\n */\n\n(function() {\n var SearchBoxDirective, SearchController, SearchDirective, bindOnce, debounce, debounceLeading, groupBy, mixOf, module, taiga, trim,\n __hasProp = {}.hasOwnProperty,\n __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };\n\n taiga = this.taiga;\n\n groupBy = this.taiga.groupBy;\n\n bindOnce = this.taiga.bindOnce;\n\n mixOf = this.taiga.mixOf;\n\n debounceLeading = this.taiga.debounceLeading;\n\n trim = this.taiga.trim;\n\n debounce = this.taiga.debounce;\n\n module = angular.module(\"taigaSearch\", []);\n\n SearchController = (function(_super) {\n __extends(SearchController, _super);\n\n SearchController.$inject = [\"$scope\", \"$tgRepo\", \"$tgResources\", \"$routeParams\", \"$q\", \"$tgLocation\", \"$appTitle\", \"$tgNavUrls\", \"tgLoader\"];\n\n function SearchController(scope, repo, rs, params, q, location, appTitle, navUrls, tgLoader) {\n var loadSearchData, promise;\n this.scope = scope;\n this.repo = repo;\n this.rs = rs;\n this.params = params;\n this.q = q;\n this.location = location;\n this.appTitle = appTitle;\n this.navUrls = navUrls;\n this.tgLoader = tgLoader;\n this.scope.sectionName = \"Search\";\n promise = this.loadInitialData();\n promise.then((function(_this) {\n return function() {\n return _this.appTitle.set(\"Search\");\n };\n })(this));\n promise.then(null, this.onInitialDataError.bind(this));\n this.scope.searchTerm = \"\";\n loadSearchData = debounceLeading(100, (function(_this) {\n return function(t) {\n return _this.loadSearchData(t);\n };\n })(this));\n this.scope.$watch(\"searchTerm\", (function(_this) {\n return function(term) {\n if (!term) {\n return _this.tgLoader.pageLoaded();\n } else {\n return loadSearchData(term);\n }\n };\n })(this));\n }\n\n SearchController.prototype.loadFilters = function() {\n var defered;\n defered = this.q.defer();\n defered.resolve();\n return defered.promise;\n };\n\n SearchController.prototype.loadProject = function() {\n return this.rs.projects.getBySlug(this.params.pslug).then((function(_this) {\n return function(project) {\n _this.scope.project = project;\n _this.scope.$emit('project:loaded', project);\n _this.scope.issueStatusById = groupBy(project.issue_statuses, function(x) {\n return x.id;\n });\n _this.scope.taskStatusById = groupBy(project.task_statuses, function(x) {\n return x.id;\n });\n _this.scope.severityById = groupBy(project.severities, function(x) {\n return x.id;\n });\n _this.scope.priorityById = groupBy(project.priorities, function(x) {\n return x.id;\n });\n _this.scope.membersById = groupBy(project.memberships, function(x) {\n return x.user;\n });\n _this.scope.usStatusById = groupBy(project.us_statuses, function(x) {\n return x.id;\n });\n return project;\n };\n })(this));\n };\n\n SearchController.prototype.loadSearchData = function(term) {\n var promise;\n promise = this.rs.search[\"do\"](this.scope.projectId, term).then((function(_this) {\n return function(data) {\n _this.scope.searchResults = data;\n return data;\n };\n })(this));\n promise[\"finally\"]((function(_this) {\n return function() {\n return _this.tgLoader.pageLoaded();\n };\n })(this));\n return promise;\n };\n\n SearchController.prototype.loadInitialData = function() {\n return this.loadProject().then((function(_this) {\n return function(project) {\n _this.scope.projectId = project.id;\n return _this.fillUsersAndRoles(project.users, project.roles);\n };\n })(this));\n };\n\n return SearchController;\n\n })(mixOf(taiga.Controller, taiga.PageMixin));\n\n module.controller(\"SearchController\", SearchController);\n\n SearchBoxDirective = function($lightboxService, $navurls, $location, $route) {\n var link;\n link = function($scope, $el, $attrs) {\n var project, submit;\n project = null;\n submit = debounce(2000, (function(_this) {\n return function(event) {\n var form, text, url;\n event.preventDefault();\n form = $el.find(\"form\").checksley();\n if (!form.validate()) {\n return;\n }\n text = $el.find(\"#search-text\").val();\n url = $navurls.resolve(\"project-search\", {\n project: project.slug\n });\n $lightboxService.close($el);\n return $scope.$apply(function() {\n $location.path(url);\n $location.search(\"text\", text).path(url);\n return $route.reload();\n });\n };\n })(this));\n $scope.$on(\"search-box:show\", function(ctx, newProject) {\n project = newProject;\n $lightboxService.open($el);\n return $el.find(\"#search-text\").val(\"\");\n });\n $el.on(\"submit\", \"form\", submit);\n return $el.on(\"click\", \".submit-button\", submit);\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgSearchBox\", [\"lightboxService\", \"$tgNavUrls\", \"$tgLocation\", \"$route\", SearchBoxDirective]);\n\n SearchDirective = function($log, $compile, $templatecache, $routeparams, $location) {\n var link, linkTable;\n linkTable = function($scope, $el, $attrs, $ctrl) {\n var getActiveSection, lastSeatchResults, markSectionTabActive, renderFilterTabs, renderTableContent, tabsDom, templates;\n tabsDom = $el.find(\"section.search-filter\");\n lastSeatchResults = null;\n getActiveSection = function(data) {\n var maxVal, name, selectedSectionData, selectedSectionName, value;\n maxVal = 0;\n selectedSectionName = null;\n selectedSectionData = null;\n for (name in data) {\n value = data[name];\n if (name === \"count\") {\n continue;\n }\n if (value.length > maxVal) {\n maxVal = value.length;\n selectedSectionName = name;\n selectedSectionData = value;\n }\n }\n if (maxVal === 0) {\n return {\n name: \"userstories\",\n value: []\n };\n }\n return {\n name: selectedSectionName,\n value: selectedSectionData\n };\n };\n renderFilterTabs = function(data) {\n var name, value, _results;\n _results = [];\n for (name in data) {\n value = data[name];\n if (name === \"count\") {\n continue;\n }\n _results.push(tabsDom.find(\"li.\" + name + \" .num\").html(value.length));\n }\n return _results;\n };\n markSectionTabActive = function(section) {\n tabsDom.find(\"a.active\").removeClass(\"active\");\n return tabsDom.find(\"li.\" + section.name + \" a\").addClass(\"active\");\n };\n templates = {\n issues: $templatecache.get(\"search-issues\"),\n tasks: $templatecache.get(\"search-tasks\"),\n userstories: $templatecache.get(\"search-userstories\"),\n wikipages: $templatecache.get(\"search-wikipages\")\n };\n renderTableContent = function(section) {\n var element, oldElements, oldScope, scope, template;\n oldElements = $el.find(\".search-result-table\").children();\n oldScope = oldElements.scope();\n if (oldScope) {\n oldScope.$destroy();\n oldElements.remove();\n }\n scope = $scope.$new();\n scope[section.name] = section.value;\n template = angular.element.parseHTML(trim(templates[section.name]));\n element = $compile(template)(scope);\n return $el.find(\".search-result-table\").html(element);\n };\n $scope.$watch(\"searchResults\", function(data) {\n var activeSection;\n lastSeatchResults = data;\n activeSection = getActiveSection(data);\n renderFilterTabs(data);\n renderTableContent(activeSection);\n return markSectionTabActive(activeSection);\n });\n $scope.$watch(\"searchTerm\", function(searchTerm) {\n if (searchTerm) {\n return $location.search(\"text\", searchTerm);\n }\n });\n return $el.on(\"click\", \".search-filter li > a\", function(event) {\n var section, sectionData, sectionName, target;\n event.preventDefault();\n target = angular.element(event.currentTarget);\n sectionName = target.parent().data(\"name\");\n sectionData = lastSeatchResults[sectionName];\n section = {\n name: sectionName,\n value: sectionData\n };\n return $scope.$apply(function() {\n renderTableContent(section);\n return markSectionTabActive(section);\n });\n });\n };\n link = function($scope, $el, $attrs) {\n var $ctrl, searchText;\n $ctrl = $el.controller();\n linkTable($scope, $el, $attrs, $ctrl);\n searchText = $routeparams.text;\n return $scope.$watch(\"projectId\", function(projectId) {\n if (projectId != null) {\n return $scope.searchTerm = searchText;\n }\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgSearch\", [\"$log\", \"$compile\", \"$templateCache\", \"$routeParams\", \"$tgLocation\", SearchDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/taskboard.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaTaskboard\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/tasks.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaTasks\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/team.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaTeam\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/user-settings.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaUserSettings\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/userstories.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaUserStories\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/wiki.coffee\n */\n\n(function() {\n var module;\n\n module = angular.module(\"taigaWiki\", []);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/analytics.coffee\n */\n\n(function() {\n var AnalyticsService, module, taiga,\n __hasProp = {}.hasOwnProperty,\n __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };\n\n taiga = this.taiga;\n\n module = angular.module(\"taigaCommon\");\n\n AnalyticsService = (function(_super) {\n __extends(AnalyticsService, _super);\n\n AnalyticsService.$inject = [\"$rootScope\", \"$log\", \"$tgConfig\", \"$window\", \"$document\", \"$location\"];\n\n function AnalyticsService(rootscope, log, config, win, doc, location) {\n var conf;\n this.rootscope = rootscope;\n this.log = log;\n this.config = config;\n this.win = win;\n this.doc = doc;\n this.location = location;\n this.initialized = false;\n conf = this.config.get(\"analytics\", {});\n this.accountId = conf.accountId;\n this.pageEvent = conf.pageEvent || \"$routeChangeSuccess\";\n this.trackRoutes = conf.trackRoutes || true;\n this.ignoreFirstPageLoad = conf.ignoreFirstPageLoad || false;\n }\n\n AnalyticsService.prototype.initialize = function() {\n if (!this.accountId) {\n this.log.debug(\"Analytics: no acount id provided. Disabling.\");\n return;\n }\n this.injectAnalytics();\n this.win.ga(\"create\", this.accountId, \"auto\");\n this.win.ga(\"require\", \"displayfeatures\");\n if (this.trackRoutes && (!this.ignoreFirstPageLoad)) {\n this.win.ga(\"send\", \"pageview\", this.getUrl());\n }\n if (this.trackRoutes) {\n this.rootscope.$on(this.pageEvent, (function(_this) {\n return function() {\n return _this.trackPage(_this.getUrl(), \"Taiga\");\n };\n })(this));\n }\n return this.initialized = true;\n };\n\n AnalyticsService.prototype.getUrl = function() {\n return this.location.path();\n };\n\n AnalyticsService.prototype.injectAnalytics = function() {\n var fn;\n fn = (function(i,s,o,g,r,a,m){i[\"GoogleAnalyticsObject\"]=r;i[r]=i[r]||function(){\n (i[r].q=i[r].q||[]).push(arguments);},i[r].l=1*new Date();a=s.createElement(o),\n m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m);});\n return fn(window, document, \"script\", \"//www.google-analytics.com/analytics.js\", \"ga\");\n };\n\n AnalyticsService.prototype.trackPage = function(url, title) {\n if (!this.initialized) {\n return;\n }\n if (!this.win.ga) {\n return;\n }\n title = title || this.doc[0].title;\n return this.win.ga(\"send\", \"pageview\", {\n \"page\": url,\n \"title\": title\n });\n };\n\n AnalyticsService.prototype.trackEvent = function(category, action, label, value) {\n if (!this.initialized) {\n return;\n }\n if (!this.win.ga) {\n return;\n }\n return this.win.ga(\"send\", \"event\", category, action, label, value);\n };\n\n return AnalyticsService;\n\n })(taiga.Service);\n\n module.service(\"$tgAnalytics\", AnalyticsService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/common/attachments.coffee\n */\n\n(function() {\n var AttachmentDirective, AttachmentsController, AttachmentsDirective, bindMethods, bindOnce, module, sizeFormat, taiga,\n __hasProp = {}.hasOwnProperty,\n __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };\n\n taiga = this.taiga;\n\n sizeFormat = this.taiga.sizeFormat;\n\n bindOnce = this.taiga.bindOnce;\n\n bindMethods = this.taiga.bindMethods;\n\n module = angular.module(\"taigaCommon\");\n\n AttachmentsController = (function(_super) {\n __extends(AttachmentsController, _super);\n\n AttachmentsController.$inject = [\"$scope\", \"$rootScope\", \"$tgRepo\", \"$tgResources\", \"$tgConfirm\", \"$q\"];\n\n function AttachmentsController(scope, rootscope, repo, rs, confirm, q) {\n this.scope = scope;\n this.rootscope = rootscope;\n this.repo = repo;\n this.rs = rs;\n this.confirm = confirm;\n this.q = q;\n bindMethods(this);\n this.type = null;\n this.objectId = null;\n this.projectId = null;\n this.uploadingAttachments = [];\n this.attachments = [];\n this.attachmentsCount = 0;\n this.deprecatedAttachmentsCount = 0;\n this.showDeprecated = false;\n }\n\n AttachmentsController.prototype.initialize = function(type, objectId) {\n this.type = type;\n this.objectId = objectId;\n return this.projectId = this.scope.projectId;\n };\n\n AttachmentsController.prototype.loadAttachments = function() {\n var urlname;\n if (!this.objectId) {\n return this.attachments;\n }\n urlname = \"attachments/\" + this.type;\n return this.rs.attachments.list(urlname, this.objectId, this.projectId).then((function(_this) {\n return function(attachments) {\n _this.attachments = _.sortBy(attachments, \"order\");\n _this.updateCounters();\n return attachments;\n };\n })(this));\n };\n\n AttachmentsController.prototype.updateCounters = function() {\n this.attachmentsCount = this.attachments.length;\n return this.deprecatedAttachmentsCount = _.filter(this.attachments, {\n is_deprecated: true\n }).length;\n };\n\n AttachmentsController.prototype._createAttachment = function(attachment) {\n var promise, urlName;\n urlName = \"attachments/\" + this.type;\n promise = this.rs.attachments.create(urlName, this.projectId, this.objectId, attachment);\n promise = promise.then((function(_this) {\n return function(data) {\n var index;\n data.isCreatedRightNow = true;\n index = _this.uploadingAttachments.indexOf(attachment);\n _this.uploadingAttachments.splice(index, 1);\n _this.attachments.push(data);\n return _this.rootscope.$broadcast(\"attachment:create\");\n };\n })(this));\n promise = promise.then(null, (function(_this) {\n return function(data) {\n var index;\n if (data.status === 413) {\n _this.scope.$emit(\"attachments:size-error\");\n }\n index = _this.uploadingAttachments.indexOf(attachment);\n _this.uploadingAttachments.splice(index, 1);\n _this.confirm.notify(\"error\", \"We have not been able to upload '\" + attachment.name + \"'. \" + data.data._error_message);\n return _this.q.reject(data);\n };\n })(this));\n return promise;\n };\n\n AttachmentsController.prototype.createAttachments = function(attachments) {\n var promises;\n promises = _.map(attachments, (function(_this) {\n return function(x) {\n return _this._createAttachment(x);\n };\n })(this));\n return this.q.all(promises).then((function(_this) {\n return function() {\n return _this.updateCounters();\n };\n })(this));\n };\n\n AttachmentsController.prototype.addUploadingAttachments = function(attachments) {\n return this.uploadingAttachments = _.union(this.uploadingAttachments, attachments);\n };\n\n AttachmentsController.prototype.reorderAttachment = function(attachment, newIndex) {\n var oldIndex;\n oldIndex = this.attachments.indexOf(attachment);\n if (oldIndex === newIndex) {\n return;\n }\n this.attachments.splice(oldIndex, 1);\n this.attachments.splice(newIndex, 0, attachment);\n return _.each(this.attachments, function(x, i) {\n return x.order = i + 1;\n });\n };\n\n AttachmentsController.prototype.updateAttachment = function(attachment) {\n var onError, onSuccess;\n onSuccess = (function(_this) {\n return function() {\n _this.updateCounters();\n return _this.rootscope.$broadcast(\"attachment:edit\");\n };\n })(this);\n onError = (function(_this) {\n return function(response) {\n if (response.status === 413) {\n $scope.$emit(\"attachments:size-error\");\n }\n _this.confirm.notify(\"error\");\n return _this.q.reject();\n };\n })(this);\n return this.repo.save(attachment).then(onSuccess, onError);\n };\n\n AttachmentsController.prototype.saveAttachments = function() {\n return this.repo.saveAll(this.attachments).then(null, (function(_this) {\n return function() {\n var item, _i, _len, _ref;\n _ref = _this.attachments;\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n item = _ref[_i];\n item.revert();\n }\n return _this.attachments = _.sorBy(_this.attachments, \"order\");\n };\n })(this));\n };\n\n AttachmentsController.prototype.removeAttachment = function(attachment) {\n var message, title;\n title = \"Delete attachment\";\n message = \"the attachment '\" + attachment.name + \"'\";\n return this.confirm.askOnDelete(title, message).then((function(_this) {\n return function(finish) {\n var onError, onSuccess;\n onSuccess = function() {\n var index;\n finish();\n index = _this.attachments.indexOf(attachment);\n _this.attachments.splice(index, 1);\n _this.updateCounters();\n return _this.rootscope.$broadcast(\"attachment:delete\");\n };\n onError = function() {\n finish(false);\n _this.confirm.notify(\"error\", null, \"We have not been able to delete \" + message + \".\");\n return _this.q.reject();\n };\n return _this.repo.remove(attachment).then(onSuccess, onError);\n };\n })(this));\n };\n\n AttachmentsController.prototype.filterAttachments = function(item) {\n if (this.showDeprecated) {\n return true;\n }\n return !item.is_deprecated;\n };\n\n return AttachmentsController;\n\n })(taiga.Controller);\n\n AttachmentsDirective = function($config, $confirm) {\n var link, template, templateFn;\n template = _.template(\"\\n
\");\n link = function($scope, $el, $attrs, $ctrls) {\n var render;\n render = function(projects) {\n $el.html($compile(template({\n projects: projects\n }))($scope));\n return $scope.$emit(\"regenerate:project-pagination\");\n };\n return $scope.$watch(\"projects\", function(projects) {\n if (projects != null) {\n return render(projects);\n }\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgProjectsList\", [\"$compile\", ProjectsListDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/bind.coffee\n */\n\n(function() {\n var BindHtmlDirective, BindOnceAltDirective, BindOnceBindDirective, BindOnceHrefDirective, BindOnceHtmlDirective, BindOnceRefDirective, BindOnceSrcDirective, BindOnceTitleDirective, BindTitleDirective, bindOnce, module;\n\n bindOnce = this.taiga.bindOnce;\n\n BindOnceBindDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, $attrs.tgBoBind, function(val) {\n return $el.text(val);\n });\n };\n return {\n link: link\n };\n };\n\n BindOnceHtmlDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, $attrs.tgBoHtml, function(val) {\n return $el.html(val);\n });\n };\n return {\n link: link\n };\n };\n\n BindOnceRefDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, $attrs.tgBoRef, function(val) {\n return $el.html(\"#\" + val + \" \");\n });\n };\n return {\n link: link\n };\n };\n\n BindOnceSrcDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, $attrs.tgBoSrc, function(val) {\n return $el.attr(\"src\", val);\n });\n };\n return {\n link: link\n };\n };\n\n BindOnceHrefDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, $attrs.tgBoHref, function(val) {\n return $el.attr(\"href\", val);\n });\n };\n return {\n link: link\n };\n };\n\n BindOnceAltDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, $attrs.tgBoAlt, function(val) {\n return $el.attr(\"alt\", val);\n });\n };\n return {\n link: link\n };\n };\n\n BindOnceTitleDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return bindOnce($scope, $attrs.tgBoTitle, function(val) {\n return $el.attr(\"title\", val);\n });\n };\n return {\n link: link\n };\n };\n\n BindTitleDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return $scope.$watch($attrs.tgTitleHtml, function(val) {\n if (val != null) {\n return $el.attr(\"title\", val);\n }\n });\n };\n return {\n link: link\n };\n };\n\n BindHtmlDirective = function() {\n var link;\n link = function($scope, $el, $attrs) {\n return $scope.$watch($attrs.tgBindHtml, function(val) {\n if (val != null) {\n return $el.html(val);\n }\n });\n };\n return {\n link: link\n };\n };\n\n module = angular.module(\"taigaBase\");\n\n module.directive(\"tgBoBind\", BindOnceBindDirective);\n\n module.directive(\"tgBoHtml\", BindOnceHtmlDirective);\n\n module.directive(\"tgBoRef\", BindOnceRefDirective);\n\n module.directive(\"tgBoSrc\", BindOnceSrcDirective);\n\n module.directive(\"tgBoHref\", BindOnceHrefDirective);\n\n module.directive(\"tgBoAlt\", BindOnceAltDirective);\n\n module.directive(\"tgBoTitle\", BindOnceTitleDirective);\n\n module.directive(\"tgBindTitle\", BindTitleDirective);\n\n module.directive(\"tgBindHtml\", BindHtmlDirective);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/conf.coffee\n */\n\n(function() {\n var ConfigurationService, defaults, module;\n\n defaults = {\n api: \"http://localhost:8000/api/v1/\",\n debug: true,\n lang: \"en\"\n };\n\n ConfigurationService = (function() {\n ConfigurationService.$inject = [\"localconf\"];\n\n function ConfigurationService(localconf) {\n this.config = _.merge(_.clone(defaults, true), localconf);\n }\n\n ConfigurationService.prototype.get = function(key, defaultValue) {\n if (defaultValue == null) {\n defaultValue = null;\n }\n if (_.has(this.config, key)) {\n return this.config[key];\n }\n return defaultValue;\n };\n\n return ConfigurationService;\n\n })();\n\n module = angular.module(\"taigaBase\");\n\n module.service(\"$tgConfig\", ConfigurationService);\n\n module.value(\"localconf\", null);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/filters.coffee\n */\n\n(function() {\n var FiltersStorageService, taiga,\n __hasProp = {}.hasOwnProperty,\n __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };\n\n taiga = this.taiga;\n\n FiltersStorageService = (function(_super) {\n __extends(FiltersStorageService, _super);\n\n FiltersStorageService.$inject = [\"$tgStorage\", \"$routeParams\"];\n\n function FiltersStorageService(storage, params) {\n this.storage = storage;\n this.params = params;\n }\n\n FiltersStorageService.prototype.generateHash = function(components) {\n if (components == null) {\n components = [];\n }\n components = _.map(components, function(x) {\n return JSON.stringify(x);\n });\n return hex_sha1(components.join(\":\"));\n };\n\n return FiltersStorageService;\n\n })(taiga.Service);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/http.coffee\n */\n\n(function() {\n var HttpService, module, taiga,\n __hasProp = {}.hasOwnProperty,\n __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };\n\n taiga = this.taiga;\n\n HttpService = (function(_super) {\n __extends(HttpService, _super);\n\n HttpService.$inject = [\"$http\", \"$q\", \"$tgStorage\"];\n\n HttpService.prototype.headers = function() {\n var token;\n token = this.storage.get('token');\n if (token) {\n return {\n \"Authorization\": \"Bearer \" + token\n };\n }\n return {};\n };\n\n function HttpService(http, q, storage) {\n this.http = http;\n this.q = q;\n this.storage = storage;\n HttpService.__super__.constructor.call(this);\n }\n\n HttpService.prototype.request = function(options) {\n options.headers = _.merge({}, options.headers || {}, this.headers());\n if (_.isPlainObject(options.data)) {\n options.data = JSON.stringify(options.data);\n }\n return this.http(options);\n };\n\n HttpService.prototype.get = function(url, params, options) {\n options = _.merge({\n method: \"GET\",\n url: url\n }, options);\n if (params) {\n options.params = params;\n }\n return this.request(options);\n };\n\n HttpService.prototype.post = function(url, data, params, options) {\n options = _.merge({\n method: \"POST\",\n url: url\n }, options);\n if (data) {\n options.data = data;\n }\n if (params) {\n options.params = params;\n }\n return this.request(options);\n };\n\n HttpService.prototype.put = function(url, data, params, options) {\n options = _.merge({\n method: \"PUT\",\n url: url\n }, options);\n if (data) {\n options.data = data;\n }\n if (params) {\n options.params = params;\n }\n return this.request(options);\n };\n\n HttpService.prototype.patch = function(url, data, params, options) {\n options = _.merge({\n method: \"PATCH\",\n url: url\n }, options);\n if (data) {\n options.data = data;\n }\n if (params) {\n options.params = params;\n }\n return this.request(options);\n };\n\n HttpService.prototype[\"delete\"] = function(url, data, params, options) {\n options = _.merge({\n method: \"DELETE\",\n url: url\n }, options);\n if (data) {\n options.data = data;\n }\n if (params) {\n options.params = params;\n }\n return this.request(options);\n };\n\n return HttpService;\n\n })(taiga.Service);\n\n module = angular.module(\"taigaBase\");\n\n module.service(\"$tgHttp\", HttpService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/i18n.coffee\n */\n\n(function() {\n var I18nDirective, I18nService, bindOnce, defaults, module, taiga,\n __hasProp = {}.hasOwnProperty,\n __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };\n\n taiga = this.taiga;\n\n bindOnce = this.taiga.bindOnce;\n\n defaults = {\n ns: \"app\",\n fallbackLng: \"en\",\n async: false,\n lng: \"en\"\n };\n\n I18nService = (function(_super) {\n __extends(I18nService, _super);\n\n function I18nService(rootscope, localesEn) {\n this.rootscope = rootscope;\n this.options = _.clone(defaults, true);\n this.options.resStore = {\n en: {\n app: localesEn\n }\n };\n }\n\n I18nService.prototype.setLanguage = function(language) {\n i18n.setLng(language);\n this.rootscope.currentLang = language;\n return this.rootscope.$broadcast(\"i18n:changeLang\", language);\n };\n\n I18nService.prototype.initialize = function() {\n i18n.init(this.options);\n return this.rootscope.t = i18n.t;\n };\n\n I18nService.prototype.t = function(path, opts) {\n return i18n.t(path, opts);\n };\n\n return I18nService;\n\n })(taiga.Service);\n\n I18nDirective = function($rootscope, $i18n) {\n var link;\n link = function($scope, $el, $attrs) {\n var ns, options, opts, v, values, _i, _len, _ref, _results;\n values = $attrs.tr.split(\",\");\n options = $attrs.trOpts || '{}';\n opts = $scope.$eval(options);\n _results = [];\n for (_i = 0, _len = values.length; _i < _len; _i++) {\n v = values[_i];\n if (v.indexOf(\":\") === -1) {\n _results.push($el.html(_.escape($i18n.t(v, opts))));\n } else {\n _ref = v.split(\":\"), ns = _ref[0], v = _ref[1];\n _results.push($el.attr(ns, _.escape($i18n.t(v, opts))));\n }\n }\n return _results;\n };\n return {\n link: link,\n restrict: \"A\",\n scope: false\n };\n };\n\n module = angular.module(\"taigaBase\");\n\n module.service(\"$tgI18n\", [\"$rootScope\", \"localesEn\", I18nService]);\n\n module.directive(\"tr\", [\"$rootScope\", \"$tgI18n\", I18nDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/location.coffee\n */\n\n(function() {\n var locationFactory, module;\n\n locationFactory = function($location, $route, $rootscope) {\n $location.noreload = function(scope) {\n var lastRoute, un;\n lastRoute = $route.current;\n un = scope.$on(\"$locationChangeSuccess\", function() {\n $route.current = lastRoute;\n return un();\n });\n return $location;\n };\n return $location;\n };\n\n module = angular.module(\"taigaBase\");\n\n module.factory(\"$tgLocation\", [\"$location\", \"$route\", \"$rootScope\", locationFactory]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/model.coffee\n */\n\n(function() {\n var Model, ModelService, module, provider, taiga,\n __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },\n __hasProp = {}.hasOwnProperty,\n __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };\n\n Model = (function() {\n function Model(name, data, dataTypes) {\n this._attrs = data;\n this._name = name;\n this._dataTypes = dataTypes;\n this.setAttrs(data);\n this.initialize();\n }\n\n Model.prototype.clone = function() {\n var instance;\n instance = new Model(this._name, this._attrs, this._dataTypes);\n instance._modifiedAttrs = this._modifiedAttrs;\n instance._isModified = this._isModified;\n return instance;\n };\n\n Model.prototype.applyCasts = function() {\n var attrName, castMethod, castName, _ref, _results;\n _ref = this._dataTypes;\n _results = [];\n for (attrName in _ref) {\n castName = _ref[attrName];\n castMethod = service.casts[castName];\n if (!castMethod) {\n continue;\n }\n _results.push(this._attrs[attrName] = castMethod(this._attrs[attrName]));\n }\n return _results;\n };\n\n Model.prototype.getIdAttrName = function() {\n return \"id\";\n };\n\n Model.prototype.getName = function() {\n return this._name;\n };\n\n Model.prototype.getAttrs = function(patch) {\n if (patch == null) {\n patch = false;\n }\n if (this._attrs.version != null) {\n this._modifiedAttrs.version = this._attrs.version;\n }\n if (patch) {\n return _.extend({}, this._modifiedAttrs);\n }\n return _.extend({}, this._attrs, this._modifiedAttrs);\n };\n\n Model.prototype.setAttrs = function(attrs) {\n this._attrs = attrs;\n this._modifiedAttrs = {};\n this.applyCasts();\n return this._isModified = false;\n };\n\n Model.prototype.setAttr = function(name, value) {\n this._modifiedAttrs[name] = value;\n return this._isModified = true;\n };\n\n Model.prototype.initialize = function() {\n var getter, self, setter;\n self = this;\n getter = function(name) {\n return function() {\n if (typeof name === 'string' && name.substr(0, 2) === \"__\") {\n return self[name];\n }\n if (__indexOf.call(_.keys(self._modifiedAttrs), name) < 0) {\n return self._attrs[name];\n }\n return self._modifiedAttrs[name];\n };\n };\n setter = function(name) {\n return function(value) {\n if (typeof name === 'string' && name.substr(0, 2) === \"__\") {\n self[name] = value;\n return;\n }\n if (self._attrs[name] !== value) {\n self._modifiedAttrs[name] = value;\n self._isModified = true;\n } else {\n delete self._modifiedAttrs[name];\n }\n };\n };\n return _.each(this._attrs, function(value, name) {\n var options;\n options = {\n get: getter(name),\n set: setter(name),\n enumerable: true,\n configurable: true\n };\n return Object.defineProperty(self, name, options);\n });\n };\n\n Model.prototype.serialize = function() {\n var data;\n data = {\n \"data\": _.clone(this._attrs),\n \"name\": this._name\n };\n return JSON.stringify(data);\n };\n\n Model.prototype.isModified = function() {\n return this._isModified;\n };\n\n Model.prototype.isAttributeModified = function(attribute) {\n return this._modifiedAttrs[attribute] != null;\n };\n\n Model.prototype.markSaved = function() {\n this._isModified = false;\n this._attrs = this.getAttrs();\n return this._modifiedAttrs = {};\n };\n\n Model.prototype.revert = function() {\n this._modifiedAttrs = {};\n return this._isModified = false;\n };\n\n Model.desSerialize = function(sdata) {\n var ddata, model;\n ddata = JSON.parse(sdata);\n model = new Model(ddata.url, ddata.data);\n return model;\n };\n\n return Model;\n\n })();\n\n taiga = this.taiga;\n\n ModelService = (function(_super) {\n __extends(ModelService, _super);\n\n ModelService.$inject = [\"$q\", \"$tgUrls\", \"$tgStorage\", \"$tgHttp\"];\n\n function ModelService(q, urls, storage, http) {\n this.q = q;\n this.urls = urls;\n this.storage = storage;\n this.http = http;\n ModelService.__super__.constructor.call(this);\n }\n\n return ModelService;\n\n })(taiga.Service);\n\n provider = function($q, $http, $gmUrls, $gmStorage) {\n var service;\n service = {};\n service.make_model = function(name, data, cls, dataTypes) {\n if (cls == null) {\n cls = Model;\n }\n if (dataTypes == null) {\n dataTypes = {};\n }\n return new cls(name, data, dataTypes);\n };\n service.cls = Model;\n service.casts = {\n int: function(value) {\n return parseInt(value, 10);\n },\n float: function(value) {\n return parseFloat(value, 10);\n }\n };\n return service;\n };\n\n module = angular.module(\"taigaBase\");\n\n module.factory(\"$tgModel\", [\"$q\", \"$http\", \"$tgUrls\", \"$tgStorage\", provider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/navurl.coffee\n */\n\n(function() {\n var NavigationUrlsDirective, NavigationUrlsService, bindOnce, module, taiga, trim,\n __hasProp = {}.hasOwnProperty,\n __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };\n\n taiga = this.taiga;\n\n trim = this.taiga.trim;\n\n bindOnce = this.taiga.bindOnce;\n\n module = angular.module(\"taigaBase\");\n\n NavigationUrlsService = (function(_super) {\n __extends(NavigationUrlsService, _super);\n\n function NavigationUrlsService() {\n this.urls = {};\n }\n\n NavigationUrlsService.prototype.update = function(urls) {\n return this.urls = _.merge({}, this.urls, urls || {});\n };\n\n NavigationUrlsService.prototype.formatUrl = function(url, ctx) {\n var replacer;\n if (ctx == null) {\n ctx = {};\n }\n replacer = function(match) {\n match = trim(match, \":\");\n return ctx[match] || \"undefined\";\n };\n return url.replace(/(:\\w+)/g, replacer);\n };\n\n NavigationUrlsService.prototype.resolve = function(name, ctx) {\n var url;\n url = this.urls[name];\n if (!url) {\n return \"\";\n }\n if (ctx) {\n return this.formatUrl(url, ctx);\n }\n return url;\n };\n\n return NavigationUrlsService;\n\n })(taiga.Service);\n\n module.service(\"$tgNavUrls\", NavigationUrlsService);\n\n NavigationUrlsDirective = function($navurls, $auth, $q, $location) {\n var bindOnceP, link, parseNav;\n bindOnceP = function($scope, attr) {\n var defered;\n defered = $q.defer();\n bindOnce($scope, attr, function(v) {\n return defered.resolve(v);\n });\n return defered.promise;\n };\n parseNav = function(data, $scope) {\n var name, params, promises, values, _ref;\n _ref = _.map(data.split(\":\"), trim), name = _ref[0], params = _ref[1];\n if (params) {\n params = _.map(params.split(\",\"), trim);\n } else {\n params = [];\n }\n values = _.map(params, function(x) {\n return trim(x.split(\"=\")[1]);\n });\n promises = _.map(values, function(x) {\n return bindOnceP($scope, x);\n });\n return $q.all(promises).then(function() {\n var item, key, options, value, _i, _len, _ref1;\n options = {};\n for (_i = 0, _len = params.length; _i < _len; _i++) {\n item = params[_i];\n _ref1 = _.map(item.split(\"=\"), trim), key = _ref1[0], value = _ref1[1];\n options[key] = $scope.$eval(value);\n }\n return [name, options];\n });\n };\n link = function($scope, $el, $attrs) {\n if ($el.is(\"a\")) {\n $el.attr(\"href\", \"#\");\n }\n $el.on(\"mouseenter\", function(event) {\n var target;\n target = $(event.currentTarget);\n if (!target.data(\"fullUrl\")) {\n return parseNav($attrs.tgNav, $scope).then(function(result) {\n var fullUrl, name, options, url, user;\n name = result[0], options = result[1];\n user = $auth.getUser();\n if (user) {\n options.user = user.username;\n }\n url = $navurls.resolve(name);\n fullUrl = $navurls.formatUrl(url, options);\n target.data(\"fullUrl\", fullUrl);\n if (target.is(\"a\")) {\n target.attr(\"href\", fullUrl);\n }\n return $el.on(\"click\", function(event) {\n event.preventDefault();\n target = $(event.currentTarget);\n if (target.hasClass('noclick')) {\n return;\n }\n fullUrl = target.data(\"fullUrl\");\n switch (event.which) {\n case 1:\n $location.url(fullUrl);\n return $scope.$apply();\n case 2:\n return window.open(fullUrl);\n }\n });\n });\n }\n });\n return $scope.$on(\"$destroy\", function() {\n return $el.off();\n });\n };\n return {\n link: link\n };\n };\n\n module.directive(\"tgNav\", [\"$tgNavUrls\", \"$tgAuth\", \"$q\", \"$tgLocation\", NavigationUrlsDirective]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/repository.coffee\n */\n\n(function() {\n var RepositoryService, module, taiga,\n __hasProp = {}.hasOwnProperty,\n __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };\n\n taiga = this.taiga;\n\n RepositoryService = (function(_super) {\n __extends(RepositoryService, _super);\n\n RepositoryService.$inject = [\"$q\", \"$tgModel\", \"$tgStorage\", \"$tgHttp\", \"$tgUrls\"];\n\n function RepositoryService(q, model, storage, http, urls) {\n this.q = q;\n this.model = model;\n this.storage = storage;\n this.http = http;\n this.urls = urls;\n RepositoryService.__super__.constructor.call(this);\n }\n\n RepositoryService.prototype.resolveUrlForModel = function(model) {\n var idAttrName;\n idAttrName = model.getIdAttrName();\n return \"\" + (this.urls.resolve(model.getName())) + \"/\" + model[idAttrName];\n };\n\n RepositoryService.prototype.resolveUrlForAttributeModel = function(model) {\n return this.urls.resolve(model.getName(), model.parent);\n };\n\n RepositoryService.prototype.create = function(name, data, dataTypes, extraParams) {\n var defered, promise, url;\n if (dataTypes == null) {\n dataTypes = {};\n }\n if (extraParams == null) {\n extraParams = {};\n }\n defered = this.q.defer();\n url = this.urls.resolve(name);\n promise = this.http.post(url, JSON.stringify(data));\n promise.success((function(_this) {\n return function(_data, _status) {\n return defered.resolve(_this.model.make_model(name, _data, null, dataTypes));\n };\n })(this));\n promise.error((function(_this) {\n return function(data, status) {\n return defered.reject(data);\n };\n })(this));\n return defered.promise;\n };\n\n RepositoryService.prototype.remove = function(model, params) {\n var defered, promise, url;\n if (params == null) {\n params = {};\n }\n defered = this.q.defer();\n url = this.resolveUrlForModel(model);\n promise = this.http[\"delete\"](url, {}, params);\n promise.success(function(data, status) {\n return defered.resolve(model);\n });\n promise.error(function(data, status) {\n return defered.reject(model);\n });\n return defered.promise;\n };\n\n RepositoryService.prototype.saveAll = function(models, patch) {\n var promises;\n if (patch == null) {\n patch = true;\n }\n promises = _.map(models, (function(_this) {\n return function(x) {\n return _this.save(x, true);\n };\n })(this));\n return this.q.all(promises);\n };\n\n RepositoryService.prototype.save = function(model, patch) {\n var data, defered, promise, url;\n if (patch == null) {\n patch = true;\n }\n defered = this.q.defer();\n if (!model.isModified() && patch) {\n defered.resolve(model);\n return defered.promise;\n }\n url = this.resolveUrlForModel(model);\n data = JSON.stringify(model.getAttrs(patch));\n if (patch) {\n promise = this.http.patch(url, data);\n } else {\n promise = this.http.put(url, data);\n }\n promise.success((function(_this) {\n return function(data, status) {\n model._isModified = false;\n model._attrs = _.extend(model.getAttrs(), data);\n model._modifiedAttrs = {};\n model.applyCasts();\n return defered.resolve(model);\n };\n })(this));\n promise.error(function(data, status) {\n return defered.reject(data);\n });\n return defered.promise;\n };\n\n RepositoryService.prototype.saveAttribute = function(model, attribute, patch) {\n var data, defered, promise, url;\n if (patch == null) {\n patch = true;\n }\n defered = this.q.defer();\n if (!model.isModified() && patch) {\n defered.resolve(model);\n return defered.promise;\n }\n url = this.resolveUrlForAttributeModel(model);\n data = {};\n data[attribute] = model.getAttrs();\n if (patch) {\n promise = this.http.patch(url, data);\n } else {\n promise = this.http.put(url, data);\n }\n promise.success((function(_this) {\n return function(data, status) {\n model._isModified = false;\n model._attrs = _.extend(model.getAttrs(), data);\n model._modifiedAttrs = {};\n model.applyCasts();\n return defered.resolve(model);\n };\n })(this));\n promise.error(function(data, status) {\n return defered.reject(data);\n });\n return defered.promise;\n };\n\n RepositoryService.prototype.refresh = function(model) {\n var defered, promise, url;\n defered = this.q.defer();\n url = this.resolveUrlForModel(model);\n promise = this.http.get(url);\n promise.success(function(data, status) {\n model._modifiedAttrs = {};\n model._attrs = data;\n model._isModified = false;\n model.applyCasts();\n return defered.resolve(model);\n });\n promise.error(function(data, status) {\n return defered.reject(data);\n });\n return defered.promise;\n };\n\n RepositoryService.prototype.queryMany = function(name, params, options) {\n var httpOptions, url;\n if (options == null) {\n options = {};\n }\n url = this.urls.resolve(name);\n httpOptions = {\n headers: {}\n };\n if (!options.enablePagination) {\n httpOptions.headers[\"x-disable-pagination\"] = \"1\";\n }\n return this.http.get(url, params, httpOptions).then((function(_this) {\n return function(data) {\n return _.map(data.data, function(x) {\n return _this.model.make_model(name, x);\n });\n };\n })(this));\n };\n\n RepositoryService.prototype.queryOneAttribute = function(name, id, attribute, params, options) {\n var httpOptions, url;\n if (options == null) {\n options = {};\n }\n url = this.urls.resolve(name, id);\n httpOptions = {\n headers: {}\n };\n if (!options.enablePagination) {\n httpOptions.headers[\"x-disable-pagination\"] = \"1\";\n }\n return this.http.get(url, params, httpOptions).then((function(_this) {\n return function(data) {\n var model;\n model = _this.model.make_model(name, data.data[attribute]);\n model.parent = id;\n return model;\n };\n })(this));\n };\n\n RepositoryService.prototype.queryOne = function(name, id, params, options) {\n var httpOptions, url;\n if (options == null) {\n options = {};\n }\n url = this.urls.resolve(name);\n if (id) {\n url = \"\" + url + \"/\" + id;\n }\n httpOptions = {\n headers: {}\n };\n if (!options.enablePagination) {\n httpOptions.headers[\"x-disable-pagination\"] = \"1\";\n }\n return this.http.get(url, params, httpOptions).then((function(_this) {\n return function(data) {\n return _this.model.make_model(name, data.data);\n };\n })(this));\n };\n\n RepositoryService.prototype.queryOneRaw = function(name, id, params, options) {\n var httpOptions, url;\n if (options == null) {\n options = {};\n }\n url = this.urls.resolve(name);\n if (id) {\n url = \"\" + url + \"/\" + id;\n }\n httpOptions = _.merge({\n headers: {}\n }, options);\n if (!options.enablePagination) {\n httpOptions.headers[\"x-disable-pagination\"] = \"1\";\n }\n return this.http.get(url, params, httpOptions).then((function(_this) {\n return function(data) {\n return data.data;\n };\n })(this));\n };\n\n RepositoryService.prototype.queryPaginated = function(name, params, options) {\n var httpOptions, url;\n if (options == null) {\n options = {};\n }\n url = this.urls.resolve(name);\n httpOptions = _.merge({\n headers: {}\n }, options);\n return this.http.get(url, params, httpOptions).then((function(_this) {\n return function(data) {\n var headers, result;\n headers = data.headers();\n result = {};\n result.models = _.map(data.data, function(x) {\n return _this.model.make_model(name, x);\n });\n result.count = parseInt(headers[\"x-pagination-count\"], 10);\n result.current = parseInt(headers[\"x-pagination-current\"] || 1, 10);\n result.paginatedBy = parseInt(headers[\"x-paginated-by\"], 10);\n return result;\n };\n })(this));\n };\n\n RepositoryService.prototype.resolve = function(options) {\n var cache, params;\n params = {};\n if (options.pslug != null) {\n params.project = options.pslug;\n }\n if (options.usref != null) {\n params.us = options.usref;\n }\n if (options.taskref != null) {\n params.task = options.taskref;\n }\n if (options.issueref != null) {\n params.issue = options.issueref;\n }\n if (options.sslug != null) {\n params.milestone = options.sslug;\n }\n if (options.wikipage != null) {\n params.wikipage = options.wikipage;\n }\n cache = !(options.wikipage || options.sslug);\n return this.queryOneRaw(\"resolver\", null, params, {\n cache: cache\n });\n };\n\n return RepositoryService;\n\n })(taiga.Service);\n\n module = angular.module(\"taigaBase\");\n\n module.service(\"$tgRepo\", RepositoryService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/storage.coffee\n */\n\n(function() {\n var StorageService, module, taiga,\n __hasProp = {}.hasOwnProperty,\n __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };\n\n taiga = this.taiga;\n\n StorageService = (function(_super) {\n __extends(StorageService, _super);\n\n StorageService.$inject = [\"$rootScope\"];\n\n function StorageService($rootScope) {\n StorageService.__super__.constructor.call(this);\n }\n\n StorageService.prototype.get = function(key, _default) {\n var serializedValue;\n serializedValue = localStorage.getItem(key);\n if (serializedValue === null) {\n return _default || null;\n }\n return JSON.parse(serializedValue);\n };\n\n StorageService.prototype.set = function(key, val) {\n if (_.isObject(key)) {\n return _.each(key, (function(_this) {\n return function(val, key) {\n return _this.set(key, val);\n };\n })(this));\n } else {\n return localStorage.setItem(key, JSON.stringify(val));\n }\n };\n\n StorageService.prototype.contains = function(key) {\n var value;\n value = this.get(key);\n return value !== null;\n };\n\n StorageService.prototype.remove = function(key) {\n return localStorage.removeItem(key);\n };\n\n StorageService.prototype.clear = function() {\n return localStorage.clear();\n };\n\n return StorageService;\n\n })(taiga.Service);\n\n module = angular.module(\"taigaBase\");\n\n module.service(\"$tgStorage\", StorageService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/base/http.coffee\n */\n\n(function() {\n var UrlsService, format, module, taiga,\n __hasProp = {}.hasOwnProperty,\n __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };\n\n format = function(fmt, obj) {\n obj = _.clone(obj);\n return fmt.replace(/%s/g, function(match) {\n return String(obj.shift());\n });\n };\n\n taiga = this.taiga;\n\n UrlsService = (function(_super) {\n __extends(UrlsService, _super);\n\n UrlsService.$inject = [\"$tgConfig\"];\n\n function UrlsService(config) {\n this.config = config;\n this.urls = {};\n this.mainUrl = config.get(\"api\");\n }\n\n UrlsService.prototype.update = function(urls) {\n return this.urls = _.merge(this.urls, urls);\n };\n\n UrlsService.prototype.resolve = function() {\n var args, name, url;\n args = _.toArray(arguments);\n if (args.length === 0) {\n throw Error(\"wrong arguments to setUrls\");\n }\n name = args.slice(0, 1)[0];\n url = format(this.urls[name], args.slice(1));\n return format(\"%s/%s\", [_.str.rtrim(this.mainUrl, \"/\"), _.str.ltrim(url, \"/\")]);\n };\n\n return UrlsService;\n\n })(taiga.Service);\n\n module = angular.module(\"taigaBase\");\n\n module.service('$tgUrls', UrlsService);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/attachments.coffee\n */\n\n(function() {\n var module, resourceProvider, sizeFormat, taiga;\n\n taiga = this.taiga;\n\n sizeFormat = this.taiga.sizeFormat;\n\n resourceProvider = function($rootScope, $config, $urls, $model, $repo, $auth, $q) {\n var service;\n service = {};\n service.list = function(urlName, objectId, projectId) {\n var params;\n params = {\n object_id: objectId,\n project: projectId\n };\n return $repo.queryMany(urlName, params);\n };\n service.create = function(urlName, projectId, objectId, file) {\n var data, defered, maxFileSize, response, uploadComplete, uploadFailed, uploadProgress, xhr;\n defered = $q.defer();\n if (file === void 0) {\n defered.reject(null);\n return defered.promise;\n }\n maxFileSize = $config.get(\"maxUploadFileSize\", null);\n if (maxFileSize && file.size > maxFileSize) {\n response = {\n status: 413,\n data: {\n _error_message: \"'\" + file.name + \"' (\" + (sizeFormat(file.size)) + \") is too heavy for our oompa loompas, try it with a smaller than (\" + (sizeFormat(maxFileSize)) + \")\"\n }\n };\n defered.reject(response);\n return defered.promise;\n }\n uploadProgress = (function(_this) {\n return function(evt) {\n return $rootScope.$apply(function() {\n file.status = \"in-progress\";\n file.size = sizeFormat(evt.total);\n file.progressMessage = \"upload \" + (sizeFormat(evt.loaded)) + \" of \" + (sizeFormat(evt.total));\n return file.progressPercent = \"\" + (Math.round((evt.loaded / evt.total) * 100)) + \"%\";\n });\n };\n })(this);\n uploadComplete = (function(_this) {\n return function(evt) {\n return $rootScope.$apply(function() {\n var data, model;\n file.status = \"done\";\n try {\n data = JSON.parse(evt.target.responseText);\n } catch (_error) {\n data = {};\n }\n model = $model.make_model(urlName, data);\n return defered.resolve(model);\n });\n };\n })(this);\n uploadFailed = (function(_this) {\n return function(evt) {\n return $rootScope.$apply(function() {\n file.status = \"error\";\n return defered.reject(\"fail\");\n });\n };\n })(this);\n data = new FormData();\n data.append(\"project\", projectId);\n data.append(\"object_id\", objectId);\n data.append(\"attached_file\", file);\n xhr = new XMLHttpRequest();\n xhr.upload.addEventListener(\"progress\", uploadProgress, false);\n xhr.addEventListener(\"load\", uploadComplete, false);\n xhr.addEventListener(\"error\", uploadFailed, false);\n xhr.open(\"POST\", $urls.resolve(urlName));\n xhr.setRequestHeader(\"Authorization\", \"Bearer \" + ($auth.getToken()));\n xhr.setRequestHeader('Accept', 'application/json');\n xhr.send(data);\n return defered.promise;\n };\n return function(instance) {\n return instance.attachments = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgAttachmentsResourcesProvider\", [\"$rootScope\", \"$tgConfig\", \"$tgUrls\", \"$tgModel\", \"$tgRepo\", \"$tgAuth\", \"$q\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/history.coffee\n */\n\n(function() {\n var module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n resourceProvider = function($repo, $http, $urls) {\n var service;\n service = {};\n service.get = function(type, objectId) {\n return $repo.queryOneRaw(\"history/\" + type, objectId);\n };\n service.deleteComment = function(type, objectId, activityId) {\n var params, url;\n url = $urls.resolve(\"history/\" + type);\n url = \"\" + url + \"/\" + objectId + \"/delete_comment\";\n params = {\n id: activityId\n };\n return $http.post(url, null, params).then((function(_this) {\n return function(data) {\n return data.data;\n };\n })(this));\n };\n service.undeleteComment = function(type, objectId, activityId) {\n var params, url;\n url = $urls.resolve(\"history/\" + type);\n url = \"\" + url + \"/\" + objectId + \"/undelete_comment\";\n params = {\n id: activityId\n };\n return $http.post(url, null, params).then((function(_this) {\n return function(data) {\n return data.data;\n };\n })(this));\n };\n return function(instance) {\n return instance.history = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgHistoryResourcesProvider\", [\"$tgRepo\", \"$tgHttp\", \"$tgUrls\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino \n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n * File: modules/resources/projects.coffee\n */\n\n(function() {\n var module, resourceProvider, taiga;\n\n taiga = this.taiga;\n\n resourceProvider = function($repo) {\n var service;\n service = {};\n service.get = function(token) {\n return $repo.queryOne(\"invitations\", token);\n };\n return function(instance) {\n return instance.invitations = service;\n };\n };\n\n module = angular.module(\"taigaResources\");\n\n module.factory(\"$tgInvitationsResourcesProvider\", [\"$tgRepo\", resourceProvider]);\n\n}).call(this);\n\n\n/*\n * Copyright (C) 2014 Andrey Antukh \n * Copyright (C) 2014 Jesús Espino Garcia \n * Copyright (C) 2014 David Barragán Merino