From cf69dbe1dcf6135b5f8f3db9139f7ee5233919c9 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Wed, 13 Apr 2016 18:10:04 -0700 Subject: [PATCH] TypedInput: preload type icons to ensure width calc correct --- editor/js/ui/typedInput.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/editor/js/ui/typedInput.js b/editor/js/ui/typedInput.js index 294ce2517..3be1c3de1 100644 --- a/editor/js/ui/typedInput.js +++ b/editor/js/ui/typedInput.js @@ -235,12 +235,17 @@ if (!arguments.length) { return this.propertyType; } else { + var that = this; var opt = this.typeMap[type]; if (opt && this.propertyType !== type) { this.propertyType = type; this.typeField.val(type); this.selectLabel.empty(); + var image; if (opt.icon) { + image = new Image(); + image.name = opt.icon; + image.src = opt.icon; $('',{src:opt.icon,style:"margin-right: 4px;height: 18px;"}).prependTo(this.selectLabel); } else { this.selectLabel.text(opt.label); @@ -249,7 +254,6 @@ if (this.optionSelectTrigger) { this.optionSelectTrigger.show(); this.element.hide(); - var that = this; this.optionMenu = this._createMenu(opt.options,function(v){ that.optionSelectLabel.text(v); that.value(v); @@ -277,7 +281,12 @@ } this.element.trigger('change'); } - this._resize(); + if (image) { + image.onload = function() { that._resize(); } + image.onerror = function() { that._resize(); } + } else { + this._resize(); + } } } },