1; /* /bitrix/js/main/dd.js?170892849414809*/ 2; /* /bitrix/js/main/core/core_uf.js?177728766318794*/ 3; /* /bitrix/js/main/core/core_dd.js?17772876633614*/ 4; /* /bitrix/js/main/core/core_tooltip.js?177728766315635*/ 5; /* /bitrix/js/main/date/main.date.js?174834456662683*/ 6; /* /bitrix/js/main/core/core_date.js?177728766336251*/ 7; /* /bitrix/js/main/utils.js?161786687629279*/ 8; /* /bitrix/js/main/session.js?16424293153701*/ 9; /* /bitrix/js/main/core/core_window.js?177728766398767*/ 10 11; /* Start:"a:4:{s:4:"full";s:41:"/bitrix/js/main/session.js?16424293153701";s:6:"source";s:26:"/bitrix/js/main/session.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 12function CBXSession() 13{ 14 var _this = this; 15 this.dateInput = new Date(); 16 this.dateCheck = new Date(); 17 this.dateHit = new Date(); 18 this.notifier = null; 19 this.checkInterval = 60; 20 this.checkImmediately = false; 21 22 this.Expand = function(key) 23 { 24 this.key = key; 25 26 BX.ready(function(){ 27 BX.bind(document, "keypress", _this.OnUserInput); 28 BX.bind(document.body, "mousemove", _this.OnUserInput); 29 BX.bind(document.body, "click", _this.OnUserInput); 30 31 //check the state once in a minute 32 setInterval(_this.CheckSession, _this.checkInterval*1000); 33 }) 34 }; 35 36 this.OnUserInput = function() 37 { 38 var currentDate = new Date(); 39 _this.dateInput.setTime(currentDate.valueOf()); 40 41 if ((currentDate - _this.dateHit)/1000 > (_this.checkInterval + 5) && _this.checkImmediately === false) 42 { 43 // last hit was long time ago, need to recheck immediately 44 _this.checkImmediately = true; 45 _this.CheckSession(); 46 } 47 }; 48 49 this.CheckSession = function() 50 { 51 var currentDate = new Date(); 52 53 if((currentDate - _this.dateCheck)/1000 < (_this.checkInterval - 1) && _this.checkImmediately === false) 54 { 55 //storm protection, e.g. after PC wake-up 56 return; 57 } 58 59 _this.dateCheck.setTime(currentDate.valueOf()); 60 61 if(_this.dateInput > _this.dateHit) 62 { 63 //there was input after the last hit, expand/check the session 64 var config = { 65 'method': 'GET', 66 'headers': [ 67 {'name': 'X-Bitrix-Csrf-Token', 'value': BX.bitrix_sessid()} 68 ], 69 'dataType': 'html', 70 'url': '/bitrix/tools/public_session.php?k='+_this.key, 71 'data': '', 72 'onsuccess': function(data){_this.CheckResult(data)}, 73 'lsId': 'sess_expand', //caching the result in the local storage for multiple tabs 74 'lsTimeout': _this.checkInterval - 5 //some delta for response time 75 }; 76 BX.ajax(config); 77 } 78 }; 79 80 this.CheckResult = function(data) 81 { 82 var currentDate = new Date(); 83 _this.dateHit.setTime(currentDate.valueOf()); 84 _this.checkImmediately = false; 85 86 if(data == 'SESSION_EXPIRED') 87 { 88 if(BX.message("SessExpired")) 89 { 90 if(!_this.notifier) 91 { 92 _this.notifier = document.body.appendChild(BX.create('DIV', { 93 props: {className: 'bx-session-message'}, 94 style: { 95 top: '0', 96 backgroundColor: '#FFEB41', 97 border: '1px solid #EDDA3C', 98 width: '630px', 99 fontFamily: 'Arial,Helvetica,sans-serif', 100 fontSize: '13px', 101 fontWeight: 'bold', 102 textAlign: 'center', 103 color: 'black', 104 position: 'absolute', 105 zIndex: '10000', 106 padding: '10px' 107 }, 108 html: '<a class="bx-session-message-close" ' + 109 'style="display:block; width:12px; height:12px; background:url(/bitrix/js/main/core/images/close.gif) center no-repeat; float:right;" ' + 110 'href="javascript:bxSession.Close()"></a>' + 111 BX.message("SessExpired") 112 })); 113 114 BX.ZIndexManager.register(_this.notifier); 115 BX.ZIndexManager.bringToFront(_this.notifier); 116 117 var windowScroll = BX.GetWindowScrollPos(); 118 var windowSize = BX.GetWindowInnerSize(); 119 120 _this.notifier.style.left = parseInt(windowScroll.scrollLeft + (windowSize.innerWidth / 2) - (parseInt(_this.notifier.clientWidth) / 2)) + 'px'; 121 122 if(BX.browser.IsIE()) 123 { 124 _this.notifier.style.top = windowScroll.scrollTop + 'px'; 125 126 BX.bind(window, 'scroll', function() 127 { 128 var windowScroll = BX.GetWindowScrollPos(); 129 _this.notifier.style.top = windowScroll.scrollTop + 'px'; 130 }); 131 } 132 else 133 { 134 _this.notifier.style.position='fixed'; 135 } 136 } 137 138 _this.notifier.style.display = ''; 139 } 140 } 141 }; 142 143 this.Close = function() 144 { 145 this.notifier.style.display = 'none'; 146 } 147} 148 149var bxSession = new CBXSession(); 150 151/* End */ 152; 153; /* Start:"a:4:{s:4:"full";
153s:51:"/bitrix/js/main/core/core_window.js?177728766398767";s:6:"source";s:35:"/bitrix/js/main/core/core_window.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 154;(function(window) { 155if (BX.WindowManager) return; 156 157/* windows manager */ 158BX.WindowManager = { 159 _stack: [], 160 _runtime_resize: {}, 161 _delta: 2, 162 _delta_start: 1000, 163 currently_loaded: null, 164 165 settings_category: 'BX.WindowManager.9.5', 166 167 register: function (w) 168 { 169 this.currently_loaded = null; 170 171 w.WM_REG_INDEX = this._stack.length; 172 this._stack.push(w); 173 174 if (this._stack.length < 2) 175 { 176 BX.bind(document, 'keyup', BX.proxy(this.__checkKeyPress, this)); 177 } 178 }, 179 180 unregister: function (w) 181 { 182 if (null == w.WM_REG_INDEX) 183 return null; 184 185 var _current; 186 if (this._stack.length > 0) 187 { 188 while ((_current = this.__pop_stack()) != w) 189 { 190 if (!_current) 191 { 192 _current = null; 193 break; 194 } 195 } 196 197 if (this._stack.length <= 0) 198 { 199 this.enableKeyCheck(); 200 } 201 202 return _current; 203 } 204 else 205 { 206 return null; 207 } 208 }, 209 210 __pop_stack: function(clean) 211 { 212 if (this._stack.length > 0) 213 { 214 var _current = this._stack.pop(); 215 _current.WM_REG_INDEX = null; 216 BX.onCustomEvent(_current, 'onWindowUnRegister', [clean === true]); 217 218 return _current; 219 } 220 else 221 return null; 222 }, 223 224 clean: function() 225 { 226 while (this.__pop_stack(true)){} 227 this._stack = []; 228 this.disableKeyCheck(); 229 }, 230 231 Get: function() 232 { 233 if (this.currently_loaded) 234 return this.currently_loaded; 235 else if (this._stack.length > 0) 236 return this._stack[this._stack.length-1]; 237 else 238 return null; 239 }, 240 241 setStartZIndex: function(value) 242 { 243 this._delta_start = value; 244 }, 245 246 restoreStartZIndex: function() 247 { 248 this._delta_start = 1000; 249 }, 250 251 GetZIndex: function() 252 { 253 var _current; 254 return (null != (_current = this._stack[this._stack.length-1]) 255 ? parseInt(_current.Get().style.zIndex) + this._delta 256 : this._delta_start 257 ); 258 }, 259 260 __get_check_url: function(url) 261 { 262 var pos = url.indexOf('?'); 263 return pos == -1 ? url : url.substring(0, pos); 264 }, 265 266 saveWindowSize: function(url, params) 267 { 268 var check_url = this.__get_check_url(url); 269 if (BX.userOptions) 270 { 271 BX.userOptions.save(this.settings_category, 'size_' + check_url, 'width', params.width); 272 BX.userOptions.save(this.settings_category, 'size_' + check_url, 'height', params.height); 273 } 274 275 this._runtime_resize[check_url] = params; 276 }, 277 278 saveWindowOptions: function(wnd_id, opts) 279 { 280 if (BX.userOptions) 281 { 282 for (var i in opts) 283 { 284 if(opts.hasOwnProperty(i)) 285 { 286 BX.userOptions.save(this.settings_category, 'options_' + wnd_id, i, opts[i]); 287 } 288 } 289 } 290 }, 291 292 getRuntimeWindowSize: function(url) 293 { 294 return this._runtime_resize[this.__get_check_url(url)]; 295 }, 296 297 disableKeyCheck: function() 298 { 299 BX.unbind(document, 'keyup', BX.proxy(this.__checkKeyPress, this)); 300 }, 301 302 enableKeyCheck: function() 303 { 304 BX.bind(document, 'keyup', BX.proxy(this.__checkKeyPress, this)); 305 }, 306 307 __checkKeyPress: function(e) 308 { 309 if (null == e) 310 e = window.event; 311 312 if (e.keyCode == 27) 313 { 314 var wnd = BX.WindowManager.Get(); 315 if (wnd && !wnd.unclosable) wnd.Close(); 316 } 317 } 318}; 319 320BX.garbage(BX.WindowManager.clean, BX.WindowManager); 321 322/* base button class */ 323BX.CWindowButton = function(params) 324{ 325 if (params.btn) 326 { 327 this.btn = params.btn; 328 this.parentWindow = params.parentWindow; 329 330 if (/save|apply/i.test(this.btn.name)) 331 { 332 BX.bind(this.btn, 'click', BX.delegate(this.disableUntilError, this)); 333 } 334 } 335 else 336 { 337 this.title = params.title; // html value attr 338 this.hint = params.hint; // html title attr 339 this.id = params.id; // html name and id attrs 340 this.name = params.name; // html name or value attrs when id and title 're absent 341 this.className = params.className; // className for button input 342 343 this.action = params.action; 344 this.onclick = params.onclick; 345 346 // you can override button creation method 347 if (params.Button && BX.type.isFunction(params.Button)) 348 this.Button = params.Button; 349 350 this.btn = null; 351 } 352}; 353 354BX.CWindowButton.prototype.disable = function() 355{ 356 if (this.btn) 357 this.parentWindow.showWait(this.btn); 358}; 359BX.CWindowButton.prototype.enable = function(){ 360 if (this.btn) 361 this.parentWindow.closeWait(this.btn); 362}; 363 364BX.CWindowButton.prototype.emulate = function() 365{ 366 if (this.btn && this.btn.disabled) 367 return; 368 369 var act = 370 this.action 371 ? BX.delegate(this.action, this) 372 : ( 373 this.onclick 374 ? this.onclick 375 : ( 376 this.btn 377 ? this.btn.getAttribute('onclick') 378 : '' 379 ) 380 ); 381 382 if (act) 383 { 384 setTimeout(act, 50); 385 if (this.btn && /save|apply/i.test(this.btn.name) && !this.action) 386 { 387 this.disableUntilError(); 388 } 389 } 390}; 391 392BX.CWindowButton.prototype.Button = function(parentWindow) 393{ 394 this.parentWindow = parentWindow; 395 396 var btn = { 397 props: { 398 'type': 'button', 399 'name': this.id ? this.id : this.name, 400 'value': this.title ? this.title : this.name, 401 'id': this.id 402 } 403 }; 404 405 if (this.hint) 406 btn.props.title = this.hint; 407 if (!!this.className) 408 btn.props.className = this.className; 409 410 if (this.action) 411 { 412 btn.events = { 413 'click': BX.delegate(this.action, this) 414 }; 415 } 416 else if (this.onclick) 417 { 418 if (BX.browser.IsIE()) 419 { 420 btn.events = { 421 'click': BX.delegate(function() {eval(this.onclick)}, this) 422 }; 423 } 424 else 425 { 426 btn.attrs = { 427 'onclick': this.onclick 428 }; 429 } 430 } 431 432 this.btn = BX.create('INPUT', btn); 433 434 return this.btn; 435}; 436 437BX.CWindowButton.prototype.disableUntilError = function() { 438 this.disable(); 439 if (!this.__window_error_handler_set) 440 { 441 BX.addCustomEvent(this.parentWindow, 'onWindowError', BX.delegate(this.enable, this)); 442 this.__window_error_handler_set = true; 443 } 444}; 445 446/* base window class */ 447BX.CWindow = function(div, type) 448{ 449 this.DIV = div || document.createElement('DIV'); 450 451 this.SETTINGS = { 452 resizable: false, 453 min_height: 0, 454 min_width: 0, 455 top: 0, 456 left: 0, 457 draggable: false, 458 drag_restrict: true, 459 resize_restrict: true 460 }; 461 462 this.ELEMENTS = { 463 draggable: [], 464 resizer: [], 465 close: [] 466 }; 467 468 this.type = type == 'float' ? 'float' : 'dialog'; 469 470 BX.adjust(this.DIV, { 471 props: { 472 className: 'bx-core-window' 473 }, 474 style: { 475 'zIndex': 0, 476 'position': 'absolute', 477 'display': 'none', 478 'top': this.SETTINGS.top + 'px', 479 'left': this.SETTINGS.left + 'px', 480 'height': '100px', 481 'width': '100px' 482 } 483 }); 484 485 this.isOpen = false;
486 487 BX.addCustomEvent(this, 'onWindowRegister', BX.delegate(this.onRegister, this)); 488 BX.addCustomEvent(this, 'onWindowUnRegister', BX.delegate(this.onUnRegister, this)); 489 490 this.MOUSEOVER = null; 491 BX.bind(this.DIV, 'mouseover', BX.delegate(this.__set_msover, this)); 492 BX.bind(this.DIV, 'mouseout', BX.delegate(this.__unset_msover, this)); 493 494 BX.ready(BX.delegate(function() { 495 document.body.appendChild(this.DIV); 496 BX.ZIndexManager.register(this.DIV); 497 }, this)); 498}; 499 500BX.CWindow.prototype.Get = function () {return this.DIV}; 501BX.CWindow.prototype.visible = function() {return this.isOpen;}; 502 503BX.CWindow.prototype.Show = function(bNotRegister) 504{ 505 this.DIV.style.display = 'block'; 506 507 if (!bNotRegister) 508 { 509 BX.WindowManager.register(this); 510 BX.onCustomEvent(this, 'onWindowRegister'); 511 } 512 513 BX.ZIndexManager.bringToFront(this.DIV); 514}; 515 516BX.CWindow.prototype.Hide = function() 517{ 518 BX.WindowManager.unregister(this); 519 this.DIV.style.display = 'none'; 520}; 521 522BX.CWindow.prototype.onRegister = function() 523{ 524 this.isOpen = true; 525}; 526 527BX.CWindow.prototype.onUnRegister = function(clean) 528{ 529 this.isOpen = false; 530 531 if (clean || (this.PARAMS && this.PARAMS.content_url)) 532 { 533 if (clean) {BX.onCustomEvent(this, 'onWindowClose', [this, true]);} 534 535 if (this.DIV.parentNode) 536 this.DIV.parentNode.removeChild(this.DIV); 537 } 538 else 539 { 540 this.DIV.style.display = 'none'; 541 } 542}; 543 544BX.CWindow.prototype.CloseDialog = // compatibility 545BX.CWindow.prototype.Close = function(bImmediately) 546{ 547 BX.onCustomEvent(this, 'onBeforeWindowClose', [this]); 548 if (bImmediately !== true) 549 { 550 if (this.denyClose) 551 return false; 552 } 553 554 BX.onCustomEvent(this, 'onWindowClose', [this]); 555 556 //this crashes vis editor in ie via onWindowResizeExt event handler 557 //if (this.bExpanded) this.__expand(); 558 // alternative version: 559 if (this.bExpanded) 560 { 561 var pDocElement = BX.GetDocElement(); 562 BX.unbind(window, 'resize', BX.proxy(this.__expand_onresize, this)); 563 pDocElement.style.overflow = this.__expand_settings.overflow; 564 } 565 566 BX.WindowManager.unregister(this); 567 568 return true; 569}; 570 571BX.CWindow.prototype.SetResize = function(elem) 572{ 573 elem.style.cursor = 'se-resize'; 574 BX.bind(elem, 'mousedown', BX.proxy(this.__startResize, this)); 575 576 this.ELEMENTS.resizer.push(elem); 577 this.SETTINGS.resizable = true; 578}; 579 580BX.CWindow.prototype.SetExpand = function(elem, event_name) 581{ 582 event_name = event_name || 'click'; 583 BX.bind(elem, event_name, BX.proxy(this.__expand, this)); 584}; 585 586BX.CWindow.prototype.__expand_onresize = function() 587{ 588 var windowSize = BX.GetWindowInnerSize(); 589 this.DIV.style.width = windowSize.innerWidth + "px"; 590 this.DIV.style.height = windowSize.innerHeight + "px"; 591 592 BX.onCustomEvent(this, 'onWindowResize'); 593}; 594 595BX.CWindow.prototype.__expand = function() 596{ 597 var pDocElement = BX.GetDocElement(); 598 599 if (!this.bExpanded) 600 { 601 var wndScroll = BX.GetWindowScrollPos(), 602 wndSize = BX.GetWindowInnerSize(); 603 604 this.__expand_settings = { 605 resizable: this.SETTINGS.resizable, 606 draggable: this.SETTINGS.draggable, 607 width: this.DIV.style.width, 608 height: this.DIV.style.height, 609 left: this.DIV.style.left, 610 top: this.DIV.style.top, 611 scrollTop: wndScroll.scrollTop, 612 scrollLeft: wndScroll.scrollLeft, 613 overflow: BX.style(pDocElement, 'overflow') 614 }; 615 616 this.SETTINGS.resizable = false; 617 this.SETTINGS.draggable = false; 618 619 window.scrollTo(0,0); 620 pDocElement.style.overflow = 'hidden'; 621 622 this.DIV.style.top = '0px'; 623 this.DIV.style.left = '0px'; 624 625 this.DIV.style.width = wndSize.innerWidth + 'px'; 626 this.DIV.style.height = wndSize.innerHeight + 'px'; 627 628 this.bExpanded = true; 629 630 BX.onCustomEvent(this, 'onWindowExpand'); 631 BX.onCustomEvent(this, 'onWindowResize'); 632 633 BX.bind(window, 'resize', BX.proxy(this.__expand_onresize, this)); 634 } 635 else 636 { 637 BX.unbind(window, 'resize', BX.proxy(this.__expand_onresize, this)); 638 639 this.SETTINGS.resizable = this.__expand_settings.resizable; 640 this.SETTINGS.draggable = this.__expand_settings.draggable; 641 642 pDocElement.style.overflow = this.__expand_settings.overflow; 643 644 this.DIV.style.top = this.__expand_settings.top; 645 this.DIV.style.left = this.__expand_settings.left; 646 this.DIV.style.width = this.__expand_settings.width; 647 this.DIV.style.height = this.__expand_settings.height; 648 649 window.scrollTo(this.__expand_settings.scrollLeft, this.__expand_settings.scrollTop); 650 651 this.bExpanded = false;
652 653 BX.onCustomEvent(this, 'onWindowNarrow'); 654 BX.onCustomEvent(this, 'onWindowResize'); 655 656 } 657}; 658 659BX.CWindow.prototype.Resize = function(x, y) 660{ 661 var new_width = Math.max(x - this.pos.left + this.dx, this.SETTINGS.min_width); 662 var new_height = Math.max(y - this.pos.top + this.dy, this.SETTINGS.min_height); 663 664 if (this.SETTINGS.resize_restrict) 665 { 666 var scrollSize = BX.GetWindowScrollSize(); 667 668 if (this.pos.left + new_width > scrollSize.scrollWidth - this.dw) 669 new_width = scrollSize.scrollWidth - this.pos.left - this.dw; 670 } 671 672 this.DIV.style.width = new_width + 'px'; 673 this.DIV.style.height = new_height + 'px'; 674 675 BX.onCustomEvent(this, 'onWindowResize'); 676}; 677 678BX.CWindow.prototype.__startResize = function(e) 679{ 680 if (!this.SETTINGS.resizable) 681 return false; 682 683 if(!e) e = window.event; 684 685 this.wndSize = BX.GetWindowScrollPos(); 686 this.wndSize.innerWidth = BX.GetWindowInnerSize().innerWidth; 687 688 this.pos = BX.pos(this.DIV); 689 690 this.x = e.clientX + this.wndSize.scrollLeft; 691 this.y = e.clientY + this.wndSize.scrollTop; 692 693 this.dx = this.pos.left + this.pos.width - this.x; 694 this.dy = this.pos.top + this.pos.height - this.y; 695 this.dw = this.pos.width - parseInt(this.DIV.style.width); 696 697 BX.bind(document, "mousemove", BX.proxy(this.__moveResize, this)); 698 BX.bind(document, "mouseup", BX.proxy(this.__stopResize, this)); 699 700 if(document.body.setCapture) 701 document.body.setCapture(); 702 703 document.onmousedown = BX.False; 704 705 var b = document.body; 706 b.ondrag = b.onselectstart = BX.False; 707 b.style.MozUserSelect = this.DIV.style.MozUserSelect = 'none'; 708 b.style.cursor = 'se-resize'; 709 710 BX.onCustomEvent(this, 'onWindowResizeStart'); 711 712 return true; 713}; 714 715BX.CWindow.prototype.__moveResize = function(e) 716{ 717 if(!e) e = window.event; 718 719 var windowScroll = BX.GetWindowScrollPos(); 720 721 var x = e.clientX + windowScroll.scrollLeft; 722 var y = e.clientY + windowScroll.scrollTop; 723 724 if(this.x == x && this.y == y) 725 return; 726 727 this.Resize(x, y); 728 729 this.x = x; 730 this.y = y; 731}; 732 733BX.CWindow.prototype.__stopResize = function() 734{ 735 if(document.body.releaseCapture) 736 document.body.releaseCapture(); 737 738 BX.unbind(document, "mousemove", BX.proxy(this.__moveResize, this)); 739 BX.unbind(document, "mouseup", BX.proxy(this.__stopResize, this)); 740 741 document.onmousedown = null; 742 743 var b = document.body; 744 b.ondrag = b.onselectstart = null; 745 b.style.MozUserSelect = this.DIV.style.MozUserSelect = ''; 746 b.style.cursor = ''; 747 748 BX.onCustomEvent(this, 'onWindowResizeFinished') 749}; 750 751BX.CWindow.prototype.SetClose = function(elem) 752{ 753 BX.bind(elem, 'click', BX.proxy(this.Close, this)); 754 this.ELEMENTS.close.push(elem); 755}; 756 757BX.CWindow.prototype.SetDraggable = function(elem) 758{ 759 BX.bind(elem, 'mousedown', BX.proxy(this.__startDrag, this)); 760 761 elem.style.cursor = 'move'; 762 763 this.ELEMENTS.draggable.push(elem); 764 this.SETTINGS.draggable = true; 765}; 766 767BX.CWindow.prototype.Move = function(x, y) 768{ 769 var dxShadow = 1; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 770 771 var left = parseInt(this.DIV.style.left)+x; 772 var top = parseInt(this.DIV.style.top)+y; 773 774 if (this.SETTINGS.drag_restrict) 775 { 776 //Left side 777 if (left < 0) 778 left = 0; 779 780 //Right side 781 var scrollSize = BX.GetWindowScrollSize(); 782 var floatWidth = this.DIV.offsetWidth; 783 var floatHeight = this.DIV.offsetHeight; 784 785 if (left > (scrollSize.scrollWidth - floatWidth - dxShadow)) 786 left = scrollSize.scrollWidth - floatWidth - dxShadow; 787 788 var scrollHeight = Math.max( 789 document.body.scrollHeight, document.documentElement.scrollHeight, 790 document.body.offsetHeight, document.documentElement.offsetHeight, 791 document.body.clientHeight, document.documentElement.clientHeight, 792 scrollSize.scrollHeight 793 ); 794 795 if (top > (scrollHeight - floatHeight - dxShadow)) 796 top = scrollHeight - floatHeight - dxShadow; 797 798 //Top side 799 if (top < 0) 800 top = 0; 801 } 802 803 this.DIV.style.left = left+'px'; 804 this.DIV.style.top = top+'px'; 805 806 //this.AdjustShadow(div); 807}; 808 809BX.CWindow.prototype.__startDrag = function(e) 810{ 811 if (!this.SETTINGS.draggable) 812 return false; 813 814 if(!e) e = window.event; 815 816 this.x = e.clientX + document.body.scrollLeft; 817 this.y = e.clientY + document.body.scrollTop; 818 819 this.__bWasDragged = false;
820 BX.bind(document, "mousemove", BX.proxy(this.__moveDrag, this)); 821 BX.bind(document, "mouseup", BX.proxy(this.__stopDrag, this)); 822 823 if(document.body.setCapture) 824 document.body.setCapture(); 825 826 document.onmousedown = BX.False; 827 828 var b = document.body; 829 b.ondrag = b.onselectstart = BX.False; 830 b.style.MozUserSelect = this.DIV.style.MozUserSelect = 'none'; 831 b.style.cursor = 'move'; 832 return BX.PreventDefault(e); 833}; 834 835BX.CWindow.prototype.__moveDrag = function(e) 836{ 837 if(!e) e = window.event; 838 839 var x = e.clientX + document.body.scrollLeft; 840 var y = e.clientY + document.body.scrollTop; 841 842 if(this.x == x && this.y == y) 843 return; 844 845 this.Move((x - this.x), (y - this.y)); 846 this.x = x; 847 this.y = y; 848 849 if (!this.__bWasDragged) 850 { 851 BX.onCustomEvent(this, 'onWindowDragStart'); 852 this.__bWasDragged = true; 853 BX.bind(BX.proxy_context, "click", BX.PreventDefault); 854 } 855 856 BX.onCustomEvent(this, 'onWindowDrag'); 857}; 858 859BX.CWindow.prototype.__stopDrag = function(e) 860{ 861 if(document.body.releaseCapture) 862 document.body.releaseCapture(); 863 864 BX.unbind(document, "mousemove", BX.proxy(this.__moveDrag, this)); 865 BX.unbind(document, "mouseup", BX.proxy(this.__stopDrag, this)); 866 867 document.onmousedown = null; 868 869 var b = document.body; 870 b.ondrag = b.onselectstart = null; 871 b.style.MozUserSelect = this.DIV.style.MozUserSelect = ''; 872 b.style.cursor = ''; 873 874 if (this.__bWasDragged) 875 { 876 BX.onCustomEvent(this, 'onWindowDragFinished'); 877 var _proxy_context = BX.proxy_context; 878 setTimeout(function(){BX.unbind(_proxy_context, "click", BX.PreventDefault)}, 100); 879 this.__bWasDragged = false; 880 } 881 return BX.PreventDefault(e); 882}; 883 884BX.CWindow.prototype.DenyClose = function() 885{ 886 this.denyClose = true; 887}; 888 889BX.CWindow.prototype.AllowClose = function() 890{ 891 this.denyClose = false; 892}; 893 894BX.CWindow.prototype.ShowError = function(str) 895{ 896 BX.onCustomEvent(this, 'onWindowError', [str]); 897 898 if (this._wait) 899 BX.closeWait(this._wait); 900 901 window.alert(str); 902}; 903 904BX.CWindow.prototype.__set_msover = function() {this.MOUSEOVER = true;}; 905BX.CWindow.prototype.__unset_msover = function() {this.MOUSEOVER = false;}; 906 907/* dialog window class extends window class */ 908BX.CWindowDialog = function() { 909 var a = arguments; 910 a[1] = 'dialog'; 911 BX.CWindowDialog.superclass.constructor.apply(this, a); 912 913 this.DIV.style.top = '10px'; 914 this.OVERLAY = null; 915}; 916BX.extend(BX.CWindowDialog, BX.CWindow); 917 918BX.CWindowDialog.prototype.__resizeOverlay = function() 919{ 920 var windowSize = BX.GetWindowScrollSize(); 921 this.OVERLAY.style.width = windowSize.scrollWidth + "px"; 922}; 923 924BX.CWindowDialog.prototype.CreateOverlay = function(zIndex) 925{ 926 if (null == this.OVERLAY) 927 { 928 var windowSize = BX.GetWindowScrollSize(); 929 930 // scrollHeight in BX.GetWindowScrollSize may be incorrect 931 var scrollHeight = Math.max( 932 document.body.scrollHeight, document.documentElement.scrollHeight, 933 document.body.offsetHeight, document.documentElement.offsetHeight, 934 document.body.clientHeight, document.documentElement.clientHeight, 935 windowSize.scrollHeight 936 ); 937 938 this.OVERLAY = document.body.appendChild(BX.create("DIV", { 939 style: { 940 position: 'absolute', 941 top: '0px', 942 left: '0px', 943 zIndex: zIndex || (parseInt(this.DIV.style.zIndex)-2), 944 width: windowSize.scrollWidth + "px", 945 height: scrollHeight + "px" 946 } 947 })); 948 949 var component = BX.ZIndexManager.getComponent(this.DIV); 950 if (component) 951 { 952 component.setOverlay(this.OVERLAY); 953 } 954 } 955 956 return this.OVERLAY; 957}; 958 959BX.CWindowDialog.prototype.Show = function() 960{ 961 BX.CWindowDialog.superclass.Show.apply(this, arguments); 962 963 this.CreateOverlay(); 964 965 this.OVERLAY.style.display = 'block'; 966 967 BX.unbind(window, 'resize', BX.proxy(this.__resizeOverlay, this)); 968 BX.bind(window, 'resize', BX.proxy(this.__resizeOverlay, this)); 969}; 970 971BX.CWindowDialog.prototype.onUnRegister = function(clean) 972{ 973 BX.CWindowDialog.superclass.onUnRegister.apply(this, arguments); 974 975 if (this.clean) 976 { 977 if (this.OVERLAY.parentNode) 978 this.OVERLAY.parentNode.removeChild(this.OVERLAY); 979 } 980 else 981 { 982 this.OVERLAY.style.display = 'none'; 983 } 984 985 BX.unbind(window, 'resize', BX.proxy(this.__resizeOverlay, this)); 986}; 987 988/* standard bitrix dialog extends BX.CWindowDialog */ 989/*
990 arParams = { 991 ( 992 title: 'dialog title', 993 head: 'head block html', 994 content: 'dialog content', 995 icon: 'head icon classname or filename', 996 997 resize_id: 'some id to save resize information'// useless if resizable = false 998 ) 999 or 1000 ( 1001 content_url: url to content load 1002 loaded content scripts can use BX.WindowManager.Get() to get access to the current window object 1003 ) 1004 1005 height: window_height_in_pixels, 1006 width: window_width_in_pixels, 1007 1008 draggable: true|false, 1009 resizable: true|false, 1010 1011 min_height: min_window_height_in_pixels, // useless if resizable = false 1012 min_width: min_window_width_in_pixels, // useless if resizable = false 1013 1014 buttons: [ 1015 'html_code', 1016 BX.CDialog.btnSave, BX.CDialog.btnCancel, BX.CDialog.btnClose 1017 ] 1018 } 1019*/ 1020BX.CDialog = function(arParams) 1021{ 1022 BX.CDialog.superclass.constructor.apply(this); 1023 1024 this._sender = 'core_window_cdialog'; 1025 1026 this.PARAMS = arParams || {}; 1027 1028 for (var i in this.defaultParams) 1029 { 1030 if (typeof this.PARAMS[i] == 'undefined') 1031 this.PARAMS[i] = this.defaultParams[i]; 1032 } 1033 1034 this.PARAMS.width = (!isNaN(parseInt(this.PARAMS.width))) 1035 ? this.PARAMS.width 1036 : this.defaultParams['width']; 1037 this.PARAMS.height = (!isNaN(parseInt(this.PARAMS.height))) 1038 ? this.PARAMS.height 1039 : this.defaultParams['height']; 1040 1041 if (this.PARAMS.resize_id || this.PARAMS.content_url) 1042 { 1043 var arSize = BX.WindowManager.getRuntimeWindowSize(this.PARAMS.resize_id || this.PARAMS.content_url); 1044 if (arSize) 1045 { 1046 this.PARAMS.width = arSize.width; 1047 this.PARAMS.height = arSize.height; 1048 } 1049 } 1050 1051 BX.addClass(this.DIV, 'bx-core-adm-dialog'); 1052 this.DIV.id = 'bx-admin-prefix'; 1053 1054 this.PARTS = {}; 1055 1056 this.DIV.style.height = null; 1057 this.DIV.style.width = null; 1058 1059 this.PARTS.TITLEBAR = this.DIV.appendChild(BX.create('DIV', {props: { 1060 className: 'bx-core-adm-dialog-head' 1061 } 1062 })); 1063 1064 this.PARTS.TITLE_CONTAINER = this.PARTS.TITLEBAR.appendChild(BX.create('SPAN', { 1065 props: {className: 'bx-core-adm-dialog-head-inner'}, 1066 text: this.PARAMS.title 1067 })); 1068 1069 this.PARTS.TITLEBAR_ICONS = this.PARTS.TITLEBAR.appendChild(BX.create('DIV', { 1070 props: { 1071 className: 'bx-core-adm-dialog-head-icons' 1072 }, 1073 children: (this.PARAMS.resizable ? [ 1074 BX.create('SPAN', {props: {className: 'bx-core-adm-icon-expand', title: BX.message('JS_CORE_WINDOW_EXPAND')}}), 1075 BX.create('SPAN', {props: {className: 'bx-core-adm-icon-close', title: BX.message('JS_CORE_WINDOW_CLOSE')}}) 1076 ] : [ 1077 BX.create('SPAN', {props: {className: 'bx-core-adm-icon-close', title: BX.message('JS_CORE_WINDOW_CLOSE')}}) 1078 ]) 1079 })); 1080 1081 1082 this.PARTS.CONTENT = this.DIV.appendChild(BX.create('DIV', { 1083 props: {className: 'bx-core-adm-dialog-content-wrap adm-workarea'} 1084 })); 1085 1086 this.PARTS.CONTENT_DATA = this.PARTS.CONTENT.appendChild(BX.create('DIV', { 1087 props: {className: 'bx-core-adm-dialog-content'}, 1088 style: { 1089 height: this.PARAMS.height + 'px', 1090 width: this.PARAMS.width + 'px' 1091 } 1092 })); 1093 1094 this.PARTS.HEAD = this.PARTS.CONTENT_DATA.appendChild(BX.create('DIV', { 1095 props: { 1096 className: 'bx-core-adm-dialog-head-block' + (this.PARAMS.icon ? ' ' + this.PARAMS.icon : '') 1097 } 1098 })); 1099 1100 this.SetHead(this.PARAMS.head); 1101 this.SetContent(this.PARAMS.content); 1102 this.SetTitle(this.PARAMS.title); 1103 this.SetClose(this.PARTS.TITLEBAR_ICONS.lastChild); 1104 1105 if (this.PARAMS.resizable) 1106 { 1107 this.SetExpand(this.PARTS.TITLEBAR_ICONS.firstChild); 1108 this.SetExpand(this.PARTS.TITLEBAR, 'dblclick'); 1109 1110 BX.addCustomEvent(this, 'onWindowExpand', BX.proxy(this.__onexpand, this)); 1111 BX.addCustomEvent(this, 'onWindowNarrow', BX.proxy(this.__onexpand, this)); 1112 } 1113 1114 this.PARTS.FOOT = this.PARTS.BUTTONS_CONTAINER = this.PARTS.CONTENT.appendChild(BX.create('DIV', { 1115 props: { 1116 className: 'bx-core-adm-dialog-buttons' 1117 }, 1118 //events: { 1119 // 'click': BX.delegateEvent({property:{type: /button|submit/}}, BX.delegate(function() {this.showWait(BX.proxy_context)}, this)) 1120 //}, 1121 children: this.ShowButtons() 1122 } 1123 )); 1124 1125 if (this.PARAMS.draggable) 1126 this.SetDraggable(this.PARTS.TITLEBAR); 1127 1128 if (this.PARAMS.resizable) 1129 { 1130 this.PARTS.RESIZER = this.DIV.appendChild(BX.create('DIV', { 1131 props: {className: 'bx-core-resizer'} 1132 })); 1133 1134 this.SetResize(this.PARTS.RESIZER); 1135 1136 this.SETTINGS.min_width = this.PARAMS.min_width; 1137 this.SETTINGS.min_height = this.PARAMS.min_height; 1138 } 1139 1140 this.auth_callback = BX.delegate(function(){ 1141 this.PARAMS.content = ''; 1142 this.hideNotify(); 1143 this.Show(); 1144 }, this) 1145}; 1146BX.extend(BX.CDialog, BX.CWindowDialog); 1147 1148BX.CDialog.prototype.defaultParams = { 1149 width: 700, 1150 height: 400, 1151 min_width: 500, 1152 min_height: 300, 1153 1154 resizable: true, 1155 draggable: true, 1156 1157 title: '', 1158 icon: '' 1159}; 1160 1161BX.CDialog.prototype.showWait = function(el) 1162{ 1163 if (BX.type.isElementNode(el) && (el.type == 'button' || el.type == 'submit')) 1164 { 1165 BX.defer(function(){el.disabled = true})(); 1166 1167 var bSave = (BX.hasClass(el, 'adm-btn-save') || BX.hasClass(el, 'adm-btn-save')), 1168 pos = BX.pos(el, true); 1169 1170 el.bxwaiter = this.PARTS.FOOT.appendChild(BX.create('DIV', { 1171 props: {className: 'adm-btn-load-img' + (bSave ? '-green' : '')}, 1172 style: { 1173 top: parseInt((pos.bottom + pos.top)/2 - 10) + 'px', 1174 left: parseInt((pos.right + pos.left)/2 - 10) + 'px' 1175 } 1176 })); 1177 1178 BX.addClass(el, 'adm-btn-load'); 1179 1180 this.lastWaitElement = el; 1181 1182 return el.bxwaiter; 1183 } 1184 return null; 1185}; 1186 1187BX.CDialog.prototype.closeWait = function(el) 1188{ 1189 el = el || this.lastWaitElement; 1190 1191 if (BX.type.isElementNode(el)) 1192 { 1193 if (el.bxwaiter) 1194 { 1195 if(el.bxwaiter.parentNode) 1196 { 1197 el.bxwaiter.parentNode.removeChild(el.bxwaiter); 1198 } 1199 1200 el.bxwaiter = null; 1201 } 1202 1203 el.disabled = false;
1204 BX.removeClass(el, 'adm-btn-load'); 1205 1206 if (this.lastWaitElement == el) 1207 this.lastWaitElement = null; 1208 } 1209}; 1210 1211BX.CDialog.prototype.Authorize = function(arAuthResult) 1212{ 1213 this.bSkipReplaceContent = true; 1214 this.ShowError(BX.message('JSADM_AUTH_REQ')); 1215 1216 BX.onCustomEvent(this, 'onWindowError', []); 1217 1218 BX.closeWait(); 1219 1220 (new BX.CAuthDialog({ 1221 content_url: this.PARAMS.content_url, 1222 auth_result: arAuthResult, 1223 callback: BX.delegate(function(){ 1224 if (this.auth_callback) 1225 this.auth_callback() 1226 }, this) 1227 })).Show(); 1228}; 1229 1230BX.CDialog.prototype.ShowError = function(str) 1231{ 1232 BX.onCustomEvent(this, 'onWindowError', [str]); 1233 1234 this.closeWait(); 1235 1236 if (this._wait) 1237 BX.closeWait(this._wait); 1238 1239 this.Notify(str, true); 1240}; 1241 1242 1243BX.CDialog.prototype.__expandGetSize = function() 1244{ 1245 var pDocElement = BX.GetDocElement(); 1246 pDocElement.style.overflow = 'hidden'; 1247 1248 var wndSize = BX.GetWindowInnerSize(); 1249 1250 pDocElement.scrollTop = 0; 1251 1252 this.DIV.style.top = '-' + this.dxShadow + 'px'; 1253 this.DIV.style.left = '-' + this.dxShadow + 'px'; 1254 1255 return { 1256 width: (wndSize.innerWidth - parseInt(BX.style(this.PARTS.CONTENT, 'padding-right')) - parseInt(BX.style(this.PARTS.CONTENT, 'padding-left'))) + this.dxShadow, 1257 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 1258 }; 1259}; 1260 1261BX.CDialog.prototype.__expand = function() 1262{ 1263 var pDocElement = BX.GetDocElement(); 1264 this.dxShadow = 2; 1265 1266 if (!this.bExpanded) 1267 { 1268 var wndScroll = BX.GetWindowScrollPos(); 1269 1270 this.__expand_settings = { 1271 resizable: this.SETTINGS.resizable, 1272 draggable: this.SETTINGS.draggable, 1273 width: this.PARTS.CONTENT_DATA.style.width, 1274 height: this.PARTS.CONTENT_DATA.style.height, 1275 left: this.DIV.style.left, 1276 top: this.DIV.style.top, 1277 scrollTop: wndScroll.scrollTop, 1278 scrollLeft: wndScroll.scrollLeft, 1279 overflow: BX.style(pDocElement, 'overflow') 1280 }; 1281 1282 this.SETTINGS.resizable = false; 1283 this.SETTINGS.draggable = false; 1284 1285 var pos = this.__expandGetSize(); 1286 1287 this.PARTS.CONTENT_DATA.style.width = pos.width + 'px'; 1288 this.PARTS.CONTENT_DATA.style.height = pos.height + 'px'; 1289 1290 window.scrollTo(0,0); 1291 pDocElement.style.overflow = 'hidden'; 1292 1293 this.bExpanded = true; 1294 1295 BX.onCustomEvent(this, 'onWindowExpand'); 1296 BX.onCustomEvent(this, 'onWindowResize'); 1297 BX.onCustomEvent(this, 'onWindowResizeExt', [{'width': pos.width, 'height': pos.height}]); 1298 1299 BX.bind(window, 'resize', BX.proxy(this.__expand_onresize, this)); 1300 } 1301 else 1302 { 1303 BX.unbind(window, 'resize', BX.proxy(this.__expand_onresize, this)); 1304 1305 this.SETTINGS.resizable = this.__expand_settings.resizable; 1306 this.SETTINGS.draggable = this.__expand_settings.draggable; 1307 1308 pDocElement.style.overflow = this.__expand_settings.overflow; 1309 1310 this.DIV.style.top = this.__expand_settings.top; 1311 this.DIV.style.left = this.__expand_settings.left; 1312 this.PARTS.CONTENT_DATA.style.width = this.__expand_settings.width; 1313 this.PARTS.CONTENT_DATA.style.height = this.__expand_settings.height; 1314 window.scrollTo(this.__expand_settings.scrollLeft, this.__expand_settings.scrollTop); 1315 this.bExpanded = false; 1316 1317 BX.onCustomEvent(this, 'onWindowNarrow'); 1318 BX.onCustomEvent(this, 'onWindowResize'); 1319 BX.onCustomEvent(this, 'onWindowResizeExt', [{'width': parseInt(this.__expand_settings.width), 'height': parseInt(this.__expand_settings.height)}]); 1320 } 1321}; 1322 1323BX.CDialog.prototype.__expand_onresize = function() 1324{ 1325 var pos = this.__expandGetSize(); 1326 1327 this.PARTS.CONTENT_DATA.style.width = pos.width + 'px'; 1328 this.PARTS.CONTENT_DATA.style.height = pos.height + 'px'; 1329 1330 BX.onCustomEvent(this, 'onWindowResize'); 1331 BX.onCustomEvent(this, 'onWindowResizeExt', [pos]); 1332}; 1333 1334BX.CDialog.prototype.__onexpand = function() 1335{ 1336 var ob = this.PARTS.TITLEBAR_ICONS.firstChild; 1337 ob.className = BX.toggle(ob.className, ['bx-core-adm-icon-expand', 'bx-core-adm-icon-narrow']); 1338 ob.title = BX.toggle(ob.title, [BX.message('JS_CORE_WINDOW_EXPAND'), BX.message('JS_CORE_WINDOW_NARROW')]); 1339 1340 if (this.PARTS.RESIZER) 1341 { 1342 this.PARTS.RESIZER.style.display = this.bExpanded ? 'none' : 'block'; 1343 } 1344}; 1345 1346 1347BX.CDialog.prototype.__startResize = function(e) 1348{ 1349 if (!this.SETTINGS.resizable) 1350 return false;
1351 1352 if(!e) e = window.event; 1353 1354 this.wndSize = BX.GetWindowScrollPos(); 1355 this.wndSize.innerWidth = BX.GetWindowInnerSize().innerWidth; 1356 1357 this.pos = BX.pos(this.PARTS.CONTENT_DATA); 1358 1359 this.x = e.clientX + this.wndSize.scrollLeft; 1360 this.y = e.clientY + this.wndSize.scrollTop; 1361 1362 this.dx = this.pos.left + this.pos.width - this.x; 1363 this.dy = this.pos.top + this.pos.height - this.y; 1364 1365 1366 // TODO: suspicious 1367 this.dw = this.pos.width - parseInt(this.PARTS.CONTENT_DATA.style.width) + parseInt(BX.style(this.PARTS.CONTENT, 'padding-right')); 1368 1369 BX.bind(document, "mousemove", BX.proxy(this.__moveResize, this)); 1370 BX.bind(document, "mouseup", BX.proxy(this.__stopResize, this)); 1371 1372 if(document.body.setCapture) 1373 document.body.setCapture(); 1374 1375 document.onmousedown = BX.False; 1376 1377 var b = document.body; 1378 b.ondrag = b.onselectstart = BX.False; 1379 b.style.MozUserSelect = this.DIV.style.MozUserSelect = 'none'; 1380 b.style.cursor = 'se-resize'; 1381 1382 BX.onCustomEvent(this, 'onWindowResizeStart'); 1383 1384 return true; 1385}; 1386 1387BX.CDialog.prototype.Resize = function(x, y) 1388{ 1389 var new_width = Math.max(x - this.pos.left + this.dx, this.SETTINGS.min_width); 1390 var new_height = Math.max(y - this.pos.top + this.dy, this.SETTINGS.min_height); 1391 1392 if (this.SETTINGS.resize_restrict) 1393 { 1394 var scrollSize = BX.GetWindowScrollSize(); 1395 1396 if (this.pos.left + new_width > scrollSize.scrollWidth - this.dw) 1397 new_width = scrollSize.scrollWidth - this.pos.left - this.dw; 1398 } 1399 1400 this.PARTS.CONTENT_DATA.style.width = new_width + 'px'; 1401 this.PARTS.CONTENT_DATA.style.height = new_height + 'px'; 1402 1403 BX.onCustomEvent(this, 'onWindowResize'); 1404 BX.onCustomEvent(this, 'onWindowResizeExt', [{'height': new_height, 'width': new_width}]); 1405}; 1406 1407BX.CDialog.prototype.SetSize = function(obSize) 1408{ 1409 this.PARTS.CONTENT_DATA.style.width = obSize.width + 'px'; 1410 this.PARTS.CONTENT_DATA.style.height = obSize.height + 'px'; 1411 1412 BX.onCustomEvent(this, 'onWindowResize'); 1413 BX.onCustomEvent(this, 'onWindowResizeExt', [obSize]); 1414}; 1415 1416BX.CDialog.prototype.GetParameters = function(form_name) 1417{ 1418 var form = this.GetForm(); 1419 1420 if(!form) 1421 return ""; 1422 1423 var i, s = ""; 1424 var n = form.elements.length; 1425 1426 var delim = ''; 1427 for(i=0; i<n; i++) 1428 { 1429 if (s != '') delim = '&'; 1430 var el = form.elements[i]; 1431 if (el.disabled) 1432 continue; 1433 1434 switch(el.type.toLowerCase()) 1435 { 1436 case 'text': 1437 case 'textarea': 1438 case 'password': 1439 case 'hidden': 1440 if (null == form_name && el.name.substr(el.name.length-4) == '_alt' && form.elements[el.name.substr(0, el.name.length-4)]) 1441 break; 1442 s += delim + el.name + '=' + BX.util.urlencode(el.value); 1443 break; 1444 case 'radio': 1445 if(el.checked) 1446 s += delim + el.name + '=' + BX.util.urlencode(el.value); 1447 break; 1448 case 'checkbox': 1449 s += delim + el.name + '=' + BX.util.urlencode(el.checked ? 'Y':'N'); 1450 break; 1451 case 'select-one': 1452 var val = ""; 1453 if (null == form_name && form.elements[el.name + '_alt'] && el.selectedIndex == 0) 1454 val = form.elements[el.name+'_alt'].value; 1455 else 1456 val = el.value; 1457 s += delim + el.name + '=' + BX.util.urlencode(val); 1458 break; 1459 case 'select-multiple': 1460 var j, bAdded = false; 1461 var l = el.options.length; 1462 for (j=0; j<l; j++) 1463 { 1464 if (el.options[j].selected) 1465 { 1466 s += delim + el.name + '=' + BX.util.urlencode(el.options[j].value); 1467 bAdded = true; 1468 } 1469 } 1470 if (!bAdded) 1471 s += delim + el.name + '='; 1472 break; 1473 default: 1474 break; 1475 } 1476 } 1477 1478 return s; 1479}; 1480 1481BX.CDialog.prototype.PostParameters = function(params) 1482{ 1483 var url = this.PARAMS.content_url; 1484 1485 if (null == params) 1486 params = ""; 1487 1488 params += (params == "" ? "" : "&") + "bxsender=" + this._sender; 1489 1490 var index = url.indexOf('?'); 1491 if (index == -1) 1492 url += '?' + params; 1493 else 1494 url = url.substring(0, index) + '?' + params + "&" + url.substring(index+1); 1495 1496 BX.showWait(); 1497 1498 this.auth_callback = BX.delegate(function(){ 1499 this.hideNotify(); 1500 this.PostParameters(params); 1501 }, this); 1502 1503 BX.ajax.Setup({skipAuthCheck:true},true); 1504 BX.ajax.post(url, this.GetParameters(), BX.delegate(function(result) { 1505 BX.closeWait(); 1506 if (!this.bSkipReplaceContent) 1507 { 1508 this.ClearButtons(); // buttons are appended during form reload, so we should clear footer 1509 this.SetContent(result); 1510 this.Show(true); 1511 } 1512 1513 this.bSkipReplaceContent = false;
1514 }, this)); 1515}; 1516 1517BX.CDialog.prototype.Submit = function(params, url) 1518{ 1519 var FORM = this.GetForm(); 1520 if (FORM) 1521 { 1522 FORM.onsubmit = null; 1523 1524 FORM.method = 'POST'; 1525 if (!FORM.action || url) 1526 { 1527 url = url || this.PARAMS.content_url; 1528 if (null != params) 1529 { 1530 var index = url.indexOf('?'); 1531 if (index == -1) 1532 url += '?' + params; 1533 else 1534 url = url.substring(0, index) + '?' + params + "&" + url.substring(index+1); 1535 } 1536 1537 FORM.action = url; 1538 } 1539 1540 if (!FORM._bxsender) 1541 { 1542 FORM._bxsender = FORM.appendChild(BX.create('INPUT', { 1543 attrs: { 1544 type: 'hidden', 1545 name: 'bxsender', 1546 value: this._sender 1547 } 1548 })); 1549 } 1550 1551 this._wait = BX.showWait(); 1552 1553 this.auth_callback = BX.delegate(function(){ 1554 this.hideNotify(); 1555 this.Submit(params); 1556 }, this); 1557 1558 BX.ajax.submit(FORM, BX.delegate(function(){this.closeWait()}, this)); 1559 } 1560 else 1561 { 1562 window.alert('no form registered!'); 1563 } 1564}; 1565 1566BX.CDialog.prototype.GetForm = function() 1567{ 1568 if (null == this.__form) 1569 { 1570 var forms = this.PARTS.CONTENT_DATA.getElementsByTagName('FORM'); 1571 this.__form = forms[0] ? forms[0] : null; 1572 } 1573 1574 return this.__form; 1575}; 1576 1577BX.CDialog.prototype.GetRealForm = function() 1578{ 1579 if (null == this.__rform) 1580 { 1581 var forms = this.PARTS.CONTENT_DATA.getElementsByTagName('FORM'); 1582 this.__rform = forms[1] ? forms[1] : (forms[0] ? forms[0] : null); 1583 } 1584 1585 return this.__rform; 1586}; 1587 1588BX.CDialog.prototype._checkButton = function(btn) 1589{ 1590 var arCustomButtons = ['btnSave', 'btnCancel', 'btnClose']; 1591 1592 for (var i = 0; i < arCustomButtons.length; i++) 1593 { 1594 if (this[arCustomButtons[i]] && (btn == this[arCustomButtons[i]])) 1595 return arCustomButtons[i]; 1596 } 1597 1598 return false; 1599}; 1600 1601BX.CDialog.prototype.ShowButtons = function() 1602{ 1603 var result = []; 1604 if (this.PARAMS.buttons) 1605 { 1606 if (this.PARAMS.buttons.title) this.PARAMS.buttons = [this.PARAMS.buttons]; 1607 1608 for (var i=0, len=this.PARAMS.buttons.length; i<len; i++) 1609 { 1610 if (BX.type.isNotEmptyString(this.PARAMS.buttons[i])) 1611 { 1612 result.push(this.PARAMS.buttons[i]); 1613 } 1614 else if (BX.type.isElementNode(this.PARAMS.buttons[i])) 1615 { 1616 result.push(this.PARAMS.buttons[i]); 1617 } 1618 else if (this.PARAMS.buttons[i]) 1619 { 1620 //if (!(this.PARAMS.buttons[i] instanceof BX.CWindowButton)) 1621 if (!BX.is_subclass_of(this.PARAMS.buttons[i], BX.CWindowButton)) 1622 { 1623 var b = this._checkButton(this.PARAMS.buttons[i]); // hack to set links to real CWindowButton object in btnSave etc; 1624 this.PARAMS.buttons[i] = new BX.CWindowButton(this.PARAMS.buttons[i]); 1625 if (b) this[b] = this.PARAMS.buttons[i]; 1626 } 1627 1628 result.push(this.PARAMS.buttons[i].Button(this)); 1629 } 1630 } 1631 } 1632 1633 return result; 1634}; 1635 1636BX.CDialog.prototype.setAutosave = function () { 1637 if (!this.bSetAutosaveDelay) 1638 { 1639 this.bSetAutosaveDelay = true; 1640 setTimeout(BX.proxy(this.setAutosave, this), 10); 1641 } 1642}; 1643 1644BX.CDialog.prototype.SetTitle = function(title) 1645{ 1646 this.PARAMS.title = title; 1647 BX.cleanNode(this.PARTS.TITLE_CONTAINER).appendChild(document.createTextNode(this.PARAMS.title)); 1648}; 1649 1650BX.CDialog.prototype.SetHead = function(head) 1651{ 1652 this.PARAMS.head = BX.util.trim(head); 1653 this.PARTS.HEAD.innerHTML = this.PARAMS.head || " "; 1654 this.PARTS.HEAD.style.display = this.PARAMS.head ? 'block' : 'none'; 1655 this.adjustSize(); 1656}; 1657 1658BX.CDialog.prototype.Notify = function(note, bError, html) 1659{ 1660 if (!this.PARTS.NOTIFY) 1661 { 1662 this.PARTS.NOTIFY = this.DIV.insertBefore(BX.create('DIV', { 1663 props: {className: 'adm-warning-block'}, 1664 children: [ 1665 BX.create('SPAN', { 1666 props: {className: 'adm-warning-text'} 1667 }), 1668 BX.create('SPAN', { 1669 props: {className: 'adm-warning-icon'} 1670 }), 1671 BX.create('SPAN', { 1672 props: {className: 'adm-warning-close'}, 1673 events: {click: BX.proxy(this.hideNotify, this)} 1674 }) 1675 ] 1676 }), this.DIV.firstChild); 1677 } 1678 1679 if (bError) 1680 BX.addClass(this.PARTS.NOTIFY, 'adm-warning-block-red'); 1681 else 1682 BX.removeClass(this.PARTS.NOTIFY, 'adm-warning-block-red'); 1683 1684 if(html !== true) 1685 { 1686 note = BX.util.htmlspecialchars(note); 1687 } 1688 1689 this.PARTS.NOTIFY.firstChild.innerHTML = note || ' '; 1690 this.PARTS.NOTIFY.firstChild.style.width = (this.PARAMS.width-50) + 'px'; 1691 BX.removeClass(this.PARTS.NOTIFY, 'adm-warning-animate'); 1692}; 1693 1694BX.CDialog.prototype.hideNotify = function() 1695{ 1696 BX.addClass(this.PARTS.NOTIFY, 'adm-warning-animate'); 1697}; 1698 1699BX.CDialog.prototype.__adjustHeadToIcon = function() 1700{ 1701 if (!this.PARTS.HEAD.offsetHeight) 1702 { 1703 setTimeout(BX.delegate(this.__adjustHeadToIcon, this), 50); 1704 } 1705 else 1706 { 1707 if (this.icon_image && this.icon_image.height && this.icon_image.height > this.PARTS.HEAD.offsetHeight - 5) 1708 { 1709 this.PARTS.HEAD.style.height = this.icon_image.height + 5 + 'px'; 1710 this.adjustSize(); 1711 } 1712 1713 this.icon_image.onload = null; 1714 this.icon_image = null; 1715 } 1716}; 1717 1718BX.CDialog.prototype.SetIcon = function(icon_class) 1719{ 1720 if (this.PARAMS.icon != icon_class) 1721 { 1722 if (this.PARAMS.icon) 1723 BX.removeClass(this.PARTS.HEAD, this.PARAMS.icon); 1724 1725 this.PARAMS.icon = icon_class; 1726 1727 if (this.PARAMS.icon) 1728 { 1729 BX.addClass(this.PARTS.HEAD, this.PARAMS.icon); 1730 1731 var icon_file = (BX.style(this.PARTS.HEAD, 'background-image') || BX.style(this.PARTS.HEAD, 'backgroundImage')); 1732 if (BX.type.isNotEmptyString(icon_file) && icon_file != 'none') 1733 { 1734 var match = icon_file.match(new RegExp('url\\s*\\(\\s*(\'|"|)(.+?)(\\1)\\s*\\)')); 1735 if(match) 1736 { 1737 icon_file = match[2]; 1738 if (BX.type.isNotEmptyString(icon_file)) 1739 { 1740 this.icon_image = new Image(); 1741 this.icon_image.onload = BX.delegate(this.__adjustHeadToIcon, this); 1742 this.icon_image.src = icon_file; 1743 } 1744 } 1745 } 1746 } 1747 } 1748 this.adjustSize(); 1749}; 1750 1751BX.CDialog.prototype.SetIconFile = function(icon_file) 1752{ 1753 this.icon_image = new Image(); 1754 this.icon_image.onload = BX.delegate(this.__adjustHeadToIcon, this); 1755 this.icon_image.src = icon_file; 1756 1757 BX.adjust(this.PARTS.HEAD, {style: {backgroundImage: 'url(' + icon_file + ')', backgroundPosition: 'right 9px'/*'99% center'*/}}); 1758 this.adjustSize(); 1759}; 1760 1761/* 1762BUTTON: { 1763 title: 'title',
1764 'action': function executed in window object context 1765} 1766BX.CDialog.btnSave || BX.CDialog.btnCancel - standard buttons 1767*/ 1768 1769BX.CDialog.prototype.SetButtons = function(a) 1770{ 1771 if (BX.type.isString(a)) 1772 { 1773 if (a.length > 0) 1774 { 1775 this.PARTS.BUTTONS_CONTAINER.innerHTML += a; 1776 1777 var btns = this.PARTS.BUTTONS_CONTAINER.getElementsByTagName('INPUT'); 1778 if (btns.length > 0) 1779 { 1780 this.PARAMS.buttons = []; 1781 for (var i = 0; i < btns.length; i++) 1782 { 1783 this.PARAMS.buttons.push(new BX.CWindowButton({btn: btns[i], parentWindow: this})); 1784 } 1785 } 1786 } 1787 } 1788 else 1789 { 1790 this.PARAMS.buttons = a; 1791 BX.adjust(this.PARTS.BUTTONS_CONTAINER, { 1792 children: this.ShowButtons() 1793 }); 1794 } 1795 this.adjustSize(); 1796}; 1797 1798BX.CDialog.prototype.ClearButtons = function() 1799{ 1800 BX.cleanNode(this.PARTS.BUTTONS_CONTAINER); 1801 this.adjustSize(); 1802}; 1803 1804BX.CDialog.prototype.SetContent = function(html) 1805{ 1806 this.__form = null; 1807 1808 if (BX.type.isElementNode(html)) 1809 { 1810 if (html.parentNode) 1811 html.parentNode.removeChild(html); 1812 } 1813 else if (BX.type.isString(html)) 1814 { 1815 html = BX.create('DIV', {html: html}); 1816 } 1817 1818 this.PARAMS.content = html; 1819 BX.cleanNode(this.PARTS.CONTENT_DATA); 1820 1821 BX.adjust(this.PARTS.CONTENT_DATA, { 1822 children: [ 1823 this.PARTS.HEAD, 1824 BX.create('DIV', { 1825 props: { 1826 className: 'bx-core-adm-dialog-content-wrap-inner' 1827 }, 1828 children: [this.PARAMS.content] 1829 }) 1830 ] 1831 }); 1832 1833 if (this.PARAMS.content_url && this.GetForm()) 1834 { 1835 this.__form.submitbtn = this.__form.appendChild(BX.create('INPUT', {props:{type:'submit'},style:{display:'none'}})); 1836 this.__form.onsubmit = BX.delegate(this.__submit, this); 1837 } 1838}; 1839 1840BX.CDialog.prototype.__submit = function(e) 1841{ 1842 for (var i=0,len=this.PARAMS.buttons.length; i<len; i++) 1843 { 1844 if ( 1845 this.PARAMS.buttons[i] 1846 && ( 1847 this.PARAMS.buttons[i].name && /save|apply/i.test(this.PARAMS.buttons[i].name) 1848 || 1849 this.PARAMS.buttons[i].btn && this.PARAMS.buttons[i].btn.name && /save|apply/i.test(this.PARAMS.buttons[i].btn.name) 1850 ) 1851 ) 1852 { 1853 this.PARAMS.buttons[i].emulate(); 1854 break; 1855 } 1856 } 1857 1858 return BX.PreventDefault(e); 1859}; 1860 1861BX.CDialog.prototype.SwapContent = function(cont) 1862{ 1863 cont = BX(cont); 1864 1865 BX.cleanNode(this.PARTS.CONTENT_DATA); 1866 cont.parentNode.removeChild(cont); 1867 this.PARTS.CONTENT_DATA.appendChild(cont); 1868 cont.style.display = 'block'; 1869 this.SetContent(cont.innerHTML); 1870}; 1871 1872// this method deprecated 1873BX.CDialog.prototype.adjustSize = function() 1874{ 1875}; 1876 1877// this method deprecated 1878BX.CDialog.prototype.__adjustSize = function() 1879{ 1880}; 1881 1882BX.CDialog.prototype.adjustSizeEx = function() 1883{ 1884 BX.defer(this.__adjustSizeEx, this)(); 1885}; 1886 1887BX.CDialog.prototype.__adjustSizeEx = function() 1888{ 1889 var ob = this.PARTS.CONTENT_DATA.firstChild, 1890 new_height = 0, 1891 marginTop, 1892 marginBottom; 1893 1894 while (ob) 1895 { 1896 if (BX.type.isElementNode(ob)) 1897 { 1898 marginTop = parseInt(BX.style(ob, 'margin-top'), 10); 1899 if (isNaN(marginTop)) 1900 marginTop = 0; 1901 marginBottom = parseInt(BX.style(ob, 'margin-bottom'), 10); 1902 if (isNaN(marginBottom)) 1903 marginBottom = 0; 1904 new_height += ob.offsetHeight + marginTop + marginBottom; 1905 } 1906 ob = BX.nextSibling(ob); 1907 } 1908 1909 if (new_height) 1910 this.PARTS.CONTENT_DATA.style.height = new_height + 'px'; 1911}; 1912 1913 1914BX.CDialog.prototype.__onResizeFinished = function() 1915{ 1916 BX.WindowManager.saveWindowSize( 1917 this.PARAMS.resize_id || this.PARAMS.content_url, {height: parseInt(this.PARTS.CONTENT_DATA.style.height), width: parseInt(this.PARTS.CONTENT_DATA.style.width)} 1918 ); 1919}; 1920 1921BX.CDialog.prototype.Show = function(bNotRegister) 1922{ 1923 if ((!this.PARAMS.content) && this.PARAMS.content_url && BX.ajax && !bNotRegister) 1924 { 1925 var wait = BX.showWait(); 1926 1927 BX.WindowManager.currently_loaded = this; 1928 1929 this.CreateOverlay(); 1930 this.OVERLAY.style.display = 'block'; 1931 this.OVERLAY.className = 'bx-core-dialog-overlay'; 1932 1933 var post_data = '', method = 'GET'; 1934 if (this.PARAMS.content_post) 1935 { 1936 post_data = this.PARAMS.content_post; 1937 method = 'POST'; 1938 } 1939 1940 var url = this.PARAMS.content_url 1941 + (this.PARAMS.content_url.indexOf('?')<0?'?':'&')+'bxsender=' + this._sender; 1942 1943 this.auth_callback = BX.delegate(function(){ 1944 this.PARAMS.content = ''; 1945 this.hideNotify(); 1946 this.Show(); 1947 }, this); 1948 1949 BX.ajax({ 1950 method: method, 1951 dataType: 'html', 1952 url: url, 1953 data: post_data, 1954 skipAuthCheck: true, 1955 onsuccess: BX.delegate(function(data) { 1956 BX.closeWait(null, wait); 1957 1958 this.SetContent(data || ' '); 1959 this.Show(); 1960 }, this) 1961 }); 1962 } 1963 else 1964 { 1965 BX.WindowManager.currently_loaded = null; 1966 BX.CDialog.superclass.Show.apply(this, arguments); 1967 1968 this.adjustPos(); 1969 1970 this.OVERLAY.className = 'bx-core-dialog-overlay'; 1971 1972 this.__adjustSize(); 1973 1974 BX.removeCustomEvent(this, 'onWindowResize', BX.proxy(this.__adjustSize, this)); 1975 BX.addCustomEvent(this, 'onWindowResize', BX.proxy(this.__adjustSize, this)); 1976 1977 if (this.PARAMS.resizable && (this.PARAMS.content_url || this.PARAMS.resize_id)) 1978 { 1979 BX.removeCustomEvent(this, 'onWindowResizeFinished', BX.proxy(this.__onResizeFinished, this)); 1980 BX.addCustomEvent(this, 'onWindowResizeFinished', BX.proxy(this.__onResizeFinished, this)); 1981 } 1982 } 1983}; 1984 1985BX.CDialog.prototype.GetInnerPos = function() 1986{ 1987 return {'width': parseInt(this.PARTS.CONTENT_DATA.style.width), 'height': parseInt(this.PARTS.CONTENT_DATA.style.height)}; 1988}; 1989 1990BX.CDialog.prototype.adjustPos = function() 1991{ 1992 if (!this.bExpanded) 1993 { 1994 var currentWindow = window; 1995 var topWindow = BX.PageObject.getRootWindow(); 1996 if (topWindow.BX.SidePanel && topWindow.BX.SidePanel.Instance && topWindow.BX.SidePanel.Instance.getTopSlider()) 1997 { 1998 currentWindow = topWindow.BX.SidePanel.Instance.getTopSlider().getWindow(); 1999 } 2000 var windowSize = currentWindow.BX.GetWindowInnerSize(); 2001 var windowScroll = currentWindow.BX.GetWindowScrollPos(); 2002 2003 var style = { 2004 left: parseInt(windowScroll.scrollLeft + windowSize.innerWidth / 2 - parseInt(this.DIV.offsetWidth) / 2) + 'px', 2005 top: Math.max(parseInt(windowScroll.scrollTop + windowSize.innerHe
2005ight / 2 - parseInt(this.DIV.offsetHeight) / 2), 0) + 'px' 2006 }; 2007 2008 BX.adjust(this.DIV, { 2009 style: style 2010 }); 2011 } 2012}; 2013 2014BX.CDialog.prototype.GetContent = function () {return this.PARTS.CONTENT_DATA}; 2015 2016BX.CDialog.prototype.btnSave = BX.CDialog.btnSave = { 2017 title: BX.message('JS_CORE_WINDOW_SAVE'), 2018 id: 'savebtn', 2019 name: 'savebtn', 2020 className: BX.browser.IsIE() && BX.browser.IsDoctype() && !BX.browser.IsIE10() ? '' : 'adm-btn-save', 2021 action: function () { 2022 this.disableUntilError(); 2023 this.parentWindow.PostParameters(); 2024 } 2025}; 2026 2027BX.CDialog.prototype.btnCancel = BX.CDialog.btnCancel = { 2028 title: BX.message('JS_CORE_WINDOW_CANCEL'), 2029 id: 'cancel', 2030 name: 'cancel', 2031 action: function () { 2032 this.parentWindow.Close(); 2033 } 2034}; 2035 2036BX.CDialog.prototype.btnClose = BX.CDialog.btnClose = { 2037 title: BX.message('JS_CORE_WINDOW_CLOSE'), 2038 id: 'close', 2039 name: 'close', 2040 action: function () { 2041 this.parentWindow.Close(); 2042 } 2043}; 2044 2045/* special child for admin forms loaded into public page */ 2046BX.CAdminDialog = function(arParams) 2047{ 2048 BX.CAdminDialog.superclass.constructor.apply(this, arguments); 2049 2050 this._sender = 'core_window_cadmindialog'; 2051 2052 BX.addClass(this.DIV, 'bx-core-adm-admin-dialog'); 2053 2054 this.PARTS.CONTENT.insertBefore(this.PARTS.HEAD, this.PARTS.CONTENT.firstChild); 2055 this.PARTS.HEAD.className = 'bx-core-adm-dialog-tabs'; 2056}; 2057BX.extend(BX.CAdminDialog, BX.CDialog); 2058 2059BX.CAdminDialog.prototype.SetHead = function() 2060{ 2061 BX.CAdminDialog.superclass.SetHead.apply(this, arguments); 2062 2063 if (this.PARTS.HEAD.firstChild && BX.type.isElementNode(this.PARTS.HEAD.firstChild)) 2064 { 2065 var ob = this.PARTS.HEAD.firstChild, new_width = 0, marginLeft = 0, marginRight = 0; 2066 2067 while (ob) 2068 { 2069 if (BX.type.isElementNode(ob)) 2070 { 2071 marginLeft = parseInt(BX.style(ob, 'margin-left'), 10); 2072 if (isNaN(marginLeft)) 2073 marginLeft = 0; 2074 marginRight = parseInt(BX.style(ob, 'margin-right'), 10); 2075 if (isNaN(marginRight)) 2076 marginRight = 0; 2077 new_width += ob.offsetWidth + marginLeft + marginRight; 2078 } 2079 ob = BX.nextSibling(ob); 2080 } 2081 2082 this.SETTINGS.min_width = Math.max(new_width, this.SETTINGS.min_width) - 2; 2083 if (this.PARAMS.width < this.SETTINGS.min_width) 2084 { 2085 BX.adjust(this.PARTS.CONTENT_DATA, { 2086 style: { 2087 width: this.SETTINGS.min_width + 'px' 2088 } 2089 }); 2090 } 2091 } 2092}; 2093 2094BX.CAdminDialog.prototype.SetContent = function(html) 2095{ 2096 this.__form = null; 2097 2098 if (BX.type.isElementNode(html)) 2099 { 2100 if (html.parentNode) 2101 html.parentNode.removeChild(html); 2102 } 2103 2104 this.PARAMS.content = html; 2105 BX.cleanNode(this.PARTS.CONTENT_DATA); 2106 2107 BX.adjust(this.PARTS.CONTENT_DATA, { 2108 children: [ 2109 this.PARAMS.content || ' ' 2110 ] 2111 }); 2112 2113 if (this.PARAMS.content_url && this.GetForm()) 2114 { 2115 this.__form.appendChild(BX.create('INPUT', {props:{type:'submit'},style:{display:'none'}})); 2116 this.__form.onsubmit = BX.delegate(this.__submit, this); 2117 } 2118}; 2119 2120BX.CAdminDialog.prototype.__expandGetSize = function() 2121{ 2122 var res = BX.CAdminDialog.superclass.__expandGetSize.apply(this, arguments); 2123 2124 res.width -= parseInt(BX.style(this.PARTS.CONTENT_DATA, 'padding-right')) + parseInt(BX.style(this.PARTS.CONTENT_DATA, 'padding-left')); 2125 res.height -= parseInt(BX.style(this.PARTS.CONTENT_DATA, 'padding-top')) + parseInt(BX.style(this.PARTS.CONTENT_DATA, 'padding-bottom')); 2126 2127 res.height -= this.PARTS.HEAD.offsetHeight; 2128 2129 return res; 2130}; 2131 2132BX.CAdminDialog.prototype.Submit = function() 2133{ 2134 var FORM = this.GetForm(); 2135 if (FORM && !FORM['bxpublic'] && !/bxpublic=/.test(FORM.action)) 2136 { 2137 FORM.appendChild(BX.create('INPUT', { 2138 props: { 2139 type: 'hidden', 2140 name: 'bxpublic', 2141 value: 'Y' 2142 } 2143 })); 2144 } 2145 2146 return BX.CAdminDialog.superclass.Submit.apply(this, arguments); 2147}; 2148 2149BX.CAdminDialog.prototype.btnSave = BX.CAdminDialog.btnSave = { 2150 title: BX.message('JS_CORE_WINDOW_SAVE'), 2151 id: 'savebtn', 2152 name: 'savebtn', 2153 className: 'adm-btn-save', 2154 action: function () { 2155 this.disableUntilError(); 2156 this.parentWindow.Submit(); 2157 } 2158}; 2159 2160BX.CAdminDialog.btnCancel = BX.CAdminDialog.superclass.btnCancel; 2161BX.CAdminDialog.btnClose = BX.CAdminDialog.superclass.btnClose; 2162 2163BX.CDebugDialog = function(arParams) 2164{ 2165 BX.CDebugDialog.superclass.constructor.apply(this, arguments); 2166}; 2167BX.extend(BX.CDebugDialog, BX.CDialog); 2168
2169BX.CDebugDialog.prototype.ShowDetails = function(div_id) 2170{ 2171 var div = BX(div_id); 2172 if (div) 2173 { 2174 if (this.div_detail_current) 2175 this.div_detail_current.style.display = 'none'; 2176 2177 div.style.display = 'block'; 2178 this.div_detail_current = div; 2179 } 2180}; 2181 2182BX.CDebugDialog.prototype.SetContent = function(html) 2183{ 2184 if (!html) 2185 return; 2186 2187 var arHtml = html.split('#DIVIDER#'); 2188 if (arHtml.length > 1) 2189 { 2190 this.PARAMS.content = arHtml[1]; 2191 2192 this.PARTS.CONTENT_DATA.style.overflow = 'hidden'; 2193 2194 BX.CDebugDialog.superclass.SetContent.apply(this, [arHtml[1]]); 2195 2196 this.PARTS.CONTENT_INNER = this.PARTS.CONTENT_DATA.firstChild.nextSibling; 2197 this.PARTS.CONTENT_TOP = this.PARTS.CONTENT_DATA.insertBefore(BX.create('DIV', { 2198 props: { 2199 className: 'bx-debug-content-top' 2200 }, 2201 html: arHtml[0] 2202 }), this.PARTS.CONTENT_INNER); 2203 this.PARTS.CONTENT_INNER.style.overflow = 'auto'; 2204 } 2205 else 2206 { 2207 BX.CDebugDialog.superclass.SetContent.apply(this, arguments); 2208 } 2209}; 2210 2211BX.CDebugDialog.prototype.__adjustSize = function() 2212{ 2213 BX.CDebugDialog.superclass.__adjustSize.apply(this, arguments); 2214 2215 if (this.PARTS.CONTENT_TOP) 2216 { 2217 var new_height = this.PARTS.CONTENT_DATA.offsetHeight - this.PARTS.HEAD.offsetHeight - this.PARTS.CONTENT_TOP.offsetHeight - 38; 2218 2219 if (new_height > 0) 2220 { 2221 this.PARTS.CONTENT_INNER.style.height = new_height + 'px'; 2222 } 2223 } 2224}; 2225 2226 2227/* class for dialog window with editors */ 2228 2229BX.CEditorDialog = function(arParams) 2230{ 2231 BX.CEditorDialog.superclass.constructor.apply(this, arguments); 2232 2233 BX.removeClass(this.PARTS.CONTENT, 'bx-core-adm-dialog-content-wrap'); 2234 BX.removeClass(this.PARTS.CONTENT_DATA, 'bx-core-adm-dialog-content'); 2235 2236 BX.removeClass(this.PARTS.CONTENT_DATA.lastChild, 'bx-core-adm-dialog-content-wrap-inner'); 2237 BX.removeClass(this.PARTS.BUTTONS_CONTAINER, 'bx-core-adm-dialog-buttons'); 2238 2239 BX.addClass(this.PARTS.CONTENT, 'bx-core-editor-dialog-content-wrap'); 2240 BX.addClass(this.PARTS.CONTENT_DATA, 'bx-core-editor-dialog-content'); 2241 BX.addClass(this.PARTS.BUTTONS_CONTAINER, 'bx-core-editor-dialog-buttons'); 2242}; 2243BX.extend(BX.CEditorDialog, BX.CDialog); 2244 2245BX.CEditorDialog.prototype.SetContent = function() 2246{ 2247 BX.CEditorDialog.superclass.SetContent.apply(this, arguments); 2248 2249 BX.removeClass(this.PARTS.CONTENT_DATA.lastChild, 'bx-core-adm-dialog-content-wrap-inner'); 2250}; 2251 2252/* class for wizards in admin section */ 2253BX.CWizardDialog = function(arParams) 2254{ 2255 BX.CWizardDialog.superclass.constructor.apply(this, arguments); 2256 2257 BX.removeClass(this.PARTS.CONTENT, 'bx-core-adm-dialog-content-wrap'); 2258 BX.removeClass(this.PARTS.CONTENT_DATA, 'bx-core-adm-dialog-content'); 2259 BX.removeClass(this.PARTS.CONTENT_DATA.lastChild, 'bx-core-adm-dialog-content-wrap-inner'); 2260 BX.removeClass(this.PARTS.BUTTONS_CONTAINER, 'bx-core-adm-dialog-buttons'); 2261 2262 BX.addClass(this.PARTS.CONTENT, 'bx-core-wizard-dialog-content-wrap'); 2263}; 2264 2265BX.extend(BX.CWizardDialog, BX.CDialog); 2266 2267/* class for auth dialog */ 2268BX.CAuthDialog = function(arParams) 2269{ 2270 arParams.resizable = false; 2271 arParams.width = 350;
2272 arParams.height = 200; 2273 2274 arParams.buttons = [this.btnSave]; 2275 2276 BX.CAuthDialog.superclass.constructor.apply(this, arguments); 2277 this._sender = 'core_window_cauthdialog'; 2278 2279 BX.addClass(this.DIV, 'bx-core-auth-dialog'); 2280 2281 BX.AUTHAGENT = this; 2282}; 2283BX.extend(BX.CAuthDialog, BX.CDialog); 2284 2285BX.CAuthDialog.prototype.btnSave = BX.CAuthDialog.btnSave = { 2286 title: BX.message('JS_CORE_WINDOW_AUTH'), 2287 id: 'savebtn', 2288 name: 'savebtn', 2289 className: 'adm-btn-save', 2290 action: function () { 2291 this.disableUntilError(); 2292 this.parentWindow.Submit('', this.parentWindow.PARAMS.content_url); 2293 } 2294}; 2295 2296BX.CAuthDialog.prototype.SetError = function(error) 2297{ 2298 BX.closeWait(); 2299 2300 if (!!error) 2301 this.ShowError(error.MESSAGE || error); 2302}; 2303 2304BX.CAuthDialog.prototype.setAuthResult = function(result) 2305{ 2306 BX.closeWait(); 2307 2308 if (result === false) 2309 { 2310 this.Close(); 2311 if (this.PARAMS.callback) 2312 this.PARAMS.callback(); 2313 } 2314 else 2315 { 2316 this.SetError(result); 2317 } 2318}; 2319 2320/* MENU CLASSES */ 2321 2322BX.CWindowFloat = function(node) 2323{ 2324 BX.CWindowFloat.superclass.constructor.apply(this, [node, 'float']); 2325 2326 this.SETTINGS.resizable = false; 2327}; 2328BX.extend(BX.CWindowFloat, BX.CWindow); 2329 2330BX.CWindowFloat.prototype.adjustPos = function() 2331{ 2332 if (this.PARAMS.parent) 2333 this.adjustToNode(); 2334 else if (this.PARAMS.x && this.PARAMS.y) 2335 this.adjustToPos([this.PARAMS.x, this.PARAMS.y]); 2336}; 2337 2338BX.CWindowFloat.prototype.adjustToPos = function(pos) 2339{ 2340 this.DIV.style.left = parseInt(pos[0]) + 'px'; 2341 this.DIV.style.top = parseInt(pos[1]) + 'px'; 2342}; 2343 2344BX.CWindowFloat.prototype.adjustToNodeGetPos = function() 2345{ 2346 return BX.pos(this.PARAMS.parent); 2347}; 2348 2349BX.CWindowFloat.prototype.adjustToNode = function(el) 2350{ 2351 el = el || this.PARAMS.parent; 2352 2353 this.PARAMS.parent = BX(el); 2354 2355 if (this.PARAMS.parent) 2356 { 2357 var pos = this.adjustToNodeGetPos(); 2358 2359 this.DIV.style.top = pos.top + 'px';//(pos.top - 26) + 'px'; 2360 this.DIV.style.left = pos.left + 'px'; 2361 2362 this.PARAMS.parent.OPENER = this; 2363 } 2364}; 2365 2366BX.CWindowFloat.prototype.Show = function() 2367{ 2368 this.adjustToPos([-1000, -1000]); 2369 BX.CWindowFloat.superclass.Show.apply(this, arguments); 2370 this.adjustPos(); 2371}; 2372 2373/* menu opener class */ 2374/* 2375{ 2376 DOMNode DIV, 2377 BX.CMenu or Array MENU, 2378 TYPE = 'hover' | 'click', 2379 TIMEOUT: 1000 2380 ATTACH_MODE: 'top' | 'right' 2381 ACTIVE_CLASS: className for opener element when menu is opened 2382} 2383*/ 2384BX.COpener = function(arParams) 2385{ 2386 this.PARAMS = arParams || {}; 2387 2388 this.MENU = arParams.MENU || []; 2389 2390 this.DIV = arParams.DIV; 2391 this.ATTACH = arParams.ATTACH || arParams.DIV; 2392 this.ATTACH_MODE = arParams.ATTACH_MODE || 'bottom'; 2393 2394 this.ACTIVE_CLASS = arParams.ACTIVE_CLASS || ''; 2395 this.PUBLIC_FRAME = arParams.PUBLIC_FRAME || 0; 2396 this.LEVEL = arParams.LEVEL || 0; 2397 2398 this.CLOSE_ON_CLICK = typeof arParams.CLOSE_ON_CLICK != 'undefined' ? !!arParams.CLOSE_ON_CLICK : true; 2399 this.ADJUST_ON_CLICK = typeof arParams.ADJUST_ON_CLICK != 'undefined' ? !!arParams.ADJUST_ON_CLICK : true; 2400 2401 this.TYPE = this.PARAMS.TYPE == 'hover' ? 'hover' : 'click'; 2402 2403 this._openTimeout = null; 2404 2405 if (this.PARAMS.TYPE == 'hover' && arParams.TIMEOUT !== 0)
2406 this.TIMEOUT = arParams.TIMEOUT || 1000; 2407 else 2408 this.TIMEOUT = 0; 2409 2410 this.bMenuInit = false; 2411 2412 if (!!this.PARAMS.MENU_URL) 2413 { 2414 this.bMenuLoaded = false; 2415 this.bMenuLoading = false; 2416 2417 this.MENU = [{ 2418 TEXT: BX.message('JS_CORE_LOADING'), 2419 CLOSE_ON_CLICK: false 2420 }]; 2421 2422 if (this.PARAMS.MENU_PRELOAD) 2423 { 2424 BX.defer(this.Load, this)(); 2425 } 2426 } 2427 2428 BX.ready(BX.defer(this.Init, this)); 2429}; 2430 2431BX.COpener.prototype.Init = function() 2432{ 2433 this.DIV = BX(this.DIV); 2434 2435 switch (this.TYPE) 2436 { 2437 case 'hover': 2438 BX.bind(this.DIV, 'mouseover', BX.proxy(this.Open, this)); 2439 BX.bind(this.DIV, 'click', BX.proxy(this.Toggle, this)); 2440 break; 2441 2442 case 'click': 2443 BX.bind(this.DIV, 'click', BX.proxy(this.Toggle, this)); 2444 break; 2445 } 2446 2447 //BX.bind(window, 'scroll', BX.delegate(this.__close_immediately, this)); 2448 2449 //this.bMenuInit = false; 2450}; 2451 2452BX.COpener.prototype.Load = function() 2453{ 2454 if (this.PARAMS.MENU_URL && !this.bMenuLoaded) 2455 { 2456 if (!this.bMenuLoading) 2457 { 2458 var url = this.PARAMS.MENU_URL; 2459 if (url.indexOf('sessid=') <= 0) 2460 url += (url.indexOf('?') > 0 ? '&' : '?') + 'sessid=' + BX.bitrix_sessid(); 2461 2462 this.bMenuLoading = true; 2463 BX.ajax.loadJSON(url, BX.proxy(this.SetMenu, this), BX.proxy(this.LoadFailed, this)); 2464 } 2465 } 2466}; 2467 2468BX.COpener.prototype.SetMenu = function(menu) 2469{ 2470 this.bMenuLoaded = true; 2471 this.bMenuLoading = false; 2472 if (this.bMenuInit) 2473 { 2474 this.MENU.setItems(menu); 2475 } 2476 else 2477 { 2478 this.MENU = menu; 2479 } 2480}; 2481 2482BX.COpener.prototype.LoadFailed = function(type, error) 2483{ 2484 this.bMenuLoading = false; 2485 this.SetMenu([{ 2486 TEXT: BX.message('JS_CORE_NO_DATA'), 2487 CLOSE_ON_CLICK: true 2488 }]); 2489 BX.debug(arguments); 2490}; 2491 2492BX.COpener.prototype.checkAdminMenu = function() 2493{ 2494 if (document.documentElement.id == 'bx-admin-prefix') 2495 return true; 2496 2497 return !!BX.findParent(this.DIV, {property: {id: 'bx-admin-prefix'}}); 2498}; 2499 2500BX.COpener.prototype.Toggle = function(e) 2501{ 2502 this.__clear_timeout(); 2503 2504 if (!this.bMenuInit || !this.MENU.visible()) 2505 { 2506 var t = this.TIMEOUT; 2507 this.TIMEOUT = 0; 2508 this.Open(e); 2509 this.TIMEOUT = t; 2510 } 2511 else 2512 { 2513 this.MENU.Close(); 2514 } 2515 2516 return !!(e||window.event) && BX.PreventDefault(e); 2517}; 2518 2519BX.COpener.prototype.GetMenu = function() 2520{ 2521 if (!this.bMenuInit) 2522 { 2523 if (BX.type.isArray(this.MENU)) 2524 { 2525 this.MENU = new BX.CMenu({ 2526 ITEMS: this.MENU, 2527 ATTACH_MODE: this.ATTACH_MODE, 2528 SET_ID: this.checkAdminMenu() ? 'bx-admin-prefix' : '', 2529 CLOSE_ON_CLICK: !!this.CLOSE_ON_CLICK, 2530 ADJUST_ON_CLICK: !!this.ADJUST_ON_CLICK, 2531 PUBLIC_FRAME: !!this.PUBLIC_FRAME, 2532 LEVEL: this.LEVEL, 2533 parent: BX(this.DIV), 2534 parent_attach: BX(this.ATTACH) 2535 }); 2536 2537 if (this.LEVEL > 0) 2538 { 2539 BX.bind(this.MENU.DIV, 'mouseover', BX.proxy(this._on_menu_hover, this)); 2540 BX.bind(this.MENU.DIV, 'mouseout', BX.proxy(this._on_menu_hout, this)); 2541 } 2542 } 2543 2544 BX.addCustomEvent(this.MENU, 'onMenuOpen', BX.proxy(this.handler_onopen, this)); 2545 BX.addCustomEvent(this.MENU, 'onMenuClose', BX.proxy(this.handler_onclose, this)); 2546 2547 BX.addCustomEvent('onMenuItemHover', BX.proxy(this.handler_onover, this)); 2548 2549 this.bMenuInit = true; 2550 } 2551 2552 return this.MENU; 2553}; 2554 2555BX.COpener.prototype.Open = function() 2556{ 2557 this.GetMenu(); 2558 2559 this.bOpen = true; 2560 2561 this.__clear_timeout(); 2562 2563 if (this.TIMEOUT > 0) 2564 { 2565 BX.bind(this.DIV, 'mouseout', BX.proxy(this.__clear_timeout, this)); 2566 this._openTimeout = setTimeout(BX.proxy(this.__open, this), this.TIMEOUT); 2567 } 2568 else 2569 { 2570 this.__open(); 2571 } 2572 2573 if (!!this.PARAMS.MENU_URL && !this.bMenuLoaded) 2574 { 2575 this._loadTimeout = setTimeout(BX.proxy(this.Load, this), parseInt(this.TIMEOUT/2)); 2576 } 2577 2578 return true; 2579}; 2580 2581BX.COpener.prototype.__clear_timeout = function() 2582{ 2583 if (!!this._openTimeout) 2584 clearTimeout(this._openTimeout); 2585 if (!!this._loadTimeout) 2586 clearTimeout(this._loadTimeout); 2587 2588 BX.unbind(this.DIV, 'mouseout', BX.proxy(this.__clear_timeout, this)); 2589}; 2590 2591BX.COpener.prototype._on_menu_hover = function() 2592{ 2593 this.bMenuHover = true; 2594 2595 this.__clear_timeout(); 2596 2597 if (this.ACTIVE_CLASS) 2598 BX.addClass(this.DIV, this.ACTIVE_CLASS); 2599 2600}; 2601 2602BX.COpener.prototype._on_menu_hout = function() 2603{ 2604 this.bMenuHover = false; 2605}; 2606 2607BX.COpener.prototype.handler_onover = function(level, opener) 2608{ 2609 if (this.bMenuHover) 2610 return; 2611 2612 if (opener != this && level == this.LEVEL-1 && this.ACTIVE_CLASS) 2613 { 2614 BX.removeClass(this.DIV, this.ACTIVE_CLASS); 2615 } 2616 2617 if (this.bMenuInit && level <= this.LEVEL-1 && this.MENU.visible()) 2618 { 2619 if (opener != this) 2620 { 2621 this.__clear_timeout(); 2622 this._openTimeout = setTimeout(BX.proxy(this.Close, this), this.TIMEOUT); 2623 } 2624 } 2625}; 2626 2627BX.COpener.prototype.handler_onopen = function() 2628{ 2629 this.bOpen = true; 2630 2631 if (this.ACTIVE_CLASS) 2632 BX.addClass(this.DIV, this.ACTIVE_CLASS); 2633 2634 BX.defer(function() { 2635 BX.onCustomEvent(this, 'onOpenerMenuOpen'); 2636 }, this)(); 2637}; 2638 2639BX.COpener.prototype.handler_onclose = function() 2640{ 2641 this.bOpen = false;
2642 BX.onCustomEvent(this, 'onOpenerMenuClose'); 2643 2644 if (this.ACTIVE_CLASS) 2645 BX.removeClass(this.DIV, this.ACTIVE_CLASS); 2646}; 2647 2648BX.COpener.prototype.Close = function() 2649{ 2650 if (!this.bMenuInit) 2651 return; 2652 2653 if (!!this._openTimeout) 2654 clearTimeout(this._openTimeout); 2655 2656 this.bOpen = false; 2657 2658 this.__close(); 2659}; 2660 2661BX.COpener.prototype.__open = function() 2662{ 2663 this.__clear_timeout(); 2664 2665 if (this.bMenuInit && this.bOpen && !this.MENU.visible()) 2666 this.MENU.Show(); 2667}; 2668 2669BX.COpener.prototype.__close = function() 2670{ 2671 if (this.bMenuInit && !this.bOpen && this.MENU.visible()) 2672 this.MENU.Hide(); 2673}; 2674 2675BX.COpener.prototype.__close_immediately = function() { 2676 this.bOpen = false; this.__close(); 2677}; 2678 2679BX.COpener.prototype.isMenuVisible = function() { 2680 return null != this.MENU.visible && this.MENU.visible() 2681}; 2682 2683/* common menu class */ 2684 2685BX.CMenu = function(arParams) 2686{ 2687 BX.CMenu.superclass.constructor.apply(this); 2688 2689 this.DIV.style.width = 'auto';//this.DIV.firstChild.offsetWidth + 'px'; 2690 this.DIV.style.height = 'auto';//this.DIV.firstChild.offsetHeight + 'px'; 2691 2692 this.PARAMS = arParams || {}; 2693 this.PARTS = {}; 2694 2695 this.PARAMS.ATTACH_MODE = this.PARAMS.ATTACH_MODE || 'bottom'; 2696 this.PARAMS.CLOSE_ON_CLICK = typeof this.PARAMS.CLOSE_ON_CLICK == 'undefined' ? true : this.PARAMS.CLOSE_ON_CLICK; 2697 this.PARAMS.ADJUST_ON_CLICK = typeof this.PARAMS.ADJUST_ON_CLICK == 'undefined' ? true : this.PARAMS.ADJUST_ON_CLICK; 2698 this.PARAMS.PUBLIC_FRAME = typeof this.PARAMS.PUBLIC_FRAME == 'undefined' ? false : this.PARAMS.PUBLIC_FRAME; 2699 this.PARAMS.LEVEL = this.PARAMS.LEVEL || 0; 2700 2701 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 : ''); 2702 if (!!this.PARAMS.SET_ID) 2703 this.DIV.id = this.PARAMS.SET_ID; 2704 2705 if (this.PARAMS.LEVEL == 0) 2706 { 2707 this.ARROW = this.DIV.appendChild(BX.create('SPAN', {props: {className: 'bx-core-popup-menu-angle'}, style: {left:'15px'}})); 2708 } 2709 2710 if (!!this.PARAMS.CLASS_NAME) 2711 this.DIV.className += ' ' + this.PARAMS.CLASS_NAME; 2712 2713 BX.bind(this.DIV, 'click', BX.eventCancelBubble); 2714 2715 this.ITEMS = []; 2716 2717 this.setItems(this.PARAMS.ITEMS); 2718 2719 BX.addCustomEvent('onMenuOpen', BX.proxy(this._onMenuOpen, this)); 2720 BX.addCustomEvent('onMenuItemSelected', BX.proxy(this.Hide, this)); 2721}; 2722BX.extend(BX.CMenu, BX.CWindowFloat); 2723 2724BX.CMenu.broadcastCloseEvent = function() 2725{ 2726 BX.onCustomEvent("onMenuItemSelected"); 2727}; 2728 2729BX.CMenu._toggleChecked = function() 2730{ 2731 BX.toggleClass(this, 'bx-core-popup-menu-item-checked'); 2732}; 2733 2734BX.CMenu._itemDblClick = function() 2735{ 2736 window.location.href = this.href; 2737}; 2738 2739BX.CMenu.prototype.toggleArrow = function(v) 2740{ 2741 if (!!this.ARROW) 2742 { 2743 if (typeof v == 'undefined') 2744 { 2745 v = this.ARROW.style.visibility == 'hidden'; 2746 } 2747 2748 this.ARROW.style.visibility = !!v ? 'visible' : 'hidden'; 2749 } 2750}; 2751 2752BX.CMenu.prototype.visible = function() 2753{ 2754 return this.DIV.style.display !== 'none'; 2755}; 2756 2757BX.CMenu.prototype._onMenuOpen = function(menu, menu_level) 2758{ 2759 if (this.visible()) 2760 { 2761 if (menu_level == this.PARAMS.LEVEL && menu != this) 2762 { 2763 this.Hide(); 2764 } 2765 } 2766}; 2767 2768BX.CMenu.prototype.onUnRegister = function() 2769{ 2770 if (!this.visible()) 2771 return; 2772 2773 this.Hide(); 2774}; 2775 2776BX.CMenu.prototype.setItems = function(items) 2777{ 2778 this.PARAMS.ITEMS = items; 2779 2780 BX.cleanNode(this.DIV); 2781 2782 if (!!this.ARROW) 2783 this.DIV.appendChild(this.ARROW); 2784 2785 if (this.PARAMS.ITEMS) 2786 { 2787 this.PARAMS.ITEMS = BX.util.array_values(this.PARAMS.ITEMS); 2788 2789 var bIcons = false; 2790 var cnt = 0; 2791 for (var i = 0, len = this.PARAMS.ITEMS.length; i < len; i++) 2792 { 2793 if ((i == 0 || i == len-1) && this.PARAMS.ITEMS[i].SEPARATOR) 2794 continue; 2795 2796 cnt++; 2797 2798 if (!bIcons) 2799 bIcons = !!this.PARAMS.ITEMS[i].GLOBAL_ICON; 2800 2801 this.addItem(this.PARAMS.ITEMS[i], i); 2802 } 2803 2804 // Occam turning in his grave 2805 if (cnt === 1) 2806 BX.addClass(this.DIV, 'bx-core-popup-menu-single-item'); 2807 else 2808 BX.removeClass(this.DIV, 'bx-core-popup-menu-single-item'); 2809 2810 if (!bIcons) 2811 BX.addClass(this.DIV, 'bx-core-popup-menu-no-icons'); 2812 else 2813 BX.removeClass(this.DIV, 'bx-core-popup-menu-no-icons'); 2814 2815 } 2816}; 2817 2818BX.CMenu.prototype.addItem = function(item) 2819{ 2820 this.ITEMS.push(item); 2821 2822 if (item.SEPARATOR) 2823 { 2824 item.NODE = BX.create( 2825 'DIV', {props: {className: 'bx-core-popup-menu-separator'}} 2826 ); 2827 } 2828 else 2829 { 2830 var bHasMenu = (!!item.MENU 2831 && (
2832 (BX.type.isArray(item.MENU) && item.MENU.length > 0) 2833 || item.MENU instanceof BX.CMenu 2834 ) || !!item.MENU_URL 2835 ); 2836 2837 if (item.DISABLED) 2838 { 2839 item.CLOSE_ON_CLICK = false; 2840 item.LINK = null; 2841 item.ONCLICK = null; 2842 item.ACTION = null; 2843 } 2844 2845 var attrs = {}; 2846 if (!!item.LINK || BX.browser.IsIE() && !BX.browser.IsDoctype()) 2847 { 2848 attrs.href = item.LINK || 'javascript:void(0)'; 2849 } 2850 if (this.PARAMS.PUBLIC_FRAME) 2851 { 2852 attrs.target = '_top'; 2853 } 2854 2855 item.NODE = BX.create(!!item.LINK || BX.browser.IsIE() && !BX.browser.IsDoctype() ? 'A' : 'SPAN', { 2856 props: { 2857 className: 'bx-core-popup-menu-item' 2858 + (bHasMenu ? ' bx-core-popup-menu-item-opener' : '') 2859 + (!!item.DEFAULT ? ' bx-core-popup-menu-item-default' : '') 2860 + (!!item.DISABLED ? ' bx-core-popup-menu-item-disabled' : '') 2861 + (!!item.CHECKED ? ' bx-core-popup-menu-item-checked' : ''), 2862 title: !!BX.message['MENU_ENABLE_TOOLTIP'] || !!item.SHOW_TITLE ? item.TITLE || '' : '', 2863 BXMENULEVEL: this.PARAMS.LEVEL 2864 }, 2865 attrs: attrs, 2866 events: { 2867 mouseover: function() 2868 { 2869 BX.onCustomEvent('onMenuItemHover', [this.BXMENULEVEL, this.OPENER]) 2870 } 2871 }, 2872 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>' 2873 }); 2874 2875 if (bHasMenu && !item.DISABLED) 2876 { 2877 item.NODE.OPENER = new BX.COpener({ 2878 DIV: item.NODE, 2879 ACTIVE_CLASS: 'bx-core-popup-menu-item-opened', 2880 TYPE: 'hover', 2881 MENU: item.MENU, 2882 MENU_URL: item.MENU_URL, 2883 MENU_PRELOAD: !!item.MENU_PRELOAD, 2884 LEVEL: this.PARAMS.LEVEL + 1, 2885 ATTACH_MODE:'right', 2886 TIMEOUT: 500 2887 }); 2888 } 2889 else if (this.PARAMS.CLOSE_ON_CLICK && (typeof item.CLOSE_ON_CLICK == 'undefined' || !!item.CLOSE_ON_CLICK)) 2890 { 2891 BX.bind(item.NODE, 'click', BX.CMenu.broadcastCloseEvent); 2892 } 2893 else if (this.PARAMS.ADJUST_ON_CLICK && (typeof item.ADJUST_ON_CLICK == 'undefined' || !!item.ADJUST_ON_CLICK)) 2894 { 2895 BX.bind(item.NODE, 'click', BX.defer(this.adjustPos, this)); 2896 } 2897 2898 if (bHasMenu && !!item.LINK) 2899 { 2900 BX.bind(item.NODE, 'dblclick', BX.CMenu._itemDblClick); 2901 } 2902 2903 if (typeof item.CHECKED != 'undefined') 2904 { 2905 BX.bind(item.NODE, 'click', BX.CMenu._toggleChecked); 2906 } 2907 2908 item.ONCLICK = item.ACTION || item.ONCLICK; 2909 if (!!item.ONCLICK) 2910 { 2911 if (BX.type.isString(item.ONCLICK)) 2912 { 2913 item.ONCLICK = new Function("event", item.ONCLICK); 2914 } 2915 2916 BX.bind(item.NODE, 'click', item.ONCLICK); 2917 } 2918 } 2919 2920 this.DIV.appendChild(item.NODE); 2921}; 2922 2923BX.CMenu.prototype._documentClickBind = function() 2924{ 2925 this._documentClickUnBind(); 2926 BX.bind(document, 'click', BX.proxy(this._documentClick, this)); 2927}; 2928 2929BX.CMenu.prototype._documentClickUnBind = function() 2930{ 2931 BX.unbind(document, 'click', BX.proxy(this._documentClick, this)); 2932}; 2933 2934BX.CMenu.prototype._documentClick = function(e) 2935{ 2936 e = e||window.event; 2937 if(!!e && !(BX.getEventButton(e) & BX.MSLEFT)) 2938 return; 2939 2940 this.Close(); 2941}; 2942 2943BX.CMenu.prototype.Show = function() 2944{ 2945 BX.onCustomEvent(this, 'onMenuOpen', [this, this.PARAMS.LEVEL]); 2946 BX.CMenu.superclass.Show.apply(this, []); 2947 2948 this.bCloseEventFired = false; 2949 2950 BX.addCustomEvent(this.PARAMS.parent_attach, 'onChangeNodePosition', BX.proxy(this.adjustToNode, this)); 2951 2952 (BX.defer(this._documentClickBind, this))(); 2953}; 2954 2955BX.CMenu.prototype.Close = // we shouldn't 'Close' window - only hide 2956BX.CMenu.prototype.Hide = function() 2957{ 2958 if (!this.visible()) 2959 return; 2960 2961 BX.removeCustomEvent(this.PARAMS.parent_attach, 'onChangeNodePosition', BX.proxy(this.adjustToNode, this)); 2962 2963 this._documentClickUnBind(); 2964 2965 if (!this.bCloseEventFired) 2966 { 2967 BX.onCustomEvent(this, 'onMenuClose', [this, this.PARAMS.LEVEL]); 2968 this.bCloseEventFired = true; 2969 } 2970 BX.CMenu.superclass.Hide.apply(this, arguments); 2971 2972 2973// this.DIV.onclick = null; 2974 //this.PARAMS.parent.onclick = null; 2975}; 2976 2977BX.CMenu.prototype.__adjustMenuToNode = function() 2978{ 2979 var pos = BX.pos(this.PARAMS.parent_attach), 2980 bFixed = !!BX.findParent(this.PARAMS.parent_attach, BX.is_fixed); 2981 2982 if (bFixed) 2983 this.DIV.style.position = 'fixed'; 2984 else 2985 this.DIV.style.position = 'absolute'; 2986 2987 if (!pos.top) 2988 { 2989 this.DIV.style.top = '-1000px'; 2990 this.DIV.style.left = '-1000px'; 2991 } 2992 2993 if (this.bTimeoutSet) return; 2994 2995 var floatWidth = this.DIV.offsetWidth, floatHeight = this.DIV.offsetHeight; 2996 if (!floatWidth) 2997 { 2998 setTimeout(BX.delegate(function(){ 2999 this.bTimeoutSet = false; this.__adjustMenuToNode(); 3000 }, this), 100); 3001 3002 this.bTimeoutSet = true; 3003 return; 3004 } 3005 3006 var menu_pos = {}, 3007 wndSize = BX.GetWindowSize(); 3008 3009/* 3010 if (BX.browser.IsIE() && !BX.browser.IsDoctype()) 3011 { 3012 pos.top -= 4; pos.bottom -= 4; 3013 pos.left -= 2; pos.right -= 2; 3014 } 3015*/ 3016 3017 switch (this.PARAMS.ATTACH_MODE) 3018 { 3019 case 'bottom': 3020 menu_pos.top = pos.bottom + 9; 3021 menu_pos.left = pos.left; 3022 3023 var arrowPos = 0; 3024 if (!!this.ARROW) 3025 { 3026 if (pos.width > floatWidth) 3027 arrowPos = parseInt(floatWidth/2 - 7); 3028 else 3029 arrowPos = parseInt(Math.min(floatWidth, pos.width)/2 - 7); 3030 3031 if (arrowPos < 7) 3032 { 3033 menu_pos.left -= 15; 3034 arrowPos += 15; 3035 } 3036 } 3037 3038 if (menu_pos.left > wndSize.scrollWidth - floatWidth - 10) 3039 { 3040 var orig_menu_pos = menu_pos.left; 3041 menu_pos.left = wndSize.scrollWidth - floatWidth - 10; 3042 3043 if (!!this.ARROW) 3044 arrowPos += orig_menu_pos - menu_pos.left; 3045 } 3046 3047 if (bFixed) 3048 { 3049 menu_pos.left -= wndSize.scrollLeft; 3050 } 3051 3052 if (!!this.ARROW) 3053 this.ARROW.style.left = arrowPos + 'px'; 3054 break; 3055 case 'right': 3056 menu_pos.top = pos.top-1; 3057 menu_pos.left = pos.right; 3058 3059 if (menu_pos.left > wndSize.scrollWidth - floatWidth - 10) 3060 { 3061 menu_pos.left = pos.left - floatWidth - 1; 3062 } 3063 break; 3064 } 3065 3066 if (bFixed) 3067 { 3068 menu_pos.top -= wndSize.scrollTop; 3069 } 3070 3071 if (!!this.ARROW) 3072 this.ARROW.className = 'bx-core-popup-menu-angle'; 3073 3074 if((menu_pos.top + floatHeight >
3074 wndSize.scrollTop + wndSize.innerHeight) 3075 || (menu_pos.top + floatHeight > wndSize.scrollHeight)) 3076 { 3077 var new_top = this.PARAMS.ATTACH_MODE == 'bottom' 3078 ? pos.top - floatHeight - 9 3079 : pos.bottom - floatHeight + 1; 3080 3081 if((new_top > wndSize.scrollTop) 3082 || (menu_pos.top + floatHeight > wndSize.scrollHeight)) 3083 { 3084 if ((menu_pos.top + floatHeight > wndSize.scrollHeight)) 3085 { 3086 menu_pos.top = Math.max(0, wndSize.scrollHeight-floatHeight); 3087 this.toggleArrow(false); 3088 } 3089 else 3090 { 3091 menu_pos.top = new_top; 3092 3093 if (!!this.ARROW) 3094 this.ARROW.className = 'bx-core-popup-menu-angle-bottom'; 3095 } 3096 } 3097 } 3098 3099 if (menu_pos.top + menu_pos.left == 0) 3100 { 3101 this.Hide(); 3102 } 3103 else 3104 { 3105 this.DIV.style.top = menu_pos.top + 'px'; 3106 this.DIV.style.left = menu_pos.left + 'px'; 3107 } 3108}; 3109 3110BX.CMenu.prototype.adjustToNode = function(el) 3111{ 3112 this.PARAMS.parent_attach = BX(el) || this.PARAMS.parent_attach || this.PARAMS.parent; 3113 this.__adjustMenuToNode(); 3114}; 3115 3116 3117/* components toolbar class */ 3118 3119BX.CMenuOpener = function(arParams) 3120{ 3121 BX.CMenuOpener.superclass.constructor.apply(this); 3122 3123 this.PARAMS = arParams || {}; 3124 this.setParent(this.PARAMS.parent); 3125 this.PARTS = {}; 3126 3127 this.SETTINGS.drag_restrict = true; 3128 3129 this.defaultAction = null; 3130 3131 this.timeout = 500; 3132 3133 this.DIV.className = 'bx-component-opener'; 3134 this.DIV.ondblclick = BX.PreventDefault; 3135 3136 if (this.PARAMS.component_id) 3137 { 3138 this.PARAMS.transform = !!this.PARAMS.transform; 3139 } 3140 3141 this.OPENERS = []; 3142 3143 this.DIV.appendChild(BX.create('SPAN', { 3144 props: {className: 'bx-context-toolbar' + (this.PARAMS.transform ? ' bx-context-toolbar-vertical-mode' : '')} 3145 })); 3146 3147 //set internal structure and register draggable element 3148 this.PARTS.INNER = this.DIV.firstChild.appendChild(BX.create('SPAN', { 3149 props: {className: 'bx-context-toolbar-inner'}, 3150 html: '<span class="bx-context-toolbar-drag-icon"></span><span class="bx-context-toolbar-vertical-line"></span><br>' 3151 })); 3152 3153 this.EXTRA_BUTTONS = {}; 3154 3155 var btnCount = 0; 3156 for (var i = 0, len = this.PARAMS.menu.length; i < len; i++) 3157 { 3158 var item = this.addItem(this.PARAMS.menu[i]); 3159 if (null != item) 3160 { 3161 btnCount++; 3162 this.PARTS.INNER.appendChild(item); 3163 this.PARTS.INNER.appendChild(BX.create('BR')); 3164 } 3165 } 3166 var bHasButtons = btnCount > 0; 3167 3168 //menu items will be attached here 3169 3170 this.PARTS.ICONS = this.PARTS.INNER.appendChild(BX.create('SPAN', { 3171 props: {className: 'bx-context-toolbar-icons'} 3172 })); 3173 3174 if (this.PARAMS.component_id) 3175 { 3176 this.PARAMS.pin = !!this.PARAMS.pin; 3177 3178 if (bHasButtons) 3179 this.PARTS.ICONS.appendChild(BX.create('SPAN', {props: {className: 'bx-context-toolbar-separator'}})); 3180 3181 this.PARTS.ICON_PIN = this.PARTS.ICONS.appendChild(BX.create('A', { 3182 attrs: { 3183 href: 'javascript:void(0)' 3184 }, 3185 props: { 3186 className: this.PARAMS.pin 3187 ? 'bx-context-toolbar-pin-fixed' 3188 : 'bx-context-toolbar-pin' 3189 }, 3190 events: { 3191 click: BX.delegate(this.__pin_btn_clicked, this) 3192 } 3193 })); 3194 } 3195 3196 3197 if (this.EXTRA_BUTTONS['components2_props']) 3198 { 3199 var btn = this.EXTRA_BUTTONS['components2_props'] || {URL: 'javascript:void(0)'}; 3200 if (null == this.defaultAction) 3201 { 3202 this.defaultAction = btn.ONCLICK; 3203 this.defaultActionTitle = btn.TITLE || btn.TEXT; 3204 } 3205 3206 btn.URL = 'javascript:' + BX.util.urlencode(btn.ONCLICK); 3207 3208 this.ATTACH = this.PARTS.ICONS.appendChild(BX.create('SPAN', { 3209 props: {className: 'bx-context-toolbar-button bx-context-toolbar-button-settings' }, 3210 children: 3211 [ 3212 BX.create('SPAN', 3213 { 3214 props:{className: 'bx-context-toolbar-button-inner'}, 3215 children: 3216 [ 3217 BX.create('A', { 3218 attrs: {href: btn.URL}, 3219 events: { 3220 mouseover: BX.proxy(this.__msover_text, this), 3221 mouseout: BX.proxy(this.__msout_text, this), 3222 mousedown: BX.proxy(this.__msdown_text, this) 3223 }, 3224 html: '<span class="bx-context-toolbar-button-icon bx-context-toolbar-settings-icon"></span>' 3225 }), 3226 BX.create('A', { 3227 attrs: {href: 'javascript: void(0)'}, 3228 props: {className: 'bx-context-toolbar-button-arrow'}, 3229 events: { 3230 mouseover: BX.proxy(this.__msover_arrow, this), 3231 mouseout: BX.proxy(this.__msout_arrow, this), 3232 mousedown: BX.proxy(this.__msdown_arrow, this) 3233 }, 3234 html: '<span class="bx-context-toolbar-button-arrow"></span>' 3235 }) 3236 ] 3237 }) 3238 ] 3239 })); 3240
3241 this.OPENER = this.ATTACH.firstChild.lastChild; 3242 3243 var opener = this.attachMenu(this.EXTRA_BUTTONS['components2_submenu']['MENU']); 3244 3245 BX.addCustomEvent(opener, 'onOpenerMenuOpen', BX.proxy(this.__menu_open, this)); 3246 BX.addCustomEvent(opener, 'onOpenerMenuClose', BX.proxy(this.__menu_close, this)); 3247 } 3248 3249 if (btnCount > 1) 3250 { 3251 this.PARTS.ICONS.appendChild(BX.create('span', { props: {className: 'bx-context-toolbar-separator bx-context-toolbar-separator-switcher'}})); 3252 3253 this.ICON_TRANSFORM = this.PARTS.ICONS.appendChild(BX.create('A', { 3254 attrs: {href: 'javascript: void(0)'}, 3255 props: {className: 'bx-context-toolbar-switcher'}, 3256 events: { 3257 click: BX.delegate(this.__trf_btn_clicked, this) 3258 } 3259 })); 3260 } 3261 3262 if (this.PARAMS.HINT) 3263 { 3264 this.DIV.BXHINT = this.HINT = new BX.CHint({ 3265 parent: this.DIV, 3266 hint:this.PARAMS.HINT.TEXT || '', 3267 title: this.PARAMS.HINT.TITLE || '', 3268 hide_timeout: this.timeout/2, 3269 preventHide: false 3270 }); 3271 } 3272 3273 BX.addCustomEvent(this, 'onWindowDragFinished', BX.delegate(this.__onMoveFinished, this)); 3274 BX.addCustomEvent('onDynamicModeChange', BX.delegate(this.__onDynamicModeChange, this)); 3275 BX.addCustomEvent('onTopPanelCollapse', BX.delegate(this.__onPanelCollapse, this)); 3276 3277 BX.addCustomEvent('onMenuOpenerMoved', BX.delegate(this.checkPosition, this)); 3278 BX.addCustomEvent('onMenuOpenerUnhide', BX.delegate(this.checkPosition, this)); 3279 3280 BX.Event.EventEmitter.incrementMaxListeners('onDynamicModeChange'); 3281 BX.Event.EventEmitter.incrementMaxListeners('onTopPanelCollapse'); 3282 BX.Event.EventEmitter.incrementMaxListeners('onMenuOpenerMoved'); 3283 BX.Event.EventEmitter.incrementMaxListeners('onMenuOpenerUnhide'); 3284 3285 if (this.OPENERS) 3286 { 3287 for (i=0,len=this.OPENERS.length; i<len; i++) 3288 { 3289 BX.addCustomEvent(this.OPENERS[i], 'onOpenerMenuOpen', BX.proxy(this.__hide_hint, this)); 3290 } 3291 } 3292}; 3293BX.extend(BX.CMenuOpener, BX.CWindowFloat); 3294 3295BX.CMenuOpener.prototype.setParent = function(new_parent) 3296{ 3297 new_parent = BX(new_parent); 3298 3299 if (!new_parent) 3300 { 3301 return; 3302 } 3303 3304 if(new_parent.OPENER && new_parent.OPENER != this) 3305 { 3306 new_parent.OPENER.Close(); 3307 new_parent.OPENER.clearHoverHoutEvents(); 3308 } 3309 3310 if(this.PARAMS.parent && this.PARAMS.parent != new_parent) 3311 { 3312 this.clearHoverHoutEvents(); 3313 this.PARAMS.parent.OPENER = null; 3314 } 3315 3316 this.PARAMS.parent = new_parent; 3317 this.PARAMS.parent.OPENER = this; 3318}; 3319 3320BX.CMenuOpener.prototype.setHoverHoutEvents = function(hover, hout) 3321{ 3322 if(!this.__opener_events_set) 3323 { 3324 BX.bind(this.Get(), 'mouseover', hover); 3325 BX.bind(this.Get(), 'mouseout', hout); 3326 this.__opener_events_set = true; 3327 } 3328}; 3329 3330BX.CMenuOpener.prototype.clearHoverHoutEvents = function() 3331{ 3332 if(this.Get()) 3333 { 3334 BX.unbindAll(this.Get()); 3335 this.__opener_events_set = false; 3336 } 3337}; 3338 3339 3340BX.CMenuOpener.prototype.unclosable = true; 3341 3342BX.CMenuOpener.prototype.__check_intersection = function(pos_self, pos_other) 3343{ 3344 return !(pos_other.right <= pos_self.left || pos_other.left >= pos_self.right 3345 || pos_other.bottom <= pos_self.top || pos_other.top >= pos_self.bottom); 3346}; 3347 3348 3349BX.CMenuOpener.prototype.__msover_text = function() { 3350 this.bx_hover = true; 3351 if (!this._menu_open) 3352 BX.addClass(this.ATTACH, 'bx-context-toolbar-button-text-hover'); 3353}; 3354 3355BX.CMenuOpener.prototype.__msout_text = function() { 3356 this.bx_hover = false; 3357 if (!this._menu_open) 3358 BX.removeClass(this.ATTACH, 'bx-context-toolbar-button-text-hover bx-context-toolbar-button-text-active'); 3359}; 3360 3361BX.CMenuOpener.prototype.__msover_arrow = function() { 3362 this.bx_hover = true; 3363 if (!this._menu_open) 3364 BX.addClass(this.ATTACH, 'bx-context-toolbar-button-arrow-hover'); 3365}; 3366 3367BX.CMenuOpener.prototype.__msout_arrow = function() { 3368 this.bx_hover = false; 3369 if (!this._menu_open) 3370 BX.removeClass(this.ATTACH, 'bx-context-toolbar-button-arrow-hover bx-context-toolbar-button-arrow-active'); 3371}; 3372 3373BX.CMenuOpener.prototype.__msdown_text = function() { 3374 this.bx_active = true; 3375 if (!this._menu_open) 3376 BX.addClass(this.ATTACH, 'bx-context-toolbar-button-text-active'); 3377}; 3378 3379BX.CMenuOpener.prototype.__msdown_arrow = function() { 3380 this.bx_active = true; 3381 if (!this._menu_open) 3382 BX.addClass(this.ATTACH, 'bx-context-toolbar-button-arrow-active'); 3383}; 3384 3385BX.CMenuOpener.prototype.__menu_close = function() { 3386 this._menu_open = false;
3387 this.bx_active = false; 3388 BX.removeClass(this.ATTACH, 'bx-context-toolbar-button-active bx-context-toolbar-button-text-active bx-context-toolbar-button-arrow-active'); 3389 if (!this.bx_hover) 3390 { 3391 BX.removeClass(this.ATTACH, 'bx-context-toolbar-button-hover bx-context-toolbar-button-text-hover bx-context-toolbar-button-arrow-hover'); 3392 this.bx_hover = false; 3393 } 3394}; 3395 3396BX.CMenuOpener.prototype.__menu_open = function() { 3397 this._menu_open = true; 3398}; 3399 3400BX.CMenuOpener.prototype.checkPosition = function() 3401{ 3402 if (this.isMenuVisible() || this.DIV.style.display == 'none' 3403 || this == BX.proxy_context || BX.proxy_context.zIndex > this.zIndex) 3404 return; 3405 3406 this.correctPosition(BX.proxy_context); 3407}; 3408 3409BX.CMenuOpener.prototype.correctPosition = function(opener) 3410{ 3411 var pos_self = BX.pos(this.DIV), pos_other = BX.pos(opener.Get()); 3412 if (this.__check_intersection(pos_self, pos_other)) 3413 { 3414 var new_top = pos_other.top - pos_self.height; 3415 if (new_top < 0) 3416 new_top = pos_other.bottom; 3417 3418 this.DIV.style.top = new_top + 'px'; 3419 3420 BX.addCustomEvent(opener, 'onMenuOpenerHide', BX.proxy(this.restorePosition, this)); 3421 BX.onCustomEvent(this, 'onMenuOpenerMoved'); 3422 } 3423}; 3424 3425BX.CMenuOpener.prototype.restorePosition = function() 3426{ 3427 if (!this.MOUSEOVER && !this.isMenuVisible()) 3428 { 3429 if (this.originalPos) 3430 this.DIV.style.top = this.originalPos.top + 'px'; 3431 3432 BX.removeCustomEvent(BX.proxy_context, 'onMenuOpenerHide', BX.proxy(this.restorePosition, this)); 3433 if (this.restore_pos_timeout) clearTimeout(this.restore_pos_timeout); 3434 } 3435 else 3436 { 3437 this.restore_pos_timeout = setTimeout(BX.proxy(this.restorePosition, this), this.timeout); 3438 } 3439}; 3440 3441 3442BX.CMenuOpener.prototype.Show = function() 3443{ 3444 BX.CMenuOpener.superclass.Show.apply(this, arguments); 3445 3446 this.SetDraggable(this.PARTS.INNER.firstChild); 3447 3448 this.DIV.style.width = 'auto'; 3449 this.DIV.style.height = 'auto'; 3450 3451 if (!this.PARAMS.pin) 3452 { 3453 this.DIV.style.left = '-1000px'; 3454 this.DIV.style.top = '-1000px'; 3455 3456 this.Hide(); 3457 } 3458 else 3459 { 3460 this.bPosAdjusted = true; 3461 this.bMoved = true; 3462 3463 if (this.PARAMS.top) this.DIV.style.top = this.PARAMS.top + 'px'; 3464 if (this.PARAMS.left) this.DIV.style.left = this.PARAMS.left + 'px'; 3465 3466 this.DIV.style.display = (!BX.admin.dynamic_mode || BX.admin.dynamic_mode_show_borders) ? 'block' : 'none'; 3467 3468 if (this.DIV.style.display == 'block') 3469 { 3470 setTimeout(BX.delegate(function() {BX.onCustomEvent(this, 'onMenuOpenerUnhide')}, this), 50); 3471 } 3472 } 3473}; 3474 3475BX.CMenuOpener.prototype.executeDefaultAction = function() 3476{ 3477 if (this.defaultAction) 3478 { 3479 if (BX.type.isFunction(this.defaultAction)) 3480 this.defaultAction(); 3481 else if(BX.type.isString(this.defaultAction)) 3482 BX.evalGlobal(this.defaultAction); 3483 } 3484}; 3485 3486BX.CMenuOpener.prototype.__onDynamicModeChange = function(val) 3487{ 3488 this.DIV.style.display = val ? 'block' : 'none'; 3489}; 3490 3491BX.CMenuOpener.prototype.__onPanelCollapse = function(bCollapsed, dy) 3492{ 3493 this.DIV.style.top = (parseInt(this.DIV.style.top) + dy) + 'px'; 3494 if (this.PARAMS.pin) 3495 { 3496 this.__savePosition(); 3497 } 3498}; 3499 3500BX.CMenuOpener.prototype.__onMoveFinished = function() 3501{ 3502 BX.onCustomEvent(this, 'onMenuOpenerMoved'); 3503 3504 this.bMoved = true; 3505 3506 if (this.PARAMS.pin) 3507 this.__savePosition(); 3508}; 3509 3510BX.CMenuOpener.prototype.__savePosition = function() 3511{ 3512 var arOpts = {}; 3513 3514 arOpts.pin = this.PARAMS.pin; 3515 if (!this.PARAMS.pin) 3516 { 3517 arOpts.top = false; arOpts.left = false; arOpts.transform = false; 3518 } 3519 else 3520 { 3521 arOpts.transform = this.PARAMS.transform; 3522 if (this.bMoved) 3523 { 3524 arOpts.left = parseInt(this.DIV.style.left); 3525 arOpts.top = parseInt(this.DIV.style.top); 3526 } 3527 } 3528 3529 BX.WindowManager.saveWindowOptions(this.PARAMS.component_id, arOpts); 3530}; 3531 3532BX.CMenuOpener.prototype.__pin_btn_clicked = function() {this.Pin()}; 3533BX.CMenuOpener.prototype.Pin = function(val) 3534{ 3535 if (null == val) 3536 this.PARAMS.pin = !this.PARAMS.pin; 3537 else 3538 this.PARAMS.pin = !!val; 3539 3540 this.PARTS.ICON_PIN.className = (this.PARAMS.pin ? 'bx-context-toolbar-pin-fixed' : 'bx-context-toolbar-pin'); 3541 3542 this.__savePosition(); 3543}; 3544 3545BX.CMenuOpener.prototype.__trf_btn_clicked = function() {this.Transform()}; 3546BX.CMenuOpener.prototype.Transform = function(val) 3547{ 3548 var pos = {}; 3549 3550 if (null == val) 3551 this.PARAMS.transform = !this.PARAMS.transform; 3552 else 3553 this.PARAMS.transform = !!val; 3554 3555 if (this.bMoved) 3556 { 3557 pos = BX.pos(this.DIV); 3558 } 3559 3560 if (this.PARAMS.transform) 3561 BX.addClass(this.DIV.firstChild, 'bx-context-toolbar-vertical-mode'); 3562 else 3563 BX.removeClass(this.DIV.firstChild, 'bx-context-toolbar-vertical-mode'); 3564 3565 if (!this.bMoved) 3566 { 3567 this.adjustPos(); 3568 } 3569 else 3570 { 3571 this.DIV.style.left = (pos.right - this.DIV.offsetWidth - (BX.browser.IsIE() && !BX.browser.IsDoctype() ? 2 : 0)) + 'px'; 3572 } 3573 3574 this.__savePosition(); 3575}; 3576 3577BX.CMenuOpener.prototype.adjustToNodeGetPos = function() 3578{ 3579 var pos = BX.pos(this.PARAMS.parent/*, true*/); 3580 3581 var scrollSize = BX.GetWindowScrollSize(); 3582 var floatWidth = this.DIV.offsetWidth; 3583 3584 pos.left -= BX.admin.__border_dx; 3585 pos.top -= BX.admin.__border_dx; 3586 3587 if (true || !this.PARAMS.transform) 3588 { 3589 pos.top -= 45; 3590 } 3591 3592 if (pos.left > scrollSize.scrollWidth - floatWidth) 3593 { 3594 pos.left = scrollSize.scrollWidth - floatWidth; 3595 } 3596 3597 return pos; 3598}; 3599 3600BX.CMenuOpener.prototype.addItem = function(item) 3601{ 3602 if (item.TYPE) 3603 { 3604 this.EXTRA_BUTTONS[item.TYPE] = item; 3605 return null; 3606 } 3607 else 3608 { 3609 var q = new BX.CMenuOpenerItem(item); 3610 if (null == this.defaultAction) 3611 { 3612 if (q.item.ONCLICK) 3613 { 3614 this.defaultAction = item.ONCLICK; 3615 } 3616 else if (q.item.MENU) 3617 { 3618 this.defaultAction = BX.delegate(function() {this.Open()}, q.item.OPENER); 3619 } 3620 3621 this.defaultActionTitle = item.TITLE || item.TEXT; 3622 3623 BX.addClass(q.Get(), 'bx-content-toolbar-default'); 3624 } 3625 if (q.item.OPENER) this.OPENERS[this.OPENERS.length] = q.item.OPENER; 3626 return q.Get(); 3627 } 3628}; 3629 3630BX.CMenuOpener.prototype.attachMenu = function(menu) 3631{ 3632 var opener = new BX.COpener({ 3633 'DIV': this.OPENER,
3634 'ATTACH': this.ATTACH, 3635 'MENU': menu, 3636 'TYPE': 'click' 3637 }); 3638 3639 this.OPENERS[this.OPENERS.length] = opener; 3640 3641 return opener; 3642}; 3643 3644BX.CMenuOpener.prototype.__hide_hint = function() 3645{ 3646 if (this.HINT) this.HINT.__hide_immediately(); 3647}; 3648 3649BX.CMenuOpener.prototype.isMenuVisible = function() 3650{ 3651 for (var i=0,len=this.OPENERS.length; i<len; i++) 3652 { 3653 if (this.OPENERS[i].isMenuVisible()) 3654 return true; 3655 } 3656 3657 return false; 3658}; 3659 3660BX.CMenuOpener.prototype.Hide = function() 3661{ 3662 if (!this.PARAMS.pin) 3663 { 3664 this.DIV.style.display = 'none'; 3665 BX.onCustomEvent(this, 'onMenuOpenerHide'); 3666 } 3667}; 3668BX.CMenuOpener.prototype.UnHide = function() 3669{ 3670 this.DIV.style.display = 'block'; 3671 if (!this.bPosAdjusted && !this.PARAMS.pin) 3672 { 3673 this.adjustPos(); 3674 this.bPosAdjusted = true; 3675 } 3676 3677 if (null == this.originalPos && !this.bMoved) 3678 { 3679 this.originalPos = BX.pos(this.DIV); 3680 } 3681 3682 BX.onCustomEvent(this, 'onMenuOpenerUnhide'); 3683}; 3684 3685BX.CMenuOpenerItem = function(item) 3686{ 3687 this.item = item; 3688 3689 if (this.item.ACTION && !this.item.ONCLICK) 3690 { 3691 this.item.ONCLICK = this.item.ACTION; 3692 } 3693 3694 this.DIV = BX.create('SPAN'); 3695 this.DIV.appendChild(BX.create('SPAN', {props: {className: 'bx-context-toolbar-button-underlay'}})); 3696 3697 this.WRAPPER = this.DIV.appendChild(BX.create('SPAN', { 3698 props: {className: 'bx-context-toolbar-button-wrapper'}, 3699 children: [ 3700 BX.create('SPAN', { 3701 props: {className: 'bx-context-toolbar-button', title: item.TITLE}, 3702 children: [ 3703 BX.create('SPAN', { 3704 props: {className: 'bx-context-toolbar-button-inner'} 3705 }) 3706 ] 3707 }) 3708 ] 3709 })); 3710 3711 var btn_icon = BX.create('SPAN', { 3712 props: {className: 'bx-context-toolbar-button-icon' + (this.item.ICON || this.item.ICONCLASS ? ' ' + (this.item.ICON || this.item.ICONCLASS) : '')}, 3713 attrs: ( 3714 !(this.item.ICON || this.item.ICONCLASS) 3715 && 3716 (this.item.SRC || this.item.IMAGE) 3717 ) 3718 ? { 3719 style: 'background: scroll transparent url(' + (this.item.SRC || this.item.IMAGE) + ') no-repeat center center !important;' 3720 } 3721 : {} 3722 }), btn_text = BX.create('SPAN', { 3723 props: {className: 'bx-context-toolbar-button-text'}, 3724 text: this.item.TEXT 3725 }); 3726 3727 if (this.item.ACTION && !this.item.ONCLICK) 3728 { 3729 this.item.ONCLICK = this.item.ACTION; 3730 } 3731 3732 this.bHasMenu = !!this.item.MENU; 3733 this.bHasAction = !!this.item.ONCLICK; 3734 3735 if (this.bHasAction) 3736 { 3737 this.LINK = this.WRAPPER.firstChild.firstChild.appendChild(BX.create('A', { 3738 attrs: { 3739 'href': 'javascript: void(0)' 3740 }, 3741 events: { 3742 mouseover: this.bHasMenu ? BX.proxy(this.__msover_text, this) : BX.proxy(this.__msover, this), 3743 mouseout: this.bHasMenu ? BX.proxy(this.__msout_text, this) : BX.proxy(this.__msout, this), 3744 mousedown: this.bHasMenu ? BX.proxy(this.__msdown_text, this) : BX.proxy(this.__msdown, this) 3745 }, 3746 children: [btn_icon, btn_text] 3747 })); 3748 3749 if (this.bHasMenu) 3750 { 3751 this.LINK_MENU = this.WRAPPER.firstChild.firstChild.appendChild(BX.create('A', { 3752 props: {className: 'bx-context-toolbar-button-arrow'}, 3753 attrs: { 3754 'href': 'javascript: void(0)' 3755 }, 3756 events: { 3757 mouseover: BX.proxy(this.__msover_arrow, this), 3758 mouseout: BX.proxy(this.__msout_arrow, this), 3759 mousedown: BX.proxy(this.__msdown_arrow, this) 3760 }, 3761 children: [ 3762 BX.create('SPAN', {props: {className: 'bx-context-toolbar-button-arrow'}}) 3763 ] 3764 })); 3765 } 3766 3767 } 3768 else if (this.bHasMenu) 3769 { 3770 this.item.ONCLICK = null; 3771 3772 this.LINK = this.LINK_MENU = this.WRAPPER.firstChild.firstChild.appendChild(BX.create('A', { 3773 attrs: { 3774 'href': 'javascript: void(0)' 3775 }, 3776 events: { 3777 mouseover: BX.proxy(this.__msover, this), 3778 mouseout: BX.proxy(this.__msout, this), 3779 mousedown: BX.proxy(this.__msdown, this) 3780 }, 3781 children: [ 3782 btn_icon, 3783 btn_text 3784 ] 3785 })); 3786 3787 this.LINK.appendChild(BX.create('SPAN', {props: {className: 'bx-context-toolbar-single-button-arrow'}})); 3788 3789 } 3790 3791 if (this.bHasMenu) 3792 { 3793 this.item.SUBMENU = new BX.CMenu({ 3794 ATTACH_MODE:'bottom', 3795 ITEMS:this.item['MENU'], 3796 //PARENT_MENU:this.parentMenu, 3797 parent: this.LINK_MENU, 3798 parent_attach: this.WRAPPER.firstChild 3799 }); 3800 3801 this.item.OPENER = new BX.COpener({ 3802 DIV: this.LINK_MENU, 3803 TYPE: 'click', 3804 MENU: this.item.SUBMENU 3805 }); 3806 3807 BX.addCustomEvent(this.item.OPENER, 'onOpenerMenuOpen', BX.proxy(this.__menu_open, this)); 3808 BX.addCustomEvent(this.item.OPENER, 'onOpenerMenuClose', BX.proxy(this.__menu_close, this)); 3809 } 3810 3811 if (this.bHasAction) 3812 { 3813 BX.bind(this.LINK, 'click', BX.delegate(this.__click, this)); 3814 } 3815}; 3816 3817BX.CMenuOpenerItem.prototype.Get = function() {return this.DIV;}; 3818BX.CMenuOpenerItem.prototype.__msover = function() { 3819 this.bx_hover = true; 3820 if (!this._menu_open) 3821 BX.addClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-hover'); 3822}; 3823BX.CMenuOpenerItem.prototype.__msout = function() { 3824 this.bx_hover = false;
3825 if (!this._menu_open) 3826 BX.removeClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-hover bx-context-toolbar-button-active'); 3827}; 3828BX.CMenuOpenerItem.prototype.__msover_text = function() { 3829 this.bx_hover = true; 3830 if (!this._menu_open) 3831 BX.addClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-text-hover'); 3832}; 3833BX.CMenuOpenerItem.prototype.__msout_text = function() { 3834 this.bx_hover = false; 3835 if (!this._menu_open) 3836 BX.removeClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-text-hover bx-context-toolbar-button-text-active'); 3837}; 3838BX.CMenuOpenerItem.prototype.__msover_arrow = function() { 3839 this.bx_hover = true; 3840 if (!this._menu_open) 3841 BX.addClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-arrow-hover'); 3842}; 3843BX.CMenuOpenerItem.prototype.__msout_arrow = function() { 3844 this.bx_hover = false; 3845 if (!this._menu_open) 3846 BX.removeClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-arrow-hover bx-context-toolbar-button-arrow-active'); 3847}; 3848BX.CMenuOpenerItem.prototype.__msdown = function() { 3849 this.bx_active = true; 3850 if (!this._menu_open) 3851 BX.addClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-active'); 3852}; 3853BX.CMenuOpenerItem.prototype.__msdown_text = function() { 3854 this.bx_active = true; 3855 if (!this._menu_open) 3856 BX.addClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-text-active'); 3857}; 3858BX.CMenuOpenerItem.prototype.__msdown_arrow = function() { 3859 this.bx_active = true; 3860 if (!this._menu_open) 3861 BX.addClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-arrow-active'); 3862}; 3863BX.CMenuOpenerItem.prototype.__menu_close = function() { 3864 3865 this._menu_open = false; 3866 this.bx_active = false; 3867 BX.removeClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-active bx-context-toolbar-button-text-active bx-context-toolbar-button-arrow-active'); 3868 if (!this.bx_hover) 3869 { 3870 BX.removeClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-hover bx-context-toolbar-button-text-hover bx-context-toolbar-button-arrow-hover'); 3871 this.bx_hover = false; 3872 } 3873}; 3874BX.CMenuOpenerItem.prototype.__menu_open = function() { 3875 this._menu_open = true; 3876}; 3877 3878BX.CMenuOpenerItem.prototype.__click = function() {BX.evalGlobal(this.item.ONCLICK)}; 3879 3880/* global page opener class */ 3881BX.CPageOpener = function(arParams) 3882{ 3883 //if (null == arParams.pin) arParams.pin = true; 3884 BX.CPageOpener.superclass.constructor.apply(this, arguments); 3885 3886 this.timeout = 505; 3887 3888 window.PAGE_EDIT_CONTROL = this; 3889}; 3890BX.extend(BX.CPageOpener, BX.CMenuOpener); 3891 3892BX.CPageOpener.prototype.checkPosition = function() 3893{ 3894 if (/*this.isMenuVisible() || this.DIV.style.display == 'none' || */this == BX.proxy_context) 3895 return; 3896 3897 this.correctPosition(BX.proxy_context); 3898}; 3899 3900BX.CPageOpener.prototype.correctPosition = function(opener) 3901{ 3902 if (this.bPosCorrected) return; 3903 var pos_self; 3904 if (this.DIV.style.display == 'none') 3905 { 3906 pos_self = this.adjustToNodeGetPos(); 3907 pos_self.bottom = pos_self.top + 30; 3908 pos_self.right = pos_self.left + 300; 3909 } 3910 else 3911 { 3912 pos_self = BX.pos(this.DIV); 3913 } 3914 3915 var pos_other = BX.pos(opener.Get()); 3916 if (this.__check_intersection(pos_self, pos_other)) 3917 { 3918 this.DIV.style.display = 'none'; 3919 3920 var handler = BX.proxy(this.restorePosition, this); 3921 3922 BX.removeCustomEvent(opener, 'onMenuOpenerHide', handler); 3923 BX.addCustomEvent(opener, 'onMenuOpenerHide', handler); 3924 3925 this.bPosCorrected = true; 3926 } 3927}; 3928 3929BX.CPageOpener.prototype.restorePosition = function() 3930{ 3931 if (BX.proxy_context && BX.proxy_context.Get().style.display == 'none') 3932 { 3933 this.bPosCorrected = false; 3934 3935 if (this.PARAMS.parent.bx_over || this.PARAMS.pin) 3936 this.UnHide(); 3937 3938 BX.removeCustomEvent('onMenuOpenerHide', BX.proxy(this.restorePosition, this)); 3939 } 3940}; 3941 3942BX.CPageOpener.prototype.UnHide = function() 3943{ 3944 if (!this.bPosCorrected) 3945 BX.CPageOpener.superclass.UnHide.apply(this, arguments); 3946}; 3947 3948BX.CPageOpener.prototype.Remove = function() 3949{ 3950 BX.admin.removeComponentBorder(this.PARAMS.parent); 3951 BX.userOptions.save('global', 'settings', 'page_edit_control_enable', 'N'); 3952 this.DIV.style.display = 'none'; 3953}; 3954 3955/******* HINT ***************/ 3956BX.CHintSimple = function() 3957{ 3958 BX.CHintSimple.superclass.constructor.apply(this, arguments); 3959}; 3960BX.extend(BX.CHintSimple, BX.CHint); 3961 3962BX.CHintSimple.prototype.Init = function() 3963{ 3964 this.DIV = document.body.appendChild(BX.create('DIV', {props: {className: 'bx-tooltip-simple'}, style: {display: 'none'}, children: [(this.CONTENT = BX.create('DIV'))]})); 3965 3966 BX.ZIndexManager.register(this.DIV); 3967 3968 if (this.HINT_TITLE) 3969 this.CONTENT.appendChild(BX.create('B', {text: this.HINT_TITLE})); 3970 3971 if (this.HINT) 3972 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV')).appendChild(BX.create('SPAN', {html: this.HINT})); 3973 3974 if (this.PARAMS.preventHide) 3975 { 3976 BX.bind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 3977 BX.bind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 3978 } 3979 3980 this.bInited = true; 3981}; 3982 3983/*************************** admin informer **********************************/ 3984BX.adminInformer = { 3985 3986 itemsShow: 3, 3987 3988 Init: function (itemsShow) 3989 { 3990 if(itemsShow) 3991 BX.adminInformer.itemsShow = itemsShow; 3992 3993 var informer = BX("admin-informer"); 3994 3995 if(informer) 3996 { 3997 document.body.appendChild(informer); 3998 BX.ZIndexManager.register(informer); 3999 } 4000 4001 BX.addCustomEvent("onTopPanelCollapse", BX.proxy(BX.adminInformer.Close, BX.adminInformer)); 4002 }, 4003 4004 Toggle: function(notifyBlock) 4005 { 4006 var informer = BX("admin-informer"); 4007 4008 if(!informer) 4009 return false;
4010 4011 var pos = BX.pos(notifyBlock); 4012 4013 informer.style.top = (parseInt(pos.top)+parseInt(pos.height)+7)+'px'; 4014 informer.style.left = pos.left+'px'; 4015 4016 if(!BX.hasClass(informer, "adm-informer-active")) 4017 BX.adminInformer.Show(informer); 4018 else 4019 BX.adminInformer.Hide(informer); 4020 4021 return false; 4022 }, 4023 4024 Close: function() 4025 { 4026 BX.adminInformer.Hide(BX("admin-informer")); 4027 }, 4028 4029 OnInnerClick: function(event) 4030 { 4031 var target = event.target || event.srcElement; 4032 4033 if(target.nodeName.toLowerCase() != 'a' || BX.hasClass(target,"adm-informer-footer")) 4034 { 4035 return BX.PreventDefault(event); 4036 } 4037 4038 return true; 4039 }, 4040 4041 ToggleExtra : function() 4042 { 4043 var footerLink = BX("adm-informer-footer"); 4044 4045 if (BX.hasClass(footerLink, "adm-informer-footer-collapsed")) 4046 this.ShowAll(); 4047 else 4048 this.HideExtra(); 4049 4050 return false; 4051 }, 4052 4053 ShowAll: function() 4054 { 4055 var informer = BX("admin-informer"); 4056 for(var i=0; i<informer.children.length; i++) 4057 4058 if(BX.hasClass(informer.children[i], "adm-informer-item") && informer.children[i].style.display == "none") { 4059 informer.children[i].style.display = "block"; 4060 } 4061 4062 var footerLink = BX("adm-informer-footer"); 4063 4064 if(footerLink.textContent !== undefined) 4065 footerLink.textContent = BX.message('JSADM_AI_HIDE_EXTRA'); 4066 else 4067 footerLink.innerText = BX.message('JSADM_AI_HIDE_EXTRA'); 4068 4069 BX.removeClass(footerLink, "adm-informer-footer-collapsed"); 4070 4071 return false; 4072 }, 4073 4074 HideExtra: function() 4075 { 4076 var informer = BX("admin-informer"); 4077 var hided = 0; 4078 4079 for(var i=BX.adminInformer.itemsShow+1; i<informer.children.length; i++) 4080 { 4081 if (BX.hasClass(informer.children[i], "adm-informer-item") && informer.children[i].style.display == "block") { 4082 informer.children[i].style.display = "none"; 4083 hided++; 4084 } 4085 } 4086 4087 var footerLink = BX("adm-informer-footer"); 4088 4089 var linkText = BX.message('JSADM_AI_ALL_NOTIF')+" ("+(BX.adminInformer.itemsShow+parseInt(hided))+")"; 4090 4091 if(footerLink.textContent !== undefined) 4092 footerLink.textContent = linkText; 4093 else 4094 footerLink.innerText = linkText; 4095 4096 BX.addClass(footerLink, "adm-informer-footer-collapsed"); 4097 4098 return false; 4099 }, 4100 4101 Show: function(informer) 4102 { 4103 var notifButton = BX("adm-header-notif-block"); 4104 if (notifButton) 4105 BX.addClass(notifButton, "adm-header-notif-block-active"); 4106 4107 BX.onCustomEvent(informer, 'onBeforeAdminInformerShow'); 4108 setTimeout( 4109 BX.proxy(function() { 4110 BX.bind(document, "click", BX.proxy(BX.adminInformer.Close, BX.adminInformer)); 4111 }, 4112 BX.adminInformer 4113 ),0 4114 ); 4115 BX.addClass(informer, "adm-informer-active"); 4116 4117 BX.ZIndexManager.bringToFront(informer); 4118 4119 setTimeout(function() {BX.addClass(informer, "adm-informer-animate");},0); 4120 }, 4121 4122 Hide: function(informer) 4123 { 4124 var notifButton = BX("adm-header-notif-block"); 4125 if (notifButton) 4126 BX.removeClass(notifButton, "adm-header-notif-block-active"); 4127 4128 BX.unbind(document, "click", BX.proxy(BX.adminInformer.Close, BX.adminInformer)); 4129 4130 BX.removeClass(informer, "adm-informer-animate"); 4131 4132 if (this.IsAnimationSupported()) 4133 setTimeout(function() {BX.removeClass(informer, "adm-informer-active");}, 300); 4134 else 4135 BX.removeClass(informer, "adm-informer-active"); 4136 4137 BX.onCustomEvent(informer, 'onAdminInformerHide'); 4138 //setTimeout(function() {BX.adminInformer.HideExtra();},500); 4139 }, 4140 4141 IsAnimationSupported : function() 4142 { 4143 var d = document.body || document.documentElement; 4144 if (typeof(d.style.transition) == "string") 4145 return true; 4146 else if (typeof(d.style.MozTransition) == "string") 4147 return true; 4148 else if (typeof(d.style.OTransition) == "string") 4149 return true; 4150 else if (typeof(d.style.WebkitTransition) == "string") 4151 return true; 4152 else if (typeof(d.style.msTransition) == "string") 4153 return true; 4154 4155 return false; 4156 }, 4157 4158 4159 SetItemHtml: function(itemIdx, html) 4160 { 4161 var itemHtmlDiv = BX("adm-informer-item-html-"+itemIdx); 4162 4163 if(!itemHtmlDiv) 4164 return false; 4165 4166 itemHtmlDiv.innerHTML = html; 4167 4168 return true; 4169 }, 4170 4171 SetItemFooter: function(itemIdx, html) 4172 { 4173 var itemFooterDiv = BX("adm-informer-item-footer-"+itemIdx); 4174 4175 if(!itemFooterDiv) 4176 return false; 4177 4178 itemFooterDiv.innerHTML = html; 4179 4180 if(html) 4181 itemFooterDiv.style.display = "block"; 4182 else 4183 itemFooterDiv.style.display = "none"; 4184 4185 return true; 4186 } 4187 4188}; 4189 4190}
4190)(window); 4191 4192 4193 4194/* End */ 4195; 4196; /* Start:"a:4:{s:4:"full";s:49:"/bitrix/js/main/date/main.date.js?174834456662683";s:6:"source";s:33:"/bitrix/js/main/date/main.date.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 4197/* eslint-disable */ 4198this.BX = this.BX || {}; 4199(function (exports,main_core) { 4200 'use strict'; 4201 4202 function convertBitrixFormat(format) { 4203 if (!main_core.Type.isStringFilled(format)) { 4204 return ''; 4205 } 4206 return format.replace('YYYY', 'Y') // 1999 4207 .replace('MMMM', 'F') // January - December 4208 .replace('MM', 'm') // 01 - 12 4209 .replace('M', 'M') // Jan - Dec 4210 .replace('DD', 'd') // 01 - 31 4211 .replace('G', 'g') // 1 - 12 4212 .replace(/GG/i, 'G') // 0 - 23 4213 .replace('H', 'h') // 01 - 12 4214 .replace(/HH/i, 'H') // 00 - 24 4215 .replace('MI', 'i') // 00 - 59 4216 .replace('SS', 's') // 00 - 59 4217 .replace('TT', 'A') // AM - PM 4218 .replace('T', 'a'); // am - pm 4219 } 4220 4221 const formatsCache = new main_core.Cache.MemoryCache(); 4222 4223 /** 4224 * Returns culture-specific datetime format by code. 4225 * The full list with examples can be found in config.php of this extension in ['settings']['formats']. 4226 * All formats are compatible with this.format() without any additional transformations. 4227 * 4228 * @param code 4229 * @returns {string|null} 4230 */ 4231 function getFormat(code) { 4232 return formatsCache.remember(`main.date.format.${code}`, () => { 4233 let format = main_core.Extension.getSettings('main.date').get(`formats.${code}`); 4234 if (main_core.Type.isStringFilled(format) && (code === 'FORMAT_DATE' || code === 'FORMAT_DATETIME')) { 4235 format = convertBitrixFormat(format); 4236 } 4237 return format; 4238 }); 4239 } 4240 4241 /** 4242 * @memberOf BX.Main 4243 * @alias Date 4244 */ 4245 let DateTimeFormat = /*#__PURE__*/function () { 4246 function DateTimeFormat() { 4247 babelHelpers.classCallCheck(this, DateTimeFormat); 4248 } 4249 babelHelpers.createClass(DateTimeFormat, null, [{ 4250 key: "isAmPmMode", 4251 value: function isAmPmMode(returnConst) { 4252 if (returnConst === true) { 4253 return this._getMessage('AMPM_MODE'); 4254 } 4255 return this._getMessage('AMPM_MODE') !== false; 4256 } 4257 }, { 4258 key: "convertToUTC", 4259 value: function convertToUTC(date) { 4260 if (!main_core.Type.isDate(date)) { 4261 return null; 4262 } 4263 return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds())); 4264 } 4265 /** 4266 * Function creates and returns Javascript Date() object from server timestamp regardless of local browser (system) timezone. 4267 * For example can be used to convert timestamp from some exact date on server to the JS Date object with the same value. 4268 * 4269 * @param timestamp - timestamp in seconds 4270 * @returns {Date} 4271 */ 4272 }, { 4273 key: "getNewDate", 4274 value: function getNewDate(timestamp) { 4275 return new Date(this.getBrowserTimestamp(timestamp)); 4276 } 4277 /** 4278 * Function transforms server timestamp (in sec) to javascript timestamp (calculated depend on local browser timezone offset). Returns timestamp in milliseconds. 4279 * Also see BX.Main.Date.getNewDate description. 4280 * 4281 * @param timestamp - timestamp in seconds 4282 * @returns {number} 4283 */ 4284 }, { 4285 key: "getBrowserTimestamp", 4286 value: function getBrowserTimestamp(timestamp) { 4287 timestamp = parseInt(timestamp, 10); 4288 const browserOffset = new Date(timestamp * 1000).getTimezoneOffset() * 60; 4289 return (parseInt(timestamp, 10) + parseInt(this._getMessage('SERVER_TZ_OFFSET')) + browserOffset) * 1000; 4290 } 4291 /** 4292 * Function transforms local browser timestamp (in ms) to server timestamp (calculated depend on local browser timezone offset). Returns timestamp in seconds. 4293 * 4294 * @param timestamp - timestamp in milliseconds 4295 * @returns {number} 4296 */ 4297 }, { 4298 key: "getServerTimestamp", 4299 value: function getServerTimestamp(timestamp) { 4300 timestamp = parseInt(timestamp, 10); 4301 const browserOffset = new Date(timestamp).getTimezoneOffset() * 60; 4302 return Math.round(timestamp / 1000 - (parseInt(this._getMessage('SERVER_TZ_OFFSET'), 10) + parseInt(browserOffset, 10))); 4303 } 4304 }, { 4305 key: "formatLastActivityDate", 4306 value: function formatLastActivityDate(timestamp, now, utc) { 4307 const ampm = this.isAmPmMode(true); 4308 const timeFormat = ampm === this.AM_PM_MODE.LOWER ? 'g:i a' : ampm === this.AM_PM_MODE.UPPER ? 'g:i A' : 'H:i'; 4309 const format = [['tomorrow', '#01#' + timeFormat], ['now', '#02#'], ['todayFuture', '#03#' + timeFormat], ['yesterday', '#04#' + timeFormat], ['-', this.convertBitrixFormat(this._getMessage('FORMAT_DATETIME')).replace(/:s/g, '')], ['
4309s60', 'sago'], ['i60', 'iago'], ['H5', 'Hago'], ['H24', '#03#' + timeFormat], ['d31', 'dago'], ['m12>1', 'mago'], ['m12>0', 'dago'], ['', '#05#']]; 4310 let formattedDate = this.format(format, timestamp, now, utc); 4311 let match = null; 4312 if ((match = /^#(\d+)#(.*)/.exec(formattedDate)) != null) { 4313 switch (match[1]) { 4314 case '01': 4315 formattedDate = this._getMessage('FD_LAST_SEEN_TOMORROW').replace('#TIME#', match[2]); 4316 break; 4317 case '02': 4318 formattedDate = this._getMessage('FD_LAST_SEEN_NOW'); 4319 break; 4320 case '03': 4321 formattedDate = this._getMessage('FD_LAST_SEEN_TODAY').replace('#TIME#', match[2]); 4322 break; 4323 case '04': 4324 formattedDate = this._getMessage('FD_LAST_SEEN_YESTERDAY').replace('#TIME#', match[2]); 4325 break; 4326 case '05': 4327 formattedDate = this._getMessage('FD_LAST_SEEN_MORE_YEAR'); 4328 break; 4329 default: 4330 formattedDate = match[2]; 4331 break; 4332 } 4333 } 4334 return formattedDate; 4335 } 4336 /** 4337 * The method is designed to replace the localization storage on sites without Bitrix Framework. 4338 * It gets overloaded with custom implementation: 4339 * 4340 * const CustomDate = Object.create(BX.Main.Date); 4341 * CustomDate._getMessage = () => ...new implementation...; 4342 * 4343 * This class should get messages only via this method. 4344 * Otherwise, the class won't work on sites without Bitrix Framework. 4345 * 4346 * @param message 4347 * @returns {*} 4348 * @private 4349 */ 4350 }, { 4351 key: "_getMessage", 4352 value: function _getMessage(message) { 4353 return main_core.Loc.getMessage(message); 4354 } 4355 /** 4356 * The method used to parse date from string by given format. 4357 * 4358 * @param {string} str - date in given format 4359 * @param {boolean} isUTC - is date in UTC 4360 * @param {string} formatDate - format of the date without time 4361 * @param {string} formatDatetime - format of the date with time 4362 * @returns {Date|null} - returns Date object if string was parsed or null 4363 */ 4364 }, { 4365 key: "parse", 4366 value: function parse(str, isUTC, formatDate, formatDatetime) { 4367 if (main_core.Type.isStringFilled(str)) { 4368 if (!formatDate) { 4369 formatDate = this._getMessage('FORMAT_DATE'); 4370 } 4371 if (!formatDatetime) { 4372 formatDatetime = this._getMessage('FORMAT_DATETIME'); 4373 } 4374 let regMonths = ''; 4375 for (let i = 1; i <= 12; i++) { 4376 regMonths = regMonths + '|' + this._getMessage('MON_' + i); 4377 }
4378 const expr = new RegExp('([0-9]+|[a-z]+' + regMonths + ')', 'ig'); 4379 const aDate = str.match(expr); 4380 let aFormat = formatDate.match(/(DD|MI|MMMM|MM|M|YYYY)/ig); 4381 const aDateArgs = []; 4382 const aFormatArgs = []; 4383 const aResult = {}; 4384 if (!aDate) { 4385 return null; 4386 } 4387 if (aDate.length > aFormat.length) { 4388 aFormat = formatDatetime.match(/(DD|MI|MMMM|MM|M|YYYY|HH|H|SS|TT|T|GG|G)/ig); 4389 } 4390 for (let i = 0, cnt = aDate.length; i < cnt; i++) { 4391 if (aDate[i].trim() !== '') { 4392 aDateArgs[aDateArgs.length] = aDate[i]; 4393 } 4394 } 4395 for (let i = 0, cnt = aFormat.length; i < cnt; i++) { 4396 if (aFormat[i].trim() !== '') { 4397 aFormatArgs[aFormatArgs.length] = aFormat[i]; 4398 } 4399 } 4400 let m = aFormatArgs.findIndex(item => item === 'MMMM'); 4401 if (m > 0) { 4402 aDateArgs[m] = this.getMonthIndex(aDateArgs[m]); 4403 aFormatArgs[m] = 'MM'; 4404 } else { 4405 m = aFormatArgs.findIndex(item => item === 'M'); 4406 if (m > 0) { 4407 aDateArgs[m] = this.getMonthIndex(aDateArgs[m]); 4408 aFormatArgs[m] = 'MM'; 4409 } 4410 } 4411 for (let i = 0, cnt = aFormatArgs.length; i < cnt; i++) { 4412 const k = aFormatArgs[i].toUpperCase(); 4413 aResult[k] = k === 'T' || k === 'TT' ? aDateArgs[i] : parseInt(aDateArgs[i], 10); 4414 } 4415 if (aResult['DD'] > 0 && aResult['MM'] > 0 && aResult['YYYY'] > 0) { 4416 const d = new Date(); 4417 if (isUTC) { 4418 d.setUTCDate(1); 4419 d.setUTCFullYear(aResult['YYYY']); 4420 d.setUTCMonth(aResult['MM'] - 1); 4421 d.setUTCDate(aResult['DD']); 4422 d.setUTCHours(0, 0, 0, 0); 4423 } else { 4424 d.setDate(1); 4425 d.setFullYear(aResult['YYYY']); 4426 d.setMonth(aResult['MM'] - 1); 4427 d.setDate(aResult['DD']); 4428 d.setHours(0, 0, 0, 0); 4429 } 4430 if ((!isNaN(aResult['HH']) || !isNaN(aResult['GG']) || !isNaN(aResult['H']) || !isNaN(aResult['G'])) && !isNaN(aResult['MI'])) { 4431 if (!isNaN(aResult['H']) || !isNaN(aResult['G'])) { 4432 const bPM = (aResult['T'] || aResult['TT'] || 'am').toUpperCase() === 'PM', 4433 h = parseInt(aResult['H'] || aResult['G'] || 0, 10); 4434 if (bPM) { 4435 aResult['HH'] = h + (h === 12 ? 0 : 12); 4436 } else { 4437 aResult['HH'] = h < 12 ? h : 0; 4438 } 4439 } else { 4440 aResult['HH'] = parseInt(aResult['HH'] || aResult['GG'] || 0, 10); 4441 } 4442 if (isNaN(aResult['SS'])) { 4443 aResult['SS'] = 0; 4444 } 4445 if (isUTC) { 4446 d.setUTCHours(aResult['HH'], aResult['MI'], aResult['SS']); 4447 } else { 4448 d.setHours(aResult['HH'], aResult['MI'], aResult['SS']); 4449 } 4450 } 4451 return d; 4452 } 4453 } 4454 return null; 4455 } 4456 }, { 4457 key: "getMonthIndex", 4458 value: function getMonthIndex(month) { 4459 const q = month.toUpperCase(); 4460 const wordMonthCut = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']; 4461 const wordMonth = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']; 4462 for (let i = 1; i <= 12; i++) { 4463 if (q === this._getMessage('MON_' + i).toUpperCase() || q === this._getMessage('MONTH_' + i).toUpperCase() || q === this._getMessage('MONTH_' + i + '_S').toUpperCase() || q === wordMonthCut[i - 1].toUpperCase() || q === wordMonth[i - 1].toUpperCase()) { 4464 return i; 4465 } 4466 } 4467 return month; 4468 } 4469 }, { 4470 key: "format", 4471 value: function format(_format, timestamp, now, utc) { 4472 /* 4473 PHP to Javascript: 4474 time() = new Date() 4475 mktime(...) = new Date(...) 4476 gmmktime(...) = new Date(Date.UTC(...)) 4477 mktime(0,0,0, 1, 1, 1970) != 0 new Date(1970,0,1).getTime() != 0 4478 gmmktime(0,0,0, 1, 1, 1970) == 0 new Date(Date.UTC(1970,0,1)).getTime() == 0 4479 date('d.m.Y H:i:s') = BX.Main.Date.format('d.m.Y H:i:s') 4480 gmdate('d.m.Y H:i:s') = BX.Main.Date.format('d.m.Y H:i:s', null, null, true); 4481 */ 4482 const date = main_core.Type.isDate(timestamp) ? new Date(timestamp.getTime()) : main_core.Type.isNumber(timestamp) ? new Date(timestamp * 1000) : new Date(); 4483 const nowDate = main_core.Type.isDate(now) ? new Date(now.getTime()) : main_core.Type.isNumber(now) ? new Date(now * 1000) : new Date(); 4484 const isUTC = !!utc; 4485 // used in hoisting inner functions, like _formatDateInterval 4486 const thisDateTimeFormat = this; 4487 if (main_core.Type.isArray(_format)) { 4488 return _formatDateInterval(_format, date, nowDate, isUTC); 4489 } else { 4490 if (!main_core.Type.isStringFilled(_format)) { 4491 return ''; 4492 } 4493 } 4494 const replaceMap = (_format.match(/{{([^{}]*)}}/g) || []).map(x => { 4495 return (x.match(/[^{}]+/) || [''])[0]; 4496 }); 4497 if (replaceMap.length > 0) {
4498 replaceMap.forEach((element, index) => { 4499 _format = _format.replace('{{' + element + '}}', '{{' + index + '}}'); 4500 }); 4501 } 4502 const formatRegex = /\\?(sago|iago|isago|Hago|dago|mago|Yago|sdiff|idiff|Hdiff|ddiff|mdiff|Ydiff|sshort|ishort|Hshort|dshort|mshort|Yshort|yesterday|today|tommorow|tomorrow|.)/gi; 4503 const dateFormats = { 4504 d: () => { 4505 // Day of the month 01 to 31 4506 return getDate(date).toString().padStart(2, '0'); 4507 }, 4508 D: () => { 4509 //Mon through Sun 4510 return this._getMessage('DOW_' + getDay(date)); 4511 }, 4512 j: () => { 4513 //Day of the month 1 to 31 4514 return getDate(date); 4515 }, 4516 l: () => { 4517 //Sunday through Saturday 4518 return this._getMessage('DAY_OF_WEEK_' + getDay(date)); 4519 }, 4520 N: () => { 4521 //1 (for Monday) through 7 (for Sunday) 4522 return getDay(date) || 7; 4523 }, 4524 S: () => { 4525 //st, nd, rd or th. Works well with j 4526 if (getDate(date) % 10 == 1 && getDate(date) != 11) { 4527 return 'st'; 4528 } else if (getDate(date) % 10 == 2 && getDate(date) != 12) { 4529 return 'nd'; 4530 } else if (getDate(date) % 10 == 3 && getDate(date) != 13) { 4531 return 'rd'; 4532 } else { 4533 return 'th'; 4534 } 4535 }, 4536 w: () => { 4537 //0 (for Sunday) through 6 (for Saturday) 4538 return getDay(date); 4539 }, 4540 z: () => { 4541 //0 through 365 4542 const firstDay = new Date(getFullYear(date), 0, 1); 4543 const currentDay = new Date(getFullYear(date), getMonth(date), getDate(date)); 4544 return Math.ceil((currentDay - firstDay) / (24 * 3600 * 1000)); 4545 }, 4546 W: () => { 4547 //ISO-8601 week number of year 4548 const newDate = new Date(date.getTime()); 4549 const dayNumber = (getDay(date) + 6) % 7; 4550 setDate(newDate, getDate(newDate) - dayNumber + 3); 4551 const firstThursday = newDate.getTime(); 4552 setMonth(newDate, 0, 1); 4553 if (getDay(newDate) != 4) { 4554 setMonth(newDate, 0, 1 + (4 - getDay(newDate) + 7) % 7); 4555 } 4556 const weekNumber = 1 + Math.ceil((firstThursday - newDate) / (7 * 24 * 3600 * 1000)); 4557 return weekNumber.toString().padStart(2, '0'); 4558 }, 4559 F: () => { 4560 //January through December 4561 return this._getMessage('MONTH_' + (getMonth(date) + 1) + '_S'); 4562 }, 4563 f: () => { 4564 //January through December 4565 return this._getMessage('MONTH_' + (getMonth(date) + 1)); 4566 }, 4567 m: () => { 4568 //Numeric representation of a month 01 through 12 4569 return (getMonth(date) + 1).toString().padStart(2, '0'); 4570 }, 4571 M: () => { 4572 //A short textual representation of a month, three letters Jan through Dec 4573 return this._getMessage('MON_' + (getMonth(date) + 1)); 4574 }, 4575 n: () => { 4576 //Numeric representation of a month 1 through 12 4577 return getMonth(date) + 1; 4578 }, 4579 t: () => { 4580 //Number of days in the given month 28 through 31 4581 const lastMonthDay = isUTC ? new Date(Date.UTC(getFullYear(date), getMonth(date) + 1, 0)) : new Date(getFullYear(date), getMonth(date) + 1, 0); 4582 return getDate(lastMonthDay); 4583 }, 4584 L: () => { 4585 //1 if it is a leap year, 0 otherwise. 4586 const year = getFullYear(date); 4587 return year % 4 == 0 && year % 100 != 0 || year % 400 == 0 ? 1 : 0; 4588 }, 4589 o: () => { 4590 //ISO-8601 year number 4591 const correctDate = new Date(date.getTime()); 4592 setDate(correctDate, getDate(correctDate) - (getDay(date) + 6) % 7 + 3); 4593 return getFullYear(correctDate); 4594 }, 4595 Y: () => { 4596 //A full numeric representation of a year, 4 digits 4597 return getFullYear(date); 4598 }, 4599 y: () => { 4600 //A two digit representation of a year 4601 return getFullYear(date).toString().slice(2); 4602 }, 4603 a: () => { 4604 //am or pm 4605 return getHours(date) > 11 ? 'pm' : 'am'; 4606 }, 4607 A: () => { 4608 //AM or PM 4609 return getHours(date) > 11 ? 'PM' : 'AM'; 4610 }, 4611 B: () => { 4612 //000 through 999 4613 const swatch = (date.getUTCHours() + 1) % 24 + date.getUTCMinutes() / 60 + date.getUTCSeconds() / 3600; 4614 return Math.floor(swatch * 1000 / 24).toString().padStart(3, '0'); 4615 }, 4616 g: () => { 4617 //12-hour format of an hour without leading zeros 1 through 12 4618 return getHours(date) % 12 || 12; 4619 }, 4620 G: () => { 4621 //24-hour format of an hour without leading zeros 0 through 23 4622 return getHours(date); 4623 }, 4624 h: () => { 4625 //12-hour format of an hour with leading zeros 01 through 12 4626 return (getHours(date) % 12 || 12).toString().padStart(2, '0'); 4627 }, 4628 H: () => { 4629 //24-hour format of an hour with leading zeros 00 through 23 4630 return getHours(date).toString().padStart(2, '0'); 4631 }, 4632 i: () => { 4633 //Minutes with leading zeros 00 to 59 4634 return getMinutes(date).toString().padStart(2, '0'); 4635 }, 4636 s: () => { 4637 //Seconds, with leading zeros 00 through 59 4638 return getSeconds(date).toString().padStart(2, '0'); 4639 }, 4640 u: () => { 4641 //Microseconds 4642 return (getMilliseconds(date) * 1000).toString().padStart(6, '0'); 4643 }, 4644 e: () => { 4645 if (isUTC) { 4646 return 'UTC'; 4647 } 4648 return ''; 4649 }, 4650 I: () => { 4651 if (isUTC) { 4652 return 0; 4653 } 4654 4655 //Whether or not the date is in daylight saving time 1 if Daylight Saving Time, 0 otherwise 4656 const firstJanuary = new Date(getFullYear(date), 0, 1); 4657 const firstJanuaryUTC = Date.UTC(getFullYear(date), 0, 1); 4658 const firstJuly = new Date(getFullYear(date), 6, 0); 4659 const firstJulyUTC = Date.UTC(getFullYear(date), 6, 0); 4660 return 0 + (firstJanuary - firstJanuaryUTC !== firstJuly - firstJulyUTC); 4661 }, 4662 O: () => { 4663 if (isUTC) { 4664 return '+0000'; 4665 } 4666 4667 //Difference to Greenwich time (GMT) in hours +0200 4668 const timezoneOffset = date.getTimezoneOffset(); 4669 const timezoneOffsetAbs = Math.abs(timezoneOffset); 4670 return (timezoneOffset > 0 ? '-' : '+') + (Math.floor(timezoneOffsetAbs / 60) * 100 + timezoneOffsetAbs % 60).toString().padStart(4, '0'); 4671 }, 4672 //this method references 'O' method of the same object, arrow function is not suitable here 4673 P: function () { 4674 if (isUTC) { 4675 return '+00:00'; 4676 } 4677 4678 //Difference to Greenwich time (GMT) with colon between hours and minutes +02:00 4679 const difference = this.O(); 4680 return difference.substr(0, 3) + ':' + difference.substr(3); 4681 }, 4682 Z: () => { 4683 if (isUTC) { 4684 return 0; 4685 } 4686 //Timezone offset in seconds. The offset for timezones west of UTC is always negative, 4687 //and for those east of UTC is always positive. 4688 return -date.getTimezoneOffset() * 60; 4689 }, 4690 c: () => { 4691 //ISO 8601 date 4692 return 'Y-m-d\\TH:i:sP'.replace(formatRegex, _replaceDateFormat); 4693 }, 4694 r: () => { 4695 //RFC 2822 formatted date 4696 return 'D, d M Y H:i:s O'.replace(formatRegex, _replaceDateFormat); 4697 }, 4698 U: () => { 4699 //Seconds since the Unix Epoch 4700 return Math.floor(date.getTime() / 1000); 4701 }, 4702 sago: () => { 4703 return _formatDateMessage(intval((nowDate - date) / 1000), { 4704 '0': 'FD_SECOND_AGO_0', 4705 '1': 'FD_SECOND_AGO_1', 4706 '10_20': 'FD_SECOND_AGO_10_20', 4707 'MOD_1': 'FD_SECOND_AGO_MOD_1', 4708 'MOD_2_4': 'FD_SECOND_AGO_MOD_2_4', 4709 'MOD_OTHER': 'FD_SECOND_AGO_MOD_OTHER' 4710 }); 4711 }, 4712 sdiff: () => { 4713 return _formatDateMessage(intval((nowDate - date) / 1000), { 4714 '0': 'FD_SECOND_DIFF_0', 4715 '1': 'FD_SECOND_DIFF_1', 4716 '10_20': 'FD_SECOND_DIFF_10_20', 4717 'MOD_1': 'FD_SECOND_DIFF_MOD_1', 4718 'MOD_2_4': 'FD_SECOND_DIFF_MOD_2_4', 4719 'MOD_OTHER': 'FD_SECOND_DIFF_MOD_OTHER' 4720 }); 4721 },
4722 sshort: () => { 4723 return this._getMessage('FD_SECOND_SHORT').replace(/#VALUE#/g, intval((nowDate - date) / 1000)); 4724 }, 4725 iago: () => { 4726 return _formatDateMessage(intval((nowDate - date) / 60 / 1000), { 4727 '0': 'FD_MINUTE_AGO_0', 4728 '1': 'FD_MINUTE_AGO_1', 4729 '10_20': 'FD_MINUTE_AGO_10_20', 4730 'MOD_1': 'FD_MINUTE_AGO_MOD_1', 4731 'MOD_2_4': 'FD_MINUTE_AGO_MOD_2_4', 4732 'MOD_OTHER': 'FD_MINUTE_AGO_MOD_OTHER' 4733 }); 4734 }, 4735 idiff: () => { 4736 return _formatDateMessage(intval((nowDate - date) / 60 / 1000), { 4737 '0': 'FD_MINUTE_DIFF_0', 4738 '1': 'FD_MINUTE_DIFF_1', 4739 '10_20': 'FD_MINUTE_DIFF_10_20', 4740 'MOD_1': 'FD_MINUTE_DIFF_MOD_1', 4741 'MOD_2_4': 'FD_MINUTE_DIFF_MOD_2_4', 4742 'MOD_OTHER': 'FD_MINUTE_DIFF_MOD_OTHER' 4743 }); 4744 }, 4745 isago: () => { 4746 const minutesAgo = intval((nowDate - date) / 60 / 1000); 4747 let result = _formatDateMessage(minutesAgo, { 4748 '0': 'FD_MINUTE_0', 4749 '1': 'FD_MINUTE_1', 4750 '10_20': 'FD_MINUTE_10_20', 4751 'MOD_1': 'FD_MINUTE_MOD_1', 4752 'MOD_2_4': 'FD_MINUTE_MOD_2_4', 4753 'MOD_OTHER': 'FD_MINUTE_MOD_OTHER' 4754 }); 4755 result += ' '; 4756 const secondsAgo = intval((nowDate - date) / 1000) - minutesAgo * 60; 4757 result += _formatDateMessage(secondsAgo, { 4758 '0': 'FD_SECOND_AGO_0', 4759 '1': 'FD_SECOND_AGO_1', 4760 '10_20': 'FD_SECOND_AGO_10_20', 4761 'MOD_1': 'FD_SECOND_AGO_MOD_1', 4762 'MOD_2_4': 'FD_SECOND_AGO_MOD_2_4', 4763 'MOD_OTHER': 'FD_SECOND_AGO_MOD_OTHER' 4764 }); 4765 return result; 4766 }, 4767 ishort: () => { 4768 return this._getMessage('FD_MINUTE_SHORT').replace(/#VALUE#/g, intval((nowDate - date) / 60 / 1000)); 4769 }, 4770 Hago: () => { 4771 return _formatDateMessage(intval((nowDate - date) / 60 / 60 / 1000), { 4772 '0': 'FD_HOUR_AGO_0', 4773 '1': 'FD_HOUR_AGO_1', 4774 '10_20': 'FD_HOUR_AGO_10_20', 4775 'MOD_1': 'FD_HOUR_AGO_MOD_1', 4776 'MOD_2_4': 'FD_HOUR_AGO_MOD_2_4', 4777 'MOD_OTHER': 'FD_HOUR_AGO_MOD_OTHER' 4778 }); 4779 }, 4780 Hdiff: () => { 4781 return _formatDateMessage(intval((nowDate - date) / 60 / 60 / 1000), { 4782 '0': 'FD_HOUR_DIFF_0', 4783 '1': 'FD_HOUR_DIFF_1', 4784 '10_20': 'FD_HOUR_DIFF_10_20', 4785 'MOD_1': 'FD_HOUR_DIFF_MOD_1', 4786 'MOD_2_4': 'FD_HOUR_DIFF_MOD_2_4', 4787 'MOD_OTHER': 'FD_HOUR_DIFF_MOD_OTHER' 4788 }); 4789 }, 4790 Hshort: () => { 4791 return this._getMessage('FD_HOUR_SHORT').replace(/#VALUE#/g, intval((nowDate - date) / 60 / 60 / 1000)); 4792 }, 4793 yesterday: () => { 4794 return this._getMessage('FD_YESTERDAY'); 4795 }, 4796 today: () => { 4797 return this._getMessage('FD_TODAY'); 4798 }, 4799 tommorow: () => { 4800 return this._getMessage('FD_TOMORROW'); 4801 }, 4802 tomorrow: () => { 4803 return this._getMessage('FD_TOMORROW'); 4804 }, 4805 dago: () => { 4806 return _formatDateMessage(intval((nowDate - date) / 60 / 60 / 24 / 1000), { 4807 '0': 'FD_DAY_AGO_0', 4808 '1': 'FD_DAY_AGO_1', 4809 '10_20': 'FD_DAY_AGO_10_20', 4810 'MOD_1': 'FD_DAY_AGO_MOD_1', 4811 'MOD_2_4': 'FD_DAY_AGO_MOD_2_4', 4812 'MOD_OTHER': 'FD_DAY_AGO_MOD_OTHER' 4813 }); 4814 }, 4815 ddiff: () => { 4816 return _formatDateMessage(intval((nowDate - date) / 60 / 60 / 24 / 1000), { 4817 '0': 'FD_DAY_DIFF_0', 4818 '1': 'FD_DAY_DIFF_1', 4819 '10_20': 'FD_DAY_DIFF_10_20', 4820 'MOD_1': 'FD_DAY_DIFF_MOD_1', 4821 'MOD_2_4': 'FD_DAY_DIFF_MOD_2_4', 4822 'MOD_OTHER': 'FD_DAY_DIFF_MOD_OTHER' 4823 }); 4824 }, 4825 dshort: () => { 4826 return this._getMessage('FD_DAY_SHORT').replace(/#VALUE#/g, intval((nowDate - date) / 60 / 60 / 24 / 1000)); 4827 }, 4828 mago: () => { 4829 return _formatDateMessage(intval((nowDate - date) / 60 / 60 / 24 / 31 / 1000), { 4830 '0': 'FD_MONTH_AGO_0', 4831 '1': 'FD_MONTH_AGO_1', 4832 '10_20': 'FD_MONTH_AGO_10_20', 4833 'MOD_1': 'FD_MONTH_AGO_MOD_1', 4834 'MOD_2_4': 'FD_MONTH_AGO_MOD_2_4', 4835 'MOD_OTHER': 'FD_MONTH_AGO_MOD_OTHER' 4836 }); 4837 }, 4838 mdiff: () => { 4839 return _formatDateMessage(intval((nowDate - date) / 60 / 60 / 24 / 31 / 1000), { 4840 '0': 'FD_MONTH_DIFF_0', 4841 '1': 'FD_MONTH_DIFF_1', 4842 '10_20': 'FD_MONTH_DIFF_10_20', 4843 'MOD_1': 'FD_MONTH_DIFF_MOD_1', 4844 'MOD_2_4': 'FD_MONTH_DIFF_MOD_2_4', 4845 'MOD_OTHER': 'FD_MONTH_DIFF_MOD_OTHER' 4846 }); 4847 }, 4848 mshort: () => { 4849 return this._getMessage('FD_MONTH_SHORT').replace(/#VALUE#/g, intval((nowDate - date) / 60 / 60 / 24 / 31 / 1000)); 4850 }, 4851 Yago: () => { 4852 return _formatDateMessage(intval((nowDate - date) / 60 / 60 / 24 / 365 / 1000), { 4853 '0': 'FD_YEARS_AGO_0', 4854 '1': 'FD_YEARS_AGO_1', 4855 '10_20': 'FD_YEARS_AGO_10_20', 4856 'MOD_1': 'FD_YEARS_AGO_MOD_1', 4857 'MOD_2_4': 'FD_YEARS_AGO_MOD_2_4', 4858 'MOD_OTHER': 'FD_YEARS_AGO_MOD_OTHER' 4859 }); 4860 }, 4861 Ydiff: () => { 4862 return _formatDateMessage(intval((nowDate - date) / 60 / 60 / 24 / 365 / 1000), { 4863 '0': 'FD_YEARS_DIFF_0', 4864 '1': 'FD_YEARS_DIFF_1', 4865 '10_20': 'FD_YEARS_DIFF_10_20', 4866 'MOD_1': 'FD_YEARS_DIFF_MOD_1', 4867 'MOD_2_4': 'FD_YEARS_DIFF_MOD_2_4', 4868 'MOD_OTHER': 'FD_YEARS_DIFF_MOD_OTHER' 4869 }); 4870 }, 4871 Yshort: () => { 4872 return _formatDateMessage(intval((nowDate - date) / 60 / 60 / 24 / 365 / 1000), { 4873 '0': 'FD_YEARS_SHORT_0', 4874 '1': 'FD_YEARS_SHORT_1', 4875 '10_20': 'FD_YEARS_SHORT_10_20', 4876 'MOD_1': 'FD_YEARS_SHORT_MOD_1', 4877 'MOD_2_4': 'FD_YEARS_SHORT_MOD_2_4', 4878 'MOD_OTHER': 'FD_YEARS_SHORT_MOD_OTHER' 4879 }); 4880 }, 4881 x: () => { 4882 const ampm = this.isAmPmMode(true); 4883 const timeFormat = ampm === this.AM_PM_MODE.LOWER ? 'g:i a' : ampm === this.AM_PM_MODE.UPPER ? 'g:i A' : 'H:i'; 4884 return this.format([['tomorrow', 'tomorrow, ' + timeFormat], ['-', this.convertBitrixFormat(this._getMessage('FORMAT_DATETIME')).replace(/:s/g, '')], ['
4884s', 'sago'], ['i', 'iago'], ['today', 'today, ' + timeFormat], ['yesterday', 'yesterday, ' + timeFormat], ['', this.convertBitrixFormat(this._getMessage('FORMAT_DATETIME')).replace(/:s/g, '')]], date, nowDate, isUTC); 4885 }, 4886 X: () => { 4887 const ampm = this.isAmPmMode(true); 4888 const timeFormat = ampm === this.AM_PM_MODE.LOWER ? 'g:i a' : ampm === this.AM_PM_MODE.UPPER ? 'g:i A' : 'H:i'; 4889 const day = this.format([['tomorrow', 'tomorrow'], ['-', this.convertBitrixFormat(this._getMessage('FORMAT_DATE'))], ['today', 'today'], ['yesterday', 'yesterday'], ['', this.convertBitrixFormat(this._getMessage('FORMAT_DATE'))]], date, nowDate, isUTC); 4890 const time = this.format([['tomorrow', timeFormat], ['today', timeFormat], ['yesterday', timeFormat], ['', '']], date, nowDate, isUTC); 4891 if (time.length > 0) { 4892 return this._getMessage('FD_DAY_AT_TIME').replace(/#DAY#/g, day).replace(/#TIME#/g, time); 4893 } else { 4894 return day; 4895 } 4896 }, 4897 Q: () => { 4898 const daysAgo = intval((nowDate - date) / 60 / 60 / 24 / 1000); 4899 if (daysAgo == 0) { 4900 return this._getMessage('FD_DAY_DIFF_1').replace(/#VALUE#/g, 1); 4901 } else { 4902 return this.format([['d', 'ddiff'], ['m', 'mdiff'], ['', 'Ydiff']], date, nowDate); 4903 } 4904 } 4905 }; 4906 let cutZeroTime = false; 4907 if (_format[0] && _format[0] == '^') { 4908 cutZeroTime = true; 4909 _format = _format.substr(1); 4910 } 4911 let result = _format.replace(formatRegex, _replaceDateFormat); 4912 if (cutZeroTime) { 4913 /* 15.04.12 13:00:00 => 15.04.12 13:00 4914 00:01:00 => 00:01 4915 4 may 00:00:00 => 4 may 4916 01-01-12 00:00 => 01-01-12 4917 */ 4918 4919 result = result.replace(/\s*00:00:00\s*/g, '').replace(/(\d\d:\d\d)(:00)/g, '$1').replace(/(\s*00:00\s*)(?!:)/g, ''); 4920 } 4921 if (replaceMap.length > 0) { 4922 replaceMap.forEach(function (element, index) { 4923 result = result.replace('{{' + index + '}}', element); 4924 }); 4925 } 4926 return result; 4927 function _formatDateInterval(formats, date, nowDate, isUTC) { 4928 const secondsAgo = intval((nowDate - date) / 1000); 4929 for (let i = 0; i < formats.length; i++) { 4930 const formatInterval = formats[i][0]; 4931 const formatValue = formats[i][1]; 4932 let match = null; 4933 if (formatInterval == 's') { 4934 if (secondsAgo < 60) { 4935 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 4936 } 4937 } else if ((match = /^s(\d+)\>?(\d+)?/.exec(formatInterval)) != null) { 4938 if (match[1] && match[2]) { 4939 if (secondsAgo < match[1] && secondsAgo > match[2]) { 4940 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 4941 } 4942 } else if (secondsAgo < match[1]) { 4943 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 4944 } 4945 } else if (formatInterval == 'i') { 4946 if (secondsAgo < 60 * 60) { 4947 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 4948 } 4949 } else if ((match = /^i(\d+)\>?(\d+)?/.exec(formatInterval)) != null) { 4950 if (match[1] && match[2]) { 4951 if (secondsAgo < match[1] * 60 && secondsAgo > match[2] * 60) { 4952 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 4953 } 4954 } else if (secondsAgo < match[1] * 60) { 4955 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 4956 } 4957 } else if (formatInterval == 'H') { 4958 if (secondsAgo < 24 * 60 * 60) { 4959 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 4960 } 4961 } else if ((match = /^H(\d+)\>?(\d+)?/.exec(formatInterval)) != null) { 4962 if (match[1] && match[2]) { 4963 if (secondsAgo < match[1] * 60 * 60 && secondsAgo > match[2] * 60 * 60) { 4964 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 4965 } 4966 } else if (secondsAgo < match[1] * 60 * 60) { 4967 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 4968 } 4969 } else if (formatInterval == 'd') { 4970 if (secondsAgo < 31 * 24 * 60 * 60) { 4971 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 4972 } 4973 } else if ((match = /^d(\d+)\>?(\d+)?/.exec(formatInterval)) != null) { 4974 if (match[1] && match[2]) { 4975 if (secondsAgo < match[1] * 24 * 60 * 60 && secondsAgo > match[2] * 24 * 60 * 60) { 4976 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 4977 } 4978 } else if (secondsAgo < match[1] * 24 * 60 * 60) { 4979 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 4980 } 4981 } else if (formatInterval == 'm') { 4982 if (secondsAgo < 365 * 24 * 60 * 60) { 4983 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 4984 } 4985 } else if ((match = /^m(\d+)\>?(\d+)?/.exec(formatInterval)) != null) { 4986 if (match[1] && match[2]) { 4987 if (secondsAgo < match[1] * 31 * 24 * 60 * 60 && secondsAgo > match[2] * 31 * 24 * 60 * 60) { 4988 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 4989 } 4990 } else if (secondsAgo < match[1] * 31 * 24 * 60 * 60) { 4991 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 4992 } 4993 } else if (formatInterval == 'now') { 4994 if (date.getTime() == nowDate.getTime()) { 4995 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 4996 } 4997 } else if (formatInterval == 'today') { 4998 const year = getFullYear(nowDate);
4999 const month = getMonth(nowDate); 5000 const day = getDate(nowDate); 5001 const todayStart = isUTC ? new Date(Date.UTC(year, month, day, 0, 0, 0, 0)) : new Date(year, month, day, 0, 0, 0, 0); 5002 const todayEnd = isUTC ? new Date(Date.UTC(year, month, day + 1, 0, 0, 0, 0)) : new Date(year, month, day + 1, 0, 0, 0, 0); 5003 if (date >= todayStart && date < todayEnd) { 5004 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5005 } 5006 } else if (formatInterval == 'todayFuture') { 5007 const year = getFullYear(nowDate); 5008 const month = getMonth(nowDate); 5009 const day = getDate(nowDate); 5010 const todayStart = nowDate.getTime(); 5011 const todayEnd = isUTC ? new Date(Date.UTC(year, month, day + 1, 0, 0, 0, 0)) : new Date(year, month, day + 1, 0, 0, 0, 0); 5012 if (date >= todayStart && date < todayEnd) { 5013 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5014 } 5015 } else if (formatInterval == 'yesterday') { 5016 const year = getFullYear(nowDate);
5017 const month = getMonth(nowDate); 5018 const day = getDate(nowDate); 5019 const yesterdayStart = isUTC ? new Date(Date.UTC(year, month, day - 1, 0, 0, 0, 0)) : new Date(year, month, day - 1, 0, 0, 0, 0); 5020 const yesterdayEnd = isUTC ? new Date(Date.UTC(year, month, day, 0, 0, 0, 0)) : new Date(year, month, day, 0, 0, 0, 0); 5021 if (date >= yesterdayStart && date < yesterdayEnd) { 5022 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5023 } 5024 } else if (formatInterval == 'tommorow' || formatInterval == 'tomorrow') { 5025 const year = getFullYear(nowDate); 5026 const month = getMonth(nowDate); 5027 const day = getDate(nowDate); 5028 const tomorrowStart = isUTC ? new Date(Date.UTC(year, month, day + 1, 0, 0, 0, 0)) : new Date(year, month, day + 1, 0, 0, 0, 0); 5029 const tomorrowEnd = isUTC ? new Date(Date.UTC(year, month, day + 2, 0, 0, 0, 0)) : new Date(year, month, day + 2, 0, 0, 0, 0); 5030 if (date >= tomorrowStart && date < tomorrowEnd) { 5031 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5032 } 5033 } else if (formatInterval == '-') { 5034 if (secondsAgo < 0) { 5035 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5036 } 5037 } 5038 } 5039 5040 //return formats.length > 0 ? thisDateTimeFormat.format(formats.pop()[1], date, nowDate, isUTC) : ''; 5041 return formats.length > 0 ? thisDateTimeFormat.format(formats[formats.length - 1][1], date, nowDate, isUTC) : ''; 5042 } 5043 function getFullYear(date) { 5044 return isUTC ? date.getUTCFullYear() : date.getFullYear(); 5045 } 5046 function getDate(date) { 5047 return isUTC ? date.getUTCDate() : date.getDate(); 5048 } 5049 function getMonth(date) { 5050 return isUTC ? date.getUTCMonth() : date.getMonth(); 5051 } 5052 function getHours(date) { 5053 return isUTC ? date.getUTCHours() : date.getHours(); 5054 } 5055 function getMinutes(date) { 5056 return isUTC ? date.getUTCMinutes() : date.getMinutes(); 5057 } 5058 function getSeconds(date) { 5059 return isUTC ? date.getUTCSeconds() : date.getSeconds(); 5060 } 5061 function getMilliseconds(date) { 5062 return isUTC ? date.getUTCMilliseconds() : date.getMilliseconds(); 5063 } 5064 function getDay(date) { 5065 return isUTC ? date.getUTCDay() : date.getDay(); 5066 } 5067 function setDate(date, dayValue) { 5068 return isUTC ? date.setUTCDate(dayValue) : date.setDate(dayValue); 5069 } 5070 function setMonth(date, monthValue, dayValue) { 5071 return isUTC ? date.setUTCMonth(monthValue, dayValue) : date.setMonth(monthValue, dayValue); 5072 } 5073 function _formatDateMessage(value, messages) { 5074 const val = value < 100 ? Math.abs(value) : Math.abs(value % 100); 5075 const dec = val % 10; 5076 let message = ''; 5077 if (val == 0) { 5078 message = thisDateTimeFormat._getMessage(messages['0']); 5079 } else if (val == 1) { 5080 message = thisDateTimeFormat._getMessage(messages['1']); 5081 } else if (val >= 10 && val <= 20) { 5082 message = thisDateTimeFormat._getMessage(messages['10_20']); 5083 } else if (dec == 1) { 5084 message = thisDateTimeFormat._getMessage(messages['MOD_1']); 5085 } else if (2 <= dec && dec <= 4) { 5086 message = thisDateTimeFormat._getMessage(messages['MOD_2_4']); 5087 } else { 5088 message = thisDateTimeFormat._getMessage(messages['MOD_OTHER']); 5089 } 5090 return message.replace(/#VALUE#/g, value); 5091 } 5092 function _replaceDateFormat(match, matchFull) { 5093 if (dateFormats[match]) { 5094 return dateFormats[match](); 5095 } else { 5096 return matchFull; 5097 } 5098 } 5099 function intval(number) { 5100 return number >= 0 ? Math.floor(number) : Math.ceil(number); 5101 } 5102 } 5103 }]); 5104 return DateTimeFormat; 5105 }(); 5106 babelHelpers.defineProperty(DateTimeFormat, "AM_PM_MODE", { 5107 UPPER: 1, 5108 LOWER: 2, 5109 NONE: false 5110 }); 5111 babelHelpers.defineProperty(DateTimeFormat, "convertBitrixFormat", convertBitrixFormat); 5112 babelHelpers.defineProperty(DateTimeFormat, "getFormat", getFormat); 5113 5114 function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); } 5115 function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 5116 function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 5117 5118 /** 5119 * Available units: `Y` - years, `m` - months, `d` - days, `H` - hours, `i` - minutes, `s` - seconds. 5120 */ 5121 5122 const defaultOptions = { 5123 format: 'Y m d H i s', 5124 style: 'long' 5125 }; 5126 var _getSeparator = /*#__PURE__*/new WeakSet(); 5127 var _getMaxUnit = /*#__PURE__*/new WeakSet(); 5128 var _formatUnit = /*#__PURE__*/new WeakSet(); 5129 var _getUnitPropertyModByFormat = /*#__PURE__*/new WeakSet(); 5130 var _getUnitPropertyByFormat = /*#__PURE__*/new WeakSet(); 5131 var _getUnitDuration = /*#__PURE__*/new WeakSet(); 5132 let DurationFormat = /*#__PURE__*/function () { 5133 function DurationFormat(milliseconds) { 5134 babelHelpers.classCallCheck(this, DurationFormat); 5135 _classPrivateMethodInitSpec(this, _getUnitDuration); 5136 _classPrivateMethodInitSpec(this, _getUnitPropertyByFormat); 5137 _classPrivateMethodInitSpec(this, _getUnitPropertyModByFormat); 5138 _classPrivateMethodInitSpec(this, _formatUnit); 5139 _classPrivateMethodInitSpec(this, _getMaxUnit); 5140 _classPrivateMethodInitSpec(this, _getSeparator); 5141 this.milliseconds = Math.abs(milliseconds); 5142 } 5143 babelHelpers.createClass(DurationFormat, [{ 5144 key: "format", 5145 /** 5146 * @example new DurationFormat(5070000).format() // 1 hour, 24 minutes, 30 seconds 5147 * @example new DurationFormat(5070000).format({ style: 'short' }) // 1 h 24 m 30 s 5148 * @example new DurationFormat(5070000).format({ format: 'd H i' }) // 1 hour, 24 minutes 5149 * @example new DurationFormat(5070000).format({ format: 'i s' }) // 84 minutes, 30 seconds 5150 */ 5151 value: function format(formatOptions = defaultOptions) { 5152 const options = { 5153 ...defaultOptions, 5154 ...formatOptions 5155 }; 5156 const orderedUnits = main_core.Loc.getMessage('FD_UNIT_ORDER').split(' '); 5157 const separator = _classPrivateMethodGet(this, _getSeparator, _getSeparator2).
5157call(this, options.style); 5158 const formatUnits = new Set(options.format.split(' ')); 5159 const maxUnit = _classPrivateMethodGet(this, _getMaxUnit, _getMaxUnit2).call(this, options.format); 5160 return orderedUnits.filter(unit => formatUnits.has(unit)).map(unit => _classPrivateMethodGet(this, _formatUnit, _formatUnit2).call(this, unit, unit !== maxUnit, options.style)).filter(unit => unit !== '').join(separator); 5161 } 5162 /** 5163 * @example new DurationFormat(5070000).formatClosest() // 1 hour 5164 * @example new DurationFormat(5070000).formatClosest({ format: 'i s' }) // 84 minutes 5165 */ 5166 }, { 5167 key: "formatClosest", 5168 value: function formatClosest(formatOptions = defaultOptions) { 5169 const options = { 5170 ...defaultOptions, 5171 ...formatOptions 5172 }; 5173 const maxUnit = _classPrivateMethodGet(this, _getMaxUnit, _getMaxUnit2).call(this, options.format); 5174 return _classPrivateMethodGet(this, _formatUnit, _formatUnit2).call(this, maxUnit, false, options.style); 5175 } 5176 }, { 5177 key: "seconds", 5178 get: function () { 5179 return Math.floor(this.milliseconds / DurationFormat.getUnitDurations().s); 5180 } 5181 }, { 5182 key: "minutes", 5183 get: function () { 5184 return Math.floor(this.milliseconds / DurationFormat.getUnitDurations().i); 5185 } 5186 }, { 5187 key: "hours", 5188 get: function () { 5189 return Math.floor(this.milliseconds / DurationFormat.getUnitDurations().H); 5190 } 5191 }, { 5192 key: "days", 5193 get: function () { 5194 return Math.floor(this.milliseconds / DurationFormat.getUnitDurations().d); 5195 } 5196 /** 5197 * Considering month is 31 days 5198 */ 5199 }, { 5200 key: "months", 5201 get: function () { 5202 return Math.floor(this.milliseconds / DurationFormat.getUnitDurations().m); 5203 } 5204 /** 5205 * Considering year is 365 days 5206 */ 5207 }, { 5208 key: "years", 5209 get: function () { 5210 return Math.floor(this.milliseconds / DurationFormat.getUnitDurations().Y); 5211 } 5212 }], [{ 5213 key: "createFromSeconds", 5214 value: function createFromSeconds(seconds) { 5215 return new DurationFormat(seconds * DurationFormat.getUnitDurations().s); 5216 } 5217 }, { 5218 key: "createFromMinutes", 5219 value: function createFromMinutes(minutes) { 5220 return new DurationFormat(minutes * DurationFormat.getUnitDurations().i); 5221 } 5222 }, { 5223 key: "getUnitDurations", 5224 value: function getUnitDurations() { 5225 return { 5226 s: 1000, 5227 i: 60000, 5228 H: 3600000, 5229 d: 86400000, 5230 m: 2678400000, 5231 Y: 31536000000 5232 }; 5233 } 5234 }]); 5235 return DurationFormat; 5236 }(); 5237 function _getSeparator2(style) { 5238 if (style === 'short') { 5239 return main_core.Loc.getMessage('FD_SEPARATOR_SHORT').replaceAll(' ', ' '); 5240 } 5241 return main_core.Loc.getMessage('FD_SEPARATOR').replaceAll(' ', ' '); 5242 } 5243 function _getMaxUnit2(format) { 5244 const formatUnits = new Set(format.split(' ')); 5245 const units = Object.entries(DurationFormat.getUnitDurations()).filter(([unit]) => formatUnits.has(unit)); 5246 return units.reduce((closestDuration, unitDuration) => { 5247 const whole = Math.floor(this.milliseconds / unitDuration[1]) >= 1; 5248 const max = unitDuration[1] > closestDuration[1]; 5249 return whole && max ? unitDuration : closestDuration; 5250 }, units[0])[0]; 5251 } 5252 function _formatUnit2(unitStr, mod, style) { 5253 const value = mod ? _classPrivateMethodGet(this, _getUnitPropertyModByFormat, _getUnitPropertyModByFormat2).call(this, unitStr) : _classPrivateMethodGet(this, _getUnitPropertyByFormat, _getUnitPropertyByFormat2).call(this, unitStr); 5254 if (mod && value === 0) { 5255 return ''; 5256 } 5257 const now = Date.now() / 1000; 5258 const unitDuration = value * _classPrivateMethodGet(this, _getUnitDuration, _getUnitDuration2).call(this, unitStr) / 1000; 5259 const format = style === 'short' ? `${unitStr}short` : `${unitStr}diff`; 5260 return DateTimeFormat.format(format, now - unitDuration, now); 5261 } 5262 function _getUnitPropertyModByFormat2(unitStr) { 5263 const propsMod = { 5264 s: this.seconds % 60, 5265 i: this.minutes % 60, 5266 H: this.hours % 24, 5267 d: this.days % 31, 5268 m: this.months % 12, 5269 Y: this.years 5270 }; 5271 return propsMod[unitStr]; 5272 } 5273 function _getUnitPropertyByFormat2(unitStr) { 5274 const props = { 5275 s: this.seconds, 5276 i: this.minutes, 5277 H: this.hours, 5278 d: this.days, 5279 m: this.months, 5280 Y: this.years 5281 }; 5282 return props[unitStr]; 5283 } 5284 function _getUnitDuration2(unitStr) { 5285 return DurationFormat.getUnitDurations()[unitStr]; 5286 } 5287 5288 const cache = new main_core.Cache.MemoryCache(); 5289 /** 5290 * @memberOf BX.Main.Timezone 5291 * 5292 * WARNING! Don't use this class or any classes from Timezone namespace on sites without Bitrix Framework. 5293 * It is not designed to handle this case and will definitely break. 5294 */ 5295 const Offset = { 5296 get SERVER_TO_UTC() { 5297 return cache.remember('SERVER_TO_UTC', () => { 5298 return main_core.Text.toInteger(main_core.Loc.getMessage('SERVER_TZ_OFFSET')); 5299 }); 5300 }, 5301 get USER_TO_SERVER() { 5302 return cache.remember('USER_TO_SERVER', () => { 5303 return main_core.Text.toInteger(main_core.Loc.getMessage('USER_TZ_OFFSET')); 5304 }); 5305 }, 5306 // Date returns timezone offset in minutes by default, change it to seconds 5307 // Also offset is negative in UTC+ timezones and positive in UTC- timezones. 5308 // By convention Bitrix uses the opposite approach, so change offset sign. 5309 get BROWSER_TO_UTC() { 5310 return cache.remember('BROWSER_TO_UTC', () => { 5311 const offset = main_core.Text.toInteger(new Date().getTimezoneOffset() * 60); 5312 return -offset; 5313 }); 5314 } 5315 }; 5316 Object.freeze(Offset); 5317 5318 function normalizeTimeValue(timeValue) { 5319 if (main_core.Type.isDate(timeValue)) { 5320 return getTimestampFromDate(timeValue); 5321 } 5322 return main_core.Text.toInteger(timeValue); 5323 } 5324 function createDateFromTimestamp(timestampInSeconds) { 5325 return new Date(timestampInSeconds * 1000); 5326 } 5327 function getTimestampFromDate(date) { 5328 return Math.floor(date.getTime() / 1000); 5329 } 5330 5331 let offset = Offset; 5332 let now = null; 5333 function getOffset() { 5334 return offset; 5335 } 5336 function getNowTimestamp() { 5337 var _now; 5338 return (_now = now) !== null && _now !== void 0 ? _now : getTimestampFromDate(new Date()); 5339 } 5340 5341 /** 5342 * @memberOf BX.Main.Timezone 5343 * 5344 * WARNING! Don't use this class or any classes from Timezone namespace on sites without Bitrix Framework. 5345 * It is not designed to handle this case and will definitely break. 5346 */ 5347 let BrowserTime = /*#__PURE__*/function () { 5348 function BrowserTime() { 5349 babelHelpers.classCallCheck(this, BrowserTime); 5350 } 5351 babelHelpers.createClass(BrowserTime, null, [{ 5352 key: "getDate", 5353 /** 5354 * Returns a Date object with time and date that represent a specific moment in Browser (device) timezone. 5355 * 5356 * @param utcTimestamp - normal utc timestamp in seconds. 'now' by default 5357 * @returns {Date} 5358 */ 5359 value: function getDate(utcTimestamp = null) { 5360 const timestamp = main_core.Type.isNumber(utcTimestamp) ? utcTimestamp : this.getTimestamp(); 5361 return createDateFromTimestamp(timestamp); 5362 } 5363 /** 5364 * Transforms a moment in Browser (device) timezone to a moment in User timezone. 5365 * 5366 * ATTENTION! Date.getTime() and Date.getTimezoneOffset() will return inaccurate data. Since a native Date object 5367 * doesn't support timezone other that device timezone, we have to manually change timestamp to shift time value in 5368 * a Date object. 5369 * 5370 * @param browserTime - a moment in Browser (device) timezone. Either a Date object (recommended way). Or timestamp
5371 * in seconds in Browser timezone (see this.getTimestamp for details). 5372 * @returns {Date} 5373 */ 5374 }, { 5375 key: "toUserDate", 5376 value: function toUserDate(browserTime) { 5377 return createDateFromTimestamp(this.toUser(browserTime)); 5378 } 5379 /** 5380 * Transforms a moment in Browser (device) timezone to a moment in Server timezone. 5381 * 5382 * ATTENTION! Date.getTime() and Date.getTimezoneOffset() will return inaccurate data. Since a native Date object 5383 * doesn't support timezone other that device timezone, we have to manually change timestamp to shift time value in 5384 * a Date object. 5385 * 5386 * @param browserTime - a moment in Browser (device) timezone. Either a Date object (recommended way). Or timestamp 5387 * in seconds in Browser timezone (see this.getTimestamp for details). 5388 * @returns {Date} 5389 */ 5390 }, { 5391 key: "toServerDate", 5392 value: function toServerDate(browserTime) { 5393 return createDateFromTimestamp(this.toServer(browserTime)); 5394 } 5395 /** 5396 * Transforms a moment in Browser (device) timezone to a timestamp in User timezone. 5397 * It's recommended to use this.toUserDate for more clear code. 5398 * 5399 * @param browserTime - a moment in Browser timezone. Either a Date object (recommended way). Or timestamp in seconds 5400 * in Browser timezone (see this.getTimestamp for details). 5401 * @returns {number} - timestamp that when passed to 'new Date' will create an object with absolute time matching 5402 * the time in User timezone 5403 */ 5404 }, { 5405 key: "toUser", 5406 value: function toUser(browserTime) { 5407 return this.toServer(browserTime) + getOffset().USER_TO_SERVER; 5408 } 5409 /** 5410 * Transforms a moment in Browser (device) timezone to a timestamp in Server timezone. 5411 * It's recommended to use this.toServerDate for more clear code. 5412 * 5413 * @param browserTime - a moment in Browser timezone. Either a Date object (recommended way). Or timestamp in seconds 5414 * in Browser timezone (see this.getTimestamp for details). 5415 * @returns {number} - timestamp that when passed to 'new Date' will create an object with absolute time matching 5416 * the time in Server timezone 5417 */ 5418 }, { 5419 key: "toServer", 5420 value: function toServer(browserTime) { 5421 return normalizeTimeValue(browserTime) - getOffset().BROWSER_TO_UTC + getOffset().SERVER_TO_UTC; 5422 } 5423 /** 5424 * Returns 'now' timestamp in Browser (device) timezone - when it's passed to a 'new Date', it will create an object 5425 * with absolute time matching the time as if it was in Browser (device) timezone. 5426 * 5427 * @returns {number} 5428 */ 5429 }, { 5430 key: "getTimestamp", 5431 value: function getTimestamp() { 5432 // since 'Date' class in JS is hardcoded to use device timezone, 'browser timestamp' is just normal UTC timestamp :) 5433 5434 return getNowTimestamp(); 5435 } 5436 }]); 5437 return BrowserTime; 5438 }(); 5439 5440 /** 5441 * @memberOf BX.Main.Timezone 5442 * 5443 * WARNING! Don't use this class or any classes from Timezone namespace on sites without Bitrix Framework. 5444 * It is not designed to handle this case and will definitely break. 5445 */ 5446 let ServerTime = /*#__PURE__*/function () { 5447 function ServerTime() { 5448 babelHelpers.classCallCheck(this, ServerTime); 5449 } 5450 babelHelpers.createClass(ServerTime, null, [{ 5451 key: "getDate", 5452 /** 5453 * Returns a Date object with time and date that represent a specific moment in Server timezone. 5454 * 5455 * ATTENTION! Date.getTime() and Date.getTimezoneOffset() will return inaccurate data. Since a native Date object 5456 * doesn't support timezone other that device timezone, we have to manually change timestamp to shift time value in 5457 * a Date object. 5458 * 5459 * @param utcTimestamp - normal utc timestamp in seconds. 'now' by default 5460 * @returns {Date} 5461 */ 5462 value: function getDate(utcTimestamp = null) { 5463 if (main_core.Type.isNumber(utcTimestamp)) { 5464 const browserToServerOffset = getOffset().SERVER_TO_UTC - getOffset().BROWSER_TO_UTC; 5465 return createDateFromTimestamp(utcTimestamp + browserToServerOffset); 5466 } 5467 return BrowserTime.toServerDate(BrowserTime.getDate()); 5468 } 5469 /** 5470 * Transforms a moment in Server timezone to a moment in User timezone. 5471 * 5472 * ATTENTION! Date.getTime() and Date.getTimezoneOffset() will return inaccurate data. Since a native Date object 5473 * doesn't support timezone other that device timezone, we have to manually change timestamp to shift time value in 5474 * a Date object. 5475 * 5476 * @param serverTime - a moment in Server timezone. Either a Date object (recommended way). Or timestamp in seconds
5476in 5477 * Server timezone (see this.getTimestamp for details). 5478 * @returns {Date} 5479 */ 5480 }, { 5481 key: "toUserDate", 5482 value: function toUserDate(serverTime) { 5483 return createDateFromTimestamp(this.toUser(serverTime)); 5484 } 5485 /** 5486 * Transforms a moment in Server timezone to a moment in Browser (device) timezone. 5487 * 5488 * @param serverTime - a moment in Server timezone. Either a Date object (recommended way). Or timestamp in seconds in 5489 * Server timezone (see this.getTimestamp for details). 5490 * @returns {Date} 5491 */ 5492 }, { 5493 key: "toBrowserDate", 5494 value: function toBrowserDate(serverTime) { 5495 return createDateFromTimestamp(this.toBrowser(serverTime)); 5496 } 5497 /** 5498 * Transforms a moment in Server timezone to a timestamp in User timezone. 5499 * It's recommended to use this.toServerDate for more clear code. 5500 * 5501 * @param serverTime - a moment in Server timezone. Either a Date object (recommended way). Or timestamp in seconds in 5502 * Server timezone (see this.getTimestamp for details). 5503 * @returns {number} - timestamp that when passed to 'new Date' will create an object with absolute time matching 5504 * the time in User timezone 5505 */ 5506 }, { 5507 key: "toUser", 5508 value: function toUser(serverTime) { 5509 return normalizeTimeValue(serverTime) + getOffset().USER_TO_SERVER; 5510 } 5511 /** 5512 * Transforms a moment in Server timezone to a timestamp in Browser (device) timezone. 5513 * It's recommended to use this.toBrowserDate for more clear code. 5514 * 5515 * @param serverTime - a moment in Server timezone. Either a Date object (recommended way). Or timestamp in seconds in 5516 * Server timezone (see this.getTimestamp for details). 5517 * @returns {number} - timestamp that when passed to 'new Date' will create an object with absolute time matching 5518 * the time in Browser (device) timezone 5519 */ 5520 }, { 5521 key: "toBrowser", 5522 value: function toBrowser(serverTime) { 5523 return normalizeTimeValue(serverTime) + getOffset().BROWSER_TO_UTC - getOffset().SERVER_TO_UTC; 5524 } 5525 /** 5526 * Returns 'now' timestamp in Server timezone - when it's passed to a 'new Date', it will create an object with 5527 * absolute time matching the time as if it was in Server timezone. 5528 * 5529 * @returns {number} 5530 */ 5531 }, { 5532 key: "getTimestamp", 5533 value: function getTimestamp() { 5534 return BrowserTime.toServer(BrowserTime.getTimestamp()); 5535 } 5536 }]); 5537 return ServerTime; 5538 }(); 5539 5540 function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) { _classCheckPrivateStaticAccess(receiver, classConstructor); _classCheckPrivateStaticFieldDescriptor(descriptor, "get"); return _classApplyDescriptorGet(receiver, descriptor); } 5541 function _classCheckPrivateStaticFieldDescriptor(descriptor, action) { if (descriptor === undefined) { throw new TypeError("attempted to " + action + " private static field before its declaration"); } } 5542 function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } } 5543 function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; } 5544 5545 /** 5546 * @memberOf BX.Main.Timezone 5547 * 5548 * WARNING! Don't use this class or any classes from Timezone namespace on sites without Bitrix Framework. 5549 * It is not designed to handle this case and will definitely break. 5550 * 5551 * ATTENTION! In Bitrix user timezone !== browser timezone. Users can change their timezone from their profile settings 5552 * and the timezone will be different from browser timezone. 5553 */ 5554 let UserTime = /*#__PURE__*/function () { 5555 function UserTime() { 5556 babelHelpers.classCallCheck(this, UserTime); 5557 } 5558 babelHelpers.createClass(UserTime, null, [{ 5559 key: "getDate", 5560 /** 5561 * Returns a Date object with time and date that represent a specific moment in User timezone. 5562 * 5563 * ATTENTION! Date.getTime() and Date.getTimezoneOffset() will return inaccurate data. Since a native Date object 5564 * doesn't support timezone other that device timezone, we have to manually change timestamp to shift time value in 5565 * a Date object. 5566 * 5567 * @param utcTimestamp - normal utc timestamp in seconds. 'now' by default 5568 * @returns {Date} 5569 */ 5570 value: function getDate(utcTimestamp = null) { 5571 if (main_core.Type.isNumber(utcTimestamp)) { 5572 return createDateFromTimestamp(utcTimestamp + _classStaticPrivateFieldSpecGet(this, UserTime, _userToBrowserOffset)); 5573 } 5574 return createDateFromTimestamp(this.getTimestamp()); 5575 } 5576 }, { 5577 key: "toBrowserDate", 5578 /** 5579 * Transforms a moment in User timezone to a moment in Browser (device) timezone. 5580 * 5581 * @param userTime - a moment in User timezone. Either a Date object (recommended way). Or timestamp in seconds
5581in 5582 * User timezone (see this.getTimestamp for details). 5583 * @returns {Date} 5584 */ 5585 value: function toBrowserDate(userTime) { 5586 return createDateFromTimestamp(this.toBrowser(userTime)); 5587 } 5588 /** 5589 * Transforms a moment in User timezone to a moment in Server timezone. 5590 * 5591 * ATTENTION! Date.getTime() and Date.getTimezoneOffset() will return inaccurate data. Since a native Date object 5592 * doesn't support timezone other that device timezone, we have to manually change timestamp to shift time value in 5593 * a Date object. 5594 * 5595 * @param userTime - a moment in User timezone. Either a Date object (recommended way). Or timestamp in seconds in 5596 * User timezone (see this.getTimestamp for details). 5597 * @returns {Date} 5598 */ 5599 }, { 5600 key: "toServerDate", 5601 value: function toServerDate(userTime) { 5602 return createDateFromTimestamp(this.toServer(userTime)); 5603 } 5604 }, { 5605 key: "toUTCTimestamp", 5606 value: function toUTCTimestamp(userTime) { 5607 return normalizeTimeValue(userTime) - _classStaticPrivateFieldSpecGet(this, UserTime, _userToBrowserOffset); 5608 } 5609 /** 5610 * Transforms a moment in User timezone to a timestamp in Browser timezone. 5611 * It's recommended to use this.toBrowserDate for more clear code. 5612 * 5613 * @param userTime - a moment in User timezone. Either a Date object (recommended way). Or timestamp in seconds in 5614 * User timezone (see this.getTimestamp for details). 5615 * @returns {number} - timestamp that when passed to 'new Date' will create an object with absolute time matching 5616 * the time in Browser (device) timezone 5617 */ 5618 }, { 5619 key: "toBrowser", 5620 value: function toBrowser(userTime) { 5621 return normalizeTimeValue(userTime) + getOffset().BROWSER_TO_UTC - getOffset().SERVER_TO_UTC - getOffset().USER_TO_SERVER; 5622 } 5623 /** 5624 * Transforms a moment in User timezone to a timestamp in Server timezone. 5625 * It's recommended to use this.toServerDate for more clear code. 5626 * 5627 * @param userTime - a moment in User timezone. Either a Date object (recommended way). Or timestamp in seconds in 5628 * User timezone (see this.getTimestamp for details). 5629 * @returns {number} - timestamp that when passed to 'new Date' will create an object with absolute time matching 5630 * the time in Server timezone 5631 */ 5632 }, { 5633 key: "toServer", 5634 value: function toServer(userTime) { 5635 return normalizeTimeValue(userTime) - getOffset().USER_TO_SERVER; 5636 } 5637 /** 5638 * Returns 'now' timestamp in User timezone - when it's passed to a 'new Date', it will create an object with absolute 5639 * time matching the time as if it was in User timezone. 5640 * 5641 * @returns {number} 5642 */ 5643 }, { 5644 key: "getTimestamp", 5645 value: function getTimestamp() { 5646 return BrowserTime.toUser(BrowserTime.getTimestamp()); 5647 } 5648 }]); 5649 return UserTime; 5650 }(); 5651 function _get_userToBrowserOffset() { 5652 const userToUTCOffset = getOffset().SERVER_TO_UTC + getOffset().USER_TO_SERVER; 5653 return userToUTCOffset - getOffset().BROWSER_TO_UTC; 5654 } 5655 var _userToBrowserOffset = { 5656 get: _get_userToBrowserOffset, 5657 set: void 0 5658 }; 5659 5660 const Timezone = Object.freeze({ 5661 BrowserTime, 5662 Offset, 5663 ServerTime, 5664 UserTime 5665 }); 5666 5667 exports.Timezone = Timezone; 5668 exports.Date = DateTimeFormat; 5669 exports.DateTimeFormat = DateTimeFormat; 5670 exports.DurationFormat = DurationFormat; 5671 5672}((this.BX.Main = this.BX.Main || {}),BX)); 5673//# sourceMappingURL=main.date.js.map 5674 5675/* End */ 5676; 5677; /* Start:"a:4:{s:4:"full";s:49:"/bitrix/js/main/core/core_date.js?177728766336251";s:6:"source";s:33:"/bitrix/js/main/core/core_date.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 5678;(function(){ 5679 5680if (BX.date) 5681 return; 5682 5683BX.date = BX.Main.Date; 5684 5685/************************************** calendar class **********************************/ 5686 5687var obCalendarSingleton = null; 5688 5689/* 5690params: { 5691 node: bind element || document.body 5692 5693 value - start value in site format (using 'field' param if 'value' does not exist) 5694 callback - date check handler. can return false to prevent calendar closing. 5695 callback_after - another handler, called after date picking 5696 5697 field - field to read/write data 5698 5699 bTime = true - whether to enable time control 5700 bHideTime = false - whether to hide time control by default 5701 5702 currentTime - current UTC time() 5703 5704} 5705*/ 5706 5707 5708BX.calendar = function(params) 5709{ 5710 return BX.calendar.get().Show(params); 5711}; 5712 5713BX.calendar.get = function() 5714{ 5715 if (!obCalendarSingleton)
5716 obCalendarSingleton = new BX.JCCalendar(); 5717 5718 return obCalendarSingleton; 5719}; 5720 5721// simple func for compatibility with the oldies 5722BX.calendar.InsertDaysBack = function(input, days) 5723{ 5724 if (days != '') 5725 { 5726 var d = new Date(); 5727 if(days > 0) 5728 { 5729 d.setTime(d.valueOf() - days*86400000); 5730 } 5731 5732 input.value = BX.date.format(BX.date.convertBitrixFormat(BX.message('FORMAT_DATE')), d, null); 5733 } 5734 else 5735 { 5736 input.value = ''; 5737 } 5738}; 5739 5740BX.calendar.ValueToString = function(value, bTime, bUTC) 5741{ 5742 return BX.date.format( 5743 BX.date.convertBitrixFormat(BX.message(bTime ? 'FORMAT_DATETIME' : 'FORMAT_DATE')), 5744 value, 5745 null, 5746 !!bUTC 5747 ); 5748}; 5749 5750BX.calendar.ValueToStringFormat = function(value, bitrixFormat, bUTC) 5751{ 5752 return BX.date.format( 5753 BX.date.convertBitrixFormat(bitrixFormat), 5754 value, 5755 null, 5756 !!bUTC 5757 ); 5758}; 5759 5760 5761BX.CalendarPeriod = 5762{ 5763 Init: function(inputFrom, inputTo, selPeriod) 5764 { 5765 if((inputFrom.value != "" || inputTo.value != "") && selPeriod.value == "") 5766 selPeriod.value = "interval"; 5767 5768 selPeriod.onchange(); 5769 }, 5770 5771 ChangeDirectOpts: function(peroidValue, selPParent) // "week" || "others" 5772 { 5773 var selDirect = BX.findChild(selPParent, {'className':'adm-select adm-calendar-direction'}, true); 5774 5775 if(peroidValue == "week") 5776 { 5777 selDirect.options[0].text = BX.message('JSADM_CALEND_PREV_WEEK'); 5778 selDirect.options[1].text = BX.message('JSADM_CALEND_CURR_WEEK'); 5779 selDirect.options[2].text = BX.message('JSADM_CALEND_NEXT_WEEK'); 5780 } 5781 else 5782 { 5783 selDirect.options[0].text = BX.message('JSADM_CALEND_PREV'); 5784 selDirect.options[1].text = BX.message('JSADM_CALEND_CURR'); 5785 selDirect.options[2].text = BX.message('JSADM_CALEND_NEXT'); 5786 } 5787 }, 5788 5789 SaveAndClearInput: function(oInput) 5790 { 5791 if(!window.SavedPeriodValues) 5792 window.SavedPeriodValues = {}; 5793 5794 window.SavedPeriodValues[oInput.id] = oInput.value; 5795 oInput.value=""; 5796 }, 5797 5798 RestoreInput: function(oInput) 5799 { 5800 if(!window.SavedPeriodValues || !window.SavedPeriodValues[oInput.id]) 5801 return; 5802 5803 oInput.value = window.SavedPeriodValues[oInput.id]; 5804 delete(window.SavedPeriodValues[oInput.id]); 5805 }, 5806 5807 OnChangeP: function(sel) 5808 { 5809 var selPParent = sel.parentNode.parentNode; 5810 var bShowFrom, bShowTo, bShowDirect, bShowSeparate; 5811 bShowFrom = bShowTo = bShowDirect = bShowSeparate = false; 5812 5813 var inputFromWrap = BX.findChild(selPParent, {'className':'adm-input-wrap adm-calendar-inp adm-calendar-first'}); 5814 var inputToWrap = BX.findChild(selPParent, {'className':'adm-input-wrap adm-calendar-second'}); 5815 var selDirectWrap = BX.findChild(selPParent, {'className':'adm-select-wrap adm-calendar-direction'}); 5816 var separator = BX.findChild(selPParent, {'className':'adm-calendar-separate'}); 5817 var inputFrom = BX.findChild(selPParent, {'className':'adm-input adm-calendar-from'},true); 5818 var inputTo = BX.findChild(selPParent, {'className':'adm-input adm-calendar-to'},true); 5819 5820 // define who must be shown 5821 switch (sel.value) 5822 { 5823 case "day": 5824 case "week": 5825 case "month": 5826 case "quarter": 5827 case "year": 5828 bShowDirect=true; 5829 BX.CalendarPeriod.OnChangeD(selDirectWrap.children[0]); 5830 break; 5831 5832 case "before": 5833 bShowTo = true; 5834 break; 5835 5836 case "after": 5837 bShowFrom = true; 5838 break; 5839 5840 case "exact": 5841 bShowFrom= true; 5842 break; 5843 5844 case "interval": 5845 bShowFrom = bShowTo = bShowSeparate = true; 5846 BX.CalendarPeriod.RestoreInput(inputFrom); 5847 BX.CalendarPeriod.RestoreInput(inputTo); 5848 5849 break; 5850 5851 case "": 5852 BX.CalendarPeriod.SaveAndClearInput(inputFrom); 5853 BX.CalendarPeriod.SaveAndClearInput(inputTo); 5854 break; 5855 5856 default: 5857 break; 5858 5859 } 5860 5861 BX.CalendarPeriod.ChangeDirectOpts(sel.value, selPParent); 5862 5863 inputFromWrap.style.display = (bShowFrom? 'inline-block':'none'); 5864 inputToWrap.style.display = (bShowTo? 'inline-block':'none'); 5865 selDirectWrap.style.display = (bShowDirect? 'inline-block':'none'); 5866 separator.style.display = (bShowSeparate? 'inline-block':'none'); 5867 }, 5868 5869 5870 OnChangeD: function(sel) 5871 { 5872 var selPParent = sel.parentNode.parentNode; 5873 var inputFrom = BX.findChild(selPParent, {'className':'adm-input adm-calendar-from'},true); 5874 var inputTo = BX.findChild(selPParent, {'className':'adm-input adm-calendar-to'},true); 5875 var selPeriod = BX.findChild(selPParent, {'className':'adm-select adm-calendar-period'},true); 5876 5877 var offset=0; 5878 5879 switch (sel.value) 5880 { 5881 case "previous": 5882 offset = -1; 5883 break; 5884 5885 case "next": 5886 offset = 1; 5887 break; 5888 5889 case "current": 5890 default: 5891 break; 5892 5893 } 5894 5895 var from = false;
5896 var to = false; 5897 5898 var today = new Date(); 5899 var year = today.getFullYear(); 5900 var month = today.getMonth(); 5901 var day = today.getDate(); 5902 var dayW = today.getDay(); 5903 5904 if (dayW == 0) 5905 dayW = 7; 5906 5907 switch (selPeriod.value) 5908 { 5909 case "day": 5910 from = new Date(year, month, day+offset, 0, 0, 0); 5911 to = new Date(year, month, day+offset, 23, 59, 59); 5912 break; 5913 5914 case "week": 5915 from = new Date(year, month, day-dayW+1+offset*7, 0, 0, 0); 5916 to = new Date(year, month, day+(7-dayW)+offset*7, 23, 59, 59); 5917 break; 5918 5919 case "month": 5920 from = new Date(year, month+offset, 1, 0, 0, 0); 5921 to = new Date(year, month+1+offset, 0, 23, 59, 59); 5922 break; 5923 5924 case "quarter": 5925 var quarterNum = Math.floor((month/3))+offset; 5926 from = new Date(year, 3*(quarterNum), 1, 0, 0, 0); 5927 to = new Date(year, 3*(quarterNum+1), 0, 23, 59, 59); 5928 break; 5929 5930 case "year": 5931 from = new Date(year+offset, 0, 1, 0, 0, 0); 5932 to = new Date(year+1+offset, 0, 0, 23, 59, 59); 5933 break; 5934 5935 default: 5936 break; 5937 } 5938 5939 var format = window[inputFrom.name+"_bTime"] ? BX.message('FORMAT_DATETIME') : BX.message('FORMAT_DATE'); 5940 5941 if(from) 5942 { 5943 inputFrom.value = BX.formatDate(from, format); 5944 BX.addClass(inputFrom,"adm-calendar-inp-setted"); 5945 } 5946 5947 if(to) 5948 { 5949 inputTo.value = BX.formatDate(to, format); 5950 BX.addClass(inputTo,"adm-calendar-inp-setted"); 5951 } 5952 } 5953}; 5954 5955 5956BX.JCCalendar = function() 5957{ 5958 this.params = {}; 5959 5960 this.bAmPm = BX.isAmPmMode(); 5961 5962 this.popup = null; 5963 this.popup_month = null; 5964 this.popup_year = null; 5965 this.month_popup_classname = ''; 5966 this.year_popup_classname = ''; 5967 this.value = null; 5968 this._layers = {}; 5969 this._current_layer = null; 5970 5971 this.DIV = null; 5972 this.PARTS = {}; 5973 5974 this.weekStart = 0; 5975 this.numRows = 6; 5976 5977 this._create = function(params) 5978 { 5979 const paramsForPopupWindow = { 5980 closeByEsc: true, 5981 autoHide: false, 5982 content: this._get_content(), 5983 bindOptions: { forceBindPosition: true }, 5984 }; 5985 if (Boolean(params.fixed) && params.fixed) 5986 { 5987 paramsForPopupWindow.fixed = params.fixed; 5988 } 5989 5990 this.popup = new BX.PopupWindow( 5991 'calendar_popup_' + Math.random(), 5992 params.node, 5993 paramsForPopupWindow, 5994 ); 5995 5996 BX.bind(this.popup.popupContainer, 'click', function(event) { 5997 event.stopPropagation(); 5998 }); 5999 }; 6000 6001 this._auto_hide_disable = function() 6002 { 6003 BX.unbind(document, 'click', BX.proxy(this._auto_hide, this)); 6004 }; 6005 6006 this._auto_hide_enable = function() 6007 { 6008 BX.bind(document, 'click', BX.proxy(this._auto_hide, this)); 6009 }; 6010 6011 this._auto_hide = function(e) 6012 { 6013 this._auto_hide_disable(); 6014 this.popup.close(); 6015 }; 6016 6017 this._get_content = function() 6018 { 6019 var _layer_onclick = BX.delegate(function(e) { 6020 e = e||window.event; 6021 this.SetDate( 6022 new Date(parseInt(BX.proxy_context.getAttribute('data-date'))), 6023 (e.type === 'dblclick' || (this.params.bCompatibility && !this.params.bTimeVisibility)) 6024 ) 6025 }, this); 6026 6027 this.DIV = BX.create('DIV', { 6028 props: {className: 'bx-calendar'}, 6029 children: [ 6030 BX.create('DIV', { 6031 props: { 6032 className: 'bx-calendar-header' 6033 }, 6034 children: [ 6035 BX.create('A', { 6036 attrs: {href: 'javascript:void(0)'}, 6037 props: {className: 'bx-calendar-left-arrow'}, 6038 events: {click: BX.proxy(this._prev, this)} 6039 }), 6040 6041 BX.create('SPAN', { 6042 props: {className: 'bx-calendar-header-content'}, 6043 children: [ 6044 (this.PARTS.MONTH = BX.create('A', { 6045 attrs: {href: 'javascript:void(0)'}, 6046 props: {className: 'bx-calendar-top-month'}, 6047 events: {click: BX.proxy(this._menu_month, this)} 6048 })), 6049 6050 (this.PARTS.YEAR = BX.create('A', { 6051 attrs: {href: 'javascript:void(0)'}, 6052 props: {className: 'bx-calendar-top-year'}, 6053 events: {click: BX.proxy(this._menu_year, this)} 6054 })) 6055 ] 6056 }), 6057 6058 BX.create('A', { 6059 attrs: {href: 'javascript:void(0)'}, 6060 props: {className: 'bx-calendar-right-arrow'}, 6061 events: {click: BX.proxy(this._next, this)} 6062 }) 6063 ] 6064 }), 6065 6066 (this.PARTS.WEEK = BX.create('DIV', { 6067 props: { 6068 className: 'bx-calendar-name-day-wrap' 6069 } 6070 })), 6071 6072 (this.PARTS.LAYERS = BX.create('DIV', { 6073 props: { 6074 className: 'bx-calendar-cell-block' 6075 }, 6076 events: { 6077 click: BX.delegateEvent({className: 'bx-calendar-cell'}, _layer_onclick), 6078 dblclick: BX.delegateEvent({className: 'bx-calendar-cell'}, _layer_onclick) 6079 } 6080 })), 6081 6082 (this.PARTS.TIME = BX.create('DIV', { 6083 props: { 6084 className: 'bx-calendar-set-time-wrap' 6085 }, 6086 events: { 6087 click: BX.delegateEvent( 6088 {attr: 'data-action'}, 6089 BX.delegate(this._time_actions, this) 6090 ) 6091 }, 6092 html: '<a href="javascript:void(0)" data-action="time_show" class="bx-calendar-set-time"><i></i>'+BX.message('CAL_TIME_SET')+'</a><div class="bx-calendar-form-block"><span class="bx-calendar-form-text">'+BX.message('CAL_TIME')+'</span><span class="bx-calendar-form"><input type="text" class="bx-calendar-form-input" maxwidth="2" onkeyup="BX.calendar.get()._check_time()" /><span class="bx-calendar-form-separator"></span><input type="text" class="bx-calendar-form-input" maxwidth="2" onkeyup="BX.calendar.get()._check_time()" />'+(this.bAmPm?'<span class="bx-calendar-AM-PM-block"><span class="bx-calendar-AM-PM-text" data-action="time_ampm"></span><span class="bx-calendar-form-arrow-r"><a href="javascript:void(0)" class="bx-calendar-form-arrow-top" data-action="time_ampm_up"><i></i></a><a href="javascript:void(0)" class="bx-calendar-form-arrow-bottom" data-action="time_ampm_down"><i></i></a></span></span>':'')+'</span><a href="javascript:void(0)" data-action="time_hide" class="bx-calendar-form-close"><i></i></a></div>' 6093 })), 6094 6095 (this.PARTS.BUTTONS = BX.create('DIV', { 6096 props: {className: 'bx-calendar-button-block'}, 6097 events: { 6098 click: BX.delegateEvent( 6099 {attr: 'data-action'}, 6100 BX.delegate(this._button_actions, this) 6101 ) 6102 }, 6103 html: '<a href="javascript:void(0)" class="bx-calendar-button bx-calendar-button-select" data-action="submit"><span class="bx-calendar-button-left"></span><span class="bx-calendar-button-text">'+BX.message('CAL_BUTTON')+'</span><span class="bx-calendar-button-right"></span></a><a href="javascript:void(0)" class="bx-calendar-button bx-calendar-button-cancel" data-action="cancel"><span class="bx-calendar-button-left"></span><span class="bx-calendar-button-text">'+BX.message('JS_CORE_WINDOW_CLOSE')+'</span><span class="bx-calendar-button-right"></span></a>' 6104 })) 6105 ] 6106 }); 6107 6108 this.PARTS.TIME_INPUT_H = BX.findChild(this.PARTS.TIME, {tag: 'INPUT'}, true); 6109 this.PARTS.TIME_INPUT_M = this.PARTS.TIME_INPUT_H.nextSibling.nextSibling; 6110 6111 if (this.bAmPm) 6112 this.PARTS.TIME_AMPM = this.PARTS.TIME_INPUT_M.nextSibling.firstChild; 6113 6114 var spinner = (new BX.JCSpinner({
6115 input: this.PARTS.TIME_INPUT_H, 6116 callback_change: BX.proxy(this._check_time, this), 6117 bSaveValue: false 6118 })).Show(); 6119 spinner.className = 'bx-calendar-form-arrow-l'; 6120 this.PARTS.TIME_INPUT_H.parentNode.insertBefore(spinner, this.PARTS.TIME_INPUT_H); 6121 6122 spinner = (new BX.JCSpinner({ 6123 input: this.PARTS.TIME_INPUT_M, 6124 callback_change: BX.proxy(this._check_time, this), 6125 bSaveValue: true 6126 })).Show(); 6127 spinner.className = 'bx-calendar-form-arrow-r'; 6128 if (!this.PARTS.TIME_INPUT_M.nextSibling) 6129 this.PARTS.TIME_INPUT_M.parentNode.appendChild(spinner); 6130 else 6131 this.PARTS.TIME_INPUT_M.parentNode.insertBefore(spinner, this.PARTS.TIME_INPUT_M.nextSibling); 6132 6133 for (var i = 0; i < 7; i++) 6134 { 6135 this.PARTS.WEEK.appendChild(BX.create('SPAN', { 6136 props: { 6137 className: 'bx-calendar-name-day' 6138 }, 6139 text: BX.message('DOW_' + ((i + this.weekStart) % 7)) 6140 })); 6141 } 6142 6143 return this.DIV; 6144 }; 6145 6146 this._time_actions = function() 6147 { 6148 switch (BX.proxy_context.getAttribute('data-action')) 6149 { 6150 case 'time_show': 6151 BX.addClass(this.PARTS.TIME, 'bx-calendar-set-time-opened'); 6152 if (this.params.bCompatibility) 6153 { 6154 BX.removeClass(this.PARTS.BUTTONS, 'bx-calendar-buttons-disabled'); 6155 } 6156 this.popup.adjustPosition(); 6157 break; 6158 case 'time_hide': 6159 BX.removeClass(this.PARTS.TIME, 'bx-calendar-set-time-opened'); 6160 if (this.params.bCompatibility) 6161 { 6162 this._saveChoice('hide'); 6163 BX.addClass(this.PARTS.BUTTONS, 'bx-calendar-buttons-disabled'); 6164 } 6165 this.popup.adjustPosition(); 6166 break; 6167 case 'time_ampm': 6168 this.PARTS.TIME_AMPM.innerHTML = this.PARTS.TIME_AMPM.innerHTML == 'AM' ? 'PM' : 'AM'; 6169 break; 6170 case 'time_ampm_up': 6171 this._check_time({bSaveValue: false}, null, 12); 6172 return; 6173 break; 6174 case 'time_ampm_down': 6175 this._check_time({bSaveValue: false}, null, -12); 6176 return; 6177 break; 6178 } 6179 6180 this._check_time(); 6181 }; 6182 6183 this._button_actions = function() 6184 { 6185 switch (BX.proxy_context.getAttribute('data-action')) 6186 { 6187 case 'submit': 6188 if (this.params.bCompatibility) 6189 { 6190 this._saveChoice('show'); 6191 } 6192 this.SaveValue(); 6193 break; 6194 case 'cancel': 6195 this.Close(); 6196 break; 6197 } 6198 }; 6199 6200 this._saveChoice = function(state) 6201 { 6202 if (this.params.bCategoryTimeVisibilityOption) 6203 { 6204 BX.userOptions.save( 6205 this.params.bCategoryTimeVisibilityOption, 6206 this.params.bNameTimeVisibilityOption, 6207 'visibility', 6208 (state === 'show' ? 'Y' : 'N') 6209 ); 6210 } 6211 6212 this._bTimeVisibility = (state === 'show'); 6213 this.params.bTimeVisibility = this._bTimeVisibility; 6214 }; 6215 6216 this._check_time = function(params, value, direction) 6217 { 6218 var h = parseInt(this.PARTS.TIME_INPUT_H.value.substring(0,5),10)||0, 6219 m = parseInt(this.PARTS.TIME_INPUT_M.value.substring(0,5),10)||0, 6220 bChanged = false; 6221 6222 if (!!params && !params.bSaveValue) 6223 { 6224 this.value.setUTCHours(this.value.getUTCHours() + direction); 6225 } 6226 else if (!isNaN(h)) 6227 { 6228 if (this.bAmPm) 6229 { 6230 if (h != 12 && this.PARTS.TIME_AMPM.innerHTML == 'PM') 6231 { 6232 h += 12; 6233 } 6234 } 6235 6236 bChanged = true; 6237 this.value.setUTCHours(h % 24); 6238 } 6239 6240 if (!isNaN(m)) 6241 { 6242 bChanged = true; 6243 this.value.setUTCMinutes(m % 60); 6244 } 6245 6246 if (bChanged) 6247 { 6248 this.SetValue(this.value); 6249 } 6250 }; 6251 6252 this._set_layer = function() 6253 { 6254 var layerId = parseInt(this.value.getUTCFullYear() + '' + BX.util.str_pad_left(this.value.getUTCMonth()+'', 2, "0")); 6255 6256 if (!this._layers[layerId]) 6257 { 6258 this._layers[layerId] = this._create_layer(); 6259 this._layers[layerId].BXLAYERID = layerId; 6260 } 6261 6262 if (this._current_layer) 6263 { 6264 var v = new Date(this.value.valueOf()); 6265 v.setUTCHours(0); v.setUTCMinutes(0); 6266 6267 var cur_value = BX.findChild(this._layers[layerId], { 6268 tag: 'A', 6269 className: 'bx-calendar-active' 6270 }, true), 6271 new_value = BX.findChild(this._layers[layerId], { 6272 tag: 'A', 6273 attr: { 6274 'data-date' : v.valueOf() + '' 6275 } 6276 }, true); 6277 6278 if (cur_value) 6279 { 6280 BX.removeClass(cur_value, 'bx-calendar-active'); 6281 } 6282 6283 if (new_value) 6284 { 6285 BX.addClass(new_value, 'bx-calendar-active'); 6286 } 6287 6288 this._replace_layer(this._current_layer, this._layers[layerId]); 6289 } 6290 else 6291 { 6292 this.PARTS.LAYERS.appendChild(this._layers[layerId]); 6293 } 6294 6295 this._current_layer = this._layers[layerId]; 6296 }; 6297 6298 this._replace_layer = function(old_layer, new_layer) 6299 { 6300 if (old_layer != new_layer) 6301 { 6302 if (!BX.browser.IsIE() || BX.browser.IsDoctype()) 6303 { 6304 var dir = old_layer.BXLAYERID > new_layer.BXLAYERID ? 1 : -1; 6305 6306 var old_top = 0; 6307 var new_top = -dir * old_layer.offsetHeight; 6308 6309 old_layer.style.position = 'relative'; 6310 old_layer.style.top = "0px"; 6311 old_layer.style.zIndex = 5; 6312 6313 new_layer.style.position = 'absolute'; 6314 new_layer.style.top = new_top + 'px'; 6315 new_layer.style.zIndex = 6; 6316 6317 this.PARTS.LAYERS.appendChild(new_layer); 6318 6319 var delta = 15; 6320 6321 var f; 6322 (f = function() { 6323 new_top += dir * delta; 6324 old_top += dir * delta; 6325 6326 if (dir * new_top < 0) 6327 { 6328 old_layer.style.top = old_top + 'px'; 6329 new_layer.style.top = new_top + 'px'; 6330 setTimeout(f, 10); 6331 } 6332 else 6333 { 6334 old_layer.parentNode.removeChild(old_layer); 6335 6336 new_layer.style.top = "0px"; 6337 new_layer.style.position = 'static'; 6338 new_layer.style.zIndex = 0; 6339 } 6340 })(); 6341 } 6342 else 6343 {
6344 this.PARTS.LAYERS.replaceChild(new_layer, old_layer); 6345 } 6346 } 6347 }; 6348 6349 this._create_layer = function() 6350 { 6351 var l = BX.create('DIV', { 6352 props: { 6353 className: 'bx-calendar-layer' 6354 } 6355 }); 6356 6357 var month_start = new Date(this.value); 6358 month_start.setUTCHours(0); 6359 month_start.setUTCMinutes(0); 6360 6361 month_start.setUTCDate(1); 6362 6363 if (month_start.getUTCDay() != this.weekStart) 6364 { 6365 var d = month_start.getUTCDay() - this.weekStart; 6366 d += d < 0 ? 7 : 0; 6367 month_start.setUTCDate(month_start.getUTCDate()-d); 6368 } 6369 6370 var cur_month = this.value.getUTCMonth(), 6371 cur_day = this.value.getUTCDate(), 6372 s = ''; 6373 for (var i = 0; i < this.numRows; i++) 6374 { 6375 s += '<div class="bx-calendar-range' 6376 +(i == this.numRows-1 ? ' bx-calendar-range-noline' : '') 6377 +'">'; 6378 6379 for (var j = 0; j < 7; j++) 6380 { 6381 d = month_start.getUTCDate(); 6382 var wd = month_start.getUTCDay(); 6383 var className = 'bx-calendar-cell'; 6384 6385 if (cur_month != month_start.getUTCMonth()) 6386 className += ' bx-calendar-date-hidden'; 6387 else if (cur_day == d) 6388 className += ' bx-calendar-active'; 6389 6390 6391 if (wd == 0 || wd == 6) 6392 className += ' bx-calendar-weekend'; 6393 6394 s += '<a href="javascript:void(0)" class="'+className+'" data-date="' + month_start.valueOf() + '">' + d + '</a>'; 6395 6396 month_start.setUTCDate(month_start.getUTCDate()+1); 6397 } 6398 s += '</div>'; 6399 } 6400 6401 l.innerHTML = s; 6402 6403 return l; 6404 }; 6405 6406 this._prev = function() 6407 { 6408 this.SetMonth(this.value.getUTCMonth()-1); 6409 }; 6410 6411 this._next = function() 6412 { 6413 this.SetMonth(this.value.getUTCMonth()+1); 6414 }; 6415 6416 this._menu_month_content = function() 6417 { 6418 var months = '', cur_month = this.value.getMonth(), i; 6419 for (i = 0; i < 12; i++) 6420 { 6421 months += '<span class="bx-calendar-month'+(i == cur_month ? ' bx-calendar-month-active' : '')+'" data-bx-month="' + i + '">' + BX.message('MONTH_' + (i + 1)) + '</span>'; 6422 } 6423 6424 return '<div class="bx-calendar-month-popup"><div class="bx-calendar-month-title" data-bx-month="' + this.value.getUTCMonth() + '">' + BX.message('MONTH_' + (this.value.getUTCMonth() + 1)) + '</div><div class="bx-calendar-month-content">' + months + '</div></div>'; 6425 }; 6426 6427 this._menu_month = function() 6428 { 6429 if (!this.popup_month) 6430 { 6431 this.popup_month = new BX.PopupWindow( 6432 'calendar_popup_month_' + Math.random(), this.PARTS.MONTH, 6433 { 6434 content: this._menu_month_content(), 6435 closeByEsc: true, 6436 autoHide: true, 6437 offsetTop: -29, 6438 offsetLeft: -1, 6439 className: this.month_popup_classname, 6440 events: { 6441 onPopupShow: BX.delegate(function() { 6442 if (this.popup_year) 6443 { 6444 this.popup_year.close(); 6445 } 6446 }, this) 6447 } 6448 } 6449 ); 6450 6451 BX.bind(this.popup_month.popupContainer, 'click', BX.proxy(this.month_popup_click, this)); 6452 this.popup_month.BXMONTH = this.value.getUTCMonth(); 6453 } 6454 else if (this.popup_month.BXMONTH != this.value.getUTCMonth()) 6455 { 6456 this.popup_month.setContent(this._menu_month_content()); 6457 this.popup_month.BXMONTH = this.value.getUTCMonth(); 6458 } 6459 6460 this.popup_month.show(); 6461 }; 6462 6463 this.month_popup_click = function(e) 6464 { 6465 var target = e.target || e.srcElement; 6466 if (target && target.getAttribute && target.getAttribute('data-bx-month')) 6467 { 6468 this.SetMonth(parseInt(target.getAttribute('data-bx-month'))); 6469 this.popup_month.close(); 6470 } 6471 }; 6472 6473 this._menu_year_content = function() 6474 { 6475 var s = '<div class="bx-calendar-year-popup"><div class="bx-calendar-year-title" data-bx-year="' + this.value.getUTCFullYear() + '">' + this.value.getUTCFullYear() + '</div><div class="bx-calendar-year-content" id="bx-calendar-year-content">'; 6476 6477 for (var i=-3; i <= 3; i++) 6478 { 6479 s += '<span class="bx-calendar-year-number' + (i == 0?' bx-calendar-year-active' : '') + '" data-bx-year="' + (this.value.getUTCFullYear() - i) + '">' + (this.value.getUTCFullYear() - i)+'</span>'; 6480 } 6481 6482 s += '</div><input data-bx-year-input="Y" type="text" class="bx-calendar-year-input" maxlength="4" /></div>'; 6483 6484 return s; 6485 }; 6486 6487 this._menu_year = function() 6488 { 6489 if (!this.popup_year) 6490 { 6491 this.popup_year = new BX.PopupWindow( 6492 'calendar_popup_year_' + Math.random(), this.PARTS.YEAR, 6493 { 6494 content: this._menu_year_content(), 6495 closeByEsc: true, 6496 autoHide: true, 6497 offsetTop: -29, 6498 offsetLeft: -1, 6499 className: this.year_popup_classname, 6500 events: { 6501 onPopupShow: BX.delegate(function() { 6502 if (this.popup_month) 6503 { 6504 this.popup_month.close(); 6505 } 6506 }, this) 6507 } 6508 } 6509 ); 6510 6511 BX.bind(this.popup_year.popupContainer, 'click', BX.proxy(this.year_popup_click, this)); 6512 BX.bind(this.popup_year.popupContainer, 'keyup', BX.proxy(this.year_popup_keyup, this)); 6513 this.popup_year.BXYEAR = this.value.getUTCFullYear(); 6514 } 6515 else if (this.popup_year.BXYEAR != this.value.getUTCFullYear()) 6516 { 6517 this.popup_year.setContent(this._menu_year_content()); 6518 this.popup_year.BXYEAR = this.value.getUTCFullYear(); 6519 } 6520 6521 this.popup_year.show(); 6522 }; 6523 6524 this.year_popup_click = function(e) 6525 { 6526 var target = e.target || e.srcElement; 6527 if (target && target.getAttribute && target.getAttribute('data-bx-year')) 6528 { 6529 this.SetYear(parseInt(target.getAttribute('data-bx-year'))); 6530 this.popup_year.close(); 6531 } 6532 }; 6533 this.year_popup_keyup = function(e) 6534 { 6535 var target = e.target || e.srcElement; 6536 if (target && target.getAttribute && target.getAttribute('data-bx-year-input') == 'Y') 6537 { 6538 var value = parseInt(target.value); 6539 if(value >= 1900 && value <= 2100) 6540 { 6541 this.SetYear(value); 6542 this.popup_year.close(); 6543 } 6544 } 6545 }; 6546 6547 this._check_date = function(v) 6548 { 6549 var res = v; 6550 6551 if (BX.type.isString(v)) 6552 { 6553 res = BX.parseDate(v, true); 6554 } 6555 6556 if (!BX.type.isDate(res) || isNaN(res.valueOf())) 6557 { 6558 res = BX.date.convertToUTC(new Date()); 6559 if (this.params.bHideTime) 6560 { 6561 res.setUTCHours(0); 6562 res.setUTCMinutes(0); 6563 } 6564 } 6565 6566 res.setUTCMilliseconds(0); 6567 res.setUTCSeconds(0); 6568 6569 res.BXCHECKED = true; 6570 6571 return res; 6572 }; 6573}; 6574 6575BX.JCCalendar.prototype.Show = function(params) 6576{ 6577 if (!BX.isReady) 6578 { 6579 BX.ready(BX.delegate(function() {this.Show(params)}, this)); 6580 return; 6581 } 6582 6583 params.node = params.node||document.body; 6584 6585 if (BX.type.isNotEmptyString(params.node)) 6586 { 6587 var n = BX(params.node); 6588 if (!n) 6589 { 6590 n = document.getElementsByName(params.node); 6591 if (n && n.length > 0) 6592 { 6593 n = n[0] 6594 } 6595 } 6596 params.node = n; 6597 } 6598 6599 if (!params.node) 6600 return; 6601 6602 if (!!params.field) 6603 { 6604 if (BX.type.isString(params.field)) 6605 { 6606 n = BX(params.field); 6607 if (!!n) 6608 { 6609 params.field = n; 6610 } 6611 else 6612 {
6613 if (params.form) 6614 { 6615 if (BX.type.isString(params.form)) 6616 { 6617 params.form = document.forms[params.form]; 6618 } 6619 } 6620 6621 if (BX.type.isDomNode(params.form) && !!params.form[params.field]) 6622 { 6623 params.field = params.form[params.field]; 6624 } 6625 else 6626 { 6627 n = document.getElementsByName(params.field); 6628 if (n && n.length > 0) 6629 { 6630 n = n[0]; 6631 params.field = n; 6632 } 6633 } 6634 } 6635 6636 if (BX.type.isString(params.field)) 6637 { 6638 params.field = BX(params.field); 6639 } 6640 } 6641 } 6642 6643 var bShow = !this.popup || !this.popup.isShown() || this.params.node != params.node; 6644 6645 this.params = params; 6646 6647 this.params.bCompatibility = (typeof this.params.bCompatibility == 'undefined' ? false : this.params.bCompatibility); 6648 this.params.bTimeVisibility = (typeof this.params.bTimeVisibility == 'undefined' ? !this.params.bCompatibility : this.params.bTimeVisibility); 6649 if (this.params.bCompatibility) 6650 { 6651 this.params.bCategoryTimeVisibilityOption = ( 6652 this.params.bCategoryTimeVisibilityOption ? this.params.bCategoryTimeVisibilityOption : '' 6653 ); 6654 this.params.bNameTimeVisibilityOption = ( 6655 this.params.bNameTimeVisibilityOption ? this.params.bNameTimeVisibilityOption : 'time_visibility' 6656 ); 6657 6658 if (typeof this._bTimeVisibility !== 'undefined') 6659 { 6660 this.params.bTimeVisibility = this._bTimeVisibility; 6661 } 6662 } 6663 6664 this.params.bTime = typeof this.params.bTime == 'undefined' ? true : !!this.params.bTime; 6665 this.params.bHideTime = typeof this.params.bHideTime == 'undefined' ? true : !!this.params.bHideTime; 6666 this.params.bUseSecond = typeof this.params.bUseSecond == 'undefined' ? true : !!this.params.bUseSecond; 6667 6668 this.weekStart = parseInt(this.params.weekStart || this.params.weekStart || BX.message('WEEK_START')); 6669 if (isNaN(this.weekStart)) 6670 this.weekStart = 1; 6671 6672 if (!this.popup) 6673 { 6674 this._create(this.params); 6675 } 6676 else 6677 { 6678 this.popup.setBindElement(this.params.node); 6679 } 6680 6681 var bHideTime = !!this.params.bHideTime; 6682 if (this.params.value) 6683 { 6684 this.SetValue(this.params.value); 6685 bHideTime = this.value.getUTCHours() <= 0 && this.value.getUTCMinutes() <= 0; 6686 } 6687 else if (this.params.field) 6688 { 6689 this.SetValue(this.params.field.value); 6690 bHideTime = this.value.getUTCHours() <= 0 && this.value.getUTCMinutes() <= 0; 6691 } 6692 else if (!!this.params.currentTime) 6693 { 6694 this.SetValue(this.params.currentTime); 6695 } 6696 else 6697 { 6698 this.SetValue(); 6699 } 6700 6701 if (!!this.params.bTime) 6702 { 6703 this.activateTimeStyle(bHideTime); 6704 } 6705 else 6706 { 6707 this.activateDateStyle(bHideTime); 6708 } 6709 6710 if (bShow) 6711 { 6712 this._auto_hide_disable(); 6713 this.popup.show(); 6714 setTimeout(BX.proxy(this._auto_hide_enable, this), 0); 6715 } 6716 6717 this.params.bSetFocus = typeof this.params.bSetFocus == 'undefined' ? true : !!this.params.bSetFocus; 6718 if(this.params.bSetFocus) 6719 { 6720 params.node.blur(); 6721 } 6722 else 6723 { 6724 BX.bind(params.node, 'keyup', BX.defer(function(){ 6725 this.SetValue(params.node.value); 6726 if(!!this.params.bTime) 6727 { 6728 if(this.value.getUTCHours() <= 0 && this.value.getUTCMinutes() <= 0) 6729 BX.removeClass(this.PARTS.TIME, 'bx-calendar-set-time-opened'); 6730 else 6731 BX.addClass(this.PARTS.TIME, 'bx-calendar-set-time-opened'); 6732 } 6733 }, this)); 6734 } 6735 6736 return this; 6737}; 6738 6739BX.JCCalendar.prototype.activateDateStyle = function(bHideTime) 6740{ 6741 BX.addClass(this.DIV, 'bx-calendar-time-disabled'); 6742 6743 if (!!bHideTime) 6744 BX.removeClass(this.PARTS.TIME, 'bx-calendar-set-time-opened'); 6745 else 6746 BX.addClass(this.PARTS.TIME, 'bx-calendar-set-time-opened'); 6747}; 6748 6749BX.JCCalendar.prototype.activateTimeStyle = function(bHideTime) 6750{ 6751 if (this.params.bCompatibility && !this.params.bTimeVisibility) 6752 { 6753 BX.addClass(this.PARTS.BUTTONS, 'bx-calendar-buttons-disabled'); 6754 BX.addClass(this.PARTS.TIME, 'bx-calendar-set-time-wrap-simple'); 6755 BX.removeClass(this.PARTS.TIME, 'bx-calendar-set-time-opened'); 6756 } 6757 else 6758 { 6759 BX.removeClass(this.DIV, 'bx-calendar-time-disabled'); 6760 6761 if (!!bHideTime) 6762 BX.removeClass(this.PARTS.TIME, 'bx-calendar-set-time-opened'); 6763 else 6764 BX.addClass(this.PARTS.TIME, 'bx-calendar-set-time-opened'); 6765 } 6766}; 6767 6768BX.JCCalendar.prototype.SetDay = function(d) 6769{ 6770 this.value.setUTCDate(d); 6771 return this.SetValue(this.value); 6772}; 6773 6774BX.JCCalendar.prototype.SetMonth = function(m) 6775{ 6776 if (this.popup_month) 6777 this.popup_month.close(); 6778 6779 this.value.setUTCMonth(m); 6780 6781 if(m < 0) 6782 m += 12; 6783 else if (m >= 12) 6784 m -= 12; 6785 6786 while(this.value.getUTCMonth() > m) 6787 { 6788 this.value.setUTCDate(this.value.getUTCDate()-1); 6789 } 6790 6791 return this.SetValue(this.value); 6792}; 6793 6794BX.JCCalendar.prototype.SetYear = function(y) 6795{ 6796 if (this.popup_year) 6797 this.popup_year.close(); 6798 this.value.setUTCFullYear(y); 6799 return this.SetValue(this.value); 6800}; 6801 6802BX.JCCalendar.prototype.SetDate = function(v, bSet) 6803{ 6804 v = this._check_date(v); 6805 v.setUTCHours(this.value.getUTCHours()); 6806 v.setUTCMinutes(this.value.getUTCMinutes()); 6807 v.setUTCSeconds(this.value.getUTCSeconds()); 6808 6809 if (this.params.bTime && !bSet) 6810 { 6811 return this.SetValue(v); 6812 } 6813 else 6814 { 6815 this.SetValue(v); 6816 this.SaveValue(); 6817 } 6818}; 6819 6820BX.JCCalendar.prototype.SetValue = function(v) 6821{ 6822 this.value = (v && v.BXCHECKED) ? v : this._check_date(v); 6823 6824 this.PARTS.MONTH.innerHTML = BX.message('MONTH_' + (this.value.getUTCMonth()+1)); 6825 this.PARTS.YEAR.innerHTML = this.value.getUTCFullYear(); 6826 6827 if (!!this.params.bTime) 6828 {
6829 var h = this.value.getUTCHours(); 6830 if (this.bAmPm) 6831 { 6832 if (h >= 12) 6833 { 6834 this.PARTS.TIME_AMPM.innerHTML = 'PM'; 6835 6836 if (h != 12) 6837 h -= 12; 6838 } 6839 else 6840 { 6841 this.PARTS.TIME_AMPM.innerHTML = 'AM'; 6842 6843 if (h == 0) 6844 h = 12; 6845 } 6846 } 6847 6848 this.PARTS.TIME_INPUT_H.value = BX.util.str_pad_left(h.toString(), 2, "0"); 6849 this.PARTS.TIME_INPUT_M.value = BX.util.str_pad_left(this.value.getUTCMinutes().toString(), 2, "0"); 6850 } 6851 6852 this._set_layer(); 6853 6854 return this; 6855}; 6856 6857BX.JCCalendar.prototype.SaveValue = function() 6858{ 6859 if (this.popup_month) 6860 this.popup_month.close(); 6861 if (this.popup_year) 6862 this.popup_year.close(); 6863 6864 var bSetValue = true; 6865 if (!!this.params.callback) 6866 { 6867 var res = this.params.callback.apply(this, [new Date(this.value.valueOf()+this.value.getTimezoneOffset()*60000)]); 6868 if (res === false) 6869 bSetValue = false; 6870 } 6871 6872 if (bSetValue) 6873 { 6874 var bTime = !!this.params.bTime && BX.hasClass(this.PARTS.TIME, 'bx-calendar-set-time-opened'); 6875 6876 if (this.params.field) 6877 { 6878 var format = BX.message(bTime ? 'FORMAT_DATETIME' : 'FORMAT_DATE'); 6879 6880 if(bTime && !this.params.bUseSecond) 6881 { 6882 format = format.replace(':SS', ''); 6883 } 6884 6885 this.params.field.value = BX.calendar.ValueToStringFormat(this.value, format, true); 6886 BX.fireEvent(this.params.field, 'change'); 6887 } 6888 6889 this.popup.close(); 6890 6891 if (!!this.params.callback_after) 6892 { 6893 this.params.callback_after.apply(this, [new Date(this.value.valueOf()+this.value.getTimezoneOffset()*60000), bTime]); 6894 } 6895 } 6896 6897 return this; 6898}; 6899 6900BX.JCCalendar.prototype.Close = function() 6901{ 6902 if (!!this.popup) 6903 this.popup.close(); 6904 6905 return this; 6906}; 6907 6908BX.JCSpinner = function(params) 6909{ 6910 params = params || {}; 6911 this.params = { 6912 input: params.input || null, 6913 6914 delta: params.delta || 1, 6915 6916 timeout_start: params.timeout_start || 1000, 6917 timeout_cont: params.timeout_cont || 150, 6918 6919 callback_start: params.callback_start || null, 6920 callback_change: params.callback_change || null, 6921 callback_finish: params.callback_finish || null, 6922 6923 bSaveValue: typeof params.bSaveValue == 'undefined' ? !!params.input : !!params.bSaveValue 6924 }; 6925 6926 this.mousedown = false; 6927 this.direction = 1; 6928}; 6929 6930BX.JCSpinner.prototype.Show = function() 6931{ 6932 this.node = BX.create('span', { 6933 events: { 6934 mousedown: BX.delegateEvent( 6935 {attr: 'data-dir'}, 6936 BX.delegate(this.Start, this) 6937 ) 6938 }, 6939 html: '<a href="javascript:void(0)" class="bx-calendar-form-arrow bx-calendar-form-arrow-top" data-dir="1"><i></i></a><a href="javascript:void(0)" class="bx-calendar-form-arrow bx-calendar-form-arrow-bottom" data-dir="-1"><i></i></a>' 6940 }); 6941 return this.node; 6942}; 6943 6944BX.JCSpinner.prototype.Start = function() 6945{ 6946 this.mousedown = true; 6947 this.direction = BX.proxy_context.getAttribute('data-dir') > 0 ? 1 : -1; 6948 BX.bind(document, "mouseup", BX.proxy(this.MouseUp, this)); 6949 this.ChangeValue(true); 6950}; 6951 6952BX.JCSpinner.prototype.ChangeValue = function(bFirst) 6953{ 6954 if(!this.mousedown) 6955 return; 6956 6957 if (this.params.input) 6958 { 6959 var v = parseInt(this.params.input.value, 10) + this.params.delta * this.direction; 6960 6961 if (this.params.bSaveValue) 6962 this.params.input.value = v; 6963 6964 if (!!bFirst && this.params.callback_start) 6965 this.params.callback_start(this.params, v, this.direction); 6966 6967 if (this.params.callback_change) 6968 this.params.callback_change(this.params, v, this.direction); 6969 6970 setTimeout( 6971 BX.proxy(this.ChangeValue, this), 6972 !!bFirst ? this.params.timeout_start : this.params.timeout_cont 6973 ); 6974 } 6975}; 6976 6977BX.JCSpinner.prototype.MouseUp = function() 6978{ 6979 this.mousedown = false; 6980 BX.unbind(document, "mouseup", BX.proxy(this.MouseUp, this)); 6981 6982 if (this.params.callback_finish) 6983 this.params.callback_finish(this.params, this.params.input.value); 6984}; 6985 6986/**************** compatibility hacks ***************************/ 6987 6988window.jsCalendar = { 6989 Show: function(obj, field, fieldFrom, fieldTo, bTime, serverTime, form_name, bHideTimebar) 6990 { 6991 return BX.calendar({ 6992 node: obj, field: field, form: form_name, bTime: !!bTime, currentTime: serverTime, bHideTimebar: !!bHideTimebar 6993 }); 6994 }, 6995 6996 ValueToString: BX.calendar.ValueToString 6997}; 6998 6999 7000/************ clock popup transferred from timeman **************/ 7001 7002BX.CClockSelector = function(params) 7003{ 7004 this.params = params; 7005 7006 this.params.popup_buttons = this.params.popup_buttons || [ 7007 new BX.PopupWindowButton({ 7008 text : BX.message('CAL_BUTTON'), 7009 className : "popup-window-button-create", 7010 events : {click : BX.proxy(this.setValue, this)} 7011 }) 7012 ]; 7013 7014 this.isReady = false;
7015 7016 this.WND = new BX.PopupWindow( 7017 this.params.popup_id || 'clock_selector_popup', 7018 this.params.node, 7019 this.params.popup_config || { 7020 titleBar: BX.message('CAL_TIME'), 7021 offsetLeft: -45, 7022 offsetTop: -135, 7023 autoHide: true, 7024 closeIcon: true, 7025 closeByEsc: true 7026 } 7027 ); 7028 7029 this.SHOW = false; 7030 BX.addCustomEvent(this.WND, "onPopupClose", BX.delegate(this.onPopupClose, this)); 7031 7032 this.obClocks = {}; 7033 this.CLOCK_ID = this.params.clock_id || 'clock_selector'; 7034}; 7035 7036BX.CClockSelector.prototype.Show = function() 7037{ 7038 if (!this.isReady) 7039 { 7040 //BX.timeman.showWait(this.parent.DIV); 7041 7042 BX.addCustomEvent('onClockRegister', BX.proxy(this.onClockRegister, this)); 7043 return BX.ajax.get('/bitrix/tools/clock_selector.php', {start_time: this.params.start_time, clock_id: this.CLOCK_ID, sessid: BX.bitrix_sessid()}, BX.delegate(this.Ready, this)); 7044 } 7045 7046 this.WND.setButtons(this.params.popup_buttons); 7047 this.WND.show(); 7048 7049 this.SHOW = true; 7050 7051 if (window['bxClock_' + this.obClocks[this.CLOCK_ID]]) 7052 { 7053 setTimeout("window['bxClock_" + this.obClocks[this.CLOCK_ID] + "'].CalculateCoordinates()", 40); 7054 } 7055 7056 return true; 7057}; 7058 7059BX.CClockSelector.prototype.onClockRegister = function(obClocks) 7060{ 7061 if (obClocks[this.CLOCK_ID]) 7062 { 7063 this.obClocks[this.CLOCK_ID] = obClocks[this.CLOCK_ID]; 7064 BX.removeCustomEvent('onClockRegister', BX.proxy(this.onClockRegister, this)); 7065 } 7066}; 7067 7068BX.CClockSelector.prototype.Ready = function(data) 7069{ 7070 this.content = this.CreateContent(data); 7071 this.WND.setContent(this.content); 7072 7073 this.isReady = true; 7074 //BX.timeman.closeWait(); 7075 7076 setTimeout(BX.proxy(this.Show, this), 30); 7077}; 7078 7079BX.CClockSelector.prototype.CreateContent = function(data) 7080{ 7081 return BX.create('DIV', { 7082 events: {click: BX.PreventDefault}, 7083 html: 7084 '<div class="bx-tm-popup-clock">' + data + '</div>' 7085 }); 7086}; 7087 7088BX.CClockSelector.prototype.setValue = function(e) 7089{ 7090 if (this.params.callback) 7091 { 7092 var input = BX.findChild(this.content, {tagName: 'INPUT'}, true); 7093 this.params.callback.apply(this.params.node, [input.value]); 7094 } 7095 7096 return BX.PreventDefault(e); 7097}; 7098 7099BX.CClockSelector.prototype.closeWnd = function(e) 7100{ 7101 this.WND.close(); 7102 return (e || window.event) ? BX.PreventDefault(e) : true; 7103}; 7104 7105BX.CClockSelector.prototype.setNode = function(node) 7106{ 7107 this.WND.setBindElement(node); 7108}; 7109 7110BX.CClockSelector.prototype.setTime = function(timestamp) 7111{ 7112 this.params.start_time = timestamp; 7113 if (window['bxClock_' + this.obClocks[this.CLOCK_ID]]) 7114 { 7115 window['bxClock_' + this.obClocks[this.CLOCK_ID]].SetTime(parseInt(timestamp/3600), parseInt((timestamp%3600)/60)); 7116 } 7117}; 7118 7119BX.CClockSelector.prototype.setCallback = function(cb) 7120{ 7121 this.params.callback = cb; 7122}; 7123 7124BX.CClockSelector.prototype.onPopupClose = function() 7125{ 7126 this.SHOW = false;
7127}; 7128 7129})(); 7130 7131 7132/* End */ 7133; 7134; /* Start:"a:4:{s:4:"full";s:40:"/bitrix/js/main/utils.js?161786687629279";s:6:"source";s:24:"/bitrix/js/main/utils.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 7135var phpVars; 7136if(!phpVars) 7137{ 7138 phpVars = { 7139 ADMIN_THEME_ID: '.default', 7140 LANGUAGE_ID: 'en', 7141 FORMAT_DATE: 'DD.MM.YYYY', 7142 FORMAT_DATETIME: 'DD.MM.YYYY HH:MI:SS', 7143 opt_context_ctrl: false, 7144 cookiePrefix: 'BITRIX_SM', 7145 titlePrefix: '', 7146 bitrix_sessid: '', 7147 messHideMenu: '', 7148 messShowMenu: '', 7149 messHideButtons: '', 7150 messShowButtons: '', 7151 messFilterInactive: '', 7152 messFilterActive: '', 7153 messFilterLess: '', 7154 messLoading: 'Loading...', 7155 messMenuLoading: '', 7156 messMenuLoadingTitle: '', 7157 messNoData: '', 7158 messExpandTabs: '', 7159 messCollapseTabs: '', 7160 messPanelFixOn: '', 7161 messPanelFixOff: '', 7162 messPanelCollapse: '', 7163 messPanelExpand: '' 7164 }; 7165} 7166 7167var jsUtils = 7168{ 7169 arEvents: Array(), 7170 7171 addEvent: function(el, evname, func, capture) 7172 { 7173 if(el.attachEvent) // IE 7174 el.attachEvent("on" + evname, func); 7175 else if(el.addEventListener) // Gecko / W3C 7176 el.addEventListener(evname, func, false); 7177 else 7178 el["on" + evname] = func; 7179 this.arEvents[this.arEvents.length] = {'element': el, 'event': evname, 'fn': func}; 7180 }, 7181 7182 removeEvent: function(el, evname, func) 7183 { 7184 if(el.detachEvent) // IE 7185 el.detachEvent("on" + evname, func); 7186 else if(el.removeEventListener) // Gecko / W3C 7187 el.removeEventListener(evname, func, false); 7188 else 7189 el["on" + evname] = null; 7190 }, 7191 7192 removeAllEvents: function(el) 7193 { 7194 var i; 7195 for(i=0; i<this.arEvents.length; i++) 7196 { 7197 if(this.arEvents[i] && (el==false || el==this.arEvents[i].element)) 7198 { 7199 jsUtils.removeEvent(this.arEvents[i].element, this.arEvents[i].event, this.arEvents[i].fn); 7200 this.arEvents[i] = null; 7201 } 7202 } 7203 if(el==false) 7204 this.arEvents.length = 0; 7205 }, 7206 7207 IsDoctype: function() 7208 { 7209 if (document.compatMode) 7210 return (document.compatMode == "CSS1Compat"); 7211 7212 if (document.documentElement && document.documentElement.clientHeight) 7213 return true; 7214 7215 return false; 7216 }, 7217 7218 GetRealPos: function(el) 7219 { 7220 if(window.BX) 7221 return BX.pos(el); 7222 7223 if(!el || !el.offsetParent) 7224 return false; 7225 7226 var res = Array(); 7227 res["left"] = el.offsetLeft; 7228 res["top"] = el.offsetTop; 7229 var objParent = el.offsetParent; 7230 7231 while(objParent && objParent.tagName != "BODY") 7232 { 7233 res["left"] += objParent.offsetLeft; 7234 res["top"] += objParent.offsetTop; 7235 objParent = objParent.offsetParent; 7236 } 7237 res["right"] = res["left"] + el.offsetWidth; 7238 res["bottom"] = res["top"] + el.offsetHeight; 7239 7240 return res; 7241 }, 7242 7243 FindChildObject: function(obj, tag_name, class_name, recursive) 7244 { 7245 if(!obj) 7246 return null; 7247 var tag = tag_name.toUpperCase(); 7248 var cl = (class_name? class_name.toLowerCase() : null); 7249 var n = obj.childNodes.length; 7250 for(var j=0; j<n; j++) 7251 { 7252 var child = obj.childNodes[j]; 7253 if(child.tagName && child.tagName.toUpperCase() == tag) 7254 if(!class_name || child.className.toLowerCase() == cl) 7255 return child; 7256 if(recursive == true) 7257 { 7258 var deepChild; 7259 if((deepChild = jsUtils.FindChildObject(child, tag_name, class_name, true))) 7260 return deepChild; 7261 } 7262 } 7263 return null; 7264 }, 7265 7266 FindParentObject: function(obj, tag_name, class_name) 7267 { 7268 if(!obj) 7269 return null; 7270 var o = obj; 7271 var tag = tag_name.toUpperCase(); 7272 var cl = (class_name? class_name.toLowerCase() : null); 7273 while(o.parentNode) 7274 { 7275 var parent = o.parentNode; 7276 if(parent.tagName && parent.tagName.toUpperCase() == tag) 7277 if(!class_name || parent.className.toLowerCase() == cl) 7278 return parent; 7279 o = parent; 7280 } 7281 return null; 7282 }, 7283 7284 FindNextSibling: function(obj, tag_name) 7285 { 7286 if(!obj) 7287 return null; 7288 var o = obj; 7289 var tag = tag_name.toUpperCase(); 7290 while(o.nextSibling) 7291 { 7292 var sibling = o.nextSibling; 7293 if(sibling.tagName && sibling.tagName.toUpperCase() == tag) 7294 return sibling; 7295 o = sibling; 7296 } 7297 return null; 7298 }, 7299 7300 FindPreviousSibling: function(obj, tag_name) 7301 { 7302 if(!obj) 7303 return null; 7304 var o = obj; 7305 var tag = tag_name.toUpperCase(); 7306 while(o.previousSibling) 7307 { 7308 var sibling = o.previousSibling; 7309 if(sibling.tagName && sibling.tagName.toUpperCase() == tag) 7310 return sibling; 7311 o = sibling; 7312 } 7313 return null; 7314 }, 7315 7316 bOpera : navigator.userAgent.toLowerCase().indexOf('opera') != -1, 7317 bIsIE : document.attachEvent && navigator.userAgent.toLowerCase().indexOf('opera') == -1, 7318 7319 IsIE: function() 7320 { 7321 return this.bIsIE; 7322 }, 7323 7324 IsOpera: function() 7325 { 7326 return this.bOpera; 7327 }, 7328 7329 IsSafari: function() 7330 { 7331 var userAgent = navigator.userAgent.toLowerCase(); 7332 return (/webkit/.test(userAgent)); 7333 }, 7334 7335 IsEditor: function() 7336 { 7337 var userAgent = navigator.userAgent.toLowerCase(); 7338 var version = (userAgent.match( /.+(msie)[\/: ]([\d.]+)/ ) || [])[2]; 7339 var safari = /webkit/.test(userAgent); 7340 7341 if (this.IsOpera() || (document.all && !document.compatMode && version < 6) || safari) 7342 return false;
7343 7344 return true; 7345 }, 7346 7347 ToggleDiv: function(div) 7348 { 7349 var style = document.getElementById(div).style; 7350 if(style.display!="none") 7351 style.display = "none"; 7352 else 7353 style.display = "block"; 7354 return (style.display != "none"); 7355 }, 7356 7357 urlencode: function(s) 7358 { 7359 return escape(s).replace(new RegExp('\\+','g'), '%2B'); 7360 }, 7361 7362 OpenWindow: function(url, width, height) 7363 { 7364 var w = screen.width, h = screen.height; 7365 if(this.IsOpera()) 7366 { 7367 w = document.body.offsetWidth; 7368 h = document.body.offsetHeight; 7369 } 7370 window.open(url, '', 'status=no,scrollbars=yes,resizable=yes,width='+width+',height='+height+',top='+Math.floor((h - height)/2-14)+',left='+Math.floor((w - width)/2-5)); 7371 }, 7372 7373 SetPageTitle: function(s) 7374 { 7375 document.title = phpVars.titlePrefix+s; 7376 var h1 = document.getElementsByTagName("H1"); 7377 if(h1) 7378 h1[0].innerHTML = s; 7379 }, 7380 7381 LoadPageToDiv: function(url, div_id) 7382 { 7383 var div = document.getElementById(div_id); 7384 if(!div) 7385 return; 7386 CHttpRequest.Action = function(result) 7387 { 7388 CloseWaitWindow(); 7389 document.getElementById(div_id).innerHTML = result; 7390 } 7391 ShowWaitWindow(); 7392 CHttpRequest.Send(url); 7393 }, 7394 7395 trim: function(s) 7396 { 7397 if (typeof s == 'string' || typeof s == 'object' && s.constructor == String) 7398 { 7399 var r, re; 7400 7401 re = /^[\s\r\n]+/g; 7402 r = s.replace(re, ""); 7403 re = /[\s\r\n]+$/g; 7404 r = r.replace(re, ""); 7405 return r; 7406 } 7407 else 7408 return s; 7409 }, 7410 7411 Redirect: function(args, url) 7412 { 7413 var e = null, bShift = false; 7414 if(args && args.length > 0) 7415 e = args[0]; 7416 if(!e) 7417 e = window.event; 7418 if(e) 7419 bShift = e.shiftKey; 7420 7421 if(bShift) 7422 window.open(url); 7423 else 7424 { 7425 window.location.href=url; 7426 } 7427 }, 7428 7429 False: function(){return false;}, 7430 7431 AlignToPos: function(pos, w, h) 7432 { 7433 var x = pos["left"], y = pos["bottom"]; 7434 7435 var scroll = jsUtils.GetWindowScrollPos(); 7436 var size = jsUtils.GetWindowInnerSize(); 7437 7438 if((size.innerWidth + scroll.scrollLeft) - (pos["left"] + w) < 0) 7439 { 7440 if(pos["right"] - w >= 0 ) 7441 x = pos["right"] - w; 7442 else 7443 x = scroll.scrollLeft; 7444 } 7445 7446 if((size.innerHeight + scroll.scrollTop) - (pos["bottom"] + h) < 0) 7447 { 7448 if(pos["top"] - h >= 0) 7449 y = pos["top"] - h; 7450 else 7451 y = scroll.scrollTop; 7452 } 7453 7454 return {'left':x, 'top':y}; 7455 }, 7456 7457 // evaluate js string in window scope 7458 EvalGlobal: function(script) 7459 { 7460 try { 7461 if (window.execScript) 7462 window.execScript(script, 'javascript'); 7463 else if (jsUtils.IsSafari()) 7464 window.setTimeout(script, 0); 7465 else 7466 window.eval(script); 7467 } catch (e) {/*alert("Error! jsUtils.EvalGlobal");*/} 7468 }, 7469 7470 GetStyleValue: function(el, styleProp) 7471 { 7472 var res; 7473 if(el.currentStyle) 7474 res = el.currentStyle[styleProp]; 7475 else if(window.getComputedStyle) 7476 res = document.defaultView.getComputedStyle(el, null).getPropertyValue(styleProp); 7477 if(!res) 7478 res = ''; 7479 return res; 7480 }, 7481 7482 GetWindowInnerSize: function(pDoc) 7483 { 7484 var width, height; 7485 if (!pDoc) 7486 pDoc = document; 7487 7488 if (self.innerHeight) // all except Explorer 7489 { 7490 width = self.innerWidth; 7491 height = self.innerHeight; 7492 } 7493 else if (pDoc.documentElement && (pDoc.documentElement.clientHeight || pDoc.documentElement.clientWidth)) // Explorer 6 Strict Mode 7494 { 7495 width = pDoc.documentElement.clientWidth; 7496 height = pDoc.documentElement.clientHeight; 7497 } 7498 else if (pDoc.body) // other Explorers 7499 { 7500 width = pDoc.body.clientWidth; 7501 height = pDoc.body.clientHeight; 7502 } 7503 return {innerWidth : width, innerHeight : height}; 7504 }, 7505 7506 GetWindowScrollPos: function(pDoc) 7507 { 7508 var left, top; 7509 if (!pDoc) 7510 pDoc = document; 7511 7512 if (self.pageYOffset) // all except Explorer 7513 { 7514 left = self.pageXOffset; 7515 top = self.pageYOffset; 7516 } 7517 else if (pDoc.documentElement && (pDoc.documentElement.scrollTop || pDoc.documentElement.scrollLeft)) // Explorer 6 Strict 7518 { 7519 left = document.documentElement.scrollLeft; 7520 top = document.documentElement.scrollTop; 7521 } 7522 else if (pDoc.body) // all other Explorers 7523 { 7524 left = pDoc.body.scrollLeft; 7525 top = pDoc.body.scrollTop; 7526 } 7527 return {scrollLeft : left, scrollTop : top}; 7528 }, 7529 7530 GetWindowScrollSize: function(pDoc) 7531 { 7532 var width, height; 7533 if (!pDoc) 7534 pDoc = document; 7535 7536 if ( (pDoc.compatMode && pDoc.compatMode == "CSS1Compat")) 7537 { 7538 width = pDoc.documentElement.scrollWidth; 7539 height = pDoc.documentElement.scrollHeight; 7540 } 7541 else 7542 { 7543 if (pDoc.body.scrollHeight > pDoc.body.offsetHeight) 7544 height = pDoc.body.scrollHeight; 7545 else 7546 height = pDoc.body.offsetHeight; 7547 7548 if (pDoc.body.scrollWidth > pDoc.body.offsetWidth || 7549 (pDoc.compatMode && pDoc.compatMode == "BackCompat") || 7550 (pDoc.documentElement && !pDoc.documentElement.clientWidth) 7551 ) 7552 width = pDoc.body.scrollWidth; 7553 else 7554 width = pDoc.body.offsetWidth; 7555 } 7556 return {scrollWidth : width, scrollHeight : height}; 7557 }, 7558 7559 GetWindowSize: function() 7560 { 7561 var innerSize = jsUtils.GetWindowInnerSize(); 7562 var scrollPos = jsUtils.GetWindowScrollPos(); 7563 var scrollSize = jsUtils.GetWindowScrollSize(); 7564 7565 return {
7566 innerWidth : innerSize.innerWidth, innerHeight : innerSize.innerHeight, 7567 scrollLeft : scrollPos.scrollLeft, scrollTop : scrollPos.scrollTop, 7568 scrollWidth : scrollSize.scrollWidth, scrollHeight : scrollSize.scrollHeight 7569 }; 7570 }, 7571 7572 7573 arCustomEvents: {}, 7574 7575 addCustomEvent: function(eventName, eventHandler, arParams, handlerContextObject) 7576 { 7577 if (!this.arCustomEvents[eventName]) 7578 this.arCustomEvents[eventName] = []; 7579 7580 if (!arParams) 7581 arParams = []; 7582 if (!handlerContextObject) 7583 handlerContextObject = false; 7584 7585 this.arCustomEvents[eventName].push( 7586 { 7587 handler: eventHandler, 7588 arParams: arParams, 7589 obj: handlerContextObject 7590 } 7591 ); 7592 }, 7593 7594 removeCustomEvent: function(eventName, eventHandler) 7595 { 7596 if (!this.arCustomEvents[eventName]) 7597 return; 7598 7599 var l = this.arCustomEvents[eventName].length; 7600 if (l == 1) 7601 { 7602 delete this.arCustomEvents[eventName]; 7603 return; 7604 } 7605 7606 for (var i = 0; i < l; i++) 7607 { 7608 if (!this.arCustomEvents[eventName][i]) 7609 continue; 7610 if (this.arCustomEvents[eventName][i].handler == eventHandler) 7611 { 7612 delete this.arCustomEvents[eventName][i]; 7613 return; 7614 } 7615 } 7616 }, 7617 7618 onCustomEvent: function(eventName, arEventParams) 7619 { 7620 if (!this.arCustomEvents[eventName]) 7621 return; 7622 7623 if (!arEventParams) 7624 arEventParams = []; 7625 7626 var h; 7627 for (var i = 0, l = this.arCustomEvents[eventName].length; i < l; i++) 7628 { 7629 h = this.arCustomEvents[eventName][i]; 7630 if (!h || !h.handler) 7631 continue; 7632 7633 if (h.obj) 7634 h.handler.call(h.obj, h.arParams, arEventParams); 7635 else 7636 h.handler(h.arParams, arEventParams); 7637 } 7638 }, 7639 7640 loadJSFile: function(arJs, oCallBack, pDoc) 7641 { 7642 if (!pDoc) 7643 pDoc = document; 7644 if (typeof arJs == 'string') 7645 arJs = [arJs]; 7646 var callback = function() 7647 { 7648 if (!oCallBack) 7649 return; 7650 if (typeof oCallBack == 'function') 7651 return oCallBack(); 7652 if (typeof oCallBack != 'object' || !oCallBack.func) 7653 return; 7654 var p = oCallBack.params || {}; 7655 if (oCallBack.obj) 7656 oCallBack.func.apply(oCallBack.obj, p); 7657 else 7658 oCallBack.func(p); 7659 }; 7660 var load_js = function(ind) 7661 { 7662 if (ind >= arJs.length) 7663 return callback(); 7664 var oSript = pDoc.body.appendChild(pDoc.createElement('script')); 7665 oSript.src = arJs[ind]; 7666 var bLoaded = false; 7667 oSript.onload = oSript.onreadystatechange = function() 7668 { 7669 if (!bLoaded && (!oSript.readyState || oSript.readyState == "loaded" || oSript.readyState == "complete")) 7670 { 7671 bLoaded = true; 7672 setTimeout(function (){load_js(++ind);}, 50); 7673 } 7674 }; 7675 }; 7676 load_js(0); 7677 }, 7678 7679 loadCSSFile: function(arCSS, pDoc, pWin) 7680 { 7681 if (typeof arCSS == 'string') 7682 { 7683 var bSingle = true; 7684 arCSS = [arCSS]; 7685 } 7686 var i, l = arCSS.length, pLnk = []; 7687 if (l == 0) 7688 return; 7689 if (!pDoc) 7690 pDoc = document; 7691 if (!pWin) 7692 pWin = window; 7693 if (!pWin.bxhead) 7694 { 7695 var heads = pDoc.getElementsByTagName('HEAD'); 7696 pWin.bxhead = heads[0]; 7697 } 7698 if (!pWin.bxhead) 7699 return; 7700 for (i = 0; i < l; i++) 7701 { 7702 var lnk = document.createElement('LINK'); 7703 lnk.href = arCSS[i]; 7704 lnk.rel = 'stylesheet'; 7705 lnk.type = 'text/css'; 7706 pWin.bxhead.appendChild(lnk); 7707 pLnk.push(lnk); 7708 } 7709 if (bSingle) 7710 return lnk; 7711 return pLnk; 7712 }, 7713 7714 appendBXHint : function(node, html) 7715 { 7716 if (!node || !node.parentNode || !html) 7717 return; 7718 var oBXHint = new BXHint(html); 7719 node.parentNode.insertBefore(oBXHint.oIcon, node); 7720 node.parentNode.removeChild(node); 7721 oBXHint.oIcon.style.marginLeft = "5px"; 7722 }, 7723 7724 PreventDefault : function(e) 7725 { 7726 if(!e) e = window.event; 7727 if(e.stopPropagation) 7728 { 7729 e.preventDefault(); 7730 e.stopPropagation(); 7731 } 7732 else 7733 { 7734 e.cancelBubble = true; 7735 e.returnValue = false; 7736 } 7737 return false; 7738 }, 7739 7740 CreateElement: function(tag, arAttr, arStyles, pDoc) 7741 { 7742 if (!pDoc) 7743 pDoc = document; 7744 var pEl = pDoc.createElement(tag), p; 7745 if(arAttr) 7746 { 7747 for(p in arAttr) 7748 { 7749 if(p == 'className' || p == 'class') 7750 { 7751 pEl.setAttribute('class', arAttr[p]); 7752 if (jsUtils.IsIE()) 7753 pEl.setAttribute('className', arAttr[p]); 7754 continue; 7755 } 7756 7757 if (arAttr[p] != undefined && arAttr[p] != null) 7758 pEl.setAttribute(p, arAttr[p]); 7759 } 7760 } 7761 if(arStyles) 7762 { 7763 for(p in arStyles) 7764 pEl.style[p] = arStyles[p]; 7765 } 7766 return pEl; 7767 }, 7768 7769 in_array: function(needle, haystack) 7770 { 7771 for(var i=0; i<haystack.length; i++) 7772 { 7773 if(haystack[i] == needle) 7774 return true; 7775 } 7776 return false;
7777 }, 7778 7779 htmlspecialchars: function(str) 7780 { 7781 if(!str.replace) 7782 return str; 7783 7784 return str.replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>'); 7785 } 7786} 7787 7788/************************************************/ 7789 7790function JCFloatDiv() 7791{ 7792 var _this = this; 7793 this.floatDiv = null; 7794 this.x = this.y = 0; 7795 7796 this.Create = function(arParams) 7797 { 7798 var div = document.body.appendChild(document.createElement("DIV")); 7799 div.id = arParams.id; 7800 div.style.position = 'absolute'; 7801 div.style.left = '-10000px'; 7802 div.style.top = '-10000px'; 7803 if(arParams.className) 7804 div.className = arParams.className; 7805 if(arParams.zIndex) 7806 div.style.zIndex = arParams.zIndex; 7807 if(arParams.width) 7808 div.style.width = arParams.width+'px'; 7809 if(arParams.height) 7810 div.style.height = arParams.height+'px'; 7811 return div; 7812 } 7813 7814 this.Show = function(div, left, top, dxShadow, restrictDrag) 7815 { 7816 var component = BX.ZIndexManager.getComponent(div); 7817 if (!component) 7818 { 7819 BX.ZIndexManager.register(div); 7820 } 7821 7822 BX.ZIndexManager.bringToFront(div); 7823 7824 if (left < 0) 7825 left = 0; 7826 7827 if (top < 0) 7828 top = 0; 7829 7830 div.style.left = parseInt(left) + "px"; 7831 div.style.top = parseInt(top) + "px"; 7832 7833 /*Restrict drag*/ 7834 div.restrictDrag = restrictDrag || false; 7835 7836 /*shadow*/ 7837 if(isNaN(dxShadow)) 7838 dxShadow = 5; 7839 7840 div.dxShadow = dxShadow; 7841 } 7842 7843 this.Close = function(div) 7844 { 7845 if(!div) 7846 return; 7847 var sh = document.getElementById(div.id+"_shadow"); 7848 if(sh) 7849 sh.style.visibility = 'hidden'; 7850 7851 var frame = document.getElementById(div.id+"_frame"); 7852 if(frame) 7853 frame.style.visibility = 'hidden'; 7854 } 7855 7856 this.Move = function(div, x, y) 7857 { 7858 if(!div) 7859 return; 7860 7861 var dxShadow = div.dxShadow; 7862 var left = parseInt(div.style.left)+x; 7863 var top = parseInt(div.style.top)+y; 7864 7865 if (div.restrictDrag) 7866 { 7867 //Left side 7868 if (left < 0) 7869 left = 0; 7870 7871 //Right side 7872 if ( (document.compatMode && document.compatMode == "CSS1Compat")) 7873 windowWidth = document.documentElement.scrollWidth; 7874 else 7875 { 7876 if (document.body.scrollWidth > document.body.offsetWidth || 7877 (document.compatMode && document.compatMode == "BackCompat") || 7878 (document.documentElement && !document.documentElement.clientWidth) 7879 ) 7880 windowWidth = document.body.scrollWidth; 7881 else 7882 windowWidth = document.body.offsetWidth; 7883 } 7884 7885 var floatWidth = div.offsetWidth; 7886 if (left > (windowWidth - floatWidth - dxShadow)) 7887 left = windowWidth - floatWidth - dxShadow; 7888 7889 //Top side 7890 if (top < 0) 7891 top = 0; 7892 } 7893 7894 div.style.left = left+'px'; 7895 div.style.top = top+'px'; 7896 7897 this.AdjustShadow(div); 7898 } 7899 7900 this.HideShadow = function(div) 7901 { 7902 var sh = document.getElementById(div.id + "_shadow"); 7903 sh.style.visibility = 'hidden'; 7904 } 7905 7906 this.UnhideShadow = function(div) 7907 { 7908 var sh = document.getElementById(div.id + "_shadow"); 7909 sh.style.visibility = 'visible'; 7910 } 7911 7912 this.AdjustShadow = function(div) 7913 { 7914 var sh = document.getElementById(div.id + "_shadow"); 7915 if(sh && sh.style.visibility != 'hidden') 7916 { 7917 var dxShadow = div.dxShadow; 7918 7919 sh.style.width = div.offsetWidth+'px'; 7920 sh.style.height = div.offsetHeight+'px'; 7921 sh.style.left = parseInt(div.style.left)+dxShadow+'px'; 7922 sh.style.top = parseInt(div.style.top)+dxShadow+'px'; 7923 } 7924 7925 var frame = document.getElementById(div.id+"_frame"); 7926 if(frame) 7927 { 7928 frame.style.width = div.offsetWidth + "px"; 7929 frame.style.height = div.offsetHeight + "px"; 7930 frame.style.left = div.style.left; 7931 frame.style.top = div.style.top; 7932 } 7933 } 7934 7935 this.StartDrag = function(e, div) 7936 { 7937 if(!e) 7938 e = window.event; 7939 this.x = e.clientX + document.body.scrollLeft; 7940 this.y = e.clientY + document.body.scrollTop; 7941 this.floatDiv = div; 7942 7943 jsUtils.addEvent(document, "mousemove", this.MoveDrag); 7944 document.onmouseup = this.StopDrag; 7945 if(document.body.setCapture) 7946 document.body.setCapture(); 7947 7948 document.onmousedown = jsUtils.False; 7949 var b = document.body; 7950 b.ondrag = jsUtils.False; 7951 b.onselectstart = jsUtils.False; 7952 b.style.MozUserSelect = _this.floatDiv.style.MozUserSelect = 'none'; 7953 b.style.cursor = 'move'; 7954 } 7955 7956 this.StopDrag = function(e) 7957 { 7958 if(document.body.releaseCapture) 7959 document.body.releaseCapture(); 7960 7961 jsUtils.removeEvent(document, "mousemove", _this.MoveDrag); 7962 document.onmouseup = null; 7963 7964 this.floatDiv = null; 7965 7966 document.onmousedown = null; 7967 var b = document.body; 7968 b.ondrag = null; 7969 b.onselectstart = null; 7970 b.style.MozUserSelect = _this.floatDiv.style.MozUserSelect = ''; 7971 b.style.cursor = ''; 7972 } 7973 7974 this.MoveDrag = function(e) 7975 { 7976 var x = e.clientX + document.body.scrollLeft; 7977 var y = e.clientY + document.body.scrollTop; 7978 7979 if(_this.x == x && _this.y == y) 7980 return; 7981 7982 _this.Move(_this.floatDiv, (x - _this.x), (y - _this.y)); 7983 _this.x = x; 7984 _this.y = y; 7985 } 7986} 7987var jsFloatDiv = new JCFloatDiv(); 7988 7989/************************************************/ 7990 7991var BXHint = function(innerHTML, element, addParams) 7992{ 7993 this.oDivOver = false;
7994 this.timeOutID = null; 7995 this.oIcon = null; 7996 this.freeze = false; 7997 this.x = 0; 7998 this.y = 0; 7999 this.time = 700; 8000 8001 if (!innerHTML) 8002 innerHTML = ""; 8003 this.Create(innerHTML, element, addParams); 8004} 8005 8006BXHint.prototype.Create = function(innerHTML, element, addParams) 8007{ 8008 var 8009 _this = this, 8010 width = 0, 8011 height = 0, 8012 className = null, 8013 type = "icon"; 8014 this.bWidth = true; 8015 8016 if (addParams) 8017 { 8018 if (addParams.width === false) 8019 this.bWidth = false; 8020 else if (addParams.width) 8021 width = addParams.width; 8022 8023 if (addParams.height) 8024 height = addParams.height; 8025 8026 if (addParams.className) 8027 className = addParams.className; 8028 8029 if (addParams.type && (addParams.type == "link" || addParams.type == "icon")) 8030 type = addParams.type; 8031 if (addParams.time > 0) 8032 this.time = addParams.time; 8033 } 8034 8035 if (element) 8036 type = "element"; 8037 8038 if (type == "icon") 8039 { 8040 var element = document.createElement("IMG"); 8041 element.src = (addParams && addParams.iconSrc) ? addParams.iconSrc : "/bitrix/themes/"+phpVars.ADMIN_THEME_ID+"/public/popup/hint.gif"; 8042 element.ondrag = jsUtils.False; 8043 } 8044 else if (type == "link") 8045 { 8046 var element = document.createElement("A"); 8047 element.href = ""; 8048 element.onclick = function(e){return false;} 8049 element.innerHTML = "[?]"; 8050 } 8051 8052 this.element = element; 8053 if (type == "element") 8054 { 8055 if(addParams && addParams.show_on_click) 8056 { 8057 jsUtils.addEvent( 8058 element, 8059 "click", 8060 function (event) 8061 { 8062 if (!event) 8063 event = window.event; 8064 _this.GetMouseXY(event); 8065 _this.timeOutID = setTimeout(function () {_this.Show(innerHTML,width,height,className) }, 10); 8066 } 8067 ); 8068 } 8069 else 8070 { 8071 jsUtils.addEvent( 8072 element, 8073 "mouseover", 8074 function (event) 8075 { 8076 if (!event) 8077 event = window.event; 8078 _this.GetMouseXY(event); 8079 _this.timeOutID = setTimeout(function () {_this.Show(innerHTML,width,height,className) }, 750); 8080 } 8081 ); 8082 } 8083 8084 jsUtils.addEvent( 8085 element, 8086 "mouseout", 8087 function(event) 8088 { 8089 if (_this.timeOutID) 8090 clearTimeout(_this.timeOutID); 8091 _this.SmartHide(_this); 8092 } 8093 ); 8094 } 8095 else 8096 { 8097 this.oIcon = element; 8098 element.onmouseover = function(event) {if (!event) event = window.event; _this.GetMouseXY(event); _this.Show(innerHTML,width,height,className)}; 8099 element.onmouseout = function() {_this.SmartHide(_this);}; 8100 } 8101} 8102 8103BXHint.prototype.IsFrozen = function() 8104{ 8105 return this.freeze; 8106} 8107 8108BXHint.prototype.Freeze = function() 8109{ 8110 this.freeze = true; 8111 this.Hide(); 8112} 8113 8114BXHint.prototype.UnFreeze = function() 8115{ 8116 this.freeze = false; 8117} 8118 8119BXHint.prototype.GetMouseXY = function(event) 8120{ 8121 if (event.pageX || event.pageY) 8122 { 8123 this.x = event.pageX; 8124 this.y = event.pageY; 8125 } 8126 else if (event.clientX || event.clientY) 8127 { 8128 this.x = event.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft; 8129 this.y = event.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop; 8130 } 8131} 8132 8133BXHint.prototype.Show = function(innerHTML, width, height, className) 8134{ 8135 //Delete previous hint 8136 var old = document.getElementById("__BXHint_div"); 8137 if (old) 8138 this.Hide(); 8139 8140 if (this.freeze) 8141 return; 8142 8143 var _this = this; 8144 var oDiv = document.body.appendChild(document.createElement("DIV")); 8145 oDiv.onmouseover = function(){_this.oDivOver = true}; 8146 oDiv.onmouseout = function(){_this.oDivOver = false; _this.SmartHide(_this);} 8147 oDiv.id = "__BXHint_div"; 8148 oDiv.className = (className) ? className : "bxhint"; 8149 oDiv.style.position = 'absolute'; 8150 if (width && this.bWidth) 8151 oDiv.style.width = width + "px"; 8152 8153 if (height) 8154 oDiv.style.height = height + "px"; 8155 oDiv.innerHTML = innerHTML; 8156 8157 var w = oDiv.offsetWidth; 8158 var h = oDiv.offsetHeight; 8159 if (this.bWidth) 8160 { 8161 if (!width && w>200) 8162 w = Math.round(Math.sqrt(1.618*w*h)); 8163 oDiv.style.width = w + "px"; 8164 h = oDiv.offsetHeight; 8165 } 8166 8167 var pos = {left : this.x + 10, right : this.x + w, top : this.y, bottom : this.y + h}; 8168 8169 pos = this.AlignToPos(pos, w, h); 8170 8171 jsFloatDiv.Show(oDiv, pos.left, pos.top,3); 8172 8173// oDiv.ondrag = jsUtils.False; 8174// oDiv.onselectstart = jsUtils.False; 8175// oDiv.style.MozUserSelect = 'none'; 8176 oDiv = null; 8177} 8178 8179BXHint.prototype.AlignToPos = function(pos, w, h) 8180{ 8181 var body = document.body; 8182 if((body.clientWidth + body.scrollLeft) < (pos.left + w)) 8183 pos.left = (pos.left - w >= 0) ? (pos.left - w) : body.scrollLeft; 8184 8185 if((body.clientHeight + body.scrollTop) - (pos["bottom"]) < 0) 8186 pos.top = (pos.top - h >= 0) ? (pos.top - h) : body.scrollTop; 8187 8188 return pos; 8189} 8190 8191BXHint.prototype.Hide = function() 8192{ 8193 var oDiv = document.getElementById("__BXHint_div"); 8194 8195 if (!oDiv) 8196 return; 8197 8198 BX.ZIndexManager.unregister(oDiv); 8199 8200 jsFloatDiv.Close(oDiv); 8201 oDiv.parentNode.removeChild(oDiv); 8202 oDiv = null; 8203} 8204 8205BXHint.prototype.SmartHide = function(_this) 8206{ 8207 setTimeout(function () 8208 { 8209 if (!_this.oDivOver) 8210 _this.Hide(); 8211 }, 100 8212 ); 8213} 8214 8215/************************************************/ 8216 8217function WaitOnKeyPress(e) 8218{ 8219 if(!e) e = window.event 8220 if(!e) return; 8221 if(e.keyCode == 27) 8222 CloseWaitWindow(); 8223} 8224 8225function ShowWaitWindow() 8226{ 8227 CloseWaitWindow(); 8228 8229 var obWndSize = jsUtils.GetWindowSize(); 8230 8231 var div = document.body.appendChild(document.createElement("DIV")); 8232 div.id = "wait_window_div"; 8233 div.innerHTML = phpVars.messLoading; 8234 div.className = "waitwindow"; 8235 //div.style.left = obWndSize.scrollLeft + (obWndSize.innerWidth - div.offsetWidth) - (jsUtils.IsIE() ? 5 : 20) + "px"; 8236 div.style.right = (5 - obWndSize.scrollLeft) + 'px'; 8237 div.style.top = obWndSize.scrollTop + 5 + "px"; 8238
8239 if(jsUtils.IsIE()) 8240 { 8241 var frame = document.createElement("IFRAME"); 8242 frame.src = "javascript:''"; 8243 frame.id = "wait_window_frame"; 8244 frame.className = "waitwindow"; 8245 frame.style.width = div.offsetWidth + "px"; 8246 frame.style.height = div.offsetHeight + "px"; 8247 frame.style.right = div.style.right; 8248 frame.style.top = div.style.top; 8249 document.body.appendChild(frame); 8250 } 8251 jsUtils.addEvent(document, "keypress", WaitOnKeyPress); 8252} 8253 8254function CloseWaitWindow() 8255{ 8256 jsUtils.removeEvent(document, "keypress", WaitOnKeyPress); 8257 8258 var frame = document.getElementById("wait_window_frame"); 8259 if(frame) 8260 frame.parentNode.removeChild(frame); 8261 8262 var div = document.getElementById("wait_window_div"); 8263 if(div) 8264 div.parentNode.removeChild(div); 8265} 8266 8267/************************************************/ 8268 8269var jsSelectUtils = 8270{ 8271 addNewOption: function(select_id, opt_value, opt_name, do_sort, check_unique) 8272 { 8273 var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id); 8274 if(oSelect) 8275 { 8276 var n = oSelect.length; 8277 if(check_unique !== false) 8278 { 8279 for(var i=0;i<n;i++) 8280 if(oSelect[i].value==opt_value) 8281 return; 8282 } 8283 var newoption = new Option(opt_name, opt_value, false, false); 8284 oSelect.options[n]=newoption; 8285 } 8286 if(do_sort === true) 8287 this.sortSelect(select_id); 8288 }, 8289 8290 deleteOption: function(select_id, opt_value) 8291 { 8292 var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id); 8293 if(oSelect) 8294 { 8295 for(var i=0;i<oSelect.length;i++) 8296 if(oSelect[i].value==opt_value) 8297 { 8298 oSelect.remove(i); 8299 break; 8300 } 8301 } 8302 }, 8303 8304 deleteSelectedOptions: function(select_id) 8305 { 8306 var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id); 8307 if(oSelect) 8308 { 8309 var i=0; 8310 while(i<oSelect.length) 8311 if(oSelect[i].selected) 8312 { 8313 oSelect[i].selected=false; 8314 oSelect.remove(i); 8315 } 8316 else 8317 i++; 8318 } 8319 }, 8320 8321 deleteAllOptions: function(oSelect) 8322 { 8323 if(oSelect) 8324 { 8325 for(var i=oSelect.length-1; i>=0; i--) 8326 oSelect.remove(i); 8327 } 8328 }, 8329 8330 optionCompare: function(record1, record2) 8331 { 8332 var value1 = record1.optText.toLowerCase(); 8333 var value2 = record2.optText.toLowerCase(); 8334 if (value1 > value2) return(1); 8335 if (value1 < value2) return(-1); 8336 return(0); 8337 }, 8338 8339 sortSelect: function(select_id) 8340 { 8341 var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id); 8342 if(oSelect) 8343 { 8344 var myOptions = []; 8345 var n = oSelect.options.length; 8346 for (var i=0;i<n;i++) 8347 { 8348 myOptions[i] = { 8349 optText:oSelect[i].text, 8350 optValue:oSelect[i].value 8351 }; 8352 } 8353 myOptions.sort(this.optionCompare); 8354 oSelect.length=0; 8355 n = myOptions.length; 8356 for(var i=0;i<n;i++) 8357 { 8358 var newoption = new Option(myOptions[i].optText, myOptions[i].optValue, false, false); 8359 oSelect[i]=newoption; 8360 } 8361 } 8362 }, 8363 8364 selectAllOptions: function(select_id) 8365 { 8366 var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id); 8367 if(oSelect) 8368 { 8369 var n = oSelect.length; 8370 for(var i=0;i<n;i++) 8371 oSelect[i].selected=true; 8372 } 8373 }, 8374 8375 selectOption: function(select_id, opt_value) 8376 { 8377 var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id); 8378 if(oSelect) 8379 { 8380 var n = oSelect.length; 8381 for(var i=0;i<n;i++) 8382 oSelect[i].selected = (oSelect[i].value == opt_value); 8383 } 8384 }, 8385 8386 addSelectedOptions: function(oSelect, to_select_id, check_unique, do_sort) 8387 { 8388 if(!oSelect) 8389 return; 8390 var n = oSelect.length; 8391 for(var i=0; i<n; i++) 8392 if(oSelect[i].selected) 8393 this.addNewOption(to_select_id, oSelect[i].value, oSelect[i].text, do_sort, check_unique); 8394 }, 8395 8396 moveOptionsUp: function(oSelect) 8397 { 8398 if(!oSelect) 8399 return; 8400 var n = oSelect.length; 8401 for(var i=0; i<n; i++) 8402 { 8403 if(oSelect[i].selected && i>0 && oSelect[i-1].selected == false) 8404 { 8405 var option1 = new Option(oSelect[i].text, oSelect[i].value); 8406 var option2 = new Option(oSelect[i-1].text, oSelect[i-1].value); 8407 oSelect[i] = option2; 8408 oSelect[i].selected = false;
8409 oSelect[i-1] = option1; 8410 oSelect[i-1].selected = true; 8411 } 8412 } 8413 }, 8414 8415 moveOptionsDown: function(oSelect) 8416 { 8417 if(!oSelect) 8418 return; 8419 var n = oSelect.length; 8420 for(var i=n-1; i>=0; i--) 8421 { 8422 if(oSelect[i].selected && i<n-1 && oSelect[i+1].selected == false) 8423 { 8424 var option1 = new Option(oSelect[i].text, oSelect[i].value); 8425 var option2 = new Option(oSelect[i+1].text, oSelect[i+1].value); 8426 oSelect[i] = option2; 8427 oSelect[i].selected = false; 8428 oSelect[i+1] = option1; 8429 oSelect[i+1].selected = true; 8430 } 8431 } 8432 } 8433 8434} 8435 8436/************************************************/ 8437 8438/* End */ 8439; 8440; /* Start:"a:4:{s:4:"full";s:37:"/bitrix/js/main/dd.js?170892849414809";s:6:"source";s:21:"/bitrix/js/main/dd.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 8441;(function(){ 8442 8443if (window.jsDD) 8444 return; 8445 8446jsDD = { 8447 arObjects: [], 8448 arDestinations: [], 8449 arDestinationsPriority: [], 8450 8451 arContainers: [], 8452 arContainersPos: [], 8453 8454 current_dest_index: false, 8455 current_node: null, 8456 8457 wndSize: null, 8458 8459 bStarted: false, 8460 bDisable: false, 8461 bDisableDestRefresh: false, 8462 8463 bEscPressed: false, 8464 8465 bScrollWindow: false, 8466 scrollViewTimer: null, 8467 scrollViewConfig: { 8468 checkerTimeout: 30, 8469 scrollZone: 25, 8470 scrollBy: 25, 8471 scrollContainer: null, 8472 bScrollH: true, 8473 bScrollV: true, 8474 pos: null 8475 }, 8476 8477 setScrollWindow: function(val) 8478 { 8479 jsDD.bScrollWindow = !!val; 8480 if (BX.type.isDomNode(val)) 8481 { 8482 jsDD.scrollViewConfig.scrollContainer = val; 8483 jsDD.scrollViewConfig.pos = BX.pos(val); 8484 8485 var s = BX.style(val, 'overflow') || 'visible', 8486 s1 = BX.style(val, 'overflow-x') || 'visible', 8487 s2 = BX.style(val, 'overflow-y') || 'visible'; 8488 8489 jsDD.scrollViewConfig.bScrollH = s != 'visible' || s1 != 'visible'; 8490 jsDD.scrollViewConfig.bScrollV = s != 'visible' || s2 != 'visible'; 8491 } 8492 }, 8493 8494 Reset: function() 8495 { 8496 jsDD.arObjects = []; 8497 jsDD.arDestinations = []; 8498 jsDD.arDestinationsPriority = []; 8499 jsDD.bStarted = false; 8500 jsDD.current_node = null; 8501 jsDD.current_dest_index = false; 8502 jsDD.bDisableDestRefresh = false; 8503 jsDD.bDisable = false; 8504 jsDD.x = null; 8505 jsDD.y = null; 8506 jsDD.start_x = null; 8507 jsDD.start_y = null; 8508 jsDD.wndSize = null; 8509 8510 jsDD.bEscPressed = false; 8511 8512 clearInterval(jsDD.scrollViewTimer) 8513 jsDD.bScrollWindow = false; 8514 jsDD.scrollViewTimer = null; 8515 jsDD.scrollViewConfig.scrollContainer = null; 8516 }, 8517 8518 registerObject: function (obNode) 8519 { 8520 BX.bind(obNode, 'mousedown', jsDD.startDrag); 8521 BX.Event.bind(obNode, 'touchstart', jsDD.startDrag, { passive: true }); 8522 8523 obNode.__bxddid = jsDD.arObjects.length; 8524 8525 jsDD.arObjects[obNode.__bxddid] = obNode; 8526 }, 8527 unregisterObject: function(obNode) 8528 { 8529 if(typeof(obNode["__bxddid"]) === "undefined") 8530 { 8531 return; 8532 } 8533 8534 delete jsDD.arObjects[obNode.__bxddid]; 8535 delete obNode.__bxddid; 8536 BX.unbind(obNode, 'mousedown', jsDD.startDrag); 8537 BX.unbind(obNode, 'touchstart', jsDD.startDrag); 8538 }, 8539 registerDest: function (obDest, priority) 8540 { 8541 if (!priority) 8542 priority = 100; 8543 8544 obDest.__bxddeid = jsDD.arDestinations.length; 8545 obDest.__bxddpriority = priority; 8546 8547 jsDD.arDestinations[obDest.__bxddeid] = obDest; 8548 if (!jsDD.arDestinationsPriority[priority]) 8549 jsDD.arDestinationsPriority[priority] = [obDest.__bxddeid] 8550 else 8551 jsDD.arDestinationsPriority[priority].push(obDest.__bxddeid); 8552 8553 jsDD.refreshDestArea(obDest.__bxddeid); 8554 }, 8555 unregisterDest: function(obDest) 8556 { 8557 if(typeof(obDest["__bxddeid"]) === "undefined") 8558 { 8559 return; 8560 } 8561 8562 delete jsDD.arDestinations[obDest.__bxddeid]; 8563 delete obDest.__bxddeid; 8564 delete obDest.__bxddpriority; 8565 8566 jsDD.refreshDestArea(); 8567 }, 8568 disableDest: function(obDest) 8569 { 8570 if (typeof(obDest.__bxddeid) !== "undefined") 8571 { 8572 obDest.__bxdddisabled = true; 8573 } 8574 }, 8575 8576 enableDest: function(obDest) 8577 { 8578 if (typeof(obDest.__bxddeid) !== "undefined") 8579 { 8580 obDest.__bxdddisabled = false; 8581 } 8582 }, 8583 8584 registerContainer: function (obCont) 8585 { 8586 jsDD.arContainers[jsDD.arContainers.length] = obCont; 8587 }, 8588 8589 getContainersScrollPos: function(x, y) 8590 { 8591 var pos = {'left':0, 'top':0}; 8592 for(var i=0, n=jsDD.arContainers.length; i<n; i++) 8593 { 8594 if(jsDD.arContainers[i] && x >= jsDD.arContainersPos[i]["left"] && x <= jsDD.arContainersPos[i]["right"] && y >= jsDD.arContainersPos[i]["top"] && y <= jsDD.arContainersPos[i]["bottom"]) 8595 { 8596 pos.left = jsDD.arContainers[i].scrollLeft; 8597 pos.top = jsDD.arContainers[i].scrollTop; 8598 } 8599 } 8600 return pos; 8601 }, 8602 8603 setContainersPos: function() 8604 { 8605 for(var i=0, n=jsDD.arContainers.length; i<n; i++) 8606 { 8607 if(jsDD.arContainers[i]) 8608 jsDD.arContainersPos[i] = BX.pos(jsDD.arContainers[i]); 8609 } 8610 }, 8611 8612 refreshDestArea: function(id) 8613 { 8614 if (id && typeof (id) == "object" && typeof (id.__bxddeid) != 'undefined') 8615 { 8616 id = id.__bxddeid; 8617 } 8618 8619 if (typeof id == 'undefined') 8620 { 8621 for (var i = 0, cnt = jsDD.arDestinations.length; i < cnt; i++) 8622 { 8623 jsDD.refreshDestArea(i); 8624 } 8625 } 8626 else 8627 { 8628 if (null == jsDD.arDestinations[id]) 8629 return; 8630 8631 var arPos = BX.pos(jsDD.arDestinations[id]);
8632 jsDD.arDestinations[id].__bxpos = [arPos.left, arPos.top, arPos.right, arPos.bottom]; 8633 } 8634 }, 8635 8636 _checkEsc: function(e) 8637 { 8638 e = e||window.event; 8639 if (jsDD.bStarted && e.keyCode == 27) 8640 { 8641 jsDD.stopCurrentDrag(); 8642 } 8643 }, 8644 8645 stopCurrentDrag: function() 8646 { 8647 if (jsDD.bStarted) 8648 { 8649 jsDD.bEscPressed = true; 8650 jsDD.stopDrag(); 8651 } 8652 }, 8653 8654 /* scroll checkers */ 8655 8656 _onscroll: function() { 8657 jsDD.wndSize = BX.GetWindowSize(); 8658 }, 8659 8660 _checkScroll: function() 8661 { 8662 if (jsDD.bScrollWindow) 8663 { 8664 var pseudo_e = { 8665 clientX: jsDD.x - jsDD.wndSize.scrollLeft, 8666 clientY: jsDD.y - jsDD.wndSize.scrollTop 8667 }, 8668 bChange = false, 8669 d = jsDD.scrollViewConfig.scrollZone; 8670 8671 // check whether window scroll needed 8672 if (pseudo_e.clientY < d && jsDD.wndSize.scrollTop > 0) 8673 { 8674 window.scrollBy(0, -jsDD.scrollViewConfig.scrollBy); 8675 bChange = true; 8676 } 8677 8678 if (pseudo_e.clientY > jsDD.wndSize.innerHeight - d && jsDD.wndSize.scrollTop < jsDD.wndSize.scrollHeight - jsDD.wndSize.innerHeight) 8679 { 8680 window.scrollBy(0, jsDD.scrollViewConfig.scrollBy); 8681 bChange = true; 8682 } 8683 8684 if (pseudo_e.clientX < d && jsDD.wndSize.scrollLeft > 0) 8685 { 8686 window.scrollBy(-jsDD.scrollViewConfig.scrollBy, 0); 8687 bChange = true; 8688 } 8689 8690 if (pseudo_e.clientX > jsDD.wndSize.innerWidth - d && jsDD.wndSize.scrollLeft < jsDD.wndSize.scrollWidth - jsDD.wndSize.innerWidth) 8691 { 8692 window.scrollBy(jsDD.scrollViewConfig.scrollBy, 0); 8693 bChange = true; 8694 } 8695 8696 // check whether container scroll needed 8697 8698 if (jsDD.scrollViewConfig.scrollContainer) 8699 { 8700 var c = jsDD.scrollViewConfig.scrollContainer; 8701 8702 if (jsDD.scrollViewConfig.bScrollH) 8703 { 8704 if (pseudo_e.clientX + jsDD.wndSize.scrollLeft < jsDD.scrollViewConfig.pos.left + d && c.scrollLeft > 0) 8705 { 8706 c.scrollLeft -= jsDD.scrollViewConfig.scrollBy; 8707 bChange = true; 8708 } 8709 8710 if (pseudo_e.clientX + jsDD.wndSize.scrollLeft > jsDD.scrollViewConfig.pos.right - d 8711 && c.scrollLeft < c.scrollWidth - c.offsetWidth) 8712 { 8713 c.scrollLeft += jsDD.scrollViewConfig.scrollBy; 8714 bChange = true; 8715 } 8716 } 8717 8718 if (jsDD.scrollViewConfig.bScrollV) 8719 { 8720 if (pseudo_e.clientY + jsDD.wndSize.scrollTop < jsDD.scrollViewConfig.pos.top + d && c.scrollTop > 0) 8721 { 8722 c.scrollTop -= jsDD.scrollViewConfig.scrollBy; 8723 bChange = true; 8724 } 8725 8726 if (pseudo_e.clientY + jsDD.wndSize.scrollTop > jsDD.scrollViewConfig.pos.bottom - d 8727 && c.scrollTop < c.scrollHeight - c.offsetHeight) 8728 { 8729 c.scrollTop += jsDD.scrollViewConfig.scrollBy; 8730 bChange = true; 8731 } 8732 } 8733 } 8734 8735 if (bChange) 8736 { 8737 jsDD._onscroll(); 8738 jsDD.drag(pseudo_e); 8739 } 8740 } 8741 }, 8742 8743 /* DD process */ 8744 8745 startDrag: function(e) 8746 { 8747 if (jsDD.bDisable) 8748 return true; 8749 8750 e = e || window.event; 8751 8752 if (!(BX.getEventButton(e)&BX.MSLEFT)) 8753 return true; 8754 8755 jsDD.current_node = null; 8756 if (e.currentTarget) 8757 { 8758 jsDD.current_node = e.currentTarget; 8759 if (null == jsDD.current_node || null == jsDD.current_node.__bxddid) 8760 { 8761 jsDD.current_node = null; 8762 return; 8763 } 8764 } 8765 else 8766 { 8767 jsDD.current_node = e.srcElement; 8768 if (null == jsDD.current_node) 8769 return; 8770 8771 while (null == jsDD.current_node.__bxddid) 8772 { 8773 jsDD.current_node = jsDD.current_node.parentNode; 8774 if (jsDD.current_node.tagName == 'BODY') 8775 return; 8776 } 8777 } 8778 8779 jsDD.bStarted = false; 8780 jsDD.bPreStarted = true; 8781 8782 jsDD.wndSize = BX.GetWindowSize(); 8783 8784 jsDD.start_x = e.clientX + jsDD.wndSize.scrollLeft; 8785 jsDD.start_y = e.clientY + jsDD.wndSize.scrollTop; 8786 8787 BX.bind(document, "mouseup", jsDD.stopDrag); 8788 BX.bind(document, "touchend", jsDD.stopDrag); 8789 BX.bind(document, "mousemove", jsDD.drag); 8790 BX.bind(document, "touchmove", jsDD.drag); 8791 BX.bind(window, 'scroll', jsDD._onscroll); 8792 8793 if(document.body.setCapture) 8794 document.body.setCapture(); 8795 8796 if (!jsDD.bDisableDestRefresh) 8797 jsDD.refreshDestArea(); 8798 8799 jsDD.setContainersPos(); 8800 8801 if(e.type !== "touchstart") 8802 { 8803 jsDD.denySelection(); 8804 return BX.PreventDefault(e); 8805 } 8806 else 8807 { 8808 return true; 8809 } 8810 }, 8811 8812 start: function() 8813 { 8814 if (jsDD.bDisable) 8815 return true; 8816 8817 document.body.style.cursor = 'move'; 8818 8819 if (jsDD.current_node.onbxdragstart) 8820 jsDD.current_node.onbxdragstart(); 8821 8822 for (var i = 0, cnt = jsDD.arDestinations.length; i < cnt; i++) 8823 { 8824 if (jsDD.arDestinations[i] && jsDD.arDestinations[i].onbxdestdragstart) 8825 jsDD.arDestinations[i].onbxdestdragstart(jsDD.current_node); 8826 } 8827 8828 jsDD.bStarted = true; 8829 jsDD.bPreStarted = false;
8830 8831 if (jsDD.bScrollWindow) 8832 { 8833 if (jsDD.scrollViewTimer) 8834 clearInterval(jsDD.scrollViewTimer); 8835 8836 jsDD.scrollViewTimer = setInterval(jsDD._checkScroll, jsDD.scrollViewConfig.checkerTimeout); 8837 } 8838 8839 BX.bind(document, 'keypress', this._checkEsc); 8840 }, 8841 8842 drag: function(e) 8843 { 8844 if (jsDD.bDisable) 8845 return true; 8846 8847 e = e || window.event; 8848 8849 jsDD.x = e.clientX + jsDD.wndSize.scrollLeft; 8850 jsDD.y = e.clientY + jsDD.wndSize.scrollTop; 8851 8852 if (!jsDD.bStarted) 8853 { 8854 var delta = 5; 8855 if(jsDD.x >= jsDD.start_x-delta && jsDD.x <= jsDD.start_x+delta && jsDD.y >= jsDD.start_y-delta && jsDD.y <= jsDD.start_y+delta) 8856 return true; 8857 8858 jsDD.start(); 8859 } 8860 8861 if (jsDD.current_node.onbxdrag) 8862 { 8863 jsDD.current_node.onbxdrag(jsDD.x, jsDD.y, e); 8864 } 8865 8866 var containersScroll = jsDD.getContainersScrollPos(jsDD.x, jsDD.y); 8867 var current_dest_index = jsDD.searchDest(jsDD.x+containersScroll.left, jsDD.y+containersScroll.top); 8868 8869 if (current_dest_index !== jsDD.current_dest_index) 8870 { 8871 if (jsDD.current_dest_index !== false) 8872 { 8873 if (jsDD.current_node.onbxdraghout) 8874 jsDD.current_node.onbxdraghout(jsDD.arDestinations[jsDD.current_dest_index], jsDD.x, jsDD.y); 8875 8876 if (jsDD.arDestinations[jsDD.current_dest_index].onbxdestdraghout) 8877 jsDD.arDestinations[jsDD.current_dest_index].onbxdestdraghout(jsDD.current_node, jsDD.x, jsDD.y); 8878 } 8879 8880 if (current_dest_index !== false) 8881 { 8882 if (jsDD.current_node.onbxdraghover) 8883 jsDD.current_node.onbxdraghover(jsDD.arDestinations[current_dest_index], jsDD.x, jsDD.y); 8884 8885 if (jsDD.arDestinations[current_dest_index].onbxdestdraghover) 8886 jsDD.arDestinations[current_dest_index].onbxdestdraghover(jsDD.current_node, jsDD.x, jsDD.y); 8887 } 8888 } 8889 8890 jsDD.current_dest_index = current_dest_index; 8891 }, 8892 8893 stopDrag: function(e) 8894 { 8895 BX.unbind(document, 'keypress', jsDD._checkEsc); 8896 8897 e = e || window.event; 8898 8899 jsDD.bPreStarted = false; 8900 8901 if (jsDD.bStarted) 8902 { 8903 if (!jsDD.bEscPressed) 8904 { 8905 jsDD.x = e.clientX + jsDD.wndSize.scrollLeft; 8906 jsDD.y = e.clientY + jsDD.wndSize.scrollTop; 8907 } 8908 8909 if (null != jsDD.current_node.onbxdragstop) 8910 jsDD.current_node.onbxdragstop(jsDD.x, jsDD.y, e); 8911 8912 var containersScroll = jsDD.getContainersScrollPos(jsDD.x, jsDD.y); 8913 var dest_index = jsDD.searchDest(jsDD.x+containersScroll.left, jsDD.y+containersScroll.top); 8914 8915 if (false !== dest_index) 8916 { 8917 if (jsDD.bEscPressed) 8918 { 8919 if (null != jsDD.arDestinations[dest_index].onbxdestdraghout) 8920 { 8921 if (!jsDD.arDestinations[dest_index].onbxdestdraghout(jsDD.current_node, jsDD.x, jsDD.y)) 8922 dest_index = false; 8923 else 8924 { 8925 if (null != jsDD.current_node.onbxdragfinish) 8926 jsDD.current_node.onbxdragfinish(jsDD.arDestinations[dest_index], jsDD.x, jsDD.y); 8927 } 8928 } 8929 8930 } 8931 else 8932 { 8933 if (null != jsDD.arDestinations[dest_index].onbxdestdragfinish) 8934 { 8935 if (!jsDD.arDestinations[dest_index].onbxdestdragfinish(jsDD.current_node, jsDD.x, jsDD.y, e)) 8936 dest_index = false; 8937 else 8938 { 8939 if (null != jsDD.current_node.onbxdragfinish) 8940 jsDD.current_node.onbxdragfinish(jsDD.arDestinations[dest_index], jsDD.x, jsDD.y); 8941 } 8942 } 8943 } 8944 } 8945 8946 if (false === dest_index) 8947 { 8948 if (null != jsDD.current_node.onbxdragrelease) 8949 jsDD.current_node.onbxdragrelease(jsDD.x, jsDD.y); 8950 } 8951 else 8952 { 8953 for (var i = 0, cnt = jsDD.arDestinations.length; i < cnt; i++) 8954 { 8955 if (i != dest_index && jsDD.arDestinations[i] && null != jsDD.arDestinations[i].onbxdestdragrelease) 8956 jsDD.arDestinations[i].onbxdestdragrelease(jsDD.current_node, jsDD.x, jsDD.y); 8957 } 8958 } 8959 8960 for (var i = 0, cnt = jsDD.arDestinations.length; i < cnt; i++) 8961 { 8962 if (jsDD.arDestinations[i] && null != jsDD.arDestinations[i].onbxdestdragstop) 8963 jsDD.arDestinations[i].onbxdestdragstop(jsDD.current_node, jsDD.x, jsDD.y); 8964 } 8965 } 8966 8967 if(document.body.releaseCapture) 8968 document.body.releaseCapture(); 8969 8970 BX.unbind(window, 'scroll', jsDD._onscroll); 8971 BX.unbind(document, "mousemove", jsDD.drag); 8972 BX.unbind(document, "touchmove", jsDD.drag); 8973 BX.unbind(document, "keypress", jsDD._checkEsc); 8974 BX.unbind(document, "mouseup", jsDD.stopDrag); 8975 BX.unbind(document, "touchend", jsDD.stopDrag); 8976 8977 jsDD.allowSelection(); 8978 document.body.style.cursor = ''; 8979 8980 jsDD.current_node = null; 8981 jsDD.current_dest_index = false;
8982 8983 if (jsDD.bScrollWindow) 8984 { 8985 if (jsDD.scrollViewTimer) 8986 clearInterval(jsDD.scrollViewTimer); 8987 } 8988 8989 if (jsDD.bStarted && !jsDD.bDisableDestRefresh) 8990 jsDD.refreshDestArea(); 8991 8992 jsDD.bStarted = false; 8993 jsDD.bEscPressed = false; 8994 }, 8995 8996 searchDest: function(x, y) 8997 { 8998 var p, len, p1, len1, i; 8999 for (p = 0, len = jsDD.arDestinationsPriority.length; p < len; p++) 9000 { 9001 if (jsDD.arDestinationsPriority[p] && BX.type.isArray(jsDD.arDestinationsPriority[p])) 9002 { 9003 for (p1 = 0, len1 = jsDD.arDestinationsPriority[p].length; p1 < len1; p1++) 9004 { 9005 i = jsDD.arDestinationsPriority[p][p1]; 9006 if (jsDD.arDestinations[i] && !jsDD.arDestinations[i].__bxdddisabled) 9007 { 9008 if ( 9009 jsDD.arDestinations[i].__bxpos[0] <= x && 9010 jsDD.arDestinations[i].__bxpos[2] >= x && 9011 9012 jsDD.arDestinations[i].__bxpos[1] <= y && 9013 jsDD.arDestinations[i].__bxpos[3] >= y 9014 ) 9015 { 9016 return i; 9017 } 9018 } 9019 } 9020 } 9021 } 9022 9023 return false; 9024 }, 9025 9026 allowSelection: function() 9027 { 9028 document.onmousedown = document.ontouchstart = null; 9029 var b = document.body; 9030 b.ondrag = null; 9031 b.onselectstart = null; 9032 b.style.MozUserSelect = ''; 9033 9034 if (jsDD.current_node) 9035 { 9036 jsDD.current_node.ondrag = null; 9037 jsDD.current_node.onselectstart = null; 9038 jsDD.current_node.style.MozUserSelect = ''; 9039 } 9040 }, 9041 9042 denySelection: function() 9043 { 9044 document.onmousedown = document.ontouchstart = BX.False; 9045 var b = document.body; 9046 b.ondrag = BX.False; 9047 b.onselectstart = BX.False; 9048 b.style.MozUserSelect = 'none'; 9049 if (jsDD.current_node) 9050 { 9051 jsDD.current_node.ondrag = BX.False; 9052 jsDD.current_node.onselectstart = BX.False; 9053 jsDD.current_node.style.MozUserSelect = 'none'; 9054 } 9055 }, 9056 9057 Disable: function() {jsDD.bDisable = true;}, 9058 Enable: function() {jsDD.bDisable = false;} 9059} 9060 9061})(); 9062 9063/* End */ 9064; 9065; /* Start:"a:4:{s:4:"full";s:47:"/bitrix/js/main/core/core_uf.js?177728766318794";s:6:"source";s:31:"/bitrix/js/main/core/core_uf.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 9066;(function () 9067{ 9068 'use strict'; 9069 9070 BX.namespace('BX.Main.UF'); 9071 9072 if (typeof BX.Main.UF.Manager !== 'undefined') 9073 { 9074 return; 9075 } 9076 9077 var fieldStack = {}; 9078 9079 /** 9080 * Dynamic form manager. Initilized as singleton below 9081 * 9082 * @constructor 9083 */ 9084 9085 BX.Main.UF.Manager = function () 9086 { 9087 this.mode = this.mode || ''; 9088 this.ajaxUrl = '/bitrix/tools/uf.php'; 9089 }; 9090 9091 9092 BX.Main.UF.Manager.getEdit = function (param, callback) 9093 { 9094 return BX.Main.UF.EditManager.get(param, callback); 9095 }; 9096 9097 BX.Main.UF.Manager.getView = function (param, callback) 9098 { 9099 return BX.Main.UF.ViewManager.get(param, callback); 9100 }; 9101 9102 BX.Main.UF.Manager.prototype.get = function (param, callback) 9103 { 9104 if (!this.mode) 9105 { 9106 this.displayError([ 9107 'No mode set. Use BX.UF.EditManager or BX.UF.ViewManager' 9108 ]); 9109 9110 return; 9111 } 9112 9113 return this.query(this.mode, { 9114 FIELDS: param.FIELDS, 9115 FORM: param.FORM || '', 9116 CONTEXT: param.CONTEXT || '', 9117 MEDIA_TYPE: param.MEDIA_TYPE || '' 9118 }, callback); 9119 }; 9120 9121 BX.Main.UF.Manager.prototype.add = function (param, callback) 9122 { 9123 if (!this.mode) 9124 { 9125 this.displayError([ 9126 'No mode set. Use BX.UF.EditManager or BX.UF.ViewManager' 9127 ]); 9128 9129 return; 9130 } 9131 9132 return this.query(this.mode, { 9133 action: 'add', 9134 FIELDS: param.FIELDS, 9135 FORM: param.FORM || '' 9136 }, callback); 9137 }; 9138 9139 BX.Main.UF.Manager.prototype.update = function (param, callback) 9140 { 9141 if (!this.mode) 9142 { 9143 this.displayError([ 9144 'No mode set. Use BX.UF.EditManager or BX.UF.ViewManager' 9145 ]); 9146 9147 return; 9148 } 9149 9150 return this.query(this.mode, { 9151 action: 'update', 9152 FIELDS: param.FIELDS, 9153 FORM: param.FORM || '' 9154 }, callback); 9155 }; 9156 9157 BX.Main.UF.Manager.prototype.delete = function (param, callback) 9158 { 9159 if (!this.mode) 9160 { 9161 this.displayError([ 9162 'No mode set. Use BX.UF.EditManager or BX.UF.ViewManager' 9163 ]); 9164 9165 return; 9166 } 9167 9168 return this.query(this.mode, { 9169 action: 'delete', 9170 FIELDS: param.FIELDS, 9171 FORM: param.FORM || '' 9172 }, callback); 9173 }; 9174 9175 BX.Main.UF.Manager.prototype.query = function (mode, param, callback) 9176 { 9177 BX.ajax({ 9178 dataType: 'json', 9179 url: this.ajaxUrl, 9180 method: 'POST', 9181 data: this.prepareQuery(mode, param), 9182 onsuccess: this.queryCallback(callback) 9183 }); 9184 }; 9185 9186 BX.Main.UF.Manager.prototype.prepareQuery = function (mode, param) 9187 { 9188 var p = param || {}; 9189 9190 p.mode = mode; 9191 p.lang = BX.message('LANGUAGE_ID') || ''; 9192 p.tpl = BX.message('UF_SITE_TPL') || ''; 9193 p.tpls = BX.message('UF_SITE_TPL_SIGN') || ''; 9194 p.sessid = BX.bitrix_sessid(); 9195 9196 return p; 9197 }; 9198 9199 BX.Main.UF.Manager.prototype.queryCallback = function (callback) 9200 { 9201 var processResult = BX.proxy(this.processResult, this); 9202 return function (result) 9203 { 9204 processResult(result, callback); 9205 } 9206 }; 9207 9208 BX.Main.UF.Manager.prototype.processResult = function (result, callback) 9209 { 9210 var asset = ''; 9211 if (BX.type.isArray(result.ASSET)) 9212 { 9213 asset += result.ASSET.join('\n'); 9214 } 9215
9216 if (!!result.ERROR) 9217 { 9218 this.displayError(result.ERROR); 9219 } 9220 9221 return BX.html(null, asset).then(function () 9222 { 9223 if (!!callback) 9224 { 9225 callback(result.FIELD); 9226 } 9227 }); 9228 }; 9229 9230 BX.Main.UF.Manager.prototype.displayError = function (errorList) 9231 { 9232 for (var i in errorList) 9233 { 9234 if (errorList.hasOwnProperty(i)) 9235 { 9236 console.error(errorList[i]); 9237 } 9238 } 9239 }; 9240 9241 BX.Main.UF.Manager.prototype.registerField = function (field, fieldDescription, node) 9242 { 9243 fieldStack[field] = { 9244 FIELD: fieldDescription, 9245 NODE: node 9246 }; 9247 }; 9248 9249 BX.Main.UF.Manager.prototype.unRegisterField = function (field) 9250 { 9251 if (!!fieldStack[field]) 9252 { 9253 delete fieldStack[field]; 9254 } 9255 }; 9256 9257 9258 BX.Main.UF.ViewManager = function () 9259 { 9260 BX.Main.UF.ViewManager.superclass.constructor.apply(this, arguments); 9261 9262 this.mode = 'main.view'; 9263 }; 9264 BX.extend(BX.Main.UF.ViewManager, BX.Main.UF.Manager); 9265 9266 BX.Main.UF.EditManager = function () 9267 { 9268 BX.Main.UF.EditManager.superclass.constructor.apply(this, arguments); 9269 9270 this.mode = 'main.edit'; 9271 }; 9272 BX.extend(BX.Main.UF.EditManager, BX.Main.UF.Manager); 9273 9274 BX.Main.UF.EditManager.prototype.validate = function (fieldList, callback) 9275 { 9276 if (fieldList.length > 0) 9277 { 9278 var request = []; 9279 for (var i = 0; i < fieldList.length; i++) 9280 { 9281 var value = BX.Main.UF.Factory.getValue(fieldList[i]); 9282 if (value !== null) 9283 { 9284 request.push({ 9285 'ENTITY_ID': fieldStack[fieldList[i]].FIELD.ENTITY_ID, 9286 'FIELD': fieldStack[fieldList[i]].FIELD.FIELD, 9287 'ENTITY_VALUE_ID': fieldStack[fieldList[i]].FIELD.ENTITY_VALUE_ID, 9288 'VALUE': value 9289 }); 9290 } 9291 } 9292 9293 return this.query(this.mode, { 9294 action: 'validate', 9295 FIELDS: request 9296 }, callback); 9297 } 9298 else 9299 { 9300 this.queryCallback(callback)({'FIELD': []}); 9301 } 9302 }; 9303 9304 /** 9305 * Base type handler class. Will be initialized in Factory. 9306 * 9307 * @constructor 9308 */ 9309 9310 BX.Main.UF.BaseType = function () 9311 { 9312 }; 9313 9314 BX.Main.UF.BaseType.prototype.addRow = function (fieldName, thisButton) 9315 { 9316 var element = thisButton.parentNode.getElementsByTagName('span'); 9317 if (element && element.length > 0 && element[0]) 9318 { 9319 var parentElement = element[0].parentNode; // parent 9320 var newNode = this.getClone(element[element.length - 1], fieldName); 9321 9322 if (parentElement === thisButton.parentNode) 9323 { 9324 parentElement.insertBefore(newNode, thisButton); 9325 } 9326 else 9327 { 9328 parentElement.appendChild(newNode); 9329 } 9330 } 9331 }; 9332 9333 /** 9334 * @deprecated 9335 * @param fieldName 9336 * @param thisButton 9337 */ 9338 BX.Main.UF.BaseType.prototype.addMobileRow = function (fieldName, thisButton) 9339 { 9340 var element = thisButton.parentNode.getElementsByTagName('span'); 9341 if (element && element.length && element[0]) 9342 { 9343 var parentElement = element[0].parentNode; // parent 9344 var newNode = this.getClone(element[element.length - 1], fieldName); 9345 var firstChildren = newNode.firstElementChild; 9346 var name = firstChildren.getAttribute('name'); 9347 var re = /\[(\d)]/; 9348 var newName = name.replace(re, function (match, index) 9349 { 9350 index = parseInt(index) + 1; 9351 return '[' + index + ']'; 9352 }); 9353 var newItemId = false; 9354 var prevItemName = false; 9355 var userFieldTypeName = null; 9356 9357 firstChildren.setAttribute('name', newName); 9358 9359 if (firstChildren.hasChildNodes()) 9360 { 9361 firstChildren.childNodes.forEach( 9362 function (item, index, array) 9363 { 9364 if (!prevItemName && item.attributes !== undefined && item.tagName === 'INPUT') 9365 { 9366 item.setAttribute('name', newName); 9367 prevItemName = item.getAttribute('id'); 9368 newItemId = prevItemName + '_1'; 9369 userFieldTypeName = item.getAttribute('data-user-field-type-name'); 9370 } 9371 9372 if (prevItemName && item.attributes !== undefined && item.id !== undefined) 9373 { 9374 var id = item.getAttribute('id'); 9375 9376 if (id !== prevItemName) 9377 { 9378 item.setAttribute('id', id.replace(prevItemName, newItemId)); 9379 } 9380 else 9381 { 9382 item.setAttribute('id', newItemId); 9383 } 9384 } 9385 } 9386 ); 9387 } 9388 9389 if (parentElement === thisButton.parentNode) 9390 { 9391 parentElement.insertBefore(newNode, thisButton); 9392 } 9393 else 9394 {
9395 parentElement.appendChild(newNode); 9396 } 9397 9398 if (newItemId) 9399 { 9400 BX.onCustomEvent( 9401 'onAddMobileUfField', 9402 [newItemId, userFieldTypeName] 9403 ); 9404 } 9405 9406 } 9407 }; 9408 9409 BX.Main.UF.BaseType.prototype.getClone = function (node, fieldName) 9410 { 9411 var newNode = node.cloneNode(true); 9412 9413 var inputList = this.findInput(newNode, fieldName); 9414 for (var i = 0; i < inputList.length; i++) 9415 { 9416 inputList[i].value = ''; 9417 } 9418 9419 return newNode; 9420 }; 9421 9422 BX.Main.UF.BaseType.prototype.findInput = function (node, fieldName) 9423 { 9424 return BX.findChildren(node, { 9425 tagName: /INPUT|TEXTAREA|SELECT/i, 9426 attribute: { 9427 name: fieldName 9428 } 9429 }, true); 9430 }; 9431 9432 BX.Main.UF.BaseType.prototype.isEmpty = function (field) 9433 { 9434 var node = this.getNode(field), 9435 fieldName = field + ( 9436 fieldStack[field].FIELD.MULTIPLE === 'Y' 9437 ? '[]' 9438 : '' 9439 ); 9440 9441 if (!BX.isNodeInDom(node)) 9442 { 9443 console.error('Node for field ' + field + ' is already removed from DOM'); 9444 } 9445 9446 var nodeList = this.findInput(node, fieldName); 9447 9448 if (nodeList.length <= 0) 9449 { 9450 console.error('Unable to find field ' + field + ' in the registered node'); 9451 } 9452 else 9453 { 9454 for (var i = 0; i < nodeList.length; i++) 9455 { 9456 if (nodeList[i].value !== '') 9457 { 9458 return false; 9459 } 9460 } 9461 } 9462 9463 return true; 9464 }; 9465 9466 BX.Main.UF.BaseType.prototype.getValue = function (field) 9467 { 9468 var node = this.getNode(field), 9469 fieldName = field + ( 9470 fieldStack[field].FIELD.MULTIPLE === 'Y' 9471 ? '[]' 9472 : '' 9473 ), 9474 value = fieldStack[field].FIELD.MULTIPLE === 'Y' ? [] : ''; 9475 9476 if (!BX.isNodeInDom(node)) 9477 { 9478 console.error('Node for field ' + field + ' is already removed from DOM'); 9479 } 9480 var nodeList = this.findInput(node, fieldName); 9481 9482 if (nodeList.length <= 0) 9483 { 9484 var nodeChildren = (node.children.length ? node.children[0] : false); 9485 /** 9486 * @todo remove !BX.util.in_array(fieldStack[field].FIELD.USER_TYPE_ID, ['crm', 'employee']) 9487 * after deploy new Crm and Employee types 9488 */ 9489 if ( 9490 !BX.util.in_array(fieldStack[field].FIELD.USER_TYPE_ID, ['crm', 'employee']) 9491 && 9492 ( 9493 !nodeChildren 9494 || 9495 nodeChildren.getAttribute('data-has-input') !== 'no' 9496 ) 9497 ) 9498 { 9499 console.error('Unable to find field ' + field + ' in the registered node'); 9500 } 9501 } 9502 else 9503 { 9504 for (var i = 0; i < nodeList.length; i++) 9505 { 9506 if ( 9507 nodeList[i].tagName === 'INPUT' 9508 && (nodeList[i].type === 'radio' || nodeList[i].type === 'checkbox') 9509 && !nodeList[i].checked 9510 ) 9511 { 9512 continue; 9513 } 9514 9515 if (!BX.Type.isStringFilled(nodeList[i].value)) 9516 { 9517 continue; 9518 } 9519 9520 if (fieldStack[field].FIELD.MULTIPLE === 'Y') 9521 { 9522 value.push(nodeList[i].value); 9523 } 9524 else 9525 { 9526 value = nodeList[i].value; 9527 break; 9528 } 9529 } 9530 } 9531 9532 return value; 9533 }; 9534 9535 BX.Main.UF.BaseType.prototype.focus = function (field) 9536 { 9537 var node = this.getNode(field), 9538 fieldName = field + ( 9539 fieldStack[field].FIELD.MULTIPLE === 'Y' 9540 ? '[]' 9541 : '' 9542 ); 9543 9544 if (!BX.isNodeInDom(node)) 9545 { 9546 console.error('Node for field ' + field + ' is already removed from DOM'); 9547 } 9548 var nodeList = this.findInput(node, fieldName); 9549 9550 if (nodeList.length > 0) 9551 { 9552 BX.focus(nodeList[0]); 9553 } 9554 }; 9555 9556 BX.Main.UF.BaseType.prototype.getNode = function (field) 9557 { 9558 return fieldStack[field].NODE; 9559 }; 9560 9561 /** 9562 * Integer type handler class. Will be initialized in Factory. 9563 * 9564 * @constructor 9565 */ 9566 BX.Main.UF.TypeBoolean = function () 9567 { 9568 }; 9569 BX.extend(BX.Main.UF.TypeBoolean, BX.Main.UF.BaseType); 9570 9571 BX.Main.UF.TypeBoolean.USER_TYPE_ID = 'boolean'; 9572 9573 BX.Main.UF.TypeBoolean.prototype.isEmpty = function (field) 9574 { 9575 return false; 9576 }; 9577 9578 /** 9579 * Integer type handler class. Will be initialized in Factory. 9580 * 9581 * @constructor 9582 */ 9583 BX.Main.UF.TypeInteger = function () 9584 { 9585 }; 9586 BX.extend(BX.Main.UF.TypeInteger, BX.Main.UF.BaseType); 9587 9588 BX.Main.UF.TypeInteger.USER_TYPE_ID = 'integer'; 9589 9590 /** 9591 * Double type handler class. Will be initialized in Factory. 9592 * 9593 * @constructor 9594 */ 9595 BX.Main.UF.TypeDouble = function () 9596 { 9597 }; 9598 BX.extend(BX.Main.UF.TypeDouble, BX.Main.UF.BaseType); 9599 9600 BX.Main.UF.TypeDouble.USER_TYPE_ID = 'double'; 9601 9602 /** 9603 * String type handler class. Will be initialized in Factory. 9604 * 9605 * @constructor 9606 */
9607 BX.Main.UF.TypeSting = function () 9608 { 9609 }; 9610 BX.extend(BX.Main.UF.TypeSting, BX.Main.UF.BaseType); 9611 9612 BX.Main.UF.TypeSting.USER_TYPE_ID = 'string'; 9613 9614 /** 9615 * URL type handler class. Will be initialized in Factory. 9616 * 9617 * @constructor 9618 */ 9619 BX.Main.UF.TypeUrl = function () 9620 { 9621 }; 9622 BX.extend(BX.Main.UF.TypeUrl, BX.Main.UF.BaseType); 9623 9624 BX.Main.UF.TypeUrl.USER_TYPE_ID = 'url'; 9625 9626 /** 9627 * Formatted string type handler class. Will be initialized in Factory. 9628 * 9629 * @constructor 9630 */ 9631 BX.Main.UF.TypeStingFormatted = function () 9632 { 9633 }; 9634 BX.extend(BX.Main.UF.TypeStingFormatted, BX.Main.UF.TypeSting); 9635 9636 BX.Main.UF.TypeStingFormatted.USER_TYPE_ID = 'string_formatted'; 9637 9638 9639 /** 9640 * Enumeration type handler class. Will be initialized in Factory. 9641 * 9642 * @constructor 9643 */ 9644 BX.Main.UF.TypeEnumeration = function () 9645 { 9646 }; 9647 BX.extend(BX.Main.UF.TypeEnumeration, BX.Main.UF.BaseType); 9648 9649 BX.Main.UF.TypeEnumeration.USER_TYPE_ID = 'enumeration'; 9650 9651 BX.Main.UF.TypeEnumeration.prototype.findInput = function (node, fieldName) 9652 { 9653 var inputList = BX.Main.UF.TypeEnumeration.superclass.findInput.apply(this, arguments); 9654 9655 if (inputList.length > 0) 9656 { 9657 for (var i = 0; i < inputList.length; i++) 9658 { 9659 if (inputList[i].tagName === 'INPUT' && inputList[i].type === 'hidden' && inputList.length > 1) 9660 { 9661 delete inputList[i]; 9662 break; 9663 } 9664 } 9665 } 9666 9667 return BX.util.array_values(inputList); 9668 }; 9669 9670 BX.Main.UF.TypeEnumeration.prototype.focus = function (field) 9671 { 9672 if (fieldStack[field] 9673 && fieldStack[field].FIELD.SETTINGS.DISPLAY === 'UI' 9674 && BX.type.isElementNode(fieldStack[field].NODE) 9675 ) 9676 { 9677 BX.fireEvent(fieldStack[field].NODE, 'focus'); 9678 } 9679 else 9680 { 9681 BX.Main.UF.TypeEnumeration.superclass.focus.apply(this, arguments); 9682 } 9683 }; 9684 9685 /** 9686 * Date type handler class. Will be initialized in Factory. 9687 * 9688 * @constructor 9689 */ 9690 BX.Main.UF.TypeDate = function () 9691 { 9692 }; 9693 BX.extend(BX.Main.UF.TypeDate, BX.Main.UF.BaseType); 9694 9695 BX.Main.UF.TypeDate.USER_TYPE_ID = 'date'; 9696 9697 BX.Main.UF.TypeDate.prototype.focus = function (field) 9698 { 9699 var fieldName = field + ( 9700 fieldStack[field].FIELD.MULTIPLE === 'Y' 9701 ? '[]' 9702 : '' 9703 ); 9704 var inputList = this.findInput(this.getNode(field), fieldName); 9705 9706 if (inputList.length > 0) 9707 { 9708 BX.fireEvent(inputList[0], 'click'); 9709 } 9710 9711 BX.Main.UF.TypeDate.superclass.focus.apply(this, arguments); 9712 }; 9713 9714 /** 9715 * Datetime type handler class. Will be initialized in Factory. 9716 * 9717 * @constructor 9718 */ 9719 BX.Main.UF.TypeDateTime = function () 9720 { 9721 }; 9722 BX.extend(BX.Main.UF.TypeDateTime, BX.Main.UF.TypeDate); 9723 9724 BX.Main.UF.TypeDateTime.USER_TYPE_ID = 'datetime'; 9725 9726 /** 9727 * Datetime type handler class. Will be initialized in Factory. 9728 * 9729 * @constructor 9730 */ 9731 BX.Main.UF.TypeFile = function () 9732 { 9733 }; 9734 BX.extend(BX.Main.UF.TypeFile, BX.Main.UF.BaseType); 9735 9736 BX.Main.UF.TypeFile.USER_TYPE_ID = 'file'; 9737 9738 BX.Main.UF.TypeFile.prototype.findInput = function (node, fieldName) 9739 { 9740 var inputList = BX.Main.UF.TypeFile.superclass.findInput.apply(this, arguments); 9741 9742 if (inputList.length <= 0) 9743 { 9744 inputList = BX.findChildren(node, { 9745 tagName: /INPUT/i, 9746 attribute: { 9747 type: 'file', 9748 name: /^bxu_files/ 9749 } 9750 }, true); 9751 } 9752 9753 return inputList; 9754 }; 9755 9756 BX.Main.UF.TypeFile.prototype.getValue = function (field) 9757 { 9758 var 9759 baseValue = BX.Main.UF.TypeFile.superclass.getValue.apply(this, arguments), 9760 node = fieldStack[field].NODE, 9761 deletedNodeList = [], 9762 i; 9763 9764 if (fieldStack[field].FIELD.MULTIPLE === 'Y') 9765 { 9766 var deletedFieldName = field + '_del[]'; 9767 9768 if (BX.type.isArray(baseValue) && baseValue.length > 0) 9769 { 9770 deletedNodeList = BX.Main.UF.TypeFile.superclass.findInput.apply(this, [node, deletedFieldName]); 9771 9772 for (i = 0; i < deletedNodeList.length; i++) 9773 { 9774 var pos = BX.util.array_search(deletedNodeList[i].value, baseValue); 9775 if (pos >= 0) 9776 { 9777 baseValue[pos] = {'old_id': deletedNodeList[i].value, 'del': 'Y', 'tmp_name': ''}; 9778 } 9779 } 9780 } 9781 9782 return BX.util.array_values(baseValue); 9783 } 9784 9785 if (baseValue > 0) 9786 { 9787 var deletedFieldName = field + '_del'; 9788 9789 deletedNodeList = BX.Main.UF.TypeFile.superclass.findInput.apply(this, [node, deletedFieldName]); 9790 9791 for (i = 0; i < deletedNodeList.length; i++) 9792 { 9793 if (baseValue == deletedNodeList[i].value) 9794 { 9795 baseValue = {'old_id': baseValue, 'del': 'Y', 'tmp_name': ''}; 9796 break; 9797 } 9798 } 9799 9800 return baseValue; 9801 } 9802 9803 return null; 9804 }; 9805 9806 9807 /** 9808 * Type handler Factory singleton. Will be initialized below. 9809 * 9810 * @constructor 9811 */ 9812 BX.Main.UF.Factory = function () 9813 { 9814 this.defaultTypeHandler = BX.Main.UF.BaseType; 9815 9816 this.typeHandlerList = {}; 9817 this.objectCollection = {}; 9818 }; 9819 9820 BX.Main.UF.Factory.prototype.setTypeHandler = function (type, handlerClass) 9821 { 9822 this.typeHandlerList[type] = handlerClass; 9823 if (typeof this.objectCollection[type] !== 'undefined') 9824 { 9825 delete this.objectCollection[type]; 9826 } 9827 }; 9828 9829 BX.Main.UF.Factory.prototype.get = function (type) 9830 { 9831 if (typeof this.objectCollection[type] === 'undefined') 9832 { 9833 this.objectCollection[type] = this.getObject(type); 9834 } 9835 9836 return this.objectCollection[type]; 9837 }; 9838 9839 BX.Main.UF.Factory.prototype.getObject = function (type) 9840 { 9841 return new (this.typeHandlerList[type] || this.defaultTypeHandler); 9842 }; 9843 9844 BX.Main.UF.Factory.prototype.getFieldObject = function (field) 9845 { 9846 if (typeof fieldStack[field] === 'undefined') 9847 {
9848 console.error('Field ' + field + 'is not registered. Use BX.Main.UF.Factory.registerField to register'); 9849 9850 return null; 9851 } 9852 9853 return this.get(fieldStack[field]['FIELD']['USER_TYPE_ID']); 9854 }; 9855 9856 BX.Main.UF.Factory.prototype.isEmpty = function (field) 9857 { 9858 if (typeof fieldStack[field] === 'undefined') 9859 { 9860 console.error('Field ' + field + 'is not registered. Use BX.Main.UF.Factory.registerField to register'); 9861 9862 return true; 9863 } 9864 9865 return this.get(fieldStack[field]['FIELD']['USER_TYPE_ID']).isEmpty(field); 9866 }; 9867 9868 BX.Main.UF.Factory.prototype.getValue = function (field) 9869 { 9870 if (typeof fieldStack[field] === 'undefined') 9871 { 9872 console.error('Field ' + field + 'is not registered. Use BX.Main.UF.Factory.registerField to register'); 9873 9874 return null; 9875 } 9876 9877 return this.get(fieldStack[field]['FIELD']['USER_TYPE_ID']).getValue(field); 9878 }; 9879 9880 BX.Main.UF.Factory.prototype.focus = function (field) 9881 { 9882 if (typeof fieldStack[field] === 'undefined') 9883 { 9884 console.error('Field ' + field + 'is not registered. Use BX.Main.UF.Factory.registerField to register'); 9885 } 9886 9887 return this.get(fieldStack[field]['FIELD']['USER_TYPE_ID']).focus(field); 9888 }; 9889 9890 /** 9891 * Singletons initialization 9892 */ 9893 9894 BX.Main.UF.EditManager = new BX.Main.UF.EditManager(); 9895 BX.Main.UF.ViewManager = new BX.Main.UF.ViewManager(); 9896 BX.Main.UF.Factory = new BX.Main.UF.Factory(); 9897 9898 BX.Main.UF.Factory.setTypeHandler(BX.Main.UF.TypeBoolean.USER_TYPE_ID, BX.Main.UF.TypeBoolean); 9899 BX.Main.UF.Factory.setTypeHandler(BX.Main.UF.TypeInteger.USER_TYPE_ID, BX.Main.UF.TypeInteger); 9900 BX.Main.UF.Factory.setTypeHandler(BX.Main.UF.TypeDouble.USER_TYPE_ID, BX.Main.UF.TypeDouble); 9901 BX.Main.UF.Factory.setTypeHandler(BX.Main.UF.TypeSting.USER_TYPE_ID, BX.Main.UF.TypeSting); 9902 BX.Main.UF.Factory.setTypeHandler(BX.Main.UF.TypeStingFormatted.USER_TYPE_ID, BX.Main.UF.TypeStingFormatted); 9903 BX.Main.UF.Factory.setTypeHandler(BX.Main.UF.TypeEnumeration.USER_TYPE_ID, BX.Main.UF.TypeEnumeration); 9904 BX.Main.UF.Factory.setTypeHandler(BX.Main.UF.TypeFile.USER_TYPE_ID, BX.Main.UF.TypeFile); 9905 BX.Main.UF.Factory.setTypeHandler(BX.Main.UF.TypeDate.USER_TYPE_ID, BX.Main.UF.TypeDate); 9906 BX.Main.UF.Factory.setTypeHandler(BX.Main.UF.TypeDateTime.USER_TYPE_ID, BX.Main.UF.TypeDateTime); 9907})(); 9908 9909 9910/* End */ 9911; 9912; /* Start:"a:4:{s:4:"full";s:46:"/bitrix/js/main/core/core_dd.js?17772876633614";s:6:"source";s:31:"/bitrix/js/main/core/core_dd.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 9913(function(window){ 9914BX.DD = function(params) 9915{ 9916 return new BX.DD.dragdrop(params); 9917} 9918 9919BX.DD.allowSelection = function() 9920{ 9921 document.onmousedown = null; 9922 var b = document.body; 9923 b.ondrag = null; 9924 b.onselectstart = null; 9925 b.style.MozUserSelect = ''; 9926 9927 // if (jsDD.current_node) 9928 // { 9929 // jsDD.current_node.ondrag = null; 9930 // jsDD.current_node.onselectstart = null; 9931 // jsDD.current_node.style.MozUserSelect = ''; 9932 // } 9933} 9934 9935BX.DD.denySelection = function() 9936{ 9937 document.onmousedown = BX.False; 9938 var b = document.body; 9939 b.ondrag = BX.False; 9940 b.onselectstart = BX.False; 9941 b.style.MozUserSelect = 'none'; 9942 // if (jsDD.current_node) 9943 // { 9944 // jsDD.current_node.ondrag = jsUtils.False; 9945 // jsDD.current_node.onselectstart = jsUtils.False; 9946 // jsDD.current_node.style.MozUserSelect = 'none'; 9947 // } 9948} 9949 9950BX.DD.dragdrop = function(params) 9951{ 9952 9953 9954} 9955 9956/* 9957 * BX.DD.dropFiles - for html5 drag and drop files 9958 * 9959 * example: 9960 * 9961 * BX(function() { 9962 * var dropBoxNode = BX('WebDAV23'); 9963 * var dropbox = new BX.DD.dropFiles(dropBoxNode); 9964 * if (dropbox && dropbox.supported()) 9965 * { 9966 * BX.addCustomEvent(dropbox, 'dropFiles', function(files) { WDUploadDroppedFiles(files);}); 9967 * BX.addCustomEvent(dropbox, 'dragEnter', function() {BX.addClass( dropBoxNode, 'droptarget');}); 9968 * BX.addCustomEvent(dropbox, 'dragLeave', function() {BX.removeClass( dropBoxNode, 'droptarget');}); 9969 * } 9970 * }); 9971 * 9972 * to save files use BX.ajax.FormData 9973 */ 9974BX.DD.dropFiles = function(div) 9975{ 9976 if (BX.type.isElementNode(div) 9977 && this.supported()) 9978 { 9979 div.setAttribute('dropzone', 'copy f:*/*'); 9980 this.DIV = div; 9981 this._timer = null; 9982 this._initEvents(); 9983 9984 this._cancelLeave = function() 9985 { 9986 if (this._timer != null) 9987 { 9988 clearTimeout(this._timer); 9989 this._timer = null; 9990 } 9991 } 9992 this._prepareLeave = function() 9993 { 9994 this._cancelLeave(); 9995 this._timer = setTimeout( BX.delegate(function() { 9996 BX.onCustomEvent(this, 'dragLeave') 9997 }, this), 100); 9998 } 9999 10000 return this; 10001 } 10002 return false;
10003} 10004 10005BX.DD.dropFiles.prototype._initEvents = function() 10006{ 10007 BX.bind(this.DIV, 'dragover', BX.proxy(this._dragOver, this)); 10008 BX.bind(this.DIV, 'dragenter', BX.proxy(this._dragEnter, this)); 10009 BX.bind(this.DIV, 'dragleave', BX.proxy(this._dragLeave, this)); 10010 BX.bind(this.DIV, 'dragexit', BX.proxy(this._dragExit, this)); 10011 BX.bind(this.DIV, 'drop', BX.proxy(this._drop, this)); 10012} 10013 10014BX.DD.dropFiles.prototype._dragEnter = function(e) 10015{ 10016 BX.PreventDefault(e); 10017 this._cancelLeave(); 10018 BX.onCustomEvent(this, 'dragEnter', [e]); 10019 return true; 10020} 10021 10022BX.DD.dropFiles.prototype._dragExit = function(e) 10023{ 10024 BX.PreventDefault(e); 10025 this._prepareLeave(); 10026 return false; 10027} 10028 10029 10030BX.DD.dropFiles.prototype._dragLeave = function(e) 10031{ 10032 BX.PreventDefault(e); 10033 this._prepareLeave(); 10034 return false; 10035} 10036 10037BX.DD.dropFiles.prototype._dragOver = function(e) 10038{ 10039 BX.PreventDefault(e); 10040 this._cancelLeave(); 10041 return true; 10042} 10043 10044BX.DD.dropFiles.prototype._drop = function(e) 10045{ 10046 BX.PreventDefault(e); 10047 var dt = e.dataTransfer; 10048 var files = dt.files; 10049 BX.onCustomEvent(this, 'dropFiles', [files, e]); 10050 BX.onCustomEvent(this, 'dragLeave') 10051 return false; 10052} 10053 10054BX.DD.dropFiles.prototype.isEventSupported = function(event) 10055{ 10056 var div = BX.create('DIV'); 10057 var eventName = 'on'+event; 10058 var result = (eventName in div); 10059 10060 if (!result && div.setAttribute && div.removeAttribute) 10061 { 10062 div.setAttribute(eventName, ''); 10063 result = (typeof div[eventName] === 'function'); 10064 } 10065 10066 div = null; 10067 return result; 10068} 10069 10070BX.DD.dropFiles.prototype.supported = function() 10071{ 10072 return ( (!!window.FileReader) && this.isEventSupported('dragstart') && this.isEventSupported('drop') ); 10073} 10074 10075})(window) 10076 10077 10078 10079/* End */ 10080; 10081; /* Start:"a:4:{s:4:"full";s:52:"/bitrix/js/main/core/core_tooltip.js?177728766315635";s:6:"source";s:36:"/bitrix/js/main/core/core_tooltip.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 10082(function(window) { 10083if (BX.tooltip) return; 10084 10085var arTooltipIndex = {}, 10086 bDisable = false; 10087 10088BX.tooltip = function(user_id, anchor_name, loader, rootClassName, bForceUseLoader, params) 10089{ 10090 if (BX.message('TOOLTIP_ENABLED') != "Y") 10091 { 10092 return; 10093 } 10094 10095 if ( 10096 BX.browser.IsAndroid() 10097 || BX.browser.IsIOS() 10098 ) 10099 { 10100 return; 10101 } 10102 10103 BX.ready(function() { 10104 var anchor = BX(anchor_name); 10105 if (null == anchor) 10106 { 10107 return; 10108 } 10109 10110 var tooltipId = user_id; 10111 if(bForceUseLoader && BX.type.isNotEmptyString(loader)) 10112 { 10113 // prepare tooltip ID from custom loader 10114 var loaderHash = 0; 10115 for(var i = 0, len = loader.length; i < len; i++) 10116 { 10117 loaderHash = (31 * loaderHash + loader.charCodeAt(i)) << 0; 10118 } 10119 10120 tooltipId = loaderHash + user_id; 10121 } 10122 10123 if (null == arTooltipIndex[tooltipId]) 10124 { 10125 arTooltipIndex[tooltipId] = new BX.CTooltip(user_id, anchor, loader, rootClassName, bForceUseLoader, params); 10126 } 10127 else 10128 { 10129 arTooltipIndex[tooltipId].ANCHOR = anchor; 10130 arTooltipIndex[tooltipId].rootClassName = rootClassName; 10131 arTooltipIndex[tooltipId].LOADER = ( 10132 bForceUseLoader 10133 && BX.type.isNotEmptyString(loader) 10134 ? loader 10135 : '/bitrix/tools/tooltip.php' 10136 ); 10137 arTooltipIndex[tooltipId].params = params; 10138 arTooltipIndex[tooltipId].Create(); 10139 } 10140 }); 10141}; 10142 10143BX.tooltip.disable = function(){ bDisable = true; }; 10144BX.tooltip.enable = function(){ bDisable = false; }; 10145 10146BX.tooltip.hide = function(userId) { 10147 if (BX('user_info_' + userId)) 10148 { 10149 BX('user_info_' + userId).style.display = 'none'; 10150 } 10151}; 10152 10153BX.tooltip.openIM = function(userId) { 10154 10155 const namespace = top.BX.Reflection.namespace('BX.Messenger.Public'); 10156 if (namespace) 10157 { 10158 namespace.openChat(userId); 10159 BX.tooltip.hide(userId); 10160 } 10161 else if (BX('MULSonetMessageChatTemplate')) 10162 { 10163 window.open(BX('MULSonetMessageChatTemplate').replace('#user_id#', userId).replace('#USER_ID#', userId).replace('#ID#', userId), '', 'location=yes,status=no,scrollbars=yes,resizable=yes,width=700,height=550,top='+Math.floor((screen.height - 550)/2-14)+',left='+Math.floor((screen.width - 700)/2-5)); 10164 BX.tooltip.hide(userId); 10165 } 10166 return false; 10167}; 10168 10169 10170BX.tooltip.openCallTo = function(userId) { 10171 10172 const namespace = top.BX.Reflection.namespace('BX.Messenger.Public'); 10173 if (namespace) 10174 { 10175 namespace.startVideoCall(userId); 10176 } 10177 return false;
10178}; 10179 10180BX.tooltip.checkCallTo = function(nodeId) { 10181}; 10182 10183BX.tooltip.openVideoCall = function(userId) { 10184 const namespace = top.BX.Reflection.namespace('BX.Messenger.Public'); 10185 if (namespace) 10186 { 10187 namespace.startVideoCall(userId); 10188 } 10189 else if (BX('MULVideoCallTemplate')) 10190 { 10191 window.open(BX('MULVideoCallTemplate').replace('#user_id#', userId).replace('#USER_ID#', userId).replace('#ID#', userId), '', 'location=yes,status=no,scrollbars=yes,resizable=yes,width=1000,height=600,top='+Math.floor((screen.height - 600)/2-14)+',left='+Math.floor((screen.width - 1000)/2-5)); 10192 BX.tooltip.hide(userId); 10193 } 10194 return false; 10195}; 10196 10197BX.CTooltip = function(user_id, anchor, loader, rootClassName, bForceUseLoader, params) 10198{ 10199 this.LOADER = ( 10200 bForceUseLoader 10201 && BX.type.isNotEmptyString(loader) 10202 ? loader 10203 : '/bitrix/tools/tooltip.php' 10204 ); 10205 this.USER_ID = user_id; 10206 this.ANCHOR = anchor; 10207 this.rootClassName = ''; 10208 this.params = (typeof params != 'undefined' ? params : {}); 10209 10210 if ( 10211 rootClassName != 'undefined' 10212 && rootClassName != null 10213 && rootClassName.length > 0 10214 ) 10215 { 10216 this.rootClassName = rootClassName; 10217 } 10218 10219 var old = document.getElementById('user_info_' + this.USER_ID); 10220 if (null != old) 10221 { 10222 if (null != old.parentNode) 10223 old.parentNode.removeChild(old); 10224 10225 old = null; 10226 } 10227 10228 var _this = this; 10229 10230 this.INFO = null; 10231 10232 this.width = 393; 10233 this.height = 302; 10234 10235 this.RealAnchor = null; 10236 this.CoordsLeft = 0; 10237 this.CoordsTop = 0; 10238 this.AnchorRight = 0; 10239 this.AnchorBottom = 0; 10240 10241 this.DIV = null; 10242 this.ROOT_DIV = null; 10243 10244 if (BX.browser.IsIE()) 10245 { 10246 this.IFRAME = null; 10247 } 10248 10249 this.v_delta = 0; 10250 this.classNameAnim = false; 10251 this.classNameFixed = false; 10252 10253 this.left = 0; 10254 this.top = 0; 10255 10256 this.tracking = false; 10257 this.active = false; 10258 this.showed = false; 10259 10260 this.Create = function() 10261 { 10262 _this.ANCHOR.onmouseover = function() { 10263 if (!bDisable) 10264 { 10265 _this.StartTrackMouse(this); 10266 } 10267 }; 10268 10269 _this.ANCHOR.onmouseout = function() { 10270 _this.StopTrackMouse(this); 10271 } 10272 }; 10273 10274 this.Create(); 10275 10276 this.TrackMouse = function(e) 10277 { 10278 if(!_this.tracking) 10279 return; 10280 10281 var current; 10282 if(e && e.pageX) 10283 current = {x: e.pageX, y: e.pageY}; 10284 else 10285 current = {x: e.clientX + document.body.scrollLeft, y: e.clientY + document.body.scrollTop}; 10286 10287 if(current.x < 0) 10288 current.x = 0; 10289 if(current.y < 0) 10290 current.y = 0; 10291 10292 current.time = _this.tracking; 10293 10294 if(!_this.active) 10295 _this.active = current; 10296 else 10297 { 10298 if( 10299 _this.active.x >= (current.x - 1) && _this.active.x <= (current.x + 1) 10300 && _this.active.y >= (current.y - 1) && _this.active.y <= (current.y + 1) 10301 ) 10302 { 10303 if((_this.active.time + 20/*2sec*/) <= current.time) 10304 _this.ShowTooltip(); 10305 } 10306 else 10307 _this.active = current; 10308 } 10309 }; 10310 10311 this.ShowTooltip = function() 10312 { 10313 var old = document.getElementById('user_info_' + _this.USER_ID); 10314 if(bDisable || old && old.style.display == 'block') 10315 return; 10316 10317 var bIE = (BX.browser.IsIE() && !BX.browser.IsIE10()); 10318 10319 if (!BX.type.isPlainObject(this.params)) 10320 { 10321 this.params = {}; 10322 } 10323 10324 if (null == _this.DIV && null == _this.ROOT_DIV) 10325 { 10326 _this.ROOT_DIV = document.body.appendChild(document.createElement('DIV')); 10327 _this.ROOT_DIV.style.position = 'absolute'; 10328 10329 BX.ZIndexManager.register(_this.ROOT_DIV); 10330 10331 _this.DIV = _this.ROOT_DIV.appendChild(document.createElement('DIV')); 10332 if (bIE) 10333 _this.DIV.className = 'bx-user-info-shadow-ie'; 10334 else 10335 _this.DIV.className = 'bx-user-info-shadow'; 10336 10337 _this.DIV.style.width = _this.width + 'px'; 10338 _this.DIV.style.height = _this.height + 'px'; 10339 } 10340 10341 var left = _this.CoordsLeft; 10342 var top = _this.CoordsTop + 30; 10343 var arScroll = BX.GetWindowScrollPos(); 10344 var body = document.body; 10345 10346 var h_mirror = false; 10347 var v_mirror = false; 10348 10349 if((body.clientWidth + arScroll.scrollLeft) < (left + _this.width)) 10350 { 10351 left = _this.AnchorRight - _this.width; 10352 h_mirror = true; 10353 } 10354 10355 if((top - arScroll.scrollTop) < 0) 10356 { 10357 top = _this.AnchorBottom - 5; 10358 v_mirror = true; 10359 _this.v_delta = 40; 10360 } 10361 else 10362 _this.v_delta = 0; 10363 10364 _this.ROOT_DIV.style.left = parseInt(left) + "px"; 10365 _this.ROOT_DIV.style.top = parseInt(top) + "px"; 10366 10367 BX.ZIndexManager.bringToFront(_this.ROOT_DIV); 10368 10369 BX.bind(BX(_this.ROOT_DIV), "click", BX.eventCancelBubble); 10370 10371 if ( 10372 this.rootClassName != 'undefined' 10373 && this.rootClassName != null 10374 && this.rootClassName.length > 0 10375 ) 10376 _this.ROOT_DIV.className = this.rootClassName; 10377 10378 if ('' == _this.DIV.innerHTML) 10379 { 10380 var url = _this.LOADER + 10381 (_this.LOADER.indexOf('?') >= 0 ? '&' : '?') + 10382 'MUL_MODE=INFO&USER_ID=' + _this.USER_ID + 10383 '&site=' + (BX.message('SITE_ID') || '') + 10384 ( 10385 typeof _this.params != 'undefined' 10386 && typeof _this.params.entityType != 'undefined' 10387 && _this.params.entityType.length > 0 10388 ? '&entityType=' + _this.params.entityType 10389 : '' 10390 ) + 10391 ( 10392 typeof _this.params != 'undefined' 10393 && typeof _this.params.entityId != 'undefined' 10394 && parseInt(_this.params.entityId) > 0
10395 ? '&entityId=' + parseInt(_this.params.entityId) 10396 : '' 10397 ); 10398 10399 BX.ajax.get(url, _this.InsertData); 10400 _this.DIV.id = 'user_info_' + _this.USER_ID; 10401 10402 _this.DIV.innerHTML = '<div class="bx-user-info-wrap">' 10403 + '<div class="bx-user-info-leftcolumn">' 10404 + '<div class="bx-user-photo" id="user-info-photo-' + _this.USER_ID + '"><div class="bx-user-info-data-loading">' + BX.message('JS_CORE_LOADING') + '</div></div>' 10405 + '<div class="bx-user-tb-control bx-user-tb-control-left" id="user-info-toolbar-' + _this.USER_ID + '"></div>' 10406 + '</div>' 10407 + '<div class="bx-user-info-data">' 10408 + '<div id="user-info-data-card-' + _this.USER_ID + '"></div>' 10409 + '<div class="bx-user-info-data-tools">' 10410 + '<div class="bx-user-tb-control bx-user-tb-control-right" id="user-info-toolbar2-' + _this.USER_ID + '"></div>' 10411 + '<div class="bx-user-info-data-clear"></div>' 10412 + '</div>' 10413 + '</div>' 10414 + '</div><div class="bx-user-info-bottomarea"></div>'; 10415 } 10416 10417 if (bIE) 10418 { 10419 _this.DIV.className = 'bx-user-info-shadow-ie'; 10420 _this.classNameAnim = 'bx-user-info-shadow-anim-ie'; 10421 _this.classNameFixed = 'bx-user-info-shadow-ie'; 10422 } 10423 else 10424 { 10425 _this.DIV.className = 'bx-user-info-shadow'; 10426 _this.classNameAnim = 'bx-user-info-shadow-anim'; 10427 _this.classNameFixed = 'bx-user-info-shadow'; 10428 } 10429 10430 _this.filterFixed = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/bitrix/components/bitrix/main.user.link/templates/.default/images/cloud-left-top.png', sizingMethod = 'crop' );"; 10431 10432 if (h_mirror && v_mirror) 10433 { 10434 if (BX.browser.IsIE6()) 10435 { 10436 _this.DIV.className = 'bx-user-info-shadow-hv-ie6'; 10437 _this.classNameAnim = 'bx-user-info-shadow-hv-anim-ie6'; 10438 _this.classNameFixed = 'bx-user-info-shadow-hv-ie6'; 10439 } 10440 else if (bIE) 10441 { 10442 _this.DIV.className = 'bx-user-info-shadow-hv-ie'; 10443 _this.classNameAnim = 'bx-user-info-shadow-hv-anim-ie'; 10444 _this.classNameFixed = 'bx-user-info-shadow-hv-ie'; 10445 } 10446 else 10447 { 10448 _this.DIV.className = 'bx-user-info-shadow-hv'; 10449 _this.classNameAnim = 'bx-user-info-shadow-hv-anim'; 10450 _this.classNameFixed = 'bx-user-info-shadow-hv'; 10451 } 10452 10453 _this.filterFixed = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/bitrix/components/bitrix/main.user.link/templates/.default/images/cloud-right-bottom.png', sizingMethod = 'crop' );"; 10454 } 10455 else 10456 { 10457 if (h_mirror) 10458 { 10459 if (bIE) 10460 { 10461 _this.DIV.className = 'bx-user-info-shadow-h-ie'; 10462 _this.classNameAnim = 'bx-user-info-shadow-h-anim-ie'; 10463 _this.classNameFixed = 'bx-user-info-shadow-h-ie'; 10464 } 10465 else 10466 { 10467 _this.DIV.className = 'bx-user-info-shadow-h'; 10468 _this.classNameAnim = 'bx-user-info-shadow-h-anim'; 10469 _this.classNameFixed = 'bx-user-info-shadow-h'; 10470 } 10471 10472 _this.filterFixed = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/bitrix/components/bitrix/main.user.link/templates/.default/images/cloud-right-top.png', sizingMethod = 'crop' );"; 10473 } 10474 10475 if (v_mirror) 10476 { 10477 if (BX.browser.IsIE6()) 10478 { 10479 _this.DIV.className = 'bx-user-info-shadow-v-ie6'; 10480 _this.classNameAnim = 'bx-user-info-shadow-v-anim-ie6'; 10481 _this.classNameFixed = 'bx-user-info-shadow-v-ie6'; 10482 } 10483 else if (bIE) 10484 { 10485 _this.DIV.className = 'bx-user-info-shadow-v-ie'; 10486 _this.classNameAnim = 'bx-user-info-shadow-v-anim-ie'; 10487 _this.classNameFixed = 'bx-user-info-shadow-v-ie'; 10488 } 10489 else 10490 { 10491 _this.DIV.className = 'bx-user-info-shadow-v'; 10492 _this.classNameAnim = 'bx-user-info-shadow-v-anim'; 10493 _this.classNameFixed = 'bx-user-info-shadow-v'; 10494 } 10495 10496 _this.filterFixed = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/bitrix/components/bitrix/main.user.link/templates/.default/images/cloud-left-bottom.png', sizingMethod = 'crop' );"; 10497 } 10498 } 10499 10500 10501 if (BX.browser.IsIE() && null == _this.IFRAME) 10502 { 10503 _this.IFRAME = document.body.appendChild(document.createElement('IFRAME')); 10504 _this.IFRAME.id = _this.DIV.id + "_frame"; 10505 _this.IFRAME.style.position = 'absolute'; 10506 _this.IFRAME.style.width = (_this.width - 60) + 'px'; 10507 _this.IFRAME.style.height = (_this.height - 100) + 'px'; 10508 _this.IFRAME.style.borderStyle = 'solid'; 10509 _this.IFRAME.style.borderWidth = '0px'; 10510 _this.IFRAME.style.zIndex = 550; 10511 _this.IFRAME.style.display = 'none'; 10512 } 10513 if (BX.browser.IsIE()) 10514 { 10515 _this.IFRAME.style.left = (parseInt(left) + 25) + "px"; 10516 _this.IFRAME.style.top = (parseInt(top) + 30 + _this.v_delta) + "px"; 10517 } 10518 10519 _this.DIV.style.display = 'none'; 10520 _this.ShowOpacityEffect({func: _this.SetVisible, obj: _this.DIV, arParams: []}
10520, 0); 10521 10522 document.getElementById('user_info_' + _this.USER_ID).onmouseover = function() { 10523 _this.StartTrackMouse(this); 10524 }; 10525 10526 document.getElementById('user_info_' + _this.USER_ID).onmouseout = function() { 10527 _this.StopTrackMouse(this); 10528 }; 10529 10530 BX.onCustomEvent('onTooltipShow', [this]); 10531 }; 10532 10533 this.InsertData = function(data) 10534 { 10535 if (null != data && data.length > 0) 10536 { 10537 eval('_this.INFO = ' + data); 10538 10539 var cardEl = document.getElementById('user-info-data-card-' + _this.USER_ID); 10540 cardEl.innerHTML = _this.INFO.RESULT.Card; 10541 10542 var photoEl = document.getElementById('user-info-photo-' + _this.USER_ID); 10543 photoEl.innerHTML = _this.INFO.RESULT.Photo; 10544 10545 var toolbarEl = document.getElementById('user-info-toolbar-' + _this.USER_ID); 10546 toolbarEl.innerHTML = _this.INFO.RESULT.Toolbar; 10547 10548 var toolbar2El = document.getElementById('user-info-toolbar2-' + _this.USER_ID); 10549 toolbar2El.innerHTML = _this.INFO.RESULT.Toolbar2; 10550 10551 if(BX.type.isArray(_this.INFO.RESULT.Scripts)) 10552 { 10553 for(var i = 0; i < _this.INFO.RESULT.Scripts.length; i++) 10554 { 10555 eval(_this.INFO.RESULT.Scripts[i]); 10556 } 10557 } 10558 10559 BX.onCustomEvent('onTooltipInsertData', [_this]); 10560 } 10561 } 10562 10563}; 10564BX.CTooltip.prototype.StartTrackMouse = function(ob) 10565{ 10566 var _this = this; 10567 10568 if(!this.tracking) 10569 { 10570 var elCoords = BX.pos(ob); 10571 this.RealAnchor = ob; 10572 this.CoordsLeft = elCoords.left + 0; 10573 this.CoordsTop = elCoords.top - 325; 10574 this.AnchorRight = elCoords.right; 10575 this.AnchorBottom = elCoords.bottom; 10576 10577 this.tracking = 1; 10578 BX.bind(document, "mousemove", _this.TrackMouse); 10579 10580 setTimeout(function() {_this.tickTimer()}, 500); 10581 } 10582}; 10583 10584BX.CTooltip.prototype.StopTrackMouse = function() 10585{ 10586 var _this = this; 10587 if(this.tracking) 10588 { 10589 BX.unbind(document, "mousemove", _this.TrackMouse); 10590 this.active = false; 10591 setTimeout(function() {_this.HideTooltip()}, 500); 10592 this.tracking = false; 10593 } 10594}; 10595 10596BX.CTooltip.prototype.tickTimer = function() 10597{ 10598 var _this = this; 10599 10600 if(this.tracking) 10601 { 10602 this.tracking++; 10603 if(this.active) 10604 { 10605 if( (this.active.time + 5/*0.5sec*/) <= this.tracking) 10606 this.ShowTooltip(); 10607 } 10608 setTimeout(function() {_this.tickTimer()}, 100); 10609 } 10610}; 10611 10612BX.CTooltip.prototype.HideTooltip = function() 10613{ 10614 if(!this.tracking) 10615 this.ShowOpacityEffect({func: this.SetInVisible, obj: this.DIV, arParams: []}, 1); 10616}; 10617 10618BX.CTooltip.prototype.ShowOpacityEffect = function(oCallback, bFade) 10619{ 10620 var steps = 3; 10621 var period = 1; 10622 var delta = 1 / steps; 10623 var i = 0, op, _this = this; 10624 10625 if(BX.browser.IsIE() && _this.DIV) 10626 _this.DIV.className = _this.classNameAnim; 10627 10628 var show = function() 10629 { 10630 i++; 10631 if (i > steps) 10632 { 10633 clearInterval(intId); 10634 if (!oCallback.arParams) 10635 oCallback.arParams = []; 10636 if (oCallback.func && oCallback.obj) 10637 oCallback.func.apply(oCallback.obj, oCallback.arParams); 10638 return; 10639 } 10640 op = bFade ? 1 - i * delta : i * delta; 10641 10642 if (_this.DIV != null) 10643 { 10644 try{ 10645 _this.DIV.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + (op * 100) + ')'; 10646 _this.DIV.style.opacity = op; 10647 _this.DIV.style.MozOpacity = op; 10648 _this.DIV.style.KhtmlOpacity = op; 10649 } 10650 catch(e){ 10651 } 10652 finally{ 10653 if (!bFade && i == 1) 10654 _this.DIV.style.display = 'block'; 10655 10656 if (bFade && i == steps && _this.DIV) 10657 _this.DIV.style.display = 'none'; 10658 10659 10660 if (BX.browser.IsIE() && i == 1 && bFade && _this.IFRAME) 10661 _this.IFRAME.style.display = 'none'; 10662 10663 10664 if (BX.browser.IsIE() && i == steps && _this.DIV) 10665 { 10666 if (!bFade) 10667 _this.IFRAME.style.display = 'block'; 10668 10669 _this.DIV.style.filter = _this.filterFixed; 10670 _this.DIV.className = _this.classNameFixed; 10671 _this.DIV.innerHTML = ''+_this.DIV.innerHTML; 10672 } 10673 10674 if(bFade) 10675 { 10676 BX.onCustomEvent('onTooltipHide', [_this]); 10677 } 10678 } 10679 } 10680 10681 }; 10682 var intId = setInterval(show, period); 10683 10684} 10685 10686})(window); 10687 10688 10689/* End */ 10690;
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.