Skip to main content
/*Natural Language Form*/ (function () { var $nlForm = $('#nl-form'), baseurl = './', $programUndergrad = $('.program-undergrad'), $programGrad = $('.program-grad'), $courseUndergrad = $('.course-undergrad'), $courseGrad = $('.course-grad'), $inputContainer = $('.input-container'), $errorMsg = $('.error'), $submit = $('#submit-nl-form'), $courseInterest = $('#course-interest'), $programInterest = $('#program-interest'), $programEnd = $('#program-end'); /*Show and hide styled inputs, update natural language statement*/ $inputContainer.click(function () { var $target = $(this); var $targetSelect = $(this).find('select'); var $styledSelect = $(this).find('.newSelect'); $inputContainer.removeClass('active'); $target.addClass('active'); $targetSelect.change(function () { var $inputValue = $(this).val(); var $inputText = $(this).find('option:selected').text(); var $placeholder = $target.find('.placeholder'); $target.removeClass('active'); $placeholder.html($inputText).parent().addClass('selection-made'); if($('#interest .placeholder').text() == 'taking graduate online courses' || $('#interest .placeholder').text() == 'taking undergraduate online courses') { $submit.text('Show me courses'); $courseInterest.css('display','inline'); $programInterest.css('display','none'); $programEnd.css('display','none'); } else if($('#interest .placeholder').text() == 'Professional Development') { $submit.text('Show me courses and certificates'); $courseInterest.css('display','none'); $programInterest.css('display','inline'); $programEnd.css('display','none'); } else { $submit.text('Show me programs'); $courseInterest.css('display','none'); $programInterest.css('display','inline'); $programEnd.css('display','inline'); } }); $styledSelect.click(function () { var $target = $(this); setTimeout(function () { $target.parent().parent().removeClass('active'); }, 10); }); }); /* Create the new select*/ var $select = $('.fancy-select'); $select.wrap('
'); $('.newSelect').prepend('
'); /* Populate the new select*/ var $selectOption = ""; var $target = ""; var $optionContents = ""; var $optionValue = ""; var $optionClass = ""; $select.each(function () { $selectOption = $(this).find('option'); $target = $(this).parent().find('.newOptions'); $selectOption.each(function () { $optionContents = $(this).html(); $optionValue = $(this).attr('value'); $optionClass = $(this).attr('class'); $target.append('
' + $optionContents + '
'); }); }); /* New select functionality*/ var $newSelect = $('.newSelect'); var $newOption = $('.newOption'); /* update based on selection */ $newOption.on('click', function () { var $optionInUse = $(this), $siblingOptions = $(this).parent().find('.newOption'), $newValue = $(this).attr('data-value'), $selectOption = $(this).parent().parent().find('select option'); /*style selected option*/ $siblingOptions.removeClass('selected'); $optionInUse.addClass('selected'); $errorMsg.fadeOut(); /* update the actual input*/ var $type = ""; var $area = ""; var $optionValue = ""; $selectOption.each(function () { $optionValue = $(this).attr('value'); if ($newValue == $optionValue) { $(this).prop('selected', true); $type = $('#interest .newSelect .newOptions .selected').attr('data-value'); $area = $('#area .newSelect .newOptions .selected').attr('data-value'); console.log($type); } else { $(this).prop('selected', false); } }); /* change the hidden select element*/ $newSelect.click(function () { var $target = $(this); $target.parent().find('select').change(); }); /* build the URL for PowerED*/ if ($type == 'https://powered.athabascau.ca') { /*update base url to PowerED*/ $submit.attr('href', 'https://powered.athabascau.ca/'); /*build URL on area selection*/ if($area) { $submit.attr('href', 'https://powered.athabascau.ca/' + $area ); } /* build the URL for AU Courses and Programs*/ } else { /*update base url to match dropdown selections*/ $submit.attr('href', baseurl + $type ); if ($type && $area) { $submit.attr('href', baseurl + $area ); } if ($type && $area) { $submit.attr('href', baseurl + $type + '/' + $area ); } } /* show undergraduate course programs */ if($type == 'programs/index.html?/undergraduate') { $('.newOptions').show(); $('.program-undergrad').show(); $('.program-grad').hide(); $('.course-undergrad').hide(); $('.course-grad').hide(); $('.pro-developement').hide(); /* show graduate course programs */ } else if ($type == 'programs/index.html?/graduate') { $('.newOptions').show(); $('.program-grad').show(); $('.program-undergrad').hide(); $('.course-undergrad').hide(); $('.course-grad').hide(); $('.pro-developement').hide(); /* show graduate course options */ } else if ($type == 'course/index.html?/graduate') { $('.newOptions').show(); $('.course-grad').show(); $('.course-undergrad').hide(); $('.program-grad').hide(); $('.program-undergrad').hide(); $('.pro-developement').hide(); /* show undergraduate course options */ } else if ($type == 'course/index.html?/undergraduate') { $('.newOptions').show(); $('.course-undergrad').show(); $('.course-grad').hide(); $('.program-undergrad').hide(); $('.program-grad').hide(); $('.pro-developement').hide(); /* Show Professional Development options */ } else if ($type == 'https://powered.athabascau.ca') { $('.newOptions').show(); $('.pro-developement').show(); $('.program-undergrad').hide(); $('.program-grad').hide(); $('.course-undergrad').hide(); $('.course-grad').hide(); } /*remove specific area placeholder when new interest and/or level is selected */ $('#interest .placeholder, #level .placeholder').click(function () { $('#area .placeholder').text(''); $('#area').removeClass('selection-made'); }); }); /*hide select box when clicked outside of it*/ $(document).on('click', function(e) { var $newSelect = $('.input-container'); if (!$newSelect.is(e.target) && $newSelect.has(e.target).length === 0) { $newSelect.removeClass('active'); } }); /*submit form if all selections are filled*/ $submit.on('click', function(e) { $('.placeholder').each(function() { var $selection = $(this).text(); if($selection == '' && $(this).parent().css('display') !== 'none') { e.preventDefault(); $errorMsg.fadeIn(); } else { return true; } }); }); }());