var DropDownWidget = Class.create( {
tlog: TMDebug.gen_tlog( 'dropdown' ),
initialize: function( where, config ) {
this.config = Object.extend( {
}, config );
if ( this.config.choice_form )
this.choice_form = $( this.config.choice_form );
else
this.choice_form = DropDownWidget.list;
this.select = $(where);
if ( TMDebug.prototype )
this.tlog = TMDebug.gen_tlog( 'dropdown', this.select.id + ':' );
this.create_elements();
this.clear_options();
this.build_options();
if ( config.options )
this.build_options( config.options );
if ( document.loaded )
this.render();
else
DropDownWidget.to_render.push( this );
DropDownWidget.all.push( this );
},
on_real_select_change: function() {
false;
var si = this.select.selectedIndex;
this.collapse();
this.select.selectedIndex = si;
this.update_dropdown();
this.fire_change_event();
},
show: function() {
false;
if ( this.spacer ) {
this.frame.removeClassName( 'hide' );
this.spacer.removeClassName( 'hide' );
if ( this.blocking_iframe ) {
this.blocking_iframe.update();
}
}
},
hide: function() {
false;
if( this.is_expanded )
this.collapse();
if ( this.spacer ) {
this.frame.addClassName( 'hide' );
this.spacer.addClassName( 'hide' );
if ( this.blocking_iframe ) {
this.blocking_iframe.update();
}
}
},
fire_change_event: function () {
this.dropdown.fire( 'dropdown:change' );
},
on_keypress: function( event ) {
false;
switch ( event.keyCode ) {
case 13:
if ( this.is_expanded )
this.select_choice();
else
this.expand();
Event.stop( event );
break;
case 38:
if ( this.is_expanded )
this.choice_up();
else
this.select_up();
Event.stop( event );
break;
case 40:
if ( this.is_expanded )
this.choice_down();
else
this.select_down();
Event.stop( event );
break;
case 37:
if ( this.is_expanded )
this.choice_up();
else
this.select_up();
Event.stop( event );
break;
case 39:
if ( this.is_expanded )
this.choice_down();
else
this.select_down();
Event.stop( event );
break;
case 33:
if ( this.is_expanded )
this.choice_page_up();
Event.stop( event );
break;
case 34:
if ( this.is_expanded )
this.choice_page_down();
Event.stop( event );
break;
case 36:
if ( this.is_expanded )
this.choice_home();
Event.stop( event );
break;
case 35:
if ( this.is_expanded )
this.choice_end();
Event.stop( event );
break;
case 27:
if( this.is_expanded )
this.collapse();
Event.stop( event );
break;
default:
break;
}
var symbol = String.fromCharCode( event.keyCode );
},
select_up: function() {
false;
this.select.selectedIndex = this.selectedIndex;
if ( this.select.selectedIndex > 0 ) {
this.select.selectedIndex = this.select.selectedIndex - 1;
this.update_dropdown();
this.fire_change_event();
}
},
select_down: function() {
false;
this.select.selectedIndex = this.selectedIndex;
if ( this.select.selectedIndex < this.select.options.length-1 ) {
this.select.selectedIndex = this.select.selectedIndex + 1;
this.update_dropdown();
this.fire_change_event();
}
},
choice_up: function() {
if ( this.choice > 0 ) {
var new_choice = this.choice-1;
if ( this.has_scrollbar ) {
var bottom_choice = DropDownWidget.scrollbar.value + this.config.rows - 1;
if ( new_choice > bottom_choice )
new_choice = bottom_choice;
}
this.update_choice( new_choice );
}
},
choice_down: function() {
if ( this.choice < this.choices.length-1 ) {
var new_choice = this.choice+1;
if ( this.has_scrollbar ) {
var top_choice = DropDownWidget.scrollbar.value;
if ( new_choice < top_choice )
new_choice = top_choice;
}
this.update_choice( new_choice );
}
},
choice_page_up: function() {
if ( this.has_scrollbar ) {
var new_choice = this.choice - (this.config.rows - 1);
if ( this.choice > this.scrollbar_index )
new_choice = this.scrollbar_index;
else if ( new_choice < 0 )
new_choice = 0;
this.update_choice( new_choice );
}
else
this.choice_end();
},
choice_page_down: function() {
if ( this.has_scrollbar ) {
var new_choice = this.choice + (this.config.rows - 1);
if ( this.choice < this.scrollbar_index + this.config.rows - 1 )
new_choice = this.scrollbar_index + this.config.rows - 1;
if ( new_choice >= this.choices.length )
new_choice = this.choices.length - 1;
this.update_choice( new_choice );
}
else
this.choice_end();
},
choice_home: function() {
this.update_choice( 0 );
},
choice_end: function() {
this.update_choice( this.choices.length - 1 );
},
update_choice: function( choice ) {
if ( choice == this.choice )
return;
false;
this.choices[this.choice].choice.className = this.config.style.choice;
this.choice = choice;
this.choices[this.choice].choice.className = this.config.style.selected;
this.select.selectedIndex = this.selectedIndex;
this.choice_scroll();
},
choice_scroll: function () {
if ( this.has_scrollbar ) {
var top_choice = DropDownWidget.scrollbar.value;
var bottom_choice = DropDownWidget.scrollbar.value + this.config.rows - 1;
if ( this.choice < top_choice ) {
DropDownWidget.scrollbar.set_value( this.choice );
this.scroll_choices( DropDownWidget.scrollbar );
}
else if ( this.choice > bottom_choice ) {
DropDownWidget.scrollbar.set_value( this.choice - this.config.rows + 1 );
this.scroll_choices( DropDownWidget.scrollbar );
}
}
},
select_choice: function( choice ) {
false;
this.collapse();
if ( typeof( choice ) != 'undefined' )
this.choice = choice;
if ( this.choice != this.current_choice ) {
this.select.selectedIndex = this.choice;
this.update_dropdown();
this.fire_change_event();
}
this.select.focus();
},
on_choice_form_mousedown: function ( event ) {
false;
if ( is_IE6 ) {
this.do_not_blur = true;
this.do_not_focus = true;
}
else if ( Prototype.Browser.IE )
this.on_dropdown_mousedown( event );
else
Event.stop( event );
},
on_dropdown_mousedown: function( event ) {
false;
if ( DropDownWidget.active == this ) {
false;
this.do_not_blur = true;
this.select.focus();
}
},
on_dropdown_click: function( event ) {
false;
DropDownWidget.active = this;
this.select.focus();
if ( this.is_expanded )
this.collapse();
else
this.expand();
},
keep_focus: function() {
false;
if ( DropDownWidget.active == this ) {
this.select.focus();
if ( is_IE6 ) {
this.do_not_blur = true;
this.do_not_focus = true;
}
}
},
focus: function() {
false;
if ( !this.disabled )
this.frame.className = this.config.style.focused_frame;
},
unfocus: function() {
false;
if ( !this.disabled )
this.frame.className = this.config.style.frame;
},
blur: function( event ) {
false;
if ( this.do_not_blur ) {
false;
delete this.do_not_blur;
if ( this.do_not_focus ) {
false;
delete this.do_not_focus;
}
else
this.select.focus();
return;
}
false;
if ( this.is_expanded )
this.collapse();
this.unfocus();
if ( DropDownWidget.active == this )
delete DropDownWidget.active;
},
get_value: function() {
if ( this.select.selectedIndex  == -1 )
return null;
var select_options = this.select.options;
return select_options[this.select.selectedIndex].value;
},
select_option: function( option ) {
false;
if( this.selected_option )
this.selected_option.selected.hide();
if ( typeof(option) != 'undefined' ) {
option.selected.show();
this.selected_option = option;
}
else
delete this.selected_option;
},
set_ellipsis: function( option ) {
this.selected.style.width = '';
var width = Element.getWidth( option );
if ( width > this.selected_width ) {
var text_node = option;
while ( text_node.nodeType != 3 )
text_node = text_node.firstChild;
this.ellipsis_node = text_node.parentNode;
this.ellipsis_text = text_node.data;
var orig_length = this.ellipsis_text.length;
var slice = 0;
do {
slice ++;
Element.update( this.ellipsis_node, this.ellipsis_text.slice( 0, -slice ) + " &hellip;" );
width = Element.getWidth( option );
} while ( slice < orig_length && width > this.selected_width );
}
this.selected.style.width = this.selected_width + 'px';
},
remove_ellipsis: function() {
this.ellipsis_node.update( this.ellipsis_text );
delete this.ellipsis_node;
},
update_dropdown: function() {
false;
if ( !this.frame )
return;
if ( this.config.choice_form && this.config.get_choice_text ) {
var text = this.config.get_choice_text();
this.set_option( { text: text, value: 0 } );
}
else if ( this.ellipsis_node )
this.remove_ellipsis();
if ( !this.is_expanded ) {
var si = this.select.selectedIndex;
if ( si >= 0 ) {
var selected_value = this.select.options[si].value;
var opt = this.options[selected_value];
this.select_option( opt );
}
this.selectedIndex = si;
}
if ( ( !this.is_expanded || this.config.choice_form ) &&
this.config.ellipsis &&
this.selectedIndex >= 0 && this.selected_width ) {
var selected_value = this.select.options[this.selectedIndex].value;
var opt = this.options[selected_value];
this.set_ellipsis( opt.selected );
}
this.current_choice = this.selectedIndex;
},
close_option_list: function() {
DropDownWidget.scrollbar.remove();
Event.stopObserving( DropDownWidget.scrollbar.scrollbar );
this.has_scrollbar = false;
for ( var i = 0 ; i < this.choices.length ; i ++ )
Element.stopObserving( this.choices[i].choice );
},
collapse: function() {
if ( ! this.is_expanded )
return;
false;
if ( DropDownWidget.active == this ) {
this.choice_form.hide();
if ( DropDownWidget.blocking_iframe )
DropDownWidget.blocking_iframe.detach();
}
this.dropdown.className = this.config.style.dropdown;
Element.stopObserving( this.choice_form );
if ( !this.config.choice_form )
this.close_option_list();
this.frame.style.zIndex = this.config.zIndex || this._default_zIndex;
this.is_expanded = false;
if ( !this.config.choice_form )
this.select.selectedIndex = this.current_choice;
},
build_list: function() {
false;
while ( DropDownWidget.list.hasChildNodes() )
Element.remove( DropDownWidget.list.firstChild );
var values = {};
var select_options = this.select.options;
this.choice = this.select.selectedIndex;
this.choices = [];
for ( var i = 0 ; i < select_options.length ; i ++ ) {
var option = this.options[select_options[i].value];
if ( option ) {
DropDownWidget.list.appendChild( option.choice );
if ( i == this.choice )
option.choice.className = this.config.style.selected;
else
option.choice.className = this.config.style.choice;
option.choice.style.width = '';
this.choices.push( option );
}
}
},
get_mousewheel_delta: function( event ) {
var delta;
if ( event.wheelDelta )
delta = -event.wheelDelta;
else
delta = event.detail;
return delta;
},
on_dropdown_mousewheel: function( event ) {
false;
if ( this.is_expanded )
this.on_list_mousewheel( event );
else {
var delta = this.get_mousewheel_delta( event );
if ( delta > 0 )
this.select_down();
else
this.select_up();
Event.stop( event );
}
},
on_list_mousewheel: function( event ) {
false;
if ( this.has_scrollbar ) {
var delta = this.get_mousewheel_delta( event );
if ( delta > 0 )
DropDownWidget.scrollbar.increment();
else
DropDownWidget.scrollbar.decrement();
Event.stop( event );
}
},
expand: function() {
if ( this.disabled )
return;
this.frame.style.zIndex = (this.config.zIndex || this._default_zIndex) + 10;
this.choice_form.style.zIndex = +this.frame.style.zIndex + 1;
if ( DropDownWidget.blocking_iframe )
DropDownWidget.blocking_iframe.attach( this.choice_form );
if ( this.config.choice_form ) {
this.choice_form.style.left = "-10000px";
this.choice_form.show();
if ( this.config.choice_form_setup_handler )
this.config.choice_form_setup_handler();
this.choice_form.style.width = '';
var choice_form_width = Element.getWidth( this.choice_form );
var dropdown_width = Element.getWidth( this.dropdown );
if ( choice_form_width < dropdown_width )
this.choice_form.style.width = dropdown_width + 'px';
if ( this.config.display_choice_form )
this.config.display_choice_form();
}
else
this.setup_dropdown_choices();
this.dropdown.className = this.config.style.dropdown_active;
var boffset = Element.cumulativeOffset( this.border );
var doffset = Element.cumulativeOffset( this.dropdown );
var viewportOffset = document.viewport.getScrollOffsets();
var scrollOffset = Element.cumulativeScrollOffset( this.spacer );
var x = boffset[0] - scrollOffset[0] + viewportOffset[0];
var y = doffset[1] - scrollOffset[1] + viewportOffset[1];
var list_height = Element.getHeight( this.choice_form );
var dropdown_height = Element.getHeight( this.dropdown );
var viewport_height = document.viewport.getHeight();
if ( y + dropdown_height + list_height < viewportOffset[1] + viewport_height )
y += Element.getHeight( this.dropdown );
else
y -= list_height;
this.choice_form.style.left = x + "px";
this.choice_form.style.top = y + "px";
Element.observe( this.choice_form, 'mouseout', this.keep_focus.bind( this ) );
Element.observe( this.choice_form, 'mousedown', this.on_choice_form_mousedown.bind( this ) );
this.choice_form.show();
if ( DropDownWidget.blocking_iframe )
DropDownWidget.blocking_iframe.update();
DropDownWidget.active = this;
this.is_expanded = true;
},
setup_dropdown_choices: function() {
false;
this.build_list();
DropDownWidget.list.style.width = '';
DropDownWidget.list.className = this.config.style.list;
DropDownWidget.list.style.height = '';
DropDownWidget.list.style.overflow = '';
DropDownWidget.list.style.left = '-10000px';
DropDownWidget.list.style.width = '';
DropDownWidget.list.style.display = '';
var max_width = 0;
var scrollbar_height = 0;
for ( var i = 0 ; i < this.choices.length ; i ++ ) {
var element = this.choices[i].choice;
element.firstChild.style.width = '';
Element.observe( element, 'mouseover', this.update_choice.bind( this, i ) );
Element.observe( element, 'click', this.select_choice.bind( this, i ) );
var size = Element.getDimensions( element.firstChild );
if ( max_width < size.width )
max_width = size.width;
if ( this.config.rows && i < this.config.rows )
scrollbar_height += size.height;
}
if ( !Prototype.Browser.IE )
Element.observe( DropDownWidget.list, 'DOMMouseScroll', this.on_list_mousewheel.bind( this ) );
Element.observe( DropDownWidget.list, 'mousewheel', this.on_list_mousewheel.bind( this ) );
var dropdown_width = this.dropdown.getWidth()
- ( Element.getWidth( this.choices[0].choice ) - Element.getWidth( this.choices[0].choice.firstChild ) );
var choice_width = max_width;
if ( choice_width < dropdown_width )
choice_width = dropdown_width;
else
choice_width ++;
var list_size = Element.getDimensions( DropDownWidget.list );
for ( i = 0 ; i < this.choices.length ; i ++ )
this.choices[i].choice.firstChild.style.width = choice_width + 'px';
if ( this.config.rows && this.config.rows < this.choices.length ) {
this.has_scrollbar = true;
DropDownWidget.scrollbar.set_styles( this.config.style );
DropDownWidget.scrollbar.set_range( 0, this.choices.length - this.config.rows );
DropDownWidget.scrollbar.set_page_size( this.config.rows );
this.scrollbar_index = 0;
DropDownWidget.scrollbar.set_value( this.scrollbar_index );
DropDownWidget.scrollbar.set_height( scrollbar_height );
DropDownWidget.scrollbar.insert( DropDownWidget.list, 'top' );
for ( i = this.config.rows ; i < this.choices.length; i ++ )
Element.remove( this.choices[i].choice );
var scrollbar_size = DropDownWidget.scrollbar.get_dimensions();
var width_needed = scrollbar_size.width;
if ( width_needed > choice_width - max_width ) {
var width_diff = width_needed - ( choice_width - max_width );
choice_width += width_diff;
for ( i = 0 ; i < this.choices.length ; i ++ )
this.choices[i].choice.style.width = choice_width + 'px';
}
var first_visible_choice = 0;
if ( this.choice >= this.config.rows ) {
first_visible_choice = this.choice - this.config.rows + 1;
DropDownWidget.scrollbar.set_value( first_visible_choice );
this.scroll_choices( DropDownWidget.scrollbar );
}
var top_choice = this.choices[first_visible_choice].choice;
var scrollbar_position = [ Element.getWidth( top_choice ) - scrollbar_size.width, 0 ];
DropDownWidget.scrollbar.move_to( scrollbar_position );
DropDownWidget.scrollbar.insert( DropDownWidget.list, 'top' );
Event.observe(
DropDownWidget.scrollbar.scrollbar,
'scrollbar:change',
this.scroll_choices.bind( this, DropDownWidget.scrollbar )
);
}
},
scroll_choices: function( scrollbar, event ) {
false;
if ( scrollbar.value != this.scrollbar_index ) {
for ( var i = 0 ; i < this.config.rows ; i ++ ) {
Element.remove( this.choices[this.scrollbar_index + i].choice );
}
for ( i = 0 ; i < this.config.rows ; i ++ ) {
DropDownWidget.list.appendChild( this.choices[scrollbar.value + i].choice );
}
this.scrollbar_index = scrollbar.value;
}
if ( typeof(event) != 'undefined' )
Event.stop( event );
},
clear_options: function() {
this.options = {};
},
set_option: function( option, choice, selected ) {
false;
var opt = this.options[option.value];
if ( !opt ) {
opt = {
value: option.value,
selected:  new Element( 'div' ),
choice:  new Element( 'div' )
};
this.selected.appendChild( opt.selected );
opt.selected.hide();
this.options[option.value] = opt;
}
if ( choice ) {
opt.choice.update();
opt.choice.appendChild( choice.cloneNode( true ) );
}
else if ( option.text )
opt.choice.update( '<div>' + option.text + '</div>' );
if ( selected ) {
opt.selected.update();
opt.selected.appendChild( selected.cloneNode( true ) );
}
else if ( option.text )
opt.selected.update( '<div>' + option.text + '</div>' );
else if ( !opt.selected.hasChildNodes() )
opt.selected.appendChild( opt.choice.firstChild.cloneNode( true ) );
},
build_options: function( options ) {
false;
var select_options = this.select.options;
if ( options ) {
this.tlog ( 'Add custom options from', options );
var items = $(options).childNodes;
var id = $(options).id;
var value_ref_regexp = new RegExp( id + ":" );
for ( var i = 0 ; i < items.length ; i ++ ) {
if ( items[i].tagName == 'DIV' ) {
var item = items[i];
var value = items[i].id.replace( value_ref_regexp, '');
var opt_display = [];
var states = item.childNodes;
for ( var s = 0 ; s < states.length ; s ++ ) {
if ( states[s].tagName == 'DIV' ) {
opt_display.push ( states[s] );
}
}
this.set_option( { value: value }, opt_display[0], opt_display[1] );
}
}
}
else {
for ( var i = 0 ; i < select_options.length ; i ++ )
this.set_option ( select_options[i] );
}
},
_default_zIndex: 50,
create_elements: function() {
this.spacer = new Element( 'span' );
this.spacer.style.position = 'relative';
Element.addClassName( this.spacer, 'ie_has_layout' );
this.select.classNames().each( function ( name ) {
this.spacer.addClassName( name );
}, this );
this.spacer_text = new Element( 'span' );
this.spacer_text.update( '&nbsp;' );
this.spacer.appendChild( this.spacer_text );
this.select_holder = new Element( 'div' );
this.select_holder.style.position = 'absolute';
this.select_holder.style.left = '-10000px';
this.select_holder.style.top = '0px';
this.frame = new Element( 'div' );
this.frame.className = this.config.style.frame;
this.frame.style.position = 'absolute';
this.frame.style.zIndex = this.config.zIndex || this._default_zIndex;
this.border = new Element( 'div' );
this.border.className = this.config.style.border;
this.dropdown = new Element( 'div' );
this.dropdown.className = this.config.style.dropdown;
this.selected = new Element( 'div' );
this.selected.style.cursor = 'default';
this.selected.style.whiteSpace = 'nowrap';
this.spacer.appendChild( this.select_holder );
this.frame.appendChild( this.border );
this.border.appendChild( this.dropdown );
this.dropdown.appendChild( this.selected );
Element.insert( this.spacer, { top: this.frame } );
},
disable: function() {
this.disabled = true;
this.blur();
this.frame.addClassName( this.config.style.disabled );
},
enable: function() {
this.disabled = false;
this.frame.removeClassName( this.config.style.disabled );
},
render: function() {
false;
Element.insert( this.select, { after: this.spacer } );
Element.remove( this.select );
this.select_holder.appendChild( this.select );
if ( is_IE6 )
this.blocking_iframe = new BlockingIframe( this.frame );
this.frame.observe( 'mousedown', this.on_dropdown_mousedown.bind( this ) );
this.frame.observe( 'click', this.on_dropdown_click.bind( this ) );
if ( !Prototype.Browser.IE )
Element.observe( this.frame, 'DOMMouseScroll', this.on_dropdown_mousewheel.bind( this ) );
Element.observe( this.frame, 'mousewheel', this.on_dropdown_mousewheel.bind( this ) );
this.select.observe( 'focus', this.focus.bind( this ) );
this.select.observe( 'blur', this.blur.bind( this ) );
this.select.observe( 'keydown', this.on_keypress.bind( this ) );
this.select.observe( 'change', this.on_real_select_change.bind( this ) );
if ( this.config.choice_form ) {
this.select.options.length = 0;
this.select.options[0] = new Option( "Choice Form Value", 0 );
this.build_options();
}
Event.observe( this.frame, 'mouseout', this.keep_focus.bind( this ) );
this.update_dropdown();
this.update_width();
},
update_width: function() {
false;
var options = $H(this.options).values();
if ( !options.length )
return;
var marker = new Element( 'span' );
Element.insert( this.spacer, { before: marker } );
Element.remove( this.spacer );
document.body.appendChild( this.spacer );
this.selected.style.overflow = '';
this.selected.style.width = '';
var max_width;
var current_option = this.selected_option;
if ( this.config.width ) {
max_width = this.config.width;
if ( !current_option )
options[0].selected.show();
}
else {
for ( var i = 0 ; i < options.length; i ++ )
options[i].selected.show();
var size = Element.getDimensions( this.selected );
max_width = size.width;
for ( i = 0 ; i < options.length; i ++ )
options[i].selected.hide();
if ( current_option )
current_option.selected.show();
else
options[0].selected.show();
if ( this.config.max_width && max_width > this.config.max_width )
max_width = this.config.max_width;
}
this.selected.style.width = '2000px';
this.selected.style.overflow = 'hidden';
this.selected.style.width = max_width + 'px';
this.selected_width = max_width;
this.spacer_text.style.fontSize = '';
this.spacer.style.paddingLeft = '0px';
this.spacer_text.style.fontSize = Element.getHeight( this.border ) + 'px';
this.spacer.style.paddingLeft = Element.getWidth( this.border ) - Element.getWidth( this.spacer ) + 'px';
var foffset = this.frame.cumulativeOffset();
var boffset = this.border.cumulativeOffset();
var nudge = Element.getHeight( this.frame ) - Element.getHeight( this.spacer );
var shift = [ foffset[0] - boffset[0], foffset[1] - boffset[1] ];
if ( Prototype.Browser.IE )
shift[1] += nudge;
else
shift[1] = -shift[1] - nudge;
this.frame.style.left = shift[0] + "px";
this.frame.style.top = shift[1] + "px";
if ( this.blocking_iframe )
this.blocking_iframe.update();
if ( !current_option )
options[0].selected.hide();
Element.remove( this.spacer );
Element.insert( marker, { after: this.spacer } );
Element.remove( marker );
if ( this.config.ellipsis )
this.update_dropdown();
}
} );
DropDownWidget.to_render = [];
DropDownWidget.list = new Element( 'div' );
DropDownWidget.list.style.display = 'none';
DropDownWidget.list.style.position = 'absolute';
DropDownWidget.scrollbar = new ScrollBar( { zIndex: 50 } );
DropDownWidget.all = [];
Element.observe( window, 'load', function () {
document.body.appendChild( DropDownWidget.list );
DropDownWidget.to_render.each( function( widget ) { widget.render(); } );
if ( is_IE6 ) {
DropDownWidget.blocking_iframe = new BlockingIframe( DropDownWidget.list );
DropDownWidget.blocking_iframe.update();
DropDownWidget.blocking_iframe.detach();
}
} );
DropDownWidget.build = function( base_config, widget ) {
if ( !widget )
widget = DropDownWidget;
return function ( where, config ) {
var new_config = Object.clone( base_config );
Object.extend( new_config, config );
if ( config && config.style ) {
var style = Object.clone( base_config.style || {} );
new_config.style = Object.extend( style, config.style );
}
return new widget ( where, new_config );
};
};

