-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable the combinaison deletion on touch device
- Loading branch information
1 parent
e1ed6a9
commit 6931f37
Showing
2 changed files
with
37 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
(function ($) { | ||
|
||
var selectionTimeout, | ||
selection; | ||
|
||
$('.box-combinaison').on('touchstart', 'span', function(e) { | ||
e.preventDefault(); | ||
|
||
if (selectionTimeout) clearTimeout(selectionTimeout); | ||
|
||
selection = $(this); | ||
selectionTimeout = setTimeout(openDeletionConfirmation, 500); | ||
}); | ||
|
||
$('.box-combinaison').on('touchend', 'span', function(e) { | ||
e.preventDefault(); | ||
if (selectionTimeout) clearTimeout(selectionTimeout); | ||
}); | ||
|
||
function openDeletionConfirmation() { | ||
Popup.open( | ||
'Do you want to delete this combinaison?', | ||
[ | ||
{ text: 'Delete combinaison', click: deleteSelectedCombinaison }, | ||
{ text: 'Cancel' } | ||
] | ||
); | ||
} | ||
|
||
function deleteSelectedCombinaison() { | ||
var index = parseInt(selection.attr('data-combinaison-index')), | ||
isOpen = selection.parents('div').attr('id') === 'OpenCombinaison'; | ||
viewModel.remove(index, isOpen); | ||
} | ||
|
||
} (jQuery)); |