1/** 2 * Search result count component functionality 3 * @module searchResultsCount 4 * @param {jQuery} $ Instance of jQuery 5 * @param {Document} document dom document object 6 * @return {Object} list of methods for working with search result count component 7*/ 8XA.component.search.results.count = (function ($, document) { 9 /** 10 * This object stores all public api methods 11 * @type {Object.<Methods>} 12 * @memberOf module:searchResultsCount 13 */ 14 var api = {}, initialized = false; 15 /** 16 * @name module:searchResultsCount.SearchResultCountView 17 * @constructor 18 * @augments Backbone.View 19 */ 20 var SearchResultCountView = Backbone.View.extend( 21 /** @lends module:searchResultsCount.SearchResultCountView.prototype **/ 22 { 23 /** 24 * Initially shows fake data for creative exchange mode 25 * and watches events on which 26 * view should be updated in all modes 27 * @listens module:XA.component.search.vent~event:results-loaded 28 * @memberof module:searchResultsCount.SearchResultCountView 29 */ 30 initialize: function () { 31 var dataProperties = this.$el.data(), 32 resultsCountContainer = this.$el.find(".results-count"), 33 inst = this; 34 35 this.resultsCountText = resultsCountContainer.html(); 36 37 //check if page is opened from disc - if yes then we are in Creative Exchange mode so let's show fake results count 38 if (window.location.href.startsWith("file://")) { 39 resultsCountContainer.html(inst.resultsCountText.replace('{count}', 1)); 40 inst.$el.find(".results-count").show(); 41 return; 42 } 43 44 XA.component.search.vent.on("results-loaded", function (data) { 45 if (inst.$el.find(".results-count").length > 0) { 46 var signature = inst.$el.data("properties").targetSignature; 47 if (signature != "" && signature != data.searchResultsSignature) { 48 return; 49 } 50 resultsCountContainer.html(inst.resultsCountText.replace('{count}', data.dataCount)); 51 inst.$el.find(".results-count").show(); 52 } 53 }); 54 } 55 }); 56 57 /** 58 * For each search managed range component on a page creates instance of 59 * ["SearchResultCountView"]{@link module:searchResultsCount.SearchResultCountView} 60 * @memberOf module:searchResultsCount 61 * @alias module:searchResultsCount.init 62 */ 63 api.init = function () { 64 if ($("body").hasClass("on-page-editor") || initialized) { 65 return; 66 } 67 68 var searchResults = $(".search-results-count"); 69 _.each(searchResults, function (elem) { 70 var searchResultsCountView = new SearchResultCountView({ el: $(elem) }); 71 }); 72 73 initialized = true; 74 }; 75 76 return api; 77 78}(jQuery, document)); 79 80XA.register('searchResultsCount', XA.component.search.results.count);
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.