# Ext.namespace('com.faceye.layout');
# Ext.BLANK_IMAGE_URL = 'scripts/ext/resources/images/vista/s.gif';
emptyText:'请选择您喜欢的颜色',
user = Ext.get('user');// 生成Ext element元素
el = new Ext.Element(user);
<button onclick="location.href='www.baidu.com';">点击链接到百度</button>
window.location.reload(true); //重载页面
chooser.view.on('contextmenu', function(d, i, n, e){//元素加menu
//ext 窗体操作
//Ext.WindowMgr.each(function(w){w.hide()});//window.location.reload(true);
layout:'fit' 'border' 'table' 'column' 'card'
Ext.QuickTips.init();
disabled:ture,
hidden :true,
closeAction: 'hide' //关闭按钮效果
target="_blank"//弹出新窗口
render(document.body);
renderTo: document.body,
applyTo: 'local-states'
animate:true, // 生机勃勃 特效
layoutOnTabChange :true, //tabPanel doLayout
labelAlign: 'left', //form 标签左对齐
hideLabel :booler //隐藏标签
contentEl :'cartT', //将元素内容读入到ext组件中。
listeners:{check:onCheck},
hiddenName:'server', //commbox 获取值时,返回valueField :"retrunValue",
//否则返回 displayField: "displayText",
emptyText:'请输入标题' //textField为空时显示的内容
anchor:'90%' //占用百分之几的位置
closable: true, //是否现实关闭按钮
modal:true, //是否模态方式显示窗口
border:true, //边框宽度
bodyBorder :true,
bodyStyle:'padding:5px', //边的类型设置了内补丁,空余5像素。
collapsible:true, //工具条添加收缩按钮
disabled:true, //窗体状态灰色显示,且不可用
collapsed:coll, //窗体状态收缩、true收起--与expandOnShow一起用
tools:tools, //工具条
expandOnShow : false, //显示的时候扩张true为显示
autoWidth:true, //自动调节宽度
plain:true, //将标签页头的背景设置为透明
closable:true, //有关闭按钮
closeAction: 'hide', //关闭按钮 隐藏窗体
frame:false, //窗体没有背景
header:false, //有窗体头部
autoScroll: true, //窗体自动出先滚动条
shadow:false, //窗体影子
draggable:false, //窗体是否可拖动
resizable:false, //窗体不可改变大小
labelSeparator:':', //标题的分隔符号我们用中文冒号代替英文的冒号(labelSeparator:':')
isVisible(); //窗体显示
maximizable:true, //放大缩小窗口
focus(); //焦点
minWidth :30, //按钮最大宽度
<a ext:qtip="sssss">ssss</a>
buttons: [{//----------------------------------button
id: 'ok-btn',
text: '选择',
handler: this.doCallback,
scope: this
}]
Store 读取回调后的json数组
'load': {fn:function(s){
s.getAt(0).get("expHost")
//-----------------------------------------------------------------------------读取json
var res = this.cartoonPreview.previewstore.reader.jsonData;
path:res.view[0].url
listeners: {
'load': {fn:function(s){
var res1 = s.reader.jsonData;
if(s.reader.jsonData){
var res = s.reader.jsonData;
if(s.getCount()<1){
st = res.status;
ms= res.msg;
switch(st){
//case
'noconnection': Ext.Msg.alert('提示','由于网络异常,暂时无法获取数据'); break;
case 'error':
Ext.Msg.show({
title:'提示:',
msg: ms,
cls:'cartoon-msg',
buttons: Ext.Msg.OK
}); break;
}
}
}
}
}, scope:this},
'loadexception':{fn:function(){this.body.update('暂时无法获取数据');
},scope:this}
//-------------------------------------------------------------------------------监听
listeners: { //默认显示第一幅图片
'load': {fn:function(s){}, scope:this}
}
//new Ext.Element(n).remove(); //移除元素
var objArray = Ext.DomQuery.select("input[type=radio]");
Ext.each(objArray, function(obj) {
var radio = new Ext.form.Radio({
applyTo : obj
});
});
//--ext onClick 按钮事件添加
var button = Ext.get('show-btn');
button.on('click',function(){
if(!win){
var win;
var tools=[{
id:'close',
handler : function(e, target, Window) {
Window.hide();//
}
var res = s.reader.jsonData;//---------store
// alert(res.images[0].url);
//------------------------------------------------------------------------键盘监听
content1.el.on('keypress', function(e){
if (e.getKey() == e.ENTER && this.getValue().length > 0) {
previewFn();
}
});
//------------------------------------------------------------------------数据视图 取id
this.thumbTemplate = new Ext.XTemplate(
'<tpl for=".">',
'<div class="thumb-wrap" id="{name}" >',
//'<p class="thumb"><img onload="Haolog.util.Image.resize(this,80,80)"
src="{url}" title="{name}" name="{imageId}" style="display:none" /></p>',
'<p class="thumb"><img onload="Haolog.util.Image.resize(this,80,80)"
src="{url}" title="{name}" name="{imageId}" style="display:none" /></p>',
'<div>{shortName}</div></div>',
'</tpl>'
);
var selNode = this.view.getSelectedNodes();
selNode[0].id
//-------------------------------------------------------------------------------------------
Ext.get('popid').dom.className=str+"-tl"; //样式切换
//Ext.get('cart_show').alignTo(Ext.get('vv'),'c-c',[0,0],true); // 元素之间的相对定位
CallingCard.win.el.anchorTo(Ext.get('cartoon-myRoomId'),'tl-br',[0,0],false);
this.cp = new Ext.ColorPalette({});//颜色盘
this.cp.colors = ["FFFFFF", "FDF9E1", "EEF1FB","E6F8E4","FAECFB", "FAEFE2", "E4FAF9","FCEDED"];
//----------------form
Ext 乱码解决
客记端加入以下语句:Ext.lib.Ajax.defaultPostHeader += '; charset=utf-8';
服务器端加入以下语句:arg1.setContentType("text/json; charset=utf-8");
this.buttons=[ previousbut,
nextbut
];
inputType: 'password' //显示为密码
//------------------------------------------Ext.form.text
allowBlank:false, //文本框不能为空
nanText : '请输入数字类型的阴历!' ,//文本框为数字类型的提示
re = new RegExp(" ","ig"); //使用正则表达式将 空格替换为空格
content = content.replace(re," ");
Javascript中为String对象添加trim
<script language=Javascript> //自己动手为string添加Trim
function String.prototype.Trim() {return this.replace(/(^\s*)|(\s*$)/g,"");}
function String.prototype.Ltrim(){return this.replace(/(^\s*)/g, "");}
function String.prototype.Rtrim(){return this.replace(/(\s*$)/g, "");}
alert(" meizz ".Trim());
</script>
//------------------------------- Ext loading ....
setTimeout(function(){
Ext.get('loading').remove();
Ext.get('loading-mask').fadeOut({remove:true});
}, 250);
//--------------------经典的截取字符串代码
(1)String.prototype.ellipse = function(maxLength){//增加String属性
if(this.length > maxLength){
return this.substr(0, maxLength-3) + '...';
}
return this;
};
(2)var formatData = function(data){
data.shortName = data.name.ellipse(15);
data.sizeString = formatSize(data);
data.dateString = new Date(data.lastmod).format("m/d/Y g:i a");
this.lookup[data.name] = data;
return data;
};
(3)this.view = new Ext.DataView({
prepareData: formatData.createDelegate(this)
});
//--------------------------------------------------------------------------------------- submit 表单提交
submit:function(w,cho,insertFn){
var win = w;
var chooser = cho;
btn =this.uploadBtn;
btn.disable();
if(this.uploadPanel.getForm().isValid()){
this.uploadPanel.getForm().waitMsgTarget =true
var ch =chooser;
this.uploadPanel.form.doAction('submit',{// this.uploadPanel.getForm().submit({
url: '/qmail/userupload.do?method=saveUserImage',
// waitTitle:'请等待...',
waitMsg: '您的图片正在上传...',
headers:'charset=utf-8; ',
success: function(form, action){
btn.enable();
// ch.win.show();
if (action.result.status == "ok") {
// document.getElementById('cartoon-changeId').click();
if(ch.win!=null){
ch.win.show();
ch.showUser();
}
msg('表情上传成功!,请在<font color=red>“我的上传”</font>分类中查找您上传的
表情。');
win.hide();
}
if (action.result.status == "error") {
msg(action.result.msg);
}
},
failure: function(){alert("error");}
});
}
}
//-----------------------------
ext继承
var Haolog={version:'0.8'};
Ext.namespace('Haolog','Haolog.module','Haolog.form');
Haolog.module.CallingCard = function(config){
Ext.apply(this,config);
Haolog.module.CallingCard.superclass.constructor.call(this);
};
Ext.extend(Haolog.module.CallingCard, Ext.Window, {
initComponent : function(){
Haolog.module.CallingCard.superclass.initComponent.call(this);
this.addEvents(
);
// this.on("show",function(win){ }, this.scope || this);
}
});
//----------------------继承 2
PaperFactory = function(cfg) {
Ext.apply(this, cfg);
Ext.onReady(this.init, this);
}
Ext.extend(PaperFactory, Ext.util.Observable, {
paperDatas : null,
init : function() {
this.htmlTemp = new Ext.XTemplate(
'<div class="paperDiv"><p class="toName">{toName}:</p>',
'<p class="content">{content}</p>',
'<p class="fromName">{fromName}</p></div>');
this.data = {};
}
}
//-----------------------------------------------------------form表单的提交
buttons: [{
text: '保存',
handler:function(){
if(simpleForm.form.isValid()){//basicform的客户端验证
this.disabled=true;
simpleForm.form.doAction('submit',{
url:'test.asp',
method:'post',
params:'',
success:function(form,action){
Ext.Msg.alert('操作',action.result.data);
this.disabled=false;
},
failure:function(){
Ext.Msg.alert('操作','保存失败!');
this.disabled=false;
}
});
}
}
},{
text: '取消',
handler:function(){simpleForm.form.reset();}
}]
//---------------------------------------------
xtype:'fieldset', //可收缩的局部区域
checkboxToggle:true, //checkobx 点选框形式
collapsible: true, //图标形式
//---------------------------------------------
contentEl: 'xtheme', //将内js对象渲染到<div id = 'xtheme'></div>上。
//----------------------------------------------------ajax 同步提交
readDb : function(){
var cookies = {};
var conn = Ext.lib.Ajax.getConnectionObject().conn;
conn.open("POST", '../../readCookieAction.do',false);
conn.send(null);
//成功状态码为200
if (conn.status == "200") {
// alert("read state"+conn.responseText);
return Ext.util.JSON.decode(conn.responseText);
}
},
---------------------ajax request---
Ext.Ajax.request({
url: '../../calendarAddAction.do',
params:{
birthday: text
},
success: function(response, options) {
Ext.MessageBox.alert('恭喜:', '您的个性化日历 设置成功!', function(btn) {
});
} ,
failure : function() {
Ext.Msg.alert('message init failed');
},
scope : this
});
userdata = Ext.decode(res.responseText);//回调 取值
role =userdata.role||false;
--------------------end ajax
//----------------ajax 回调
Ext.Ajax.request( {
url : '../../getMessage.do',
success : function(action) {
var decoded = Ext.util.JSON.decode(action.responseText);
var configs = decoded.configs;
for (var i = 0, len = configs.length;i < len; i++) {
var config = configs[i];
var win = new Ext.Window( {
title : '编号:' + config.id + ' --- ' + config.createDate,
iconCls : 'icon-msg',
width : 255,
height : 240,
layout : 'fit',
collapsible : true,
resizable : false
});
var regs = new RegExp("\n", "gi");
this.setData( {
toName : config.toName,
content : config.content.replace(regs, '<br>'),
fromName : config.fromName
});
win.setPosition(config.x, config.y);
win.show();
this.htmlTemp.overwrite(win.body, this.data);
}
},
failure : function() {
Ext.Msg.alert('message init failed');
},
scope : this
});