diff options
author | Romulus Urakagi Tsai <urakagi@gmail.com> | 2020-02-13 09:02:26 +0000 |
---|---|---|
committer | Romulus Urakagi Tsai <urakagi@gmail.com> | 2020-02-13 09:02:26 +0000 |
commit | 4b196d537896f39fb76090020cb5851a699546eb (patch) | |
tree | 28e2e025ce90645ed360bb8c26ab39e6f40214e4 /client/lib | |
parent | b34ed58289a3dae5838d3b621260938a3ecf52d5 (diff) | |
parent | 3fcde252f705f9527f7190517082a047714a4eec (diff) | |
download | wekan-4b196d537896f39fb76090020cb5851a699546eb.tar.gz wekan-4b196d537896f39fb76090020cb5851a699546eb.tar.bz2 wekan-4b196d537896f39fb76090020cb5851a699546eb.zip |
Merge branch 'master' of https://github.com/wekan/wekan into lib-change
Diffstat (limited to 'client/lib')
-rwxr-xr-x | client/lib/keyboard.js | 28 | ||||
-rw-r--r-- | client/lib/textComplete.js | 11 | ||||
-rw-r--r-- | client/lib/utils.js | 66 |
3 files changed, 102 insertions, 3 deletions
diff --git a/client/lib/keyboard.js b/client/lib/keyboard.js index d3f974be..da33f806 100755 --- a/client/lib/keyboard.js +++ b/client/lib/keyboard.js @@ -70,6 +70,30 @@ Mousetrap.bind('space', evt => { } }); +// XXX This shortcut should also work when hovering over a card in board view +Mousetrap.bind('c', evt => { + if (!Session.get('currentCard')) { + return; + } + + const currentUserId = Meteor.userId(); + if (currentUserId === null) { + return; + } + + if ( + Meteor.user().isBoardMember() && + !Meteor.user().isCommentOnly() && + !Meteor.user().isWorker() + ) { + const card = Cards.findOne(Session.get('currentCard')); + card.archive(); + // We should prevent scrolling in card when spacebar is clicked + // This should do it according to Mousetrap docs, but it doesn't + evt.preventDefault(); + } +}); + Template.keyboardShortcuts.helpers({ mapping: [ { @@ -104,5 +128,9 @@ Template.keyboardShortcuts.helpers({ keys: ['SPACE'], action: 'shortcut-assign-self', }, + { + keys: ['C'], + action: 'archive-card', + }, ], }); diff --git a/client/lib/textComplete.js b/client/lib/textComplete.js index 8b6dc1f7..e97d3853 100644 --- a/client/lib/textComplete.js +++ b/client/lib/textComplete.js @@ -48,6 +48,11 @@ $.fn.escapeableTextComplete = function(strategies, options, ...otherArgs) { return this; }; -EscapeActions.register('textcomplete', () => {}, () => dropdownMenuIsOpened, { - noClickEscapeOn: '.textcomplete-dropdown', -}); +EscapeActions.register( + 'textcomplete', + () => {}, + () => dropdownMenuIsOpened, + { + noClickEscapeOn: '.textcomplete-dropdown', + }, +); diff --git a/client/lib/utils.js b/client/lib/utils.js index 213124f1..d712cc73 100644 --- a/client/lib/utils.js +++ b/client/lib/utils.js @@ -1,4 +1,40 @@ +import { Cookies } from 'meteor/ostrio:cookies'; +const cookies = new Cookies(); + Utils = { + setBoardView(view) { + currentUser = Meteor.user(); + if (currentUser) { + Meteor.user().setBoardView(view); + } else if (view === 'board-view-lists') { + cookies.set('boardView', 'board-view-lists'); //true + } else if (view === 'board-view-swimlanes') { + cookies.set('boardView', 'board-view-swimlanes'); //true + } else if (view === 'board-view-cal') { + cookies.set('boardView', 'board-view-cal'); //true + } + }, + + unsetBoardView() { + cookies.remove('boardView'); + cookies.remove('collapseSwimlane'); + }, + + boardView() { + currentUser = Meteor.user(); + if (currentUser) { + return (currentUser.profile || {}).boardView; + } else if (cookies.get('boardView') === 'board-view-lists') { + return 'board-view-lists'; + } else if (cookies.get('boardView') === 'board-view-swimlanes') { + return 'board-view-swimlanes'; + } else if (cookies.get('boardView') === 'board-view-cal') { + return 'board-view-cal'; + } else { + return false; + } + }, + // XXX We should remove these two methods goBoardId(_id) { const board = Boards.findOne(_id); @@ -117,8 +153,38 @@ Utils = { // in a small window (even on desktop), Wekan run in compact mode. // we can easily debug with a small window of desktop browser. :-) isMiniScreen() { + // OLD WINDOW WIDTH DETECTION: this.windowResizeDep.depend(); return $(window).width() <= 800; + + // NEW TOUCH DEVICE DETECTION: + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent + + /* + var hasTouchScreen = false; + if ("maxTouchPoints" in navigator) { + hasTouchScreen = navigator.maxTouchPoints > 0; + } else if ("msMaxTouchPoints" in navigator) { + hasTouchScreen = navigator.msMaxTouchPoints > 0; + } else { + var mQ = window.matchMedia && matchMedia("(pointer:coarse)"); + if (mQ && mQ.media === "(pointer:coarse)") { + hasTouchScreen = !!mQ.matches; + } else if ('orientation' in window) { + hasTouchScreen = true; // deprecated, but good fallback + } else { + // Only as a last resort, fall back to user agent sniffing + var UA = navigator.userAgent; + hasTouchScreen = ( + /\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(UA) || + /\b(Android|Windows Phone|iPad|iPod)\b/i.test(UA) + ); + } + } + */ + //if (hasTouchScreen) + // document.getElementById("exampleButton").style.padding="1em"; + //return false; }, calculateIndexData(prevData, nextData, nItems = 1) { |