📄 contentpanels.js
字号:
setSize : function(width, height){
if(this.fitToFrame && !this.ignoreResize(width, height)){
if(this.fitContainer && this.resizeEl != this.el){
this.el.setSize(width, height);
}
var size = this.adjustForComponents(width, height);
this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
this.fireEvent('resize', this, size.width, size.height);
}
},
/**
* Returns this panel's title
* @return {String}
*/
getTitle : function(){
return this.title;
},
/**
* Set this panel's title
* @param {String} title
*/
setTitle : function(title){
this.title = title;
if(this.region){
this.region.updatePanelTitle(this, title);
}
},
/**
* Returns true is this panel was configured to be closable
* @return {Boolean}
*/
isClosable : function(){
return this.closable;
},
beforeSlide : function(){
this.el.clip();
this.resizeEl.clip();
},
afterSlide : function(){
this.el.unclip();
this.resizeEl.unclip();
},
/**
* Force a content refresh from the URL specified in the {@link #setUrl} method.
* Will fail silently if the {@link #setUrl} method has not been called.
* This does not activate the panel, just updates its content.
*/
refresh : function(){
if(this.refreshDelegate){
this.loaded = false;
this.refreshDelegate();
}
},
/**
* Destroys this panel
*/
destroy : function(){
this.el.removeAllListeners();
var tempEl = document.createElement("span");
tempEl.appendChild(this.el.dom);
tempEl.innerHTML = "";
this.el.remove();
this.el = null;
}
});
Ext.ContentPanel.prototype.getUpdateManager = Ext.ContentPanel.prototype.getUpdater;
/**
* @class Ext.GridPanel
* @extends Ext.ContentPanel
* @constructor
* Create a new GridPanel.
* @param {Ext.grid.Grid} grid The grid for this panel
* @param {String/Object} config A string to set only the panel's title, or a config object
*/
Ext.GridPanel = function(grid, config){
this.wrapper = Ext.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
{tag: "div", cls: "x-layout-grid-wrapper x-layout-inactive-content"}, true);
this.wrapper.dom.appendChild(grid.getGridEl().dom);
Ext.GridPanel.superclass.constructor.call(this, this.wrapper, config);
if(this.toolbar){
this.toolbar.el.insertBefore(this.wrapper.dom.firstChild);
}
grid.monitorWindowResize = false; // turn off autosizing
grid.autoHeight = false;
grid.autoWidth = false;
this.grid = grid;
this.grid.getGridEl().replaceClass("x-layout-inactive-content", "x-layout-component-panel");
};
Ext.extend(Ext.GridPanel, Ext.ContentPanel, {
getId : function(){
return this.grid.id;
},
/**
* Returns the grid for this panel
* @return {Ext.grid.Grid}
*/
getGrid : function(){
return this.grid;
},
setSize : function(width, height){
if(!this.ignoreResize(width, height)){
var grid = this.grid;
var size = this.adjustForComponents(width, height);
grid.getGridEl().setSize(size.width, size.height);
grid.autoSize();
}
},
beforeSlide : function(){
this.grid.getView().scroller.clip();
},
afterSlide : function(){
this.grid.getView().scroller.unclip();
},
destroy : function(){
this.grid.destroy();
delete this.grid;
Ext.GridPanel.superclass.destroy.call(this);
}
});
/**
* @class Ext.NestedLayoutPanel
* @extends Ext.ContentPanel
* @constructor
* Create a new NestedLayoutPanel.
* @param {Ext.BorderLayout} layout The layout for this panel
* @param {String/Object} config A string to set only the title or a config object
*/
Ext.NestedLayoutPanel = function(layout, config){
Ext.NestedLayoutPanel.superclass.constructor.call(this, layout.getEl(), config);
layout.monitorWindowResize = false; // turn off autosizing
this.layout = layout;
this.layout.getEl().addClass("x-layout-nested-layout");
};
Ext.extend(Ext.NestedLayoutPanel, Ext.ContentPanel, {
setSize : function(width, height){
if(!this.ignoreResize(width, height)){
var size = this.adjustForComponents(width, height);
var el = this.layout.getEl();
el.setSize(size.width, size.height);
var touch = el.dom.offsetWidth;
this.layout.layout();
// ie requires a double layout on the first pass
if(Ext.isIE && !this.initialized){
this.initialized = true;
this.layout.layout();
}
}
},
/**
* Returns the nested BorderLayout for this panel
* @return {Ext.BorderLayout}
*/
getLayout : function(){
return this.layout;
}
});
Ext.ScrollPanel = function(el, config, content){
config = config || {};
config.fitToFrame = true;
Ext.ScrollPanel.superclass.constructor.call(this, el, config, content);
this.el.dom.style.overflow = "hidden";
var wrap = this.el.wrap({cls: "x-scroller x-layout-inactive-content"});
this.el.removeClass("x-layout-inactive-content");
this.el.on("mousewheel", this.onWheel, this);
var up = wrap.createChild({cls: "x-scroller-up", html: " "}, this.el.dom);
var down = wrap.createChild({cls: "x-scroller-down", html: " "});
up.unselectable(); down.unselectable();
up.on("click", this.scrollUp, this);
down.on("click", this.scrollDown, this);
up.addClassOnOver("x-scroller-btn-over");
down.addClassOnOver("x-scroller-btn-over");
up.addClassOnClick("x-scroller-btn-click");
down.addClassOnClick("x-scroller-btn-click");
this.adjustments = [0, -(up.getHeight() + down.getHeight())];
this.resizeEl = this.el;
this.el = wrap; this.up = up; this.down = down;
};
Ext.extend(Ext.ScrollPanel, Ext.ContentPanel, {
increment : 100,
wheelIncrement : 5,
scrollUp : function(){
this.resizeEl.scroll("up", this.increment, {callback: this.afterScroll, scope: this});
},
scrollDown : function(){
this.resizeEl.scroll("down", this.increment, {callback: this.afterScroll, scope: this});
},
afterScroll : function(){
var el = this.resizeEl;
var t = el.dom.scrollTop, h = el.dom.scrollHeight, ch = el.dom.clientHeight;
this.up[t == 0 ? "addClass" : "removeClass"]("x-scroller-btn-disabled");
this.down[h - t <= ch ? "addClass" : "removeClass"]("x-scroller-btn-disabled");
},
setSize : function(){
Ext.ScrollPanel.superclass.setSize.apply(this, arguments);
this.afterScroll();
},
onWheel : function(e){
var d = e.getWheelDelta();
this.resizeEl.dom.scrollTop -= (d*this.wheelIncrement);
this.afterScroll();
e.stopEvent();
},
setContent : function(content, loadScripts){
this.resizeEl.update(content, loadScripts);
}
});
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -