1;(function(window) { 2if (BX.WindowManager) return; 3 4/* windows manager */ 5BX.WindowManager = { 6 _stack: [], 7 _runtime_resize: {}, 8 _delta: 2, 9 _delta_start: 1000, 10 currently_loaded: null, 11 12 settings_category: 'BX.WindowManager.9.5', 13 14 register: function (w) 15 { 16 this.currently_loaded = null; 17 var div = w.Get(); 18 19 div.style.zIndex = w.zIndex = this.GetZIndex(); 20 21 w.WM_REG_INDEX = this._stack.length; 22 this._stack.push(w); 23 24 if (this._stack.length < 2) 25 { 26 BX.bind(document, 'keyup', BX.proxy(this.__checkKeyPress, this)); 27 } 28 }, 29 30 unregister: function (w) 31 { 32 if (null == w.WM_REG_INDEX) 33 return null; 34 35 var _current; 36 if (this._stack.length > 0) 37 { 38 while ((_current = this.__pop_stack()) != w) 39 { 40 if (!_current) 41 { 42 _current = null; 43 break; 44 } 45 } 46 47 if (this._stack.length <= 0) 48 { 49 this.enableKeyCheck(); 50 } 51 52 return _current; 53 } 54 else 55 { 56 return null; 57 } 58 }, 59 60 __pop_stack: function(clean) 61 { 62 if (this._stack.length > 0) 63 { 64 var _current = this._stack.pop(); 65 _current.WM_REG_INDEX = null; 66 BX.onCustomEvent(_current, 'onWindowUnRegister', [clean === true]); 67 68 return _current; 69 } 70 else 71 return null; 72 }, 73 74 clean: function() 75 { 76 while (this.__pop_stack(true)){} 77 this._stack = null; 78 this.disableKeyCheck(); 79 }, 80 81 Get: function() 82 { 83 if (this.currently_loaded) 84 return this.currently_loaded; 85 else if (this._stack.length > 0) 86 return this._stack[this._stack.length-1]; 87 else 88 return null; 89 }, 90 91 setStartZIndex: function(value) 92 { 93 this._delta_start = value; 94 }, 95 96 restoreStartZIndex: function() 97 { 98 this._delta_start = 1000; 99 }, 100 101 GetZIndex: function() 102 { 103 var _current; 104 return (null != (_current = this._stack[this._stack.length-1]) 105 ? parseInt(_current.Get().style.zIndex) + this._delta 106 : this._delta_start 107 ); 108 }, 109 110 __get_check_url: function(url) 111 { 112 var pos = url.indexOf('?'); 113 return pos == -1 ? url : url.substring(0, pos); 114 }, 115 116 saveWindowSize: function(url, params) 117 { 118 var check_url = this.__get_check_url(url); 119 if (BX.userOptions) 120 { 121 BX.userOptions.save(this.settings_category, 'size_' + check_url, 'width', params.width); 122 BX.userOptions.save(this.settings_category, 'size_' + check_url, 'height', params.height); 123 } 124 125 this._runtime_resize[check_url] = params; 126 }, 127 128 saveWindowOptions: function(wnd_id, opts) 129 { 130 if (BX.userOptions) 131 { 132 for (var i in opts) 133 { 134 if(opts.hasOwnProperty(i)) 135 { 136 BX.userOptions.save(this.settings_category, 'options_' + wnd_id, i, opts[i]); 137 } 138 } 139 } 140 }, 141 142 getRuntimeWindowSize: function(url) 143 { 144 return this._runtime_resize[this.__get_check_url(url)]; 145 }, 146 147 disableKeyCheck: function() 148 { 149 BX.unbind(document, 'keyup', BX.proxy(this.__checkKeyPress, this)); 150 }, 151 152 enableKeyCheck: function() 153 { 154 BX.bind(document, 'keyup', BX.proxy(this.__checkKeyPress, this)); 155 }, 156 157 __checkKeyPress: function(e) 158 { 159 if (null == e) 160 e = window.event; 161 162 if (e.keyCode == 27) 163 { 164 var wnd = BX.WindowManager.Get(); 165 if (wnd && !wnd.unclosable) wnd.Close(); 166 } 167 } 168}; 169 170BX.garbage(BX.WindowManager.clean, BX.WindowManager); 171 172/* base button class */ 173BX.CWindowButton = function(params) 174{ 175 if (params.btn) 176 { 177 this.btn = params.btn; 178 this.parentWindow = params.parentWindow; 179 180 if (/save|apply/i.test(this.btn.name)) 181 { 182 BX.bind(this.btn, 'click', BX.delegate(this.disableUntilError, this)); 183 } 184 } 185 else 186 { 187 this.title = params.title; // html value attr 188 this.hint = params.hint; // html title attr 189 this.id = params.id; // html name and id attrs 190 this.name = params.name; // html name or value attrs when id and title 're absent 191 this.className = params.className; // className for button input 192 193 this.action = params.action; 194 this.onclick = params.onclick; 195 196 // you can override button creation method 197 if (params.Button && BX.type.isFunction(params.Button)) 198 this.Button = params.Button; 199 200 this.btn = null; 201 } 202}; 203 204BX.CWindowButton.prototype.disable = function() 205{ 206 if (this.btn) 207 this.parentWindow.showWait(this.btn); 208}; 209BX.CWindowButton.prototype.enable = function(){ 210 if (this.btn) 211 this.parentWindow.closeWait(this.btn); 212}; 213 214BX.CWindowButton.prototype.emulate = function() 215{ 216 if (this.btn && this.btn.disabled) 217 return; 218 219 var act = 220 this.action 221 ? BX.delegate(this.action, this) 222 : ( 223 this.onclick 224 ? this.onclick 225 : ( 226 this.btn 227 ? this.btn.getAttribute('onclick') 228 : '' 229 ) 230 ); 231 232 if (act) 233 { 234 setTimeout(act, 50); 235 if (this.btn && /save|apply/i.test(this.btn.name) && !this.action) 236 { 237 this.disableUntilError(); 238 } 239 } 240}; 241 242BX.CWindowButton.prototype.Button = function(parentWindow) 243{ 244 this.parentWindow = parentWindow; 245 246 var btn = { 247 props: { 248 'type': 'button', 249 'name': this.id ? this.id : this.name, 250 'value': this.title ? this.title : this.name, 251 'id': this.id 252 } 253 }; 254 255 if (this.hint) 256 btn.props.title = this.hint; 257 if (!!this.className) 258 btn.props.className = this.className; 259 260 if (this.action) 261 { 262 btn.events = { 263 'click': BX.delegate(this.action, this) 264 }; 265 } 266 else if (this.onclick) 267 { 268 if (BX.browser.IsIE()) 269 { 270 btn.events = { 271 'click': BX.delegate(function() {eval(this.onclick)}, this) 272 }; 273 } 274 else 275 { 276 btn.attrs = { 277 'onclick': this.onclick 278 }; 279 } 280 } 281 282 this.btn = BX.create('INPUT', btn); 283 284 return this.btn; 285}; 286 287BX.CWindowButton.prototype.disableUntilError = function() { 288 this.disable(); 289 if (!this.__window_error_handler_set) 290 { 291 BX.addCustomEvent(this.parentWindow, 'onWindowError', BX.delegate(this.enable, this)); 292 this.__window_error_handler_set = true; 293 } 294}; 295 296/* base window class */ 297BX.CWindow = function(div, type) 298{ 299 this.DIV = div || document.createElement('DIV'); 300 301 this.SETTINGS = { 302 resizable: false, 303 min_height: 0, 304 min_width: 0, 305 top: 0, 306 left: 0, 307 draggable: false, 308 drag_restrict: true, 309 resize_restrict: true 310 }; 311 312 this.ELEMENTS = { 313 draggable: [], 314 resizer: [], 315 close: [] 316 }; 317 318 this.type = type == 'float' ? 'float' : 'dialog'; 319 320 BX.adjust(this.DIV, { 321 props: { 322 className: 'bx-core-window' 323 }, 324 style: { 325 'zIndex': 0, 326 'position': 'absolute', 327 'display': 'none', 328 'top': this.SETTINGS.top + 'px', 329 'left': this.SETTINGS.left + 'px', 330 'height': '100px', 331 'width': '100px' 332 } 333 }); 334 335 this.isOpen = false;
336 337 BX.addCustomEvent(this, 'onWindowRegister', BX.delegate(this.onRegister, this)); 338 BX.addCustomEvent(this, 'onWindowUnRegister', BX.delegate(this.onUnRegister, this)); 339 340 this.MOUSEOVER = null; 341 BX.bind(this.DIV, 'mouseover', BX.delegate(this.__set_msover, this)); 342 BX.bind(this.DIV, 'mouseout', BX.delegate(this.__unset_msover, this)); 343 344 BX.ready(BX.delegate(function() { 345 document.body.appendChild(this.DIV); 346 }, this)); 347}; 348 349BX.CWindow.prototype.Get = function () {return this.DIV}; 350BX.CWindow.prototype.visible = function() {return this.isOpen;}; 351 352BX.CWindow.prototype.Show = function(bNotRegister) 353{ 354 this.DIV.style.display = 'block'; 355 356 if (!bNotRegister) 357 { 358 BX.WindowManager.register(this); 359 BX.onCustomEvent(this, 'onWindowRegister'); 360 } 361}; 362 363BX.CWindow.prototype.Hide = function() 364{ 365 BX.WindowManager.unregister(this); 366 this.DIV.style.display = 'none'; 367}; 368 369BX.CWindow.prototype.onRegister = function() 370{ 371 this.isOpen = true; 372}; 373 374BX.CWindow.prototype.onUnRegister = function(clean) 375{ 376 this.isOpen = false; 377 378 if (clean || (this.PARAMS && this.PARAMS.content_url)) 379 { 380 if (clean) {BX.onCustomEvent(this, 'onWindowClose', [this, true]);} 381 382 if (this.DIV.parentNode) 383 this.DIV.parentNode.removeChild(this.DIV); 384 } 385 else 386 { 387 this.DIV.style.display = 'none'; 388 } 389}; 390 391BX.CWindow.prototype.CloseDialog = // compatibility 392BX.CWindow.prototype.Close = function(bImmediately) 393{ 394 BX.onCustomEvent(this, 'onBeforeWindowClose', [this]); 395 if (bImmediately !== true) 396 { 397 if (this.denyClose) 398 return false; 399 } 400 401 BX.onCustomEvent(this, 'onWindowClose', [this]); 402 403 //this crashes vis editor in ie via onWindowResizeExt event handler 404 //if (this.bExpanded) this.__expand(); 405 // alternative version: 406 if (this.bExpanded) 407 { 408 var pDocElement = BX.GetDocElement(); 409 BX.unbind(window, 'resize', BX.proxy(this.__expand_onresize, this)); 410 pDocElement.style.overflow = this.__expand_settings.overflow; 411 } 412 413 BX.WindowManager.unregister(this); 414 415 return true; 416}; 417 418BX.CWindow.prototype.SetResize = function(elem) 419{ 420 elem.style.cursor = 'se-resize'; 421 BX.bind(elem, 'mousedown', BX.proxy(this.__startResize, this)); 422 423 this.ELEMENTS.resizer.push(elem); 424 this.SETTINGS.resizable = true; 425}; 426 427BX.CWindow.prototype.SetExpand = function(elem, event_name) 428{ 429 event_name = event_name || 'click'; 430 BX.bind(elem, event_name, BX.proxy(this.__expand, this)); 431}; 432 433BX.CWindow.prototype.__expand_onresize = function() 434{ 435 var windowSize = BX.GetWindowInnerSize(); 436 this.DIV.style.width = windowSize.innerWidth + "px"; 437 this.DIV.style.height = windowSize.innerHeight + "px"; 438 439 BX.onCustomEvent(this, 'onWindowResize'); 440}; 441 442BX.CWindow.prototype.__expand = function() 443{ 444 var pDocElement = BX.GetDocElement(); 445 446 if (!this.bExpanded) 447 { 448 var wndScroll = BX.GetWindowScrollPos(), 449 wndSize = BX.GetWindowInnerSize(); 450 451 this.__expand_settings = { 452 resizable: this.SETTINGS.resizable, 453 draggable: this.SETTINGS.draggable, 454 width: this.DIV.style.width, 455 height: this.DIV.style.height, 456 left: this.DIV.style.left, 457 top: this.DIV.style.top, 458 scrollTop: wndScroll.scrollTop, 459 scrollLeft: wndScroll.scrollLeft, 460 overflow: BX.style(pDocElement, 'overflow') 461 }; 462 463 this.SETTINGS.resizable = false; 464 this.SETTINGS.draggable = false; 465 466 window.scrollTo(0,0); 467 pDocElement.style.overflow = 'hidden'; 468 469 this.DIV.style.top = '0px'; 470 this.DIV.style.left = '0px'; 471 472 this.DIV.style.width = wndSize.innerWidth + 'px'; 473 this.DIV.style.height = wndSize.innerHeight + 'px'; 474 475 this.bExpanded = true; 476 477 BX.onCustomEvent(this, 'onWindowExpand'); 478 BX.onCustomEvent(this, 'onWindowResize'); 479 480 BX.bind(window, 'resize', BX.proxy(this.__expand_onresize, this)); 481 } 482 else 483 { 484 BX.unbind(window, 'resize', BX.proxy(this.__expand_onresize, this)); 485 486 this.SETTINGS.resizable = this.__expand_settings.resizable; 487 this.SETTINGS.draggable = this.__expand_settings.draggable; 488 489 pDocElement.style.overflow = this.__expand_settings.overflow; 490 491 this.DIV.style.top = this.__expand_settings.top; 492 this.DIV.style.left = this.__expand_settings.left; 493 this.DIV.style.width = this.__expand_settings.width; 494 this.DIV.style.height = this.__expand_settings.height; 495 496 window.scrollTo(this.__expand_settings.scrollLeft, this.__expand_settings.scrollTop); 497 498 this.bExpanded = false;
499 500 BX.onCustomEvent(this, 'onWindowNarrow'); 501 BX.onCustomEvent(this, 'onWindowResize'); 502 503 } 504}; 505 506BX.CWindow.prototype.Resize = function(x, y) 507{ 508 var new_width = Math.max(x - this.pos.left + this.dx, this.SETTINGS.min_width); 509 var new_height = Math.max(y - this.pos.top + this.dy, this.SETTINGS.min_height); 510 511 if (this.SETTINGS.resize_restrict) 512 { 513 var scrollSize = BX.GetWindowScrollSize(); 514 515 if (this.pos.left + new_width > scrollSize.scrollWidth - this.dw) 516 new_width = scrollSize.scrollWidth - this.pos.left - this.dw; 517 } 518 519 this.DIV.style.width = new_width + 'px'; 520 this.DIV.style.height = new_height + 'px'; 521 522 BX.onCustomEvent(this, 'onWindowResize'); 523}; 524 525BX.CWindow.prototype.__startResize = function(e) 526{ 527 if (!this.SETTINGS.resizable) 528 return false; 529 530 if(!e) e = window.event; 531 532 this.wndSize = BX.GetWindowScrollPos(); 533 this.wndSize.innerWidth = BX.GetWindowInnerSize().innerWidth; 534 535 this.pos = BX.pos(this.DIV); 536 537 this.x = e.clientX + this.wndSize.scrollLeft; 538 this.y = e.clientY + this.wndSize.scrollTop; 539 540 this.dx = this.pos.left + this.pos.width - this.x; 541 this.dy = this.pos.top + this.pos.height - this.y; 542 this.dw = this.pos.width - parseInt(this.DIV.style.width); 543 544 BX.bind(document, "mousemove", BX.proxy(this.__moveResize, this)); 545 BX.bind(document, "mouseup", BX.proxy(this.__stopResize, this)); 546 547 if(document.body.setCapture) 548 document.body.setCapture(); 549 550 document.onmousedown = BX.False; 551 552 var b = document.body; 553 b.ondrag = b.onselectstart = BX.False; 554 b.style.MozUserSelect = this.DIV.style.MozUserSelect = 'none'; 555 b.style.cursor = 'se-resize'; 556 557 BX.onCustomEvent(this, 'onWindowResizeStart'); 558 559 return true; 560}; 561 562BX.CWindow.prototype.__moveResize = function(e) 563{ 564 if(!e) e = window.event; 565 566 var windowScroll = BX.GetWindowScrollPos(); 567 568 var x = e.clientX + windowScroll.scrollLeft; 569 var y = e.clientY + windowScroll.scrollTop; 570 571 if(this.x == x && this.y == y) 572 return; 573 574 this.Resize(x, y); 575 576 this.x = x; 577 this.y = y; 578}; 579 580BX.CWindow.prototype.__stopResize = function() 581{ 582 if(document.body.releaseCapture) 583 document.body.releaseCapture(); 584 585 BX.unbind(document, "mousemove", BX.proxy(this.__moveResize, this)); 586 BX.unbind(document, "mouseup", BX.proxy(this.__stopResize, this)); 587 588 document.onmousedown = null; 589 590 var b = document.body; 591 b.ondrag = b.onselectstart = null; 592 b.style.MozUserSelect = this.DIV.style.MozUserSelect = ''; 593 b.style.cursor = ''; 594 595 BX.onCustomEvent(this, 'onWindowResizeFinished') 596}; 597 598BX.CWindow.prototype.SetClose = function(elem) 599{ 600 BX.bind(elem, 'click', BX.proxy(this.Close, this)); 601 this.ELEMENTS.close.push(elem); 602}; 603 604BX.CWindow.prototype.SetDraggable = function(elem) 605{ 606 BX.bind(elem, 'mousedown', BX.proxy(this.__startDrag, this)); 607 608 elem.style.cursor = 'move'; 609 610 this.ELEMENTS.draggable.push(elem); 611 this.SETTINGS.draggable = true; 612}; 613 614BX.CWindow.prototype.Move = function(x, y) 615{ 616 var dxShadow = 1; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 617 618 var left = parseInt(this.DIV.style.left)+x; 619 var top = parseInt(this.DIV.style.top)+y; 620 621 if (this.SETTINGS.drag_restrict) 622 { 623 //Left side 624 if (left < 0) 625 left = 0; 626 627 //Right side 628 var scrollSize = BX.GetWindowScrollSize(); 629 var floatWidth = this.DIV.offsetWidth; 630 var floatHeight = this.DIV.offsetHeight; 631 632 if (left > (scrollSize.scrollWidth - floatWidth - dxShadow)) 633 left = scrollSize.scrollWidth - floatWidth - dxShadow; 634 635 var scrollHeight = Math.max( 636 document.body.scrollHeight, document.documentElement.scrollHeight, 637 document.body.offsetHeight, document.documentElement.offsetHeight, 638 document.body.clientHeight, document.documentElement.clientHeight, 639 scrollSize.scrollHeight 640 ); 641 642 if (top > (scrollHeight - floatHeight - dxShadow)) 643 top = scrollHeight - floatHeight - dxShadow; 644 645 //Top side 646 if (top < 0) 647 top = 0; 648 } 649 650 this.DIV.style.left = left+'px'; 651 this.DIV.style.top = top+'px'; 652 653 //this.AdjustShadow(div); 654}; 655 656BX.CWindow.prototype.__startDrag = function(e) 657{ 658 if (!this.SETTINGS.draggable) 659 return false; 660 661 if(!e) e = window.event; 662 663 this.x = e.clientX + document.body.scrollLeft; 664 this.y = e.clientY + document.body.scrollTop; 665 666 this.__bWasDragged = false;
667 BX.bind(document, "mousemove", BX.proxy(this.__moveDrag, this)); 668 BX.bind(document, "mouseup", BX.proxy(this.__stopDrag, this)); 669 670 if(document.body.setCapture) 671 document.body.setCapture(); 672 673 document.onmousedown = BX.False; 674 675 var b = document.body; 676 b.ondrag = b.onselectstart = BX.False; 677 b.style.MozUserSelect = this.DIV.style.MozUserSelect = 'none'; 678 b.style.cursor = 'move'; 679 return BX.PreventDefault(e); 680}; 681 682BX.CWindow.prototype.__moveDrag = function(e) 683{ 684 if(!e) e = window.event; 685 686 var x = e.clientX + document.body.scrollLeft; 687 var y = e.clientY + document.body.scrollTop; 688 689 if(this.x == x && this.y == y) 690 return; 691 692 this.Move((x - this.x), (y - this.y)); 693 this.x = x; 694 this.y = y; 695 696 if (!this.__bWasDragged) 697 { 698 BX.onCustomEvent(this, 'onWindowDragStart'); 699 this.__bWasDragged = true; 700 BX.bind(BX.proxy_context, "click", BX.PreventDefault); 701 } 702 703 BX.onCustomEvent(this, 'onWindowDrag'); 704}; 705 706BX.CWindow.prototype.__stopDrag = function(e) 707{ 708 if(document.body.releaseCapture) 709 document.body.releaseCapture(); 710 711 BX.unbind(document, "mousemove", BX.proxy(this.__moveDrag, this)); 712 BX.unbind(document, "mouseup", BX.proxy(this.__stopDrag, this)); 713 714 document.onmousedown = null; 715 716 var b = document.body; 717 b.ondrag = b.onselectstart = null; 718 b.style.MozUserSelect = this.DIV.style.MozUserSelect = ''; 719 b.style.cursor = ''; 720 721 if (this.__bWasDragged) 722 { 723 BX.onCustomEvent(this, 'onWindowDragFinished'); 724 var _proxy_context = BX.proxy_context; 725 setTimeout(function(){BX.unbind(_proxy_context, "click", BX.PreventDefault)}, 100); 726 this.__bWasDragged = false; 727 } 728 return BX.PreventDefault(e); 729}; 730 731BX.CWindow.prototype.DenyClose = function() 732{ 733 this.denyClose = true; 734}; 735 736BX.CWindow.prototype.AllowClose = function() 737{ 738 this.denyClose = false; 739}; 740 741BX.CWindow.prototype.ShowError = function(str) 742{ 743 BX.onCustomEvent(this, 'onWindowError', [str]); 744 745 if (this._wait) 746 BX.closeWait(this._wait); 747 748 window.alert(str); 749}; 750 751BX.CWindow.prototype.__set_msover = function() {this.MOUSEOVER = true;}; 752BX.CWindow.prototype.__unset_msover = function() {this.MOUSEOVER = false;}; 753 754/* dialog window class extends window class */ 755BX.CWindowDialog = function() { 756 var a = arguments; 757 a[1] = 'dialog'; 758 BX.CWindowDialog.superclass.constructor.apply(this, a); 759 760 this.DIV.style.top = '10px'; 761 this.OVERLAY = null; 762}; 763BX.extend(BX.CWindowDialog, BX.CWindow); 764 765BX.CWindowDialog.prototype.__resizeOverlay = function() 766{ 767 var windowSize = BX.GetWindowScrollSize(); 768 this.OVERLAY.style.width = windowSize.scrollWidth + "px"; 769}; 770 771BX.CWindowDialog.prototype.CreateOverlay = function(zIndex) 772{ 773 if (null == this.OVERLAY) 774 { 775 var windowSize = BX.GetWindowScrollSize(); 776 777 // scrollHeight in BX.GetWindowScrollSize may be incorrect 778 var scrollHeight = Math.max( 779 document.body.scrollHeight, document.documentElement.scrollHeight, 780 document.body.offsetHeight, document.documentElement.offsetHeight, 781 document.body.clientHeight, document.documentElement.clientHeight, 782 windowSize.scrollHeight 783 ); 784 785 this.OVERLAY = document.body.appendChild(BX.create("DIV", { 786 style: { 787 position: 'absolute', 788 top: '0px', 789 left: '0px', 790 zIndex: zIndex || (parseInt(this.DIV.style.zIndex)-2), 791 width: windowSize.scrollWidth + "px", 792 height: scrollHeight + "px" 793 } 794 })); 795 } 796 797 return this.OVERLAY; 798}; 799 800BX.CWindowDialog.prototype.Show = function() 801{ 802 BX.CWindowDialog.superclass.Show.apply(this, arguments); 803 804 this.CreateOverlay(); 805 806 this.OVERLAY.style.display = 'block'; 807 this.OVERLAY.style.zIndex = parseInt(this.DIV.style.zIndex)-2; 808 809 BX.unbind(window, 'resize', BX.proxy(this.__resizeOverlay, this)); 810 BX.bind(window, 'resize', BX.proxy(this.__resizeOverlay, this)); 811}; 812 813BX.CWindowDialog.prototype.onUnRegister = function(clean) 814{ 815 BX.CWindowDialog.superclass.onUnRegister.apply(this, arguments); 816 817 if (this.clean) 818 { 819 if (this.OVERLAY.parentNode) 820 this.OVERLAY.parentNode.removeChild(this.OVERLAY); 821 } 822 else 823 { 824 this.OVERLAY.style.display = 'none'; 825 } 826 827 BX.unbind(window, 'resize', BX.proxy(this.__resizeOverlay, this)); 828}; 829 830/* standard bitrix dialog extends BX.CWindowDialog */ 831/* 832 arParams = { 833 ( 834 title: 'dialog title', 835 head: 'head block html', 836 content: 'dialog content', 837 icon: 'head icon classname or filename', 838 839 resize_id: 'some id to save resize information'// useless if resizable = false 840 ) 841 or 842 ( 843 content_url: url to content load 844 loaded content scripts can use BX.WindowManager.Get() to get access to the current window object 845 ) 846 847 height: window_height_in_pixels, 848 width: window_width_in_pixels, 849 850 draggable: true|false, 851 resizable: true|false, 852
853 min_height: min_window_height_in_pixels, // useless if resizable = false 854 min_width: min_window_width_in_pixels, // useless if resizable = false 855 856 buttons: [ 857 'html_code', 858 BX.CDialog.btnSave, BX.CDialog.btnCancel, BX.CDialog.btnClose 859 ] 860 } 861*/ 862BX.CDialog = function(arParams) 863{ 864 BX.CDialog.superclass.constructor.apply(this); 865 866 this._sender = 'core_window_cdialog'; 867 868 this.PARAMS = arParams || {}; 869 870 for (var i in this.defaultParams) 871 { 872 if (typeof this.PARAMS[i] == 'undefined') 873 this.PARAMS[i] = this.defaultParams[i]; 874 } 875 876 this.PARAMS.width = (!isNaN(parseInt(this.PARAMS.width))) 877 ? this.PARAMS.width 878 : this.defaultParams['width']; 879 this.PARAMS.height = (!isNaN(parseInt(this.PARAMS.height))) 880 ? this.PARAMS.height 881 : this.defaultParams['height']; 882 883 if (this.PARAMS.resize_id || this.PARAMS.content_url) 884 { 885 var arSize = BX.WindowManager.getRuntimeWindowSize(this.PARAMS.resize_id || this.PARAMS.content_url); 886 if (arSize) 887 { 888 this.PARAMS.width = arSize.width; 889 this.PARAMS.height = arSize.height; 890 } 891 } 892 893 BX.addClass(this.DIV, 'bx-core-adm-dialog'); 894 this.DIV.id = 'bx-admin-prefix'; 895 896 this.PARTS = {}; 897 898 this.DIV.style.height = null; 899 this.DIV.style.width = null; 900 901 this.PARTS.TITLEBAR = this.DIV.appendChild(BX.create('DIV', {props: { 902 className: 'bx-core-adm-dialog-head' 903 } 904 })); 905 906 this.PARTS.TITLE_CONTAINER = this.PARTS.TITLEBAR.appendChild(BX.create('SPAN', { 907 props: {className: 'bx-core-adm-dialog-head-inner'}, 908 text: this.PARAMS.title 909 })); 910 911 this.PARTS.TITLEBAR_ICONS = this.PARTS.TITLEBAR.appendChild(BX.create('DIV', { 912 props: { 913 className: 'bx-core-adm-dialog-head-icons' 914 }, 915 children: (this.PARAMS.resizable ? [ 916 BX.create('SPAN', {props: {className: 'bx-core-adm-icon-expand', title: BX.message('JS_CORE_WINDOW_EXPAND')}}), 917 BX.create('SPAN', {props: {className: 'bx-core-adm-icon-close', title: BX.message('JS_CORE_WINDOW_CLOSE')}}) 918 ] : [ 919 BX.create('SPAN', {props: {className: 'bx-core-adm-icon-close', title: BX.message('JS_CORE_WINDOW_CLOSE')}}) 920 ]) 921 })); 922 923 924 this.PARTS.CONTENT = this.DIV.appendChild(BX.create('DIV', { 925 props: {className: 'bx-core-adm-dialog-content-wrap adm-workarea'} 926 })); 927 928 this.PARTS.CONTENT_DATA = this.PARTS.CONTENT.appendChild(BX.create('DIV', { 929 props: {className: 'bx-core-adm-dialog-content'}, 930 style: { 931 height: this.PARAMS.height + 'px', 932 width: this.PARAMS.width + 'px' 933 } 934 })); 935 936 this.PARTS.HEAD = this.PARTS.CONTENT_DATA.appendChild(BX.create('DIV', { 937 props: { 938 className: 'bx-core-adm-dialog-head-block' + (this.PARAMS.icon ? ' ' + this.PARAMS.icon : '') 939 } 940 })); 941 942 this.SetHead(this.PARAMS.head); 943 this.SetContent(this.PARAMS.content); 944 this.SetTitle(this.PARAMS.title); 945 this.SetClose(this.PARTS.TITLEBAR_ICONS.lastChild); 946 947 if (this.PARAMS.resizable) 948 { 949 this.SetExpand(this.PARTS.TITLEBAR_ICONS.firstChild); 950 this.SetExpand(this.PARTS.TITLEBAR, 'dblclick'); 951 952 BX.addCustomEvent(this, 'onWindowExpand', BX.proxy(this.__onexpand, this)); 953 BX.addCustomEvent(this, 'onWindowNarrow', BX.proxy(this.__onexpand, this)); 954 } 955 956 this.PARTS.FOOT = this.PARTS.BUTTONS_CONTAINER = this.PARTS.CONTENT.appendChild(BX.create('DIV', { 957 props: { 958 className: 'bx-core-adm-dialog-buttons' 959 }, 960 //events: { 961 // 'click': BX.delegateEvent({property:{type: /button|submit/}}, BX.delegate(function() {this.showWait(BX.proxy_context)}, this)) 962 //}, 963 children: this.ShowButtons() 964 } 965 )); 966 967 if (this.PARAMS.draggable) 968 this.SetDraggable(this.PARTS.TITLEBAR); 969 970 if (this.PARAMS.resizable) 971 { 972 this.PARTS.RESIZER = this.DIV.appendChild(BX.create('DIV', { 973 props: {className: 'bx-core-resizer'} 974 })); 975 976 this.SetResize(this.PARTS.RESIZER); 977 978 this.SETTINGS.min_width = this.PARAMS.min_width; 979 this.SETTINGS.min_height = this.PARAMS.min_height; 980 } 981 982 this.auth_callback = BX.delegate(function(){ 983 this.PARAMS.content = ''; 984 this.hideNotify(); 985 this.Show(); 986 }, this) 987}; 988BX.extend(BX.CDialog, BX.CWindowDialog); 989 990BX.CDialog.prototype.defaultParams = { 991 width: 700, 992 height: 400, 993 min_width: 500, 994 min_height: 300, 995 996 resizable: true, 997 draggable: true, 998 999 title: '', 1000 icon: '' 1001}; 1002 1003BX.CDialog.prototype.showWait = function(el) 1004{ 1005 if (BX.type.isElementNode(el) && (el.type == 'button' || el.type == 'submit')) 1006 { 1007 BX.defer(function(){el.disabled = true})(); 1008 1009 var bSave = (BX.hasClass(el, 'adm-btn-save') || BX.hasClass(el, 'adm-btn-save')), 1010 pos = BX.pos(el, true); 1011 1012 el.bxwaiter = this.PARTS.FOOT.appendChild(BX.create('DIV', { 1013 props: {className: 'adm-btn-load-img' + (bSave ? '-green' : '')}, 1014 style: { 1015 top: parseInt((pos.bottom + pos.top)/2 - 10) + 'px', 1016 left: parseInt((pos.right + pos.left)/2 - 10) + 'px' 1017 } 1018 })); 1019 1020 BX.addClass(el, 'adm-btn-load'); 1021 1022 this.lastWaitElement = el; 1023 1024 return el.bxwaiter; 1025 } 1026 return null; 1027}; 1028 1029BX.CDialog.prototype.closeWait = function(el) 1030{ 1031 el = el || this.lastWaitElement; 1032 1033 if (BX.type.isElementNode(el)) 1034 { 1035 if (el.bxwaiter) 1036 { 1037 if(el.bxwaiter.parentNode) 1038 { 1039 el.bxwaiter.parentNode.removeChild(el.bxwaiter); 1040 } 1041 1042 el.bxwaiter = null; 1043 } 1044 1045 el.disabled = false;
1046 BX.removeClass(el, 'adm-btn-load'); 1047 1048 if (this.lastWaitElement == el) 1049 this.lastWaitElement = null; 1050 } 1051}; 1052 1053BX.CDialog.prototype.Authorize = function(arAuthResult) 1054{ 1055 this.bSkipReplaceContent = true; 1056 this.ShowError(BX.message('JSADM_AUTH_REQ')); 1057 1058 BX.onCustomEvent(this, 'onWindowError', []); 1059 1060 BX.closeWait(); 1061 1062 (new BX.CAuthDialog({ 1063 content_url: this.PARAMS.content_url, 1064 auth_result: arAuthResult, 1065 callback: BX.delegate(function(){ 1066 if (this.auth_callback) 1067 this.auth_callback() 1068 }, this) 1069 })).Show(); 1070}; 1071 1072BX.CDialog.prototype.ShowError = function(str) 1073{ 1074 BX.onCustomEvent(this, 'onWindowError', [str]); 1075 1076 this.closeWait(); 1077 1078 if (this._wait) 1079 BX.closeWait(this._wait); 1080 1081 this.Notify(str, true); 1082}; 1083 1084 1085BX.CDialog.prototype.__expandGetSize = function() 1086{ 1087 var pDocElement = BX.GetDocElement(); 1088 pDocElement.style.overflow = 'hidden'; 1089 1090 var wndSize = BX.GetWindowInnerSize(); 1091 1092 pDocElement.scrollTop = 0; 1093 1094 this.DIV.style.top = '-' + this.dxShadow + 'px'; 1095 this.DIV.style.left = '-' + this.dxShadow + 'px'; 1096 1097 return { 1098 width: (wndSize.innerWidth - parseInt(BX.style(this.PARTS.CONTENT, 'padding-right')) - parseInt(BX.style(this.PARTS.CONTENT, 'padding-left'))) + this.dxShadow, 1099 height: (wndSize.innerHeight - this.PARTS.TITLEBAR.offsetHeight - this.PARTS.FOOT.offsetHeight - parseInt(BX.style(this.PARTS.CONTENT, 'padding-top')) - parseInt(BX.style(this.PARTS.CONTENT, 'padding-bottom'))) + this.dxShadow 1100 }; 1101}; 1102 1103BX.CDialog.prototype.__expand = function() 1104{ 1105 var pDocElement = BX.GetDocElement(); 1106 this.dxShadow = 2; 1107 1108 if (!this.bExpanded) 1109 { 1110 var wndScroll = BX.GetWindowScrollPos(); 1111 1112 this.__expand_settings = { 1113 resizable: this.SETTINGS.resizable, 1114 draggable: this.SETTINGS.draggable, 1115 width: this.PARTS.CONTENT_DATA.style.width, 1116 height: this.PARTS.CONTENT_DATA.style.height, 1117 left: this.DIV.style.left, 1118 top: this.DIV.style.top, 1119 scrollTop: wndScroll.scrollTop, 1120 scrollLeft: wndScroll.scrollLeft, 1121 overflow: BX.style(pDocElement, 'overflow') 1122 }; 1123 1124 this.SETTINGS.resizable = false; 1125 this.SETTINGS.draggable = false; 1126 1127 var pos = this.__expandGetSize(); 1128 1129 this.PARTS.CONTENT_DATA.style.width = pos.width + 'px'; 1130 this.PARTS.CONTENT_DATA.style.height = pos.height + 'px'; 1131 1132 window.scrollTo(0,0); 1133 pDocElement.style.overflow = 'hidden'; 1134 1135 this.bExpanded = true; 1136 1137 BX.onCustomEvent(this, 'onWindowExpand'); 1138 BX.onCustomEvent(this, 'onWindowResize'); 1139 BX.onCustomEvent(this, 'onWindowResizeExt', [{'width': pos.width, 'height': pos.height}]); 1140 1141 BX.bind(window, 'resize', BX.proxy(this.__expand_onresize, this)); 1142 } 1143 else 1144 { 1145 BX.unbind(window, 'resize', BX.proxy(this.__expand_onresize, this)); 1146 1147 this.SETTINGS.resizable = this.__expand_settings.resizable; 1148 this.SETTINGS.draggable = this.__expand_settings.draggable; 1149 1150 pDocElement.style.overflow = this.__expand_settings.overflow; 1151 1152 this.DIV.style.top = this.__expand_settings.top; 1153 this.DIV.style.left = this.__expand_settings.left; 1154 this.PARTS.CONTENT_DATA.style.width = this.__expand_settings.width; 1155 this.PARTS.CONTENT_DATA.style.height = this.__expand_settings.height; 1156 window.scrollTo(this.__expand_settings.scrollLeft, this.__expand_settings.scrollTop); 1157 this.bExpanded = false; 1158 1159 BX.onCustomEvent(this, 'onWindowNarrow'); 1160 BX.onCustomEvent(this, 'onWindowResize'); 1161 BX.onCustomEvent(this, 'onWindowResizeExt', [{'width': parseInt(this.__expand_settings.width), 'height': parseInt(this.__expand_settings.height)}]); 1162 } 1163}; 1164 1165BX.CDialog.prototype.__expand_onresize = function() 1166{ 1167 var pos = this.__expandGetSize(); 1168 1169 this.PARTS.CONTENT_DATA.style.width = pos.width + 'px'; 1170 this.PARTS.CONTENT_DATA.style.height = pos.height + 'px'; 1171 1172 BX.onCustomEvent(this, 'onWindowResize'); 1173 BX.onCustomEvent(this, 'onWindowResizeExt', [pos]); 1174}; 1175 1176BX.CDialog.prototype.__onexpand = function() 1177{ 1178 var ob = this.PARTS.TITLEBAR_ICONS.firstChild; 1179 ob.className = BX.toggle(ob.className, ['bx-core-adm-icon-expand', 'bx-core-adm-icon-narrow']); 1180 ob.title = BX.toggle(ob.title, [BX.message('JS_CORE_WINDOW_EXPAND'), BX.message('JS_CORE_WINDOW_NARROW')]); 1181 1182 if (this.PARTS.RESIZER) 1183 { 1184 this.PARTS.RESIZER.style.display = this.bExpanded ? 'none' : 'block'; 1185 } 1186}; 1187 1188 1189BX.CDialog.prototype.__startResize = function(e) 1190{ 1191 if (!this.SETTINGS.resizable) 1192 return false;
1193 1194 if(!e) e = window.event; 1195 1196 this.wndSize = BX.GetWindowScrollPos(); 1197 this.wndSize.innerWidth = BX.GetWindowInnerSize().innerWidth; 1198 1199 this.pos = BX.pos(this.PARTS.CONTENT_DATA); 1200 1201 this.x = e.clientX + this.wndSize.scrollLeft; 1202 this.y = e.clientY + this.wndSize.scrollTop; 1203 1204 this.dx = this.pos.left + this.pos.width - this.x; 1205 this.dy = this.pos.top + this.pos.height - this.y; 1206 1207 1208 // TODO: suspicious 1209 this.dw = this.pos.width - parseInt(this.PARTS.CONTENT_DATA.style.width) + parseInt(BX.style(this.PARTS.CONTENT, 'padding-right')); 1210 1211 BX.bind(document, "mousemove", BX.proxy(this.__moveResize, this)); 1212 BX.bind(document, "mouseup", BX.proxy(this.__stopResize, this)); 1213 1214 if(document.body.setCapture) 1215 document.body.setCapture(); 1216 1217 document.onmousedown = BX.False; 1218 1219 var b = document.body; 1220 b.ondrag = b.onselectstart = BX.False; 1221 b.style.MozUserSelect = this.DIV.style.MozUserSelect = 'none'; 1222 b.style.cursor = 'se-resize'; 1223 1224 BX.onCustomEvent(this, 'onWindowResizeStart'); 1225 1226 return true; 1227}; 1228 1229BX.CDialog.prototype.Resize = function(x, y) 1230{ 1231 var new_width = Math.max(x - this.pos.left + this.dx, this.SETTINGS.min_width); 1232 var new_height = Math.max(y - this.pos.top + this.dy, this.SETTINGS.min_height); 1233 1234 if (this.SETTINGS.resize_restrict) 1235 { 1236 var scrollSize = BX.GetWindowScrollSize(); 1237 1238 if (this.pos.left + new_width > scrollSize.scrollWidth - this.dw) 1239 new_width = scrollSize.scrollWidth - this.pos.left - this.dw; 1240 } 1241 1242 this.PARTS.CONTENT_DATA.style.width = new_width + 'px'; 1243 this.PARTS.CONTENT_DATA.style.height = new_height + 'px'; 1244 1245 BX.onCustomEvent(this, 'onWindowResize'); 1246 BX.onCustomEvent(this, 'onWindowResizeExt', [{'height': new_height, 'width': new_width}]); 1247}; 1248 1249BX.CDialog.prototype.SetSize = function(obSize) 1250{ 1251 this.PARTS.CONTENT_DATA.style.width = obSize.width + 'px'; 1252 this.PARTS.CONTENT_DATA.style.height = obSize.height + 'px'; 1253 1254 BX.onCustomEvent(this, 'onWindowResize'); 1255 BX.onCustomEvent(this, 'onWindowResizeExt', [obSize]); 1256}; 1257 1258BX.CDialog.prototype.GetParameters = function(form_name) 1259{ 1260 var form = this.GetForm(); 1261 1262 if(!form) 1263 return ""; 1264 1265 var i, s = ""; 1266 var n = form.elements.length; 1267 1268 var delim = ''; 1269 for(i=0; i<n; i++) 1270 { 1271 if (s != '') delim = '&'; 1272 var el = form.elements[i]; 1273 if (el.disabled) 1274 continue; 1275 1276 switch(el.type.toLowerCase()) 1277 { 1278 case 'text': 1279 case 'textarea': 1280 case 'password': 1281 case 'hidden': 1282 if (null == form_name && el.name.substr(el.name.length-4) == '_alt' && form.elements[el.name.substr(0, el.name.length-4)]) 1283 break; 1284 s += delim + el.name + '=' + BX.util.urlencode(el.value); 1285 break; 1286 case 'radio': 1287 if(el.checked) 1288 s += delim + el.name + '=' + BX.util.urlencode(el.value); 1289 break; 1290 case 'checkbox': 1291 s += delim + el.name + '=' + BX.util.urlencode(el.checked ? 'Y':'N'); 1292 break; 1293 case 'select-one': 1294 var val = ""; 1295 if (null == form_name && form.elements[el.name + '_alt'] && el.selectedIndex == 0) 1296 val = form.elements[el.name+'_alt'].value; 1297 else 1298 val = el.value; 1299 s += delim + el.name + '=' + BX.util.urlencode(val); 1300 break; 1301 case 'select-multiple': 1302 var j, bAdded = false; 1303 var l = el.options.length; 1304 for (j=0; j<l; j++) 1305 { 1306 if (el.options[j].selected) 1307 { 1308 s += delim + el.name + '=' + BX.util.urlencode(el.options[j].value); 1309 bAdded = true; 1310 } 1311 } 1312 if (!bAdded) 1313 s += delim + el.name + '='; 1314 break; 1315 default: 1316 break; 1317 } 1318 } 1319 1320 return s; 1321}; 1322 1323BX.CDialog.prototype.PostParameters = function(params) 1324{ 1325 var url = this.PARAMS.content_url; 1326 1327 if (null == params) 1328 params = ""; 1329 1330 params += (params == "" ? "" : "&") + "bxsender=" + this._sender; 1331 1332 var index = url.indexOf('?'); 1333 if (index == -1) 1334 url += '?' + params; 1335 else 1336 url = url.substring(0, index) + '?' + params + "&" + url.substring(index+1); 1337 1338 BX.showWait(); 1339 1340 this.auth_callback = BX.delegate(function(){ 1341 this.hideNotify(); 1342 this.PostParameters(params); 1343 }, this); 1344 1345 BX.ajax.Setup({skipAuthCheck:true},true); 1346 BX.ajax.post(url, this.GetParameters(), BX.delegate(function(result) { 1347 BX.closeWait(); 1348 if (!this.bSkipReplaceContent) 1349 { 1350 this.ClearButtons(); // buttons are appended during form reload, so we should clear footer 1351 this.SetContent(result); 1352 this.Show(true); 1353 } 1354 1355 this.bSkipReplaceContent = false;
1356 }, this)); 1357}; 1358 1359BX.CDialog.prototype.Submit = function(params, url) 1360{ 1361 var FORM = this.GetForm(); 1362 if (FORM) 1363 { 1364 FORM.onsubmit = null; 1365 1366 FORM.method = 'POST'; 1367 if (!FORM.action || url) 1368 { 1369 url = url || this.PARAMS.content_url; 1370 if (null != params) 1371 { 1372 var index = url.indexOf('?'); 1373 if (index == -1) 1374 url += '?' + params; 1375 else 1376 url = url.substring(0, index) + '?' + params + "&" + url.substring(index+1); 1377 } 1378 1379 FORM.action = url; 1380 } 1381 1382 if (!FORM._bxsender) 1383 { 1384 FORM._bxsender = FORM.appendChild(BX.create('INPUT', { 1385 attrs: { 1386 type: 'hidden', 1387 name: 'bxsender', 1388 value: this._sender 1389 } 1390 })); 1391 } 1392 1393 this._wait = BX.showWait(); 1394 1395 this.auth_callback = BX.delegate(function(){ 1396 this.hideNotify(); 1397 this.Submit(params); 1398 }, this); 1399 1400 BX.ajax.submit(FORM, BX.delegate(function(){this.closeWait()}, this)); 1401 } 1402 else 1403 { 1404 window.alert('no form registered!'); 1405 } 1406}; 1407 1408BX.CDialog.prototype.GetForm = function() 1409{ 1410 if (null == this.__form) 1411 { 1412 var forms = this.PARTS.CONTENT_DATA.getElementsByTagName('FORM'); 1413 this.__form = forms[0] ? forms[0] : null; 1414 } 1415 1416 return this.__form; 1417}; 1418 1419BX.CDialog.prototype.GetRealForm = function() 1420{ 1421 if (null == this.__rform) 1422 { 1423 var forms = this.PARTS.CONTENT_DATA.getElementsByTagName('FORM'); 1424 this.__rform = forms[1] ? forms[1] : (forms[0] ? forms[0] : null); 1425 } 1426 1427 return this.__rform; 1428}; 1429 1430BX.CDialog.prototype._checkButton = function(btn) 1431{ 1432 var arCustomButtons = ['btnSave', 'btnCancel', 'btnClose']; 1433 1434 for (var i = 0; i < arCustomButtons.length; i++) 1435 { 1436 if (this[arCustomButtons[i]] && (btn == this[arCustomButtons[i]])) 1437 return arCustomButtons[i]; 1438 } 1439 1440 return false; 1441}; 1442 1443BX.CDialog.prototype.ShowButtons = function() 1444{ 1445 var result = []; 1446 if (this.PARAMS.buttons) 1447 { 1448 if (this.PARAMS.buttons.title) this.PARAMS.buttons = [this.PARAMS.buttons]; 1449 1450 for (var i=0, len=this.PARAMS.buttons.length; i<len; i++) 1451 { 1452 if (BX.type.isNotEmptyString(this.PARAMS.buttons[i])) 1453 { 1454 result.push(this.PARAMS.buttons[i]); 1455 } 1456 else if (BX.type.isElementNode(this.PARAMS.buttons[i])) 1457 { 1458 result.push(this.PARAMS.buttons[i]); 1459 } 1460 else if (this.PARAMS.buttons[i]) 1461 { 1462 //if (!(this.PARAMS.buttons[i] instanceof BX.CWindowButton)) 1463 if (!BX.is_subclass_of(this.PARAMS.buttons[i], BX.CWindowButton)) 1464 { 1465 var b = this._checkButton(this.PARAMS.buttons[i]); // hack to set links to real CWindowButton object in btnSave etc; 1466 this.PARAMS.buttons[i] = new BX.CWindowButton(this.PARAMS.buttons[i]); 1467 if (b) this[b] = this.PARAMS.buttons[i]; 1468 } 1469 1470 result.push(this.PARAMS.buttons[i].Button(this)); 1471 } 1472 } 1473 } 1474 1475 return result; 1476}; 1477 1478BX.CDialog.prototype.setAutosave = function () { 1479 if (!this.bSetAutosaveDelay) 1480 { 1481 this.bSetAutosaveDelay = true; 1482 setTimeout(BX.proxy(this.setAutosave, this), 10); 1483 } 1484}; 1485 1486BX.CDialog.prototype.SetTitle = function(title) 1487{ 1488 this.PARAMS.title = title; 1489 BX.cleanNode(this.PARTS.TITLE_CONTAINER).appendChild(document.createTextNode(this.PARAMS.title)); 1490}; 1491 1492BX.CDialog.prototype.SetHead = function(head) 1493{ 1494 this.PARAMS.head = BX.util.trim(head); 1495 this.PARTS.HEAD.innerHTML = this.PARAMS.head || " "; 1496 this.PARTS.HEAD.style.display = this.PARAMS.head ? 'block' : 'none'; 1497 this.adjustSize(); 1498}; 1499 1500BX.CDialog.prototype.Notify = function(note, bError, html) 1501{ 1502 if (!this.PARTS.NOTIFY) 1503 { 1504 this.PARTS.NOTIFY = this.DIV.insertBefore(BX.create('DIV', { 1505 props: {className: 'adm-warning-block'}, 1506 children: [ 1507 BX.create('SPAN', { 1508 props: {className: 'adm-warning-text'} 1509 }), 1510 BX.create('SPAN', { 1511 props: {className: 'adm-warning-icon'} 1512 }), 1513 BX.create('SPAN', { 1514 props: {className: 'adm-warning-close'}, 1515 events: {click: BX.proxy(this.hideNotify, this)} 1516 }) 1517 ] 1518 }), this.DIV.firstChild); 1519 } 1520 1521 if (bError) 1522 BX.addClass(this.PARTS.NOTIFY, 'adm-warning-block-red'); 1523 else 1524 BX.removeClass(this.PARTS.NOTIFY, 'adm-warning-block-red'); 1525 1526 if(html !== true) 1527 { 1528 note = BX.util.htmlspecialchars(note); 1529 } 1530 1531 this.PARTS.NOTIFY.firstChild.innerHTML = note || ' '; 1532 this.PARTS.NOTIFY.firstChild.style.width = (this.PARAMS.width-50) + 'px'; 1533 BX.removeClass(this.PARTS.NOTIFY, 'adm-warning-animate'); 1534}; 1535 1536BX.CDialog.prototype.hideNotify = function() 1537{ 1538 BX.addClass(this.PARTS.NOTIFY, 'adm-warning-animate'); 1539}; 1540 1541BX.CDialog.prototype.__adjustHeadToIcon = function() 1542{ 1543 if (!this.PARTS.HEAD.offsetHeight) 1544 { 1545 setTimeout(BX.delegate(this.__adjustHeadToIcon, this), 50); 1546 } 1547 else 1548 { 1549 if (this.icon_image && this.icon_image.height && this.icon_image.height > this.PARTS.HEAD.offsetHeight - 5) 1550 { 1551 this.PARTS.HEAD.style.height = this.icon_image.height + 5 + 'px'; 1552 this.adjustSize(); 1553 } 1554 1555 this.icon_image.onload = null; 1556 this.icon_image = null; 1557 } 1558}; 1559 1560BX.CDialog.prototype.SetIcon = function(icon_class) 1561{ 1562 if (this.PARAMS.icon != icon_class) 1563 { 1564 if (this.PARAMS.icon) 1565 BX.removeClass(this.PARTS.HEAD, this.PARAMS.icon); 1566 1567 this.PARAMS.icon = icon_class; 1568 1569 if (this.PARAMS.icon) 1570 { 1571 BX.addClass(this.PARTS.HEAD, this.PARAMS.icon); 1572 1573 var icon_file = (BX.style(this.PARTS.HEAD, 'background-image') || BX.style(this.PARTS.HEAD, 'backgroundImage')); 1574 if (BX.type.isNotEmptyString(icon_file) && icon_file != 'none') 1575 { 1576 var match = icon_file.match(new RegExp('url\\s*\\(\\s*(\'|"|)(.+?)(\\1)\\s*\\)')); 1577 if(match) 1578 { 1579 icon_file = match[2]; 1580 if (BX.type.isNotEmptyString(icon_file)) 1581 { 1582 this.icon_image = new Image(); 1583 this.icon_image.onload = BX.delegate(this.__adjustHeadToIcon, this); 1584 this.icon_image.src = icon_file; 1585 } 1586 } 1587 } 1588 } 1589 } 1590 this.adjustSize(); 1591}; 1592 1593BX.CDialog.prototype.SetIconFile = function(icon_file) 1594{ 1595 this.icon_image = new Image(); 1596 this.icon_image.onload = BX.delegate(this.__adjustHeadToIcon, this); 1597 this.icon_image.src = icon_file; 1598 1599 BX.adjust(this.PARTS.HEAD, {style: {backgroundImage: 'url(' + icon_file + ')', backgroundPosition: 'right 9px'/*'99% center'*/}}); 1600 this.adjustSize(); 1601}; 1602 1603/* 1604BUTTON: { 1605 title: 'title',
1606 'action': function executed in window object context 1607} 1608BX.CDialog.btnSave || BX.CDialog.btnCancel - standard buttons 1609*/ 1610 1611BX.CDialog.prototype.SetButtons = function(a) 1612{ 1613 if (BX.type.isString(a)) 1614 { 1615 if (a.length > 0) 1616 { 1617 this.PARTS.BUTTONS_CONTAINER.innerHTML += a; 1618 1619 var btns = this.PARTS.BUTTONS_CONTAINER.getElementsByTagName('INPUT'); 1620 if (btns.length > 0) 1621 { 1622 this.PARAMS.buttons = []; 1623 for (var i = 0; i < btns.length; i++) 1624 { 1625 this.PARAMS.buttons.push(new BX.CWindowButton({btn: btns[i], parentWindow: this})); 1626 } 1627 } 1628 } 1629 } 1630 else 1631 { 1632 this.PARAMS.buttons = a; 1633 BX.adjust(this.PARTS.BUTTONS_CONTAINER, { 1634 children: this.ShowButtons() 1635 }); 1636 } 1637 this.adjustSize(); 1638}; 1639 1640BX.CDialog.prototype.ClearButtons = function() 1641{ 1642 BX.cleanNode(this.PARTS.BUTTONS_CONTAINER); 1643 this.adjustSize(); 1644}; 1645 1646BX.CDialog.prototype.SetContent = function(html) 1647{ 1648 this.__form = null; 1649 1650 if (BX.type.isElementNode(html)) 1651 { 1652 if (html.parentNode) 1653 html.parentNode.removeChild(html); 1654 } 1655 else if (BX.type.isString(html)) 1656 { 1657 html = BX.create('DIV', {html: html}); 1658 } 1659 1660 this.PARAMS.content = html; 1661 BX.cleanNode(this.PARTS.CONTENT_DATA); 1662 1663 BX.adjust(this.PARTS.CONTENT_DATA, { 1664 children: [ 1665 this.PARTS.HEAD, 1666 BX.create('DIV', { 1667 props: { 1668 className: 'bx-core-adm-dialog-content-wrap-inner' 1669 }, 1670 children: [this.PARAMS.content] 1671 }) 1672 ] 1673 }); 1674 1675 if (this.PARAMS.content_url && this.GetForm()) 1676 { 1677 this.__form.submitbtn = this.__form.appendChild(BX.create('INPUT', {props:{type:'submit'},style:{display:'none'}})); 1678 this.__form.onsubmit = BX.delegate(this.__submit, this); 1679 } 1680}; 1681 1682BX.CDialog.prototype.__submit = function(e) 1683{ 1684 for (var i=0,len=this.PARAMS.buttons.length; i<len; i++) 1685 { 1686 if ( 1687 this.PARAMS.buttons[i] 1688 && ( 1689 this.PARAMS.buttons[i].name && /save|apply/i.test(this.PARAMS.buttons[i].name) 1690 || 1691 this.PARAMS.buttons[i].btn && this.PARAMS.buttons[i].btn.name && /save|apply/i.test(this.PARAMS.buttons[i].btn.name) 1692 ) 1693 ) 1694 { 1695 this.PARAMS.buttons[i].emulate(); 1696 break; 1697 } 1698 } 1699 1700 return BX.PreventDefault(e); 1701}; 1702 1703BX.CDialog.prototype.SwapContent = function(cont) 1704{ 1705 cont = BX(cont); 1706 1707 BX.cleanNode(this.PARTS.CONTENT_DATA); 1708 cont.parentNode.removeChild(cont); 1709 this.PARTS.CONTENT_DATA.appendChild(cont); 1710 cont.style.display = 'block'; 1711 this.SetContent(cont.innerHTML); 1712}; 1713 1714// this method deprecated 1715BX.CDialog.prototype.adjustSize = function() 1716{ 1717}; 1718 1719// this method deprecated 1720BX.CDialog.prototype.__adjustSize = function() 1721{ 1722}; 1723 1724BX.CDialog.prototype.adjustSizeEx = function() 1725{ 1726 BX.defer(this.__adjustSizeEx, this)(); 1727}; 1728 1729BX.CDialog.prototype.__adjustSizeEx = function() 1730{ 1731 var ob = this.PARTS.CONTENT_DATA.firstChild, 1732 new_height = 0, 1733 marginTop, 1734 marginBottom; 1735 1736 while (ob) 1737 { 1738 if (BX.type.isElementNode(ob)) 1739 { 1740 marginTop = parseInt(BX.style(ob, 'margin-top'), 10); 1741 if (isNaN(marginTop)) 1742 marginTop = 0; 1743 marginBottom = parseInt(BX.style(ob, 'margin-bottom'), 10); 1744 if (isNaN(marginBottom)) 1745 marginBottom = 0; 1746 new_height += ob.offsetHeight + marginTop + marginBottom; 1747 } 1748 ob = BX.nextSibling(ob); 1749 } 1750 1751 if (new_height) 1752 this.PARTS.CONTENT_DATA.style.height = new_height + 'px'; 1753}; 1754 1755 1756BX.CDialog.prototype.__onResizeFinished = function() 1757{ 1758 BX.WindowManager.saveWindowSize( 1759 this.PARAMS.resize_id || this.PARAMS.content_url, {height: parseInt(this.PARTS.CONTENT_DATA.style.height), width: parseInt(this.PARTS.CONTENT_DATA.style.width)} 1760 ); 1761}; 1762 1763BX.CDialog.prototype.Show = function(bNotRegister) 1764{ 1765 if ((!this.PARAMS.content) && this.PARAMS.content_url && BX.ajax && !bNotRegister) 1766 { 1767 var wait = BX.showWait(); 1768 1769 BX.WindowManager.currently_loaded = this; 1770 1771 var zIndex = (this.PARAMS.zIndex ? this.PARAMS.zIndex : parseInt(BX.style(wait, 'z-index'))-1); 1772 this.CreateOverlay(zIndex); 1773 this.OVERLAY.style.display = 'block'; 1774 this.OVERLAY.className = 'bx-core-dialog-overlay'; 1775 1776 var post_data = '', method = 'GET'; 1777 if (this.PARAMS.content_post) 1778 { 1779 post_data = this.PARAMS.content_post; 1780 method = 'POST'; 1781 } 1782 1783 var url = this.PARAMS.content_url 1784 + (this.PARAMS.content_url.indexOf('?')<0?'?':'&')+'bxsender=' + this._sender; 1785 1786 this.auth_callback = BX.delegate(function(){ 1787 this.PARAMS.content = ''; 1788 this.hideNotify(); 1789 this.Show(); 1790 }, this); 1791 1792 BX.ajax({ 1793 method: method, 1794 dataType: 'html', 1795 url: url, 1796 data: post_data, 1797 skipAuthCheck: true, 1798 onsuccess: BX.delegate(function(data) { 1799 BX.closeWait(null, wait); 1800 1801 this.SetContent(data || ' '); 1802 this.Show(); 1803 }, this) 1804 }); 1805 } 1806 else 1807 { 1808 BX.WindowManager.currently_loaded = null; 1809 BX.CDialog.superclass.Show.apply(this, arguments); 1810 1811 this.adjustPos(); 1812 1813 this.OVERLAY.className = 'bx-core-dialog-overlay'; 1814 1815 this.__adjustSize(); 1816 1817 BX.addCustomEvent(this, 'onWindowResize', BX.proxy(this.__adjustSize, this)); 1818 1819 if (this.PARAMS.resizable && (this.PARAMS.content_url || this.PARAMS.resize_id)) 1820 BX.addCustomEvent(this, 'onWindowResizeFinished', BX.delegate(this.__onResizeFinished, this)); 1821 } 1822}; 1823 1824BX.CDialog.prototype.GetInnerPos = function() 1825{ 1826 return {'width': parseInt(this.PARTS.CONTENT_DATA.style.width), 'height': parseInt(this.PARTS.CONTENT_DATA.style.height)}; 1827}; 1828 1829BX.CDialog.prototype.adjustPos = function() 1830{ 1831 if (!this.bExpanded) 1832 { 1833 var currentWindow = window; 1834 if (top.BX.SidePanel && top.BX.SidePanel.Instance && top.BX.SidePanel.Instance.getTopSlider()) 1835 { 1836 currentWindow = top.BX.SidePanel.Instance.getTopSlider().getWindow(); 1837 } 1838 var windowSize = currentWindow.BX.GetWindowInnerSize(); 1839 var windowScroll = currentWindow.BX.GetWindowScrollPos(); 1840 1841 var style = { 1842 left: parseInt(windowScroll.scrollLeft + windowSize.innerWidth / 2 - parseInt(this.DIV.offsetWidth) / 2) + 'px', 1843 top: Math.max(parseInt(windowScroll.scrollTop + windowSize.innerHe
1843ight / 2 - parseInt(this.DIV.offsetHeight) / 2), 0) + 'px' 1844 }; 1845 if (this.PARAMS.zIndex) 1846 { 1847 style["z-index"] = this.PARAMS.zIndex; 1848 } 1849 1850 BX.adjust(this.DIV, { 1851 style: style 1852 }); 1853 } 1854}; 1855 1856BX.CDialog.prototype.GetContent = function () {return this.PARTS.CONTENT_DATA}; 1857 1858BX.CDialog.prototype.btnSave = BX.CDialog.btnSave = { 1859 title: BX.message('JS_CORE_WINDOW_SAVE'), 1860 id: 'savebtn', 1861 name: 'savebtn', 1862 className: BX.browser.IsIE() && BX.browser.IsDoctype() && !BX.browser.IsIE10() ? '' : 'adm-btn-save', 1863 action: function () { 1864 this.disableUntilError(); 1865 this.parentWindow.PostParameters(); 1866 } 1867}; 1868 1869BX.CDialog.prototype.btnCancel = BX.CDialog.btnCancel = { 1870 title: BX.message('JS_CORE_WINDOW_CANCEL'), 1871 id: 'cancel', 1872 name: 'cancel', 1873 action: function () { 1874 this.parentWindow.Close(); 1875 } 1876}; 1877 1878BX.CDialog.prototype.btnClose = BX.CDialog.btnClose = { 1879 title: BX.message('JS_CORE_WINDOW_CLOSE'), 1880 id: 'close', 1881 name: 'close', 1882 action: function () { 1883 this.parentWindow.Close(); 1884 } 1885}; 1886 1887/* special child for admin forms loaded into public page */ 1888BX.CAdminDialog = function(arParams) 1889{ 1890 BX.CAdminDialog.superclass.constructor.apply(this, arguments); 1891 1892 this._sender = 'core_window_cadmindialog'; 1893 1894 BX.addClass(this.DIV, 'bx-core-adm-admin-dialog'); 1895 1896 this.PARTS.CONTENT.insertBefore(this.PARTS.HEAD, this.PARTS.CONTENT.firstChild); 1897 this.PARTS.HEAD.className = 'bx-core-adm-dialog-tabs'; 1898}; 1899BX.extend(BX.CAdminDialog, BX.CDialog); 1900 1901BX.CAdminDialog.prototype.SetHead = function() 1902{ 1903 BX.CAdminDialog.superclass.SetHead.apply(this, arguments); 1904 1905 if (this.PARTS.HEAD.firstChild && BX.type.isElementNode(this.PARTS.HEAD.firstChild)) 1906 { 1907 var ob = this.PARTS.HEAD.firstChild, new_width = 0, marginLeft = 0, marginRight = 0; 1908 1909 while (ob) 1910 { 1911 if (BX.type.isElementNode(ob)) 1912 { 1913 marginLeft = parseInt(BX.style(ob, 'margin-left'), 10); 1914 if (isNaN(marginLeft)) 1915 marginLeft = 0; 1916 marginRight = parseInt(BX.style(ob, 'margin-right'), 10); 1917 if (isNaN(marginRight)) 1918 marginRight = 0; 1919 new_width += ob.offsetWidth + marginLeft + marginRight; 1920 } 1921 ob = BX.nextSibling(ob); 1922 } 1923 1924 this.SETTINGS.min_width = Math.max(new_width, this.SETTINGS.min_width) - 2; 1925 if (this.PARAMS.width < this.SETTINGS.min_width) 1926 { 1927 BX.adjust(this.PARTS.CONTENT_DATA, { 1928 style: { 1929 width: this.SETTINGS.min_width + 'px' 1930 } 1931 }); 1932 } 1933 } 1934}; 1935 1936BX.CAdminDialog.prototype.SetContent = function(html) 1937{ 1938 this.__form = null; 1939 1940 if (BX.type.isElementNode(html)) 1941 { 1942 if (html.parentNode) 1943 html.parentNode.removeChild(html); 1944 } 1945 1946 this.PARAMS.content = html; 1947 BX.cleanNode(this.PARTS.CONTENT_DATA); 1948 1949 BX.adjust(this.PARTS.CONTENT_DATA, { 1950 children: [ 1951 this.PARAMS.content || ' ' 1952 ] 1953 }); 1954 1955 if (this.PARAMS.content_url && this.GetForm()) 1956 { 1957 this.__form.appendChild(BX.create('INPUT', {props:{type:'submit'},style:{display:'none'}})); 1958 this.__form.onsubmit = BX.delegate(this.__submit, this); 1959 } 1960}; 1961 1962BX.CAdminDialog.prototype.__expandGetSize = function() 1963{ 1964 var res = BX.CAdminDialog.superclass.__expandGetSize.apply(this, arguments); 1965 1966 res.width -= parseInt(BX.style(this.PARTS.CONTENT_DATA, 'padding-right')) + parseInt(BX.style(this.PARTS.CONTENT_DATA, 'padding-left')); 1967 res.height -= parseInt(BX.style(this.PARTS.CONTENT_DATA, 'padding-top')) + parseInt(BX.style(this.PARTS.CONTENT_DATA, 'padding-bottom')); 1968 1969 res.height -= this.PARTS.HEAD.offsetHeight; 1970 1971 return res; 1972}; 1973 1974BX.CAdminDialog.prototype.Submit = function() 1975{ 1976 var FORM = this.GetForm(); 1977 if (FORM && !FORM['bxpublic'] && !/bxpublic=/.test(FORM.action)) 1978 { 1979 FORM.appendChild(BX.create('INPUT', { 1980 props: { 1981 type: 'hidden', 1982 name: 'bxpublic', 1983 value: 'Y' 1984 } 1985 })); 1986 } 1987 1988 return BX.CAdminDialog.superclass.Submit.apply(this, arguments); 1989}; 1990 1991BX.CAdminDialog.prototype.btnSave = BX.CAdminDialog.btnSave = { 1992 title: BX.message('JS_CORE_WINDOW_SAVE'), 1993 id: 'savebtn', 1994 name: 'savebtn', 1995 className: 'adm-btn-save', 1996 action: function () { 1997 this.disableUntilError(); 1998 this.parentWindow.Submit(); 1999 } 2000}; 2001 2002BX.CAdminDialog.btnCancel = BX.CAdminDialog.superclass.btnCancel; 2003BX.CAdminDialog.btnClose = BX.CAdminDialog.superclass.btnClose; 2004 2005BX.CDebugDialog = function(arParams) 2006{ 2007 BX.CDebugDialog.superclass.constructor.apply(this, arguments); 2008}; 2009BX.extend(BX.CDebugDialog, BX.CDialog); 2010
2011BX.CDebugDialog.prototype.ShowDetails = function(div_id) 2012{ 2013 var div = BX(div_id); 2014 if (div) 2015 { 2016 if (this.div_detail_current) 2017 this.div_detail_current.style.display = 'none'; 2018 2019 div.style.display = 'block'; 2020 this.div_detail_current = div; 2021 } 2022}; 2023 2024BX.CDebugDialog.prototype.SetContent = function(html) 2025{ 2026 if (!html) 2027 return; 2028 2029 var arHtml = html.split('#DIVIDER#'); 2030 if (arHtml.length > 1) 2031 { 2032 this.PARAMS.content = arHtml[1]; 2033 2034 this.PARTS.CONTENT_DATA.style.overflow = 'hidden'; 2035 2036 BX.CDebugDialog.superclass.SetContent.apply(this, [arHtml[1]]); 2037 2038 this.PARTS.CONTENT_INNER = this.PARTS.CONTENT_DATA.firstChild.nextSibling; 2039 this.PARTS.CONTENT_TOP = this.PARTS.CONTENT_DATA.insertBefore(BX.create('DIV', { 2040 props: { 2041 className: 'bx-debug-content-top' 2042 }, 2043 html: arHtml[0] 2044 }), this.PARTS.CONTENT_INNER); 2045 this.PARTS.CONTENT_INNER.style.overflow = 'auto'; 2046 } 2047 else 2048 { 2049 BX.CDebugDialog.superclass.SetContent.apply(this, arguments); 2050 } 2051}; 2052 2053BX.CDebugDialog.prototype.__adjustSize = function() 2054{ 2055 BX.CDebugDialog.superclass.__adjustSize.apply(this, arguments); 2056 2057 if (this.PARTS.CONTENT_TOP) 2058 { 2059 var new_height = this.PARTS.CONTENT_DATA.offsetHeight - this.PARTS.HEAD.offsetHeight - this.PARTS.CONTENT_TOP.offsetHeight - 38; 2060 2061 if (new_height > 0) 2062 { 2063 this.PARTS.CONTENT_INNER.style.height = new_height + 'px'; 2064 } 2065 } 2066}; 2067 2068 2069/* class for dialog window with editors */ 2070 2071BX.CEditorDialog = function(arParams) 2072{ 2073 BX.CEditorDialog.superclass.constructor.apply(this, arguments); 2074 2075 BX.removeClass(this.PARTS.CONTENT, 'bx-core-adm-dialog-content-wrap'); 2076 BX.removeClass(this.PARTS.CONTENT_DATA, 'bx-core-adm-dialog-content'); 2077 2078 BX.removeClass(this.PARTS.CONTENT_DATA.lastChild, 'bx-core-adm-dialog-content-wrap-inner'); 2079 BX.removeClass(this.PARTS.BUTTONS_CONTAINER, 'bx-core-adm-dialog-buttons'); 2080 2081 BX.addClass(this.PARTS.CONTENT, 'bx-core-editor-dialog-content-wrap'); 2082 BX.addClass(this.PARTS.CONTENT_DATA, 'bx-core-editor-dialog-content'); 2083 BX.addClass(this.PARTS.BUTTONS_CONTAINER, 'bx-core-editor-dialog-buttons'); 2084}; 2085BX.extend(BX.CEditorDialog, BX.CDialog); 2086 2087BX.CEditorDialog.prototype.SetContent = function() 2088{ 2089 BX.CEditorDialog.superclass.SetContent.apply(this, arguments); 2090 2091 BX.removeClass(this.PARTS.CONTENT_DATA.lastChild, 'bx-core-adm-dialog-content-wrap-inner'); 2092}; 2093 2094/* class for wizards in admin section */ 2095BX.CWizardDialog = function(arParams) 2096{ 2097 BX.CWizardDialog.superclass.constructor.apply(this, arguments); 2098 2099 BX.removeClass(this.PARTS.CONTENT, 'bx-core-adm-dialog-content-wrap'); 2100 BX.removeClass(this.PARTS.CONTENT_DATA, 'bx-core-adm-dialog-content'); 2101 BX.removeClass(this.PARTS.CONTENT_DATA.lastChild, 'bx-core-adm-dialog-content-wrap-inner'); 2102 BX.removeClass(this.PARTS.BUTTONS_CONTAINER, 'bx-core-adm-dialog-buttons'); 2103 2104 BX.addClass(this.PARTS.CONTENT, 'bx-core-wizard-dialog-content-wrap'); 2105}; 2106 2107BX.extend(BX.CWizardDialog, BX.CDialog); 2108 2109/* class for auth dialog */ 2110BX.CAuthDialog = function(arParams) 2111{ 2112 arParams.resizable = false; 2113 arParams.width = 350;
2114 arParams.height = 200; 2115 2116 arParams.buttons = [this.btnSave]; 2117 2118 BX.CAuthDialog.superclass.constructor.apply(this, arguments); 2119 this._sender = 'core_window_cauthdialog'; 2120 2121 BX.addClass(this.DIV, 'bx-core-auth-dialog'); 2122 2123 BX.AUTHAGENT = this; 2124}; 2125BX.extend(BX.CAuthDialog, BX.CDialog); 2126 2127BX.CAuthDialog.prototype.btnSave = BX.CAuthDialog.btnSave = { 2128 title: BX.message('JS_CORE_WINDOW_AUTH'), 2129 id: 'savebtn', 2130 name: 'savebtn', 2131 className: 'adm-btn-save', 2132 action: function () { 2133 this.disableUntilError(); 2134 this.parentWindow.Submit('', this.parentWindow.PARAMS.content_url); 2135 } 2136}; 2137 2138BX.CAuthDialog.prototype.SetError = function(error) 2139{ 2140 BX.closeWait(); 2141 2142 if (!!error) 2143 this.ShowError(error.MESSAGE || error); 2144}; 2145 2146BX.CAuthDialog.prototype.setAuthResult = function(result) 2147{ 2148 BX.closeWait(); 2149 2150 if (result === false) 2151 { 2152 this.Close(); 2153 if (this.PARAMS.callback) 2154 this.PARAMS.callback(); 2155 } 2156 else 2157 { 2158 this.SetError(result); 2159 } 2160}; 2161 2162/* MENU CLASSES */ 2163 2164BX.CWindowFloat = function(node) 2165{ 2166 BX.CWindowFloat.superclass.constructor.apply(this, [node, 'float']); 2167 2168 this.SETTINGS.resizable = false; 2169}; 2170BX.extend(BX.CWindowFloat, BX.CWindow); 2171 2172BX.CWindowFloat.prototype.adjustPos = function() 2173{ 2174 if (this.PARAMS.parent) 2175 this.adjustToNode(); 2176 else if (this.PARAMS.x && this.PARAMS.y) 2177 this.adjustToPos([this.PARAMS.x, this.PARAMS.y]); 2178}; 2179 2180BX.CWindowFloat.prototype.adjustToPos = function(pos) 2181{ 2182 this.DIV.style.left = parseInt(pos[0]) + 'px'; 2183 this.DIV.style.top = parseInt(pos[1]) + 'px'; 2184}; 2185 2186BX.CWindowFloat.prototype.adjustToNodeGetPos = function() 2187{ 2188 return BX.pos(this.PARAMS.parent); 2189}; 2190 2191BX.CWindowFloat.prototype.adjustToNode = function(el) 2192{ 2193 el = el || this.PARAMS.parent; 2194 2195 this.PARAMS.parent = BX(el); 2196 2197 if (this.PARAMS.parent) 2198 { 2199 var pos = this.adjustToNodeGetPos(); 2200 2201 this.DIV.style.top = pos.top + 'px';//(pos.top - 26) + 'px'; 2202 this.DIV.style.left = pos.left + 'px'; 2203 2204 this.PARAMS.parent.OPENER = this; 2205 } 2206}; 2207 2208BX.CWindowFloat.prototype.Show = function() 2209{ 2210 this.adjustToPos([-1000, -1000]); 2211 BX.CWindowFloat.superclass.Show.apply(this, arguments); 2212 this.adjustPos(); 2213}; 2214 2215/* menu opener class */ 2216/* 2217{ 2218 DOMNode DIV, 2219 BX.CMenu or Array MENU, 2220 TYPE = 'hover' | 'click', 2221 TIMEOUT: 1000 2222 ATTACH_MODE: 'top' | 'right' 2223 ACTIVE_CLASS: className for opener element when menu is opened 2224} 2225*/ 2226BX.COpener = function(arParams) 2227{ 2228 this.PARAMS = arParams || {}; 2229 2230 this.MENU = arParams.MENU || []; 2231 2232 this.DIV = arParams.DIV; 2233 this.ATTACH = arParams.ATTACH || arParams.DIV; 2234 this.ATTACH_MODE = arParams.ATTACH_MODE || 'bottom'; 2235 2236 this.ACTIVE_CLASS = arParams.ACTIVE_CLASS || ''; 2237 this.PUBLIC_FRAME = arParams.PUBLIC_FRAME || 0; 2238 this.LEVEL = arParams.LEVEL || 0; 2239 2240 this.CLOSE_ON_CLICK = typeof arParams.CLOSE_ON_CLICK != 'undefined' ? !!arParams.CLOSE_ON_CLICK : true; 2241 this.ADJUST_ON_CLICK = typeof arParams.ADJUST_ON_CLICK != 'undefined' ? !!arParams.ADJUST_ON_CLICK : true; 2242 2243 this.TYPE = this.PARAMS.TYPE == 'hover' ? 'hover' : 'click'; 2244 2245 this._openTimeout = null; 2246 2247 if (this.PARAMS.TYPE == 'hover' && arParams.TIMEOUT !== 0)
2248 this.TIMEOUT = arParams.TIMEOUT || 1000; 2249 else 2250 this.TIMEOUT = 0; 2251 2252 if (!!this.PARAMS.MENU_URL) 2253 { 2254 this.bMenuLoaded = false; 2255 this.bMenuLoading = false; 2256 2257 this.MENU = [{ 2258 TEXT: BX.message('JS_CORE_LOADING'), 2259 CLOSE_ON_CLICK: false 2260 }]; 2261 2262 if (this.PARAMS.MENU_PRELOAD) 2263 { 2264 BX.defer(this.Load, this)(); 2265 } 2266 } 2267 2268 BX.ready(BX.defer(this.Init, this)); 2269}; 2270 2271BX.COpener.prototype.Init = function() 2272{ 2273 this.DIV = BX(this.DIV); 2274 2275 switch (this.TYPE) 2276 { 2277 case 'hover': 2278 BX.bind(this.DIV, 'mouseover', BX.proxy(this.Open, this)); 2279 BX.bind(this.DIV, 'click', BX.proxy(this.Toggle, this)); 2280 break; 2281 2282 case 'click': 2283 BX.bind(this.DIV, 'click', BX.proxy(this.Toggle, this)); 2284 break; 2285 } 2286 2287 //BX.bind(window, 'scroll', BX.delegate(this.__close_immediately, this)); 2288 2289 this.bMenuInit = false; 2290}; 2291 2292BX.COpener.prototype.Load = function() 2293{ 2294 if (this.PARAMS.MENU_URL && !this.bMenuLoaded) 2295 { 2296 if (!this.bMenuLoading) 2297 { 2298 var url = this.PARAMS.MENU_URL; 2299 if (url.indexOf('sessid=') <= 0) 2300 url += (url.indexOf('?') > 0 ? '&' : '?') + 'sessid=' + BX.bitrix_sessid(); 2301 2302 this.bMenuLoading = true; 2303 BX.ajax.loadJSON(url, BX.proxy(this.SetMenu, this), BX.proxy(this.LoadFailed, this)); 2304 } 2305 } 2306}; 2307 2308BX.COpener.prototype.SetMenu = function(menu) 2309{ 2310 this.bMenuLoaded = true; 2311 this.bMenuLoading = false; 2312 if (this.bMenuInit) 2313 { 2314 this.MENU.setItems(menu); 2315 } 2316 else 2317 { 2318 this.MENU = menu; 2319 } 2320}; 2321 2322BX.COpener.prototype.LoadFailed = function(type, error) 2323{ 2324 this.bMenuLoading = false; 2325 this.SetMenu([{ 2326 TEXT: BX.message('JS_CORE_NO_DATA'), 2327 CLOSE_ON_CLICK: true 2328 }]); 2329 BX.debug(arguments); 2330}; 2331 2332BX.COpener.prototype.checkAdminMenu = function() 2333{ 2334 if (document.documentElement.id == 'bx-admin-prefix') 2335 return true; 2336 2337 return !!BX.findParent(this.DIV, {property: {id: 'bx-admin-prefix'}}); 2338}; 2339 2340BX.COpener.prototype.Toggle = function(e) 2341{ 2342 this.__clear_timeout(); 2343 2344 if (!this.bMenuInit || !this.MENU.visible()) 2345 { 2346 var t = this.TIMEOUT; 2347 this.TIMEOUT = 0; 2348 this.Open(e); 2349 this.TIMEOUT = t; 2350 } 2351 else 2352 { 2353 this.MENU.Close(); 2354 } 2355 2356 return !!(e||window.event) && BX.PreventDefault(e); 2357}; 2358 2359BX.COpener.prototype.GetMenu = function() 2360{ 2361 if (!this.bMenuInit) 2362 { 2363 if (BX.type.isArray(this.MENU)) 2364 { 2365 this.MENU = new BX.CMenu({ 2366 ITEMS: this.MENU, 2367 ATTACH_MODE: this.ATTACH_MODE, 2368 SET_ID: this.checkAdminMenu() ? 'bx-admin-prefix' : '', 2369 CLOSE_ON_CLICK: !!this.CLOSE_ON_CLICK, 2370 ADJUST_ON_CLICK: !!this.ADJUST_ON_CLICK, 2371 PUBLIC_FRAME: !!this.PUBLIC_FRAME, 2372 LEVEL: this.LEVEL, 2373 parent: BX(this.DIV), 2374 parent_attach: BX(this.ATTACH) 2375 }); 2376 2377 if (this.LEVEL > 0) 2378 { 2379 BX.bind(this.MENU.DIV, 'mouseover', BX.proxy(this._on_menu_hover, this)); 2380 BX.bind(this.MENU.DIV, 'mouseout', BX.proxy(this._on_menu_hout, this)); 2381 } 2382 } 2383 2384 BX.addCustomEvent(this.MENU, 'onMenuOpen', BX.proxy(this.handler_onopen, this)); 2385 BX.addCustomEvent(this.MENU, 'onMenuClose', BX.proxy(this.handler_onclose, this)); 2386 2387 BX.addCustomEvent('onMenuItemHover', BX.proxy(this.handler_onover, this)); 2388 2389 this.bMenuInit = true; 2390 } 2391 2392 return this.MENU; 2393}; 2394 2395BX.COpener.prototype.Open = function() 2396{ 2397 this.GetMenu(); 2398 2399 this.bOpen = true; 2400 2401 this.__clear_timeout(); 2402 2403 if (this.TIMEOUT > 0) 2404 { 2405 BX.bind(this.DIV, 'mouseout', BX.proxy(this.__clear_timeout, this)); 2406 this._openTimeout = setTimeout(BX.proxy(this.__open, this), this.TIMEOUT); 2407 } 2408 else 2409 { 2410 this.__open(); 2411 } 2412 2413 if (!!this.PARAMS.MENU_URL && !this.bMenuLoaded) 2414 { 2415 this._loadTimeout = setTimeout(BX.proxy(this.Load, this), parseInt(this.TIMEOUT/2)); 2416 } 2417 2418 return true; 2419}; 2420 2421BX.COpener.prototype.__clear_timeout = function() 2422{ 2423 if (!!this._openTimeout) 2424 clearTimeout(this._openTimeout); 2425 if (!!this._loadTimeout) 2426 clearTimeout(this._loadTimeout); 2427 2428 BX.unbind(this.DIV, 'mouseout', BX.proxy(this.__clear_timeout, this)); 2429}; 2430 2431BX.COpener.prototype._on_menu_hover = function() 2432{ 2433 this.bMenuHover = true; 2434 2435 this.__clear_timeout(); 2436 2437 if (this.ACTIVE_CLASS) 2438 BX.addClass(this.DIV, this.ACTIVE_CLASS); 2439 2440}; 2441 2442BX.COpener.prototype._on_menu_hout = function() 2443{ 2444 this.bMenuHover = false; 2445}; 2446 2447BX.COpener.prototype.handler_onover = function(level, opener) 2448{ 2449 if (this.bMenuHover) 2450 return; 2451 2452 if (opener != this && level == this.LEVEL-1 && this.ACTIVE_CLASS) 2453 { 2454 BX.removeClass(this.DIV, this.ACTIVE_CLASS); 2455 } 2456 2457 if (this.bMenuInit && level <= this.LEVEL-1 && this.MENU.visible()) 2458 { 2459 if (opener != this) 2460 { 2461 this.__clear_timeout(); 2462 this._openTimeout = setTimeout(BX.proxy(this.Close, this), this.TIMEOUT); 2463 } 2464 } 2465}; 2466 2467BX.COpener.prototype.handler_onopen = function() 2468{ 2469 this.bOpen = true; 2470 2471 if (this.ACTIVE_CLASS) 2472 BX.addClass(this.DIV, this.ACTIVE_CLASS); 2473 2474 BX.defer(function() { 2475 BX.onCustomEvent(this, 'onOpenerMenuOpen'); 2476 }, this)(); 2477}; 2478 2479BX.COpener.prototype.handler_onclose = function() 2480{ 2481 this.bOpen = false;
2482 BX.onCustomEvent(this, 'onOpenerMenuClose'); 2483 2484 if (this.ACTIVE_CLASS) 2485 BX.removeClass(this.DIV, this.ACTIVE_CLASS); 2486}; 2487 2488BX.COpener.prototype.Close = function() 2489{ 2490 if (!this.bMenuInit) 2491 return; 2492 2493 if (!!this._openTimeout) 2494 clearTimeout(this._openTimeout); 2495 2496 this.bOpen = false; 2497 2498 this.__close(); 2499}; 2500 2501BX.COpener.prototype.__open = function() 2502{ 2503 this.__clear_timeout(); 2504 2505 if (this.bMenuInit && this.bOpen && !this.MENU.visible()) 2506 this.MENU.Show(); 2507}; 2508 2509BX.COpener.prototype.__close = function() 2510{ 2511 if (this.bMenuInit && !this.bOpen && this.MENU.visible()) 2512 this.MENU.Hide(); 2513}; 2514 2515BX.COpener.prototype.__close_immediately = function() { 2516 this.bOpen = false; this.__close(); 2517}; 2518 2519BX.COpener.prototype.isMenuVisible = function() { 2520 return null != this.MENU.visible && this.MENU.visible() 2521}; 2522 2523/* common menu class */ 2524 2525BX.CMenu = function(arParams) 2526{ 2527 BX.CMenu.superclass.constructor.apply(this); 2528 2529 this.DIV.style.width = 'auto';//this.DIV.firstChild.offsetWidth + 'px'; 2530 this.DIV.style.height = 'auto';//this.DIV.firstChild.offsetHeight + 'px'; 2531 2532 this.PARAMS = arParams || {}; 2533 this.PARTS = {}; 2534 2535 this.PARAMS.ATTACH_MODE = this.PARAMS.ATTACH_MODE || 'bottom'; 2536 this.PARAMS.CLOSE_ON_CLICK = typeof this.PARAMS.CLOSE_ON_CLICK == 'undefined' ? true : this.PARAMS.CLOSE_ON_CLICK; 2537 this.PARAMS.ADJUST_ON_CLICK = typeof this.PARAMS.ADJUST_ON_CLICK == 'undefined' ? true : this.PARAMS.ADJUST_ON_CLICK; 2538 this.PARAMS.PUBLIC_FRAME = typeof this.PARAMS.PUBLIC_FRAME == 'undefined' ? false : this.PARAMS.PUBLIC_FRAME; 2539 this.PARAMS.LEVEL = this.PARAMS.LEVEL || 0; 2540 2541 this.DIV.className = 'bx-core-popup-menu bx-core-popup-menu-' + this.PARAMS.ATTACH_MODE + ' bx-core-popup-menu-level' + this.PARAMS.LEVEL + (typeof this.PARAMS.ADDITIONAL_CLASS != 'undefined' ? ' ' + this.PARAMS.ADDITIONAL_CLASS : ''); 2542 if (!!this.PARAMS.SET_ID) 2543 this.DIV.id = this.PARAMS.SET_ID; 2544 2545 if (this.PARAMS.LEVEL == 0) 2546 { 2547 this.ARROW = this.DIV.appendChild(BX.create('SPAN', {props: {className: 'bx-core-popup-menu-angle'}, style: {left:'15px'}})); 2548 } 2549 2550 if (!!this.PARAMS.CLASS_NAME) 2551 this.DIV.className += ' ' + this.PARAMS.CLASS_NAME; 2552 2553 BX.bind(this.DIV, 'click', BX.eventCancelBubble); 2554 2555 this.ITEMS = []; 2556 2557 this.setItems(this.PARAMS.ITEMS); 2558 2559 BX.addCustomEvent('onMenuOpen', BX.proxy(this._onMenuOpen, this)); 2560 BX.addCustomEvent('onMenuItemSelected', BX.proxy(this.Hide, this)); 2561}; 2562BX.extend(BX.CMenu, BX.CWindowFloat); 2563 2564BX.CMenu.broadcastCloseEvent = function() 2565{ 2566 BX.onCustomEvent("onMenuItemSelected"); 2567}; 2568 2569BX.CMenu._toggleChecked = function() 2570{ 2571 BX.toggleClass(this, 'bx-core-popup-menu-item-checked'); 2572}; 2573 2574BX.CMenu._itemDblClick = function() 2575{ 2576 window.location.href = this.href; 2577}; 2578 2579BX.CMenu.prototype.toggleArrow = function(v) 2580{ 2581 if (!!this.ARROW) 2582 { 2583 if (typeof v == 'undefined') 2584 { 2585 v = this.ARROW.style.visibility == 'hidden'; 2586 } 2587 2588 this.ARROW.style.visibility = !!v ? 'visible' : 'hidden'; 2589 } 2590}; 2591 2592BX.CMenu.prototype.visible = function() 2593{ 2594 return this.DIV.style.display !== 'none'; 2595}; 2596 2597BX.CMenu.prototype._onMenuOpen = function(menu, menu_level) 2598{ 2599 if (this.visible()) 2600 { 2601 if (menu_level == this.PARAMS.LEVEL && menu != this) 2602 { 2603 this.Hide(); 2604 } 2605 } 2606}; 2607 2608BX.CMenu.prototype.onUnRegister = function() 2609{ 2610 if (!this.visible()) 2611 return; 2612 2613 this.Hide(); 2614}; 2615 2616BX.CMenu.prototype.setItems = function(items) 2617{ 2618 this.PARAMS.ITEMS = items; 2619 2620 BX.cleanNode(this.DIV); 2621 2622 if (!!this.ARROW) 2623 this.DIV.appendChild(this.ARROW); 2624 2625 if (this.PARAMS.ITEMS) 2626 { 2627 this.PARAMS.ITEMS = BX.util.array_values(this.PARAMS.ITEMS); 2628 2629 var bIcons = false; 2630 var cnt = 0; 2631 for (var i = 0, len = this.PARAMS.ITEMS.length; i < len; i++) 2632 { 2633 if ((i == 0 || i == len-1) && this.PARAMS.ITEMS[i].SEPARATOR) 2634 continue; 2635 2636 cnt++; 2637 2638 if (!bIcons) 2639 bIcons = !!this.PARAMS.ITEMS[i].GLOBAL_ICON; 2640 2641 this.addItem(this.PARAMS.ITEMS[i], i); 2642 } 2643 2644 // Occam turning in his grave 2645 if (cnt === 1) 2646 BX.addClass(this.DIV, 'bx-core-popup-menu-single-item'); 2647 else 2648 BX.removeClass(this.DIV, 'bx-core-popup-menu-single-item'); 2649 2650 if (!bIcons) 2651 BX.addClass(this.DIV, 'bx-core-popup-menu-no-icons'); 2652 else 2653 BX.removeClass(this.DIV, 'bx-core-popup-menu-no-icons'); 2654 2655 } 2656}; 2657 2658BX.CMenu.prototype.addItem = function(item) 2659{ 2660 this.ITEMS.push(item); 2661 2662 if (item.SEPARATOR) 2663 { 2664 item.NODE = BX.create( 2665 'DIV', {props: {className: 'bx-core-popup-menu-separator'}} 2666 ); 2667 } 2668 else 2669 { 2670 var bHasMenu = (!!item.MENU 2671 && (
2672 (BX.type.isArray(item.MENU) && item.MENU.length > 0) 2673 || item.MENU instanceof BX.CMenu 2674 ) || !!item.MENU_URL 2675 ); 2676 2677 if (item.DISABLED) 2678 { 2679 item.CLOSE_ON_CLICK = false; 2680 item.LINK = null; 2681 item.ONCLICK = null; 2682 item.ACTION = null; 2683 } 2684 2685 var attrs = {}; 2686 if (!!item.LINK || BX.browser.IsIE() && !BX.browser.IsDoctype()) 2687 { 2688 attrs.href = item.LINK || 'javascript:void(0)'; 2689 } 2690 if (this.PARAMS.PUBLIC_FRAME) 2691 { 2692 attrs.target = '_top'; 2693 } 2694 2695 item.NODE = BX.create(!!item.LINK || BX.browser.IsIE() && !BX.browser.IsDoctype() ? 'A' : 'SPAN', { 2696 props: { 2697 className: 'bx-core-popup-menu-item' 2698 + (bHasMenu ? ' bx-core-popup-menu-item-opener' : '') 2699 + (!!item.DEFAULT ? ' bx-core-popup-menu-item-default' : '') 2700 + (!!item.DISABLED ? ' bx-core-popup-menu-item-disabled' : '') 2701 + (!!item.CHECKED ? ' bx-core-popup-menu-item-checked' : ''), 2702 title: !!BX.message['MENU_ENABLE_TOOLTIP'] || !!item.SHOW_TITLE ? item.TITLE || '' : '', 2703 BXMENULEVEL: this.PARAMS.LEVEL 2704 }, 2705 attrs: attrs, 2706 events: { 2707 mouseover: function() 2708 { 2709 BX.onCustomEvent('onMenuItemHover', [this.BXMENULEVEL, this.OPENER]) 2710 } 2711 }, 2712 html: '<span class="bx-core-popup-menu-item-icon' + (item.GLOBAL_ICON ? ' '+item.GLOBAL_ICON : '') + '"></span><span class="bx-core-popup-menu-item-text">'+(item.HTML||(item.TEXT? BX.util.htmlspecialchars(item.TEXT) : ''))+'</span>' 2713 }); 2714 2715 if (bHasMenu && !item.DISABLED) 2716 { 2717 item.NODE.OPENER = new BX.COpener({ 2718 DIV: item.NODE, 2719 ACTIVE_CLASS: 'bx-core-popup-menu-item-opened', 2720 TYPE: 'hover', 2721 MENU: item.MENU, 2722 MENU_URL: item.MENU_URL, 2723 MENU_PRELOAD: !!item.MENU_PRELOAD, 2724 LEVEL: this.PARAMS.LEVEL + 1, 2725 ATTACH_MODE:'right', 2726 TIMEOUT: 500 2727 }); 2728 } 2729 else if (this.PARAMS.CLOSE_ON_CLICK && (typeof item.CLOSE_ON_CLICK == 'undefined' || !!item.CLOSE_ON_CLICK)) 2730 { 2731 BX.bind(item.NODE, 'click', BX.CMenu.broadcastCloseEvent); 2732 } 2733 else if (this.PARAMS.ADJUST_ON_CLICK && (typeof item.ADJUST_ON_CLICK == 'undefined' || !!item.ADJUST_ON_CLICK)) 2734 { 2735 BX.bind(item.NODE, 'click', BX.defer(this.adjustPos, this)); 2736 } 2737 2738 if (bHasMenu && !!item.LINK) 2739 { 2740 BX.bind(item.NODE, 'dblclick', BX.CMenu._itemDblClick); 2741 } 2742 2743 if (typeof item.CHECKED != 'undefined') 2744 { 2745 BX.bind(item.NODE, 'click', BX.CMenu._toggleChecked); 2746 } 2747 2748 item.ONCLICK = item.ACTION || item.ONCLICK; 2749 if (!!item.ONCLICK) 2750 { 2751 if (BX.type.isString(item.ONCLICK)) 2752 { 2753 item.ONCLICK = new Function("event", item.ONCLICK); 2754 } 2755 2756 BX.bind(item.NODE, 'click', item.ONCLICK); 2757 } 2758 } 2759 2760 this.DIV.appendChild(item.NODE); 2761}; 2762 2763BX.CMenu.prototype._documentClickBind = function() 2764{ 2765 this._documentClickUnBind(); 2766 BX.bind(document, 'click', BX.proxy(this._documentClick, this)); 2767}; 2768 2769BX.CMenu.prototype._documentClickUnBind = function() 2770{ 2771 BX.unbind(document, 'click', BX.proxy(this._documentClick, this)); 2772}; 2773 2774BX.CMenu.prototype._documentClick = function(e) 2775{ 2776 e = e||window.event; 2777 if(!!e && !(BX.getEventButton(e) & BX.MSLEFT)) 2778 return; 2779 2780 this.Close(); 2781}; 2782 2783BX.CMenu.prototype.Show = function() 2784{ 2785 BX.onCustomEvent(this, 'onMenuOpen', [this, this.PARAMS.LEVEL]); 2786 BX.CMenu.superclass.Show.apply(this, []); 2787 2788 this.bCloseEventFired = false; 2789 2790 BX.addCustomEvent(this.PARAMS.parent_attach, 'onChangeNodePosition', BX.proxy(this.adjustToNode, this)); 2791 2792 (BX.defer(this._documentClickBind, this))(); 2793}; 2794 2795BX.CMenu.prototype.Close = // we shouldn't 'Close' window - only hide 2796BX.CMenu.prototype.Hide = function() 2797{ 2798 if (!this.visible()) 2799 return; 2800 2801 BX.removeCustomEvent(this.PARAMS.parent_attach, 'onChangeNodePosition', BX.proxy(this.adjustToNode, this)); 2802 2803 this._documentClickUnBind(); 2804 2805 if (!this.bCloseEventFired) 2806 { 2807 BX.onCustomEvent(this, 'onMenuClose', [this, this.PARAMS.LEVEL]); 2808 this.bCloseEventFired = true; 2809 } 2810 BX.CMenu.superclass.Hide.apply(this, arguments); 2811 2812 2813// this.DIV.onclick = null; 2814 //this.PARAMS.parent.onclick = null; 2815}; 2816 2817BX.CMenu.prototype.__adjustMenuToNode = function() 2818{ 2819 var pos = BX.pos(this.PARAMS.parent_attach), 2820 bFixed = !!BX.findParent(this.PARAMS.parent_attach, BX.is_fixed); 2821 2822 if (bFixed) 2823 this.DIV.style.position = 'fixed'; 2824 else 2825 this.DIV.style.position = 'absolute'; 2826 2827 if (!pos.top) 2828 { 2829 this.DIV.style.top = '-1000px'; 2830 this.DIV.style.left = '-1000px'; 2831 } 2832 2833 if (this.bTimeoutSet) return; 2834 2835 var floatWidth = this.DIV.offsetWidth, floatHeight = this.DIV.offsetHeight; 2836 if (!floatWidth) 2837 { 2838 setTimeout(BX.delegate(function(){ 2839 this.bTimeoutSet = false; this.__adjustMenuToNode(); 2840 }, this), 100); 2841 2842 this.bTimeoutSet = true; 2843 return; 2844 } 2845 2846 var menu_pos = {}, 2847 wndSize = BX.GetWindowSize(); 2848 2849/* 2850 if (BX.browser.IsIE() && !BX.browser.IsDoctype()) 2851 { 2852 pos.top -= 4; pos.bottom -= 4; 2853 pos.left -= 2; pos.right -= 2; 2854 } 2855*/ 2856 2857 switch (this.PARAMS.ATTACH_MODE) 2858 { 2859 case 'bottom': 2860 menu_pos.top = pos.bottom + 9; 2861 menu_pos.left = pos.left; 2862 2863 var arrowPos = 0; 2864 if (!!this.ARROW) 2865 { 2866 if (pos.width > floatWidth) 2867 arrowPos = parseInt(floatWidth/2 - 7); 2868 else 2869 arrowPos = parseInt(Math.min(floatWidth, pos.width)/2 - 7); 2870 2871 if (arrowPos < 7) 2872 { 2873 menu_pos.left -= 15; 2874 arrowPos += 15; 2875 } 2876 } 2877 2878 if (menu_pos.left > wndSize.scrollWidth - floatWidth - 10) 2879 { 2880 var orig_menu_pos = menu_pos.left; 2881 menu_pos.left = wndSize.scrollWidth - floatWidth - 10; 2882 2883 if (!!this.ARROW) 2884 arrowPos += orig_menu_pos - menu_pos.left; 2885 } 2886 2887 if (bFixed) 2888 { 2889 menu_pos.left -= wndSize.scrollLeft; 2890 } 2891 2892 if (!!this.ARROW) 2893 this.ARROW.style.left = arrowPos + 'px'; 2894 break; 2895 case 'right': 2896 menu_pos.top = pos.top-1; 2897 menu_pos.left = pos.right; 2898 2899 if (menu_pos.left > wndSize.scrollWidth - floatWidth - 10) 2900 { 2901 menu_pos.left = pos.left - floatWidth - 1; 2902 } 2903 break; 2904 } 2905 2906 if (bFixed) 2907 { 2908 menu_pos.top -= wndSize.scrollTop; 2909 } 2910 2911 if (!!this.ARROW) 2912 this.ARROW.className = 'bx-core-popup-menu-angle'; 2913 2914 if((menu_pos.top + floatHeight >
2914 wndSize.scrollTop + wndSize.innerHeight) 2915 || (menu_pos.top + floatHeight > wndSize.scrollHeight)) 2916 { 2917 var new_top = this.PARAMS.ATTACH_MODE == 'bottom' 2918 ? pos.top - floatHeight - 9 2919 : pos.bottom - floatHeight + 1; 2920 2921 if((new_top > wndSize.scrollTop) 2922 || (menu_pos.top + floatHeight > wndSize.scrollHeight)) 2923 { 2924 if ((menu_pos.top + floatHeight > wndSize.scrollHeight)) 2925 { 2926 menu_pos.top = Math.max(0, wndSize.scrollHeight-floatHeight); 2927 this.toggleArrow(false); 2928 } 2929 else 2930 { 2931 menu_pos.top = new_top; 2932 2933 if (!!this.ARROW) 2934 this.ARROW.className = 'bx-core-popup-menu-angle-bottom'; 2935 } 2936 } 2937 } 2938 2939 if (menu_pos.top + menu_pos.left == 0) 2940 { 2941 this.Hide(); 2942 } 2943 else 2944 { 2945 this.DIV.style.top = menu_pos.top + 'px'; 2946 this.DIV.style.left = menu_pos.left + 'px'; 2947 } 2948}; 2949 2950BX.CMenu.prototype.adjustToNode = function(el) 2951{ 2952 this.PARAMS.parent_attach = BX(el) || this.PARAMS.parent_attach || this.PARAMS.parent; 2953 this.__adjustMenuToNode(); 2954}; 2955 2956 2957/* components toolbar class */ 2958 2959BX.CMenuOpener = function(arParams) 2960{ 2961 BX.CMenuOpener.superclass.constructor.apply(this); 2962 2963 this.PARAMS = arParams || {}; 2964 this.setParent(this.PARAMS.parent); 2965 this.PARTS = {}; 2966 2967 this.SETTINGS.drag_restrict = true; 2968 2969 this.defaultAction = null; 2970 2971 this.timeout = 500; 2972 2973 this.DIV.className = 'bx-component-opener'; 2974 this.DIV.ondblclick = BX.PreventDefault; 2975 2976 if (this.PARAMS.component_id) 2977 { 2978 this.PARAMS.transform = !!this.PARAMS.transform; 2979 } 2980 2981 this.OPENERS = []; 2982 2983 this.DIV.appendChild(BX.create('SPAN', { 2984 props: {className: 'bx-context-toolbar' + (this.PARAMS.transform ? ' bx-context-toolbar-vertical-mode' : '')} 2985 })); 2986 2987 //set internal structure and register draggable element 2988 this.PARTS.INNER = this.DIV.firstChild.appendChild(BX.create('SPAN', { 2989 props: {className: 'bx-context-toolbar-inner'}, 2990 html: '<span class="bx-context-toolbar-drag-icon"></span><span class="bx-context-toolbar-vertical-line"></span><br>' 2991 })); 2992 2993 this.EXTRA_BUTTONS = {}; 2994 2995 var btnCount = 0; 2996 for (var i = 0, len = this.PARAMS.menu.length; i < len; i++) 2997 { 2998 var item = this.addItem(this.PARAMS.menu[i]); 2999 if (null != item) 3000 { 3001 btnCount++; 3002 this.PARTS.INNER.appendChild(item); 3003 this.PARTS.INNER.appendChild(BX.create('BR')); 3004 } 3005 } 3006 var bHasButtons = btnCount > 0; 3007 3008 //menu items will be attached here 3009 3010 this.PARTS.ICONS = this.PARTS.INNER.appendChild(BX.create('SPAN', { 3011 props: {className: 'bx-context-toolbar-icons'} 3012 })); 3013 3014 if (this.PARAMS.component_id) 3015 { 3016 this.PARAMS.pin = !!this.PARAMS.pin; 3017 3018 if (bHasButtons) 3019 this.PARTS.ICONS.appendChild(BX.create('SPAN', {props: {className: 'bx-context-toolbar-separator'}})); 3020 3021 this.PARTS.ICON_PIN = this.PARTS.ICONS.appendChild(BX.create('A', { 3022 attrs: { 3023 href: 'javascript:void(0)' 3024 }, 3025 props: { 3026 className: this.PARAMS.pin 3027 ? 'bx-context-toolbar-pin-fixed' 3028 : 'bx-context-toolbar-pin' 3029 }, 3030 events: { 3031 click: BX.delegate(this.__pin_btn_clicked, this) 3032 } 3033 })); 3034 } 3035 3036 3037 if (this.EXTRA_BUTTONS['components2_props']) 3038 { 3039 var btn = this.EXTRA_BUTTONS['components2_props'] || {URL: 'javascript:void(0)'}; 3040 if (null == this.defaultAction) 3041 { 3042 this.defaultAction = btn.ONCLICK; 3043 this.defaultActionTitle = btn.TITLE || btn.TEXT; 3044 } 3045 3046 btn.URL = 'javascript:' + BX.util.urlencode(btn.ONCLICK); 3047 3048 this.ATTACH = this.PARTS.ICONS.appendChild(BX.create('SPAN', { 3049 props: {className: 'bx-context-toolbar-button bx-context-toolbar-button-settings' }, 3050 children: 3051 [ 3052 BX.create('SPAN', 3053 { 3054 props:{className: 'bx-context-toolbar-button-inner'}, 3055 children: 3056 [ 3057 BX.create('A', { 3058 attrs: {href: btn.URL}, 3059 events: { 3060 mouseover: BX.proxy(this.__msover_text, this), 3061 mouseout: BX.proxy(this.__msout_text, this), 3062 mousedown: BX.proxy(this.__msdown_text, this) 3063 }, 3064 html: '<span class="bx-context-toolbar-button-icon bx-context-toolbar-settings-icon"></span>' 3065 }), 3066 BX.create('A', { 3067 attrs: {href: 'javascript: void(0)'}, 3068 props: {className: 'bx-context-toolbar-button-arrow'}, 3069 events: { 3070 mouseover: BX.proxy(this.__msover_arrow, this), 3071 mouseout: BX.proxy(this.__msout_arrow, this), 3072 mousedown: BX.proxy(this.__msdown_arrow, this) 3073 }, 3074 html: '<span class="bx-context-toolbar-button-arrow"></span>' 3075 }) 3076 ] 3077 }) 3078 ] 3079 })); 3080
3081 this.OPENER = this.ATTACH.firstChild.lastChild; 3082 3083 var opener = this.attachMenu(this.EXTRA_BUTTONS['components2_submenu']['MENU']); 3084 3085 BX.addCustomEvent(opener, 'onOpenerMenuOpen', BX.proxy(this.__menu_open, this)); 3086 BX.addCustomEvent(opener, 'onOpenerMenuClose', BX.proxy(this.__menu_close, this)); 3087 } 3088 3089 if (btnCount > 1) 3090 { 3091 this.PARTS.ICONS.appendChild(BX.create('span', { props: {className: 'bx-context-toolbar-separator bx-context-toolbar-separator-switcher'}})); 3092 3093 this.ICON_TRANSFORM = this.PARTS.ICONS.appendChild(BX.create('A', { 3094 attrs: {href: 'javascript: void(0)'}, 3095 props: {className: 'bx-context-toolbar-switcher'}, 3096 events: { 3097 click: BX.delegate(this.__trf_btn_clicked, this) 3098 } 3099 })); 3100 } 3101 3102 if (this.PARAMS.HINT) 3103 { 3104 this.DIV.BXHINT = this.HINT = new BX.CHint({ 3105 parent: this.DIV, 3106 hint:this.PARAMS.HINT.TEXT || '', 3107 title: this.PARAMS.HINT.TITLE || '', 3108 hide_timeout: this.timeout/2, 3109 preventHide: false 3110 }); 3111 } 3112 3113 BX.addCustomEvent(this, 'onWindowDragFinished', BX.delegate(this.__onMoveFinished, this)); 3114 BX.addCustomEvent('onDynamicModeChange', BX.delegate(this.__onDynamicModeChange, this)); 3115 BX.addCustomEvent('onTopPanelCollapse', BX.delegate(this.__onPanelCollapse, this)); 3116 3117 BX.addCustomEvent('onMenuOpenerMoved', BX.delegate(this.checkPosition, this)); 3118 BX.addCustomEvent('onMenuOpenerUnhide', BX.delegate(this.checkPosition, this)); 3119 3120 if (this.OPENERS) 3121 { 3122 for (i=0,len=this.OPENERS.length; i<len; i++) 3123 { 3124 BX.addCustomEvent(this.OPENERS[i], 'onOpenerMenuOpen', BX.proxy(this.__hide_hint, this)); 3125 } 3126 } 3127}; 3128BX.extend(BX.CMenuOpener, BX.CWindowFloat); 3129 3130BX.CMenuOpener.prototype.setParent = function(new_parent) 3131{ 3132 new_parent = BX(new_parent); 3133 if(new_parent.OPENER && new_parent.OPENER != this) 3134 { 3135 new_parent.OPENER.Close(); 3136 new_parent.OPENER.clearHoverHoutEvents(); 3137 } 3138 3139 if(this.PARAMS.parent && this.PARAMS.parent != new_parent) 3140 { 3141 this.clearHoverHoutEvents(); 3142 this.PARAMS.parent.OPENER = null; 3143 } 3144 3145 this.PARAMS.parent = new_parent; 3146 this.PARAMS.parent.OPENER = this; 3147}; 3148 3149BX.CMenuOpener.prototype.setHoverHoutEvents = function(hover, hout) 3150{ 3151 if(!this.__opener_events_set) 3152 { 3153 BX.bind(this.Get(), 'mouseover', hover); 3154 BX.bind(this.Get(), 'mouseout', hout); 3155 this.__opener_events_set = true; 3156 } 3157}; 3158 3159BX.CMenuOpener.prototype.clearHoverHoutEvents = function() 3160{ 3161 if(this.Get()) 3162 { 3163 BX.unbindAll(this.Get()); 3164 this.__opener_events_set = false; 3165 } 3166}; 3167 3168 3169BX.CMenuOpener.prototype.unclosable = true; 3170 3171BX.CMenuOpener.prototype.__check_intersection = function(pos_self, pos_other) 3172{ 3173 return !(pos_other.right <= pos_self.left || pos_other.left >= pos_self.right 3174 || pos_other.bottom <= pos_self.top || pos_other.top >= pos_self.bottom); 3175}; 3176 3177 3178BX.CMenuOpener.prototype.__msover_text = function() { 3179 this.bx_hover = true; 3180 if (!this._menu_open) 3181 BX.addClass(this.ATTACH, 'bx-context-toolbar-button-text-hover'); 3182}; 3183 3184BX.CMenuOpener.prototype.__msout_text = function() { 3185 this.bx_hover = false; 3186 if (!this._menu_open) 3187 BX.removeClass(this.ATTACH, 'bx-context-toolbar-button-text-hover bx-context-toolbar-button-text-active'); 3188}; 3189 3190BX.CMenuOpener.prototype.__msover_arrow = function() { 3191 this.bx_hover = true; 3192 if (!this._menu_open) 3193 BX.addClass(this.ATTACH, 'bx-context-toolbar-button-arrow-hover'); 3194}; 3195 3196BX.CMenuOpener.prototype.__msout_arrow = function() { 3197 this.bx_hover = false; 3198 if (!this._menu_open) 3199 BX.removeClass(this.ATTACH, 'bx-context-toolbar-button-arrow-hover bx-context-toolbar-button-arrow-active'); 3200}; 3201 3202BX.CMenuOpener.prototype.__msdown_text = function() { 3203 this.bx_active = true; 3204 if (!this._menu_open) 3205 BX.addClass(this.ATTACH, 'bx-context-toolbar-button-text-active'); 3206}; 3207 3208BX.CMenuOpener.prototype.__msdown_arrow = function() { 3209 this.bx_active = true; 3210 if (!this._menu_open) 3211 BX.addClass(this.ATTACH, 'bx-context-toolbar-button-arrow-active'); 3212}; 3213 3214BX.CMenuOpener.prototype.__menu_close = function() { 3215 this._menu_open = false; 3216 this.bx_active = false; 3217 BX.removeClass(this.ATTACH, 'bx-context-toolbar-button-active bx-context-toolbar-button-text-active bx-context-toolbar-button-arrow-active'); 3218 if (!this.bx_hover) 3219 {
3220 BX.removeClass(this.ATTACH, 'bx-context-toolbar-button-hover bx-context-toolbar-button-text-hover bx-context-toolbar-button-arrow-hover'); 3221 this.bx_hover = false; 3222 } 3223}; 3224 3225BX.CMenuOpener.prototype.__menu_open = function() { 3226 this._menu_open = true; 3227}; 3228 3229BX.CMenuOpener.prototype.checkPosition = function() 3230{ 3231 if (this.isMenuVisible() || this.DIV.style.display == 'none' 3232 || this == BX.proxy_context || BX.proxy_context.zIndex > this.zIndex) 3233 return; 3234 3235 this.correctPosition(BX.proxy_context); 3236}; 3237 3238BX.CMenuOpener.prototype.correctPosition = function(opener) 3239{ 3240 var pos_self = BX.pos(this.DIV), pos_other = BX.pos(opener.Get()); 3241 if (this.__check_intersection(pos_self, pos_other)) 3242 { 3243 var new_top = pos_other.top - pos_self.height; 3244 if (new_top < 0) 3245 new_top = pos_other.bottom; 3246 3247 this.DIV.style.top = new_top + 'px'; 3248 3249 BX.addCustomEvent(opener, 'onMenuOpenerHide', BX.proxy(this.restorePosition, this)); 3250 BX.onCustomEvent(this, 'onMenuOpenerMoved'); 3251 } 3252}; 3253 3254BX.CMenuOpener.prototype.restorePosition = function() 3255{ 3256 if (!this.MOUSEOVER && !this.isMenuVisible()) 3257 { 3258 if (this.originalPos) 3259 this.DIV.style.top = this.originalPos.top + 'px'; 3260 3261 BX.removeCustomEvent(BX.proxy_context, 'onMenuOpenerHide', BX.proxy(this.restorePosition, this)); 3262 if (this.restore_pos_timeout) clearTimeout(this.restore_pos_timeout); 3263 } 3264 else 3265 { 3266 this.restore_pos_timeout = setTimeout(BX.proxy(this.restorePosition, this), this.timeout); 3267 } 3268}; 3269 3270 3271BX.CMenuOpener.prototype.Show = function() 3272{ 3273 BX.CMenuOpener.superclass.Show.apply(this, arguments); 3274 3275 this.SetDraggable(this.PARTS.INNER.firstChild); 3276 3277 this.DIV.style.width = 'auto'; 3278 this.DIV.style.height = 'auto'; 3279 3280 if (!this.PARAMS.pin) 3281 { 3282 this.DIV.style.left = '-1000px'; 3283 this.DIV.style.top = '-1000px'; 3284 3285 this.Hide(); 3286 } 3287 else 3288 { 3289 this.bPosAdjusted = true; 3290 this.bMoved = true; 3291 3292 if (this.PARAMS.top) this.DIV.style.top = this.PARAMS.top + 'px'; 3293 if (this.PARAMS.left) this.DIV.style.left = this.PARAMS.left + 'px'; 3294 3295 this.DIV.style.display = (!BX.admin.dynamic_mode || BX.admin.dynamic_mode_show_borders) ? 'block' : 'none'; 3296 3297 if (this.DIV.style.display == 'block') 3298 { 3299 setTimeout(BX.delegate(function() {BX.onCustomEvent(this, 'onMenuOpenerUnhide')}, this), 50); 3300 } 3301 } 3302}; 3303 3304BX.CMenuOpener.prototype.executeDefaultAction = function() 3305{ 3306 if (this.defaultAction) 3307 { 3308 if (BX.type.isFunction(this.defaultAction)) 3309 this.defaultAction(); 3310 else if(BX.type.isString(this.defaultAction)) 3311 BX.evalGlobal(this.defaultAction); 3312 } 3313}; 3314 3315BX.CMenuOpener.prototype.__onDynamicModeChange = function(val) 3316{ 3317 this.DIV.style.display = val ? 'block' : 'none'; 3318}; 3319 3320BX.CMenuOpener.prototype.__onPanelCollapse = function(bCollapsed, dy) 3321{ 3322 this.DIV.style.top = (parseInt(this.DIV.style.top) + dy) + 'px'; 3323 if (this.PARAMS.pin) 3324 { 3325 this.__savePosition(); 3326 } 3327}; 3328 3329BX.CMenuOpener.prototype.__onMoveFinished = function() 3330{ 3331 BX.onCustomEvent(this, 'onMenuOpenerMoved'); 3332 3333 this.bMoved = true; 3334 3335 if (this.PARAMS.pin) 3336 this.__savePosition(); 3337}; 3338 3339BX.CMenuOpener.prototype.__savePosition = function() 3340{ 3341 var arOpts = {}; 3342 3343 arOpts.pin = this.PARAMS.pin; 3344 if (!this.PARAMS.pin) 3345 { 3346 arOpts.top = false; arOpts.left = false; arOpts.transform = false; 3347 } 3348 else 3349 { 3350 arOpts.transform = this.PARAMS.transform; 3351 if (this.bMoved) 3352 { 3353 arOpts.left = parseInt(this.DIV.style.left); 3354 arOpts.top = parseInt(this.DIV.style.top); 3355 } 3356 } 3357 3358 BX.WindowManager.saveWindowOptions(this.PARAMS.component_id, arOpts); 3359}; 3360 3361BX.CMenuOpener.prototype.__pin_btn_clicked = function() {this.Pin()}; 3362BX.CMenuOpener.prototype.Pin = function(val) 3363{ 3364 if (null == val) 3365 this.PARAMS.pin = !this.PARAMS.pin; 3366 else 3367 this.PARAMS.pin = !!val; 3368 3369 this.PARTS.ICON_PIN.className = (this.PARAMS.pin ? 'bx-context-toolbar-pin-fixed' : 'bx-context-toolbar-pin'); 3370 3371 this.__savePosition(); 3372}; 3373 3374BX.CMenuOpener.prototype.__trf_btn_clicked = function() {this.Transform()}; 3375BX.CMenuOpener.prototype.Transform = function(val) 3376{ 3377 var pos = {}; 3378 3379 if (null == val) 3380 this.PARAMS.transform = !this.PARAMS.transform; 3381 else 3382 this.PARAMS.transform = !!val; 3383 3384 if (this.bMoved) 3385 { 3386 pos = BX.pos(this.DIV); 3387 } 3388 3389 if (this.PARAMS.transform) 3390 BX.addClass(this.DIV.firstChild, 'bx-context-toolbar-vertical-mode'); 3391 else 3392 BX.removeClass(this.DIV.firstChild, 'bx-context-toolbar-vertical-mode'); 3393 3394 if (!this.bMoved) 3395 { 3396 this.adjustPos(); 3397 } 3398 else 3399 { 3400 this.DIV.style.left = (pos.right - this.DIV.offsetWidth - (BX.browser.IsIE() && !BX.browser.IsDoctype() ? 2 : 0)) + 'px'; 3401 } 3402 3403 this.__savePosition(); 3404}; 3405 3406BX.CMenuOpener.prototype.adjustToNodeGetPos = function() 3407{ 3408 var pos = BX.pos(this.PARAMS.parent/*, true*/); 3409 3410 var scrollSize = BX.GetWindowScrollSize(); 3411 var floatWidth = this.DIV.offsetWidth; 3412 3413 pos.left -= BX.admin.__border_dx; 3414 pos.top -= BX.admin.__border_dx; 3415 3416 if (true || !this.PARAMS.transform) 3417 { 3418 pos.top -= 45; 3419 } 3420 3421 if (pos.left > scrollSize.scrollWidth - floatWidth) 3422 { 3423 pos.left = scrollSize.scrollWidth - floatWidth; 3424 } 3425 3426 return pos; 3427}; 3428 3429BX.CMenuOpener.prototype.addItem = function(item) 3430{ 3431 if (item.TYPE) 3432 { 3433 this.EXTRA_BUTTONS[item.TYPE] = item; 3434 return null; 3435 } 3436 else 3437 { 3438 var q = new BX.CMenuOpenerItem(item); 3439 if (null == this.defaultAction) 3440 { 3441 if (q.item.ONCLICK) 3442 { 3443 this.defaultAction = item.ONCLICK; 3444 } 3445 else if (q.item.MENU) 3446 { 3447 this.defaultAction = BX.delegate(function() {this.Open()}, q.item.OPENER); 3448 } 3449 3450 this.defaultActionTitle = item.TITLE || item.TEXT; 3451 3452 BX.addClass(q.Get(), 'bx-content-toolbar-default'); 3453 } 3454 if (q.item.OPENER) this.OPENERS[this.OPENERS.length] = q.item.OPENER; 3455 return q.Get(); 3456 } 3457}; 3458 3459BX.CMenuOpener.prototype.attachMenu = function(menu) 3460{ 3461 var opener = new BX.COpener({ 3462 'DIV': this.OPENER,
3463 'ATTACH': this.ATTACH, 3464 'MENU': menu, 3465 'TYPE': 'click' 3466 }); 3467 3468 this.OPENERS[this.OPENERS.length] = opener; 3469 3470 return opener; 3471}; 3472 3473BX.CMenuOpener.prototype.__hide_hint = function() 3474{ 3475 if (this.HINT) this.HINT.__hide_immediately(); 3476}; 3477 3478BX.CMenuOpener.prototype.isMenuVisible = function() 3479{ 3480 for (var i=0,len=this.OPENERS.length; i<len; i++) 3481 { 3482 if (this.OPENERS[i].isMenuVisible()) 3483 return true; 3484 } 3485 3486 return false; 3487}; 3488 3489BX.CMenuOpener.prototype.Hide = function() 3490{ 3491 if (!this.PARAMS.pin) 3492 { 3493 this.DIV.style.display = 'none'; 3494 BX.onCustomEvent(this, 'onMenuOpenerHide'); 3495 } 3496}; 3497BX.CMenuOpener.prototype.UnHide = function() 3498{ 3499 this.DIV.style.display = 'block'; 3500 if (!this.bPosAdjusted && !this.PARAMS.pin) 3501 { 3502 this.adjustPos(); 3503 this.bPosAdjusted = true; 3504 } 3505 3506 if (null == this.originalPos && !this.bMoved) 3507 { 3508 this.originalPos = BX.pos(this.DIV); 3509 } 3510 3511 BX.onCustomEvent(this, 'onMenuOpenerUnhide'); 3512}; 3513 3514BX.CMenuOpenerItem = function(item) 3515{ 3516 this.item = item; 3517 3518 if (this.item.ACTION && !this.item.ONCLICK) 3519 { 3520 this.item.ONCLICK = this.item.ACTION; 3521 } 3522 3523 this.DIV = BX.create('SPAN'); 3524 this.DIV.appendChild(BX.create('SPAN', {props: {className: 'bx-context-toolbar-button-underlay'}})); 3525 3526 this.WRAPPER = this.DIV.appendChild(BX.create('SPAN', { 3527 props: {className: 'bx-context-toolbar-button-wrapper'}, 3528 children: [ 3529 BX.create('SPAN', { 3530 props: {className: 'bx-context-toolbar-button', title: item.TITLE}, 3531 children: [ 3532 BX.create('SPAN', { 3533 props: {className: 'bx-context-toolbar-button-inner'} 3534 }) 3535 ] 3536 }) 3537 ] 3538 })); 3539 3540 var btn_icon = BX.create('SPAN', { 3541 props: {className: 'bx-context-toolbar-button-icon' + (this.item.ICON || this.item.ICONCLASS ? ' ' + (this.item.ICON || this.item.ICONCLASS) : '')}, 3542 attrs: ( 3543 !(this.item.ICON || this.item.ICONCLASS) 3544 && 3545 (this.item.SRC || this.item.IMAGE) 3546 ) 3547 ? { 3548 style: 'background: scroll transparent url(' + (this.item.SRC || this.item.IMAGE) + ') no-repeat center center !important;' 3549 } 3550 : {} 3551 }), btn_text = BX.create('SPAN', { 3552 props: {className: 'bx-context-toolbar-button-text'}, 3553 text: this.item.TEXT 3554 }); 3555 3556 if (this.item.ACTION && !this.item.ONCLICK) 3557 { 3558 this.item.ONCLICK = this.item.ACTION; 3559 } 3560 3561 this.bHasMenu = !!this.item.MENU; 3562 this.bHasAction = !!this.item.ONCLICK; 3563 3564 if (this.bHasAction) 3565 { 3566 this.LINK = this.WRAPPER.firstChild.firstChild.appendChild(BX.create('A', { 3567 attrs: { 3568 'href': 'javascript: void(0)' 3569 }, 3570 events: { 3571 mouseover: this.bHasMenu ? BX.proxy(this.__msover_text, this) : BX.proxy(this.__msover, this), 3572 mouseout: this.bHasMenu ? BX.proxy(this.__msout_text, this) : BX.proxy(this.__msout, this), 3573 mousedown: this.bHasMenu ? BX.proxy(this.__msdown_text, this) : BX.proxy(this.__msdown, this) 3574 }, 3575 children: [btn_icon, btn_text] 3576 })); 3577 3578 if (this.bHasMenu) 3579 { 3580 this.LINK_MENU = this.WRAPPER.firstChild.firstChild.appendChild(BX.create('A', { 3581 props: {className: 'bx-context-toolbar-button-arrow'}, 3582 attrs: { 3583 'href': 'javascript: void(0)' 3584 }, 3585 events: { 3586 mouseover: BX.proxy(this.__msover_arrow, this), 3587 mouseout: BX.proxy(this.__msout_arrow, this), 3588 mousedown: BX.proxy(this.__msdown_arrow, this) 3589 }, 3590 children: [ 3591 BX.create('SPAN', {props: {className: 'bx-context-toolbar-button-arrow'}}) 3592 ] 3593 })); 3594 } 3595 3596 } 3597 else if (this.bHasMenu) 3598 { 3599 this.item.ONCLICK = null; 3600 3601 this.LINK = this.LINK_MENU = this.WRAPPER.firstChild.firstChild.appendChild(BX.create('A', { 3602 attrs: { 3603 'href': 'javascript: void(0)' 3604 }, 3605 events: { 3606 mouseover: BX.proxy(this.__msover, this), 3607 mouseout: BX.proxy(this.__msout, this), 3608 mousedown: BX.proxy(this.__msdown, this) 3609 }, 3610 children: [ 3611 btn_icon, 3612 btn_text 3613 ] 3614 })); 3615 3616 this.LINK.appendChild(BX.create('SPAN', {props: {className: 'bx-context-toolbar-single-button-arrow'}})); 3617 3618 } 3619 3620 if (this.bHasMenu) 3621 { 3622 this.item.SUBMENU = new BX.CMenu({ 3623 ATTACH_MODE:'bottom', 3624 ITEMS:this.item['MENU'], 3625 //PARENT_MENU:this.parentMenu, 3626 parent: this.LINK_MENU, 3627 parent_attach: this.WRAPPER.firstChild 3628 }); 3629 3630 this.item.OPENER = new BX.COpener({ 3631 DIV: this.LINK_MENU, 3632 TYPE: 'click', 3633 MENU: this.item.SUBMENU 3634 }); 3635 3636 BX.addCustomEvent(this.item.OPENER, 'onOpenerMenuOpen', BX.proxy(this.__menu_open, this)); 3637 BX.addCustomEvent(this.item.OPENER, 'onOpenerMenuClose', BX.proxy(this.__menu_close, this)); 3638 } 3639 3640 if (this.bHasAction) 3641 { 3642 BX.bind(this.LINK, 'click', BX.delegate(this.__click, this)); 3643 } 3644}; 3645 3646BX.CMenuOpenerItem.prototype.Get = function() {return this.DIV;}; 3647BX.CMenuOpenerItem.prototype.__msover = function() { 3648 this.bx_hover = true; 3649 if (!this._menu_open) 3650 BX.addClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-hover'); 3651}; 3652BX.CMenuOpenerItem.prototype.__msout = function() { 3653 this.bx_hover = false;
3654 if (!this._menu_open) 3655 BX.removeClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-hover bx-context-toolbar-button-active'); 3656}; 3657BX.CMenuOpenerItem.prototype.__msover_text = function() { 3658 this.bx_hover = true; 3659 if (!this._menu_open) 3660 BX.addClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-text-hover'); 3661}; 3662BX.CMenuOpenerItem.prototype.__msout_text = function() { 3663 this.bx_hover = false; 3664 if (!this._menu_open) 3665 BX.removeClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-text-hover bx-context-toolbar-button-text-active'); 3666}; 3667BX.CMenuOpenerItem.prototype.__msover_arrow = function() { 3668 this.bx_hover = true; 3669 if (!this._menu_open) 3670 BX.addClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-arrow-hover'); 3671}; 3672BX.CMenuOpenerItem.prototype.__msout_arrow = function() { 3673 this.bx_hover = false; 3674 if (!this._menu_open) 3675 BX.removeClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-arrow-hover bx-context-toolbar-button-arrow-active'); 3676}; 3677BX.CMenuOpenerItem.prototype.__msdown = function() { 3678 this.bx_active = true; 3679 if (!this._menu_open) 3680 BX.addClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-active'); 3681}; 3682BX.CMenuOpenerItem.prototype.__msdown_text = function() { 3683 this.bx_active = true; 3684 if (!this._menu_open) 3685 BX.addClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-text-active'); 3686}; 3687BX.CMenuOpenerItem.prototype.__msdown_arrow = function() { 3688 this.bx_active = true; 3689 if (!this._menu_open) 3690 BX.addClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-arrow-active'); 3691}; 3692BX.CMenuOpenerItem.prototype.__menu_close = function() { 3693 3694 this._menu_open = false; 3695 this.bx_active = false; 3696 BX.removeClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-active bx-context-toolbar-button-text-active bx-context-toolbar-button-arrow-active'); 3697 if (!this.bx_hover) 3698 { 3699 BX.removeClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-hover bx-context-toolbar-button-text-hover bx-context-toolbar-button-arrow-hover'); 3700 this.bx_hover = false; 3701 } 3702}; 3703BX.CMenuOpenerItem.prototype.__menu_open = function() { 3704 this._menu_open = true; 3705}; 3706 3707BX.CMenuOpenerItem.prototype.__click = function() {BX.evalGlobal(this.item.ONCLICK)}; 3708 3709/* global page opener class */ 3710BX.CPageOpener = function(arParams) 3711{ 3712 //if (null == arParams.pin) arParams.pin = true; 3713 BX.CPageOpener.superclass.constructor.apply(this, arguments); 3714 3715 this.timeout = 505; 3716 3717 window.PAGE_EDIT_CONTROL = this; 3718}; 3719BX.extend(BX.CPageOpener, BX.CMenuOpener); 3720 3721BX.CPageOpener.prototype.checkPosition = function() 3722{ 3723 if (/*this.isMenuVisible() || this.DIV.style.display == 'none' || */this == BX.proxy_context) 3724 return; 3725 3726 this.correctPosition(BX.proxy_context); 3727}; 3728 3729BX.CPageOpener.prototype.correctPosition = function(opener) 3730{ 3731 if (this.bPosCorrected) return; 3732 var pos_self; 3733 if (this.DIV.style.display == 'none') 3734 { 3735 pos_self = this.adjustToNodeGetPos(); 3736 pos_self.bottom = pos_self.top + 30; 3737 pos_self.right = pos_self.left + 300; 3738 } 3739 else 3740 { 3741 pos_self = BX.pos(this.DIV); 3742 } 3743 3744 var pos_other = BX.pos(opener.Get()); 3745 if (this.__check_intersection(pos_self, pos_other)) 3746 { 3747 this.DIV.style.display = 'none'; 3748 BX.addCustomEvent(opener, 'onMenuOpenerHide', BX.proxy(this.restorePosition, this)); 3749 3750 this.bPosCorrected = true; 3751 } 3752}; 3753 3754BX.CPageOpener.prototype.restorePosition = function() 3755{ 3756 if (BX.proxy_context && BX.proxy_context.Get().style.display == 'none') 3757 { 3758 this.bPosCorrected = false; 3759 3760 if (this.PARAMS.parent.bx_over || this.PARAMS.pin) 3761 this.UnHide(); 3762 3763 BX.removeCustomEvent('onMenuOpenerHide', BX.proxy(this.restorePosition, this)); 3764 } 3765}; 3766 3767BX.CPageOpener.prototype.UnHide = function() 3768{ 3769 if (!this.bPosCorrected) 3770 BX.CPageOpener.superclass.UnHide.apply(this, arguments); 3771}; 3772 3773BX.CPageOpener.prototype.Remove = function() 3774{ 3775 BX.admin.removeComponentBorder(this.PARAMS.parent); 3776 BX.userOptions.save('global', 'settings', 'page_edit_control_enable', 'N'); 3777 this.DIV.style.display = 'none'; 3778}; 3779 3780/******* HINT ***************/ 3781BX.CHintSimple = function() 3782{ 3783 BX.CHintSimple.superclass.constructor.apply(this, arguments); 3784}; 3785BX.extend(BX.CHintSimple, BX.CHint); 3786 3787BX.CHintSimple.prototype.Init = function() 3788{ 3789 this.DIV = document.body.appendChild(BX.create('DIV', {props: {className: 'bx-tooltip-simple'}, style: {display: 'none'}, children: [(this.CONTENT = BX.create('DIV'))]})); 3790 3791 if (this.HINT_TITLE) 3792 this.CONTENT.appendChild(BX.create('B', {text: this.HINT_TITLE})); 3793 3794 if (this.HINT) 3795 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV')).appendChild(BX.create('SPAN', {html: this.HINT})); 3796 3797 if (this.PARAMS.preventHide) 3798 { 3799 BX.bind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 3800 BX.bind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 3801 } 3802 3803 this.bInited = true; 3804}; 3805 3806/*************************** admin informer **********************************/ 3807BX.adminInformer = { 3808 3809 itemsShow: 3, 3810 3811 Init: function (itemsShow) 3812 { 3813 if(itemsShow) 3814 BX.adminInformer.itemsShow = itemsShow; 3815 3816 var informer = BX("admin-informer"); 3817 3818 if(informer) 3819 document.body.appendChild(informer); 3820 3821 BX.addCustomEvent("onTopPanelCollapse", BX.proxy(BX.adminInformer.Close, BX.adminInformer)); 3822 }, 3823 3824 Toggle: function(notifyBlock) 3825 { 3826 var informer = BX("admin-informer"); 3827 3828 if(!informer) 3829 return false;
3830 3831 var pos = BX.pos(notifyBlock); 3832 3833 informer.style.top = (parseInt(pos.top)+parseInt(pos.height)+7)+'px'; 3834 informer.style.left = pos.left+'px'; 3835 3836 if(!BX.hasClass(informer, "adm-informer-active")) 3837 BX.adminInformer.Show(informer); 3838 else 3839 BX.adminInformer.Hide(informer); 3840 3841 return false; 3842 }, 3843 3844 Close: function() 3845 { 3846 BX.adminInformer.Hide(BX("admin-informer")); 3847 }, 3848 3849 OnInnerClick: function(event) 3850 { 3851 var target = event.target || event.srcElement; 3852 3853 if(target.nodeName.toLowerCase() != 'a' || BX.hasClass(target,"adm-informer-footer")) 3854 { 3855 return BX.PreventDefault(event); 3856 } 3857 3858 return true; 3859 }, 3860 3861 ToggleExtra : function() 3862 { 3863 var footerLink = BX("adm-informer-footer"); 3864 3865 if (BX.hasClass(footerLink, "adm-informer-footer-collapsed")) 3866 this.ShowAll(); 3867 else 3868 this.HideExtra(); 3869 3870 return false; 3871 }, 3872 3873 ShowAll: function() 3874 { 3875 var informer = BX("admin-informer"); 3876 for(var i=0; i<informer.children.length; i++) 3877 3878 if(BX.hasClass(informer.children[i], "adm-informer-item") && informer.children[i].style.display == "none") { 3879 informer.children[i].style.display = "block"; 3880 } 3881 3882 var footerLink = BX("adm-informer-footer"); 3883 3884 if(footerLink.textContent !== undefined) 3885 footerLink.textContent = BX.message('JSADM_AI_HIDE_EXTRA'); 3886 else 3887 footerLink.innerText = BX.message('JSADM_AI_HIDE_EXTRA'); 3888 3889 BX.removeClass(footerLink, "adm-informer-footer-collapsed"); 3890 3891 return false; 3892 }, 3893 3894 HideExtra: function() 3895 { 3896 var informer = BX("admin-informer"); 3897 var hided = 0; 3898 3899 for(var i=BX.adminInformer.itemsShow+1; i<informer.children.length; i++) 3900 { 3901 if (BX.hasClass(informer.children[i], "adm-informer-item") && informer.children[i].style.display == "block") { 3902 informer.children[i].style.display = "none"; 3903 hided++; 3904 } 3905 } 3906 3907 var footerLink = BX("adm-informer-footer"); 3908 3909 var linkText = BX.message('JSADM_AI_ALL_NOTIF')+" ("+(BX.adminInformer.itemsShow+parseInt(hided))+")"; 3910 3911 if(footerLink.textContent !== undefined) 3912 footerLink.textContent = linkText; 3913 else 3914 footerLink.innerText = linkText; 3915 3916 BX.addClass(footerLink, "adm-informer-footer-collapsed"); 3917 3918 return false; 3919 }, 3920 3921 Show: function(informer) 3922 { 3923 var notifButton = BX("adm-header-notif-block"); 3924 if (notifButton) 3925 BX.addClass(notifButton, "adm-header-notif-block-active"); 3926 3927 BX.onCustomEvent(informer, 'onBeforeAdminInformerShow'); 3928 setTimeout( 3929 BX.proxy(function() { 3930 BX.bind(document, "click", BX.proxy(BX.adminInformer.Close, BX.adminInformer)); 3931 }, 3932 BX.adminInformer 3933 ),0 3934 ); 3935 BX.addClass(informer, "adm-informer-active"); 3936 setTimeout(function() {BX.addClass(informer, "adm-informer-animate");},0); 3937 }, 3938 3939 Hide: function(informer) 3940 { 3941 var notifButton = BX("adm-header-notif-block"); 3942 if (notifButton) 3943 BX.removeClass(notifButton, "adm-header-notif-block-active"); 3944 3945 BX.unbind(document, "click", BX.proxy(BX.adminInformer.Close, BX.adminInformer)); 3946 3947 BX.removeClass(informer, "adm-informer-animate"); 3948 3949 if (this.IsAnimationSupported()) 3950 setTimeout(function() {BX.removeClass(informer, "adm-informer-active");}, 300); 3951 else 3952 BX.removeClass(informer, "adm-informer-active"); 3953 3954 BX.onCustomEvent(informer, 'onAdminInformerHide'); 3955 //setTimeout(function() {BX.adminInformer.HideExtra();},500); 3956 }, 3957 3958 IsAnimationSupported : function() 3959 { 3960 var d = document.body || document.documentElement; 3961 if (typeof(d.style.transition) == "string") 3962 return true; 3963 else if (typeof(d.style.MozTransition) == "string") 3964 return true; 3965 else if (typeof(d.style.OTransition) == "string") 3966 return true; 3967 else if (typeof(d.style.WebkitTransition) == "string") 3968 return true; 3969 else if (typeof(d.style.msTransition) == "string") 3970 return true; 3971 3972 return false; 3973 }, 3974 3975 3976 SetItemHtml: function(itemIdx, html) 3977 { 3978 var itemHtmlDiv = BX("adm-informer-item-html-"+itemIdx); 3979 3980 if(!itemHtmlDiv) 3981 return false; 3982 3983 itemHtmlDiv.innerHTML = html; 3984 3985 return true; 3986 }, 3987 3988 SetItemFooter: function(itemIdx, html) 3989 { 3990 var itemFooterDiv = BX("adm-informer-item-footer-"+itemIdx); 3991 3992 if(!itemFooterDiv) 3993 return false; 3994 3995 itemFooterDiv.innerHTML = html; 3996 3997 if(html) 3998 itemFooterDiv.style.display = "block"; 3999 else 4000 itemFooterDiv.style.display = "none"; 4001 4002 return true; 4003 } 4004 4005}; 4006 4007}
4007)(window); 4008
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.