diff options
author | Fatih Acet <acetfatih@gmail.com> | 2016-07-14 14:32:36 +0000 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2016-07-14 14:32:36 +0000 |
commit | bb8e39cf533591fdd01b69f045ce7c043f37f2ae (patch) | |
tree | 2785b7bb99991bf83948de8667abc7cda6cd5ad9 /app | |
parent | 7458892c32ca0d74db97c3d529bf8c805bac733f (diff) | |
parent | e0f3b66c38e574e084e0448a7fdd5430ba58fbda (diff) | |
download | gitlab-ce-bb8e39cf533591fdd01b69f045ce7c043f37f2ae.tar.gz |
Merge branch 'lbennett/gitlab-ce-18120-focus-filter-shortcut' into 'master'
Added shortcut to focus filters
## What does this MR do?
Adds shortcut `f` to focus filter inputs.
## Are there points in the code the reviewer needs to double check?
Is this a valid implementation?
Please check [this comment below](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/4570#note_12359978)!
## Why was this MR needed?
Keyboard ninja UX :crossed_swords:
## What are the relevant issue numbers?
Closes #18120.
## Screenshots (if relevant)
![Screen_Shot_2016-06-09_at_18.34.56](/uploads/d4cfb6ec340c118f5227be3f16ffbed1/Screen_Shot_2016-06-09_at_18.34.56.png)
## Does this MR meet the acceptance criteria?
- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [ ] API support added
- [ ] Tests
- [ ] Added for this feature/bug
- [ ] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)
See merge request !4763
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/issuable.js.coffee | 4 | ||||
-rw-r--r-- | app/assets/javascripts/projects_list.js.coffee | 11 | ||||
-rw-r--r-- | app/assets/javascripts/shortcuts.js.coffee | 13 | ||||
-rw-r--r-- | app/views/help/_shortcuts.html.haml | 4 |
4 files changed, 20 insertions, 12 deletions
diff --git a/app/assets/javascripts/issuable.js.coffee b/app/assets/javascripts/issuable.js.coffee index c71d4ecf505..7f795f8096b 100644 --- a/app/assets/javascripts/issuable.js.coffee +++ b/app/assets/javascripts/issuable.js.coffee @@ -32,13 +32,11 @@ issuable_created = false $search = $('#issue_search') $form = $('.js-filter-form') $input = $("input[name='#{$search.attr('name')}']", $form) - if $input.length is 0 $form.append "<input type='hidden' name='#{$search.attr('name')}' value='#{_.escape($search.val())}'/>" else $input.val $search.val() - - Issuable.filterResults $form + Issuable.filterResults $form if $search.val() isnt '' , 500) initLabelFilterRemove: -> diff --git a/app/assets/javascripts/projects_list.js.coffee b/app/assets/javascripts/projects_list.js.coffee index e4c4bf3b273..a7d78d9e461 100644 --- a/app/assets/javascripts/projects_list.js.coffee +++ b/app/assets/javascripts/projects_list.js.coffee @@ -5,13 +5,12 @@ this.initPagination() initSearch: -> - @timer = null - $(".projects-list-filter").on('keyup', -> - clearTimeout(@timer) - @timer = setTimeout(ProjectsList.filterResults, 500) - ) + projectsListFilter = $('.projects-list-filter') + debounceFilter = _.debounce ProjectsList.filterResults, 500 + projectsListFilter.on 'keyup', (e) -> + debounceFilter() if projectsListFilter.val() isnt '' - filterResults: => + filterResults: -> $('.projects-list-holder').fadeTo(250, 0.5) form = null diff --git a/app/assets/javascripts/shortcuts.js.coffee b/app/assets/javascripts/shortcuts.js.coffee index 3319a67a79d..8c8689bacee 100644 --- a/app/assets/javascripts/shortcuts.js.coffee +++ b/app/assets/javascripts/shortcuts.js.coffee @@ -2,9 +2,10 @@ class @Shortcuts constructor: (skipResetBindings) -> @enabledHelp = [] Mousetrap.reset() if not skipResetBindings - Mousetrap.bind('?', @onToggleHelp) - Mousetrap.bind('s', Shortcuts.focusSearch) - Mousetrap.bind(['ctrl+shift+p', 'command+shift+p'], @toggleMarkdownPreview) + Mousetrap.bind '?', @onToggleHelp + Mousetrap.bind 's', Shortcuts.focusSearch + Mousetrap.bind 'f', (e) => @focusFilter e + Mousetrap.bind ['ctrl+shift+p', 'command+shift+p'], @toggleMarkdownPreview Mousetrap.bind('t', -> Turbolinks.visit(findFileURL)) if findFileURL? onToggleHelp: (e) => @@ -32,10 +33,16 @@ class @Shortcuts $('.js-more-help-button').remove() ) + focusFilter: (e) -> + @filterInput ?= $('input[type=search]', '.nav-controls') + @filterInput.focus() + e.preventDefault() + @focusSearch: (e) -> $('#search').focus() e.preventDefault() + $(document).on 'click.more_help', '.js-more-help-button', (e) -> $(@).remove() $('.hidden-shortcut').show() diff --git a/app/views/help/_shortcuts.html.haml b/app/views/help/_shortcuts.html.haml index 8cc0b59edeb..ce4536ebdc6 100644 --- a/app/views/help/_shortcuts.html.haml +++ b/app/views/help/_shortcuts.html.haml @@ -20,6 +20,10 @@ %td Focus Search %tr %td.shortcut + .key f + %td Focus Filter + %tr + %td.shortcut .key ? %td Show/hide this dialog %tr |