Selectbox now allows 'option'-widgets inside of it, added hrule widget, added support for 'buttononly'

This commit is contained in:
Andreas Stöckel 2011-08-21 13:24:20 +00:00
parent 4ad303529c
commit 09bc77426c
7 changed files with 145 additions and 40 deletions

View File

@ -63,9 +63,12 @@ var et2_button = et2_baseWidget.extend(et2_IInput, {
}
// Submit the form
this.clicked = true;
this.getInstanceManager().submit();
this.clicked = false;
if (this._type != "buttononly")
{
this.clicked = true;
this.getInstanceManager().submit();
this.clicked = false;
}
},
set_label: function(_value) {
@ -105,5 +108,5 @@ var et2_button = et2_baseWidget.extend(et2_IInput, {
});
et2_register_widget(et2_button, ["button"]);
et2_register_widget(et2_button, ["button", "buttononly"]);

33
etemplate/js/et2_hrule.js Normal file
View File

@ -0,0 +1,33 @@
/**
* eGroupWare eTemplate2 - JS HRule object
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate
* @subpackage api
* @link http://www.egroupware.org
* @author Andreas Stöckel
* @copyright Stylite 2011
* @version $Id$
*/
"use strict";
/*egw:uses
et2_baseWidget;
*/
/**
* Class which implements the hrule tag
*/
var et2_hrule = et2_baseWidget.extend({
init: function(_parent) {
this._super.apply(this, arguments);
this.setDOMNode(document.createElement("hr"));
}
});
et2_register_widget(et2_hrule, ["hrule"]);

View File

@ -14,7 +14,9 @@
"use strict";
/*egw:uses
lib/tooltip;
jquery.jquery;
et2_DOMWidget;
et2_inputWidget;
*/
@ -40,7 +42,10 @@ var et2_selectbox = et2_inputWidget.extend({
"description": "Textual label for first row, eg: 'All' or 'None'. ID will be ''"
},
"select_options": {
"ignore": true // Just include "select_options" here to have it copied from the parseArrayMgrAttrs to the options-object
"type": "any",
"name": "Select options",
"default": {},
"description": "Internaly used to hold the select options."
}
},
@ -49,12 +54,18 @@ var et2_selectbox = et2_inputWidget.extend({
init: function(_parent) {
this._super.apply(this, arguments);
// This widget allows no other widgets inside of it
this.supportedWidgetClasses = [];
// Only allow options inside this element
this.supportedWidgetClasses = [et2_option];
this.createInputWidget();
},
destroy: function() {
this._super.apply(this, arguments);
this.input = null;
},
parseArrayMgrAttrs: function(_attrs) {
// Try to find the options inside the "sel-options" array
_attrs["select_options"] = this.getArrayMgr("sel_options").getValueForID(this.id);
@ -96,17 +107,23 @@ var et2_selectbox = et2_inputWidget.extend({
this.empty_label);
}
// Add the select_options
for(var key in this.options.select_options)
{
this._appendOptionElement(key, this.options.select_options[key]);
}
// Set multiselect
if(this.options.multiselect)
{
this.input.attr("multiple", "multiple");
}
},
/**
* The set_select_optons function is added, as the select options have to be
* added after the "option"-widgets were added to selectbox.
*/
set_select_options: function(_options) {
// Add the select_options
for (var key in _options)
{
this._appendOptionElement(key, _options[key]);
}
}
});
@ -114,6 +131,55 @@ var et2_selectbox = et2_inputWidget.extend({
et2_register_widget(et2_selectbox, ["menupopup", "listbox", "select-cat",
"select-account"]);
/**
* Widget class which represents a single option inside a selectbox
*/
var et2_option = et2_baseWidget.extend({
attributes: {
"value": {
"name": "Value",
"type": "string",
"description": "Value which is sent back to the server when this entry is selected."
},
"width": {
"ignore": true
},
"height": {
"ignore": true
},
"align": {
"ignore": true
}
},
init: function() {
this._super.apply(this, arguments);
// Allow no other widgets inside of this one.
this.supportedWidgetClasses = [];
this.option = $j(document.createElement("option"))
.attr("value", this.options.value);
this.setDOMNode(this.option[0]);
},
destroy: function() {
this._super.apply(this, arguments);
this.option = null;
},
loadContent: function(_data) {
this.option.text(_data);
}
});
et2_register_widget(et2_option, ["option"]);
/**
* Class which just implements the menulist container
*/

View File

@ -26,6 +26,7 @@
et2_styles;
et2_html;
et2_tabs;
et2_hrule;
// Requirements for the etemplate2 object
et2_xml;

View File

@ -13,32 +13,21 @@
<hrule label="HR"/>
<image label="Image" src="image_value"/>
<menulist>
<menupopup label="Selectbox" id="selectbox_value" options="No value"/>
<menupopup label="Selectbox" id="selectbox_value" options="No value">
<option value="1">Test 1</option>
<option value="2">Test 2</option>
<option value="3">Test 3</option>
<option value="4">Test 4</option>
<option value="5">Test 5</option>
<option value="6">Test 6</option>
</menupopup>
</menulist>
<listbox label="Multiselect" id="multiselect" rows="5"/>
<!-- Test with template -->
<!--
<template id="test.basic_widget_test">
<description value="This is a label" id="label_value"/>
<textbox label="This is a text" id="text_value"/>
<textbox label="This is required text" id="text_value" required="true"/>
<int label="This is an integer" id="integer_value" min="5"/>
<textbox type="float" label="This is a float" id="float_value"/>
<textbox multiline="true" label="This is a text area" id="text_area_value" rows="3" cols="3"/>
<checkbox label="Checkbox %s here" id="checkbox_value"/>
<radio label="Radio" id="radio_value"/>
<buttononly label="Button" id="button_value"/>
<hrule label="HR"/>
<image label="Image" src="image_value"/>
<menulist>
<menupopup label="Selectbox" id="selectbox_value" options="No value"/>
</menulist>
<listbox label="Multiselect" id="multiselect" rows="5"/>
</template>
-->
<!-- Reference the template above (Why?) -->
<!--
<template id="test.basic_widget_test" />
-->
<listbox label="Multiselect" id="multiselect" rows="5">
<option value="1">Test 1</option>
<option value="2">Test 2</option>
<option value="3">Test 3</option>
<option value="4">Test 4</option>
<option value="5">Test 5</option>
<option value="6" statustext="This is the sixth option">Test 6</option>
</listbox>
</overlay>

View File

@ -239,3 +239,15 @@ input.invalid {
.error p {
margin: 0;
}
/**
* hrule widget
*/
hr {
border-style: none;
border-top: 1px solid silver;
height: 1px;
margin: 10px 0px 10px 0px;
}

View File

@ -25,6 +25,7 @@
<script src="../et2_radiobox.js"></script>
<script src="../et2_styles.js"></script>
<script src="../et2_html.js"></script>
<script src="../et2_hrule.js"></script>
<script src="../etemplate2.js"></script>