1(function($, window, document, undefined) { 2 'use strict'; 3 4 var gridContainer = $('#grid-portfolio'), 5 filtersContainer = $('#filters-portfolio'), 6 wrap, filtersCallback; 7 8 9 /********************************* 10 init cubeportfolio 11 *********************************/ 12 gridContainer.cubeportfolio({ 13 14 defaultFilter: '*', 15 16 animationType: 'flipOutDelay', 17 18 gapHorizontal: 35, 19 20 gapVertical: 30, 21 22 gridAdjustment: 'responsive', 23 24 caption: 'overlayBottomReveal', 25 26 displayType: 'lazyLoading', 27 28 displayTypeSpeed: 100, 29 30 // lightbox 31 lightboxDelegate: '.cbp-lightbox', 32 lightboxGallery: true, 33 lightboxTitleSrc: 'data-title', 34 lightboxCounter: '<div class="cbp-popup-lightbox-counter">{{current}} of {{total}}</div>', 35 36 // singlePage popup 37 singlePageDelegate: '.cbp-singlePage', 38 singlePageDeeplinking: true, 39 singlePageStickyNavigation: true, 40 singlePageCounter: '<div class="cbp-popup-singlePage-counter">{{current}} of {{total}}</div>', 41 singlePageCallback: function(url, element) { 42 // dont use ajax 43 window.location = url; 44 // to update singlePage content use the following method: this.updateSinglePage(yourContent) 45 var t = this; 46 47 // $.ajax({ 48 // url: url, 49 // type: 'GET', 50 // dataType: 'html', 51 // timeout: 5000 52 // }) 53 // .done(function(result) { 54 // t.updateSinglePage(result); 55 // }) 56 // .fail(function() { 57 // t.updateSinglePage("Error! Please refresh the page!"); 58 // }); 59 60 }, 61 62 // single page inline 63 singlePageInlineDelegate: '.cbp-singlePageInline', 64 singlePageInlinePosition: 'above', 65 singlePageInlineInFocus: true, 66 singlePageInlineCallback: function(url, element) { 67 // to update singlePage Inline content use the following method: this.updateSinglePageInline(yourContent) 68 } 69 }); 70 71 72 /********************************* 73 add listener for filters 74 *********************************/ 75 if (filtersContainer.hasClass('cbp-l-filters-dropdown')) { 76 77 wrap = filtersContainer.find('.cbp-l-filters-dropdownWrap'); 78 79 wrap.on({ 80 'mouseover.cbp': function() { 81 wrap.addClass('cbp-l-filters-dropdownWrap-open'); 82 }, 83 'mouseleave.cbp': function() { 84 wrap.removeClass('cbp-l-filters-dropdownWrap-open'); 85 } 86 }); 87 88 filtersCallback = function(me) { 89 wrap.find('.cbp-filter-item').removeClass('cbp-filter-item-active'); 90 91 wrap.find('.cbp-l-filters-dropdownHeader').text(me.text()); 92 93 me.addClass('cbp-filter-item-active'); 94 95 wrap.trigger('mouseleave.cbp'); 96 }; 97 98 } else { 99 filtersCallback = function(me) { 100 me.addClass('cbp-filter-item-active').siblings().removeClass('cbp-filter-item-active'); 101 }; 102 } 103 104 filtersContainer.on('click.cbp', '.cbp-filter-item', function() { 105 106 var me = $(this); 107 108 if (me.hasClass('cbp-filter-item-active')) { 109 return; 110 } 111 112 // get cubeportfolio data and check if is still animating (reposition) the items. 113 if (!$.data(gridContainer[0], 'cubeportfolio').isAnimating) { 114 filtersCallback.call(null, me); 115 } 116 117 // filter the items 118 gridContainer.cubeportfolio('filter', me.data('filter'), function() {}); 119 120 }); 121 122 123 /********************************* 124 activate counter for filters 125 *********************************/ 126 gridContainer.cubeportfolio('showCounter', filtersContainer.find('.cbp-filter-item'), function() { 127 // read from url and change filter active 128 var match = /#cbpf=(.*?)([#|?&]|$)/gi.exec(location.href), 129 item; 130 if (match !== null) { 131 item = filtersContainer.find('.cbp-filter-item').filter('[data-filter="' + match[1] + '"]'); 132 if (item.length) { 133 filtersCallback.call(null, item); 134 } 135 } 136 }); 137 138 139 /********************************* 140 add listener for load more 141 *********************************/ 142 $('.cbp-l-loadMore-button-link').on('click.cbp', function(e) { 143 144 e.preventDefault(); 145 146 var clicks, me = $(this), 147 oMsg; 148 149 if (me.hasClass('cbp-l-loadMore-button-stop')) { 150 return; 151 } 152 153 // get the number of times the loadMore link has been clicked 154 clicks = $.data(this, 'numberOfClicks'); 155 clicks = (clicks) ? ++clicks : 1; 156 $.data(this, 'numberOfClicks', clicks); 157 158 // set loading status 159 oMsg = me.text(); 160 me.text('LOADING...'); 161 162 // perform ajax request 163 $.ajax({ 164 url: me.attr('href'), 165 type: 'GET', 166 dataType: 'HTML' 167 }).done(function(result) { 168 var items, itemsNext; 169 170 // find current container 171 items = $(result).filter(function() { 172 return $(this).is('div' + '.cbp-loadMore-block' + clicks); 173 }); 174 175 gridContainer.cubeportfolio('appendItems', items.html(), 176 function() { 177 // put the original message back
178 me.text(oMsg); 179 180 // check if we have more works 181 itemsNext = $(result).filter(function() { 182 return $(this).is('div' + '.cbp-loadMore-block' + (clicks + 1)); 183 }); 184 185 if (itemsNext.length === 0) { 186 me.text('NO MORE WORKS'); 187 me.addClass('cbp-l-loadMore-button-stop'); 188 } 189 190 }); 191 192 }).fail(function() { 193 // error 194 }); 195 196 }); 197 198})(jQuery, window, document);
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.