3
* Copyright(c) 2006-2008, Ext JS, LLC.
6
* http://extjs.com/license
10
* @class Ext.ContentPanel
11
* @extends Ext.util.Observable
12
* A basic ContentPanel element.
13
* @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
14
* @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
15
* @cfg {Boolean/Object} autoCreate True to auto generate the DOM element for this panel, or a {@link Ext.DomHelper} config of the element to create
16
* @cfg {Boolean} closable True if the panel can be closed/removed
17
* @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
18
* @cfg {Mixed} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
19
* @cfg {Toolbar} toolbar A toolbar for this panel
20
* @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
21
* @cfg {String} title The title for this panel
22
* @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
23
* @cfg {String} url Calls {@link #setUrl} with this value
24
* @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
25
* @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
27
* Create a new ContentPanel.
28
* @param {Mixed} el The container element for this panel
29
* @param {String/Object} config A string to set only the title or a config object
30
* @param {String} content (optional) Set the HTML content for this panel
32
Ext.ContentPanel = function(el, config, content){
37
this.el = Ext.get(el);
38
if(!this.el && config && config.autoCreate){
39
if(typeof config.autoCreate == "object"){
40
if(!config.autoCreate.id){
41
config.autoCreate.id = config.id||el;
43
this.el = Ext.DomHelper.append(document.body,
44
config.autoCreate, true);
46
this.el = Ext.DomHelper.append(document.body,
47
{tag: "div", cls: "x-layout-inactive-content", id: config.id||el}, true);
50
this.closable = false;
53
if(typeof config == "string"){
56
Ext.apply(this, config);
59
this.resizeEl = Ext.get(this.resizeEl, true);
61
this.resizeEl = this.el;
66
* Fires when this panel is activated.
67
* @param {Ext.ContentPanel} this
72
* Fires when this panel is activated.
73
* @param {Ext.ContentPanel} this
79
* Fires when this panel is resized if fitToFrame is true.
80
* @param {Ext.ContentPanel} this
81
* @param {Number} width The width after any component adjustments
82
* @param {Number} height The height after any component adjustments
87
this.resizeEl.setStyle("overflow", "auto");
89
content = content || this.content;
91
this.setContent(content);
93
if(config && config.url){
94
this.setUrl(this.url, this.params, this.loadOnce);
96
Ext.ContentPanel.superclass.constructor.call(this);
99
Ext.extend(Ext.ContentPanel, Ext.util.Observable, {
101
setRegion : function(region){
102
this.region = region;
104
this.el.replaceClass("x-layout-inactive-content", "x-layout-active-content");
106
this.el.replaceClass("x-layout-active-content", "x-layout-inactive-content");
111
* Returns the toolbar for this Panel if one was configured.
112
* @return {Ext.Toolbar}
114
getToolbar : function(){
118
setActiveState : function(active){
119
this.active = active;
121
this.fireEvent("deactivate", this);
123
this.fireEvent("activate", this);
127
* Updates this panel's element
128
* @param {String} content The new content
129
* @param {Boolean} loadScripts (optional) true to look for and process scripts
131
setContent : function(content, loadScripts){
132
this.el.update(content, loadScripts);
135
ignoreResize : function(w, h){
136
if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
139
this.lastSize = {width: w, height: h};
144
* Get the {@link Ext.Updater} for this panel. Enables you to perform Ajax updates.
145
* @return {Ext.Updater} The Updater
147
getUpdater : function(){
148
return this.el.getUpdater();
151
* Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
152
* @param {Object/String/Function} url The URL for this request or a function to call to get the URL or a config object containing any of the following options:
156
params: {param1: "foo", param2: "bar"}, // or a URL encoded string
157
callback: yourFunction,
158
scope: yourObject, //(optional scope)
166
* The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
167
* are shorthand for <i>disableCaching</i>, <i>indicatorText</i> and <i>loadScripts</i> and are used to set their associated property on this panel Updater instance.
168
* @param {String/Object} params (optional) The parameters to pass as either a URL encoded string "param1=1&param2=2" or an object {param1: 1, param2: 2}
169
* @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
170
* @param {Boolean} discardUrl (optional) By default when you execute an update the defaultUrl is changed to the last used URL. If true, it will not store the URL.
171
* @return {Ext.ContentPanel} this
174
this.el.load.apply(this.el, arguments);
180
* Set a URL to be used to load the content for this panel. When this panel is activated, the content will be loaded from that URL.
181
* @param {String/Function} url The URL to load the content from or a function to call to get the URL
182
* @param {String/Object} params (optional) The string params for the update call or an object of the params. See {@link Ext.Updater#update} for more details. (Defaults to null)
183
* @param {Boolean} loadOnce (optional) Whether to only load the content once. If this is false it makes the Ajax call every time this panel is activated. (Defaults to false)
184
* @return {Ext.Updater} The Updater
186
setUrl : function(url, params, loadOnce){
187
if(this.refreshDelegate){
188
this.removeListener("activate", this.refreshDelegate);
190
this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
191
this.on("activate", this.refreshDelegate);
192
return this.el.getUpdater();
195
_handleRefresh : function(url, params, loadOnce){
196
if(!loadOnce || !this.loaded){
197
var updater = this.el.getUpdater();
198
updater.update(url, params, this._setLoaded.createDelegate(this));
202
_setLoaded : function(){
207
* Returns this panel's id
215
* Returns this panel's element
216
* @return {Ext.Element}
222
adjustForComponents : function(width, height){
223
if(this.resizeEl != this.el){
224
width -= this.el.getFrameWidth('lr');
225
height -= this.el.getFrameWidth('tb');
228
var te = this.toolbar.getEl();
229
height -= te.getHeight();
232
if(this.adjustments){
233
width += this.adjustments[0];
234
height += this.adjustments[1];
236
return {"width": width, "height": height};
239
setSize : function(width, height){
240
if(this.fitToFrame && !this.ignoreResize(width, height)){
241
if(this.fitContainer && this.resizeEl != this.el){
242
this.el.setSize(width, height);
244
var size = this.adjustForComponents(width, height);
245
this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
246
this.fireEvent('resize', this, size.width, size.height);
251
* Returns this panel's title
254
getTitle : function(){
259
* Set this panel's title
260
* @param {String} title
262
setTitle : function(title){
265
this.region.updatePanelTitle(this, title);
270
* Returns true is this panel was configured to be closable
273
isClosable : function(){
274
return this.closable;
277
beforeSlide : function(){
279
this.resizeEl.clip();
282
afterSlide : function(){
284
this.resizeEl.unclip();
288
* Force a content refresh from the URL specified in the {@link #setUrl} method.
289
* Will fail silently if the {@link #setUrl} method has not been called.
290
* This does not activate the panel, just updates its content.
292
refresh : function(){
293
if(this.refreshDelegate){
295
this.refreshDelegate();
300
* Destroys this panel
302
destroy : function(){
303
this.el.removeAllListeners();
304
var tempEl = document.createElement("span");
305
tempEl.appendChild(this.el.dom);
306
tempEl.innerHTML = "";
312
Ext.ContentPanel.prototype.getUpdateManager = Ext.ContentPanel.prototype.getUpdater;
315
* @class Ext.GridPanel
316
* @extends Ext.ContentPanel
318
* Create a new GridPanel.
319
* @param {Ext.grid.Grid} grid The grid for this panel
320
* @param {String/Object} config A string to set only the panel's title, or a config object
322
Ext.GridPanel = function(grid, config){
323
this.wrapper = Ext.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
324
{tag: "div", cls: "x-layout-grid-wrapper x-layout-inactive-content"}, true);
325
this.wrapper.dom.appendChild(grid.getGridEl().dom);
326
Ext.GridPanel.superclass.constructor.call(this, this.wrapper, config);
328
this.toolbar.el.insertBefore(this.wrapper.dom.firstChild);
330
grid.monitorWindowResize = false; // turn off autosizing
331
grid.autoHeight = false;
332
grid.autoWidth = false;
334
this.grid.getGridEl().replaceClass("x-layout-inactive-content", "x-layout-component-panel");
337
Ext.extend(Ext.GridPanel, Ext.ContentPanel, {
343
* Returns the grid for this panel
344
* @return {Ext.grid.Grid}
346
getGrid : function(){
350
setSize : function(width, height){
351
if(!this.ignoreResize(width, height)){
352
var grid = this.grid;
353
var size = this.adjustForComponents(width, height);
354
grid.getGridEl().setSize(size.width, size.height);
359
beforeSlide : function(){
360
this.grid.getView().scroller.clip();
363
afterSlide : function(){
364
this.grid.getView().scroller.unclip();
367
destroy : function(){
370
Ext.GridPanel.superclass.destroy.call(this);
376
* @class Ext.NestedLayoutPanel
377
* @extends Ext.ContentPanel
379
* Create a new NestedLayoutPanel.
380
* @param {Ext.BorderLayout} layout The layout for this panel
381
* @param {String/Object} config A string to set only the title or a config object
383
Ext.NestedLayoutPanel = function(layout, config){
384
Ext.NestedLayoutPanel.superclass.constructor.call(this, layout.getEl(), config);
385
layout.monitorWindowResize = false; // turn off autosizing
386
this.layout = layout;
387
this.layout.getEl().addClass("x-layout-nested-layout");
390
Ext.extend(Ext.NestedLayoutPanel, Ext.ContentPanel, {
392
setSize : function(width, height){
393
if(!this.ignoreResize(width, height)){
394
var size = this.adjustForComponents(width, height);
395
var el = this.layout.getEl();
396
el.setSize(size.width, size.height);
397
var touch = el.dom.offsetWidth;
398
this.layout.layout();
399
// ie requires a double layout on the first pass
400
if(Ext.isIE && !this.initialized){
401
this.initialized = true;
402
this.layout.layout();
408
* Returns the nested BorderLayout for this panel
409
* @return {Ext.BorderLayout}
411
getLayout : function(){
416
Ext.ScrollPanel = function(el, config, content){
417
config = config || {};
418
config.fitToFrame = true;
419
Ext.ScrollPanel.superclass.constructor.call(this, el, config, content);
421
this.el.dom.style.overflow = "hidden";
422
var wrap = this.el.wrap({cls: "x-scroller x-layout-inactive-content"});
423
this.el.removeClass("x-layout-inactive-content");
424
this.el.on("mousewheel", this.onWheel, this);
426
var up = wrap.createChild({cls: "x-scroller-up", html: " "}, this.el.dom);
427
var down = wrap.createChild({cls: "x-scroller-down", html: " "});
428
up.unselectable(); down.unselectable();
429
up.on("click", this.scrollUp, this);
430
down.on("click", this.scrollDown, this);
431
up.addClassOnOver("x-scroller-btn-over");
432
down.addClassOnOver("x-scroller-btn-over");
433
up.addClassOnClick("x-scroller-btn-click");
434
down.addClassOnClick("x-scroller-btn-click");
435
this.adjustments = [0, -(up.getHeight() + down.getHeight())];
437
this.resizeEl = this.el;
438
this.el = wrap; this.up = up; this.down = down;
441
Ext.extend(Ext.ScrollPanel, Ext.ContentPanel, {
444
scrollUp : function(){
445
this.resizeEl.scroll("up", this.increment, {callback: this.afterScroll, scope: this});
448
scrollDown : function(){
449
this.resizeEl.scroll("down", this.increment, {callback: this.afterScroll, scope: this});
452
afterScroll : function(){
453
var el = this.resizeEl;
454
var t = el.dom.scrollTop, h = el.dom.scrollHeight, ch = el.dom.clientHeight;
455
this.up[t == 0 ? "addClass" : "removeClass"]("x-scroller-btn-disabled");
456
this.down[h - t <= ch ? "addClass" : "removeClass"]("x-scroller-btn-disabled");
459
setSize : function(){
460
Ext.ScrollPanel.superclass.setSize.apply(this, arguments);
464
onWheel : function(e){
465
var d = e.getWheelDelta();
466
this.resizeEl.dom.scrollTop -= (d*this.wheelIncrement);
471
setContent : function(content, loadScripts){
472
this.resizeEl.update(content, loadScripts);
b'\\ No newline at end of file'