4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-panel-Header'>/**
19 </span> * @class Ext.panel.Header
20 * @extends Ext.container.Container
21 * Simple header class which is used for on {@link Ext.panel.Panel} and {@link Ext.window.Window}
24 Ext.define('Ext.panel.Header', {
25 extend: 'Ext.container.Container',
26 uses: ['Ext.panel.Tool', 'Ext.draw.Component', 'Ext.util.CSS'],
27 alias: 'widget.header',
34 renderTpl: ['<div class="{baseCls}-body<tpl if="bodyCls"> {bodyCls}</tpl><tpl if="uiCls"><tpl for="uiCls"> {parent.baseCls}-body-{parent.ui}-{.}</tpl></tpl>"<tpl if="bodyStyle"> style="{bodyStyle}"</tpl>></div>'],
36 initComponent: function() {
43 me.indicateDragCls = me.baseCls + '-draggable';
44 me.title = me.title || '&#160;';
45 me.tools = me.tools || [];
46 me.items = me.items || [];
47 me.orientation = me.orientation || 'horizontal';
48 me.dock = (me.dock) ? me.dock : (me.orientation == 'horizontal') ? 'top' : 'left';
50 //add the dock as a ui
51 //this is so we support top/right/left/bottom headers
52 me.addClsWithUI(me.orientation);
53 me.addClsWithUI(me.dock);
55 Ext.applyIf(me.renderSelectors, {
56 body: '.' + me.baseCls + '-body'
60 if (!Ext.isEmpty(me.iconCls)) {
62 me.items.push(me.iconCmp);
66 if (me.orientation == 'vertical') {
67 // Hack for IE6/7's inability to display an inline-block
68 if (Ext.isIE6 || Ext.isIE7) {
69 me.width = this.width || 24;
70 } else if (Ext.isIEQuirks) {
71 me.width = this.width || 25;
77 clearInnerCtOnLayout: true,
78 bindToOwnerCtContainer: false
81 cls: me.baseCls + '-text',
89 if (Ext.isArray(ui)) {
92 rule = Ext.util.CSS.getRule('.' + me.baseCls + '-text-' + ui);
97 Ext.apply(me.textConfig, {
98 'font-family': style.fontFamily,
99 'font-weight': style.fontWeight,
100 'font-size': style.fontSize,
104 me.titleCmp = Ext.create('Ext.draw.Component', {
105 ariaRole : 'heading',
110 items: [ me.textConfig ],
112 textEl: '.' + me.baseCls + '-text'
119 clearInnerCtOnLayout: true,
120 bindToOwnerCtContainer: false
122 me.titleCmp = Ext.create('Ext.Component', {
124 ariaRole : 'heading',
126 renderTpl : ['<span class="{cls}-text {cls}-text-{ui}">{title}</span>'],
133 textEl: '.' + me.baseCls + '-text'
137 me.items.push(me.titleCmp);
148 me.items = me.items.concat(me.tools);
152 initIconCmp: function() {
153 this.iconCmp = Ext.create('Ext.Component', {
155 renderTpl : ['<img alt="" src="{blank}" class="{cls}-icon {iconCls}"/>'],
157 blank : Ext.BLANK_IMAGE_URL,
159 iconCls: this.iconCls,
160 orientation: this.orientation
163 iconEl: '.' + this.baseCls + '-icon'
165 iconCls: this.iconCls
169 afterRender: function() {
172 me.el.unselectable();
173 if (me.indicateDrag) {
174 me.el.addCls(me.indicateDragCls);
183 afterLayout: function() {
185 me.callParent(arguments);
187 // IE7 needs a forced repaint to make the top framing div expand to full width
194 addUIClsToElement: function(cls, force) {
197 me.callParent(arguments);
199 if (!force && me.rendered) {
200 me.body.addCls(me.baseCls + '-body-' + cls);
201 me.body.addCls(me.baseCls + '-body-' + me.ui + '-' + cls);
206 removeUIClsFromElement: function(cls, force) {
209 me.callParent(arguments);
211 if (!force && me.rendered) {
212 me.body.removeCls(me.baseCls + '-body-' + cls);
213 me.body.removeCls(me.baseCls + '-body-' + me.ui + '-' + cls);
218 addUIToElement: function(force) {
221 me.callParent(arguments);
223 if (!force && me.rendered) {
224 me.body.addCls(me.baseCls + '-body-' + me.ui);
227 if (!force && me.titleCmp && me.titleCmp.rendered && me.titleCmp.textEl) {
228 me.titleCmp.textEl.addCls(me.baseCls + '-text-' + me.ui);
233 removeUIFromElement: function() {
236 me.callParent(arguments);
239 me.body.removeCls(me.baseCls + '-body-' + me.ui);
242 if (me.titleCmp && me.titleCmp.rendered && me.titleCmp.textEl) {
243 me.titleCmp.textEl.removeCls(me.baseCls + '-text-' + me.ui);
247 onClick: function(e) {
248 if (!e.getTarget(Ext.baseCSSPrefix + 'tool')) {
249 this.fireEvent('click', e);
253 getTargetEl: function() {
254 return this.body || this.frameBody || this.el;
257 <span id='Ext-panel-Header-method-setTitle'> /**
258 </span> * Sets the title of the header.
259 * @param {String} title The title to be set
261 setTitle: function(title) {
264 if (me.titleCmp.rendered) {
265 if (me.titleCmp.surface) {
266 me.title = title || '';
267 var sprite = me.titleCmp.surface.items.items[0],
268 surface = me.titleCmp.surface;
270 surface.remove(sprite);
271 me.textConfig.type = 'text';
272 me.textConfig.text = title;
273 sprite = surface.add(me.textConfig);
274 sprite.setAttributes({
279 me.titleCmp.autoSizeSurface();
281 me.title = title || '&#160;';
282 me.titleCmp.textEl.update(me.title);
303 <span id='Ext-panel-Header-method-setIconCls'> /**
304 </span> * Sets the CSS class that provides the icon image for this panel. This method will replace any existing
305 * icon class if one has already been set and fire the {@link #iconchange} event after completion.
306 * @param {String} cls The new CSS class name
308 setIconCls: function(cls) {
312 this.insert(0, this.iconCmp);
315 if (!cls || !cls.length) {
316 this.iconCmp.destroy();
319 var iconCmp = this.iconCmp,
322 el.removeCls(iconCmp.iconCls);
324 iconCmp.iconCls = cls;
329 <span id='Ext-panel-Header-method-addTool'> /**
330 </span> * Add a tool to the header
331 * @param {Object} tool
333 addTool: function(tool) {
334 this.tools.push(this.add(tool));
337 <span id='Ext-panel-Header-method-onAdd'> /**
339 * Set up the tools.&lt;tool type> link in the owning Panel.
340 * Bind the tool to its owning Panel.
344 onAdd: function(component, index) {
345 this.callParent([arguments]);
346 if (component instanceof Ext.panel.Tool) {
347 component.bindTo(this.ownerCt);
348 this.tools[component.type] = component;