*/
show : function()
{
- if (this.el) {
- this.el.removeClass('hidden');
+ if(!this.getEl()){
+ return;
}
+
+ this.getEl().removeClass('hidden');
+
},
/**
* Hide a component - adds 'hidden' class
*/
hide: function()
{
- if (this.el && !this.el.hasClass('hidden')) {
- this.el.addClass('hidden');
+ if(!this.getEl() || this.getEl().hasClass('hidden')){
+ return;
}
+
+ this.getEl().addClass('hidden');
+
}
});
e.preventDefault();
this.fireEvent('click', this, e);
+ },
+
+ allChildren : function()
+ {
+ var r=new Roo.util.MixedCollection(false, function(o){
+ return o.id || (o.id = Roo.id());
+ });
+ var iter = function(el) {
+ if (el.inputEl) {
+ r.add(el);
+ }
+ if (!el.items) {
+ return;
+ }
+ Roo.each(el.items,function(e) {
+ iter(e);
+ });
+ };
+
+ iter(this);
+ return r;
+ },
+
+ checkEmpty : function()
+ {
+ var items = this.allChildren();
+ var isEmpty = true;
+
+ items.each(function(f){
+ if(f.el.isVisible()) {
+ isEmpty = false;
+ }
+ });
+
+ return isEmpty;
}
});
{
Roo.log(this.el);
return this.el;
+ },
+
+ clear : function()
+ {
+ this.getEl().dom.innerHTML = '';
+ this.menuitems.clear();
}
});
Roo.bootstrap.Form = function(config){
+
Roo.bootstrap.Form.superclass.constructor.call(this, config);
Roo.bootstrap.Form.popover.apply();
*/
actioncomplete : true
});
-
};
Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
Roo.each(el.items,function(e) {
iter(e);
});
-
-
};
iter(this);
return r;
-
+ },
+
+ hideFields : function(items)
+ {
+ Roo.each(items, function(i){
+
+ var f = this.findField(i);
+
+ if(!f){
+ return;
+ }
+
+ if(f.xtype == 'DateField'){
+ f.setVisible(false);
+ return;
+ }
+
+ f.hide();
+
+ }, this);
+ },
+
+ showFields : function(items)
+ {
+ Roo.each(items, function(i){
+
+ var f = this.findField(i);
+
+ if(!f){
+ return;
+ }
+
+ if(f.xtype == 'DateField'){
+ f.setVisible(true);
+ return;
+ }
+
+ f.show();
+
+ }, this);
}
});
* @param {Mixed} value The value to validate
* @return {Boolean} True if the value is valid, else false
*/
- validateValue : function(value){
+ validateValue : function(value)
+ {
+ if(this.getEl().hasClass('hidden')){
+ return true;
+ }
+
if(value.length < 1) { // if it's blank
if(this.allowBlank){
return true;
- }
- return this.inputEl().hasClass('hide') ? true : false;
+ }
+ return false;
}
if(value.length < this.minLength){
return true;
},
-
-
// private
fireKey : function(e){
validate : function()
{
+ if(this.getEl().hasClass('hidden')){
+ return true;
+ }
+
var v = this.getRawValue();
if(this.multiple){
validateValue : function(value)
{
+ if(this.getEl().hasClass('hidden')){
+ return true;
+ }
+
if(value.length < 1) {
if(this.allowBlank){
return true;
return true;
+ },
+
+ setVisible : function(visible)
+ {
+ if(!this.getEl()){
+ return;
+ }
+
+ this.getEl().removeClass('hidden');
+
+ if(visible){
+ return;
+ }
+
+ this.getEl().addClass('hidden');
}
});
},
- onClick : function()
+ onClick : function(e)
{
- this.setChecked(true);
+ if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
+ this.setChecked(true);
+ }
},
setChecked : function(state, suppressEvent)
/*
* - LGPL
*
- * Input
- *
+ * Number field
*/
/**
* @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
*/
allowNegative : true,
+
+ /**
+ * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
+ */
+ allowZero: true,
/**
* @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
*/
this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
- this.inputEl().dom.value = Roo.util.Format.number(v, this.decimalPrecision,
- this.thousandsDelimiter || ''
- );
-
- Roo.log(v);
+ this.inputEl().dom.value = (v == '') ? '' :
+ Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
- if(this.allowBlank && !v) {
+ if(!this.allowZero && v === '0') {
+ this.hiddenEl().dom.value = '';
this.inputEl().dom.value = '';
}
}
var v = this.parseValue(this.getRawValue());
- if(v){
+
+ if(v || v === 0){
this.setValue(v);
}
},
* @param {Roo.bootstrap.RadioSet} this This radio
* @param {Roo.bootstrap.Radio} item The checked item
*/
- check : true
+ check : true,
+ /**
+ * @event click
+ * Fires when the element is click.
+ * @param {Roo.bootstrap.RadioSet} this This radio set
+ * @param {Roo.bootstrap.Radio} item The checked item
+ * @param {Roo.EventObject} e The event object
+ */
+ click : true
});
};
validate : function()
{
+ if(this.getEl().hasClass('hidden')){
+ return true;
+ }
+
var valid = false;
Roo.each(this.radioes, function(i){
/**
* @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
*/
- decimalPrecision : 2,
+ decimalPrecision : 0,
/**
* @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
*/
* value should be in lkey
*/
defaultCurrency : false,
+ /**
+ * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
+ */
+ thousandsDelimiter : false,
inputlg : 9,
autocomplete: 'new-password'
};
+ var hiddenInput = {
+ tag: 'input',
+ type: 'hidden',
+ id: Roo.id(),
+ cls: 'hidden-number-input'
+ };
+
if (this.name) {
- input.name = this.name;
+ hiddenInput.name = this.name;
}
if (this.disabled) {
cfg.cn = [
label,
- container
+ container,
+ hiddenInput
];
-
+
var settings = this;
['xs','sm','md','lg'].map(function(size){
});
return cfg;
-
},
initEvents : function()
this.initCurrencyEvent();
this.initNumberEvent();
-
},
initCurrencyEvent : function()
this.value = v;
if(this.rendered){
- this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
+
+ this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
+
+ this.inputEl().dom.value = Roo.util.Format.number(v, this.decimalPrecision,
+ this.thousandsDelimiter || ','
+ );
+
+ if(this.allowBlank && !v) {
+ this.inputEl().dom.value = '';
+ }
+
this.validate();
}
},
var v = this.parseValue(this.getRawValue());
- if(v){
+ if(v || v == 0){
this.setValue(v);
}
},
currencyEl : function()
{
return this.el.select('.roo-money-currency-input', true).first();
+ },
+
+ hiddenEl : function()
+ {
+ return this.el.select('input.hidden-number-input',true).first();
}
});
\ No newline at end of file