ux-all-debug.js
资源名称:ext-3.0.0.zip [点击查看]
上传用户:shuoshiled
上传日期:2018-01-28
资源大小:10124k
文件大小:193k
源码类别:
中间件编程
开发平台:
JavaScript
- /*! * Ext JS Library 3.0.0 * Copyright(c) 2006-2009 Ext JS, LLC * licensing@extjs.com * http://www.extjs.com/license */ Ext.ns('Ext.ux.grid'); /** * @class Ext.ux.grid.BufferView * @extends Ext.grid.GridView * A custom GridView which renders rows on an as-needed basis. */ Ext.ux.grid.BufferView = Ext.extend(Ext.grid.GridView, { /** * @cfg {Number} rowHeight * The height of a row in the grid. */ rowHeight: 19, /** * @cfg {Number} borderHeight * The combined height of border-top and border-bottom of a row. */ borderHeight: 2, /** * @cfg {Boolean/Number} scrollDelay * The number of milliseconds before rendering rows out of the visible * viewing area. Defaults to 100. Rows will render immediately with a config * of false. */ scrollDelay: 100, /** * @cfg {Number} cacheSize * The number of rows to look forward and backwards from the currently viewable * area. The cache applies only to rows that have been rendered already. */ cacheSize: 20, /** * @cfg {Number} cleanDelay * The number of milliseconds to buffer cleaning of extra rows not in the * cache. */ cleanDelay: 500, initTemplates : function(){ Ext.ux.grid.BufferView.superclass.initTemplates.call(this); var ts = this.templates; // empty div to act as a place holder for a row ts.rowHolder = new Ext.Template( '<div class="x-grid3-row {alt}" style="{tstyle}"></div>' ); ts.rowHolder.disableFormats = true; ts.rowHolder.compile(); ts.rowBody = new Ext.Template( '<table class="x-grid3-row-table" border="0" cellspacing="0" cellpadding="0" style="{tstyle}">', '<tbody><tr>{cells}</tr>', (this.enableRowBody ? '<tr class="x-grid3-row-body-tr" style="{bodyStyle}"><td colspan="{cols}" class="x-grid3-body-cell" tabIndex="0" hidefocus="on"><div class="x-grid3-row-body">{body}</div></td></tr>' : ''), '</tbody></table>' ); ts.rowBody.disableFormats = true; ts.rowBody.compile(); }, getStyleRowHeight : function(){ return Ext.isBorderBox ? (this.rowHeight + this.borderHeight) : this.rowHeight; }, getCalculatedRowHeight : function(){ return this.rowHeight + this.borderHeight; }, getVisibleRowCount : function(){ var rh = this.getCalculatedRowHeight(); var visibleHeight = this.scroller.dom.clientHeight; return (visibleHeight < 1) ? 0 : Math.ceil(visibleHeight / rh); }, getVisibleRows: function(){ var count = this.getVisibleRowCount(); var sc = this.scroller.dom.scrollTop; var start = (sc == 0 ? 0 : Math.floor(sc/this.getCalculatedRowHeight())-1); return { first: Math.max(start, 0), last: Math.min(start + count + 2, this.ds.getCount()-1) }; }, doRender : function(cs, rs, ds, startRow, colCount, stripe, onlyBody){ var ts = this.templates, ct = ts.cell, rt = ts.row, rb = ts.rowBody, last = colCount-1; var rh = this.getStyleRowHeight(); var vr = this.getVisibleRows(); var tstyle = 'width:'+this.getTotalWidth()+';height:'+rh+'px;'; // buffers var buf = [], cb, c, p = {}, rp = {tstyle: tstyle}, r; for (var j = 0, len = rs.length; j < len; j++) { r = rs[j]; cb = []; var rowIndex = (j+startRow); var visible = rowIndex >= vr.first && rowIndex <= vr.last; if (visible) { for (var i = 0; i < colCount; i++) { c = cs[i]; p.id = c.id; p.css = i == 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : ''); p.attr = p.cellAttr = ""; p.value = c.renderer(r.data[c.name], p, r, rowIndex, i, ds); p.style = c.style; if (p.value == undefined || p.value === "") { p.value = " "; } if (r.dirty && typeof r.modified[c.name] !== 'undefined') { p.css += ' x-grid3-dirty-cell'; } cb[cb.length] = ct.apply(p); } } var alt = []; if(stripe && ((rowIndex+1) % 2 == 0)){ alt[0] = "x-grid3-row-alt"; } if(r.dirty){ alt[1] = " x-grid3-dirty-row"; } rp.cols = colCount; if(this.getRowClass){ alt[2] = this.getRowClass(r, rowIndex, rp, ds); } rp.alt = alt.join(" "); rp.cells = cb.join(""); buf[buf.length] = !visible ? ts.rowHolder.apply(rp) : (onlyBody ? rb.apply(rp) : rt.apply(rp)); } return buf.join(""); }, isRowRendered: function(index){ var row = this.getRow(index); return row && row.childNodes.length > 0; }, syncScroll: function(){ Ext.ux.grid.BufferView.superclass.syncScroll.apply(this, arguments); this.update(); }, // a (optionally) buffered method to update contents of gridview update: function(){ if (this.scrollDelay) { if (!this.renderTask) { this.renderTask = new Ext.util.DelayedTask(this.doUpdate, this); } this.renderTask.delay(this.scrollDelay); }else{ this.doUpdate(); } }, doUpdate: function(){ if (this.getVisibleRowCount() > 0) { var g = this.grid, cm = g.colModel, ds = g.store; var cs = this.getColumnData(); var vr = this.getVisibleRows(); for (var i = vr.first; i <= vr.last; i++) { // if row is NOT rendered and is visible, render it if(!this.isRowRendered(i)){ var html = this.doRender(cs, [ds.getAt(i)], ds, i, cm.getColumnCount(), g.stripeRows, true); this.getRow(i).innerHTML = html; } } this.clean(); } }, // a buffered method to clean rows clean : function(){ if(!this.cleanTask){ this.cleanTask = new Ext.util.DelayedTask(this.doClean, this); } this.cleanTask.delay(this.cleanDelay); }, doClean: function(){ if (this.getVisibleRowCount() > 0) { var vr = this.getVisibleRows(); vr.first -= this.cacheSize; vr.last += this.cacheSize; var i = 0, rows = this.getRows(); // if first is less than 0, all rows have been rendered // so lets clean the end... if(vr.first <= 0){ i = vr.last + 1; } for(var len = this.ds.getCount(); i < len; i++){ // if current row is outside of first and last and // has content, update the innerHTML to nothing if ((i < vr.first || i > vr.last) && rows[i].innerHTML) { rows[i].innerHTML = ''; } } } }, layout: function(){ Ext.ux.grid.BufferView.superclass.layout.call(this); this.update(); } }); // We are adding these custom layouts to a namespace that does not // exist by default in Ext, so we have to add the namespace first: Ext.ns('Ext.ux.layout'); /** * @class Ext.ux.layout.CenterLayout * @extends Ext.layout.FitLayout * <p>This is a very simple layout style used to center contents within a container. This layout works within * nested containers and can also be used as expected as a Viewport layout to center the page layout.</p> * <p>As a subclass of FitLayout, CenterLayout expects to have a single child panel of the container that uses * the layout. The layout does not require any config options, although the child panel contained within the * layout must provide a fixed or percentage width. The child panel's height will fit to the container by * default, but you can specify <tt>autoHeight:true</tt> to allow it to autosize based on its content height. * Example usage:</p> * <pre><code> // The content panel is centered in the container var p = new Ext.Panel({ title: 'Center Layout', layout: 'ux.center', items: [{ title: 'Centered Content', width: '75%', html: 'Some content' }] }); // If you leave the title blank and specify no border // you'll create a non-visual, structural panel just // for centering the contents in the main container. var p = new Ext.Panel({ layout: 'ux.center', border: false, items: [{ title: 'Centered Content', width: 300, autoHeight: true, html: 'Some content' }] }); </code></pre> */ Ext.ux.layout.CenterLayout = Ext.extend(Ext.layout.FitLayout, { // private setItemSize : function(item, size){ this.container.addClass('ux-layout-center'); item.addClass('ux-layout-center-item'); if(item && size.height > 0){ if(item.width){ size.width = item.width; } item.setSize(size); } } }); Ext.Container.LAYOUTS['ux.center'] = Ext.ux.layout.CenterLayout; Ext.ns('Ext.ux.grid');
- /**
- * @class Ext.ux.grid.CheckColumn
- * @extends Object
- * GridPanel plugin to add a column with check boxes to a grid.
- * <p>Example usage:</p>
- * <pre><code>
- // create the column
- var checkColumn = new Ext.grid.CheckColumn({
- header: 'Indoor?',
- dataIndex: 'indoor',
- id: 'check',
- width: 55
- });
- // add the column to the column model
- var cm = new Ext.grid.ColumnModel([{
- header: 'Foo',
- ...
- },
- checkColumn
- ]);
- // create the grid
- var grid = new Ext.grid.EditorGridPanel({
- ...
- cm: cm,
- plugins: [checkColumn], // include plugin
- ...
- });
- * </code></pre>
- * In addition to storing a Boolean value within the record data, this
- * class toggles a css class between <tt>'x-grid3-check-col'</tt> and
- * <tt>'x-grid3-check-col-on'</tt> to alter the background image used for
- * a column.
- */
- Ext.ux.grid.CheckColumn = function(config){
- Ext.apply(this, config);
- if(!this.id){
- this.id = Ext.id();
- }
- this.renderer = this.renderer.createDelegate(this);
- };
- Ext.ux.grid.CheckColumn.prototype ={
- init : function(grid){
- this.grid = grid;
- this.grid.on('render', function(){
- var view = this.grid.getView();
- view.mainBody.on('mousedown', this.onMouseDown, this);
- }, this);
- },
- onMouseDown : function(e, t){
- if(t.className && t.className.indexOf('x-grid3-cc-'+this.id) != -1){
- e.stopEvent();
- var index = this.grid.getView().findRowIndex(t);
- var record = this.grid.store.getAt(index);
- record.set(this.dataIndex, !record.data[this.dataIndex]);
- }
- },
- renderer : function(v, p, record){
- p.css += ' x-grid3-check-col-td';
- return '<div class="x-grid3-check-col'+(v?'-on':'')+' x-grid3-cc-'+this.id+'"> </div>';
- }
- };
- // register ptype
- Ext.preg('checkcolumn', Ext.ux.grid.CheckColumn);
- // backwards compat
- Ext.grid.CheckColumn = Ext.ux.grid.CheckColumn;Ext.ns('Ext.ux.tree');
- /**
- * @class Ext.ux.tree.ColumnTree
- * @extends Ext.tree.TreePanel
- *
- * @xtype columntree
- */
- Ext.ux.tree.ColumnTree = Ext.extend(Ext.tree.TreePanel, {
- lines : false,
- borderWidth : Ext.isBorderBox ? 0 : 2, // the combined left/right border for each cell
- cls : 'x-column-tree',
- onRender : function(){
- Ext.tree.ColumnTree.superclass.onRender.apply(this, arguments);
- this.headers = this.header.createChild({cls:'x-tree-headers'});
- var cols = this.columns, c;
- var totalWidth = 0;
- var scrollOffset = 19; // similar to Ext.grid.GridView default
- for(var i = 0, len = cols.length; i < len; i++){
- c = cols[i];
- totalWidth += c.width;
- this.headers.createChild({
- cls:'x-tree-hd ' + (c.cls?c.cls+'-hd':''),
- cn: {
- cls:'x-tree-hd-text',
- html: c.header
- },
- style:'width:'+(c.width-this.borderWidth)+'px;'
- });
- }
- this.headers.createChild({cls:'x-clear'});
- // prevent floats from wrapping when clipped
- this.headers.setWidth(totalWidth+scrollOffset);
- this.innerCt.setWidth(totalWidth);
- }
- });
- Ext.reg('columntree', Ext.ux.tree.ColumnTree);
- //backwards compat
- Ext.tree.ColumnTree = Ext.ux.tree.ColumnTree;
- /**
- * @class Ext.ux.tree.ColumnNodeUI
- * @extends Ext.tree.TreeNodeUI
- */
- Ext.ux.tree.ColumnNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
- focus: Ext.emptyFn, // prevent odd scrolling behavior
- renderElements : function(n, a, targetNode, bulkRender){
- this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';
- var t = n.getOwnerTree();
- var cols = t.columns;
- var bw = t.borderWidth;
- var c = cols[0];
- var buf = [
- '<li class="x-tree-node"><div ext:tree-node-id="',n.id,'" class="x-tree-node-el x-tree-node-leaf ', a.cls,'">',
- '<div class="x-tree-col" style="width:',c.width-bw,'px;">',
- '<span class="x-tree-node-indent">',this.indentMarkup,"</span>",
- '<img src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow">',
- '<img src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon',(a.icon ? " x-tree-node-inline-icon" : ""),(a.iconCls ? " "+a.iconCls : ""),'" unselectable="on">',
- '<a hidefocus="on" class="x-tree-node-anchor" href="',a.href ? a.href : "#",'" tabIndex="1" ',
- a.hrefTarget ? ' target="'+a.hrefTarget+'"' : "", '>',
- '<span unselectable="on">', n.text || (c.renderer ? c.renderer(a[c.dataIndex], n, a) : a[c.dataIndex]),"</span></a>",
- "</div>"];
- for(var i = 1, len = cols.length; i < len; i++){
- c = cols[i];
- buf.push('<div class="x-tree-col ',(c.cls?c.cls:''),'" style="width:',c.width-bw,'px;">',
- '<div class="x-tree-col-text">',(c.renderer ? c.renderer(a[c.dataIndex], n, a) : a[c.dataIndex]),"</div>",
- "</div>");
- }
- buf.push(
- '<div class="x-clear"></div></div>',
- '<ul class="x-tree-node-ct" style="display:none;"></ul>',
- "</li>");
- if(bulkRender !== true && n.nextSibling && n.nextSibling.ui.getEl()){
- this.wrap = Ext.DomHelper.insertHtml("beforeBegin",
- n.nextSibling.ui.getEl(), buf.join(""));
- }else{
- this.wrap = Ext.DomHelper.insertHtml("beforeEnd", targetNode, buf.join(""));
- }
- this.elNode = this.wrap.childNodes[0];
- this.ctNode = this.wrap.childNodes[1];
- var cs = this.elNode.firstChild.childNodes;
- this.indentNode = cs[0];
- this.ecNode = cs[1];
- this.iconNode = cs[2];
- this.anchor = cs[3];
- this.textNode = cs[3].firstChild;
- }
- });
- //backwards compat
- Ext.tree.ColumnNodeUI = Ext.ux.tree.ColumnNodeUI;
- /**
- * @class Ext.DataView.LabelEditor
- * @extends Ext.Editor
- *
- */
- Ext.DataView.LabelEditor = Ext.extend(Ext.Editor, {
- alignment: "tl-tl",
- hideEl : false,
- cls: "x-small-editor",
- shim: false,
- completeOnEnter: true,
- cancelOnEsc: true,
- labelSelector: 'span.x-editable',
- constructor: function(cfg, field){
- Ext.DataView.LabelEditor.superclass.constructor.call(this,
- field || new Ext.form.TextField({
- allowBlank: false,
- growMin:90,
- growMax:240,
- grow:true,
- selectOnFocus:true
- }), cfg
- );
- },
- init : function(view){
- this.view = view;
- view.on('render', this.initEditor, this);
- this.on('complete', this.onSave, this);
- },
- initEditor : function(){
- this.view.on({
- scope: this,
- containerclick: this.doBlur,
- click: this.doBlur
- });
- this.view.getEl().on('mousedown', this.onMouseDown, this, {delegate: this.labelSelector});
- },
- doBlur: function(){
- if(this.editing){
- this.field.blur();
- }
- },
- onMouseDown : function(e, target){
- if(!e.ctrlKey && !e.shiftKey){
- var item = this.view.findItemFromChild(target);
- e.stopEvent();
- var record = this.view.store.getAt(this.view.indexOf(item));
- this.startEdit(target, record.data[this.dataIndex]);
- this.activeRecord = record;
- }else{
- e.preventDefault();
- }
- },
- onSave : function(ed, value){
- this.activeRecord.set(this.dataIndex, value);
- }
- });
- Ext.DataView.DragSelector = function(cfg){
- cfg = cfg || {};
- var view, proxy, tracker;
- var rs, bodyRegion, dragRegion = new Ext.lib.Region(0,0,0,0);
- var dragSafe = cfg.dragSafe === true;
- this.init = function(dataView){
- view = dataView;
- view.on('render', onRender);
- };
- function fillRegions(){
- rs = [];
- view.all.each(function(el){
- rs[rs.length] = el.getRegion();
- });
- bodyRegion = view.el.getRegion();
- }
- function cancelClick(){
- return false;
- }
- function onBeforeStart(e){
- return !dragSafe || e.target == view.el.dom;
- }
- function onStart(e){
- view.on('containerclick', cancelClick, view, {single:true});
- if(!proxy){
- proxy = view.el.createChild({cls:'x-view-selector'});
- }else{
- proxy.setDisplayed('block');
- }
- fillRegions();
- view.clearSelections();
- }
- function onDrag(e){
- var startXY = tracker.startXY;
- var xy = tracker.getXY();
- var x = Math.min(startXY[0], xy[0]);
- var y = Math.min(startXY[1], xy[1]);
- var w = Math.abs(startXY[0] - xy[0]);
- var h = Math.abs(startXY[1] - xy[1]);
- dragRegion.left = x;
- dragRegion.top = y;
- dragRegion.right = x+w;
- dragRegion.bottom = y+h;
- dragRegion.constrainTo(bodyRegion);
- proxy.setRegion(dragRegion);
- for(var i = 0, len = rs.length; i < len; i++){
- var r = rs[i], sel = dragRegion.intersect(r);
- if(sel && !r.selected){
- r.selected = true;
- view.select(i, true);
- }else if(!sel && r.selected){
- r.selected = false;
- view.deselect(i);
- }
- }
- }
- function onEnd(e){
- if (!Ext.isIE) {
- view.un('containerclick', cancelClick, view);
- }
- if(proxy){
- proxy.setDisplayed(false);
- }
- }
- function onRender(view){
- tracker = new Ext.dd.DragTracker({
- onBeforeStart: onBeforeStart,
- onStart: onStart,
- onDrag: onDrag,
- onEnd: onEnd
- });
- tracker.initEl(view.el);
- }
- };Ext.ns('Ext.ux.form'); /** * @class Ext.ux.form.FileUploadField * @extends Ext.form.TextField * Creates a file upload field. * @xtype fileuploadfield */ Ext.ux.form.FileUploadField = Ext.extend(Ext.form.TextField, { /** * @cfg {String} buttonText The button text to display on the upload button (defaults to * 'Browse...'). Note that if you supply a value for {@link #buttonCfg}, the buttonCfg.text * value will be used instead if available. */ buttonText: 'Browse...', /** * @cfg {Boolean} buttonOnly True to display the file upload field as a button with no visible * text field (defaults to false). If true, all inherited TextField members will still be available. */ buttonOnly: false, /** * @cfg {Number} buttonOffset The number of pixels of space reserved between the button and the text field * (defaults to 3). Note that this only applies if {@link #buttonOnly} = false. */ buttonOffset: 3, /** * @cfg {Object} buttonCfg A standard {@link Ext.Button} config object. */ // private readOnly: true, /** * @hide * @method autoSize */ autoSize: Ext.emptyFn, // private initComponent: function(){ Ext.ux.form.FileUploadField.superclass.initComponent.call(this); this.addEvents( /** * @event fileselected * Fires when the underlying file input field's value has changed from the user * selecting a new file from the system file selection dialog. * @param {Ext.ux.form.FileUploadField} this * @param {String} value The file value returned by the underlying file input field */ 'fileselected' ); }, // private onRender : function(ct, position){ Ext.ux.form.FileUploadField.superclass.onRender.call(this, ct, position); this.wrap = this.el.wrap({cls:'x-form-field-wrap x-form-file-wrap'}); this.el.addClass('x-form-file-text'); this.el.dom.removeAttribute('name'); this.fileInput = this.wrap.createChild({ id: this.getFileInputId(), name: this.name||this.getId(), cls: 'x-form-file', tag: 'input', type: 'file', size: 1 }); var btnCfg = Ext.applyIf(this.buttonCfg || {}, { text: this.buttonText }); this.button = new Ext.Button(Ext.apply(btnCfg, { renderTo: this.wrap, cls: 'x-form-file-btn' + (btnCfg.iconCls ? ' x-btn-icon' : '') })); if(this.buttonOnly){ this.el.hide(); this.wrap.setWidth(this.button.getEl().getWidth()); } this.fileInput.on('change', function(){ var v = this.fileInput.dom.value; this.setValue(v); this.fireEvent('fileselected', this, v); }, this); }, // private getFileInputId: function(){ return this.id + '-file'; }, // private onResize : function(w, h){ Ext.ux.form.FileUploadField.superclass.onResize.call(this, w, h); this.wrap.setWidth(w); if(!this.buttonOnly){ var w = this.wrap.getWidth() - this.button.getEl().getWidth() - this.buttonOffset; this.el.setWidth(w); } }, // private onDestroy: function(){ Ext.ux.form.FileUploadField.superclass.onDestroy.call(this); Ext.destroy(this.fileInput, this.button, this.wrap); }, // private preFocus : Ext.emptyFn, // private getResizeEl : function(){ return this.wrap; }, // private getPositionEl : function(){ return this.wrap; }, // private alignErrorIcon : function(){ this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]); } }); Ext.reg('fileuploadfield', Ext.ux.form.FileUploadField); // backwards compat Ext.form.FileUploadField = Ext.ux.form.FileUploadField; (function(){
- Ext.ns('Ext.a11y');
- Ext.a11y.Frame = Ext.extend(Object, {
- initialized: false,
- constructor: function(size, color){
- this.setSize(size || 1);
- this.setColor(color || '15428B');
- },
- init: function(){
- if (!this.initialized) {
- this.sides = [];
- var s, i;
- this.ct = Ext.DomHelper.append(document.body, {
- cls: 'x-a11y-focusframe'
- }, true);
- for (i = 0; i < 4; i++) {
- s = Ext.DomHelper.append(this.ct, {
- cls: 'x-a11y-focusframe-side',
- style: 'background-color: #' + this.color
- }, true);
- s.visibilityMode = Ext.Element.DISPLAY;
- this.sides.push(s);
- }
- this.frameTask = new Ext.util.DelayedTask(function(el){
- var newEl = Ext.get(el);
- if (newEl != this.curEl) {
- var w = newEl.getWidth();
- var h = newEl.getHeight();
- this.sides[0].show().setSize(w, this.size).anchorTo(el, 'tl', [0, -1]);
- this.sides[2].show().setSize(w, this.size).anchorTo(el, 'bl', [0, -1]);
- this.sides[1].show().setSize(this.size, h).anchorTo(el, 'tr', [-1, 0]);
- this.sides[3].show().setSize(this.size, h).anchorTo(el, 'tl', [-1, 0]);
- this.curEl = newEl;
- }
- }, this);
- this.unframeTask = new Ext.util.DelayedTask(function(){
- if (this.initialized) {
- this.sides[0].hide();
- this.sides[1].hide();
- this.sides[2].hide();
- this.sides[3].hide();
- this.curEl = null;
- }
- }, this);
- this.initialized = true;
- }
- },
- frame: function(el){
- this.init();
- this.unframeTask.cancel();
- this.frameTask.delay(2, false, false, [el]);
- },
- unframe: function(){
- this.init();
- this.unframeTask.delay(2);
- },
- setSize: function(size){
- this.size = size;
- },
- setColor: function(color){
- this.color = color;
- }
- });
- Ext.a11y.FocusFrame = new Ext.a11y.Frame(2, '15428B');
- Ext.a11y.RelayFrame = new Ext.a11y.Frame(1, '6B8CBF');
- Ext.a11y.Focusable = Ext.extend(Ext.util.Observable, {
- constructor: function(el, relayTo, noFrame, frameEl){
- Ext.a11y.Focusable.superclass.constructor.call(this);
- this.addEvents('focus', 'blur', 'left', 'right', 'up', 'down', 'esc', 'enter', 'space');
- if (el instanceof Ext.Component) {
- this.el = el.el;
- this.setComponent(el);
- }
- else {
- this.el = Ext.get(el);
- this.setComponent(null);
- }
- this.setRelayTo(relayTo)
- this.setNoFrame(noFrame);
- this.setFrameEl(frameEl);
- this.init();
- Ext.a11y.FocusMgr.register(this);
- },
- init: function(){
- this.el.dom.tabIndex = '1';
- this.el.addClass('x-a11y-focusable');
- this.el.on({
- focus: this.onFocus,
- blur: this.onBlur,
- keydown: this.onKeyDown,
- scope: this
- });
- },
- setRelayTo: function(relayTo){
- this.relayTo = relayTo ? Ext.a11y.FocusMgr.get(relayTo) : null;
- },
- setNoFrame: function(noFrame){
- this.noFrame = (noFrame === true) ? true : false;
- },
- setFrameEl: function(frameEl){
- this.frameEl = frameEl && Ext.get(frameEl) || this.el;
- },
- setComponent: function(cmp){
- this.component = cmp || null;
- },
- onKeyDown: function(e, t){
- var k = e.getKey(), SK = Ext.a11y.Focusable.SpecialKeys, ret, tf;
- tf = (t !== this.el.dom) ? Ext.a11y.FocusMgr.get(t, true) : this;
- if (!tf) {
- // this can happen when you are on a focused item within a panel body
- // that is not a Ext.a11y.Focusable
- tf = Ext.a11y.FocusMgr.get(Ext.fly(t).parent('.x-a11y-focusable'));
- }
- if (SK[k] !== undefined) {
- ret = this.fireEvent(SK[k], e, t, tf, this);
- }
- if (ret === false || this.fireEvent('keydown', e, t, tf, this) === false) {
- e.stopEvent();
- }
- },
- focus: function(){
- this.el.dom.focus();
- },
- blur: function(){
- this.el.dom.blur();
- },
- onFocus: function(e, t){
- this.el.addClass('x-a11y-focused');
- if (this.relayTo) {
- this.relayTo.el.addClass('x-a11y-focused-relay');
- if (!this.relayTo.noFrame) {
- Ext.a11y.FocusFrame.frame(this.relayTo.frameEl);
- }
- if (!this.noFrame) {
- Ext.a11y.RelayFrame.frame(this.frameEl);
- }
- }
- else {
- if (!this.noFrame) {
- Ext.a11y.FocusFrame.frame(this.frameEl);
- }
- }
- this.fireEvent('focus', e, t, this);
- },
- onBlur: function(e, t){
- if (this.relayTo) {
- this.relayTo.el.removeClass('x-a11y-focused-relay');
- Ext.a11y.RelayFrame.unframe();
- }
- this.el.removeClass('x-a11y-focused');
- Ext.a11y.FocusFrame.unframe();
- this.fireEvent('blur', e, t, this);
- },
- destroy: function(){
- this.el.un('keydown', this.onKeyDown);
- this.el.un('focus', this.onFocus);
- this.el.un('blur', this.onBlur);
- this.el.removeClass('x-a11y-focusable');
- this.el.removeClass('x-a11y-focused');
- if (this.relayTo) {
- this.relayTo.el.removeClass('x-a11y-focused-relay');
- }
- }
- });
- Ext.a11y.FocusItem = Ext.extend(Object, {
- constructor: function(el, enableTabbing){
- Ext.a11y.FocusItem.superclass.constructor.call(this);
- this.el = Ext.get(el);
- this.fi = new Ext.a11y.Focusable(el);
- this.fi.setComponent(this);
- this.fi.on('tab', this.onTab, this);
- this.enableTabbing = enableTabbing === true ? true : false;
- },
- getEnterItem: function(){
- if (this.enableTabbing) {
- var items = this.getFocusItems();
- if (items && items.length) {
- return items[0];
- }
- }
- },
- getFocusItems: function(){
- if (this.enableTabbing) {
- return this.el.query('a, button, input, select');
- }
- return null;
- },
- onTab: function(e, t){
- var items = this.getFocusItems(), i;
- if (items && items.length && (i = items.indexOf(t)) !== -1) {
- if (e.shiftKey && i > 0) {
- e.stopEvent();
- items[i - 1].focus();
- Ext.a11y.FocusFrame.frame.defer(20, Ext.a11y.FocusFrame, [this.el]);
- return;
- }
- else
- if (!e.shiftKey && i < items.length - 1) {
- e.stopEvent();
- items[i + 1].focus();
- Ext.a11y.FocusFrame.frame.defer(20, Ext.a11y.FocusFrame, [this.el]);
- return;
- }
- }
- },
- focus: function(){
- if (this.enableTabbing) {
- var items = this.getFocusItems();
- if (items && items.length) {
- items[0].focus();
- Ext.a11y.FocusFrame.frame.defer(20, Ext.a11y.FocusFrame, [this.el]);
- return;
- }
- }
- this.fi.focus();
- },
- blur: function(){
- this.fi.blur();
- }
- });
- Ext.a11y.FocusMgr = function(){
- var all = new Ext.util.MixedCollection();
- return {
- register: function(f){
- all.add(f.el && Ext.id(f.el), f);
- },
- unregister: function(f){
- all.remove(f);
- },
- get: function(el, noCreate){
- return all.get(Ext.id(el)) || (noCreate ? false : new Ext.a11y.Focusable(el));
- },
- all: all
- }
- }();
- Ext.a11y.Focusable.SpecialKeys = {};
- Ext.a11y.Focusable.SpecialKeys[Ext.EventObjectImpl.prototype.LEFT] = 'left';
- Ext.a11y.Focusable.SpecialKeys[Ext.EventObjectImpl.prototype.RIGHT] = 'right';
- Ext.a11y.Focusable.SpecialKeys[Ext.EventObjectImpl.prototype.DOWN] = 'down';
- Ext.a11y.Focusable.SpecialKeys[Ext.EventObjectImpl.prototype.UP] = 'up';
- Ext.a11y.Focusable.SpecialKeys[Ext.EventObjectImpl.prototype.ESC] = 'esc';
- Ext.a11y.Focusable.SpecialKeys[Ext.EventObjectImpl.prototype.ENTER] = 'enter';
- Ext.a11y.Focusable.SpecialKeys[Ext.EventObjectImpl.prototype.SPACE] = 'space';
- Ext.a11y.Focusable.SpecialKeys[Ext.EventObjectImpl.prototype.TAB] = 'tab';
- // we use the new observeClass method to fire our new initFocus method on components
- Ext.util.Observable.observeClass(Ext.Component);
- Ext.Component.on('render', function(cmp){
- cmp.initFocus();
- cmp.initARIA();
- });
- Ext.override(Ext.Component, {
- initFocus: Ext.emptyFn,
- initARIA: Ext.emptyFn
- });
- Ext.override(Ext.Container, {
- isFocusable: true,
- noFocus: false,
- // private
- initFocus: function(){
- if (!this.fi && !this.noFocus) {
- this.fi = new Ext.a11y.Focusable(this);
- }
- this.mon(this.fi, {
- focus: this.onFocus,
- blur: this.onBlur,
- tab: this.onTab,
- enter: this.onEnter,
- esc: this.onEsc,
- scope: this
- });
- if (this.hidden) {
- this.isFocusable = false;
- }
- this.on('show', function(){
- this.isFocusable = true;
- }, this);
- this.on('hide', function(){
- this.isFocusable = false;
- }, this);
- },
- focus: function(){
- this.fi.focus();
- },
- blur: function(){
- this.fi.blur();
- },
- enter: function(){
- var eitem = this.getEnterItem();
- if (eitem) {
- eitem.focus();
- }
- },
- onFocus: Ext.emptyFn,
- onBlur: Ext.emptyFn,
- onTab: function(e, t, tf){
- var rf = tf.relayTo || tf;
- if (rf.component && rf.component !== this) {
- e.stopEvent();
- var item = e.shiftKey ? this.getPreviousFocus(rf.component) : this.getNextFocus(rf.component);
- item.focus();
- }
- },
- onEnter: function(e, t, tf){
- // check to see if enter is pressed while "on" the panel
- if (tf.component && tf.component === this) {
- e.stopEvent();
- this.enter();
- }
- e.stopPropagation();
- },
- onEsc: function(e, t){
- e.preventDefault();
- // check to see if esc is pressed while "inside" the panel
- // or while "on" the panel
- if (t === this.el.dom) {
- // "on" the panel, check if this panel has an owner panel and focus that
- // we dont stop the event in this case so that this same check will be
- // done for this ownerCt
- if (this.ownerCt) {
- this.ownerCt.focus();
- }
- }
- else {
- // we were inside the panel when esc was pressed,
- // so go back "on" the panel
- if (this.ownerCt && this.ownerCt.isFocusable) {
- var si = this.ownerCt.getFocusItems();
- if (si && si.getCount() > 1) {
- e.stopEvent();
- }
- }
- this.focus();
- }
- },
- getFocusItems: function(){
- return this.items &&
- this.items.filterBy(function(o){
- return o.isFocusable;
- }) ||
- null;
- },
- getEnterItem: function(){
- var ci = this.getFocusItems(), length = ci ? ci.getCount() : 0;
- if (length === 1) {
- return ci.first().getEnterItem && ci.first().getEnterItem() || ci.first();
- }
- else
- if (length > 1) {
- return ci.first();
- }
- },
- getNextFocus: function(current){
- var items = this.getFocusItems(), next = current, i = items.indexOf(current), length = items.getCount();
- if (i === length - 1) {
- next = items.first();
- }
- else {
- next = items.get(i + 1);
- }
- return next;
- },
- getPreviousFocus: function(current){
- var items = this.getFocusItems(), prev = current, i = items.indexOf(current), length = items.getCount();
- if (i === 0) {
- prev = items.last();
- }
- else {
- prev = items.get(i - 1);
- }
- return prev;
- },
- getFocusable : function() {
- return this.fi;
- }
- });
- Ext.override(Ext.Panel, {
- /**
- * @cfg {Boolean} enableTabbing <tt>true</tt> to enable tabbing. Default is <tt>false</tt>.
- */
- getFocusItems: function(){
- // items gets all the items inside the body
- var items = Ext.Panel.superclass.getFocusItems.call(this), bodyFocus = null;
- if (!items) {
- items = new Ext.util.MixedCollection();
- this.bodyFocus = this.bodyFocus || new Ext.a11y.FocusItem(this.body, this.enableTabbing);
- items.add('body', this.bodyFocus);
- }
- // but panels can also have tbar, bbar, fbar
- if (this.tbar && this.topToolbar) {
- items.insert(0, this.topToolbar);
- }
- if (this.bbar && this.bottomToolbar) {
- items.add(this.bottomToolbar);
- }
- if (this.fbar) {
- items.add(this.fbar);
- }
- return items;
- }
- });
- Ext.override(Ext.TabPanel, {
- // private
- initFocus: function(){
- Ext.TabPanel.superclass.initFocus.call(this);
- this.mon(this.fi, {
- left: this.onLeft,
- right: this.onRight,
- scope: this
- });
- },
- onLeft: function(e){
- if (!this.activeTab) {
- return;
- }
- e.stopEvent();
- var prev = this.items.itemAt(this.items.indexOf(this.activeTab) - 1);
- if (prev) {
- this.setActiveTab(prev);
- }
- return false;
- },
- onRight: function(e){
- if (!this.activeTab) {
- return;
- }
- e.stopEvent();
- var next = this.items.itemAt(this.items.indexOf(this.activeTab) + 1);
- if (next) {
- this.setActiveTab(next);
- }
- return false;
- }
- });
- Ext.override(Ext.tree.TreeNodeUI, {
- // private
- focus: function(){
- this.node.getOwnerTree().bodyFocus.focus();
- }
- });
- Ext.override(Ext.tree.TreePanel, {
- // private
- afterRender : function(){
- Ext.tree.TreePanel.superclass.afterRender.call(this);
- this.root.render();
- if(!this.rootVisible){
- this.root.renderChildren();
- }
- this.bodyFocus = new Ext.a11y.FocusItem(this.body.down('.x-tree-root-ct'));
- this.bodyFocus.fi.setFrameEl(this.body);
- }
- });
- Ext.override(Ext.grid.GridPanel, {
- initFocus: function(){
- Ext.grid.GridPanel.superclass.initFocus.call(this);
- this.bodyFocus = new Ext.a11y.FocusItem(this.view.focusEl);
- this.bodyFocus.fi.setFrameEl(this.body);
- }
- });
- Ext.override(Ext.Button, {
- isFocusable: true,
- noFocus: false,
- initFocus: function(){
- Ext.Button.superclass.initFocus.call(this);
- this.fi = this.fi || new Ext.a11y.Focusable(this.btnEl, null, null, this.el);
- this.fi.setComponent(this);
- this.mon(this.fi, {
- focus: this.onFocus,
- blur: this.onBlur,
- scope: this
- });
- if (this.menu) {
- this.mon(this.fi, 'down', this.showMenu, this);
- this.on('menuhide', this.focus, this);
- }
- if (this.hidden) {
- this.isFocusable = false;
- }
- this.on('show', function(){
- this.isFocusable = true;
- }, this);
- this.on('hide', function(){
- this.isFocusable = false;
- }, this);
- },
- focus: function(){
- this.fi.focus();
- },
- blur: function(){
- this.fi.blur();
- },
- onFocus: function(){
- if (!this.disabled) {
- this.el.addClass("x-btn-focus");
- }
- },
- onBlur: function(){
- this.el.removeClass("x-btn-focus");
- }
- });
- Ext.override(Ext.Toolbar, {
- initFocus: function(){
- Ext.Toolbar.superclass.initFocus.call(this);
- this.mon(this.fi, {
- left: this.onLeft,
- right: this.onRight,
- scope: this
- });
- this.on('focus', this.onButtonFocus, this, {
- stopEvent: true
- });
- },
- addItem: function(item){
- Ext.Toolbar.superclass.add.apply(this, arguments);
- if (item.rendered && item.fi !== undefined) {
- item.fi.setRelayTo(this.el);
- this.relayEvents(item.fi, ['focus']);
- }
- else {
- item.on('render', function(){
- if (item.fi !== undefined) {
- item.fi.setRelayTo(this.el);
- this.relayEvents(item.fi, ['focus']);
- }
- }, this, {
- single: true
- });
- }
- return item;
- },
- onFocus: function(){
- var items = this.getFocusItems();
- if (items && items.getCount() > 0) {
- if (this.lastFocus && items.indexOf(this.lastFocus) !== -1) {
- this.lastFocus.focus();
- }
- else {
- items.first().focus();
- }
- }
- },
- onButtonFocus: function(e, t, tf){
- this.lastFocus = tf.component || null;
- },
- onLeft: function(e, t, tf){
- e.stopEvent();
- this.getPreviousFocus(tf.component).focus();
- },
- onRight: function(e, t, tf){
- e.stopEvent();
- this.getNextFocus(tf.component).focus();
- },
- getEnterItem: Ext.emptyFn,
- onTab: Ext.emptyFn,
- onEsc: Ext.emptyFn
- });
- Ext.override(Ext.menu.BaseItem, {
- initFocus: function(){
- this.fi = new Ext.a11y.Focusable(this, this.parentMenu && this.parentMenu.el || null, true);
- }
- });
- Ext.override(Ext.menu.Menu, {
- initFocus: function(){
- this.fi = new Ext.a11y.Focusable(this);
- this.focusEl = this.fi;
- }
- });
- Ext.a11y.WindowMgr = new Ext.WindowGroup();
- Ext.apply(Ext.WindowMgr, {
- bringToFront: function(win){
- Ext.a11y.WindowMgr.bringToFront.call(this, win);
- if (win.modal) {
- win.enter();
- }
- else {
- win.focus();
- }
- }
- });
- Ext.override(Ext.Window, {
- initFocus: function(){
- Ext.Window.superclass.initFocus.call(this);
- this.on('beforehide', function(){
- Ext.a11y.RelayFrame.unframe();
- Ext.a11y.FocusFrame.unframe();
- });
- }
- });
- Ext.override(Ext.form.Field, {
- isFocusable: true,
- noFocus: false,
- initFocus: function(){
- this.fi = this.fi || new Ext.a11y.Focusable(this, null, true);
- Ext.form.Field.superclass.initFocus.call(this);
- if (this.hidden) {
- this.isFocusable = false;
- }
- this.on('show', function(){
- this.isFocusable = true;
- }, this);
- this.on('hide', function(){
- this.isFocusable = false;
- }, this);
- }
- });
- Ext.override(Ext.FormPanel, {
- initFocus: function(){
- Ext.FormPanel.superclass.initFocus.call(this);
- this.on('focus', this.onFieldFocus, this, {
- stopEvent: true
- });
- },
- // private
- createForm: function(){
- delete this.initialConfig.listeners;
- var form = new Ext.form.BasicForm(null, this.initialConfig);
- form.afterMethod('add', this.formItemAdd, this);
- return form;
- },
- formItemAdd: function(item){
- item.on('render', function(field){
- field.fi.setRelayTo(this.el);
- this.relayEvents(field.fi, ['focus']);
- }, this, {
- single: true
- });
- },
- onFocus: function(){
- var items = this.getFocusItems();
- if (items && items.getCount() > 0) {
- if (this.lastFocus && items.indexOf(this.lastFocus) !== -1) {
- this.lastFocus.focus();
- }
- else {
- items.first().focus();
- }
- }
- },
- onFieldFocus: function(e, t, tf){
- this.lastFocus = tf.component || null;
- },
- onTab: function(e, t, tf){
- if (tf.relayTo.component === this) {
- var item = e.shiftKey ? this.getPreviousFocus(tf.component) : this.getNextFocus(tf.component);
- if (item) {
- ev.stopEvent();
- item.focus();
- return;
- }
- }
- Ext.FormPanel.superclass.onTab.apply(this, arguments);
- },
- getNextFocus: function(current){
- var items = this.getFocusItems(), i = items.indexOf(current), length = items.getCount();
- return (i < length - 1) ? items.get(i + 1) : false;
- },
- getPreviousFocus: function(current){
- var items = this.getFocusItems(), i = items.indexOf(current), length = items.getCount();
- return (i > 0) ? items.get(i - 1) : false;
- }
- });
- Ext.override(Ext.Viewport, {
- initFocus: function(){
- Ext.Viewport.superclass.initFocus.apply(this);
- this.mon(Ext.get(document), 'focus', this.focus, this);
- this.mon(Ext.get(document), 'blur', this.blur, this);
- this.fi.setNoFrame(true);
- },
- onTab: function(e, t, tf, f){
- e.stopEvent();
- if (tf === f) {
- items = this.getFocusItems();
- if (items && items.getCount() > 0) {
- items.first().focus();
- }
- }
- else {
- var rf = tf.relayTo || tf;
- var item = e.shiftKey ? this.getPreviousFocus(rf.component) : this.getNextFocus(rf.component);
- item.focus();
- }
- }
- });
- })();/**
- * @class Ext.ux.GMapPanel
- * @extends Ext.Panel
- * @author Shea Frederick
- */
- Ext.ux.GMapPanel = Ext.extend(Ext.Panel, {
- initComponent : function(){
- var defConfig = {
- plain: true,
- zoomLevel: 3,
- yaw: 180,
- pitch: 0,
- zoom: 0,
- gmapType: 'map',
- border: false
- };
- Ext.applyIf(this,defConfig);
- Ext.ux.GMapPanel.superclass.initComponent.call(this);
- },
- afterRender : function(){
- var wh = this.ownerCt.getSize();
- Ext.applyIf(this, wh);
- Ext.ux.GMapPanel.superclass.afterRender.call(this);
- if (this.gmapType === 'map'){
- this.gmap = new GMap2(this.body.dom);
- }
- if (this.gmapType === 'panorama'){
- this.gmap = new GStreetviewPanorama(this.body.dom);
- }
- if (typeof this.addControl == 'object' && this.gmapType === 'map') {
- this.gmap.addControl(this.addControl);
- }
- if (typeof this.setCenter === 'object') {
- if (typeof this.setCenter.geoCodeAddr === 'string'){
- this.geoCodeLookup(this.setCenter.geoCodeAddr);
- }else{
- if (this.gmapType === 'map'){
- var point = new GLatLng(this.setCenter.lat,this.setCenter.lng);
- this.gmap.setCenter(point, this.zoomLevel);
- }
- if (typeof this.setCenter.marker === 'object' && typeof point === 'object'){
- this.addMarker(point,this.setCenter.marker,this.setCenter.marker.clear);
- }
- }
- if (this.gmapType === 'panorama'){
- this.gmap.setLocationAndPOV(new GLatLng(this.setCenter.lat,this.setCenter.lng), {yaw: this.yaw, pitch: this.pitch, zoom: this.zoom});
- }
- }
- GEvent.bind(this.gmap, 'load', this, function(){
- this.onMapReady();
- });
- },
- onMapReady : function(){
- this.addMarkers(this.markers);
- this.addMapControls();
- this.addOptions();
- },
- onResize : function(w, h){
- if (typeof this.getMap() == 'object') {
- this.gmap.checkResize();
- }
- Ext.ux.GMapPanel.superclass.onResize.call(this, w, h);
- },
- setSize : function(width, height, animate){
- if (typeof this.getMap() == 'object') {
- this.gmap.checkResize();
- }
- Ext.ux.GMapPanel.superclass.setSize.call(this, width, height, animate);
- },
- getMap : function(){
- return this.gmap;
- },
- getCenter : function(){
- return this.getMap().getCenter();
- },
- getCenterLatLng : function(){
- var ll = this.getCenter();
- return {lat: ll.lat(), lng: ll.lng()};
- },
- addMarkers : function(markers) {
- if (Ext.isArray(markers)){
- for (var i = 0; i < markers.length; i++) {
- var mkr_point = new GLatLng(markers[i].lat,markers[i].lng);
- this.addMarker(mkr_point,markers[i].marker,false,markers[i].setCenter, markers[i].listeners);
- }
- }
- },
- addMarker : function(point, marker, clear, center, listeners){
- Ext.applyIf(marker,G_DEFAULT_ICON);
- if (clear === true){
- this.getMap().clearOverlays();
- }
- if (center === true) {
- this.getMap().setCenter(point, this.zoomLevel);
- }
- var mark = new GMarker(point,marker);
- if (typeof listeners === 'object'){
- for (evt in listeners) {
- GEvent.bind(mark, evt, this, listeners[evt]);
- }
- }
- this.getMap().addOverlay(mark);
- },
- addMapControls : function(){
- if (this.gmapType === 'map') {
- if (Ext.isArray(this.mapControls)) {
- for(i=0;i<this.mapControls.length;i++){
- this.addMapControl(this.mapControls[i]);
- }
- }else if(typeof this.mapControls === 'string'){
- this.addMapControl(this.mapControls);
- }else if(typeof this.mapControls === 'object'){
- this.getMap().addControl(this.mapControls);
- }
- }
- },
- addMapControl : function(mc){
- var mcf = window[mc];
- if (typeof mcf === 'function') {
- this.getMap().addControl(new mcf());
- }
- },
- addOptions : function(){
- if (Ext.isArray(this.mapConfOpts)) {
- var mc;
- for(i=0;i<this.mapConfOpts.length;i++){
- this.addOption(this.mapConfOpts[i]);
- }
- }else if(typeof this.mapConfOpts === 'string'){
- this.addOption(this.mapConfOpts);
- }
- },
- addOption : function(mc){
- var mcf = this.getMap()[mc];
- if (typeof mcf === 'function') {
- this.getMap()[mc]();
- }
- },
- geoCodeLookup : function(addr) {
- this.geocoder = new GClientGeocoder();
- this.geocoder.getLocations(addr, this.addAddressToMap.createDelegate(this));
- },
- addAddressToMap : function(response) {
- if (!response || response.Status.code != 200) {
- Ext.MessageBox.alert('Error', 'Code '+response.Status.code+' Error Returned');
- }else{
- place = response.Placemark[0];
- addressinfo = place.AddressDetails;
- accuracy = addressinfo.Accuracy;
- if (accuracy === 0) {
- Ext.MessageBox.alert('Unable to Locate Address', 'Unable to Locate the Address you provided');
- }else{
- if (accuracy < 7) {
- Ext.MessageBox.alert('Address Accuracy', 'The address provided has a low accuracy.<br><br>Level '+accuracy+' Accuracy (8 = Exact Match, 1 = Vague Match)');
- }else{
- point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);
- if (typeof this.setCenter.marker === 'object' && typeof point === 'object'){
- this.addMarker(point,this.setCenter.marker,this.setCenter.marker.clear,true, this.setCenter.listeners);
- }
- }
- }
- }
- }
- });
- Ext.reg('gmappanel', Ext.ux.GMapPanel); Ext.ns('Ext.ux.grid');
- /**
- * @class Ext.ux.grid.GroupSummary
- * @extends Ext.util.Observable
- * A GridPanel plugin that enables dynamic column calculations and a dynamically
- * updated grouped summary row.
- */
- Ext.ux.grid.GroupSummary = Ext.extend(Ext.util.Observable, {
- /**
- * @cfg {Function} summaryRenderer Renderer example:<pre><code>
- summaryRenderer: function(v, params, data){
- return ((v === 0 || v > 1) ? '(' + v +' Tasks)' : '(1 Task)');
- },
- * </code></pre>
- */
- /**
- * @cfg {String} summaryType (Optional) The type of
- * calculation to be used for the column. For options available see
- * {@link #Calculations}.
- */
- constructor : function(config){
- Ext.apply(this, config);
- Ext.ux.grid.GroupSummary.superclass.constructor.call(this);
- },
- init : function(grid){
- this.grid = grid;
- this.cm = grid.getColumnModel();
- this.view = grid.getView();
- var v = this.view;
- v.doGroupEnd = this.doGroupEnd.createDelegate(this);
- v.afterMethod('onColumnWidthUpdated', this.doWidth, this);
- v.afterMethod('onAllColumnWidthsUpdated', this.doAllWidths, this);
- v.afterMethod('onColumnHiddenUpdated', this.doHidden, this);
- v.afterMethod('onUpdate', this.doUpdate, this);
- v.afterMethod('onRemove', this.doRemove, this);
- if(!this.rowTpl){
- this.rowTpl = new Ext.Template(
- '<div class="x-grid3-summary-row" style="{tstyle}">',
- '<table class="x-grid3-summary-table" border="0" cellspacing="0" cellpadding="0" style="{tstyle}">',
- '<tbody><tr>{cells}</tr></tbody>',
- '</table></div>'
- );
- this.rowTpl.disableFormats = true;
- }
- this.rowTpl.compile();
- if(!this.cellTpl){
- this.cellTpl = new Ext.Template(
- '<td class="x-grid3-col x-grid3-cell x-grid3-td-{id} {css}" style="{style}">',
- '<div class="x-grid3-cell-inner x-grid3-col-{id}" unselectable="on">{value}</div>',
- "</td>"
- );
- this.cellTpl.disableFormats = true;
- }
- this.cellTpl.compile();
- },
- /**
- * Toggle the display of the summary row on/off
- * @param {Boolean} visible <tt>true</tt> to show the summary, <tt>false</tt> to hide the summary.
- */
- toggleSummaries : function(visible){
- var el = this.grid.getGridEl();
- if(el){
- if(visible === undefined){
- visible = el.hasClass('x-grid-hide-summary');
- }
- el[visible ? 'removeClass' : 'addClass']('x-grid-hide-summary');
- }
- },
- renderSummary : function(o, cs){
- cs = cs || this.view.getColumnData();
- var cfg = this.cm.config;
- var buf = [], c, p = {}, cf, last = cs.length-1;
- for(var i = 0, len = cs.length; i < len; i++){
- c = cs[i];
- cf = cfg[i];
- p.id = c.id;
- p.style = c.style;
- p.css = i == 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '');
- if(cf.summaryType || cf.summaryRenderer){
- p.value = (cf.summaryRenderer || c.renderer)(o.data[c.name], p, o);
- }else{
- p.value = '';
- }
- if(p.value == undefined || p.value === "") p.value = " ";
- buf[buf.length] = this.cellTpl.apply(p);
- }
- return this.rowTpl.apply({
- tstyle: 'width:'+this.view.getTotalWidth()+';',
- cells: buf.join('')
- });
- },
- /**
- * @private
- * @param {Object} rs
- * @param {Object} cs
- */
- calculate : function(rs, cs){
- var data = {}, r, c, cfg = this.cm.config, cf;
- for(var j = 0, jlen = rs.length; j < jlen; j++){
- r = rs[j];
- for(var i = 0, len = cs.length; i < len; i++){
- c = cs[i];
- cf = cfg[i];
- if(cf.summaryType){
- data[c.name] = Ext.ux.grid.GroupSummary.Calculations[cf.summaryType](data[c.name] || 0, r, c.name, data);
- }
- }
- }
- return data;
- },
- doGroupEnd : function(buf, g, cs, ds, colCount){
- var data = this.calculate(g.rs, cs);
- buf.push('</div>', this.renderSummary({data: data}, cs), '</div>');
- },
- doWidth : function(col, w, tw){
- var gs = this.view.getGroups(), s;
- for(var i = 0, len = gs.length; i < len; i++){
- s = gs[i].childNodes[2];
- s.style.width = tw;
- s.firstChild.style.width = tw;
- s.firstChild.rows[0].childNodes[col].style.width = w;
- }
- },
- doAllWidths : function(ws, tw){
- var gs = this.view.getGroups(), s, cells, wlen = ws.length;
- for(var i = 0, len = gs.length; i < len; i++){
- s = gs[i].childNodes[2];
- s.style.width = tw;
- s.firstChild.style.width = tw;
- cells = s.firstChild.rows[0].childNodes;
- for(var j = 0; j < wlen; j++){
- cells[j].style.width = ws[j];
- }
- }
- },
- doHidden : function(col, hidden, tw){
- var gs = this.view.getGroups(), s, display = hidden ? 'none' : '';
- for(var i = 0, len = gs.length; i < len; i++){
- s = gs[i].childNodes[2];
- s.style.width = tw;
- s.firstChild.style.width = tw;
- s.firstChild.rows[0].childNodes[col].style.display = display;
- }
- },
- // Note: requires that all (or the first) record in the
- // group share the same group value. Returns false if the group
- // could not be found.
- refreshSummary : function(groupValue){
- return this.refreshSummaryById(this.view.getGroupId(groupValue));
- },
- getSummaryNode : function(gid){
- var g = Ext.fly(gid, '_gsummary');
- if(g){
- return g.down('.x-grid3-summary-row', true);
- }
- return null;
- },
- refreshSummaryById : function(gid){
- var g = document.getElementById(gid);
- if(!g){
- return false;
- }
- var rs = [];
- this.grid.store.each(function(r){
- if(r._groupId == gid){
- rs[rs.length] = r;
- }
- });
- var cs = this.view.getColumnData();
- var data = this.calculate(rs, cs);
- var markup = this.renderSummary({data: data}, cs);
- var existing = this.getSummaryNode(gid);
- if(existing){
- g.removeChild(existing);
- }
- Ext.DomHelper.append(g, markup);
- return true;
- },
- doUpdate : function(ds, record){
- this.refreshSummaryById(record._groupId);
- },
- doRemove : function(ds, record, index, isUpdate){
- if(!isUpdate){
- this.refreshSummaryById(record._groupId);
- }
- },
- /**
- * Show a message in the summary row.
- * <pre><code>
- grid.on('afteredit', function(){
- var groupValue = 'Ext Forms: Field Anchoring';
- summary.showSummaryMsg(groupValue, 'Updating Summary...');
- });
- * </code></pre>
- * @param {String} groupValue
- * @param {String} msg Text to use as innerHTML for the summary row.
- */
- showSummaryMsg : function(groupValue, msg){
- var gid = this.view.getGroupId(groupValue);
- var node = this.getSummaryNode(gid);
- if(node){
- node.innerHTML = '<div class="x-grid3-summary-msg">' + msg + '</div>';
- }
- }
- });
- //backwards compat
- Ext.grid.GroupSummary = Ext.ux.grid.GroupSummary;
- /**
- * Calculation types for summary row:</p><div class="mdetail-params"><ul>
- * <li><b><tt>sum</tt></b> : <div class="sub-desc"></div></li>
- * <li><b><tt>count</tt></b> : <div class="sub-desc"></div></li>
- * <li><b><tt>max</tt></b> : <div class="sub-desc"></div></li>
- * <li><b><tt>min</tt></b> : <div class="sub-desc"></div></li>
- * <li><b><tt>average</tt></b> : <div class="sub-desc"></div></li>
- * </ul></div>
- * <p>Custom calculations may be implemented. An example of
- * custom <code>summaryType=totalCost</code>:</p><pre><code>
- // define a custom summary function
- Ext.ux.grid.GroupSummary.Calculations['totalCost'] = function(v, record, field){
- return v + (record.data.estimate * record.data.rate);
- };
- * </code></pre>
- * @property Calculations
- */
- Ext.ux.grid.GroupSummary.Calculations = {
- 'sum' : function(v, record, field){
- return v + (record.data[field]||0);
- },
- 'count' : function(v, record, field, data){
- return data[field+'count'] ? ++data[field+'count'] : (data[field+'count'] = 1);
- },
- 'max' : function(v, record, field, data){
- var v = record.data[field];
- var max = data[field+'max'] === undefined ? (data[field+'max'] = v) : data[field+'max'];
- return v > max ? (data[field+'max'] = v) : max;
- },
- 'min' : function(v, record, field, data){
- var v = record.data[field];
- var min = data[field+'min'] === undefined ? (data[field+'min'] = v) : data[field+'min'];
- return v < min ? (data[field+'min'] = v) : min;
- },
- 'average' : function(v, record, field, data){
- var c = data[field+'count'] ? ++data[field+'count'] : (data[field+'count'] = 1);
- var t = (data[field+'total'] = ((data[field+'total']||0) + (record.data[field]||0)));
- return t === 0 ? 0 : t / c;
- }
- };
- Ext.grid.GroupSummary.Calculations = Ext.ux.grid.GroupSummary.Calculations;
- /**
- * @class Ext.ux.grid.HybridSummary
- * @extends Ext.ux.grid.GroupSummary
- * Adds capability to specify the summary data for the group via json as illustrated here:
- * <pre><code>
- {
- data: [
- {
- projectId: 100, project: 'House',
- taskId: 112, description: 'Paint',
- estimate: 6, rate: 150,
- due:'06/24/2007'
- },
- ...
- ],
- summaryData: {
- 'House': {
- description: 14, estimate: 9,
- rate: 99, due: new Date(2009, 6, 29),
- cost: 999
- }
- }
- }
- * </code></pre>
- *
- */
- Ext.ux.grid.HybridSummary = Ext.extend(Ext.ux.grid.GroupSummary, {
- /**
- * @private
- * @param {Object} rs
- * @param {Object} cs
- */
- calculate : function(rs, cs){
- var gcol = this.view.getGroupField();
- var gvalue = rs[0].data[gcol];
- var gdata = this.getSummaryData(gvalue);
- return gdata || Ext.ux.grid.HybridSummary.superclass.calculate.call(this, rs, cs);
- },
- /**
- * <pre><code>
- grid.on('afteredit', function(){
- var groupValue = 'Ext Forms: Field Anchoring';
- summary.showSummaryMsg(groupValue, 'Updating Summary...');
- setTimeout(function(){ // simulate server call
- // HybridSummary class implements updateSummaryData
- summary.updateSummaryData(groupValue,
- // create data object based on configured dataIndex
- {description: 22, estimate: 888, rate: 888, due: new Date(), cost: 8});
- }, 2000);
- });
- * </code></pre>
- * @param {String} groupValue
- * @param {Object} data data object
- * @param {Boolean} skipRefresh (Optional) Defaults to false
- */
- updateSummaryData : function(groupValue, data, skipRefresh){
- var json = this.grid.store.reader.jsonData;
- if(!json.summaryData){
- json.summaryData = {};
- }
- json.summaryData[groupValue] = data;
- if(!skipRefresh){
- this.refreshSummary(groupValue);
- }
- },
- /**
- * Returns the summaryData for the specified groupValue or null.
- * @param {String} groupValue
- * @return {Object} summaryData
- */
- getSummaryData : function(groupValue){
- var json = this.grid.store.reader.jsonData;
- if(json && json.summaryData){
- return json.summaryData[groupValue];
- }
- return null;
- }
- });
- //backwards compat
- Ext.grid.HybridSummary = Ext.ux.grid.HybridSummary;
- Ext.ux.GroupTab = Ext.extend(Ext.Container, {
- mainItem: 0,
- expanded: true,
- deferredRender: true,
- activeTab: null,
- idDelimiter: '__',
- headerAsText: false,
- frame: false,
- hideBorders: true,
- initComponent: function(config){
- Ext.apply(this, config);
- this.frame = false;
- Ext.ux.GroupTab.superclass.initComponent.call(this);
- this.addEvents('activate', 'deactivate', 'changemainitem', 'beforetabchange', 'tabchange');
- this.setLayout(new Ext.layout.CardLayout({
- deferredRender: this.deferredRender
- }));
- if (!this.stack) {
- this.stack = Ext.TabPanel.AccessStack();
- }
- this.initItems();
- this.on('beforerender', function(){
- this.groupEl = this.ownerCt.getGroupEl(this);
- }, this);
- this.on('add', this.onAdd, this, {
- target: this
- });
- this.on('remove', this.onRemove, this, {
- target: this
- });
- if (this.mainItem !== undefined) {
- var item = (typeof this.mainItem == 'object') ? this.mainItem : this.items.get(this.mainItem);
- delete this.mainItem;
- this.setMainItem(item);
- }
- },
- /**
- * Sets the specified tab as the active tab. This method fires the {@link #beforetabchange} event which
- * can return false to cancel the tab change.
- * @param {String/Panel} tab The id or tab Panel to activate
- */
- setActiveTab : function(item){
- item = this.getComponent(item);
- if(!item || this.fireEvent('beforetabchange', this, item, this.activeTab) === false){
- return;
- }
- if(!this.rendered){
- this.activeTab = item;
- return;
- }
- if(this.activeTab != item){
- if(this.activeTab && this.activeTab != this.mainItem){
- var oldEl = this.getTabEl(this.activeTab);
- if(oldEl){
- Ext.fly(oldEl).removeClass('x-grouptabs-strip-active');
- }
- this.activeTab.fireEvent('deactivate', this.activeTab);
- }
- var el = this.getTabEl(item);
- Ext.fly(el).addClass('x-grouptabs-strip-active');
- this.activeTab = item;
- this.stack.add(item);
- this.layout.setActiveItem(item);
- if(this.layoutOnTabChange && item.doLayout){
- item.doLayout();
- }
- if(this.scrolling){
- this.scrollToTab(item, this.animScroll);
- }
- item.fireEvent('activate', item);
- this.fireEvent('tabchange', this, item);
- }
- },
- getTabEl: function(item){
- if (item == this.mainItem) {
- return this.groupEl;
- }
- return Ext.TabPanel.prototype.getTabEl.call(this, item);
- },
- onRender: function(ct, position){
- Ext.ux.GroupTab.superclass.onRender.call(this, ct, position);
- this.strip = Ext.fly(this.groupEl).createChild({
- tag: 'ul',
- cls: 'x-grouptabs-sub'
- });
- this.tooltip = new Ext.ToolTip({
- target: this.groupEl,
- delegate: 'a.x-grouptabs-text',
- trackMouse: true,
- renderTo: document.body,
- listeners: {
- beforeshow: function(tip) {
- var item = (tip.triggerElement.parentNode === this.mainItem.tabEl)
- ? this.mainItem
- : this.findById(tip.triggerElement.parentNode.id.split(this.idDelimiter)[1]);
- if(!item.tabTip) {
- return false;
- }
- tip.body.dom.innerHTML = item.tabTip;
- },
- scope: this
- }
- });
- if (!this.itemTpl) {
- var tt = new Ext.Template('<li class="{cls}" id="{id}">', '<a onclick="return false;" class="x-grouptabs-text {iconCls}">{text}</a>', '</li>');
- tt.disableFormats = true;
- tt.compile();
- Ext.ux.GroupTab.prototype.itemTpl = tt;
- }
- this.items.each(this.initTab, this);
- },
- afterRender: function(){
- Ext.ux.GroupTab.superclass.afterRender.call(this);
- if (this.activeTab !== undefined) {
- var item = (typeof this.activeTab == 'object') ? this.activeTab : this.items.get(this.activeTab);
- delete this.activeTab;
- this.setActiveTab(item);
- }
- },
- // private
- initTab: function(item, index){
- var before = this.strip.dom.childNodes[index];
- var p = Ext.TabPanel.prototype.getTemplateArgs.call(this, item);
- if (item === this.mainItem) {
- item.tabEl = this.groupEl;
- p.cls += ' x-grouptabs-main-item';
- }
- var el = before ? this.itemTpl.insertBefore(before, p) : this.itemTpl.append(this.strip, p);
- item.tabEl = item.tabEl || el;
- item.on('disable', this.onItemDisabled, this);
- item.on('enable', this.onItemEnabled, this);
- item.on('titlechange', this.onItemTitleChanged, this);
- item.on('iconchange', this.onItemIconChanged, this);
- item.on('beforeshow', this.onBeforeShowItem, this);
- },
- setMainItem: function(item){
- item = this.getComponent(item);
- if (!item || this.fireEvent('changemainitem', this, item, this.mainItem) === false) {
- return;
- }
- this.mainItem = item;
- },
- getMainItem: function(){
- return this.mainItem || null;
- },
- // private
- onBeforeShowItem: function(item){
- if (item != this.activeTab) {
- this.setActiveTab(item);
- return false;
- }
- },
- // private
- onAdd: function(gt, item, index){
- if (this.rendered) {
- this.initTab.call(this, item, index);
- }
- },
- // private
- onRemove: function(tp, item){
- Ext.destroy(Ext.get(this.getTabEl(item)));
- this.stack.remove(item);
- item.un('disable', this.onItemDisabled, this);
- item.un('enable', this.onItemEnabled, this);
- item.un('titlechange', this.onItemTitleChanged, this);
- item.un('iconchange', this.onItemIconChanged, this);
- item.un('beforeshow', this.onBeforeShowItem, this);
- if (item == this.activeTab) {
- var next = this.stack.next();
- if (next) {
- this.setActiveTab(next);
- }
- else if (this.items.getCount() > 0) {
- this.setActiveTab(0);
- }
- else {
- this.activeTab = null;
- }
- }
- },
- // private
- onBeforeAdd: function(item){
- var existing = item.events ? (this.items.containsKey(item.getItemId()) ? item : null) : this.items.get(item);
- if (existing) {
- this.setActiveTab(item);
- return false;
- }
- Ext.TabPanel.superclass.onBeforeAdd.apply(this, arguments);
- var es = item.elements;
- item.elements = es ? es.replace(',header', '') : es;
- item.border = (item.border === true);
- },
- // private
- onItemDisabled: Ext.TabPanel.prototype.onItemDisabled,
- onItemEnabled: Ext.TabPanel.prototype.onItemEnabled,
- // private
- onItemTitleChanged: function(item){
- var el = this.getTabEl(item);
- if (el) {
- Ext.fly(el).child('a.x-grouptabs-text', true).innerHTML = item.title;
- }
- },
- //private
- onItemIconChanged: function(item, iconCls, oldCls){
- var el = this.getTabEl(item);
- if (el) {
- Ext.fly(el).child('a.x-grouptabs-text').replaceClass(oldCls, iconCls);
- }
- },
- beforeDestroy: function(){
- Ext.TabPanel.prototype.beforeDestroy.call(this);
- this.tooltip.destroy();
- }
- });
- Ext.reg('grouptab', Ext.ux.GroupTab);
- Ext.ns('Ext.ux');
- Ext.ux.GroupTabPanel = Ext.extend(Ext.TabPanel, {
- tabPosition: 'left',
- alternateColor: false,
- alternateCls: 'x-grouptabs-panel-alt',
- defaultType: 'grouptab',
- deferredRender: false,
- activeGroup : null,
- initComponent: function(){
- Ext.ux.GroupTabPanel.superclass.initComponent.call(this);
- this.addEvents(
- 'beforegroupchange',
- 'groupchange'
- );
- this.elements = 'body,header';
- this.stripTarget = 'header';
- this.tabPosition = this.tabPosition == 'right' ? 'right' : 'left';
- this.addClass('x-grouptabs-panel');
- if (this.tabStyle && this.tabStyle != '') {
- this.addClass('x-grouptabs-panel-' + this.tabStyle);
- }
- if (this.alternateColor) {
- this.addClass(this.alternateCls);
- }
- this.on('beforeadd', function(gtp, item, index){
- this.initGroup(item, index);
- });
- },
- initEvents : function() {
- this.mon(this.strip, 'mousedown', this.onStripMouseDown, this);
- },
- onRender: function(ct, position){
- Ext.TabPanel.superclass.onRender.call(this, ct, position);
- if(this.plain){
- var pos = this.tabPosition == 'top' ? 'header' : 'footer';
- this[pos].addClass('x-tab-panel-'+pos+'-plain');
- }
- var st = this[this.stripTarget];
- this.stripWrap = st.createChild({cls:'x-tab-strip-wrap ', cn:{
- tag:'ul', cls:'x-grouptabs-strip x-grouptabs-tab-strip-'+this.tabPosition}});
- var beforeEl = (this.tabPosition=='bottom' ? this.stripWrap : null);
- this.strip = new Ext.Element(this.stripWrap.dom.firstChild);
- this.header.addClass('x-grouptabs-panel-header');
- this.bwrap.addClass('x-grouptabs-bwrap');
- this.body.addClass('x-tab-panel-body-'+this.tabPosition + ' x-grouptabs-panel-body');
- if (!this.itemTpl) {
- var tt = new Ext.Template(
- '<li class="{cls}" id="{id}">',
- '<a class="x-grouptabs-expand" onclick="return false;"></a>',
- '<a class="x-grouptabs-text {iconCls}" href="#" onclick="return false;">',
- '<span>{text}</span></a>',
- '</li>'
- );
- tt.disableFormats = true;
- tt.compile();
- Ext.ux.GroupTabPanel.prototype.itemTpl = tt;
- }
- this.items.each(this.initGroup, this);
- },
- afterRender: function(){
- Ext.ux.GroupTabPanel.superclass.afterRender.call(this);
- this.tabJoint = Ext.fly(this.body.dom.parentNode).createChild({
- cls: 'x-tab-joint'
- });
- this.addClass('x-tab-panel-' + this.tabPosition);
- this.header.setWidth(this.tabWidth);
- if (this.activeGroup !== undefined) {
- var group = (typeof this.activeGroup == 'object') ? this.activeGroup : this.items.get(this.activeGroup);
- delete this.activeGroup;
- this.setActiveGroup(group);
- group.setActiveTab(group.getMainItem());
- }
- },
- getGroupEl : Ext.TabPanel.prototype.getTabEl,
- // private
- findTargets: function(e){
- var item = null;
- var itemEl = e.getTarget('li', this.strip);
- if (itemEl) {
- item = this.findById(itemEl.id.split(this.idDelimiter)[1]);
- if (item.disabled) {
- return {
- expand: null,
- item: null,
- el: null
- };
- }
- }
- return {
- expand: e.getTarget('.x-grouptabs-expand', this.strip),
- isGroup: !e.getTarget('ul.x-grouptabs-sub', this.strip),
- item: item,
- el: itemEl
- };
- },
- // private
- onStripMouseDown: function(e){
- if (e.button != 0) {
- return;
- }
- e.preventDefault();
- var t = this.findTargets(e);
- if (t.expand) {
- this.toggleGroup(t.el);
- }
- else if (t.item) {
- if(t.isGroup) {
- t.item.setActiveTab(t.item.getMainItem());
- }
- else {
- t.item.ownerCt.setActiveTab(t.item);
- }
- }
- },
- expandGroup: function(groupEl){
- if(groupEl.isXType) {
- groupEl = this.getGroupEl(groupEl);
- }
- Ext.fly(groupEl).addClass('x-grouptabs-expanded');
- },
- toggleGroup: function(groupEl){
- if(groupEl.isXType) {
- groupEl = this.getGroupEl(groupEl);
- }
- Ext.fly(groupEl).toggleClass('x-grouptabs-expanded');
- this.syncTabJoint();
- },
- syncTabJoint: function(groupEl){
- if (!this.tabJoint) {
- return;
- }
- groupEl = groupEl || this.getGroupEl(this.activeGroup);
- if(groupEl) {
- this.tabJoint.setHeight(Ext.fly(groupEl).getHeight() - 2);
- var y = Ext.isGecko2 ? 0 : 1;
- if (this.tabPosition == 'left'){
- this.tabJoint.alignTo(groupEl, 'tl-tr', [-2,y]);
- }
- else {
- this.tabJoint.alignTo(groupEl, 'tr-tl', [1,y]);
- }
- }
- else {
- this.tabJoint.hide();
- }
- },
- getActiveTab : function() {
- if(!this.activeGroup) return null;
- return this.activeGroup.getTabEl(this.activeGroup.activeTab) || null;
- },
- onResize: function(){
- Ext.ux.GroupTabPanel.superclass.onResize.apply(this, arguments);
- this.syncTabJoint();
- },
- createCorner: function(el, pos){
- return Ext.fly(el).createChild({
- cls: 'x-grouptabs-corner x-grouptabs-corner-' + pos
- });
- },
- initGroup: function(group, index){
- var before = this.strip.dom.childNodes[index];
- var p = this.getTemplateArgs(group);
- if (index === 0) {
- p.cls += ' x-tab-first';
- }
- p.cls += ' x-grouptabs-main';
- p.text = group.getMainItem().title;
- var el = before ? this.itemTpl.insertBefore(before, p) : this.itemTpl.append(this.strip, p);
- var tl = this.createCorner(el, 'top-' + this.tabPosition);
- var bl = this.createCorner(el, 'bottom-' + this.tabPosition);
- if (group.expanded) {
- this.expandGroup(el);
- }
- if (Ext.isIE6 || (Ext.isIE && !Ext.isStrict)){
- bl.setLeft('-10px');
- bl.setBottom('-5px');
- tl.setLeft('-10px');
- tl.setTop('-5px');
- }
- this.mon(group, 'changemainitem', this.onGroupChangeMainItem, this);
- this.mon(group, 'beforetabchange', this.onGroupBeforeTabChange, this);
- },
- setActiveGroup : function(group) {
- group = this.getComponent(group);
- if(!group || this.fireEvent('beforegroupchange', this, group, this.activeGroup) === false){
- return;
- }
- if(!this.rendered){
- this.activeGroup = group;
- return;
- }
- if(this.activeGroup != group){
- if(this.activeGroup){
- var oldEl = this.getGroupEl(this.activeGroup);
- if(oldEl){
- Ext.fly(oldEl).removeClass('x-grouptabs-strip-active');
- }
- this.activeGroup.fireEvent('deactivate', this.activeTab);
- }
- var groupEl = this.getGroupEl(group);
- Ext.fly(groupEl).addClass('x-grouptabs-strip-active');
- this.activeGroup = group;
- this.stack.add(group);
- this.layout.setActiveItem(group);
- this.syncTabJoint(groupEl);
- group.fireEvent('activate', group);
- this.fireEvent('groupchange', this, group);
- }
- },
- onGroupBeforeTabChange: function(group, newTab, oldTab){
- if(group !== this.activeGroup || newTab !== oldTab) {
- this.strip.select('.x-grouptabs-sub > li.x-grouptabs-strip-active', true).removeClass('x-grouptabs-strip-active');
- }
- this.expandGroup(this.getGroupEl(group));
- this.setActiveGroup(group);
- },
- getFrameHeight: function(){
- var h = this.el.getFrameWidth('tb');
- h += (this.tbar ? this.tbar.getHeight() : 0) +
- (this.bbar ? this.bbar.getHeight() : 0);
- return h;
- },
- adjustBodyWidth: function(w){
- return w - this.tabWidth;
- }
- });
- Ext.reg('grouptabpanel', Ext.ux.GroupTabPanel);/*
- * Note that this control will most likely remain as an example, and not as a core Ext form
- * control. However, the API will be changing in a future release and so should not yet be
- * treated as a final, stable API at this time.
- */
- /**
- * @class Ext.ux.form.ItemSelector
- * @extends Ext.form.Field
- * A control that allows selection of between two Ext.ux.form.MultiSelect controls.
- *
- * @history
- * 2008-06-19 bpm Original code contributed by Toby Stuart (with contributions from Robert Williams)
- *
- * @constructor
- * Create a new ItemSelector
- * @param {Object} config Configuration options
- * @xtype itemselector
- */
- Ext.ux.form.ItemSelector = Ext.extend(Ext.form.Field, {
- hideNavIcons:false,
- imagePath:"",
- iconUp:"up2.gif",
- iconDown:"down2.gif",
- iconLeft:"left2.gif",
- iconRight:"right2.gif",
- iconTop:"top2.gif",
- iconBottom:"bottom2.gif",
- drawUpIcon:true,
- drawDownIcon:true,
- drawLeftIcon:true,
- drawRightIcon:true,
- drawTopIcon:true,
- drawBotIcon:true,
- delimiter:',',
- bodyStyle:null,
- border:false,
- defaultAutoCreate:{tag: "div"},
- /**
- * @cfg {Array} multiselects An array of {@link Ext.ux.form.MultiSelect} config objects, with at least all required parameters (e.g., store)
- */
- multiselects:null,
- initComponent: function(){
- Ext.ux.form.ItemSelector.superclass.initComponent.call(this);
- this.addEvents({
- 'rowdblclick' : true,
- 'change' : true
- });
- },
- onRender: function(ct, position){
- Ext.ux.form.ItemSelector.superclass.onRender.call(this, ct, position);
- // Internal default configuration for both multiselects
- var msConfig = [{
- legend: 'Available',
- draggable: true,
- droppable: true,
- width: 100,
- height: 100
- },{
- legend: 'Selected',
- droppable: true,
- draggable: true,
- width: 100,
- height: 100
- }];
- this.fromMultiselect = new Ext.ux.form.MultiSelect(Ext.applyIf(this.multiselects[0], msConfig[0]));
- this.fromMultiselect.on('dblclick', this.onRowDblClick, this);
- this.toMultiselect = new Ext.ux.form.MultiSelect(Ext.applyIf(this.multiselects[1], msConfig[1]));
- this.toMultiselect.on('dblclick', this.onRowDblClick, this);
- var p = new Ext.Panel({
- bodyStyle:this.bodyStyle,
- border:this.border,
- layout:"table",