Added basic approach to have selectbox widget running again (probably not fully working yet)

This commit is contained in:
Andreas Stöckel 2011-08-20 18:34:14 +00:00
parent e92087df31
commit 7c7a8230cf
4 changed files with 35 additions and 26 deletions

View File

@ -17,9 +17,6 @@
et2_inputWidget; et2_inputWidget;
*/ */
/**
* Class which implements the "menulist" XET-Tag
*/
var et2_selectbox = et2_inputWidget.extend({ var et2_selectbox = et2_inputWidget.extend({
attributes: { attributes: {
@ -54,25 +51,6 @@ var et2_selectbox = et2_inputWidget.extend({
this.createInputWidget(); this.createInputWidget();
}, },
/**
* Override load to be able to handle menupopup tag inside of menulist
*/
loadFromXML: function(_node) {
var menupopupElems = et2_directChildrenByTagName(_node, "menupopup");
if(menupopupElems.length == 1) {
this.loadAttributes(menupopupElems[0].attributes);
} else {
this._super.apply(this,arguments);
}
// Legacy options could have row count or empty label in first slot
if(typeof this.rows == "string" && isNaN(this.rows)) {
this.set_empty_label(this.rows);
this.set_rows(1);
}
if(this.rows > 1) this.set_multiselect(true);
},
createInputWidget: function() { createInputWidget: function() {
if(this.type == "menupopup") { if(this.type == "menupopup") {
return; return;
@ -134,6 +112,7 @@ var et2_selectbox = et2_inputWidget.extend({
} }
} }
}, },
set_rows: function(_rows) { set_rows: function(_rows) {
if (_rows != this.rows) if (_rows != this.rows)
{ {
@ -141,6 +120,7 @@ var et2_selectbox = et2_inputWidget.extend({
this.input.attr("size",this.rows); this.input.attr("size",this.rows);
} }
}, },
set_empty_label: function(_label) { set_empty_label: function(_label) {
if(_label != this.empty_label) { if(_label != this.empty_label) {
this.empty_label = _label; this.empty_label = _label;
@ -149,5 +129,34 @@ var et2_selectbox = et2_inputWidget.extend({
} }
}); });
et2_register_widget(et2_selectbox, ["menulist","listbox"]); et2_register_widget(et2_selectbox, ["menupopup", "listbox", "select-cat", "select-account"]);
/**
* Class which just implements the menulist container
*/
var et2_menulist = et2_DOMWidget.extend({
createNamespace: true,
init: function() {
this._super.apply(this, arguments);
this.supportedWidgetClasses = [et2_selectbox];
},
// Just pass the parent DOM node through
getDOMNode: function(_sender) {
if (_sender != this._parent && _sender != this)
{
return this._parent.getDOMNode(this);
}
return null;
}
});
et2_register_widget(et2_menulist, ["menulist"]);

View File

@ -497,7 +497,7 @@ var et2_widget = Class.extend({
} }
// Create the new element // Create the new element
this.createElementFromNode(node, widgetType); this.createElementFromNode(node);
} }
}, },

View File

@ -20,7 +20,7 @@
et2_description; et2_description;
et2_textbox; et2_textbox;
et2_number; et2_number;
// et2_selectbox; et2_selectbox;
et2_checkbox; et2_checkbox;
et2_radiobox; et2_radiobox;
et2_styles; et2_styles;

View File

@ -20,7 +20,7 @@
<script src="../et2_hbox.js"></script> <script src="../et2_hbox.js"></script>
<script src="../et2_textbox.js"></script> <script src="../et2_textbox.js"></script>
<script src="../et2_number.js"></script> <script src="../et2_number.js"></script>
<!-- <script src="../et2_selectbox.js"></script>--> <script src="../et2_selectbox.js"></script>
<script src="../et2_checkbox.js"></script> <script src="../et2_checkbox.js"></script>
<script src="../et2_radiobox.js"></script> <script src="../et2_radiobox.js"></script>
<script src="../et2_styles.js"></script> <script src="../et2_styles.js"></script>