1function _DebugTrace(message) 2{ 3 var traceConsole = $('TraceConsole'); 4 if (traceConsole != null) 5 { 6 var debugPanel = getParent(getParent(traceConsole)); 7 if (debugPanel.style.display == 'none') 8 debugPanel.style.display = 'block'; 9 Sys.Debug.trace(message); 10 } 11} 12function _DebugTraceDump(control, message) 13{ 14 var traceConsole = $('TraceConsole'); 15 if (traceConsole != null) 16 { 17 var debugPanel = getParent(getParent(traceConsole)); 18 if (debugPanel.style.display == 'none') 19 debugPanel.style.display = 'block'; 20 Sys.Debug.traceDump(control, message); 21 } 22} 23function _DebugFail(message) 24{ 25 Sys.Debug.fail(message); 26} 27 28//########################################################### 29// Header functions 30//############################################################# 31 32function __Document_Head_Init(noCookiesUrl, checkBrowserMessage, disableContextMenu) 33{ 34 if (!__CookiesEnabled()) 35 window.location.href = noCookiesUrl; 36 37 eraseCookie("Asi.Web.Browser.CookiesEnabled"); 38 39 if (checkBrowserMessage != 0) 40 { alert(checkBrowserMessage); } 41 42 __CloseDisposableWindow(); 43 44 // Only disable the context menu in IE7 (basically imis desktop) 45 if (disableContextMenu) { 46 if (typeof jQuery == "undefined") { // if no jQuery, disable anyway 47 document.oncontextmenu = __DisableContextMenu; 48 } 49 else { 50 if (browser.isIE && browser.version == 7) 51 document.oncontextmenu = __DisableContextMenu; 52 } 53 } 54} 55 56function __CloseDisposableWindow() 57{ 58 if (__GetCookieValue("Asi.Web.Browser.DisposableWindow.Loaded") == "true") 59 { 60 var disposableWindow = window.open("", "Asi_Web_Browser_DisposableWindow", "width=1,height=1,top=9999,left=9999,resizable=no,scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no"); 61 disposableWindow.close(); 62 document.cookie = "Asi.Web.Browser.DisposableWindow.Loaded=false;path=/"; 63 } 64} 65 66function __CookiesEnabled() 67{ 68 if (__GetCookieValue("Asi.Web.Browser.CookiesEnabled") != "true") 69 { 70 document.cookie = "Asi.Web.Browser.CookiesEnabled=true;path=/"; 71 if (__GetCookieValue("Asi.Web.Browser.CookiesEnabled") != "true") 72 return false; 73 } 74 return true; 75} 76 77function __GetCookieValue(cookieName) 78{ 79 if (document.cookie != null) 80 { 81 var startPos = document.cookie.indexOf(cookieName + "="); 82 if (startPos < 0) 83 return null; 84 startPos += cookieName.length + 1; 85 var endPos = document.cookie.indexOf(";", startPos); 86 if (endPos == -1) 87 endPos = document.cookie.length; 88 return unescape(document.cookie.substring(startPos, endPos)); 89 } 90 return null; 91} 92 93function __WindowOnLoad() 94{ 95 var ic = gWindowOnLoad.length; 96 for (var i = 1; i < ic; i++) 97 { 98 if (gWindowOnLoad[i] && gWindowOnLoad[i] != __WindowOnLoad) 99 { 100 gWindowOnLoad[i](); 101 } 102 } 103} 104function SetDocumentTitle(title) 105{ 106 gDocumentTitle = title; 107} 108 109function CheckCommit(customMessage) 110{ 111 if (gPostBackFormObject != null) 112 { 113 if (__NeedCommit()) 114 { 115 var confirmMessage = customMessage; 116 if (confirmMessage == null || confirmMessage == "") 117 { 118 confirmMessage = gDefaultConfirmMessage; 119 } 120 return confirm(confirmMessage); 121 } 122 } 123 return true; 124} 125 126function __DisableContextMenu(sender, args) { 127 var e = sender ? sender.target.tagName : event.srcElement.tagName; 128 return (e && (e.toUpperCase() == "INPUT" || e.toUpperCase() == "TEXTAREA")); 129} 130 131// ########################################################### 132// Collection of Utility JavaScript functions compiled by ASI 133// ########################################################### 134 135// 136// Client-side version of Asi.Aid.CollapsedSimpleName(). Strips name of whitespace and special characters, 137// and does camel casing. This method must be kept in sync with the server version. 138// 139function CollapsedSimpleName(value) { 140 var space = ' '; 141 var underscore = '_'; 142 143 if (value == null) return null; 144 value = value.replace(/^\s+|\s+$/g, ''); // trims the value 145 if (value.length == 0) return ''; 146 147 var sb = ''; 148 var lastChar = space; 149 for (var x = 0, xc = value.length; x < xc; x++) { 150 if (IsLetterOrDigit(value.charAt(x)) || value.charAt(x) == underscore) { 151 if (IsLetterOrDigit(lastChar)) 152 sb = sb + value.charAt(x); 153 else { 154 // If the first character is a digit, make valid by adding a character first 155 if (sb.length == 0 && IsDigit(value.charAt(x))) 156 sb = sb + 'N'; 157 sb = sb + value.charAt(x).toUpperCase(); 158 } 159 } 160 lastChar = value.charAt(x); 161 } 162 return sb; 163} 164 165function IsLetterOrDigit(value) { 166 var regEx = /[a-zA-Z0-9]/; 167 if (value.match(regEx) == null) 168 return false; 169 return true; 170} 171 172function IsDigit(value) { 173 var regEx = /[0-9]/; 174 if (value.match(regEx) == null) 175 return false; 176 return true; 177} 178 179function IsEmail(value) { 180 // regex taken from http://www.regular-expressions.info/email.html 181 var regEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i; 182 if (value.match(regEx) == null) 183 return false; 184 return true; 185} 186 187// 188// Adds event to window.onload without overwriting currently assigned onload functions. 189// 190function addLoadEvent(loadFunc) 191{ 192 if (loadFunc) 193 { 194 var oldonload = window.onload; 195 if (typeof window.onload != 'function') 196 { 197 window.onload = loadFunc; 198 } 199 else 200 { 201 window.onload = function() 202 { 203 if (typeof oldonload == 'function') oldonload(); 204 loadFunc(); 205 } 206 } 207 } 208} 209 210// Add RadControl related load events 211// 212function addAjaxLoadEvent(loadFunc) 213{ 214 function f() { loadFunc(); Sys.Application.remove_load(f); }; 215 Sys.Application.add_load(f); 216} 217 218// 219// Adds event to window.onresize without overwriting currently assigned onresize functions. 220// 221function addResizeEvent(resizeFunc, resizeControl) 222{ 223 if (resizeControl == null) 224 resizeControl = window; 225 226 $addHandler(resizeControl, 'resize', resizeFunc); 227 228 // var oldonresize = resizeControl.onresize; 229 // if (typeof resizeWin.onresize != 'function'){ 230 //resizeControl.onresize = resizeFunc; 231 // } else { 232 // resizeControl.onresize = function(){ 233 // oldonresize(); 234 // resizeFunc(); 235 // } 236 // } 237} 238var resizeFunctionNames = new Array(); 239// 240// Adds a function name to a collection of function names that should be executed 241// when the content is resized (window resize, or page content resized). 242// 243function addContentResizeEvent(resizeFunctionName) 244{ 245 resizeFunctionNames.push(resizeFunctionName); 246} 247// 248// Call this function after the main content area has been resized. 249// 250function contentResized(contentWidth, contentHeight) 251{ 252 for (var i = 0; i < resizeFunctionNames.length; i++) 253 { 254 var evalText = resizeFunctionNames[i] + '(' + contentWidth + ',' + contentHeight + ')'; 255 eval(evalText); 256 } 257} 258// 259// nextObject and previousObject perform exactly the same function as nextSibling and previousSibling, 260// but will only return the next/previous HTML element, ignoring text nodes altogether
261// 262function getNextObject(n) 263{ 264 do n = n.nextSibling; 265 while (n && n.nodeType != 1); 266 return n; 267} 268function getPreviousObject(p) 269{ 270 do p = p.previousSibling; 271 while (p && p.nodeType != 1); 272 return p; 273} 274 275function cancelSubmit() 276{ 277 return CancelEvent(); 278} 279// 280// Browser-independent way of cancelling the last event. 281// Example: 282// <button onclick="if (!confirm('Do Something?')) return CancelEvent(); else doSomething();" /> 283// 284function CancelEvent(e) 285{ 286 if (!e) 287 { 288 e = window.event; 289 } 290 291 if (e != null) 292 e.returnValue = false; 293 return false; 294} 295// I can never remember the casing for this function, so this makes it not matter. 296function cancelEvent() 297{ 298 return CancelEvent(); 299} 300// 301// Browser-independent function for cancelling event 302// propagation (event bubbling). 303// 304function CancelEventPropagation(e) 305{ 306 if (!e) 307 { 308 e = window.event; 309 } 310 e.cancelBubble = true; 311 312 if (e.stopPropagation) 313 e.stopPropagation(); 314} 315// 316// Browser-independent method for getting the last event source object 317// 318function eventSource(e) 319{ 320 if (window.event) 321 return window.event.srcElement; 322 323 return e.target; 324} 325// 326// Get the last key entered by user 327// 328function KeyStroke(e) 329{ 330 if (window.event) 331 { 332 return e.keyCode; 333 } 334 else 335 { 336 return e.which; 337 } 338} 339// 340// Convenience function for extracting a number from a given variable (presumably of 341// some other type, like string) 342// 343function ExtractNumber(value) 344{ 345 var n = parseInt(value); 346 return n == null || isNaN(n) ? 0 : n; 347} 348// 349// Convenience function for saving lots of typing, instead of typing 350// document.getElementById() all the time. 351// 352function $(id) 353{ 354 return document.getElementById(id); 355} 356// 357// Given any object within a form, this function will find the containing form and submit it 358// 359function submitForm(object) 360{ 361 if (object && object != null) 362 form = findAncestor(object, "FORM"); 363 else 364 form = window.template; 365 366 if (form != null) 367 form.submit(); 368} 369// Given an element, return its parent in a way that both IE6 and actual standards-compliant browsers both support. 370function getParent(element) 371{ 372 return element.parentNode || element.parentElement; 373} 374if (!window.Node) var Node = 375 { 376 ELEMENT_NODE: 1, 377 ATTRIBUTE_NODE: 2, 378 TEXT_NODE: 3, 379 CDATA_SECTION_NODE: 4, 380 ENTITY_REFERENCE_NODE: 5, 381 ENTITY_NODE: 6, 382 PROCESSING_INSTRUCTION_NODE: 7, 383 COMMENT_NODE: 8, 384 DOCUMENT_NODE: 9, 385 DOCUMENT_TYPE_NODE: 10, 386 DOCUMENT_FRAGMENT_NODE: 11, 387 NOTATION_NODE: 12 388 } 389// 390// Given an object and a type of ancestor to find, locates the first ancestor of the given object that is of the specified type. 391// If none is found, null is returned 392// 393function findAncestor(object, type) 394{ 395 oParent = getParent(object); 396 while (oParent != null) 397 { 398 if (oParent.tagName.toLowerCase() == type.toLowerCase()) 399 return oParent; 400 oParent = getParent(oParent); 401 } 402 return null; 403} 404function trim(str, chars) 405{ 406 return ltrim(rtrim(str, chars), chars); 407} 408function ltrim(str, chars) 409{ 410 chars = chars || "\\s"; 411 return str.replace(new RegExp("^[" + chars + "]+", "g"), ""); 412} 413function rtrim(str, chars) 414{ 415 chars = chars || "\\s"; 416 return str.replace(new RegExp("[" + chars + "]+$", "g"), ""); 417} // 418// Browser-independent function for returning the height of the current page. 419// 420function livePageHeight() 421{ 422 if (window.innerHeight && window.scrollMaxY && BrowserDetect.version < 3) // Firefox 2 423 { 424 return window.innerHeight + window.scrollMaxY; 425 426 } 427 else // works in Explorer 6, 7 Strict, Mozilla, Safari and FireFox 3 428 { 429 return document.body.offsetHeight + document.body.offsetTop; 430 } 431 432 return null; 433 // if (window.innerHeight != null) 434 // return window.innerHeight; 435 // 436 // if (document.body.clientHeight != null) 437 // return document.body.clientHeight; 438 // 439 // return null; 440} 441// 442// Browser-independent function for returning the width of the current page. 443// 444function livePageWidth() 445{ 446 if (window.innerHeight && window.scrollMaxY) // Firefox 447 { 448 return window.innerWidth + window.scrollMaxX; 449 450 } 451 else // works in Explorer 6 Strict, Mozilla (not FF) and Safari 452 { 453 return document.body.offsetWidth + document.body.offsetLeft; 454 } 455 456 return null; 457 458 // if (window.innerWidth != null) 459 // return window.innerWidth; 460 // 461 // if (document.body.clientWidth != null) 462 // return document.body.clientWidth; 463 // 464 // return null; 465} 466//
467// Given an object, finds its absolute and relative position on the page. 468// Returns a "shape" which contains these attributes: 469// left, top, width, height, absoluteLeft, absoluteTop 470// 471function findAbsoluteCoords(obj) 472{ 473 var shape = new Object(); 474 shape.left = obj.offsetLeft; 475 shape.top = obj.offsetTop; 476 shape.width = obj.clientWidth; 477 shape.height = obj.clientHeight; 478 shape.absoluteLeft = 0; 479 shape.absoluteTop = 0; 480 481 482 // figure out the absolute x,y coords by going up the ancestory 483 var temp = obj; 484 while (temp != null) 485 { 486 var tagName = temp.tagName.toUpperCase(); 487 if (tagName == 'BODY' || tagName == 'FORM' || tagName == 'HTML') 488 break; 489 490 shape.absoluteLeft = shape.absoluteLeft + temp.offsetLeft; 491 shape.absoluteTop = shape.absoluteTop + temp.offsetTop; 492 temp = temp.offsetParent; 493 494 if (temp != null && (temp.style.position == 'absolute' || temp.style.position == 'relative')) 495 break; 496 } 497 498 // if the width is 0 (i.e., unspecified) make it as wide as possible 499 if (shape.width == 0) 500 shape.width = livePageWidth() - shape.absoluteLeft; 501 502 // if the height is 0 (i.e., unspecified) make it as tall as possible 503 if (shape.height == 0) 504 shape.height = livePageHeight() - shape.absoluteTop; 505 506 return shape; 507} 508// 509// Returns an array of the url parameters, with each element in the form of "param=value" 510// 511function GetURLParameters() 512{ 513 var url = window.document.URL.toString(); 514 515 if (url.indexOf("?") > 0) 516 { 517 var parts = url.split("?"); 518 var paramsArray = parts[1].split("&"); 519 return paramsArray; 520 } 521 return null; 522} 523// 524// Return the value in the URL parameter string for a given parameter name 525// 526function FindURLParameter(paramName) 527{ 528 paramName = paramName.toUpperCase(); 529 var paramsArray = GetURLParameters(); 530 if (paramsArray != null) 531 return FindParameterInArray(paramName, paramsArray); 532 return null; 533} 534// 535// Given an array of parm=value strings, splits the parm name from the value, looks for the paramName in the array of names 536// and if found returns the param value 537// 538function FindParameterInArray(paramName, paramsArray) 539{ 540 paramName = paramName.toUpperCase(); 541 for (i = 0; i < paramsArray.length; i++) 542 { 543 var sParam = paramsArray[i].split("="); 544 if (sParam[0].toUpperCase() == paramName) 545 return sParam[1]; 546 } 547 return null; 548} 549function findPos(obj) 550{ 551 var curleft = curtop = 0; 552 if (obj.offsetParent) 553 { 554 do 555 { 556 curleft += obj.offsetLeft; 557 curtop += obj.offsetTop; 558 } while (obj = obj.offsetParent); 559 } 560 return [curleft, curtop]; 561} 562 563// 564// Move an element directly on top of another element. Optionally 565// make it the same size or set an offset for X and Y coordinates. 566// 567// 568// Move an element directly on top of another element. Optionally 569// make it the same size or set an offset for X and Y coordinates. 570// 571function Cover(bottomElement, topElement, ignoreSize, offsetX, offsetY) 572{ 573 var location = findPos(bottomElement); 574 topElement.style.position = 'absolute'; 575 576 var positionY = location[1]; 577 if (offsetY != null && !isNaN(offsetY)) 578 positionY = positionY + offsetY; 579 580 var positionX = location[0]; 581 if (offsetX != null && !isNaN(offsetX)) 582 positionX = positionX + offsetX; 583 584 var bottomheight = 0; 585 var bottomwidth = 0; 586 587 // Use local vars for the Bottom control size - In this case we can compare those values to actual screen size and adjast them if size greater then Screen. 588 bottomheight = bottomElement.offsetHeight; 589 if (screen.height < bottomheight) 590 bottomheight = screen.height; 591 bottomwidth = bottomElement.offsetWidth; 592 if (screen.width < bottomwidth) 593 bottomwidth = screen.width; 594 595 596 if (!ignoreSize) 597 { 598 topElement.style.height = bottomheight + 'px'; 599 topElement.style.width = bottomwidth + 'px'; 600 } 601 602 // figure out the physical area of the page the browser is currently displaying, accounting for any scrolling 603 var pageLeft = GetViewportScrollPos().x; 604 var pageRight = pageLeft + document.body.offsetWidth - 1; 605 var pageTop = GetViewportScrollPos().y; 606 var pageBottom = pageTop + document.body.offsetHeight - 1; 607 608 /* 609 var pageHeight = livePageHeight() - 30; 610 var pageWidth = livePageWidth() - 30; 611 */ 612 613 // Check Right/Bottom screen boundaries 614 var elementHeight = topElement.offsetHeight > 0 ? topElement.offsetHeight : bottomheight; 615 var elementWidth = topElement.offsetWidth > 0 ? topElement.offsetWidth : bottomwidth; 616 if ((positionY + elementHeight) > pageBottom) 617 positionY = pageBottom - elementHeight; 618 if ((positionX + elementWidth) > pageRight) 619 positionX = pageRight - elementWidth; 620 621 // Check Top/Left screen boundaries 622 if (positionX < pageLeft) 623 positionX = pageLeft; 624 if (positionY < pageTop) 625 positionY = pageTop; 626 627 topElement.style.top = positionY + 'px'; 628 topElement.style.left = positionX + 'px'; 629 630 topElement.style.zIndex = 1001;
630 // bottomElement.style.zIndex + 1; 631} 632// 633// Create a cookie 634// 635function createCookie(name, value, days) 636{ 637 if (days) 638 { 639 var date = new Date(); 640 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); 641 var expires = "; expires=" + date.toGMTString(); 642 } 643 else var expires = ""; 644 document.cookie = name + "=" + value + expires + "; path=/"; 645} 646// 647// Read a cookie 648// 649function readCookie(name) 650{ 651 var nameEQ = name + "="; 652 var ca = document.cookie.split(';'); 653 for (var i = 0; i < ca.length; i++) 654 { 655 var c = ca[i]; 656 while (c.charAt(0) == ' ') c = c.substring(1, c.length); 657 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); 658 } 659 return null; 660} 661// 662// Delete a cookie 663// 664function eraseCookie(name) 665{ 666 createCookie(name, "", -1); 667} 668 669/** Determines if the string is a url */ 670function IsUrl(s, optionalSchema) 671{ 672 var regexp = new RegExp('^(([a-z]+)://)' + (optionalSchema ? '?' : '') + '([a-z0-9\-]+|[a-z0-9][a-z0-9\-\.\_]*\.[a-z]+)(:[0-9]+)?(/.*)?$', 'i'); 673 return regexp.test(s); 674} 675 676// 677// Browser Detection 678// 679var BrowserDetect = { 680 init: function() 681 { 682 this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; 683 this.version = this.searchVersion(navigator.userAgent) 684 || this.searchVersion(navigator.appVersion) 685 || "an unknown version"; 686 this.OS = this.searchString(this.dataOS) || "an unknown OS"; 687 }, 688 searchString: function(data) 689 { 690 for (var i = 0; i < data.length; i++) 691 { 692 var dataString = data[i].string; 693 var dataProp = data[i].prop; 694 this.versionSearchString = data[i].versionSearch || data[i].identity; 695 if (dataString) 696 { 697 if (dataString.indexOf(data[i].subString) != -1) 698 return data[i].identity; 699 } 700 else if (dataProp) 701 return data[i].identity; 702 } 703 }, 704 searchVersion: function(dataString) 705 { 706 var index = dataString.indexOf(this.versionSearchString); 707 if (index == -1) return; 708 return parseFloat(dataString.substring(index + this.versionSearchString.length + 1)); 709 }, 710 dataBrowser: [ 711 { string: navigator.userAgent, 712 subString: "OmniWeb", 713 versionSearch: "OmniWeb/", 714 identity: "OmniWeb" 715 }, 716 { 717 string: navigator.vendor, 718 subString: "Apple", 719 identity: "Safari" 720 }, 721 { 722 prop: window.opera, 723 identity: "Opera" 724 }, 725 { 726 string: navigator.vendor, 727 subString: "iCab", 728 identity: "iCab" 729 }, 730 { 731 string: navigator.vendor, 732 subString: "KDE", 733 identity: "Konqueror" 734 }, 735 { 736 string: navigator.userAgent, 737 subString: "Firefox", 738 identity: "Firefox" 739 }, 740 { 741 string: navigator.vendor, 742 subString: "Camino", 743 identity: "Camino" 744 }, 745 { // for newer Netscapes (6+) 746 string: navigator.userAgent, 747 subString: "Netscape", 748 identity: "Netscape" 749 }, 750 { 751 string: navigator.userAgent, 752 subString: "MSIE", 753 identity: "Explorer", 754 versionSearch: "MSIE" 755 }, 756 { 757 string: navigator.userAgent, 758 subString: "Gecko", 759 identity: "Mozilla", 760 versionSearch: "rv" 761 }, 762 { // for older Netscapes (4-) 763 string: navigator.userAgent, 764 subString: "Mozilla", 765 identity: "Netscape", 766 versionSearch: "Mozilla" 767 } 768 ], 769 dataOS: [ 770 { 771 string: navigator.platform, 772 subString: "Win", 773 identity: "Windows" 774 }, 775 { 776 string: navigator.platform, 777 subString: "Mac", 778 identity: "Mac" 779 }, 780 { 781 string: navigator.platform, 782 subString: "Linux", 783 identity: "Linux" 784 } 785 ] 786 787}; 788 789 790BrowserDetect.init(); 791 792/* 793Returns the x/y coordinates of an element relative to the viewport. 794If an element is at x=10,y=1000, but the browser window is scrolled down by 950px, the return coords will be x=10,y=50 795*/ 796function GetElementViewportOffset(forElement) 797{ 798 799 var valueY = 0, valueX = 0, docBody = document.body; 800 801 var element = forElement; 802 do 803 { 804 valueY += element.offsetTop || 0; 805 valueX += element.offsetLeft || 0; 806 // Safari fix 807 if (element.offsetParent == docBody && element.style.position && element.style.position == 'absolute') break; 808 } while (element = element.offsetParent); 809 810 element = forElement; 811 do 812 { 813 // Opera < 9.5 sets scrollTop/Left on both HTML and BODY elements. 814 // Other browsers set it only on the HTML element. The BODY element 815 // can be skipped since its scrollTop/Left should always be 0. 816 if (element != docBody) 817 { 818 valueY -= element.scrollTop || 0; 819 valueX -= element.scrollLeft || 0; 820 } 821 } while (element = element.parentNode); 822 823 var coords = new Object(); 824 coords.x = valueX; 825 coords.y = valueY; 826 827 return coords; 828} 829 830 831/* 832Size an image to fit within specific width and height bounds. 833If the image is larger than the bounds, it will be downsized maintaining its aspect ratio. 834If the image is smaller than the bounds and allowUpsize=true, the image will be upsized maintaining its aspect ratio. 835 836Params 837imageElement = (ref) reference to the image element to be sized 838maxWidth = (int) max allowed width in pixels or null 839maxHeight = (int) max allowed height in pixels or null 840allowUpsize = (bool) if the image is smaller than the bounds, then upscale it 841 842maxWidth AND/OR maxHeight can be specified. 843maxWidth 844The image width will be set to the specified maxWidth 845The height will be adjusted accordingly to maintain aspect ratio. There will be no upper bound for resulting height. 846maxHeight 847The image height will be set to the specified maxHeight. 848The width will be adjusted accordingly to maintain aspect ratio. There will be no upper bound for resulting width. 849maxWidth AND maxHeight 850Based on the images aspect ratio, the relevant maximum sizing parameter will be selected i.e. either width or height. 851The image will then be sized to its maximum based on that dimension i.e. either width to maxWidth or height to maxHeight. 852The other dimension will be adjusted accordingly to maintain aspect ratio. 853The final result will be that both width and height fall within the bounds of maxWidth and maxHeight. 854*/ 855function SizeImageWithinBounds(imageElement, maxWidth, maxHeight, allowUpsize) { 856 857 // were we given some bounds 858 maxWidth = parseInt(maxWidth); 859 if (isNaN(maxWidth)) maxWidth = 0; 860 maxHeight = parseInt(maxHeight); 861 if (isNaN(maxHeight)) maxHeight = 0; 862 if (maxWidth <= 0 && maxHeight <= 0) return; 863 864 // do we have an image 865 if (imageElement == null) return; 866 if (!imageElement.tagName) return; 867 if (imageElement.tagName.toUpperCase() != "IMG") return;
868 var width = imageElement.naturalWidth; 869 var height = imageElement.naturalHeight; 870 if (width == 0 || height == 0) return; 871 872 // determine current aspect ratio 873 var aspectRatio = imageElement.naturalHeight / imageElement.naturalHeight; 874 875 // figure out sizing mode 876 var sizeMode = 0; // 0(none), 1(by width), 2(by height) 877 if (maxWidth > 0 && maxHeight > 0) { 878 // width and height 879 sizeMode = (Math.floor(maxWidth / aspectRatio) <= maxHeight) ? 1 : 2; 880 } 881 else { 882 if (maxWidth > 0) { 883 // width 884 if (width > maxWidth || (width < maxWidth && allowUpsize)) sizeMode = 1; 885 } 886 else { 887 // height 888 if (height > maxHeight || (height < maxHeight && allowUpsize)) sizeMode = 2; 889 } 890 } 891 if (sizeMode == 0) return; 892 893 // size the image 894 if (sizeMode == 1) { 895 // by width 896 width = maxWidth; 897 height = Math.max(Math.floor(width / aspectRatio), 1); 898 } 899 else { 900 // by height 901 height = maxHeight; 902 width = Math.max(Math.floor(height * aspectRatio), 1); 903 } 904 imageElement.width = width; 905 imageElement.height = height; 906 907} 908 909 910/* 911Returns the x/y scroll positions of viewport. 912This refers to the browser or iFrame scrollbars, not the scrollbars of any sub elements on the page. 913*/ 914function GetViewportScrollPos() 915{ 916 917 var scrollPos = new Object(); 918 scrollPos.x = scrollPos.y = 0; 919 920 if (typeof window.pageYOffset != 'undefined') 921 { 922 scrollPos.y = window.pageYOffset; 923 scrollPos.x = window.pageXOffset; 924 } 925 else 926 if (document.documentElement) 927 { 928 scrollPos.y = document.documentElement.scrollTop; 929 scrollPos.x = document.documentElement.scrollLeft; 930 } 931 else 932 if (document.body && typeof document.body.scrollTop != 'undefined') 933 { 934 scrollPos.y = document.body.scrollTop; 935 scrollPos.x = document.body.scrollLeft; 936 } 937 938 return scrollPos; 939 940} 941 942function hasClass(el, className) { 943 if (el !== null) { 944 var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)'); 945 return re.test(el['className']); 946 } 947 return false; 948} 949 950function addClass(el, className) 951{ 952 if (this.hasClass(el, className)) 953 return; 954 if (el !== null) { 955 el['className'] = [el['className'], className].join(' '); 956 } 957} 958 959function removeClass(el, className) 960{ 961 var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', 'g'); 962 if (!hasClass(el, className)) 963 return; 964 if (el !== null) { 965 var c = el['className']; 966 el['className'] = c.replace(re, ' '); 967 if (hasClass(el, className)) { 968 removeClass(el, className); 969 } 970 } 971} 972function replaceClass(el, oldClassName, newClassName) 973{ 974 if (oldClassName === newClassName) 975 return false; 976 var re = new RegExp('(?:^|\\s+)' + oldClassName + '(?:\\s+|$)', 'g'); 977 if (!hasClass(el, oldClassName)) 978 { 979 addClass(el, newClassName); 980 return; 981 } 982 el['className'] = el['className'].replace(re, ' ' + newClassName + ' '); 983 if (hasClass(el, oldClassName)) 984 { 985 replaceClass(el, oldClassName, newClassName); 986 } 987} 988 989// ############################################################################ 990// Collection of JavaScript functions that are required throughout ASI 991// software. These functions are different from those found in ASIUtility.js 992// in that they are only useful if used inside Asi.Webroot. 993// ############################################################################ 994 995// 996// A browser-independent function for determining if the user has the CTRL key 997// pressed. 998// 999function IsCtrl(e) 1000{ 1001 if (window.event) 1002 return window.event.ctrlKey; 1003 if (e.ctrlKey) 1004 return e.ctrlKey; 1005 return (e.modifiers & Event.CONTROL_MASK == Event.CONTROL_MASK); 1006} 1007// 1008// A browser-independent function for determining if the user has the SHIFT key 1009// pressed. 1010// 1011function IsShift(e) 1012{ 1013 if (window.event) 1014 return window.event.shiftKey; 1015 if (e.shiftKey) 1016 return e.shiftKey; 1017 return (e.modifiers & Event.SHIFT_MASK == Event.SHIFT_MASK); 1018} 1019// 1020// Use this function when you want to pass back to the server the state 1021// of the user's CTRL key. On the server-side Method you can access whether 1022// the CTRL key was pressed using the DisplayPageBase.IsCtrl property. 1023// If this function name changes you must change DisplayPageBase.CLIENTSCR
1023IPT_SetIsCtrl 1024// 1025function SetIsCtrl(e) 1026{ 1027 if ($get('__CTRLKEY') != null) 1028 $get('__CTRLKEY').value = IsCtrl(e); 1029 1030 // TODO: should i create the hidden input element if it's not already on the Form? 1031} 1032// 1033// Use this function when you want to pass back to the server the state 1034// of the user's SHIFT key. On the server-side Method you can access whether 1035// the SHIFT key was pressed using the DisplayPageBase.IsShift property. 1036// If this function name changes you must change DisplayPageBase.CLIENTSCRIPT_SetIsShift 1037// 1038function SetIsShift(e) 1039{ 1040 if ($get('__SHIFTKEY') != null) 1041 $get('__SHIFTKEY').value = IsShift(e); 1042 1043 // TODO: should i create the hidden input element if it's not already on the Form? 1044} 1045// 1046// Perform the specified event on the specifed control. Also sets the 1047// requested argument into the __EVENTARGUMENT hidden input element. 1048// If eventName is not specified 'click' will be used by default. 1049// 1050function InitiateControlEventWithArgument(controlClientID, argument, eventName) 1051{ 1052 if (eventName == null) 1053 eventName = 'click'; 1054 1055 if (argument != null && argument != '') 1056 $get('__EVENTARGUMENT').value = argument; 1057 1058 var ajaxifiedControl = $get(controlClientID); 1059 if (ajaxifiedControl != null) 1060 eval('ajaxifiedControl.' + eventName + '()'); 1061} 1062// 1063// 1064// 1065function InitiatePostBack(controlUniqueId, argument) 1066{ 1067 __doPostBack(controlUniqueId, argument); 1068} 1069// 1070// To support the bug with ajax tabcontainer not persisting current 1071// active tab across postbacks. 1072// 1073var ignoreTabChange = false; 1074// TODO: Would like to do the same thing on save, in case the validation failure is in another tab. 1075function TabContainer_OnActiveTabChanged(sender, args) 1076{ 1077 sender.get_clientStateField().value = sender.saveClientState(); 1078 if (typeof (Page_ClientValidate) == 'function') 1079 { 1080 if (!ignoreTabChange && !Page_ClientValidate()) 1081 { 1082 ShowFailedTab(sender); 1083 } 1084 } 1085} 1086function ShowProblemTab() 1087{ 1088 if (typeof (Page_ClientValidate) == 'function' && !Page_IsValid) 1089 { 1090 // Find all ajax tabviews on the page. 1091 var tabContainers = jQuery('.ajax__tab_xp').get(); 1092 for (var i = 0; i < tabContainers.length; ++i) 1093 { 1094 ShowFailedTab($find(tabContainers[i].id)); 1095 } 1096 } 1097} 1098function ShowFailedTab(tabContainer) 1099{ 1100 // Check to see if there is a validator on the current tab that failed. If so, disallow the tab change. 1101 for (i = 0; i < Page_Validators.length; ++i) 1102 { 1103 var val = Page_Validators[i]; 1104 if (val.evaluationfunction(val) == false) 1105 { 1106 // Find the tab containing the invalid control. 1107 var tabs = tabContainer.get_tabs(); 1108 1109 var control = val.parentNode; 1110 while (control != null) 1111 { 1112 for (var i = 0; i < tabs.length; ++i) 1113 { 1114 if (control == tabs[i]._element) 1115 { 1116 ignoreTabChange = true; 1117 tabContainer.set_activeTab(tabs[i]); 1118 ignoreTabChange = false; 1119 return; 1120 } 1121 } 1122 control = control.parentNode; 1123 } 1124 } 1125 } 1126} 1127function getElementsByClassName(classname, node) 1128{ 1129 if (!node) node = document.getElementsByTagName("body")[0]; 1130 var a = []; 1131 var re = new RegExp('\\b' + classname + '\\b'); 1132 var els = node.getElementsByTagName("*"); 1133 for (var i = 0, j = els.length; i < j; i++) 1134 if (re.test(els[i].className)) a.push(els[i]); 1135 return a; 1136} 1137 1138var win = null; 1139function NewWindow(sURL, sName, sSize, sMode, sAppendWebsiteKey, callBackFunction, closeWindowOnCommit, preserveStatefulBusinessContainer, dialogCloseFunction) 1140{ 1141 1142 // default to large 1143 var w = 750; 1144 var h = 500; 1145 var winName = ''; 1146 1147 if (sSize.toLowerCase() == 'current' || sSize.toLowerCase() == 'c') { w = window.document.body.offsetWidth - 20; h = window.document.body.offsetHeight - 20; mw = 800; mh = 600 }; 1148 if (sSize.toLowerCase() == 'full' || sSize.toLowerCase() == 'f') { w = 900; h = 600; mw = 800; mh = 600 }; 1149 if (sSize == '' || sSize.toLowerCase() == 'large' || sSize.toLowerCase() == 'l') { w = 750; h = 500; mw = 750; mh = 500 }; 1150 if (sSize.toLowerCase() == 'medium' || sSize.toLowerCase() == 'm') { w = 650; h = 400; mw = 650; mh = 400 }; 1151 if (sSize.toLowerCase() == 'small' || sSize.toLowerCase() == 's') { w = 400; h = 200; ; mw = 400; mh = 200 }; 1152 if (sSize.toLowerCase() == 'help' || sSize.toLowerCase() == 'h') { w = 650; h = 400; mw = 650; mh = 400 }; 1153 if (sSize.toLowerCase() == 'print' || sSize.toLowerCase() == 'p') { w = 750; h = 500; mw = 750; mh = 500 }; 1154 if (sSize.toLowerCase() == 'flowchart' || sSize.toLowerCase() == 'l') { w = 790; h = 515; mw = 790; mh = 515 }; 1155 1156 if ((sAppendWebsiteKey == null || sAppendWebsiteKey) && (typeof gWebsiteKey != 'undefined' && gWebsiteKey != 'null' && sURL.indexOf('&WebsiteKey=') < 0)) 1157 sURL += '&WebsiteKey=' + gWebsiteKey; 1158 1159 if (sName.indexOf("-") >= 1) 1160 { 1161 winName = sName.substr(0, 9); 1162 } 1163 else 1164 { 1165 winName = sName; 1166 } 1167 1168 //function ShowDialog_NoReturnValue(url, args, width, height, title, iconUrl, templateType, callBackFunction, windowName, closeWindowOnCommit, preserveStatefulBusinessContainer, dialogCloseFunction, sourceObject) 1169 ShowDialog_NoReturnValue(sURL, null, w, h, sName, null, 'D', callBackFunction, winName, closeWindowOnCommit, preserveStatefulBusinessContainer, dialogCloseFunction, null); 1170} 1171 1172function RefreshBySubmit() 1173{ 1174 if (gPostBackFormObject != null) 1175 { 1176 gPostBackFormObject.submit(); 1177 } 1178 else 1179 { 1180 if (document.forms.length > 0) 1181 { 1182 document.forms[0].submit(); 1183 } 1184 else 1185 { 1186 window.location.href = window.location.href; 1187 } 1188 } 1189} 1190 1191function SetDefaultStyle(item) 1192{ 1193 if (item.className != 'VTabSelectedStyle') 1194 item.className = 'VTabDefaultStyle'; 1195} 1196 1197function SetHoverStyle(item) 1198{ 1199 if (item.className != 'VTabSelectedStyle') 1200 item.className = 'VTabHoverStyle'; 1201} 1202 1203function UpdateFormInputAndSubmit(name, val) 1204{ 1205 var docForms = document.forms; 1206 if (docFormsLen > 0) 1207 { 1208 for (var i = 0, ic = docForms.length; i < ic; i++) 1209 { 1210 if (docForms[i].elements[name] != null) 1211 { 1212 docForms[i].elements[name].value = val; 1213 docForms[i].submit(); 1214 break; 1215 } 1216 } 1217 } 1218} 1219 1220function toggleElement(targetId, controlImage) 1221{ 1222 target = document.getElementById(targetId); 1223 switch (target.style.display) 1224 { 1225 case ("block"): 1226 target.style.display = "none"; 1227 controlImage.src = gWebRoot + "/AsiCommon/Images/+.gif"; 1228 break; 1229 default: 1230 target.style.display = "block"; 1231 controlImage.src = gWebRoot + "/AsiCommon/Images/-.gif"; 1232 break; 1233 } 1234} 1235 1236//Append a fields value into another field 1237function fieldAppend(selectfield, fieldId) 1238{ 1239 var selval = selectfield.options[selectfield.selectedIndex].value; 1240 var output = document.getElementById(fieldId); 1241 output.count = (typeof output.count == 'undefined') ? 1 : ++output.count; 1242 output.value += selval + ' \n'; 1243} 1244 1245var brushState = "block"; 1246var existingClassNames = new Array(); 1247 1248function surfToEditNavigationItem(key) 1249{ 1250 ShowDialog_NoReturnValue(gWebRoot + "/iMIS/ContentManagement/NavigationItemProperties.aspx?iUniformKey=" + key, null, '800', '600', 'Navigation Designer', '~/AsiCommon/Images/icon_nav.gif', 'E'); 1251 CancelEvent(); 1252} 1253 1254function surfToEditContentItem(contentRecordKey, contentItemKey, contentTypeKey, windowTitle) 1255{ 1256 ShowDialog_NoReturnValue(gWebRoot + "/iMIS/ContentManagement/ContentItemEdit.aspx?ContentTypeKey=" + contentTypeKey + "&ContentKey=" + contentRecordKey + 1257 "&ContentItemKey=" + contentItemKey + "&iOperation=Edit", null, '800', '600', windowTitle, null, 'E', null, null, false, true, null, null); 1258 CancelEvent(); 1259} 1260 1261function surfToEditHtmlContentItem(contentRecordKey, contentItemKey, contentTypeKey, windowTitle) 1262{ 1263 ShowDialog_NoReturnValue(gWebRoot + "/iMIS/ContentManagement/ContentItemEdit.aspx?ContentTypeKey=" + contentTypeKey + "&ContentKey=" + contentRecordKey + 1264 "&ContentItemKey=" + contentItemKey + "&iOperation=Edit", null, '97%', '97%', windowTitle, null, 'E', null, null, false, true, null, null); 1265 CancelEvent(); 1266} 1267 1268function surfToEditContentRecord(key, queryStringParams, windowTitle) 1269{ 1270 var url = gWebRoot + '/iMIS/ContentManagement/ContentDesigner.aspx?ShowSummary=false&TemplateType=E&ShowMenu=true&DialogMode=true&ShowHierarchyTree=false&Mode=EditContent&ShowAddress=false&ContentHierarchyKey=' + key; 1271 if (queryStringParams != null && queryStringParams.length > 0) 1272 { 1273 if (queryStringParams.substr(0, 1) == '?') 1274 queryStringParams = queryStringParams.substr(1); 1275 1276 if (queryStringParams.substr(0, 1) != '&') 1277 queryStringParams = '&' + queryStringParams; 1278 1279 url += queryStringParams; 1280 } 1281 //ShowDialog_NoReturnValue(url, null, '95%', '95%', 'Content Designer', '~/AsiCommon/Images/icon_con.gif', 'E'); 1282 if (windowTitle == null) 1283 windowTitle = "Content Designer"; 1284 NewWindow(url, windowTitle, 'current', 'nonmodal', false); 1285 1286 CancelEvent(); 1287} 1288 1289setBodyCssClass(gIsEasyEditEnabled); 1290function setBodyCssClass(isEasyEditEnabled) { 1291 if (isEasyEditEnabled) { 1292 jQuery("Body").addClass("EasyEditOn"); 1293 } 1294} 1295 1296function contentRecordChangeRequest(key, queryStringParams, windowTitle) 1297{
1298 var url = gWebRoot + '/AsiCommon/Controls/ContentManagement/ContentDesigner/ContentChangeRequestEdit.aspx?CloseWindowOnCommit=true&PageOperation=New&ContentRecordKey=' + key; 1299 if (queryStringParams != null && queryStringParams.length > 0) 1300 { 1301 if (queryStringParams.substr(0, 1) == '?') 1302 queryStringParams = queryStringParams.substr(1); 1303 1304 if (queryStringParams.substr(0, 1) != '&') 1305 queryStringParams = '&' + queryStringParams; 1306 1307 url += queryStringParams; 1308 } 1309 if (windowTitle == null) 1310 windowTitle = "Content Designer"; 1311 ShowDialog_NoReturnValue(url, null, '600', '400', windowTitle, '~/AsiCommon/Images/icon_con.gif', 'E'); 1312 1313 CancelEvent(); 1314} 1315 1316function emailAFriend(pageTitle) 1317{ 1318 var url = gWebRoot + '/iMIS/ContentManagement/EmailAFriend.aspx?PageTitle=' + pageTitle + '&PreserveStatefulBusinessContainer=true'; 1319 ShowDialog_NoReturnValue(url, null, 600, 400, 'E-mail a friend', '~/AsiCommon/Images/icon_email.gif', 'E'); 1320 1321 return CancelEvent(); 1322} 1323 1324function printThisPage() 1325{ 1326 window.open(gWebRoot + '/iMIS/Print.aspx'); 1327} 1328 1329function printThisPageTemplate() 1330{ 1331 var url = window.location.href; 1332 var re = new RegExp('[?&]TemplateType=[A-Za-z]', "g"); 1333 url = url.replace(re, ""); 1334 if (url.indexOf("?") < 0) 1335 url += "?"; 1336 else if (url.indexOf("?") != url.length - 1) // don't append '&' if the last character in the url is '?' 1337 url += "&"; 1338 url += "TemplateType=P"; 1339 window.location.href = url; 1340} 1341 1342function showHideBrush() 1343{ 1344 var links = document.getElementsByName("editlink"); 1345 1346 if (links == null || links.length == 0) { 1347 alert('There are no Screen Designer Panels to edit on this page.'); 1348 return; 1349 } 1350 1351 for (var i = 0; i < links.length; i++) 1352 { 1353 links[i].style.display = brushState; 1354 links[i].className = ""; 1355 if (brushState == "block") 1356 { 1357 existingClassNames[i] = getParent(links[i]).className; 1358 1359 getParent(links[i]).className = "PanelEditLink"; 1360 var title = links[i].getAttribute("panelName"); 1361 getParent(links[i]).title = title; 1362 } 1363 else 1364 { 1365 getParent(links[i]).className = existingClassNames[i]; 1366 getParent(links[i]).title = ""; 1367 } 1368 } 1369 if (brushState == "none") 1370 brushState = "block"; 1371 else 1372 brushState = "none"; 1373} 1374 1375function Rollover(obj, image) { 1376 obj.src = image; 1377} 1378 1379function printWindow() { 1380 var bV = parseInt(navigator.appVersion); 1381 if (bV >= 4) window.print(); 1382} 1383 1384function emailWindow() { 1385 alert('email window'); 1386} 1387 1388function showInfoCenter() { 1389 alert('InfoCenter'); 1390} 1391 1392// CDR - 11/29/2006 - window.showHelp is a standard javascript func - commenting out b/c it was killing help links 1393//CP 6/13/12 -modified because regular showHelp was not working except in IE, so now using a pop up for rest of browsers 1394//DS 18/May/18 - stripping it down to just opening a new window for compatibility with all browsers 1395function showHelpDialog(url) { 1396 try { 1397 window.open(url, '_blank', ''); 1398 } catch (error) { 1399 alert("There was a problem launching a new browser window. Please try again."); 1400 } 1401} 1402 1403// 1404// Same thing as ShowDialog except that it doesn't return the Dialog Window at the end of the function. This is necessary 1405// if you want to hook up this function directly to <a href="javascript:ShowDialog(...)">. 1406// 1407function ShowDialog_NoReturnValue(url, args, width, height, title, iconUrl, templateType, callBackFunction, windowName, closeWindowOnCommit, preserveStatefulBusinessContainer, dialogCloseFunction, sourceObject) 1408{ 1409 ShowDialog(url, args, width, height, title, iconUrl, templateType, callBackFunction, windowName, closeWindowOnCommit, preserveStatefulBusinessContainer, dialogCloseFunction, sourceObject); 1410} 1411var RadWindowInformation = new Object(); 1412// 1413// Opens a modal dialog given the parameters 1414// 1415function ShowDialog(url, args, width, height, title, iconUrl, templateType, callBackFunction, 1416windowName, closeWindowOnCommit, preserveStatefulBusinessContainer, dialogCloseFunction, sourceObject) 1417{ 1418 if (url.indexOf("http://") > -1) { 1419 var tempUrl = url.replace("http://", ""); 1420 tempUrl = tempUrl.replace("//", "/"); 1421 url = "http://" + tempUrl; 1422 } 1423 else if (url.indexOf("https://") > -1) { 1424 var tempUrl = url.replace("https://", ""); 1425 tempUrl = tempUrl.replace("//", "/"); 1426 url = "https://" + tempUrl; 1427 } 1428 else 1429 url = url.replace("//", "/"); 1430 1431 if (url.indexOf('~') == 0) 1432 url = gWebRoot + url.substring(1); 1433 1434 if (windowName == null || windowName.length == 0) 1435 windowName = 'GenericWindow'; 1436 1437 if (url.indexOf("TemplateType=") < 0) 1438 { 1439 if (templateType == null || templateType.length == 0) 1440 templateType = "E"; 1441 var separator = url.indexOf("?") > -1 ? "&" : "?"; 1442 url += separator + "TemplateType=" + templateType; 1443 } 1444 if (closeWindowOnCommit && url.indexOf("CloseWindowOnCommit") < 0) 1445 { 1446 var separator = url.indexOf("?") > -1 ? "&" : "?"; 1447 url += separator + "CloseWindowOnCommit=" + closeWindowOnCommit; 1448 } 1449 if (preserveStatefulBusinessContainer && url.indexOf("PreserveStatefulBusinessContainer") < 0) 1450 { 1451 var separator = url.indexOf("?") > -1 ? "&" : "?"; 1452 url += separator + "PreserveStatefulBusinessContainer=" + preserveStatefulBusinessContainer; 1453 var parentPageInstanceKey = $get('PageInstanceKey'); 1454 if (parentPageInstanceKey != null) 1455 url += "&ParentPageInstanceKey=" + parentPageInstanceKey.value; 1456 } 1457 if (url.indexOf("DialogCacheParam") < 0) 1458 { 1459 var separator = url.indexOf("?") > -1 ? "&" : "?"; 1460 url += separator + "DialogCacheParam=" + Math.random(); 1461 } 1462 // Indicate in the URL that this is a popup 1463 if (url.indexOf("IsPopup") < 0) { 1464 var separator = url.indexOf("?") > -1 ? "&" : "?"; 1465 url += separator + "IsPopup=true"; 1466 } 1467 1468 var pageWidth = livePageWidth(); 1469 if ((width + '').indexOf('%') > -1) 1470 width = pageWidth * (parseInt(width) / 100); 1471 else if (width > pageWidth) 1472 width = pageWidth; 1473 1474 var pageHeight = livePageHeight(); 1475 if ((height + '').indexOf('%') > -1) 1476 height = pageHeight * (parseInt(height) / 100); 1477 else if (height > pageHeight) 1478 height = pageHeight; 1479 1480 RadWindowInformation.windowName = windowName; 1481 RadWindowInformation.url = url; 1482 RadWindowInformation.args = args; 1483 RadWindowInformation.width = width; 1484 RadWindowInformation.height = height; 1485 RadWindowInformation.title = title; 1486 RadWindowInformation.iconUrl = iconUrl; 1487 RadWindowInformation.callBackFunction = callBackFunction; 1488 RadWindowInformation.dialogCloseFunction = dialogCloseFunction; 1489 RadWindowInformation.sourceObject = sourceObject; 1490 RadWindowInformation.dialogWindow = null; 1491 1492 var windowManager = GetRadWindowManager(); 1493 if (windowManager == null) 1494 { 1495 DelaySetupRadWindow(); 1496 return null; 1497 } 1498 var dialogWindow = windowManager.getWindowByName(windowName); 1499 if (dialogWindow != null && dialogWindow.IsClosed()) 1500 { 1501 dialogWindow.Name = null; 1502 dialogWindow = null; 1503 } 1504 1505 if (dialogWindow == null) 1506 dialogWindow = window.radopen(null, windowName); 1507 if (dialogWindow == null) 1508 { 1509 DelaySetupRadWindow(); 1510 return null; 1511 } 1512 1513 // Prevent the content designer window from allowing a resize by dragging the edge of the RadWindow 1514 if (dialogWindow != null && url.indexOf('Mode=EditContent') > -1
1515 || url.indexOf('/ContentRecordEdit.aspx?') > -1) { 1516 dialogWindow.set_behaviors(4 + 16 + 32 + 64); 1517 height = livePageHeight(); 1518 width = livePageWidth(); 1519 dialogWindow.setSize(width, height); 1520 dialogWindow.maximize(); 1521 dialogWindow.set_animationDuration(0); 1522 dialogWindow.set_keepInScreenBounds(true); 1523 dialogWindow.set_destroyOnClose(false); 1524 } 1525 1526 if (dialogWindow != null && url.indexOf('/WebsiteEdit.aspx?') > -1 1527 || url.indexOf('/SelectTheme.aspx?') > -1) { 1528 height = livePageHeight() - 10; 1529 width = livePageWidth() - 10; 1530 dialogWindow.setSize(width, height); 1531 dialogWindow.maximize(); 1532 dialogWindow.set_animationDuration(0); 1533 dialogWindow.set_behaviors(4 + 64); 1534 dialogWindow.set_keepInScreenBounds(true); 1535 dialogWindow.set_destroyOnClose(false); 1536 } 1537 1538 if (dialogWindow != null && url.indexOf('/ContentItemEdit.aspx?') > -1 1539 && url.indexOf('ContentTypeKey=a85f082a-e710-499c-a9f5-27829b8fbff7') > -1) { 1540 height = livePageHeight() + 20; 1541 width = livePageWidth(); 1542 dialogWindow.setSize(width, height); 1543 dialogWindow.maximize(); 1544 dialogWindow.set_animationDuration(0); 1545 dialogWindow.set_behaviors(4 + 64); 1546 dialogWindow.set_keepInScreenBounds(true); 1547 dialogWindow.set_destroyOnClose(false); 1548 } 1549 1550 RadWindowInformation.dialogWindow = dialogWindow; 1551 return SetupRadWindow(); 1552} 1553 1554// Show Confirmation Dialog (ok/cancel) when action button/link is clicked. Returns action and selected grid element to c# function 1555// selectedElement, customCommandName, businessDataGridID are required if fireCommandBoolean is set to true 1556function ShowConfirmationDialog(confirmationWindowTitle, confirmationPhrase, fireCommandBoolean, selectedElement, customCommandName, businessDataGridId) { 1557 CancelEvent(this.Event); 1558 this.windowTitle = confirmationWindowTitle !== String.EMPTY ? confirmationWindowTitle : "Confirm"; 1559 this.windowConfirmText = confirmationPhrase !== String.EMPTY ? confirmationPhrase : "Are you sure?"; 1560 this.width = 375; 1561 this.height = 200; 1562 1563 this.FireCommand_CallBack = function (confirmed) { 1564 if (confirmed) { 1565 var grid = $find(businessDataGridId).get_masterTableView(); 1566 if (grid == null) 1567 grid = $find(businessDataGridId).MasterTableView; 1568 1569 if (grid != null) 1570 grid.fireCommand(customCommandName, selectedElement); 1571 } 1572 } 1573 if (fireCommandBoolean) { 1574 if (businessDataGridId !== "" && selectedElement !== "" && customCommandName !== "") { 1575 radconfirm(this.windowConfirmText, this.FireCommand_CallBack, this.width, this.height, null, this.windowTitle); 1576 } 1577 else { 1578 return false;//Cannot fire command without required fields 1579 } 1580 } 1581} 1582 1583function DelaySetupRadWindow() 1584{ 1585 // Have to delay a little bit to give the RadWindowManager time to open the window. 1586 addAjaxLoadEvent(SetupRadWindow); 1587} 1588 1589function SetWindowTitle(oWindow, args) 1590{ 1591 oWindow.set_title(RadWindowInformation.title); 1592} 1593 1594Sys.EventHandlerList.prototype.removeExtraneousHandlers = function(id, keepFirst) { 1595 a = this._getEvent(id, true); 1596 b = null; 1597 if (a.length > 0) { 1598 b = a[0]; 1599 } 1600 Array.clear(this._getEvent(id, true)); 1601 if (keepFirst && b != null) { 1602 Array.add(this._getEvent(id, true), b); 1603 } 1604}; 1605 1606function SetupRadWindow() 1607{ 1608 var dialogWindow = RadWindowInformation.dialogWindow; 1609 if (dialogWindow == null) 1610 dialogWindow = GetRadWindowManager().getWindowByName(RadWindowInformation.windowName); 1611 1612 dialogWindow.get_events().removeExtraneousHandlers('beforeClose', false); 1613 dialogWindow.get_events().removeExtraneousHandlers('close', true); 1614 // SBI 7448 - Need to set title in page load (for Safari) 1615 //dialogWindow.set_title(RadWindowInformation.title); 1616 dialogWindow.remove_pageLoad(SetWindowTitle); 1617 dialogWindow.add_pageLoad(SetWindowTitle); 1618 1619 // TODO: after Telerik decides to implement SetIcon we need to use it instead of 1620 // this hack 1621 //actionWindow.SetIcon(result.IconUrl); 1622 //dialogWindow.ii = iconUrl; 1623 //dialogWindow.Ii = iconUrl; 1624 //ctl00_ctl02[result.WindowName].children(0).children(0).children(1).children(1).children(0).children(0).children(0).children(0).src = result.IconUrl; 1625 1626 dialogWindow.Argument = RadWindowInformation.args; 1627 dialogWindow.dialogArguments = RadWindowInformation.args; 1628 if (RadWindowInformation.callBackFunction != null) 1629 dialogWindow.add_beforeClose(RadWindowInformation.callBackFunction); 1630 if (RadWindowInformation.dialogCloseFunction != null) 1631 dialogWindow.add_close(RadWindowInformation.dialogCloseFunction); 1632 dialogWindow.SourceObject = RadWindowInformation.sourceObject; 1633
1634 dialogWindow.setUrl(RadWindowInformation.url); 1635 dialogWindow.SetVisible(true); //DT6174 - Show() moved here in order to resolve issue with display of scrollbars 1636 // fix; ensure the dialog never starts out larger than the browser window. 1637 var viewWidth = GetViewportWidth(); 1638 var viewHeight = GetViewportHeight(); 1639 if (RadWindowInformation.width > viewWidth) RadWindowInformation.width = viewWidth; 1640 if (RadWindowInformation.height > viewHeight) RadWindowInformation.height = viewHeight; 1641 dialogWindow.setSize(RadWindowInformation.width, RadWindowInformation.height); 1642 dialogWindow.set_visibleStatusbar(false); 1643 // Set the window icon 1644 var oTitle = dialogWindow.GetTitlebar(); 1645 var oAnchor = oTitle.getElementsByTagName('a'); 1646 oAnchor[0].style.background = "url(about:blank)"; 1647 1648 dialogWindow.center(); 1649 1650 return dialogWindow; 1651} 1652 1653// opens a dialog window 1654// Parameters: 1655// contentCode - the ContentCode of the content to show in the dialog. Required. 1656// modal - if true the dialog is modal, if false it is pseudo modal, meaning it can postback etc. If not supplied, false (pseudo) is assumed 1657// urlParamString - any url params to pass to the window (e.g., the server). Should be a string like param1=value1¶m2=value2 etc. 1658// args - any arguments passed to the client as dialogArguments (for modal), or accessible in opener.dialogWin.args if pseudo
1659// width - the width of the dialog. If not supplied, 600 is assumed 1660// height - the width of the dialog. If not supplied, 400 is assumed 1661// returnFunc -- reference to the function (on this caller) to be called when the dialog is done 1662// navigationCode - If specified, this value is put into the query string. This is to allow the IQD to 1663// utilize this function. 1664// title - the title to appear on the pop-up window 1665function CMOpenDialog(contentCode, modal, width, height, urlParamString, args, returnFunc, navigationCode, title) 1666{ 1667 // contentCode is required 1668 if (contentCode != null) 1669 { 1670 // initialize any parameters not sent 1671 if (urlParamString == null) 1672 urlParamString = ""; 1673 else if (urlParamString.substr(0, 1) != "&") 1674 urlParamString = "&" + urlParamString; 1675 if (width == null) 1676 width = 600; 1677 if (height == null) 1678 height = 400; 1679 if (title == null) 1680 title = ''; 1681 1682 var url = gWebRoot + "/iMIS/ContentManagement/Template.aspx?ContentCode=" + contentCode + urlParamString; 1683 if (typeof gWebsiteKey != 'undefined' && gWebsiteKey != 'null' && url.indexOf('&WebsiteKey=') < 0) 1684 url += '&WebsiteKey=' + gWebsiteKey; 1685 1686 if (navigationCode != null) 1687 url = url + "&NavigationCode=" + navigationCode; 1688 1689 ShowDialog(url, args, width, height, title, '', 'E', returnFunc); 1690 } 1691 else 1692 alert('contentCode is required!'); 1693} 1694 1695function GetViewportWidth() 1696{ 1697 var viewportwidth; 1698 1699 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight 1700 if (typeof window.innerWidth != 'undefined') 1701 { 1702 viewportwidth = window.innerWidth; 1703 } 1704 else if (typeof document.documentElement != 'undefined' 1705 && typeof document.documentElement.clientWidth != 1706 'undefined' && document.documentElement.clientWidth != 0) 1707 { 1708 // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document) 1709 viewportwidth = document.documentElement.clientWidth; 1710 } 1711 else 1712 { 1713 // older versions of IE 1714 viewportwidth = document.getElementsByTagName('body')[0].clientWidth; 1715 } 1716 1717 return viewportwidth; 1718} 1719 1720function GetViewportHeight() 1721{ 1722 var viewportheight; 1723 1724 if (typeof window.innerWidth != 'undefined') 1725 { 1726 viewportheight = window.innerHeight; 1727 } 1728 else if (typeof document.documentElement != 'undefined' 1729 && typeof document.documentElement.clientWidth != 1730 'undefined' && document.documentElement.clientWidth != 0) 1731 { 1732 viewportheight = document.documentElement.clientHeight; 1733 } 1734 else 1735 { 1736 viewportheight = document.getElementsByTagName('body')[0].clientHeight; 1737 } 1738 1739 return viewportheight; 1740} 1741 1742// One object tracks the current modal dialog opened from this window. 1743var dialogWin = new Object(); 1744 1745// Generate a pseudo modal dialog that can do postback etc. i.e., it is a real window that acts modal 1746// Parameters: 1747// url -- URL of the page/frameset to be loaded into dialog 1748// width -- pixel width of the dialog window 1749// height -- pixel height of the dialog window 1750// returnFunc -- reference to the function (on this page) 1751// that is to act on the data returned from the dialog 1752// args -- [optional] any data you need to pass to the dialog 1753function ShowPseudoDialog(url, args, width, height, returnFunc) 1754{ 1755 // set the window events on the parent so that trying to go back there set focus back to the dialog 1756 window.attachEvent('onclick', checkModal); 1757 window.attachEvent('onfocus', checkModal); 1758 1759 // SAT - 11/9/2006 - DT18027
1760 // Added the following try/catch to handle the exception which occurs when the parent of the 1761 // dialog is hosted in c/s. 1762 var newDialog = false; 1763 try 1764 { 1765 if (!dialogWin.win || (dialogWin.win && dialogWin.win.closed)) 1766 newDialog = true; 1767 } 1768 catch (e) 1769 { 1770 if (e.message == 'The remote server machine does not exist or is unavailable') 1771 newDialog = true; 1772 } 1773 1774 if (newDialog) 1775 { 1776 // Initialize properties of the modal dialog object. 1777 dialogWin.returnFunc = returnFunc; 1778 dialogWin.returnedValue = ""; 1779 dialogWin.args = args; 1780 if (typeof (returnFunc) == "string" && returnFunc != "") 1781 { 1782 if (url.indexOf("?") < 0) 1783 url += "?" + "iCallbackFunction=" + returnFunc; 1784 else 1785 url += "&" + "iCallbackFunction=" + returnFunc; 1786 } 1787 dialogWin.url = url; 1788 dialogWin.width = width; 1789 dialogWin.height = height; 1790 // Keep name unique so Navigator doesn't overwrite an existing dialog. 1791 dialogWin.name = (new Date()).getSeconds().toString(); 1792 // Assemble window attributes and center on the screen 1793 dialogWin.left = (screen.width - dialogWin.width) / 2; 1794 dialogWin.top = (screen.height - dialogWin.height) / 2; 1795 var attr = "left=" + dialogWin.left + ",top=" + 1796 dialogWin.top + ",scrollbars=yes,resizable=yes,width="
1796+ dialogWin.width + 1797 ",height=" + dialogWin.height; 1798 1799 // Generate the dialog and make sure it has focus. 1800 dialogWin.win = window.open(dialogWin.url, dialogWin.name, attr); 1801 dialogWin.win.focus(); 1802 } else 1803 { 1804 dialogWin.win.focus(); 1805 } 1806} 1807 1808// Invoked by onFocus event handler of EVERY frame, 1809// return focus to dialog window if it's open. 1810function checkModal() 1811{ 1812 setTimeout("finishChecking()", 50); 1813 return true; 1814} 1815 1816function finishChecking() 1817{ 1818 // try-catch required to handle exception when dialog's parent is hosted in omnis. 1819 try 1820 { 1821 if (dialogWin.win && !dialogWin.win.closed) 1822 { 1823 dialogWin.win.focus(); 1824 } 1825 } 1826 catch (e) 1827 { 1828 if (e.message == 'The remote server machine does not exist or is unavailable') 1829 return; 1830 } 1831} 1832 1833function wait() 1834{ 1835 window.document.body.style.cursor = "wait"; 1836 1837 //disable all input type=submit,img,button objects so user doesn't 1838 //inadvertantly click a button while page is posting 1839 var inputs = document.getElementsByTagName("input"); 1840 for (var i = 0; i < inputs.length; i++) 1841 { 1842 if (inputs[i].getAttribute("type") == null) 1843 continue; 1844 var type = inputs[i].getAttribute("type").toLowerCase(); 1845 if ((type == "submit" || type == "image" || type == "button")) 1846 inputs[i].disabled = true; 1847 } 1848} 1849function waitStop() 1850{ 1851 window.document.body.style.cursor = "default"; 1852 1853 //disable all input type=submit,img,button objects so user doesn't 1854 //inadvertantly click a button while page is posting 1855 var inputs = document.getElementsByTagName("input"); 1856 for (var i = 0; i < inputs.length; i++) 1857 { 1858 if (inputs[i].getAttribute("type") == null) 1859 continue; 1860 var type = inputs[i].getAttribute("type").toLowerCase(); 1861 if ((type == "submit" || type == "image" || type == "button")) 1862 inputs[i].disabled = false; 1863 } 1864} 1865 1866function dropDownListNavigate(ddl) 1867{ 1868 var loc = ddl.options[ddl.selectedIndex].value; 1869 if (loc != "") 1870 { 1871 if (loc.substr(0, 1) == '~') 1872 { 1873 loc = gWebRoot + loc.substr(1); 1874 } 1875 location.href = loc; 1876 } 1877} 1878 1879// opens the BSA object browser as a pop-up allowing the user to select one or more documents or folders for return to the caller 1880// Parameters: 1881// urlParamString - any url params to pass to the browser (see list of available arguments in object browser documentation. 1882// Should be a string like param1=value1¶m2=value2 etc. 1883// returnFunc -- reference to the function (on the caller) to be called when the dialog is done. This function will receive 1884// the following parameters from the browser: 1885// count - the number of keys selected by the user 1886// keys - a comma delimited list of the keys selected: HierarchyKeys for folders or DocumentKeys for anything else 1887// type - the DocumentTypeCode of the document selected if there is only one. Null if more than one 1888// name - the DocumentName of the document selected if there is only one. Null if more than one 1889// executeCallbackOnClose - whether to execute returnFunc anytime the dialog is closed (true), or only when it's closed after a commit operation (false). 1890function OpenObjectBrowserSized(urlParamString, returnFunc, singleSelect, publishedOnly, args, width, height, executeCallbackOnClose, windowTitle) 1891{ 1892 var url = gWebRoot + '/AsiCommon/Controls/BSA/ObjectBrowser.aspx?TemplateType=E&DialogMode=true'; 1893 var preserveBusContainer = true; 1894 1895 if (urlParamString != null) 1896 { 1897 var paramsArray = urlParamString.split("&"); 1898 1899 // we have a few defaults for the pop-up browser that differ from the browser's normal defaults. 1900 // Set them unless they are already in the urlParamString 1901 if (FindParameterInArray("Mode", paramsArray) == null) 1902 urlParamString += "&Mode=SelectContent"; 1903 if (singleSelect != null && singleSelect && FindParameterInArray("AllowMultiSelect", paramsArray) == null) 1904 urlParamString += "&AllowMultiSelect=false"; 1905 if (publishedOnly != null && FindParameterInArray("PublishedOnly", paramsArray) == null) 1906 urlParamString += "&PublishedOnly=" + publishedOnly; 1907 1908 if (urlParamString.substr(0, 1) != "&") 1909 url += "&"; 1910 url += urlParamString; 1911 1912 //check to see if stateful business container needs to be preserved 1913 if (FindParameterInArray("PreserveContainer", paramsArray) != null) 1914 preserveBusContainer = false; 1915 } 1916 else 1917 { 1918 url += "&Mode=SelectContent"; 1919 if (singleSelect != null && singleSelect) 1920 url += "&AllowMultiSelect=false"; 1921 if (publishedOnly != null) 1922 url += "&PublishedOnly=" + publishedOnly; 1923 } 1924 if (windowTitle == null) 1925 windowTitle = "Document Browser"; 1926 //CP 11/7/12 SBI#32199: Setting preserveStatefulBusinessContainer value to true because otherwise iparts' configs using this would break if tried to call twice in a row 1927 return ShowDialog(url, args, width, height, windowTitle, null, 'E', returnFunc, 'ObjectBrowser', false, preserveBusContainer, (executeCallbackOnClose ? returnFunc : null)); 1928} 1929 1930// opens the BSA object browser as a pop-up allowing the user to select one or more documents or folders for return to the caller 1931// Parameters: 1932// urlParamString - any url params to pass to the browser (see list of available arguments in object browser documentation. 1933// Should be a string like param1=value1¶m2=value2 etc. 1934// returnFunc -- reference to the function (on the caller) to be called when the dialog is done. This function will receive 1935// the following parameters from the browser: 1936// count - the number of keys selected by the user 1937// keys - a comma delimited list of the keys selected: HierarchyKeys for folders or DocumentKeys for anything else 1938// type - the DocumentTypeCode of the document selected if there is only one. Null if more than one 1939// name - the DocumentName of the document selected if there is only one. Null if more than one 1940function OpenObjectBrowser(urlParamString, returnFunc, singleSelect, publishedOnly, args, windowTitle) 1941{ 1942 return OpenObjectBrowserSized(urlParamString, returnFunc, singleSelect, publishedOnly, args, 800, 600, false, windowTitle); 1943} 1944 1945function OpenContentForSaveAs(documentHierarchyKey, filename, returnFunc) {
1946 var url = gWebRoot + '/AsiCommon/Controls/BSA/ObjectBrowser.aspx?TypeFilter=CON,CFL&ShowMenu=false&ShowFilename=true&DialogMode=true&PublishedOnly=false&Mode=SelectContainer&AutoSizeObjectBrowser=true'; 1947 1948 url += "&DocumentHierarchyKey=" + documentHierarchyKey; 1949 url += "&Filename=" + filename; 1950 1951 //function ShowDialog(url, args, width, height, title, iconUrl, templateType, callBackFunction, windowName, closeWindowOnCommit, preserveStatefulBusinessContainer, dialogCloseFunction, sourceObject) 1952 return ShowDialog(url, '', 800, 600, 'Content Browser', null, 'E', returnFunc, 'ObjectBrowser', false, false, null); 1953} 1954function OpenContentForEdit(contentHierarchyKey) 1955{ 1956 var url = gWebRoot + '/iMIS/ContentManagement/ContentDesigner.aspx?TemplateType=E&ShowMenu=true&DialogMode=true'; 1957 1958 url += "&ContentHierarchyKey=" + contentHierarchyKey; 1959 1960 var obWindow = radopen(url, 'ObjectBrowser'); 1961 return obWindow; 1962} 1963function EditContentItem(hierarchyKey) 1964{ 1965 OpenContentForEdit(hierarchyKey); 1966} 1967function OpenFinderAdder(returnFunc, singleSelect, documentKey, documentPath, atomName, displayValueColumn, keyValueColumn, width, height) 1968{ 1969 OpenFinderAdderWithQueryFilter(returnFunc, singleSelect, documentKey, documentPath, atomName, displayValueColumn, keyValueColumn, "", width, height, ""); 1970} 1971function OpenFinderAdderWithQueryFilter(returnFunc, singleSelect, documentKey, documentPath, atomName, displayValueColumn, keyValueColumn, filterValue, width, height, addTargetUrl) 1972{ 1973 var url = gWebRoot + '/AsiCommon/Controls/Shared/FinderAdder/FinderAdder.aspx?DialogMode=true'; 1974 1975 if (documentKey != null) 1976 url += "&DocumentKey=" + documentKey; 1977 else if (documentPath != null) 1978 url += "&DocumentPath=" + documentPath; 1979 else if (atomName != null) 1980 url += "&AtomName=" + atomName; 1981 1982 if (displayValueColumn != null && displayValueColumn.length > 0) 1983 url += "&DisplayValueColumn=" + displayValueColumn; 1984 if (keyValueColumn != null && keyValueColumn.length > 0) 1985 url += "&DataKeyName=" + keyValueColumn; 1986 1987 if (filterValue != null && filterValue.length > 0) 1988 url += "&filterValue=" + filterValue; 1989 1990 // we have a few defaults for the pop-up browser that differ from the browser's normal defaults. 1991 // Set them unless they are already in the urlParamString 1992 if (singleSelect != null && singleSelect) 1993 url += "&AllowMultiSelect=false"; 1994 else 1995 url += "&AllowMultiSelect=true&PagingEnabled=false"; 1996 1997 if (addTargetUrl != null && addTargetUrl.length > 0) 1998 url += "&AddTargetUrl=" + addTargetUrl; 1999 2000 if (width == null) 2001 width = 800; 2002 if (height == null) 2003 height = 600; 2004 2005 var windowTitle = "Find"; 2006 if (addTargetUrl != null && addTargetUrl.length > 0) windowTitle = "Find/Add"; 2007 2008 return ShowDialog(url, null, width, height, windowTitle, null, 'E', returnFunc, 'ObjectBrowser', false, true); 2009} 2010function OpenPartyFinderAdder(returnFunc, singleSelect, documentKey, documentPath, atomName, displayValueColumn, keyValueColumn, width, height) { 2011 OpenPartyFinderAdderWithQueryFilter(returnFunc, singleSelect, documentKey, documentPath, atomName, displayValueColumn, keyValueColumn, "", width, height, false, null); 2012} 2013function OpenPartyFinderAdderWithQueryFilter(returnFunc, singleSelect, documentKey, documentPath, atomName, displayValueColumn, keyValueColumn, filterValue, width, height, addGuests, addType, addTargetShortcut) { 2014 var url = gWebRoot + '/AsiCommon/Controls/Shared/FinderAdder/PartyFinderAdder.aspx?DialogMode=true'; 2015 2016 if (documentKey != null) 2017 url += "&DocumentKey=" + documentKey; 2018 else if (documentPath != null) 2019 url += "&DocumentPath=" + documentPath; 2020 else if (atomName != null) 2021 url += "&AtomName=" + atomName; 2022 2023 if (displayValueColumn != null && displayValueColumn.length > 0) 2024 url += "&DisplayValueColumn=" + displayValueColumn; 2025 if (keyValueColumn != null && keyValueColumn.length > 0) 2026 url += "&DataKeyName=" + keyValueColumn; 2027 2028 if (filterValue != null && filterValue.length > 0) 2029 url += "&filterValue=" + filterValue; 2030 2031 // we have a few defaults for the pop-up browser that differ from the browser's normal defaults. 2032 // Set them unless they are already in the urlParamString 2033 if (singleSelect != null && singleSelect) 2034 url += "&AllowMultiSelect=false"; 2035 else 2036 url += "&AllowMultiSelect=true&PagingEnabled=false"; 2037 2038 if (addGuests != null && addGuests == "True") 2039 url += "&AllowAdd=" + addGuests; 2040 2041 if (addType != null && addType.length > 0) 2042 url += "&PartyType=" + addType; 2043 2044 if (width == null) 2045 width = 800; 2046 if (height == null) 2047 height = 600; 2048 2049 var windowTitle = "Find"; 2050 if (addGuests != null && addGuests == "True") windowTitle = "Find/Add"; 2051 2052 if (addTargetShortcut != null && addTargetShortcut.length > 0) 2053 url += "&addTargetShortcut=" + addTargetShortcut; 2054 2055 return ShowDialog(url, null, width, height, windowTitle, null, 'E', returnFunc, 'ObjectBrowser', false, true); 2056} 2057function OpenFileUpload(returnFunc, documentStorageKey, documentServerPath, maxFileSize, allowedTypes, enableDescriptionField) 2058{
2059 var url = gWebRoot + '/AsiCommon/Controls/Shared/FileUpload/FileUpload.aspx'; 2060 if (documentStorageKey != null && documentStorageKey.length > 0) 2061 url += "?DocumentStorageKey=" + documentStorageKey; 2062 if (documentServerPath != null && documentServerPath.length > 0) 2063 { 2064 if (url.indexOf("?") < 0) 2065 url += "?DocumentServerPath=" + documentServerPath; 2066 else 2067 url += "&DocumentServerPath=" + documentServerPath; 2068 } 2069 if (maxFileSize != null && maxFileSize > 0) 2070 { 2071 if (url.indexOf("?") < 0) 2072 url += "?MaxFileUploadSize=" + maxFileSize; 2073 else 2074 url += "&MaxFileUploadSize=" + maxFileSize; 2075 } 2076 if (allowedTypes != null && allowedTypes.length > 0) { 2077 if (url.indexOf("?") < 0) 2078 url += "?AllowedTypes=" + allowedTypes; 2079 else 2080 url += "&AllowedTypes=" + allowedTypes; 2081 } 2082 if (enableDescriptionField != null && enableDescriptionField.toLowerCase() == 'true') { 2083 if (url.indexOf("?") < 0) 2084 url += "?EnableDescriptionField=true"; 2085 else 2086 url += "&EnableDescriptionField=true"; 2087 } 2088 2089 return ShowDialog(url, null, 450, 430, "File Upload", null, 'E', returnFunc, 'GenericWindow', false, true); 2090} 2091 2092// opens the BSA object browser in Save mode 2093// Parameters: 2094// urlParamString - any url params to pass to the browser (see list of available arguments in object browser documentation. 2095// Should be a string like param1=value1¶m2=value2 etc. 2096// returnFunc -- reference to the function (on the caller) to be called when the dialog is done. This function will receive 2097// the following parameters from the browser: 2098// hierarchyKey - the hierarchy key of the folder selected by the user 2099// filename - the name of the file to be saved 2100function OpenObjectSaver(urlParamString, returnFunc) 2101{ 2102 var paramsArray = urlParamString.split("&"); 2103 2104 // we have one default for the saver that differs from the pop-up browser 2105 // Set it unless it is already in the urlParamString 2106 if (FindParameterInArray("ShowFilename", paramsArray) == null) 2107 urlParamString = urlParamString + "&ShowFilename=true"; 2108 if (FindParameterInArray("Mode", paramsArray) == null) 2109 urlParamString = urlParamString + "&Mode=SelectContainer"; 2110 2111 OpenObjectBrowser(urlParamString, returnFunc); 2112} 2113function clickButton(e, buttonid) 2114{ 2115 var bt = document.getElementById(buttonid); 2116 if (typeof bt == 'object') 2117 { 2118 var evt = navigator.appName.indexOf('Netscape') > (-1) ? e : event; 2119 if (evt.keyCode == 13) 2120 { 2121 bt.click(); 2122 return cancelEvent(); 2123 } 2124 } 2125 return true; 2126} 2127 2128var dirty = true; 2129//window.onunload = finish; 2130function finish(buttonId) 2131{ 2132 if (dirty && window.opener) 2133 { 2134 // tryU 2135 { 2136 if (buttonId) 2137 { 2138 var button = window.opener.document.getElementById(buttonId); 2139 2140 if (button == null && window.opener.dialogWin.args != null) 2141 { 2142 button = window.opener.document.getElementById(window.opener.dialogWin.args); 2143 } 2144 if (button != null) 2145 button.click(); 2146 } 2147 2148 if (button == null && window.opener.RefreshBySubmit) 2149 window.opener.RefreshBySubmit(); 2150 2151 if (window.opener.dialogWin.returnFunc != null) 2152 window.opener.dialogWin.returnFunc(); 2153 2154 } 2155 // catch(e) 2156 // { 2157 // // exception will happen when dialog opened from within Client/Server b/c of 2158 // // security. this will be a problem. 2159 // } 2160 } 2161 else if (dirty && parent) 2162 { 2163 // If we were opened in an iframe (for example, in the Edit Pane in ObjectBrowser2), notify the parent page 2164 // that we committed so that it can update any needed status. 2165 if (typeof parent.SubPage_Committed == 'function') 2166 parent.SubPage_Committed(); 2167 else if (parent.objectBrowserClass !== null) 2168 parent.objectBrowserClass.SubPage_Committed(); 2169 } 2170} 2171 2172/* 2173Derived from a script by Alejandro Gervasio.
2174Modified to work in FireFox by Stefan Mischook for Killersites.com 2175 2176How it works: just apply the CSS class of 'column' to your pages' main columns. 2177*/ 2178var MatchColumnsSemaphore = false; 2179matchColumns = function() 2180{ 2181 var divs, contDivs, maxHeight, divHeight, d; 2182 2183 // get all <div> elements in the document 2184 divs = document.getElementsByTagName('div'); 2185 contDivs = []; 2186 2187 // initialize maximum height value 2188 maxHeight = 0; 2189 2190 // iterate over all <div> elements in the document 2191 for (var i = 0; i < divs.length; i++) 2192 { 2193 // make collection with <div> elements with class attribute 'column' 2194 if (/\bcolumn\b/.test(divs[i].className)) 2195 { 2196 d = divs[i]; 2197 contDivs[contDivs.length] = d; 2198 // determine height for <div> element 2199 if (d.offsetHeight) 2200 divHeight = d.offsetHeight; 2201 else if (d.style.pixelHeight) 2202 divHeight = d.style.pixelHeight; 2203 else 2204 { 2205 // added the time out for use when resizing is happening onload (like in rad window) 2206 if (MatchColumnsSemaphore) 2207 MatchColumnsSemaphore = false; 2208 else 2209 { 2210 window.setTimeout(matchColumns, 500); 2211 MatchColumnsSemaphore = true; 2212 return; 2213 } 2214 } 2215 // calculate maximum height 2216 maxHeight = Math.max(maxHeight, divHeight); 2217 } 2218 } 2219 2220 // assign maximum height value to all of container <div> elements 2221 for (var i = 0; i < contDivs.length; i++) 2222 contDivs[i].style.height = maxHeight + "px"; 2223} 2224 2225// Runs the script when page loads 2226window.onload = function() 2227{ 2228 if (document.getElementsByTagName) 2229 matchColumns(); 2230} 2231 2232// Set the next fields value and append additional values 2233function setNextAppend(theField) 2234{ 2235 theForm = theField.form; 2236 for (i = 0; i < theForm.elements.length; i++) 2237 { 2238 if (theForm.elements[i].id == theField.id) 2239 { 2240 theForm.elements[i + 1].value += '\n' + theField.value; 2241 break; 2242 } 2243 } 2244} 2245 2246// Set the next fields value without appending 2247function setNext(theField) 2248{ 2249 theForm = theField.form; 2250 for (i = 0; i < theForm.elements.length; i++) 2251 { 2252 if (theForm.elements[i].id == theField.id) 2253 { 2254 theForm.elements[i + 1].value = theField.value; 2255 break; 2256 } 2257 } 2258} 2259 2260// Input type button on panels that need to handle navigating 2261function ButtonNavigate(url) 2262{ 2263 if (url != "") 2264 location.href = url; 2265 2266} 2267 2268//<![CDATA[ 2269 2270//***************************************************************************** 2271// Do not remove this notice. 2272// 2273// Copyright 2000 by Mike Hall. 2274// See http://www.brainjar.com for terms of use. 2275//***************************************************************************** 2276 2277//---------------------------------------------------------------------------- 2278// Code to determine the browser and version. 2279//---------------------------------------------------------------------------- 2280function Browser() 2281{ 2282 2283 var ua, s, i; 2284 2285 this.isIE = false; // Internet Explorer 2286 this.isNS = false; // Netscape 2287 this.version = null; 2288 2289 ua = navigator.userAgent; 2290 2291 s = "MSIE"; 2292 if ((i = ua.indexOf(s)) >= 0) 2293 { 2294 this.isIE = true; 2295 this.version = parseFloat(ua.substr(i + s.length)); 2296 return; 2297 } 2298 2299 s = "Netscape6/"; 2300 if ((i = ua.indexOf(s)) >= 0) 2301 { 2302 this.isNS = true; 2303 this.version = parseFloat(ua.substr(i + s.length)); 2304 return; 2305 } 2306 2307 // Treat any other "Gecko" browser as NS 6.1. 2308 2309 s = "Gecko"; 2310 if ((i = ua.indexOf(s)) >= 0) 2311 { 2312 this.isNS = true; 2313 this.version = 6.1; 2314 return; 2315 } 2316} 2317 2318var browser = new Browser(); 2319 2320//---------------------------------------------------------------------------- 2321// Code for handling the menu bar and active button. 2322//---------------------------------------------------------------------------- 2323 2324var activeButton = null; 2325 2326/* [MODIFIED] This code commented out, not needed for activate/deactivate 2327on mouseover. 2328 2329// Capture mouse clicks on the page so any active button can be 2330// deactivated. 2331 2332if (browser.isIE) 2333document.onmousedown = pageMousedown; 2334else 2335document.addEventListener("mousedown", pageMousedown, true); 2336 2337function pageMousedown(event) { 2338 2339var el; 2340 2341// If there is no active button, exit. 2342 2343if (activeButton == null) 2344return; 2345 2346// Find the element that was clicked on. 2347 2348if (browser.isIE) 2349el = window.event.srcElement; 2350else 2351el = (event.target.tagName ? event.target : event.target.parentNode); 2352 2353// If the active button was clicked on, exit. 2354 2355if (el == activeButton) 2356return; 2357 2358// If the element is not part of a menu, reset and clear the active 2359// button. 2360 2361if (getContainerWith(el, "DIV", "menu") == null) { 2362resetButton(activeButton); 2363activeButton = null; 2364} 2365} 2366 2367[END MODIFIED] */ 2368 2369function buttonClick(event, menuId) 2370{ 2371 var button; 2372 2373 // Get the target button element. 2374 2375 if (browser.isIE) 2376 button = window.event.srcElement; 2377 else 2378 button = event.currentTarget; 2379 2380 // Blur focus from the link to remove that annoying outline. 2381 2382 button.blur(); 2383 2384 // Associate the named menu to this button if not already done. 2385 // Additionally, initialize menu display. 2386 2387 if (button.menu == null) 2388 { 2389 button.menu = document.getElementById(menuId); 2390 if (button.menu.isInitialized == null) 2391 menuInit(button.menu); 2392 } 2393 2394 // [MODIFIED] Added for activate/deactivate on mouseover. 2395 2396 // Set mouseout event handler for the button, if not already done. 2397 2398 if (button.onmouseout == null) 2399 button.onmouseout = buttonOrMenuMouseout; 2400 2401 // Exit if this button is the currently active one. 2402 2403 if (button == activeButton) 2404 return false; 2405 2406 // [END MODIFIED] 2407 2408 // Reset the currently active button, if any. 2409 2410 if (activeButton != null) 2411 resetButton(activeButton); 2412 2413 // Activate this button, unless it was the currently active one. 2414 2415 if (button != activeButton) 2416 { 2417 depressButton(button); 2418 activeButton = button; 2419 } 2420 else 2421 activeButton = null; 2422 2423 return false; 2424} 2425 2426function buttonMouseover(event, menuId) 2427{ 2428 var button; 2429 2430 // [MODIFIED] Added for activate/deactivate on mouseover. 2431 2432 // Activates this button's menu if no other is currently active. 2433 2434 if (activeButton == null) 2435 { 2436 buttonClick(event, menuId); 2437 return; 2438 } 2439 2440 // [END MODIFIED] 2441 2442 // Find the target button element. 2443 2444 if (browser.isIE) 2445 button = window.event.srcElement; 2446 else 2447 button = event.currentTarget; 2448 2449 // If any other button menu is active, make this one active instead. 2450 2451 if (activeButton != null && activeButton != button) 2452 buttonClick(event, menuId); 2453} 2454 2455function depressButton(button) 2456{ 2457 2458 var x, y; 2459 2460 // Update the button's style class to make it look like it's 2461 // depressed. 2462 2463 button.className += " menuButtonActive"; 2464 2465 // [MODIFIED] Added for activate/deactivate on mouseover. 2466 2467 // MODIFIED - R.Wenger 9/22/04 - attache event because the code below won't if there is already another event there (e.g., rollover) 2468 button.attachEvent('onmouseout', buttonOrMenuMouseout); 2469 2470 // Set mouseout event handler for the button, if not already done. 2471 if (button.onmouseout == null) 2472 button.onmouseout = buttonOrMenuMouseout; 2473 if (button.menu.onmouseout == null) 2474 button.menu.onmouseout = buttonOrMenuMouseout; 2475 2476 // [END MODIFIED] 2477 2478 // Position the associated drop down menu under the button and 2479 // show it. 2480 2481 x = getPageOffsetLeft(button); 2482 y = getPageOffsetTop(button) + button.offsetHeight; 2483
2484 // For IE, adjust position. 2485 2486 if (browser.isIE) 2487 { 2488 x += button.offsetParent.clientLeft; 2489 y += button.offsetParent.clientTop; 2490 } 2491 2492 // [MODIFIED] Adjust menu position if it pops up off screen [JG 1/22/05] 2493 var menuRight = 0; 2494 var menuBottom = 0; 2495 var bodyRight = document.body.offsetLeft + document.body.offsetWidth - 30; // -30 for the scroll bar; 2496 var bodyBottom = document.body.offsetTop + document.body.offsetHeight - 30; // -30 for the scroll bar; 2497 var parent = getParent(button.menu); 2498 2499 var menuOffsetLeft = x + getPageOffsetLeft(parent) 2500 var menuOffsetTop = y + getPageOffsetTop(parent) + parent.offsetHeight; 2501 2502 if (browser.isIE) 2503 { 2504 menuRight = menuOffsetLeft + button.menu.clientWidth; 2505 menuBottom = menuOffsetTop + button.menu.clientHeight; 2506 } 2507 else 2508 { 2509 // i don't know how to get the width and height for 2510 // DIV elements on non-IE browsers, so just assume 2511 // width to be 100 pixels and height to be 300 2512 menuRight = menuOffsetLeft + 100; 2513 menuBottom = menuOffsetTop + 300; 2514 } 2515 2516 if (menuRight > bodyRight) 2517 { 2518 x -= (menuRight - bodyRight); 2519 menuRight = x + button.menu.clientWidth; 2520 } 2521 if (menuBottom > bodyBottom) 2522 { 2523 //y -= (menuBottom - bodyBottom); 2524 menuBottom = y + button.menu.clientHeight; 2525 } 2526 // [END MODIFIED] 2527 2528 // Set menu position and make it visible 2529 button.menu.style.left = x + "px"; 2530 button.menu.style.top = y + "px"; 2531 button.menu.style.visibility = "visible"; 2532 2533 // [MODIFIED] Added to hide <select> fields so the menu won't be covered 2534 var allSelectFields = document.getElementsByTagName("select"); 2535 2536 for (i = 0; i < allSelectFields.length; i++) 2537 { 2538 var selectField = allSelectFields(i); 2539 2540 // only hide select field if its at least partially covered by the menu 2541 var selectFieldX = getPageOffsetLeft(selectField); 2542 var selectFieldY = getPageOffsetTop(selectField) + selectField.offsetHeight; 2543 var selectFieldRight = 0; 2544 var selectFieldBottom = 0; 2545 2546 if (browser.isIE) 2547 { 2548 selectFieldX += selectField.offsetParent.clientLeft; 2549 selectFieldY += selectField.offsetParent.clientTop; 2550 2551 selectFieldRight += selectFieldX + selectField.clientWidth; 2552 selectFieldBottom += selectFieldY + selectField.clientHeight; 2553 } 2554 else 2555 { 2556 selectFieldRight += selectFieldX + 200; 2557 selectFieldBottom += selectFieldY + 20; 2558 } 2559 2560 menuBottom += 5; 2561 2562 //alert("X: "+selectFieldX+"\t"+menuOffsetLeft+"\r\nR: "+selectFieldRight+"\t"+menuRight+"\r\nY: "+selectFieldY+"\t"+menuOffsetTop+"\r\nB: "+selectFieldBottom+"\t"+menuBottom); 2563 if (squareIntersectsSquare(selectFieldX, selectFieldRight, selectFieldY, selectFieldBottom, menuOffsetLeft, menuRight, menuOffsetTop, menuBottom)) 2564 { 2565 selectField.style.visibility = "hidden"; 2566 } 2567 } 2568 // [END MODIFIED] 2569} 2570 2571function numberOrder(a, b) { return a - b; } 2572 2573function squareIntersectsSquare(aLeft, aRight, aTop, aBottom, bLeft, bRight, bTop, bBottom) 2574{ 2575 xArray = new Array(aLeft, aRight, bLeft, bRight); 2576 xArray.sort(numberOrder); 2577 yArray = new Array(aTop, aBottom, bTop, bBottom); 2578 yArray.sort(numberOrder); 2579 2580 if ((xArray[0] == aLeft && xArray[1] == aRight) || 2581 (xArray[0] == bLeft && xArray[1] == bRight)) 2582 return false; 2583 2584 if ((yArray[0] == aTop && yArray[1] == aBottom) || 2585 (yArray[0] == bTop && yArray[1] == bBottom)) 2586 return false; 2587 2588 return true; 2589} 2590 2591function resetButton(button) 2592{ 2593 2594 // Restore the button's style class. 2595 2596 removeClassName(button, "menuButtonActive"); 2597 2598 // Hide the button's menu, first closing any sub menus. 2599 2600 if (button.menu != null) 2601 { 2602 closeSubMenu(button.menu); 2603 button.menu.style.visibility = "hidden"; 2604 } 2605 2606 // [MODIFIED] Added to hide <select> fields so the menu won't be covered 2607 var allSelectFields = document.getElementsByTagName("select"); 2608 for (i = 0; i < allSelectFields.length; i++) 2609 { 2610 allSelectFields(i).style.visibility = "visible"; 2611 } 2612 // [END MODIFIED] 2613} 2614 2615//---------------------------------------------------------------------------- 2616// Code to handle the menus and sub menus. 2617//---------------------------------------------------------------------------- 2618 2619function menuMouseover(event) 2620{ 2621 2622 var menu; 2623 2624 // Find the target menu element. 2625 2626 if (browser.isIE) 2627 menu = getContainerWith(window.event.srcElement, "DIV", "menu"); 2628 else 2629 menu = event.currentTarget; 2630 2631 // Close any active sub menu. 2632 2633 if (menu.activeItem != null) 2634 closeSubMenu(menu); 2635} 2636 2637function menuItemMouseover(event, menuId) 2638{ 2639 2640 var item, menu, x, y; 2641 2642 // Find the target item element and its parent menu element. 2643 2644 if (browser.isIE) 2645 item = getContainerWith(window.event.srcElement, "A", "menuItem"); 2646 else 2647 item = event.currentTarget; 2648 menu = getContainerWith(item, "DIV", "menu"); 2649 2650 // Close any active sub menu and mark this one as active. 2651 2652 if (menu.activeItem != null) 2653 closeSubMenu(menu); 2654 menu.activeItem = item; 2655 2656 // Highlight the item element. 2657 2658 item.className += " menuItemHighlight"; 2659 2660 // Initialize the sub menu, if not already done. 2661 2662 if (item.subMenu == null) 2663 { 2664 item.subMenu = document.getElementById(menuId); 2665 if (item.subMenu.isInitialized == null) 2666 menuInit(item.subMenu); 2667 } 2668 2669 // [MODIFIED] Added for activate/deactivate on mouseover. 2670 2671 // Set mouseout event handler for the sub menu, if not already done. 2672 2673 if (item.subMenu.onmouseout == null) 2674 item.subMenu.onmouseout = buttonOrMenuMouseout; 2675 2676 // [END MODIFIED] 2677 2678 // Get position for submenu based on the menu item. 2679 2680 x = getPageOffsetLeft(item) + item.offsetWidth; 2681 y = getPageOffsetTop(item); 2682 2683 // Adjust position to fit in view. 2684 2685 var maxX, maxY; 2686 2687 if (browser.isNS) 2688 { 2689 maxX = window.scrollX + window.innerWidth; 2690 maxY = window.scrollY + window.innerHeight; 2691 } 2692 if (browser.isIE) 2693 { 2694 maxX = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft) + 2695 (document.documentElement.clientWidth != 0 ? document.documentElement.clientWidth : document.body.clientWidth);
2696 maxY = Math.max(document.documentElement.scrollTop, document.body.scrollTop) + 2697 (document.documentElement.clientHeight != 0 ? document.documentElement.clientHeight : document.body.clientHeight); 2698 } 2699 maxX -= item.subMenu.offsetWidth; 2700 maxY -= item.subMenu.offsetHeight; 2701 2702 if (x > maxX) 2703 x = Math.max(0, x - item.offsetWidth - item.subMenu.offsetWidth 2704 + (menu.offsetWidth - item.offsetWidth)); 2705 y = Math.max(0, Math.min(y, maxY)); 2706 2707 // Position and show the sub menu. 2708 2709 item.subMenu.style.left = x + "px"; 2710 item.subMenu.style.top = y + "px"; 2711 item.subMenu.style.visibility = "visible"; 2712 2713 // Stop the event from bubbling. 2714 2715 if (browser.isIE) 2716 window.event.cancelBubble = true; 2717 else 2718 event.stopPropagation(); 2719} 2720 2721function closeSubMenu(menu) 2722{ 2723 2724 if (menu == null || menu.activeItem == null) 2725 return; 2726 2727 // Recursively close any sub menus. 2728 2729 if (menu.activeItem.subMenu != null) 2730 { 2731 closeSubMenu(menu.activeItem.subMenu); 2732 menu.activeItem.subMenu.style.visibility = "hidden"; 2733 menu.activeItem.subMenu = null; 2734 } 2735 removeClassName(menu.activeItem, "menuItemHighlight"); 2736 menu.activeItem = null; 2737} 2738 2739// [MODIFIED] Added for activate/deactivate on mouseover. Handler for mouseout 2740// event on buttons and menus. 2741 2742function buttonOrMenuMouseout(event) 2743{ 2744 var el; 2745 2746 // If there is no active button, exit. 2747 2748 if (activeButton == null) 2749 return; 2750 2751 // Find the element the mouse is moving to. 2752 2753 if (browser.isIE) 2754 el = window.event.toElement; 2755 else if (event.relatedTarget != null) 2756 el = (event.relatedTarget.tagName ? event.relatedTarget : getParent(event.relatedTarget)); 2757 2758 // If the element is not part of a menu, reset the active button. 2759 2760 if (getContainerWith(el, "DIV", "menu") == null) 2761 { 2762 resetButton(activeButton); 2763 activeButton = null; 2764 } 2765 // MODIFIED - R.Wenger 9/22/04 - remove event attached in depressButton above 2766 window.event.srcElement.detachEvent('onmouseout', buttonOrMenuMouseout); 2767} 2768 2769// [END MODIFIED] 2770 2771//---------------------------------------------------------------------------- 2772// Code to initialize menus. 2773//---------------------------------------------------------------------------- 2774 2775function menuInit(menu) 2776{ 2777 2778 var itemList, spanList; 2779 var textEl, arrowEl; 2780 var itemWidth; 2781 var w, dw; 2782 var i, j; 2783 2784 // For IE, replace arrow characters. 2785 2786 if (browser.isIE) 2787 { 2788 menu.style.lineHeight = "2.5ex"; 2789 spanList = menu.getElementsByTagName("SPAN"); 2790 for (i = 0; i < spanList.length; i++) 2791 if (hasClassName(spanList[i], "menuItemArrow")) 2792 { 2793 spanList[i].style.fontFamily = "Webdings"; 2794 spanList[i].firstChild.nodeValue = "4"; 2795 } 2796 } 2797 2798 // Find the width of a menu item. 2799 2800 itemList = menu.getElementsByTagName("A"); 2801 if (itemList.length > 0) 2802 itemWidth = itemList[0].offsetWidth; 2803 else 2804 return; 2805 2806 // For items with arrows, add padding to item text to make the 2807 // arrows flush right. 2808 2809 for (i = 0; i < itemList.length; i++) 2810 { 2811 spanList = itemList[i].getElementsByTagName("SPAN"); 2812 textEl = null; 2813 arrowEl = null; 2814 for (j = 0; j < spanList.length; j++) 2815 { 2816 if (hasClassName(spanList[j], "menuItemText")) 2817 textEl = spanList[j]; 2818 if (hasClassName(spanList[j], "menuItemArrow")) 2819 arrowEl = spanList[j]; 2820 } 2821 if (textEl != null && arrowEl != null) 2822 textEl.style.paddingRight = (itemWidth 2823 - (textEl.offsetWidth + arrowEl.offsetWidth)) + "px"; 2824 } 2825 2826 // Fix IE hover problem by setting an explicit width on first item of 2827 // the menu. 2828 2829 if (browser.isIE) 2830 { 2831 w = itemList[0].offsetWidth; 2832 itemList[0].style.width = w + "px"; 2833 dw = itemList[0].offsetWidth - w; 2834 w -= dw; 2835 itemList[0].style.width = w + "px"; 2836 } 2837 2838 // Mark menu as initialized. 2839 2840 menu.isInitialized = true; 2841} 2842 2843//---------------------------------------------------------------------------- 2844// General utility functions. 2845//---------------------------------------------------------------------------- 2846 2847function getContainerWith(node, tagName, className) 2848{ 2849 2850 // Starting with the given node, find the nearest containing element 2851 // with the specified tag name and style class. 2852 2853 while (node != null) 2854 { 2855 if (node.tagName != null && node.tagName == tagName && 2856 hasClassName(node, className)) 2857 return node; 2858 node = getParent(node); 2859 } 2860 2861 return node; 2862} 2863 2864function hasClassName(el, name) 2865{ 2866 2867 var i, list; 2868 2869 // Return true if the given element currently has the given class 2870 // name. 2871 2872 list = el.className.split(" "); 2873 for (i = 0; i < list.length; i++) 2874 if (list[i] == name) 2875 return true; 2876 2877 return false; 2878} 2879 2880function removeClassName(el, name) 2881{ 2882 2883 var i, curList, newList; 2884 2885 if (el.className == null) 2886 return; 2887
2888 // Remove the given class name from the element's className property. 2889 2890 newList = new Array(); 2891 curList = el.className.split(" "); 2892 for (i = 0; i < curList.length; i++) 2893 if (curList[i] != name) 2894 newList.push(curList[i]); 2895 el.className = newList.join(" "); 2896} 2897 2898function getPageOffsetLeft(el) 2899{ 2900 2901 var x; 2902 2903 // Return the x coordinate of an element relative to the page. 2904 2905 x = el.offsetLeft; 2906 2907 // MODIFIED - R.Wenger - absolute positioning messes up the calculation so only continue if not using absolute positioning 2908 if (el.offsetParent != null && el.offsetParent.style.position != 'absolute') 2909 x += getPageOffsetLeft(el.offsetParent); 2910 2911 return x; 2912} 2913 2914function getPageOffsetTop(el) 2915{ 2916 2917 var y; 2918 2919 // Return the x coordinate of an element relative to the page. 2920 2921 y = el.offsetTop; 2922 // MODIFIED - R.Wenger - absolute positioning messes up the calculation so only continue if not using absolute positioning 2923 if (el.offsetParent != null && el.offsetParent.style.position != 'absolute') 2924 y += getPageOffsetTop(el.offsetParent); 2925 2926 return y; 2927} 2928 2929// Look for any fields with submit actions specified to handle return/enter keypress events. 2930// e.g. <div id="SomeContainerId" data-SubmitAction='{"ButtonId":"ClientSaveButtonId", "ClientId":"ClientControlID"}' /> 2931// e.g. DataPanel.Attributes.Add("data-SubmitAction", string.Format(CultureInfo.InvariantCulture, "{{\"ButtonId\":\"{0}\", \"ClientId\":\"{1}\"}}", Update.ClientID, ClientID)); 2932// e.g. DataPanel.Attributes.Add("data-SubmitAction", string.Format(CultureInfo.InvariantCulture, "{{\"ButtonId\":\"{0}\", \"ClientId\":\"{1}\", \"HiddenFocusableFieldId\":\"{2}\"}}", Update.ClientID, ClientID, HiddenFocusableFieldId.ClientID)); 2933 Sys.Application.add_load(function () { 2934 handleSubmitActions(); 2935 Sys.Application.remove_load(function () { 2936 handleSubmitActions(); 2937 }); 2938 }); 2939 2940 function handleSubmitActions() { 2941 // Look for any submit actions. 2942 var fields = jQuery('*[data-SubmitAction]'); 2943 if (fields == null) return; 2944 for (var i = 0; i < fields.length; i++) { 2945 var tempField = fields[i]; 2946 if (tempField != null && tempField.id != "") { 2947 // The container or field with the attribute also has an ID, 2948 // so just create the submit action. 2949 createSubmitAction(tempField); 2950 } 2951 else if (tempField != null && tempField.childNodes != null && tempField.childNodes.length > 0) { 2952 // The container doesn't have an ID, so handle 'contained fields' individually 2953 // ('copy' the submit action attribute, then create the submit action). 2954 var tempChildFields = tempField.childNodes; 2955 for (var x = 0; x < tempChildFields.length; x++) { 2956 var tempChildField = tempChildFields[x]; 2957 addSubmitActionAttribute(tempChildField, tempField); 2958 createSubmitAction(tempChildField); 2959 } 2960 } 2961 } 2962 } 2963 2964 function addSubmitActionAttribute(fieldToAddAttribTo, fieldWithAttrib) { 2965 // Validate. Just return if info is missing. 2966 if (fieldToAddAttribTo == null) return; 2967 var fieldToAddAttribToId = fieldToAddAttribTo.id; 2968 if (fieldToAddAttribToId == "") return; 2969 var containedField = jQuery(fieldToAddAttribTo); 2970 if (containedField == null) return; 2971 var submitAction = jQuery(fieldWithAttrib).data('submitaction'); 2972 if (submitAction == null) return; 2973 2974 // Add the submit action attribute to the 'contained field', 2975 // which is the field inside the container that has the attribute. 2976 // 2977 // Must use 'attr' to copy the actual value, then update the ClientId key 2978 // with the contained field's ID. 2979 containedField.attr('data-SubmitAction', jQuery(fieldWithAttrib).attr('data-SubmitAction')); 2980 containedField.data('submitaction').ClientId = fieldToAddAttribToId; 2981 } 2982 2983 function createSubmitAction(field) { 2984 // Validate. Just return if info is missing. 2985 if (field == null) return; 2986 var fieldId = field.id; 2987 if (fieldId == "") return; 2988 var submitActionField = jQuery(field); 2989 if (submitActionField == null) return; 2990 var submitAction = submitActionField.data('submitaction'); 2991 if (submitAction == null) return; 2992 2993 // Gather the info needed to handle the keypress events. 2994 var submitActionClientId = submitAction.ClientId; 2995 if (submitActionClientId != null && submitActionClientId != 'undefined' && submitActionClientId.trim != '') { 2996 var submitActionButtonId = submitAction.ButtonId || ''; 2997 var submitActionHiddenFocusableFieldId = submitAction.HiddenFocusableFieldId || ''; 2998 var enterKeyClassInstanceVar = 'enterKeyPressClass_' + submitActionClientId + fieldId; 2999 3000 // Instantiate the EnterKeyPressClass class. 3001 var classInstance = 'var ' + enterKeyClassInstanceVar + ' = new EnterKeyPressClass("' + submitActionButtonId + '", "' + submitActionHiddenFocusableFieldId + '");'; 3002 eval(classInstance); 3003 // Call the TurnOnEnterKey method. 3004 var methodCall = enterKeyClassInstanceVar + '.TurnOnEnterKey("' + fieldId + '");'; 3005 eval(methodCall); 3006 } 3007 } 3008 3009// Attach keypress event to textboxes, radio buttons, and checkboxes. When user hits return/enter within textboxes we submit the buttonToClickId. 3010// We do nothing for radio buttons and checkboxes (it's a no-op). If the buttonToClickId parameter is empty, then pressing return/enter is also a no-op. 3011// 3012// A hidden field may (optionally) be specified to save the keypress event field id in for tabbing purposes (for maintaining tab order on postback). 3013// It can be retrieved server side (e.g. in the OnPreRender event)...
3014// if (IsPostBack) 3015// { 3016// var masterPage = (MasterPageBase)Page.Master; 3017// if (masterPage != null) 3018// masterPage.RestoreFocus(MasterPageBase.FocusTargetProperty.Id, HiddenFocusableFieldId.Value); 3019// } 3020// HiddenFocusableFieldId.Value = string.Empty; 3021// 3022function EnterKeyPressClass(buttonToClickId, hiddenFieldIdToStoreFocusableFieldId) { 3023 // The serverId parameter can either be a div/container with fields, or an actual field. 3024 // If serverId is a div/container, then the ClientId of the fields must END with (not contain) the serverId parameter. 3025 this.TurnOnEnterKey = function (serverId) { 3026 var fields; 3027 // Look for a wrapper control with fields to add the keypress event to. 3028 var container = jQuery("div[id$=" + serverId + "]:first"); 3029 if (container != null) 3030 fields = container.find('input[type=text], input[type=radio], input[type=checkbox], input[type=password]'); 3031 // If fields weren't found, then try and use the passed in parameter as the field. 3032 if (container == null || container.length == 0 || fields == null || fields.length == 0) 3033 fields = jQuery('#' + serverId); 3034 // Attach the handler to the fields. 3035 if (fields != null) { 3036 fields.on('keypress', (function (event) { 3037 handlEnterKeyPressInInputFields(event); 3038 })); 3039 } 3040 }; 3041 3042 function handlEnterKeyPressInInputFields(event) { 3043 // Get the key/code for the button that was pressed (Enter = 13). 3044 var key = event.keyCode ? event.keyCode : event.which; 3045 if (key == 13) { 3046 // This is for FF autocomplete, which triggers button click when selecting item from drop down, code below prevents it. 3047 if (window.previousKeyCode) { 3048 // down=40,up=38,pgdn=34,pgup=33 3049 if (window.previousKeyCode == 33 || window.previousKeyCode == 34 || 3050 window.previousKeyCode == 39 || window.previousKeyCode == 40) { 3051 3052 window.previousKeyCode = key; 3053 return; 3054 } 3055 } 3056 3057 // Perform the desired action (e.g. click the button). 3058 switch (event.target.type) { 3059 case 'text': 3060 case 'password': 3061 // Check if a hidden field was specified to set the focusable field for tabbing and postback behavior. 3062 if (hiddenFieldIdToStoreFocusableFieldId != null && hiddenFieldIdToStoreFocusableFieldId != '') 3063 saveFocusableFieldId(event.target.id, hiddenFieldIdToStoreFocusableFieldId); 3064 var button = jQuery('#' + buttonToClickId); 3065 if (button != null && button.length == 1 && !button[0].disabled) 3066 button.click(); // __doPostBack('ctl00_SaveButton', 'OnClick'); - this won't fire client events hooked up to the btn. 3067 break; 3068 case 'radio': 3069 // Don't submit for radio buttons. 3070 break; 3071 case 'checkbox': 3072 // Don't submit for checkboxes. 3073 break; 3074 default: 3075 // The default action is not to submit. 3076 break; 3077 } 3078 event.preventDefault(); 3079 //this is necessary because the generic SaveButton click would trigger print in certain master pages (e.g. Forest/Aspen). 3080 } else { 3081 window.previousKeyCode = key; 3082 } 3083 } 3084 3085 function saveFocusableFieldId(focusableFieldId, storageFieldId) { 3086 // Validate. Just return if info is missing. 3087 if (storageFieldId == null || storageFieldId == "") return; 3088 if (focusableFieldId == "") return; 3089 var focusableField = jQuery('#' + focusableFieldId); 3090 if (focusableField == null) return; 3091 3092 var storageField = jQuery('#' + storageFieldId); 3093 if (storageField != null) 3094 storageField.val(focusableFieldId); 3095 } 3096} // end EnterKeyPressClass 3097 3098//]]> 3099 3100//////////////////////////////////////////////// 3101// End Menu.js 3102/////////////////////////////////////////////// 3103 3104//#################### 3105// AtomControl.js 3106//###################### 3107function ChangeSelectedTab(object) 3108{ 3109 var i = object.selectedIndex; 3110 var allTabName = "Tab_"; 3111 var code = allTabName + i; 3112 3113 var divItems = document.getElementById(code); 3114 3115 var divItemsOff = document.getElementsByTagName("div"); 3116 3117 // turn off all the tabs 3118 for (var i = 0; i < divItemsOff.length; i++) 3119 { 3120 if ((divItemsOff[i].id) != code && (divItemsOff[i].id).substring(0, 4) == allTabName) 3121 { 3122 divItemsOff[i].style.display = "none"; 3123 } 3124 } 3125 3126 // then turn on the tab that was clicked
3127 if (document.all.namedItem(code).style.display == "none") 3128 { 3129 document.all.namedItem(code).style.display = "block"; 3130 if (document.all.namedItem("iAddItemTab") != null) 3131 document.all.namedItem("iAddItemTab").value = object.selectedIndex; 3132 } 3133} 3134 3135/*function ChangeSelectedTab(code) 3136{ 3137var allTabName = code.substring(0,3); 3138var divItems = document.getElementById(code); 3139var divItemsOff = document.getElementsByTagName("div"); 3140 3141// turn off all the tabs 3142for (var i = 0; i < divItemsOff.length; i++) 3143{ 3144if((divItemsOff[i].id)!= code && (divItemsOff[i].id).substring(0,3) == allTabName) 3145{ 3146divItemsOff[i].style.display="none"; 3147} 3148} 3149 3150// then turn on the tab that was clicked 3151if(document.all.namedItem(code).style.display=="none") 3152{ 3153document.all.namedItem(code).style.display="block"; 3154} 3155 3156}*/ 3157 3158function ShowHidePanelSection(sectionID) 3159{ 3160 element = document.getElementById(sectionID); 3161 if (element.style.display == "none") 3162 element.style.display = "block"; 3163 else 3164 element.style.display = "none"; 3165} 3166 3167//This is a workaround until we get JavaScript library. 3168function ValidateTextLength(field, maxLength) 3169{ 3170 if (field.value.length > maxLength) 3171 field.value = field.value.substring(0, maxLength); 3172} 3173 3174//###################### 3175//end AtomControl.js 3176//####################### 3177 3178 3179//#################### 3180// Command bar button validation: CommandButtonBar.cs 3181//###################### 3182 3183// Runs all validators on the page, independent of an validation groups 3184// If you pass in a string array of validation groups only those groups will be run 3185function RunAllValidators(validationGroups, runValidatorsWithoutAGroup) { 3186 3187 // escape if no validators exist 3188 if (typeof Page_ClientValidate == "function") { 3189 3190 var i; 3191 for (i = 0; i < Page_Validators.length; i++) { 3192 // fire either all validators on the page, or only those in our list of validation groups 3193 // we also have the option of firing those without a validation group. 3194 if (IncludeValidationGroup(validationGroups, Page_Validators[i].validationGroup, runValidatorsWithoutAGroup)) { 3195 ValidatorValidate(Page_Validators[i]); //this fires the validator, ignoring the group 3196 } 3197 } 3198 // If validation has failed, stop all the validators disapearing and stop the page submitting 3199 ValidatorUpdateIsValid(); 3200 3201 // Force validation summary for every group. 3202 if(validationGroups!=null && validationGroups!='undefined'){ 3203 for (i = 0; i < validationGroups.length; i++){ 3204 ValidationSummaryOnSubmit(validationGroups[i]); 3205 } 3206 } 3207 else 3208 ValidationSummaryOnSubmit(""); 3209 3210 // if we are using ajax tabs and a validator fails, this returns the user back to the tab with a failed validator 3211 ShowProblemTab(); 3212 // if we are using telerik tabs and a validator fails, this returns the user back to the tab with a failed validator 3213 ShowProblemTelerikTab(); 3214 3215 return Page_IsValid; 3216 } 3217 return true; 3218} 3219 3220// returns true if the passed in validation group is in our list of those to check 3221function IncludeValidationGroup(validationGroups, group, runValidatorsWithoutAGroup) { 3222 if (validationGroups == undefined) // if no group passed in then we're checking everything 3223 { 3224 return true; 3225 } 3226 // If validator has no group or matches a group in our list then return true. 3227 if ((group == undefined && runValidatorsWithoutAGroup) || jQuery.inArray(group, validationGroups) >= 0) { 3228 return true; 3229 } 3230 3231 return false; 3232} 3233 3234//#################### 3235// END Command bar button validation 3236//###################### 3237 3238//#################### 3239// BEGIN Handle Telerik radTabStrips if clientside validation has failed. 3240//###################### 3241//Selects appropriate telerik tab for given failed control. 3242function ShowProblemTelerikTab() { 3243 3244 // Handle Talerik TabStrips 3245 // First get all tabstrips on this page. 3246 var tabStrips = GetAllTabsStrips(); 3247 3248 //If we have any - deal with it. 3249 if (tabStrips.length > 0) { 3250 for (i = 0; i < Page_Validators.length; ++i) { 3251 var val = Page_Validators[i]; 3252 if (val == null) continue; 3253 var failedElement = document.getElementById(val.controltovalidate); 3254 if (failedElement == null) continue; 3255 if (val.evaluationfunction(val) == false) { 3256 //first try and find using jQuery and the data-multipage attribute 3257 //if can't find it, use old recursive method instead 3258 var radMultiPage = null; 3259 var domElementForRadMultiPage = jQuery('#' + val.controltovalidate).closest("[data-multipage='yes']").get(0); 3260 if (typeof(domElementForRadMultiPage) == "undefined" || domElementForRadMultiPage.length < 1) { 3261 radMultiPage = GetMultiPageId(failedElement); 3262 } else { 3263 radMultiPage = $find(domElementForRadMultiPage.
3263id); 3264 } 3265 3266 //now ensure we have the correct component 3267 var hasMultiPage = false; 3268 if (radMultiPage != null) { 3269 try { 3270 var cnt = radMultiPage.get_pageViews(); 3271 hasMultiPage = true; 3272 } 3273 catch (ex) { hasMultiPage = false; } 3274 } 3275 3276 if (hasMultiPage) { 3277 //Find PageView for troubled control 3278 var i; 3279 var troublePageId = -1; 3280 for (i = 0; i < radMultiPage.get_pageViews().get_count(); i++) { 3281 3282 if (IsParent(radMultiPage.get_pageViews().getPageView(i).get_id(), failedElement)) { 3283 troublePageId = i; 3284 break; 3285 } 3286 } 3287 3288 if (troublePageId >= 0) { 3289 // OK we have Tabstrips, we have PageView in trouble, so now switch Tabs and display 3290 for (i = 0; i < tabStrips.length; i++) { 3291 var tabstrip = $find(tabStrips[i].id); 3292 if (tabstrip.get_multiPageID() == radMultiPage.get_id()) { 3293 tabstrip.set_selectedIndex(troublePageId); 3294 if (!failedElement.disabled) { 3295 try //IE8 fix: Try-catch only straightforward way to handle case where any of parent elements has display='none'. 3296 { 3297 failedElement.focus(); 3298 } 3299 catch (err) { } 3300 } 3301 break; 3302 } 3303 } 3304 3305 } 3306 3307 } 3308 3309 break; 3310 } 3311 } 3312 } 3313} 3314 3315//Returns array will all TabStrips on the page 3316function GetAllTabsStrips() { 3317 var res = new Array(); 3318 var list = document.getElementsByTagName("DIV"); 3319 if (list.length > 0) 3320 var i = 0; 3321 var isTab = false; 3322 for (i = 0; i < list.length; i++) { 3323 isTab = false; 3324 if (list[i].control != null) { 3325 3326 try { 3327 if (list[i].control.get_multiPageID() != "") 3328 isTab = true; 3329 } 3330 catch (exc) { isTab = false } 3331 } 3332 if (isTab) 3333 res.push(list[i]); 3334 } 3335 return res; 3336} 3337 3338//Returns true if Given ID is parent for the given control 3339function IsParent(parentId, childcontrol) { 3340 var res = false; 3341 if (childcontrol.parentNode != null) { 3342 if (childcontrol.id == parentId) 3343 return true; 3344 else 3345 res = IsParent(parentId, childcontrol.parentNode); 3346 } 3347 return res; 3348} 3349//Returns RadMultiPage that contains troubled control 3350function GetMultiPageId(childcontrol) { 3351 var res = null; 3352 if (childcontrol.parentNode != null) { 3353 if (childcontrol.control != null) 3354 return childcontrol.control; 3355 else 3356 res = GetMultiPageId(childcontrol.parentNode); 3357 if (res != null) 3358 return res; 3359 } 3360} 3361 3362// Reset form to original state 3363function ResetForm() { 3364 jQuery("#aspnetForm").trigger('reset'); 3365} 3366 3367//#################### 3368// END Handle Telerik radTabStrips if clientside validation has failed. 3369//###################### 3370 3371//###################### 3372// BEGIN Debounce function 3373//###################### 3374// From Underscore.js: http://underscorejs.org/#debounce 3375// Further explanation: https://davidwalsh.name/javascript-debounce-function 3376// Returns a function, that, as long as it continues to be invoked, will not 3377// be triggered. The function will be called after it stops being called for 3378// N milliseconds. If `immediate` is passed, trigger the function on the 3379// leading edge, instead of the trailing. 3380function debounce(func, wait, immediate) { 3381 var timeout; 3382 return function () { 3383 var context = this, args = arguments; 3384 var later = function () { 3385 timeout = null;
3386 if (!immediate) func.apply(context, args); 3387 }; 3388 var callNow = immediate && !timeout; 3389 clearTimeout(timeout); 3390 timeout = setTimeout(later, wait); 3391 if (callNow) func.apply(context, args); 3392 }; 3393}; 3394//###################### 3395// END Debounce function 3396//######################
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.