Quantcast
Channel: Experiencing Adobe Experience Manager (AEM, CQ)
Viewing all articles
Browse latest Browse all 525

AEM Cloud Service - Assets Folder Properties Dynamic Media Image Profiles Sorted Case Ignored

$
0
0

Goal

Sample code in this post is for Case Ignored Sorting of Dynamic Media Image Profiles in folder properties

Package Install | Github


Product


Extension


Solution

Create a cq:ClientLibrayFolder /apps/eaem-cs-sort-image-profiles/clientlibs/sort-image-profiles with categories=cq.gui.damadmin.v2.foldershare.coral and a JS file /apps/eaem-cs-sort-image-profiles/clientlibs/sort-image-profiles/sort-profiles.js with the following logic, to read the select ./jcr:content/imageProfile and order the values....

(function ($, $document) {
"use strict";
var IMAGE_PROFILE_SEL = "[name='./jcr:content/imageProfile']";

$document.on("foundation-contentloaded", sortImageProfiles);

function sortImageProfiles(){
var $imageProfileSelect = $(IMAGE_PROFILE_SEL);

if(_.isEmpty($imageProfileSelect)){
return;
}

var selectItems = $imageProfileSelect[0].items,
values = selectItems.getAll(),
noneValue = values[0];

values.sort(function (a, b) {
var nameA = a.textContent.toUpperCase();
var nameB = b.textContent.toUpperCase();

return ((nameA < nameB) ? -1 : ((nameA > nameB) ? 1 : 0));
});

selectItems.clear();

selectItems.add(noneValue);

_.each(values, function(value){
if(value.textContent === "None"){
return;
}

selectItems.add(value);
});
}

}(jQuery, jQuery(document)));





Viewing all articles
Browse latest Browse all 525

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>