Commit b6b83f3c authored by geoandri's avatar geoandri Committed by George Andrinopoulos

Refactor shortcuts_wiki.js

parent 0c3a0b65
...@@ -47,6 +47,7 @@ import BlobLinePermalinkUpdater from './blob/blob_line_permalink_updater'; ...@@ -47,6 +47,7 @@ import BlobLinePermalinkUpdater from './blob/blob_line_permalink_updater';
import BlobForkSuggestion from './blob/blob_fork_suggestion'; import BlobForkSuggestion from './blob/blob_fork_suggestion';
import UserCallout from './user_callout'; import UserCallout from './user_callout';
import { ProtectedTagCreate, ProtectedTagEditList } from './protected_tags'; import { ProtectedTagCreate, ProtectedTagEditList } from './protected_tags';
import ShortcutsWiki from './shortcuts_wiki';
const ShortcutsBlob = require('./shortcuts_blob'); const ShortcutsBlob = require('./shortcuts_blob');
......
/* 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 Mousetrap */
/* global ShortcutsNavigation */ /* global ShortcutsNavigation */
require('mousetrap'); class ShortcutsWiki extends ShortcutsNavigation {
require('./shortcuts_navigation'); constructor() {
super();
(function() { Mousetrap.bind('e', this.editWiki);
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;
this.ShortcutsWiki = (function(superClass) {
extend(ShortcutsWiki, superClass);
function ShortcutsWiki() { editWiki() {
ShortcutsWiki.__super__.constructor.call(this); this.gl.utils.visitUrl($('.wiki-edit').attr('href'));
Mousetrap.bind('e', (function(_this) {
return function() {
_this.editWiki();
return false;
};
})(this));
} }
}
ShortcutsWiki.prototype.editWiki = function() { module.exports = ShortcutsWiki;
var $editBtn;
$editBtn = $('.wiki-edit');
return gl.utils.visitUrl($editBtn.attr('href'));
};
return ShortcutsWiki;
})(ShortcutsNavigation);
}).call(window);
...@@ -113,7 +113,7 @@ ...@@ -113,7 +113,7 @@
%td.shortcut %td.shortcut
.key y .key y
%td Go to file permalink %td Go to file permalink
%tbody.hidden-shortcut.merge_requests{ style: 'display:none' } %tbody.hidden-shortcut.wiki{ style: 'display:none' }
%tr %tr
%th %th
%th Wiki pages %th Wiki pages
......
...@@ -12,7 +12,7 @@ feature 'Wiki shortcuts', :feature, :js do ...@@ -12,7 +12,7 @@ feature 'Wiki shortcuts', :feature, :js do
visit namespace_project_wiki_path(project.namespace, project, wiki_page) visit namespace_project_wiki_path(project.namespace, project, wiki_page)
end 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') find('body').native.send_key('e')
expect(find('.wiki-page-title')).to have_content('Edit Page') expect(find('.wiki-page-title')).to have_content('Edit Page')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment