diff options
author | Luke Bennett <lukeeeebennettplus@gmail.com> | 2016-08-30 00:28:44 +0100 |
---|---|---|
committer | Luke Bennett <lukeeeebennettplus@gmail.com> | 2016-09-01 14:36:02 +0100 |
commit | 0ccdb41ced96c304658cf88b0869c5b78a4f15b7 (patch) | |
tree | f0d9d904cf9561a5abc695e8dfcf4dd3c4095a0c /app/assets/javascripts | |
parent | bd595eb82cd239c123818be9144258fdbaaae79c (diff) | |
download | gitlab-ce-0ccdb41ced96c304658cf88b0869c5b78a4f15b7.tar.gz |
Review changes, simplified dropdown init
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r-- | app/assets/javascripts/todos.js | 51 |
1 files changed, 10 insertions, 41 deletions
diff --git a/app/assets/javascripts/todos.js b/app/assets/javascripts/todos.js index ef1eadfb9c0..a908f730954 100644 --- a/app/assets/javascripts/todos.js +++ b/app/assets/javascripts/todos.js @@ -30,9 +30,9 @@ Todos.prototype.initFilters = function() { new UsersSelect(); - this.initProjectFilterDropdown(); - this.initTypeFilterDropdown(); - this.initActionFilterDropdown(); + this.initFilterDropdown($('.js-project-search'), 'project_id', true); + this.initFilterDropdown($('.js-type-search'), 'type'); + this.initFilterDropdown($('.js-action-search'), 'action_id'); $('form.filter-form').on('submit', function (event) { event.preventDefault(); @@ -40,47 +40,16 @@ }); }; - Todos.prototype.initProjectFilterDropdown = function() { - $projectDropdown = $('.js-project-search'); - $projectDropdown.glDropdown({ - filterable: true, + Todos.prototype.initFilterDropdown = function($dropdown, fieldName, isFilterable) { + $dropdown.glDropdown({ selectable: true, - fieldName: 'project_id', - data: $projectDropdown.data('data'), + filterable: isFilterable, + fieldName: fieldName, + data: $dropdown.data('data'), clicked: function() { - if ($projectDropdown.hasClass('js-filter-submit')) { - return $projectDropdown.closest('form.filter-form').submit(); - } + return $dropdown.closest('form.filter-form').submit(); } - }); - }; - - Todos.prototype.initTypeFilterDropdown = function() { - $typeDropdown = $('.js-type-search'); - $typeDropdown.glDropdown({ - selectable: true, - fieldName: 'type', - data: $typeDropdown.data('data'), - clicked: function() { - if ($typeDropdown.hasClass('js-filter-submit')) { - return $typeDropdown.closest('form.filter-form').submit(); - } - } - }); - }; - - Todos.prototype.initActionFilterDropdown = function() { - $actionDropdown = $('.js-action-search'); - $actionDropdown.glDropdown({ - selectable: true, - fieldName: 'action_id', - data: $actionDropdown.data('data'), - clicked: function() { - if ($actionDropdown.hasClass('js-filter-submit')) { - return $actionDropdown.closest('form.filter-form').submit(); - } - } - }); + }) }; Todos.prototype.doneClicked = function(e) { |