forked from joaool/MotherGithub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_grid.html
299 lines (287 loc) · 10.9 KB
/
test_grid.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
<html>
<head>
<!--
<script type="text/javascript" src="Dojo Toolkit/dojo-release-1.7.1/dojo/dojo.js" djconfig="parseOnLoad: true, isDebug: true" >
</script>
<link href="Dojo Toolkit/dojo-release-1.7.1/dijit/themes/claro/claro.css" rel="stylesheet">
-->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Test Grid 1.0</title>
<!--
<script>
// we’re creating a dojoConfig object *before* we load dojo.js
var dojoConfig = {
async: true,
parseOnLoad:true,
isDebug:true
};
</script>
<script src="Dojo Toolkit/dojo-release-1.7.1/dojo/dojo.js"></script>
-->
<!-- este bloco substitui o bloco anterior -->
<script type="text/javascript" src="../dojo1.9.2/dojo/dojo.js"></script>
<!------ Mother CSS ------------------------------------------------------------------- -->
<!--- For Mother Builder --->
<link rel="stylesheet" type="text/css" href="Mother1/MotherBuilder.css" />
<!--- For Mother Forms A -BlueHills, B-Simple Green C- Tree D-Chess E-light blue F(A+C)=>(fz,f0)--->
<link rel="stylesheet" type="text/css" href="Mother1/MotherF.css"/>
<!------------------------------------------------------------------------------------- -->
<script>
oDbg=null;//so that we can use "this" inside this html with embedded script
require([
"Mother/ResizeMoveArea8.js",
"dojo/_base/declare",
"dojo/_base/window",
"dojo/_base/lang",
"dojo/_base/event",
"dojo/on",
"dojo/parser",//recomendation from JS
"dojo/dom",
"dojo/dom-construct",//used outside class
"dojo/dom-style",
"dgrid/Grid",
"dgrid/Keyboard",
"dgrid/Selection",
"dojo/request",
"dojo/store/Memory",
"dgrid/OnDemandGrid",
"dgrid/extensions/ColumnResizer",
"dojo/domReady!",
],
function(ResizeMoveArea,
Declare,Win,Lang,Event,On,Parser,Dom,DomConstruct,DomStyle,Grid,Keyboard,Selection,request,Memory,OnDemandGrid,ColumnResizer){
var data = [
{ first: "Bob", last: "Barker", age: 89 },
{ first: "Vanna", last: "White", age: 55 },
{ first: "Pat", last: "Sajak", age: 65 }
];
// var grid = new Grid({
// columns: {
// first: "First Name",
// last: "Last Name",
// age: "Age"
// }
// }, "grid");
// Create a new constructor by mixing in the components
var CustomGrid = Declare([ OnDemandGrid, Keyboard, Selection,ColumnResizer]);
// Now, create an instance of our custom grid which
// have the features we added!
// var grid = new CustomGrid({
// columns: {
// first: "First Name",
// last: "Last Name",
// age: "Age"
// },
// selectionMode: "single", // for Selection; only select a single row at a time
// cellNavigation: false // for Keyboard; allow only row-level keyboard navigation
// }, "grid");
// var grid = new (Declare([OnDemandGrid, Keyboard, Selection, ColumnResizer]))({
// columns: {
// col1: {
// label: "Column1",
// resizable: false,
// width:100
// },
// col2: "Column 2",
// col3: "Column 3"
// }
// }, "grid");
// grid.renderArray(data);
// request("hof-batting.json", {
// handleAs: "json"
// }).then(function (response) {
// var grid = new OnDemandGrid({
// store: new Memory({ data: response }),
// columns: [
// { field: "first", label: "First" },
// { field: "last", label: "Last" }
// ]
// }, "grid");
// grid.startup();
// });
request("hof-batting.json", {
handleAs: "json"
}).then(function (response) {
var grid = new OnDemandGrid({
store: new Memory({ data: response }),
subRows: [
[
{ field: "first", label: "First", rowSpan: 2 },
{ field: "last", label: "Last", rowSpan: 2 },
{ field: "bats", label: "Bats", rowSpan: 2 },
{ field: "throws", label: "Throws", rowSpan: 2 },
{ field: "totalG", label: "G" },
{ field: "totalAB", label: "AB" },
{ field: "totalR", label: "R" },
{ field: "totalRBI", label: "RBI" },
{ field: "totalBB", label: "BB" },
{ field: "totalK", label: "K" }
],
[
{ field: "totalGAB", label: "Games as Batter", colSpan: 2 },
{ field: "totalH", label: "H" },
{ field: "total2B", label: "2B" },
{ field: "total3B", label: "3B" },
{ field: "totalHR", label: "HR" }
]
]
}, "grid");
grid.startup();
});
// grid.on("dgrid-select", function(event){
// // Report the item from the selected row to the console.
// console.log("Row selected: ", event.rows[0].data);
// });
// grid.on("dgrid-deselect", function(event){
// console.log("Row de-selected: ", event.rows[0].data);
// });
// grid.on(".dgrid-row:click", function(event){
// var row = grid.row(event);
// console.log("Row clicked:", row.id);
// });
// var columns = {
// first: "First Name",
// last: "Last Name",
// age: "Age"
// };
//----------------------------------------
// alert("Hello !!!");
/*
var beginFunction=function(){
//alert("beginFunction !!!");
//var oF=x2.getDim();
//x1.resize(oF);
//x2.forceTermination();
};
var endFunction=function(){
alert("endFunction !!!");
//var oF=x2.getDim();
//x1.resize(oF);
};
var swapFunction=function(){
//alert("swapFunction !!!");
var oF=x2.getDim();
//x1.resize(oF);
};
handlerMouseInCanvas=On.pausable(Win.body(), "mousemove", function(e){
//checks if mouse is over a candidate area while Area1 is active
if(x1.current.active){
var target=redTarget(e.pageX,e.pageY);
if(target){
//alert("RED TARGET");
x1.xxxName="RED TARGET";
x2.resize({l:1000,t:100,w:100,h:100});
//x1.forceTermination();
x2.beginCallback=beginFunction;
x2.endCallback=endFunction;
x2.swapCallback=swapFunction;
//console.log("RED TARGET");
//x1.mouseDownCallback=zzz;
//console.log("@@@@@@ mouse in canvas pos x="+e.pageX+" y="+e.pageY+" x1.current.active="+x1.current.active+" target="+x1.xxxName);
}else{
//x1.mouseDownCallback=null;
x1.xxxName=""
};
};
});
//handlerMouseInCanvas.pause();
var zzz=function(){
console.log("»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»");
console.log("»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»mouseDownCallback»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»");
console.log("»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» xxxName="+x1.xxxName+"»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»");
console.log("»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»");
};
redTarget=function(x,y){//returns always false except if mouse is over red target (1000,100,100,100)
var bRet=false;
var tg={l:1000,t:100,w:100,h:100};
if(x>tg.l){
if(y>tg.t){
if(x<(tg.l+tg.w)){
if(y<(tg.t+tg.h)){
bRet=true;
};
};
};
};
return bRet;
};
var oLanding={l:20,t:30,w:120,h:30};
var oBoundaries={l:20,t:20,w:1270,h:420};
x1=new ResizeMoveArea("test",oLanding,oBoundaries,{
label:"Area 1",
gridPattern:5,
//borderThickness:4,
//borderType:"inset",//"dotted",
//borderColor:"blue",
//fillColor:"purple",
opacity:.9
//tooltip:"this is a test"
});
x1.setCursorInactive("move");
var oLanding2={l:20,t:70,w:120,h:30};
x2=new ResizeMoveArea("test2",oLanding2,oBoundaries,{
label:"Area 2",
gridPattern:5,
opacity:.6,
fillColor:"lightblue",
tooltip:"this is area2 that has inactiveCursor 'crosshair' and active cursor 'pointer'"
});
x2.setCursorInactive("crosshair");
x2.setCursorActive("pointer");
var mouseDownHandler=On.pausable(Dom.byId(x1.avatarId),"mousedown",function(){
console.log("Caller =====================================================->Mouse down in the area1");
if(x2.current.active) {
console.log(" x2 is activated !!!! - we will toggle handles down !");
x2.toggleHandles(false);
}
x1.toggleHandles(true);
mouseDownHandler.pause();
mouseDownHandler2.resume();
});
x1.on("resizeMovePartial",Lang.hitch(this,function(oEvt){
console.log(" caller ->Parcial Area1 resize/move with x="+oEvt.x+" y="+oEvt.y+" w="+oEvt.w+" h="+oEvt.h+" move="+oEvt.move);
}));
x1.on("resizeMoveEnd",Lang.hitch(this,function(oEvt){
console.log("#- resizeMoveEnd DETECTED in caller !!! (A1) inside="+oEvt.inside+", x1.current.active="+x1.current.active);
mouseDownHandler.resume();//put it ready to be detected when mouse clicks the area
}));
x1.on("clickInside",Lang.hitch(this,function(oEvt){
alert("click inside area "+x1.current.label);
}));
var mouseDownHandler2=On.pausable(Dom.byId(x2.avatarId),"mousedown",function(){
console.log("Caller =====================================================->Mouse down in the area2");
if(x1.current.active) {
console.log(" x1 is activated !!!! - we will toggle handles down !");
x1.toggleHandles(false);
}
x2.toggleHandles(true);
mouseDownHandler2.pause();
mouseDownHandler.resume();
});
// x2.on("resizeMovePartial",Lang.hitch(this,function(oEvt){
// console.log("!!!!!!!!!!!!!!! caller ->Parcial Area2 resize/move with x="+oEvt.x+" y="+oEvt.y+" w="+oEvt.w+" h="+oEvt.h+" move="+oEvt.move);
// // x2.setLanding({l: oEvt.x,t: oEvt.y,w: oEvt.w,h: oEvt.h});
// }));
x2.on("resizeMoveEnd",Lang.hitch(this,function(oEvt){
console.log("######################################################################## ------ resizeMoveEnd DETECTED in caller (A2) !!! inside="+oEvt.inside+", x2.current.active="+x2.current.active);
x2.beginCallback=null;
x2.endCallback=null;
x2.swapCallback=null;
mouseDownHandler2.resume();
}));
*/
function test(){
alert("test message in function test - this call is defined in menu object exterior to the class...");
}
//--------------------------------------------------------------------------------------------------------------------------
}//closing of main function
);//closing of require function
</script>
</head>
<body class="claro">
<div id="xwrapper" width="640" height="360" color="red"></div>
<!--<div id="box" style="position: absolute;left:1000px;top:100px;width:100px;height:1030px;border:1px solid red" class="boxes" onmouseover="alert('Red spot - was blue !')"> -->
<div id="box" style="position: absolute;left:1000px;top:100px;width:100px;height:100px;border:1px solid red"></div>
<div id="grid"></div>
</body>
</html>