PageSourceSearch

https://www.poolsupplies.com/scripts/_app/pagination/pag.controller.js

js poolsupplies.com collected 2026-10-02 19:11:46 UTC 6,803 bytes, 181 lines download raw bytes

1app.controller('PagCtrl', function (paginationService,$timeout,$scope,$sce) {
2	var ScopeName = '';
3    var _this = this;
4    $scope.pagCtrl = _this;
5	_this.data = {};  _this.url = {Search:''}; _this.RowsLoading = {}; _this.InitialLoad = {};
6	_this.Loading = true;
7	var querycount = 0;
8	var arr=[];
9
10	_this.urldecode = function(value) {
11		return decodeURIComponent(value).replace(/\+/g, " ");
12	}
13
14	_this.trustAsHtml = function(value) {
15		return $sce.trustAsHtml(value);
16	}
17
18    _this.liveChange = function(trigger, updateUrl = true){
19		_this.Loading = true;
20	    if(trigger == 'load'){ _this.InitialLoad[ScopeName] = true; }
21		if((!_this.InitialLoad[ScopeName] && trigger != 'load') || (_this.InitialLoad[ScopeName] && trigger == 'load')){
22	    	_this.RowsLoading[ScopeName] = true;
23		}
24		pagination = paginationService.Pagination(trigger,_this.url,_this.data,updateUrl);
25
26		pagination.then(function(value) {
27			if(_this.data['IsDev'] == 1){ console.log(value);}
28			if(typeof(value.redirect) !== "undefined") {
29				window.location = value.redirect;
30			} else {
31				_this[ScopeName] = value;
32				if(trigger == 'load' && _this[ScopeName].url){
33					angular.forEach(_this[ScopeName].url, function(value, key) { _this.url[key] =  _this[ScopeName].url[key] = value; });
34				}
35				
36				if(_this.data.IsPaginated == 0 && (_this[ScopeName].Count > _this.data.MinLength)) {
37					_this[ScopeName].TooLarge = 1;
38				}
39				
40				if(_this[ScopeName].Count > 0 && _this.data.IsPaginated){ 
41					_this.data.JumpTo = _this[ScopeName].JumpPages[(_this[ScopeName].CurrentPage-1)];
42						//if a scroll point is defined, jump to it
43						if ( trigger!='load' && $("div.refineAutoScroll").length) {
44							$('html,body').animate({scrollTop: $("div.refineAutoScroll").offset().top }, 'slow');
45						}
46						else {
47							document.body.scrollTop = document.documentElement.scrollTop = 0;
48						}
49				}
50				_this.Loading = false;
51
52				$timeout(function() {
53					_this.RowsLoading[ScopeName] = false; _this.InitialLoad[ScopeName] = false; querycount = 0;
54					if(typeof window.trustspot_init !== "undefined") {
55						window.trustspot_init(); //run trustspot reviews
56					}
57				}, 10);
58			}
59    	}, function(reason) {
60    		console.log('error'); console.log(reason); _this[ScopeName] = '';
61    		$timeout(function() { _this.RowsLoading[ScopeName] = false; _this.InitialLoad[ScopeName] = false; }, 1);
62    	});
63    };
64
65	_this.initialize = function(dataArr){
66		ScopeName = (dataArr['ScopeName']) ? dataArr['ScopeName']:'ListInfo';
67		_this.url['Length'] = (dataArr['minLength']) ? dataArr['minLength']:10;
68		_this.url.Sort = 'featured';
69		_this.data['Module'] = (dataArr['Module']) ? dataArr['Module']:'';
70		_this.data['Modulelist'] = (dataArr['Modulelist']) ? dataArr['Modulelist']:'';
71		_this.data['IsPaginated'] = (dataArr['isPaginated']) == undefined ? 1:dataArr['isPaginated'];
72		_this.data['IsDev'] = (dataArr['IsDev']) ? 1:0;
73		_this.data['MinLength'] = _this.url.Length;
74		if(dataArr['isActive'] != undefined){ 
75			_this.data['isActive'] = dataArr['isActive'];
76			_this.url.isActive = dataArr['isActive']; // Initialize controls tied to url.isActive.
77		}
78		if(dataArr['Data']){ angular.forEach(dataArr['Data'], function(value, key) { _this.data[key] = value; }); }
79		if(dataArr['Url']){ angular.forEach(dataArr['Url'], function(value, key) { _this.url[key] = value; }); }
80		_this.liveChange('load');
81	};
82
83    window.setTimeout(function(){
84    	var currentLocation = document.URL;
85		// WAT-182 - MK - Prevent menu popup from causing additonal reloads with an extra anchor tag.
86		// If last character is a #, strip it.
87		if (currentLocation.slice(-1) == "#") {
88			currentLocation = currentLocation.slice(0, -1);
89		}
90	    window.onpopstate = function (e) {
91	    	var newLocation = document.URL;
92			// If last character is a #, strip it.
93			if (newLocation.slice(-1) == "#") {
94				newLocation = newLocation.slice(0, -1);
95			}
96	    	if(window.location.href.indexOf("?Page=") && currentLocation != newLocation){
97            window.location.reload();   
98         }
99
100	    };
101	},1);
102
103	$scope.pagCtrl.filtersExpanded = false;
104	$scope.pagCtrl.filtersOverflowing = false;
105
106	$scope.pagCtrl.toggleFiltersExpanded = function(filtersExpanded) {
107		$scope.pagCtrl.filtersExpanded = !$scope.pagCtrl.filtersExpanded;
108		if (typeof filtersExpanded === 'boolean') {
109			// If a specific state is passed, use it instead of toggling.
110			$scope.pagCtrl.filtersExpanded = filtersExpanded;
111		}
112		// Optionally, scroll into view or focus
113
114		var el = document.getElementById('filterList');
115		if (el && el.children.length > 1) {
116			if ($scope.pagCtrl.filtersExpanded) {
117				// Show all items (skipping the "Show more/less" button)
118				for (var i = 0; i < el.children.length - 1; i++) {
119					el.children[i].style.display = '';
120				}
121				return;
122			}
123			if ($scope.pagCtrl.filtersOverflowing === false) {
124				// No need to collapse if everything fits on one row.
125				return;
126			}
127			// Collapse to show only first row and last item (the "Show more/less" button)
128			var firstTop = el.children[0].offsetTop;
129			var lastTopAttr = 0;
130			// Find last item on first row (before the "Show more/less" button)
131			for (var i = 1; i < el.children.length-1; i++) {
132				if (el.children[i].offsetTop !== firstTop) {
133					lastTopAttr = i - 1;
134					break;
135				}
136			}
137			// Hide all items including and after lastTopAttr (skipping the "Show more/less" button)
138			for (var i = lastTopAttr; i < el.children.length - 1; i++) {
139				el.children[i].style.display = 'none';
140			}
141		}
142	};
143
144	// Function to check if all elements fit on one row
145	$scope.pagCtrl.checkFilterOverflow = function() {
146		var el = document.getElementById('filterList');
147		if (el) {
148			// Get top position of first element
149			var firstTop = el.children[0].offsetTop;
150			// Check if any other element is on a different row (skipping the "Show more/less" button)
151			for (var i = 1; i < el.children.length-1; i++) {
152				el.children[i].style.display = '';
153				if (el.children[i].offsetTop !== firstTop) {
154					// Found first item on next row. Show the toggle button.
155
156					$scope.pagCtrl.filtersOverflowing = true;
157					break;
158				}
159				// No second row found. Hide the toggle button.
160				$scope.pagCtrl.filtersOverflowing = false;
161			}
162			$scope.pagCtrl.toggleFiltersExpanded($scope.pagCtrl.filtersExpanded);
163			$scope.$applyAsync();
164		}
165	};
166
167	// Call this after filters are rendered/updated
168	$scope.$watch('pagCtrl.ListInfo.Attrs', function() {
169		if (!$scope.pagCtrl.ListInfo || !$scope.pagCtrl.ListInfo.Attrs) {
170			return;
171		}
172
173		setTimeout($scope.pagCtrl.checkFilterOverflow, 100);
174	}, true);
175	$scope.$watch('pagCtrl.ListInfo.specialAttrs', function() {
176		if (!$scope.pagCtrl.ListInfo || !$scope.pagCtrl.ListInfo.specialAttrs) {
177			return;
178		}
179		setTimeout($scope.pagCtrl.checkFilterOverflow, 100);
180	}, true);
181});

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.