1(function ($) { 2 "use strict"; 3 /*jslint undef: false, browser: true, devel: false, eqeqeq: false, bitwise: false, white: false, plusplus: false, regexp: false, nomen: false */ 4 /*jshint undef: false, browser: true, devel: false, eqeqeq: false, bitwise: false, white: false, plusplus: false, regexp: false, nomen: false, validthis: true */ 5 /*global jQuery,setTimeout,location,setInterval,YT,clearInterval,clearTimeout,pixelentity,window,JSON */ 6 7 $.pixelentity = $.pixelentity || {version: '1.0.0'}; 8 9 $.pixelentity.peLoadMore = { 10 conf: { 11 api: false 12 } 13 }; 14 15 var jwin = $(window); 16 17 function PeLoadMore(target, conf) { 18 var pages = []; 19 var active = 0; 20 var container,last; 21 var buffer; 22 var parent; 23 var widgets; 24 var loading=0; 25 26 function loaded(data) { 27 28 var pos = target.offset().top; 29 if (container.is(parent)) { 30 target.detach(); 31 } 32 33 var items = []; 34 var isotope = container.closest(".isotope"); 35 isotope = isotope.length > 0 ? isotope : false; 36 var frag = isotope ? false : document.createDocumentFragment(); 37 38 buffer.find(".pe-load-more-item").each(function () { 39 if (frag) { 40 frag.appendChild(this); 41 } 42 items.push(this); 43 }); 44 45 items = $(items); 46 47 if (isotope) { 48 var isoitems = items.filter(".peIsotopeItem"); 49 isotope.isotope('insert',isoitems).trigger("insert.pixelentity",{items: isoitems,extra:items.not(".peIsotopeItem")}); 50 setTimeout(function () { 51 // just to be safe 52 isotope.isotope("resize"); 53 },100); 54 } else { 55 container.append(frag); 56 } 57 58 widgets(items,{}); 59 60 items.find("img[data-original]:not(img.pe-lazyload-inited)").peLazyLoading(); 61 62 if (active >= (pages.length-1)) { 63 target.hide(); 64 } else if (container.is(parent)) { 65 parent.append(target); 66 } 67 68 clearTimeout(loading); 69 loading = 0; 70 hideSpinner(); 71 target.removeClass('pe-load-more-loading'); 72 } 73 74 function showSpinner() { 75 target.addClass('pe-load-more-loading'); 76 } 77 78 function hideSpinner() { 79 target.removeClass('pe-load-more-loading'); 80 } 81 82 function load(e) { 83 e.stopImmediatePropagation(); 84 e.preventDefault(); 85 if (loading) { 86 return false; 87 } 88 active++; 89 var id = container.attr("id"); 90 var sel = id ? "#"+id : ".pe-load-more-item"; 91 buffer.load(pages[active]+" %0".format(sel),loaded); 92 loading = setTimeout(showSpinner,300); 93 return false; 94 } 95 96 97 function start() { 98 var i,li = target.find("ul > li.pe-is-page"); 99 100 if (li.length > 1) { 101 for (i = 0; i< li.length;i++) { 102 var current = li.eq(i); 103 if (i === 0 && !current.hasClass("active")) { 104 break; 105 } 106 var href = current.find("a").attr("href"); 107 if (href) { 108 pages.push(href); 109 } 110 } 111 112 if (pages.length > 0) { 113 114 if (target.attr("data-all")) { 115 var all; 116 try { 117 all = JSON.parse(target.attr("data-all")); 118 } catch (x) {} 119 if (all && all.length > pages.length) { 120 pages = all; 121 } 122 } 123 124 parent = target.parent(); 125 var first = parent.find(".pe-load-more-item:first"); 126 if (first.length === 0) { 127 // no items found, bail out 128 return; 129 } 130 last = first.parent().find("> .pe-load-more-item:last"); 131 container = first.parent(); 132 133 widgets = typeof pixelentity.controller.widgets === 'function' ? pixelentity.controller.widgets : $.pixelentity.widgets.build; 134 buffer = $("<div></div>"); 135 136 var more = $('<a class="pe-load-more-button" href="#">%0</a>'.format(target.attr('data-msg'))); 137 more.on("click",load); 138 target.addClass('pe-load-more-active').find("ul").replaceWith(more); 139 target.prepend('<div class="pe-ajax-portfolio-spinner"><div class="pe-spinner"></div></div>'); 140 } 141 } 142 } 143 144 145 $.extend(this, { 146 // public API 147 destroy: function() { 148 target.data("peLoadMore", null); 149 target = undefined; 150 } 151 }); 152 153 // initialize 154 start(); 155 } 156 157 // jQuery plugin implementation 158 $.fn.peLoadMore = function(conf) { 159 160 // return existing instance 161 var api = this.data("peLoadMore"); 162 163 if (api) { 164 return api; 165 } 166 167 conf = $.extend(true, {}, $.pixelentity.peLoadMore.conf, conf); 168 169 // install the plugin for each entry in jQuery object 170 this.each(function() { 171 var el = $(this); 172 api = new PeLoadMore(el, conf); 173 el.data("peLoadMore", api); 174 }); 175 176 return conf.api ? api: this; 177 }; 178 179}(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.