Merge branch 'issue71' into 'k-fet'

Fix Issue71

Fix #71 

Ajoute la sélection des articles dans K-Psul à la souris/tactile

See merge request !80
This commit is contained in:
Aurélien Delobelle 2016-09-22 21:18:02 +02:00
commit 92903cd71f
2 changed files with 30 additions and 4 deletions

View file

@ -319,6 +319,11 @@ input[type=number]::-webkit-outer-spin-button {
padding-left:20px;
}
#articles_data .article:hover {
background:rgba(200,16,46,0.3);
cursor:pointer;
}
/* Second part - Left - bottom */
.kpsul_middle_left_bottom {

View file

@ -685,6 +685,12 @@ $(document).ready(function() {
return false;
}
// A utiliser après la sélection d'un article
function goToArticleNb() {
articleNb.val('1');
articleNb.focus().select();
}
articleSelect.on('keydown', function(e) {
var text = articleSelect.val();
// Comportement normal pour ces touches
@ -699,13 +705,28 @@ $(document).ready(function() {
}
return true;
}
if (updateMatchedArticles(text+e.key)) {
articleNb.val('1');
articleNb.focus().select();
}
if (updateMatchedArticles(text+e.key))
goToArticleNb();
return false;
});
function getArticleId($article) {
return $article.attr('id').split('-')[2];
}
function getArticleName($article) {
return $article.find('.name').text();
}
// Sélection des articles à la souris/tactile
articles_container.on('click', '.article', function() {
console.log('1');
articleId.val(getArticleId($(this)));
articleSelect.val(getArticleName($(this)));
displayMatchedArticles(articlesList);
goToArticleNb();
});
function is_nb_ok(nb) {
return /^[0-9]+$/.test(nb) && nb > 0 && nb <= 24;
}