1;(function(window) { 2 3if (BX.PopupWindowManager) 4 return; 5 6BX.PopupWindowManager = 7{ 8 _popups : [], 9 _currentPopup : null, 10 11 create : function(uniquePopupId, bindElement, params) 12 { 13 var index = -1; 14 if ( (index = this._getPopupIndex(uniquePopupId)) !== -1) 15 return this._popups[index]; 16 17 var popupWindow = new BX.PopupWindow(uniquePopupId, bindElement, params); 18 19 BX.addCustomEvent(popupWindow, "onPopupShow", BX.delegate(this.onPopupShow, this)); 20 BX.addCustomEvent(popupWindow, "onPopupClose", BX.delegate(this.onPopupClose, this)); 21 BX.addCustomEvent(popupWindow, "onPopupDestroy", BX.delegate(this.onPopupDestroy, this)); 22 23 this._popups.push(popupWindow); 24 25 return popupWindow; 26 }, 27 28 onPopupShow : function(popupWindow) 29 { 30 if (this._currentPopup !== null) 31 this._currentPopup.close(); 32 33 this._currentPopup = popupWindow; 34 }, 35 36 onPopupClose : function(popupWindow) 37 { 38 this._currentPopup = null; 39 }, 40 41 onPopupDestroy : function(popupWindow) 42 { 43 var index = -1; 44 if ( (index = this._getPopupIndex(popupWindow.uniquePopupId)) !== -1) 45 this._popups = BX.util.deleteFromArray(this._popups, index); 46 }, 47 48 getCurrentPopup : function() 49 { 50 return this._currentPopup; 51 }, 52 53 isPopupExists : function(uniquePopupId) 54 { 55 return this._getPopupIndex(uniquePopupId) !== -1 56 }, 57 58 _getPopupIndex : function(uniquePopupId) 59 { 60 var index = -1; 61 62 for (var i = 0; i < this._popups.length; i++) 63 if (this._popups[i].uniquePopupId == uniquePopupId) 64 return i; 65 66 return index; 67 } 68}; 69 70BX.PopupWindow = function(uniquePopupId, bindElement, params) 71{ 72 BX.onCustomEvent("onPopupWindowInit", [uniquePopupId, bindElement, params ]); 73 74 this.uniquePopupId = uniquePopupId; 75 this.params = params || {}; 76 this.params.zIndex = parseInt(this.params.zIndex); 77 this.params.zIndex = isNaN(this.params.zIndex) ? 0 : this.params.zIndex; 78 this.buttons = this.params.buttons && BX.type.isArray(this.params.buttons) ? this.params.buttons : []; 79 this.offsetTop = BX.PopupWindow.getOption("offsetTop"); 80 this.offsetLeft = BX.PopupWindow.getOption("offsetLeft"); 81 this.firstShow = false; 82 this.bordersWidth = 20; 83 this.bindElementPos = null; 84 this.closeIcon = null; 85 this.angle = null; 86 this.overlay = null; 87 this.titleBar = null; 88 this.bindOptions = typeof(this.params.bindOptions) == "object" ? this.params.bindOptions : {}; 89 this.isAutoHideBinded = false; 90 this.closeByEsc = !!this.params.closeByEsc; 91 this.isCloseByEscBinded = false; 92 93 if (this.params.parentPopup instanceof BX.PopupWindow) 94 { 95 this.parentPopup = this.params.parentPopup; 96 this.appendContainer = this.params.parentPopup.contentContainer; 97 98 this.params.offsetTop = (this.params.offsetTop? this.params.offsetTop: 0) - (BX.PopupWindow.fullscreenStatus? 0: this.parentPopup.popupContainer.offsetTop); 99 this.params.offsetLeft = (this.params.offsetLeft? this.params.offsetLeft: 0) - (BX.PopupWindow.fullscreenStatus? 0: this.parentPopup.popupContainer.offsetLeft); 100 } 101 else 102 { 103 this.parentPopup = null; 104 this.appendContainer = document.body; 105 } 106 107 this.dragged = false; 108 this.dragPageX = 0; 109 this.dragPageY = 0; 110 111 if (this.params.events) 112 { 113 for (var eventName in this.params.events) 114 BX.addCustomEvent(this, eventName, this.params.events[eventName]); 115 } 116 117 if (params.darkMode) 118 { 119 BX.addClass(this.popupContainer, 'popup-window-dark'); 120 } 121 122 var popupClassName = "popup-window"; 123 124 /*if (params.lightShadow) 125 popupClassName += " popup-window-light";*/ 126 127 if (params.contentColor && BX.type.isNotEmptyString(params.contentColor)) 128 popupClassName += " popup-window-content-" + params.contentColor; 129 130 if (params.contentNoPaddings) 131 popupClassName += " popup-window-content-no-paddings"; 132 133 if (params.noAllPaddings) 134 popupClassName += " popup-window-no-paddings"; 135 136 if (params.titleBar) 137 popupClassName += " popup-window-with-titlebar"; 138 139 if (params.className && BX.type.isNotEmptyString(params.className)) 140 popupClassName += " " + params.className; 141 142 if (params.darkMode) 143 popupClassName += ' popup-window-dark'; 144 145 this.popupContainer = document.createElement("DIV"); 146 var titleBarID = 'popup-window-titlebar-' + uniquePopupId; 147 148 149 if(params.titleBar) 150 { 151 this.titleBar = BX.create('div', { 152 props : { 153 className : 'popup-window-titlebar', 154 id : titleBarID 155 } 156 }); 157 } 158 159 if (params.closeIcon) 160 { 161 this.closeIcon = BX.create("a", { 162 props : { className: "popup-window-close-icon" + (params.titleBar ? " popup-window-titlebar-close-icon" : ""), href : ""}, 163 style : (typeof(params.closeIcon) == "object" ? params.closeIcon : {} ), 164 events : { click : BX.proxy(this._onCloseIconClick, this) } 165 }); 166 167 if (BX.browser.IsIE()) 168 BX.adjust(this.closeIcon, { attrs: { hidefocus: "true" } }); 169 } 170 171 this.contentContainer = BX.create('div',{ 172 props:{ 173 id: 'popup-window-content-' + uniquePopupId, 174 className: 'popup-window-content' 175 } 176 }); 177 178 179 180 BX.adjust(this.popupContainer, { 181 props : { 182 id : uniquePopupId, 183 className : popupClassName 184 }, 185 style : { 186 zIndex: this.getZindex(), 187 position: "absolute", 188 display: "none", 189 top: "0px", 190 left: "0px" 191 }, 192 children : [this.titleBar, this.contentContainer, this.closeIcon] 193 }); 194 195 196 this.appendContainer.appendChild(this.popupContainer); 197 198 this.buttonsContainer = null; 199 200 if (params.angle) 201 this.setAngle(params.angle); 202 203 if (params.overlay) 204 this.setOverlay(params.overlay); 205 206 this.setOffset(this.params); 207 this.setBindElement(bindElement); 208 this.setTitleBar(this.params.titleBar); 209 this.setContent(this.params.content); 210 this.setButtons(this.params.buttons); 211 212 if (this.params.bindOnResize !== false) 213 { 214 BX.bind(window, "resize", BX.proxy(this._onResizeWindow, this)); 215 } 216}; 217 218BX.PopupWindow.prototype.setContent = function(content) 219{ 220 if (!this.contentContainer || !content) 221 return; 222 223 if (BX.type.isElementNode(content)) 224 { 225 BX.cleanNode(this.contentContainer); 226 this.contentContainer.appendChild(content.parentNode ? content.parentNode.removeChild(content) : content ); 227 content.style.display = "block"; 228 } 229 else if (BX.type.isString(content)) 230 { 231 this.contentContainer.innerHTML = content; 232 } 233 else 234 this.contentContainer.innerHTML = " "; 235 236}; 237 238BX.PopupWindow.prototype.setButtons = function(buttons) 239{ 240 this.buttons = buttons && BX.type.isArray(buttons) ? buttons : []; 241 242 if (this.buttonsContainer) 243 BX.remove(this.buttonsContainer); 244 245 if (this.buttons.length > 0 && this.contentContainer) 246 { 247 var newButtons = []; 248 for (var i = 0; i < this.buttons.length; i++) 249 { 250 var button = this.buttons[i]; 251 if (button == null || !BX.is_subclass_of(button, BX.PopupWindowButton)) 252 continue; 253 254 button.popupWindow = this; 255 newButtons.push(button.render()); 256 } 257 258 this.buttonsContainer = this.contentContainer.parentNode.appendChild( 259 BX.create("div",{ 260 props : { className : "popup-window-buttons" }, 261 children : newButtons 262 }) 263 ); 264 } 265}; 266 267BX.PopupWindow.prototype.setBindElement = function(bindElement) 268{ 269 if (!bindElement || typeof(bindElement) != "object") 270 return; 271
272 if (BX.type.isDomNode(bindElement) || (BX.type.isNumber(bindElement.top) && BX.type.isNumber(bindElement.left))) 273 this.bindElement = bindElement; 274 else if (BX.type.isNumber(bindElement.clientX) && BX.type.isNumber(bindElement.clientY)) 275 { 276 BX.fixEventPageXY(bindElement); 277 this.bindElement = { left : bindElement.pageX, top : bindElement.pageY, bottom : bindElement.pageY }; 278 } 279}; 280 281BX.PopupWindow.prototype.getBindElementPos = function(bindElement) 282{ 283 if (BX.type.isDomNode(bindElement)) 284 { 285 return BX.pos(bindElement, false); 286 } 287 else if (bindElement && typeof(bindElement) == "object") 288 { 289 if (!BX.type.isNumber(bindElement.bottom)) 290 bindElement.bottom = bindElement.top; 291 return bindElement; 292 } 293 else 294 { 295 var windowSize = BX.GetWindowInnerSize(); 296 var windowScroll = BX.GetWindowScrollPos(); 297 var popupWidth = this.popupContainer.offsetWidth; 298 var popupHeight = this.popupContainer.offsetHeight; 299 300 this.bindOptions.forceTop = true; 301 302 return { 303 left : windowSize.innerWidth/2 - popupWidth/2 + windowScroll.scrollLeft, 304 top : windowSize.innerHeight/2 - popupHeight/2 + windowScroll.scrollTop, 305 bottom : windowSize.innerHeight/2 - popupHeight/2 + windowScroll.scrollTop, 306 307 //for optimisation purposes 308 windowSize : windowSize, 309 windowScroll : windowScroll, 310 popupWidth : popupWidth, 311 popupHeight : popupHeight 312 }; 313 } 314}; 315 316BX.PopupWindow.prototype.setAngle = function(params) 317{ 318 319 var className = "popup-window-angly"; 320 if (this.angle == null) 321 { 322 var position = this.bindOptions.position && this.bindOptions.position == "top" ? "bottom" : "top"; 323 var angleMinLeft = BX.PopupWindow.getOption(position == "top" ? "angleMinTop" : "angleMinBottom"); 324 var defaultOffset = BX.type.isNumber(params.offset) ? params.offset : 0; 325 326 var angleLeftOffset = BX.PopupWindow.getOption("angleLeftOffset", null); 327 if (defaultOffset > 0 && BX.type.isNumber(angleLeftOffset)) 328 defaultOffset += angleLeftOffset - BX.PopupWindow.defaultOptions.angleLeftOffset; 329 330 this.angle = { 331 element : BX.create("div", { props : { className: className + " " + className +"-" + position }}), 332 position : position, 333 offset : 0, 334 defaultOffset : Math.max(defaultOffset, angleMinLeft) 335 //Math.max(BX.type.isNumber(params.offset) ? params.offset : 0, angleMinLeft) 336 }; 337 this.popupContainer.appendChild(this.angle.element); 338 } 339 340 if (typeof(params) == "object" && params.position && BX.util.in_array(params.position, ["top", "right", "bottom", "left", "hide"])) 341 { 342 BX.removeClass(this.angle.element, className + "-" + this.angle.position); 343 BX.addClass(this.angle.element, className + "-" + params.position); 344 this.angle.position = params.position; 345 } 346 347 if (typeof(params) == "object" && BX.type.isNumber(params.offset)) 348 { 349 var offset = params.offset; 350 var minOffset, maxOffset; 351 if (this.angle.position == "top") 352 { 353 minOffset = BX.PopupWindow.getOption("angleMinTop"); 354 maxOffset = this.popupContainer.offsetWidth - BX.PopupWindow.getOption("angleMaxTop"); 355 maxOffset = maxOffset < minOffset ? Math.max(minOffset, offset) : maxOffset; 356 357 this.angle.offset = Math.min(Math.max(minOffset, offset), maxOffset); 358 this.angle.element.style.left = this.angle.offset + "px"; 359 this.angle.element.style.marginLeft = 0; 360 } 361 else if (this.angle.position == "bottom") 362 { 363 minOffset = BX.PopupWindow.getOption("angleMinBottom"); 364 maxOffset = this.popupContainer.offsetWidth - BX.PopupWindow.getOption("angleMaxBottom"); 365 maxOffset = maxOffset < minOffset ? Math.max(minOffset, offset) : maxOffset; 366 367 this.angle.offset = Math.min(Math.max(minOffset, offset), maxOffset); 368 this.angle.element.style.marginLeft = this.angle.offset + "px"; 369 this.angle.element.style.left = 0; 370 } 371 else if (this.angle.position == "right") 372 { 373 minOffset = BX.PopupWindow.getOption("angleMinRight"); 374 maxOffset = this.popupContainer.offsetHeight - BX.PopupWindow.getOption("angleMaxRight"); 375 maxOffset = maxOffset < minOffset ? Math.max(minOffset, offset) : maxOffset; 376 377 this.angle.offset = Math.min(Math.max(minOffset, offset), maxOffset); 378 this.angle.element.style.top = this.angle.offset + "px"; 379 } 380 else if (this.angle.position == "left") 381 { 382 minOffset = BX.PopupWindow.getOption("angleMinLeft"); 383 maxOffset = this.popupContainer.offsetHeight - BX.PopupWindow.getOption("angleMaxLeft"); 384 maxOffset = maxOffset < minOffset ? Math.max(minOffset, offset) : maxOffset; 385 386 this.angle.offset = Math.min(Math.max(minOffset, offset), maxOffset); 387 this.angle.element.style.top = this.angle.offset + "px"; 388 } 389 } 390}; 391 392BX.PopupWindow.prototype.isTopAngle = function() 393{ 394 return this.angle != null && this.angle.position == "top"; 395}; 396 397BX.PopupWindow.prototype.isBottomAngle = function() 398{ 399 return this.angle != null && this.angle.position == "bottom"; 400}; 401 402BX.PopupWindow.prototype.isTopOrBottomAngle = function() 403{ 404 return this.angle != null && BX.util.in_array(this.angle.position, ["to
404p", "bottom"]); 405}; 406 407BX.PopupWindow.prototype.getAngleHeight = function() 408{ 409 return (this.isTopOrBottomAngle() ? BX.PopupWindow.getOption("angleTopOffset") : 0); 410}; 411 412BX.PopupWindow.prototype.setOffset = function(params) 413{ 414 if (typeof(params) != "object") 415 return; 416 417 if (params.offsetLeft && BX.type.isNumber(params.offsetLeft)) 418 this.offsetLeft = params.offsetLeft + BX.PopupWindow.getOption("offsetLeft"); 419 420 if (params.offsetTop && BX.type.isNumber(params.offsetTop)) 421 this.offsetTop = params.offsetTop + BX.PopupWindow.getOption("offsetTop"); 422 423}; 424 425BX.PopupWindow.prototype.setTitleBar = function(params) 426{ 427 if (!this.titleBar) 428 return; 429 430 if (typeof(params) == "object" && BX.type.isDomNode(params.content)) 431 { 432 this.titleBar.innerHTML = ""; 433 this.titleBar.appendChild(params.content); 434 } 435 else if (typeof(params) == "string") 436 { 437 this.titleBar.innerHTML = ""; 438 this.titleBar.appendChild( 439 BX.create("span", { props : { className: "popup-window-titlebar-text" }, text : params }) 440 ); 441 } 442 443 if (this.params.draggable) 444 { 445 this.titleBar.style.cursor = "move"; 446 BX.bind(this.titleBar, "mousedown", BX.proxy(this._startDrag, this)); 447 } 448}; 449 450BX.PopupWindow.prototype.setClosingByEsc = function(enable) 451{ 452 enable = !!enable; 453 if (enable) 454 { 455 this.closeByEsc = true; 456 if (!this.isCloseByEscBinded) 457 { 458 BX.bind(document, "keyup", BX.proxy(this._onKeyUp, this)); 459 this.isCloseByEscBinded = true; 460 } 461 } 462 else 463 { 464 this.closeByEsc = false; 465 if (this.isCloseByEscBinded) 466 { 467 BX.unbind(document, "keyup", BX.proxy(this._onKeyUp, this)); 468 this.isCloseByEscBinded = false; 469 } 470 } 471}; 472 473BX.PopupWindow.prototype.setOverlay = function(params) 474{ 475 if (this.overlay == null) 476 { 477 this.overlay = { 478 element : BX.create("div", { props : { className: "popup-window-overlay", id : "popup-window-overlay-" + this.uniquePopupId } }) 479 }; 480 481 this.adjustOverlayZindex(); 482 this.resizeOverlay(); 483 484 this.appendContainer.appendChild(this.overlay.element); 485 } 486 487 if (params && params.opacity && BX.type.isNumber(params.opacity) && params.opacity >= 0 && params.opacity <= 100) 488 { 489 if (BX.browser.IsIE() && !BX.browser.IsIE9()) 490 this.overlay.element.style.filter = "alpha(opacity=" + params.opacity +")"; 491 else 492 { 493 this.overlay.element.style.filter = "none"; 494 this.overlay.element.style.opacity = parseFloat(params.opacity/100).toPrecision(3); 495 } 496 } 497 498 if (params && params.backgroundColor) 499 this.overlay.element.style.backgroundColor = params.backgroundColor; 500}; 501 502BX.PopupWindow.prototype.removeOverlay = function() 503{ 504 if (this.overlay != null && this.overlay.element != null) 505 BX.remove(this.overlay.element); 506 507 this.overlay = null; 508}; 509 510BX.PopupWindow.prototype.hideOverlay = function() 511{ 512 if (this.overlay != null && this.overlay.element != null) 513 this.overlay.element.style.display = "none"; 514}; 515 516BX.PopupWindow.prototype.showOverlay = function() 517{ 518 if (this.overlay != null && this.overlay.element != null) 519 this.overlay.element.style.display = "block"; 520}; 521 522BX.PopupWindow.prototype.resizeOverlay = function() 523{ 524 if (this.overlay != null && this.overlay.element != null) 525 { 526 if (this.parentPopup) 527 { 528 this.overlay.element.style.width = this.parentPopup.popupContainer.offsetWidth + "px"; 529 this.overlay.element.style.height = this.parentPopup.popupContainer.offsetHeight + "px"; 530 } 531 else 532 { 533 var windowSize = BX.GetWindowScrollSize(); 534 var scrollHeight = Math.max( 535 document.body.scrollHeight, document.documentElement.scrollHeight, 536 document.body.offsetHeight, document.documentElement.offsetHeight, 537 document.body.clientHeight, document.documentElement.clientHeight 538 ); 539 540 this.overlay.element.style.width = windowSize.scrollWidth + "px"; 541 this.overlay.element.style.height = scrollHeight + "px"; 542 } 543 } 544}; 545 546BX.PopupWindow.prototype.getZindex = function() 547{ 548 if (this.overlay != null) 549 return BX.PopupWindow.getOption("popupOverlayZindex") + this.params.zIndex; 550 else 551 return BX.PopupWindow.getOption("popupZindex") + this.params.zIndex; 552}; 553 554 555BX.PopupWindow.prototype.adjustOverlayZindex = function() 556{ 557 if (this.overlay != null && this.overlay.element != null) 558 { 559 this.overlay.element.style.zIndex = parseInt(this.popupContainer.style.zIndex) - 1; 560 } 561}; 562 563 564BX.PopupWindow.prototype.show = function() 565{ 566 if (!this.firstShow) 567 { 568 BX.onCustomEvent(this, "onPopupFirstShow", [this]); 569 this.firstShow = true; 570 } 571 BX.onCustomEvent(this, "onPopupShow", [this]); 572 573 this.showOverlay(); 574 this.popupContainer.style.display = "block"; 575 576 this.adjustPosition(); 577 578 BX.onCustomEvent(this, "onAfterPopupShow", [this]); 579 580 if (this.closeByEsc && !this.isCloseByEscBinded) 581 { 582 BX.bind(document, "keyup", BX.proxy(this._onKeyUp, this)); 583 this.isCloseByEscBinded = true; 584 } 585 586 if (this.params.autoHide && !this.isAutoHideBinded) 587 { 588 setTimeout( 589 BX.proxy(function() { 590 if (this.isShown()) 591 { 592 this.isAutoHideBinded = true; 593 BX.bind(this.popupContainer, "click", this.cancelBubble); 594 BX.bind(document, "click", BX.proxy(this.close, this)); 595 } 596 }, this), 100 597 ); 598 } 599}; 600 601BX.PopupWindow.prototype.isShown = function() 602{ 603 return this.popupContainer.style.display == "block"; 604}; 605 606BX.PopupWindow.prototype.cancelBubble = function(event) 607{ 608 if(!event) 609 event = window.event; 610 611 if (event.stopPropagation) 612 event.stopPropagation(); 613 else 614 event.cancelBubble = true; 615}; 616 617BX.PopupWindow.prototype.close = function(event) 618{ 619 if (!this.isShown()) 620 return; 621 622 if (event && !(BX.getEventButton(event)&BX.MSLEFT)) 623 return true; 624 625 BX.onCustomEvent(this, "onPopupClose", [this, event]); 626 627 this.hideOverlay(); 628 this.popupContainer.style.display = "none"; 629 630 if (this.isCloseByEscBinded) 631 { 632 BX.unbind(document, "keyup", BX.proxy(this._onKeyUp, this)); 633 this.isCloseByEscBinded = false;
634 } 635 636 setTimeout(BX.proxy(this._close, this), 0); 637}; 638 639BX.PopupWindow.prototype._close = function() 640{ 641 if (this.params.autoHide && this.isAutoHideBinded) 642 { 643 this.isAutoHideBinded = false; 644 BX.unbind(this.popupContainer, "click", this.cancelBubble); 645 BX.unbind(document, "click", BX.proxy(this.close, this)); 646 } 647}; 648 649BX.PopupWindow.prototype._onCloseIconClick = function(event) 650{ 651 event = event || window.event; 652 this.close(event); 653 BX.PreventDefault(event); 654}; 655 656BX.PopupWindow.prototype._onKeyUp = function(event) 657{ 658 event = event || window.event; 659 if (event.keyCode == 27) 660 { 661 _checkEscPressed(this.getZindex(), BX.proxy(this.close, this)); 662 } 663}; 664 665BX.PopupWindow.prototype.destroy = function() 666{ 667 BX.onCustomEvent(this, "onPopupDestroy", [this]); 668 BX.unbindAll(this); 669 BX.unbind(document, "keyup", BX.proxy(this._onKeyUp, this)); 670 BX.unbind(document, "click", BX.proxy(this.close, this)); 671 BX.unbind(document, "mousemove", BX.proxy(this._moveDrag, this)); 672 BX.unbind(document, "mouseup", BX.proxy(this._stopDrag, this)); 673 BX.unbind(window, "resize", BX.proxy(this._onResizeWindow, this)); 674 BX.remove(this.popupContainer); 675 this.removeOverlay(); 676}; 677 678BX.PopupWindow.prototype.enterFullScreen = function() 679{ 680 if (BX.PopupWindow.fullscreenStatus) 681 { 682 if (document.cancelFullScreen) 683 document.cancelFullScreen(); 684 else if (document.mozCancelFullScreen) 685 document.mozCancelFullScreen(); 686 else if (document.webkitCancelFullScreen) 687 document.webkitCancelFullScreen(); 688 } 689 else 690 { 691 if (BX.browser.IsChrome() || BX.browser.IsSafari()) 692 { 693 this.contentContainer.webkitRequestFullScreen(this.contentContainer.ALLOW_KEYBOARD_INPUT); 694 BX.bind(window, "webkitfullscreenchange", this.fullscreenBind = BX.proxy(this.eventFullScreen, this)); 695 } 696 else if (BX.browser.IsFirefox()) 697 { 698 this.contentContainer.mozRequestFullScreen(this.contentContainer.ALLOW_KEYBOARD_INPUT); 699 BX.bind(window, "mozfullscreenchange", this.fullscreenBind = BX.proxy(this.eventFullScreen, this)); 700 } 701 } 702}; 703 704BX.PopupWindow.prototype.eventFullScreen = function(event) 705{ 706 if (BX.PopupWindow.fullscreenStatus) 707 { 708 if (BX.browser.IsChrome() || BX.browser.IsSafari()) 709 BX.unbind(window, "webkitfullscreenchange", this.fullscreenBind); 710 else if (BX.browser.IsFirefox()) 711 BX.unbind(window, "mozfullscreenchange", this.fullscreenBind); 712 713 BX.removeClass(this.contentContainer, 'popup-window-fullscreen', [this.contentContainer]); 714 715 BX.PopupWindow.fullscreenStatus = false; 716 BX.onCustomEvent(this, "onPopupFullscreenLeave"); 717 this.adjustPosition(); 718 } 719 else 720 { 721 BX.addClass(this.contentContainer, 'popup-window-fullscreen'); 722 BX.PopupWindow.fullscreenStatus = true; 723 BX.onCustomEvent(this, "onPopupFullscreenEnter", [this.contentContainer]); 724 this.adjustPosition(); 725 726 } 727}; 728 729BX.PopupWindow.prototype.adjustPosition = function(bindOptions) 730{ 731 if (bindOptions && typeof(bindOptions) == "object") 732 this.bindOptions = bindOptions; 733 734 var bindElementPos = this.getBindElementPos(this.bindElement); 735 736 if (!this.bindOptions.forceBindPosition && this.bindElementPos != null && 737 bindElementPos.top == this.bindElementPos.top && 738 bindElementPos.left == this.bindElementPos.left 739 ) 740 { 741 return; 742 } 743 744 this.bindElementPos = bindElementPos; 745 746 var windowSize = bindElementPos.windowSize ? bindElementPos.windowSize : BX.GetWindowInnerSize(); 747 var windowScroll = bindElementPos.windowScroll ? bindElementPos.windowScroll : BX.GetWindowScrollPos(); 748 var popupWidth = bindElementPos.popupWidth ? bindElementPos.popupWidth : this.popupContainer.offsetWidth; 749 var popupHeight = bindElementPos.popupHeight ? bindElementPos.popupHeight : this.popupContainer.offsetHeight; 750 751 var angleTopOffset = BX.PopupWindow.getOption("angleTopOffset"); 752 753 var left = this.bindElementPos.left + this.offsetLeft - 754 (this.isTopOrBottomAngle() ? BX.PopupWindow.getOption("angleLeftOffset") : 0); 755 756 if ( !this.bindOptions.forceLeft && 757 (left + popupWidth + this.bordersWidth) >= (windowSize.innerWidth + windowScroll.scrollLeft) && 758 (windowSize.innerWidth + windowScroll.scrollLeft - popupWidth - this.bordersWidth) > 0) 759 { 760 var bindLeft = left; 761 left = windowSize.innerWidth + windowScroll.scrollLeft - popupWidth - this.bordersWidth; 762 if (this.isTopOrBottomAngle()) 763 { 764 this.setAngle({ offset : bindLeft - left + this.angle.defaultOffset}); 765 } 766 } 767 else if (this.isTopOrBottomAngle()) 768 { 769 this.setAngle({ offset : this.angle.defaultOffset + (left < 0 ? left : 0) }); 770 } 771 772 if (left < 0) 773 left = 0; 774 775 var top = 0; 776 777 if (this.bindOptions.position && this.bindOptions.position == "top") 778 { 779 780 top = this.bindElementPos.top - popupHeight - this.offsetTop - (this.isBottomAngle() ? angleTopOffset : 0); 781 if (top < 0 || (!this.bindOptions.forceTop && top < windowScroll.scrollTop)) 782 { 783 top = this.bindElementPos.bottom + this.offsetTop; 784 if (this.angle != null) 785 { 786 top += angleTopOffset; 787 this.setAngle({ position: "top"}); 788 } 789 } 790 else if (this.isTopAngle()) 791 { 792 top = top - angleTopOffset + BX.PopupWindow.getOption("positionTopXOffset"); 793 this.setAngle({ position: "bottom"}); 794 } 795 else 796 { 797 top += BX.PopupWindow.getOption("positionTopXOffset"); 798 } 799 } 800 else 801 { 802 803 top = this.bindElementPos.bottom + this.offsetTop + this.getAngleHeight(); 804 805 if ( !this.bindOptions.forceTop && 806 (top + popupHeight) >
806 (windowSize.innerHeight + windowScroll.scrollTop) && 807 (this.bindElementPos.top - popupHeight - this.getAngleHeight()) >= 0) //Can we place the PopupWindow above the bindElement? 808 { 809 //The PopupWindow doesn't place below the bindElement. We should place it above. 810 top = this.bindElementPos.top - popupHeight; 811 812 if (this.isTopOrBottomAngle()) 813 { 814 top -= angleTopOffset; 815 this.setAngle({ position: "bottom"}); 816 } 817 818 top += BX.PopupWindow.getOption("positionTopXOffset"); 819 820 } 821 else if (this.isBottomAngle()) 822 { 823 top += angleTopOffset; 824 this.setAngle({ position: "top"}); 825 } 826 } 827 828 if (!this.parentPopup && top < 0) 829 top = 0; 830 831 BX.adjust(this.popupContainer, { style: { 832 top: top + "px", 833 left: left + "px", 834 zIndex: this.getZindex() 835 }}); 836 837 this.adjustOverlayZindex(); 838}; 839 840BX.PopupWindow.prototype._onResizeWindow = function(event) 841{ 842 if (this.isShown()) 843 { 844 this.adjustPosition(); 845 if (this.overlay != null) 846 this.resizeOverlay(); 847 } 848}; 849 850BX.PopupWindow.prototype.move = function(offsetX, offsetY) 851{ 852 var left = parseInt(this.popupContainer.style.left) + offsetX; 853 var top = parseInt(this.popupContainer.style.top) + offsetY; 854 855 if (typeof(this.params.draggable) == "object" && this.params.draggable.restrict) 856 { 857 //Left side 858 if (!this.parentPopup && left < 0) 859 left = 0; 860 861 //Right side 862 var scrollSize = BX.GetWindowScrollSize(); 863 var floatWidth = this.popupContainer.offsetWidth; 864 var floatHeight = this.popupContainer.offsetHeight; 865 866 if (left > (scrollSize.scrollWidth - floatWidth)) 867 left = scrollSize.scrollWidth - floatWidth; 868 869 if (top > (scrollSize.scrollHeight - floatHeight)) 870 top = scrollSize.scrollHeight - floatHeight; 871 872 //Top side 873 if (!this.parentPopup && top < 0) 874 top = 0; 875 } 876 877 this.popupContainer.style.left = left + "px"; 878 this.popupContainer.style.top = top + "px"; 879}; 880 881BX.PopupWindow.prototype._startDrag = function(event) 882{ 883 event = event || window.event; 884 BX.fixEventPageXY(event); 885 886 this.dragPageX = event.pageX; 887 this.dragPageY = event.pageY; 888 this.dragged = false; 889 890 BX.bind(document, "mousemove", BX.proxy(this._moveDrag, this)); 891 BX.bind(document, "mouseup", BX.proxy(this._stopDrag, this)); 892 893 if (document.body.setCapture) 894 document.body.setCapture(); 895 896 //document.onmousedown = BX.False; 897 document.body.ondrag = BX.False; 898 document.body.onselectstart = BX.False; 899 document.body.style.cursor = "move"; 900 document.body.style.MozUserSelect = "none"; 901 this.popupContainer.style.MozUserSelect = "none"; 902 903 return BX.PreventDefault(event); 904}; 905 906BX.PopupWindow.prototype._moveDrag = function(event) 907{ 908 event = event || window.event; 909 BX.fixEventPageXY(event); 910 911 if(this.dragPageX == event.pageX && this.dragPageY == event.pageY) 912 return; 913 914 this.move((event.pageX - this.dragPageX), (event.pageY - this.dragPageY)); 915 this.dragPageX = event.pageX; 916 this.dragPageY = event.pageY; 917 918 if (!this.dragged) 919 { 920 BX.onCustomEvent(this, "onPopupDragStart"); 921 this.dragged = true; 922 } 923 924 BX.onCustomEvent(this, "onPopupDrag"); 925}; 926 927BX.PopupWindow.prototype._stopDrag = function(event) 928{ 929 if(document.body.releaseCapture) 930 document.body.releaseCapture(); 931 932 BX.unbind(document, "mousemove", BX.proxy(this._moveDrag, this)); 933 BX.unbind(document, "mouseup", BX.proxy(this._stopDrag, this)); 934 935 //document.onmousedown = null; 936 document.body.ondrag = null; 937 document.body.onselectstart = null; 938 document.body.style.cursor = ""; 939 document.body.style.MozUserSelect = ""; 940 this.popupContainer.style.MozUserSelect = ""; 941 942 BX.onCustomEvent(this, "onPopupDragEnd"); 943 this.dragged = false; 944 945 return BX.PreventDefault(event); 946}; 947 948BX.PopupWindow.options = {}; 949BX.PopupWindow.defaultOptions = { 950 951 angleLeftOffset : 40, /*left offset for popup about target */ 952 953 positionTopXOffset : -11, /* when popup position is 'top' offset distance between popup body and target node */ 954 955 angleTopOffset : 10, /* offset distance between popup body and target node if use angle, sum with positionTopXOffset */ 956 957 popupZindex : 1000, 958 popupOverlayZindex : 1100, 959 960 angleMinLeft : 10, 961 angleMaxLeft : 10, 962 963 angleMinRight : 10, 964 angleMaxRight : 10, 965 966 angleMinBottom : 23, /**/ 967 angleMaxBottom : 25, 968 969 angleMinTop : 23, 970 angleMaxTop : 25, 971 972 offsetLeft : 0, 973 offsetTop: 0 974}; 975BX.PopupWindow.setOptions = function(options) 976{ 977 if (!options || typeof(options) != "object") 978 return; 979 980 for (var option in options) 981 BX.PopupWindow.options[option] = options[option]; 982}; 983 984BX.PopupWindow.getOption = function(option, defaultValue) 985{ 986 if (typeof(BX.PopupWindow.options[option]) != "undefined") 987 return BX.PopupWindow.options[option]; 988 else if (typeof(defaultValue) != "undefined") 989 return defaultValue; 990 else 991 return BX.PopupWindow.defaultOptions[option]; 992}; 993 994 995/*========================================Buttons===========================================*/ 996 997BX.PopupWindowButton = function(params) 998{ 999 this.popupWindow = null; 1000 1001 this.params = params || {}; 1002 1003 this.text = this.params.text || ""; 1004 this.id = this.params.id || ""; 1005 this.className = this.params.className || ""; 1006 this.events = this.params.events || {}; 1007 1008 this.contextEvents = {}; 1009 for (var eventName in this.events) 1010 this.contextEvents[eventName] = BX.proxy(this.events[eventName], this); 1011 1012 this.buttonNode = BX.create( 1013 "span", 1014 { 1015 props : { className : "popup-window-button" + (this.className.length > 0 ? " " + this.className : ""), id : this.id }, 1016 events : this.contextEvents, 1017 text : this.text 1018 } 1019 ); 1020}; 1021 1022BX.PopupWindowButton.prototype.render = function() 1023{ 1024 return this.buttonNode; 1025}; 1026 1027BX.PopupWindowButton.prototype.setName = function(name) 1028{ 1029 this.text = name || ""; 1030 if (this.buttonNode) 1031 { 1032 BX.cleanNode(this.buttonNode); 1033 BX.adjust(this.buttonNode, { text : this.text} ); 1034 } 1035}; 1036 1037BX.PopupWindowButton.prototype.setClassName = function(className) 1038{ 1039 if (this.buttonNode) 1040 { 1041 if (BX.type.isString(this.className) && (this.className != '')) 1042 BX.removeClass(this.buttonNode, this.className); 1043 1044 BX.addClass(this.buttonNode, className) 1045 } 1046 1047 this.className = className; 1048}; 1049 1050BX.PopupWindowButtonLink = function(params) 1051{ 1052 BX.PopupWindowButtonLink.superclass.constructor.apply(this, arguments); 1053 1054 this.buttonNode = BX.create( 1055 "span", 1056 { 1057 props : { className : "popup-window-button popup-window-button-link" + (this.className.length > 0 ? " " + this.className : ""), id : this.id }, 1058 text : this.text, 1059 events : this.contextEvents 1060 } 1061 ); 1062 1063}; 1064 1065BX.extend(BX.PopupWindowButtonLink, BX.PopupWindowButton); 1066 1067BX.PopupMenu = { 1068 1069 Data : {}, 1070 currentItem : null, 1071 1072 show : function(id, bindElement, menuItems, params) 1073 { 1074 if (this.currentItem !== null) 1075 { 1076 this.currentItem.popupWindow.close(); 1077 } 1078 1079 this.currentItem = this.create(id, bindElement, menuItems, params); 1080 this.currentItem.popupWindow.show(); 1081 }, 1082 1083 create : function(id, bindElement, menuItems, params) 1084 { 1085 if (!this.Data[id]) 1086 { 1087 this.Data[id] = new BX.PopupMenuWindow(id, bindElement, menuItems, params); 1088 } 1089 1090 return this.Data[id]; 1091 }, 1092 1093 getCurrentMenu : function() 1094 { 1095 return this.currentItem; 1096 }, 1097 1098 getMenuById : function(id) 1099 { 1100 return this.Data[id] ? this.Data[id] : null; 1101 }, 1102 1103 destroy : function(id) 1104 { 1105 var menu = this.getMenuById(id); 1106 if (menu) 1107 { 1108 if (this.currentItem == menu) 1109 { 1110 this.currentItem = null; 1111 } 1112 menu.popupWindow.destroy(); 1113 delete this.Data[id]; 1114 } 1115 } 1116}; 1117 1118BX.PopupMenuWindow = function(id, bindElement, menuItems, params) 1119{ 1120 this.id = id; 1121 this.bindElement = bindElement; 1122 this.menuItems = []; 1123 this.itemsContainer = null; 1124 1125 if (menuItems && BX.type.isArray(menuItems)) 1126 { 1127 for (var i = 0; i < menuItems.length; i++) 1128 { 1129 this.__addMenuItem(menuItems[i], null); 1130 } 1131 } 1132 1133 this.params = params && typeof(params) == "object" ? params : {}; 1134 this.popupWindow = this.__createPopup(); 1135}; 1136 1137BX.PopupMenuWindow.prototype.__createItem = function(item) 1138{ 1139 if (item.delimiter) 1140 { 1141 item.layout.item = BX.create("span", { props: { className: "popup-window-delimiter" }}); 1142 } 1143 else 1144 { 1145 item.layout.item = BX.create(!!item.href ? "a" : "span", { 1146 props : { className: "menu-popup-item" + (BX.type.isNotEmptyString(item.className) ? " " + item.className : " menu-popup-no-icon")}, 1147 attrs : { title : item.title ? item.title : "", onclick: item.onclick && BX.type.isString(item.onclick) ? item.onclick : "", target : item.target ? item.target : "" }, 1148 events : item.onclick && BX.type.isFunction(item.onclick) ? { click : BX.proxy(this.onItemClick, {obj : this, item : item }) } : null, 1149 children : [ 1150 BX.create("span", { props : { className: "menu-popup-item-icon"} }), 1151 (item.layout.text = BX.create("span", { props : { className: "menu-popup-item-text"}, html : item.text })) 1152 ] 1153 }); 1154 1155 if (item.href) 1156 item.layout.item.href = item.href; 1157 } 1158 1159 return item; 1160}; 1161 1162BX.PopupMenuWindow.prototype.__createPopup = function() 1163{ 1164 var domItems = []; 1165 for (var i = 0; i < this.menuItems.length; i++) 1166 { 1167 this.__createItem(this.menuItems[i]); 1168 if (this.menuItems[i].layout.hr != null) 1169 { 1170 domItems.push(this.menuItems[i].layout.hr); 1171 } 1172 1173 domItems.push(this.menuItems[i].layout.item); 1174 } 1175 1176 var popupWindow = new BX.PopupWindow("menu-popup-" + this.id, this.bindElement, { 1177 closeByEsc : typeof(this.params.closeByEsc) != "undefined" ? this.params.closeByEsc: false, 1178 bindOptions : typeof(this.params.bindOptions) == "object" ? this.params.bindOptions : {}, 1179 angle : typeof(this.params.angle) != "undefined" ? this.params.angle : false, 1180 zIndex : this.params.zIndex ? this.params.zIndex : 0, 1181 overlay: typeof(this.params.overlay) == "object" ? this.params.overlay : null, 1182 autoHide : typeof(this.params.autoHide) != "undefined" ? this.params.autoHide : true, 1183 offsetTop : this.params.offsetTop ? this.params.offsetTop : 1, 1184 offsetLeft : this.params.offsetLeft ? this.params.offsetLeft : 0, 1185 1186 noAllPaddings : true, 1187 1188 content : BX.create("div", { props : { className : "menu-popup" }, children: [ 1189 (this.itemsContainer = BX.create("div", { props : { className : "menu-popup-items" }, children: domItems})) 1190 ]}) 1191 }); 1192 1193 if (this.params && this.params.events) 1194 { 1195 for (var eventName in this.params.events) 1196 { 1197 if (this.params.events.hasOwnProperty(eventName)) 1198 { 1199 BX.addCustomEvent(popupWindow, eventName, this.params.events[eventName]); 1200 } 1201 } 1202 } 1203 1204 return popupWindow; 1205}; 1206 1207BX.PopupMenuWindow.prototype.onItemClick = function(event) 1208{ 1209 event = event || window.event; 1210 this.item.onclick.call(this.obj, event, this.item); 1211}; 1212 1213BX.PopupMenuWindow.prototype.addMenuItem = function(menuItem, refItemId) 1214{ 1215 var position = this.__addMenuItem(menuItem, refItemId); 1216 if (position < 0) 1217 { 1218 return false;
1219 } 1220 1221 this.__createItem(menuItem); 1222 var refItem = this.getMenuItem(refItemId); 1223 if (refItem != null) 1224 { 1225 if (refItem.layout.hr == null) 1226 { 1227 refItem.layout.hr = BX.create("div", { props : { className : "popup-window-hr" }, children : [ BX.create("i", {}) ]}); 1228 this.itemsContainer.insertBefore(refItem.layout.hr, refItem.layout.item); 1229 } 1230 1231 if (menuItem.layout.hr != null) 1232 { 1233 this.itemsContainer.insertBefore(menuItem.layout.hr, refItem.layout.hr); 1234 } 1235 1236 this.itemsContainer.insertBefore(menuItem.layout.item, refItem.layout.hr); 1237 } 1238 else 1239 { 1240 if (menuItem.layout.hr != null) 1241 { 1242 this.itemsContainer.appendChild(menuItem.layout.hr); 1243 } 1244 1245 this.itemsContainer.appendChild(menuItem.layout.item); 1246 } 1247 1248 return true; 1249}; 1250 1251BX.PopupMenuWindow.prototype.__addMenuItem = function(menuItem, refItemId) 1252{ 1253 if (!menuItem || (!menuItem.delimiter && !BX.type.isNotEmptyString(menuItem.text)) || (menuItem.id && this.getMenuItem(menuItem.id) != null)) 1254 { 1255 return -1; 1256 } 1257 1258 menuItem.layout = { item : null, text : null, hr : null }; 1259 1260 var position = this.getMenuItemPosition(refItemId); 1261 if (position >= 0) 1262 { 1263 this.menuItems = BX.util.insertIntoArray(this.menuItems, position, menuItem); 1264 } 1265 else 1266 { 1267 this.menuItems.push(menuItem); 1268 position = this.menuItems.length - 1; 1269 } 1270 1271 return position; 1272}; 1273 1274BX.PopupMenuWindow.prototype.removeMenuItem = function(itemId) 1275{ 1276 var item = this.getMenuItem(itemId); 1277 if (!item) 1278 { 1279 return; 1280 } 1281 1282 for (var position = 0; position < this.menuItems.length; position++) 1283 { 1284 if (this.menuItems[position] == item) 1285 { 1286 this.menuItems = BX.util.deleteFromArray(this.menuItems, position); 1287 break; 1288 } 1289 } 1290 1291 if (position == 0) 1292 { 1293 if (this.menuItems[0]) 1294 { 1295 this.menuItems[0].layout.hr.parentNode.removeChild(this.menuItems[0].layout.hr); 1296 this.menuItems[0].layout.hr = null; 1297 } 1298 } 1299 else 1300 { 1301 item.layout.hr.parentNode.removeChild(item.layout.hr); 1302 } 1303 1304 item.layout.item.parentNode.removeChild(item.layout.item); 1305 item.layout.item = null; 1306}; 1307 1308BX.PopupMenuWindow.prototype.getMenuItem = function(itemId) 1309{ 1310 for (var i = 0; i < this.menuItems.length; i++) 1311 { 1312 if (this.menuItems[i].id && this.menuItems[i].id == itemId) 1313 { 1314 return this.menuItems[i]; 1315 } 1316 } 1317 1318 return null; 1319}; 1320 1321BX.PopupMenuWindow.prototype.getMenuItemPosition = function(itemId) 1322{ 1323 if (itemId) 1324 { 1325 for (var i = 0; i < this.menuItems.length; i++) 1326 { 1327 if (this.menuItems[i].id && this.menuItems[i].id == itemId) 1328 { 1329 return i; 1330 } 1331 } 1332 } 1333 1334 return -1; 1335}; 1336 1337// TODO: copypaste/update/enhance CSS and images from calendar to MAIN CORE 1338// this.values = [{ID: 1, NAME : '111', DESCRIPTION: '111', URL: 'href://...'}] 1339 1340window.BXInputPopup = function(params) 1341{ 1342 this.id = params.id || 'bx-inp-popup-' + Math.round(Math.random() * 1000000); 1343 this.handler = params.handler || false; 1344 this.values = params.values || false; 1345 this.pInput = params.input; 1346 this.bValues = !!this.values; 1347 this.defaultValue = params.defaultValue || ''; 1348 this.openTitle = params.openTitle || ''; 1349 this.className = params.className || ''; 1350 this.noMRclassName = params.noMRclassName || 'ec-no-rm'; 1351 this.emptyClassName = params.noMRclassName || 'ec-label'; 1352 1353 var _this = this; 1354 this.curInd = false; 1355 1356 if (this.bValues) 1357 { 1358 this.pInput.onfocus = this.pInput.onclick = function(e) 1359 { 1360 if (this.value == _this.defaultValue) 1361 { 1362 this.value = ''; 1363 this.className = _this.className; 1364 } 1365 _this.ShowPopup(); 1366 return BX.PreventDefault(e); 1367 }; 1368 this.pInput.onblur = function() 1369 { 1370 if (_this.bShowed) 1371 setTimeout(function(){_this.ClosePopup(true);}, 200); 1372 _this.OnChange(); 1373 }; 1374 } 1375 else 1376 { 1377 this.pInput.className = this.noMRclassName; 1378 this.pInput.onblur = BX.proxy(this.OnChange, this); 1379 } 1380} 1381 1382BXInputPopup.prototype = { 1383ShowPopup: function() 1384{ 1385 if (this.bShowed) 1386 return; 1387 1388 var _this = this; 1389 if (!this.oPopup) 1390 { 1391 var 1392 pRow, 1393 pWnd = BX.create("DIV", {props:{className: "bxecpl-loc-popup " + this.className}}); 1394 1395 for (var i = 0, l = this.values.length; i < l; i++) 1396 { 1397 pRow = pWnd.appendChild(BX.create("DIV", { 1398 props: {id: 'bxecmr_' + i}, 1399 text: this.values[i].NAME, 1400 events: { 1401 mouseover: function(){BX.addClass(this, 'bxecplloc-over');}, 1402 mouseout: function(){BX.removeClass(this, 'bxecplloc-over');}, 1403 click: function() 1404 { 1405 var ind = this.id.substr('bxecmr_'.length); 1406 _this.pInput.value = _this.values[ind].NAME; 1407 _this.curInd = ind; 1408 _this.OnChange(); 1409 _this.ClosePopup(true); 1410 } 1411 } 1412 })); 1413 1414 if (this.values[i].DESCRIPTION) 1415 pRow.title = this.values[i].DESCRIPTION; 1416 if (this.values[i].CLASS_NAME) 1417 BX.addClass(pRow, this.values[i].CLASS_NAME); 1418 1419 if (this.values[i].URL) 1420 pRow.appendChild(BX.create('A', {props: {href: this.values[i].URL, className: 'bxecplloc-view', target: '_blank', title: this.openTitle}})); 1421 } 1422 1423 this.oPopup = new BX.PopupWindow(this.id, this.pInput, { 1424 autoHide : true, 1425 offsetTop : 1, 1426 offsetLeft : 0, 1427 lightShadow : true, 1428 closeByEsc : true, 1429 content : pWnd 1430 }); 1431 1432 BX.addCustomEvent(this.oPopup, 'onPopupClose', BX.proxy(this.ClosePopup, this)); 1433 } 1434 1435 this.oPopup.show(); 1436 this.pInput.select(); 1437 1438 this.bShowed = true;
1439 BX.onCustomEvent(this, 'onInputPopupShow', [this]); 1440}, 1441 1442ClosePopup: function(bClosePopup) 1443{ 1444 this.bShowed = false; 1445 1446 if (this.pInput.value == '') 1447 this.OnChange(); 1448 1449 BX.onCustomEvent(this, 'onInputPopupClose', [this]); 1450 1451 if (bClosePopup === true) 1452 this.oPopup.close(); 1453}, 1454 1455OnChange: function() 1456{ 1457 var val = this.pInput.value; 1458 if (this.bValues) 1459 { 1460 if (this.pInput.value == '' || this.pInput.value == this.defaultValue) 1461 { 1462 this.pInput.value = this.defaultValue; 1463 this.pInput.className = this.emptyClassName; 1464 val = ''; 1465 } 1466 else 1467 { 1468 this.pInput.className = ''; 1469 } 1470 } 1471 1472 if (isNaN(parseInt(this.curInd)) || this.curInd !==false && val != this.values[this.curInd].NAME) 1473 this.curInd = false; 1474 else 1475 this.curInd = parseInt(this.curInd); 1476 1477 BX.onCustomEvent(this, 'onInputPopupChanged', [this, this.curInd, val]); 1478 if (this.handler && typeof this.handler == 'function') 1479 this.handler({ind: this.curInd, value: val}); 1480}, 1481 1482Set: function(ind, val, bOnChange) 1483{ 1484 this.curInd = ind; 1485 if (this.curInd !== false) 1486 this.pInput.value = this.values[this.curInd].NAME; 1487 else 1488 this.pInput.value = val; 1489 1490 if (bOnChange !== false) 1491 this.OnChange(); 1492}, 1493 1494Get: function(ind) 1495{ 1496 var 1497 id = false; 1498 if (typeof ind == 'undefined') 1499 ind = this.curInd; 1500 1501 if (ind !== false && this.values[ind]) 1502 id = this.values[ind].ID; 1503 return id; 1504}, 1505 1506GetIndex: function(id) 1507{ 1508 for (var i = 0, l = this.values.length; i < l; i++) 1509 if (this.values[i].ID == id) 1510 return i; 1511 return false; 1512}, 1513 1514Deactivate: function(bDeactivate) 1515{ 1516 if (this.pInput.value == '' || this.pInput.value == this.defaultValue) 1517 { 1518 if (bDeactivate) 1519 { 1520 this.pInput.value = ''; 1521 this.pInput.className = this.noMRclassName; 1522 } 1523 else if (this.oEC.bUseMR) 1524 { 1525 this.pInput.value = this.defaultValue; 1526 this.pInput.className = this.emptyClassName; 1527 } 1528 } 1529 this.pInput.disabled = bDeactivate; 1530} 1531}; 1532 1533/************** utility *************/ 1534 1535var _escCallbackIndex = -1, 1536 _escCallback = null; 1537 1538function _checkEscPressed(zIndex, callback) 1539{ 1540 if(zIndex === false) 1541 { 1542 if(_escCallback && _escCallback.length > 0) 1543 { 1544 for(var i=0;i<_escCallback.length; i++) 1545 { 1546 _escCallback[i](); 1547 } 1548 1549 _escCallback = null; 1550 _escCallbackIndex = -1; 1551 } 1552 } 1553 else 1554 { 1555 if(_escCallback === null) 1556 { 1557 _escCallback = []; 1558 _escCallbackIndex = -1; 1559 BX.defer(_checkEscPressed)(false); 1560 } 1561 1562 if(zIndex > _escCallbackIndex) 1563 { 1564 _escCallbackIndex = zIndex; 1565 _escCallback = [callback]; 1566 } 1567 else if(zIndex == _escCallbackIndex) 1568 { 1569 _escCallback.push(callback) 1570 } 1571 } 1572} 1573 1574 1575})(window); 1576
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.