mirror of
https://github.com/wekan/wekan.git
synced 2026-02-06 16:41:48 +01:00
Set drag handle on touch screen not miniscreen
This commit is contained in:
parent
61d2fd0308
commit
d7bb0b4cc0
16 changed files with 214 additions and 223 deletions
|
|
@ -5,20 +5,20 @@ import { Random } from 'meteor/random';
|
|||
import '../utils';
|
||||
|
||||
|
||||
describe('Utils', function() {
|
||||
beforeEach(function() {
|
||||
sinon.stub(Utils, 'reload').callsFake(() => {});
|
||||
describe('Utils', function () {
|
||||
beforeEach(function () {
|
||||
sinon.stub(Utils, 'reload').callsFake(() => { });
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
window.localStorage.removeItem(boardView);
|
||||
sinon.restore();
|
||||
});
|
||||
|
||||
const boardView = 'boardView';
|
||||
|
||||
describe(Utils.setBoardView.name, function() {
|
||||
it('sets the board view if the user exists', function(done) {
|
||||
describe(Utils.setBoardView.name, function () {
|
||||
it('sets the board view if the user exists', function (done) {
|
||||
const viewId = Random.id();
|
||||
const user = {
|
||||
setBoardView: (view) => {
|
||||
|
|
@ -32,14 +32,14 @@ describe('Utils', function() {
|
|||
expect(window.localStorage.getItem(boardView)).to.equal(viewId);
|
||||
});
|
||||
|
||||
it('sets a specific view if no user exists but a view is defined', function() {
|
||||
it('sets a specific view if no user exists but a view is defined', function () {
|
||||
const views = [
|
||||
'board-view-swimlanes',
|
||||
'board-view-lists',
|
||||
'board-view-cal'
|
||||
];
|
||||
|
||||
sinon.stub(Meteor, 'user').callsFake(() => {});
|
||||
sinon.stub(Meteor, 'user').callsFake(() => { });
|
||||
|
||||
views.forEach(viewName => {
|
||||
Utils.setBoardView(viewName);
|
||||
|
|
@ -47,15 +47,15 @@ describe('Utils', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('sets a default view if no user and no view are given', function() {
|
||||
sinon.stub(Meteor, 'user').callsFake(() => {});
|
||||
it('sets a default view if no user and no view are given', function () {
|
||||
sinon.stub(Meteor, 'user').callsFake(() => { });
|
||||
Utils.setBoardView();
|
||||
expect(window.localStorage.getItem(boardView)).to.equal('board-view-swimlanes');
|
||||
});
|
||||
});
|
||||
|
||||
describe(Utils.unsetBoardView.name, function() {
|
||||
it('removes the boardview from localStoage', function() {
|
||||
describe(Utils.unsetBoardView.name, function () {
|
||||
it('removes the boardview from localStoage', function () {
|
||||
window.localStorage.setItem(boardView, Random.id());
|
||||
window.localStorage.setItem('collapseSwimlane', Random.id());
|
||||
|
||||
|
|
@ -66,8 +66,8 @@ describe('Utils', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe(Utils.boardView.name, function() {
|
||||
it('returns the user\'s board view if a user exists', function() {
|
||||
describe(Utils.boardView.name, function () {
|
||||
it('returns the user\'s board view if a user exists', function () {
|
||||
const viewId = Random.id();
|
||||
const user = {};
|
||||
sinon.stub(Meteor, 'user').callsFake(() => user);
|
||||
|
|
@ -78,108 +78,108 @@ describe('Utils', function() {
|
|||
|
||||
expect(Utils.boardView()).to.equal(boardView);
|
||||
});
|
||||
it('returns the current defined view', function() {
|
||||
it('returns the current defined view', function () {
|
||||
const views = [
|
||||
'board-view-swimlanes',
|
||||
'board-view-lists',
|
||||
'board-view-cal'
|
||||
];
|
||||
|
||||
sinon.stub(Meteor, 'user').callsFake(() => {});
|
||||
sinon.stub(Meteor, 'user').callsFake(() => { });
|
||||
|
||||
views.forEach(viewName => {
|
||||
window.localStorage.setItem(boardView, viewName);
|
||||
expect(Utils.boardView()).to.equal(viewName);
|
||||
});
|
||||
});
|
||||
it('returns a default if nothing is set', function() {
|
||||
sinon.stub(Meteor, 'user').callsFake(() => {});
|
||||
it('returns a default if nothing is set', function () {
|
||||
sinon.stub(Meteor, 'user').callsFake(() => { });
|
||||
expect(Utils.boardView()).to.equal('board-view-swimlanes');
|
||||
expect(window.localStorage.getItem(boardView)).to.equal('board-view-swimlanes');
|
||||
});
|
||||
});
|
||||
|
||||
describe(Utils.myCardsSort.name, function() {
|
||||
describe(Utils.myCardsSort.name, function () {
|
||||
it('has no tests yet');
|
||||
});
|
||||
|
||||
describe(Utils.myCardsSortToggle.name, function() {
|
||||
describe(Utils.myCardsSortToggle.name, function () {
|
||||
it('has no tests yet');
|
||||
});
|
||||
|
||||
describe(Utils.setMyCardsSort.name, function() {
|
||||
describe(Utils.setMyCardsSort.name, function () {
|
||||
it('has no tests yet');
|
||||
});
|
||||
|
||||
describe(Utils.archivedBoardIds.name, function() {
|
||||
describe(Utils.archivedBoardIds.name, function () {
|
||||
it('has no tests yet');
|
||||
});
|
||||
|
||||
describe(Utils.dueCardsView.name, function() {
|
||||
describe(Utils.dueCardsView.name, function () {
|
||||
it('has no tests yet');
|
||||
});
|
||||
|
||||
describe(Utils.setDueCardsView.name, function() {
|
||||
describe(Utils.setDueCardsView.name, function () {
|
||||
it('has no tests yet');
|
||||
});
|
||||
|
||||
describe(Utils.goBoardId.name, function() {
|
||||
describe(Utils.goBoardId.name, function () {
|
||||
it('has no tests yet');
|
||||
});
|
||||
|
||||
describe(Utils.goCardId.name, function() {
|
||||
describe(Utils.goCardId.name, function () {
|
||||
it('has no tests yet');
|
||||
});
|
||||
|
||||
describe(Utils.processUploadedAttachment.name, function() {
|
||||
describe(Utils.processUploadedAttachment.name, function () {
|
||||
it('has no tests yet');
|
||||
});
|
||||
|
||||
describe(Utils.shrinkImage.name, function() {
|
||||
describe(Utils.shrinkImage.name, function () {
|
||||
it('has no tests yet');
|
||||
});
|
||||
|
||||
describe(Utils.capitalize.name, function() {
|
||||
describe(Utils.capitalize.name, function () {
|
||||
it('has no tests yet');
|
||||
});
|
||||
|
||||
describe(Utils.isMiniScreen.name, function() {
|
||||
describe(Utils.isMiniScreen.name, function () {
|
||||
it('has no tests yet');
|
||||
});
|
||||
|
||||
describe(Utils.isShowDesktopDragHandles.name, function() {
|
||||
describe(Utils.isShowDesktopDragHandles.name, function () {
|
||||
it('has no tests yet');
|
||||
});
|
||||
|
||||
describe(Utils.isMiniScreenOrShowDesktopDragHandles.name, function() {
|
||||
describe(Utils.isTouchScreenOrShowDesktopDragHandles.name, function () {
|
||||
it('has no tests yet');
|
||||
});
|
||||
|
||||
describe(Utils.calculateIndexData.name, function() {
|
||||
describe(Utils.calculateIndexData.name, function () {
|
||||
it('has no tests yet');
|
||||
});
|
||||
|
||||
describe(Utils.calculateIndex.name, function() {
|
||||
describe(Utils.calculateIndex.name, function () {
|
||||
it('has no tests yet');
|
||||
});
|
||||
|
||||
describe(Utils.manageCustomUI.name, function() {
|
||||
describe(Utils.manageCustomUI.name, function () {
|
||||
it('has no tests yet');
|
||||
});
|
||||
|
||||
describe(Utils.setCustomUI.name, function() {
|
||||
describe(Utils.setCustomUI.name, function () {
|
||||
it('has no tests yet');
|
||||
});
|
||||
|
||||
describe(Utils.setMatomo.name, function() {
|
||||
describe(Utils.setMatomo.name, function () {
|
||||
it('has no tests yet');
|
||||
});
|
||||
|
||||
describe(Utils.manageMatomo.name, function() {
|
||||
describe(Utils.manageMatomo.name, function () {
|
||||
it('has no tests yet');
|
||||
});
|
||||
|
||||
describe(Utils.getTriggerActionDesc.name, function() {
|
||||
describe(Utils.getTriggerActionDesc.name, function () {
|
||||
it('has no tests yet');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ Utils = {
|
|||
const ret = Cards.findOne(cardId);
|
||||
return ret;
|
||||
},
|
||||
reload () {
|
||||
reload() {
|
||||
// we move all window.location.reload calls into this function
|
||||
// so we can disable it when running tests.
|
||||
// This is because we are not allowed to override location.reload but
|
||||
|
|
@ -201,14 +201,14 @@ Utils = {
|
|||
image = document.createElement('img');
|
||||
const maxSize = options.maxSize || 1024;
|
||||
const ratio = options.ratio || 1.0;
|
||||
const next = function(result) {
|
||||
const next = function (result) {
|
||||
image = null;
|
||||
canvas = null;
|
||||
if (typeof callback === 'function') {
|
||||
callback(result);
|
||||
}
|
||||
};
|
||||
image.onload = function() {
|
||||
image.onload = function () {
|
||||
let width = this.width,
|
||||
height = this.height;
|
||||
let changed = false;
|
||||
|
|
@ -237,7 +237,7 @@ Utils = {
|
|||
next(changed);
|
||||
}
|
||||
};
|
||||
image.onerror = function() {
|
||||
image.onerror = function () {
|
||||
next(false);
|
||||
};
|
||||
image.src = dataurl;
|
||||
|
|
@ -256,35 +256,34 @@ Utils = {
|
|||
// OLD WINDOW WIDTH DETECTION:
|
||||
this.windowResizeDep.depend();
|
||||
return $(window).width() <= 800;
|
||||
},
|
||||
|
||||
isTouchScreen() {
|
||||
|
||||
// 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;
|
||||
hasTouchScreen = navigator.maxTouchPoints > 0;
|
||||
} else if ("msMaxTouchPoints" in navigator) {
|
||||
hasTouchScreen = navigator.msMaxTouchPoints > 0;
|
||||
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)
|
||||
);
|
||||
}
|
||||
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;
|
||||
return hasTouchScreen;
|
||||
},
|
||||
|
||||
// returns if desktop drag handles are enabled
|
||||
|
|
@ -300,8 +299,8 @@ Utils = {
|
|||
},
|
||||
|
||||
// returns if mini screen or desktop drag handles
|
||||
isMiniScreenOrShowDesktopDragHandles() {
|
||||
return this.isMiniScreen() || this.isShowDesktopDragHandles();
|
||||
isTouchScreenOrShowDesktopDragHandles() {
|
||||
return this.isTouchScreen() || this.isShowDesktopDragHandles();
|
||||
},
|
||||
|
||||
calculateIndexData(prevData, nextData, nItems = 1) {
|
||||
|
|
@ -396,7 +395,7 @@ Utils = {
|
|||
window._paq.push(['trackPageView']);
|
||||
window._paq.push(['enableLinkTracking']);
|
||||
|
||||
(function() {
|
||||
(function () {
|
||||
window._paq.push(['setTrackerUrl', `${data.address}piwik.php`]);
|
||||
window._paq.push(['setSiteId', data.siteId]);
|
||||
|
||||
|
|
@ -500,8 +499,8 @@ Utils = {
|
|||
copyTextToClipboard(text) {
|
||||
let ret;
|
||||
if (navigator.clipboard) {
|
||||
ret = navigator.clipboard.writeText(text).then(function() {
|
||||
}, function(err) {
|
||||
ret = navigator.clipboard.writeText(text).then(function () {
|
||||
}, function (err) {
|
||||
console.error('Async: Could not copy text: ', err);
|
||||
});
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue