-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from jaanauati/organize-modules
reorganize code into modules.
- Loading branch information
Showing
9 changed files
with
116 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
exports.TOGGLE_SEARCH_INPUT = 'HS_TOGGLE_SEARCH_INPUT'; | ||
exports.UPDATE_SEARCH_TEXT = 'HS_UPDATE_SEARCH_TEXT'; | ||
exports.CURRENT_MATCH = 'HS_CURRENT_MATCH'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const { CURRENT_MATCH, TOGGLE_SEARCH_INPUT, UPDATE_SEARCH_TEXT } = require('./actionTypes'); | ||
|
||
module.exports.setCurrentMatch = function setCurrentMatch(uid, row, startIndex, endIndex) { | ||
return (dispatch) => { | ||
dispatch({ type: CURRENT_MATCH, data: { uid, row, startIndex, endIndex } }); | ||
}; | ||
}; | ||
|
||
module.exports.toggleSearchInput = function toggleSearchInput(uid) { | ||
return (dispatch) => { | ||
dispatch({ type: TOGGLE_SEARCH_INPUT, uid }); | ||
}; | ||
}; | ||
|
||
module.exports.updateSearchText = function updateSearchText(uid, text) { | ||
return (dispatch) => { | ||
dispatch({ type: UPDATE_SEARCH_TEXT, uid, text }); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports.LEAD_KEY = process.platform === 'darwin' ? 'Cmd' : 'Ctrl'; | ||
module.exports.EDIT = 'Edit'; | ||
module.exports.ENTER = 'Enter'; | ||
module.exports.DIRECTION_NEXT = 1; | ||
module.exports.DIRECTION_PREV = -1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
const { decorateTerm, mapTermsState, passProps, getTermGroupProps, getTermProps } = require('./containers'); | ||
const { decorateMenu } = require('./menu'); | ||
const { reduceUI } = require('./reducers'); | ||
|
||
exports.reduceUI = reduceUI; | ||
exports.decorateMenu = decorateMenu; | ||
exports.decorateTerm = decorateTerm; | ||
exports.mapTermsState = mapTermsState; | ||
exports.passProps = passProps; | ||
exports.getTermGroupProps = getTermGroupProps; | ||
exports.getTermProps = getTermProps; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const { EDIT, LEAD_KEY } = require('./constants'); | ||
|
||
exports.decorateMenu = (menu) => { | ||
for (const menuItem of menu) { | ||
if (menuItem.label === EDIT) { | ||
menuItem.submenu = menuItem.submenu.concat({ | ||
label: 'Find', | ||
submenu: [ | ||
{ | ||
label: 'Toggle Find Bar', | ||
accelerator: `${LEAD_KEY}+F`, | ||
click(item, focusedWindow) { | ||
if (focusedWindow !== null) { | ||
focusedWindow.rpc.emit('hyper-search:toggle:input', { focusedWindow }); | ||
} | ||
}, | ||
}, | ||
{ | ||
label: 'Find Next', | ||
accelerator: `${LEAD_KEY}+G`, | ||
click(item, focusedWindow) { | ||
if (focusedWindow !== null) { | ||
focusedWindow.rpc.emit('hyper-search:seach:next', { focusedWindow }); | ||
} | ||
}, | ||
}, | ||
{ | ||
label: 'Find Previous', | ||
accelerator: `${LEAD_KEY}+Shift+G`, | ||
click(item, focusedWindow) { | ||
if (focusedWindow !== null) { | ||
focusedWindow.rpc.emit('hyper-search:seach:prev', { focusedWindow }); | ||
} | ||
}, | ||
}, | ||
], | ||
}); | ||
break; | ||
} | ||
} | ||
return menu; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const { TOGGLE_SEARCH_INPUT, UPDATE_SEARCH_TEXT, CURRENT_MATCH } = require('./actionTypes'); | ||
|
||
exports.reduceUI = (state, action) => { | ||
switch (action.type) { | ||
case TOGGLE_SEARCH_INPUT: { | ||
const uid = action.uid; | ||
const { hyperSearchToggleInput = {} } = state; | ||
return state.set( | ||
'hyperSearchToggleInput', | ||
Object.assign({}, hyperSearchToggleInput, { [uid]: !hyperSearchToggleInput[uid] }) | ||
); | ||
} | ||
case UPDATE_SEARCH_TEXT: { | ||
const { hyperSearchInputText = {} } = state; | ||
return state.set('hyperSearchInputText', | ||
Object.assign({}, hyperSearchInputText, { [action.uid]: action.text })); | ||
} | ||
case CURRENT_MATCH: { | ||
const { hyperSearchCurrentRow = {} } = state; | ||
const { uid, row, startIndex, endIndex } = action.data; | ||
return state.set('hyperSearchCurrentRow', | ||
Object.assign({}, hyperSearchCurrentRow, { [uid]: { row, startIndex, endIndex } })); | ||
} | ||
default: | ||
return state; | ||
} | ||
}; |