var items = this.getItems();
var ret = {};
items.each(function(f){
+
if (!f.getName()) {
return;
}
+
var v = f.getValue();
+
if (f.inputType =='radio') {
if (typeof(ret[f.getName()]) == 'undefined') {
ret[f.getName()] = ''; // empty..
v = f.el.dom.value;
}
+
+ if(f.xtype == 'MoneyField'){
+ ret[f.currencyName] = f.getCurrency();
+ }
// not sure if this supported any more..
if ((typeof(v) == 'object') && f.getRawValue) {
this.onLoad();
+ Roo.log('onload???');
}else{
initEvents : function()
{
+ this.indicator = this.indicatorEl();
+
this.initCurrencyEvent();
this.initNumberEvent();
this.createList();
- this.indicator = this.indicatorEl();
-
this.triggerEl = this.el.select('.input-group-addon', true).first();
this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
- this.currencyEl = this.el.select('.roo-money-currency-input', true).first();
-
- this.amountEl = this.el.select('.roo-money-amount-input', true).first();
-
var _this = this;
(function(){
this.store.on('load', this.onLoad, this);
this.store.on('loadexception', this.onLoadException, this);
- this.keyNav = new Roo.KeyNav(this.currencyEl, {
+ this.keyNav = new Roo.KeyNav(this.currencyEl(), {
"up" : function(e){
this.inKeyMode = true;
this.selectPrev();
forceKeyDown: true
});
+ this.queryDelay = Math.max(this.queryDelay || 10,
+ this.mode == 'local' ? 10 : 250);
+
+
+ this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
+
+ if(this.typeAhead){
+ this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
+ }
+
+ this.currencyEl().on("keyup", this.onCurrencyKeyUp, this);
+
},
initNumberEvent : function(e)
{
+ this.inputEl().on("keydown" , this.fireKey, this);
+ this.inputEl().on("focus", this.onFocus, this);
+ this.inputEl().on("blur", this.onBlur, this);
+
+ this.inputEl().relayEvent('keyup', this);
+
+ if(this.indicator){
+ this.indicator.addClass('invisible');
+ }
+
+ this.originalValue = this.getValue();
+
+ if(this.validationEvent == 'keyup'){
+ this.validationTask = new Roo.util.DelayedTask(this.validate, this);
+ this.inputEl().on('keyup', this.filterValidation, this);
+ }
+ else if(this.validationEvent !== false){
+ this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
+ }
+
+ if(this.selectOnFocus){
+ this.on("focus", this.preFocus, this);
+
+ }
+ if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
+ this.inputEl().on("keypress", this.filterKeys, this);
+ } else {
+ this.inputEl().relayEvent('keypress', this);
+ }
+
var allowed = "0123456789";
if(this.allowDecimals){
}
};
- this.amountEl.on("keypress", keyPress, this);
+ this.inputEl().on("keypress", keyPress, this);
},
getCurrency : function()
{
- var v = this.currencyEl.getValue();
+ var v = this.currencyEl().getValue();
return v;
},
restrictHeight : function()
{
- this.list.alignTo(this.currencyEl, this.listAlign);
- this.list.alignTo(this.currencyEl, this.listAlign);
+ this.list.alignTo(this.currencyEl(), this.listAlign);
+ this.list.alignTo(this.currencyEl(), this.listAlign);
},
onViewClick : function(view, doFocus, el, e)
this.lastCurrency = o;
- if (this.currencyName) {
- currency = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
+ if (this.currencyField) {
+ currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
} else {
- Roo.log('no currencyName value set for '+ (this.name ? this.name : this.id));
+ Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
}
this.lastSelectionText = currency;
setFromData : function(o)
{
- this.setFromCurrencyData(o);
+ var c = {};
+
+ c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
+
+ this.setFromCurrencyData(c);
var value = '';
this.currencyValue = v;
if(this.rendered){
- this.currencyEl.dom.value = (v === null || v === undefined ? '' : v);
+ this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
this.validate();
}
},
this.value = v;
if(this.rendered){
- this.amountEl.dom.value = (v === null || v === undefined ? '' : v);
+ this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
this.validate();
}
},
getRawValue : function()
{
- var v = this.amountEl.getValue();
+ var v = this.inputEl().getValue();
return v;
},
this.markInvalid();
return false;
+ },
+
+ getName: function()
+ {
+ return this.name;
+ },
+
+ beforeBlur : function()
+ {
+ if(!this.castInt){
+ return;
+ }
+
+ var v = this.parseValue(this.getRawValue());
+
+ if(v){
+ this.setValue(v);
+ }
+ },
+
+ onBlur : function()
+ {
+ this.beforeBlur();
+
+ if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
+ //this.el.removeClass(this.focusClass);
+ }
+
+ this.hasFocus = false;
+
+ if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
+ this.validate();
+ }
+
+ var v = this.getValue();
+
+ if(String(v) !== String(this.startValue)){
+ this.fireEvent('change', this, v, this.startValue);
+ }
+
+ this.fireEvent("blur", this);
+ },
+
+ onCurrencyKeyUp : function(e)
+ {
+ Roo.log('on currency keyup');
+ if(!e.isSpecialKey()){
+ this.lastKey = e.getKey();
+ this.dqTask.delay(this.queryDelay);
+ }
+ },
+
+ inputEl : function()
+ {
+ return this.el.select('.roo-money-amount-input', true).first();
+ },
+
+ currencyEl : function()
+ {
+ return this.el.select('.roo-money-currency-input', true).first();
+ },
+
+ initQuery : function()
+ {
+ var v = this.getCurrency();
+ Roo.log('initQuery???');
+ this.doQuery(v);
+ },
+
+ onTypeAhead : function()
+ {
+ if(this.store.getCount() > 0){
+ var r = this.store.getAt(0);
+ var newValue = r.data[this.currencyField];
+ var len = newValue.length;
+ var selStart = this.getCurrency().length;
+
+ if(selStart != len){
+ this.setCurrency(newValue);
+ this.selectText(selStart, newValue.length);
+ }
+ }
+ },
+
+ selectText : function(start, end)
+ {
+ var v = this.getCurrency();
+
+ if(v.length > 0){
+ start = start === undefined ? 0 : start;
+ end = end === undefined ? v.length : end;
+ var d = this.el.dom;
+ if(d.setSelectionRange){
+ d.setSelectionRange(start, end);
+ }else if(d.createTextRange){
+ var range = d.createTextRange();
+ range.moveStart("character", start);
+ range.moveEnd("character", v.length-end);
+ range.select();
+ }
+ }
}
});
\ No newline at end of file