Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
})
// Add a reference to the Ember Data model to each API item search result
.map(searchResult => {
let { document } = searchResult;
if (document.type !== 'template') {
let store = this.get('store');
searchResult.model = store.peekRecord(document.type, document.item.id)
}
return searchResult;
});
}
}),
gotoSelectedItem: on(keyUp('Enter'), function() {
if (this.get('selectedIndex') !== null) {
let selectedResult = this.get('searchResults')[this.get('selectedIndex')];
if (selectedResult.document.type === 'template') {
this.get('router').transitionTo(selectedResult.document.route);
} else {
this.get('router').transitionTo('docs.api.item', selectedResult.model.get('routingId'));
}
}
this.get('on-visit')();
}),
nextSearchResult: on(keyDown('ctrl+KeyN'), keyDown('ArrowDown'), function() {
let hasSearchResults = this.get('searchResults.length');
let lastResultIsSelected = (this.get('selectedIndex') + 1 === this.get('searchResults.length'));
didInsertElement() {
this._super();
this.get('fetchProject').perform();
},
// TODO: The searchbox doesn't work without the project being fetched.
// We should move this logic (and everywhere else in the code that's fetching
// the project) within a new addonDocs service that wires all that up together.
// I think it's fine if our Docs-* components assume there is a single global
// project.
fetchProject: task(function*() {
yield this.get('store').findRecord('project', projectName);
}),
focusSearch: on(keyUp('Slash'), function() {
if (!formElementHasFocus()) {
this.element.querySelector('input').focus();
}
}),
unfocusSearch: on(keyUp('Escape'), function() {
this.get('on-input')(null);
})
});
import Ember from 'ember';
import { EKOnInsertMixin, keyUp } from 'ember-keyboard';
const { Component, on } = Ember;
export default Component.extend(EKOnInsertMixin, {
name: 'Modal Container',
isOpen: false,
openModal: on(keyUp('ctrl+shift+a'), function() {
this.set('isOpen', true);
}),
actions: {
closeModal() {
this.set('isOpen', false);
}
}
});
return `x-${this.get('slides.role.type')}-slide`;
}),
init() {
this._super(...arguments);
this.set('keyboardActivated', true);
let slides = this.get('slides');
slides.setupRole(this.get('role'));
},
onLeft: on(keyUp('ArrowLeft'), function() {
this.get('slides').previous();
}),
onRight: on(keyUp('ArrowRight'), keyUp('Space'), keyUp('Enter'), function() {
this.get('slides').next();
})
});
let currentSlideIndex = this.get('currentSlideIndex');
if (currentSlideIndex < slideCount - 1) {
return currentSlideIndex + 1;
} else {
return currentSlideIndex;
}
}),
nextSlide: computed('slideRoutes.[]', 'nextSlideIndex', function() {
let slideRoutes = this.get('slideRoutes');
let nextSlideIndex = this.get('nextSlideIndex');
return slideRoutes[nextSlideIndex];
}),
onLeft: on(keyUp('ArrowLeft'), function() {
this.previous();
}),
onRight: on(keyUp('ArrowRight'), keyUp('Space'), keyUp('Enter'), function() {
this.next();
}),
previous() {
if (this.get('hasPreviousSlide')) {
let slide = this.get('previousSlide');
this.get('router').transitionTo(slide.path);
this.get('realtime').emit('goToSlide', { slide: slide.path });
}
},
next() {
} else {
return currentSlideIndex;
}
}),
nextSlide: computed('slideRoutes.[]', 'nextSlideIndex', function() {
let slideRoutes = this.get('slideRoutes');
let nextSlideIndex = this.get('nextSlideIndex');
return slideRoutes[nextSlideIndex];
}),
onLeft: on(keyUp('ArrowLeft'), function() {
this.previous();
}),
onRight: on(keyUp('ArrowRight'), keyUp('Space'), keyUp('Enter'), function() {
this.next();
}),
previous() {
if (this.get('hasPreviousSlide')) {
let slide = this.get('previousSlide');
this.get('router').transitionTo(slide.path);
this.get('realtime').emit('goToSlide', { slide: slide.path });
}
},
next() {
if (this.get('hasNextSlide')) {
let slide = this.get('nextSlide');
this.get('router').transitionTo(slide.path);
this.get('realtime').emit('goToSlide', { slide: slide.path });
didInsertElement() {
this._super(...arguments);
if (this.onKeyUp) {
this.on(keyUp(this.key), this.onKeyUp);
}
if (this.onKeyDown) {
this.on(keyDown(this.key), this.onKeyDown);
}
if (this.onKeyPress) {
this.on(keyPress(this.key), this.onKeyPress);
}
},
});
this.set('isGoingTo', true);
later(() => {
this.set('isGoingTo', false);
}, 500);
}
}),
gotoDocs: on(keyUp('KeyD'), function() {
if (!formElementHasFocus()) {
if (this.get('isGoingTo')) {
this.get('router').transitionTo('docs');
}
}
}),
gotoHome: on(keyUp('KeyH'), function() {
if (!formElementHasFocus()) {
if (this.get('isGoingTo')) {
this.get('router').transitionTo('index');
}
}
}),
toggleKeyboardShortcuts: on(keyUp('shift+Slash'), function() {
if (!formElementHasFocus()) {
this.toggleProperty('isShowingKeyboardShortcuts');
}
}),
hideKeyboardShortcuts: on(keyUp('Escape'), function() {
if (!formElementHasFocus() && this.get('isShowingKeyboardShortcuts')) {
this.set('isShowingKeyboardShortcuts', false);
this.set('isGoingTo', true);
later(() => {
this.set('isGoingTo', false);
}, 500);
}
}),
gotoDocs: on(keyUp('KeyD'), function() {
if (!formElementHasFocus()) {
if (this.get('isGoingTo')) {
this.get('router').transitionTo('docs');
}
}
}),
gotoHome: on(keyUp('KeyH'), function() {
if (!formElementHasFocus()) {
if (this.get('isGoingTo')) {
this.get('router').transitionTo('index');
}
}
}),
toggleKeyboardShortcuts: on(keyUp('shift+Slash'), function() {
if (!formElementHasFocus()) {
this.toggleProperty('isShowingKeyboardShortcuts');
}
}),
actions: {
toggleKeyboardShortcuts() {
this.toggleProperty('isShowingKeyboardShortcuts');
A component that enables keyboard shortcuts. Press '?' to toggle the keyboard shortcuts dialog.
@class DocsKeyboardShortcuts
@public
*/
export default Component.extend(EKMixin, {
layout,
router: service(),
isShowingKeyboardShortcuts: false,
keyboardActivated: true,
goto: on(keyUp('KeyG'), function() {
if (!formElementHasFocus()) {
this.set('isGoingTo', true);
later(() => {
this.set('isGoingTo', false);
}, 500);
}
}),
gotoDocs: on(keyUp('KeyD'), function() {
if (!formElementHasFocus()) {
if (this.get('isGoingTo')) {
this.get('router').transitionTo('docs');
}
}
}),