1/** 2 * @file 3 * Fire callbacks for media query breakpoints 4 * 5 * To use this file enable the OnMediaQuery.js polyfill in your subthemes 6 * appearance settings - this will load the required plugin and this file. 7 * 8 * This allows you to write context (media query) specific JS without hard 9 * coding the media queries, aka like matchMedia. Each context matches the 10 * media queries you set in theme settings (by adding the font-family 11 * declarations to the responsive layout CSS). 12 * 13 * SEE: https://github.com/JoshBarr/js-media-queries (really, go look, lots of 14 * useful documentation available). 15 * 16 * IMPORTANT: do not rename or move this file, or change the directory name! 17 */ 18 19 20 21// set initial state 22 23/** 24var $theStatus = 'off'; 25 26jQuery("#primary-menu-bar ul.menu li.first").click( 27 function () { 28 if ($theStatus == 'on') { 29 30 //menu hidden, show 31 jQuery('#primary-menu-bar ul.menu li:not(:first)').hide('slow'); 32 $theStatus = 'off'; 33 } else { 34 35 //menu visible, hide 36 jQuery('#primary-menu-bar ul.menu li:not(:first)').show('slow'); 37 $theStatus = 'on'; 38 } 39 } 40); 41 */ 42jQuery.fn.exists = function(){return this.length>0;} 43 44 45var $window = jQuery(window); 46var $widthChecked = false; 47var $theArray = []; 48var $contentWidth = 0; 49 50jQuery(document).ready(function() { 51 52 //give nav nice ID 53 jQuery('.primary-menu:not(#newmenu)').attr('id','mainMenu'); 54 55 //initial check 56 checkWidth(); 57 58 //subsequent checks on resize 59 jQuery(window).resize(checkWidth); 60}); 61 62function checkWidth() { 63 64 var $windowsize = $window.width(); 65 var $navwidth = 0; 66 var $doDropdown = false; 67 var $dropWidth = 0; 68 var $dropStr = ''; 69 70 //remove drop down (will be added below if necessary) 71 jQuery('#drop').remove(); 72 73 if (!$widthChecked) { 74 75 //initialize array with <li> sizes and HTML 76 jQuery('#mainMenu li').each(function(index) { 77 78 if (index>0) { 79 //skip first hidden element 80 $navwidth += jQuery(this).width(); 81 82 //2D array 83 $theArray[index] = []; 84 85 $theArray[index][0] = jQuery(this).width(); //width 86 $theArray[index][1] = jQuery(this).clone().wrap('<p>').parent().html(); //HTML 87 } 88 89 }); 90 91 if ($navwidth-10 >
91 $windowsize) { 92 //nav exceeds screen width, this gives us the min width of the elements 93 //now that we know the widths and have our array set, exit 94 $widthChecked = true; 95 $contentWidth = $navwidth; 96 } 97 } 98 99 if ($widthChecked) { 100 101 $navwidth = 0; 102 103 if ($contentWidth > $windowsize) { 104 //if we alreayd have a "more" button, add the button's width (106) to nav width in calculations (so it doesn't get cut off) 105 $dropWidth = 106; 106 } 107 108 //remove all nav items (will be added below if necessary) 109 jQuery('#mainMenu li').remove(); 110 111 for (var $i = 1; $i < $theArray.length; $i++) { 112 113 $navwidth += $theArray[$i][0]; 114 115 if (($navwidth-10+$dropWidth) > $windowsize) { 116 117 //we have exceeded window width, add this and future elements to "more" dropdown 118 $doDropdown = true; 119 120 $dropStr += $theArray[$i][1]; 121 } else { 122 123 //haven't exceeded widnow width, add to main nav 124 jQuery('#mainMenu').append($theArray[$i][1]); 125 } 126 } 127 128 } 129 130 if ($doDropdown) { 131 132 //create "more" button 133 jQuery('#mainMenu').append('<li id="more-menu" style="background-color:#BC9182;"><a href="javascript:;" style="color:#ffffff;">MORE <img src="/sites/default/files/down_arrows.png" /></a></li>'); 134 135 //create "more" dropdown 136 jQuery('.primary-menu-wrapper').append('<div id="drop" style="display:none; position:absolute; right:0px; background-color:#BC9182; width:200px; text-align:center; z-index:1000;"><ul>' + $dropStr + '</ul></div>'); 137 138 //style dropdown <li>s 139 jQuery('#drop').find('a').css('color','#ffffff'); 140 jQuery('#drop').find('li').css('display','block'); 141 142 //browser check 143 var $ua = navigator.userAgent; 144 var $event = ($ua.match(/iPad/i)) ? "touchstart" : "click"; 145 146 //if iPad/iPhone/iPod, use 'touchstart', else use 'click' 147 jQuery("#more-menu").bind($event, 148 function () { 149 //on click toggle up/down 150 jQuery('#drop').slideToggle('slow'); 151 jQuery("#more-menu").focus(); 152 } 153 ); 154 155 jQuery("#more-menu").focusout(function() { 156 jQuery('#drop').slideUp('slow'); 157 }); 158 159 160 } else { 161 162 //we do not exceed window width, hide "more" button 163 jQuery('#more-menu').remove(); 164 } 165 166 if(!jQuery('#more-menu').is(':visible')) { 167 //toggle dropdown 168 jQuery('#drop').remove(); 169 } 170 171} 172 173if (!jQuery('#newmenu').exists()) { 174 175 var theMenu = jQuery('.primary-menu'); 176 177 theMenu.clone().attr('id', 'newmenu').insertBefore(theMenu); 178 179 jQuery('#newmenu').hide(); 180 181 jQuery('#newmenu .menu-776').insertAfter('#newmenu .menu-539'); 182 jQuery('#newmenu .menu-776 a').text('QUESTIONS'); 183 jQuery('#newmenu .menu-528').insertAfter('#newmenu .menu-776'); 184 185 jQuery('<li class="menu-000" id="moreLink"><a title="" href="javascript:;" >MORE...</a></li>').insertAfter('#newmenu .menu-528'); 186 187 jQuery('<li class="menu-000" style="display: none;" id="lessLink"><a title="" href="javascript:;" >LESS...</a></li>').insertAfter('#newmenu .menu-427'); 188 189 jQuery("#newmenu .menu-218").bind('touchstart', 190 function () { 191 192 if(!jQuery('#newmenu .menu-539').is(':visible')) { 193 jQuery('#newmenu .menu-539').show(); 194 jQuery('#newmenu .menu-776').show(); 195 jQuery('#newmenu .menu-528').show(); 196 197 jQuery('#moreLink').show(); 198 199 } else { 200 jQuery('#newmenu .menu-539').hide(); 201 jQuery('#newmenu .menu-776').hide(); 202 jQuery('#newmenu .menu-528').hide(); 203 jQuery('#newmenu .menu-580').hide(); 204 jQuery('#newmenu .menu-598').hide(); 205 jQuery('#newmenu .menu-597').hide(); 206 jQuery('#newmenu .menu-427').hide(); 207 208 jQuery('#moreLink').hide(); 209 jQuery('#lessLink').hide(); 210 211 } 212 } 213 ); 214 215 jQuery("#moreLink").bind('touchstart', 216 217 function () { 218 jQuery("#newmenu li:not(#newmenu .menu-218)").show(); 219 jQuery(this).hide(); 220 221 jQuery('#lessLink').show(); 222 223 return false; 224 } 225 226 ); 227 228 jQuery("#lessLink").bind('touchstart', 229 230 function () { 231 jQuery("#newmenu li:not(#newmenu .menu-218)").hide(); 232 jQuery(this).hide(); 233 234 jQuery('#newmenu .menu-539').show(); 235 jQuery('#newmenu .menu-776').show(); 236 jQuery('#newmenu .menu-528').show(); 237 238 jQuery('#moreLink').show(); 239 240 return false; 241 242 } 243 ); 244 245} 246 247var queries = [ 248 // README! The following are examples, remove what you don't need! 249 250 251 // Smartphone 252 { 253 context: ['smartphone_portrait', 'smartphone_landscape'], 254 call_in_each_context: false, 255 callback: function() { 256 // Debug 257 258 jQuery('.primary-menu').hide(); 259 jQuery('#newmenu').show(); 260 261 jQuery('#newmenu li:not(#newmenu .menu-218)').hide(); 262 } 263 }, 264 // portrait only 265 { 266 context: 'smartphone_portrait', 267 callback: function() { 268 // Debug 269 270 //jQuery('#columns').appendTo('primary-menu-bar'); 271 272 jQuery('.primary-menu').hide(); 273 jQuery('#newmenu').show(); 274 275 jQuery('#newmenu li:not(#newmenu .menu-218)').hide(); 276 } 277 }, 278 // landscape only 279 { 280 context: 'smartphone_landscape', 281 callback: function() { 282 // Debug 283 284 jQuery('.primary-menu').hide(); 285 jQuery('#newmenu').show(); 286 287 jQuery('#newmenu li:not(#newmenu .menu-218)').hide(); 288 } 289 }, 290 291 292 // Tablet 293 { 294 context: ['tablet_portrait', 'tablet_landscape'], 295 call_in_each_context: false, 296 callback: function() { 297 // Debug 298 299 jQuery('.primary-menu').show(); 300 jQuery('#newmenu').hide(); 301 302 303 } 304 }, 305 // portrait only 306 { 307 context: 'tablet_portrait', 308 callback: function() { 309 // Debug 310 311 jQuery('.primary-menu').show(); 312 jQuery('#newmenu').hide(); 313 314 315 } 316 }, 317 // landscape only 318 { 319 context: 'tablet_landscape', 320 callback: function() { 321 // Debug 322 jQuery('.primary-menu').show(); 323 jQuery('#newmenu').hide(); 324 325 326 } 327 }, 328 329 330 // Standard desktop context 331 { 332 context: 'standard', 333 callback: function() { 334 // Debug 335 jQuery('.primary-menu').show(); 336 jQuery('#newmenu').hide(); 337 338 } 339 }, 340]; 341 342// Go! 343MQ.init(queries); 344;
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.