Update extensions to Ext JS 3.4.0

This commit is contained in:
Calum Lind 2012-02-18 17:54:51 +00:00
commit abc82c1439
12 changed files with 1277 additions and 1183 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -1,8 +1,8 @@
/*! /*!
* Ext JS Library 3.1.0 * Ext JS Library 3.4.0
* Copyright(c) 2006-2009 Ext JS, LLC * Copyright(c) 2006-2011 Sencha Inc.
* licensing@extjs.com * licensing@sencha.com
* http://www.extjs.com/license * http://www.sencha.com/license
*/ */
/** /**
* @class Ext.ux.Spinner * @class Ext.ux.Spinner
@ -89,12 +89,14 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
doEnable: function(){ doEnable: function(){
if (this.wrap) { if (this.wrap) {
this.disabled = false;
this.wrap.removeClass(this.field.disabledClass); this.wrap.removeClass(this.field.disabledClass);
} }
}, },
doDisable: function(){ doDisable: function(){
if (this.wrap) { if (this.wrap) {
this.disabled = true;
this.wrap.addClass(this.field.disabledClass); this.wrap.addClass(this.field.disabledClass);
this.el.removeClass(this.field.disabledClass); this.el.removeClass(this.field.disabledClass);
} }
@ -431,6 +433,9 @@ Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
if (this.repeater) { if (this.repeater) {
this.repeater.purgeListeners(); this.repeater.purgeListeners();
} }
if (this.mimicing){
Ext.get(Ext.isIE ? document.body : document).un("mousedown", this.mimicBlur, this);
}
} }
}); });

View file

@ -1,8 +1,8 @@
/*! /*!
* Ext JS Library 3.1.0 * Ext JS Library 3.4.0
* Copyright(c) 2006-2009 Ext JS, LLC * Copyright(c) 2006-2011 Sencha Inc.
* licensing@extjs.com * licensing@sencha.com
* http://www.extjs.com/license * http://www.sencha.com/license
*/ */
Ext.ns('Ext.ux.form'); Ext.ns('Ext.ux.form');
@ -119,9 +119,11 @@ Ext.ux.form.FileUploadField = Ext.extend(Ext.form.TextField, {
}, },
reset : function(){ reset : function(){
this.fileInput.remove(); if (this.rendered) {
this.createFileInput(); this.fileInput.remove();
this.bindListeners(); this.createFileInput();
this.bindListeners();
}
Ext.ux.form.FileUploadField.superclass.reset.call(this); Ext.ux.form.FileUploadField.superclass.reset.call(this);
}, },

View file

