1//version: 1.0 2 3jQuery(function($) { 4 5 $(document).ready(function() { 6 detectSearchView(); 7 setupDashboardCarouselHeight(); 8 modifyResourcePickerOptions(); 9 setupGameSelection(); 10 // Dashboard scrolling 11 $('.sf-results-overlay .sf-link-title a, .wpgb-results-list .item-title a').hover(startMarquee, stopMarquee); 12 }); // end document ready 13 14 /** 15 * Modify or detect changes in the dashboard 16 * view dropdown menu 17 */ 18 function detectSearchView() { 19 // if($('select[name="search_view_dropdown"]').length) { 20 if($('.search-view-dropdown-wrapper .select-view-icons').length) { 21 22 // get the current setting 23 // var search_view_dropdown = $('select[name="search_view_dropdown"]'); 24 var select_view_icons = $('.search-view-dropdown-wrapper .select-view-icons .select-view-icon'); 25 26 // var search_view_dropdown_value = $(search_view_dropdown).val(); 27 28 // see if there's a get value and set the dropdown value 29 var urlParams = new URLSearchParams(window.location.search); 30 if(urlParams.has('_dashboard_view')) { 31 if(urlParams.get('_dashboard_view') == 'thumbnails') { 32 // $(search_view_dropdown).val('thumbnails'); 33 $('.select-view-icon').removeClass('selected_view'); 34 $('.select-grid-icon').addClass('selected_view'); 35 } 36 if(urlParams.get('_dashboard_view') == 'carousel') { 37 // $(search_view_dropdown).val('carousel'); 38 $('.select-view-icon').removeClass('selected_view'); 39 $('.select-carousel-icon').addClass('selected_view'); 40 setTimeout(function(){ 41 $('html, body').animate({ 42 scrollTop: ($('#search-results').first().offset().top - 242) 43 }, 500); 44 },2000); 45 46 } 47 } 48 49 // $(search_view_dropdown).on('change', function() { 50 // var search_view_dropdown_value = $(search_view_dropdown).val();
51 // if ('URLSearchParams' in window) { 52 // var searchParams = new URLSearchParams(window.location.search); 53 // searchParams.set("_dashboard_view", search_view_dropdown_value); 54 // window.location.search = searchParams.toString(); 55 // } 56 // }); 57 $(select_view_icons).on('click', function() { 58 if($(this).hasClass('select-grid-icon')) { 59 var search_view_dropdown_value = 'thumbnails'; 60 } else if($(this).hasClass('select-carousel-icon')) { 61 var search_view_dropdown_value = 'carousel'; 62 } 63 // var search_view_dropdown_value = $(search_view_dropdown).val(); 64 if ('URLSearchParams' in window) { 65 var searchParams = new URLSearchParams(window.location.search); 66 searchParams.set("_dashboard_view", search_view_dropdown_value); 67 window.location.search = searchParams.toString(); 68 } 69 70 }); 71 } 72 } 73 /** 74 * Initial function to set up the carousel resizing 75 */ 76 function setupDashboardCarouselHeight() { 77 if($('#dslp-wpgb-carousel-thumbs').length){ 78 // add a stylesheet 79 $(window).on('resize', function() { 80 var resize_timeout = setTimeout(function() { 81 resizeDashboardCarousel(); 82 clearTimeout(resize_timeout); 83 }, 500); 84 }); // end window resize 85 $(window).trigger('resize'); 86 87 // // set up the click handlers 88 // $(document).on('click', '.prev-resource', function(e) { 89 // e.preventDefault(); 90 // $('button.wpgb-prev-button')[0].click(); 91 // carouselButtonsStatus(); 92 // }); 93 // $(document).on('click', '.next-resource', function(e) { 94 // e.preventDefault(); 95 // $('button.wpgb-next-button')[0].click(); 96 // carouselButtonsStatus(); 97 // }); 98 99 // carouselButtonsStatus(); 100 101 // function carouselButtonsStatus() { 102 // if($('button.wpgb-prev-button').prop('disabled')) { 103 // $('.prev-resource').prop('disabled', true); 104 // } else { 105 // $('.prev-resource').prop('disabled', false); 106 // } 107 // if($('button.wpgb-next-button').prop('disabled')) { 108 // $('.next-resource').prop('disabled', true); 109 // } else { 110 // $('.next-resource').prop('disabled', false); 111 // } 112 // } 113 } 114 115 } 116 117 function resizeDashboardCarousel() { 118 119 var viewportHeight = $(window).height(); 120 var dslpDashboardWidth = $('#dslp-lists-dashboard').width(); 121 var headerHeight = parseInt($('#header').outerHeight(true)) || 0; 122 var adminBarHeight = parseInt($('#wpadminbar').outerHeight(true)) || 0; 123 // var pageWrapHeight = $('#page-wrap').height(); 124 // if((adminBarHeight + headerHeight + pageWrapHeight) > viewportHeight) { 125 // var dslpListsDashboardHeaderHeight = $('#dslp-lists-dashboard-header').outerHeight(true); 126 var dslpCarouselThumbsHeight = $('#dslp-wpgb-carousel-thumbs').outerHeight(true); 127 128 var combined = adminBarHeight + headerHeight + dslpCarouselThumbsHeight + 200; 129 var coverHeightWidth = viewportHeight - combined; 130 131 if(coverHeightWidth > 800) { 132 coverHeightWidth = 800; 133 } 134 if(coverHeightWidth > dslpDashboardWidth) { 135 coverHeightWidth = dslpDashboardWidth; 136 } 137 $('.dslp-wpgb-lists-dashboard .search-container .selected-cover').css('width', coverHeightWidth + 'px'); 138 $('.dslp-wpgb-lists-dashboard .search-container .selected-cover').css('height', coverHeightWidth + 'px'); 139 140 // $('.dslp-wpgb-lists-dashboard .search-container .selected-cover .dslp-lists-launcher .dslp-lists-popup').css('margin-left', (coverHeightWidth - 180) + 'px'); 141 142 143 var style = '<style id="dslp-wpgb-carousel-styles">.dslp-wpgb-lists-dashboard .search-container .selected-cover .dslp-lists-launcher .dslp-lists-popup { margin-left: ' + (coverHeightWidth - 180) + 'px; }</style>'; 144 var el = $( '#dslp-wpgb-carousel-styles' ); // look for a matching style element that might already be there 145 146 // add the style element into the DOM or replace the matching style element that is already there 147 if ( el.length ) { 148 el.replaceWith( style ); // style element already exists, so replace it 149 } else { 150 $( 'head' ).append( style ); // style element doesn't exist so add it 151 } 152 153 } 154 155 /** 156 * Scrolling for long titles on the dashboard 157 */ 158 function startMarquee() { 159 var menuItemWidth = $(this).width(); 160 var listItemWidth = $(this).parent().width(); 161 162 163 if (menuItemWidth > listItemWidth) { 164 var scrollDistance = menuItemWidth - listItemWidth; 165 var listItem = $(this).parent(); 166 listItem.stop(); 167 listItem.addClass('scrolling'); 168 listItem.animate({ 169 scrollLeft: scrollDistance 170 }, scrollDistance * 15, 'linear'); 171 } 172 } 173 /** 174 * Scrolling for long titles on the dashboard 175 */ 176 function stopMarquee() { 177 var listItem = $(this).parent(); 178 listItem.stop(); 179 listItem.animate({ 180 scrollLeft: 0 181 }, 'medium', 'swing', function() { 182 listItem.removeClass('scrolling'); 183 }); 184 } 185 186 /** 187 * Change items for the resource picker 188 */ 189 function modifyResourcePickerOptions() { 190 if($('#dslp-resource-picker-form').length) { 191 $(document).on('change', '.speech_position input[type="checkbox"]', function(e) { 192 if($(this).prop("checked") == true && $(this).attr('value') == 'Any' ) { 193 $('.speech_position input[type="checkbox"]').prop("checked", false); 194 $('.speech_position .gfield_checkbox .gchoice:first-child .gfield-choice-input').prop("checked", true); 195 196 } else { 197 $('.speech_position .gfield_checkbox .gchoice:first-child .gfield-choice-input').prop("checked", false); 198 } 199 200 }); 201 $(document).on('change', '.grade_levels input[type="checkbox"]', function(e) { 202 if($(this).prop("checked") == true && $(this).attr('value') == 'Any' ) { 203 $('.grade_levels input[type="checkbox"]').prop("checked", false); 204 $('.grade_levels .gfield_checkbox .gchoice:first-child .gfield-choice-input').prop("checked", true); 205 206 } else { 207 $('.grade_levels .gfield_checkbox .gchoice:first-child .gfield-choice-input').prop("checked", false); 208 } 209 210 }); 211 } 212 213 // submit the form on the last page if there are less than two choices 214 $(document).on('gform_page_loaded', function(event, form_id, current_page){ 215 // code to be trigger when next/previous page is loaded 216 if(current_page == '3') { 217 // get the number of children of the student motivations field 218 var student_motivations_choices = $('#input_1_7').children().length; 219 if(student_motivations_choices < 2) { 220 // submit the form 221 $('#gform_submit_button_1').trigger('click'); 222 } 223 } 224 }); 225 226 } 227 228 /** 229 * Change options related to the game selection shortcode 230 */ 231 function setupGameSelection() { 232 if($('#dslp-wpgb-lists-dashboard-game-selection').length) { 233 if (!window.location.toString().includes("game-selection")) { 234 235 setTimeout(function(){ 236 // get the current viewport height 237 var headerHeight = parseInt($('#header').outerHeight(true)) || 0; 238 var adminBarHeight = parseInt($('#wpadminbar').outerHeight(true)) || 0; 239 240 var combined = headerHeight + adminBarHeight; 241 242 $('html, body').animate({ 243 scrollTop: ($('#dslp-wpgb-lists-dashboard-game-selection').first().offset().top - combined) 244 }, 500); 245 },500); 246 247 } 248 } 249 } 250});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.