1/* Checks namespace existence */ 2eDirectory = eDirectory || {}; 3eDirectory.Search = eDirectory.Search || {}; 4 5/** 6 * Class responsible for keeping track of user choices on the sorter selected element and functionalities 7 * @param element 8 * @param geoLocation eDirectory.Utility.Geolocation 9 * @param errorHandlerCallback 10 * @constructor 11 */ 12eDirectory.Search.Sorter = function (element, geoLocation, errorHandlerCallback) { 13 this.element = element; 14 this.geoLocation = geoLocation; 15 this.errorHandlerCallback = errorHandlerCallback; 16}; 17 18/** 19 * Disables all options containing geolocation features 20 */ 21eDirectory.Search.Sorter.prototype.disableGeoLocation = function () { 22 $('*[data-needsgeolocation="1"]').prop("disabled", true); 23 //this.element.selectpicker('refresh'); 24}; 25 26/** 27 * Initializes sorter component and functionality 28 */ 29eDirectory.Search.Sorter.prototype.initialize = function () { 30 var instance = this; 31 32 this.element.on('change', function () { 33 var selected; 34 35 if (selected = $(this).find("option:selected")) { 36 if (selected.data("needsgeolocation")) { 37 instance.geoLocation.getCoordinates( 38 function (coordinates) { 39 window.location = selected.val(); 40 }, 41 function (errors) { 42 instance.disableGeoLocation(); 43 44 if( instance.errorHandlerCallback ){ 45 instance.errorHandlerCallback(errors); 46 } 47 } 48 ); 49 } else { 50 window.location = selected.val(); 51 } 52 } 53 }); 54};
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.