Skip to content

Commit

Permalink
Fixed issue #14425: Improve Ranking speed without same height
Browse files Browse the repository at this point in the history
Dev: even with same height , speed is clearly impeoved (but not with a lot of rank)
  • Loading branch information
Shnoulle committed Jan 12, 2019
1 parent 06f3bf0 commit f722577
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion assets/packages/questions/ranking/scripts/ranking.js
Expand Up @@ -101,6 +101,7 @@ var RankingQuestion = function (options) {
updateDragDropRank = function() {
$('#question' + questionId + ' .select-item select').val('');
$('#sortable-rank-' + questionId + ' li').each(function (index) {
$('#question' + questionId + ' .select-item select').eq(index).data("old-val",$('#question' + questionId + ' .select-item select').eq(index).val());
$('#question' + questionId + ' .select-item select').eq(index).val($(this).data("value"));
});

Expand All @@ -111,7 +112,11 @@ var RankingQuestion = function (options) {
if ($(this).val() != "") {
$("#" + relevancename + (index+1) ).val("1");
}
$(this).trigger("change", { source: 'dragdrop' });
/* trigger change only if val is updated see #14425 */
if( (typeof $(this).data("old-val") == 'undefined' && $(this).val() != "") || ($(this).val() != $(this).data("old-val")) ) {
$(this).trigger("change", { source: 'dragdrop' });
$(this).data("old-val",$(this).val())
}
});
$('#sortable-rank-' + questionId + ' li').removeClass("text-error");
$('#sortable-choice-' + questionId + ' li').removeClass("text-error");
Expand All @@ -135,6 +140,8 @@ var RankingQuestion = function (options) {
$("#" + relevancename + (index+1)).val("1");
$('#sortable-choice-' + questionId + ' li#' + rankingID + $(this).val()).appendTo('#sortable-rank-' + questionId);
}
/* set old-val for updateDragDropRank see #14425 */
$(this).closest("select").data("old-val",$(this).closest("select").val());
});

updateDragDropRank(); // Update to reorder select
Expand Down

0 comments on commit f722577

Please sign in to comment.