If using LS 6.x and you want to disable the stacked table view of the array-by-column on mobile devices...
1) Place this in your
custom.js file.
Code:
function maxDiff(qID, randomize, disableMobileView) {
// Identify some elements
var thisQuestion = $('#question'+qID);
var thisTable = $('table.subquestion-list:eq(0)', thisQuestion);
// Assign a new question class
$(thisQuestion).addClass('max-diff-array');
// Disable the mobile table view
if(disableMobileView) {
$(thisTable).removeClass('ls-answers').addClass('disable-mobile-view');
}
// Move the columns
$('thead tr:eq(0)', thisTable).prepend($('thead tr:eq(0) th:eq(1)', thisTable));
$('tr.answers-list', thisTable).each(function(i){
$('td.answer-item:eq(0)', this).prependTo(this);
});
// Random rows
if(randomize) {
var rowsArr = [];
$('tr.answers-list', thisTable).each(function(i){
$(this).attr('data-index', i);
rowsArr.push(i);
});
shuffleArray(rowsArr);
$(rowsArr).each(function(i){
$('tbody', thisTable).append($('tr[data-index="'+this+'"]', thisTable));
});
}
// Prevent clicking twice in the same row
$('input:radio', thisQuestion).on('click', function () {
$('input:radio', thisQuestion).prop('disabled', false);
$('input:radio:checked', thisQuestion).each(function(i) {
var thisRow = $(this).closest('tr.answers-list');
$('input:radio', thisRow).not(this).prop('disabled', true);
});
});
// Fix up the row classes
var rowClass = 1;
$('tr.answers-list', thisTable).each(function(i) {
$(this).addClass('array'+(2-(i%2)));
});
}
function shuffleArray(array) {
for (var i = array.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = array[i];
array[i] = array[j];
array[j] = temp;
}
return array;
}
2) Place this in your
custom.css file.
Code:
.max-diff-array tbody th.answertext {
text-align: center;
font-weight: normal;
}
.max-diff-array table.disable-mobile-view > tbody > tr > td {
vertical-align: middle;
}
.max-diff-array table.disable-mobile-view tbody td {
text-align: center;
}
3) Place this in the question source. Note the third parameter set to true.
Code:
<script type="text/javascript" data-author="Tony Partner">
$(document).on('ready pjax:scriptcomplete',function(){
// Call the maxDiff() function
// Set the second parameter to true for randomized rows
// Set the third parameter to true to disable the LS mobile table view
maxDiff({QID}, true, true);
});
</script>