Skip to content

Commit

Permalink
Touch combinaison deletion
Browse files Browse the repository at this point in the history
Enable the combinaison deletion on touch device
  • Loading branch information
EmeraldCoder committed Jan 25, 2014
1 parent e1ed6a9 commit 6931f37
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ <h2>Your hand points</h2>
<script src="src/gui/LeftMenu.js"></script>
<script src="src/gui/Popup.js"></script>
<script src="src/gui/TouchDoraDeletion.js"></script>
<script src="src/gui/TouchCombinaisonDeletion.js"></script>
<script src="src/gui/DragDropDoraDeletion.js"></script>
<script src="src/gui/DragDropCombinaisonDeletion.js"></script>

Expand Down
36 changes: 36 additions & 0 deletions src/gui/TouchCombinaisonDeletion.js
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));

0 comments on commit 6931f37

Please sign in to comment.