@ -1,8 +1,8 @@
/*! /*!
* Ext JS Library 3.1.0 * Ext JS Library 3.4.0
* Copyright(c) 2006-2009 Ext JS, LLC * Copyright(c) 2006-2011 Sencha Inc.
* licensing@extjs.com * licensing@sencha.com
* http://www.extjs.com/license * http://www.sencha.com/license
*/ */
Ext.ns('Ext.ux.form'); Ext.ns('Ext.ux.form');
@ -20,17 +20,17 @@ Ext.ux.form.SpinnerField = Ext.extend(Ext.form.NumberField, {
adjustSize: Ext.BoxComponent.prototype.adjustSize, adjustSize: Ext.BoxComponent.prototype.adjustSize,
constructor: function(config) { constructor: function(config) {
var spinnerConfig = Ext.copyTo({}, config, 'incrementValue,alternateIncrementValue,accelerate,defaultValue,triggerClass,splitterClass'); var spinnerConfig = Ext.copyTo({}, config, 'incrementValue,alternateIncrementValue,accelerate,defaultValue,triggerClass,splitterClass');
var spl = this.spinner = new Ext.ux.Spinner(spinnerConfig); var spl = this.spinner = new Ext.ux.Spinner(spinnerConfig);
var plugins = config.plugins var plugins = config.plugins
? (Ext.isArray(config.plugins) ? (Ext.isArray(config.plugins)
? config.plugins.push(spl) ? config.plugins.push(spl)
: [config.plugins, spl]) : [config.plugins, spl])
: spl; : spl;
Ext.ux.form.SpinnerField.superclass.constructor.call(this, Ext.apply(config, {plugins: plugins})); Ext.ux.form.SpinnerField.superclass.constructor.call(this, Ext.apply(config, {plugins: plugins}));
}, },
// private // private

View file

@ -1,8 +1,8 @@
/*! /*!
* Ext JS Library 3.1.0 * Ext JS Library 3.4.0
* Copyright(c) 2006-2009 Ext JS, LLC * Copyright(c) 2006-2011 Sencha Inc.
* licensing@extjs.com * licensing@sencha.com
* http://www.extjs.com/license * http://www.sencha.com/license
*/ */
Ext.ns('Ext.ux.grid'); Ext.ns('Ext.ux.grid');
@ -50,14 +50,14 @@ Ext.ux.grid.BufferView = Ext.extend(Ext.grid.GridView, {
Ext.ux.grid.BufferView.superclass.initTemplates.call(this); Ext.ux.grid.BufferView.superclass.initTemplates.call(this);
var ts = this.templates; var ts = this.templates;
// empty div to act as a place holder for a row // empty div to act as a place holder for a row
ts.rowHolder = new Ext.Template( ts.rowHolder = new Ext.Template(
'<div class="x-grid3-row {alt}" style="{tstyle}"></div>' '<div class="x-grid3-row {alt}" style="{tstyle}"></div>'
); );
ts.rowHolder.disableFormats = true; ts.rowHolder.disableFormats = true;
ts.rowHolder.compile(); ts.rowHolder.compile();
ts.rowBody = new Ext.Template( ts.rowBody = new Ext.Template(
'<table class="x-grid3-row-table" border="0" cellspacing="0" cellpadding="0" style="{tstyle}">', '<table class="x-grid3-row-table" border="0" cellspacing="0" cellpadding="0" style="{tstyle}">',
'<tbody><tr>{cells}</tr>', '<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>' : ''), (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>' '</tbody></table>'
@ -75,15 +75,15 @@ Ext.ux.grid.BufferView = Ext.extend(Ext.grid.GridView, {
}, },
getVisibleRowCount : function(){ getVisibleRowCount : function(){
var rh = this.getCalculatedRowHeight(); var rh = this.getCalculatedRowHeight(),
var visibleHeight = this.scroller.dom.clientHeight; visibleHeight = this.scroller.dom.clientHeight;
return (visibleHeight < 1) ? 0 : Math.ceil(visibleHeight / rh); return (visibleHeight < 1) ? 0 : Math.ceil(visibleHeight / rh);
}, },
getVisibleRows: function(){ getVisibleRows: function(){
var count = this.getVisibleRowCount(); var count = this.getVisibleRowCount(),
var sc = this.scroller.dom.scrollTop; sc = this.scroller.dom.scrollTop,
var start = (sc == 0 ? 0 : Math.floor(sc/this.getCalculatedRowHeight())-1); start = (sc === 0 ? 0 : Math.floor(sc/this.getCalculatedRowHeight())-1);
return { return {
first: Math.max(start, 0), first: Math.max(start, 0),
last: Math.min(start + count + 2, this.ds.getCount()-1) last: Math.min(start + count + 2, this.ds.getCount()-1)
@ -91,25 +91,34 @@ Ext.ux.grid.BufferView = Ext.extend(Ext.grid.GridView, {
}, },
doRender : function(cs, rs, ds, startRow, colCount, stripe, onlyBody){ 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 ts = this.templates,
var rh = this.getStyleRowHeight(); ct = ts.cell,
var vr = this.getVisibleRows(); rt = ts.row,
var tstyle = 'width:'+this.getTotalWidth()+';height:'+rh+'px;'; rb = ts.rowBody,
// buffers last = colCount-1,
var buf = [], cb, c, p = {}, rp = {tstyle: tstyle}, r; rh = this.getStyleRowHeight(),
vr = this.getVisibleRows(),
tstyle = 'width:'+this.getTotalWidth()+';height:'+rh+'px;',
// buffers
buf = [],
cb,
c,
p = {},
rp = {tstyle: tstyle},
r;
for (var j = 0, len = rs.length; j < len; j++) { for (var j = 0, len = rs.length; j < len; j++) {
r = rs[j]; cb = []; r = rs[j]; cb = [];
var rowIndex = (j+startRow); var rowIndex = (j+startRow),
var visible = rowIndex >= vr.first && rowIndex <= vr.last; visible = rowIndex >= vr.first && rowIndex <= vr.last;
if (visible) { if (visible) {
for (var i = 0; i < colCount; i++) { for (var i = 0; i < colCount; i++) {
c = cs[i]; c = cs[i];
p.id = c.id; p.id = c.id;
p.css = i == 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : ''); p.css = i === 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '');
p.attr = p.cellAttr = ""; p.attr = p.cellAttr = "";
p.value = c.renderer(r.data[c.name], p, r, rowIndex, i, ds); p.value = c.renderer(r.data[c.name], p, r, rowIndex, i, ds);
p.style = c.style; p.style = c.style;
if (p.value == undefined || p.value === "") { if (p.value === undefined || p.value === "") {
p.value = "&#160;"; p.value = "&#160;";
} }
if (r.dirty && typeof r.modified[c.name] !== 'undefined') { if (r.dirty && typeof r.modified[c.name] !== 'undefined') {
@ -119,7 +128,7 @@ Ext.ux.grid.BufferView = Ext.extend(Ext.grid.GridView, {
} }
} }
var alt = []; var alt = [];
if(stripe && ((rowIndex+1) % 2 == 0)){ if(stripe && ((rowIndex+1) % 2 === 0)){
alt[0] = "x-grid3-row-alt"; alt[0] = "x-grid3-row-alt";
} }
if(r.dirty){ if(r.dirty){
@ -159,23 +168,25 @@ Ext.ux.grid.BufferView = Ext.extend(Ext.grid.GridView, {
}, },
onRemove : function(ds, record, index, isUpdate){ onRemove : function(ds, record, index, isUpdate){
Ext.ux.grid.BufferView.superclass.onRemove.apply(this, arguments); Ext.ux.grid.BufferView.superclass.onRemove.apply(this, arguments);
if(isUpdate !== true){ if(isUpdate !== true){
this.update(); this.update();
} }
}, },
doUpdate: function(){ doUpdate: function(){
if (this.getVisibleRowCount() > 0) { if (this.getVisibleRowCount() > 0) {
var g = this.grid, cm = g.colModel, ds = g.store; var g = this.grid,
var cs = this.getColumnData(); cm = g.colModel,
ds = g.store,
var vr = this.getVisibleRows(); cs = this.getColumnData(),
vr = this.getVisibleRows(),
row;
for (var i = vr.first; i <= vr.last; i++) { for (var i = vr.first; i <= vr.last; i++) {
// if row is NOT rendered and is visible, render it // if row is NOT rendered and is visible, render it
if(!this.isRowRendered(i)){ if(!this.isRowRendered(i) && (row = this.getRow(i))){
var html = this.doRender(cs, [ds.getAt(i)], ds, i, cm.getColumnCount(), g.stripeRows, true); var html = this.doRender(cs, [ds.getAt(i)], ds, i, cm.getColumnCount(), g.stripeRows, true);
this.getRow(i).innerHTML = html; row.innerHTML = html;
} }
} }
this.clean(); this.clean();
@ -212,6 +223,20 @@ Ext.ux.grid.BufferView = Ext.extend(Ext.grid.GridView, {
} }
}, },
removeTask: function(name){
var task = this[name];
if(task && task.cancel){
task.cancel();
this[name] = null;
}
},
destroy : function(){
this.removeTask('cleanTask');
this.removeTask('renderTask');
Ext.ux.grid.BufferView.superclass.destroy.call(this);
},
layout: function(){ layout: function(){
Ext.ux.grid.BufferView.superclass.layout.call(this); Ext.ux.grid.BufferView.superclass.layout.call(this);
this.update(); this.update();

View file

@ -1,8 +1,8 @@
/*! /*!
* Ext JS Library 3.1.0 * Ext JS Library 3.4.0
* Copyright(c) 2006-2009 Ext JS, LLC * Copyright(c) 2006-2011 Sencha Inc.
* licensing@extjs.com * licensing@sencha.com
* http://www.extjs.com/license * http://www.sencha.com/license
*/ */
Ext.ns('Ext.ux.tree'); Ext.ns('Ext.ux.tree');
@ -42,14 +42,6 @@ Ext.ux.tree.TreeGrid = Ext.extend(Ext.tree.TreePanel, {
}else if(Ext.isObject(l) && !l.load){ }else if(Ext.isObject(l) && !l.load){
l = new Ext.ux.tree.TreeGridLoader(l); l = new Ext.ux.tree.TreeGridLoader(l);
} }
else if(l) {
l.createNode = function(attr) {
if (!attr.uiProvider) {
attr.uiProvider = Ext.ux.tree.TreeGridNodeUI;
}
return Ext.tree.TreeLoader.prototype.createNode.call(this, attr);
}
}
this.loader = l; this.loader = l;
Ext.ux.tree.TreeGrid.superclass.initComponent.call(this); Ext.ux.tree.TreeGrid.superclass.initComponent.call(this);
@ -71,7 +63,7 @@ Ext.ux.tree.TreeGrid = Ext.extend(Ext.tree.TreePanel, {
'<div class="x-grid3-header">', '<div class="x-grid3-header">',
'<div class="x-treegrid-header-inner">', '<div class="x-treegrid-header-inner">',
'<div class="x-grid3-header-offset">', '<div class="x-grid3-header-offset">',
'<table cellspacing="0" cellpadding="0" border="0"><colgroup><tpl for="columns"><col /></tpl></colgroup>', '<table style="table-layout: fixed;" cellspacing="0" cellpadding="0" border="0"><colgroup><tpl for="columns"><col /></tpl></colgroup>',
'<thead><tr class="x-grid3-hd-row">', '<thead><tr class="x-grid3-hd-row">',
'<tpl for="columns">', '<tpl for="columns">',
'<td class="x-grid3-hd x-grid3-cell x-treegrid-hd" style="text-align: {align};" id="', this.id, '-xlhd-{#}">', '<td class="x-grid3-hd x-grid3-cell x-treegrid-hd" style="text-align: {align};" id="', this.id, '-xlhd-{#}">',
@ -81,7 +73,7 @@ Ext.ux.tree.TreeGrid = Ext.extend(Ext.tree.TreePanel, {
'</div>', '</div>',
'</td></tpl>', '</td></tpl>',
'</tr></thead>', '</tr></thead>',
'</div></table>', '</table>',
'</div></div>', '</div></div>',
'</div>', '</div>',
'<div class="x-treegrid-root-node">', '<div class="x-treegrid-root-node">',
@ -140,7 +132,7 @@ Ext.ux.tree.TreeGrid = Ext.extend(Ext.tree.TreePanel, {
this.colgroupTpl.insertFirst(this.innerCt, {columns: this.columns}); this.colgroupTpl.insertFirst(this.innerCt, {columns: this.columns});
if(this.hideHeaders){ if(this.hideHeaders){
this.header.dom.style.display = 'none'; this.el.child('.x-grid3-header').setDisplayed('none');
} }
else if(this.enableHdMenu !== false){ else if(this.enableHdMenu !== false){
this.hmenu = new Ext.menu.Menu({id: this.id + '-hctx'}); this.hmenu = new Ext.menu.Menu({id: this.id + '-hctx'});
@ -172,6 +164,17 @@ Ext.ux.tree.TreeGrid = Ext.extend(Ext.tree.TreePanel, {
return node; return node;
}, },
clearInnerCt : function(){
if(Ext.isIE){
var dom = this.innerCt.dom;
while(dom.firstChild){
dom.removeChild(dom.firstChild);
}
}else{
Ext.ux.tree.TreeGrid.superclass.clearInnerCt.call(this);
}
},
initEvents : function() { initEvents : function() {
Ext.ux.tree.TreeGrid.superclass.initEvents.apply(this, arguments); Ext.ux.tree.TreeGrid.superclass.initEvents.apply(this, arguments);

View file

@ -1,8 +1,8 @@
/*! /*!
* Ext JS Library 3.1.0 * Ext JS Library 3.4.0
* Copyright(c) 2006-2009 Ext JS, LLC * Copyright(c) 2006-2011 Sencha Inc.
* licensing@extjs.com * licensing@sencha.com
* http://www.extjs.com/license * http://www.sencha.com/license
*/ */
/** /**
* @class Ext.tree.ColumnResizer * @class Ext.tree.ColumnResizer
@ -80,6 +80,7 @@ Ext.tree.ColumnResizer = Ext.extend(Ext.util.Observable, {
}, },
onStart : function(e){ onStart : function(e){
this.dragHeadersDisabled = this.tree.headersDisabled;
this.tree.headersDisabled = true; this.tree.headersDisabled = true;
this.proxy = this.tree.body.createChild({cls:'x-treegrid-resizer'}); this.proxy = this.tree.body.createChild({cls:'x-treegrid-resizer'});
this.proxy.setHeight(this.tree.body.getHeight()); this.proxy.setHeight(this.tree.body.getHeight());
@ -102,7 +103,8 @@ Ext.tree.ColumnResizer = Ext.extend(Ext.util.Observable, {
onEnd : function(e){ onEnd : function(e){
var nw = this.proxy.getWidth(), var nw = this.proxy.getWidth(),
tree = this.tree; tree = this.tree,
disabled = this.dragHeadersDisabled;
this.proxy.remove(); this.proxy.remove();
delete this.dragHd; delete this.dragHd;
@ -111,7 +113,7 @@ Ext.tree.ColumnResizer = Ext.extend(Ext.util.Observable, {
tree.updateColumnWidths(); tree.updateColumnWidths();
setTimeout(function(){ setTimeout(function(){
tree.headersDisabled = false; tree.headersDisabled = disabled;
}, 100); }, 100);
} }
}); });

View file

@ -1,34 +1,28 @@
/*! /*!
* Ext JS Library 3.1.0 * Ext JS Library 3.4.0
* Copyright(c) 2006-2009 Ext JS, LLC * Copyright(c) 2006-2011 Sencha Inc.
* licensing@extjs.com * licensing@sencha.com
* http://www.extjs.com/license * http://www.sencha.com/license
*/ */
(function() { (function() {
Ext.override(Ext.list.Column, { Ext.override(Ext.list.Column, {
init : function() { init : function() {
if(!this.type){ var types = Ext.data.Types,
this.type = "auto"; st = this.sortType;
}
var st = Ext.data.SortTypes; if(this.type){
// named sortTypes are supported, here we look them up if(Ext.isString(this.type)){
if(typeof this.sortType == "string"){ this.type = Ext.data.Types[this.type.toUpperCase()] || types.AUTO;
this.sortType = st[this.sortType];
}
// set default sortType for strings and dates
if(!this.sortType){
switch(this.type){
case "string":
this.sortType = st.asUCString;
break;
case "date":
this.sortType = st.asDate;
break;
default:
this.sortType = st.none;
} }
}else{
this.type = types.AUTO;
}
// named sortTypes are supported, here we look them up
if(Ext.isString(st)){
this.sortType = Ext.data.SortTypes[st];
}else if(Ext.isEmpty(st)){
this.sortType = this.type.sortType;
} }
} }
}); });

View file

@ -1,8 +1,8 @@
/*! /*!
* Ext JS Library 3.1.0 * Ext JS Library 3.4.0
* Copyright(c) 2006-2009 Ext JS, LLC * Copyright(c) 2006-2011 Sencha Inc.
* licensing@extjs.com * licensing@sencha.com
* http://www.extjs.com/license * http://www.sencha.com/license
*/ */
/** /**
* @class Ext.ux.tree.TreeGridLoader * @class Ext.ux.tree.TreeGridLoader

View file

@ -1,8 +1,8 @@
/*! /*!
* Ext JS Library 3.1.0 * Ext JS Library 3.4.0
* Copyright(c) 2006-2009 Ext JS, LLC * Copyright(c) 2006-2011 Sencha Inc.
* licensing@extjs.com * licensing@sencha.com
* http://www.extjs.com/license * http://www.sencha.com/license
*/ */
/** /**
* @class Ext.ux.tree.TreeGridNodeUI * @class Ext.ux.tree.TreeGridNodeUI
@ -21,11 +21,11 @@ Ext.ux.tree.TreeGridNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
buf = [ buf = [
'<tbody class="x-tree-node">', '<tbody class="x-tree-node">',
'<tr ext:tree-node-id="', n.id ,'" class="x-tree-node-el ', a.cls, '">', '<tr ext:tree-node-id="', n.id ,'" class="x-tree-node-el x-tree-node-leaf ', a.cls, '">',
'<td class="x-treegrid-col">', '<td class="x-treegrid-col">',
'<span class="x-tree-node-indent">', this.indentMarkup, "</span>", '<span class="x-tree-node-indent">', this.indentMarkup, "</span>",
'<img src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow">', '<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">', '<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 hidefocus="on" class="x-tree-node-anchor" href="', a.href ? a.href : '#', '" tabIndex="1" ',
a.hrefTarget ? ' target="'+a.hrefTarget+'"' : '', '>', a.hrefTarget ? ' target="'+a.hrefTarget+'"' : '', '>',
'<span unselectable="on">', (c.tpl ? c.tpl.apply(a) : a[c.dataIndex] || c.text), '</span></a>', '<span unselectable="on">', (c.tpl ? c.tpl.apply(a) : a[c.dataIndex] || c.text), '</span></a>',

View file

@ -1,14 +1,30 @@
/*! /*!
* Ext JS Library 3.1.0 * Ext JS Library 3.4.0
* Copyright(c) 2006-2009 Ext JS, LLC * Copyright(c) 2006-2011 Sencha Inc.
* licensing@extjs.com * licensing@sencha.com
* http://www.extjs.com/license * http://www.sencha.com/license
*/ */
Ext.ns('Ext.ux.tree'); Ext.ns('Ext.ux.tree');
/** /**
* @class Ext.ux.tree.TreeGridSorter * @class Ext.ux.tree.TreeGridSorter
* @extends Ext.tree.TreeSorter * @extends Ext.tree.TreeSorter
* Provides sorting of nodes in a {@link Ext.ux.tree.TreeGrid}. The TreeGridSorter automatically monitors events on the
* associated TreeGrid that might affect the tree's sort order (beforechildrenrendered, append, insert and textchange).
* Example usage:<br />
* <pre><code>
new Ext.ux.tree.TreeGridSorter(myTreeGrid, {
folderSort: true,
dir: "desc",
sortType: function(node) {
// sort by a custom, typed attribute:
return parseInt(node.id, 10);
}
});
</code></pre>
* @constructor
* @param {TreeGrid} tree
* @param {Object} config
*/ */
Ext.ux.tree.TreeGridSorter = Ext.extend(Ext.tree.TreeSorter, { Ext.ux.tree.TreeGridSorter = Ext.extend(Ext.tree.TreeSorter, {
/** /**
@ -38,30 +54,34 @@ Ext.ux.tree.TreeGridSorter = Ext.extend(Ext.tree.TreeSorter, {
tree.on('headerclick', this.onHeaderClick, this); tree.on('headerclick', this.onHeaderClick, this);
tree.ddAppendOnly = true; tree.ddAppendOnly = true;
me = this; var me = this;
this.defaultSortFn = function(n1, n2){ this.defaultSortFn = function(n1, n2){
var dsc = me.dir && me.dir.toLowerCase() == 'desc'; var desc = me.dir && me.dir.toLowerCase() == 'desc',
var p = me.property || 'text'; prop = me.property || 'text',
var sortType = me.sortType; sortType = me.sortType,
var fs = me.folderSort; caseSensitive = me.caseSensitive === true,
var cs = me.caseSensitive === true; leafAttr = me.leafAttr || 'leaf',
var leafAttr = me.leafAttr || 'leaf'; attr1 = n1.attributes,
attr2 = n2.attributes;
if(fs){ if(me.folderSort){
if(n1.attributes[leafAttr] && !n2.attributes[leafAttr]){ if(attr1[leafAttr] && !attr2[leafAttr]){
return 1; return 1;
} }
if(!n1.attributes[leafAttr] && n2.attributes[leafAttr]){ if(!attr1[leafAttr] && attr2[leafAttr]){
return -1; return -1;
} }
} }
var v1 = sortType ? sortType(n1.attributes[p]) : (cs ? n1.attributes[p] : n1.attributes[p].toUpperCase()); var prop1 = attr1[prop],
var v2 = sortType ? sortType(n2.attributes[p]) : (cs ? n2.attributes[p] : n2.attributes[p].toUpperCase()); prop2 = attr2[prop],
v1 = sortType ? sortType(prop1) : (caseSensitive ? prop1 : prop1.toUpperCase());
v2 = sortType ? sortType(prop2) : (caseSensitive ? prop2 : prop2.toUpperCase());
if(v1 < v2){ if(v1 < v2){
return dsc ? +1 : -1; return desc ? +1 : -1;
}else if(v1 > v2){ }else if(v1 > v2){
return dsc ? -1 : +1; return desc ? -1 : +1;
}else{ }else{
return 0; return 0;
} }
@ -72,11 +92,12 @@ Ext.ux.tree.TreeGridSorter = Ext.extend(Ext.tree.TreeSorter, {
}, },
onAfterTreeRender : function() { onAfterTreeRender : function() {
var hmenu = this.tree.hmenu; if(this.tree.hmenu){
hmenu.insert(0, this.tree.hmenu.insert(0,
{itemId:'asc', text: this.sortAscText, cls: 'xg-hmenu-sort-asc'}, {itemId:'asc', text: this.sortAscText, cls: 'xg-hmenu-sort-asc'},
{itemId:'desc', text: this.sortDescText, cls: 'xg-hmenu-sort-desc'} {itemId:'desc', text: this.sortDescText, cls: 'xg-hmenu-sort-desc'}
); );
}
this.updateSortIcon(0, 'asc'); this.updateSortIcon(0, 'asc');
}, },
@ -109,8 +130,8 @@ Ext.ux.tree.TreeGridSorter = Ext.extend(Ext.tree.TreeSorter, {
// private // private
updateSortIcon : function(col, dir){ updateSortIcon : function(col, dir){
var sc = this.sortClasses; var sc = this.sortClasses,
var hds = this.tree.innerHd.select('td').removeClass(sc); hds = this.tree.innerHd.select('td').removeClass(sc);
hds.item(col).addClass(sc[dir == 'desc' ? 1 : 0]); hds.item(col).addClass(sc[dir == 'desc' ? 1 : 0]);
} }
}); });