X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/84f4d7abd8501301c22d9be0565a392d33fd9cd9..8e78a2ef463acc281ead22b006c0609c60821293:/src/editor/views/openSelect/openSelect.js?ds=sidebyside diff --git a/src/editor/views/openSelect/openSelect.js b/src/editor/views/openSelect/openSelect.js index eeea988..ef5b94a 100644 --- a/src/editor/views/openSelect/openSelect.js +++ b/src/editor/views/openSelect/openSelect.js @@ -24,6 +24,12 @@ var OpenSelect = Backbone.View.extend({ this.input = $(this.options.inputTemplate); this.$('.input-wrapper').append(this.input); } + if(this.options.maxHeight) { + this.menu.css('max-height', this.options.maxHeight); + } + if(this.options.maxWidth) { + this.menu.css('max-width', this.options.maxWidth); + } }, toggleHandler: function(toggle) { this.$('.toggle').css('visibility', toggle ? 'inherit' : 'hidden'); @@ -32,11 +38,18 @@ var OpenSelect = Backbone.View.extend({ this.menu.append(_.template(itemTemplate)({value: value})); this.toggleHandler(true); }, - onSelection: function(e) { - var val = $(e.target).text(); + clearItems: function() { + this.menu.empty(); + this.toggleHandler(false); + }, + setInput: function(value) { if(this.options.setInput) { - this.options.setInput(this.input, val); + this.options.setInput(this.input, value); } + }, + onSelection: function(e) { + var val = $(e.target).text(); + this.setInput(val); this.trigger('itemSelected', this.input.val()); } });