📄 ext.lingo.formutils.js
字号:
/*
* Ext JS Library 1.1
* Copyright(c) 2006-2007, Ext JS, LLC.
* licensing@extjs.com
*
* http://www.extjs.com/license
*
* @author Lingo
* @since 2007-09-19
* http://code.google.com/p/anewssystem/
*/
/**
* 声明Ext.lingo命名控件
* TODO: 完全照抄,作用不明
*/
Ext.namespace("Ext.lingo");
/**
* 封装表单操作的工具类.
*
*/
Ext.lingo.FormUtils = function() {
var isApply = true;
return {
// 创建<input type="text">输入框
createTextField : function(meta) {
var field = new Ext.form.TextField({
allowBlank : meta.allowBlank == undefined ? false : meta.allowBlank
, vType : meta.vType
, cls : meta.type == "password" ? meta.cls : null
, width : meta.vWidth
, id : meta.id
, name : meta.id
, style : (meta.vType == "integer" || meta.vType == "number" ? "text-align: right;" : "")
, readOnly : meta.readOnly
, defValue : meta.defValue
, alt : meta.alt
, maxLength : meta.maxlength ? meta.maxlength : Number.MAX_VALUE
, minLength : meta.minlength ? meta.minlength : 0
, minValue : meta.minvalue ? meta.minvalue : 0
, maxValue : meta.maxvalue ? meta.maxvalue : Number.MAX_VALUE
, mapping : meta.mapping
});
if(meta.readOnly) {
field.style += "color:#656B86;";
}
//if(meta.value != "" && meta.format == "date") {
// field.value = datagrids[0].date(meta.value);
//}
if(meta.defValue) {
field.setValue(meta.defValue);
}
if (isApply) {
field.applyTo(meta.id);
}
return field;
}
// 数字输入框
, createNumberField : function(meta) {
var field = new Ext.form.NumberField({
allowBlank : meta.allowBlank == undefined ? false : meta.allowBlank
, cls : meta.type == "password" ? meta.cls : null
, width : meta.vWidth
, id : meta.id
, name : meta.id
, style : (meta.vType == "integer" || meta.vType == "number" ? "text-align: right;" : "")
, readOnly : meta.readOnly
, defValue : meta.defValue
, alt : meta.alt
, maxLength : meta.maxlength ? meta.maxlength : Number.MAX_VALUE
, minLength : meta.minlength ? meta.minlength : 0
, minValue : meta.minvalue ? meta.minvalue : Number.NEGATIVE_INFINITY
, maxValue : meta.maxvalue ? meta.maxvalue : Number.MAX_VALUE
, mapping : meta.mapping
});
field.parseValue = function(value){
value = parseFloat(String(value).replace(this.decimalSeparator, "."));
return isNaN(value) ? '' : value;
};
if(meta.readOnly) {
field.style += "color:#656B86;";
}
//if(meta.value != "" && meta.format == "date") {
// field.value = datagrids[0].date(meta.value);
//}
if(meta.defValue) {
field.setValue(meta.defValue);
} else {
field.setValue(0);
}
if (isApply) {
field.applyTo(meta.id);
}
return field;
}
// 创建textarea文本框
, createTextArea : function(meta) {
var field = new Ext.form.TextArea({
allowBlank : meta.allowBlank == undefined ? false : meta.allowBlank
, vType : meta.vType
, width : meta.vWidth
, id : meta.id
, name : meta.id
, readOnly : meta.readOnly
, defValue : meta.defValue
, alt : meta.alt
, maxLength : meta.maxlength ? meta.maxlength : Number.MAX_VALUE
, minLength : meta.minlength ? meta.minlength : 0
, minValue : meta.minvalue ? meta.minvalue : 0
, maxValue : meta.maxvalue ? meta.maxvalue : Number.MAX_VALUE
, mapping : meta.mapping
});
if(meta.readOnly) {
field.style += "color:#656B86;";
}
if(meta.defValue) {
field.setValue(meta.defValue);
}
if (isApply) {
field.applyTo(meta.id);
}
return field;
}
// 创建日期选择框
, createDateField : function(meta) {
var field = new Ext.form.DateField({
id : meta.id
, name : meta.id
, allowBlank : meta.allowBlank == undefined ? false : eval(meta.allowBlank)
, format : meta.format ? meta.format : "Y年m月d日"
, readOnly : true
, width : meta.vWidth
, defValue : meta.defValue
, vType : "date"
, alt : meta.alt
, setAllMonth : meta.setAllMonth ? el.setAllMonth : false
, mapping : meta.mapping
});
if(meta.defValue) {
field.setValue(meta.defValue);
} else {
field.setValue(new Date());
}
if (isApply) {
field.applyTo(meta.id);
}
return field;
}
// 创建下拉框
, createComboBox : function(meta) {
var field = new Ext.form.ComboBox({
id : meta.id
, name : meta.id
, readOnly : meta.readOnly !== false
, triggerAction : "all"
, allowBlank : meta.allowBlank == undefined ? false : eval(meta.allowBlank)
, transform : meta.id
, vType : "comboBox"
, width : meta.vWidth
, mapping : meta.mapping
});
return field;
}
// 创建单选框
, createRadio : function(meta) {
var fields = new Array();
for (var k = 0; k < meta.values.length; k++) {
var value = meta.values[k];
var field = new Ext.form.Radio({
fieldLabel : meta.qtip
, name : meta.id
, boxLabel : value.name
, value : value.id
, vType : "radio"
, mapping : meta.mapping
});
if (meta.defValue && value.id == meta.defValue) {
field.fireEvent("check");
field.checked = true;
document.getElementById(meta.id + value.id).checked = true;;
}
if (isApply) {
field.applyTo(meta.id + value.id);
}
// 横向排列
field.el.dom.parentNode.style.display = "inline";
fields[fields.length] = field;
}
return fields;
}
// 创建复选框
, createCheckBox : function(meta) {
var field = new Ext.form.Checkbox({
id: meta.id
, name: meta.id
, vType: 'checkbox'
, inputValue: meta.inputValue
, mapping: meta.mapping
});
if (isApply) {
field.applyTo(meta.id);
}
return field;
}
// 创建treeField
, createTreeField : function(meta) {
var el = Ext.get(meta.id).dom;
var config = {
title : meta.qtip
, rootId : 0
, height : 200
, dataTag : meta.url
, treeHeight : 150
, beforeSelect : function(){}
};
var field = new Ext.lingo.TreeField({
id : el.id
, name : el.id
, allowBlank : false
, treeConfig : config
, mapping : meta.mapping
});
field.vType = "treeField";
//if(不是EditorGrid && 不是Form) object.applyTo(el.id);
if (isApply) {
field.applyTo(el.id);
}
return field;
}
// 生成密码框
, createPasswordField : function(meta) {
var field = new Ext.form.TextField({
id : meta.id
, allowBlank : meta.allowBlank == undefined ? false : meta.allowBlank
, cls : 'password'
, name : meta.id
, mapping : meta.mapping
});
field.vType = "password";
if (isApply) {
field.applyTo(meta.id);
}
return field;
}
// 生成检测密码强度的密码框
, createPasswordFieldMeta : function(meta) {
var field = new Ext.ux.PasswordMeter({
id : meta.id
, allowBlank : meta.allowBlank == undefined ? false : meta.allowBlank
, cls : 'password'
, name : meta.id
, mapping : meta.mapping
});
field.vType = "password";
if (isApply) {
field.applyTo(meta.id);
}
return field;
}
// 生成在线编辑器
, createHtmlEditor : function(meta) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -