diff --git a/etemplate/js/et2_widget_selectbox.js b/etemplate/js/et2_widget_selectbox.js index fe0405d9b8..48c7f39c26 100644 --- a/etemplate/js/et2_widget_selectbox.js +++ b/etemplate/js/et2_widget_selectbox.js @@ -33,6 +33,14 @@ var et2_selectbox = et2_inputWidget.extend( "default": false, "description": "Allow selecting multiple options" }, + "expand_multiple_rows": { + "name": "Expand multiple", + "type": "integer", + "default": et2_no_init, + "description": "Shows single select widget, with a button. If the "+ + "user clicks the button, the input will toggle to a multiselect,"+ + "with this many rows. " + }, "rows": { "name": "Rows", "type": "any", // Old options put either rows or empty_label in first space @@ -137,6 +145,10 @@ var et2_selectbox = et2_inputWidget.extend( { this.input.unchosen(); } + if(this.expand_button) + { + this.expand_button.off(); + } this._super.apply(this, arguments); this.input = null; @@ -591,6 +603,40 @@ var et2_selectbox = et2_inputWidget.extend( this.value = _value; }, + /** + * Add a button to toggle between single select and multi select. + * + * @param {number} _rows How many rows for multi-select + */ + set_expand_multiple_rows: function(_rows) + { + this.options.expand_multiple_rows = _rows; + + var surroundings = this.getSurroundings(); + if(_rows <= 1 ) + { + // Remove + surroundings.removeDOMNode(this.expand_button.get(0)); + } + else + { + var button_id = this.getInstanceManager().uniqueId+'_'+this.id.replace(/\./g, '-') + "_expand"; + this.expand_button = $j("