Skip to content
This repository was archived by the owner on Jun 13, 2019. It is now read-only.

Commit da13f4e

Browse files
author
Jay Garcia
committed
Update examples
1 parent 6a95622 commit da13f4e

13 files changed

+107
-36
lines changed

.DS_Store

-9 KB
Binary file not shown.

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.idea
2+
*DS_Store
3+
4+
.idea/workspace.xml
5+
*.iml
6+
examples/ch14/build
7+

examples.zip

55.2 MB
Binary file not shown.

examples/.DS_Store

9 KB
Binary file not shown.

examples/ch05/5.1_Implementing_the_auto_layout.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222

2323
var childPnl2 = {
2424
xtype : 'panel',
25+
width : 150,
2526
html : 'Second child',
2627
title : 'Second children have all the fun!'
2728
};
2829

29-
var myWin = Ext.create("Ext.Window", ({
30+
var myWin = Ext.create("Ext.Window", {
3031
height : 300,
3132
width : 300,
3233
title : 'A window with a container layout',
@@ -53,7 +54,7 @@
5354
}
5455
}
5556
]
56-
}));
57+
});
5758

5859
myWin.show();
5960

examples/ch08/8.2_to_8.4_Complex_gridpanel.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
dock : 'bottom',
5353
displayInfo : true
5454
};
55-
55+
f
5656

