From 26389be8269e31574a83bf59c1da0211e35921cf Mon Sep 17 00:00:00 2001 From: Menithal Date: Sat, 27 May 2017 11:18:29 +0300 Subject: [PATCH] Minor tweaks to unselect behavior --- .../particle_explorer/hifi-entity-ui.js | 22 ++++++++++++++++--- .../particle_explorer/particle-style.css | 3 ++- .../particle_explorer/particleExplorer.js | 6 +++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/scripts/system/particle_explorer/hifi-entity-ui.js b/scripts/system/particle_explorer/hifi-entity-ui.js index 9eff03d696..0c0dd3aae9 100644 --- a/scripts/system/particle_explorer/hifi-entity-ui.js +++ b/scripts/system/particle_explorer/hifi-entity-ui.js @@ -59,6 +59,9 @@ function HifiEntityUI(parent) { } HifiEntityUI.prototype = { + setOnSelect: function (callback){ + this.onSelect = callback; + }, submitChanges: function (structure) { var message = { messageType: "settings_update", @@ -72,11 +75,22 @@ HifiEntityUI.prototype = { disableFields: function() { var fields = document.getElementsByTagName("input"); for (var i = 0; i < fields.length; i++) { - fields[i].setAttribute("disabled", true); if (fields[i].getAttribute("type") !== "button") { fields[i].value = ""; } + + fields[i].setAttribute("disabled", true); } + var textures = document.getElementsByTagName("img"); + for (i = 0; i < textures.length; i++) { + textures[i].src = ""; + } + + textures = document.getElementsByClassName("with-texture"); + for (i = 0; i < textures.length; i++) { + textures[i].className = textures[i].className.replace("with-texture", "no-texture"); + } + var textareas = document.getElementsByTagName("textarea"); for (var x = 0; x < textareas.length; x++) { textareas[x].remove(); @@ -131,7 +145,9 @@ HifiEntityUI.prototype = { for (var i = 0; i < fields.length; i++) { fields[i].removeAttribute("disabled"); } - + if (self.onSelect) { + self.onSelect(); + } var keys = Object.keys(currentProperties); for (var e in keys) { var value = keys[e]; @@ -447,7 +463,7 @@ HifiEntityUI.prototype = { var image = document.createElement("img"); var imageLoad = _.debounce(function(url) { if (url.length > 0) { - textureImage.className = textureImage.className.replace(' no-texture', ''); + textureImage.className = textureImage.className.replace(' no-texture', ' with-texture'); image.src = url; image.style.display = "block"; } else { diff --git a/scripts/system/particle_explorer/particle-style.css b/scripts/system/particle_explorer/particle-style.css index 6440d9171d..e8b71fdba0 100644 --- a/scripts/system/particle_explorer/particle-style.css +++ b/scripts/system/particle_explorer/particle-style.css @@ -33,7 +33,8 @@ } input[type="button"] { - margin: 0.2rem; + margin: 0.4rem; + min-width: 6rem; } input[type="text"] { margin: 0; diff --git a/scripts/system/particle_explorer/particleExplorer.js b/scripts/system/particle_explorer/particleExplorer.js index 3b3da4b0b3..c16ac79b82 100644 --- a/scripts/system/particle_explorer/particleExplorer.js +++ b/scripts/system/particle_explorer/particleExplorer.js @@ -31,6 +31,7 @@ name: "Show Properties", type: "Button", class: "blue", + disabled: true, callback: function(event){ var insertZone = document.getElementById("export-import-field"); var json = ui.getSettings(); @@ -316,6 +317,11 @@ ] }; ui.setUI(menuStructure); + ui.setOnSelect(function(){ + document.getElementById("show-properties-button").removeAttribute("disabled"); + document.getElementById("export-properties-button").setAttribute("disabled",true); + document.getElementById("import-properties-button").setAttribute("disabled",true); + }); ui.build(); var overrideLoad = false; if (openEventBridge === undefined) {