1(function(root, $) { 2 var $doc = $(document); 3 var $win = $(window); 4 var $body = null; 5 6 var defaultBreakpoints = [{ 7 min: 0, 8 max: 180, 9 id: 'tiny', 10 }, { 11 min: 180, 12 max: 360, 13 id: 'small', 14 }, { 15 min: 360, 16 max: 640, 17 id: 'smallish', 18 }, { 19 min: 640, 20 max: 960, 21 id: 'medium', 22 }, { 23 min: 960, 24 max: 1280, 25 id: 'large', 26 }, { 27 min: 1280, 28 max: 9999, 29 id: 'huge', 30 }]; 31 32 var obj = Object.create(null); 33 34 var counter = 0; 35 36 obj.init = function(breakpoints) { 37 breakpoints = breakpoints || defaultBreakpoints; 38 counter++; 39 $body = $body || $(document.body); 40 this.namespace = 'obj_' + counter; 41 this.breakpoints = breakpoints; 42 this.classList = []; 43 for (var i = 0, len = breakpoints.length; i < len; ++i) { 44 this.classList.push(breakpoints[i].id); 45 } 46 var self = this; 47 function go() { 48 self.apply(); 49 } 50 $win.on('resize.' + this.namespace, go); 51 this.apply(); 52 }; 53 54 obj.destroy = function() { 55 $win.off('.' + this.namespace); 56 }; 57 58 obj.apply = function($parent) { 59 $parent = $parent || $body; 60 var breakpoints = this.breakpoints; 61 var len = breakpoints.length; 62 var self = this; 63 $parent.find('[data-wdz][data-id]').each(function() { 64 var $el = $(this); 65 var w = $el.width(); 66 for (var i = 0; i < len; ++i) { 67 var b = breakpoints[i]; 68 if (w >= b.min && w < b.max) { 69 $el.attr('data-widthis', self.classList.slice(0, i + 1).join(' ')); 70 $el.attr('data-widthnot', self.classList.slice(i).join(' ')); 71 break; 72 } 73 } 74 }); 75 }; 76 77 root.Breakpoints = obj; 78})(window.iai, 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.