From ec590c32ae93ea704681974869079028ccb3109e Mon Sep 17 00:00:00 2001 From: Arunoda Susiripala Date: Mon, 9 May 2016 14:06:35 +0530 Subject: [PATCH] Add shortcuts to go back and forth (prev & next) (#176) Add shortcuts to jump to previous and next stories --- dist/client/libs/key_events.js | 10 ++- dist/manager.js | 22 +++---- dist/manager.js.map | 2 +- src/client/libs/key_events.js | 8 +++ .../modules/api/actions/__tests__/api.js | 48 ++++++++++++++ src/client/manager/modules/api/actions/api.js | 7 ++ .../manager/modules/api/actions/index.js | 3 +- .../api/configs/reducers/__tests__/api.js | 65 +++++++++++++++++++ .../modules/api/configs/reducers/api.js | 36 +++++++++- .../modules/shortcuts/actions/shortcuts.js | 22 +++++-- .../modules/ui/components/shortcuts_help.js | 10 +++ 11 files changed, 212 insertions(+), 21 deletions(-) diff --git a/dist/client/libs/key_events.js b/dist/client/libs/key_events.js index 3d6865036217..dd6470d0a209 100644 --- a/dist/client/libs/key_events.js +++ b/dist/client/libs/key_events.js @@ -18,7 +18,9 @@ var features = exports.features = { DOWN_PANEL: 2, LEFT_PANEL: 3, SHORTCUTS_HELP: 4, - ESCAPE: 5 + ESCAPE: 5, + NEXT_STORY: 6, + PREV_STORY: 7 }; function isModifierPressed(e) { @@ -44,6 +46,12 @@ function handle(e) { case (0, _keycode2.default)('L'): e.preventDefault(); return features.LEFT_PANEL; + case (0, _keycode2.default)('right'): + e.preventDefault(); + return features.NEXT_STORY; + case (0, _keycode2.default)('left'): + e.preventDefault(); + return features.PREV_STORY; default: return false; } diff --git a/dist/manager.js b/dist/manager.js index c333595db450..a1029d0781a0 100644 --- a/dist/manager.js +++ b/dist/manager.js @@ -1,5 +1,5 @@ -!function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}(function(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))switch(typeof e[t]){case"function":break;case"object":e[t]=function(t){var n=t.slice(1),r=e[t[0]];return function(e,t,o){r.apply(this,[e,t,o].concat(n))}}(e[t]);break;default:e[t]=e[e[t]]}return e}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}var o=Object.assign||function(e){for(var t=1;tn;n++)t["_"+String.fromCharCode(n)]=n;var r=Object.getOwnPropertyNames(t).map(function(e){return t[e]});if("0123456789"!==r.join(""))return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(e){o[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(i){return!1}}var o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;e.exports=r()?Object.assign:function(e,t){for(var r,a,u=n(e),s=1;s1){for(var d=Array(f),h=0;f>h;h++)d[h]=arguments[h+2];i.children=d}if(e&&e.defaultProps){var v=e.defaultProps;for(r in v)void 0===i[r]&&(i[r]=v[r])}return u(e,s,l,c,p,o.current,i)},u.createFactory=function(e){var t=u.createElement.bind(null,e);return t.type=e,t},u.cloneAndReplaceKey=function(e,t){var n=u(e.type,t,e.ref,e._self,e._source,e._owner,e.props);return n},u.cloneElement=function(e,t,n){var i,s=r({},e.props),l=e.key,c=e.ref,p=e._self,f=e._source,d=e._owner;if(null!=t){void 0!==t.ref&&(c=t.ref,d=o.current),void 0!==t.key&&(l=""+t.key);var h;e.type&&e.type.defaultProps&&(h=e.type.defaultProps);for(i in t)t.hasOwnProperty(i)&&!a.hasOwnProperty(i)&&(void 0===t[i]&&void 0!==h?s[i]=h[i]:s[i]=t[i])}var v=arguments.length-2;if(1===v)s.children=n;else if(v>1){for(var y=Array(v),m=0;v>m;m++)y[m]=arguments[m+2];s.children=y}return u(e.type,l,c,p,f,d,s)},u.isValidElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===i},e.exports=u},function(e,t,n){"use strict";function r(){S.ReactReconcileTransaction&&C?void 0:m(!1)}function o(){this.reinitializeTransaction(),this.dirtyComponentsLength=null,this.callbackQueue=p.getPooled(),this.reconcileTransaction=S.ReactReconcileTransaction.getPooled(!0)}function i(e,t,n,o,i,a){r(),C.batchedUpdates(e,t,n,o,i,a)}function a(e,t){return e._mountOrder-t._mountOrder}function u(e){var t=e.dirtyComponentsLength;t!==g.length?m(!1):void 0,g.sort(a);for(var n=0;t>n;n++){var r=g[n],o=r._pendingCallbacks;r._pendingCallbacks=null;var i;if(d.logTopLevelRenders){var u=r;r._currentElement.props===r._renderedComponent._currentElement&&(u=r._renderedComponent),i="React update: "+u.getName(),console.time(i)}if(v.performUpdateIfNecessary(r,e.reconcileTransaction),i&&console.timeEnd(i),o)for(var s=0;s-1?void 0:a(!1),!l.plugins[n]){t.extractEvents?void 0:a(!1),l.plugins[n]=t;var r=t.eventTypes;for(var i in r)o(r[i],t,i)?void 0:a(!1)}}}function o(e,t,n){l.eventNameDispatchConfigs.hasOwnProperty(n)?a(!1):void 0,l.eventNameDispatchConfigs[n]=e;var r=e.phasedRegistrationNames;if(r){for(var o in r)if(r.hasOwnProperty(o)){var u=r[o];i(u,t,n)}return!0}return e.registrationName?(i(e.registrationName,t,n),!0):!1}function i(e,t,n){l.registrationNameModules[e]?a(!1):void 0,l.registrationNameModules[e]=t,l.registrationNameDependencies[e]=t.eventTypes[n].dependencies}var a=n(1),u=null,s={},l={plugins:[],eventNameDispatchConfigs:{},registrationNameModules:{},registrationNameDependencies:{},possibleRegistrationNames:null,injectEventPluginOrder:function(e){u?a(!1):void 0,u=Array.prototype.slice.call(e),r()},injectEventPluginsByName:function(e){var t=!1;for(var n in e)if(e.hasOwnProperty(n)){var o=e[n];s.hasOwnProperty(n)&&s[n]===o||(s[n]?a(!1):void 0,s[n]=o,t=!0)}t&&r()},getPluginModuleForEvent:function(e){var t=e.dispatchConfig;if(t.registrationName)return l.registrationNameModules[t.registrationName]||null;for(var n in t.phasedRegistrationNames)if(t.phasedRegistrationNames.hasOwnProperty(n)){var r=l.registrationNameModules[t.phasedRegistrationNames[n]];if(r)return r}return null},_resetEventPlugins:function(){u=null;for(var e in s)s.hasOwnProperty(e)&&delete s[e];l.plugins.length=0;var t=l.eventNameDispatchConfigs;for(var n in t)t.hasOwnProperty(n)&&delete t[n];var r=l.registrationNameModules;for(var o in r)r.hasOwnProperty(o)&&delete r[o]}};e.exports=l},function(e,t,n){"use strict";function r(e){return Object.prototype.hasOwnProperty.call(e,y)||(e[y]=h++,f[e[y]]={}),f[e[y]]}var o,i=n(3),a=n(12),u=n(46),s=n(325),l=n(142),c=n(353),p=n(90),f={},d=!1,h=0,v={topAbort:"abort",topAnimationEnd:c("animationend")||"animationend",topAnimationIteration:c("animationiteration")||"animationiteration",topAnimationStart:c("animationstart")||"animationstart",topBlur:"blur",topCanPlay:"canplay",topCanPlayThrough:"canplaythrough",topChange:"change",topClick:"click",topCompositionEnd:"compositionend",topCompositionStart:"compositionstart",topCompositionUpdate:"compositionupdate",topContextMenu:"contextmenu",topCopy:"copy",topCut:"cut",topDoubleClick:"dblclick",topDrag:"drag",topDragEnd:"dragend",topDragEnter:"dragenter",topDragExit:"dragexit",topDragLeave:"dragleave",topDragOver:"dragover",topDragStart:"dragstart",topDrop:"drop",topDurationChange:"durationchange",topEmptied:"emptied",topEncrypted:"encrypted",topEnded:"ended",topError:"error",topFocus:"focus",topInput:"input",topKeyDown:"keydown",topKeyPress:"keypress",topKeyUp:"keyup",topLoadedData:"loadeddata",topLoadedMetadata:"loadedmetadata",topLoadStart:"loadstart",topMouseDown:"mousedown",topMouseMove:"mousemove",topMouseOut:"mouseout",topMouseOver:"mouseover",topMouseUp:"mouseup",topPaste:"paste",topPause:"pause",topPlay:"play",topPlaying:"playing",topProgress:"progress",topRateChange:"ratechange",topScroll:"scroll",topSeeked:"seeked",topSeeking:"seeking",topSelectionChange:"selectionchange",topStalled:"stalled",topSuspend:"suspend",topTextInput:"textInput",topTimeUpdate:"timeupdate",topTouchCancel:"touchcancel",topTouchEnd:"touchend",topTouchMove:"touchmove",topTouchStart:"touchstart",topTransitionEnd:c("transitionend")||"transitionend",topVolumeChange:"volumechange",topWaiting:"waiting",topWheel:"wheel"},y="_reactListenersID"+String(Math.random()).slice(2),m=i({},s,{ReactEventListener:null,injection:{injectReactEventListener:function(e){e.setHandleTopLevel(m.handleTopLevel),m.ReactEventListener=e}},setEnabled:function(e){m.ReactEventListener&&m.ReactEventListener.setEnabled(e)},isEnabled:function(){return!(!m.ReactEventListener||!m.ReactEventListener.isEnabled())},listenTo:function(e,t){for(var n=t,o=r(n),i=u.registrationNameDependencies[e],s=a.topLevelTypes,l=0;l":">","<":"<",'"':""","'":"'"},i=/[&><"']/g;e.exports=r},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0}),t.types=void 0;var o=n(161),i=r(o);t.types={SELECT_STORY:"API_SELECT_STORY",CLEAR_ACTIONS:"API_CLEAR_ACTIONS",SET_STORIES:"API_SET_STORIES",ADD_ACTION:"API_ADD_ACTION"};t["default"]={api:i["default"]}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0}),t.types=void 0;var o=n(169),i=r(o);t.types={HANDLE_EVENT:"SHORTCUTS_HANDLE_EVENT"};t["default"]={shortcuts:i["default"]}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0}),t.types=void 0;var o=n(173),i=r(o);t.types={SET_STORY_FILTER:"UI_SET_STORY_FILTER",TOGGLE_SHORTCUTS_HELP:"UI_TOGGLE_SHORTCUTS_HELP"};t["default"]={ui:i["default"]}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=n(197),i=r(o);t["default"]=i["default"]||function(e){for(var t=1;t";for(t.style.display="none",n(219).appendChild(t),t.src="javascript:",e=t.contentWindow.document,e.open(),e.write("