diff --git a/app/app/components/document/document-heading.js b/app/app/components/document/document-heading.js index cbb4f954..2f4998f2 100644 --- a/app/app/components/document/document-heading.js +++ b/app/app/components/document/document-heading.js @@ -22,18 +22,27 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { editMode: false, docName: '', docExcerpt: '', - hasNameError: computed.empty('docName'), hasExcerptError: computed.empty('docExcerpt'), + keyUp(e) { + if (e.keyCode === 27) { // escape key + this.send('onCancel'); + } + }, + actions: { toggleEdit() { this.set('docName', this.get('document.name')); this.set('docExcerpt', this.get('document.excerpt')); this.set('editMode', true); + + Ember.run.schedule('afterRender', () => { + $('#document-name').select(); + }); }, - onSaveDocument() { + onSave() { if (this.get('hasNameError') || this.get('hasExcerptError')) { return; } @@ -46,7 +55,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { this.set('editMode', false); }, - cancel() { + onCancel() { this.set('editMode', false); } } diff --git a/app/app/components/section/base-editor-inline.js b/app/app/components/section/base-editor-inline.js index 98b37874..e8941f5d 100644 --- a/app/app/components/section/base-editor-inline.js +++ b/app/app/components/section/base-editor-inline.js @@ -19,8 +19,12 @@ const { export default Ember.Component.extend({ drop: null, busy: false, - + mousetrap: null, hasNameError: computed.empty('page.title'), + containerId: Ember.computed('page', function () { + let page = this.get('page'); + return `base-editor-inline-container-${page.id}`; + }), pageId: Ember.computed('page', function () { let page = this.get('page'); return `page-editor-${page.id}`; @@ -43,16 +47,20 @@ export default Ember.Component.extend({ }), didRender() { - let self = this; - Mousetrap.bind('esc', function () { - self.send('onCancel'); + let msContainer = document.getElementById(this.get('containerId')); + let mousetrap = new Mousetrap(msContainer); + + mousetrap.bind('esc', () => { + this.send('onCancel'); return false; }); - Mousetrap.bind(['ctrl+s', 'command+s'], function () { - self.send('onAction'); + mousetrap.bind(['ctrl+s', 'command+s'], () => { + this.send('onAction'); return false; }); + this.set('mousetrap', mousetrap); + $('#' + this.get('pageId')).focus(function() { $(this).select(); }); @@ -65,8 +73,11 @@ export default Ember.Component.extend({ drop.destroy(); } - Mousetrap.unbind('esc'); - Mousetrap.unbind(['ctrl+s', 'command+s']); + let mousetrap = this.get('mousetrap'); + if (is.not.null(mousetrap)) { + mousetrap.unbind('esc'); + mousetrap.unbind(['ctrl+s', 'command+s']); + } }, actions: { diff --git a/app/app/styles/widget/widget-button.scss b/app/app/styles/widget/widget-button.scss index 530dee90..218a9b85 100644 --- a/app/app/styles/widget/widget-button.scss +++ b/app/app/styles/widget/widget-button.scss @@ -39,6 +39,8 @@ } .round-button-mono { + @extend .no-select; + @include ease-in(); display: inline-block; position: relative; overflow: hidden; @@ -52,9 +54,8 @@ vertical-align: middle; border: 1px solid $color-stroke; text-align: center; - @extend .no-select; - @include ease-in(); font-size: 1.2rem; + background-color: transparent; &:hover { @extend .z-depth-tiny; diff --git a/app/app/templates/components/document/document-heading.hbs b/app/app/templates/components/document/document-heading.hbs index 2dbc6ca1..5188d190 100644 --- a/app/app/templates/components/document/document-heading.hbs +++ b/app/app/templates/components/document/document-heading.hbs @@ -4,20 +4,22 @@
{{document.excerpt}}
{{else}} -
-
- {{focus-input id="document-name" type="text" value=docName class=(if hasNameError 'error-inline') placeholder="Name" autocomplete="off"}} -
-
- {{input id="document-excerpt" type="text" value=docExcerpt class=(if hasExcerptError 'error-inline') placeholder="Excerpt" autocomplete="off"}} -
-
-
- check +
+
+
+ {{focus-input id="document-name" type="text" value=docName class=(if hasNameError 'error-inline') placeholder="Name" autocomplete="off"}}
-
- close +
+ {{input id="document-excerpt" type="text" value=docExcerpt class=(if hasExcerptError 'error-inline') placeholder="Excerpt" autocomplete="off"}} +
+
+ +
+ close +
-
+
{{/unless}} diff --git a/app/app/templates/components/dropdown-dialog.hbs b/app/app/templates/components/dropdown-dialog.hbs index 6f201020..fbb53937 100644 --- a/app/app/templates/components/dropdown-dialog.hbs +++ b/app/app/templates/components/dropdown-dialog.hbs @@ -5,18 +5,12 @@
{{#if showCancel}} -
- cancel -
+
cancel
{{/if}} {{#if hasSecondButton}} -
- {{button2}} -
+
{{button2}}
{{/if}} - +
diff --git a/app/app/templates/components/section/base-editor-inline.hbs b/app/app/templates/components/section/base-editor-inline.hbs index 2ffa32cb..c7509314 100644 --- a/app/app/templates/components/section/base-editor-inline.hbs +++ b/app/app/templates/components/section/base-editor-inline.hbs @@ -1,4 +1,4 @@ -
+
{{#if busy}}