summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgeoandri <geoandri@gmail.com>2017-03-29 14:47:34 +0300
committerGeorge Andrinopoulos <geoandri@gmail.com>2017-04-11 20:30:28 +0300
commitb6b83f3c50384c956950dedb6f55739c1605579e (patch)
treeb83452a8dfc115a31a01667df33122f45adf3716
parent0c3a0b6560912ad044a214dcfd74bca960a1fd24 (diff)
downloadgitlab-ce-b6b83f3c50384c956950dedb6f55739c1605579e.tar.gz
Refactor shortcuts_wiki.js
-rw-r--r--app/assets/javascripts/dispatcher.js1
-rw-r--r--app/assets/javascripts/shortcuts_wiki.js37
-rw-r--r--app/views/help/_shortcuts.html.haml2
-rw-r--r--spec/features/projects/wiki/shortcuts_spec.rb2
4 files changed, 13 insertions, 29 deletions
diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js
index d6a019333b7..d88b7cd0e17 100644
--- a/app/assets/javascripts/dispatcher.js
+++ b/app/assets/javascripts/dispatcher.js
@@ -47,6 +47,7 @@ import BlobLinePermalinkUpdater from './blob/blob_line_permalink_updater';
import BlobForkSuggestion from './blob/blob_fork_suggestion';
import UserCallout from './user_callout';
import { ProtectedTagCreate, ProtectedTagEditList } from './protected_tags';
+import ShortcutsWiki from './shortcuts_wiki';
const ShortcutsBlob = require('./shortcuts_blob');
diff --git a/app/assets/javascripts/shortcuts_wiki.js b/app/assets/javascripts/shortcuts_wiki.js
index f09215fdd6d..00d0d8f3a62 100644
--- a/app/assets/javascripts/shortcuts_wiki.js
+++ b/app/assets/javascripts/shortcuts_wiki.js
@@ -1,32 +1,15 @@
-/* eslint-disable func-names, space-before-function-paren, max-len, no-var, one-var, no-restricted-syntax, vars-on-top, no-use-before-define, no-param-reassign, new-cap, no-underscore-dangle, wrap-iife, one-var-declaration-per-line, quotes, prefer-arrow-callback, consistent-return, prefer-template, no-mixed-operators */
/* global Mousetrap */
/* global ShortcutsNavigation */
-require('mousetrap');
-require('./shortcuts_navigation');
+class ShortcutsWiki extends ShortcutsNavigation {
+ constructor() {
+ super();
+ Mousetrap.bind('e', this.editWiki);
+ }
-(function() {
- var extend = 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; },
- hasProp = {}.hasOwnProperty;
+ editWiki() {
+ this.gl.utils.visitUrl($('.wiki-edit').attr('href'));
+ }
+}
- this.ShortcutsWiki = (function(superClass) {
- extend(ShortcutsWiki, superClass);
-
- function ShortcutsWiki() {
- ShortcutsWiki.__super__.constructor.call(this);
- Mousetrap.bind('e', (function(_this) {
- return function() {
- _this.editWiki();
- return false;
- };
- })(this));
- }
-
- ShortcutsWiki.prototype.editWiki = function() {
- var $editBtn;
- $editBtn = $('.wiki-edit');
- return gl.utils.visitUrl($editBtn.attr('href'));
- };
- return ShortcutsWiki;
- })(ShortcutsNavigation);
-}).call(window);
+module.exports = ShortcutsWiki;
diff --git a/app/views/help/_shortcuts.html.haml b/app/views/help/_shortcuts.html.haml
index 83d03a82a9b..c6b4ba20b63 100644
--- a/app/views/help/_shortcuts.html.haml
+++ b/app/views/help/_shortcuts.html.haml
@@ -113,7 +113,7 @@
%td.shortcut
.key y
%td Go to file permalink
- %tbody.hidden-shortcut.merge_requests{ style: 'display:none' }
+ %tbody.hidden-shortcut.wiki{ style: 'display:none' }
%tr
%th
%th Wiki pages
diff --git a/spec/features/projects/wiki/shortcuts_spec.rb b/spec/features/projects/wiki/shortcuts_spec.rb
index add4b7f6190..c1f6b0cce3b 100644
--- a/spec/features/projects/wiki/shortcuts_spec.rb
+++ b/spec/features/projects/wiki/shortcuts_spec.rb
@@ -12,7 +12,7 @@ feature 'Wiki shortcuts', :feature, :js do
visit namespace_project_wiki_path(project.namespace, project, wiki_page)
end
- scenario 'Visit edit wiki page using "e" heyboard shortcut' do
+ scenario 'Visit edit wiki page using "e" keyboard shortcut' do
find('body').native.send_key('e')
expect(find('.wiki-page-title')).to have_content('Edit Page')