';
var iWidth = Math.max(250, this.oButton.width());
this.oMenu = this.oButton.menu({ content: sMenu, callback: function(data) {me._on_icon_selection(data);}, showSpeed: 0, maxHeight: 300, flyOut: true, width: iWidth, positionOpts: {posX: 'left', posY: 'top', offsetX: 0, offsetY: 0} });
},
_on_button_clicked: function(event, ui)
{
// Adjust the position of the menu, in case the button was moved...
// The simpler is to kill and rebuild the menu !!!
KillAllMenus();
this._create_menu();
},
// events bound via _bind are removed automatically
// revert other modifications here
_destroy: function()
{
this.element.removeClass( "itop-icon-select" );
this.oButton.button( "destroy" );
},
// _setOptions is called with a hash of all options that are changing
// always refresh when changing options
_setOptions: function()
{
// in 1.9 would use _superApply
this._superApply(arguments);
this._refresh();
},
// _setOption is called for each individual option that is changing
_setOption: function( key, value )
{
if (key == 'current_idx')
{
this.element.val(this.options.items[value].value).trigger('change');
}
// in 1.9 would use _super
this._superApply(arguments);
},
_on_icon_selection: function(data)
{
this._setOptions({current_idx: data.item.attr('value')});
},
_find_item: function(value)
{
var res = null;
for(var idx in this.options.items)
{
if (value == this.options.items[idx].value)
{
res = idx;
break;
}
}
return res;
},
add_item: function(value, label, icon, position)
{
if (position == 'bottom')
{
this.options.items.push({value: value, label: label, icon: icon });
}
else
{
// Assume 'top'
this.options.items.unshift({value: value, label: label, icon: icon });
}
this._refresh();
},
get_post_upload_to: function()
{
return this.options.post_upload_to;
},
_upload_dlg: function()
{
var me = this;
this.oUploadDlg = $('