Hi Devs,

Recently there was a requirement to have all the icons replaced with custom
ones from a single location. With the current implementation the icons
resides in each components UI bundle. So we had to go and replace each and
every icon in each ui bundle. I wrote a script to replace these icons
location in the menu that it will look for them in
org.wso2.carbon.ui-<version_number>.jar\web\admin\images folder. Invoke
this method at page load event. I have done this on file
org.wso2.carbon.ui-<version_number>.jar\web\admin\template.js
inside jQuery(document).ready call. Following is the source.

jQuery(document).ready(
  function() {
   var menuImageOverrideHandler = function(){
var $elem = jQuery(this);
if($elem.css('background-image') != "" && $elem.css('background-image') !=
"none") {
var splitArray = $elem.css('background-image').split('/');
var newPath = "";
var foundCarbon = false;
for (var i=0;i<splitArray.length;i++){
if(splitArray[i] == "carbon"){
foundCarbon = true;
newPath += splitArray[i];
}else{
if(foundCarbon){
newPath += "admin";
foundCarbon=false;
}else{
newPath += splitArray[i];
}
}
if(splitArray.length-1 != i ){
newPath += '/';
}
}
$elem.attr('style','background-image:'+newPath);
}
  };

  jQuery('#menu-table li').each(menuImageOverrideHandler);
  jQuery('#menu-table a').each(menuImageOverrideHandler);
});

Hope this will help someone looking to do the same thing as well.

thanks,

-- 
Chanaka Jayasena
Senior Software Engineer; WSO2, Inc.;  http://wso2.com/
email: [email protected]; cell: +94 77 785 5565
blog: http://chanaka3d.blogspot.com
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to