1;(function(){ 2 3if (window.jsDD) 4 return; 5 6jsDD = { 7 arObjects: [], 8 arDestinations: [], 9 arDestinationsPriority: [], 10 11 arContainers: [], 12 arContainersPos: [], 13 14 current_dest_index: false, 15 current_node: null, 16 17 wndSize: null, 18 19 bStarted: false, 20 bDisable: false, 21 bDisableDestRefresh: false, 22 23 bEscPressed: false, 24 25 bScrollWindow: false, 26 scrollViewTimer: null, 27 scrollViewConfig: { 28 checkerTimeout: 30, 29 scrollZone: 25, 30 scrollBy: 25, 31 scrollContainer: null, 32 bScrollH: true, 33 bScrollV: true, 34 pos: null 35 }, 36 37 setScrollWindow: function(val) 38 { 39 jsDD.bScrollWindow = !!val; 40 if (BX.type.isDomNode(val)) 41 { 42 jsDD.scrollViewConfig.scrollContainer = val; 43 jsDD.scrollViewConfig.pos = BX.pos(val); 44 45 var s = BX.style(val, 'overflow') || 'visible', 46 s1 = BX.style(val, 'overflow-x') || 'visible', 47 s2 = BX.style(val, 'overflow-y') || 'visible'; 48 49 jsDD.scrollViewConfig.bScrollH = s != 'visible' || s1 != 'visible'; 50 jsDD.scrollViewConfig.bScrollV = s != 'visible' || s2 != 'visible'; 51 } 52 }, 53 54 Reset: function() 55 { 56 jsDD.arObjects = []; 57 jsDD.arDestinations = []; 58 jsDD.arDestinationsPriority = []; 59 jsDD.bStarted = false; 60 jsDD.current_node = null; 61 jsDD.current_dest_index = false; 62 jsDD.bDisableDestRefresh = false; 63 jsDD.bDisable = false; 64 jsDD.x = null; 65 jsDD.y = null; 66 jsDD.start_x = null; 67 jsDD.start_y = null; 68 jsDD.wndSize = null; 69 70 jsDD.bEscPressed = false; 71 72 clearInterval(jsDD.scrollViewTimer) 73 jsDD.bScrollWindow = false; 74 jsDD.scrollViewTimer = null; 75 jsDD.scrollViewConfig.scrollContainer = null; 76 }, 77 78 registerObject: function (obNode) 79 { 80 BX.bind(obNode, 'mousedown', jsDD.startDrag); 81 BX.Event.bind(obNode, 'touchstart', jsDD.startDrag, { passive: true }); 82 83 obNode.__bxddid = jsDD.arObjects.length; 84 85 jsDD.arObjects[obNode.__bxddid] = obNode; 86 }, 87 unregisterObject: function(obNode) 88 { 89 if(typeof(obNode["__bxddid"]) === "undefined") 90 { 91 return; 92 } 93 94 delete jsDD.arObjects[obNode.__bxddid]; 95 delete obNode.__bxddid; 96 BX.unbind(obNode, 'mousedown', jsDD.startDrag); 97 BX.unbind(obNode, 'touchstart', jsDD.startDrag); 98 }, 99 registerDest: function (obDest, priority) 100 { 101 if (!priority) 102 priority = 100; 103 104 obDest.__bxddeid = jsDD.arDestinations.length; 105 obDest.__bxddpriority = priority; 106 107 jsDD.arDestinations[obDest.__bxddeid] = obDest; 108 if (!jsDD.arDestinationsPriority[priority]) 109 jsDD.arDestinationsPriority[priority] = [obDest.__bxddeid] 110 else 111 jsDD.arDestinationsPriority[priority].push(obDest.__bxddeid); 112 113 jsDD.refreshDestArea(obDest.__bxddeid); 114 }, 115 unregisterDest: function(obDest) 116 { 117 if(typeof(obDest["__bxddeid"]) === "undefined") 118 { 119 return; 120 } 121 122 delete jsDD.arDestinations[obDest.__bxddeid]; 123 delete obDest.__bxddeid; 124 delete obDest.__bxddpriority; 125 126 jsDD.refreshDestArea(); 127 }, 128 disableDest: function(obDest) 129 { 130 if (typeof(obDest.__bxddeid) !== "undefined") 131 { 132 obDest.__bxdddisabled = true; 133 } 134 }, 135 136 enableDest: function(obDest) 137 { 138 if (typeof(obDest.__bxddeid) !== "undefined") 139 { 140 obDest.__bxdddisabled = false; 141 } 142 }, 143 144 registerContainer: function (obCont) 145 { 146 jsDD.arContainers[jsDD.arContainers.length] = obCont; 147 }, 148 149 getContainersScrollPos: function(x, y) 150 { 151 var pos = {'left':0, 'top':0}; 152 for(var i=0, n=jsDD.arContainers.length; i<n; i++) 153 { 154 if(jsDD.arContainers[i] && x >= jsDD.arContainersPos[i]["left"] && x <= jsDD.arContainersPos[i]["right"] && y >= jsDD.arContainersPos[i]["top"] && y <= jsDD.arContainersPos[i]["bottom"]) 155 { 156 pos.left = jsDD.arContainers[i].scrollLeft; 157 pos.top = jsDD.arContainers[i].scrollTop; 158 } 159 } 160 return pos; 161 }, 162 163 setContainersPos: function() 164 { 165 for(var i=0, n=jsDD.arContainers.length; i<n; i++) 166 { 167 if(jsDD.arContainers[i]) 168 jsDD.arContainersPos[i] = BX.pos(jsDD.arContainers[i]); 169 } 170 }, 171 172 refreshDestArea: function(id) 173 { 174 if (id && typeof (id) == "object" && typeof (id.__bxddeid) != 'undefined') 175 { 176 id = id.__bxddeid; 177 } 178 179 if (typeof id == 'undefined') 180 { 181 for (var i = 0, cnt = jsDD.arDestinations.length; i < cnt; i++) 182 { 183 jsDD.refreshDestArea(i); 184 } 185 } 186 else 187 { 188 if (null == jsDD.arDestinations[id]) 189 return; 190 191 var arPos = BX.pos(jsDD.arDestinations[id]);
192 jsDD.arDestinations[id].__bxpos = [arPos.left, arPos.top, arPos.right, arPos.bottom]; 193 } 194 }, 195 196 _checkEsc: function(e) 197 { 198 e = e||window.event; 199 if (jsDD.bStarted && e.keyCode == 27) 200 { 201 jsDD.stopCurrentDrag(); 202 } 203 }, 204 205 stopCurrentDrag: function() 206 { 207 if (jsDD.bStarted) 208 { 209 jsDD.bEscPressed = true; 210 jsDD.stopDrag(); 211 } 212 }, 213 214 /* scroll checkers */ 215 216 _onscroll: function() { 217 jsDD.wndSize = BX.GetWindowSize(); 218 }, 219 220 _checkScroll: function() 221 { 222 if (jsDD.bScrollWindow) 223 { 224 var pseudo_e = { 225 clientX: jsDD.x - jsDD.wndSize.scrollLeft, 226 clientY: jsDD.y - jsDD.wndSize.scrollTop 227 }, 228 bChange = false, 229 d = jsDD.scrollViewConfig.scrollZone; 230 231 // check whether window scroll needed 232 if (pseudo_e.clientY < d && jsDD.wndSize.scrollTop > 0) 233 { 234 window.scrollBy(0, -jsDD.scrollViewConfig.scrollBy); 235 bChange = true; 236 } 237 238 if (pseudo_e.clientY > jsDD.wndSize.innerHeight - d && jsDD.wndSize.scrollTop < jsDD.wndSize.scrollHeight - jsDD.wndSize.innerHeight) 239 { 240 window.scrollBy(0, jsDD.scrollViewConfig.scrollBy); 241 bChange = true; 242 } 243 244 if (pseudo_e.clientX < d && jsDD.wndSize.scrollLeft > 0) 245 { 246 window.scrollBy(-jsDD.scrollViewConfig.scrollBy, 0); 247 bChange = true; 248 } 249 250 if (pseudo_e.clientX > jsDD.wndSize.innerWidth - d && jsDD.wndSize.scrollLeft < jsDD.wndSize.scrollWidth - jsDD.wndSize.innerWidth) 251 { 252 window.scrollBy(jsDD.scrollViewConfig.scrollBy, 0); 253 bChange = true; 254 } 255 256 // check whether container scroll needed 257 258 if (jsDD.scrollViewConfig.scrollContainer) 259 { 260 var c = jsDD.scrollViewConfig.scrollContainer; 261 262 if (jsDD.scrollViewConfig.bScrollH) 263 { 264 if (pseudo_e.clientX + jsDD.wndSize.scrollLeft < jsDD.scrollViewConfig.pos.left + d && c.scrollLeft > 0) 265 { 266 c.scrollLeft -= jsDD.scrollViewConfig.scrollBy; 267 bChange = true; 268 } 269 270 if (pseudo_e.clientX + jsDD.wndSize.scrollLeft > jsDD.scrollViewConfig.pos.right - d 271 && c.scrollLeft < c.scrollWidth - c.offsetWidth) 272 { 273 c.scrollLeft += jsDD.scrollViewConfig.scrollBy; 274 bChange = true; 275 } 276 } 277 278 if (jsDD.scrollViewConfig.bScrollV) 279 { 280 if (pseudo_e.clientY + jsDD.wndSize.scrollTop < jsDD.scrollViewConfig.pos.top + d && c.scrollTop > 0) 281 { 282 c.scrollTop -= jsDD.scrollViewConfig.scrollBy; 283 bChange = true; 284 } 285 286 if (pseudo_e.clientY + jsDD.wndSize.scrollTop > jsDD.scrollViewConfig.pos.bottom - d 287 && c.scrollTop < c.scrollHeight - c.offsetHeight) 288 { 289 c.scrollTop += jsDD.scrollViewConfig.scrollBy; 290 bChange = true; 291 } 292 } 293 } 294 295 if (bChange) 296 { 297 jsDD._onscroll(); 298 jsDD.drag(pseudo_e); 299 } 300 } 301 }, 302 303 /* DD process */ 304 305 startDrag: function(e) 306 { 307 if (jsDD.bDisable) 308 return true; 309 310 e = e || window.event; 311 312 if (!(BX.getEventButton(e)&BX.MSLEFT)) 313 return true; 314 315 jsDD.current_node = null; 316 if (e.currentTarget) 317 { 318 jsDD.current_node = e.currentTarget; 319 if (null == jsDD.current_node || null == jsDD.current_node.__bxddid) 320 { 321 jsDD.current_node = null; 322 return; 323 } 324 } 325 else 326 { 327 jsDD.current_node = e.srcElement; 328 if (null == jsDD.current_node) 329 return; 330 331 while (null == jsDD.current_node.__bxddid) 332 { 333 jsDD.current_node = jsDD.current_node.parentNode; 334 if (jsDD.current_node.tagName == 'BODY') 335 return; 336 } 337 } 338 339 jsDD.bStarted = false; 340 jsDD.bPreStarted = true; 341 342 jsDD.wndSize = BX.GetWindowSize(); 343 344 jsDD.start_x = e.clientX + jsDD.wndSize.scrollLeft; 345 jsDD.start_y = e.clientY + jsDD.wndSize.scrollTop; 346 347 BX.bind(document, "mouseup", jsDD.stopDrag); 348 BX.bind(document, "touchend", jsDD.stopDrag); 349 BX.bind(document, "mousemove", jsDD.drag); 350 BX.bind(document, "touchmove", jsDD.drag); 351 BX.bind(window, 'scroll', jsDD._onscroll); 352 353 if(document.body.setCapture) 354 document.body.setCapture(); 355 356 if (!jsDD.bDisableDestRefresh) 357 jsDD.refreshDestArea(); 358 359 jsDD.setContainersPos(); 360 361 if(e.type !== "touchstart") 362 { 363 jsDD.denySelection(); 364 return BX.PreventDefault(e); 365 } 366 else 367 { 368 return true; 369 } 370 }, 371 372 start: function() 373 { 374 if (jsDD.bDisable) 375 return true; 376 377 document.body.style.cursor = 'move'; 378 379 if (jsDD.current_node.onbxdragstart) 380 jsDD.current_node.onbxdragstart(); 381 382 for (var i = 0, cnt = jsDD.arDestinations.length; i < cnt; i++) 383 { 384 if (jsDD.arDestinations[i] && jsDD.arDestinations[i].onbxdestdragstart) 385 jsDD.arDestinations[i].onbxdestdragstart(jsDD.current_node); 386 } 387 388 jsDD.bStarted = true; 389 jsDD.bPreStarted = false;
390 391 if (jsDD.bScrollWindow) 392 { 393 if (jsDD.scrollViewTimer) 394 clearInterval(jsDD.scrollViewTimer); 395 396 jsDD.scrollViewTimer = setInterval(jsDD._checkScroll, jsDD.scrollViewConfig.checkerTimeout); 397 } 398 399 BX.bind(document, 'keypress', this._checkEsc); 400 }, 401 402 drag: function(e) 403 { 404 if (jsDD.bDisable) 405 return true; 406 407 e = e || window.event; 408 409 jsDD.x = e.clientX + jsDD.wndSize.scrollLeft; 410 jsDD.y = e.clientY + jsDD.wndSize.scrollTop; 411 412 if (!jsDD.bStarted) 413 { 414 var delta = 5; 415 if(jsDD.x >= jsDD.start_x-delta && jsDD.x <= jsDD.start_x+delta && jsDD.y >= jsDD.start_y-delta && jsDD.y <= jsDD.start_y+delta) 416 return true; 417 418 jsDD.start(); 419 } 420 421 if (jsDD.current_node.onbxdrag) 422 { 423 jsDD.current_node.onbxdrag(jsDD.x, jsDD.y, e); 424 } 425 426 var containersScroll = jsDD.getContainersScrollPos(jsDD.x, jsDD.y); 427 var current_dest_index = jsDD.searchDest(jsDD.x+containersScroll.left, jsDD.y+containersScroll.top); 428 429 if (current_dest_index !== jsDD.current_dest_index) 430 { 431 if (jsDD.current_dest_index !== false) 432 { 433 if (jsDD.current_node.onbxdraghout) 434 jsDD.current_node.onbxdraghout(jsDD.arDestinations[jsDD.current_dest_index], jsDD.x, jsDD.y); 435 436 if (jsDD.arDestinations[jsDD.current_dest_index].onbxdestdraghout) 437 jsDD.arDestinations[jsDD.current_dest_index].onbxdestdraghout(jsDD.current_node, jsDD.x, jsDD.y); 438 } 439 440 if (current_dest_index !== false) 441 { 442 if (jsDD.current_node.onbxdraghover) 443 jsDD.current_node.onbxdraghover(jsDD.arDestinations[current_dest_index], jsDD.x, jsDD.y); 444 445 if (jsDD.arDestinations[current_dest_index].onbxdestdraghover) 446 jsDD.arDestinations[current_dest_index].onbxdestdraghover(jsDD.current_node, jsDD.x, jsDD.y); 447 } 448 } 449 450 jsDD.current_dest_index = current_dest_index; 451 }, 452 453 stopDrag: function(e) 454 { 455 BX.unbind(document, 'keypress', jsDD._checkEsc); 456 457 e = e || window.event; 458 459 jsDD.bPreStarted = false; 460 461 if (jsDD.bStarted) 462 { 463 if (!jsDD.bEscPressed) 464 { 465 jsDD.x = e.clientX + jsDD.wndSize.scrollLeft; 466 jsDD.y = e.clientY + jsDD.wndSize.scrollTop; 467 } 468 469 if (null != jsDD.current_node.onbxdragstop) 470 jsDD.current_node.onbxdragstop(jsDD.x, jsDD.y, e); 471 472 var containersScroll = jsDD.getContainersScrollPos(jsDD.x, jsDD.y); 473 var dest_index = jsDD.searchDest(jsDD.x+containersScroll.left, jsDD.y+containersScroll.top); 474 475 if (false !== dest_index) 476 { 477 if (jsDD.bEscPressed) 478 { 479 if (null != jsDD.arDestinations[dest_index].onbxdestdraghout) 480 { 481 if (!jsDD.arDestinations[dest_index].onbxdestdraghout(jsDD.current_node, jsDD.x, jsDD.y)) 482 dest_index = false; 483 else 484 { 485 if (null != jsDD.current_node.onbxdragfinish) 486 jsDD.current_node.onbxdragfinish(jsDD.arDestinations[dest_index], jsDD.x, jsDD.y); 487 } 488 } 489 490 } 491 else 492 { 493 if (null != jsDD.arDestinations[dest_index].onbxdestdragfinish) 494 { 495 if (!jsDD.arDestinations[dest_index].onbxdestdragfinish(jsDD.current_node, jsDD.x, jsDD.y, e)) 496 dest_index = false; 497 else 498 { 499 if (null != jsDD.current_node.onbxdragfinish) 500 jsDD.current_node.onbxdragfinish(jsDD.arDestinations[dest_index], jsDD.x, jsDD.y); 501 } 502 } 503 } 504 } 505 506 if (false === dest_index) 507 { 508 if (null != jsDD.current_node.onbxdragrelease) 509 jsDD.current_node.onbxdragrelease(jsDD.x, jsDD.y); 510 } 511 else 512 { 513 for (var i = 0, cnt = jsDD.arDestinations.length; i < cnt; i++) 514 { 515 if (i != dest_index && jsDD.arDestinations[i] && null != jsDD.arDestinations[i].onbxdestdragrelease) 516 jsDD.arDestinations[i].onbxdestdragrelease(jsDD.current_node, jsDD.x, jsDD.y); 517 } 518 } 519 520 for (var i = 0, cnt = jsDD.arDestinations.length; i < cnt; i++) 521 { 522 if (jsDD.arDestinations[i] && null != jsDD.arDestinations[i].onbxdestdragstop) 523 jsDD.arDestinations[i].onbxdestdragstop(jsDD.current_node, jsDD.x, jsDD.y); 524 } 525 } 526 527 if(document.body.releaseCapture) 528 document.body.releaseCapture(); 529 530 BX.unbind(window, 'scroll', jsDD._onscroll); 531 BX.unbind(document, "mousemove", jsDD.drag); 532 BX.unbind(document, "touchmove", jsDD.drag); 533 BX.unbind(document, "keypress", jsDD._checkEsc); 534 BX.unbind(document, "mouseup", jsDD.stopDrag); 535 BX.unbind(document, "touchend", jsDD.stopDrag); 536 537 jsDD.allowSelection(); 538 document.body.style.cursor = ''; 539 540 jsDD.current_node = null; 541 jsDD.current_dest_index = false;
542 543 if (jsDD.bScrollWindow) 544 { 545 if (jsDD.scrollViewTimer) 546 clearInterval(jsDD.scrollViewTimer); 547 } 548 549 if (jsDD.bStarted && !jsDD.bDisableDestRefresh) 550 jsDD.refreshDestArea(); 551 552 jsDD.bStarted = false; 553 jsDD.bEscPressed = false; 554 }, 555 556 searchDest: function(x, y) 557 { 558 var p, len, p1, len1, i; 559 for (p = 0, len = jsDD.arDestinationsPriority.length; p < len; p++) 560 { 561 if (jsDD.arDestinationsPriority[p] && BX.type.isArray(jsDD.arDestinationsPriority[p])) 562 { 563 for (p1 = 0, len1 = jsDD.arDestinationsPriority[p].length; p1 < len1; p1++) 564 { 565 i = jsDD.arDestinationsPriority[p][p1]; 566 if (jsDD.arDestinations[i] && !jsDD.arDestinations[i].__bxdddisabled) 567 { 568 if ( 569 jsDD.arDestinations[i].__bxpos[0] <= x && 570 jsDD.arDestinations[i].__bxpos[2] >= x && 571 572 jsDD.arDestinations[i].__bxpos[1] <= y && 573 jsDD.arDestinations[i].__bxpos[3] >= y 574 ) 575 { 576 return i; 577 } 578 } 579 } 580 } 581 } 582 583 return false; 584 }, 585 586 allowSelection: function() 587 { 588 document.onmousedown = document.ontouchstart = null; 589 var b = document.body; 590 b.ondrag = null; 591 b.onselectstart = null; 592 b.style.MozUserSelect = ''; 593 594 if (jsDD.current_node) 595 { 596 jsDD.current_node.ondrag = null; 597 jsDD.current_node.onselectstart = null; 598 jsDD.current_node.style.MozUserSelect = ''; 599 } 600 }, 601 602 denySelection: function() 603 { 604 document.onmousedown = document.ontouchstart = BX.False; 605 var b = document.body; 606 b.ondrag = BX.False; 607 b.onselectstart = BX.False; 608 b.style.MozUserSelect = 'none'; 609 if (jsDD.current_node) 610 { 611 jsDD.current_node.ondrag = BX.False; 612 jsDD.current_node.onselectstart = BX.False; 613 jsDD.current_node.style.MozUserSelect = 'none'; 614 } 615 }, 616 617 Disable: function() {jsDD.bDisable = true;}, 618 Enable: function() {jsDD.bDisable = false;} 619} 620 621})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.