refactoring of ComboBoxFonts

This commit is contained in:
Maxim Kadushkin 2016-08-03 15:58:47 +03:00
parent d1ea727e4c
commit 72f281abde
2 changed files with 10 additions and 4 deletions

View file

@ -188,12 +188,13 @@ define([
Common.NotificationCenter.on('menumanager:hideall', _.bind(me.closeMenu, me)); Common.NotificationCenter.on('menumanager:hideall', _.bind(me.closeMenu, me));
this.scroller = new Common.UI.Scroller({
this.scroller = new Common.UI.Scroller(_.extend({
el: $('.dropdown-menu', me.cmpEl), el: $('.dropdown-menu', me.cmpEl),
minScrollbarLength : 40, minScrollbarLength : 40,
scrollYMarginOffset: 30, scrollYMarginOffset: 30,
includePadding : true includePadding : true
}); }, this.options.scroller));
// set default selection // set default selection
this.setDefaultSelection(); this.setDefaultSelection();

View file

@ -86,10 +86,13 @@ define([
initialize : function(options) { initialize : function(options) {
Common.UI.ComboBox.prototype.initialize.call(this, _.extend(options, { Common.UI.ComboBox.prototype.initialize.call(this, _.extend(options, {
displayField: 'name' displayField: 'name'
, scroller: {
alwaysVisibleY: true,
onChange: this.updateVisibleFontsTiles.bind(this)
}
})); }));
this.recent = _.isNumber(options.recent) ? options.recent : 3; this.recent = _.isNumber(options.recent) ? options.recent : 3;
this.bindUpdateVisibleFontsTiles = _.bind(this.updateVisibleFontsTiles, this);
Common.NotificationCenter.on('fonts:change', _.bind(this.onApiChangeFont, this)); Common.NotificationCenter.on('fonts:change', _.bind(this.onApiChangeFont, this));
Common.NotificationCenter.on('fonts:load', _.bind(this.fillFonts, this)); Common.NotificationCenter.on('fonts:load', _.bind(this.fillFonts, this));
@ -109,7 +112,9 @@ define([
this._input.on('keyup', _.bind(this.onInputKeyUp, this)); this._input.on('keyup', _.bind(this.onInputKeyUp, this));
this._input.on('keydown', _.bind(this.onInputKeyDown, this)); this._input.on('keydown', _.bind(this.onInputKeyDown, this));
this.scroller.update({alwaysVisibleY: true, onChange:this.bindUpdateVisibleFontsTiles}); setTimeout(function(me){
me.scroller.update();
}, 30, this);
return this; return this;
}, },