mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Merge pull request #1987 from node-red-hitachi/fa-nonexist
Show arrow-in node when invalid font-awesome icon name was specified …
This commit is contained in:
		| @@ -498,7 +498,7 @@ RED.diff = (function() { | ||||
|         nodeDiv.css('backgroundColor',colour); | ||||
|  | ||||
|         var iconContainer = $('<div/>',{class:"palette_icon_container"}).appendTo(nodeDiv); | ||||
|         RED.utils.createIconElement(icon_url, iconContainer, false, def, node); | ||||
|         RED.utils.createIconElement(icon_url, iconContainer, false); | ||||
|  | ||||
|         return nodeDiv; | ||||
|     } | ||||
|   | ||||
| @@ -830,7 +830,7 @@ RED.editor = (function() { | ||||
|             var icon_url = RED.utils.getNodeIcon(node._def,node); | ||||
|             nodeDiv.css('backgroundColor',colour); | ||||
|             var iconContainer = $('<div/>',{class:"palette_icon_container"}).appendTo(nodeDiv); | ||||
|             RED.utils.createIconElement(icon_url, iconContainer, true, node._def, node); | ||||
|             RED.utils.createIconElement(icon_url, iconContainer, true); | ||||
|  | ||||
|             iconButton.click(function(e) { | ||||
|                 e.preventDefault(); | ||||
| @@ -844,7 +844,7 @@ RED.editor = (function() { | ||||
|                 showIconPicker(iconRow,node,iconPath,function(newIcon) { | ||||
|                     $("#node-settings-icon").text(newIcon||""); | ||||
|                     var icon_url = RED.utils.getNodeIcon(node._def,{type:node.type,icon:newIcon}); | ||||
|                     RED.utils.createIconElement(icon_url, iconContainer, true, node._def, node); | ||||
|                     RED.utils.createIconElement(icon_url, iconContainer, true); | ||||
|                 }); | ||||
|             }); | ||||
|             $('<div id="node-settings-icon">').text(node.icon).appendTo(iconButton); | ||||
|   | ||||
| @@ -144,7 +144,7 @@ RED.palette = (function() { | ||||
|     function setIcon(element,sf) { | ||||
|         var icon_url = RED.utils.getNodeIcon(sf._def); | ||||
|         var iconContainer = element.find(".palette_icon_container"); | ||||
|         RED.utils.createIconElement(icon_url, iconContainer, true, sf._def); | ||||
|         RED.utils.createIconElement(icon_url, iconContainer, true); | ||||
|     } | ||||
|  | ||||
|     function escapeNodeType(nt) { | ||||
| @@ -182,7 +182,7 @@ RED.palette = (function() { | ||||
|             if (def.icon) { | ||||
|                 var icon_url = RED.utils.getNodeIcon(def); | ||||
|                 var iconContainer = $('<div/>',{class:"palette_icon_container"+(def.align=="right"?" palette_icon_container_right":"")}).appendTo(d); | ||||
|                 RED.utils.createIconElement(icon_url, iconContainer, true, def); | ||||
|                 RED.utils.createIconElement(icon_url, iconContainer, true); | ||||
|             } | ||||
|  | ||||
|             d.style.backgroundColor = RED.utils.getNodeColor(nt,def); | ||||
|   | ||||
| @@ -203,7 +203,7 @@ RED.search = (function() { | ||||
|                     nodeDiv.css('backgroundColor',colour); | ||||
|  | ||||
|                     var iconContainer = $('<div/>',{class:"palette_icon_container"}).appendTo(nodeDiv); | ||||
|                     RED.utils.createIconElement(icon_url, iconContainer, true, node._def, node); | ||||
|                     RED.utils.createIconElement(icon_url, iconContainer, true); | ||||
|  | ||||
|                     var contentDiv = $('<div>',{class:"red-ui-search-result-description"}).appendTo(div); | ||||
|                     if (node.z) { | ||||
|   | ||||
| @@ -133,7 +133,7 @@ RED.typeSearch = (function() { | ||||
|                 nodeDiv.css('backgroundColor',colour); | ||||
|  | ||||
|                 var iconContainer = $('<div/>',{class:"palette_icon_container"}).appendTo(nodeDiv); | ||||
|                 RED.utils.createIconElement(icon_url, iconContainer, false, def); | ||||
|                 RED.utils.createIconElement(icon_url, iconContainer, false); | ||||
|  | ||||
|                 if (def.inputs > 0) { | ||||
|                     $('<div/>',{class:"red-ui-search-result-node-port"}).appendTo(nodeDiv); | ||||
|   | ||||
| @@ -782,15 +782,18 @@ RED.utils = (function() { | ||||
|         } | ||||
|  | ||||
|         var iconPath = getDefaultNodeIcon(def, node); | ||||
|         if (def.category === 'subflows') { | ||||
|             if (!isIconExists(iconPath)) { | ||||
|                 return RED.settings.apiRootUrl+"icons/node-red/subflow.png"; | ||||
|         if (isIconExists(iconPath)) { | ||||
|             if (iconPath.module === "font-awesome") { | ||||
|                 return iconPath.module+"/"+iconPath.file; | ||||
|             } else { | ||||
|                 return RED.settings.apiRootUrl+"icons/"+iconPath.module+"/"+iconPath.file; | ||||
|             } | ||||
|         } | ||||
|         if (iconPath.module === "font-awesome") { | ||||
|             return iconPath.module+"/"+iconPath.file; | ||||
|         } else { | ||||
|             return RED.settings.apiRootUrl+"icons/"+iconPath.module+"/"+iconPath.file; | ||||
|             if (def.category === 'subflows') { | ||||
|                 return RED.settings.apiRootUrl+"icons/node-red/subflow.png"; | ||||
|             } else { | ||||
|                 return RED.settings.apiRootUrl+"icons/node-red/arrow-in.png"; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -904,10 +907,8 @@ RED.utils = (function() { | ||||
|       * @param iconUrl - Url of icon. | ||||
|       * @param iconContainer - Icon container element with palette_icon_container class. | ||||
|       * @param isLarge - Whether the icon size is large. | ||||
|       * @param def - Default definition of a node. | ||||
|       * @param node - If the icon is a specific node instance, this parameter must be specified. If it is icon template such as an icon on the palette, this must be omitted. | ||||
|       */ | ||||
|     function createIconElement(iconUrl, iconContainer, isLarge, def, node) { | ||||
|     function createIconElement(iconUrl, iconContainer, isLarge) { | ||||
|         // Removes the previous icon when icon was changed. | ||||
|         var iconElement = iconContainer.find(".palette_icon"); | ||||
|         if (iconElement.length !== 0) { | ||||
| @@ -928,13 +929,8 @@ RED.utils = (function() { | ||||
|                 faIconElement.addClass("palette_icon_fa fa fa-fw " + faLarge + iconPath.file); | ||||
|                 return; | ||||
|             } | ||||
|             // If the specified name is not defined in font-awesome, show the default icon. | ||||
|             if (def) { | ||||
|                 var iconPath = RED.utils.getDefaultNodeIcon(def, node); | ||||
|                 iconUrl = RED.settings.apiRootUrl+"icons/"+iconPath.module+"/"+iconPath.file; | ||||
|             } else { | ||||
|                 iconUrl = RED.settings.apiRootUrl+"icons/node-red/arrow-in.png" | ||||
|             } | ||||
|             // If the specified name is not defined in font-awesome, show arrow-in icon. | ||||
|             iconUrl = RED.settings.apiRootUrl+"icons/node-red/arrow-in.png" | ||||
|         } | ||||
|         var imageIconElement = $('<div/>',{class:"palette_icon"}).appendTo(iconContainer); | ||||
|         imageIconElement.css("backgroundImage", "url("+iconUrl+")"); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user