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';
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');
......
/* 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;
......@@ -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
......
......@@ -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')
......
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