1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-08 23:15:29 +02:00

can press return on updated mousetrap lib

This commit is contained in:
Harvey Kandola 2016-06-22 11:57:10 -07:00
parent 038e916db1
commit f53b911e50
5 changed files with 51 additions and 26 deletions

View file

@ -44,7 +44,7 @@
> .action { > .action {
float: right; float: right;
vertical-align: text-top; margin-top: -8px;
@extend .cursor-pointer; @extend .cursor-pointer;
display: none; display: none;
color: $color-stroke; color: $color-stroke;

View file

@ -37,7 +37,7 @@
> .dropdown-dialog { > .dropdown-dialog {
@extend .clearfix; @extend .clearfix;
.content { .content {
> p { > p {
margin: 7px 0; margin: 7px 0;
font-size: 0.9em; font-size: 0.9em;
@ -48,7 +48,7 @@
} }
} }
> .actions { .actions {
margin-top: 15px; margin-top: 15px;
float: right; float: right;
} }

View file

@ -1,21 +1,23 @@
<div id="{{contentId}}" class="dropdown-dialog"> <div id="{{contentId}}" class="dropdown-dialog">
<div class="content"> <form class="form" {{action 'onAction' on="submit"}}>
{{yield}} <div class="content">
</div> {{yield}}
<div class="actions"> </div>
{{#if showCancel}} <div class="actions">
<div class="flat-button" {{action 'onCancel'}}> {{#if showCancel}}
cancel <div class="flat-button" {{action 'onCancel'}}>
</div> cancel
{{/if}} </div>
{{#if hasSecondButton}} {{/if}}
<div class="flat-button {{color2}}" {{action 'onAction2'}}> {{#if hasSecondButton}}
{{button2}} <div class="flat-button {{color2}}" {{action 'onAction2'}}>
{{button2}}
</div>
{{/if}}
<div class="flat-button {{color}}" {{action 'onAction'}}>
{{button}}
</div> </div>
{{/if}} </div>
<div class="flat-button {{color}}" {{action 'onAction'}}> <div class="clearfix"></div>
{{button}} </form>
</div>
</div>
<div class="clearfix"></div>
</div> </div>

View file

@ -9,7 +9,7 @@
<div class="input-control"> <div class="input-control">
<label>New space</label> <label>New space</label>
<div class="tip">A repository for related documentation</div> <div class="tip">A repository for related documentation</div>
{{input type='text' id="new-folder-name" value=newFolder}} {{input type='text' id="new-folder-name" class="mousetrap" value=newFolder}}
</div> </div>
</div> </div>
{{/dropdown-dialog}} {{/dropdown-dialog}}

View file

@ -1,6 +1,6 @@
/*global define:false */ /*global define:false */
/** /**
* Copyright 2015 Craig Campbell * Copyright 2016 Craig Campbell
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,11 +17,16 @@
* Mousetrap is a simple keyboard shortcut library for Javascript with * Mousetrap is a simple keyboard shortcut library for Javascript with
* no external dependencies * no external dependencies
* *
* @version 1.5.2 * @version 1.6.0
* @url craig.is/killing/mice * @url craig.is/killing/mice
*/ */
(function(window, document, undefined) { (function(window, document, undefined) {
// Check if mousetrap is used inside browser, if not, return
if (!window) {
return;
}
/** /**
* mapping of special keycodes to their corresponding keys * mapping of special keycodes to their corresponding keys
* *
@ -151,7 +156,13 @@
* loop through to map numbers on the numeric keypad * loop through to map numbers on the numeric keypad
*/ */
for (i = 0; i <= 9; ++i) { for (i = 0; i <= 9; ++i) {
_MAP[i + 96] = i;
// This needs to use a string cause otherwise since 0 is falsey
// mousetrap will never fire for numpad 0 pressed as part of a keydown
// event.
//
// @see https://github.com/ccampbell/mousetrap/pull/258
_MAP[i + 96] = i.toString();
} }
/** /**
@ -983,6 +994,18 @@
return self._handleKey.apply(self, arguments); return self._handleKey.apply(self, arguments);
}; };
/**
* allow custom key mappings
*/
Mousetrap.addKeycodes = function(object) {
for (var key in object) {
if (object.hasOwnProperty(key)) {
_MAP[key] = object[key];
}
}
_REVERSE_MAP = null;
};
/** /**
* Init the global mousetrap functions * Init the global mousetrap functions
* *
@ -1018,4 +1041,4 @@
return Mousetrap; return Mousetrap;
}); });
} }
}) (window, document); }) (typeof window !== 'undefined' ? window : null, typeof window !== 'undefined' ? document : null);