1XA.component.search.loadMore = (function ($, document) { 2 3 var api = {}, 4 initialized = false, 5 SearchLoadMoreModel, 6 SearchLoadMoreView; 7 8 SearchLoadMoreModel = Backbone.Model.extend({ 9 defaults: { 10 dataProperties: {}, 11 sig: [] 12 } 13 }); 14 15 SearchLoadMoreView = Backbone.View.extend({ 16 initialize : function () { 17 var dataProperties = this.$el.data(), 18 that = this; 19 20 if (dataProperties.properties.searchResultsSignature === null){ 21 dataProperties.properties.searchResultsSignature = ""; 22 } 23 24 if (this.model) { 25 this.model.set('sig', dataProperties.properties.searchResultsSignature.split(',')); 26 } 27 28 XA.component.search.vent.on("results-loaded", function (results) { 29 var sig = that.model.get('sig'), 30 offset = typeof results.offset !== "undefined" ? results.offset : 0, 31 i; 32 33 for (i = 0; i < sig.length; i++) { 34 if (sig[i] === results.searchResultsSignature) { 35 if (results.pageSize >= results.dataCount || offset + results.pageSize >= results.dataCount) { 36 that.$el.hide(); 37 } else { 38 that.$el.show(); 39 } 40 } 41 } 42 }); 43 }, 44 events: { 45 'mousedown input': 'loadMore' 46 }, 47 loadMore: function () { 48 var sig = this.model.get('sig'), 49 i; 50 51 for (i = 0; i < sig.length; i++) { 52 XA.component.search.vent.trigger('loadMore', { 53 sig: sig[i] 54 }); 55 } 56 } 57 }); 58 59 api.init = function () { 60 if ($('body').hasClass('on-page-editor') || initialized) { 61 return; 62 } 63 64 var searchLoadMore = $('.load-more'); 65 _.each(searchLoadMore, function (elem) { 66 new SearchLoadMoreView({el: $(elem), model : new SearchLoadMoreModel()}); 67 }); 68 69 initialized = true; 70 }; 71 72 return api; 73 74}(jQuery, document)); 75 76XA.register('searchLoadMore', XA.component.search.loadMore);
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.