/**
* @namespace WPGMZA
* @module AtlasMajorFeatureList
* @requires WPGMZA
*
* Custom feature list renderer for Atlas Major.
* Renders clean lists for all shape types (polygons, polylines, circles,
* rectangles, point labels, heatmaps, image overlays) matching the
* Concept C mockup design. Same pattern as AtlasMajorMarkerList.
*/
jQuery(function($) {
if(!document.querySelector('.wpgmza-atlas-major'))
return;
WPGMZA.AtlasMajorFeatureList = function(container, featureType){
this.container = container;
this.featureType = featureType;
this.page = 1;
this.perPage = 50;
this.searchTerm = '';
this.render();
this.bindMapEvents();
}
/**
* Get features from the map by type
*/
WPGMZA.AtlasMajorFeatureList.prototype.getFeatures = function(){
var map = WPGMZA.maps[0];
if(!map) return [];
var plural = this.featureType + 's';
return map[plural] || [];
}
/**
* Get a display name for a feature
*/
WPGMZA.AtlasMajorFeatureList.prototype.getFeatureName = function(feature){
/* Try common name properties */
if(feature.title && feature.title.trim()) return feature.title;
if(feature.name && feature.name.trim()) return feature.name;
if(feature.text && feature.text.trim()) return feature.text;
/* Fallback: type + ID */
var type = WPGMZA.capitalizeWords(this.featureType);
return type + ' #' + feature.id;
}
/**
* Get a subtitle/description for a feature
*/
WPGMZA.AtlasMajorFeatureList.prototype.getFeatureSubtitle = function(feature){
if(feature.address && feature.address.trim()) return feature.address;
if(feature.description && feature.description.trim()){
var text = feature.description.replace(/<[^>]*>/g, '').trim();
return text.length > 60 ? text.substring(0, 60) + '...' : text;
}
return '';
}
/**
* Render the list
*/
WPGMZA.AtlasMajorFeatureList.prototype.render = function(){
if(!this.container) return;
var features = this.getFeatures();
var total = features.length;
var totalPages = Math.ceil(total / this.perPage);
if(this.page > totalPages) this.page = Math.max(1, totalPages);
var start = (this.page - 1) * this.perPage;
var pageItems = features.slice(start, start + this.perPage);
var html = '';
if(total === 0){
html = '
No ' + this.featureType + 's yet
';
} else {
html = '
';
for(var i = 0; i < pageItems.length; i++){
html += this.renderItem(pageItems[i]);
}
html += '
';
}
this.container.innerHTML = html;
this.bindItemEvents();
}
/**
* Render a single feature item
*/
WPGMZA.AtlasMajorFeatureList.prototype.renderItem = function(feature){
var id = feature.id;
var name = this.esc(this.getFeatureName(feature));
var subtitle = this.esc(this.getFeatureSubtitle(feature));
var type = this.featureType;
return '