- 浏览: 33644 次
- 性别:
- 来自: 广州
文章分类
最新评论
-
demosaid:
什么鸡毛玩意
itext实现pdf打印之一 -
843630311:
正在学习843630311@qq.com,谢谢啦
用Ext3.0的API主页框架做的项目 -
风凌雪:
我也想学习学习啊,i@zhangyuwei.me。谢谢
用Ext3.0的API主页框架做的项目 -
kukule520129:
谢谢我需要一份:
42552346@qq.com
谢谢了。
用Ext3.0的API主页框架做的项目 -
panghaichao:
给我发一份 panghaichao@163.com 谢谢了
用Ext3.0的API主页框架做的项目
最近一段时间公司里没有项目,有空就专研ext,顺便用它完成了一个小项目。Ext API的主页就是一个典型的tab框架,通过它可以创建如同FireFox浏览器一样,打开一个页面就往上面添加一个tab,方便用户的使用,可以在同一个浏览器中浏览多个页面。
左边是一个树形结构的菜单,右边是一个tab的页面,左边菜单的代码为
/*!
* Ext JS Library 3.0.0
* Copyright(c) 2006-2009 Ext JS, LLC
* licensing@extjs.com
* http://www.extjs.com/license
*/
Docs.classData ={"id":"apidocs","iconCls":"icon-docs","text":"图书管理系统","singleClickExpand":true,"children":[
{"id":"apidocs3","text":"图书管理","iconCls":"icon-pkg","cls":"package","singleClickExpand":true, children:[
{"href":"output/book.jsp","text":"图书信息管理","id":"book","isClass":true,"iconCls":"icon-cls","cls":"cls","leaf":true}]},
{"id":"apidocs1","iconCls":"icon-docs","text":"系统管理","singleClickExpand":true,"children":[
{"href":"output/company.jsp","text":"分公司管理","id":"company","isClass":true,"iconCls":"icon-cmp","cls":"cls","leaf":true}
,
{"href":"output/department.jsp","text":"部门管理管理","id":"department","isClass":true,"iconCls":"icon-cls","cls":"cls","leaf":true}
,
{"href":"output/user.jsp","text":"用户管理","id":"user","isClass":true,"iconCls":"icon-cmp","cls":"cls","leaf":true}
,
{"href":"output/business.jsp","text":"职务管理","id":"business","isClass":true,"iconCls":"icon-cls","cls":"cls","leaf":true}]},
{"id":"apidocs2","iconCls":"icon-docs","text":"科目和分类管理","singleClickExpand":true,"children":[
{"href":"output/subject.jsp","text":"科目管理","id":"subject","isClass":true,"iconCls":"icon-cls","cls":"cls","leaf":true}
,
{"href":"output/class.jsp","text":"分类管理","id":"class","isClass":true,"iconCls":"icon-cmp","cls":"cls","leaf":true}
]}
]};
Docs.icons = {
"book":"icon-cls"
,
"company":"icon-cmp"
,
"department":"icon-cls"
,
"user":"icon-cmp"
,
"business":"icon-cls"
,
"subject":"icon-cls"
,
"class":"icon-cmp"
};
这是菜单的结构,我没有全部改源码,只改成了连接到我的jsp页面,iconCls属性还是和原来的一样。
/*!
* Ext JS Library 3.0.0
* Copyright(c) 2006-2009 Ext JS, LLC
* licensing@extjs.com
* http://www.extjs.com/license
*/
//这个地方要特别注意,要加上这句话,要不他默认的配置连接地址是到EXT网站上去下载这个图片,所以我们要改这个地址,让他不要到网上去下载。
Ext.BLANK_IMAGE_URL = '/book/resources/images/default/s.gif';
Docs = {};
ApiPanel = function() {
ApiPanel.superclass.constructor.call(this, {
id:'api-tree',
region:'west',
split:true,
width: 220,
minSize: 175,
maxSize: 450,
collapsible: true,
margins:'0 0 5 5',
cmargins:'0 0 0 0',
rootVisible:false,
lines:false,
autoScroll:true,
animCollapse:false,
animate: false,
collapseMode:'mini',
loader: new Ext.tree.TreeLoader({
preloadChildren: true,
clearOnLoad: false
}),
root: new Ext.tree.AsyncTreeNode({
id:'root',
expanded:true,
children:[Docs.classData]
}),
collapseFirst:false
});
this.getSelectionModel().on('beforeselect', function(sm, node){
return node.isLeaf();
});
};
Ext.extend(ApiPanel, Ext.tree.TreePanel, {
//当选择了右边的tap就自动选择左边的菜单
selectClass : function(cls){
if(cls){
var parts = cls.split('.');
var last = parts.length-1;
var res = [];
var pkg = [];
for(var i = 0; i < last; i++){
var p = parts[i];
var fc = p.charAt(0);
var staticCls = fc.toUpperCase() == fc;
if(p == 'Ext' || !staticCls){
pkg.push(p);
res[i] = 'pkg-'+pkg.join('.');
}else if(staticCls){
--last;
res.splice(i, 1);
}
}
res[last] = cls
}
}
});
DocPanel = Ext.extend(Ext.Panel, {
closable: true,
autoScroll:true,
initComponent : function(){
var ps = this.cclass.split('.');
this.title = ps[ps.length-1];
DocPanel.superclass.initComponent.call(this);
},
scrollToMember : function(member){
var el = Ext.fly(this.cclass + '-' + member);
if(el){
var top = (el.getOffsetsTo(this.body)[1]) + this.body.dom.scrollTop;
this.body.scrollTo('top', top-25, {duration:.75, callback: this.hlMember.createDelegate(this, [member])});
}
},
scrollToSection : function(id){
var el = Ext.getDom(id);
if(el){
var top = (Ext.fly(el).getOffsetsTo(this.body)[1]) + this.body.dom.scrollTop;
this.body.scrollTo('top', top-25, {duration:.5, callback: function(){
Ext.fly(el).next('h2').pause(.2).highlight('#8DB2E3', {attr:'color'});
}});
}
},
hlMember : function(member){
var el = Ext.fly(this.cclass + '-' + member);
if(el){
el.up('tr').highlight('#cadaf9');
}
}
});
MainPanel = function(){
MainPanel.superclass.constructor.call(this, {
id:'doc-body',
region:'center',
margins:'0 5 5 0',
resizeTabs: true,
minTabWidth: 135,
tabWidth: 135,
closable: true,
enableTabScroll: true,
activeTab: 0,
items: {
id:'welcome-panel',
title: '欢迎',
autoLoad: {url: 'welcome.html', callback: this.initSearch, scope: this},
iconCls:'icon-docs',
autoScroll: true,
tbar: [
]
}
});
};
Ext.extend(MainPanel, Ext.TabPanel, {
initEvents : function(){
MainPanel.superclass.initEvents.call(this);
this.body.on('click', this.onClick, this);
},
onClick: function(e, target){
if(target = e.getTarget('a:not(.exi)', 3)){
var cls = Ext.fly(target).getAttributeNS('ext', 'cls');
e.stopEvent();
if(cls){
var member = Ext.fly(target).getAttributeNS('ext', 'member');
this.loadClass(target.href, cls, member);
}else if(target.className == 'inner-link'){
this.getActiveTab().scrollToSection(target.href.split('#')[1]);
}else{
window.open(target.href);
}
}else if(target = e.getTarget('.micon', 2)){
e.stopEvent();
var tr = Ext.fly(target.parentNode);
if(tr.hasClass('expandable')){
tr.toggleClass('expanded');
}
}
},
loadClass : function(href, cls, member){
var id = 'docs-' + cls;
var tab = this.getComponent(id);
if(tab){
this.setActiveTab(tab);
if(member){
tab.scrollToMember(member);
}
}else{
var autoLoad = {url: href,scripts: true};
if(member){
autoLoad.callback = function(){
Ext.getCmp(id).scrollToMember(member);
}
}
var p = this.add(new DocPanel({
id: id,
cclass : cls,
autoLoad: autoLoad,
iconCls: Docs.icons[cls]
}));
this.setActiveTab(p);
}
}
});
Ext.onReady(function(){
Ext.QuickTips.init();
var api = new ApiPanel();
var mainPanel = new MainPanel();
api.on('click', function(node, e){
if(node.isLeaf()){
e.stopEvent();
mainPanel.loadClass(node.attributes.href, node.text);
}
});
mainPanel.on('tabchange', function(tp, tab){
api.selectClass(tab.cclass);
});
var hd = new Ext.Panel({
border: false,
layout:'anchor',
region:'north',
cls: 'docs-header',
height:60,
items: [{
xtype:'box',
el:'header',
border:false,
anchor: 'none -25'
},
new Ext.Toolbar({
cls:'top-toolbar',
items:[ ' ',
new Ext.form.TextField({
width: 200,
emptyText:'查询菜单',
listeners:{
render: function(f){
f.el.on('keydown', filterTree, f, {buffer: 350});
}
}
}), ' ', ' ',
{
iconCls: 'icon-expand-all',
tooltip: '全部展开',
handler: function(){ api.root.expand(true); }
}, '-', {
iconCls: 'icon-collapse-all',
tooltip: '全部收缩',
handler: function(){ api.root.collapse(true); }
}/**, '->', {
tooltip:'Hide Inherited Members',
iconCls: 'icon-hide-inherited',
enableToggle: true,
toggleHandler : function(b, pressed){
mainPanel[pressed ? 'addClass' : 'removeClass']('hide-inherited');
}
}, '-', {
tooltip:'Expand All Members',
iconCls: 'icon-expand-members',
enableToggle: true,
toggleHandler : function(b, pressed){
mainPanel[pressed ? 'addClass' : 'removeClass']('full-details');
}
}*/]
})]
})
var viewport = new Ext.Viewport({
layout:'border',
items:[ hd, api, mainPanel ]
});
var page = window.location.href.split('?')[1];
if(page){
var ps = Ext.urlDecode(page);
var cls = ps['class'];
mainPanel.loadClass('output/' + cls + '.html', cls, ps.member);
}
viewport.doLayout();
setTimeout(function(){
Ext.get('loading').remove();
Ext.get('loading-mask').fadeOut({remove:true});
}, 250);
var filter = new Ext.tree.TreeFilter(api, {
clearBlank: true,
autoClear: true
});
var hiddenPkgs = [];
function filterTree(e){
var text = e.target.value;
Ext.each(hiddenPkgs, function(n){
n.ui.show();
});
if(!text){
filter.clear();
return;
}
api.expandAll();
var re = new RegExp('^' + Ext.escapeRe(text), 'i');
filter.filterBy(function(n){
return !n.attributes.isClass || re.test(n.text);
});
hiddenPkgs = [];
api.root.cascade(function(n){
if(!n.attributes.isClass && n.ui.ctNode.offsetHeight < 3){
n.ui.hide();
hiddenPkgs.push(n);
}
});
}
});
Ext.app.SearchField = Ext.extend(Ext.form.TwinTriggerField, {
initComponent : function(){
Ext.app.SearchField.superclass.initComponent.call(this);
this.on('specialkey', function(f, e){
if(e.getKey() == e.ENTER){
this.onTrigger2Click();
}
}, this);
},
validationEvent:false,
validateOnBlur:false,
trigger1Class:'x-form-clear-trigger',
trigger2Class:'x-form-search-trigger',
hideTrigger1:true,
width:180,
hasSearch : false,
paramName : 'query',
onTrigger1Click : function(){
if(this.hasSearch){
this.store.removeAll();
this.el.dom.value = '';
this.triggers[0].hide();
this.hasSearch = false;
this.focus();
}
},
onTrigger2Click : function(){
var v = this.getRawValue();
if(v.length < 1){
this.onTrigger1Click();
return;
}
if(v.length < 2){
return;
}
var o = {start: 0};
this.store.reload({params:o});
this.hasSearch = true;
this.triggers[0].show();
this.focus();
}
});
Ext.ux.SelectBox = function(config){
this.searchResetDelay = 1000;
config = config || {};
config = Ext.apply(config || {}, {
editable: false,
forceSelection: true,
rowHeight: false,
lastSearchTerm: false,
triggerAction: 'all',
mode: 'local'
});
Ext.ux.SelectBox.superclass.constructor.apply(this, arguments);
this.lastSelectedIndex = this.selectedIndex || 0;
};
Ext.extend(Ext.ux.SelectBox, Ext.form.ComboBox, {
lazyInit: false,
initEvents : function(){
Ext.ux.SelectBox.superclass.initEvents.apply(this, arguments);
this.el.on('keydown', this.keySearch, this, true);
this.cshTask = new Ext.util.DelayedTask(this.clearSearchHistory, this);
},
keySearch : function(e, target, options) {
var raw = e.getKey();
var key = String.fromCharCode(raw);
var startIndex = 0;
if( !this.store.getCount() ) {
return;
}
switch(raw) {
case Ext.EventObject.HOME:
e.stopEvent();
this.selectFirst();
return;
case Ext.EventObject.END:
e.stopEvent();
this.selectLast();
return;
case Ext.EventObject.PAGEDOWN:
this.selectNextPage();
e.stopEvent();
return;
case Ext.EventObject.PAGEUP:
this.selectPrevPage();
e.stopEvent();
return;
}
// skip special keys other than the shift key
if( (e.hasModifier() && !e.shiftKey) || e.isNavKeyPress() || e.isSpecialKey() ) {
return;
}
if( this.lastSearchTerm == key ) {
startIndex = this.lastSelectedIndex;
}
this.search(this.displayField, key, startIndex);
this.cshTask.delay(this.searchResetDelay);
},
onRender : function(ct, position) {
this.store.on('load', this.calcRowsPerPage, this);
Ext.ux.SelectBox.superclass.onRender.apply(this, arguments);
if( this.mode == 'local' ) {
this.calcRowsPerPage();
}
},
onSelect : function(record, index, skipCollapse){
if(this.fireEvent('beforeselect', this, record, index) !== false){
this.setValue(record.data[this.valueField || this.displayField]);
if( !skipCollapse ) {
this.collapse();
}
this.lastSelectedIndex = index + 1;
this.fireEvent('select', this, record, index);
}
},
render : function(ct) {
Ext.ux.SelectBox.superclass.render.apply(this, arguments);
if( Ext.isSafari ) {
this.el.swallowEvent('mousedown', true);
}
this.el.unselectable();
this.innerList.unselectable();
this.trigger.unselectable();
this.innerList.on('mouseup', function(e, target, options) {
if( target.id && target.id == this.innerList.id ) {
return;
}
this.onViewClick();
}, this);
this.innerList.on('mouseover', function(e, target, options) {
if( target.id && target.id == this.innerList.id ) {
return;
}
this.lastSelectedIndex = this.view.getSelectedIndexes()[0] + 1;
this.cshTask.delay(this.searchResetDelay);
}, this);
this.trigger.un('click', this.onTriggerClick, this);
this.trigger.on('mousedown', function(e, target, options) {
e.preventDefault();
this.onTriggerClick();
}, this);
this.on('collapse', function(e, target, options) {
Ext.getDoc().un('mouseup', this.collapseIf, this);
}, this, true);
this.on('expand', function(e, target, options) {
Ext.getDoc().on('mouseup', this.collapseIf, this);
}, this, true);
},
clearSearchHistory : function() {
this.lastSelectedIndex = 0;
this.lastSearchTerm = false;
},
selectFirst : function() {
this.focusAndSelect(this.store.data.first());
},
selectLast : function() {
this.focusAndSelect(this.store.data.last());
},
selectPrevPage : function() {
if( !this.rowHeight ) {
return;
}
var index = Math.max(this.selectedIndex-this.rowsPerPage, 0);
this.focusAndSelect(this.store.getAt(index));
},
selectNextPage : function() {
if( !this.rowHeight ) {
return;
}
var index = Math.min(this.selectedIndex+this.rowsPerPage, this.store.getCount() - 1);
this.focusAndSelect(this.store.getAt(index));
},
search : function(field, value, startIndex) {
field = field || this.displayField;
this.lastSearchTerm = value;
var index = this.store.find.apply(this.store, arguments);
if( index !== -1 ) {
this.focusAndSelect(index);
}
},
focusAndSelect : function(record) {
var index = typeof record === 'number' ? record : this.store.indexOf(record);
this.select(index, this.isExpanded());
this.onSelect(this.store.getAt(record), index, this.isExpanded());
},
calcRowsPerPage : function() {
if( this.store.getCount() ) {
this.rowHeight = Ext.fly(this.view.getNode(0)).getHeight();
this.rowsPerPage = this.maxHeight / this.rowHeight;
} else {
this.rowHeight = false;
}
}
});
Ext.Ajax.on('requestcomplete', function(ajax, xhr, o){
if(typeof urchinTracker == 'function' && o && o.url){
urchinTracker(o.url);
}
});
这个添加tab也只修改了一些地方,还没有简化到最优。由于项目大于10M没法上传,如有需要请留言。
左边是一个树形结构的菜单,右边是一个tab的页面,左边菜单的代码为
/*!
* Ext JS Library 3.0.0
* Copyright(c) 2006-2009 Ext JS, LLC
* licensing@extjs.com
* http://www.extjs.com/license
*/
Docs.classData ={"id":"apidocs","iconCls":"icon-docs","text":"图书管理系统","singleClickExpand":true,"children":[
{"id":"apidocs3","text":"图书管理","iconCls":"icon-pkg","cls":"package","singleClickExpand":true, children:[
{"href":"output/book.jsp","text":"图书信息管理","id":"book","isClass":true,"iconCls":"icon-cls","cls":"cls","leaf":true}]},
{"id":"apidocs1","iconCls":"icon-docs","text":"系统管理","singleClickExpand":true,"children":[
{"href":"output/company.jsp","text":"分公司管理","id":"company","isClass":true,"iconCls":"icon-cmp","cls":"cls","leaf":true}
,
{"href":"output/department.jsp","text":"部门管理管理","id":"department","isClass":true,"iconCls":"icon-cls","cls":"cls","leaf":true}
,
{"href":"output/user.jsp","text":"用户管理","id":"user","isClass":true,"iconCls":"icon-cmp","cls":"cls","leaf":true}
,
{"href":"output/business.jsp","text":"职务管理","id":"business","isClass":true,"iconCls":"icon-cls","cls":"cls","leaf":true}]},
{"id":"apidocs2","iconCls":"icon-docs","text":"科目和分类管理","singleClickExpand":true,"children":[
{"href":"output/subject.jsp","text":"科目管理","id":"subject","isClass":true,"iconCls":"icon-cls","cls":"cls","leaf":true}
,
{"href":"output/class.jsp","text":"分类管理","id":"class","isClass":true,"iconCls":"icon-cmp","cls":"cls","leaf":true}
]}
]};
Docs.icons = {
"book":"icon-cls"
,
"company":"icon-cmp"
,
"department":"icon-cls"
,
"user":"icon-cmp"
,
"business":"icon-cls"
,
"subject":"icon-cls"
,
"class":"icon-cmp"
};
这是菜单的结构,我没有全部改源码,只改成了连接到我的jsp页面,iconCls属性还是和原来的一样。
/*!
* Ext JS Library 3.0.0
* Copyright(c) 2006-2009 Ext JS, LLC
* licensing@extjs.com
* http://www.extjs.com/license
*/
//这个地方要特别注意,要加上这句话,要不他默认的配置连接地址是到EXT网站上去下载这个图片,所以我们要改这个地址,让他不要到网上去下载。
Ext.BLANK_IMAGE_URL = '/book/resources/images/default/s.gif';
Docs = {};
ApiPanel = function() {
ApiPanel.superclass.constructor.call(this, {
id:'api-tree',
region:'west',
split:true,
width: 220,
minSize: 175,
maxSize: 450,
collapsible: true,
margins:'0 0 5 5',
cmargins:'0 0 0 0',
rootVisible:false,
lines:false,
autoScroll:true,
animCollapse:false,
animate: false,
collapseMode:'mini',
loader: new Ext.tree.TreeLoader({
preloadChildren: true,
clearOnLoad: false
}),
root: new Ext.tree.AsyncTreeNode({
id:'root',
expanded:true,
children:[Docs.classData]
}),
collapseFirst:false
});
this.getSelectionModel().on('beforeselect', function(sm, node){
return node.isLeaf();
});
};
Ext.extend(ApiPanel, Ext.tree.TreePanel, {
//当选择了右边的tap就自动选择左边的菜单
selectClass : function(cls){
if(cls){
var parts = cls.split('.');
var last = parts.length-1;
var res = [];
var pkg = [];
for(var i = 0; i < last; i++){
var p = parts[i];
var fc = p.charAt(0);
var staticCls = fc.toUpperCase() == fc;
if(p == 'Ext' || !staticCls){
pkg.push(p);
res[i] = 'pkg-'+pkg.join('.');
}else if(staticCls){
--last;
res.splice(i, 1);
}
}
res[last] = cls
}
}
});
DocPanel = Ext.extend(Ext.Panel, {
closable: true,
autoScroll:true,
initComponent : function(){
var ps = this.cclass.split('.');
this.title = ps[ps.length-1];
DocPanel.superclass.initComponent.call(this);
},
scrollToMember : function(member){
var el = Ext.fly(this.cclass + '-' + member);
if(el){
var top = (el.getOffsetsTo(this.body)[1]) + this.body.dom.scrollTop;
this.body.scrollTo('top', top-25, {duration:.75, callback: this.hlMember.createDelegate(this, [member])});
}
},
scrollToSection : function(id){
var el = Ext.getDom(id);
if(el){
var top = (Ext.fly(el).getOffsetsTo(this.body)[1]) + this.body.dom.scrollTop;
this.body.scrollTo('top', top-25, {duration:.5, callback: function(){
Ext.fly(el).next('h2').pause(.2).highlight('#8DB2E3', {attr:'color'});
}});
}
},
hlMember : function(member){
var el = Ext.fly(this.cclass + '-' + member);
if(el){
el.up('tr').highlight('#cadaf9');
}
}
});
MainPanel = function(){
MainPanel.superclass.constructor.call(this, {
id:'doc-body',
region:'center',
margins:'0 5 5 0',
resizeTabs: true,
minTabWidth: 135,
tabWidth: 135,
closable: true,
enableTabScroll: true,
activeTab: 0,
items: {
id:'welcome-panel',
title: '欢迎',
autoLoad: {url: 'welcome.html', callback: this.initSearch, scope: this},
iconCls:'icon-docs',
autoScroll: true,
tbar: [
]
}
});
};
Ext.extend(MainPanel, Ext.TabPanel, {
initEvents : function(){
MainPanel.superclass.initEvents.call(this);
this.body.on('click', this.onClick, this);
},
onClick: function(e, target){
if(target = e.getTarget('a:not(.exi)', 3)){
var cls = Ext.fly(target).getAttributeNS('ext', 'cls');
e.stopEvent();
if(cls){
var member = Ext.fly(target).getAttributeNS('ext', 'member');
this.loadClass(target.href, cls, member);
}else if(target.className == 'inner-link'){
this.getActiveTab().scrollToSection(target.href.split('#')[1]);
}else{
window.open(target.href);
}
}else if(target = e.getTarget('.micon', 2)){
e.stopEvent();
var tr = Ext.fly(target.parentNode);
if(tr.hasClass('expandable')){
tr.toggleClass('expanded');
}
}
},
loadClass : function(href, cls, member){
var id = 'docs-' + cls;
var tab = this.getComponent(id);
if(tab){
this.setActiveTab(tab);
if(member){
tab.scrollToMember(member);
}
}else{
var autoLoad = {url: href,scripts: true};
if(member){
autoLoad.callback = function(){
Ext.getCmp(id).scrollToMember(member);
}
}
var p = this.add(new DocPanel({
id: id,
cclass : cls,
autoLoad: autoLoad,
iconCls: Docs.icons[cls]
}));
this.setActiveTab(p);
}
}
});
Ext.onReady(function(){
Ext.QuickTips.init();
var api = new ApiPanel();
var mainPanel = new MainPanel();
api.on('click', function(node, e){
if(node.isLeaf()){
e.stopEvent();
mainPanel.loadClass(node.attributes.href, node.text);
}
});
mainPanel.on('tabchange', function(tp, tab){
api.selectClass(tab.cclass);
});
var hd = new Ext.Panel({
border: false,
layout:'anchor',
region:'north',
cls: 'docs-header',
height:60,
items: [{
xtype:'box',
el:'header',
border:false,
anchor: 'none -25'
},
new Ext.Toolbar({
cls:'top-toolbar',
items:[ ' ',
new Ext.form.TextField({
width: 200,
emptyText:'查询菜单',
listeners:{
render: function(f){
f.el.on('keydown', filterTree, f, {buffer: 350});
}
}
}), ' ', ' ',
{
iconCls: 'icon-expand-all',
tooltip: '全部展开',
handler: function(){ api.root.expand(true); }
}, '-', {
iconCls: 'icon-collapse-all',
tooltip: '全部收缩',
handler: function(){ api.root.collapse(true); }
}/**, '->', {
tooltip:'Hide Inherited Members',
iconCls: 'icon-hide-inherited',
enableToggle: true,
toggleHandler : function(b, pressed){
mainPanel[pressed ? 'addClass' : 'removeClass']('hide-inherited');
}
}, '-', {
tooltip:'Expand All Members',
iconCls: 'icon-expand-members',
enableToggle: true,
toggleHandler : function(b, pressed){
mainPanel[pressed ? 'addClass' : 'removeClass']('full-details');
}
}*/]
})]
})
var viewport = new Ext.Viewport({
layout:'border',
items:[ hd, api, mainPanel ]
});
var page = window.location.href.split('?')[1];
if(page){
var ps = Ext.urlDecode(page);
var cls = ps['class'];
mainPanel.loadClass('output/' + cls + '.html', cls, ps.member);
}
viewport.doLayout();
setTimeout(function(){
Ext.get('loading').remove();
Ext.get('loading-mask').fadeOut({remove:true});
}, 250);
var filter = new Ext.tree.TreeFilter(api, {
clearBlank: true,
autoClear: true
});
var hiddenPkgs = [];
function filterTree(e){
var text = e.target.value;
Ext.each(hiddenPkgs, function(n){
n.ui.show();
});
if(!text){
filter.clear();
return;
}
api.expandAll();
var re = new RegExp('^' + Ext.escapeRe(text), 'i');
filter.filterBy(function(n){
return !n.attributes.isClass || re.test(n.text);
});
hiddenPkgs = [];
api.root.cascade(function(n){
if(!n.attributes.isClass && n.ui.ctNode.offsetHeight < 3){
n.ui.hide();
hiddenPkgs.push(n);
}
});
}
});
Ext.app.SearchField = Ext.extend(Ext.form.TwinTriggerField, {
initComponent : function(){
Ext.app.SearchField.superclass.initComponent.call(this);
this.on('specialkey', function(f, e){
if(e.getKey() == e.ENTER){
this.onTrigger2Click();
}
}, this);
},
validationEvent:false,
validateOnBlur:false,
trigger1Class:'x-form-clear-trigger',
trigger2Class:'x-form-search-trigger',
hideTrigger1:true,
width:180,
hasSearch : false,
paramName : 'query',
onTrigger1Click : function(){
if(this.hasSearch){
this.store.removeAll();
this.el.dom.value = '';
this.triggers[0].hide();
this.hasSearch = false;
this.focus();
}
},
onTrigger2Click : function(){
var v = this.getRawValue();
if(v.length < 1){
this.onTrigger1Click();
return;
}
if(v.length < 2){
return;
}
var o = {start: 0};
this.store.reload({params:o});
this.hasSearch = true;
this.triggers[0].show();
this.focus();
}
});
Ext.ux.SelectBox = function(config){
this.searchResetDelay = 1000;
config = config || {};
config = Ext.apply(config || {}, {
editable: false,
forceSelection: true,
rowHeight: false,
lastSearchTerm: false,
triggerAction: 'all',
mode: 'local'
});
Ext.ux.SelectBox.superclass.constructor.apply(this, arguments);
this.lastSelectedIndex = this.selectedIndex || 0;
};
Ext.extend(Ext.ux.SelectBox, Ext.form.ComboBox, {
lazyInit: false,
initEvents : function(){
Ext.ux.SelectBox.superclass.initEvents.apply(this, arguments);
this.el.on('keydown', this.keySearch, this, true);
this.cshTask = new Ext.util.DelayedTask(this.clearSearchHistory, this);
},
keySearch : function(e, target, options) {
var raw = e.getKey();
var key = String.fromCharCode(raw);
var startIndex = 0;
if( !this.store.getCount() ) {
return;
}
switch(raw) {
case Ext.EventObject.HOME:
e.stopEvent();
this.selectFirst();
return;
case Ext.EventObject.END:
e.stopEvent();
this.selectLast();
return;
case Ext.EventObject.PAGEDOWN:
this.selectNextPage();
e.stopEvent();
return;
case Ext.EventObject.PAGEUP:
this.selectPrevPage();
e.stopEvent();
return;
}
// skip special keys other than the shift key
if( (e.hasModifier() && !e.shiftKey) || e.isNavKeyPress() || e.isSpecialKey() ) {
return;
}
if( this.lastSearchTerm == key ) {
startIndex = this.lastSelectedIndex;
}
this.search(this.displayField, key, startIndex);
this.cshTask.delay(this.searchResetDelay);
},
onRender : function(ct, position) {
this.store.on('load', this.calcRowsPerPage, this);
Ext.ux.SelectBox.superclass.onRender.apply(this, arguments);
if( this.mode == 'local' ) {
this.calcRowsPerPage();
}
},
onSelect : function(record, index, skipCollapse){
if(this.fireEvent('beforeselect', this, record, index) !== false){
this.setValue(record.data[this.valueField || this.displayField]);
if( !skipCollapse ) {
this.collapse();
}
this.lastSelectedIndex = index + 1;
this.fireEvent('select', this, record, index);
}
},
render : function(ct) {
Ext.ux.SelectBox.superclass.render.apply(this, arguments);
if( Ext.isSafari ) {
this.el.swallowEvent('mousedown', true);
}
this.el.unselectable();
this.innerList.unselectable();
this.trigger.unselectable();
this.innerList.on('mouseup', function(e, target, options) {
if( target.id && target.id == this.innerList.id ) {
return;
}
this.onViewClick();
}, this);
this.innerList.on('mouseover', function(e, target, options) {
if( target.id && target.id == this.innerList.id ) {
return;
}
this.lastSelectedIndex = this.view.getSelectedIndexes()[0] + 1;
this.cshTask.delay(this.searchResetDelay);
}, this);
this.trigger.un('click', this.onTriggerClick, this);
this.trigger.on('mousedown', function(e, target, options) {
e.preventDefault();
this.onTriggerClick();
}, this);
this.on('collapse', function(e, target, options) {
Ext.getDoc().un('mouseup', this.collapseIf, this);
}, this, true);
this.on('expand', function(e, target, options) {
Ext.getDoc().on('mouseup', this.collapseIf, this);
}, this, true);
},
clearSearchHistory : function() {
this.lastSelectedIndex = 0;
this.lastSearchTerm = false;
},
selectFirst : function() {
this.focusAndSelect(this.store.data.first());
},
selectLast : function() {
this.focusAndSelect(this.store.data.last());
},
selectPrevPage : function() {
if( !this.rowHeight ) {
return;
}
var index = Math.max(this.selectedIndex-this.rowsPerPage, 0);
this.focusAndSelect(this.store.getAt(index));
},
selectNextPage : function() {
if( !this.rowHeight ) {
return;
}
var index = Math.min(this.selectedIndex+this.rowsPerPage, this.store.getCount() - 1);
this.focusAndSelect(this.store.getAt(index));
},
search : function(field, value, startIndex) {
field = field || this.displayField;
this.lastSearchTerm = value;
var index = this.store.find.apply(this.store, arguments);
if( index !== -1 ) {
this.focusAndSelect(index);
}
},
focusAndSelect : function(record) {
var index = typeof record === 'number' ? record : this.store.indexOf(record);
this.select(index, this.isExpanded());
this.onSelect(this.store.getAt(record), index, this.isExpanded());
},
calcRowsPerPage : function() {
if( this.store.getCount() ) {
this.rowHeight = Ext.fly(this.view.getNode(0)).getHeight();
this.rowsPerPage = this.maxHeight / this.rowHeight;
} else {
this.rowHeight = false;
}
}
});
Ext.Ajax.on('requestcomplete', function(ajax, xhr, o){
if(typeof urchinTracker == 'function' && o && o.url){
urchinTracker(o.url);
}
});
这个添加tab也只修改了一些地方,还没有简化到最优。由于项目大于10M没法上传,如有需要请留言。
评论
17 楼
843630311
2013-08-07
正在学习843630311@qq.com,谢谢啦
16 楼
风凌雪
2011-11-17
我也想学习学习啊,i@zhangyuwei.me。谢谢
15 楼
kukule520129
2011-09-27
谢谢我需要一份:
42552346@qq.com
谢谢了。
42552346@qq.com
谢谢了。
14 楼
panghaichao
2011-08-18
给我发一份 panghaichao@163.com 谢谢了
13 楼
leimeng.2008
2011-08-17
lyhc0417@163.com 谢谢,非常感谢!!!!
12 楼
liudeqiang0147
2010-11-25
正在学习中。。。。。。给我一份,boys_0147@163.com 谢谢!
11 楼
tyyytcj
2010-03-25
请楼主发份给我吧,目前正在学习ext
cheng_tyyyt@yahoo.com.cn
cheng_tyyyt@yahoo.com.cn
10 楼
xiantiaolang
2009-12-28
正在学习这个,先谢谢楼主
xiantiaolang@gmail.com
xiantiaolang@gmail.com
9 楼
wkshippou
2009-11-24
1004852108@qq.com 学习学习
8 楼
wyj1983
2009-11-06
学习中,谢谢楼主! 可以给我发一份吗?
wangyingjie2008@163.com
wangyingjie2008@163.com
7 楼
ysen
2009-10-14
给我一份不知道来迟否ysenfu@sina.com
6 楼
77woshi
2009-09-28
edwin.akon@gmail.com,谢谢
5 楼
liu_yutao
2009-09-24
我也想要,邮箱793848031@qq.com
4 楼
jhon85
2009-09-15
正在学习中,看了非常有兴趣,谢谢楼主了。给我一份。
jhon85@vip.qq.com
jhon85@vip.qq.com
3 楼
hucjie
2009-09-10
需要学习
hzjie520@yahoo.com.cn
谢谢
hzjie520@yahoo.com.cn
谢谢
2 楼
tristan89
2009-09-07
正要学习这个
tristan89@126.com
先谢谢楼主啦·
tristan89@126.com
先谢谢楼主啦·
1 楼
jameswangme
2009-08-25
给一份我
jjjameswang@sina.com
jjjameswang@sina.com
相关推荐
总的来说,Ext3.0是一个功能强大的JavaScript框架,结合其API文档和示例,开发者可以创建出功能丰富、用户体验优秀的Web应用程序。通过深入研究源代码和实践示例,开发者不仅可以掌握基本的组件使用,还能进一步提升...
EXT 3.0 是一个基于 JavaScript 的富因特网应用程序(Rich Internet Application, RIA)开发框架,尤其在Web应用程序的用户界面构建方面表现出色。它提供了大量的组件、布局管理和数据绑定功能,使得开发者能够创建...
总之,Ext3.0结合中文API,为中文开发者提供了一个功能强大、文档齐全的Web开发框架,大大降低了开发复杂应用的门槛,提升了开发效率。通过深入学习和熟练运用,开发者可以构建出高效、美观且用户体验优秀的Web应用...
EXT3.0中文API文档是针对EXT JavaScript库的版本3.0所编写的详细参考资料,主要面向前端开发者,特别是那些在Web应用中使用EXT3.0框架进行开发的专业人士。EXT是一个强大的用户界面库,提供了丰富的组件和功能,用于...
中文API CHM帮助文档是开发者学习和使用Ext 3.0的重要参考资料,它提供了详细的类库、方法、属性和事件的说明。 首先,让我们深入了解一下Ext 3.0的核心特性: 1. **组件系统**:Ext 3.0提供了一套完整的组件库,...
EXT 3.0 API 是一个针对Web开发的JavaScript库,主要用在构建富客户端应用程序。EXT是一个强大的前端框架,尤其在创建数据驱动、用户界面丰富的Web应用方面表现出色。EXT 3.0版本是该框架的一个重要里程碑,它带来了...
总而言之,EXT3.0中文API文档是学习EXT框架的关键资料,它将帮助开发者快速上手EXT,充分利用其功能来构建功能强大、用户友好的Web应用程序。无论你是初学者还是经验丰富的EXT开发者,这份文档都将为你提供宝贵的...
在实际开发中,开发者需要根据项目需求选择合适的EXT JS组件,并通过EXT3.0 API来配置和定制组件的行为。例如,创建一个数据网格可能涉及以下步骤: 1. 创建数据存储(Store),指定数据源和字段。 2. 定义列模型...
EXT3.0中文API是针对EXT JavaScript库的一个关键更新,主要目标是提供全面的中文文档,以便于中国的开发者更好地理解和使用EXT库。EXT是一个强大的前端开发框架,特别适合构建富互联网应用程序(RIA)。EXT3.0引入了...
4. **框架支持**:除了EXT3.0,Spket还支持其他流行的JavaScript框架,如Dojo、Yahoo UI(YUI)、jQuery等,为多框架开发提供便利。 5. **模板和快捷键**:提供了一系列常用的代码模板和快捷键,简化常见的编程任务...
"Ext 3.0 中文API.rar"是一个压缩包,其中包含了一份中文版的Ext 3.0 API文档,这对于中国开发者来说是一个极其宝贵的资源,因为它提供了对Ext库的详细中文解释,便于理解和使用。 在深入研究Ext 3.0 API之前,我们...
中文API文档的出现极大地便利了中文用户,帮助他们更快速地理解和使用EXT 3.0的各种功能。 在EXT 3.0 中文API文档中,你可以找到以下主要知识点: 1. **EXT基本概念**:EXT 3.0的核心是其组件模型,所有元素都是可...
Ext3.0的API文档详细地列出了框架提供的各种类、方法、属性和事件,帮助开发者理解如何使用这些功能来构建复杂的用户界面和交互逻辑。 在Ext3.0中文API文档中,你可以找到以下关键知识点: 1. **类体系结构**:Ext...
《Ext 3.0 中文文档》是Ext 3.0框架的重要参考资料,对于学习和使用Ext 3.0的开发者来说非常关键。这份文档以中文形式呈现,方便了中文用户理解并掌握该框架的使用方法。文档可能包含了以下主要知识点: 1. **基本...
Ext 3.0 是一个基于 JavaScript 的开源前端框架,用于构建富互联网应用程序(RIA)。它提供了丰富的组件库,包括窗口、面板、表格、菜单等,支持数据绑定和事件驱动的编程模型,使得开发者能够创建复杂且用户友好的...
Ext3.0中文帮助手册是针对Ext JavaScript库的详尽指南,主要面向开发者,提供了关于Ext 3.0版本的API文档。这个手册是开发基于Web的富客户端应用的重要参考资料,因为Ext是一个强大的用户界面框架,它允许创建复杂的...
10. **实战教程**:“ExtJS实用教程.pdf”可能包含实际的案例和项目,帮助开发者通过实践掌握Ext 3.0的使用。 通过深入学习和实践这两个资源,开发者将能够熟练掌握Ext 3.0,从而创建出高效、功能丰富的Web应用程序...
这份"Ext3.0中文文档"提供了全面的指南,帮助开发者深入理解并有效利用这个框架。 一、Store:在Ext 3.0中,Store是数据管理的核心。它负责存储和管理数据,与各种UI组件(如Grids和Trees)进行交互。Store可以连接...
EXT 3.0是EXT JS框架的一个重要版本,它是一个基于JavaScript的富因特网应用程序(RIA)开发库。EXT JS允许开发者构建功能强大的、交互性强的Web应用,无需深入理解底层浏览器差异和技术细节。EXT 3.0源码与帮助文档...