5757
var grid = Ext.create('Ext.grid.Panel', {
5858
columns : columns,

examples/ch09/9.3-9.9.html

+96-33
Original file line numberDiff line numberDiff line change
@@ -8,61 +8,92 @@
88
<script type="text/javascript" src="../../ext4/ext-all-debug.js"></script>
99
<script type='text/javascript'>
1010

11+
/**
12+
* Require dependencies
13+
*/
1114
Ext.require(['Ext.data.*', 'Ext.window.Window', 'Ext.tree.*']);
1215

16+
17+
/**
18+
* Delete confirmation handler
19+
*/
1320
var onConfirmDelete = function(answer, value, cfg, button) {
14-
if (answer != 'yes') {
21+
if (answer !== 'yes') {
1522
return;
1623
}
1724

1825
var menu = button.up(),
19-
node = menu.treeNode;
26+
node = menu.treeNode;
2027

2128
node.remove(true);
2229
};
30+
31+
/**
32+
* Handler for delete menu item
33+
*/
2334
var onDelete = function(button) {
2435
var callback = Ext.bind(onConfirmDelete, undefined, [button], true);
2536
Ext.Msg.confirm(
26-
'Approve deletion',
27-
'Are you sure you want to delete this node?',
28-
callback
37+
'Approve deletion',
38+
'Are you sure you want to delete this node?',
39+
callback
2940
);
3041
};
42+
43+
/**
44+
* Edit handler
45+
*/
3146
var onEdit = function(button, node) {
3247
var menu = button.up(),
3348
node = node || menu.treeNode,
3449
view = menu.treeView,
3550
tree = view.ownerCt,
3651
selMdl = view.getSelectionModel(),
37-
colHdr = tree.headerCt.getHeaderAtIndex(0);
52+
colHdr = tree.headerCt.getHeaderAtIndex(0),
53+
pos;
3854

3955
if (selMdl.getCurrentPosition) { //only in cellmodel selection model
4056
pos = selMdl.getCurrentPosition();
4157
colHdr = tree.headerCt.getHeaderAtIndex(pos.column);
4258
}
4359
treeEditor.startEdit(node, colHdr);
4460
};
61+
62+
63+
/**
64+
* Create a new entry
65+
*/
66+
var doCreate = function(node, button) {
67+
var newNode = node.appendChild({text : 'New employee', leaf : true});
68+
69+
// Turn on editing right away
70+
onEdit(button, newNode);
71+
};
72+
73+
74+
/**
75+
* Add item handler
76+
*/
4577
var onAdd = function(button) {
4678
var menu = button.up(),
47-
node = menu.treeNode,
48-
view = menu.treeView,
49-
delay = view.expandDuration + 50,
50-
newNode,
51-
doCreate;
52-
53-
doCreate = function() {
54-
newNode = node.appendChild({text : 'New employee', leaf : true});
55-
onEdit(button, newNode);
56-
};
79+
node = menu.treeNode,
80+
view = menu.treeView,
81+
delay = view.expandDuration + 50;
5782

5883
if (!node.isExpanded()) {
59-
node.expand(false, Ext.callback(doCreate, this, [], delay));
84+
// expand and wait for animation before appending a new node
85+
node.expand(false, Ext.callback(doCreate, this, [node, button], delay));
6086
}
6187
else {
62-
doCreate();
88+
doCreate(node, button);
6389
}
6490
};
6591

92+
93+
/**
94+
* Context menu
95+
* @returns {Ext.menu.Menu}
96+
*/
6697
var buildCtxMenu = function() {
6798
return Ext.create('Ext.menu.Menu', {
6899
items : [
@@ -81,7 +112,11 @@
81112
]
82113
});
83114
};
84-
//Configuring a context menu factory method
115+
116+
/**
117+
* Configuring a context menu factory method
118+
*/
119+
85120
var onCtxMenu = function(view, record, element, index, evtObj) {
86121
view.select(record);
87122
evtObj.stopEvent();
@@ -90,14 +125,14 @@
90125
this.ctxMenu = buildCtxMenu();
91126
}
92127

128+
var ctxMenu = this.ctxMenu,
129+
addItem = ctxMenu.getComponent('add'),
130+
editItem = ctxMenu.getComponent('edit'),
131+
deleteItem = ctxMenu.getComponent('delete');
132+
93133
this.ctxMenu.treeNode = record;
94134
this.ctxMenu.treeView = view;
95135

96-
var ctxMenu = this.ctxMenu;
97-
var addItem = ctxMenu.getComponent('add');
98-
var editItem = ctxMenu.getComponent('edit');
99-
var deleteItem = ctxMenu.getComponent('delete');
100-
101136
if (record.getId() == 'mycompany') {
102137
addItem.setText('Add Department');
103138
editItem.setText('Nope, not changing the name');
@@ -142,21 +177,19 @@
142177

143178
getEditingContext : function(record, columnHeader) {
144179
var me = this,
145-
grid = me.
146-
147-
if (Ext.isNumber(record)) {
148-
rowIdx = record;
149-
//record = grid,
180+
grid = me.grid,
150181
store = grid.store,
151182
rowIdx,
152183
colIdx,
153184
view = grid.getView(),
154185
root = grid.getRootNode(),
155-
value;store.getAt(rowIdx);
186+
value;
187+
188+
if (Ext.isNumber(record)) {
189+
rowIdx = record;
156190
record = root.getChildAt(rowIdx);
157191
}
158192
else {
159-
//rowIdx = store.indexOf(record);
160193
rowIdx = root.indexOf(record);
161194
}
162195
if (Ext.isNumber(columnHeader)) {
@@ -178,7 +211,39 @@
178211
rowIdx : rowIdx,
179212
colIdx : colIdx
180213
};
214+
},
215+
216+
onEditComplete : function(ed, value, startValue) {
217+
var me = this,
218+
activeColumn = me.getActiveColumn(),
219+
context = me.context,
220+
record;
221+
222+
if (activeColumn) {
223+
record = context.record;
224+
225+
me.setActiveEditor(null);
226+
me.setActiveColumn(null);
227+
me.setActiveRecord(null);
228+
229+
context.value = value;
230+
if (!me.validateEdit()) {
231+
return;
232+
}
233+
234+
if (!record.isEqual(value, startValue)) {
235+
record.set(activeColumn.dataIndex, value);
236+
}
237+
238+
if (Ext.isObject(context.view)) {
239+
context.view.focus(false, true);
240+
}
241+
242+
me.fireEvent('edit', me, context);
243+
me.editing = false;
244+
}
181245
}
246+
182247
});
183248

184249
var store = Ext.create('Ext.data.TreeStore', {
@@ -213,8 +278,6 @@
213278
}
214279
});
215280

216-
//{ptype: 'treecellediting', clicksToEdit: 1}
217-
218281
var treeEditor = Ext.create('TreeCellEditing', {clicksToEdit : 1});
219282

220283
Ext.onReady(function() {

examples/ch14/.DS_Store

-6 KB
Binary file not shown.

examples/ch14/app/.DS_Store

-6 KB
Binary file not shown.

ext4/.DS_Store

-6 KB
Binary file not shown.

ux/.DS_Store

0 Bytes
Binary file not shown.

ux/MC/.DS_Store

0 Bytes
Binary file not shown.

ux/MC/iconMgr/.DS_Store

-6 KB
Binary file not shown.

0 commit comments

Comments
 (0)