| 1 |
define([ |
| 2 |
"dojo/_base/kernel", |
| 3 |
"dojo/text!./resources/GridContainer.html", |
| 4 |
"dojo/_base/declare", |
| 5 |
"dojo/query", |
| 6 |
"dojo/_base/sniff", |
| 7 |
"dojo/dom-class", |
| 8 |
"dojo/dom-style", |
| 9 |
"dojo/dom-geometry", |
| 10 |
"dojo/dom-construct", |
| 11 |
"dojo/dom-attr", |
| 12 |
"dojo/_base/array", |
| 13 |
"dojo/_base/lang", |
| 14 |
"dojo/_base/event", |
| 15 |
"dojo/keys", |
| 16 |
"dojo/topic", |
| 17 |
"dijit/registry", |
| 18 |
"dijit/focus", |
| 19 |
"dijit/_base/focus", |
| 20 |
"dijit/_WidgetBase", |
| 21 |
"dijit/_TemplatedMixin", |
| 22 |
"dijit/layout/_LayoutWidget", |
| 23 |
"dojo/_base/NodeList", |
| 24 |
"dojox/mdnd/AreaManager", "dojox/mdnd/DropIndicator", |
| 25 |
"dojox/mdnd/dropMode/OverDropMode","dojox/mdnd/AutoScroll" |
| 26 |
],function(dojo, template, declare, query, has, domClass, domStyle, geom, domConstruct, domAttr, array, lang, events, keys, topic, registry, focus, baseFocus, _WidgetBase, _TemplatedMixin, _LayoutWidget, NodeList, AreaManager){ |
| 27 |
|
| 28 |
var gcl = declare( |
| 29 |
"dojox.layout.GridContainerLite", |
| 30 |
[_LayoutWidget, _TemplatedMixin], |
| 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 |
autoRefresh: true, |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
templateString: template, |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
dragHandleClass: "dojoxDragHandle", |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
nbZones: 1, |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
doLayout: true, |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
isAutoOrganized: true, |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
acceptTypes: [], |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
colWidths: "", |
| 108 |
|
| 109 |
constructor: function(props, node){ |
| 110 |
this.acceptTypes = (props || {}).acceptTypes || ["text"]; |
| 111 |
this._disabled = true; |
| 112 |
}, |
| 113 |
|
| 114 |
postCreate: function(){ |
| 115 |
|
| 116 |
this.inherited(arguments); |
| 117 |
this._grid = []; |
| 118 |
|
| 119 |
this._createCells(); |
| 120 |
|
| 121 |
|
| 122 |
this.subscribe("/dojox/mdnd/drop", "resizeChildAfterDrop"); |
| 123 |
this.subscribe("/dojox/mdnd/drag/start", "resizeChildAfterDragStart"); |
| 124 |
|
| 125 |
this._dragManager = AreaManager.areaManager(); |
| 126 |
|
| 127 |
this._dragManager.autoRefresh = this.autoRefresh; |
| 128 |
|
| 129 |
|
| 130 |
this._dragManager.dragHandleClass = this.dragHandleClass; |
| 131 |
|
| 132 |
if(this.doLayout){ |
| 133 |
this._border = { |
| 134 |
h: has("ie") ? geom.getBorderExtents(this.gridContainerTable).h : 0, |
| 135 |
w: (has("ie") == 6) ? 1 : 0 |
| 136 |
}; |
| 137 |
}else{ |
| 138 |
domStyle.set(this.domNode, "overflowY", "hidden"); |
| 139 |
domStyle.set(this.gridContainerTable, "height", "auto"); |
| 140 |
} |
| 141 |
}, |
| 142 |
|
| 143 |
startup: function(){ |
| 144 |
|
| 145 |
if(this._started){ return; } |
| 146 |
|
| 147 |
if(this.isAutoOrganized){ |
| 148 |
this._organizeChildren(); |
| 149 |
} |
| 150 |
else{ |
| 151 |
this._organizeChildrenManually(); |
| 152 |
} |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
array.forEach(this.getChildren(), function(child){ |
| 157 |
child.startup(); |
| 158 |
}); |
| 159 |
|
| 160 |
|
| 161 |
if(this._isShown()){ |
| 162 |
this.enableDnd(); |
| 163 |
} |
| 164 |
this.inherited(arguments); |
| 165 |
}, |
| 166 |
|
| 167 |
resizeChildAfterDrop: function(node, targetArea, indexChild){ |
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
if(this._disabled){ |
| 185 |
return false; |
| 186 |
} |
| 187 |
if(registry.getEnclosingWidget(targetArea.node) == this){ |
| 188 |
var widget = registry.byNode(node); |
| 189 |
if(widget.resize && lang.isFunction(widget.resize)){ |
| 190 |
widget.resize(); |
| 191 |
} |
| 192 |
|
| 193 |
|
| 194 |
widget.set("column", node.parentNode.cellIndex); |
| 195 |
|
| 196 |
if(this.doLayout){ |
| 197 |
var domNodeHeight = this._contentBox.h, |
| 198 |
divHeight = geom.getContentBox(this.gridContainerDiv).h; |
| 199 |
if(divHeight >= domNodeHeight){ |
| 200 |
domStyle.set(this.gridContainerTable, "height", |
| 201 |
(domNodeHeight - this._border.h) + "px"); |
| 202 |
} |
| 203 |
} |
| 204 |
return true; |
| 205 |
} |
| 206 |
return false; |
| 207 |
}, |
| 208 |
|
| 209 |
resizeChildAfterDragStart: function(node, sourceArea, indexChild){ |
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
if(this._disabled){ |
| 222 |
return false; |
| 223 |
} |
| 224 |
if(registry.getEnclosingWidget(sourceArea.node) == this){ |
| 225 |
this._draggedNode = node; |
| 226 |
if(this.doLayout){ |
| 227 |
geom.setMarginBox(this.gridContainerTable, { |
| 228 |
h: geom.getContentBox(this.gridContainerDiv).h - this._border.h |
| 229 |
}); |
| 230 |
} |
| 231 |
return true; |
| 232 |
} |
| 233 |
return false; |
| 234 |
}, |
| 235 |
|
| 236 |
getChildren: function(){ |
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
var children = new NodeList(); |
| 245 |
array.forEach(this._grid, function(dropZone){ |
| 246 |
query("> [widgetId]", dropZone.node).map(registry.byNode).forEach(function(item){ |
| 247 |
children.push(item); |
| 248 |
}); |
| 249 |
}); |
| 250 |
return children; |
| 251 |
}, |
| 252 |
|
| 253 |
_isShown: function(){ |
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
if("open" in this){ |
| 263 |
return this.open; |
| 264 |
} |
| 265 |
else{ |
| 266 |
var node = this.domNode; |
| 267 |
return (node.style.display != 'none') && (node.style.visibility != 'hidden') && !domClass.contains(node, "dijitHidden"); |
| 268 |
} |
| 269 |
}, |
| 270 |
|
| 271 |
layout: function(){ |
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
if(this.doLayout){ |
| 277 |
var contentBox = this._contentBox; |
| 278 |
geom.setMarginBox(this.gridContainerTable, { |
| 279 |
h: contentBox.h - this._border.h |
| 280 |
}); |
| 281 |
geom.setContentSize(this.domNode, { |
| 282 |
w: contentBox.w - this._border.w |
| 283 |
}); |
| 284 |
} |
| 285 |
array.forEach(this.getChildren(), function(widget){ |
| 286 |
if(widget.resize && lang.isFunction(widget.resize)){ |
| 287 |
widget.resize(); |
| 288 |
} |
| 289 |
}); |
| 290 |
}, |
| 291 |
|
| 292 |
onShow: function(){ |
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
if(this._disabled){ |
| 298 |
this.enableDnd(); |
| 299 |
} |
| 300 |
}, |
| 301 |
|
| 302 |
onHide: function(){ |
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
if(!this._disabled){ |
| 308 |
this.disableDnd(); |
| 309 |
} |
| 310 |
}, |
| 311 |
|
| 312 |
_createCells: function(){ |
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
if(this.nbZones === 0){ this.nbZones = 1; } |
| 320 |
var accept = this.acceptTypes.join(","), |
| 321 |
i = 0; |
| 322 |
|
| 323 |
var widths = this._computeColWidth(); |
| 324 |
|
| 325 |
while(i < this.nbZones){ |
| 326 |
|
| 327 |
|
| 328 |
this._grid.push({ |
| 329 |
node: domConstruct.create("td", { |
| 330 |
'class': "gridContainerZone", |
| 331 |
accept: accept, |
| 332 |
id: this.id + "_dz" + i, |
| 333 |
style: { |
| 334 |
'width': widths[i] + "%" |
| 335 |
} |
| 336 |
}, this.gridNode) |
| 337 |
}); |
| 338 |
i++; |
| 339 |
} |
| 340 |
}, |
| 341 |
|
| 342 |
_getZonesAttr: function(){ |
| 343 |
|
| 344 |
|
| 345 |
return query(".gridContainerZone", this.containerNode); |
| 346 |
}, |
| 347 |
|
| 348 |
enableDnd: function(){ |
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
var m = this._dragManager; |
| 354 |
array.forEach(this._grid, function(dropZone){ |
| 355 |
m.registerByNode(dropZone.node); |
| 356 |
}); |
| 357 |
m._dropMode.updateAreas(m._areaList); |
| 358 |
this._disabled = false; |
| 359 |
}, |
| 360 |
|
| 361 |
disableDnd: function(){ |
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
var m = this._dragManager; |
| 367 |
array.forEach(this._grid, function(dropZone){ |
| 368 |
m.unregister(dropZone.node); |
| 369 |
}); |
| 370 |
m._dropMode.updateAreas(m._areaList); |
| 371 |
this._disabled = true; |
| 372 |
}, |
| 373 |
|
| 374 |
_organizeChildren: function(){ |
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
var children = gcl.superclass.getChildren.call(this); |
| 380 |
var numZones = this.nbZones, |
| 381 |
numPerZone = Math.floor(children.length / numZones), |
| 382 |
mod = children.length % numZones, |
| 383 |
i = 0; |
| 384 |
|
| 385 |
for(var z = 0; z < numZones; z++){ |
| 386 |
for(var r = 0; r < numPerZone; r++){ |
| 387 |
this._insertChild(children[i], z); |
| 388 |
i++; |
| 389 |
} |
| 390 |
if(mod > 0){ |
| 391 |
try{ |
| 392 |
this._insertChild(children[i], z); |
| 393 |
i++; |
| 394 |
} |
| 395 |
catch(e){ |
| 396 |
console.error("Unable to insert child in GridContainer", e); |
| 397 |
} |
| 398 |
mod--; |
| 399 |
} |
| 400 |
else if(numPerZone === 0){ |
| 401 |
break; |
| 402 |
} |
| 403 |
} |
| 404 |
}, |
| 405 |
|
| 406 |
_organizeChildrenManually: function (){ |
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
var children = gcl.superclass.getChildren.call(this), |
| 412 |
length = children.length, |
| 413 |
child; |
| 414 |
for(var i = 0; i < length; i++){ |
| 415 |
child = children[i]; |
| 416 |
try{ |
| 417 |
this._insertChild(child, child.column - 1); |
| 418 |
} |
| 419 |
catch(e){ |
| 420 |
console.error("Unable to insert child in GridContainer", e); |
| 421 |
} |
| 422 |
} |
| 423 |
}, |
| 424 |
|
| 425 |
_insertChild: function(child, column, p){ |
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
var zone = this._grid[column].node, |
| 437 |
length = zone.childNodes.length; |
| 438 |
if(typeof p === "undefined" || p > length){ |
| 439 |
p = length; |
| 440 |
} |
| 441 |
if(this._disabled){ |
| 442 |
domConstruct.place(child.domNode, zone, p); |
| 443 |
domAttr.set(child.domNode, "tabIndex", "0"); |
| 444 |
} |
| 445 |
else{ |
| 446 |
if(!child.dragRestriction){ |
| 447 |
this._dragManager.addDragItem(zone, child.domNode, p, true); |
| 448 |
} |
| 449 |
else{ |
| 450 |
domConstruct.place(child.domNode, zone, p); |
| 451 |
domAttr.set(child.domNode, "tabIndex", "0"); |
| 452 |
} |
| 453 |
} |
| 454 |
child.set("column", column); |
| 455 |
return child; |
| 456 |
}, |
| 457 |
|
| 458 |
removeChild: function( widget){ |
| 459 |
|
| 460 |
if(this._disabled){ |
| 461 |
this.inherited(arguments); |
| 462 |
} |
| 463 |
else{ |
| 464 |
this._dragManager.removeDragItem(widget.domNode.parentNode, widget.domNode); |
| 465 |
} |
| 466 |
}, |
| 467 |
|
| 468 |
addService: function(child, column, p){ |
| 469 |
|
| 470 |
kernel.deprecated("addService is deprecated.", "Please use instead.", "Future"); |
| 471 |
this.addChild(child, column, p); |
| 472 |
}, |
| 473 |
|
| 474 |
addChild: function(child, column, p){ |
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
child.domNode.id = child.id; |
| 488 |
gcl.superclass.addChild.call(this, child, 0); |
| 489 |
if(column < 0 || column === undefined){ column = 0; } |
| 490 |
if(p <= 0){ p = 0; } |
| 491 |
try{ |
| 492 |
return this._insertChild(child, column, p); |
| 493 |
} |
| 494 |
catch(e){ |
| 495 |
console.error("Unable to insert child in GridContainer", e); |
| 496 |
} |
| 497 |
return null; |
| 498 |
}, |
| 499 |
|
| 500 |
_setColWidthsAttr: function(value){ |
| 501 |
this.colWidths = lang.isString(value) ? value.split(",") : (lang.isArray(value) ? value : [value]); |
| 502 |
|
| 503 |
if(this._started){ |
| 504 |
this._updateColumnsWidth(); |
| 505 |
} |
| 506 |
}, |
| 507 |
|
| 508 |
_updateColumnsWidth: function( manager){ |
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
|
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
var length = this._grid.length; |
| 518 |
|
| 519 |
var widths = this._computeColWidth(); |
| 520 |
|
| 521 |
|
| 522 |
for (var i = 0; i < length; i++){ |
| 523 |
this._grid[i].node.style.width = widths[i] + "%"; |
| 524 |
} |
| 525 |
}, |
| 526 |
|
| 527 |
_computeColWidth: function(){ |
| 528 |
var origWidths = this.colWidths || []; |
| 529 |
var widths = []; |
| 530 |
var colWidth; |
| 531 |
var widthSum = 0; |
| 532 |
var i; |
| 533 |
|
| 534 |
|
| 535 |
for(i = 0; i < this.nbZones; i++){ |
| 536 |
if(widths.length < origWidths.length){ |
| 537 |
widthSum += origWidths[i] * 1; |
| 538 |
widths.push(origWidths[i]); |
| 539 |
}else{ |
| 540 |
if(!colWidth){ |
| 541 |
colWidth = (100 - widthSum)/(this.nbZones - i); |
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
if(colWidth < 0){ |
| 547 |
colWidth = 100 / this.nbZones; |
| 548 |
} |
| 549 |
} |
| 550 |
widths.push(colWidth); |
| 551 |
widthSum += colWidth * 1; |
| 552 |
} |
| 553 |
} |
| 554 |
|
| 555 |
|
| 556 |
if(widthSum > 100){ |
| 557 |
var divisor = 100 / widthSum; |
| 558 |
for(i = 0; i < widths.length; i++){ |
| 559 |
widths[i] *= divisor; |
| 560 |
} |
| 561 |
} |
| 562 |
return widths; |
| 563 |
}, |
| 564 |
|
| 565 |
_selectFocus: function(event){ |
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
if(this._disabled){ return; } |
| 575 |
var key = event.keyCode, |
| 576 |
k = keys, |
| 577 |
zone = null, |
| 578 |
cFocus = baseFocus.getFocus(), |
| 579 |
focusNode = cFocus.node, |
| 580 |
m = this._dragManager, |
| 581 |
found, |
| 582 |
i, |
| 583 |
j, |
| 584 |
r, |
| 585 |
children, |
| 586 |
area, |
| 587 |
widget; |
| 588 |
if(focusNode == this.containerNode){ |
| 589 |
area = this.gridNode.childNodes; |
| 590 |
switch(key){ |
| 591 |
case k.DOWN_ARROW: |
| 592 |
case k.RIGHT_ARROW: |
| 593 |
found = false; |
| 594 |
for(i = 0; i < area.length; i++){ |
| 595 |
children = area[i].childNodes; |
| 596 |
for(j = 0; j < children.length; j++){ |
| 597 |
zone = children[j]; |
| 598 |
if(zone !== null && zone.style.display != "none"){ |
| 599 |
focus.focus(zone); |
| 600 |
events.stop(event); |
| 601 |
found = true; |
| 602 |
break; |
| 603 |
} |
| 604 |
} |
| 605 |
if(found){ break }; |
| 606 |
} |
| 607 |
break; |
| 608 |
case k.UP_ARROW: |
| 609 |
case k.LEFT_ARROW: |
| 610 |
area = this.gridNode.childNodes; |
| 611 |
found = false; |
| 612 |
for(i = area.length-1; i >= 0 ; i--){ |
| 613 |
children = area[i].childNodes; |
| 614 |
for(j = children.length; j >= 0; j--){ |
| 615 |
zone = children[j]; |
| 616 |
if(zone !== null && zone.style.display != "none"){ |
| 617 |
focus.focus(zone); |
| 618 |
events.stop(event); |
| 619 |
found = true; |
| 620 |
break; |
| 621 |
} |
| 622 |
} |
| 623 |
if(found){ break }; |
| 624 |
} |
| 625 |
break; |
| 626 |
} |
| 627 |
}else{ |
| 628 |
if(focusNode.parentNode.parentNode == this.gridNode){ |
| 629 |
var child = (key == k.UP_ARROW || key == k.LEFT_ARROW) ? "lastChild" : "firstChild"; |
| 630 |
var pos = (key == k.UP_ARROW || key == k.LEFT_ARROW) ? "previousSibling" : "nextSibling"; |
| 631 |
switch(key){ |
| 632 |
case k.UP_ARROW: |
| 633 |
case k.DOWN_ARROW: |
| 634 |
events.stop(event); |
| 635 |
found = false; |
| 636 |
var focusTemp = focusNode; |
| 637 |
while(!found){ |
| 638 |
children = focusTemp.parentNode.childNodes; |
| 639 |
var num = 0; |
| 640 |
for(i = 0; i < children.length; i++){ |
| 641 |
if(children[i].style.display != "none"){ num++; } |
| 642 |
if(num > 1){ break; } |
| 643 |
} |
| 644 |
if(num == 1){ return; } |
| 645 |
if(focusTemp[pos] === null){ |
| 646 |
zone = focusTemp.parentNode[child]; |
| 647 |
} |
| 648 |
else{ |
| 649 |
zone = focusTemp[pos]; |
| 650 |
} |
| 651 |
if(zone.style.display === "none"){ |
| 652 |
focusTemp = zone; |
| 653 |
} |
| 654 |
else{ |
| 655 |
found = true; |
| 656 |
} |
| 657 |
} |
| 658 |
if(event.shiftKey){ |
| 659 |
var parent = focusNode.parentNode; |
| 660 |
for(i = 0; i < this.gridNode.childNodes.length; i++){ |
| 661 |
if(parent == this.gridNode.childNodes[i]){ |
| 662 |
break; |
| 663 |
} |
| 664 |
} |
| 665 |
children = this.gridNode.childNodes[i].childNodes; |
| 666 |
for(j = 0; j < children.length; j++){ |
| 667 |
if(zone == children[j]){ |
| 668 |
break; |
| 669 |
} |
| 670 |
} |
| 671 |
if(has("mozilla") || has("webkit")){ i--; } |
| 672 |
|
| 673 |
widget = registry.byNode(focusNode); |
| 674 |
if(!widget.dragRestriction){ |
| 675 |
r = m.removeDragItem(parent, focusNode); |
| 676 |
this.addChild(widget, i, j); |
| 677 |
domAttr.set(focusNode, "tabIndex", "0"); |
| 678 |
focus.focus(focusNode); |
| 679 |
} |
| 680 |
else{ |
| 681 |
topic.publish("/dojox/layout/gridContainer/moveRestriction", this); |
| 682 |
} |
| 683 |
} |
| 684 |
else{ |
| 685 |
focus.focus(zone); |
| 686 |
} |
| 687 |
break; |
| 688 |
case k.RIGHT_ARROW: |
| 689 |
case k.LEFT_ARROW: |
| 690 |
events.stop(event); |
| 691 |
if(event.shiftKey){ |
| 692 |
var z = 0; |
| 693 |
if(focusNode.parentNode[pos] === null){ |
| 694 |
if(has("ie") && key == k.LEFT_ARROW){ |
| 695 |
z = this.gridNode.childNodes.length-1; |
| 696 |
} |
| 697 |
} |
| 698 |
else if(focusNode.parentNode[pos].nodeType == 3){ |
| 699 |
z = this.gridNode.childNodes.length - 2; |
| 700 |
} |
| 701 |
else{ |
| 702 |
for(i = 0; i < this.gridNode.childNodes.length; i++){ |
| 703 |
if(focusNode.parentNode[pos] == this.gridNode.childNodes[i]){ |
| 704 |
break; |
| 705 |
} |
| 706 |
z++; |
| 707 |
} |
| 708 |
if(has("mozilla") || has("webkit")){ z--; } |
| 709 |
} |
| 710 |
widget = registry.byNode(focusNode); |
| 711 |
var _dndType = focusNode.getAttribute("dndtype"); |
| 712 |
if(_dndType === null){ |
| 713 |
|
| 714 |
if(widget && widget.dndType){ |
| 715 |
_dndType = widget.dndType.split(/\s*,\s*/); |
| 716 |
} |
| 717 |
else{ |
| 718 |
_dndType = ["text"]; |
| 719 |
} |
| 720 |
} |
| 721 |
else{ |
| 722 |
_dndType = _dndType.split(/\s*,\s*/); |
| 723 |
} |
| 724 |
var accept = false; |
| 725 |
for(i = 0; i < this.acceptTypes.length; i++){ |
| 726 |
for(j = 0; j < _dndType.length; j++){ |
| 727 |
if(_dndType[j] == this.acceptTypes[i]){ |
| 728 |
accept = true; |
| 729 |
break; |
| 730 |
} |
| 731 |
} |
| 732 |
} |
| 733 |
if(accept && !widget.dragRestriction){ |
| 734 |
var parentSource = focusNode.parentNode, |
| 735 |
place = 0; |
| 736 |
if(k.LEFT_ARROW == key){ |
| 737 |
var t = z; |
| 738 |
if(has("mozilla") || has("webkit")){ t = z + 1; } |
| 739 |
place = this.gridNode.childNodes[t].childNodes.length; |
| 740 |
} |
| 741 |
|
| 742 |
r = m.removeDragItem(parentSource, focusNode); |
| 743 |
this.addChild(widget, z, place); |
| 744 |
domAttr.set(r, "tabIndex", "0"); |
| 745 |
focus.focus(r); |
| 746 |
} |
| 747 |
else{ |
| 748 |
topic.publish("/dojox/layout/gridContainer/moveRestriction", this); |
| 749 |
} |
| 750 |
} |
| 751 |
else{ |
| 752 |
var node = focusNode.parentNode; |
| 753 |
while(zone === null){ |
| 754 |
if(node[pos] !== null && node[pos].nodeType !== 3){ |
| 755 |
node = node[pos]; |
| 756 |
} |
| 757 |
else{ |
| 758 |
if(pos === "previousSibling"){ |
| 759 |
node = node.parentNode.childNodes[node.parentNode.childNodes.length-1]; |
| 760 |
} |
| 761 |
else{ |
| 762 |
node = node.parentNode.childNodes[has("ie") ? 0 : 1]; |
| 763 |
} |
| 764 |
} |
| 765 |
zone = node[child]; |
| 766 |
if(zone && zone.style.display == "none"){ |
| 767 |
|
| 768 |
children = zone.parentNode.childNodes; |
| 769 |
var childToSelect = null; |
| 770 |
if(pos == "previousSibling"){ |
| 771 |
for(i = children.length-1; i >= 0; i--){ |
| 772 |
if(children[i].style.display != "none"){ |
| 773 |
childToSelect = children[i]; |
| 774 |
break; |
| 775 |
} |
| 776 |
} |
| 777 |
} |
| 778 |
else{ |
| 779 |
for(i = 0; i < children.length; i++){ |
| 780 |
if(children[i].style.display != "none"){ |
| 781 |
childToSelect = children[i]; |
| 782 |
break; |
| 783 |
} |
| 784 |
} |
| 785 |
} |
| 786 |
if(!childToSelect){ |
| 787 |
focusNode = zone; |
| 788 |
node = focusNode.parentNode; |
| 789 |
zone = null; |
| 790 |
} |
| 791 |
else{ |
| 792 |
zone = childToSelect; |
| 793 |
} |
| 794 |
} |
| 795 |
} |
| 796 |
focus.focus(zone); |
| 797 |
} |
| 798 |
break; |
| 799 |
} |
| 800 |
} |
| 801 |
} |
| 802 |
}, |
| 803 |
|
| 804 |
destroy: function(){ |
| 805 |
|
| 806 |
var m = this._dragManager; |
| 807 |
array.forEach(this._grid, function(dropZone){ |
| 808 |
m.unregister(dropZone.node); |
| 809 |
}); |
| 810 |
this.inherited(arguments); |
| 811 |
} |
| 812 |
}); |
| 813 |
|
| 814 |
gcl.ChildWidgetProperties = { |
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
|
| 820 |
|
| 821 |
column: "1", |
| 822 |
|
| 823 |
|
| 824 |
|
| 825 |
|
| 826 |
dragRestriction: false |
| 827 |
}; |
| 828 |
|
| 829 |
|
| 830 |
lang.extend(_WidgetBase, gcl.ChildWidgetProperties); |
| 831 |
|
| 832 |
return gcl; |
| 833 |
}); |