1/** 2 * Search router based on backbone router 3 * @module searchRouter 4 * @param {jQuery} $ Instance of jQuery 5 * @param {Document} document dom document object 6 * @return {Object} list of methods for working with backbone routing 7*/ 8XA.component.search.router = (function ($, document) { 9 10 "use strict"; 11 /** 12 * This object stores all public api methods 13 * @type {Object.<Methods>} 14 * @memberOf module:searchRouter 15 */ 16 var api = {}, 17 queryModel, 18 initialized = false, 19 lastHashObj, 20 Router; 21 /** 22 * @name module:searchRouter.Router 23 * @constructor 24 * @augments Backbone.Model 25 */ 26 Router = Backbone.Router.extend( 27 /** @lends module:searchRouter.Router.prototype **/ 28 { 29 routes: { 30 "*params": "checkUrl" 31 }, 32 /** 33 * check url for changes in hash 34 * @fires XA.component.search.vent#hashChanged 35 * @param {Object} params parameter from url 36 */ 37 checkUrl: function (params) { 38 var hashObj = queryModel.parseHashParameters(window.location.hash); 39 40 XA.component.search.service.getData(); 41 42 if (!hashObj) { 43 XA.component.search.facet.data.getInitialFacetData(); 44 XA.component.search.vent.trigger("hashChanged", hashObj); 45 } else { 46 if (JSON.stringify(hashObj) !== JSON.stringify(lastHashObj) ) { 47 XA.component.search.facet.data.filterFacetData(hashObj); 48 lastHashObj = hashObj; 49 XA.component.search.vent.trigger("hashChanged", hashObj); 50 } 51 } 52 } 53 }); 54 /** 55 * Creates instance of Backbone Router and start 56 * backbone history 57 * @memberOf module:searchRouter 58 * @alias module:searchRouter.init 59 */ 60 api.init = function () { 61 if ($("body").hasClass("on-page-editor") || initialized) { 62 return; 63 } 64 65 queryModel = XA.component.search.query; 66 67 var router = new Router(); 68 69 if (!Backbone.History.started) { 70 Backbone.history.start(); 71 } 72 73 initialized = true; 74 }; 75 76 return api; 77 78}(jQuery, document)); 79 80XA.register('searchRouter', XA.component.search.router);
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.