iQuest JavaScript Source
function SingleButton() { //Single Answer Buttons
//Check for WCAG
if ($('#btnToggleWcag').val()==1) {
return false;
}
//Give defaultvalues if not specified
debug = (typeof debug === "undefined") ? false : debug;//Turn on debuging(true/false)
btnNumColumn = (typeof btnNumColumn === "undefined") ? 0 : btnNumColumn;//The number of buttons per row of buttons (0 = fit all on one line)
btnColor = (typeof btnColor === "undefined") ? '#FFB8FF' : btnColor;//The colour of buttons before they are clicked.
btnColorClick = (typeof btnColorClick === "undefined") ? '#99CCFF' : btnColorClick;//The colour of buttons when they are clicked.
btnHeight = (typeof btnHeight === "undefined") ? '150px' : btnHeight;//The height of the button.
btnWidth = (typeof btnWidth === "undefined") ? '150px' : btnWidth;//The width of the button.
btnVerticalAlign = (typeof btnVerticalAlign === "undefined") ? 'middle' : btnVerticalAlign;//Vertical alignment (top/middle/bottom)
btnTopSpace = (typeof btnTopSpace === "undefined") ? '15px' : btnTopSpace;//Set the space between the bottom of the question text and the buttons.
btnSpacing = (typeof btnSpacing === "undefined") ? '10px' : btnSpacing;//Set the spacing around the buttons.
btnRounded = (typeof btnRounded === "undefined") ? true : btnRounded;//Rounded corners on buttons (true/false)
btnBorderOn = (typeof btnBorderOn === "undefined") ? true : btnBorderOn;//Show 3D border around buttons (true/false).
btnBorderWidth = (typeof btnBorderWidth === "undefined") ? '4px' : btnBorderWidth;//Set the border width around the buttons.
btnGraphicAutoSize = (typeof btnGraphicAutoSize === "undefined") ? true : btnGraphicAutoSize;//Automatically size images to fit buttons (true/false).
btnTextColor = (typeof btnTextColor === "undefined") ? '#000000' : btnTextColor;//Set the color of the text displayed on the buttons.
btnCopyEditorStyle = (typeof btnCopyEditorStyle === "undefined") ? true : btnCopyEditorStyle;
btnFontSize = (typeof btnFontSize === "undefined") ? '14px' : btnFontSize;
btnFontWeight = (typeof btnFontWeight === "undefined") ? 'bold' : btnFontWeight;
btnFontStyle = (typeof btnFontStyle === "undefined") ? 'normal' : btnFontStyle;
btnGraphicBackground = (typeof btnGraphicBackground === "undefined") ? false : btnGraphicBackground;
btnHorizontalAlign = (typeof btnHorizontalAlign === "undefined") ? 'center' : btnHorizontalAlign;
btnHideText = (typeof btnHideText === "undefined") ? false : btnHideText;//If using images hide the text that will be available in the analysis (true/false).
btnAutoNext = (typeof btnAutoNext === "undefined") ? true : btnAutoNext;//Automatic advance to the next question when a button is clicked (true/false).
othPosition = (typeof othPosition === "undefined") ? 'bottom' : othPosition;//Position of open rows (top/bottom).
btnHoverFade = (typeof btnHoverFade === "undefined") ? true : btnHoverFade;
btnHoverFadeTime = (typeof btnHoverFadeTime === "undefined") ? 400 : btnHoverFadeTime;
quickMode = (typeof quickMode === "undefined") ? false : quickMode;
btnAutoStyle = (typeof btnAutoStyle === "undefined") ? 'LtBlue' : btnAutoStyle;
mobileIt();
//Clean up
var strHtml = ''; //Clear variable used for html
$('.cGridButtonContainer').remove(); //Remove html if already added
//Validate Screen to ensure correct Question type
//Exit function if question type not valid
var structOK = true;
//Number of questions on page should be 1
if ($('.cCellSubQuestion').length != 1) structOK = false;
//Check radio buttons on screen
if ($('.cRadio').length == 0) structOK = false;
if ($('.cCheck').length != 0) structOK = false;
//Check there are no open ended rows
//if ($('input:text').length!=0) {structOK = false;}
//if ($('textarea').length!=0) {structOK = false;}
//Check not a grid question
if ($('.cCellHeader').length != 0) structOK = false;
if (structOK == false) {
if (debug == true) alert('Structure not OK for iQuest e.q. Wrong question type. This iQuest requires a single choice question and one question per screen');
iQuestHelper('Structure not OK for iQuest e.q. Wrong question type. This iQuest requires a single choice question and one question per screen');
return false;
}
try {
//If btnNumColumn = 0 set to number of rows
if (btnNumColumn == 0) btnNumColumn = $('.cRowText').length;
//Create HTML
strHtml = '<div>';
var strStyle = '';
strHtml += '<table style="width: auto;"><tr>';
var intBtnCnt = 0;
var blnEndRow = false;
$('.cRowText').each(function () {
var alignStyle = "";
if ($(this).hasClass("textleft")) {
alignStyle = "text-align:left;";
}
else if ($(this).hasClass("textcenter")) {
alignStyle = "text-align:center;";
}
else if ($(this).hasClass("textright")) {
alignStyle = "text-align:right;";
}
strStyle = 'style="' + alignStyle;
if (typeof $(this).attr('style') !== 'undefined') {
strStyle += $(this).attr('style');
}
strStyle += '"';
strHtml += '<td alt="' + intBtnCnt + '" ' + strStyle + '>' + $(this).html() + '</td>';
if (parseInt(intBtnCnt + 1) % btnNumColumn == 0) { //end row depending on the number of buttons specified in the options
strHtml += '</tr>';
blnEndRow = true;
}
else {
blnEndRow = false;
}
intBtnCnt++;
});
if (blnEndRow == false) { strHtml += '</tr>'; }
strHtml += '</table>';
strHtml += '</div>';
$('#UpdatePanel1').append(strHtml);
strHtml = '';
if ($('input:text, textarea').length > 0) {
$('input:text').each(function () {
strHtml = '<table style="width:auto" align="center"><tr><td>' + $(this).parents().find('.cCell').html() + '</td><td><input type="text" size="' + $(this).attr('size') + '" value="' + $(this).attr('value') + '"></td></tr></table>';
});
$('textarea').each(function () {
strHtml = '<table style="width:auto" align="center"><tr><td>' + $(this).parents().find('.cCell').html() + '</td><td><textarea rows="' + $(this).attr('rows') + '" cols="' + $(this).attr('cols') + '"></textarea></td></tr></table>';
});
//Place the open field above or below
if (othPosition == 'top') { $('.cBtnTable').before(strHtml); }
else { $('.cBtnTable').after(strHtml); }
}
//Various formatting
$('.cBtnTable').css('width', 'auto');
$('.cBtnTable').css('margin-left', 'auto');
$('.cBtnTable').css('margin-right', 'auto');
$('.cBtnTable').css('border-collapse', 'separate');
$('.cSingleBtn').css('width', '75px');
$('.cSingleBtn').css('height', '75px');
$('.cSingleBtn').css('padding-left', '5px');
$('.cSingleBtn').css('padding-top', '5px');
$('.cSingleBtn').css('cursor', 'pointer');
if (btnHoverFade == true) {
$('.cSingleBtn').hover(function () {
$(this).stop().animate({ opacity: "0.8" }, btnHoverFadeTime);
},
function () {
$(this).stop().animate({ opacity: "1" }, btnHoverFadeTime);
});
}
//Formatting from options
$('.cSingleBtn').css('background-color', btnColor);
$('.cSingleBtn').removeClass('btnChecked');
$('.cSingleBtn').css('height', btnHeight);
$('.cSingleBtn').css('width', btnWidth);
$('.cSingleBtn').css('min-width', btnWidth);
$('.cSingleBtn').css('color', btnTextColor);
$('.cSingleBtn').css('vertical-align', btnVerticalAlign);
$('.cBtnTable').css('margin-top', btnTopSpace);
$('.cBtnTable').css('border-spacing', btnSpacing);
$('.cSingleBtn').css('border-right', btnBorderWidth + ' solid #696969');
$('.cSingleBtn').css('border-bottom', btnBorderWidth + ' solid #696969');
$('.cSingleBtn').css('border-top', btnBorderWidth + ' solid #E5E5E5');
$('.cSingleBtn').css('border-left', btnBorderWidth + ' solid #E5E5E5');
if (btnGraphicAutoSize == true) $('.cSingleBtn').find('img').css({ 'width': '100%' });
if (btnRounded != false) $('.cSingleBtn').css({ '-moz-border-radius': '20px', '-webkit-border-radius': '20px', '-khtml-border-radius': '20px', 'border-radius': '20px' });
if (btnBorderOn == false) $('.cSingleBtn').css('border', '0px solid transparent');
if (btnGraphicBackground == true) {
$('.cSingleBtn').each(function () {
strURL = $(this).find('img').eq(0).attr('src');
$(this).find('img').eq(0).remove();
$(this).css('background', btnColor + ' url("' + strURL + '") no-repeat center center');
$(this).css('background-size', '100% 100%');
});
}
if (btnCopyEditorStyle != true) {
$('.cSingleBtn').find('strong').contents().unwrap();
$('.cSingleBtn').find('span').css('text-align', '');
$('.cSingleBtn').find('span').css('font-size', '');
$('.cSingleBtn').css('font-size', btnFontSize);
$('.cSingleBtn').css('font-style', btnFontStyle);
$('.cSingleBtn').css('font-weight', btnFontWeight);
$('.cSingleBtn').css('text-align', btnHorizontalAlign);
}
if (btnHideText != false) {
$('.cSingleBtn').css({ 'font-size': '0px', 'color': 'transparent' });
$('.cSingleBtn').find('span').css({ 'font-size': '0px', 'color': 'transparent' });
}
if (quickMode == true) {
switch (btnAutoStyle) {
case 'DkBlue':
fncSetBtnBackground('Scripts/QuickMode/BtnDarkBlue.png', '.cSingleBtn');
break;
case 'Green':
fncSetBtnBackground('Scripts/QuickMode/BtnGreen.png', '.cSingleBtn');
break;
case 'LtGrey':
fncSetBtnBackground('Scripts/QuickMode/BtnLightGrey.png', '.cSingleBtn');
break;
case 'LtBlue':
fncSetBtnBackground('Scripts/QuickMode/BtnLightBlue.png', '.cSingleBtn');
break;
case 'Orange':
fncSetBtnBackground('Scripts/QuickMode/BtnOrange.png', '.cSingleBtn');
break;
case 'Red':
fncSetBtnBackground('Scripts/QuickMode/BtnRed.png', '.cSingleBtn');
break;
case 'Yellow':
fncSetBtnBackground('Scripts/QuickMode/BtnYellow.png', '.cSingleBtn');
break;
case 'DkBlueOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1DarkBlue.png', '.cSingleBtn');
break;
case 'DkGreyOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1DarkGrey.png', '.cSingleBtn');
break;
case 'GreenOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Green.png', '.cSingleBtn');
break;
case 'LtBlueOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1LightBlue.png', '.cSingleBtn');
break;
case 'LtGreyOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1LightGrey.png', '.cSingleBtn');
break;
case 'MagentaOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Magenta.png', '.cSingleBtn');
break;
case 'OrangeOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Orange.png', '.cSingleBtn');
break;
case 'RedOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Red.png', '.cSingleBtn');
break;
case 'YellowOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Yellow.png', '.cSingleBtn');
break;
}
}
//Set Pevious Answers
//Add colouring to cells answered
intBtnCnt = 0;
$('.cCell input').each(function () {
if ($(this).prop('checked')) {
$('.cSingleBtn').eq(intBtnCnt).css('background-color', btnColorClick).addClass('btnChecked');
}
intBtnCnt++;
});
//Transfer previous answers to new open field if there is any data
if ($('textarea').length != 0) $('textarea').eq(1).val($('textarea').eq(0).val());
//Set boolean variable for presence of other Specify text existing
var blnOtherSpecify = false; //Default value
if ($('input:text, textarea').length > 0) { //Other specify exists
if ($('input:text, textarea').eq(0).val().length != 0) blnOtherSpecify = true; //Text exists
}
//Hide question
$('.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').hide();
//Hide Next Button if no text in open ended answer
if (blnOtherSpecify == false) {
fncHideNext();
}
$(document).on("click", ".cSingleBtn", function () {
//$('.cSingleBtn').live('click',function () {
//Set background.
if (quickMode != true) {
$('.cSingleBtn').css('background-color', btnColor).removeClass('btnChecked'); //Clear all answered
}
else {
$('.cSingleBtn').css('background-color', 'transparent');
}
$(this).css('background-color', btnColorClick).addClass('btnChecked');
$(this).effect("pulsate", {}, 10);
var intInpID = $(this).attr('alt');
$('.cRadio').eq(intInpID).prop('checked', true);
if (!(isMobile && btnAutoNext == true)) {
//Show Next Button
fncShowNext();
}
//Clear Text boxes
$('input:text, textarea').val('');
if (btnAutoNext == true) {
//Click Next
$('#btnNext').click();
}
});
$(document).on("keyup", "input:text, textarea", function () {
//$('input:text, textarea').live('keyup',function() {
if (quickMode != true) {
$('.cSingleBtn').css('background-color', btnColor).removeClass('btnChecked'); //Clear all answered
}
else {
$('.cSingleBtn').css('background-color', 'transparent');
}
$('.cRadio').prop('checked', false);
$('input:text, textarea').eq(0).val($(this).val());
//Show Next button.
fncShowNext();
});
$('#btnNext').on('click', function () {
//Clean up
strHtml = ''; //Clear variable used for html
$(document).off("click", ".cSingleBtn");
//$('.cSingleBtn').die('click');
$('#btnNext').off('click');
$('#btnPrevious').off('click');
$(document).off("keyup", "input:text, textarea");
//$('input:text, textarea').die('keyup');
});
$('#btnPrevious').on('click', function () {
//Clean up
strHtml = ''; //Clear variable used for html
$('.cGridButtonContainer').remove(); //Remove html if already added
$(document).off("click", ".cSingleBtn");
//$('.cSingleBtn').die('click');
$('#btnNext').off('click');
$('#btnPrevious').off('click');
$(document).off("keyup", "input:text, textarea");
//$('input:text, textarea').die('keyup');
});
}
catch (err) {
if (debug == true) {
txt = "There was an error on this page.\n\n";
txt += "Error description: " + err.message + "\n\n";
txt += "Click OK to continue.\n\n";
alert(txt);
}
//Clean up
strHtml = ''; //Clear variable used for html
$('.cGridButtonContainer').remove(); //Remove html if already added
$(document).off("click", ".cSingleBtn");
//$('.cSingleBtn').die('click');
$('#btnNext').off('click');
$('#btnPrevious').off('click');
$(document).off("keyup", "input:text, textarea");
//$('input:text, textarea').die('keyup');
//Show question
$('.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').show();
//Show Next button
fncShowNext();
}
}
function MultiButton() { //Multiple Answer Buttons
//Check for WCAG
if ($('#btnToggleWcag').val()==1) {
return false;
}
//Give defaultvalues if not specified
debug = (typeof debug === "undefined") ? false : debug;//Turn on debuging(true/false)
btnNumColumn = (typeof btnNumColumn === "undefined") ? 0 : btnNumColumn;//The number of buttons per row of buttons (0 = fit all on one line)
btnColor = (typeof btnColor === "undefined") ? '#FFB8FF' : btnColor;//The colour of buttons before they are clicked.
btnColorClick = (typeof btnColorClick === "undefined") ? '#99CCFF' : btnColorClick;//The colour of buttons when they are clicked.
btnHeight = (typeof btnHeight === "undefined") ? '150px' : btnHeight;//The height of the button.
btnWidth = (typeof btnWidth === "undefined") ? '150px' : btnWidth;//The width of the button.
btnVerticalAlign = (typeof btnVerticalAlign === "undefined") ? 'middle' : btnVerticalAlign;//Vertical alignment (top/middle/bottom)
btnTopSpace = (typeof btnTopSpace === "undefined") ? '15px' : btnTopSpace;//Set the space between the bottom of the question text and the buttons.
btnSpacing = (typeof btnSpacing === "undefined") ? '10px' : btnSpacing;//Set the spacing around the buttons.
btnRounded = (typeof btnRounded === "undefined") ? true : btnRounded;//Rounded corners on buttons (true/false)
btnBorderOn = (typeof btnBorderOn === "undefined") ? true : btnBorderOn;//Show 3D border around buttons (true/false).
btnBorderWidth = (typeof btnBorderWidth === "undefined") ? '4px' : btnBorderWidth;//Set the border width around the buttons.
btnGraphicAutoSize = (typeof btnGraphicAutoSize === "undefined") ? true : btnGraphicAutoSize;//Automatically size images to fit buttons (true/false).
btnHideText = (typeof btnHideText === "undefined") ? false : btnHideText;//If using images hide the text that will be available in the analysis (true/false).
btnTextColor = (typeof btnTextColor === "undefined") ? '#000000' : btnTextColor;//Set the color of the text displayed on the buttons.
btnCopyEditorStyle = (typeof btnCopyEditorStyle === "undefined") ? true : btnCopyEditorStyle;
btnFontSize = (typeof btnFontSize === "undefined") ? '14px' : btnFontSize;
btnFontWeight = (typeof btnFontWeight === "undefined") ? 'bold' : btnFontWeight;
btnFontStyle = (typeof btnFontStyle === "undefined") ? 'normal' : btnFontStyle;
btnHorizontalAlign = (typeof btnHorizontalAlign === "undefined") ? 'center' : btnHorizontalAlign;
btnGraphicBackground = (typeof btnGraphicBackground === "undefined") ? false : btnGraphicBackground;
othPosition = (typeof othPosition === "undefined") ? 'bottom' : othPosition;//Position of open rows (top/bottom).
btnHoverFade = (typeof btnHoverFade === "undefined") ? true : btnHoverFade;
btnHoverFadeTime = (typeof btnHoverFadeTime === "undefined") ? 400 : btnHoverFadeTime;
quickMode = (typeof quickMode === "undefined") ? false : quickMode;
btnAutoStyle = (typeof btnAutoStyle === "undefined") ? 'LtBlue' : btnAutoStyle;
mobileIt(); //Change various settings if mobile device
//Clean up
var strHtml = ''; //Clear variable used for html
$('.cGridButtonContainer').remove(); //Remove html if already added
//Validate Screen to ensure correct Question type
//Exit function if question type not valid
structOK = true;
//Number of questions on page should be 1
if ($('.cCellSubQuestion').length != 1) structOK = false;
//Check checkboxes buttons on screen
if ($('.cCheck').length == 0) structOK = false;
//Check not a grid question
if ($('.cCellHeader').length != 0) structOK = false;
if ($('input:text, textarea').hasClass('exclusive') == true) structOK = false;
if (structOK == false) {
if (debug == true) alert('Structure not OK for iQuest e.q. Wrong question type. This iQuest requires a multiple choice question and one question per screen');
iQuestHelper('Structure not OK for iQuest e.q. Wrong question type. This iQuest requires a multiple choice question and one question per screen');
return false;
}
try {
//If btnNumColumn = 0 set to number of rows
if (btnNumColumn == 0) btnNumColumn = $('.cRowText').length;
//Create HTML
strHtml = '<div>';
var strStyle = '';
strHtml += '<table style="width: auto;"><tr>';
var intBtnCnt = 0;
var blnEndRow = false;
$('.cRowText').each(function () {
var alignStyle = "";
if ($(this).hasClass("textleft")) {
alignStyle = "text-align:left;";
}
else if ($(this).hasClass("textcenter")) {
alignStyle = "text-align:center;";
}
else if ($(this).hasClass("textright")) {
alignStyle = "text-align:right;";
}
strStyle = 'style="' + alignStyle;
if (typeof $(this).attr('style') !== 'undefined') {
strStyle += $(this).attr('style');
}
strStyle += '"';
strHtml += '<td alt="' + intBtnCnt + '" ' + strStyle + '>' + $(this).html() + '</td>';
if (parseInt(intBtnCnt + 1) % btnNumColumn == 0) { //end row depending on the number of buttons specified in the options
strHtml += '</tr>';
blnEndRow = true;
}
else {
blnEndRow = false;
}
intBtnCnt++;
});
if (blnEndRow == false) { strHtml += '</tr>'; }
strHtml += '</table>';
strHtml += '</div>';
$('#UpdatePanel1').append(strHtml);
//Add open rows
strHtml = '';
var numOpenRows = 0; //Number of open rows
if ($('input:text, textarea').length > 0) {
strHtml = '<table style="width:auto" align="center">';
$('input:text, textarea').each(function () {
numOpenRows++;
if ($(this).is('input:text')) {
strHtml += '<tr><td>' + $(this).parents().find('.cCell').html() + '</td><td><input type="text" size="' + $(this).attr('size') + '" value="' + $(this).attr('value') + '"/></td></tr>';
}
else {
strHtml += '<tr><td>' + $(this).parents().find('.cCell').html() + '</td><td><textarea class="cAnimationTextArea" rows="' + $(this).attr('rows') + '" cols="' + $(this).attr('cols') + '"></textarea></td></tr>';
}
});
strHtml += '</table>';
//Add the open rows above or below
if (othPosition == 'top') { $('.cBtnTable').before(strHtml); }
else { $('.cBtnTable').after(strHtml); }
}
//Various formatting
$('.cBtnTable').css('width', 'auto');
$('.cBtnTable').css('margin-left', 'auto');
$('.cBtnTable').css('margin-right', 'auto');
$('.cBtnTable').css('border-collapse', 'separate');
$('.cMultiBtn').css('width', '75px');
$('.cMultiBtn').css('height', '75px');
$('.cMultiBtn').css('padding-left', '5px');
$('.cMultiBtn').css('padding-top', '5px');
//Set cursor style
$('.cMultiBtn').css('cursor', 'pointer');
if (btnHoverFade == true) {
$('.cMultiBtn').hover(function () {
$(this).stop().animate({ opacity: "0.8" }, btnHoverFadeTime);
},
function () {
$(this).stop().animate({ opacity: "1" }, btnHoverFadeTime);
});
}
//Formatting from options
$('.cMultiBtn').css('background-color', btnColor);
$('.cMultiBtn').removeClass('btnChecked');
$('.cMultiBtn').css('height', btnHeight);
$('.cMultiBtn').css('width', btnWidth);
$('.cMultiBtn').css('min-width', btnWidth);
$('.cMultiBtn').css('color', btnTextColor);
$('.cMultiBtn').css('border-right', btnBorderWidth + ' solid #696969');
$('.cMultiBtn').css('border-bottom', btnBorderWidth + ' solid #696969');
$('.cMultiBtn').css('border-top', btnBorderWidth + ' solid #E5E5E5');
$('.cMultiBtn').css('border-left', btnBorderWidth + ' solid #E5E5E5');
$('.cMultiBtn').css('vertical-align', btnVerticalAlign);
$('.cBtnTable').css('margin-top', btnTopSpace);
$('.cBtnTable').css('border-spacing', btnSpacing);
if (btnGraphicAutoSize == true) $('.cMultiBtn').find('img').css({ 'width': '100%' });
if (btnRounded != false) $('.cMultiBtn').css({ '-moz-border-radius': '20px', '-webkit-border-radius': '20px', '-khtml-border-radius': '20px', 'border-radius': '20px' });
if (btnBorderOn == false) $('.cMultiBtn').css('border', '0px solid transparent');
if (btnGraphicBackground == true) {
$('.cMultiBtn').each(function () {
strURL = $(this).find('img').eq(0).attr('src');
$(this).find('img').eq(0).remove();
$(this).css('background', btnColor + ' url("' + strURL + '") no-repeat center center');
$(this).css('background-size', '100% 100%');
});
}
if (btnCopyEditorStyle != true) {
$('.cMultiBtn').find('strong').contents().unwrap();
$('.cMultiBtn').find('span').css('text-align', '');
$('.cMultiBtn').find('span').css('font-size', '');
$('.cMultiBtn').css('font-size', btnFontSize);
$('.cMultiBtn').css('font-style', btnFontStyle);
$('.cMultiBtn').css('font-weight', btnFontWeight);
$('.cMultiBtn').css('text-align', btnHorizontalAlign);
}
if (btnHideText != false) {
$('.cMultiBtn').css({ 'font-size': '0px', 'color': 'transparent' });
$('.cMultiBtn').find('span').css({ 'font-size': '0px', 'color': 'transparent' });
}
if (quickMode == true) {
switch (btnAutoStyle) {
case 'DkBlue':
fncSetBtnBackground('Scripts/QuickMode/BtnDarkBlue.png', '.cMultiBtn');
break;
case 'Green':
fncSetBtnBackground('Scripts/QuickMode/BtnGreen.png', '.cMultiBtn');
break;
case 'LtGrey':
fncSetBtnBackground('Scripts/QuickMode/BtnLightGrey.png', '.cMultiBtn');
break;
case 'LtBlue':
fncSetBtnBackground('Scripts/QuickMode/BtnLightBlue.png', '.cMultiBtn');
break;
case 'Orange':
fncSetBtnBackground('Scripts/QuickMode/BtnOrange.png', '.cMultiBtn');
break;
case 'Red':
fncSetBtnBackground('Scripts/QuickMode/BtnRed.png', '.cMultiBtn');
break;
case 'Yellow':
fncSetBtnBackground('Scripts/QuickMode/BtnYellow.png', '.cMultiBtn');
break;
case 'DkBlueOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1DarkBlue.png', '.cMultiBtn');
break;
case 'DkGreyOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1DarkGrey.png', '.cMultiBtn');
break;
case 'GreenOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Green.png', '.cMultiBtn');
break;
case 'LtBlueOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1LightBlue.png', '.cMultiBtn');
break;
case 'LtGreyOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1LightGrey.png', '.cMultiBtn');
break;
case 'MagentaOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Magenta.png', '.cMultiBtn');
break;
case 'OrangeOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Orange.png', '.cMultiBtn');
break;
case 'RedOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Red.png', '.cMultiBtn');
break;
case 'YellowOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Yellow.png', '.cMultiBtn');
break;
}
}
//Set Pevious Answers
//Add colouring to cells answered
intBtnCnt = 0;
$('.cCell input').each(function () {
if ($(this).prop('checked')) $('.cMultiBtn').eq(intBtnCnt).css('background-color', btnColorClick).addClass('btnChecked');
intBtnCnt++;
});
//Transfer previous answers to new open field if there is any data
$('input:text, textarea').not('.cAnimationText, .cAnimationTextArea').each(function (i) {
$('.cAnimationText, .cAnimationTextArea').eq(i).val($(this).val());
});
//Hide question
$('.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').css('display', 'none');
//Add dummy next button
$('#btnNext').before('<input id="btnNext2" name="btnNext2" value="Next" type="button">');
$('#btnNext2').val($('#btnNext').val());
//Hide Next Button
fncHideNext();
//Button Click Event
$(document).on("click", ".cMultiBtn", function () {
//$('.cMultiBtn').live('click',function () {
var intBtnNum = 0;
var intInpID = $(this).attr('alt');
var strType = $('.cCell input').eq(intInpID).prop('type');
if (strType == 'checkbox') { //Answer type checkbox
if ($('.cCell input').eq(intInpID).prop('checked')) { //already answered so remove answer
$('.cCell input').eq(intInpID).prop('checked', false);
if (!$('.cCell input').eq(intInpID).prop('checked')) { //If remove answer worked format button
if (quickMode != true) {
$(this).css('background-color', btnColor).removeClass('btnChecked');
}
else {
$(this).css('background-color', 'transparent');
}
}
}
else { //Not answered
$('.cCell input').eq(intInpID).prop('checked', true);
if ($('.cCell input').eq(intInpID).prop('checked')) {
$(this).css('background-color', btnColorClick).addClass('btnChecked');
if ($('.unified').length > 0) { $('.cCell input').eq(intInpID).parent().addClass('checked'); }
}
}
intBtnNum = 0;
//clear radio
for (i = 0; i <= (intBtnCnt - 1); i++) {
if ($('.cCell input').eq(i).prop('type') != 'checkbox') {
if (quickMode != true) {
$('.cMultiBtn').eq(intBtnNum).css('background-color', btnColor).removeClass('btnChecked');
}
else {
$('.cMultiBtn').eq(intBtnNum).css('background-color', 'transparent');
}
$('.cCell input').eq(i).prop('checked', false);
}
intBtnNum++;
}
}
else { //Answer is a radio
//Change all buttons to unclicked
if (quickMode != true) {
$('.cMultiBtn').css('background-color', btnColor).removeClass('btnChecked');
}
else {
$('.cMultiBtn').css('background-color', 'transparent');
}
if ($('.cCell input').eq(intInpID).prop('checked')) { //Already answered
$('.cCell input').eq(intInpID).prop('checked', false);
if ($('.unified').length > 0) { $('.cCell input').eq(intInpID).parent().addClass('checked'); }
}
else { //Not already answered
$(this).css('background-color', btnColorClick).addClass('btnChecked');
$('.cCell input').eq(intInpID).prop('checked', true);
if ($('.unified').length > 0) { $('.cCell input').eq(intInpID).parent().addClass('checked'); }
//clear other answers
intBtnNum = 0;
for (i = 0; i <= (intBtnCnt - 1); i++) {
if (i != intInpID) {
if (quickMode != true) {
$('.cMultiBtn').eq(i).css('background-color', btnColor).removeClass('btnChecked');
}
else {
$('.cMultiBtn').eq(i).css('background-color', 'transparent');
}
$('.cCell input').eq(i).prop('checked', false);
if ($('.unified').length > 0) { $('.cCell input').eq(i).parent().removeClass('checked'); }
}
intBtnNum++;
}
}
//Remove any open answers
$('input:text, textarea').val('');
}
$(this).effect("pulsate", {}, 10);
});
$(document).on("keyup", ".cAnimationText, .cAnimationTextArea", function () {
//$('.cAnimationText, .cAnimationTextArea').live('keyup',function() {
// What if open is exclusive? $('.cSingleBtn').css('background-color',btnColor);
// $('.cRadio').attr('checked', false);
//alert($(this).index('.cAnimationText, .cAnimationTextArea'));
$('input:text, textarea').eq($(this).index('.cAnimationText, .cAnimationTextArea')).val($(this).val());
intBtnNum = 0;
//clear radio
for (i = 0; i <= (intBtnCnt - 1); i++) {
if ($('.cCell input').eq(i).prop('type') != 'checkbox') {
if (quickMode != true) {
$('.cMultiBtn').eq(intBtnNum).css('background-color', btnColor).removeClass('btnChecked');
}
else {
$('.cMultiBtn').eq(intBtnNum).css('background-color', 'transparent');
}
$('.cCell input').eq(i).prop('checked', false);
}
intBtnNum++;
}
});
$('#btnPrevious').on('click', function () {
strHtml = ''; //Clear variable used for html
$(document).off("click", "#btnNext2");
//$('#btnNext2').die('click');
$(document).off("click", ".cMultiBtn");
//$('.cMultiBtn').die('click');
$('#btnNext2').remove();
$('#btnPrevious').off('click');
$(document).off("keyup", "input:text, textarea");
//$('input:text, textarea').die('keyup');
});
//#btnNext2 is a dummy next button used to finalise animation before next button is pressed
$(document).on("click", "#btnNext2", function () {
//$('#btnNext2').live('click',function () {
strHtml = ''; //Clear variable used for html
$(document).off("click", "#btnNext2");
//$('#btnNext2').die('click');
$(document).off("click", ".cMultiBtn");
//$('.cMultiBtn').die('click');
$('#btnNext2').remove();
$('#btnPrevious').off('click');
$(document).off("keyup", "input:text, textarea");
//$('input:text, textarea').die('keyup');
//Show Next button if click fails.
fncShowNext();
$('#btnNext').click();
});
}
catch (err) {
if (debug == true) {
txt = "There was an error on this page.\n\n";
txt += "Error description: " + err.message + "\n\n";
txt += "Click OK to continue.\n\n";
alert(txt);
}
//Clean up
strHtml = ''; //Clear variable used for html
$('.cGridButtonContainer').remove(); //Remove html if already added
$(document).off("click", "#btnNext2");
//$('#btnNext2').die('click');
$(document).off("click", ".cMultiBtn");
//$('.cMultiBtn').die('click');
$('#btnNext2').remove();
$('#btnPrevious').off('click');
$(document).off("keyup", "input:text, textarea");
//$('input:text, textarea').die('keyup');
//Show question
$('.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').css('display', '');
//Show Next button.
fncShowNext();
}
}
function horiSlider() { // Creates a basic slider for a Grid Single
//Check for WCAG
if ($('#btnToggleWcag').val()==1) {
return false;
}
sldHeight = (typeof sldHeight === "undefined") ? "30px" : sldHeight; //Slider Height
sldBackground = (typeof sldBackground === "undefined") ? "#F7F6F7" : sldBackground; //Slider background colour
sldFillColour = (typeof sldFillColour === "undefined") ? "#E15200" : sldFillColour; //Slider fill colour
sldHandleColour = (typeof sldHandleColour === "undefined") ? "#8E8075" : sldHandleColour; //Slider handle colour
intExclColumnLeft = (typeof intExclColumnLeft === "undefined") ? 0 : intExclColumnLeft; //Exclude Columns Left
intExclColumnRight = (typeof intExclColumnRight === "undefined") ? 0 : intExclColumnRight; //Exclude Columns Right
debug = (typeof debug === "undefined") ? false : debug; //Debug mode
//Exit function if question type not valid
structOK = true;
//Number of questions on page should be 1
if ($('.cCellSubQuestion').length != 1) structOK = false;
//Check radio buttons on screen
if ($('.cRadio').length == 0) structOK = false;
if ($('.cCheck').length != 0) structOK = false;
// Check answer type rn
if (structOK) {
var strID = $('.cRadio').eq(0).attr('id');
if (strID.substr(0, 2) != 'rn') structOK = false;
}
if (structOK == false) {
if (debug == true) alert('Structure not OK for iQuest e.q. Wrong question type, this iQuest requires a single choice grid question');
iQuestHelper('Structure not OK for iQuest e.q. More than one question per screen');
return false;
}
try {
var intNumCol = $('.cCellHeader:not(.cCellFirstHeader)').length; //Number of Columns
if ((intExclColumnLeft + intExclColumnRight) >= (intNumCol - 1)) {
if (debug == true) alert('Too many columns excluded to create slider.');
iQuestHelper('Too many columns excluded to create slider.');
return false;
}
var strHTML = '';
var intInitVal = 0;
//Hide Answer Cells
$('.cCell').hide();
var intSpan = intNumCol - (intExclColumnLeft + intExclColumnRight);
var strHTML = '';
$('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').each(function (i) {
strHTML = '<td colspan="' + intSpan + '"><div alt="' + i + '" style="height: ' + sldHeight + '" ></div></td>';
if (intExclColumnLeft > 0) {
$(this).find('.cCell:lt(' + intExclColumnLeft + ')').show();
$(this).find('.cCell:lt(' + intExclColumnLeft + ')').find('.cRadio').addClass('cRadioExcl');
$(this).find('.cCell:lt(' + intExclColumnLeft + ')').find('.cRadio').attr('trow', i);
}
if (intExclColumnRight > 0) {
intShowRight = intNumCol - (intExclColumnRight + 1);
$(this).find('.cCell:gt(' + intShowRight + ')').show();
$(this).find('.cCell:gt(' + intShowRight + ')').find('.cRadio').addClass('cRadioExcl');
$(this).find('.cCell:gt(' + intShowRight + ')').find('.cRadio').attr('trow', i);
}
$(this).find('.cCell:eq(' + intExclColumnLeft + ')').before(strHTML);
});
$('.cSlider').slider({
animate: true,
range: "min",
min: 1,
max: 999,
value: intInitVal,
stop: function () {
//Move slider to centre of the column
var intStep = parseInt(1000 / intSpan); //Scale is dived into steps that relate to the number of columns
var intStepMid = intStep / 2; //The middle of a step
var intCode = parseInt($(this).slider('option', 'value') / intStep); //The relevant column calculated on where the slider is stopped
if (intCode >= intSpan) { intCode = intSpan - 1; }
var intNewVal = (intCode * intStep) + intStepMid; //The new slider value based on putting the slider into the centre of the column
//If the slide is not in the centre of the column move it to the centre
if ($(this).slider('option', 'value') != intNewVal) {
$(this).slider('option', 'value', intNewVal);
}
// Set Answers
var intRow = $(this).attr('alt');
var objCurrRow = $('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').eq(intRow);
$(objCurrRow).find('.checked').removeClass('checked');
$(objCurrRow).find('.cRadio').eq(intCode + intExclColumnLeft).prop('checked', true);
}
});
$('.cRadioExcl').change(function () {
$('.cSlider').eq($(this).attr('trow')).slider('option', 'value', 0);
});
$('.cRadioExcl').keydown(function () {
$('.cSlider').eq($(this).attr('trow')).slider('option', 'value', 0);
});
var sldHandleHeight = parseInt($('.cSlider').eq(0).height()) + 8;
$('.ui-slider .ui-slider-handle').css('height', sldHandleHeight + 'px');
$('.ui-slider-range').css('background', sldFillColour);
$('.cSlider').css('background', sldBackground);
$('.cSlider').css('margin-bottom', '5px');
$('.ui-slider-handle').css('background', sldHandleColour);
//Set Previous answers
var intChecked = 0;
$('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').each(function (i) {
intChecked = $(this).find('.cRadio:checked').length;
if (intChecked != 0) {
var radioButtons = $(this).find('.cRadio');
var selectedIndex = radioButtons.index(radioButtons.filter(':checked'));
if ($(this).find('.cRadio').eq(selectedIndex).hasClass('cRadioExcl') == false) {
selectedIndex = selectedIndex - intExclColumnLeft;
var intStep = parseInt(1000 / intSpan); //Scale is dived into steps that relate to the number of columns
var intStepMid = intStep / 2; //The middle of a step
var intNewVal = (selectedIndex * intStep) + intStepMid; //The new slider value based on putting the slider into the centre of the column
$(this).find('.cSlider').slider('option', 'value', intNewVal);
}
}
});
}
catch (err) {
if (debug == true) {
txt = "There was an error on this page.\n\n";
txt += "Error description: " + err.message + "\n\n";
txt += "Click OK to continue.\n\n";
alert(txt);
}
//Clean up
$('.cCell').show();
$('.cSliderCell').remove();
}
}
function grdSlider() { // Creates a graded colour slider for a Grid Single
//Check for WCAG
if ($('#btnToggleWcag').val()==1) {
return false;
}
sldHeight = (typeof sldHeight === "undefined") ? "30px" : sldHeight; //Slider Height
sldHandleColour = (typeof sldHandleColour === "undefined") ? "#8E8075" : sldHandleColour; //Slider handle colour
sldColDir = (typeof sldColDir === "undefined") ? "1" : sldColDir; //Grading Direction
intExclColumnLeft = (typeof intExclColumnLeft === "undefined") ? 0 : intExclColumnLeft; //Exclude Columns Left
intExclColumnRight = (typeof intExclColumnRight === "undefined") ? 0 : intExclColumnRight; //Exclude Columns Right
debug = (typeof debug === "undefined") ? false : debug; //Debug mode
//Exit function if question type not valid
structOK = true;
//Number of questions on page should be 1
if ($('.cCellSubQuestion').length != 1) structOK = false;
//Check radio buttons on screen
if ($('.cRadio').length == 0) structOK = false;
if ($('.cCheck').length != 0) structOK = false;
// Check answer type rn
if (structOK) {
var strID = $('.cRadio').eq(0).attr('id');
if (strID.substr(0, 2) != 'rn') structOK = false;
}
//Check Image count = column count
if (structOK == false) {
if (debug == true) alert('Structure not OK for iQuest e.q. Wrong question type, this iQuest requires a single choice grid question');
iQuestHelper('Structure not OK for iQuest e.q. More than one question per screen');
return false;
}
try {
var intNumCol = $('.cCellHeader:not(.cCellFirstHeader)').length; //Number of Columns
if ((intExclColumnLeft + intExclColumnRight) >= (intNumCol - 1)) {
if (debug == true) alert('Too many columns excluded to create slider.');
iQuestHelper('Too many columns excluded to create slider.');
return false;
}
var intInitVal = 0;
//Hide Answer Cells
$('.cCell').hide();
var intSpan = intNumCol - (intExclColumnLeft + intExclColumnRight);
var strHTML = '';
$('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').each(function (i) {
strHTML = '<td colspan="' + intSpan + '"><div id="Slider' + i + '" alt="' + i + '" style="height: ' + sldHeight + '" ></div></td>';
if (intExclColumnLeft > 0) {
$(this).find('.cCell:lt(' + intExclColumnLeft + ')').show();
$(this).find('.cCell:lt(' + intExclColumnLeft + ')').find('.cRadio').addClass('cRadioExcl');
$(this).find('.cCell:lt(' + intExclColumnLeft + ')').find('.cRadio').attr('trow', i);
}
if (intExclColumnRight > 0) {
intShowRight = intNumCol - (intExclColumnRight + 1);
$(this).find('.cCell:gt(' + intShowRight + ')').show();
$(this).find('.cCell:gt(' + intShowRight + ')').find('.cRadio').addClass('cRadioExcl');
$(this).find('.cCell:gt(' + intShowRight + ')').find('.cRadio').attr('trow', i);
}
$(this).find('.cCell:eq(' + intExclColumnLeft + ')').before(strHTML);
});
$('.cSlider').slider({
animate: true,
range: "min",
min: 1,
max: 999,
value: intInitVal,
stop: function () {
//Move slider to centre of the column
var intStep = parseInt(1000 / intSpan); //Scale is dived into steps that relate to the number of columns
var intStepMid = intStep / 2; //The middle of a step
var intCode = parseInt($(this).slider('option', 'value') / intStep); //The relevant column calculated on where the slider is stopped
if (intCode >= intSpan) { intCode = intSpan - 1; }
var intNewVal = (intCode * intStep) + intStepMid; //The new slider value based on putting the slider into the centre of the column
//If the slide is not in the centre of the column move it to the centre
if ($(this).slider('option', 'value') != intNewVal) {
$(this).slider('option', 'value', intNewVal);
}
// Set Answers
var intRow = $(this).attr('alt');
var objCurrRow = $('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').eq(intRow);
$(objCurrRow).find('.checked').removeClass('checked');
$(objCurrRow).find('.cRadio').eq(intCode + intExclColumnLeft).prop('checked', true);
},
slide: function () {
if (sldColDir == 1) {
var intCode = parseInt($(this).slider('option', 'value') / 100); //Column score converted to colour scale value 1 to 10
sliderID = '#Slider' + $(this).attr('alt') + ' .ui-slider-range';
$(sliderID).css('background', '#' + ColNegPos(intCode));
}
else {
var intCode = parseInt($(this).slider('option', 'value') / 100); //Column score converted to colour scale value 1 to 10
sliderID = '#Slider' + $(this).attr('alt') + ' .ui-slider-range';
$(sliderID).css('background', '#' + ColPosNeg(intCode));
}
},
change: function () {
if (sldColDir == 1) {
var intCode = parseInt($(this).slider('option', 'value') / 100); //Column score converted to colour scale value 1 to 10
sliderID = '#Slider' + $(this).attr('alt') + ' .ui-slider-range';
$(sliderID).css('background', '#' + ColNegPos(intCode));
}
else {
var intCode = parseInt($(this).slider('option', 'value') / 100); //Column score converted to colour scale value 1 to 10
sliderID = '#Slider' + $(this).attr('alt') + ' .ui-slider-range';
$(sliderID).css('background', '#' + ColPosNeg(intCode));
}
}
});
$('.cRadioExcl').change(function () {
$('.cSlider').eq($(this).attr('trow')).slider('option', 'value', 0);
});
$('.cRadioExcl').keydown(function () {
$('.cSlider').eq($(this).attr('trow')).slider('option', 'value', 0);
});
var sldHandleHeight = parseInt($('.cSlider').eq(0).height()) + 8;
$('.ui-slider .ui-slider-handle').css('height', sldHandleHeight + 'px');
$('.ui-slider-handle').css('background', sldHandleColour);
$('.cSlider').css('margin-bottom', '5px');
//Set Previous answers
var intChecked = 0;
$('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').each(function (i) {
intChecked = $(this).find('.cRadio:checked').length;
if (intChecked != 0) {
var radioButtons = $(this).find('.cRadio');
var selectedIndex = radioButtons.index(radioButtons.filter(':checked'));
if ($(this).find('.cRadio').eq(selectedIndex).hasClass('cRadioExcl') == false) {
selectedIndex = selectedIndex - intExclColumnLeft;
var intStep = parseInt(1000 / intSpan); //Scale is dived into steps that relate to the number of columns
var intStepMid = intStep / 2; //The middle of a step
var intNewVal = (selectedIndex * intStep) + intStepMid; //The new slider value based on putting the slider into the centre of the column
$(this).find('.cSlider').slider('option', 'value', intNewVal);
}
}
});
}
catch (err) {
if (debug == true) {
txt = "There was an error on this page.\n\n";
txt += "Error description: " + err.message + "\n\n";
txt += "Click OK to continue.\n\n";
alert(txt);
}
//Clean up
$('.cCell').show();
$('.cSliderCell').remove();
}
}
function autoComplete() { //Creates an AJAX Style lookup from a single choice question
debug = (typeof debug === "undefined") ? false : debug; //Turn on debuging(true/false)
strLabel = (typeof strLabel === "undefined") ? "Answer" : strLabel;
intMinChar = (typeof intMinChar === "undefined") ? 3 : intMinChar;
intInputSize = (typeof intInputSize === "undefined") ? 35 : intInputSize;
var arrLookUp = new Array; //Array of lookup texts
var arrRadios = new Array; //Arroy of radio buttons
var intArrCnt = 0;
var questCode = ''; //HTML string to add to auto complete to the question
var preText = ''; //used to store the text to pre fill the inpuut if the question is already answered
//Exit function if question type not valid
var structOK = true;
//Number of questions on page should be 1
if ($('.cCellSubQuestion').length != 1) structOK = false;
//Check radio buttons on screen
if ($('.cRadio').length == 0) structOK = false;
if ($('.cCheck').length != 0) structOK = false;
//Check there is a single open ended row
if ($('input:text').length != 1) { structOK = false; }
//Check not a grid question
if ($('.cCellHeader').length != 0) structOK = false;
if (structOK == false) {
if (debug == true) alert('Structure not OK for iQuest e.q. Wrong question type, this iQuest requires a single choice question with the final row being an open row.');
iQuestHelper('Question structure is not OK for this iQuest e.q. Wrong question type, this iQuest requires a single choice question with the final row being an open row.');
return false;
}
try {
isKeyNavEnabled = false; //Disable advance to next question when the Enter key is pressed
//Hide label Text Say element
$('.cSay:contains("Label text:")').hide();
//Hide Question Rows
if (!debug) {
$('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').hide();
}
//Create the lookup text box
questCode = '<tr><td colspan="2"><label for="autoComp">' + strLabel + ' </label><input id="autoComp" type="text" size="' + intInputSize + '"></td></tr>';
//Loop through the rows
$('.cRow, .cRowSelected, .cAltRowSelected').each(function () {
$(this).find('.cRowText').each(function () {
//Add Row Text to array used as the source for the auto complete text box
arrLookUp[intArrCnt] = $.trim($(this).text());
});
$(this).find('input:radio').each(function () {
//Add the radio button id to the array containing all ids
arrRadios[intArrCnt] = $(this).attr('id');
// if radio button is checked set value of autocomplete text box
var chkBoxID = '#' + $(this).attr('id');
if ($(this).is(':checked')) {
preText = arrLookUp[intArrCnt];
}
});
intArrCnt++;
});
// Set the ID of the other specify box
var othID = '#' + $('.cCellRowText').find('input').attr('id');
// Add auto complete textbox to the question
$('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').eq(0).before(questCode);
// Set up auto complete
$('#autoComp').autocomplete({
minLength: intMinChar,
//change event runs when autocomplete text box looses focus
change: function (event, ui) {
intArrCnt = 0;
//Loop through array to find a match to the text in the text box
for (i = 1; i <= arrLookUp.length; i++) {
//Set intArrCnt to the array position of the matched text
//if (arrLookUp[i - 1] == $('#autoComp').attr('value')) { intArrCnt = i; }
var arrVar = arrLookUp[i - 1].toLowerCase();
var compVar = $('#autoComp').attr('value').toLowerCase();
if (arrVar.localeCompare(compVar) == 0) {
intArrCnt = i;
break;
}
}
// Set the radio box of the match text
if (intArrCnt > 0) {
var chkBoxID = '#' + arrRadios[intArrCnt - 1];
$(chkBoxID).prop('checked', true);
$(othID).attr('value', '')
}
//If no match is found set the other specify box
else {
//Set the other specify box
$(othID).attr('value', $('#autoComp').attr('value'));
// clear all radio buttons
for (i = 1; i <= arrRadios.length; i++) {
var chkBoxID = '#' + arrRadios[i - 1];
$(chkBoxID).prop('checked', false);
}
}
},
close: function (event, ui) {
intArrCnt = 0;
//Loop through array to find a match to the text in the text box
for (i = 1; i <= arrLookUp.length; i++) {
//Set intArrCnt to the array position of the matched text
var arrVar = arrLookUp[i - 1].toLowerCase();
var compVar = $('#autoComp').attr('value').toLowerCase();
if (arrVar.localeCompare(compVar) == 0) {
intArrCnt = i;
break;
}
}
// Set the radio box of the match text
if (intArrCnt > 0) {
var chkBoxID = '#' + arrRadios[intArrCnt - 1];
$(chkBoxID).prop('checked', true);
//sleep(1);
$(othID).attr('value', '')
}
//If no match is found set the other specify box
else {
//Set the other specify box
$(othID).attr('value', $('#autoComp').attr('value'));
// clear all radio buttons
for (i = 1; i <= arrRadios.length; i++) {
var chkBoxID = '#' + arrRadios[i - 1];
$(chkBoxID).prop('checked', false);
}
}
},
source: arrLookUp
});
//If a radio button is already check set auto complete text
if (preText != '') { $('#autoComp').attr('value', preText); }
if ($(othID).attr('value') != '') { $('#autoComp').attr('value', $(othID).attr('value')); }
//Formate Autocomplete box to have a maximum height and a scrollbar
$('.ui-autocomplete').css('max-height', '150px');
$('.ui-autocomplete').css('overflow-y', 'auto');
$('.ui-autocomplete').css('overflow-x', 'hidden');
}
catch (err) {
if (debug == true) {
txt = "There was an error on this page.\n\n";
txt += "Error description: " + err.message + "\n\n";
txt += "Click OK to continue.\n\n";
alert(txt);
}
//Clean up
$('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').show();
$('#autoComp').parents('.cRow').remove();
}
}
function staggeredGridSingle() {
//Check for WCAG
if ($('#btnToggleWcag').val()==1) {
return false;
}
intDisplayDelay = (typeof intDisplayDelay === "undefined") ? 0 : intDisplayDelay; //Delay
blnHideNext = (typeof blnHideNext === "undefined") ? true : blnHideNext; //Hide Next Button
debug = (typeof debug === "undefined") ? false : debug; //Debug mode
//Exit function if question type not valid
structOK = true;
//Number of questions on page should be 1
if ($('.cCellSubQuestion').length != 1) structOK = false;
//Check radio buttons on screen
if ($('.cRadio').length == 0) structOK = false;
if ($('.cCheck').length != 0) structOK = false;
// Check answer type rn
if (structOK) {
var strID = $('.cRadio').eq(0).attr('id');
if (strID.substr(0, 2) != 'rn') structOK = false;
}
//Check Image count = column count
if (structOK == false) {
if (debug == true) alert('Structure not OK for iQuest e.q. Wrong question type, this iQuest requires a single choice grid question');
return false;
}
try {
var intNumRows = $('.cRow, .cRowSelected, .cRowAlt, .cRowAltSelected').length;
//Hide Rows
$('.cRow, .cRowSelected, .cRowAlt, .cRowAltSelected').hide();
if (blnHideNext == true) $('#btnNext').hide();
var intHighestRow = -1;
$('.cRow, .cRowSelected, .cRowAlt, .cRowAltSelected').each(function (i) {
if ($(this).find('.cRadio:checked').length != 0) { intHighestRow = i; }
});
var intCurrRow = intHighestRow + 1;
if ($('.cRadio:checked').length == intNumRows) $('#btnNext').show();
for (i = 0; i <= (intHighestRow + 1); i++) {
$('.cRow, .cRowSelected, .cRowAlt, .cRowAltSelected').eq(i).show();
}
$('.cRadio').change(function () {
var objCurrRow = $(this).parents('tr:first');
var intClickedRow = $('.cRow, .cRowSelected, .cRowAlt, .cRowAltSelected').index(objCurrRow);
if (intClickedRow == intCurrRow) {
intCurrRow = intCurrRow + 1;
intDelay = intDisplayDelay * 1000;
$('.cRow, .cRowSelected, .cRowAlt, .cRowAltSelected').eq(intCurrRow).delay(intDelay).show(0);
}
if ($('.cRadio:checked').length == intNumRows) $('#btnNext').show();
});
}
catch (err) {
if (debug == true) {
txt = "There was an error on this page.\n\n";
txt += "Error description: " + err.message + "\n\n";
txt += "Click OK to continue.\n\n";
alert(txt);
}
//Clean up
$('.cRow, .cRowSelected, .cRowAlt, .cRowAltSelected').show();
}
}
function staggeredGridMulti() {
//Check for WCAG
if ($('#btnToggleWcag').val()==1) {
return false;
}
intDisplayDelay = (typeof intDisplayDelay === "undefined") ? 0 : intDisplayDelay; //Delay
blnHideNext = (typeof blnHideNext === "undefined") ? true : blnHideNext; //Hide Next Button
debug = (typeof debug === "undefined") ? false : debug; //Debug mode
//Exit function if question type not valid
structOK = true;
//Number of questions on page should be 1
if ($('.cCellSubQuestion').length != 1) structOK = false;
//Check check boxes on screen
if ($('.cCheck').length === 0) structOK = false;
// Check answer type rm
var strID = $('.cCheck').eq(0).attr('id');
if (strID.substr(0, 2) != 'rm') structOK = false;
//Check Image count = column count
if (structOK == false) {
if (debug == true) alert('Structure not OK for iQuest e.q. Wrong question type, this iQuest requires a multiple choice grid question');
return false;
}
try {
//Hide Rows
$('.cRow, .cRowSelected, .cRowAlt, .cRowAltSelected').hide();
if (blnHideNext == true) $('#btnNext').hide();
var intHighestRow = -1;
$('.cRow, .cRowSelected, .cRowAlt, .cRowAltSelected').each(function (i) {
if ($(this).find('.cCheck:checked').length != 0) { intHighestRow = i; }
if ($(this).find('.cRadio:checked').length != 0) { intHighestRow = i; }
});
var intCurrRow = intHighestRow + 1;
for (i = 0; i <= (intHighestRow + 1); i++) {
$('.cRow, .cRowSelected, .cRowAlt, .cRowAltSelected').eq(i).show();
}
var intNumRows = $('.cRow, .cRowSelected, .cRowAlt, .cRowAltSelected').length;
if (intCurrRow == intNumRows) $('#btnNext').show();
$('.cCheck, .cRadio').change(function () {
var objCurrRow = $(this).parents('tr:first');
var intClickedRow = $('.cRow, .cRowSelected, .cRowAlt, .cRowAltSelected').index(objCurrRow);
if (intClickedRow == intCurrRow) {
intCurrRow = intCurrRow + 1;
intDelay = intDisplayDelay * 1000;
$('.cRow, .cRowSelected, .cRowAlt, .cRowAltSelected').eq(intCurrRow).delay(intDelay).show(0);
if ((intCurrRow + 1) == intNumRows) $('#btnNext').show();
}
});
}
catch (err) {
if (debug == true) {
txt = "There was an error on this page.\n\n";
txt += "Error description: " + err.message + "\n\n";
txt += "Click OK to continue.\n\n";
alert(txt);
}
//Clean up
$('.cRow, .cRowSelected, .cRowAlt, .cRowAltSelected').show();
}
}
function AudioPlayer() { //Add an audio player from jPlayer.org
//Give defaultvalues if not specified
debug = (typeof debug === "undefined") ? false : debug;//Turn on debuging(true/false)
strAudioURL = (typeof strAudioURL === 'undefined') ? 'http://jplayer.org/audio/mp3/Miaow-07-Bubble.mp3' : strAudioURL;//Default Audio
strAudioType = (typeof strAudioType === 'undefined') ? 'mp3' : strAudioType;//Default AudioType
structOK = true;
//Number of questions on page should be 1
if ($('.cCellSubQuestion').length != 1) structOK = false;
if (structOK == false) {
if (debug == true) alert('Structure not OK for animation e.q. More than 1 question on the page');
iQuestHelper('Structure not OK for iQuest e.q. More than one question per screen');
return false;
}
try {
strHtml = ''; //Clear variable used for html to add audio player
strHtml += '<div id="jquery_jplayer_1"></div>';
strHtml += ' <div id="jp_container_1">';
strHtml += ' <div>';
strHtml += ' <div>';
strHtml += ' <ul>';
strHtml += ' <li><a href="javascript:;" tabindex="1">play</a></li>';
strHtml += ' <li><a href="javascript:;" tabindex="1">pause</a></li>';
strHtml += ' <li><a href="javascript:;" tabindex="1">stop</a></li>';
strHtml += ' <li><a href="javascript:;" tabindex="1" title="mute">mute</a></li>';
strHtml += ' <li><a href="javascript:;" tabindex="1" title="unmute">unmute</a></li>';
strHtml += ' <li><a href="javascript:;" tabindex="1" title="max volume">max volume</a></li>';
strHtml += ' </ul>';
strHtml += ' <div>';
strHtml += ' <div>';
strHtml += ' <div></div>';
strHtml += ' </div>';
strHtml += ' </div>';
strHtml += ' <div>';
strHtml += ' <div></div>';
strHtml += ' </div>';
strHtml += ' <div>';
strHtml += ' <div></div>';
strHtml += ' <div></div>';
strHtml += ' <ul>';
strHtml += ' <li><a href="javascript:;" tabindex="1" title="repeat">repeat</a></li>';
strHtml += ' <li><a href="javascript:;" tabindex="1" title="repeat off">repeat off</a></li>';
strHtml += ' </ul>';
strHtml += ' </div>';
strHtml += ' </div>';
strHtml += '<div style="display: none;">';
strHtml += '<ul>';
strHtml += '<li><span></span></li>';
strHtml += ' </ul>';
strHtml += '</div>';
strHtml += ' <div>';
strHtml += ' <span>Update Required</span>';
strHtml += ' To play the media you will need to either update your browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>.';
strHtml += ' </div>';
strHtml += ' </div>';
strHtml += ' </div>';
//Add audio player html to end of subquestion box
$('.cCellSubQuestion').append(strHtml);
//Activate Audio Player
$("#jquery_jplayer_1").jPlayer({
ready: function () {
if (strAudioType == 'mp3') {
$(this).jPlayer("setMedia", {
mp3: strAudioURL
});
}
else {
$(this).jPlayer("setMedia", {
m4a: strAudioURL
});
}
},
swfPath: "scripts/mediaplayer/jPlayer",
supplied: strAudioType,
wmode: "window",
smoothPlayBar: true,
keyEnabled: true,
remainingDuration: true,
toggleDuration: true
});
}
catch (err) {
if (debug == true) {
txt = "There was an error on this page.\n\n";
txt += "Error description: " + err.message + "\n\n";
txt += "Click OK to continue.\n\n";
alert(txt);
}
//Clean up
$('#jquery_jplayer_1').remove();
}
}
function iqVideoPlayer() {
var strHTML = '';
strHTML += '<div id="jp_container_1">';
strHTML += '<div>';
strHTML += '<div id="jquery_jplayer_1"></div>';
strHTML += '<div>';
strHTML += '<div>';
strHTML += '<a href="javascript:;" tabindex="1">play</a>';
strHTML += '</div>';
strHTML += '<div>';
strHTML += '<div>';
strHTML += '<div>';
strHTML += '<div></div>';
strHTML += '</div>';
strHTML += '</div>';
strHTML += '<div></div>';
strHTML += '<div></div>';
strHTML += '<div>';
strHTML += '<ul>';
strHTML += '<li><span></span></li>';
strHTML += '</ul>';
strHTML += '</div>';
strHTML += '<div>';
strHTML += '<ul>';
strHTML += '<li><a href="javascript:;" tabindex="1">play</a></li>';
strHTML += '<li><a href="javascript:;" tabindex="1">pause</a></li>';
strHTML += '<li><a href="javascript:;" tabindex="1">stop</a></li>';
strHTML += '<li><a href="javascript:;" tabindex="1" title="mute">mute</a></li>';
strHTML += '<li><a href="javascript:;" tabindex="1" title="unmute">unmute</a></li>';
strHTML += '<li><a href="javascript:;" tabindex="1" title="max volume">max volume</a></li>';
strHTML += '</ul>';
strHTML += '<div>';
strHTML += '<div></div>';
strHTML += '</div>';
strHTML += '<ul>';
strHTML += '<li><a href="javascript:;" tabindex="1" title="full screen">full screen</a></li>';
strHTML += '<li><a href="javascript:;" tabindex="1" title="restore screen">restore screen</a></li>';
strHTML += '<li><a href="javascript:;" tabindex="1" title="repeat">repeat</a></li>';
strHTML += '<li><a href="javascript:;" tabindex="1" title="repeat off">repeat off</a></li>';
strHTML += '</ul>';
strHTML += '</div>';
strHTML += '</div>';
strHTML += '</div>';
strHTML += '<div>';
strHTML += '<span>Update Required</span>';
strHTML += 'To play the media you will need to either update your browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>.';
strHTML += '</div>';
strHTML += '</div>';
strHTML += '</div>';
switch (playerPosition) {
case 'above':
$('.cQuestionText').before(strHTML);
break;
case 'below':
$('.cQuestionText').after(strHTML);
break;
case 'div':
var strDivName = '#' + playerDivName;
if ($(strDivName).length == 0) {
iQuestHelper('Div Name specified to contain video play does not exist. Use an HTML Element to add the div.');
}
else {
$('strDivName').eq(0).append(strHTML);
}
break;
}
playerSplashImage = (playerShowSplash == false) ? '' : playerSplashImage;
$("#jquery_jplayer_1").jPlayer({
play: function (event, ui) {
},
pause: function (event, ui) {
},
ended: function (event, ui) {
$('.buttonContainer').show();
$(this).jPlayer("setMedia", {
m4v: '', // Defines the m4v url
poster: playerSplashImage
})
},
size: {
width: playerWidth,
height: playerHeight
},
ready: function () {
//Set the video file
$(this).jPlayer("setMedia", {
m4v: strVideoURL, // Defines the m4v url
poster: playerSplashImage
})
},
solution: "flash, html", // Flash with an HTML5 fallback.
supplied: VideoType,
swfPath: "scripts/mediaplayer/jPlayer"
});
//Video player formatting
if (playerHorizontalAlign == 'center') {
$('#jp_container_1').css('margin-left', 'auto');
$('#jp_container_1').css('margin-right', 'auto');
}
if (playerHorizontalAlign == 'left') {
$('#jp_container_1').css('margin-left', '');
$('#jp_container_1').css('margin-right', '');
}
if (playerHorizontalAlign == 'right') {
$('#jp_container_1').css('display', 'block');
$('#jp_container_1').css('float', 'right');
}
$('#jp_container_1').css('margin-top', playerTopSpace);
$('#jp_container_1').css('margin-bottom', playerBottomSpace);
$('#jp_container_1').css('width', playerWidth);
$('#jp_flash_0').css('margin-left', 'auto');
$('#jp_flash_0').css('margin-right', 'auto');
if (playerHideNext == true) { $('.buttonContainer').hide(); }
if (playerHideSeek == true) { $('.jp-progress').hide(); }
if (playerHideTime == true) { $('.jp-current-time, .jp-duration').hide(); }
if (playerHideTitle == true) { $('.jp-details').hide(); }
if (playerHideControls == true) { $('.jp-controls-holder').hide(); }
if (playerHideVolume == true) { $('.jp-volume-bar').hide(); }
if (playerHideToggle == true) { $('.jp-toggles').hide(); }
$('.jp-title').text(playerTitle);
}
function BiPolar() {
//Check for WCAG
if ($('#btnToggleWcag').val()==1) {
return false;
}
btnCopyEditorStyle = (typeof btnCopyEditorStyle === "undefined") ? true : btnCopyEditorStyle;
btnFontSize = (typeof btnFontSize === "undefined") ? '14px' : btnFontSize;
btnFontWeight = (typeof btnFontWeight === "undefined") ? 'bold' : btnFontWeight;
btnFontStyle = (typeof btnFontStyle === "undefined") ? 'normal' : btnFontStyle;
btnGraphicBackground = (typeof btnGraphicBackground === "undefined") ? false : btnGraphicBackground;
btnHorizontalAlign = (typeof btnHorizontalAlign === "undefined") ? 'center' : btnHorizontalAlign;
btnVerticalAlign = (typeof btnVerticalAlign === "undefined") ? 'middle' : btnVerticalAlign;//Vertical alignment (top/middle/bottom)
btnGraphicAutoSize = (typeof btnGraphicAutoSize === "undefined") ? false : btnGraphicAutoSize;
btnTextValue = (typeof btnTextValue === "undefined") ? 'code' : btnTextValue;
//Clean up
var strHtml = ''; //Clear variable used for html
$('.cGridButtonContainer').remove(); //Remove html if already added
//Validate Screen to ensure correct Question type
//Exit function if question type not valid
var structOK = true;
//Number of questions on page should be 1
if ($('.cCellSubQuestion').length != 1) structOK = false;
//Check radio buttons on screen
if ($('.cRadio').length == 0) structOK = false;
// Check answer type rn
if (structOK) {
var strID = $('.cRadio').eq(0).attr('id');
if (strID.substr(0, 2) != 'rn') structOK = false;
}
if (structOK == false) {
if (debug == true) alert('Structure not OK for iQuest e.q. Wrong question type. This iQuest requires a single choice grid question and one question per screen');
return false;
}
try {
strHtml = '<div>';
strHtml += '<table style="width:auto; margin-left: auto; margin-right:auto;"><tr>';
strAnsLeft = $('.cCellRowText:first').html();
strAnsRight = $('.cCellRowText:first').html();
strTxtAll = $('.cCellRowText:first').text();
var arrText = new Array();
arrText = strTxtAll.split("|");
strTxtLeft = arrText[0];
strTxtRight = arrText.length > 1 ? arrText[1] : "";
strTxtAll = $.trim(strTxtAll);
strAnsLeft = strAnsLeft.replace(strTxtAll, strTxtLeft);
strAnsRight = strAnsRight.replace(strTxtAll, strTxtRight);
strHtml += '<td id="AnsLeft">' + strAnsLeft + '</td>';
var intBtnCnt = 0;
var strText = '';
$('.cValue').each(function () {
if (btnTextValue == 'code') {
strText = $(this).text().replace('[', '');
strText = strText.replace(']', '');
}
else {
strText = $('.cCellHeader').eq(intBtnCnt + 1).text();
}
strHtml += '<td alt="' + intBtnCnt + '">' + strText + '</td>';
intBtnCnt++;
});
strHtml += '<td id="AnsRight">' + strAnsRight + '</td>';
strHtml += '</tr></table>';
strHtml += '</div>';
$('#UpdatePanel1').after(strHtml);
//Hide question
$('.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').css('display', 'none');
//Hide Next Button
fncHideNext();
$('.cGridButtonImageContainer').css('height', '250px');
$('.cGridButtonWrapper').css('margin-bottom', '30px');
if (btnBackgroundType == 'image') {
strBtnBackground = 'url("' + strBackgroundURL + '") no-repeat center center';
$('.cAnswerBtn').css('background', strBtnBackground);
if (btnGraphicAutoSize == true) $('.cAnswerBtn').css({ 'background-size': '100%' });
}
else {
$('.cAnswerBtn').css('background-color', btnColor).removeClass('btnChecked');
$('.cAnswerBtn').css('border-right', btnBorderWidth + ' solid #696969');
$('.cAnswerBtn').css('border-bottom', btnBorderWidth + ' solid #696969');
$('.cAnswerBtn').css('border-top', btnBorderWidth + ' solid #E5E5E5');
$('.cAnswerBtn').css('border-left', btnBorderWidth + ' solid #E5E5E5');
if (btnRounded != false) $('.cAnswerBtn').css({ '-moz-border-radius': '20px', '-webkit-border-radius': '20px', '-khtml-border-radius': '20px', 'border-radius': '20px' });
if (btnBorderOn == false) $('.cAnswerBtn').css('border', '0px solid transparent');
}
$('.cAnswerBtn').css('height', btnHeight);
$('.cAnswerBtn').css('width', btnWidth);
$('.cAnswerBtn').css('color', btnTextColor);
$('.cAnswerBtn').css('text-align', 'center');
$('.cAnswerBtn').css('cursor', 'pointer');
if (btnCopyEditorStyle != true) {
$('.cAnswerBtn').find('strong').contents().unwrap();
$('.cAnswerBtn').find('span').contents().unwrap();
$('.cAnswerBtn').css('font-size', btnFontSize);
$('.cAnswerBtn').css('font-style', btnFontStyle);
$('.cAnswerBtn').css('font-weight', btnFontWeight);
$('.cAnswerBtn').css('text-align', btnHorizontalAlign);
}
$('.btnContainer').css('margin', '0px');
$('.btnContainer').css('border', '0px');
$('.btnContainer').css('padding', '0px');
$('#AnsRight').find('div').css('text-align', 'left');
$('#AnsRight').find('div').css('padding-left', '5px;');
$('#AnsLeft').find('div').css('text-align', 'right');
$('#AnsLeft').find('div').css('padding-right', '5px');
blnClickOn = true;
var wrapNo = 1;
//Set answer if previously answered
var intChecked = $('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').eq(wrapNo - 1).find('.cRadio:checked').length;
if (intChecked != 0) {
var radioButtons = $('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').eq(wrapNo - 1).find('.cRadio');
var selectedIndex = radioButtons.index(radioButtons.filter(':checked'));
$('.cAnswerBtn').eq(selectedIndex).css('background-color', btnColorClick).addClass('btnChecked');
}
var numItems = $('.cCellRowText').length;
$(document).on("click", ".cAnswerBtn", function () {
//$('.cAnswerBtn').live('click',function() {
if (blnClickOn == true) {
blnClickOn = false;
//Button effect
$(this).effect("pulsate", {}, 10);
//Set Answer
x = (parseInt(wrapNo - 1) * parseInt(intBtnCnt)) + parseInt($(this).attr('alt'));
//$('.cRadio').eq(x).click();
$('.cCell input').eq(x).prop('checked', true);
if (wrapNo == numItems) {
$('#btnNext').click();
}
else {
wrapNo = wrapNo + 1;
strAnsLeft = $('.cCellRowText:nth(' + (wrapNo - 1) + ')').html();
strAnsRight = $('.cCellRowText:nth(' + (wrapNo - 1) + ')').html();
strTxtAll = $('.cCellRowText:nth(' + (wrapNo - 1) + ')').text();
var arrText = new Array();
arrText = strTxtAll.split("|");
strTxtLeft = arrText[0];
strTxtRight = arrText.length > 1 ? arrText[1] : "";
strTxtAll = $.trim(strTxtAll);
strAnsLeft = strAnsLeft.replace(strTxtAll, strTxtLeft);
strAnsRight = strAnsRight.replace(strTxtAll, strTxtRight);
$('#AnsLeft').html(strAnsLeft);
$('#AnsRight').html(strAnsRight);
$('#AnsRight').find('div').css('text-align', 'left');
$('#AnsLeft').find('div').css('text-align', 'right');
//Set answer if previously answered
var intChecked = $('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').eq(wrapNo - 1).find('.cRadio:checked').length;
if (intChecked != 0) {
$('.cAnswerBtn').css('background-color', $('.cGridButtonContainer').css('background-color'));
var radioButtons = $('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').eq(wrapNo - 1).find('.cRadio');
var selectedIndex = radioButtons.index(radioButtons.filter(':checked'));
$('.cAnswerBtn').eq(selectedIndex).css('background-color', btnColorClick).addClass('btnChecked');
}
blnClickOn = true;
}
}
});
$('#btnNext').on('click', function () {
//Clean up
$(document).off("click", ".cAnswerBtn");
//$('.cAnswerBtn').die('click');
$('.cGridButtonContainer').remove();
$('#btnNext').off('click');
$('#btnPrevious').off('click');
});
$('#btnPrevious').on('click', function () {
$('#btnNext').off('click');
$('#btnPrevious').off('click');
$(document).off("click", ".cAnswerBtn");
//$('.cAnswerBtn').die('click');
$('.cGridButtonContainer').remove(); //Remove html if already added
});
}
catch (err) {
//Clean up
strHtml = ''; //Clear variable used for html
$('.cGridButtonContainer').remove(); //Remove html if already added
//Show question
$('.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').css('display', '');
//Show Next button if click fails.
fncShowNext();
}
}
function ClickRank() { //Rank items by clicking on them
//Check for WCAG
if ($('#btnToggleWcag').val()==1) {
return false;
}
//Give defaultvalues if not specified
srtNumColumn = (typeof srtNumColumn === "undefined") ? 4 : srtNumColumn;
srtItemWidth = (typeof srtItemWidth === "undefined") ? "150px" : srtItemWidth;
srtItemHeight = (typeof srtItemHeight === "undefined") ? "75px" : srtItemHeight;
srtTableCenter = (typeof srtTableCenter === "undefined") ? 20 : srtTableCenter;
idxVerticalAlign = (typeof idxVerticalAlign === "undefined") ? "middle" : idxVerticalAlign;
srtIndexWidth = (typeof srtIndexWidth === "undefined") ? "50px" : srtIndexWidth;
srtIndexHeight = (typeof srtIndexHeight === "undefined") ? "50px" : srtIndexHeight;
blnIndexRounded = (typeof blnIndexRounded === "undefined") ? true : blnIndexRounded;
srtIndexCol1 = (typeof srtIndexCol1 === "undefined") ? "#F0F0F0" : srtIndexCol1;
srtIndexCol2 = (typeof srtIndexCol2 === "undefined") ? "#00FF33" : srtIndexCol2;
inxMarginLeft = (typeof inxMarginLeft === "undefined") ? "0px" : inxMarginLeft;
idxCopyEditorStyle = (typeof idxCopyEditorStyle === "undefined") ? false : idxCopyEditorStyle;
idxFontSize = (typeof idxFontSize === "undefined") ? "14px" : idxFontSize;
idxFontWeight = (typeof idxFontWeight === "undefined") ? "bold" : idxFontWeight;
idxFontStyle = (typeof idxFontStyle === "undefined") ? "normal" : idxFontStyle;
idxHorizontalAlign = (typeof idxHorizontalAlign === "undefined") ? "center" : idxHorizontalAlign;
intMinSelected = (typeof intMinSelected === "undefined") ? 1 : intMinSelected;
intMaxSelected = (typeof intMaxSelected === "undefined") ? 99 : intMaxSelected;
strMinMessage = (typeof strMinMessage === "undefined") ? "Please select at least [Min] Items." : strMinMessage;
strMaxMessage = (typeof strMaxMessage === "undefined") ? "Please select no more than [Max] Items." : strMaxMessage;
blnHideNextMin = (typeof blnHideNextMin === "undefined") ? false : blnHideNextMin;
blnAutoNextMax = (typeof blnAutoNextMax === "undefined") ? false : blnAutoNextMax;
debug = (typeof debug === "undefined") ? false : debug;
mobileIt(); //Change various settings if mobile device
//Clean up
var strHtml = ''; //Clear variable used for html
$('.cGridButtonContainer').remove(); //Remove html if already added
//Validate Screen to ensure correct Question type
//Exit function if question type not valid
structOK = true;
//Number of questions on page should be 1
if ($('.cCellSubQuestion').length != 1) structOK = false;
//Check no checkboxes on screen
if ($('.cCheck').length != 0) structOK = false;
//Check no radio buttons on screen
if ($('.cRadio').length != 0) structOK = false;
//Check not a grid question
if ($('.cCellHeader').length != 0) structOK = false;
//Check at least 1 numeric inputs
if ($('.cFInput').length < 1) structOK = false;
if ($('input:text, textarea').hasClass('exclusive') == true) structOK = false;
if (structOK == false) {
if (debug == true) alert('Structure not OK for animation e.q. Wrong question type');
return false;
}
try {
//If srtNumColumn = 0 set to number of rows
if (srtNumColumn == 0) srtNumColumn = $('.cRowText').length;
var intCurrentIndex = 1;
//Create HTML
strHtml = '<div>';
var strStyle = '';
strHtml += '<table style="width: auto;"><tr>';
var intBtnCnt = 0;
var blnEndRow = false;
$('.cRowText').each(function () {
var alignStyle = "";
if ($(this).hasClass("textleft")) {
alignStyle = "text-align:left;";
}
else if ($(this).hasClass("textcenter")) {
alignStyle = "text-align:center;";
}
else if ($(this).hasClass("textright")) {
alignStyle = "text-align:right;";
}
strStyle = 'style="' + alignStyle;
if (typeof $(this).attr('style') !== 'undefined') {
strStyle += $(this).attr('style');
}
strStyle += '"';
strHtml += '<td alt="' + intBtnCnt + '" ' + strStyle + '><table><tr><td><div bitAnswered="0"></div></td><td><div>' + $(this).html() + '</div></td></tr></table></td>';
if (parseInt(intBtnCnt + 1) % srtNumColumn == 0) { //end row depending on the number of buttons specified in the options
strHtml += '</tr>';
blnEndRow = true;
}
else {
blnEndRow = false;
}
intBtnCnt++;
});
if (blnEndRow == false) { strHtml += '</tr>'; }
strHtml += '</table>';
strHtml += '</div>';
$('#UpdatePanel1').append(strHtml);
//Standard formatting
$('.cSrtTable').find('td').css('padding', '0px');
$('.cRankIndex').css('vertical-align', 'middle');
$('.cRankIndex').css('border', '1px solid black');
$('.cRankIndex').css('width', srtIndexWidth);
$('.cRankIndex').css('height', srtIndexHeight);
$('.cIndexTD').css('width', srtIndexWidth);
if (blnIndexRounded == true) { $('.cRankIndex').css('border-radius', '50%'); }
$('.cRankIndex').css('text-align', 'center');
//Calculate Index Font Size
strFontSize = parseInt($('.cRankIndex').eq(0).height() * 0.8) + 'px';
$('.cRankIndex').css('font-size', strFontSize);
//Formatting from options
$('.cRankIndex').css('background-color', srtIndexCol1);
$('.cRankItem').css('height', srtItemHeight);
$('.cRankItem').css('width', srtItemWidth);
if (srtTableCenter == true) {
$('.cSrtTable').css('margin-left', 'auto');
$('.cSrtTable').css('margin-right', 'auto');
}
$('.cSrtTable').find('td').css('vertical-align', idxVerticalAlign);
if (idxCopyEditorStyle != true) {
$('.cRankText').find('strong').contents().unwrap();
$('.cRankText').find('span').css('text-align', '');
$('.cRankText').find('span').css('font-size', '');
$('.cRankText').css('font-size', idxFontSize);
$('.cRankText').css('font-style', idxFontStyle);
$('.cRankText').css('font-weight', idxFontWeight);
$('.cRankText').css('text-align', idxHorizontalAlign);
}
$('.cRankText').css('margin-left', inxMarginLeft);
//Hide question
$('.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').css('display', 'none');
//Add dummy next button
$('#btnNext').before('<input id="btnNext2" name="btnNext2" value="Next" type="button">');
$('#btnNext2').val($('#btnNext').val());
//Hide Next Button
fncHideNext();
//Hide Dummy Next if option set
if (blnHideNextMin == true && intMinSelected > 0) { $('#btnNext2').hide(); }
//Set Previous Answers
$('input.cFInput').each(function (i) {
if ($(this).val().length != 0) {
$('.cRankIndex').eq(i).text($(this).val());
$('.cRankIndex').eq(i).attr('bitAnswered', '1');
$('.cRankIndex').eq(i).css('background-color', srtIndexCol2);
if ($(this).val() >= intCurrentIndex) intCurrentIndex = parseInt($(this).val()) + 1;
}
});
$(document).off("click", ".cRankItem");
//$('.cRankItem').die('click');
$(document).on("click", ".cRankItem", function () {
//$('.cRankItem').live('click',function () {
//Check if Answered
if ($(this).find('.cRankIndex').attr('bitAnswered') == 0) {
//Not Answered
$(this).find('.cRankIndex').css('background-color', srtIndexCol2);
$(this).find('.cRankIndex').text(intCurrentIndex);
$(this).find('.cRankIndex').attr('bitAnswered', '1');
//Set Answers
$('input.cFInput').eq($(this).attr('alt')).val(intCurrentIndex);
intCurrentIndex++;
}
else {
//Answered
var intAnsweredValue = parseInt($(this).find('.cRankIndex').text());
//Clear current item
$(this).find('.cRankIndex').text('');
$(this).find('.cRankIndex').css('background-color', srtIndexCol1);
$(this).find('.cRankIndex').attr('bitAnswered', '0');
$('input.cFInput').eq($(this).attr('alt')).val('');
//Decrease intCurrentIndex
intCurrentIndex = intCurrentIndex - 1;
//Loop through Items and reduce those that are higher
$('.cRankIndex').each(function (i) {
if (parseInt($(this).text()) > intAnsweredValue) {
newVal = parseInt($(this).text()) - 1;
$(this).text(newVal);
$('input.cFInput').eq(i).val(newVal);
}
});
}
if ($('.cRankIndex[bitAnswered="1"]').length >= intMinSelected) { $('#btnNext2').show(); }
if (blnHideNextMin == true && $('.cRankIndex[bitAnswered="1"]').length < intMinSelected) { $('#btnNext2').hide(); }
if (blnAutoNextMax == true && $('.cRankIndex[bitAnswered="1"]').length == intMaxSelected) { $('#btnNext2').click(); }
});
$('#btnPrevious').on('click', function () {
strHtml = ''; //Clear variable used for html
$(document).off("click", "#btnNext2");
//$('#btnNext2').die('click');
$(document).off("click", ".cRankItem");
//$('.cRankItem').die('click');
$('#btnNext2').remove();
$('#btnPrevious').off('click');
});
//#btnNext2 is a dummy next button used to finalise animation before next button is pressed
$(document).on("click", "#btnNext2", function () {
//$('#btnNext2').live('click',function () {
var blnOK = true;
$('.cError').remove();
if ($('.cRankIndex[bitAnswered="1"]').length < parseInt(intMinSelected)) {
blnOK = false;
strMinMessage = strMinMessage.replace("[Min]", intMinSelected);
strMinMessage = strMinMessage.replace("[Max]", intMaxSelected);
strHtml = '<span>' + strMinMessage + '</span>';
$('.cTDContainQues:nth(0)').append(strHtml);
}
if ($('.cRankIndex[bitAnswered="1"]').length > parseInt(intMaxSelected)) {
blnOK = false;
strMaxMessage = strMaxMessage.replace("[Min]", intMinSelected);
strMaxMessage = strMaxMessage.replace("[Max]", intMaxSelected);
strHtml = '<span>' + strMaxMessage + '</span>';
$('.cTDContainQues:nth(0)').append(strHtml);
}
if (blnOK == true) {
strHtml = ''; //Clear variable used for html
$(document).off("click", "#btnNext2");
//$('#btnNext2').die('click');
$(document).off("click", ".cRankItem");
//$('.cRankItem').die('click');
$('#btnNext2').remove();
$('#btnPrevious').off('click');
//Show Next button if click fails.
fncShowNext();
$('#btnNext').click();
}
});
}
catch (err) {
if (debug == true) {
txt = "There was an error on this page.\n\n";
txt += "Error description: " + err.message + "\n\n";
txt += "Click OK to continue.\n\n";
alert(txt);
}
//Clean up
strHtml = ''; //Clear variable used for html
$('.cGridButtonContainer').remove(); //Remove html if already added
$(document).off("click", "'#btnNext2");
//$('#btnNext2').die('click');
$(document).off("click", ".cRankItem");
//$('.cRankItem').die('click');
$('#btnNext2').remove();
$('#btnPrevious').off('click');
$(document).off("keyup", "input:text, textarea");
//$('input:text, textarea').die('keyup');
//Show question
$('.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').css('display', '');
//Show Next button.
fncShowNext();
}
}
function clickPosNeg() {
strImgURL = (typeof strImgURL === "undefined") ? "http://rs.mipro.net/PortalDataService/Content/AMGpG0VSARd/RoomForClickTest.jpg" : strImgURL; //Image URL
blnShowOptionErr = (typeof blnShowOptionErr === "undefined") ? true : blnShowOptionErr; //No Option Selected Error
strOptErrMsg = (typeof strOptErrMsg === "undefined") ? "Please click on either the positive or negative buttons before clicking on the image" : strOptErrMsg; //No Option Error Message
blnSetIndTot = (typeof blnSetIndTot === "undefined") ? true : blnSetIndTot; //Set Separate Maximums
intPosClicksAllowed = (typeof intPosClicksAllowed === "undefined") ? 99 : intPosClicksAllowed; //Positive clicks allowed
intNegClicksAllowed = (typeof intNegClicksAllowed === "undefined") ? 99 : intNegClicksAllowed; //Negative clicks allowed
strPosErrMsg = (typeof strPosErrMsg === "undefined") ? "Please make no more than [PosMax] clicks" : strPosErrMsg; //Error Message (Positive)
strNegErrMsg = (typeof strNegErrMsg === "undefined") ? "Please make no more than [NegMax] clicks" : strNegErrMsg; //Error Message (Negative)
blnSetComTot = (typeof blnSetComTot === "undefined") ? true : blnSetComTot; //Set Combined Maximums
intClicksAllowed = (typeof intClicksAllowed === "undefined") ? 99 : intClicksAllowed; //Number clicks allowed
strErrMsg = (typeof strErrMsg === "undefined") ? "Please make no more than [Max] clicks" : strErrMsg; //Error Message
blnAutoNext = (typeof blnAutoNext === "undefined") ? true : blnAutoNext; //Auto Next
strPosImgURL = (typeof strPosImgURL === "undefined") ? "http://rs.mipro.net/PortalDataService/Content/56PYY06UFev/HM_Positive.gif" : strPosImgURL; //Positive Button
strNegImgURL = (typeof strNegImgURL === "undefined") ? "http://rs.mipro.net/PortalDataService/Content/1R9pvPArUNG/HM_Negative.gif" : strNegImgURL; //Negative Button
strPosImgURLSel = (typeof strPosImgURLSel === "undefined") ? "http://rs.mipro.net/PortalDataService/Content/164g2UMuSaT/HM_Positive_s.gif" : strPosImgURLSel; //Positive Button Selected
strNegImgURLSel = (typeof strNegImgURLSel === "undefined") ? "http://rs.mipro.net/PortalDataService/Content/1hELyOtdjN2/HM_Negative_s.gif" : strNegImgURLSel; //Negative Button Selected
strUndoImgURL = (typeof strUndoImgURL === "undefined") ? "http://rs.mipro.net/PortalDataService/Content/9tQADv9yv2f/HM_Undo.gif" : strUndoImgURL; //Undo Button
strPosClickImg = (typeof strPosClickImg === "undefined") ? "http://rs.mipro.net/PortalDataService/Content/61dPLXykAt7/YesTick.png" : strPosClickImg; //Positive Click Image
strNegClickImg = (typeof strNegClickImg === "undefined") ? "http://rs.mipro.net/PortalDataService/Content/9yCPLG5c0Wj/NoCross.png" : strNegClickImg; //Negative Click Image
blnShowData = (typeof blnShowData === "undefined") ? false : blnShowData; //Show data fields
debug = (typeof debug === "undefined") ? false : debug; //Debug mode
//Validate Screen to ensure correct Question type
//Exit function if question type not valid
var structOK = true;
var intErrorCode = 0;
//Number of questions on page should be 1
if ($('.cCellSubQuestion').length != 1) { structOK = false; intErrorCode = 1 }
//Check no radio buttons, checkboxes or textarea on screen
if ($('.cRadio').length != 0) { structOK = false; intErrorCode = 2 }
if ($('.cCheck').length != 0) { structOK = false; intErrorCode = 3 }
//Check there are 3 open ended rows for the data
if ($('input:text').length != 3) { structOK = false; intErrorCode = 5 }
//Check not a grid question
if ($('.cCellHeader').length != 0) { structOK = false; intErrorCode = 6 }
if (structOK == false) {
if (debug == true) alert('(' + intErrorCode + ') Structure not OK for iQuest e.q. Wrong question type, this iQuest requires a multiple choice question with 3 open ended rows.');
iQuestHelper('Structure not OK for iQuest e.q. Wrong question type, this iQuest requires a multiple choice question with 3 open ended rows.');
return false;
}
try {
var strCurrOption = '';
var intCurrZindex = 1;
var blnAdvance = false;
var blnProcessClick = true;
//Add HTML to contation image for click test
var strHTML = '';
strHTML += '<div>';
strHTML += '<div>';
strHTML += '<div id="ClickPositive" bitOnOff="0" style="display: inline-block"><img src="' + strPosImgURL + '"></div>';
strHTML += '<div id="ClickNegative" bitOnOff="0" style="display: inline-block"><img src="' + strNegImgURL + '"></div>';
strHTML += '<div id="ClickUndo" style="display: inline-block"><img src="' + strUndoImgURL + '"></div>';
strHTML += '</div>';
strHTML += '<div>';
strHTML += '</div>';
strHTML += '<div style="text-align: center; width: 100%; auto;z-index: 0">';
strHTML += '<img src=" ' + strImgURL + '" style="z-index: 0">';
strHTML += '</div>';
strHTML += '</div>';
//Add HTML to the Question
$('.cCellSubQuestion').append(strHTML);
$('.cErrorWrapper').css('height', '20px');
//Initialise Counts
var intNumClick = 0;
var intNumView = 1;
var intNumPosClicks = 0;
var intNumNegClicks = 0;
// Set Number of Click and View fields
if ($('input:text').eq(1).val().length == 0) { $('input:text').eq(1).val(intNumClick) }
else { intNumClick = parseInt($('input:text').eq(1).val()) + 1; }
if ($('input:text').eq(2).val().length == 0) { $('input:text').eq(2).val(intNumView) }
else {
intNumView = parseInt($('input:text').eq(2).val()) + 1;
$('input:text').eq(2).val(intNumView)
}
//Add Images for existing click data and update positive and negative counts
if ($('input:text').eq(0).val().length != 0) {
setTimeout(function () {
strDataArr = $('input:text').eq(0).val().split(';');
var arrayLength = strDataArr.length;
//Scaling factors if image is scaled
var $img = $('.cClickImage');
var currentWidth = $img.width();
var currentHeight = $img.height();
var naturalWidth = $img.prop('naturalWidth');
var naturalHeight = $img.prop('naturalHeight');
var intXCorr = currentWidth / naturalWidth;
var intYCorr = currentHeight / naturalHeight;
for (var i = 0; i < arrayLength; i++) {
strPointDataArr = strDataArr[i].split(':');
if (strPointDataArr[4] == '1') {
strSRC = strPosClickImg;
intNumPosClicks = intNumPosClicks + 1;
}
else {
strSRC = strNegClickImg;
intNumNegClicks = intNumNegClicks + 1;
}
var strID = 'ClickTag' + (i + 1);
var offset = $('.cClickImage').offset();
var intY = parseInt(strPointDataArr[3] * intYCorr) + offset.top;
var intX = parseInt(strPointDataArr[2] * intXCorr) + offset.left;
strClick = '<div id="' + strID + '" style="position: absolute; top: ' + parseInt(intY - 12) + 'px ;left: ' + parseInt(intX - 12) + 'px"><img style=" height: 20px; width: 20px;"src="' + strSRC + '" /></div>';
$('.cHeatImageOuter').append(strClick);
}
intCurrZindex = i + 1;
}, 500);
}
$('.cRowSubQuestion').css('background-color', 'transparent');
//Hide data fields if option set
if (blnShowData == false) $('.cRow, .cRowAlt, .cRowSelected, .cRowAltSelected').hide();
$('.cClickImage').css('cursor', 'crosshair');
//Colect Clicks
$('.cClickImage').click(function (e) {//Handles image clicks.
if (strCurrOption != '') {
var offset = $(this).offset();
var intXCorr = parseInt((e.clientX + $(window).scrollLeft()) - offset.left);
var intYCorr = parseInt((e.clientY + $(window).scrollTop()) - offset.top);
//Correct for sizing of image
var $img = $(this);
var currentWidth = $img.width();
var currentHeight = $img.height();
var naturalWidth = this.naturalWidth;
var naturalHeight = this.naturalHeight;
intXCorr = ((naturalWidth / currentWidth) * intXCorr).toFixed(0);
intYCorr = ((naturalHeight / currentHeight) * intYCorr).toFixed(0);
if (strCurrOption == 'Positive') intFlag = '1';
else intFlag = '-1';
blnProcessClick = true;
if (blnSetIndTot == true && intNumPosClicks >= intPosClicksAllowed && strCurrOption == 'Positive') {
blnProcessClick = false;
strPosErrMsg = strPosErrMsg.replace("[PosMax]", intPosClicksAllowed);
$('.cErrorWrapper').html('<div>' + strPosErrMsg + '</div>');
}
if (blnSetIndTot == true && intNumNegClicks >= intNegClicksAllowed && strCurrOption == 'Negative') {
blnProcessClick = false;
strNegErrMsg = strNegErrMsg.replace("[NegMax]", intNegClicksAllowed);
$('.cErrorWrapper').html('<div>' + strNegErrMsg + '</div>');
}
if (blnSetComTot == true && intNumClick >= intClicksAllowed) {
blnProcessClick = false;
strErrMsg = strErrMsg.replace("[Max]", intClicksAllowed);
$('.cErrorWrapper').html('<div>' + strErrMsg + '</div>');
}
if (blnProcessClick == true) {
intNumClick++;
var strData = '';
if ($('input:text').eq(0).val().length != 0) strData = ';';
strData = strData + intNumView + ':' + intNumClick + ':' + intXCorr + ':' + intYCorr + ':' + intFlag;
$('input:text').eq(0).val($('input:text').eq(0).val() + strData);
$('input:text').eq(1).val(intNumClick);
//clickEffect(e.clientX,e.clientY)
var intY = e.clientY + $(window).scrollTop();
var intX = e.clientX + $(window).scrollLeft();
if (strCurrOption == 'Positive') {
strSRC = strPosClickImg;
intNumPosClicks = intNumPosClicks + 1;
}
else {
strSRC = strNegClickImg;
intNumNegClicks = intNumNegClicks + 1;
}
var strID = 'ClickTag' + intCurrZindex;
strClick = '<div id="' + strID + '" style="position: absolute; top: ' + parseInt(intY - 12) + 'px ;left: ' + parseInt(intX - 12) + 'px"><img style=" height: 20px; width: 20px;"src="' + strSRC + '" /></div>';
$('.cHeatImageOuter').append(strClick);
intCurrZindex = intCurrZindex + 1;
if (blnAutoNext == true) {
blnAdvance = true;
if (blnSetIndTot == true && intNumPosClicks < intPosClicksAllowed) blnAdvance = false;
if (blnSetIndTot == true && intNumNegClicks < intNegClicksAllowed) blnAdvance = false;
if (blnSetComTot == true && intNumClick < intClicksAllowed) blnAdvance = false;
if (blnAdvance == true) $('#btnNext').click();
}
}
}
else {
//No Click Type option selected
$('.cErrorWrapper').html('<div>' + strOptErrMsg + '</div>');
}
});
$('.cClickTypeButton').click(function (e) {
//Handles setting of the type of click to be recorded or removing clicks if Undo is pressed.
//Clear Error Messages
$('.cError').remove();
//Positive Clicked
if ($(this).attr('id') == 'ClickPositive') {
if ($(this).attr('bitOnOff') == '0') {
strCurrOption = 'Positive';
$(this).find('img').attr('src', strPosImgURLSel);
$('#ClickNegative').find('img').attr('src', strNegImgURL);
$(this).attr('bitOnOff', '1');
$('#ClickNegative').attr('bitOnOff', '0');
}
}
//Negative Clicked
if ($(this).attr('id') == 'ClickNegative') {
if ($(this).attr('bitOnOff') == '0') {
strCurrOption = 'Negative';
$(this).find('img').attr('src', strNegImgURLSel);
$('#ClickPositive').find('img').attr('src', strPosImgURL);
$(this).attr('bitOnOff', '1');
$('#ClickPositive').attr('bitOnOff', '0');
}
}
//Undo Clicked
if ($(this).attr('id') == 'ClickUndo') {
if (intCurrZindex > 1) {
intCurrZindex = intCurrZindex - 1;
var strID = '#ClickTag' + intCurrZindex;
$(strID).remove();
intNumClick = intNumClick - 1;
$('input:text').eq(1).val(intNumClick);
var intLastDataPos = $('input:text').eq(0).val().lastIndexOf(';');
if (intLastDataPos == 0) {
$('input:text').eq(0).val('');
//Reset all counts
intNumClick = 0;
intNumPosClicks = 0;
intNumNegClicks = 0;
}
else {
strClickTypeVal = $('input:text').eq(0).val().substr($('input:text').eq(0).val().lastIndexOf(':') + 1);
if (strClickTypeVal == '1') {
intNumPosClicks = intNumPosClicks - 1;
}
else {
intNumNegClicks = intNumNegClicks - 1;
}
strNewData = $('input:text').eq(0).val().substr(0, intLastDataPos);
$('input:text').eq(0).val(strNewData);
}
}
}
});
}
catch (err) {
if (debug == true) {
txt = "There was an error on this page.\n\n";
txt += "Error description: " + err.message + "\n\n";
txt += "Click OK to continue.\n\n";
alert(txt);
}
//Clean up
strHTML = ''; //Clear variable used for html
$('.iQuestContainer').remove(); //Remove html if already added
$('#btnNext').off('click');
$('#btnPrevious').off('click');
//Show question
$('.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').show();
}
}
function pickDate() { //Add a date picker to an open ended text box
//Exit function if question type not valid
var structOK = true;
//Number of questions on page should be 1
if ($('.cCellSubQuestion').length != 1) structOK = false;
//Check no radio or checkboxes buttons on screen
if ($('.cRadio').length != 0) structOK = false;
if ($('.cCheck').length != 0) structOK = false;
//Check there is only 1 open ended rows
if ($('input:text').length != 1) { structOK = false; }
if ($('textarea').length != 0) { structOK = false; }
//Check not a grid question
if ($('.cCellHeader').length != 0) structOK = false;
if (structOK == false) {
if (debug == true) alert('Structure not OK for iQuest e.q. Wrong question type. This question requires a single open ended row');
iQuestHelper('Structure not OK for iQuest e.q. Wrong question type. This question requires a muultiple question with one open ended row');
return false;
}
try {
var arrMinDate = strMinDate.split('/');
var datMinDate = new Date(parseInt(arrMinDate[2]), parseInt(arrMinDate[1]) - 1, parseInt(arrMinDate[0]));
var arrMaxDate = strMaxDate.split('/');
var datMaxDate = new Date(parseInt(arrMaxDate[2]), parseInt(arrMaxDate[1]) - 1, parseInt(arrMaxDate[0]));
$('input:text').datepicker({
dateFormat: strDateFormat,
firstDay: datFirstDay,
autoSize: datAutoSize,
changeMonth: datMonthDropDown,
minDate: datMinDate,
maxDate: datMaxDate,
constrainInput: true
});
}
catch (err) {
if (debug == true) {
txt = "There was an error on this page.\n\n";
txt += "Error description: " + err.message + "\n\n";
txt += "Click OK to continue.\n\n";
alert(txt);
}
}
}
function ImgSlider() {
//Check for WCAG
if ($('#btnToggleWcag').val()==1) {
return false;
}
debug = (typeof debug === "undefined") ? false : debug;//Turn on debuging(true/false)
wrpCopyEditorStyle = (typeof wrpCopyEditorStyle === "undefined") ? true : wrpCopyEditorStyle;
wrpFontSize = (typeof wrpFontSize === "undefined") ? '14px' : wrpFontSize;
wrpFontWeight = (typeof wrpFontWeight === "undefined") ? 'bold' : wrpFontWeight;
wrpFontStyle = (typeof wrpFontStyle === "undefined") ? 'normal' : wrpFontStyle;
wrpHorizontalAlign = (typeof wrpHorizontalAlign === "undefined") ? 'center' : wrpHorizontalAlign;
wrpBorderOn = (typeof wrpBorderOn === "undefined") ? true : wrpBorderOn;//Show 3D border around buttons (true/false).
wrpScrollTime = (typeof wrpScrollTime === "undefined") ? 150 : wrpScrollTime;
//Clean up
var strHtml = ''; //Clear variable used for html
$('.cGridButtonContainer').remove(); //Remove html if already added
//Validate Screen to ensure correct Question type
//Exit function if question type not valid
var structOK = true;
//Number of questions on page should be 1
if ($('.cCellSubQuestion').length != 1) structOK = false;
//Check radio buttons on screen
if ($('.cRadio').length == 0) structOK = false;
// Check answer type rn
if (structOK) {
var strID = $('.cRadio').eq(0).attr('id');
if (strID.substr(0, 2) != 'rn') structOK = false;
}
//More than 10 column images
if ($('.cCellHeader').length > 11) structOK = false;
//Not All columns have images
if (($('.cCellHeader').length - 1) != $('.cCellHeader').find('img').length) structOK = false;
if (structOK == false) {
if (debug == true) alert('(' + intErrorCode + ') Structure not OK for iQuest e.q. Wrong question type, this iQuest requires a single choice grid question with no more than 10 columns.');
iQuestHelper('Structure not OK for iQuest e.q. Wrong question type, this iQuest requires a single choice grid question with no more than 10 columns.');
if (($('.cCellHeader').length - 1) != $('.cCellHeader').find('img').length) iQuestHelper('Incorrect number of images each column should have one image');
return false;
}
try {
//Create HTML
strHtml = '<div>';
strHtml += '<div id="btnColor" style="display:none;"> </div><div id="btnColorClick" style="display:none;"> </div>';
strHtml += '<div style="margin-bottom:30px; margin-left:10px;"></div>';
strHtml += '<div id="wrap1" style="width: 100%; margin-bottom:30px;">';
strHtml += $('.cCellRowText:first').html();
strHtml += '</div>';
strHtml += '<table style="width: 100%">';
var intBtnCnt = 0;
var strStyle = '';
strHtml += '<tr><td><div style="margin-left:auto; margin-right: auto"></div></td></tr>';
strHtml += '<tr><td><div></div></td></tr>';
strHtml += '</table>';
strHtml += '</div>';
//Add HTML to Page
$('#UpdatePanel1').append(strHtml);
//Add Question text
$('.cGridButtonQuest').append($('.cCellSubQuestion').html());
//Set Row Counter
var wrapNo = 1;
//Create Slider
$('.cImgSlider').slider({
min: 0,
max: 99,
value: 50,
slide: function (event, ui) {
var intScore = parseInt($(this).slider('value') / parseInt(100 / parseInt($('.cCellHeader').length - 1)));
$('.cSliderImgBox').html($('.cCellHeader').eq(intScore + 1).html());
$('.cSliderImgBox').find('img').css('width', '100%');
},
change: function (event, ui) {
//set Answer for current row
var intScore = parseInt($(this).slider('value') / parseInt(100 / parseInt($('.cCellHeader').length - 1)));
$('.cSliderImgBox').html($('.cCellHeader').eq(intScore + 1).html());
$('.cSliderImgBox').find('img').css('width', '100%');
if (blnSysSet != true) {
var intAnswer = (parseInt(wrapNo - 1) * parseInt($('.cCellHeader').length - 1)) + parseInt(intScore);
$('.cCell input').eq(intAnswer).prop('checked', true);
}
else { blnSysSet = false; }
}
});
//Set slider position if question answered
var blnSysSet = true;
setSliderPos(wrapNo - 1);
//Add start image
$('.cSliderImgBox').html($('.cCellHeader').eq(3).html());
$('.cSliderImgBox').find('img').css('width', '100%');
//Format Screen
//$('.cGridButtonContainer').css('text-align','center');
$('.cGridButtonBtnContainer').css('width', '100%');
$('.cGridButtonBtnContainer').css('margin-left', 'auto');
$('.cGridButtonBtnContainer').css('margin-right', 'auto');
$('.cRowText').css('margin-left', 'auto');
$('.cRowText').css('margin-right', 'auto');
$('.cGridButtonWrapper').css('margin-left', 'auto');
$('.cGridButtonWrapper').css('margin-right', 'auto');
if (wrpRounded == true) $('.cGridButtonWrapper').css({ '-moz-border-radius': '20px', '-webkit-border-radius': '20px', '-khtml-border-radius': '20px', 'border-radius': '20px' });
$('.cGridButtonWrapper').css('width', wrpWidth);
$('.cGridButtonWrapper').css('height', wrpHeight);
$('.cGridButtonWrapper').css('padding-top', wrpTopPadding);
$('.cGridButtonWrapper').css('border-width', wrpBorderWidth);
$('.cGridButtonWrapper').css('border-style', wrpBorderStyle);
$('.cGridButtonWrapper').css('border-color', wrpBorderColor);
$('.cGridButtonWrapper').css('background-color', wrpBackGroundColor);
if (wrpCopyEditorStyle != true) {
$('.cRowText').find('strong').contents().unwrap();
$('.cRowText').find('span').css('text-align', '');
$('.cRowText').find('span').css('font-size', '');
$('.cRowText').css('font-size', wrpFontSize);
$('.cRowText').css('font-style', wrpFontStyle);
$('.cRowText').css('font-weight', wrpFontWeight);
$('.cRowText').css('text-align', wrpHorizontalAlign);
}
if (wrpBorderOn == false) $('.cGridButtonWrapper').css('border', '0px solid transparent');
$('.cSliderImgBox').css('height', imgHeight);
$('.cSliderImgBox').css('width', imgWidth);
//Slider handle
$('.ui-slider-horizontal .ui-state-default').css('background', '#804C00 url() no-repeat scroll 50% 50%');
//Slider Background
$('.ui-widget-content').css('background', '#ffffff url("http://rs.miprocloud.net/PortalDataService/Content/33uWjjnoouv/vSliderBackground.png") no-repeat scroll 50% 50%');
$('.ui-widget-content').css('background-size', '100%');
$('.ui-widget-content').css('height', '30px');
$('.ui-slider-range,.ui-slider-handle').css('height', '35px');
//Hide question
$('.cRowSubQuestion,.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').css('display', 'none');
//Hide Next Button
if ($('#uniform-btnNext').length != 0) {
$('#uniform-btnNext').css('visibility', 'hidden');
}
else {
$('.buttonNext').css('visibility', 'hidden');
}
//Add Dummy Next Button
$('#btnNext').before('<input id="btnNext2" name="btnNext2" value="Next" type="button">');
$('#btnNext2').on('click', function () {
//Get number of checked radio buttons - will be 1 or 0, only move on if not 0
var intAns = $('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').eq(wrapNo - 1).find('.cRadio:checked').length;
if (intAns != 0) {
var intNumRow = $('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').length;
//if last row clean up and move to next question
if (wrapNo == intNumRow) {
$('#btnNext2').off('click');
//Clean up
strHtml = ''; //Clear variable used for html
$('.cGridButtonContainer').remove(); //Remove html if already added
$('#btnNext').click();
}
//otherwise update scrolling text
else {
//Animate image off screen.
$('.cGridButtonWrapper').hide("slide", { direction: "left" }, wrpScrollTime,
//Animation Complete Function
function () {
wrapNo = wrapNo + 1;
//Create new main image
strHtml = $('.cCellRowText:nth(' + (wrapNo - 1) + ')').html();
$('.cGridButtonWrapper').html(strHtml);
//Show new main image
$('.cGridButtonWrapper').show("slide", { direction: "right" }, wrpScrollTime);
//Set previous answers
blnSysSet = true;
setSliderPos(wrapNo - 1);
});
}
}
});
$('#btnNext').on('click', function () {
//Clean up
$('.cGridButtonContainer').remove();
$('#btnNext').off('click');
$('#btnPrevious').off('click');
});
$('#btnPrevious').on('click', function () {
$('#btnNext').off('click');
$('#btnPrevious').off('click');
$('.cGridButtonContainer').remove(); //Remove html if already added
});
}
catch (err) {
//Clean up
strHtml = ''; //Clear variable used for html
$('.cGridButtonContainer').remove(); //Remove html if already added
//Show question
$('.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').css('display', '');
//Show Next button if click fails.
if ($('#uniform-btnNext').length != 0) {
$('#uniform-btnNext').css('visibility', 'visible');
}
else {
$('.buttonNext').css('visibility', 'visible');
}
}
}
function btnSingleGrid() { //Grid Single Buttons
//Check for WCAG
if ($('#btnToggleWcag').val()==1) {
return false;
}
//Give default values if not specified
quickMode = (typeof quickMode === "undefined") ? false : quickMode;
btnAutoStyle = (typeof btnAutoStyle === "undefined") ? "Ltblue" : btnAutoStyle;
quickModeHideText = (typeof quickModeHideText === "undefined") ? true : quickModeHideText;
btnHeight = (typeof btnHeight === "undefined") ? "75px" : btnHeight;
btnWidth = (typeof btnWidth === "undefined") ? "75px" : btnWidth;
btnPosition = (typeof btnPosition === "undefined") ? "below" : btnPosition;
btnNumColumn = (typeof btnNumColumn === "undefined") ? 0 : btnNumColumn;
btnSpacing = (typeof btnSpacing === "undefined") ? "5px" : btnSpacing;
btnColor = (typeof btnColor === "undefined") ? "#D3D3D3" : btnColor;
btnColorClick = (typeof btnColorClick === "undefined") ? "#DCE6F2" : btnColorClick;
btnRounded = (typeof btnRounded === "undefined") ? false : btnRounded;
btnTextColor = (typeof btnTextColor === "undefined") ? "#000000" : btnTextColor;
btnVerticalAlign = (typeof btnVerticalAlign === "undefined") ? "middle" : btnVerticalAlign;
btnCopyEditorStyle = (typeof btnCopyEditorStyle === "undefined") ? false : btnCopyEditorStyle;
btnFontSize = (typeof btnFontSize === "undefined") ? "14px" : btnFontSize;
btnFontWeight = (typeof btnFontWeight === "undefined") ? "bold" : btnFontWeight;
btnFontStyle = (typeof btnFontStyle === "undefined") ? "normal" : btnFontStyle;
btnHorizontalAlign = (typeof btnHorizontalAlign === "undefined") ? "center" : btnHorizontalAlign;
btnHideText = (typeof btnHideText === "undefined") ? false : btnHideText;
btnBorderOn = (typeof btnBorderOn === "undefined") ? true : btnBorderOn;
btnBorderWidth = (typeof btnBorderWidth === "undefined") ? "1px" : btnBorderWidth;
btnGraphicAutoSize = (typeof btnGraphicAutoSize === "undefined") ? true : btnGraphicAutoSize;
btnGraphicBackground = (typeof btnGraphicBackground === "undefined") ? false : btnGraphicBackground;
wrpHeight = (typeof wrpHeight === "undefined") ? "50px" : wrpHeight;
wrpWidth = (typeof wrpWidth === "undefined") ? "80%" : wrpWidth;
wrpTopPadding = (typeof wrpTopPadding === "undefined") ? "15px" : wrpTopPadding;
wrpSpacing = (typeof wrpSpacing === "undefined") ? "10px" : wrpSpacing;
wrpRounded = (typeof wrpRounded === "undefined") ? true : wrpRounded;
wrpBackGroundColor = (typeof wrpBackGroundColor === "undefined") ? "#F2F2F2" : wrpBackGroundColor;
wrpBorderOn = (typeof wrpBorderOn === "undefined") ? true : wrpBorderOn;
wrpBorderWidth = (typeof wrpBorderWidth === "undefined") ? "2px" : wrpBorderWidth;
wrpBorderColor = (typeof wrpBorderColor === "undefined") ? "#938953" : wrpBorderColor;
wrpBorderStyle = (typeof wrpBorderStyle === "undefined") ? "solid" : wrpBorderStyle;
wrpCopyEditorStyle = (typeof wrpCopyEditorStyle === "undefined") ? false : wrpCopyEditorStyle;
wrpTextColor = (typeof wrpTextColor === "undefined") ? "#000000" : wrpTextColor;
wrpFontSize = (typeof wrpFontSize === "undefined") ? "16px" : wrpFontSize;
wrpFontWeight = (typeof wrpFontWeight === "undefined") ? "bold" : wrpFontWeight;
wrpFontStyle = (typeof wrpFontStyle === "undefined") ? "normal" : wrpFontStyle;
wrpHorizontalAlign = (typeof wrpHorizontalAlign === "undefined") ? "center" : wrpHorizontalAlign;
wrpScrollTime = (typeof wrpScrollTime === "undefined") ? 150 : wrpScrollTime;
btnAutoNext = (typeof btnAutoNext === "undefined") ? true : btnAutoNext;
btnPreviousBeh = (typeof btnPreviousBeh === "undefined") ? "item" : btnPreviousBeh;
debug = (typeof debug === "undefined") ? false : debug;
mobileIt();
//Clean up
var strHtml = ''; //Clear variable used for html
$('.cGridButtonContainer').remove(); //Remove html if already added
//Validate Screen to ensure correct Question type
//Exit function if question type not valid
structOK = true;
//Number of questions on page should be 1
if ($('.cCellSubQuestion').length != 1) structOK = false;
//Check radio buttons on screen
if ($('.cRadio').length == 0) structOK = false;
if ($('.cCheck').length != 0) structOK = false;
// Check answer type rn
if (structOK) {
var strID = $('.cRadio').eq(0).attr('id');
if (strID.substr(0, 2) != 'rn') structOK = false;
}
if (structOK == false) {
if (debug == true) alert('Structure not OK for animation e.q. Wrong question type');
return false;
}
try {
//Create HTML
var wrapNo = 1;
if (btnPreviousBeh == 'item') {
//Add Dummy Previous button
$('#btnNext').before('<input id="btnPrevious2" name="btnPrevious2" value="Previous" type="button"></input> ');
$('#btnPrevious2').val($('#btnPrevious').val());
if ($('#btnPrevious').length == 0) { $('#btnPrevious2').val(' << '); }
//Hide Previous Button
$('#btnPrevious').hide();
if ($('#mi_direction').val() == -1) { wrapNo = $('.cCellRowText').length; }
}
var strStyle = '';
var strWrapHtml = '';
strWrapHtml += '<div id="wrap1">';
strWrapHtml += $('.cCellRowText').eq(wrapNo - 1).html();
strWrapHtml += '</div>';
var strBtnHtml = '';
strBtnHtml += '<table><tr>';
var intBtnCnt = 0;
var blnEndRow = false;
$('.cCellHeader:not(.cCellFirstHeader)').each(function () {
var alignStyle = "";
if ($(this).hasClass("textleft")) {
alignStyle = "text-align:left;";
}
else if ($(this).hasClass("textcenter")) {
alignStyle = "text-align:center;";
}
else if ($(this).hasClass("textright")) {
alignStyle = "text-align:right;";
}
strStyle = 'style="' + alignStyle;
if (typeof $(this).attr('style') !== 'undefined') {
strStyle += $(this).attr('style');
}
strStyle += '"';
strBtnHtml += '<td alt="' + intBtnCnt + '" ' + strStyle + '>' + $(this).html() + '</td>';
if (parseInt(intBtnCnt + 1) % btnNumColumn == 0) { //end row depending on the number of buttons specified in the options
strBtnHtml += '</tr>';
blnEndRow = true;
}
else {
blnEndRow = false;
}
intBtnCnt++;
});
if (blnEndRow == false) { strBtnHtml += '</tr>'; }
strBtnHtml += '</table>';
strHtml = '<div>';
if (btnPosition == 'below') {
strHtml += strWrapHtml;
strHtml += strBtnHtml;
}
else {
strHtml += strBtnHtml;
strHtml += strWrapHtml;
}
strHtml += '</div>';
$('#UpdatePanel1').append(strHtml);
//Formatting
$('.cBtnTable').css('width', 'auto');
$('.cBtnTable').css('margin-left', 'auto');
$('.cBtnTable').css('margin-right', 'auto');
$('.cBtnTable').css('border-collapse', 'separate');
$('.cBtnSingleGrid').css('padding-left', '5px');
$('.cBtnSingleGrid').css('padding-top', '5px');
$('.cBtnSingleGrid').css('cursor', 'pointer');
$('.cGridButtonWrapper').css('margin-left', 'auto');
$('.cGridButtonWrapper').css('margin-right', 'auto');
$('.cGridButtonWrapper').css('padding', '5px');
//Formatting from options
$('.cBtnSingleGrid').css('background-color', btnColor);
$('.cBtnSingleGrid').removeClass('btnChecked');
$('.cBtnSingleGrid').css('height', btnHeight);
$('.cBtnSingleGrid').css('width', btnWidth);
$('.cBtnSingleGrid').css('color', btnTextColor);
$('.cBtnSingleGrid').css('vertical-align', btnVerticalAlign);
$('.cBtnSingleGrid').css('border-right', btnBorderWidth + ' solid #696969');
$('.cBtnSingleGrid').css('border-bottom', btnBorderWidth + ' solid #696969');
$('.cBtnSingleGrid').css('border-top', btnBorderWidth + ' solid #E5E5E5');
$('.cBtnSingleGrid').css('border-left', btnBorderWidth + ' solid #E5E5E5');
if (btnGraphicBackground == true) {
$('.cBtnSingleGrid').each(function () {
strURL = $(this).find('img').eq(0).attr('src');
$(this).find('img').eq(0).remove();
$(this).css('background', btnColor + ' url("' + strURL + '") no-repeat center center');
$(this).css('background-size', '100% 100%');
});
}
if (btnCopyEditorStyle != true) {
$('.cBtnSingleGrid').find('strong').contents().unwrap();
$('.cBtnSingleGrid').find('span').contents().unwrap();
$('.cBtnSingleGrid').css('font-size', btnFontSize);
$('.cBtnSingleGrid').css('font-style', btnFontStyle);
$('.cBtnSingleGrid').css('font-weight', btnFontWeight);
$('.cBtnSingleGrid').css('text-align', btnHorizontalAlign);
}
if (wrpCopyEditorStyle != true) {
$('.cRowText').find('strong').contents().unwrap();
$('.cRowText').find('span').css('text-align', '');
$('.cRowText').find('span').css('font-size', '');
$('.cRowText').css('font-size', wrpFontSize);
$('.cRowText').css('font-style', wrpFontStyle);
$('.cRowText').css('font-weight', wrpFontWeight);
$('.cRowText').css('text-align', wrpHorizontalAlign);
}
$('.cBtnTable').css('border-spacing', btnSpacing);
if (btnHideText != false) {
$('.cBtnSingleGrid').css({ 'font-size': '0px', 'color': 'transparent' });
$('.cBtnSingleGrid').find('span').css({ 'font-size': '0px', 'color': 'transparent' });
}
if (btnGraphicAutoSize == true) $('.cBtnSingleGrid').find('img').css({ 'width': '100%' });
if (btnRounded != false) $('.cBtnSingleGrid').css({ '-moz-border-radius': '20px', '-webkit-border-radius': '20px', '-khtml-border-radius': '20px', 'border-radius': '20px' });
if (wrpWidth == 0) {
$('.cGridButtonWrapper').css('width', $('.cBtnTable').css('width'));
}
else { $('.cGridButtonWrapper').css('width', wrpWidth); }
if (wrpHeight != 0) {
$('.cGridButtonWrapper').css('height', wrpHeight);
}
if (wrpRounded != false) $('.cGridButtonWrapper').css({ '-moz-border-radius': '20px', '-webkit-border-radius': '20px', '-khtml-border-radius': '20px', 'border-radius': '20px' });
$('.cRowText').css('color', wrpTextColor);
$('.cGridButtonWrapper').css('border-width', wrpBorderWidth);
$('.cGridButtonWrapper').css('border-style', wrpBorderStyle);
$('.cGridButtonWrapper').css('border-color', wrpBorderColor);
$('.cGridButtonWrapper').css('background-color', wrpBackGroundColor);
$('.cGridButtonWrapper').css('margin-bottom', wrpSpacing);
$('.cGridButtonWrapper').css('margin-top', wrpSpacing);
$('.cGridButtonWrapper').css('padding-top', wrpTopPadding);
if (btnBorderOn == false) $('.cBtnSingleGrid').css('border', '0px solid transparent');
if (wrpBorderOn == false) $('.cGridButtonWrapper').css('border', '0px solid transparent');
if (quickMode == true) {
switch (btnAutoStyle) {
case 'DkBlue':
fncSetBtnBackground('Scripts/QuickMode/BtnDarkBlue.png', '.cBtnSingleGrid');
break;
case 'Green':
fncSetBtnBackground('Scripts/QuickMode/BtnGreen.png', '.cBtnSingleGrid');
break;
case 'LtBlue':
fncSetBtnBackground('Scripts/QuickMode/BtnLightBlue.png', '.cBtnSingleGrid');
break;
case 'LtGrey':
fncSetBtnBackground('Scripts/QuickMode/BtnLightGrey.png', '.cBtnSingleGrid');
break;
case 'Orange':
fncSetBtnBackground('Scripts/QuickMode/BtnOrange.png', '.cBtnSingleGrid');
break;
case 'Red':
fncSetBtnBackground('Scripts/QuickMode/BtnRed.png', '.cBtnSingleGrid');
break;
case 'Yellow':
fncSetBtnBackground('Scripts/QuickMode/BtnYellow.png', '.cBtnSingleGrid');
break;
case 'DkBlueOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1DarkBlue.png', '.cBtnSingleGrid');
break;
case 'DkGreyOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1DarkGrey.png', '.cBtnSingleGrid');
break;
case 'GreenOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Green.png', '.cBtnSingleGrid');
break;
case 'LtBlueOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1LightBlue.png', '.cBtnSingleGrid');
break;
case 'LtGreyOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1LightGrey.png', '.cBtnSingleGrid');
break;
case 'MagentaOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Magenta.png', '.cBtnSingleGrid');
break;
case 'OrangeOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Orange.png', '.cBtnSingleGrid');
break;
case 'RedOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Red.png', '.cBtnSingleGrid');
break;
case 'YellowOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Yellow.png', '.cBtnSingleGrid');
break;
case 'Smiley1':
fncSetGridBtnBackground('.cBtnSingleGrid', 'Smiley1', 5, 5);
break;
case 'Smiley2':
fncSetGridBtnBackground('.cBtnSingleGrid', 'Smiley2', 5, 5);
break;
case 'Dice1':
fncSetGridBtnBackground('.cBtnSingleGrid', 'Dice1', 2, 6);
break;
case 'Dice2':
fncSetGridBtnBackground('.cBtnSingleGrid', 'Dice2', 2, 6);
break;
case 'Temp':
fncSetGridBtnBackground('.cBtnSingleGrid', 'Temp', 2, 8);
break;
case 'Postit':
fncSetGridBtnBackground('.cBtnSingleGrid', 'Postit', 5, 5);
break;
case 'Dot':
fncSetGridBtnBackground('.cBtnSingleGrid', 'Dot', 3, 5);
break;
case 'Star1':
fncSetGridBtnBackground('.cBtnSingleGrid', 'Star1', 5, 5);
break;
case 'Star2':
fncSetGridBtnBackground('.cBtnSingleGrid', 'Star2', 5, 5);
break;
case 'Numbers':
fncSetGridBtnBackground('.cBtnSingleGrid', 'Numbers', 2, 9);
break;
}
}
//Hide question
$('.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').css('display', 'none');
//Hide Next Button
fncHideNext();
var blnClickOn = true;
//Check if row answered and change button if is
btnMultiSetSingle(wrapNo - 1);
var numItems = $('.cCellRowText').length;
var intAnswer = 0;
$(document).on("click", ".cBtnSingleGrid", function () {
//$('.cBtnSingleGrid').live('click',function () {
if (blnClickOn == true) {
blnClickOn = false;
//Button effect
$('.cBtnSingleGrid').css('background-color', btnColor).removeClass('btnChecked');
$(this).css('background-color', btnColorClick).addClass('btnChecked');
$(this).effect("pulsate", {}, 10);
//Set Answer
intAnswer = (parseInt(wrapNo - 1) * parseInt(intBtnCnt)) + parseInt($(this).attr('alt'));
$('.cCell input').eq(intAnswer).prop('checked', true);
if (wrapNo == numItems) {
if (btnAutoNext == true) {
$('#btnNext').click();
}
//Show Next button if click fails.
fncShowNext();
blnClickOn = true;
}
else {
//Animate image off screen.
$('.cGridButtonWrapper').hide("slide", { direction: "left" }, wrpScrollTime,
//Animation Complete Function
function () {
wrapNo = wrapNo + 1;
//Create new main image
strHtml = $('.cCellRowText:nth(' + (wrapNo - 1) + ')').html();
$('.cGridButtonWrapper').html(strHtml);
//Show new main image
$('.cGridButtonWrapper').show("slide", { direction: "right" }, wrpScrollTime,
function () {//when animation complete allow buttons to be clicked again.
//Set answer if question previously answered.
//Check if row answered and change button if is
btnMultiSetSingle(wrapNo - 1);
blnClickOn = true;
});
});
}
}
});
$('#btnPrevious2').on('click', function () {
if (blnClickOn == true) {
blnClickOn = false;
if (wrapNo == 1) {
if ($('#btnPrevious').length > 0) {
$('#btnPrevious').show();
$('#btnPrevious2').hide();
$('#btnPrevious').click();
}
blnClickOn = true;
}
else {
//Animate image off screen.
$('.cGridButtonWrapper').hide("slide", { direction: "right" }, wrpScrollTime,
//Animation Complete Function
function () {
wrapNo = wrapNo - 1;
//Create new main image
strHtml = $('.cCellRowText:nth(' + (wrapNo - 1) + ')').html();
$('.cGridButtonWrapper').html(strHtml);
//Show new main image
$('.cGridButtonWrapper').show("slide", { direction: "left" }, wrpScrollTime,
function () {//when animation complete allow buttons to be clicked again.
//Set answer if question previously answered.
//Check if row answered and change button if is
btnMultiSetSingle(wrapNo - 1);
blnClickOn = true;
});
});
}
}
});
$('#btnNext').on('click', function () {
//Clean up
strHtml = ''; //Clear variable used for html
$('.cGridButtonContainer').remove(); //Remove html if already added
$(document).off("click", ".cBtnSingleGrid");
//$('.cBtnSingleGrid').die('click');
$('#btnNext').off('click');
$('#btnPrevious').off('click');
$('#btnPrevious2').off('click');
});
$('#btnPrevious').on('click', function () {
$('#btnNext').off('click');
$('#btnPrevious').off('click');
$('#btnPrevious2').off('click');
$('#btnPrevious2').remove();
$(document).off("click", ".cBtnSingleGrid");
//$('.cBtnSingleGrid').die('click');
});
}
catch (err) {
if (debug == true) {
txt = "There was an error on this page.\n\n";
txt += "Error description: " + err.message + "\n\n";
txt += "Click OK to continue.\n\n";
alert(txt);
}
//Clean up
strHtml = ''; //Clear variable used for html
//Show question
$('.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').css('display', '');
//Show Next button
fncShowNext();
}
}
function btnMultiGrd() { //Grid Multiple Buttons
//Check for WCAG
if ($('#btnToggleWcag').val()==1) {
return false;
}
//Give defaultvalues if not specified
debug = (typeof debug === "undefined") ? false : debug;//Turn on debuging(true/false)
btnNumColumn = (typeof btnNumColumn === "undefined") ? 0 : btnNumColumn;//The number of buttons per row of buttons (0 = fit all on one line)
btnColor = (typeof btnColor === "undefined") ? '#FFB8FF' : btnColor;//The colour of buttons before they are clicked.
btnColorClick = (typeof btnColorClick === "undefined") ? '#99CCFF' : btnColorClick;//The colour of buttons when they are clicked.
btnHeight = (typeof btnHeight === "undefined") ? '75px' : btnHeight;//The height of the button.
btnWidth = (typeof btnWidth === "undefined") ? '75px' : btnWidth;//The width of the button.
btnPosition = (typeof btnPosition === "undefined") ? "below" : btnPosition;
btnVerticalAlign = (typeof btnVerticalAlign === "undefined") ? 'middle' : btnVerticalAlign;//Vertical alignment (top/middle/bottom)
btnSpacing = (typeof btnSpacing === "undefined") ? '10px' : btnSpacing;//Set the spacing around the buttons.
btnRounded = (typeof btnRounded === "undefined") ? true : btnRounded;//Rounded corners on buttons (true/false)
btnBorderOn = (typeof btnBorderOn === "undefined") ? true : btnBorderOn;//Show 3D border around buttons (true/false).
btnBorderWidth = (typeof btnBorderWidth === "undefined") ? '4px' : btnBorderWidth;//Set the border width around the buttons.
btnGraphicAutoSize = (typeof btnGraphicAutoSize === "undefined") ? true : btnGraphicAutoSize;//Automatically size images to fit buttons (true/false).
btnGraphicBackground = (typeof btnGraphicBackground === "undefined") ? false : btnGraphicBackground;
btnTextColor = (typeof btnTextColor === "undefined") ? '#000000' : btnTextColor;//Set the color of the text displayed on the buttons.
btnCopyEditorStyle = (typeof btnCopyEditorStyle === "undefined") ? true : btnCopyEditorStyle;
btnFontSize = (typeof btnFontSize === "undefined") ? '14px' : btnFontSize;
btnFontWeight = (typeof btnFontWeight === "undefined") ? 'bold' : btnFontWeight;
btnFontStyle = (typeof btnFontStyle === "undefined") ? 'normal' : btnFontStyle;
btnHorizontalAlign = (typeof btnHorizontalAlign === "undefined") ? 'center' : btnHorizontalAlign;
btnHideText = (typeof btnHideText === "undefined") ? false : btnHideText;//If using images hide the text that will be available in the analysis (true/false).
wrpWidth = (typeof wrpWidth === "undefined") ? '95%' : wrpWidth;//The width of the scrolling row element.
wrpHeight = (typeof wrpHeight === "undefined") ? '100px' : wrpHeight;//The height of the scrolling row element.
wrpTextColor = (typeof wrpTextColor === "undefined") ? '#000000' : wrpTextColor;//Set the color of the text displayed on the buttons.
wrpTopPadding = (typeof wrpTopPadding === "undefined") ? '40px' : wrpTopPadding;//The padding above the text in the scrolling row element, used to center the text
wrpRounded = (typeof wrpRounded === "undefined") ? true : wrpRounded;//Rounded corners on scrolling row element (true/false).
wrpBorderOn = (typeof wrpBorderOn === "undefined") ? true : wrpBorderOn;//Show 3D border around buttons (true/false).
wrpBorderWidth = (typeof wrpBorderWidth === "undefined") ? '1px' : wrpBorderWidth;//The border width of the scrolling row element.
wrpBorderStyle = (typeof wrpBorderStyle === "undefined") ? 'solid' : wrpBorderStyle;//The border style of the scrolling row element.
wrpBorderColor = (typeof wrpBorderColor === "undefined") ? 'black' : wrpBorderColor;//The border colour of the scrolling row element.
wrpBackGroundColor = (typeof wrpBackGroundColor === "undefined") ? '#F0F5F5' : wrpBackGroundColor; //The background colour of the scrolling row element.
wrpSpacing = (typeof wrpSpacing === "undefined") ? '10px' : wrpSpacing;//The spaceing above and below of the scrolling row element.
wrpCopyEditorStyle = (typeof wrpCopyEditorStyle === "undefined") ? true : wrpCopyEditorStyle;
wrpFontSize = (typeof wrpFontSize === "undefined") ? '14px' : wrpFontSize;
wrpFontWeight = (typeof wrpFontWeight === "undefined") ? 'bold' : wrpFontWeight;
wrpFontStyle = (typeof wrpFontStyle === "undefined") ? 'normal' : wrpFontStyle;
wrpHorizontalAlign = (typeof wrpHorizontalAlign === "undefined") ? 'center' : wrpHorizontalAlign;
wrpScrollTime = (typeof wrpScrollTime === "undefined") ? 150 : wrpScrollTime;
quickMode = (typeof quickMode === "undefined") ? false : quickMode;
btnAutoStyle = (typeof btnAutoStyle === "undefined") ? 'LtBlue' : btnAutoStyle;
//Clean up
var strHtml = ''; //Clear variable used for html
$('.cGridButtonContainer').remove(); //Remove html if already added
//Validate Screen to ensure correct Question type
//Exit function if question type not valid
var structOK = true;
//Number of questions on page should be 1
if ($('.cCellSubQuestion').length != 1) structOK = false;
//Check checkboxes buttons on screen
if ($('.cCheck').length == 0) structOK = false;
// Check answer type rm
var strID = $('.cCheck').eq(0).attr('id');
if (strID.substr(0, 2) != 'rm') structOK = false;
if (structOK == false) {
if (debug == true) alert('Structure not OK for animation e.q. Wrong question type');
return false;
}
try {
//Create HTML
var strStyle = '';
strWrapHtml = '';
strWrapHtml += '<div id="wrap1">';
strWrapHtml += $('.cCellRowText:first').html();
strWrapHtml += '</div>';
strBtnHtml = '';
strBtnHtml += '<table><tr>';
var intBtnCnt = 0;
var blnEndRow = false;
var strStyle = '';
$('.cCellHeader:not(.cCellFirstHeader)').each(function () {
var alignStyle = "";
if ($(this).hasClass("textleft")) {
alignStyle = "text-align:left;";
}
else if ($(this).hasClass("textcenter")) {
alignStyle = "text-align:center;";
}
else if ($(this).hasClass("textright")) {
alignStyle = "text-align:right;";
}
strStyle = 'style="' + alignStyle;
if (typeof $(this).attr('style') !== 'undefined') {
strStyle += $(this).attr('style');
}
strStyle += '"';
strBtnHtml += '<td alt="' + intBtnCnt + '" ' + strStyle + '>' + $(this).html() + '</td>';
if (parseInt(intBtnCnt + 1) % btnNumColumn == 0) { //end row depending on the number of buttons specified in the options
strBtnHtml += '</tr>';
blnEndRow = true;
}
else {
blnEndRow = false;
}
intBtnCnt++;
});
if (blnEndRow == false) { strBtnHtml += '</tr>'; }
strBtnHtml += '</table>';
strHtml = '<div>';
if (btnPosition == 'below') {
strHtml += strWrapHtml;
strHtml += strBtnHtml;
}
else {
strHtml += strBtnHtml;
strHtml += strWrapHtml;
}
strHtml += '</div>';
$('#UpdatePanel1').append(strHtml);
//Add Dummy next button
$('#btnNext').before('<input id="btnNext2" name="btnNext2" value="Next" type="button">');
$('#btnNext2').val($('#btnNext').val());
//Add Question Text
$('.cGridButtonQuest').append($('.cCellSubQuestion').html());
$('.cBtnTable').css('width', 'auto');
$('.cBtnTable').css('margin-left', 'auto');
$('.cBtnTable').css('margin-right', 'auto');
$('.cBtnTable').css('border-collapse', 'separate');
$('.cBtnMultiGrid').css('padding-left', '5px');
$('.cBtnMultiGrid').css('padding-top', '5px');
$('.cBtnMultiGrid').css('border-right', '5px solid #696969');
$('.cBtnMultiGrid').css('border-bottom', '5px solid #696969');
$('.cBtnMultiGrid').css('border-top', '5px solid #E5E5E5');
$('.cBtnMultiGrid').css('border-left', '5px solid #E5E5E5');
$('.cBtnMultiGrid').css('cursor', 'pointer');
$('.cGridButtonWrapper').css('margin-left', 'auto');
$('.cGridButtonWrapper').css('margin-right', 'auto');
$('.cGridButtonWrapper').css('padding', '5px');
//Formatting from options
$('.cBtnMultiGrid').css('background-color', btnColor);
$('.cBtnMultiGrid').removeClass('btnChecked');
$('.cBtnMultiGrid').css('height', btnHeight);
$('.cBtnMultiGrid').css('width', btnWidth);
$('.cBtnMultiGrid').css('color', btnTextColor);
$('.cBtnMultiGrid').css('vertical-align', btnVerticalAlign);
$('.cBtnMultiGrid').css('border-right', btnBorderWidth + ' solid #696969');
$('.cBtnMultiGrid').css('border-bottom', btnBorderWidth + ' solid #696969');
$('.cBtnMultiGrid').css('border-top', btnBorderWidth + ' solid #E5E5E5');
$('.cBtnMultiGrid').css('border-left', btnBorderWidth + ' solid #E5E5E5');
$('.cBtnMultiGrid').css('vertical-align', btnVerticalAlign);
$('.cBtnTable').css('border-spacing', btnSpacing);
if (btnHideText != false) {
$('.cBtnMultiGrid').css({ 'font-size': '0px', 'color': 'transparent' });
$('.cBtnMultiGrid').find('span').css({ 'font-size': '0px', 'color': 'transparent' });
}
if (btnGraphicAutoSize == true) $('.cBtnMultiGrid').find('img').css({ 'width': '100%' });
if (btnGraphicBackground == true) {
$('.cBtnMultiGrid').each(function () {
strURL = $(this).find('img').eq(0).attr('src');
$(this).find('img').eq(0).remove();
$(this).css('background', btnColor + ' url("' + strURL + '") no-repeat center center');
$(this).css('background-size', '100% 100%');
});
}
if (btnCopyEditorStyle != true) {
$('.cBtnMultiGrid').find('strong').contents().unwrap();
$('.cBtnMultiGrid').find('span').contents().unwrap();
$('.cBtnMultiGrid').css('font-size', btnFontSize);
$('.cBtnMultiGrid').css('font-style', btnFontStyle);
$('.cBtnMultiGrid').css('font-weight', btnFontWeight);
$('.cBtnMultiGrid').css('text-align', btnHorizontalAlign);
}
if (wrpCopyEditorStyle != true) {
$('.cRowText').find('strong').contents().unwrap();
$('.cRowText').find('span').css('text-align', '');
$('.cRowText').find('span').css('font-size', '');
$('.cRowText').css('font-size', wrpFontSize);
$('.cRowText').css('font-style', wrpFontStyle);
$('.cRowText').css('font-weight', wrpFontWeight);
$('.cRowText').css('text-align', wrpHorizontalAlign);
}
if (btnRounded != false) $('.cBtnMultiGrid').css({ '-moz-border-radius': '20px', '-webkit-border-radius': '20px', '-khtml-border-radius': '20px', 'border-radius': '20px' });
if (wrpWidth == 0) {
$('.cGridButtonWrapper').css('width', $('.cBtnTable').css('width'));
}
else { $('.cGridButtonWrapper').css('width', wrpWidth); }
if (wrpHeight != 0) {
$('.cGridButtonWrapper').css('height', wrpHeight);
}
if (wrpRounded != false) $('.cGridButtonWrapper').css({ '-moz-border-radius': '20px', '-webkit-border-radius': '20px', '-khtml-border-radius': '20px', 'border-radius': '20px' });
$('.cRowText').css('color', wrpTextColor);
$('.cGridButtonWrapper').css('border-width', wrpBorderWidth);
$('.cGridButtonWrapper').css('border-style', wrpBorderStyle);
$('.cGridButtonWrapper').css('border-color', wrpBorderColor);
$('.cGridButtonWrapper').css('background-color', wrpBackGroundColor);
$('.cGridButtonWrapper').css('margin-bottom', wrpSpacing);
$('.cGridButtonWrapper').css('margin-top', wrpSpacing);
$('.cGridButtonWrapper').css('padding-top', wrpTopPadding);
if (btnBorderOn == false) $('.cBtnMultiGrid').css('border', '0px solid transparent');
if (wrpBorderOn == false) $('.cGridButtonWrapper').css('border', '0px solid transparent');
if (quickMode == true) {
switch (btnAutoStyle) {
case 'DkBlue':
fncSetBtnBackground('Scripts/QuickMode/BtnDarkBlue.png', '.cBtnMultiGrid');
break;
case 'Green':
fncSetBtnBackground('Scripts/QuickMode/BtnGreen.png', '.cBtnMultiGrid');
break;
case 'LtGrey':
fncSetBtnBackground('Scripts/QuickMode/BtnLightGrey.png', '.cBtnMultiGrid');
break;
case 'LtBlue':
fncSetBtnBackground('Scripts/QuickMode/BtnLightBlue.png', '.cBtnMultiGrid');
break;
case 'Orange':
fncSetBtnBackground('Scripts/QuickMode/BtnOrange.png', '.cBtnMultiGrid');
break;
case 'Red':
fncSetBtnBackground('Scripts/QuickMode/BtnRed.png', '.cBtnMultiGrid');
break;
case 'Yellow':
fncSetBtnBackground('Scripts/QuickMode/BtnYellow.png', '.cBtnMultiGrid');
break;
case 'DkBlueOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1DarkBlue.png', '.cBtnMultiGrid');
break;
case 'DkGreyOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1DarkGrey.png', '.cBtnMultiGrid');
break;
case 'GreenOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Green.png', '.cBtnMultiGrid');
break;
case 'LtBlueOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1LightBlue.png', '.cBtnMultiGrid');
break;
case 'LtGreyOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1LightGrey.png', '.cBtnMultiGrid');
break;
case 'MagentaOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Magenta.png', '.cBtnMultiGrid');
break;
case 'OrangeOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Orange.png', '.cBtnMultiGrid');
break;
case 'RedOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Red.png', '.cBtnMultiGrid');
break;
case 'YellowOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Yellow.png', '.cBtnMultiGrid');
break;
}
}
//Hide question
$('.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').css('display', 'none');
//Hide Next Button
fncHideNext();
var blnClickOn = true;
var wrapNo = 1;
//Set Previous Answers
btnMultiSetMulti(wrapNo - 1);
var numItems = $('.cCellRowText').length;
var intAnswer = 0;
$(document).on("click", ".cBtnMultiGrid", function () {
//$('.cBtnMultiGrid').live('click',function () {
if (blnClickOn == true) {
blnClickOn = false;
//Button effect
$(this).effect("pulsate", {}, 10);
//Set Answer
intAnswer = (parseInt(wrapNo - 1) * parseInt(intBtnCnt)) + parseInt($(this).attr('alt'));
strType = $('.cCell input').eq(intAnswer).prop('type');
if (strType == 'checkbox') {
if ($('.cCell input').eq(intAnswer).prop('checked')) {
$('.cCell input').eq(intAnswer).prop('checked', false);
if (!$('.cCell input').eq(intAnswer).prop('checked')) {
if (quickMode != true) {
$(this).css('background-color', btnColor).removeClass('btnChecked');
}
else {
$(this).css('background-color', 'transparent');
}
if ($('.unified').length > 0) { $('.cCell input').eq(intAnswer).parent().removeClass('checked'); }
}
}
else {
$('.cCell input').eq(intAnswer).prop('checked', true);
if ($('.cCell input').eq(intAnswer).prop('checked')) {
$(this).css('background-color', btnColorClick).addClass('btnChecked');
if ($('.unified').length > 0) { $('.cCell input').eq(intAnswer).parent().addClass('checked'); }
}
}
intBtnNum = 0;
//clear radio
for (i = (parseInt(wrapNo - 1) * parseInt(intBtnCnt)); i <= (parseInt(wrapNo - 1) * parseInt(intBtnCnt)) + (intBtnCnt - 1); i++) {
if ($('.cCell input').eq(i).prop('type') != 'checkbox') {
if (quickMode != true) {
$('.cBtnMultiGrid').eq(intBtnNum).css('background-color', btnColor).removeClass('btnChecked');
}
else {
$('.cBtnMultiGrid').eq(intBtnNum).css('background-color', 'transparent');
}
$('.cCell input').eq(i).prop('checked', false);
}
intBtnNum++;
}
}
else {
if (quickMode != true) {
$('.cBtnMultiGrid').css('background-color', btnColor).removeClass('btnChecked');
}
else {
$('.cBtnMultiGrid').css('background-color', 'transparent');
}
if ($('.cCell input').eq(intAnswer).prop('checked')) {
if (quickMode != true) {
$(this).css('background-color', btnColor).removeClass('btnChecked');
}
else {
$(this).css('background-color', 'transparent');
}
$('.cCell input').eq(intAnswer).prop('checked', false);
if ($('.unified').length > 0) { $('.cCell input').eq(intAnswer).parent().addClass('checked'); }
}
else {
$(this).css('background-color', btnColorClick).addClass('btnChecked');
$('.cCell input').eq(intAnswer).prop('checked', true);
if ($('.unified').length > 0) { $('.cCell input').eq(intAnswer).parent().addClass('checked'); }
//clear other answers
intBtnNum = 0;
for (i = (parseInt(wrapNo - 1) * parseInt(intBtnCnt)); i <= (parseInt(wrapNo - 1) * parseInt(intBtnCnt)) + (intBtnCnt - 1); i++) {
if (i != intAnswer) {
if (quickMode != true) {
$('.cBtnMultiGrid').eq(i).css('background-color', btnColor).removeClass('btnChecked');
}
else {
$('.cBtnMultiGrid').eq(i).css('background-color', 'transparent');
}
$('.cCell input').eq(i).prop('checked', false);
if ($('.unified').length > 0) { $('.cCell input').eq(i).parent().removeClass('checked'); }
}
intBtnNum++;
}
}
}
blnClickOn = true;
}
});
$(document).on("click", "#btnNext2", function () {
//$('#btnNext2').live('click',function () {
$('.cError').remove();
//Calculate number of answers by counting buttons with clicked background colour
intNumAns = 0;
$('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').eq(wrapNo - 1).find('.cCheck, .cRadio').each(function () {
if ($(this).is(':checked')) intNumAns++;
});
if (intNumAns > 0) {
//Animate image off screen.
$('.cGridButtonWrapper').hide("slide", { direction: "left" }, wrpScrollTime,
//Animation Complete Function
function () {
if (wrapNo == numItems) {
//Clean up
strHtml = ''; //Clear variable used for html
$('#btnNext').click();
}
else {
wrapNo = wrapNo + 1;
//Create new main image
strHtml = $('.cCellRowText:nth(' + (wrapNo - 1) + ')').html();
$('.cGridButtonWrapper').html(strHtml);
//Show new main image
$('.cGridButtonWrapper').show("slide", { direction: "right" }, wrpScrollTime,
function () {
blnClickOn = true;
});
//Clear Answers
$('.cBtnMultiGrid').css('background-color', btnColor).removeClass('btnChecked');
//Set previous answers
btnMultiSetMulti(wrapNo - 1);
}
});
}
else {
$('.cGridButtonBtnContainer').before('<div>Please select at least 1 answer<br/><br/></div>');
}
});
$('#btnNext').on('click', function () {
//Clean up
$(document).off("click", ".cBtnMultiGrid");
//$('.cBtnMultiGrid').die('click');
$('#btnNext').off('click');
$(document).off("click", "#btnNext2");
//$('#btnNext2').die('click');
$('#btnPrevious').off('click');
});
$('#btnPrevious').on('click', function () {
$('#btnNext').off('click');
$('#btnPrevious').off('click');
$(document).off("click", ".cBtnMultiGrid");
//$('.cBtnMultiGrid').die('click');
$(document).off("click", "#btnNext2");
//$('#btnNext2').die('click');
});
}
catch (err) {
//Clean up
strHtml = ''; //Clear variable used for html
$('.cGridButtonContainer').remove(); //Remove html if already added
//Show question
$('.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').css('display', '');
//Show Next button if click fails.
if ($('#uniform-btnNext').length != 0) {
$('#uniform-btnNext').css('visibility', 'visible');
}
else {
$('.buttonNext').css('visibility', 'visible');
}
}
}
function rollSingleGrid() { //Grid Single rolling Buttons
//Check for WCAG
if ($('#btnToggleWcag').val()==1) {
return false;
}
//Give defaultvalues if not specified
quickMode = (typeof quickMode === "undefined") ? false : quickMode; //Quick Mode
btnAutoStyle = (typeof btnAutoStyle === "undefined") ? "Ltblue" : btnAutoStyle; //Select Style
quickModeHideText = (typeof quickModeHideText === "undefined") ? true : quickModeHideText; //Hide Text on Images
btnHeight = (typeof btnHeight === "undefined") ? "75px" : btnHeight; //Button Height
btnWidth = (typeof btnWidth === "undefined") ? "75px" : btnWidth; //Button Width
btnPosition = (typeof btnPosition === "undefined") ? "below" : btnPosition; //Button position
btnNumColumn = (typeof btnNumColumn === "undefined") ? 0 : btnNumColumn; //Number of buttons per row
btnSpacing = (typeof btnSpacing === "undefined") ? "5px" : btnSpacing; //Button Spacing
btnColor = (typeof btnColor === "undefined") ? "#D3D3D3" : btnColor; //Button Colour
btnColorClick = (typeof btnColorClick === "undefined") ? "#DCE6F2" : btnColorClick; //Button Colour (clicked)
btnRounded = (typeof btnRounded === "undefined") ? false : btnRounded; //Rounded Corners
btnTextColor = (typeof btnTextColor === "undefined") ? "#000000" : btnTextColor; //Text colour
btnVerticalAlign = (typeof btnVerticalAlign === "undefined") ? "middle" : btnVerticalAlign; //Vertical alignment of text
btnCopyEditorStyle = (typeof btnCopyEditorStyle === "undefined") ? false : btnCopyEditorStyle; //Copy Editor Text Styling
btnFontSize = (typeof btnFontSize === "undefined") ? "14px" : btnFontSize; //Button Text Size
btnFontWeight = (typeof btnFontWeight === "undefined") ? "bold" : btnFontWeight; //Button Text Weight
btnFontStyle = (typeof btnFontStyle === "undefined") ? "normal" : btnFontStyle; //Button Text Style
btnHorizontalAlign = (typeof btnHorizontalAlign === "undefined") ? "center" : btnHorizontalAlign; //Horizontal alignment of text
btnHideText = (typeof btnHideText === "undefined") ? false : btnHideText; //Hide button text
btnBorderOn = (typeof btnBorderOn === "undefined") ? true : btnBorderOn; //Button Border
btnBorderWidth = (typeof btnBorderWidth === "undefined") ? "1px" : btnBorderWidth; //Border Width
btnGraphicAutoSize = (typeof btnGraphicAutoSize === "undefined") ? true : btnGraphicAutoSize; //Image Auto Size
btnGraphicBackground = (typeof btnGraphicBackground === "undefined") ? false : btnGraphicBackground; //Use the Images as Background
wrpWidth = (typeof wrpWidth === "undefined") ? "80%" : wrpWidth; //Rolling item width
wrpHeight = (typeof wrpHeight === "undefined") ? "50px" : wrpHeight; //Rolling item height
wrpTopPadding = (typeof wrpTopPadding === "undefined") ? "15px" : wrpTopPadding; //Rolling item Top Padding
wrpSpacing = (typeof wrpSpacing === "undefined") ? "10px" : wrpSpacing; //Rolling Item Spacng
wrpRounded = (typeof wrpRounded === "undefined") ? true : wrpRounded; //Scolling item rounded
wrpBackGroundColor = (typeof wrpBackGroundColor === "undefined") ? "#F2F2F2" : wrpBackGroundColor; //Scolling item Background Colour
wrpBorderOn = (typeof wrpBorderOn === "undefined") ? true : wrpBorderOn; //Rolling Item Border
wrpBorderWidth = (typeof wrpBorderWidth === "undefined") ? "2px" : wrpBorderWidth; //Rolling Item Border Width
wrpBorderColor = (typeof wrpBorderColor === "undefined") ? "#938953" : wrpBorderColor; //Rolling Item Border Colour
wrpBorderStyle = (typeof wrpBorderStyle === "undefined") ? "solid" : wrpBorderStyle; //Rolling Item Border Style
wrpCopyEditorStyle = (typeof wrpCopyEditorStyle === "undefined") ? false : wrpCopyEditorStyle; //Copy Editor Text Styling
wrpTextColor = (typeof wrpTextColor === "undefined") ? "#000000" : wrpTextColor; //Text colour
wrpFontSize = (typeof wrpFontSize === "undefined") ? "16px" : wrpFontSize; //Button Text Size
wrpFontWeight = (typeof wrpFontWeight === "undefined") ? "bold" : wrpFontWeight; //Button Text Weight
wrpFontStyle = (typeof wrpFontStyle === "undefined") ? "normal" : wrpFontStyle; //Button Text Style
wrpHorizontalAlign = (typeof wrpHorizontalAlign === "undefined") ? "center" : wrpHorizontalAlign; //Horizontal alignment of text
wrpUnderTextSize = (typeof wrpUnderTextSize === "undefined") ? 4 : wrpUnderTextSize; //Number of options displayed
wrpUnderTextColor = (typeof wrpUnderTextColor === "undefined") ? "#808080" : wrpUnderTextColor; //Under Text Colour
btnAutoNext = (typeof btnAutoNext === "undefined") ? true : btnAutoNext; //Auto Next
btnPreviousBeh = (typeof btnPreviousBeh === "undefined") ? "item" : btnPreviousBeh; //Previous Button Behaviour
debug = (typeof debug === "undefined") ? false : debug; //Debug mode
mobileIt();
//Clean up
$('.cGridButtonContainer').remove(); //Remove html if already added
//Validate Screen to ensure correct Question type
//Exit function if question type not valid
structOK = true;
//Number of questions on page should be 1
if ($('.cCellSubQuestion').length != 1) structOK = false;
//Check radio buttons on screen
if ($('.cRadio').length == 0) structOK = false;
if ($('.cCheck').length != 0) structOK = false;
// Check answer type rn
if (structOK) {
var strID = $('.cRadio').eq(0).attr('id');
if (strID.substr(0, 2) != 'rn') structOK = false;
}
if (structOK == false) {
if (debug == true) alert('Structure not OK for animation e.q. Wrong question type');
return false;
}
try {
//Create HTML
var strHtml = ''; //Clear variable used for html
strHtml = '<div>';
//Create Row Wrapper
var strWrapHTML = '';
strWrapHTML += '<div id="wrap1">';
strWrapHTML += $('.cCellRowText:first').html();
strWrapHTML += '</div>';
strWrapHTML += '<div>';
var numItems = $('.cCellRowText').length;
var intLoopCnt = 2;
var intListTop = wrpUnderTextSize + 1;
while (intLoopCnt <= intListTop) {
if (intLoopCnt <= numItems) {
strWrapHTML += '<div>' + $('.cCellRowText').eq(intLoopCnt - 1).html() + '</div>';
}
else {
strWrapHTML += '<div><br></div>';
}
intLoopCnt++;
}
strWrapHTML += '</div>';
//Create Buttons from column headers
var strBtnHtml = '';
strBtnHtml += '<table><tr>';
var strStyle = '';
var intBtnCnt = 0;
var blnEndRow = false;
$('.cCellHeader:not(.cCellFirstHeader)').each(function () {
var alignStyle = "";
if ($(this).hasClass("textleft")) {
alignStyle = "text-align:left;";
}
else if ($(this).hasClass("textcenter")) {
alignStyle = "text-align:center;";
}
else if ($(this).hasClass("textright")) {
alignStyle = "text-align:right;";
}
strStyle = 'style="' + alignStyle;
if (typeof $(this).attr('style') !== 'undefined') {
strStyle += $(this).attr('style');
}
strStyle += '"';
strBtnHtml += '<td alt="' + intBtnCnt + '" ' + strStyle + '>' + $(this).html() + '</td>';
if (parseInt(intBtnCnt + 1) % btnNumColumn == 0) { //end row depending on the number of buttons specified in the options
strBtnHtml += '</tr>';
blnEndRow = true;
}
else {
blnEndRow = false;
}
intBtnCnt++;
});
if (blnEndRow == false) { strBtnHtml += '</tr>'; }
strBtnHtml += '</table>';
var strHtml = ''; //Clear variable used for html to add to page
strHtml = '<div>';
if (btnPosition == 'below') {
strHtml += strWrapHTML;
strHtml += strBtnHtml;
}
else {
strHtml += strBtnHtml;
strHtml += strWrapHTML;
}
strHtml += '</div>';
$('#UpdatePanel1').append(strHtml);
//Formatting
$('.cBtnTable').css('width', 'auto');
$('.cBtnTable').css('margin-left', 'auto');
$('.cBtnTable').css('margin-right', 'auto');
$('.cBtnTable').css('border-collapse', 'separate');
$('.cBtnSingleGrid').css('padding-left', '5px');
$('.cBtnSingleGrid').css('padding-top', '5px');
$('.cBtnSingleGrid').css('cursor', 'pointer');
$('.cGridButtonWrapper').css('margin-left', 'auto');
$('.cGridButtonWrapper').css('margin-right', 'auto');
$('.cGridButtonWrapper').css('padding', '5px');
var intUnderHeight = parseInt($('.cGridUnderWrapper').height()) + 10;
$('.cGridUnderWrapper').css('height', intUnderHeight + 'px');
//Formatting from options
$('.cBtnSingleGrid').css('background-color', btnColor);
$('.cBtnSingleGrid').removeClass('btnChecked');
$('.cBtnSingleGrid').css('height', btnHeight);
$('.cBtnSingleGrid').css('width', btnWidth);
$('.cBtnSingleGrid').css('color', btnTextColor);
$('.cBtnSingleGrid').css('vertical-align', btnVerticalAlign);
$('.cBtnSingleGrid').css('border-right', btnBorderWidth + ' solid #696969');
$('.cBtnSingleGrid').css('border-bottom', btnBorderWidth + ' solid #696969');
$('.cBtnSingleGrid').css('border-top', btnBorderWidth + ' solid #E5E5E5');
$('.cBtnSingleGrid').css('border-left', btnBorderWidth + ' solid #E5E5E5');
if (btnGraphicBackground == true) {
$('.cBtnSingleGrid').each(function () {
strURL = $(this).find('img').eq(0).attr('src');
$(this).find('img').eq(0).remove();
$(this).css('background', btnColor + ' url("' + strURL + '") no-repeat center center');
$(this).css('background-size', '100% 100%');
});
}
if (btnCopyEditorStyle != true) {
$('.cBtnSingleGrid').find('strong').contents().unwrap();
$('.cBtnSingleGrid').find('span').contents().unwrap();
$('.cBtnSingleGrid').css('font-size', btnFontSize);
$('.cBtnSingleGrid').css('font-style', btnFontStyle);
$('.cBtnSingleGrid').css('font-weight', btnFontWeight);
$('.cBtnSingleGrid').css('text-align', btnHorizontalAlign);
}
if (wrpCopyEditorStyle != true) {
$('.cRowText').find('strong').contents().unwrap();
$('.cRowText').find('span').css('text-align', '');
$('.cRowText').find('span').css('font-size', '');
$('.cRowText').css('font-size', wrpFontSize);
$('.cRowText').css('font-style', wrpFontStyle);
$('.cRowText').css('font-weight', wrpFontWeight);
$('.cRowText').css('text-align', wrpHorizontalAlign);
}
$('.cBtnTable').css('border-spacing', btnSpacing);
if (btnHideText != false) {
$('.cBtnSingleGrid').css({ 'font-size': '0px', 'color': 'transparent' });
$('.cBtnSingleGrid').find('span').css({ 'font-size': '0px', 'color': 'transparent' });
}
if (btnGraphicAutoSize == true) $('.cBtnSingleGrid').find('img').css({ 'width': '100%' });
if (btnRounded != false) $('.cBtnSingleGrid').css({ '-moz-border-radius': '20px', '-webkit-border-radius': '20px', '-khtml-border-radius': '20px', 'border-radius': '20px' });
if (wrpWidth == 0) {
$('.cGridButtonWrapper').css('width', $('.cBtnTable').css('width'));
}
else { $('.cGridButtonWrapper').css('width', wrpWidth); }
if (wrpHeight != 0) {
$('.cGridButtonWrapper').css('height', wrpHeight);
}
if (wrpRounded != false) $('.cGridButtonWrapper').css({ '-moz-border-radius': '20px', '-webkit-border-radius': '20px', '-khtml-border-radius': '20px', 'border-radius': '20px' });
$('.cRowText').css('color', wrpTextColor);
$('.cGridButtonWrapper').css('border-width', wrpBorderWidth);
$('.cGridButtonWrapper').css('border-style', wrpBorderStyle);
$('.cGridButtonWrapper').css('border-color', wrpBorderColor);
$('.cGridButtonWrapper').css('background-color', wrpBackGroundColor);
$('.cGridButtonWrapper').css('margin-bottom', wrpSpacing);
$('.cGridButtonWrapper').css('margin-top', wrpSpacing);
$('.cGridButtonWrapper').css('padding-top', wrpTopPadding);
if (btnBorderOn == false) $('.cBtnSingleGrid').css('border', '0px solid transparent');
if (wrpBorderOn == false) $('.cGridButtonWrapper').css('border', '0px solid transparent');
$('.cGridUnderText').find('.cRowText').css('color', wrpUnderTextColor);
if (quickMode == true) {
switch (btnAutoStyle) {
case 'DkBlue':
fncSetBtnBackground('Scripts/QuickMode/BtnDarkBlue.png', '.cBtnSingleGrid');
break;
case 'Green':
fncSetBtnBackground('Scripts/QuickMode/BtnGreen.png', '.cBtnSingleGrid');
break;
case 'LtGrey':
fncSetBtnBackground('Scripts/QuickMode/BtnLightGrey.png', '.cBtnSingleGrid');
break;
case 'LtBlue':
fncSetBtnBackground('Scripts/QuickMode/BtnLightBlue.png', '.cBtnSingleGrid');
break;
case 'Orange':
fncSetBtnBackground('Scripts/QuickMode/BtnOrange.png', '.cBtnSingleGrid');
break;
case 'Red':
fncSetBtnBackground('Scripts/QuickMode/BtnRed.png', '.cBtnSingleGrid');
break;
case 'Yellow':
fncSetBtnBackground('Scripts/QuickMode/BtnYellow.png', '.cBtnSingleGrid');
break;
case 'DkBlueOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1DarkBlue.png', '.cBtnSingleGrid');
break;
case 'DkGreyOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1DarkGrey.png', '.cBtnSingleGrid');
break;
case 'GreenOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Green.png', '.cBtnSingleGrid');
break;
case 'LtBlueOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1LightBlue.png', '.cBtnSingleGrid');
break;
case 'LtGreyOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1LightGrey.png', '.cBtnSingleGrid');
break;
case 'MagentaOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Magenta.png', '.cBtnSingleGrid');
break;
case 'OrangeOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Orange.png', '.cBtnSingleGrid');
break;
case 'RedOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Red.png', '.cBtnSingleGrid');
break;
case 'YellowOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Yellow.png', '.cBtnSingleGrid');
break;
case 'Smiley1':
fncSetGridBtnBackground('.cBtnSingleGrid', 'Smiley1', 5, 5);
break;
case 'Smiley2':
fncSetGridBtnBackground('.cBtnSingleGrid', 'Smiley2', 5, 5);
break;
case 'Dice1':
fncSetGridBtnBackground('.cBtnSingleGrid', 'Dice1', 2, 6);
break;
case 'Dice2':
fncSetGridBtnBackground('.cBtnSingleGrid', 'Dice2', 2, 6);
break;
case 'Temp':
fncSetGridBtnBackground('.cBtnSingleGrid', 'Temp', 2, 8);
break;
case 'Postit':
fncSetGridBtnBackground('.cBtnSingleGrid', 'Postit', 5, 5);
break;
case 'Dot':
fncSetGridBtnBackground('.cBtnSingleGrid', 'Dot', 3, 5);
break;
case 'Star1':
fncSetGridBtnBackground('.cBtnSingleGrid', 'Star1', 5, 5);
break;
case 'Star2':
fncSetGridBtnBackground('.cBtnSingleGrid', 'Star2', 5, 5);
break;
case 'Numbers':
fncSetGridBtnBackground('.cBtnSingleGrid', 'Numbers', 2, 9);
break;
}
}
//Hide question
$('.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').css('display', 'none');
//Hide Next Button
fncHideNext();
var blnClickOn = true;
var wrapNo = 1;
if (btnPreviousBeh == 'item') {
//Add Dummy Previous button
$('#btnNext').before('<input id="btnPrevious2" name="btnPrevious2" value="Previous" type="button"></input> ');
$('#btnPrevious2').val($('#btnPrevious').val());
if ($('#btnPrevious').length == 0) { $('#btnPrevious2').val(' << '); }
//Hide Previous Button
$('#btnPrevious').hide();
if ($('#mi_direction').val() == -1) {
wrapNo = $('.cCellRowText').length;
strHtml = $('.cCellRowText:nth(' + (wrapNo - 1) + ')').html();
$('.cGridButtonWrapper').html(strHtml);
$('.cGridUnderText').html('<br/>');
}
}
//Check if row answered and change button if is
btnMultiSetSingle(wrapNo - 1);
var numItems = $('.cCellRowText').length;
var intAnswer = 0;
$(document).on("click", ".cBtnSingleGrid", function () {
//$('.cBtnSingleGrid').live('click',function () {
if (blnClickOn == true) {
blnClickOn = false;
//Button effect
$(this).css('background-color', btnColorClick).addClass('btnChecked');
$(this).effect("pulsate", {}, 10);
//Set Answer
intAnswer = (parseInt(wrapNo - 1) * parseInt(intBtnCnt)) + parseInt($(this).attr('alt'));
$('.cCell input').eq(intAnswer).prop('checked', true);
if (wrapNo == numItems) {
//Show Next button if click fails.
fncShowNext();
if (btnAutoNext == true) {
$('#btnNext').click();
}
}
else {
wrapNo = wrapNo + 1;
//Create new main image
strHtml = $('.cCellRowText:nth(' + (wrapNo - 1) + ')').html();
$('.cGridButtonWrapper').html(strHtml);
btnMultiSetSingle(wrapNo - 1);
strHtml = '';
intListTop = intListTop + 1;
intLoopCnt = wrapNo + 1;
i = 0;
while (intLoopCnt <= intListTop) {
if (intLoopCnt <= numItems) {
$('.cGridUnderText').eq(i).html($('.cCellRowText').eq(intLoopCnt - 1).html());
}
else {
$('.cGridUnderText').eq(i).html('<br/>');
}
intLoopCnt++;
i++;
}
$('.cGridUnderText').find('.cRowText').css('color', wrpUnderTextColor);
}
blnClickOn = true;
}
});
$('#btnPrevious2').on('click', function () {
if (blnClickOn == true) {
blnClickOn = false;
if (wrapNo == 1) {
if ($('#btnPrevious').length > 0) {
$('#btnPrevious').show();
$('#btnPrevious2').hide();
$('#btnPrevious').click();
}
blnClickOn = true;
}
else {
wrapNo = wrapNo - 1;
//Create new main image
strHtml = $('.cCellRowText:nth(' + (wrapNo - 1) + ')').html();
$('.cGridButtonWrapper').html(strHtml);
btnMultiSetSingle(wrapNo - 1);
strHtml = '';
intListTop = intListTop - 1;
intLoopCnt = wrapNo + 1;
i = 0;
while (intLoopCnt <= intListTop) {
if (intLoopCnt <= numItems) {
$('.cGridUnderText').eq(i).html($('.cCellRowText').eq(intLoopCnt - 1).html());
}
else {
$('.cGridUnderText').eq(i).html('<br/>');
}
intLoopCnt++;
i++;
}
$('.cGridUnderText').find('.cRowText').css('color', wrpUnderTextColor);
blnClickOn = true;
}
}
});
$('#btnNext').on('click', function () {
//Clean up
strHtml = ''; //Clear variable used for html
$('.cGridButtonContainer').remove(); //Remove html if already added
$(document).off("click", ".cBtnSingleGrid");
//$('.cBtnSingleGrid').die('click');
$('#btnNext').off('click');
$('#btnPrevious').off('click');
$('#btnPrevious2').off('click');
});
$('#btnPrevious').on('click', function () {
//Clean up
strHtml = ''; //Clear variable used for html
$('.cGridButtonContainer').remove(); //Remove html if already added
$('#btnNext').off('click');
$('#btnPrevious').off('click');
$('#btnPrevious2').off('click');
$(document).off("click", ".cBtnSingleGrid");
//$('.cBtnSingleGrid').die('click');
});
}
catch (err) {
if (debug == true) {
txt = "There was an error on this page.\n\n";
txt += "Error description: " + err.message + "\n\n";
txt += "Click OK to continue.\n\n";
alert(txt);
}
//Clean up
strHtml = ''; //Clear variable used for html
//Show question
$('.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').css('display', '');
//Show Next button
fncShowNext();
}
}
function rollMultipleGrid() { //Grid Single rolling Buttons
//Check for WCAG
if ($('#btnToggleWcag').val()==1) {
return false;
}
//Give defaultvalues if not specified
quickMode = (typeof quickMode === "undefined") ? false : quickMode; //Quick Mode
btnAutoStyle = (typeof btnAutoStyle === "undefined") ? "Ltblue" : btnAutoStyle; //Select Style
quickModeHideText = (typeof quickModeHideText === "undefined") ? true : quickModeHideText; //Hide Text on Images
btnHeight = (typeof btnHeight === "undefined") ? "75px" : btnHeight; //Button Height
btnWidth = (typeof btnWidth === "undefined") ? "75px" : btnWidth; //Button Width
btnPosition = (typeof btnPosition === "undefined") ? "below" : btnPosition; //Button position
btnNumColumn = (typeof btnNumColumn === "undefined") ? 0 : btnNumColumn; //Number of buttons per row
btnSpacing = (typeof btnSpacing === "undefined") ? "5px" : btnSpacing; //Button Spacing
btnColor = (typeof btnColor === "undefined") ? "#D3D3D3" : btnColor; //Button Colour
btnColorClick = (typeof btnColorClick === "undefined") ? "#DCE6F2" : btnColorClick; //Button Colour (clicked)
btnRounded = (typeof btnRounded === "undefined") ? false : btnRounded; //Rounded Corners
btnTextColor = (typeof btnTextColor === "undefined") ? "#000000" : btnTextColor; //Text colour
btnVerticalAlign = (typeof btnVerticalAlign === "undefined") ? "middle" : btnVerticalAlign; //Vertical alignment of text
btnCopyEditorStyle = (typeof btnCopyEditorStyle === "undefined") ? false : btnCopyEditorStyle; //Copy Editor Text Styling
btnFontSize = (typeof btnFontSize === "undefined") ? "14px" : btnFontSize; //Button Text Size
btnFontWeight = (typeof btnFontWeight === "undefined") ? "bold" : btnFontWeight; //Button Text Weight
btnFontStyle = (typeof btnFontStyle === "undefined") ? "normal" : btnFontStyle; //Button Text Style
btnHorizontalAlign = (typeof btnHorizontalAlign === "undefined") ? "center" : btnHorizontalAlign; //Horizontal alignment of text
btnHideText = (typeof btnHideText === "undefined") ? false : btnHideText; //Hide button text
btnBorderOn = (typeof btnBorderOn === "undefined") ? true : btnBorderOn; //Button Border
btnBorderWidth = (typeof btnBorderWidth === "undefined") ? "1px" : btnBorderWidth; //Border Width
btnGraphicAutoSize = (typeof btnGraphicAutoSize === "undefined") ? true : btnGraphicAutoSize; //Image Auto Size
btnGraphicBackground = (typeof btnGraphicBackground === "undefined") ? false : btnGraphicBackground; //Use the Images as Background
wrpWidth = (typeof wrpWidth === "undefined") ? "80%" : wrpWidth; //Rolling item width
wrpHeight = (typeof wrpHeight === "undefined") ? "50px" : wrpHeight; //Rolling item height
wrpTopPadding = (typeof wrpTopPadding === "undefined") ? "15px" : wrpTopPadding; //Rolling item Top Padding
wrpSpacing = (typeof wrpSpacing === "undefined") ? "10px" : wrpSpacing; //Rolling Item Spacng
wrpRounded = (typeof wrpRounded === "undefined") ? true : wrpRounded; //Scolling item rounded
wrpBackGroundColor = (typeof wrpBackGroundColor === "undefined") ? "#F2F2F2" : wrpBackGroundColor; //Scolling item Background Colour
wrpBorderOn = (typeof wrpBorderOn === "undefined") ? true : wrpBorderOn; //Rolling Item Border
wrpBorderWidth = (typeof wrpBorderWidth === "undefined") ? "2px" : wrpBorderWidth; //Rolling Item Border Width
wrpBorderColor = (typeof wrpBorderColor === "undefined") ? "#938953" : wrpBorderColor; //Rolling Item Border Colour
wrpBorderStyle = (typeof wrpBorderStyle === "undefined") ? "solid" : wrpBorderStyle; //Rolling Item Border Style
wrpCopyEditorStyle = (typeof wrpCopyEditorStyle === "undefined") ? false : wrpCopyEditorStyle; //Copy Editor Text Styling
wrpTextColor = (typeof wrpTextColor === "undefined") ? "#000000" : wrpTextColor; //Text colour
wrpFontSize = (typeof wrpFontSize === "undefined") ? "16px" : wrpFontSize; //Button Text Size
wrpFontWeight = (typeof wrpFontWeight === "undefined") ? "bold" : wrpFontWeight; //Button Text Weight
wrpFontStyle = (typeof wrpFontStyle === "undefined") ? "normal" : wrpFontStyle; //Button Text Style
wrpHorizontalAlign = (typeof wrpHorizontalAlign === "undefined") ? "center" : wrpHorizontalAlign; //Horizontal alignment of text
wrpUnderTextSize = (typeof wrpUnderTextSize === "undefined") ? 4 : wrpUnderTextSize; //Number of options displayed
wrpUnderTextColor = (typeof wrpUnderTextColor === "undefined") ? "#808080" : wrpUnderTextColor; //Under Text Colour
strErrMsg = (typeof strErrMsg === "undefined") ? "Please select at least 1 answer" : strErrMsg; //Error Message
btnPreviousBeh = (typeof btnPreviousBeh === "undefined") ? "item" : btnPreviousBeh; //Previous Button Behaviour
debug = (typeof debug === "undefined") ? false : debug; //Debug mode
mobileIt();
//Clean up
$('.cGridButtonContainer').remove(); //Remove html if already added
//Validate Screen to ensure correct Question type
//Exit function if question type not valid
var structOK = true;
//Number of questions on page should be 1
if ($('.cCellSubQuestion').length != 1) structOK = false;
//Check checkboxes buttons on screen
if ($('.cCheck').length == 0) structOK = false;
// Check answer type rm
var strID = $('.cCheck').eq(0).attr('id');
if (strID.substr(0, 2) != 'rm') structOK = false;
if (structOK == false) {
if (debug == true) alert('Structure not OK for animation e.q. Wrong question type');
return false;
}
try {
//Create HTML
var strHtml = ''; //Clear variable used for html
strHtml = '<div>';
//Create Row Wrapper
var strWrapHTML = '';
strWrapHTML += '<div id="wrap1">';
strWrapHTML += $('.cCellRowText:first').html();
strWrapHTML += '</div>';
strWrapHTML += '<div>';
var numItems = $('.cCellRowText').length;
var intLoopCnt = 2;
var intListTop = wrpUnderTextSize + 1;
while (intLoopCnt <= intListTop) {
if (intLoopCnt <= numItems) {
strWrapHTML += '<div>' + $('.cCellRowText').eq(intLoopCnt - 1).html() + '</div>';
}
else {
strWrapHTML += '<div><br></div>';
}
intLoopCnt++;
}
strWrapHTML += '</div>';
//Create Buttons from column headers
var strBtnHtml = '';
strBtnHtml += '<table><tr>';
var strStyle = '';
var intBtnCnt = 0;
var blnEndRow = false;
$('.cCellHeader:not(.cCellFirstHeader)').each(function () {
var alignStyle = "";
if ($(this).hasClass("textleft")) {
alignStyle = "text-align:left;";
}
else if ($(this).hasClass("textcenter")) {
alignStyle = "text-align:center;";
}
else if ($(this).hasClass("textright")) {
alignStyle = "text-align:right;";
}
strStyle = 'style="' + alignStyle;
if (typeof $(this).attr('style') !== 'undefined') {
strStyle += $(this).attr('style');
}
strStyle += '"';
strBtnHtml += '<td alt="' + intBtnCnt + '" ' + strStyle + '>' + $(this).html() + '</td>';
if (parseInt(intBtnCnt + 1) % btnNumColumn == 0) { //end row depending on the number of buttons specified in the options
strBtnHtml += '</tr>';
blnEndRow = true;
}
else {
blnEndRow = false;
}
intBtnCnt++;
});
if (blnEndRow == false) { strBtnHtml += '</tr>'; }
strBtnHtml += '</table>';
var strHtml = ''; //Clear variable used for html to add to page
strHtml = '<div>';
if (btnPosition == 'below') {
strHtml += strWrapHTML;
strHtml += strBtnHtml;
}
else {
strHtml += strBtnHtml;
strHtml += strWrapHTML;
}
strHtml += '</div>';
$('#UpdatePanel1').append(strHtml);
//Formatting
$('.cBtnTable').css('width', 'auto');
$('.cBtnTable').css('margin-left', 'auto');
$('.cBtnTable').css('margin-right', 'auto');
$('.cBtnTable').css('border-collapse', 'separate');
$('.cBtnMultiGrid').css('padding-left', '5px');
$('.cBtnMultiGrid').css('padding-top', '5px');
$('.cBtnMultiGrid').css('cursor', 'pointer');
$('.cGridButtonWrapper').css('margin-left', 'auto');
$('.cGridButtonWrapper').css('margin-right', 'auto');
$('.cGridButtonWrapper').css('padding', '5px');
var intUnderHeight = parseInt($('.cGridUnderWrapper').height()) + 10;
$('.cGridUnderWrapper').css('height', intUnderHeight + 'px');
//Formatting from options
$('.cBtnMultiGrid').css('background-color', btnColor);
$('.cBtnMultiGrid').removeClass('btnChecked');
$('.cBtnMultiGrid').css('height', btnHeight);
$('.cBtnMultiGrid').css('width', btnWidth);
$('.cBtnMultiGrid').css('color', btnTextColor);
$('.cBtnMultiGrid').css('vertical-align', btnVerticalAlign);
$('.cBtnMultiGrid').css('border-right', btnBorderWidth + ' solid #696969');
$('.cBtnMultiGrid').css('border-bottom', btnBorderWidth + ' solid #696969');
$('.cBtnMultiGrid').css('border-top', btnBorderWidth + ' solid #E5E5E5');
$('.cBtnMultiGrid').css('border-left', btnBorderWidth + ' solid #E5E5E5');
if (btnGraphicBackground == true) {
$('.cBtnMultiGrid').each(function () {
strURL = $(this).find('img').eq(0).attr('src');
$(this).find('img').eq(0).remove();
$(this).css('background', btnColor + ' url("' + strURL + '") no-repeat center center');
$(this).css('background-size', '100% 100%');
});
}
if (btnCopyEditorStyle != true) {
$('.cBtnMultiGrid').find('strong').contents().unwrap();
$('.cBtnMultiGrid').find('span').contents().unwrap();
$('.cBtnMultiGrid').css('font-size', btnFontSize);
$('.cBtnMultiGrid').css('font-style', btnFontStyle);
$('.cBtnMultiGrid').css('font-weight', btnFontWeight);
$('.cBtnMultiGrid').css('text-align', btnHorizontalAlign);
}
if (wrpCopyEditorStyle != true) {
$('.cRowText').find('strong').contents().unwrap();
$('.cRowText').find('span').css('text-align', '');
$('.cRowText').find('span').css('font-size', '');
$('.cRowText').css('font-size', wrpFontSize);
$('.cRowText').css('font-style', wrpFontStyle);
$('.cRowText').css('font-weight', wrpFontWeight);
$('.cRowText').css('text-align', wrpHorizontalAlign);
}
$('.cBtnTable').css('border-spacing', btnSpacing);
if (btnHideText != false) {
$('.cBtnMultiGrid').css({ 'font-size': '0px', 'color': 'transparent' });
$('.cBtnMultiGrid').find('span').css({ 'font-size': '0px', 'color': 'transparent' });
}
if (btnGraphicAutoSize == true) $('.cBtnMultiGrid').find('img').css({ 'width': '100%' });
if (btnRounded != false) $('.cBtnMultiGrid').css({ '-moz-border-radius': '20px', '-webkit-border-radius': '20px', '-khtml-border-radius': '20px', 'border-radius': '20px' });
if (wrpWidth == 0) {
$('.cGridButtonWrapper').css('width', $('.cBtnTable').css('width'));
}
else { $('.cGridButtonWrapper').css('width', wrpWidth); }
if (wrpHeight != 0) {
$('.cGridButtonWrapper').css('height', wrpHeight);
}
if (wrpRounded != false) $('.cGridButtonWrapper').css({ '-moz-border-radius': '20px', '-webkit-border-radius': '20px', '-khtml-border-radius': '20px', 'border-radius': '20px' });
$('.cRowText').css('color', wrpTextColor);
$('.cGridButtonWrapper').css('border-width', wrpBorderWidth);
$('.cGridButtonWrapper').css('border-style', wrpBorderStyle);
$('.cGridButtonWrapper').css('border-color', wrpBorderColor);
$('.cGridButtonWrapper').css('background-color', wrpBackGroundColor);
$('.cGridButtonWrapper').css('margin-bottom', wrpSpacing);
$('.cGridButtonWrapper').css('margin-top', wrpSpacing);
$('.cGridButtonWrapper').css('padding-top', wrpTopPadding);
if (btnBorderOn == false) $('.cBtnMultiGrid').css('border', '0px solid transparent');
if (wrpBorderOn == false) $('.cGridButtonWrapper').css('border', '0px solid transparent');
$('.cGridUnderText').find('.cRowText').css('color', wrpUnderTextColor);
if (quickMode == true) {
switch (btnAutoStyle) {
case 'DkBlue':
fncSetBtnBackground('Scripts/QuickMode/BtnDarkBlue.png', '.cBtnMultiGrid');
break;
case 'Green':
fncSetBtnBackground('Scripts/QuickMode/BtnGreen.png', '.cBtnMultiGrid');
break;
case 'LtGrey':
fncSetBtnBackground('Scripts/QuickMode/BtnLightGrey.png', '.cBtnMultiGrid');
break;
case 'LtBlue':
fncSetBtnBackground('Scripts/QuickMode/BtnLightBlue.png', '.cBtnMultiGrid');
break;
case 'Orange':
fncSetBtnBackground('Scripts/QuickMode/BtnOrange.png', '.cBtnMultiGrid');
break;
case 'Red':
fncSetBtnBackground('Scripts/QuickMode/BtnRed.png', '.cBtnMultiGrid');
break;
case 'Yellow':
fncSetBtnBackground('Scripts/QuickMode/BtnYellow.png', '.cBtnMultiGrid');
break;
case 'DkBlueOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1DarkBlue.png', '.cBtnMultiGrid');
break;
case 'DkGreyOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1DarkGrey.png', '.cBtnMultiGrid');
break;
case 'GreenOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Green.png', '.cBtnMultiGrid');
break;
case 'LtBlueOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1LightBlue.png', '.cBtnMultiGrid');
break;
case 'LtGreyOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1LightGrey.png', '.cBtnMultiGrid');
break;
case 'MagentaOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Magenta.png', '.cBtnMultiGrid');
break;
case 'OrangeOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Orange.png', '.cBtnMultiGrid');
break;
case 'RedOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Red.png', '.cBtnMultiGrid');
break;
case 'YellowOval':
fncSetBtnBackground('Scripts/QuickMode/Btn1Yellow.png', '.cBtnMultiGrid');
break;
case 'Smiley1':
fncSetGridBtnBackground('.cBtnMultiGrid', 'Smiley1', 5, 5);
break;
case 'Smiley2':
fncSetGridBtnBackground('.cBtnMultiGrid', 'Smiley2', 5, 5);
break;
case 'Dice1':
fncSetGridBtnBackground('.cBtnMultiGrid', 'Dice1', 2, 6);
break;
case 'Dice2':
fncSetGridBtnBackground('.cBtnMultiGrid', 'Dice2', 2, 6);
break;
case 'Temp':
fncSetGridBtnBackground('.cBtnMultiGrid', 'Temp', 2, 8);
break;
case 'Postit':
fncSetGridBtnBackground('.cBtnMultiGrid', 'Postit', 5, 5);
break;
case 'Dot':
fncSetGridBtnBackground('.cBtnMultiGrid', 'Dot', 3, 5);
break;
case 'Star1':
fncSetGridBtnBackground('.cBtnMultiGrid', 'Star1', 5, 5);
break;
case 'Star2':
fncSetGridBtnBackground('.cBtnMultiGrid', 'Star2', 5, 5);
break;
case 'Numbers':
fncSetGridBtnBackground('.cBtnMultiGrid', 'Numbers', 2, 9);
break;
}
}
//Add Dummy next button
$('#btnNext').before('<input id="btnNext2" name="btnNext2" value="Next" type="button">');
$('#btnNext2').val($('#btnNext').val());
//Hide Next Button
fncHideNext();
//Hide question
$('.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').css('display', 'none');
var blnClickOn = true;
var wrapNo = 1;
if (btnPreviousBeh == 'item') {
//Add Dummy Previous button
$('#btnNext2').before('<input id="btnPrevious2" name="btnPrevious2" value="Previous" type="button"></input> ');
$('#btnPrevious2').val($('#btnPrevious').val());
if ($('#btnPrevious').length == 0) { $('#btnPrevious2').val(' << '); }
//Hide Previous Button
$('#btnPrevious').hide();
if ($('#mi_direction').val() == -1) {
wrapNo = $('.cCellRowText').length;
strHtml = $('.cCellRowText:nth(' + (wrapNo - 1) + ')').html();
$('.cGridButtonWrapper').html(strHtml);
$('.cGridUnderText').html('<br/>');
}
}
//Set Previous Answers
btnMultiSetMulti(wrapNo - 1);
var numItems = $('.cCellRowText').length;
var intAnswer = 0;
$(document).on("click", ".cBtnMultiGrid", function () {
//$('.cBtnMultiGrid').live('click',function () {
if (blnClickOn == true) {
blnClickOn = false;
//Button effect
$(this).effect("pulsate", {}, 10);
//Set Answer
intAnswer = (parseInt(wrapNo - 1) * parseInt(intBtnCnt)) + parseInt($(this).attr('alt'));
strType = $('.cCell input').eq(intAnswer).prop('type');
if (strType == 'checkbox') {
if ($('.cCell input').eq(intAnswer).prop('checked')) {
$('.cCell input').eq(intAnswer).prop('checked', false);
if (!$('.cCell input').eq(intAnswer).prop('checked')) {
if (quickMode != true) {
$(this).css('background-color', btnColor).removeClass('btnChecked');
}
else {
$(this).css('background-color', 'transparent');
}
if ($('.unified').length > 0) { $('.cCell input').eq(intAnswer).parent().removeClass('checked'); }
}
}
else {
$('.cCell input').eq(intAnswer).prop('checked', true);
if ($('.cCell input').eq(intAnswer).prop('checked')) {
$(this).css('background-color', btnColorClick).addClass('btnChecked');
if ($('.unified').length > 0) { $('.cCell input').eq(intAnswer).parent().addClass('checked'); }
}
}
intBtnNum = 0;
//clear radio
for (i = (parseInt(wrapNo - 1) * parseInt(intBtnCnt)); i <= (parseInt(wrapNo - 1) * parseInt(intBtnCnt)) + (intBtnCnt - 1); i++) {
if ($('.cCell input').eq(i).prop('type') != 'checkbox') {
if (quickMode != true) {
$('.cBtnMultiGrid').eq(intBtnNum).css('background-color', btnColor).removeClass('btnChecked');
}
else {
$('.cBtnMultiGrid').eq(intBtnNum).css('background-color', 'transparent');
}
$('.cCell input').eq(i).prop('checked', false);
}
intBtnNum++;
}
}
else {
if (quickMode != true) {
$('.cBtnMultiGrid').css('background-color', btnColor).removeClass('btnChecked');
}
else {
$('.cBtnMultiGrid').css('background-color', 'transparent');
}
if ($('.cCell input').eq(intAnswer).prop('checked')) {
if (quickMode != true) {
$(this).css('background-color', btnColor).removeClass('btnChecked');
}
else {
$(this).css('background-color', 'transparent');
}
$('.cCell input').eq(intAnswer).prop('checked', false);
if ($('.unified').length > 0) { $('.cCell input').eq(intAnswer).parent().addClass('checked'); }
}
else {
$(this).css('background-color', btnColorClick).addClass('btnChecked');
$('.cCell input').eq(intAnswer).prop('checked', true);
if ($('.unified').length > 0) { $('.cCell input').eq(intAnswer).parent().addClass('checked'); }
//clear other answers
intBtnNum = 0;
for (i = (parseInt(wrapNo - 1) * parseInt(intBtnCnt)); i <= (parseInt(wrapNo - 1) * parseInt(intBtnCnt)) + (intBtnCnt - 1); i++) {
if (i != intAnswer) {
if (quickMode != true) {
$('.cBtnMultiGrid').eq(i).css('background-color', btnColor).removeClass('btnChecked');
}
else {
$('.cBtnMultiGrid').eq(i).css('background-color', 'transparent');
}
$('.cCell input').eq(i).prop('checked', false);
if ($('.unified').length > 0) { $('.cCell input').eq(i).parent().removeClass('checked'); }
}
intBtnNum++;
}
}
}
blnClickOn = true;
}
});
$(document).on("click", "#btnNext2", function () {
//$('#btnNext2').live('click',function () {
$('.cError').remove();
//Calculate number of answers by counting buttons with clicked background colour
intNumAns = 0;
$('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').eq(wrapNo - 1).find('.cCheck, .cRadio').each(function () {
if ($(this).is(':checked')) intNumAns++;
});
if (intNumAns > 0) {
//Animate image off screen.
if (wrapNo == numItems) {
//Clean up
strHtml = ''; //Clear variable used for html
$('#btnNext').click();
}
else {
wrapNo = wrapNo + 1;
//Create new main image
strHtml = $('.cCellRowText:nth(' + (wrapNo - 1) + ')').html();
$('.cGridButtonWrapper').html(strHtml);
//Clear Answers
$('.cBtnMultiGrid').css('background-color', btnColor).removeClass('btnChecked');
//Set previous answers
btnMultiSetMulti(wrapNo - 1);
strHtml = '';
intListTop = intListTop + 1;
intLoopCnt = wrapNo + 1;
i = 0;
while (intLoopCnt <= intListTop) {
if (intLoopCnt <= numItems) {
$('.cGridUnderText').eq(i).html($('.cCellRowText').eq(intLoopCnt - 1).html());
}
else {
$('.cGridUnderText').eq(i).html('<br/>');
}
intLoopCnt++;
i++;
}
$('.cGridUnderText').find('.cRowText').css('color', wrpUnderTextColor);
}
}
else {
$('.cGridButtonContainer').before('<div>' + strErrMsg + '<br/><br/></div>');
}
});
$('#btnPrevious2').on('click', function () {
if (blnClickOn == true) {
blnClickOn = false;
if (wrapNo == 1) {
if ($('#btnPrevious').length > 0) {
$('#btnPrevious').show();
$('#btnPrevious2').hide();
$('#btnPrevious').click();
}
blnClickOn = true;
}
else {
wrapNo = wrapNo - 1;
//Create new main image
strHtml = $('.cCellRowText:nth(' + (wrapNo - 1) + ')').html();
$('.cGridButtonWrapper').html(strHtml);
btnMultiSetMulti(wrapNo - 1);
strHtml = '';
intListTop = intListTop - 1;
intLoopCnt = wrapNo + 1;
i = 0;
while (intLoopCnt <= intListTop) {
if (intLoopCnt <= numItems) {
$('.cGridUnderText').eq(i).html($('.cCellRowText').eq(intLoopCnt - 1).html());
}
else {
$('.cGridUnderText').eq(i).html('<br/>');
}
intLoopCnt++;
i++;
}
$('.cGridUnderText').find('.cRowText').css('color', wrpUnderTextColor);
blnClickOn = true;
}
}
});
$('#btnNext').on('click', function () {
//Clean up
$(document).off("click", ".cBtnMultiGrid");
//$('.cBtnMultiGrid').die('click');
$('#btnNext').off('click');
$(document).off("click", "#btnNext2");
//$('#btnNext2').die('click');
$('#btnPrevious').off('click');
$('#btnPrevious2').off('click');
});
$('#btnPrevious').on('click', function () {
$('#btnNext').off('click');
$('#btnPrevious').off('click');
$('#btnPrevious2').off('click');
$(document).off("click", ".cBtnMultiGrid");
//$('.cBtnMultiGrid').die('click');
$(document).off("click", "#btnNext2");
//$('#btnNext2').die('click');
});
}
catch (err) {
if (debug == true) {
txt = "There was an error on this page.\n\n";
txt += "Error description: " + err.message + "\n\n";
txt += "Click OK to continue.\n\n";
alert(txt);
}
//Clean up
strHtml = ''; //Clear variable used for html
//Show question
$('.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').css('display', '');
//Show Next button
fncShowNext();
}
}
function HoriDragDrop() { //Grid Single Draggable horizontal
//Give defaultvalues if not specified
itmNumColumn = (typeof itmNumColumn === "undefined") ? 0 : itmNumColumn; //Sort items per row
sortGridSpacing = (typeof sortGridSpacing === "undefined") ? "10" : sortGridSpacing; //Sort Item table spacing
sortItemColor = (typeof sortItemColor === "undefined") ? "#6699FF" : sortItemColor; //Sort item colour
sortItemWidth = (typeof sortItemWidth === "undefined") ? "75" : sortItemWidth; //Sort item width
sortItemHeight = (typeof sortItemHeight === "undefined") ? "75" : sortItemHeight; //Sort item height
sortItemPaddingTop = (typeof sortItemPaddingTop === "undefined") ? "10" : sortItemPaddingTop; //Sort Item top space
sortItemRounded = (typeof sortItemRounded === "undefined") ? true : sortItemRounded; //Sort Item Rounded
sortItemGraphicAutoSize = (typeof sortItemGraphicAutoSize === "undefined") ? true : sortItemGraphicAutoSize; //Image Auto size
sortTextColor = (typeof sortTextColor === "undefined") ? "#000000" : sortTextColor; //Sort item text colour
srtCopyEditorStyle = (typeof srtCopyEditorStyle === "undefined") ? false : srtCopyEditorStyle; //Copy Editor Text Styling
srtFontSize = (typeof srtFontSize === "undefined") ? "14px" : srtFontSize; //Sort Item Text Size
srtFontWeight = (typeof srtFontWeight === "undefined") ? "bold" : srtFontWeight; //Sort Item Text Weight
srtFontStyle = (typeof srtFontStyle === "undefined") ? "normal" : srtFontStyle; //Sort Item Text Style
srtHorizontalAlign = (typeof srtHorizontalAlign === "undefined") ? "center" : srtHorizontalAlign; //Horizontal alignment of text
sortItemHideText = (typeof sortItemHideText === "undefined") ? false : sortItemHideText; //Hide Text
sortBorderOn = (typeof sortBorderOn === "undefined") ? true : sortBorderOn; //Sort Item Border
sortBorderWidth = (typeof sortBorderWidth === "undefined") ? "4" : sortBorderWidth; //Border Width
dropItemColor = (typeof dropItemColor === "undefined") ? "#FFB8FF" : dropItemColor; //Drop item colour
dropItemDropColor = (typeof dropItemDropColor === "undefined") ? "#99CCFF" : dropItemDropColor; //Drop Colour
dropItemWidth = (typeof dropItemWidth === "undefined") ? "75" : dropItemWidth; //Drop item width
dropItemHeight = (typeof dropItemHeight === "undefined") ? "75" : dropItemHeight; //Drop item height
dropItemVerticalAlign = (typeof dropItemVerticalAlign === "undefined") ? "middle" : dropItemVerticalAlign; //Vertical align
dropItemSpacing = (typeof dropItemSpacing === "undefined") ? "10" : dropItemSpacing; //Drop item spacing
dropItemRounded = (typeof dropItemRounded === "undefined") ? true : dropItemRounded; //Drop Item Rounded
dropItemGraphicAutoSize = (typeof dropItemGraphicAutoSize === "undefined") ? true : dropItemGraphicAutoSize; //Image Auto size
dropTextColor = (typeof dropTextColor === "undefined") ? "#000000" : dropTextColor; //Drop item text colour
drpCopyEditorStyle = (typeof drpCopyEditorStyle === "undefined") ? false : drpCopyEditorStyle; //Copy Editor Text Styling
drpFontSize = (typeof drpFontSize === "undefined") ? "14px" : drpFontSize; //Drop Item Text Size
drpFontWeight = (typeof drpFontWeight === "undefined") ? "bold" : drpFontWeight; //Drop Item Text Weight
drpFontStyle = (typeof drpFontStyle === "undefined") ? "normal" : drpFontStyle; //Drop Item Text Style
drpHorizontalAlign = (typeof drpHorizontalAlign === "undefined") ? "center" : drpHorizontalAlign; //Horizontal alignment of text
dropItemHideText = (typeof dropItemHideText === "undefined") ? false : dropItemHideText; //Hide Text
dropBorderOn = (typeof dropBorderOn === "undefined") ? true : dropBorderOn; //Drop Item Border
dropBorderWidth = (typeof dropBorderWidth === "undefined") ? "4" : dropBorderWidth; //Border Width
btnAutoNext = (typeof btnAutoNext === "undefined") ? true : btnAutoNext; //Auto Next
blnShowUndoIcon = (typeof blnShowUndoIcon === "undefined") ? true : blnShowUndoIcon; //Show Undo Icon
blnShowUndoText = (typeof blnShowUndoText === "undefined") ? true : blnShowUndoText; //Show Undo Text
strUndoImgURL = (typeof strUndoImgURL === "undefined") ? "http://rs.miprocloud.net/PortalDataService/Content/6nuZJ6QQ28a/undoBlue.png" : strUndoImgURL; //Undo Icon URL
icoSizeUndo = (typeof icoSizeUndo === "undefined") ? "36" : icoSizeUndo; //Undo Icon Width
strUndoText = (typeof strUndoText === "undefined") ? "Undo" : strUndoText; //Undo Text
blnShowResetIcon = (typeof blnShowResetIcon === "undefined") ? true : blnShowResetIcon; //Show Reset Icon
blnShowResetText = (typeof blnShowResetText === "undefined") ? true : blnShowResetText; //Show Reset Text
strResetImgURL = (typeof strResetImgURL === "undefined") ? "http://rs.miprocloud.net/PortalDataService/Content/6nuZJ6QQ28a/ResetBlue.png" : strResetImgURL; //Reset Icon URL
icoSizeReset = (typeof icoSizeReset === "undefined") ? "36" : icoSizeReset; //Reset Icon Width
strResetText = (typeof strResetText === "undefined") ? "Reset" : strResetText; //Reset Text
debug = (typeof debug === "undefined") ? false : debug; //Debug Mode
//Clean up
var strHtml = ''; //Clear variable used for html
$('.cGridButtonContainer').remove(); //Remove html if already added
//Validate Screen to ensure correct Question type
//Exit function if question type not valid
structOK = true;
//Number of questions on page should be 1
if ($('.cCellSubQuestion').length != 1) structOK = false;
//Check only radio buttons on screen
if ($('.cRadio').length == 0) structOK = false;
if ($('.cCheck').length != 0) structOK = false;
// Check answer type rn
if (structOK) {
var strID = $('.cRadio').eq(0).attr('id');
if (strID.substr(0, 2) != 'rn') structOK = false;
}
if (structOK == false) {
if (debug == true) alert('Structure not OK for animation e.q. Wrong question type');
iQuestHelper('Structure not OK for iQuest e.q. Wrong question type. This iQuest requires a single choice grid question and one question per screen');
return false;
}
try {
//Create HTML
strHtml = '<div>';
var strStyle = '';
strHtml += '<table><tr>'
var intBtnCnt = 0;
var arrLast = [];
var blnEndRow = false;
$('.cCellRowText').each(function () {
strHtml += '<td><div><div alt="' + intBtnCnt + '">' + $(this).html() + '</div></div></td>';
if (parseInt(intBtnCnt + 1) % itmNumColumn == 0) { //end row depending on the number of buttons specified in the options
strHtml += '</tr>';
blnEndRow = true;
}
else {
blnEndRow = false;
}
intBtnCnt++;
});
if (blnEndRow == false) { strHtml += '</tr>'; }
strHtml += '</table>';
strHtml += '<table><tr>'
intBtnCnt = 0;
$('.cCellHeader:not(.cCellFirstHeader)').each(function () {
var alignStyle = "";
if ($(this).hasClass("textleft")) {
alignStyle = "text-align:left;";
}
else if ($(this).hasClass("textcenter")) {
alignStyle = "text-align:center;";
}
else if ($(this).hasClass("textright")) {
alignStyle = "text-align:right;";
}
strStyle = 'style="' + alignStyle;
if (typeof $(this).attr('style') !== 'undefined') {
strStyle += $(this).attr('style');
}
strStyle += '"';
strHtml += '<td alt="' + intBtnCnt + '" ' + strStyle + '>' + $(this).html() + '</td>';
intBtnCnt++;
});
strHtml += '</tr><tr><td><div><img src=""/><span></span></div><div><img src=""/><span></span></div></td></tr>';
strHtml += '</table>';
strHtml += '</div>';
$('#UpdatePanel1').append(strHtml);
//Make all parts of the cSrtTable class part of the DragGroup class used for touch devices
$('.cSrtTable').find('div, table, tr, td, span').addClass('cDragGroup');
//Hide question
$('.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').css('display', 'none');
//Hide Rows already answered
intBtnCnt = 0;
$('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').each(function () {
if ($(this).find('.cRadio:checked').length != 0) $('.cSrtItem').eq(intBtnCnt).hide();
intBtnCnt++;
});
$('.cSrtTable').css('width', 'auto');
$('.cSrtTable').css('margin-left', 'auto');
$('.cSrtTable').css('margin-right', 'auto');
$('.cBtnTable').css('width', 'auto');
$('.cBtnTable').css('margin-left', 'auto');
$('.cBtnTable').css('margin-right', 'auto');
$('.cSrtItem').css('height', '100%');
$('.cSrtItem').css('width', '100%');
$('.cSrtItem').css('padding', '1px');
$('.cSrtItem').css('border-right', '5px solid #696969');
$('.cSrtItem').css('border-bottom', '5px solid #696969');
$('.cSrtItem').css('border-top', '5px solid #E5E5E5');
$('.cSrtItem').css('border-left', '5px solid #E5E5E5');
$('.cSrtItem').css('cursor', 'pointer');
$('.cSrtBucket').css('width', '75px');
$('.cSrtBucket').css('height', '75px');
$('.cSrtBucket').css('padding-left', '5px');
$('.cSrtBucket').css('padding-top', '5px');
$('.cSrtBucket').css('margin-left', '15px');
$('.cSrtBucket').css('margin-bottom', '15px');
//Formatting from options
$('.cSrtWrap').css('width', sortItemWidth);
$('.cSrtWrap').css('height', sortItemHeight);
$('.cSrtWrap').css('margin-right', sortGridSpacing);
$('.cSrtWrap').css('margin-bottom', sortGridSpacing);
$('.cSrtTable').css('margin-top', sortGridSpacing);
$('.cSrtTable').css('margin-bottom', sortGridSpacing);
$('.cSrtItem').css('background-color', sortItemColor);
$('.cSrtCell').css('width', sortItemWidth);
$('.cSrtCell').css('height', sortItemHeight);
$('.cSrtItem').find('div').css('padding-top', sortItemPaddingTop);
$('.cSrtTable').css('border-spacing', sortGridSpacing);
$('.cSrtItem').css('border-right', sortBorderWidth + ' solid #696969');
$('.cSrtItem').css('border-bottom', sortBorderWidth + ' solid #696969');
$('.cSrtItem').css('border-top', sortBorderWidth + ' solid #E5E5E5');
$('.cSrtItem').css('border-left', sortBorderWidth + ' solid #E5E5E5');
$('.cRowText').css('color', sortTextColor);
if (srtCopyEditorStyle != true) {
$('.cSrtItem').find('strong').contents().unwrap();
$('.cSrtItem').find('span').css('text-align', '');
$('.cSrtItem').find('span').css('font-size', '');
$('.cSrtItem').css('font-size', srtFontSize);
$('.cSrtItem').css('font-style', srtFontStyle);
$('.cSrtItem').css('font-weight', srtFontWeight);
$('.cSrtItem').css('text-align', srtHorizontalAlign);
$('.cSrtItem').find('.cRowText').css('font-size', srtFontSize);
$('.cSrtItem').find('.cRowText').css('font-style', srtFontStyle);
$('.cSrtItem').find('.cRowText').css('font-weight', srtFontWeight);
$('.cSrtItem').find('.cRowText').css('text-align', srtHorizontalAlign);
}
if (sortItemHideText == true) {
$('.cSrtItem').css({ 'font-size': '0px', 'color': 'transparent' });
$('.cSrtItem').find('span').css({ 'font-size': '0px', 'color': 'transparent' });
$('.cSrtItem').find('div').css({ 'font-size': '0px', 'color': 'transparent' });
}
if (sortItemGraphicAutoSize == true) $('.cSrtItem').find('img').css({ 'width': '100%' });
if (sortItemRounded != false) $('.cSrtItem').css({ '-moz-border-radius': '20px', '-webkit-border-radius': '20px', '-khtml-border-radius': '20px', 'border-radius': '20px' });
if (sortBorderOn == false) $('.cSrtItem').css('border', '0px solid transparent');
$('.cSrtBucket').css('background-color', dropItemColor);
$('.cSrtBucket').css('width', dropItemWidth);
$('.cSrtBucket').css('height', dropItemHeight);
$('.cSrtBucket').css('vertical-align', dropItemVerticalAlign);
$('.cSrtBucket').css('border-right', dropBorderWidth + ' solid #696969');
$('.cSrtBucket').css('border-bottom', dropBorderWidth + ' solid #696969');
$('.cSrtBucket').css('border-top', dropBorderWidth + ' solid #E5E5E5');
$('.cSrtBucket').css('border-left', dropBorderWidth + ' solid #E5E5E5');
$('.cBtnTable').css('border-spacing', dropItemSpacing);
$('.cBtnTable').css('color', dropTextColor);
if (drpCopyEditorStyle != true) {
$('.cSrtBucket').find('strong').contents().unwrap();
$('.cSrtBucket').find('span').css('text-align', '');
$('.cSrtBucket').find('span').css('font-size', '');
$('.cSrtBucket').css('font-size', drpFontSize);
$('.cSrtBucket').css('font-style', drpFontStyle);
$('.cSrtBucket').css('font-weight', drpFontWeight);
$('.cSrtBucket').css('text-align', drpHorizontalAlign);
}
$('.cButtons').attr('colspan', $('.cSrtBucket').length);
$('.cButtons').css('text-align', 'right');
$('.cUndo, .cReset').css('display', 'inline');
if (blnShowUndoIcon != true) { $('.cUndoIcon').hide(); }
if (blnShowUndoText != true) { $('.cUndoText').hide(); }
$('.cUndoIcon').attr('src', strUndoImgURL);
$('.cUndoIcon').css('width', icoSizeUndo);
//$('.cResetIcon').attr('src', 'http://rs.miprocloud.net/PortalDataService/Content/2FThbfQhOid/resetGreen.png');
$('.cUndoText').text(strUndoText);
if (blnShowResetIcon != true) { $('.cResetIcon').hide(); }
if (blnShowResetText != true) { $('.cResetText').hide(); }
$('.cResetIcon').attr('src', strResetImgURL);
$('.cResetIcon').css('width', icoSizeReset);
// $('.cResetIcon').attr('src', 'http://rs.miprocloud.net/PortalDataService/Content/2FThbfQhOid/resetGreen.png');
$('.cResetText').text(strResetText);
if (dropItemHideText != false) {
$('.cSrtBucket').css({ 'font-size': '0px', 'color': 'transparent' });
$('.cSrtBucket').find('span').css({ 'font-size': '0px', 'color': 'transparent' });
}
if (dropItemGraphicAutoSize == true) $('.cSrtBucket').find('img').css({ 'width': '100%' });
if (dropItemRounded != false) $('.cSrtBucket').css({ '-moz-border-radius': '20px', '-webkit-border-radius': '20px', '-khtml-border-radius': '20px', 'border-radius': '20px' });
if (dropBorderOn == false) $('.cSrtBucket').css('border', '0px solid transparent');
//Hide Next Button
fncHideNext();
//Add answered rows to undo array
$('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').each(function (i) {
intChecked = $(this).find('.cRadio:checked').length;
if (intChecked != 0) { arrLast.push(i) }
})
$('.cSrtItem').draggable({
containment: '.cGridButtonContainer',
scroll: true,
revert: 'invalid'
});
$('.cSrtBucket').droppable({
drop: function (event, ui) {
$(this).css('background-color', dropItemDropColor);
$(this).effect("pulsate", {}, 40);
var objTim;
objTim = setTimeout(function () { $('.cSrtBucket').css('background-color', dropItemColor); }, 350);
//Get Answer Row
var SelRow = ui.draggable.attr('alt');
arrLast.push(SelRow);
//Get Answer Text
var intAns = $(this).attr('alt');
$('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').eq(SelRow).find('input').eq(intAns).prop('checked', true);
//Hide dropped item
$('.cSrtItem').eq(SelRow).hide();
var intNumbItems = $('.cCellRowText').length;
var intNumAns = $('input:checked').length;
if (intNumbItems == intNumAns) {
if (btnAutoNext == true) $('#btnNext').click();
fncShowNext();
}
}
});
$('.cUndo').click(function () {
if (arrLast.length > 0) {
intLast = arrLast[arrLast.length - 1];
$('.cSrtItem[alt="' + intLast + '"]').show();
$('.cSrtItem[alt="' + intLast + '"]').css('top', '');
$('.cSrtItem[alt="' + intLast + '"]').css('left', '');
$('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').eq(intLast).find('input').prop('checked', false);
arrLast.pop();
}
});
$('.cReset').click(function () {
$('.cSrtItem').show();
$('.cSrtItem').css('top', '');
$('.cSrtItem').css('left', '');
$('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').find('input').prop('checked', false);
arrLast = [];
});
$('#btnNext').on('click', function () {
//Clean up
$('#btnNext').off('click');
$('#btnPrevious').off('click');
});
$('#btnPrevious').on('click', function () {
$('#btnNext').off('click');
$('#btnPrevious').off('click');
});
}
catch (err) {
//Clean up
strHtml = ''; //Clear variable used for html
$('.cGridButtonContainer').remove(); //Remove html if already added
//Show question
$('.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').css('display', '');
//Show Next button if click fails.
fncShowNext();
}
}
function VertDragDrop() { //Grid Single Draggable Vertical
itmNumColumn = (typeof itmNumColumn === "undefined") ? 0 : itmNumColumn;
sortGridSpacing = (typeof sortGridSpacing === "undefined") ? "10px" : sortGridSpacing;
sortItemColor = (typeof sortItemColor === "undefined") ? "#6699FF" : sortItemColor;
sortItemWidth = (typeof sortItemWidth === "undefined") ? "75px" : sortItemWidth;
sortItemHeight = (typeof sortItemHeight === "undefined") ? "75px" : sortItemHeight;
sortItemPaddingTop = (typeof sortItemPaddingTop === "undefined") ? "10px" : sortItemPaddingTop;
sortItemRounded = (typeof sortItemRounded === "undefined") ? true : sortItemRounded;
sortItemGraphicAutoSize = (typeof sortItemGraphicAutoSize === "undefined") ? true : sortItemGraphicAutoSize;
sortTextColor = (typeof sortTextColor === "undefined") ? "#000000" : sortTextColor;
srtCopyEditorStyle = (typeof srtCopyEditorStyle === "undefined") ? false : srtCopyEditorStyle;
srtFontSize = (typeof srtFontSize === "undefined") ? "14px" : srtFontSize;
srtFontWeight = (typeof srtFontWeight === "undefined") ? "bold" : srtFontWeight;
srtFontStyle = (typeof srtFontStyle === "undefined") ? "normal" : srtFontStyle;
srtHorizontalAlign = (typeof srtHorizontalAlign === "undefined") ? "center" : srtHorizontalAlign;
sortItemHideText = (typeof sortItemHideText === "undefined") ? false : sortItemHideText;
sortBorderOn = (typeof sortBorderOn === "undefined") ? true : sortBorderOn;
sortBorderWidth = (typeof sortBorderWidth === "undefined") ? "4px" : sortBorderWidth;
dropItemColor = (typeof dropItemColor === "undefined") ? "#FFB8FF" : dropItemColor;
dropItemDropColor = (typeof dropItemDropColor === "undefined") ? "#99CCFF" : dropItemDropColor;
dropItemWidth = (typeof dropItemWidth === "undefined") ? "75px" : dropItemWidth;
dropItemHeight = (typeof dropItemHeight === "undefined") ? "75px" : dropItemHeight;
dropItemVerticalAlign = (typeof dropItemVerticalAlign === "undefined") ? "middle" : dropItemVerticalAlign;
dropItemSpacing = (typeof dropItemSpacing === "undefined") ? "10px" : dropItemSpacing;
dropItemRounded = (typeof dropItemRounded === "undefined") ? true : dropItemRounded;
dropItemGraphicAutoSize = (typeof dropItemGraphicAutoSize === "undefined") ? true : dropItemGraphicAutoSize;
dropTextColor = (typeof dropTextColor === "undefined") ? "#000000" : dropTextColor;
drpCopyEditorStyle = (typeof drpCopyEditorStyle === "undefined") ? false : drpCopyEditorStyle;
drpFontSize = (typeof drpFontSize === "undefined") ? "14px" : drpFontSize;
drpFontWeight = (typeof drpFontWeight === "undefined") ? "bold" : drpFontWeight;
drpFontStyle = (typeof drpFontStyle === "undefined") ? "normal" : drpFontStyle;
drpHorizontalAlign = (typeof drpHorizontalAlign === "undefined") ? "center" : drpHorizontalAlign;
dropItemHideText = (typeof dropItemHideText === "undefined") ? false : dropItemHideText;
dropBorderOn = (typeof dropBorderOn === "undefined") ? true : dropBorderOn;
dropBorderWidth = (typeof dropBorderWidth === "undefined") ? "4px" : dropBorderWidth;
btnAutoNext = (typeof btnAutoNext === "undefined") ? true : btnAutoNext;
blnShowUndoIcon = (typeof blnShowUndoIcon === "undefined") ? true : blnShowUndoIcon;
blnShowUndoText = (typeof blnShowUndoText === "undefined") ? true : blnShowUndoText;
strUndoImgURL = (typeof strUndoImgURL === "undefined") ? "http://rs.miprocloud.net/PortalDataService/Content/6nuZJ6QQ28a/undoBlue.png" : strUndoImgURL;
icoSizeUndo = (typeof icoSizeUndo === "undefined") ? "36px" : icoSizeUndo;
strUndoText = (typeof strUndoText === "undefined") ? "Undo" : strUndoText;
blnShowResetIcon = (typeof blnShowResetIcon === "undefined") ? true : blnShowResetIcon;
blnShowResetText = (typeof blnShowResetText === "undefined") ? true : blnShowResetText;
strResetImgURL = (typeof strResetImgURL === "undefined") ? "http://rs.miprocloud.net/PortalDataService/Content/6nuZJ6QQ28a/ResetBlue.png" : strResetImgURL;
icoSizeReset = (typeof icoSizeReset === "undefined") ? "36px" : icoSizeReset;
strResetText = (typeof strResetText === "undefined") ? "Reset" : strResetText;
debug = (typeof debug === "undefined") ? false : debug;
//Clean up
var strHtml = ''; //Clear variable used for html
$('.cGridButtonContainer').remove(); //Remove html if already added
//Validate Screen to ensure correct Question type
//Exit function if question type not valid
structOK = true;
//Number of questions on page should be 1
if ($('.cCellSubQuestion').length != 1) structOK = false;
//Check only radio buttons on screen
if ($('.cRadio').length == 0) structOK = false;
if ($('.cCheck').length != 0) structOK = false;
// Check answer type rn
if (structOK) {
var strID = $('.cRadio').eq(0).attr('id');
if (strID.substr(0, 2) != 'rn') structOK = false;
}
if (structOK == false) {
if (debug == true) alert('Structure not OK for animation e.q. Wrong question type');
return false;
}
try {
//Create HTML
strHtml = '<div>';
var strStyle = '';
strHtml += '<table><tr><td>';
strHtml += '<table><tr>';
var intBtnCnt = 0;
var arrLast = [];
var blnEndRow = false;
$('.cCellRowText').each(function () {
strHtml += '<td><div><div alt="' + intBtnCnt + '">' + $(this).html() + '</div></div></td>';
if (parseInt(intBtnCnt + 1) % itmNumColumn == 0) { //end row depending on the number of buttons specified in the options
strHtml += '</tr>';
blnEndRow = true;
}
else {
blnEndRow = false;
}
intBtnCnt++;
});
if (blnEndRow == false) { strHtml += '</tr>'; }
strHtml += '</table>';
strHtml += '</td><td>';
strHtml += '<table>';
intBtnCnt = 0;
$('.cCellHeader:not(.cCellFirstHeader)').each(function () {
var alignStyle = "";
if ($(this).hasClass("textleft")) {
alignStyle = "text-align:left;";
}
else if ($(this).hasClass("textcenter")) {
alignStyle = "text-align:center;";
}
else if ($(this).hasClass("textright")) {
alignStyle = "text-align:right;";
}
strStyle = 'style="' + alignStyle;
if (typeof $(this).attr('style') !== 'undefined') {
strStyle += $(this).attr('style');
}
strStyle += '"';
strHtml += '<tr><td alt="' + intBtnCnt + '" ' + strStyle + '>' + $(this).html() + '</td></tr>';
intBtnCnt++;
});
strHtml += '<tr><td><div><img src=""/><span></span></div><div><img src=""/><span></span></div></td></tr>';
strHtml += '</table>';
strHtml += '</td></tr></table>';
strHtml += '</div>';
$('#UpdatePanel1').append(strHtml);
//Make all parts of the cSrtTable class part of the DragGroup class used for touch devices
$('.cSrtTable').find('div, table, tr, td, span').addClass('cDragGroup');
//Hide question
$('.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').css('display', 'none');
//Hide Rows already answered
intBtnCnt = 0;
$('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').each(function () {
if ($(this).find('.cRadio:checked').length != 0) $('.cSrtItem').eq(intBtnCnt).hide();
intBtnCnt++;
});
$('.cSrtOuterTable').css('margin-left', 'auto');
$('.cSrtOuterTable').css('margin-right', 'auto');
$('.cSrtOuterTable').css('width', 'auto');
$('.cSrtTable').css('width', 'auto');
$('.cSrtTable').css('margin-left', 'auto');
$('.cSrtTable').css('margin-right', 'auto');
$('.cSrtTable').find('td').css('padding', '0px');
$('.cBtnTable').css('width', 'auto');
$('.cBtnTable').css('margin-left', 'auto');
$('.cBtnTable').css('margin-right', 'auto');
$('.cBtnTable').find('td').css('padding', '0px');
$('.cSrtItem').css('padding', '3px');
$('.cSrtItem').css('border-right', '5px solid #696969');
$('.cSrtItem').css('border-bottom', '5px solid #696969');
$('.cSrtItem').css('border-top', '5px solid #E5E5E5');
$('.cSrtItem').css('border-left', '5px solid #E5E5E5');
$('.cSrtItem').css('cursor', 'pointer');
$('.cSrtBucket').css('width', '75px');
$('.cSrtBucket').css('height', '75px');
$('.cSrtBucket').css('padding-left', '5px');
$('.cSrtBucket').css('padding-top', '5px');
$('.cUndo').css('float', 'left');
$('.cReset').css('float', 'right');
if (blnShowUndoIcon != true) { $('.cUndoIcon').hide(); }
if (blnShowUndoText != true) { $('.cUndoText').hide(); }
$('.cUndoIcon').attr('src', strUndoImgURL);
$('.cUndoIcon').css('width', icoSizeUndo);
//$('.cResetIcon').attr('src', 'http://rs.miprocloud.net/PortalDataService/Content/2FThbfQhOid/resetGreen.png');
$('.cUndoText').text(strUndoText);
if (blnShowResetIcon != true) { $('.cResetIcon').hide(); }
if (blnShowResetText != true) { $('.cResetText').hide(); }
$('.cResetIcon').attr('src', strResetImgURL);
$('.cResetIcon').css('width', icoSizeReset);
//$('.cResetIcon').attr('src', 'http://rs.miprocloud.net/PortalDataService/Content/2FThbfQhOid/resetGreen.png');
$('.cResetText').text(strResetText);
//Formatting from options
$('.cSrtItem').css('background-color', sortItemColor);
$('.cSrtWrap').css('width', sortItemWidth);
$('.cSrtWrap').css('height', sortItemHeight);
$('.cSrtWrap').css('margin-right', sortGridSpacing);
$('.cSrtWrap').css('margin-bottom', sortGridSpacing);
$('.cSrtItem').css('width', sortItemWidth);
$('.cSrtItem').css('height', sortItemHeight);
$('.cSrtItem').find('div').css('padding-top', sortItemPaddingTop);
$('.cSrtTable').css('border-spacing', sortGridSpacing);
$('.cSrtItem').css('border-right', sortBorderWidth + ' solid #696969');
$('.cSrtItem').css('border-bottom', sortBorderWidth + ' solid #696969');
$('.cSrtItem').css('border-top', sortBorderWidth + ' solid #E5E5E5');
$('.cSrtItem').css('border-left', sortBorderWidth + ' solid #E5E5E5');
$('.cRowText').css('color', sortTextColor);
if (srtCopyEditorStyle != true) {
$('.cSrtItem').find('strong').contents().unwrap();
$('.cSrtItem').find('span').css('text-align', '');
$('.cSrtItem').find('span').css('font-size', '');
$('.cSrtItem').css('font-size', srtFontSize);
$('.cSrtItem').css('font-style', srtFontStyle);
$('.cSrtItem').css('font-weight', srtFontWeight);
$('.cSrtItem').css('text-align', srtHorizontalAlign);
$('.cSrtItem').find('.cRowText').css('font-size', srtFontSize);
$('.cSrtItem').find('.cRowText').css('font-style', srtFontStyle);
$('.cSrtItem').find('.cRowText').css('font-weight', srtFontWeight);
$('.cSrtItem').find('.cRowText').css('text-align', srtHorizontalAlign);
}
if (sortItemHideText == true) {
$('.cSrtItem').css({ 'font-size': '0px', 'color': 'transparent' });
$('.cSrtItem').find('span').css({ 'font-size': '0px', 'color': 'transparent' });
$('.cSrtItem').find('div').css({ 'font-size': '0px', 'color': 'transparent' });
}
if (sortItemGraphicAutoSize == true) $('.cSrtItem').find('img').css({ 'width': '100%' });
if (sortItemRounded != false) $('.cSrtItem').css({ '-moz-border-radius': '20px', '-webkit-border-radius': '20px', '-khtml-border-radius': '20px', 'border-radius': '20px' });
if (sortBorderOn == false) $('.cSrtItem').css('border', '0px solid transparent');
$('.cSrtBucket').css('background-color', dropItemColor);
$('.cSrtBucket').css('width', dropItemWidth);
$('.cSrtBucket').css('height', dropItemHeight);
$('.cSrtBucket').css('vertical-align', dropItemVerticalAlign);
$('.cSrtBucket').css('border-right', dropBorderWidth + ' solid #696969');
$('.cSrtBucket').css('border-bottom', dropBorderWidth + ' solid #696969');
$('.cSrtBucket').css('border-top', dropBorderWidth + ' solid #E5E5E5');
$('.cSrtBucket').css('border-left', dropBorderWidth + ' solid #E5E5E5');
$('.cBtnTable').css('border-spacing', dropItemSpacing);
$('.cBtnTable').css('color', dropTextColor);
if (drpCopyEditorStyle != true) {
$('.cSrtBucket').find('strong').contents().unwrap();
$('.cSrtBucket').find('span').css('text-align', '');
$('.cSrtBucket').find('span').css('font-size', '');
$('.cSrtBucket').css('font-size', drpFontSize);
$('.cSrtBucket').css('font-style', drpFontStyle);
$('.cSrtBucket').css('font-weight', drpFontWeight);
$('.cSrtBucket').css('text-align', drpHorizontalAlign);
}
if (dropItemHideText != false) {
$('.cSrtBucket').css({ 'font-size': '0px', 'color': 'transparent' });
$('.cSrtBucket').find('span').css({ 'font-size': '0px', 'color': 'transparent' });
}
if (dropItemGraphicAutoSize == true) $('.cSrtBucket').find('img').css({ 'width': '100%' });
if (dropItemRounded != false) $('.cSrtBucket').css({ '-moz-border-radius': '20px', '-webkit-border-radius': '20px', '-khtml-border-radius': '20px', 'border-radius': '20px' });
if (dropBorderOn == false) $('.cSrtBucket').css('border', '0px solid transparent');
//Hide Next Button
fncHideNext();
//Add answered rows to undo array
$('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').each(function (i) {
intChecked = $(this).find('.cRadio:checked').length;
if (intChecked != 0) { arrLast.push(i) }
});
$('.cSrtItem').draggable({
containment: '.cGridButtonContainer',
scroll: true,
revert: 'invalid'
});
$('.cSrtBucket').droppable({
drop: function (event, ui) {
$(this).css('background-color', dropItemDropColor);
$(this).effect("pulsate", {}, 40);
var objTim;
objTim = setTimeout(function () { $('.cSrtBucket').css('background-color', dropItemColor); }, 350);
//Get Answer Row
var SelRow = ui.draggable.attr('alt');
arrLast.push(SelRow);
//Get Answer Text
var intAns = $(this).attr('alt');
$('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').eq(SelRow).find('input').eq(intAns).prop('checked', true);
//Hide dropped item
$('.cSrtItem').eq(SelRow).hide();
var intNumbItems = $('.cCellRowText').length;
var intNumAns = $('input:checked').length;
if (intNumbItems == intNumAns) {
if (btnAutoNext == true) $('#btnNext').click();
fncShowNext();
}
}
});
$('.cUndo').click(function () {
if (arrLast.length > 0) {
intLast = arrLast[arrLast.length - 1];
$('.cSrtItem[alt="' + intLast + '"]').show();
$('.cSrtItem[alt="' + intLast + '"]').css('top', '');
$('.cSrtItem[alt="' + intLast + '"]').css('left', '');
$('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').eq(intLast).find('input').prop('checked', false);
arrLast.pop();
}
});
$('.cReset').click(function () {
$('.cSrtItem').show();
$('.cSrtItem').css('top', '');
$('.cSrtItem').css('left', '');
$('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').find('input').prop('checked', false);
arrLast = [];
});
$('#btnNext').on('click', function () {
//Clean up
$('#btnNext').off('click');
$('#btnPrevious').off('click');
});
$('#btnPrevious').on('click', function () {
$('#btnNext').off('click');
$('#btnPrevious').off('click');
});
}
catch (err) {
//Clean up
strHtml = ''; //Clear variable used for html
$('.cGridButtonContainer').remove(); //Remove html if already added
//Show question
$('.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').css('display', '');
//Show Next button.
fncShowNext();
}
}
function iNumeric() { //Interactive Numeric question
blnCheckBox1 = (typeof blnCheckBox1 === "undefined") ? false : blnCheckBox1;
strCheckBox1Text = (typeof strCheckBox1Text === "undefined") ? "Don't Know" : strCheckBox1Text;
strCheckBox1Pos = (typeof strCheckBox1Pos === "undefined") ? "right" : strCheckBox1Pos;
strCheckBox1Value = (typeof strCheckBox1Value === "undefined") ? -99 : strCheckBox1Value;
blnCheckBox2 = (typeof blnCheckBox2 === "undefined") ? false : blnCheckBox2;
strCheckBox2Text = (typeof strCheckBox2Text === "undefined") ? "Refuse" : strCheckBox2Text;
strCheckBox2Pos = (typeof strCheckBox2Pos === "undefined") ? "right" : strCheckBox2Pos;
strCheckBox2Value = (typeof strCheckBox2Value === "undefined") ? -99 : strCheckBox2Value;
blnSetWidth = (typeof blnSetWidth === "undefined") ? false : blnSetWidth;
RowTextWidth = (typeof RowTextWidth === "undefined") ? "100px" : RowTextWidth;
blnAlignRight = (typeof blnAlignRight === "undefined") ? true : blnAlignRight;
blnPreFill = (typeof blnPreFill === "undefined") ? false : blnPreFill;
strPreFillValue = (typeof strPreFillValue === "undefined") ? 0 : strPreFillValue;
blnShowTotal = (typeof blnShowTotal === "undefined") ? false : blnShowTotal;
blnSetTotal = (typeof blnSetTotal === "undefined") ? false : blnSetTotal;
intMinValue = (typeof intMinValue === "undefined") ? 100 : intMinValue;
intMaxValue = (typeof intMaxValue === "undefined") ? 100 : intMaxValue;
strTotMessage = (typeof strTotMessage === "undefined") ? "Please ensure the total is between [Min] and [Max]" : strTotMessage;
blnUseHeader = (typeof blnUseHeader === "undefined") ? false : blnUseHeader;
strTotalText = (typeof strTotalText === "undefined") ? "Total" : strTotalText;
blnShowPrefix = (typeof blnShowPrefix === "undefined") ? false : blnShowPrefix;
strPrefixText = (typeof strPrefixText === "undefined") ? "�" : strPrefixText;
blnShowSuffix = (typeof blnShowSuffix === "undefined") ? false : blnShowSuffix;
strSuffixText = (typeof strSuffixText === "undefined") ? "%" : strSuffixText;
//Add Class to visible Numeric Inputs to use as selector - Due to double inputs on mobile
$('.cFInput:visible').addClass('cVisibleInput');
$('.cFInput:hidden').addClass('cHiddenInput');
//Pre Fill
if (blnPreFill == true) {
$('.cVisibleInput').each(function () {
if ($(this).val().length == 0) { $(this).val(strPreFillValue); }
});
$('.cHiddenInput').each(function () {
if ($(this).val().length == 0) { $(this).val(strPreFillValue); }
});
}
//Add Check boxes
if (blnCheckBox1 == true | blnCheckBox2 == true) {
i = 0;
$('.cVisibleInput').each(function (i) {
strHTML = '';
strHTML += '<input type="text">';
if (blnCheckBox1 == true) {
if (strCheckBox1Pos == 'below') { strHTML += '<br/>'; }
strHTML += '<input type="radio" name="iNumRadio_' + i + '" alt="' + i + '" value="' + strCheckBox1Value + '"><label>' + strCheckBox1Text + '</label>';
}
if (blnCheckBox2 == true) {
if (strCheckBox2Pos == 'below') { strHTML += '<br/>'; }
strHTML += '<input type="radio" name="iNumRadio_' + i + '" alt="' + i + '" value="' + strCheckBox2Value + '"><label>' + strCheckBox2Text + '</label>';
}
//Positioning
$(this).after(strHTML);
$(this).hide();
//Set Previous answers
switch (parseInt($(this).val())) {
case parseInt(strCheckBox1Value):
$('.ciNumRadio[value="' + strCheckBox1Value + '"]').eq(i).prop('checked', true);
break;
case parseInt(strCheckBox2Value):
$('.ciNumRadio[value="' + strCheckBox2Value + '"]').eq(i).prop('checked', true);
break;
default:
$('.ciNumText').eq(i).val($(this).val());
}
});
}
//Inform scripter if check box values are the same
if ((strCheckBox1Value == strCheckBox2Value) && (blnCheckBox1 == true && blnCheckBox2 == true)) { iQuestHelper('The values for checkbox 1 and checkbox 2 are the same and this will cause errors'); }
//Set size of new input boxes
$('.ciNumText').attr('size', $('.cVisibleInput').eq(0).attr('size'));
// Set Row text width
if (blnSetWidth == true) { $('.cCellRowTextF').css('cssText', 'width:' + RowTextWidth + ' !important;'); }
//Add a Prefix
if (blnShowPrefix == true) {
$('.cVisibleInput').before('<span>' + strPrefixText + ' </span');
}
//Add a Suffix
if (blnShowSuffix == true) {
if (blnCheckBox1 == true | blnCheckBox2 == true) {
$('.ciNumText').after('<span> ' + strSuffixText + '</span');
}
else {
$('.cVisibleInput').after('<span> ' + strSuffixText + '</span');
}
}
//Add Total
if (blnShowTotal == true) {
//Use Last Row Header if Specified
if (blnUseHeader == true) {
$('.cRowBlockText').attr('colspan', '1');
strHTML = '<td><input type="text" readonly></td>';
$('.cRowBlockText').after(strHTML);
}
else {
strHTML = '<tr><td>' + strTotalText + '</td><td><input type="text" readonly></td></tr>';
var intRow = $('.cRow, .cRowAlt, .cRowSelected, .cRowAltSelected').length - 1;
$('.cFooter:first').parents('tr').eq(0).before(strHTML);
}
if (blnShowSuffix == true) { $('.ciTotalText').after('<span> ' + strSuffixText + '</span'); }
if (blnShowPrefix == true) { $('.ciTotalText').before('<span>' + strPrefixText + ' </span'); }
$('.ciTotalText').attr('size', $('.cFInput').eq(0).attr('size'));
}
else {
strHTML = '<tr style="display: none;"><td>' + strTotalText + '</td><td><input type="text" readonly></td></tr>';
var intRow = $('.cRow, .cRowAlt, .cRowSelected, .cRowAltSelected').length - 1;
$('.cFooter:first').parents('tr').eq(0).before(strHTML);
}
//Update total if answered
UpdateTotal();
//Set alignment of input box text
if (blnAlignRight == true) {
$('input:text').css('text-align', 'right');
}
//If total checking selected - intercept button clicks
if (blnSetTotal == true) {
//Hide Next Button
$('#btnNext').hide();
//Add dummy next button
$('#btnNext').before('<input id="btnNext2" name="btnNext2" value="Next" type="button">');
$('#btnNext2').val($('#btnNext').val());
if ($('#btnPrevious').length > 0) {
//Hide Previous Button
$('#btnPrevious').hide();
//Add dummy Previous button
$('#btnPrevious').before('<input id="btnPrevious2" name="btnPrevious2" value="Previous" type="button">');
$('#btnPrevious2').val($('#btnPrevious').val());
}
$('#btnNext2, #btnPrevious2').click(function () {
strDir = $(this).attr('id');
UpdateTotal();
fncCheckTotal(strDir);
});
}
//Radio Button Change Events
$('.ciNumRadio').change(function (event) {
intIndex = $(this).attr('alt');
if ($(this).prop('checked')) {
$('.cVisibleInput').eq(intIndex).val($(this).val());
$('.cHiddenInput').eq(intIndex).val($(this).val());
$('.ciNumText').eq(intIndex).val('');
}
else {
$('.cVisibleInput').eq(intIndex).val('');
$('.cHiddenInput').eq(intIndex).val('');
$('.ciNumText').eq(intIndex).val('');
}
UpdateTotal();
});
//Update values on Test server and preview server keyup does not work in SilverLight browser
var strServer = $('#mi_server').val();
if (strServer == 'preview.miprocloud.net' || strServer == 'test.miprocloud.net') {
$('.ciNumText').keydown(function () {
intIndex = $('.ciNumText').index($(this));
myVar = setTimeout(function () {
var strCurrVal = $('.ciNumText').eq(intIndex).val();
strCurrVal = strCurrVal.replace(/[^0-9\.]/g, '');
$('.ciNumText').eq(intIndex).val(strCurrVal);
if ($('.ciNumText').length != 0) { updNum(intIndex); }
//Update Totals
UpdateTotal();
}, 250);
if ($(this).length != 0) {
$('.ciNumRadio[alt="' + intIndex + '"]').prop('checked', false);
}
});
$('.cVisibleInput').keydown(function () {
intIndex = $('.ciNumText').index($(this));
myVar = setTimeout(function () {
if ($('.ciNumText').length != 0) { updNum(intIndex); }
//Update Totals
UpdateTotal();
}, 250);
});
}
$('.ciNumText').keyup(function () {
intIndex = $('.ciNumText').index($(this));
$('.cVisibleInput').eq(intIndex).val($(this).val());
$('.cHiddenInput').eq(intIndex).val($(this).val());
//Update Total
UpdateTotal();
if ($(this).length != 0) {
$('.ciNumRadio[alt="' + intIndex + '"]').prop('checked', false);
}
this.value = this.value.replace(/[^0-9\.]/g, '');
});
$('.cVisibleInput').keyup(function () {
//Update Total
UpdateTotal();
});
function updNum(intIndex) {
$('.cVisibleInput').eq(intIndex).val($('.ciNumText').eq(intIndex).val());
$('.cHiddenInput').eq(intIndex).val($('.ciNumText').eq(intIndex).val());
}
function UpdateTotal() {
if (blnCheckBox1 == true | blnCheckBox2 == true) {
strSelector = '.ciNumText';
}
else {
strSelector = '.cVisibleInput';
}
var intTotal = 0;
$(strSelector).each(function () {
if ($(this).val().length > 0) {
intTotal = intTotal + parseInt($(this).val());
}
});
if (intTotal > 0) { $('.ciTotalText').val(intTotal); }
}
function fncCheckTotal(strDir) {
var blnTotalOK = true;
var intTotal = parseInt($('.ciTotalText').val());
if (isNaN(intTotal)) { blnTotalOK = false; }
if (intTotal < parseInt(intMinValue) || intTotal > parseInt(intMaxValue)) {
blnTotalOK = false;
}
if (blnTotalOK == true) {
if (strDir == 'btnNext2') {
$('#btnNext').click();
}
else {
$('#btnPrevious').click();
}
}
else {
$('.cError').remove();
strTotMessage = strTotMessage.replace("[Min]", intMinValue);
strTotMessage = strTotMessage.replace("[Max]", intMaxValue);
strHtml = '<span>' + strTotMessage + '</span>';
$('.cTDContainQues:nth(0)').prepend(strHtml);
}
}
}
function DragRanking() { //Drag and Drop ranking using numeric question
//Check for WCAG
if ($('#btnToggleWcag').val()==1) {
return false;
}
intNumCol = (typeof intNumCol === "undefined") ? 3 : intNumCol; //Number of sort items per row
intNumBucket = (typeof intNumBucket === "undefined") ? 3 : intNumBucket; //Number of drop items
sortGridSpacing = (typeof sortGridSpacing === "undefined") ? "10px" : sortGridSpacing; //Item grid spacing
sortItemColor = (typeof sortItemColor === "undefined") ? "#B9CDE5" : sortItemColor; //Colour
sortItemWidth = (typeof sortItemWidth === "undefined") ? "75px" : sortItemWidth; //Width
sortItemHeight = (typeof sortItemHeight === "undefined") ? "75px" : sortItemHeight; //Height
sortItemVertAlign = (typeof sortItemVertAlign === "undefined") ? "middle" : sortItemVertAlign; //Vertical Alignment
sortItemSpacing = (typeof sortItemSpacing === "undefined") ? "10px" : sortItemSpacing; //Item spacing
sortItemRounded = (typeof sortItemRounded === "undefined") ? false : sortItemRounded; //Rounded corners
sortItemGraphicAutoSize = (typeof sortItemGraphicAutoSize === "undefined") ? true : sortItemGraphicAutoSize; //Auto size graphics
sortTextColor = (typeof sortTextColor === "undefined") ? "#000000" : sortTextColor; //Text colour
srtCopyEditorStyle = (typeof srtCopyEditorStyle === "undefined") ? false : srtCopyEditorStyle; //Copy Editor Text Styling
srtFontSize = (typeof srtFontSize === "undefined") ? "14px" : srtFontSize; //Sort Item Text Size
srtFontWeight = (typeof srtFontWeight === "undefined") ? "bold" : srtFontWeight; //Sort Item Text Weight
srtFontStyle = (typeof srtFontStyle === "undefined") ? "normal" : srtFontStyle; //Sort Item Text Style
srtHorizontalAlign = (typeof srtHorizontalAlign === "undefined") ? "center" : srtHorizontalAlign; //Horizontal alignment of text
sortItemHideText = (typeof sortItemHideText === "undefined") ? false : sortItemHideText; //Hide Text
sortBorderOn = (typeof sortBorderOn === "undefined") ? true : sortBorderOn; //Show border
sortBorderWidth = (typeof sortBorderWidth === "undefined") ? "3px" : sortBorderWidth; //Border width
dropGridGap = (typeof dropGridGap === "undefined") ? "30px" : dropGridGap; //Grid Spacing
dropItemColor = (typeof dropItemColor === "undefined") ? "#8DB3E3" : dropItemColor; //Item colour
dropItemDropColor = (typeof dropItemDropColor === "undefined") ? "#548ED5" : dropItemDropColor; //Colour
dropItemWidth = (typeof dropItemWidth === "undefined") ? "150px" : dropItemWidth; //Width
dropItemHeight = (typeof dropItemHeight === "undefined") ? "100px" : dropItemHeight; //Height
dropItemVerticalAlign = (typeof dropItemVerticalAlign === "undefined") ? "middle" : dropItemVerticalAlign; //Vertical Align
dropItemSpacing = (typeof dropItemSpacing === "undefined") ? "10px" : dropItemSpacing; //Drop Item Spacing
dropItemRounded = (typeof dropItemRounded === "undefined") ? false : dropItemRounded; //Rounded corners
dropPrefixText = (typeof dropPrefixText === "undefined") ? "Choice " : dropPrefixText; //Prefix text
dropItemGraphicAutoSize = (typeof dropItemGraphicAutoSize === "undefined") ? true : dropItemGraphicAutoSize; //Auto size graphics
dropItemHideText = (typeof dropItemHideText === "undefined") ? false : dropItemHideText; //Hide Text
dropTextColor = (typeof dropTextColor === "undefined") ? "#000000" : dropTextColor; //Text colour
dropBorderOn = (typeof dropBorderOn === "undefined") ? true : dropBorderOn; //Show border
dropBorderWidth = (typeof dropBorderWidth === "undefined") ? "3px" : dropBorderWidth; //Border width
dropBackground = (typeof dropBackground === "undefined") ? true : dropBackground; //Use Background Image
dropBackgroundURl = (typeof dropBackgroundURl === "undefined") ? "" : dropBackgroundURl; //Background Image
btnAutoNext = (typeof btnAutoNext === "undefined") ? true : btnAutoNext; //Auto next
debug = (typeof debug === "undefined") ? false : debug; //Debug mode
//Clean up
var strHtml = ''; //Clear variable used for html
var blnDropOK = true;
$('.cGridButtonContainer').remove(); //Remove html if already added
//Validate Screen to ensure correct Question type
//Exit function if question type not valid
//Number of questions on page should be 1
if ($('.cCellSubQuestion').length != 1) return false;
//Check numeric inputs on screen
if ($('.cFInput').length == 0) return false;
// Check no other question types on screen
if ($('.cRadio').length != 0 || $('.cCheck').length != 0) return false;
try {
strHtml = '<div>';
strHtml += '<div id="btnColor" style="display:none;"> </div><div id="btnColorClick" style="display:none;"> </div><div id="srtItemColor" style="display:none;"> </div>';
strHtml += '<table style="width: auto; margin-left:auto; margin-right: auto;"><tr>';
strHtml += '<td style="padding-right:1.5em;;"><table style="width: auto;"><tr>';
var intBtnCnt = 1;
var blnEndRow = false;
$('.cCellRowText').each(function (i) {
strHtml += '<td align="' + $(this).attr('align') + '"><div id="SrtItem' + intBtnCnt + '" alt="' + intBtnCnt + '"><span>' + $(this).html() + '</span></div></td>';
if (parseInt(intBtnCnt) % intNumCol == 0) { //end row depending on the number of buttons specified in the options
strHtml += '</tr>';
blnEndRow = true;
}
else {
blnEndRow = false;
}
intBtnCnt++;
});
if (blnEndRow == false) { strHtml += '</tr>'; }
strHtml += '</table>';
strHtml += '</td>';
strHtml += '<td style="vertical-align:top;">';
for (i = 1; i <= intNumBucket; i++) {
strHtml += '<div id="SrtBucket' + i + '" alt="' + i + '">' + dropPrefixText + i + '<div></div></div>';
}
strHtml += '</td>';
strHtml += '</tr>';
strHtml += '</div>';
$('#UpdatePanel1').append(strHtml);
//Make all parts of the cSrtTable class part of the DragGroup class used for touch devices
$('.cSrtTable').find('div, table, tr, td, span').addClass('cDragGroup');
//Hide question
$('.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').hide();
$('.cSrtTableOuter').css('border-spacing', '0px');
$('.cSrtTable').css('border-collapse', 'separate');
$('.cSrtTable').css('border-spacing', '0px');
$('.cSrtItem').css('padding', '0px');
$('.cSrtBucket').css('text-align', 'center');
$('.cSrtBucket').css('padding-top', '5px');
//Formatting from options
$('.cSrtTable').css('margin-top', sortGridSpacing);
$('.cSrtTable').css('margin-bottom', sortGridSpacing);
$('.cSrtTable td').css('padding', sortItemSpacing);
$('.cSrtItem').css('background-color', sortItemColor);
$('.cSrtItem').css('width', sortItemWidth);
$('.cSrtItem').css('height', sortItemHeight);
$('.cSrtItemCell').css('display', 'table-cell');
$('.cSrtItemCell').css('height', sortItemHeight);
$('.cSrtItemCell').css('width', sortItemWidth);
$('.cSrtItemCell').css('vertical-align', sortItemVertAlign);
$('.cSrtItem').css('border-right', sortBorderWidth + ' solid #696969');
$('.cSrtItem').css('border-bottom', sortBorderWidth + ' solid #696969');
$('.cSrtItem').css('border-top', sortBorderWidth + ' solid #E5E5E5');
$('.cSrtItem').css('border-left', sortBorderWidth + ' solid #E5E5E5');
$('.cRowText').css('color', sortTextColor);
if (srtCopyEditorStyle != true) {
$('.cSrtItem').find('strong').contents().unwrap();
$('.cSrtItem').find('span').css('text-align', '');
$('.cSrtItem').find('span').css('font-size', '');
$('.cSrtItemCell').css('font-size', srtFontSize);
$('.cSrtItemCell').css('font-style', srtFontStyle);
$('.cSrtItemCell').css('font-weight', srtFontWeight);
$('.cSrtItemCell').css('text-align', srtHorizontalAlign);
$('.cSrtItem').find('.cRowText').css('font-size', srtFontSize);
$('.cSrtItem').find('.cRowText').css('font-style', srtFontStyle);
$('.cSrtItem').find('.cRowText').css('font-weight', srtFontWeight);
$('.cSrtItem').find('.cRowText').css('text-align', srtHorizontalAlign);
}
if (sortItemHideText == true) {
$('.cSrtItem').css({ 'font-size': '0px', 'color': 'transparent' });
$('.cSrtItem').find('span').css({ 'font-size': '0px', 'color': 'transparent' });
$('.cSrtItem').find('div').css({ 'font-size': '0px', 'color': 'transparent' });
}
if (sortItemGraphicAutoSize == true) $('.cSrtItem').find('img').css({ 'width': '100%' });
if (sortItemRounded != false) $('.cSrtItem').css({ '-moz-border-radius': '20px', '-webkit-border-radius': '20px', '-khtml-border-radius': '20px', 'border-radius': '20px' });
if (sortBorderOn == false) $('.cSrtItem').css('border', '0px solid transparent');
$('.cSrtBucketCell').css('padding-left', dropGridGap);
$('.cSrtBucketCell').css('padding-top', sortGridSpacing);
$('.cSrtBucket').css('background', dropItemColor);
$('.cSrtBucket').css('width', dropItemWidth);
$('.cSrtBucket').css('height', dropItemHeight);
$('.cGroupitems').css('display', 'table-cell');
$('.cGroupitems').css('vertical-align', dropItemVerticalAlign);
$('.cGroupitems').css('width', dropItemWidth);
$('.cGroupitems').css('height', sortItemHeight);
$('.cSrtBucket').css('border-right', dropBorderWidth + ' solid #696969');
$('.cSrtBucket').css('border-bottom', dropBorderWidth + ' solid #696969');
$('.cSrtBucket').css('border-top', dropBorderWidth + ' solid #E5E5E5');
$('.cSrtBucket').css('border-left', dropBorderWidth + ' solid #E5E5E5');
$('.cSrtBucket').css('margin-bottom', dropItemSpacing);
$('.cSrtBucket').css('color', dropTextColor);
if (dropItemHideText != false) {
$('.cSrtBucket').css({ 'font-size': '0px', 'color': 'transparent' });
$('.cSrtBucket').find('span').css({ 'font-size': '0px', 'color': 'transparent' });
}
if (dropItemGraphicAutoSize == true) $('.cSrtBucket').find('img').css({ 'width': '100%' });
if (dropItemRounded != false) $('.cSrtBucket').css({ '-moz-border-radius': '20px', '-webkit-border-radius': '20px', '-khtml-border-radius': '20px', 'border-radius': '20px' });
if (dropBorderOn == false) $('.cSrtBucket').css('border', '0px solid transparent');
if (dropBackground == true) {
strURL = 'url(' + dropBackgroundURl + ')';
$('.cSrtBucket').css('background-image', strURL);
$('.cSrtBucket').css('background-size', '100% 100%');
$('.cSrtBucket').css('background-repeat', 'no-repeat');
}
$('.cTable').css('margin-bottom', '0px');
var recycle_icon = '<a href="#" title="Remove from list" style="float: right">Remove from list</a>';
//Set Previous Answers
$('.cFInput').each(function (i) {
if ($(this).val().length != 0) {
//Get ID of srtBucker
var strID = '#SrtBucket' + $(this).val();
//Get Answer Row
var SelRow = i;
//Get Answer Text
var strAnsText = $('.cRowText').eq(i).text();
// Add answer text to bucket
$(strID).find('.cGroupitems').html('<div style="margin-top: 1px; padding-left: 2px; color:black;" alt="' + SelRow + '">' + strAnsText + recycle_icon + '</div>');
// Fade Bucket
$(strID).css('background', dropItemDropColor);
//Hide Answer
$('.cSrtItem').eq(SelRow).css('visibility', 'hidden');
}
});
//Refresh button pressed
$('.ui-icon-circle-close').on('click', function () {
var strID = '#' + $(this).parents().filter('.cSrtBucket').prop('id');
$(strID).css('background', dropItemColor);
$('.cSrtBucket').css('background-repeat', 'no-repeat');
$('.ui-droppable').css('background-repeat', 'no-repeat');
if (dropBackground == true) {
strURL = 'url(' + dropBackgroundURl + ')';
$('.cSrtBucket').css('background-image', strURL);
$('.cSrtBucket').css('background-size', '100% 100%');
$('.cSrtBucket').css('background-repeat', 'no-repeat');
}
// clear the answer selected
var SelRow = $(this).parent().attr('alt');
//Clear answer
$('.cFInput').eq(SelRow).val('')
//ReDisplay answer
$('.cSrtItem').eq(SelRow).css('visibility', 'visible');
$(this).parent().remove();
return false;
});
setTimeout(function () {
$('.cSrtItem').draggable({
containment: '.cGridButtonContainer',
scroll: true,
revert: 'invalid',
start: function () {
$(this).data("origPosition", $(this).position());
}
});
}, 200);
$('.cSrtBucket').droppable({
drop: function (event, ui) {
//Set Bucket ID
var strID = '#' + $(this).prop('id');
if ($(strID).text().length == 1 + dropPrefixText.length) {
//Get Answer Row
var SelRow = ui.draggable.attr('alt') - 1;
//Get Answer Text
var strAnsText = ui.draggable.find('.cSrtItemCell').html();
// Add answer text to bucket
$(strID).find('.cGroupitems').html('<div style="margin-top: 1px; padding-left: 2px; color:black;" alt="' + SelRow + '">' + strAnsText + recycle_icon + '</div>');
// Fade Bucket
$(strID).css('background', dropItemDropColor);
if (dropBackground == true) {
strURL = 'url(' + dropBackgroundURl + ')';
$('.cSrtBucket').css('background-image', strURL);
$('.cSrtBucket').css('background-size', '100% 100%');
$('.cSrtBucket').css('background-repeat', 'no-repeat');
}
// The answer selected
var SelInp = $(this).attr('alt');
//Set answer row
$('.cFInput').eq(SelRow).val(SelInp)
//Hide Answer
$('.cSrtItem').eq(SelRow).css('visibility', 'hidden');
//Refresh button pressed
$('.ui-icon-circle-close').on('click', function () {
var strID = '#' + $(this).parents().filter('.cSrtBucket').prop('id');
$(strID).css('background', dropItemColor);
$('.cSrtBucket').css('background-repeat', 'no-repeat');
$('.ui-droppable').css('background-repeat', 'no-repeat');
if (dropBackground == true) {
strURL = 'url(' + dropBackgroundURl + ')';
$('.cSrtBucket').css('background-image', strURL);
$('.cSrtBucket').css('background-size', '100% 100%');
$('.cSrtBucket').css('background-repeat', 'no-repeat');
}
// clear the answer selected
var SelRow = $(this).parent().attr('alt');
//Clear answer
$('.cFInput').eq(SelRow).val('')
//ReDisplay answer
$('.cSrtItem').eq(SelRow).css('visibility', 'visible');
$('.cSrtItem').eq(SelRow).css('left', '');
$('.cSrtItem').eq(SelRow).css('top', '');
$('.cSrtItem').eq(SelRow).css('positon', '');
$(this).parent().remove();
return false;
});
}
else {
var intID = ui.draggable.attr('alt') - 1;
setTimeout(function () {
$('.cSrtItem').eq(intID).animate({
top: 0,
left: 0
}, 500);
}, 200);
}
}
});
$('.cSrtBucket').css('background-repeat', 'no-repeat');
$('.ui-droppable').css('background-repeat', 'no-repeat');
$('.buttonNext').mousedown(function () {
$(this).click();
});
$('.buttonPrevious').mousedown(function () {
$(this).click();
});
$('#btnNext').on('click', function () {
//Clean up
$('.cGridButtonContainer').remove();
$('#btnNext').off('click');
$('#btnPrevious').off('click');
});
$('#btnPrevious').on('click', function () {
$('.cGridButtonContainer').remove(); //Remove html if already added
$('#btnNext').off('click');
$('#btnPrevious').off('click');
});
}
catch (err) {
//Clean up
strHtml = ''; //Clear variable used for html
$('.cGridButtonContainer').remove(); //Remove html if already added
//Show question
$('.cCellHeader,.cCellHeaderCode,.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected,.cFooter').show();
//Show Next button if click fails.
fncShowNext();
}
}
function setSlider() { //Set Slider positions if question previously answered
//No longer used from Update January 2015
try {
var intChecked = 0;
var intNumCol = $('.cCellHeader:not(.cCellFirstHeader)').length; //Number of Columns
$('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').each(function (i) {
intChecked = $(this).find('.cRadio:checked').length;
if (intChecked != 0) {
var radioButtons = $(this).find('.cRadio');
var selectedIndex = radioButtons.index(radioButtons.filter(':checked'));
var intStep = parseInt(1000 / intNumCol); //Scale is dived into steps that relate to the number of columns
var intStepMid = intStep / 2; //The middle of a step
var intNewVal = (selectedIndex * intStep) + intStepMid; //The new slider value based on putting the slider into the centre of the column
$(this).find('.cSlider').slider('option', 'value', intNewVal);
}
});
}
catch (err) {
if (debug == true) {
txt = "There was an error on this page.\n\n";
txt += "Error description: " + err.message + "\n\n";
txt += "Click OK to continue.\n\n";
alert(txt);
}
//Clean up
$('.cCell').show();
$('.cSliderCell').remove();
}
}
function setSliderPos(intCurrRow) {
//Set slider position if question already answered used on image slider
var intAns = $('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').eq(intCurrRow).find('.cRadio:checked').length;
if (intAns != 0) {
//Question Answered set slider
var intPosAns = $('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').eq(0).find('.cRadio').length;
var radioButtons = $('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').eq(intCurrRow).find('.cRadio');
var intAnsIndex = radioButtons.index(radioButtons.filter(':checked')) + 1;
var intScore = parseInt(((99 / intPosAns) * intAnsIndex) - ((99 / intPosAns) / 2));
$('.cImgSlider').slider('value', intScore);
myVar = setTimeout(function () {
$('.cSliderImgBox').html($('.cCellHeader').eq(intAnsIndex).html());
$('.cSliderImgBox').find('img').css('width', '100%');
}, 150);
}
else {
$('.cImgSlider').slider('value', 50);
}
}
function ColNegPos(intScaleValue) {
//Return colour code based on 10 point scale ranging Red to Green
if (intScaleValue < 5) {
//Set red scaling
red = 255;
green = (intScaleValue - 1) * 51;
blue = 0;
return (rgbToHex(red, green, blue));
}
if (intScaleValue == 5) {
//Set to Yellow
red = 255;
green = 255;
blue = 0;
return (rgbToHex(red, green, blue));
}
if (intScaleValue > 5) {
//Set green scaling
red = ((10 - intScaleValue) * 55);
green = 255;
blue = 0;
return (rgbToHex(red, green, blue));
}
}
function ColPosNeg(intScaleValue) {
//Return colour code based on 10 point scale ranging Red to Green
if (intScaleValue > 5) {
//Set red scaling
red = 255;
green = (10 - intScaleValue) * 51;
blue = 0;
return (rgbToHex(red, green, blue));
}
if (intScaleValue == 5) {
//Set to Yellow
red = 255;
green = 255;
blue = 0;
return (rgbToHex(red, green, blue));
}
if (intScaleValue < 5) {
//Set green scaling
red = ((intScaleValue) * 55);
green = 255;
blue = 0;
return (rgbToHex(red, green, blue));
}
}
function rgbToHex(R, G, B) { return toHex(R) + toHex(G) + toHex(B) }
function toHex(n) {
n = parseInt(n, 10);
if (isNaN(n)) return "00";
n = Math.max(0, Math.min(n, 255));
return "0123456789ABCDEF".charAt((n - n % 16) / 16) + "0123456789ABCDEF".charAt(n % 16);
}
function isEven(someNumber) {
return (someNumber % 2 == 0) ? true : false;
}
function btnMultiSetSingle(intRow) { //Function used to set previous answers on Singles
//Check if row answered
//Set background of buttons to unaswered
if (quickMode != true) {
$('.cBtnSingleGrid').css('background-color', btnColor).removeClass('btnChecked');
}
else {
$('.cBtnSingleGrid').css('background-color', 'transparent');
}
var intChecked = $('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').eq(intRow).find('.cRadio:checked').length;
if (intChecked != 0) {
var radioButtons = $('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').eq(intRow).find('.cRadio');
var selectedIndex = radioButtons.index(radioButtons.filter(':checked'));
$('.cBtnSingleGrid').eq(selectedIndex).css('background-color', btnColorClick).addClass('btnChecked');
}
}
function btnMultiSetMulti(intRow) { //Function used to set previous answers on multiples
//Check if row answered
//Set background of buttons to unaswered
if (quickMode != true) {
$('.cBtnMultiGrid').css('background-color', btnColor).removeClass('btnChecked');
}
else {
$('.cBtnMultiGrid').css('background-color', 'transparent');
}
var intChecked = $('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').eq(intRow).find('.cRadio:checked, .cCheck:checked').length;
if (intChecked != 0) {
var intBtnNum = 0;
$('.cRow,.cRowAlt,.cRowSelected,.cRowAltSelected').eq(intRow).find('.cRadio, .cCheck').each(function () {
if ($(this).prop('checked')) {
$('.cBtnMultiGrid').eq(intBtnNum).css('background-color', btnColorClick).addClass('btnChecked');
}
intBtnNum++;
});
}
}
function fncSetBtnBackground(strBkURL, strID) {
$(strID).each(function () {
$(this).find('img').eq(0).remove();
$(this).css('background', 'transparent url("' + strBkURL + '") no-repeat center center');
$(this).css('background-size', '95% 95%');
$(this).css('border', '0px transparent solid');
});
}
function fncSetGridBtnBackground(strID, strStyle, intMin, intMax) {
//Add validation for number of buttons
switch (strStyle) {
case 'Smiley1':
$(strID).eq(0).css('background', 'transparent url("Scripts/QuickMode/YellVSad.png") no-repeat center center');
$(strID).eq(1).css('background', 'transparent url("Scripts/QuickMode/YelSad.png") no-repeat center center');
$(strID).eq(2).css('background', 'transparent url("Scripts/QuickMode/YelNeutral.png") no-repeat center center');
$(strID).eq(3).css('background', 'transparent url("Scripts/QuickMode/YelHap.png") no-repeat center center');
$(strID).eq(4).css('background', 'transparent url("Scripts/QuickMode/YelVHap.png") no-repeat center center');
$(strID).css('background-size', '95% 95%');
$(strID).css('border', '0px transparent solid');
if (quickModeHideText == true) {
$(strID).css({ 'font-size': '0px', 'color': 'transparent' });
$(strID).find('span').css({ 'font-size': '0px', 'color': 'transparent' });
}
break;
case 'Smiley2':
$(strID).eq(0).css('background', 'transparent url("Scripts/QuickMode/3dVSad.jpg") no-repeat center center');
$(strID).eq(1).css('background', 'transparent url("Scripts/QuickMode/3dSad.jpg") no-repeat center center');
$(strID).eq(2).css('background', 'transparent url("Scripts/QuickMode/3dNeutral.jpg") no-repeat center center');
$(strID).eq(3).css('background', 'transparent url("Scripts/QuickMode/3dSmile.jpg") no-repeat center center');
$(strID).eq(4).css('background', 'transparent url("Scripts/QuickMode/3dVHappy.jpg") no-repeat center center');
$(strID).css('background-size', '95% 95%');
$(strID).css('border', '0px transparent solid');
if (quickModeHideText == true) {
$(strID).css({ 'font-size': '0px', 'color': 'transparent' });
$(strID).find('span').css({ 'font-size': '0px', 'color': 'transparent' });
}
break;
case 'Dice1':
$(strID).eq(0).css('background', 'transparent url("Scripts/QuickMode/BWdice1.jpg") no-repeat center center');
$(strID).eq(1).css('background', 'transparent url("Scripts/QuickMode/BWdice2.jpg") no-repeat center center');
$(strID).eq(2).css('background', 'transparent url("Scripts/QuickMode/BWdice3.jpg") no-repeat center center');
$(strID).eq(3).css('background', 'transparent url("Scripts/QuickMode/BWdice4.jpg") no-repeat center center');
$(strID).eq(4).css('background', 'transparent url("Scripts/QuickMode/BWdice5.jpg") no-repeat center center');
$(strID).eq(6).css('background', 'transparent url("Scripts/QuickMode/BWdice6.jpg") no-repeat center center');
$(strID).css('background-size', '95% 95%');
$(strID).css('border', '0px transparent solid');
if (quickModeHideText == true) {
$(strID).css({ 'font-size': '0px', 'color': 'transparent' });
$(strID).find('span').css({ 'font-size': '0px', 'color': 'transparent' });
}
break;
case 'Dice2':
$(strID).eq(0).css('background', 'transparent url("Scripts/QuickMode/BWdice1Style2.png") no-repeat center center');
$(strID).eq(1).css('background', 'transparent url("Scripts/QuickMode/BWdice2Style2.png") no-repeat center center');
$(strID).eq(2).css('background', 'transparent url("Scripts/QuickMode/BWdice3Style2.png") no-repeat center center');
$(strID).eq(3).css('background', 'transparent url("Scripts/QuickMode/BWdice4Style2.png") no-repeat center center');
$(strID).eq(4).css('background', 'transparent url("Scripts/QuickMode/BWdice5Style2.png") no-repeat center center');
$(strID).eq(6).css('background', 'transparent url("Scripts/QuickMode/BWdice6Style2.png") no-repeat center center');
$(strID).css('background-size', '95% 95%');
$(strID).css('border', '0px transparent solid');
if (quickModeHideText == true) {
$(strID).css({ 'font-size': '0px', 'color': 'transparent' });
$(strID).find('span').css({ 'font-size': '0px', 'color': 'transparent' });
}
break;
case 'Temp':
$(strID).eq(0).css('background', 'transparent url("Scripts/QuickMode/Therm1.png") no-repeat center center');
$(strID).eq(1).css('background', 'transparent url("Scripts/QuickMode/Therm2.png") no-repeat center center');
$(strID).eq(2).css('background', 'transparent url("Scripts/QuickMode/Therm3.png") no-repeat center center');
$(strID).eq(3).css('background', 'transparent url("Scripts/QuickMode/Therm4.png") no-repeat center center');
$(strID).eq(4).css('background', 'transparent url("Scripts/QuickMode/Therm5.png") no-repeat center center');
$(strID).eq(5).css('background', 'transparent url("Scripts/QuickMode/Therm6.png") no-repeat center center');
$(strID).eq(6).css('background', 'transparent url("Scripts/QuickMode/Therm7.png") no-repeat center center');
$(strID).eq(7).css('background', 'transparent url("Scripts/QuickMode/Therm8.png") no-repeat center center');
$(strID).css('background-size', '95% 95%');
$(strID).css('border', '0px transparent solid');
if (quickModeHideText == true) {
$(strID).css({ 'font-size': '0px', 'color': 'transparent' });
$(strID).find('span').css({ 'font-size': '0px', 'color': 'transparent' });
}
break;
case 'Postit':
$(strID).eq(0).css('background', 'transparent url("Scripts/QuickMode/PostitNegPlus.png") no-repeat center center');
$(strID).eq(1).css('background', 'transparent url("Scripts/QuickMode/PostitNeg.png") no-repeat center center');
$(strID).eq(2).css('background', 'transparent url("Scripts/QuickMode/PostitNeutral.png") no-repeat center center');
$(strID).eq(3).css('background', 'transparent url("Scripts/QuickMode/PostitPos.png") no-repeat center center');
$(strID).eq(4).css('background', 'transparent url("Scripts/QuickMode/PostitPosPlus.png") no-repeat center center');
$(strID).css('background-size', '95% 95%');
$(strID).css('border', '0px transparent solid');
if (quickModeHideText == true) {
$(strID).css({ 'font-size': '0px', 'color': 'transparent' });
$(strID).find('span').css({ 'font-size': '0px', 'color': 'transparent' });
}
break;
case 'Dot':
$(strID).eq(0).css('background', 'transparent url("Scripts/QuickMode/AverageScale1.png") no-repeat center center');
$(strID).eq(1).css('background', 'transparent url("Scripts/QuickMode/AverageScale2.png") no-repeat center center');
$(strID).eq(2).css('background', 'transparent url("Scripts/QuickMode/AverageScale3.png") no-repeat center center');
$(strID).eq(3).css('background', 'transparent url("Scripts/QuickMode/AverageScale4.png") no-repeat center center');
$(strID).eq(4).css('background', 'transparent url("Scripts/QuickMode/AverageScale5.png") no-repeat center center');
$(strID).css('background-size', '95% 95%');
$(strID).css('border', '0px transparent solid');
if (quickModeHideText == true) {
$(strID).css({ 'font-size': '0px', 'color': 'transparent' });
$(strID).find('span').css({ 'font-size': '0px', 'color': 'transparent' });
}
break;
case 'Star1':
$(strID).eq(0).css('background', 'transparent url("Scripts/QuickMode/1_Stars_200.png") no-repeat center center');
$(strID).eq(1).css('background', 'transparent url("Scripts/QuickMode/2_Stars_200.png") no-repeat center center');
$(strID).eq(2).css('background', 'transparent url("Scripts/QuickMode/3_Stars_200.png") no-repeat center center');
$(strID).eq(3).css('background', 'transparent url("Scripts/QuickMode/4_Stars_200.png") no-repeat center center');
$(strID).eq(4).css('background', 'transparent url("Scripts/QuickMode/5_Stars_200.png") no-repeat center center');
$(strID).css('background-size', '95% 95%');
$(strID).css('border', '0px transparent solid');
if (quickModeHideText == true) {
$(strID).css({ 'font-size': '0px', 'color': 'transparent' });
$(strID).find('span').css({ 'font-size': '0px', 'color': 'transparent' });
}
break;
case 'Star2':
$(strID).eq(0).css('background', 'transparent url("Scripts/QuickMode/1_BlueStar_200.png") no-repeat center center');
$(strID).eq(1).css('background', 'transparent url("Scripts/QuickMode/2_BlueStar_200.png") no-repeat center center');
$(strID).eq(2).css('background', 'transparent url("Scripts/QuickMode/3_BlueStar_200.png") no-repeat center center');
$(strID).eq(3).css('background', 'transparent url("Scripts/QuickMode/4_BlueStar_200.png") no-repeat center center');
$(strID).eq(4).css('background', 'transparent url("Scripts/QuickMode/5_BlueStar_200.png") no-repeat center center');
$(strID).css('background-size', '95% 95%');
$(strID).css('border', '0px transparent solid');
if (quickModeHideText == true) {
$(strID).css({ 'font-size': '0px', 'color': 'transparent' });
$(strID).find('span').css({ 'font-size': '0px', 'color': 'transparent' });
}
break;
case 'Numbers':
$(strID).eq(0).css('background', 'transparent url("Scripts/QuickMode/RoundNumberOne.png") no-repeat center center');
$(strID).eq(1).css('background', 'transparent url("Scripts/QuickMode/RoundNumberTwo.png") no-repeat center center');
$(strID).eq(2).css('background', 'transparent url("Scripts/QuickMode/RoundNumberThree.png") no-repeat center center');
$(strID).eq(3).css('background', 'transparent url("Scripts/QuickMode/RoundNumberFour.png") no-repeat center center');
$(strID).eq(4).css('background', 'transparent url("Scripts/QuickMode/RoundNumberFive.png") no-repeat center center');
$(strID).eq(5).css('background', 'transparent url("Scripts/QuickMode/RoundNumberSix.png") no-repeat center center');
$(strID).eq(6).css('background', 'transparent url("Scripts/QuickMode/RoundNumberSeven.png") no-repeat center center');
$(strID).eq(7).css('background', 'transparent url("Scripts/QuickMode/RoundNumberEight.png") no-repeat center center');
$(strID).eq(8).css('background', 'transparent url("Scripts/QuickMode/RoundNumberNine.png") no-repeat center center');
$(strID).css('background-size', '95% 95%');
$(strID).css('border', '0px transparent solid');
if (quickModeHideText == true) {
$(strID).css({ 'font-size': '0px', 'color': 'transparent' });
$(strID).find('span').css({ 'font-size': '0px', 'color': 'transparent' });
}
break;
}
}
function fncHideNext() {
if ($('#uniform-btnNext').length != 0) {
$('#uniform-btnNext').hide();
}
else {
$('#btnNext').hide();
}
}
function fncShowNext() {
if ($('#uniform-btnNext').length != 0) {
$('#uniform-btnNext').show();
}
else {
$('#btnNext').show();
}
}
function iQuestHelper(strMessage) {
var strHTML = '';
var strServer = $('#mi_server').val();
if (strServer == 'preview.miprocloud.net' || strServer == 'test.miprocloud.net') {
//Check if div exists
if ($('.iQuestHelper').length == 0) {
strHTML = '<div style="color: #008A2E"><strong>iQuest Helper:</strong><br></div>';
$('.logo2Container').before(strHTML);
}
//Add Message
strHTML = '<p>' + strMessage + '</p>';
$('.iQuestHelper').append(strHTML);
}
}
function mobileIt() { //Remove padding for mobile devices
//If a mobile browser is detected paddding is removed and the main container is centered
if (isMobile) {
$('html').css('padding-left', '1%');
$('html').css('padding-right', '1%');
$('mainContainer').css('margin-left', 'auto');
$('mainContainer').css('margin-right', 'auto');
}
}
/*
* jQuery UI Touch Punch 0.2.2
*
* Copyright 2011, Dave Furfero
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* Depends:
* jquery.ui.widget.js
* jquery.ui.mouse.js
*/
(function (b) { b.support.touch = "ontouchend" in document; if (!b.support.touch) { return; } var c = b.ui.mouse.prototype, e = c._mouseInit, a; function d(g, h) { if (g.originalEvent.touches.length > 1) { return; } g.preventDefault(); var i = g.originalEvent.changedTouches[0], f = document.createEvent("MouseEvents"); f.initMouseEvent(h, true, true, window, 1, i.screenX, i.screenY, i.clientX, i.clientY, false, false, false, false, 0, null); g.target.dispatchEvent(f); } c._touchStart = function (g) { var f = this; if (a || !f._mouseCapture(g.originalEvent.changedTouches[0])) { return; } a = true; f._touchMoved = false; d(g, "mouseover"); d(g, "mousemove"); d(g, "mousedown"); }; c._touchMove = function (f) { if (!a) { return; } this._touchMoved = true; d(f, "mousemove"); }; c._touchEnd = function (f) { if (!a) { return; } d(f, "mouseup"); d(f, "mouseout"); if (!this._touchMoved) { d(f, "click"); } a = false; }; c._mouseInit = function () { var f = this; f.element.on("touchstart", b.proxy(f, "_touchStart")).on("touchmove", b.proxy(f, "_touchMove")).on("touchend", b.proxy(f, "_touchEnd")); e.call(f); }; })(jQuery);