Skip to content

Commit

Permalink
Explicti imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Carreau committed Apr 13, 2016
1 parent cb1314f commit 702802b
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions notebook/static/notebook/js/shortcuts_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import QH from "notebook/js/quickhelp";
import dialog from "base/js/dialog";
import preact from "preact";
import preactCompat from "preact-compat";
import {render} from "preact";
import {createElement, createClass} from "preact-compat";

/**
* Humanize the action name to be consumed by user.
Expand All @@ -23,7 +23,7 @@ const humanize_action_id = function(str) {
* Wether an action have a keybinding or not.
**/

const KeyBinding = preactCompat.createClass({
const KeyBinding = createClass({
displayName: 'KeyBindings',
getInitialState: function() {
return {shrt:''};
Expand All @@ -35,32 +35,32 @@ const KeyBinding = preactCompat.createClass({
const that = this;
const av = this.props.available(this.state.shrt);
const empty = this.state.shrt === '';
return preactCompat.createElement('div',{style:{borderBottom: '1px solid gray'}, className:'jupyter-keybindings'},
return createElement('div',{style:{borderBottom: '1px solid gray'}, className:'jupyter-keybindings'},
this.props.shortcut?
preactCompat.createElement('i', {className: "pull-right fa fa-times", alt: 'remove title'+this.props.shortcut,
createElement('i', {className: "pull-right fa fa-times", alt: 'remove title'+this.props.shortcut,
onClick:()=>{
that.props.unbind(this.props.rawshrt);
}}):
preactCompat.createElement('i', {className: "pull-right fa fa-plus", alt: 'add-keyboard-shortcut',
createElement('i', {className: "pull-right fa fa-plus", alt: 'add-keyboard-shortcut',
onClick:()=>{
av?that.props.onAddBindings(that.state.shrt, that.props.ckey):null;
}
}),
this.props.shortcut? null:
preactCompat.createElement('input', {
createElement('input', {
type:'text',
placeholder:'add shortcut',
className:'pull-right'+((av||empty)?'':' alert alert-danger'),
value:this.state.shrt,
onChange:this.handleShrtChange
}),
this.props.shortcut? preactCompat.createElement('span', {className: 'pull-right'}, preactCompat.createElement('kbd', {}, this.props.shortcut)): null,
preactCompat.createElement('div', {title: '(' +this.props.ckey + ')' , className:'jupyter-keybindings-text'}, this.props.display )
this.props.shortcut? createElement('span', {className: 'pull-right'}, createElement('kbd', {}, this.props.shortcut)): null,
createElement('div', {title: '(' +this.props.ckey + ')' , className:'jupyter-keybindings-text'}, this.props.display )
);
}
});

const KeyBindingList = preactCompat.createClass({
const KeyBindingList = createClass({
displayName: 'KeyBindingList',
getInitialState: function(){
return {data:[]};
Expand All @@ -70,7 +70,7 @@ const KeyBindingList = preactCompat.createClass({
},
render: function() {
const childrens = this.state.data.map((binding)=>{
return preactCompat.createElement(KeyBinding, Object.assign({}, binding, {onAddBindings:(shortcut, action)=>{
return createElement(KeyBinding, Object.assign({}, binding, {onAddBindings:(shortcut, action)=>{
this.props.bind(shortcut, action);
this.setState({data:this.props.callback()});
},
Expand All @@ -82,14 +82,14 @@ const KeyBindingList = preactCompat.createClass({
}));
});

childrens.unshift(preactCompat.createElement('div', {className:'alert alert-info', key:'disclamer'},
childrens.unshift(createElement('div', {className:'alert alert-info', key:'disclamer'},
"This dialog shoudl allow you to modify your keymap, and persist the changes."+
"This functionality is not feature complete, and will likely not function in all the cases."+
"You can define many type of shorctuts or sequence of keys. Here are various valid shortcuts sequences: a,a"+
"-- Shift-A,Shift-B -- Shift-A,a -- "+
"Casing will have no effect, you need to explicitelty write the `Shift` modifier,"+
" `Cmd`, `Ctrl`, `Meta`, `Cmdtrl` are various valid modifier. Refer to developper docs for their signification depending on teh platform"));
return preactCompat.createElement('div',{}, childrens);
return createElement('div',{}, childrens);
}
});

Expand Down Expand Up @@ -141,8 +141,8 @@ export const ShortcutEditor = function(notebook) {
mod.addClass("modal_stretch");

mod.modal('show');
preactCompat.render(
preactCompat.createElement(KeyBindingList, {
render(
createElement(KeyBindingList, {
callback:()=>{ return get_shortcuts_data(notebook);},
bind: (shortcut, command) => {
return notebook.keyboard_manager.command_shortcuts._persist_shortcut(shortcut, command);
Expand Down

0 comments on commit 702802b

Please sign in to comment.