// If any of these elements exist, we will watch for page content in them to load var pageContentWrappersArray = [ '#course_home_content', // Course Front Page '#wiki_page_show', // Content page '#discussion_topic', // Discussions page '#course_syllabus', // Syllabus page '#assignment_show', // Assignments page '#wiki_page_revisions' ]; // Commands to run after the page content has loaded function afterPageContentLoaded() { 'use strict'; console.log('Running code'); // Place the code you want to run here // CUSTOM ACCORDION // /* added by rbenal: there are two accordion controls per page * id: custom_accordion1 id: custom_accordion2 */ if ($('#custom_accordion1').length > 0) { // Wrap h3 elements with a link after the fact so it isn't confusing to mobile app users $("#custom_accordion1 h3").each(function () { $(this).contents().wrap(''); }); // Create the accordion $("#custom_accordion1").accordion({header: 'h3'}); $("#custom_accordion1").css("height","initial"); $("#custom_accordion1").find(".ui-accordion-content").css("height","initial"); } // added by rbenal if ($('#custom_accordion2').length > 0) { // Wrap h3 elements with a link after the fact so it isn't confusing to mobile app users $("#custom_accordion2 h3").each(function () { $(this).contents().wrap(''); }); // Create the accordion $("#custom_accordion2").accordion({header: 'h3'}); $("#custom_accordion2").css("height","initial"); $("#custom_accordion2").find(".ui-accordion-content").css("height","initial"); } /* added by rbenal. Popover control, right,left,top,bottom, no limits! */ $(".cel_popover_right").attr("data-tooltip",'{"tooltipClass":"popover popover-padded", "position":"right"}'); $(".cel_popover_left").attr("data-tooltip",'{"tooltipClass":"popover popover-padded", "position":"left"}'); $(".cel_popover_top").attr("data-tooltip",'{"tooltipClass":"popover popover-padded", "position":"top"}'); $(".cel_popover_bottom").attr("data-tooltip",'{"tooltipClass":"popover popover-padded", "position":"bottom"}'); /* added by rbenal. Bootsrap TABS control, no limits but have to add class CEL_TAB to all TABS */ $(".cel_tab").tabs(); $("#myCarousel").attr("data-ride","carousel"); var $lis=$(".carousel-indicators").find("li"); $.each($lis,function(index,liHtml){ $(liHtml).attr("data-target","#myCarousel"); $(liHtml).attr("data-slide-to",index); if(index==0) $(liHtml).addClass("active"); }); $(".left").attr("data-slide","prev"); $(".right").attr("data-slide","next"); // if($('#myCarousel').length>0){ // document.write(''); // document.write(''); // $('#myCarousel').carousel(); // } } // Function that will check to see if the page content has loaded yet function pageContentCheck(pageContentWrapperElement) { 'use strict'; var contentLoaded = false; // Content Pages if ($('.show-content').length > 0 && $('.show-content').children().length > 0) { contentLoaded = true; // Discussions } else if ($('#discussion_topic').length > 0 && $('.user_content').text().length > 0) { contentLoaded = true; // Assignment (Teacher View) } else if ($('#assignment_show .teacher-version').length > 0) { contentLoaded = true; } else if ($('#assignment_show .student-version').length > 0) { contentLoaded = true; } else if ($('#course_syllabus').length > 0) { contentLoaded = true; } if (contentLoaded) { console.log('Content has loaded'); afterPageContentLoaded(); } else { setTimeout(function () { console.log('Still no content, check again (' + pageContentWrapperElement + ')'); pageContentCheck(pageContentWrapperElement); }, 100); } } // Run the functions $(document).ready(function () { 'use strict'; // Get Current UserID var task, i; // Identify which page we are on and when the content has loaded for (i = 0; i <= pageContentWrappersArray.length; i++) { if ($(pageContentWrappersArray[i]).length > 0) { // console.log(pageContentWrappersArray[i] + ' Found'); pageContentCheck(pageContentWrappersArray[i]); break; } } });