EmCombo subclass - example
I made a specialization of AW.UI.Combo that uses em units.
It nicely computes sizes for the combo, combo box, and items.
It grows with Ctrl++ (event.keycode == 107) and shrinks with Ctrl+- (event.keycode==109). Note that if the popup is shown when the user augment or diminish the font size, it is feasible to reposition the popup window by capturing the event on the window object...). Anyway the only issue I have is with shrinking the <b>.aw-combo-box .aw-item-box</b> does not shrink - What is it that I missed?
EmCombo = AW.UI.Combo.subclass();
EmCombo.create = function(){
this.prototype.fixEmSize = function() {
var n = this.getItemCount();
var tb= this.getItemText();
var tb= new Array();
for (var i=0;i<n;i++) tb[i]= this.getItemText(i).length;
var mx= Math.max.apply( Math, tb );
var w= 4 + (mx*0,7);
var h= 2 ;
this.setStyle("width" ,w +"em");
this.setStyle("height",h +"em");
var tpl= this.getItemTemplate();
tpl.setStyle("height",h +"em");
tpl= this.getPopupTemplate();
tpl.setStyle("height",((h+0.1)*n) + "em");
tpl.setStyle("width",w + "em");
};
};
var oo= new EmCombo;
oo.setControlText("Some text");
oo.setControlImage("favorites");
oo.setItemText(["Home", "Favorites", "Font size", "Search"]);
oo.setItemImage(["home", "favorites", "fontsize", "search"]);
oo.setItemCount(4);
oo.fixEmSize();
document.write(oo);
It nicely computes sizes for the combo, combo box, and items.
It grows with Ctrl++ (event.keycode == 107) and shrinks with Ctrl+- (event.keycode==109). Note that if the popup is shown when the user augment or diminish the font size, it is feasible to reposition the popup window by capturing the event on the window object...). Anyway the only issue I have is with shrinking the <b>.aw-combo-box .aw-item-box</b> does not shrink - What is it that I missed?
EmCombo = AW.UI.Combo.subclass();
EmCombo.create = function(){
this.prototype.fixEmSize = function() {
var n = this.getItemCount();
var tb= this.getItemText();
var tb= new Array();
for (var i=0;i<n;i++) tb[i]= this.getItemText(i).length;
var mx= Math.max.apply( Math, tb );
var w= 4 + (mx*0,7);
var h= 2 ;
this.setStyle("width" ,w +"em");
this.setStyle("height",h +"em");
var tpl= this.getItemTemplate();
tpl.setStyle("height",h +"em");
tpl= this.getPopupTemplate();
tpl.setStyle("height",((h+0.1)*n) + "em");
tpl.setStyle("width",w + "em");
};
};
var oo= new EmCombo;
oo.setControlText("Some text");
oo.setControlImage("favorites");
oo.setItemText(["Home", "Favorites", "Font size", "Search"]);
oo.setItemImage(["home", "favorites", "fontsize", "search"]);
oo.setItemCount(4);
oo.fixEmSize();
document.write(oo);
Philippe Marzin
March 12,