1/* 2 Breakpoints.js 3 version 1.0 4 5 Creates handy events for your responsive design breakpoints 6 7 Copyright 2011 XOXCO, Inc 8 https://xoxco.com/ 9 10 Documentation for this plugin lives here: 11 https://xoxco.com/projects/code/breakpoints 12 13 Licensed under the MIT license: 14 https://www.opensource.org/licenses/mit-license.php 15 16*/ 17(function($) { 18 19 var lastSize = 0; 20 var interval = null; 21 22 $.fn.resetBreakpoints = function() { 23 $(window).unbind('resize'); 24 if (interval) { 25 clearInterval(interval); 26 } 27 lastSize = 0; 28 }; 29 30 $.fn.setBreakpoints = function(settings) { 31 var options = jQuery.extend({ 32 distinct: true, 33 breakpoints: new Array(320,480,768,1024) 34 },settings); 35 36 37 interval = setInterval(function() { 38 39 var w = $(window).width(); 40 var done = false; 41 42 for (var bp in options.breakpoints.sort(function(a,b) { return (b-a) })) { 43 44 // fire onEnter when a browser expands into a new breakpoint 45 // if in distinct mode, remove all other breakpoints first. 46 if (!done && w >= options.breakpoints[bp] && lastSize < options.breakpoints[bp]) { 47 if (options.distinct) { 48 for (var x in options.breakpoints.sort(function(a,b) { return (b-a) })) { 49 if ($('body').hasClass('breakpoint-' + options.breakpoints[x])) { 50 $('body').removeClass('breakpoint-' + options.breakpoints[x]); 51 $(window).trigger('exitBreakpoint' + options.breakpoints[x]); 52 } 53 } 54 done = true; 55 } 56 $('body').addClass('breakpoint-' + options.breakpoints[bp]); 57 $(window).trigger('enterBreakpoint' + options.breakpoints[bp]); 58 59 } 60 61 // fire onExit when browser contracts out of a larger breakpoint 62 if (w < options.breakpoints[bp] && lastSize >= options.breakpoints[bp]) { 63 $('body').removeClass('breakpoint-' + options.breakpoints[bp]); 64 $(window).trigger('exitBreakpoint' + options.breakpoints[bp]); 65 66 } 67 68 // if in distinct mode, fire onEnter when browser contracts into a smaller breakpoint 69 if ( 70 options.distinct && // only one breakpoint at a time 71 w >= options.breakpoints[bp] && // and we are in this one 72 w < options.breakpoints[bp-1] && // and smaller than the bigger one 73 lastSize > w && // and we contracted 74 lastSize >0 && // and this is not the first time 75 !$('body').hasClass('breakpoint-' + options.breakpoints[bp]) // and we aren't already in this breakpoint 76 ) { 77 $('body').addClass('breakpoint-' + options.breakpoints[bp]); 78 $(window).trigger('enterBreakpoint' + options.breakpoints[bp]); 79 80 } 81 } 82 83 // set up for next call 84 if (lastSize != w) { 85 lastSize = w; 86 } 87 },250); 88 }; 89 90})(jQuery);
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.